1.模板上传功能

2.解析模板字典
This commit is contained in:
2023-07-31 20:41:15 +08:00
parent 344172c61d
commit 754607636e
12 changed files with 401 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
package com.njcn.access.pojo.dto.data; package com.njcn.access.pojo.dto.data;
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@@ -32,4 +33,8 @@ public class AlmDto implements Serializable {
@NotNull(message = "告警事件类别,不为空") @NotNull(message = "告警事件类别,不为空")
private String eventType; private String eventType;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
} }

View File

@@ -44,11 +44,11 @@ public class CtrlDto implements Serializable {
@SerializedName("MaxNum") @SerializedName("MaxNum")
@ApiModelProperty("设置最大值") @ApiModelProperty("设置最大值")
private Integer maxNum; private Double maxNum;
@SerializedName("MinNum") @SerializedName("MinNum")
@ApiModelProperty("设置最小值") @ApiModelProperty("设置最小值")
private Integer minNum; private Double minNum;
@SerializedName("Ctlvalue") @SerializedName("Ctlvalue")
@ApiModelProperty("参数为enum时可设置的所有值序列") @ApiModelProperty("参数为enum时可设置的所有值序列")
@@ -61,4 +61,8 @@ public class CtrlDto implements Serializable {
@SerializedName("Encode") @SerializedName("Encode")
@NotNull(message = "是否加密,不为空") @NotNull(message = "是否加密,不为空")
private Integer storeFlag; private Integer storeFlag;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
} }

View File

@@ -22,4 +22,6 @@ public class DiDto extends StsDto implements Serializable {
@NotNull(message = "数据是否上送,不为空") @NotNull(message = "数据是否上送,不为空")
private Integer tranFlag; private Integer tranFlag;
} }

View File

@@ -1,6 +1,7 @@
package com.njcn.access.pojo.dto.data; package com.njcn.access.pojo.dto.data;
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@@ -35,4 +36,8 @@ public class DoDto implements Serializable {
@SerializedName("CtlSts") @SerializedName("CtlSts")
@NotNull(message = "是否可远程控制,不为空") @NotNull(message = "是否可远程控制,不为空")
private Integer ctlSts; private Integer ctlSts;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
} }

View File

@@ -1,6 +1,7 @@
package com.njcn.access.pojo.dto.data; package com.njcn.access.pojo.dto.data;
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@@ -34,7 +35,7 @@ public class EvtDto implements Serializable {
private String eventType; private String eventType;
@SerializedName("Phase") @SerializedName("Phase")
@NotNull(message = "相别,不为空") @ApiModelProperty("相别")
private String phase; private String phase;
@SerializedName("Parm") @SerializedName("Parm")

View File

@@ -45,11 +45,11 @@ public class ParmDto implements Serializable {
@SerializedName("MaxNum") @SerializedName("MaxNum")
@ApiModelProperty("设置最大值") @ApiModelProperty("设置最大值")
private Integer maxNum; private Double maxNum;
@SerializedName("MinNum") @SerializedName("MinNum")
@ApiModelProperty("设置最小值") @ApiModelProperty("设置最小值")
private Integer minNum; private Double minNum;
@SerializedName("SetValue") @SerializedName("SetValue")
@ApiModelProperty("参数为enum可设置的所有值序列") @ApiModelProperty("参数为enum可设置的所有值序列")
@@ -63,4 +63,8 @@ public class ParmDto implements Serializable {
@NotNull(message = "参数缺省值") @NotNull(message = "参数缺省值")
private String defaultValue; private String defaultValue;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
} }

View File

@@ -45,4 +45,12 @@ public class SetDto implements Serializable {
@NotNull(message = "参数缺省值") @NotNull(message = "参数缺省值")
private String defaultValue; private String defaultValue;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
@SerializedName("Unit")
@ApiModelProperty("单位")
private String unit;
} }

View File

@@ -42,4 +42,8 @@ public class StsDto implements Serializable {
@NotNull(message = "上送规则,不为空") @NotNull(message = "上送规则,不为空")
@ApiModelProperty("变化:change 周期:period") @ApiModelProperty("变化:change 周期:period")
private String tranRule; private String tranRule;
@SerializedName("Phase")
@ApiModelProperty("相别")
private String phase;
} }

