项目结构调整
This commit is contained in:
@@ -1,27 +1,41 @@
|
||||
package com.njcn.gather.device.plan.controller;
|
||||
package com.njcn.gather.plan.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.LogEnum;
|
||||
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.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -96,20 +110,6 @@ public class AdPlanController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/bindDev")
|
||||
@ApiOperation("检测计划绑定设备")
|
||||
@ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
|
||||
public HttpResult<Object> bindDev(@RequestBody @Validated AdPlanParam.BindPlanParam bindPlanParam) {
|
||||
String methodDescribe = getMethodDescribe("bindDev");
|
||||
LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
boolean result = pqDevService.bind(bindPlanParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/listByPattern")
|
||||
@@ -129,8 +129,60 @@ public class AdPlanController extends BaseController {
|
||||
public void export(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("download");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
List<Map<String, Object>> sheetList = adPlanService.getAdPlanEexportSheetList(queryParam);
|
||||
ExcelUtil.exportExcel("检测计划导出数据.xlsx", sheetList);
|
||||
List<AdPlanExcel> data = adPlanService.getExportData(queryParam);
|
||||
ExcelUtil.exportExcel("检测计划导出数据.xlsx", AdPlanExcel.class, data);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入检测计划数据")
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true)
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
try {
|
||||
Workbook workBook = ExcelUtil.getWorkBook(file);
|
||||
int numberOfSheets = workBook.getNumberOfSheets();
|
||||
if (numberOfSheets == 2) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
params.setSheetNum(1);
|
||||
|
||||
params.setStartSheetIndex(0);
|
||||
ExcelImportResult<AdPlanExcel> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.class, params);
|
||||
if (adPlanExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
} else {
|
||||
List<AdPlanExcel> adPlanExcelList = adPlanExcelResult.getList();
|
||||
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
|
||||
params.setStartSheetIndex(1);
|
||||
String pattern = adPlanExcelList.get(0).getPattern();
|
||||
if (PatternEnum.CONTRAST.getValue().equals(pattern)) {
|
||||
ExcelImportResult<PqDevExcel.ContrastImportData> pqDevExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
|
||||
if (pqDevExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(pqDevExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
} else {
|
||||
adPlanService.importData(adPlanExcelList);
|
||||
pqDevService.importContrastData(pqDevExcelResult.getList());
|
||||
}
|
||||
} else {
|
||||
ExcelImportResult<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.SimulateOrDigitalImportData.class, params);
|
||||
if (pqDevExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(pqDevExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@@ -143,5 +195,6 @@ public class AdPlanController extends BaseController {
|
||||
List<List<Map<String, Object>>> result = pqDevService.getPieData(planId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.plan.mapper;
|
||||
package com.njcn.gather.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.plan.mapper;
|
||||
package com.njcn.gather.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.plan.mapper.AdPlanMapper">
|
||||
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.plan.mapper.AdPlanSourceMapper">
|
||||
<mapper namespace="com.njcn.gather.plan.mapper.AdPlanSourceMapper">
|
||||
|
||||
|
||||
<select id="selectPqSourceByPlanId" resultType="com.njcn.gather.device.source.pojo.po.PqSource">
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.plan.pojo.enums;
|
||||
package com.njcn.gather.plan.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -32,4 +32,13 @@ public enum DataSourceEnum {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getValueByMsg(String msg) {
|
||||
for (DataSourceEnum dataSourceEnum : DataSourceEnum.values()) {
|
||||
if (dataSourceEnum.getMsg().equals(msg)) {
|
||||
return dataSourceEnum.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.njcn.gather.device.plan.pojo.param;
|
||||
package com.njcn.gather.plan.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -127,15 +126,4 @@ public class AdPlanParam {
|
||||
// private Integer result;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BindPlanParam {
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@NotNull(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.plan.pojo.po;
|
||||
package com.njcn.gather.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.gather.device.plan.pojo.po;
|
||||
package com.njcn.gather.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.njcn.gather.device.plan.pojo.vo;
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -40,9 +43,12 @@ public class AdPlanExcel {
|
||||
@Excel(name = "报告生成状态", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"})
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "检测结果", width = 10, replace = {"不符合_0", "符合_1", "/_2"})
|
||||
@Excel(name = "检测结果", width = 10, replace = {"不符合_0", "符合_1", "未检_2"})
|
||||
private Integer result;
|
||||
|
||||
@Excel(name = "数据表后缀", width = 20)
|
||||
private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备")
|
||||
private List<PqDevExcel> devices;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.gather.device.plan.pojo.vo;
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.njcn.gather.device.plan.service;
|
||||
package com.njcn.gather.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -61,5 +62,23 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @param queryParam 查询参数
|
||||
* @return SheetList
|
||||
*/
|
||||
List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam);
|
||||
//List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取检测计划导出数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 检测计划导出数据
|
||||
*/
|
||||
List<AdPlanExcel> getExportData(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 导入检测计划
|
||||
*
|
||||
* @param adPlanExcelList 检测计划Excel列表
|
||||
* @return 导入成功则返回true,否则返回false
|
||||
*/
|
||||
void importData(List<AdPlanExcel> adPlanExcelList);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.plan.service;
|
||||
package com.njcn.gather.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.gather.device.plan.service.impl;
|
||||
package com.njcn.gather.plan.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -13,17 +12,8 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
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.PqDevExcel;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.device.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
@@ -31,7 +21,14 @@ import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PlanReportStateEnum;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -97,7 +94,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNKNOWN.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
// todo code 生成
|
||||
// 日期生成 MMdd
|
||||
//String dateStr = DateFormatUtils.format(new Date(), "MMdd");
|
||||
@@ -106,11 +103,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 新增检测计划、检测源关联
|
||||
adPlanSourceService.addAdPlanSource(planId, param.getSourceIds());
|
||||
if (ObjectUtil.isNotEmpty(param.getDevIds())) {
|
||||
AdPlanParam.BindPlanParam bindPlanParam = new AdPlanParam.BindPlanParam();
|
||||
bindPlanParam.setPlanId(planId);
|
||||
bindPlanParam.setPqDevIds(param.getDevIds());
|
||||
// 新增时,绑定设备
|
||||
pqDevService.bind(bindPlanParam);
|
||||
pqDevService.bind(planId, param.getDevIds());
|
||||
|
||||
// 守时检测
|
||||
pqDevService.updatePqDevTimeCheckResult(param.getDevIds(), TimeCheckResultEnum.UNKNOWN);
|
||||
@@ -134,10 +128,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<String> intersection = new ArrayList<>(notUnCheckedIds);
|
||||
intersection.retainAll(param.getDevIds());
|
||||
if (ObjectUtil.isEmpty(intersection)) {
|
||||
AdPlanParam.BindPlanParam bindPlanParam = new AdPlanParam.BindPlanParam();
|
||||
bindPlanParam.setPlanId(param.getId());
|
||||
bindPlanParam.setPqDevIds(param.getDevIds());
|
||||
pqDevService.bind(bindPlanParam);
|
||||
pqDevService.bind(param.getId(), param.getDevIds());
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.HAS_NOT_UNCHECKED_DEVICE);
|
||||
}
|
||||
@@ -192,30 +183,104 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
return result;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam) {
|
||||
// List<AdPlan> adPlans = this.list(this.getQueryWrapper(queryParam));
|
||||
//
|
||||
// List<AdPlanExcel> adPlanExcelList = this.getAdPlanExcelList(adPlans);
|
||||
// Map<String, Object> sheetMap1 = new HashMap<>();
|
||||
// ExportParams exportParams = new ExportParams();
|
||||
// exportParams.setSheetName("检测计划");
|
||||
// sheetMap1.put("title", exportParams);
|
||||
// sheetMap1.put("entity", AdPlanExcel.class);
|
||||
// sheetMap1.put("data", adPlanExcelList);
|
||||
//
|
||||
// List<Map<String, Object>> sheetList = new ArrayList<>();
|
||||
// sheetList.add(sheetMap1);
|
||||
// DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
|
||||
// if (ObjectUtil.isNotNull(dictData)) {
|
||||
// if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
// sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.ContrastExportData.class));
|
||||
// } else {
|
||||
// sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.SimulateOrDigitalExportData.class));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return sheetList;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam) {
|
||||
List<AdPlan> adPlans = this.list(this.getQueryWrapper(queryParam));
|
||||
public List<AdPlanExcel> getExportData(AdPlanParam.QueryParam queryParam) {
|
||||
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(planList);
|
||||
List<AdPlanExcel> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.class);
|
||||
return planExcelList;
|
||||
}
|
||||
|
||||
List<AdPlanExcel> adPlanExcelList = this.getAdPlanExcelList(adPlans);
|
||||
Map<String, Object> sheetMap1 = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("检测计划");
|
||||
sheetMap1.put("title", exportParams);
|
||||
sheetMap1.put("entity", AdPlanExcel.class);
|
||||
sheetMap1.put("data", adPlanExcelList);
|
||||
@Override
|
||||
public void importData(List<AdPlanExcel> adPlanExcelList) {
|
||||
List<AdPlan> adPlans = BeanUtil.copyToList(adPlanExcelList, AdPlan.class);
|
||||
// 逆向可视化
|
||||
this.reverseVisualize(adPlans);
|
||||
this.saveBatch(adPlans);
|
||||
//todo 脚本、误差体系处理
|
||||
}
|
||||
|
||||
List<Map<String, Object>> sheetList = new ArrayList<>();
|
||||
sheetList.add(sheetMap1);
|
||||
DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictData.getCode())) {
|
||||
sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.ContrastExportData.class));
|
||||
} else {
|
||||
sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.SimulateAndDigitalExportData.class));
|
||||
/**
|
||||
* 可视化
|
||||
*
|
||||
* @param adPlans 检测计划列表
|
||||
*/
|
||||
private void visualize(List<AdPlan> adPlans) {
|
||||
adPlans.forEach(adPlan -> {
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
}
|
||||
}
|
||||
if (DevConst.FATHER_ID.equals(adPlan.getFatherPlanId())) {
|
||||
adPlan.setFatherPlanId("");
|
||||
} else {
|
||||
adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adPlan.getDatasourceId())) {
|
||||
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getMsgByValue(id)).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
}
|
||||
if (StrUtil.isNotBlank(adPlan.getScriptId())) {
|
||||
String[] scriptIds = adPlan.getScriptId().split(StrUtil.COMMA);
|
||||
adPlan.setScriptId(Arrays.stream(scriptIds).map(id -> pqScriptService.getPqScriptById(id).getName()).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
}
|
||||
if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
|
||||
adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return sheetList;
|
||||
/**
|
||||
* 逆向可视化
|
||||
*
|
||||
* @param adPlans 检测计划列表
|
||||
*/
|
||||
private void reverseVisualize(List<AdPlan> adPlans) {
|
||||
adPlans.forEach(adPlan -> {
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataByName(adPlan.getPattern()).getId());
|
||||
}
|
||||
// if (DevConst.FATHER_ID.equals(adPlan.getFatherPlanId())) {
|
||||
// adPlan.setFatherPlanId("");
|
||||
// } else {
|
||||
// adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getId());
|
||||
// }
|
||||
if (StrUtil.isNotBlank(adPlan.getDatasourceId())) {
|
||||
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getValueByMsg(id)).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
}
|
||||
// if (StrUtil.isNotBlank(adPlan.getScriptId())) {
|
||||
// adPlan.setScriptId(pqScriptService.getPqScriptById(adPlan.getScriptId()).getName());
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
|
||||
// adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName());
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,33 +297,4 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderBy(true, true, "Create_Time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测计划excel数据
|
||||
*
|
||||
* @param adPlans 检测计划列表
|
||||
* @return 检测计划excel数据
|
||||
*/
|
||||
private List<AdPlanExcel> getAdPlanExcelList(List<AdPlan> adPlans) {
|
||||
return adPlans.stream().map(adPlan -> {
|
||||
AdPlanExcel adPlanExcel = new AdPlanExcel();
|
||||
BeanUtil.copyProperties(adPlan, adPlanExcel);
|
||||
adPlanExcel.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String datasourceId : adPlan.getDatasourceId().split(StrUtil.COMMA)) {
|
||||
sb.append(DataSourceEnum.getMsgByValue(datasourceId)).append(StrUtil.COMMA);
|
||||
}
|
||||
adPlanExcel.setDatasource(sb.toString().substring(0, sb.length() - 1));
|
||||
adPlanExcel.setScript(pqScriptService.getPqScriptById(adPlan.getScriptId()).getName());
|
||||
|
||||
sb.delete(0, sb.length());
|
||||
|
||||
for (String errorSysId : adPlan.getErrorSysId().split(StrUtil.COMMA)) {
|
||||
sb.append(pqErrSysService.getPqErrSysById(errorSysId).getName()).append(StrUtil.COMMA);
|
||||
}
|
||||
adPlanExcel.setErrorSys(sb.toString().substring(0, sb.length() - 1));
|
||||
|
||||
return adPlanExcel;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.gather.device.plan.service.impl;
|
||||
package com.njcn.gather.plan.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.plan.mapper.AdPlanSourceMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanSourceMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -19,8 +19,8 @@ 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 com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -62,7 +62,7 @@ public class PqDevController extends BaseController {
|
||||
@GetMapping("/aaa")
|
||||
@ApiOperation("分页查询被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<List<PreDetection> > aaa() {
|
||||
public HttpResult<List<PreDetection>> aaa() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
List<PreDetection> devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
|
||||
@@ -147,8 +147,9 @@ public class PqDevController extends BaseController {
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<String> importPqDevData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importPqDevData");
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
@@ -164,7 +165,7 @@ public class PqDevController extends BaseController {
|
||||
} else {
|
||||
//批量录入数据
|
||||
List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
|
||||
pqDevService.importPqDevData(list);
|
||||
pqDevService.importContrastData(list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
@@ -181,12 +182,12 @@ public class PqDevController extends BaseController {
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictData.getCode())) {
|
||||
List<Map<String, Object>> sheetList = pqDevService.getContrastExportSheetList(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", sheetList);
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
List<PqDevExcel.ContrastExportData> data = pqDevService.getContrastExportData(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.ContrastExportData.class, data);
|
||||
} else {
|
||||
List<Map<String, Object>> sheetList = pqDevService.getSimOrDigitExportSheetList(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", sheetList);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> data = pqDevService.getSimulateOrDigitExportData(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.SimulateOrDigitalExportData.class, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,6 +214,21 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/bindDev")
|
||||
@ApiOperation("检测计划绑定设备")
|
||||
@ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
|
||||
public HttpResult<Object> bindDev(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
|
||||
String methodDescribe = getMethodDescribe("bindDev");
|
||||
LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
boolean result = pqDevService.bind(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @PostMapping("/listUnDocumentByPlanId")
|
||||
// @ApiOperation("根据检测计划id查询出所有已绑定(未归档)的设备")
|
||||
|
||||
@@ -114,18 +114,6 @@ public class PqDevParam {
|
||||
@ApiModelProperty("所属电站名称")
|
||||
private String subName;
|
||||
|
||||
// @ApiModelProperty("检测状态")
|
||||
// private Integer checkState;
|
||||
|
||||
// @ApiModelProperty("检测结果")
|
||||
// private Integer checkResult;
|
||||
|
||||
// @ApiModelProperty("报告状态")
|
||||
// private Integer reportState;
|
||||
|
||||
// @ApiModelProperty("归档状态")
|
||||
// private Integer documentState;
|
||||
|
||||
@ApiModelProperty("报告路径")
|
||||
private String reportPath;
|
||||
|
||||
@@ -170,7 +158,7 @@ public class PqDevParam {
|
||||
|
||||
@ApiModelProperty("报告状态")
|
||||
@Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
private Integer reportState;
|
||||
|
||||
@ApiModelProperty("归档状态")
|
||||
@@ -221,4 +209,16 @@ public class PqDevParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BindPlanParam {
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@NotNull(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.gather.device.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
@@ -13,6 +15,7 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -23,118 +26,126 @@ public class PqDevExcel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "名称", width = 20)
|
||||
@Excel(name = "名称", width = 20, needMerge = true)
|
||||
@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 = "1")
|
||||
@Excel(name = "设备模式", width = 20, orderNum = "1", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2")
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3")
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4")
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5")
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6")
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8")
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议", width = 15, orderNum = "11")
|
||||
@Excel(name = "通讯协议", width = 15, orderNum = "11", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址", width = 20, orderNum = "12")
|
||||
@Excel(name = "IP地址", width = 20, orderNum = "12", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号", orderNum = "13")
|
||||
@Excel(name = "端口号", orderNum = "13", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(0:否、1:是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
|
||||
@Excel(name = "是否为加密版本(0:否、1:是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码", width = 30, orderNum = "15")
|
||||
@Excel(name = "识别码", width = 30, orderNum = "15", needMerge = true)
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥", width = 30, orderNum = "16")
|
||||
@Excel(name = "秘钥", width = 30, orderNum = "16", needMerge = true)
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "所属地市名称", width = 20, orderNum = "19")
|
||||
@Excel(name = "所属地市名称", width = 20, orderNum = "19", needMerge = true)
|
||||
private String cityName;
|
||||
|
||||
@Excel(name = "所属供电公司名称", width = 20, orderNum = "20")
|
||||
@Excel(name = "所属供电公司名称", width = 20, orderNum = "20", needMerge = true)
|
||||
private String gdName;
|
||||
|
||||
@Excel(name = "所属电站名称", width = 20, orderNum = "21")
|
||||
@Excel(name = "所属电站名称", width = 20, orderNum = "21", needMerge = true)
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "26")
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22", needMerge = true)
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1", "/_2"}, orderNum = "23", needMerge = true)
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成、2:未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "24", needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25", needMerge = true)
|
||||
private Integer documentState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "26", needMerge = true)
|
||||
private String reportPath;
|
||||
|
||||
@Excel(name = "关键信息二维码", width = 20, orderNum = "27")
|
||||
@Excel(name = "关键信息二维码", width = 20, orderNum = "27", needMerge = true)
|
||||
private String qrCode;
|
||||
|
||||
@Excel(name = "检测次数", width = 15, orderNum = "28")
|
||||
@Excel(name = "检测次数", width = 15, orderNum = "28", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer reCheckNum;
|
||||
|
||||
/**
|
||||
* 模拟式和比对式设备数据
|
||||
*/
|
||||
// @Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
// @NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
// private LocalDate createDate;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SimulateAndDigitalExportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
public static class ExportData extends PqDevExcel {
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17")
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟式和比对式设备导出数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SimulateOrDigitalExportData extends ExportData {
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
|
||||
private LocalDate arrivedDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1", "/_2", "_null"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成)", width = 15, replace = {"未生成_0", "已生成_1", "_null"}, orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1", "_null"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,22 +153,37 @@ public class PqDevExcel implements Serializable {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastExportData extends PqDevExcel {
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
public static class ContrastExportData extends ExportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "29")
|
||||
List<PqMonitorExcel.ExportData> monitorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 被检设备导入数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
|
||||
private Integer checkState;
|
||||
}
|
||||
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1", "/_2", "_null"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
/**
|
||||
* 模拟式和比对式设备导入数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SimulateOrDigitalImportData extends ImportData {
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成)", width = 15, replace = {"未生成_0", "已生成_1", "_null"}, orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1", "_null"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
|
||||
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
private String arrivedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,27 +191,8 @@ public class PqDevExcel implements Serializable {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastImportData extends PqDevExcel {
|
||||
@Excel(name = "设备Id", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SERIES_REGEX, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22")
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1", "/_2"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成)", width = 15, replace = {"未生成_0", "已生成_1"}, orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
public static class ContrastImportData extends ImportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "29")
|
||||
List<PqMonitorExcel.ExportData> monitorList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
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 com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -61,6 +60,22 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
boolean deletePqDev(PqDevParam.DeleteParam param);
|
||||
|
||||
/**
|
||||
* 获取模拟式||数字式设备导出时所需的数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return
|
||||
*/
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出时所需的数据
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 比对式设备导出时所需的数据
|
||||
*/
|
||||
List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*/
|
||||
@@ -71,7 +86,14 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
void importPqDevData(List<PqDevExcel.ContrastImportData> sgEventExcels);
|
||||
void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 根据检测计划planIds获取被检设备设备导出时所需的SheetMap
|
||||
@@ -116,10 +138,11 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
/**
|
||||
* 绑定计划
|
||||
*
|
||||
* @param bindPlanParam 检测计划绑定被检设备参数
|
||||
* @param planId 计划id
|
||||
* @param devIds 设备id列表
|
||||
* @return 绑定成功返回true,否则返回false
|
||||
*/
|
||||
boolean bind(AdPlanParam.BindPlanParam bindPlanParam);
|
||||
boolean bind(String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 获取饼图数据
|
||||
@@ -146,6 +169,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
/**
|
||||
* 获取装置信息和装置下监测点信息
|
||||
*
|
||||
* @param devIds
|
||||
* @return: java.util.List<com.njcn.gather.device.device.pojo.vo.PreDetection>
|
||||
* @Author: wr
|
||||
|
||||
@@ -23,8 +23,6 @@ import com.njcn.gather.device.device.util.DeviceUtil;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
@@ -80,13 +78,13 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
// 新增时默认设置为未检验、未生成报告、未归档、未出检测结果
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
pqDev.setId(id);
|
||||
// 比对式设备添加监测点
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictDataService.getDictDataById(pqDevParam.getPattern()).getCode())) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(pqDevParam.getPattern()).getCode())) {
|
||||
if (ObjectUtil.isNotEmpty(pqDevParam.getMonitorList())) {
|
||||
pqMonitorService.addPqMonitorByDevId(id, pqDevParam.getMonitorList());
|
||||
}
|
||||
@@ -108,7 +106,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
// 比对式设备修改监测点
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
|
||||
if (ObjectUtil.isNotEmpty(updateParam.getMonitorList())) {
|
||||
pqMonitorService.updatePqMonitorByDevId(updateParam.getId(), updateParam.getMonitorList());
|
||||
}
|
||||
@@ -123,7 +121,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
@Override
|
||||
public boolean deletePqDev(PqDevParam.DeleteParam param) {
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictDataService.getDictDataById(param.getPattern()).getCode())) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(param.getPattern()).getCode())) {
|
||||
for (String id : param.getIds()) {
|
||||
if (ObjectUtils.isEmpty(pqMonitorService.listPqMonitorByDevId(id))) {
|
||||
throw new BusinessException(DevResponseEnum.PQ_DEV_HAS_MONITOR);
|
||||
@@ -134,30 +132,51 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
Map<String, Object> sheet1 = new HashMap<>();
|
||||
ExportParams exportParams1 = new ExportParams();
|
||||
exportParams1.setSheetName("被检设备");
|
||||
sheet1.put("title", exportParams1);
|
||||
sheet1.put("data", Collections.emptyList());
|
||||
sheet1.put("entity", PqDevExcel.ContrastImportData.class);
|
||||
|
||||
Map<String, Object> sheet2 = new HashMap<>();
|
||||
ExportParams exportParams2 = new ExportParams();
|
||||
exportParams2.setSheetName("监测点台账");
|
||||
sheet2.put("title", exportParams2);
|
||||
sheet2.put("data", Collections.emptyList());
|
||||
sheet2.put("entity", PqMonitorExcel.ImportData.class);
|
||||
|
||||
List<Map<String, Object>> sheetsList = new ArrayList<>();
|
||||
sheetsList.add(sheet1);
|
||||
sheetsList.add(sheet2);
|
||||
|
||||
ExcelUtil.exportExcel("被检设备模板.xlsx", sheetsList);
|
||||
public List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotNull(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importPqDevData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
public List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotNull(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
|
||||
for (int i = 0; i < pqDevs.size(); i++) {
|
||||
List<PqMonitorExcel.ExportData> monitorExportList = BeanUtil.copyToList(pqMonitorService.listPqMonitorByDevId(pqDevs.get(i).getId()), PqMonitorExcel.ExportData.class);
|
||||
monitorExportList.forEach(monitor -> {
|
||||
monitor.setPtType(dictDataService.getDictDataById(monitor.getPtType()).getName());
|
||||
});
|
||||
pqDevExcels.get(i).setMonitorList(monitorExportList);
|
||||
}
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("被检设备模板.xlsx", PqDevExcel.ContrastImportData.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importContrastData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualize(pqDevList);
|
||||
this.saveBatch(pqDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualize(pqDevList);
|
||||
@@ -178,7 +197,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
exportParams.setSheetName("被检设备");
|
||||
sheetMap.put("title", exportParams);
|
||||
sheetMap.put("data", pqDevExcels);
|
||||
sheetMap.put("entity", PqDevExcel.ContrastExportData.class);
|
||||
sheetMap.put("entity", clazz);
|
||||
|
||||
return sheetMap;
|
||||
}
|
||||
@@ -187,14 +206,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public List<Map<String, Object>> getSimOrDigitExportSheetList(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.SimulateAndDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateAndDigitalExportData.class);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
|
||||
Map<String, Object> sheetMap = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("被检设备");
|
||||
sheetMap.put("title", exportParams);
|
||||
sheetMap.put("data", pqDevExcels);
|
||||
sheetMap.put("entity", PqDevExcel.SimulateAndDigitalExportData.class);
|
||||
sheetMap.put("entity", PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
return Collections.singletonList(sheetMap);
|
||||
}
|
||||
|
||||
@@ -249,18 +268,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return pqDevList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean bind(AdPlanParam.BindPlanParam bindPlanParam) {
|
||||
String planId = bindPlanParam.getPlanId();
|
||||
List<String> pqDevIds = bindPlanParam.getPqDevIds();
|
||||
|
||||
public boolean bind(String planId, List<String> devIds) {
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(planId);
|
||||
List<String> existedBoundPqDevIds = this.listByPlanId(queryParam).stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
|
||||
//共有的(交集)
|
||||
List<String> intersection = existedBoundPqDevIds.stream().filter(pqDevIds::contains).collect(Collectors.toList());
|
||||
List<String> intersection = existedBoundPqDevIds.stream().filter(devIds::contains).collect(Collectors.toList());
|
||||
|
||||
//移除 已有的历史绑定而此次不绑定的
|
||||
existedBoundPqDevIds.removeAll(intersection);
|
||||
@@ -269,9 +284,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
//绑定 没有的历史绑定而此次绑定的
|
||||
pqDevIds.removeAll(existedBoundPqDevIds);
|
||||
if (ObjectUtils.isNotEmpty(pqDevIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, pqDevIds).update();
|
||||
devIds.removeAll(existedBoundPqDevIds);
|
||||
if (ObjectUtils.isNotEmpty(devIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, devIds).update();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -340,6 +355,15 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.baseMapper.selectDevInfo(devIds);
|
||||
}
|
||||
|
||||
// private <T> List<T> getExportData(PqDevParam.QueryParam queryParam, Class<T> clazz) {
|
||||
// List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
// this.visualize(pqDevs);
|
||||
// List<T> pqDevExcels = BeanUtil.copyToList(pqDevs, clazz);
|
||||
//
|
||||
//
|
||||
// return pqDevExcels;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
@@ -433,7 +457,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
if (ObjectUtil.isNotNull(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
pqDev.setPattern(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||
|
||||
@@ -21,10 +21,6 @@ public class PqMonitorExcel {
|
||||
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
// @Excel(name = "监测点序号", width = 20)
|
||||
// @NotBlank(message = DevValidMessage.MONITOR_NUM_NOT_BLANK)
|
||||
// private Integer num;
|
||||
|
||||
@Excel(name = "PT变比", width = 20, orderNum = "4")
|
||||
@NotNull(message = DevValidMessage.PT_NOT_NULL)
|
||||
private Float pt;
|
||||
@@ -41,22 +37,14 @@ public class PqMonitorExcel {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ImportData extends PqMonitorExcel {
|
||||
@Excel(name = "所属设备Id", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.DEV_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_ID_FORMAT_ERROR)
|
||||
private String devId;
|
||||
|
||||
@Excel(name = "监测点编号", width = 20, isImportField = "true", orderNum = "1")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_CODE_FORMAT_ERROR)
|
||||
private String code;
|
||||
@Excel(name = "监测点序号", width = 20)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_NUM_FORMAT_ERROR)
|
||||
private Integer num;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ExportData extends PqMonitorExcel {
|
||||
@Excel(name = "所属设备名称", width = 20)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String devName;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
int finalI = i;
|
||||
exportData.forEach(data -> {
|
||||
// 给监测点台账添加设备名称
|
||||
data.setDevName(devList.get(finalI).getName());
|
||||
// data.setDevName(devList.get(finalI).getName());
|
||||
data.setPtType(dictDataService.getDictDataById(data.getPtType()).getName());
|
||||
});
|
||||
pqMonitorExcels.addAll(exportData);
|
||||
|
||||
@@ -9,19 +9,4 @@ public interface DevConst {
|
||||
* 顶层父节点ID
|
||||
*/
|
||||
String FATHER_ID = "0";
|
||||
|
||||
/**
|
||||
* 模拟式
|
||||
*/
|
||||
String PATTERN_SIMULATE = "Simulate";
|
||||
|
||||
/**
|
||||
* 数字式
|
||||
*/
|
||||
String PATTERN_DIGITAL = "Digital";
|
||||
|
||||
/**
|
||||
* 对比式
|
||||
*/
|
||||
String PATTERN_CONTRAST = "Contrast";
|
||||
}
|
||||
|
||||
@@ -185,4 +185,6 @@ public interface DevValidMessage {
|
||||
String MONITOR_NUM_NOT_NULL = "监测点序号不能为空";
|
||||
|
||||
String FACTOR_FLAG_FORMAT_ERROR = "是否支持系数校准格式错误";
|
||||
|
||||
String MONITOR_NUM_FORMAT_ERROR = "监测点序号格式错误";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import lombok.Getter;
|
||||
public enum CheckResultEnum {
|
||||
NOT_ACCORD("不符合", 0),
|
||||
ACCORD("符合", 1),
|
||||
UNKNOWN("/", 2);
|
||||
UNCHECKED("未检", 2);
|
||||
|
||||
private final Integer value;
|
||||
private final String msg;
|
||||
|
||||
@@ -8,8 +8,9 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum DevReportStateEnum {
|
||||
REPORT_STATE_NOT_GENERATED("未生成", 0),
|
||||
REPORT_STATE_GENERATED("已生成", 1);
|
||||
NOT_GENERATED("未生成", 0),
|
||||
GENERATED("已生成", 1),
|
||||
UNCHECKED("未检", 2);
|
||||
|
||||
private final Integer value;
|
||||
private final String msg;
|
||||
|
||||
@@ -14,7 +14,10 @@ public enum DevResponseEnum {
|
||||
PLAN_HAS_DEVICE_BIND("A001006", "检测计划下已绑定设备,请先解绑设备"),
|
||||
PQ_DEV_REPEAT("A001007", "重复的被检设备"),
|
||||
PQ_DEV_HAS_MONITOR("A001008", "该设备下关联有监测点,请先移除监测点"),
|
||||
HAS_NOT_UNCHECKED_DEVICE("A001009", "设备在检测中或已被检测过,请勿解除绑定"),;
|
||||
HAS_NOT_UNCHECKED_DEVICE("A001009", "设备在检测中或已被检测过,请勿解除绑定"),
|
||||
IMPORT_PLAN_DATA_FAIL("A001010", "导入的检测计划为空"),
|
||||
IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"),
|
||||
;
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum PatternEnum {
|
||||
SIMULATE("Simulate", "模拟式"),
|
||||
DIGITAL("Digital", "数字式"),
|
||||
CONTRAST("Contrast", "比对式");
|
||||
|
||||
private String value;
|
||||
private String msg;
|
||||
|
||||
PatternEnum(String value, String msg) {
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -119,14 +118,11 @@ public class PqSourceController extends BaseController {
|
||||
@OperateInfo
|
||||
@GetMapping("/getSourceParam")
|
||||
@ApiOperation("按照检测源ID、源参数Type、获取源参数")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true),
|
||||
@ApiImplicitParam(name = "paramType", value = "源参数Type", required = true)
|
||||
})
|
||||
public HttpResult<List<SourceParam>> getSourceParam(@RequestParam("pqSourceId") String pqSourceId, @RequestParam("paramType") String paramType) {
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true)
|
||||
public HttpResult<List<SourceParam>> getSourceParam(@RequestParam("pqSourceId") String pqSourceId) {
|
||||
String methodDescribe = getMethodDescribe("getParam");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, pqSourceId + " " + paramType);
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(pqSourceId, paramType);
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, pqSourceId);
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(pqSourceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ public class SourceParam {
|
||||
|
||||
private String pId;
|
||||
|
||||
private String sourceParamType;
|
||||
private String type;
|
||||
|
||||
private String sourceParamDesc;
|
||||
private String desc;
|
||||
|
||||
private String sourceParamValue;
|
||||
private String value;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@@ -67,8 +67,7 @@ public interface IPqSourceService extends IService<PqSource> {
|
||||
* 获取指定检测源的指定参数
|
||||
*
|
||||
* @param pqSourceId 检测源Id
|
||||
* @param paramType 参数类型
|
||||
* @return 源参数
|
||||
*/
|
||||
List<SourceParam> getSourceParam(String pqSourceId, String paramType);
|
||||
List<SourceParam> getSourceParam(String pqSourceId);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -96,7 +95,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceParam> getSourceParam(String pqSourceId, String paramType) {
|
||||
public List<SourceParam> getSourceParam(String pqSourceId) {
|
||||
PqSource pqSource = this.lambdaQuery().eq(PqSource::getId, pqSourceId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (ObjectUtil.isNotNull(pqSource)) {
|
||||
String parameter = pqSource.getParameter();
|
||||
@@ -106,7 +105,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
.peek(p -> p.setChildren(getChildren(p, list)))
|
||||
.sorted(Comparator.comparingInt(SourceParam::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return filterTree(sourceParams, paramType);
|
||||
return sourceParams;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -120,33 +119,33 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<SourceParam> filterTree(List<SourceParam> tree, String keyword) {
|
||||
if (CollectionUtils.isEmpty(tree) || StrUtil.isBlank(keyword)) {
|
||||
return tree;
|
||||
}
|
||||
filter(tree, keyword);
|
||||
return tree;
|
||||
}
|
||||
// private List<SourceParam> filterTree(List<SourceParam> tree, String keyword) {
|
||||
// if (CollectionUtils.isEmpty(tree) || StrUtil.isBlank(keyword)) {
|
||||
// return tree;
|
||||
// }
|
||||
// filter(tree, keyword);
|
||||
// return tree;
|
||||
// }
|
||||
|
||||
private void filter(List<SourceParam> list, String keyword) {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
SourceParam sourceParam = list.get(i);
|
||||
List<SourceParam> children = sourceParam.getChildren();
|
||||
if (!keyword.equals(sourceParam.getSourceParamType())) {
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
filter(children, keyword);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(sourceParam.getChildren())) {
|
||||
list.remove(i);
|
||||
}
|
||||
}
|
||||
// private void filter(List<SourceParam> list, String keyword) {
|
||||
// for (int i = list.size() - 1; i >= 0; i--) {
|
||||
// SourceParam sourceParam = list.get(i);
|
||||
// List<SourceParam> children = sourceParam.getChildren();
|
||||
// if (!keyword.equals(sourceParam.getType())) {
|
||||
// if (!CollectionUtils.isEmpty(children)) {
|
||||
// filter(children, keyword);
|
||||
// }
|
||||
// if (CollectionUtils.isEmpty(sourceParam.getChildren())) {
|
||||
// list.remove(i);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (!CollectionUtils.isEmpty(children)) {
|
||||
// filter(children, keyword);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user