检测计划相关功能代码
This commit is contained in:
@@ -10,9 +10,11 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -138,14 +140,17 @@ public class PqDevController extends BaseController {
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
public HttpResult<Boolean> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, @RequestParam("planId") String planId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
Boolean result = pqDevService.importDev(file, patternId, null, response);
|
||||
if("null".equals(planId)){
|
||||
planId = null;
|
||||
}
|
||||
Boolean result = pqDevService.importDev(file, patternId, planId, response);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
@@ -164,21 +169,12 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<PqDevVO> pqDevVOList = pqDevService.listByPlanId(param);
|
||||
|
||||
pqDevVOList.forEach(pqDevVO -> {
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
}
|
||||
});
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
|
||||
@OperateInfo
|
||||
@GetMapping("/getSelectOptions")
|
||||
@ApiOperation("根据历史记录信息来获取下拉框内容")
|
||||
public HttpResult<Map<String, List<String>>> getSelectOptions(@RequestParam("pattern") String pattern) {
|
||||
String methodDescribe = getMethodDescribe("getSelectOptions");
|
||||
Map<String, List<String>> result = pqDevService.listSelectOptions(pattern);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -138,5 +139,27 @@ public class PqStandardDevController extends BaseController {
|
||||
pqStandardDevService.importData(file, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取所有标准设备")
|
||||
public HttpResult<List<PqStandardDev>> getAll() {
|
||||
String methodDescribe = getMethodDescribe("getAll");
|
||||
LogUtil.njcnDebug(log, "{},查询所有数据", methodDescribe);
|
||||
List<PqStandardDev> result = pqStandardDevService.lambdaQuery().eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("查询出指定计划已关联的标准设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqStandardDev>> listByPlanId(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<PqStandardDev> pqDevVOList = pqStandardDevService.listByPlanId(planId);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,11 @@
|
||||
left JOIN pq_dev_sub dev_sub ON dev.Id = dev_sub.Dev_Id
|
||||
<where>
|
||||
dev.state = 1
|
||||
<if test="planId!= null and planId!= ''">
|
||||
AND dev.Plan_Id = #{planId}
|
||||
<if test="planIdList!= null and planIdList.size!=0">
|
||||
AND dev.Plan_Id in
|
||||
<foreach collection="planIdList" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="name!= null and name!= ''">
|
||||
AND dev.Name LIKE CONCAT('%',#{name},'%')
|
||||
|
||||
@@ -166,7 +166,7 @@ public class PqDevParam {
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("检测计划ID")
|
||||
private String planId;
|
||||
private List<String> planIdList;
|
||||
|
||||
@ApiModelProperty("检测状态列表")
|
||||
private List<
|
||||
@@ -191,6 +191,12 @@ public class PqDevParam {
|
||||
|
||||
@ApiModelProperty("所属电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("地市")
|
||||
private String region;
|
||||
|
||||
@ApiModelProperty("是否分配")
|
||||
private Integer assign;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -213,6 +219,6 @@ public class PqDevParam {
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DetectionValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
private List<String> devIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
@@ -23,86 +22,79 @@ import java.util.List;
|
||||
@Data
|
||||
public class ContrastDevExcel implements Serializable {
|
||||
|
||||
@Excel(name = "所属地市*", width = 30, orderNum = "1")
|
||||
private String id;
|
||||
|
||||
@Excel(name = "所属地市*", width = 30, needMerge = true, orderNum = "1")
|
||||
private String cityName;
|
||||
|
||||
@Excel(name = "所属供电公司*", width = 30, orderNum = "2")
|
||||
@Excel(name = "所属供电公司*", width = 30, needMerge = true, orderNum = "2")
|
||||
private String gdName;
|
||||
|
||||
@Excel(name = "所属电站*", width = 30, orderNum = "3")
|
||||
@Excel(name = "所属电站*", width = 30, needMerge = true, orderNum = "3")
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "设备名称*", width = 20, orderNum = "4")
|
||||
@Excel(name = "设备名称*", width = 20, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DetectionValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DetectionValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, orderNum = "6")
|
||||
@Excel(name = "设备序列号*", width = 20, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, needMerge = true, orderNum = "6")
|
||||
@NotBlank(message = DetectionValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备厂家*", width = 20, orderNum = "7")
|
||||
@Excel(name = "设备厂家*", width = 20, needMerge = true, orderNum = "7")
|
||||
@NotBlank(message = DetectionValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "通讯协议*", width = 15, orderNum = "11")
|
||||
@Excel(name = "被检通道", width = 20, needMerge = true, orderNum = "8")
|
||||
private String inspectChannel;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, needMerge = true, orderNum = "9")
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, needMerge = true, orderNum = "10")
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议*", width = 15, needMerge = true, orderNum = "11")
|
||||
@NotBlank(message = DetectionValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "12")
|
||||
@Excel(name = "是否加密*", width = 20, needMerge = true, replace = {"否_0", "是_1"}, orderNum = "12")
|
||||
@NotNull(message = DetectionValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "13")
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, needMerge = true, orderNum = "13")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "14")
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, needMerge = true, orderNum = "14")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "15")
|
||||
@Excel(name = "IP地址*", width = 20, needMerge = true, orderNum = "15")
|
||||
@NotBlank(message = DetectionValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DetectionValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "16")
|
||||
@Excel(name = "端口号*", width = 15, needMerge = true, orderNum = "16")
|
||||
@NotNull(message = DetectionValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DetectionValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "投运日期(yyyy-MM-dd)*", width = 30, orderNum = "17", format = "yyyy-MM-dd")
|
||||
@Excel(name = "投运日期(yyyy-MM-dd)*", width = 30, needMerge = true, orderNum = "17", format = "yyyy-MM-dd")
|
||||
@NotNull(message = DetectionValidMessage.CREATE_DATE_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "定检日期(yyyy-MM-dd)*", width = 30, orderNum = "18", format = "yyyy-MM-dd")
|
||||
@Excel(name = "定检日期(yyyy-MM-dd)*", width = 30, needMerge = true, orderNum = "18", format = "yyyy-MM-dd")
|
||||
@NotNull(message = DetectionValidMessage.INSPECT_DATE_NOT_NULL)
|
||||
private LocalDate inspectDate;
|
||||
|
||||
@Excel(name = "谐波系统设备id*", width = 30, orderNum = "19")
|
||||
@Excel(name = "谐波系统设备id*", width = 30, needMerge = true, orderNum = "19")
|
||||
@NotBlank(message = DetectionValidMessage.HARM_SYS_ID_NOT_BLANK)
|
||||
private String harmSysId;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportExcel extends ContrastDevExcel {
|
||||
|
||||
@ExcelCollection(name = "监测点信息", orderNum = "22")
|
||||
private List<PqMonitorExcel> pqMonitorExcelList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportExcel extends ContrastDevExcel {
|
||||
@Excel(name = "设备序列号*", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DetectionValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "被检通道", width = 20, orderNum = "8")
|
||||
private String inspectChannel;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
private String softwareVersion;
|
||||
}
|
||||
@ExcelCollection(name = "监测点信息", orderNum = "22")
|
||||
private List<PqMonitorExcel> pqMonitorExcelList;
|
||||
}
|
||||
|
||||
@@ -101,4 +101,14 @@ public class PqDevVO extends PqDev {
|
||||
* 相对湿度
|
||||
*/
|
||||
private Float humidity;
|
||||
|
||||
/**
|
||||
* 绑定的计划名称
|
||||
*/
|
||||
private String boundPlanName;
|
||||
|
||||
/**
|
||||
* 是否已经分配。0-未分配、1-已分配、2-所有
|
||||
*/
|
||||
private Integer assign;
|
||||
}
|
||||
|
||||
@@ -254,14 +254,29 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param contrastDevExcelList
|
||||
* @param patternId
|
||||
*/
|
||||
boolean importContrastDev(List<ContrastDevExcel.ImportExcel> contrastDevExcelList, String patternId);
|
||||
boolean importContrastDev(List<ContrastDevExcel> contrastDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出、导出文件模板的下拉列表
|
||||
*
|
||||
* @param startCol
|
||||
* @param isExport 是否是导出模板
|
||||
* @return
|
||||
*/
|
||||
List<PullDown> getContrastDevPullDownList(int startCol, boolean isExport);
|
||||
List<PullDown> getContrastDevPullDownList(int startCol);
|
||||
|
||||
/**
|
||||
* 根据历史记录来获取下拉框内容
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<String>> listSelectOptions(String pattern);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出数据
|
||||
*
|
||||
* @param pqDevVOList 设备id列表
|
||||
* @return
|
||||
*/
|
||||
List<ContrastDevExcel> getExportContrastDevData(List<PqDevVO> pqDevVOList);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -75,4 +76,12 @@ public interface IPqStandardDevService extends IService<PqStandardDev> {
|
||||
* @return
|
||||
*/
|
||||
void importData(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 查询出指定计划以关联的标准设备列表
|
||||
*
|
||||
* @param planId
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> listByPlanId(String planId);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -30,9 +31,9 @@ import com.njcn.gather.device.pojo.vo.*;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.service.IPqDevSubService;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
@@ -78,7 +79,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final ISysUserService userService;
|
||||
private final IPqDevSubService pqDevSubService;
|
||||
private final TableGenMapper tableGenMapper;
|
||||
|
||||
@Override
|
||||
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
@@ -97,6 +97,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
page2.getRecords().forEach(p -> {
|
||||
DevType devType = devTypeService.getById(p.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
p.setDevType(devType.getName());
|
||||
p.setDevChns(devType.getDevChns());
|
||||
p.setDevVolt(devType.getDevVolt());
|
||||
p.setDevCurr(devType.getDevCurr());
|
||||
@@ -274,7 +275,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
@Override
|
||||
public List<PqDevVO> listByPlanId(PqDevParam.QueryParam param) {
|
||||
if (StrUtil.isBlank(param.getPlanId())) {
|
||||
if (CollUtil.isEmpty(param.getPlanIdList())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PqDevVO> pqDevList = this.baseMapper.selectByQueryParam(param);
|
||||
@@ -381,7 +382,15 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
.eq(StrUtil.isNotBlank(queryParam.getCityName()), "pq_dev.City_Name", queryParam.getCityName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getGdName()), "pq_dev.Gd_Name", queryParam.getGdName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getSubName()), "pq_dev.Sub_Name", queryParam.getSubName())
|
||||
.in(CollectionUtil.isNotEmpty(queryParam.getPlanIdList()), "pq_dev.Plan_Id", queryParam.getPlanIdList())
|
||||
.isNotNull(DataStateEnum.ENABLE.getCode().equals(queryParam.getAssign()), "pq_dev.Plan_Id")
|
||||
.isNull(DataStateEnum.DELETED.getCode().equals(queryParam.getAssign()), "pq_dev.Plan_Id")
|
||||
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.Create_Date", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
|
||||
if (StrUtil.isNotBlank(queryParam.getRegion())) {
|
||||
queryWrapper.and(w -> w.like(StrUtil.isNotBlank(queryParam.getRegion()), "pq_dev.City_Name", queryParam.getRegion())
|
||||
.or().like(StrUtil.isNotBlank(queryParam.getRegion()), "pq_dev.Gd_Name", queryParam.getRegion())
|
||||
.or().like(StrUtil.isNotBlank(queryParam.getRegion()), "pq_dev.Sub_Name", queryParam.getRegion()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
@@ -460,7 +469,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDevSubService.update(wrapper);
|
||||
|
||||
PqDevParam.QueryParam param = new PqDevParam.QueryParam();
|
||||
param.setPlanId(pqDevVo.getPlanId());
|
||||
param.setPlanIdList(Arrays.asList(pqDevVo.getPlanId()));
|
||||
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||
Set<Integer> set = pqDevVOList.stream().map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
||||
@@ -505,7 +514,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public long countUnReportDev(String planId) {
|
||||
// 查询该计划下所有设备的检测状态,是否有未生成的
|
||||
PqDevParam.QueryParam param = new PqDevParam.QueryParam();
|
||||
param.setPlanId(planId);
|
||||
param.setPlanIdList(Arrays.asList(planId));
|
||||
List<PqDevVO> devVOList = this.baseMapper.selectByQueryParam(param);
|
||||
long count = devVOList.stream().filter(obj -> !DevReportStateEnum.GENERATED.getValue().equals(obj.getReportState())).count();
|
||||
return count;
|
||||
@@ -544,7 +553,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public void downloadTemplate(String patternId) {
|
||||
DictData dictData = dictDataService.getDictDataById(patternId);
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 2, this.getContrastDevPullDownList(0, false), ContrastDevExcel.ImportExcel.class, new ArrayList<>());
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 2, this.getContrastDevPullDownList(0), ContrastDevExcel.class, new ArrayList<>());
|
||||
} else {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
SceneEnum sceneEnum = SceneEnum.getSceneEnum(currrentScene);
|
||||
@@ -946,12 +955,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDevVOList.addAll(this.baseMapper.listByDevIds(idList));
|
||||
}
|
||||
|
||||
List<ContrastDevExcel.ExportExcel> contrastDevExcels = null;
|
||||
if (ObjectUtil.isNotEmpty(pqDevVOList)) {
|
||||
this.visualizeProvinceDev(pqDevVOList);
|
||||
contrastDevExcels = BeanUtil.copyToList(pqDevVOList, ContrastDevExcel.ExportExcel.class);
|
||||
}
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, this.getContrastDevPullDownList(0, true), ContrastDevExcel.ExportExcel.class, ObjectUtil.isEmpty(contrastDevExcels) ? new ArrayList<>() : contrastDevExcels);
|
||||
List<ContrastDevExcel> contrastDevExcelList = this.getExportContrastDevData(pqDevVOList);
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 2, this.getContrastDevPullDownList(0), ContrastDevExcel.class, ObjectUtil.isEmpty(contrastDevExcelList) ? new ArrayList<>() : contrastDevExcelList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1112,9 +1118,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
params.setNeedVerify(true);
|
||||
params.setHeadRows(2);
|
||||
|
||||
List<ContrastDevExcel.ImportExcel> contrastDevExcelList = null;
|
||||
List<ContrastDevExcel> contrastDevExcelList = null;
|
||||
try {
|
||||
ExcelImportResult<ContrastDevExcel.ImportExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), ContrastDevExcel.ImportExcel.class, params);
|
||||
ExcelImportResult<ContrastDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), ContrastDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
@@ -1125,12 +1131,12 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
return this.importContrastDev(contrastDevExcelList, patternId);
|
||||
return this.importContrastDev(contrastDevExcelList, patternId, planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean importContrastDev(List<ContrastDevExcel.ImportExcel> contrastDevExcelList, String patternId) {
|
||||
public boolean importContrastDev(List<ContrastDevExcel> contrastDevExcelList, String patternId, String planId) {
|
||||
if (CollUtil.isNotEmpty(contrastDevExcelList)) {
|
||||
List<PqMonitor> monitorList = new ArrayList<>();
|
||||
List<PqDev> oldDevList = contrastDevExcelList.stream().map(devExcel -> {
|
||||
@@ -1199,6 +1205,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
&& (dev.getName().equals(pqDev.getName()) || dev.getCreateId().equals(pqDev.getCreateId())))
|
||||
.count();
|
||||
if (count == 0) {
|
||||
pqDev.setPlanId(planId);
|
||||
newDevList.add(pqDev);
|
||||
}
|
||||
});
|
||||
@@ -1211,7 +1218,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
PqDev newDev = newDevList.stream().filter(dev -> dev.getHarmSysId().equals(oldDev.getHarmSysId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isNotNull(newDev)) {
|
||||
newDevList.remove(newDev);
|
||||
monitorList.removeIf(monitor -> monitor.getDevId().equals(newDev.getId()));
|
||||
monitorList.stream()
|
||||
.filter(monitor -> monitor.getDevId().equals(newDev.getId()))
|
||||
.forEach(monitor -> monitor.setDevId(oldDev.getId()));
|
||||
BeanUtil.copyProperties(newDev, oldDev, "id");
|
||||
}
|
||||
});
|
||||
@@ -1231,21 +1240,13 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
pqDevSubService.saveBatch(pqDevSubList);
|
||||
|
||||
|
||||
List<String> devIdList = oldDevList1.stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(devIdList)) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<PqMonitor>()
|
||||
.in("pq_monitor.Dev_Id", devIdList);
|
||||
pqMonitorService.remove(wrapper);
|
||||
}
|
||||
monitorList.forEach(monitor -> {
|
||||
DictData dictData = dictDataService.getDictDataByName(monitor.getConnection());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
monitor.setConnection(dictData.getId());
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.CONNECTION_NOT_EXIST);
|
||||
}
|
||||
});
|
||||
pqMonitorService.reverseVisualizeMonitor(monitorList);
|
||||
pqMonitorService.saveBatch(monitorList);
|
||||
return true;
|
||||
}
|
||||
@@ -1253,7 +1254,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PullDown> getContrastDevPullDownList(int startCol, boolean isExport) {
|
||||
public List<PullDown> getContrastDevPullDownList(int startCol) {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
List<DictData> dictDataList = null;
|
||||
PullDown pullDown = null;
|
||||
@@ -1261,13 +1262,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// 设备类型
|
||||
List<DevType> devTypeList = devTypeService.listAll();
|
||||
pullDown = new PullDown();
|
||||
if (isExport) {
|
||||
pullDown.setFirstCol(startCol + 5);
|
||||
pullDown.setLastCol(startCol + 5);
|
||||
} else {
|
||||
pullDown.setFirstCol(startCol + 4);
|
||||
pullDown.setLastCol(startCol + 4);
|
||||
}
|
||||
|
||||
pullDown.setFirstCol(startCol + 5);
|
||||
pullDown.setLastCol(startCol + 5);
|
||||
|
||||
pullDown.setStrings(devTypeList.stream().map(DevType::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
@@ -1277,13 +1275,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
if (isExport) {
|
||||
pullDown.setFirstCol(startCol + 6);
|
||||
pullDown.setLastCol(startCol + 6);
|
||||
} else {
|
||||
pullDown.setFirstCol(startCol + 5);
|
||||
pullDown.setLastCol(startCol + 5);
|
||||
}
|
||||
pullDown.setFirstCol(startCol + 6);
|
||||
pullDown.setLastCol(startCol + 6);
|
||||
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
@@ -1294,13 +1288,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
if (isExport) {
|
||||
pullDown.setFirstCol(startCol + 10);
|
||||
pullDown.setLastCol(startCol + 10);
|
||||
} else {
|
||||
pullDown.setFirstCol(startCol + 6);
|
||||
pullDown.setLastCol(startCol + 6);
|
||||
}
|
||||
pullDown.setFirstCol(startCol + 10);
|
||||
pullDown.setLastCol(startCol + 10);
|
||||
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
@@ -1308,29 +1297,23 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
// 是否加密
|
||||
pullDown = new PullDown();
|
||||
if (isExport) {
|
||||
pullDown.setFirstCol(startCol + 11);
|
||||
pullDown.setLastCol(startCol + 11);
|
||||
} else {
|
||||
pullDown.setFirstCol(startCol + 7);
|
||||
pullDown.setLastCol(startCol + 7);
|
||||
}
|
||||
pullDown.setFirstCol(startCol + 11);
|
||||
pullDown.setLastCol(startCol + 11);
|
||||
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 接线方式
|
||||
if (!isExport) {
|
||||
|
||||
dictType = dictTypeService.getByCode("Dev_Connect");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
dictType = dictTypeService.getByCode("Dev_Connect");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 25);
|
||||
pullDown.setLastCol(startCol + 25);
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(startCol + 21);
|
||||
pullDown.setLastCol(startCol + 21);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
return pullDowns;
|
||||
@@ -1389,4 +1372,47 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContrastDevExcel> getExportContrastDevData(List<PqDevVO> pqDevVOList) {
|
||||
List<ContrastDevExcel> contrastDevExcels = new ArrayList<>();
|
||||
if (ObjectUtil.isNotEmpty(pqDevVOList)) {
|
||||
this.visualizeProvinceDev(pqDevVOList);
|
||||
contrastDevExcels.addAll(BeanUtil.copyToList(pqDevVOList, ContrastDevExcel.class));
|
||||
contrastDevExcels.forEach(contrastDevExcel -> {
|
||||
List<PqMonitor> monitorList = pqMonitorService.listPqMonitorByDevId(contrastDevExcel.getId());
|
||||
pqMonitorService.visualizeMonitor(monitorList);
|
||||
List<PqMonitorExcel> pqMonitorExcelList = BeanUtil.copyToList(monitorList, PqMonitorExcel.class);
|
||||
contrastDevExcel.setPqMonitorExcelList(pqMonitorExcelList);
|
||||
});
|
||||
}
|
||||
return contrastDevExcels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> listSelectOptions(String pattern) {
|
||||
List<PqDev> pqDevList = this.lambdaQuery().eq(PqDev::getPattern, pattern)
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.list();
|
||||
String[] devKeyArray = new String[]{"cityName", "gdName", "subName", "hardwareVersion", "softwareVersion"};
|
||||
Map<String, List<String>> result = new HashMap<>();
|
||||
for (String key : devKeyArray) {
|
||||
List<String> value = pqDevList.stream().map(dev -> {
|
||||
String fieldValue = (String) ReflectUtil.getFieldValue(dev, key);
|
||||
return fieldValue;
|
||||
}).distinct().filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
result.put(key, value);
|
||||
}
|
||||
|
||||
List<PqMonitor> pqMonitorList = pqMonitorService.list();
|
||||
String[] monitorKeyArray = new String[]{"busbar", "pt", "ct"};
|
||||
for (String key : monitorKeyArray) {
|
||||
List<String> value = pqMonitorList.stream().map(monitor -> {
|
||||
String fieldValue = (String) ReflectUtil.getFieldValue(monitor, key);
|
||||
return fieldValue;
|
||||
}).distinct().filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
result.put(key, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
@@ -55,6 +56,7 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
|
||||
|
||||
@Override
|
||||
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
||||
@@ -148,6 +150,11 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
this.importData(contrastDevExcelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqStandardDev> listByPlanId(String planId) {
|
||||
return adPlanStandardDevMapper.listByPlanId(Collections.singletonList(planId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user