Commit 8cc93b56 authored by linruibiao's avatar linruibiao

接口编写

parent 515da94d
......@@ -88,66 +88,43 @@ public class InstrumentPanelInitServiceImpl extends ServiceImpl<InstrumentPanelM
one= panelGroupService.getById(groupId);
}
init(appId, one, initConfig1, initPanelName1);
init(appId, one, initConfig2, initPanelName2);
return null;
}
private void init(String appId, InstrumentPanelGroup one, String initConfig, String initPanelName) {
InstrumentPanelConfig panelConfig = configService.getById(initConfig);
String config;
try {
config = URLDecoder.decode(panelConfig.getConfigDetails(), StandardCharsets.UTF_8.name());
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情解密异常");
}
InstrumentPanelTree tree = treeService.getById(panelConfig.getPanelId());
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
where.orderByAsc(InstrumentPanelTree::getAssemblyKey);
List<InstrumentPanelTree> panelTrees = treeService.list(where);
configService.publish(appId, setConfig(one, appId, initPanelName, config, panelTrees));
}
private InstrumentPanelConfigDTO setConfig(InstrumentPanelGroup one , String appId, String panelName, String panelConfig, List<InstrumentPanelTree> panelTrees){
LambdaQueryWrapper<InstrumentPanel> where1 = new LambdaQueryWrapper<>();
where1.eq(BaseEntity::getAppId, appId);
where1.eq(InstrumentPanel::getName, initPanelName1);
where1.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
InstrumentPanel panel = baseMapper.selectOne(where1);
if(ObjectUtils.isEmpty(panel)){
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("仪表板配置详情解密异常");
}
InstrumentPanelTree tree = treeService.getById(panelConfig.getPanelId());
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
where.orderByAsc(InstrumentPanelTree::getAssemblyKey);
List<InstrumentPanelTree> panelTrees = treeService.list(where);
configService.publish(appId,setConfig(one,appId,initPanelName1,config,panelTrees));
InstrumentPanel instrumentPanel = baseMapper.selectOne(where1);
if(ObjectUtils.isEmpty(instrumentPanel)) {
SaveInstrumentPanelDTO panelDto = new SaveInstrumentPanelDTO();
panelDto.setName(panelName);
panelDto.setGroupId(one.getId());
String panelId = panelService.savePanel(appId, panelDto);
instrumentPanel=baseMapper.selectById(panelId);
}
LambdaQueryWrapper<InstrumentPanel> where2 = new LambdaQueryWrapper<>();
where2.eq(BaseEntity::getAppId, appId);
where2.eq(InstrumentPanel::getName, initPanelName2);
where2.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
InstrumentPanel panel2 = baseMapper.selectOne(where2);
if(ObjectUtils.isEmpty(panel2)){
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("仪表板配置详情解密异常");
}
InstrumentPanelTree tree = treeService.getById(panelConfig.getPanelId());
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
where.orderByAsc(InstrumentPanelTree::getAssemblyKey);
List<InstrumentPanelTree> panelTrees = treeService.list(where);
configService.publish(appId,setConfig(one,appId,initPanelName2,config,panelTrees));
}
return null;
}
private InstrumentPanelConfigDTO setConfig(InstrumentPanelGroup one , String appId, String panelName, String panelConfig, List<InstrumentPanelTree> panelTrees){
SaveInstrumentPanelDTO panelDto = new SaveInstrumentPanelDTO();
panelDto.setName(panelName);
panelDto.setGroupId(one.getId());
String panelId = panelService.savePanel(appId, panelDto);
InstrumentPanel instrumentPanel = baseMapper.selectById(panelId);
InstrumentPanelConfigDTO config = new InstrumentPanelConfigDTO();
List<InstrumentPanelAssemblyDTO> assemblys = Lists.newArrayList();
panelTrees.forEach(x->{
......
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