diff --git a/pqs-auth/Dockerfile b/pqs-auth/Dockerfile index c813b0a62..5ef77123e 100644 --- a/pqs-auth/Dockerfile +++ b/pqs-auth/Dockerfile @@ -1,4 +1,6 @@ FROM openjdk:8-jdk-alpine +#作者MAINTAINER Wu Jize #指定阿里镜象 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN set -xe \&& apk --no-cache add ttf-dejavu fontconfig ADD target/auth.jar auth.jar ENTRYPOINT ["java","-jar","/auth.jar"] diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/service/ILogService.java b/pqs-common/common-web/src/main/java/com/njcn/web/service/ILogService.java index b797083ca..bde4aedf2 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/service/ILogService.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/service/ILogService.java @@ -20,7 +20,6 @@ public interface ILogService { * @param request 请求头 * @param returnType 返回类型 * @param httpResult 返回结果 - * @param userName 用户名 * @param methodDescribe 方法描述 */ void recodeAdviceLog(ServerHttpRequest request, MethodParameter returnType, HttpResult httpResult, String methodDescribe); diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/enums/DeviceResponseEnum.java b/pqs-device/device-api/src/main/java/com/njcn/device/enums/DeviceResponseEnum.java index 2e8bd9824..2409dbc1d 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/enums/DeviceResponseEnum.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/enums/DeviceResponseEnum.java @@ -72,9 +72,9 @@ public enum DeviceResponseEnum { FLOW_SAME_NAME("A0350","当前名称已存在"), FLOW_FLAG("A0351","默认类型已存在"), - FLOW_ERROR("A0352","占比参数异常") - + FLOW_ERROR("A0352","占比参数异常"), + IMPORT_ORACLE_EXCEPTION("A0353","导入旧库台账异常") diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/bo/excel/OracleTerminalExcel.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/bo/excel/OracleTerminalExcel.java index e263d49dd..8c24d5ea4 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/bo/excel/OracleTerminalExcel.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/bo/excel/OracleTerminalExcel.java @@ -57,6 +57,10 @@ public class OracleTerminalExcel implements Serializable { @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = "设备名称违规") private String deviceName; + @Excel(name = "终端索引") + @NotNull(message = "终端索引不能为空") + private Integer deviceId; + @Excel(name = "终端模型", replace = {"虚拟设备_0", "实际设备_1", "离线设备_2"}, width = 15) @NotNull(message = "设备模型不能为空") private Integer devModel; diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/DeviceBak.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/DeviceBak.java new file mode 100644 index 000000000..8ef008d8c --- /dev/null +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/DeviceBak.java @@ -0,0 +1,26 @@ +package com.njcn.device.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + */ +@Data +@TableName("pq_device_bak") +public class DeviceBak { + + private static final long serialVersionUID = 1L; + + /** + * 终端Id + */ + private String id; + + + /** + * 原始终端Id + */ + private Integer devId; + + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/TerminalBaseController.java b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/TerminalBaseController.java index 55688e3d7..d2236aeb8 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/TerminalBaseController.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/TerminalBaseController.java @@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -55,7 +56,6 @@ public class TerminalBaseController extends BaseController { private final TerminalBaseService terminalBaseService; - /** * 终端新增操作 * @@ -188,6 +188,7 @@ public class TerminalBaseController extends BaseController { /** * 根据设备id集获取设备集信息 + * * @param list 设备集合 * @author cdf * @date 2022/6/29 @@ -198,7 +199,7 @@ public class TerminalBaseController extends BaseController { public HttpResult> getDevInfoByIds(@RequestBody List list) { String methodDescribe = getMethodDescribe("getDevInfoByIds"); LogUtil.njcnDebug(log, "{},设备集合为:{}", methodDescribe, list); - List devList = terminalBaseService.getDeviceByIdOnOrOff(list,new DeviceType(),0); + List devList = terminalBaseService.getDeviceByIdOnOrOff(list, new DeviceType(), 0); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devList, methodDescribe); } @@ -213,37 +214,41 @@ public class TerminalBaseController extends BaseController { @PostMapping(value = "importOracleTerminalData") public HttpResult importOracleTerminalData(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { String methodDescribe = getMethodDescribe("importOracleTerminalData"); - terminalBaseService.importOracleTerminalData(file,response); + if (Objects.isNull(terminalBaseService.importOracleTerminalData(file, response))) { + return null; + } return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } /** * 导出台账 + * * @author cdf * @date 2022/5/17 */ @ResponseBody @ApiOperation("导出台账信息") @GetMapping(value = "exportTerminalBase") - public HttpResult exportTerminalBase(HttpServletResponse response){ + public HttpResult exportTerminalBase(HttpServletResponse response) { String methodDescribe = getMethodDescribe("exportTerminalBase"); String fileName = "台账信息.xls"; List baseExcelList = null; try { baseExcelList = terminalBaseService.exportTerminalBase(); - }catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); } - ExportParams exportExcel = new ExportParams("批量导入模板(请严格按照模板标准填入数据)","台账信息"); - Workbook workbook = ExcelExportUtil.exportExcel(exportExcel,TerminalBaseExcel.class, baseExcelList); - PoiUtil.exportFileByWorkbook(workbook,fileName,response); + ExportParams exportExcel = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "台账信息"); + Workbook workbook = ExcelExportUtil.exportExcel(exportExcel, TerminalBaseExcel.class, baseExcelList); + PoiUtil.exportFileByWorkbook(workbook, fileName, response); return null; } /** * 导出台账生成的excel + * * @author cdf * @date 2022/5/17 */ @@ -255,6 +260,7 @@ public class TerminalBaseController extends BaseController { /** * 导入excel台账模板 + * * @author cdf * @date 2022/5/18 */ @@ -263,7 +269,7 @@ public class TerminalBaseController extends BaseController { @PostMapping(value = "importTerminalBase") public HttpResult importTerminalBase(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { String methodDescribe = getMethodDescribe("importTerminalBase"); - terminalBaseService.importTerminalBase(file,response); + terminalBaseService.importTerminalBase(file, response); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceBakMapper.java b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceBakMapper.java new file mode 100644 index 000000000..1ae65141a --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/DeviceBakMapper.java @@ -0,0 +1,19 @@ +package com.njcn.device.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.device.pojo.po.DeviceBak; + +/** + *

