检测计划导出、导入功能调整
This commit is contained in:
@@ -35,6 +35,7 @@ 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.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -237,8 +238,11 @@ public class PqDevController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/importCNDev")
|
||||
@ApiOperation("批量导入设备数据")
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file, String patternId, HttpServletResponse response) {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file,@RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
@@ -269,7 +273,7 @@ public class PqDevController extends BaseController {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId);
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId, null);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface DevValidMessage {
|
||||
|
||||
String PATTERN_NOT_BLANK = "模式不能为空,请检查pattern参数";
|
||||
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空,请检查devType参数";
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空";
|
||||
|
||||
String DEV_CHNS_NOT_NULL = "设备通道系数不能为空,请检查devChns参数";
|
||||
|
||||
@@ -205,4 +205,7 @@ public interface DevValidMessage {
|
||||
String CONDITION_TYPE_FORMAT_ERROR = "判断条件类型格式错误,请检查conditionType参数";
|
||||
|
||||
String SORT_NOT_NULL = "排序不能为空";
|
||||
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
|
||||
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
|
||||
String CREATEID_NOT_BLANK = "设备序列号不能为空";
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import javax.validation.constraints.Pattern;
|
||||
public class CNDevExcel {
|
||||
|
||||
@Excel(name = "预投计划*", width = 20, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.PREINVESTMENT_PLAN_NOT_BLANK)
|
||||
private String preinvestmentPlan;
|
||||
|
||||
@Excel(name = "设备编号(开始编号-结束编号,编号为数字)*", width = 50, orderNum = "2")
|
||||
|
||||
@@ -206,8 +206,9 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*
|
||||
* @param cnDevExcelList 灿能二楼设备数据列表
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId);
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 根据计划id列表获取设备列表
|
||||
@@ -216,4 +217,19 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @return
|
||||
*/
|
||||
List<PqDev> listByPlanIds(List<String> planIds);
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
void visualizeCNDev(List<PqDev> pqDevs);
|
||||
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs 设备列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId);
|
||||
}
|
||||
|
||||
@@ -452,9 +452,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getName());
|
||||
pqDev.setDevType(devType.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
@@ -673,35 +673,25 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadCNDevTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId) {
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId,String planId) {
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeCNDev(oldDevList);
|
||||
this.reverseVisualizeCNDev(oldDevList, patternId);
|
||||
|
||||
List<PqDev> newDevList = new ArrayList<>();
|
||||
PqDevParam param = new PqDevParam.UpdateParam();
|
||||
oldDevList.forEach(pqDev -> {
|
||||
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
pqDev.setPlanId(planId);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
@@ -728,6 +718,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
dev.setPlanId(planId);
|
||||
|
||||
param.setName(dev.getName());
|
||||
param.setCreateId(dev.getName());
|
||||
@@ -765,6 +756,35 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.lambdaQuery().in(PqDev::getPlanId, planIds).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
public void visualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
}
|
||||
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
// pqDev.setIcdId(devType.getIcd());
|
||||
// pqDev.setDevVolt(devType.getDevVolt());
|
||||
// pqDev.setDevCurr(devType.getDevCurr());
|
||||
// pqDev.setDevChns(devType.getDevChns());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
@@ -900,35 +920,4 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
private void visualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
// pqDev.setIcdId(devType.getIcd());
|
||||
// pqDev.setDevVolt(devType.getDevVolt());
|
||||
// pqDev.setDevCurr(devType.getDevCurr());
|
||||
// pqDev.setDevChns(devType.getDevChns());
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user