二楼使用导出、导入设备功能

This commit is contained in:
caozehui
2025-01-16 13:30:08 +08:00
parent de53e41f2c
commit 8c75ecb09f
13 changed files with 392 additions and 33 deletions

View File

@@ -16,6 +16,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.device.pojo.vo.PreDetection;
@@ -26,6 +27,7 @@ import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil;
import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api;
@@ -68,8 +70,8 @@ public class PqDevController extends BaseController {
public HttpResult<List<PreDetection>> aaa() {
String methodDescribe = getMethodDescribe("list");
List<PreDetection> devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
Map<String,List<PreDetection> > map=new HashMap();
map.put("deviceList",devInfo);
Map<String, List<PreDetection>> map = new HashMap();
map.put("deviceList", devInfo);
String jsonString = JSON.toJSONString(map);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
}
@@ -142,12 +144,6 @@ public class PqDevController extends BaseController {
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadTemplate() {
pqDevService.downloadTemplate();
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/export")
@@ -168,8 +164,15 @@ public class PqDevController extends BaseController {
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadTemplate() {
pqDevService.downloadTemplate();
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/importContrastData")
@PostMapping(value = "/importContrast")
@ApiOperation("批量导入被检设备数据")
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
@@ -198,33 +201,71 @@ public class PqDevController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 导出灿能二楼设备
*
* @param queryParam
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/exportCNDev")
@ApiOperation("导出被检设备数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public void exportCNDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("exportCNDev");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
pqDevService.exportCNDev(queryParam);
}
/**
* 下载灿能二楼设备导入文件模板
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
@PostMapping("/downloadCNDevTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadCNDevTemplate() {
pqDevService.downloadCNDevTemplate();
}
/**
* 导入灿能二楼设备
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
@PostMapping(value = "/import")
@ApiOperation("批量导入被检设备数据")
@PostMapping(value = "/importCNDev")
@ApiOperation("批量设备数据")
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importData");
public HttpResult<Object> importCNDev(@RequestParam("file") MultipartFile file, String pattern, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importCNDev");
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
if (!fileType) {
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
}
ImportParams params = new ImportParams();
params.setHeadRows(2);
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
params.setHeadRows(1);
params.setNeedVerify(true);
List<CNDevExcel> cnDevExcelList = null;
try {
ExcelImportResult<PqDevExcel.ContrastImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
//如果存在非法数据,将不合格的数据导出
ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
Workbook failWorkbook = excelImportResult.getFailWorkbook();
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
} else {
//批量录入数据
List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
pqDevService.importContrastData(list);
cnDevExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
}
if(ObjectUtil.isNotEmpty(cnDevExcelList)){
pqDevService.importCNDev(cnDevExcelList, pattern);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.device.device.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -112,11 +113,13 @@ public class PqDev extends BaseEntity implements Serializable {
/**
* 装置识别码3ds加密
*/
@TableField(fill = FieldFill.UPDATE)
private String series;
/**
* 装置秘钥3ds加密
*/
@TableField(fill = FieldFill.UPDATE)
private String devKey;
/**
@@ -211,5 +214,7 @@ public class PqDev extends BaseEntity implements Serializable {
@TableField("Preinvestment_Plan")
private String preinvestmentPlan;
private String power;
}

View File

@@ -0,0 +1,59 @@
package com.njcn.gather.device.device.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
* @data 2025-01-15
*/
@Data
public class CNDevExcel {
@Excel(name = "预投计划*", width = 20, orderNum = "1")
private String preinvestmentPlan;
@Excel(name = "设备编号*", width = 20, orderNum = "2")
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备类型*", width = 20, orderNum = "3")
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "通讯协议*", width = 15, orderNum = "4")
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "5")
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag;
@Excel(name = "识别码", width = 30, orderNum = "6")
private String series;
@Excel(name = "秘钥", width = 30, orderNum = "7")
private String devKey;
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "8")
private Integer factorFlag;
@Excel(name = "IP地址*", width = 20, replace = {"否_0", "是_1"}, orderNum = "9")
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号*", width = 15, orderNum = "10")
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
private Integer port;
}

View File

@@ -5,11 +5,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.device.device.pojo.enums.TimeCheckResultEnum;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.device.pojo.vo.PreDetection;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -186,4 +189,24 @@ public interface IPqDevService extends IService<PqDev> {
void updatePqDevReportState(String devId, int i);
int countUnReportDev(String planId);
/**
* 导出灿能二楼设备数据
*
* @param queryParam
*/
void exportCNDev(PqDevParam.QueryParam queryParam);
/**
* 下载灿能二楼设备模板文件
*/
void downloadCNDevTemplate();
/**
* 导入灿能二楼设备数据
*
* @param cnDevExcelList 灿能二楼设备数据列表
* @param pattern 模式Id
*/
void importCNDev(List<CNDevExcel> cnDevExcelList,String pattern);
}

View File

@@ -1,5 +1,6 @@
package com.njcn.gather.device.device.service.impl;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -12,11 +13,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.poi.PullDown;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.device.device.mapper.PqDevMapper;
import com.njcn.gather.device.device.pojo.enums.TimeCheckResultEnum;
import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.CNDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.device.pojo.vo.PreDetection;
@@ -32,7 +35,9 @@ import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
import com.njcn.gather.system.config.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTypeService;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor;
@@ -43,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -59,6 +65,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
private final DetectionDataDealService detectionDataDealService;
private final IDevTypeService devTypeService;
private final ISysTestConfigService sysTestConfigService;
private final IDictTypeService dictTypeService;
@Override
@@ -116,11 +123,13 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
PqDev pqDev = new PqDev();
BeanUtil.copyProperties(updateParam, pqDev);
if (Objects.nonNull(pqDev.getSeries())) {
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
}
if (Objects.nonNull(pqDev.getDevKey())) {
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
if (pqDev.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
// 比对式设备修改监测点
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
@@ -165,7 +174,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam) {
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
if (ObjectUtil.isNotNull(pqDevs)) {
if (ObjectUtil.isNotEmpty(pqDevs)) {
this.visualize(pqDevs);
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
for (int i = 0; i < pqDevs.size(); i++) {
@@ -252,7 +261,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public List<PqDev> listByPlanId(PqDevParam.QueryParam param) {
if(StrUtil.isBlank(param.getPlanId())){
if (StrUtil.isBlank(param.getPlanId())) {
return Collections.emptyList();
}
List<PqDev> pqDevList = this.lambdaQuery()
@@ -459,10 +468,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
// 只有检测完成的设备才可以进行归档
PqDev pqDev = this.getById(id);
if (ObjectUtil.isNotNull(pqDev)) {
if(!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())){
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
}
if(!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())){
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
throw new BusinessException(DevResponseEnum.DEV_UN_REPORT);
}
boolean update = this.lambdaUpdate()
@@ -492,10 +501,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public boolean updateResult(List<String> ids,List<String> valueType, String code) {
public boolean updateResult(List<String> ids, List<String> valueType, String code) {
if (CollUtil.isNotEmpty(ids)) {
SysTestConfig config = sysTestConfigService.getOneConfig();
Map<String, Integer> result = detectionDataDealService.devResult(ids,valueType, code);
Map<String, Integer> result = detectionDataDealService.devResult(ids, valueType, code);
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, ids));
for (PqDev pqDev : list) {
if (result.containsKey(pqDev.getId())) {
@@ -505,7 +514,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
this.baseMapper.updateReportState(pqDev.getId());
// 装置归档
checkState = CheckStateEnum.DOCUMENTED.getValue();
}else{
} else {
checkState = CheckStateEnum.CHECKED.getValue();
}
this.update(new LambdaUpdateWrapper<PqDev>()
@@ -554,6 +563,95 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
return this.count(queryWrapper);
}
@Override
public void exportCNDev(PqDevParam.QueryParam queryParam) {
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
List<CNDevExcel> pqDevExcels = null;
if (ObjectUtil.isNotEmpty(pqDevs)) {
this.visualizeCNDev(pqDevs);
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
}
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
}
@Override
public void downloadCNDevTemplate() {
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importCNDev(List<CNDevExcel> cnDevExcelList, String pattern) {
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
//逆向可视化
this.reverseVisualizeCNDev(oldDevList);
List<PqDev> newDevList = new ArrayList<>();
PqDevParam param = new PqDevParam.UpdateParam();
oldDevList.forEach(pqDev -> {
pqDev.setCreateId(pqDev.getName());
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
pqDev.setPattern(pattern);
pqDev.setState(DataStateEnum.ENABLE.getCode());
if (pqDev.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
String name = pqDev.getName();
if (name.contains("-")) {
String[] split = name.split("-");
if (split.length == 2) {
long start = Long.parseLong(split[0]);
long end = Long.parseLong(split[1]);
for (long i = start; i <= end; i++) {
PqDev dev = new PqDev();
BeanUtil.copyProperties(pqDev, dev);
dev.setName(String.valueOf(i));
dev.setCreateId(String.valueOf(i));
param.setName(dev.getName());
param.setCreateId(dev.getName());
param.setDevType(dev.getDevType());
this.checkRepeat(param, false);
long count = newDevList.stream().filter(d -> d.getName().equals(dev.getName())).count();
if (count == 0) {
newDevList.add(dev);
}
}
} else {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
}
} else {
param.setName(pqDev.getName());
param.setCreateId(pqDev.getCreateId());
param.setDevType(pqDev.getDevType());
this.checkRepeat(param, false);
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
if (count == 0) {
newDevList.add(pqDev);
}
}
});
this.saveBatch(newDevList);
}
/**
* 获取检测状态饼状图数据
*
@@ -631,4 +729,93 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
throw new BusinessException(DevResponseEnum.PQ_DEV_REPEAT);
}
}
private List<PullDown> getCNDevPullDownList() {
List<PullDown> pullDowns = new ArrayList<>();
// 预投计划
List<DictData> dictDataList = null;
PullDown pullDown = null;
DictType dictType = dictTypeService.getByCode("Preinvestment_Plan");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(0);
pullDown.setLastCol(0);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 设备类型
List<DevType> devTypeList = devTypeService.listAll();
pullDown = new PullDown();
pullDown.setFirstCol(2);
pullDown.setLastCol(2);
pullDown.setStrings(devTypeList.stream().map(DevType::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
// 通讯协议
dictType = dictTypeService.getByCode("Protocol");
if (ObjectUtil.isNotNull(dictType)) {
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
pullDown = new PullDown();
pullDown.setFirstCol(3);
pullDown.setLastCol(3);
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
pullDowns.add(pullDown);
}
// 是否加密
pullDown = new PullDown();
pullDown.setFirstCol(4);
pullDown.setLastCol(4);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
// 是否支持系数校准
pullDown = new PullDown();
pullDown.setFirstCol(7);
pullDown.setLastCol(7);
pullDown.setStrings(Arrays.asList("", ""));
pullDowns.add(pullDown);
return pullDowns;
}
/**
* 可视化-灿能二楼设备
*
* @param pqDevs
*/
private void visualizeCNDev(List<PqDev> pqDevs) {
pqDevs.forEach(pqDev -> {
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
});
}
/**
* 逆向可视化-灿能二楼设备
*
* @param pqDevs
*/
public void reverseVisualizeCNDev(List<PqDev> pqDevs) {
pqDevs.forEach(pqDev -> {
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
DevType devType = devTypeService.getByName(pqDev.getDevType());
pqDev.setDevType(devType.getId());
pqDev.setIcdId(devType.getIcd());
pqDev.setPower(devType.getPower());
pqDev.setDevVolt(devType.getDevVolt());
pqDev.setDevCurr(devType.getDevCurr());
pqDev.setDevChns(devType.getDevChns());
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
});
}
}

View File

@@ -16,4 +16,6 @@ import java.util.List;
public interface IDevTypeService extends IService<DevType> {
List<DevType> listAll();
DevType getByName(String name);
}

View File

@@ -28,4 +28,9 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
List<DevType> devTypes = this.baseMapper.selectList(queryWrapper);
return devTypes;
}
@Override
public DevType getByName(String name) {
return this.lambdaQuery().eq(DevType::getName, name).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).one();
}
}

View File

@@ -53,6 +53,12 @@ public class DictDataParam {
@ApiModelProperty("字典值")
private String value;
/**
* 是否开启使用Value值0-关闭1-开启(默认为0)
*/
@ApiModelProperty("是否开启使用Value值")
private Integer openValue;
/**
* 更新操作实体

View File

@@ -1,5 +1,7 @@
package com.njcn.gather.system.dictionary.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
@@ -55,8 +57,14 @@ public class DictData extends BaseEntity {
/**
* 目前只用于表示电压等级数值
*/
@TableField(fill = FieldFill.UPDATE)
private String value;
/**
* 是否开启使用Value值0-关闭1-开启(默认为0)
*/
private Integer openValue;
/**
* 状态0-删除 1-正常
*/

View File

@@ -26,6 +26,13 @@ public interface IDictDataService extends IService<DictData> {
*/
Page<DictData> getDictDataByTypeId(DictDataParam.QueryParam queryParam);
/**
* 根据字典类型id查询字典信息
* @param typeId 字典类型id
* @return 操作结果
*/
List<DictData> getDictDataByTypeId(String typeId);
/**
* 新增数据字典
* @param dictDataParam 字典数据

View File

@@ -47,5 +47,13 @@ public interface IDictTypeService extends IService<DictType> {
* 导出字典类型数据
* @param queryParam 查询参数
*/
public void exportDictType(DictTypeParam.QueryParam queryParam);
void exportDictType(DictTypeParam.QueryParam queryParam);
/**
* 根据code获取字典类型数据
*
* @param code 字典类型code
* @return
*/
DictType getByCode(String code);
}

View File

@@ -64,6 +64,10 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
}
@Override
public List<DictData> getDictDataByTypeId(String typeId) {
return this.lambdaQuery().eq(DictData::getTypeId, typeId).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).list();
}
@Override
@Transactional(rollbackFor = {Exception.class})

View File

@@ -104,6 +104,10 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
ExcelUtil.exportExcel("字典类型导出数据.xlsx", "字典类型", DictTypeExcel.class, dictTypeVOS);
}
@Override
public DictType getByCode(String code) {
return this.lambdaQuery().eq(DictType::getCode, code).eq(DictType::getState, DataStateEnum.ENABLE.getCode()).one();
}
/**
* 校验参数,检查是否存在相同名称的字典类型