+ * Mapper 接口 + *

+ * + * @author cdf + * @since 2022-01-04 + */ +public interface DeviceBakMapper extends BaseMapper { + + + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/DeviceBakMapper.xml b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/DeviceBakMapper.xml new file mode 100644 index 000000000..f48127db4 --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/DeviceBakMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/DeviceBakService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/DeviceBakService.java new file mode 100644 index 000000000..548a600f8 --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/DeviceBakService.java @@ -0,0 +1,15 @@ +package com.njcn.device.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.device.pojo.po.DeviceBak; + +/** + * 监测点类 + * @author denghuajun + * @date 2022/2/23 + * + */ +public interface DeviceBakService extends IService { + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/TerminalBaseService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/TerminalBaseService.java index 0716dd756..a65d7626c 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/TerminalBaseService.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/TerminalBaseService.java @@ -164,7 +164,7 @@ public interface TerminalBaseService { * 将原始数据导入新库 * @param file 原始数据信息 */ - void importOracleTerminalData(MultipartFile file, HttpServletResponse response); + String importOracleTerminalData(MultipartFile file, HttpServletResponse response); /** * 导出台账 diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/DeviceBakServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/DeviceBakServiceImpl.java new file mode 100644 index 000000000..d7f16a0ef --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/DeviceBakServiceImpl.java @@ -0,0 +1,24 @@ +package com.njcn.device.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.device.mapper.DeviceBakMapper; +import com.njcn.device.pojo.po.DeviceBak; +import com.njcn.device.service.DeviceBakService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + + +/** + * + * @author denghuajun + * @date 2022/2/23 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class DeviceBakServiceImpl extends ServiceImpl implements DeviceBakService { + + + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/TerminalBaseServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/TerminalBaseServiceImpl.java index f17915ea6..3866cb2b9 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/TerminalBaseServiceImpl.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/TerminalBaseServiceImpl.java @@ -30,6 +30,7 @@ import com.njcn.device.pojo.bo.excel.TerminalBaseExcel; import com.njcn.device.pojo.param.*; import com.njcn.device.pojo.po.*; import com.njcn.device.pojo.vo.*; +import com.njcn.device.service.DeviceBakService; import com.njcn.device.service.INodeService; import com.njcn.device.service.LineBakService; import com.njcn.device.service.TerminalBaseService; @@ -97,6 +98,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple private final LineBakService lineBakService; + private final DeviceBakService deviceBakService; + /** * 终端新增操作 * @@ -311,18 +314,18 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple List voltageName = deviceParam.getSubVoltageParam().stream().filter(item -> StrUtil.isBlank(item.getSubvIndex())).map(SubVoltageParam::getName).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(voltageName)) { List voltageList = this.baseMapper.getVoltageListBySubId(subIndex, voltageName); - if(CollectionUtil.isNotEmpty(voltageList)){ + if (CollectionUtil.isNotEmpty(voltageList)) { throw new BusinessException(DeviceResponseEnum.SUBV_NAME_SAME, String.join(";", voltageList.stream().map(Line::getName).collect(Collectors.toList()))); } } //校验同一变电站下只能有唯一母线名称 - List addVoltage = deviceParam.getSubVoltageParam().stream().filter(item->item.getSubvIndex() == null).map(SubVoltageParam::getName).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(addVoltage)) { + List addVoltage = deviceParam.getSubVoltageParam().stream().filter(item -> item.getSubvIndex() == null).map(SubVoltageParam::getName).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(addVoltage)) { List voltageListBySubId = this.baseMapper.getVoltageListBySubId(subIndex, addVoltage); - if(CollectionUtil.isNotEmpty(voltageListBySubId)){ - throw new BusinessException(DeviceResponseEnum.SUBV_NAME_SAME, String.join(";",voltageListBySubId.stream().map(Line::getName).collect(Collectors.toList()))); + if (CollectionUtil.isNotEmpty(voltageListBySubId)) { + throw new BusinessException(DeviceResponseEnum.SUBV_NAME_SAME, String.join(";", voltageListBySubId.stream().map(Line::getName).collect(Collectors.toList()))); } } @@ -333,7 +336,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple if (StrUtil.isBlank(subVoltageParam.getSubvIndex()) && StrUtil.isNotBlank(devIdIndex)) { - DictData scaleRes = dicDataFeignClient.getDicDataById(subVoltageParam.getScale()).getData(); if (Objects.isNull(scaleRes)) { throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY); @@ -1360,7 +1362,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple @Override @Transactional(rollbackFor = Exception.class) - public void importOracleTerminalData(MultipartFile file, HttpServletResponse response) { + public String importOracleTerminalData(MultipartFile file, HttpServletResponse response) { ImportParams params = new ImportParams(); params.setHeadRows(1); params.setTitleRows(1); @@ -1379,15 +1381,16 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple //如果存在非法数据,将不合格的数据导出 if (terminalExcelExcelImportResult.isVerifyFail()) { PoiUtil.exportFileByWorkbook(terminalExcelExcelImportResult.getFailWorkbook(), "非法台账信息.xlsx", response); + } else { + //执行前置机信息导入 + nodeService.saveBatchNodeInfo(nodeExcelExcelImportResult.getList()); + //执行台账信息导入(不考虑,存在监测点却不存在限值信息) + return saveTerminalInfo(terminalExcelExcelImportResult.getList(), overLimitExcelExcelImportResult.getList()); } - //执行前置机信息导入 - nodeService.saveBatchNodeInfo(nodeExcelExcelImportResult.getList()); - //执行台账信息导入(不考虑,存在监测点却不存在限值信息) - saveTerminalInfo(terminalExcelExcelImportResult.getList(), overLimitExcelExcelImportResult.getList()); } catch (Exception e) { - e.printStackTrace(); + throw new BusinessException(DeviceResponseEnum.IMPORT_ORACLE_EXCEPTION); } - + return null; } @Override @@ -1457,7 +1460,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple } } - private void saveTerminalInfo(List oracleTerminalExcels, List overLimitExcels) { + private String saveTerminalInfo(List oracleTerminalExcels, List overLimitExcels) { List oracleTerminalExcelMsg = new ArrayList<>(); //任意集合数据为空,不处理 if (CollectionUtil.isNotEmpty(oracleTerminalExcels) && CollectionUtil.isNotEmpty(overLimitExcels)) { @@ -1599,6 +1602,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple } device.setDevType(devTypeDicData.getId()); deviceMapper.insert(device); + //插入新旧终端ID中间表 + DeviceBak deviceBak = new DeviceBak(); + deviceBak.setId(temp.getId()); + deviceBak.setDevId(oracleTerminalExcel.getDeviceId()); + deviceBakService.saveOrUpdate(deviceBak); } //添加终端索引 pids.add(temp.getId()); @@ -1725,7 +1733,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl imple //错误信息不为空,则以excel的形式输出到前台 if (CollectionUtil.isNotEmpty(oracleTerminalExcelMsg)) { ExcelUtil.exportExcel("失败列表.xlsx", OracleTerminalExcel.OracleTerminalExcelMsg.class, oracleTerminalExcelMsg); + return null; } + return CommonResponseEnum.SUCCESS.getMessage(); } diff --git a/pqs-gateway/src/main/java/com/njcn/gateway/security/AuthorizationManager.java b/pqs-gateway/src/main/java/com/njcn/gateway/security/AuthorizationManager.java index da4fa61b1..2964288ae 100644 --- a/pqs-gateway/src/main/java/com/njcn/gateway/security/AuthorizationManager.java +++ b/pqs-gateway/src/main/java/com/njcn/gateway/security/AuthorizationManager.java @@ -37,6 +37,7 @@ public class AuthorizationManager implements ReactiveAuthorizationManager