同步暂降模块代码
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
FROM openjdk:8-jdk-alpine
|
||||
#作者MAINTAINER Wu Jize <wujize188@163.com>#指定阿里镜象
|
||||
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"]
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -72,9 +72,9 @@ public enum DeviceResponseEnum {
|
||||
|
||||
FLOW_SAME_NAME("A0350","当前名称已存在"),
|
||||
FLOW_FLAG("A0351","默认类型已存在"),
|
||||
FLOW_ERROR("A0352","占比参数异常")
|
||||
|
||||
FLOW_ERROR("A0352","占比参数异常"),
|
||||
|
||||
IMPORT_ORACLE_EXCEPTION("A0353","导入旧库台账异常")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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<List<TerminalBaseVO>> getDevInfoByIds(@RequestBody List<String> list) {
|
||||
String methodDescribe = getMethodDescribe("getDevInfoByIds");
|
||||
LogUtil.njcnDebug(log, "{},设备集合为:{}", methodDescribe, list);
|
||||
List<TerminalBaseVO> devList = terminalBaseService.getDeviceByIdOnOrOff(list,new DeviceType(),0);
|
||||
List<TerminalBaseVO> 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<String> 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<String> exportTerminalBase(HttpServletResponse response){
|
||||
public HttpResult<String> exportTerminalBase(HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("exportTerminalBase");
|
||||
String fileName = "台账信息.xls";
|
||||
List<TerminalBaseExcel> 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<String> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.device.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pojo.po.DeviceBak;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2022-01-04
|
||||
*/
|
||||
public interface DeviceBakMapper extends BaseMapper<DeviceBak> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +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.device.mapper.DeviceBakMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -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<DeviceBak> {
|
||||
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public interface TerminalBaseService {
|
||||
* 将原始数据导入新库
|
||||
* @param file 原始数据信息
|
||||
*/
|
||||
void importOracleTerminalData(MultipartFile file, HttpServletResponse response);
|
||||
String importOracleTerminalData(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导出台账
|
||||
|
||||
@@ -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<DeviceBakMapper, DeviceBak> implements DeviceBakService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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<LineMapper, Line> imple
|
||||
|
||||
private final LineBakService lineBakService;
|
||||
|
||||
private final DeviceBakService deviceBakService;
|
||||
|
||||
/**
|
||||
* 终端新增操作
|
||||
*
|
||||
@@ -311,18 +314,18 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
List<String> voltageName = deviceParam.getSubVoltageParam().stream().filter(item -> StrUtil.isBlank(item.getSubvIndex())).map(SubVoltageParam::getName).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(voltageName)) {
|
||||
List<Line> 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<String> addVoltage = deviceParam.getSubVoltageParam().stream().filter(item->item.getSubvIndex() == null).map(SubVoltageParam::getName).collect(Collectors.toList());
|
||||
if(CollectionUtil.isNotEmpty(addVoltage)) {
|
||||
List<String> addVoltage = deviceParam.getSubVoltageParam().stream().filter(item -> item.getSubvIndex() == null).map(SubVoltageParam::getName).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(addVoltage)) {
|
||||
List<Line> 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<LineMapper, Line> 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<LineMapper, Line> 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<LineMapper, Line> 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<LineMapper, Line> imple
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTerminalInfo(List<OracleTerminalExcel> oracleTerminalExcels, List<OverLimitExcel> overLimitExcels) {
|
||||
private String saveTerminalInfo(List<OracleTerminalExcel> oracleTerminalExcels, List<OverLimitExcel> overLimitExcels) {
|
||||
List<OracleTerminalExcel.OracleTerminalExcelMsg> oracleTerminalExcelMsg = new ArrayList<>();
|
||||
//任意集合数据为空,不处理
|
||||
if (CollectionUtil.isNotEmpty(oracleTerminalExcels) && CollectionUtil.isNotEmpty(overLimitExcels)) {
|
||||
@@ -1599,6 +1602,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> 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<LineMapper, Line> imple
|
||||
//错误信息不为空,则以excel的形式输出到前台
|
||||
if (CollectionUtil.isNotEmpty(oracleTerminalExcelMsg)) {
|
||||
ExcelUtil.exportExcel("失败列表.xlsx", OracleTerminalExcel.OracleTerminalExcelMsg.class, oracleTerminalExcelMsg);
|
||||
return null;
|
||||
}
|
||||
return CommonResponseEnum.SUCCESS.getMessage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
|
||||
//不追究请求方式,如果需追求,需要在数据库中添加请求方式的字段request.getMethodValue()
|
||||
String restPath = request.getURI().getPath();
|
||||
log.info("请求路径:{}", restPath);
|
||||
log.error("测试error" + System.currentTimeMillis());
|
||||
// 对应跨域的预检请求直接放行
|
||||
// if (request.getMethod() == HttpMethod.OPTIONS) {
|
||||
// return Mono.just(new AuthorizationDecision(true));
|
||||
|
||||
Reference in New Issue
Block a user