Commit 20337d30 authored by linruibiao's avatar linruibiao

接口编写

parent e666515e
...@@ -4,19 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,19 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants; import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelMapper; import com.syc.slm.slmbi.dao.InstrumentPanelMapper;
import com.syc.slm.slmbi.dto.*; import com.syc.slm.slmbi.dto.*;
import com.syc.slm.slmbi.entity.BaseEntity; import com.syc.slm.slmbi.entity.*;
import com.syc.slm.slmbi.entity.CurrentUser;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.entity.InstrumentPanelGroup;
import com.syc.slm.slmbi.enums.AccessType; import com.syc.slm.slmbi.enums.AccessType;
import com.syc.slm.slmbi.service.InstrumentPanelConfigService; import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.InstrumentPanelGroupService; import com.syc.slm.slmbi.service.*;
import com.syc.slm.slmbi.service.InstrumentPanelInitService;
import com.syc.slm.slmbi.service.InstrumentPanelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -24,8 +18,9 @@ import org.springframework.stereotype.Service; ...@@ -24,8 +18,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* slm-bi * slm-bi
...@@ -40,15 +35,18 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM ...@@ -40,15 +35,18 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
implements InstrumentPanelInitService { implements InstrumentPanelInitService {
@Value("${initGroupName}") @Value("${initGroupName:默认模板}")
private String initGroupName; private String initGroupName;
@Value("${initPanelName1}")
@Value("${initPanelName1:业务情况综合看板}")
private String initPanelName1; private String initPanelName1;
@Value("${initPanelName2}")
@Value("${initPanelName2:售后服务综合看板}")
private String initPanelName2; private String initPanelName2;
@Value("${initConfig1}") @Value("${initConfigId1:82752b5ba8b2bd379c771a72c83f4b3a}")
private String initConfig1; private String initConfig1 ;
@Value("${initConfig2}")
@Value("${initConfigId2:29727c771a6fcb492d206a9e811e585d}")
private String initConfig2; private String initConfig2;
...@@ -61,6 +59,10 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM ...@@ -61,6 +59,10 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
private InstrumentPanelGroupService panelGroupService; private InstrumentPanelGroupService panelGroupService;
@Autowired @Autowired
private InstrumentPanelService panelService; private InstrumentPanelService panelService;
@Autowired
private InstrumentPanelTreeService treeService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -93,7 +95,15 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM ...@@ -93,7 +95,15 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
where1.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where1.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
InstrumentPanel panel = baseMapper.selectOne(where1); InstrumentPanel panel = baseMapper.selectOne(where1);
if(ObjectUtils.isEmpty(panel)){ if(ObjectUtils.isEmpty(panel)){
configService.publish(appId,setConfig(one,appId,initPanelName2,initConfig2)); InstrumentPanelConfig panelConfig = configService.getById(initConfig1);
String config = null;
try {
config=URLDecoder.decode(panelConfig.getConfigDetails(), StandardCharsets.UTF_8.name());
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情解密异常");
}
configService.publish(appId,setConfig(one,appId,initPanelName1,config));
} }
...@@ -104,7 +114,15 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM ...@@ -104,7 +114,15 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
where2.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where2.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
InstrumentPanel panel2 = baseMapper.selectOne(where2); InstrumentPanel panel2 = baseMapper.selectOne(where2);
if(ObjectUtils.isEmpty(panel2)){ if(ObjectUtils.isEmpty(panel2)){
configService.publish(appId,setConfig(one,appId,initPanelName2,initConfig2)); InstrumentPanelConfig panelConfig = configService.getById(initConfig2);
String config = null;
try {
config=URLDecoder.decode(panelConfig.getConfigDetails(), StandardCharsets.UTF_8.name());
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情解密异常");
}
configService.publish(appId,setConfig(one,appId,initPanelName2,config));
} }
return null; return null;
...@@ -117,16 +135,19 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM ...@@ -117,16 +135,19 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
String panelId = panelService.savePanel(appId, panelDto); String panelId = panelService.savePanel(appId, panelDto);
InstrumentPanel instrumentPanel = baseMapper.selectById(panelId); InstrumentPanel instrumentPanel = baseMapper.selectById(panelId);
InstrumentPanelConfigDTO config = new InstrumentPanelConfigDTO(); InstrumentPanelConfigDTO config = new InstrumentPanelConfigDTO();
Map<String,Object> map = SlmConstants.gson.fromJson(panelConfig,new TypeToken<Map<String,Object>>(){}.getType());
List<Object> controlList = (List<Object>)map.get("ControlList");
List<InstrumentPanelAssemblyDTO> assemblys = Lists.newArrayList(); List<InstrumentPanelAssemblyDTO> assemblys = Lists.newArrayList();
for (int i = 0; i < controlList.size(); i++) { InstrumentPanelTree tree = treeService.getById(panelId);
Map<String,Object> controlMap = SlmConstants.gson.fromJson(SlmConstants.gson.toJson(controlList.get(i)),new TypeToken<Map<String,Object>>(){}.getType()); LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
Map<String,String> propertyList = SlmConstants.gson.fromJson(SlmConstants.gson.toJson(controlMap.get("PropertyList")),new TypeToken<Map<String,String>>(){}.getType()); where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
InstrumentPanelAssemblyDTO instrumentPanelAssemblyDTO = new InstrumentPanelAssemblyDTO(); where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
instrumentPanelAssemblyDTO.setKey(i+""); where.orderByAsc(InstrumentPanelTree::getAssemblyKey);
instrumentPanelAssemblyDTO.setName(propertyList.get("ComName")); List<InstrumentPanelTree> panelTrees = treeService.list(where);
} panelTrees.forEach(x->{
InstrumentPanelAssemblyDTO dto = new InstrumentPanelAssemblyDTO();
dto.setName(x.getName());
dto.setKey(x.getAssemblyKey());
assemblys.add(dto);
});
config.setAssemblys(assemblys); config.setAssemblys(assemblys);
config.setConfigDetails(panelConfig); config.setConfigDetails(panelConfig);
config.setPanelId(instrumentPanel.getId()); config.setPanelId(instrumentPanel.getId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment