Commit af7d3fde authored by linruibiao's avatar linruibiao

接口编写

parent 0cf33171
......@@ -14,6 +14,7 @@ import com.syc.slm.slmbi.entity.*;
import com.syc.slm.slmbi.enums.PublishedStatus;
import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.*;
import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import lombok.extern.slf4j.Slf4j;
......@@ -22,7 +23,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.events.Event;
import javax.validation.constraints.NotNull;
import java.net.URLDecoder;
......@@ -30,7 +30,6 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
......@@ -69,10 +68,48 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
@Override
@Transactional(readOnly = true)
public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) {
InstrumentPanelDraft draft = draftService.getByPanelId(instrumentPanelId);
return getInstrumentPanelConfigVo(instrumentPanelId,
ObjectUtils.isNotEmpty(draft) ? PublishedStatus.PUBLISHED :
PublishedStatus.WAIT_PUBLISHED);
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, instrumentPanelId);
where.eq(InstrumentPanelConfig::getPublished, PublishedStatus.WAIT_PUBLISHED.value);
InstrumentPanelConfig config = baseMapper.selectOne(where);
String status = PublishedStatus.WAIT_PUBLISHED.value;
if(ObjectUtils.isEmpty(config)){
status=PublishedStatus.PUBLISHED.value;
where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, instrumentPanelId);
where.eq(InstrumentPanelConfig::getPublished, PublishedStatus.PUBLISHED.value);
config = baseMapper.selectOne(where);
}
InstrumentPanelConfigVo vo=new InstrumentPanelConfigVo();
BeanUtils.copyProperties(config, vo);
if(StringUtils.isNotEmpty(vo.getConfigDetails())) {
if (ObjectUtils.isNotEmpty(vo)) {
try {
vo.setConfigDetails(URLDecoder.decode(vo.getConfigDetails(), StandardCharsets.UTF_8.name()));
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情解密异常");
}
}
}
List<CustomPermissionVo> permission = permissionService.getPublishPermissionByPanelId(
instrumentPanelId,
PublishedStatus.WAIT_PUBLISHED.value);
if(ObjectUtils.isEmpty(permission)){
permission= permissionService.getPublishPermissionByPanelId(
instrumentPanelId,
PublishedStatus.PUBLISHED.value);
}
vo.setPermissions(permission);
InstrumentPanel panel = panelService.getById(instrumentPanelId);
InstrumentPanelVo panelVo = new InstrumentPanelVo();
BeanUtils.copyProperties(panel, panelVo);
vo.setPanelId(instrumentPanelId);
panelVo.setGroupName(panelGroupService.getById(panel.getGroupId()).getName());
vo.setPanel(panelVo);
return vo;
}
@Override
......@@ -193,11 +230,13 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
panelConfig.setId(IdWorker.get32UUID());
panelConfig.setPanelId(panelId);
panelConfig.setPublished(publishStatus);
try {
panelConfig.setConfigDetails(URLEncoder.encode(configDetails, StandardCharsets.UTF_8.name()));
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情加密异常");
if(StringUtils.isNotEmpty(configDetails)) {
try {
panelConfig.setConfigDetails(URLEncoder.encode(configDetails, StandardCharsets.UTF_8.name()));
} catch (Exception e) {
e.printStackTrace();
throw new SysException("仪表板配置详情加密异常");
}
}
baseMapper.insert(panelConfig);
}
......
......@@ -272,6 +272,8 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
log.info("保存仪表板配置");
if (StringUtils.isNotEmpty(panel.getConfigDetails())) {
configService.savePanelConfig(panelId, panel.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value);
}else{
configService.savePanelConfig(panelId, panel.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value);
}
log.info("初始化仪表板树");
......
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