View File

@@ -87,7 +87,7 @@ public class TemplateDto implements Serializable {
@ApiModelProperty("定值") @ApiModelProperty("定值")
private List<SetDto> setDto; private List<SetDto> setDto;
@SerializedName("InSet") @SerializedName("Inset")
@ApiModelProperty("内部定值") @ApiModelProperty("内部定值")
private List<InSetDto> inSetDto; private List<InSetDto> inSetDto;

View File

@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -36,8 +37,10 @@ public class CsDevModelController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addModel") @PostMapping("/addModel")
@ApiOperation("新增设备模板") @ApiOperation("新增设备模板")
@Transactional(rollbackFor = {Exception.class})
public HttpResult<String> addModel(@RequestPart("file") @Validated MultipartFile file){ public HttpResult<String> addModel(@RequestPart("file") @Validated MultipartFile file){
String methodDescribe = getMethodDescribe("addModel"); String methodDescribe = getMethodDescribe("addModel");
csDevModelService.addDict(file);
csDevModelService.addModel(file); csDevModelService.addModel(file);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }

View File

@@ -18,4 +18,10 @@ public interface ICsDevModelService {
*/ */
void addModel(MultipartFile file); void addModel(MultipartFile file);
/**
* 解析模板文件->字典入库
* @param file
*/
void addDict(MultipartFile file);
} }

View File

@@ -6,10 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.access.enums.AccessResponseEnum; import com.njcn.access.enums.AccessResponseEnum;
import com.njcn.access.enums.DataModel; import com.njcn.access.enums.DataModel;
import com.njcn.access.enums.TypeEnum; import com.njcn.access.enums.TypeEnum;
import com.njcn.access.pojo.dto.data.EpdPqdDto; import com.njcn.access.pojo.dto.data.*;
import com.njcn.access.pojo.dto.data.EvtDto;
import com.njcn.access.pojo.dto.data.EvtParamDto;
import com.njcn.access.pojo.dto.devModel.ApfDto; import com.njcn.access.pojo.dto.devModel.ApfDto;
import com.njcn.access.pojo.dto.devModel.ClDevDto;
import com.njcn.access.pojo.dto.devModel.TemplateDto; import com.njcn.access.pojo.dto.devModel.TemplateDto;
import com.njcn.access.service.ICsDevModelService; import com.njcn.access.service.ICsDevModelService;
import com.njcn.access.utils.JsonUtil; import com.njcn.access.utils.JsonUtil;
@@ -21,12 +20,15 @@ import com.njcn.csdevice.pojo.po.CsDevModelPO;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient; import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.param.EleEpdPqdParam; import com.njcn.system.pojo.param.EleEpdPqdParam;
import com.njcn.system.pojo.param.EleEvtParam;
import com.njcn.system.pojo.po.Dic; import com.njcn.system.pojo.po.Dic;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ConditionalOnBlockingDiscoveryEnabled; import org.springframework.cloud.client.ConditionalOnBlockingDiscoveryEnabled;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -40,9 +42,7 @@ import java.io.IOException;
import java.sql.Date; import java.sql.Date;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
/** /**
* 类的介绍: * 类的介绍:
@@ -56,9 +56,6 @@ import java.util.Objects;
@AllArgsConstructor @AllArgsConstructor
public class CsDevModelServiceImpl implements ICsDevModelService { public class CsDevModelServiceImpl implements ICsDevModelService {
@Autowired
public CsDevModelServiceImpl csDevModelService;
private final FileStorageUtil fileStorageUtil; private final FileStorageUtil fileStorageUtil;
private final DevModelFeignClient devModelFeignClient; private final DevModelFeignClient devModelFeignClient;
@@ -67,6 +64,8 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final EleEvtFeignClient eleEvtFeignClient;
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public void addModel(MultipartFile file) { public void addModel(MultipartFile file) {
@@ -79,11 +78,20 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
//String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_"); //String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
String filePath = ""; String filePath = "";
//1.录入cs_dev_model表记录装置型号和模板记录 //1.录入cs_dev_model表记录装置型号和模板记录
CsDevModelPO csDevModelPo = csDevModelService.addCsDevModel(templateDto,filePath); CsDevModelPO csDevModelPo = addCsDevModel(templateDto,filePath);
//2.录入字典数据 } catch (IOException e) {
csDevModelService.analysisDict(templateDto); e.printStackTrace();
}
}
@Override
public void addDict(MultipartFile file) {
String json = null;
try {
json = JsonUtil.convertStreamToString(file.getInputStream());
Gson gson = new Gson();
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
analysisDict(templateDto);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -92,7 +100,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
/** /**
* 新增cs_dev_model数据 * 新增cs_dev_model数据
*/ */
public CsDevModelPO addCsDevModel(TemplateDto templateDto, String filePath){ private CsDevModelPO addCsDevModel(TemplateDto templateDto, String filePath){
CsDevModelPO po = devModelFeignClient.findModel(templateDto.getDevType(),templateDto.getVersion(),templateDto.getTime()).getData(); CsDevModelPO po = devModelFeignClient.findModel(templateDto.getDevType(),templateDto.getVersion(),templateDto.getTime()).getData();
if (!Objects.isNull(po)){ if (!Objects.isNull(po)){
throw new BusinessException(AccessResponseEnum.MODEL_REPEAT); throw new BusinessException(AccessResponseEnum.MODEL_REPEAT);
@@ -107,14 +115,21 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
} }
/** /**
* 解析字典数据 * 解析主设备字典数据
* 根据data_type和name来判断字典是否已经录入,录入过的就不在录入 * 根据data_type和name来判断字典是否已经录入,录入过的就不在录入
*/ */
public void analysisDict(TemplateDto templateDto){ private void analysisDict(TemplateDto templateDto){
Set<String> dataListSet = new HashSet<>();
List<EleEpdPqdParam> result = new ArrayList<>(); List<EleEpdPqdParam> result = new ArrayList<>();
List<String> dataList = templateDto.getDataList(); List<ClDevDto> clDevList = templateDto.getClDevDtoList();
if (CollectionUtil.isNotEmpty(dataList)){ if (CollectionUtil.isNotEmpty(clDevList)){
dataList.forEach(item->{ clDevList.forEach(item->{
dataListSet.addAll(item.getDataList());
});
}
dataListSet.addAll(templateDto.getDataList());
if (CollectionUtil.isNotEmpty(dataListSet)){
dataListSet.forEach(item->{
switch (item) { switch (item) {
case DataModel.APF: case DataModel.APF:
log.info("处理apf字典数据"); log.info("处理apf字典数据");
@@ -167,12 +182,330 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
EleEpdPqd po = epdFeignClient.add(eleEpdPqdParam).getData(); EleEpdPqd po = epdFeignClient.add(eleEpdPqdParam).getData();
if (CollectionUtil.isNotEmpty(evt.getParam())){ if (CollectionUtil.isNotEmpty(evt.getParam())){
evt.getParam().forEach(param->{ evt.getParam().forEach(param->{
EleEvtParam eleEvtParam = new EleEvtParam();
eleEvtParam.setPid(po.getId());
eleEvtParam.setData(param.getData());
eleEvtParam.setName(param.getName());
eleEvtParam.setType(param.getType());
eleEvtParam.setUnit(param.getUnit());
eleEvtFeignClient.add(eleEvtParam);
}); });
} }
} }
}); });
break; break;
case DataModel.ALM:
log.info("处理alm字典数据");
List<AlmDto> almList = templateDto.getAlmDto();
almList.forEach(alm->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.ALM_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(alm.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(alm.getName());
eleEpdPqdParam.setOtherName(alm.getName());
eleEpdPqdParam.setShowName(alm.getName());
eleEpdPqdParam.setSort(alm.getIdx());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(alm.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(alm.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.STS:
log.info("处理sts字典数据");
List<StsDto> stsList = templateDto.getStsDto();
stsList.forEach(sts->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.STS_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(sts.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(sts.getName());
eleEpdPqdParam.setOtherName(sts.getName());
eleEpdPqdParam.setShowName(sts.getName());
eleEpdPqdParam.setSort(sts.getIdx());
eleEpdPqdParam.setStoreFlag(sts.getStoreFlag());
eleEpdPqdParam.setCurSts(sts.getCurSts());
eleEpdPqdParam.setTranRule(sts.getTranRule());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(sts.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(sts.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.PARM:
log.info("处理parm字典数据");
List<ParmDto> parmList = templateDto.getParmDto();
parmList.forEach(parm->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.PARM_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(parm.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(parm.getName());
eleEpdPqdParam.setOtherName(parm.getName());
eleEpdPqdParam.setShowName(parm.getName());
eleEpdPqdParam.setSort(parm.getIdx());
eleEpdPqdParam.setEventType(parm.getEventType());
eleEpdPqdParam.setType(parm.getType());
eleEpdPqdParam.setCtlSts(parm.getCtlSts());
eleEpdPqdParam.setMaxNum(parm.getMaxNum());
eleEpdPqdParam.setMinNum(parm.getMinNum());
eleEpdPqdParam.setSetValue(String.join(",", parm.getSetValue()));
eleEpdPqdParam.setStrlen(parm.getStrlen());
eleEpdPqdParam.setDefaultValue(parm.getDefaultValue());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(parm.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(parm.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.SET:
log.info("处理set字典数据");
List<SetDto> setList = templateDto.getSetDto();
setList.forEach(set->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.SET_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(set.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(set.getName());
eleEpdPqdParam.setOtherName(set.getName());
eleEpdPqdParam.setShowName(set.getName());
eleEpdPqdParam.setSort(set.getIdx());
eleEpdPqdParam.setType(set.getType());
eleEpdPqdParam.setMaxNum(set.getMaxNum());
eleEpdPqdParam.setMinNum(set.getMinNum());
eleEpdPqdParam.setDefaultValue(set.getDefaultValue());
eleEpdPqdParam.setUnit(set.getUnit());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(set.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(set.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.CTRL:
log.info("处理ctrl字典数据");
List<CtrlDto> ctrlList = templateDto.getCtrlDto();
ctrlList.forEach(ctrl->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.CTRL_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(ctrl.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(ctrl.getName());
eleEpdPqdParam.setOtherName(ctrl.getName());
eleEpdPqdParam.setShowName(ctrl.getName());
eleEpdPqdParam.setSort(ctrl.getIdx());
eleEpdPqdParam.setType(ctrl.getType());
eleEpdPqdParam.setCurSts(ctrl.getCurSts());
eleEpdPqdParam.setCtlSts(ctrl.getCtlSts());
eleEpdPqdParam.setSetValue(String.join(",", ctrl.getCtlValue()));
eleEpdPqdParam.setStrlen(ctrl.getStrLen());
eleEpdPqdParam.setStoreFlag(ctrl.getStoreFlag());
eleEpdPqdParam.setMaxNum(ctrl.getMaxNum());
eleEpdPqdParam.setMinNum(ctrl.getMinNum());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(ctrl.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(ctrl.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.EPD:
log.info("处理epd字典数据");
List<EpdPqdDto> epdDto = templateDto.getEpdDto();
epdDto.forEach(epd->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.EPD_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(epd.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(epd.getName());
eleEpdPqdParam.setOtherName(epd.getName());
eleEpdPqdParam.setShowName(epd.getName());
eleEpdPqdParam.setSort(epd.getIdx());
eleEpdPqdParam.setType(epd.getType());
if (Objects.isNull(epd.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(epd.getPhase());
}
eleEpdPqdParam.setUnit(epd.getUnit());
eleEpdPqdParam.setHarmStart(epd.getHarmStart());
eleEpdPqdParam.setHarmEnd(epd.getHarmEnd());
eleEpdPqdParam.setStatMethod(epd.getStatMethod());
eleEpdPqdParam.setDataType(id);
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.PQD:
log.info("处理pqd字典数据");
List<EpdPqdDto> pqdDto = templateDto.getPqdDto();
pqdDto.forEach(pqd->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.PQD_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(pqd.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(pqd.getName());
eleEpdPqdParam.setOtherName(pqd.getName());
eleEpdPqdParam.setShowName(pqd.getName());
eleEpdPqdParam.setSort(pqd.getIdx());
eleEpdPqdParam.setType(pqd.getType());
if (Objects.isNull(pqd.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(pqd.getPhase());
}
eleEpdPqdParam.setUnit(pqd.getUnit());
eleEpdPqdParam.setHarmStart(pqd.getHarmStart());
eleEpdPqdParam.setHarmEnd(pqd.getHarmEnd());
eleEpdPqdParam.setDataType(id);
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.BMD:
log.info("处理bmd字典数据");
List<BmdDto> bmdDto = templateDto.getBmdDto();
bmdDto.forEach(bmd->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.BMD_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(bmd.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(bmd.getName());
eleEpdPqdParam.setOtherName(bmd.getName());
eleEpdPqdParam.setShowName(bmd.getName());
eleEpdPqdParam.setSort(bmd.getIdx());
eleEpdPqdParam.setType(bmd.getType());
if (Objects.isNull(bmd.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(bmd.getPhase());
}
eleEpdPqdParam.setUnit(bmd.getUnit());
eleEpdPqdParam.setStatMethod(bmd.getStatMethod());
eleEpdPqdParam.setTranRule(bmd.getTranRule());
eleEpdPqdParam.setDataType(id);
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.DI:
log.info("处理di字典数据");
List<DiDto> diDto = templateDto.getDiDto();
diDto.forEach(di->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.DI_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(di.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(di.getName());
eleEpdPqdParam.setOtherName(di.getName());
eleEpdPqdParam.setShowName(di.getName());
eleEpdPqdParam.setSort(di.getIdx());
eleEpdPqdParam.setStoreFlag(di.getStoreFlag());
eleEpdPqdParam.setCurSts(di.getCurSts());
eleEpdPqdParam.setTranFlag(di.getTranFlag());
eleEpdPqdParam.setTranRule(di.getTranRule());
if (Objects.isNull(di.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(di.getPhase());
}
eleEpdPqdParam.setDataType(id);
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.DO:
log.info("处理do字典数据");
List<DoDto> doDto = templateDto.getDoDto();
doDto.forEach(dto->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.DO_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(dto.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(dto.getName());
eleEpdPqdParam.setOtherName(dto.getName());
eleEpdPqdParam.setShowName(dto.getName());
eleEpdPqdParam.setSort(dto.getIdx());
eleEpdPqdParam.setCurSts(dto.getCurSts());
eleEpdPqdParam.setCtlSts(dto.getCtlSts());
if (Objects.isNull(dto.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(dto.getPhase());
}
eleEpdPqdParam.setDataType(id);
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
case DataModel.INSET:
log.info("处理inset字典数据");
List<InSetDto> inSetDto = templateDto.getInSetDto();
inSetDto.forEach(inSet->{
String id = dicDataFeignClient.getDicDataByCode(item).getData().getId();
String classId = dicDataFeignClient.getDicDataByCode(DataModel.INSET_DATA).getData().getId();
List<EleEpdPqd> list = epdFeignClient.judgeExist(inSet.getName(),id).getData();
if (CollectionUtil.isEmpty(list)){
EleEpdPqdParam eleEpdPqdParam = new EleEpdPqdParam();
eleEpdPqdParam.setName(inSet.getName());
eleEpdPqdParam.setOtherName(inSet.getName());
eleEpdPqdParam.setShowName(inSet.getName());
eleEpdPqdParam.setSort(inSet.getIdx());
eleEpdPqdParam.setType(inSet.getType());
eleEpdPqdParam.setMaxNum(inSet.getMaxNum());
eleEpdPqdParam.setMinNum(inSet.getMinNum());
eleEpdPqdParam.setDefaultValue(inSet.getDefaultValue());
eleEpdPqdParam.setUnit(inSet.getUnit());
eleEpdPqdParam.setDataType(id);
if (Objects.isNull(inSet.getPhase())){
eleEpdPqdParam.setPhase("M");
} else {
eleEpdPqdParam.setPhase(inSet.getPhase());
}
eleEpdPqdParam.setClassId(classId);
result.add(eleEpdPqdParam);
}
});
break;
default: default:
break; break;
} }