zbj//1.终端修改操作修改监测点信息写入日志
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.njcn.device.pq.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pqs_terminal_logs")
|
||||
public class PqsTerminalLogs extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 终端运维日志Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置或监测点Id
|
||||
*/
|
||||
private String objIndex;
|
||||
|
||||
/**
|
||||
* 运维日志类型Id
|
||||
*/
|
||||
private String terminalType;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String terminalDescribe;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 状态 0-删除;1-正常;默认正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
public interface PqsTerminalLogsMapper extends BaseMapper<PqsTerminalLogs> {
|
||||
|
||||
void InsertLog(PqsTerminalLogs terminalLogsNew);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zbj
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
public interface UserMapper {
|
||||
Map<String, Object> getUser(@Param("userId") String userId);
|
||||
Map<String,Object> getPointSuper(@Param("id") String id);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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.pq.mapper.PqsTerminalLogsMapper">
|
||||
|
||||
<insert id="InsertLog">
|
||||
INSERT INTO pqs_terminal_logs(`Obj_Index`,
|
||||
`Terminal_Type`,
|
||||
`Terminal_Describe`,
|
||||
`Create_Time`,
|
||||
`Create_By`,
|
||||
`State`)
|
||||
VALUES (#{objIndex},
|
||||
(SELECT Id
|
||||
FROM `sys_dict_data`
|
||||
WHERE `Code` = 'Line_Parameter'),
|
||||
#{terminalDescribe},
|
||||
now(),
|
||||
#{createBy},
|
||||
1
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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.pq.mapper.UserMapper">
|
||||
|
||||
<select id="getUser" resultType="java.util.Map">
|
||||
SELECT `Name` as "name",Login_Name as "loginName"
|
||||
FROM `sys_user` where id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getPointSuper" resultType="java.util.Map">
|
||||
SELECT pl.`Name` AS "mName",
|
||||
pl1.`Name` AS "pName",
|
||||
pl2.`Name` AS "devName",
|
||||
pl3.`Name` AS "subName",
|
||||
pl4.`Name` AS "urbanName"
|
||||
FROM pq_line pl
|
||||
LEFT JOIN pq_line pl1 ON pl.Pid = pl1.Id
|
||||
LEFT JOIN pq_line pl2 ON pl1.Pid = pl2.Id
|
||||
LEFT JOIN pq_line pl3 ON pl2.Pid = pl3.Id
|
||||
LEFT JOIN pq_line pl4 ON pl3.Pid = pl4.Id
|
||||
WHERE pl.Id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
public interface IPqsTerminalLogsService extends IService<PqsTerminalLogs> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import com.njcn.device.pq.mapper.PqsTerminalLogsMapper;
|
||||
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
|
||||
import com.njcn.device.pq.service.IPqsTerminalLogsService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2023-04-12
|
||||
*/
|
||||
@Service
|
||||
public class PqsTerminalLogsServiceImpl extends ServiceImpl<PqsTerminalLogsMapper, PqsTerminalLogs> implements IPqsTerminalLogsService {
|
||||
|
||||
}
|
||||
@@ -27,28 +27,27 @@ import com.njcn.device.pq.pojo.bo.excel.NodeExcel;
|
||||
import com.njcn.device.pq.pojo.bo.excel.OracleTerminalExcel;
|
||||
import com.njcn.device.pq.pojo.bo.excel.OverLimitExcel;
|
||||
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.*;
|
||||
import com.njcn.device.pq.pojo.po.*;
|
||||
import com.njcn.device.pq.pojo.vo.*;
|
||||
import com.njcn.device.pq.service.DeviceBakService;
|
||||
import com.njcn.device.pq.service.INodeService;
|
||||
import com.njcn.device.pq.service.LineBakService;
|
||||
import com.njcn.device.pq.service.TerminalBaseService;
|
||||
import com.njcn.device.pq.service.*;
|
||||
import com.njcn.device.pq.utils.DeviceUtil;
|
||||
import com.njcn.device.pq.utils.ExcelStyleUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -73,6 +72,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
private final UserMapper userMapper;
|
||||
|
||||
private final IPqsTerminalLogsService iPqsTerminalLogsService;
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
private final DevFuctionMapper devFuctionMapper;
|
||||
@@ -98,7 +101,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
private final DeviceBakService deviceBakService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 终端新增操作
|
||||
*
|
||||
@@ -202,9 +204,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
//用于记录装置id
|
||||
String devIdIndex;
|
||||
//监测点序号
|
||||
List<Integer> listLineNum = Stream.of(1, 2, 3, 4, 5, 6,7,8,9,10).collect(Collectors.toList());
|
||||
List<Integer> listLineNum = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect(Collectors.toList());
|
||||
//母线序号
|
||||
List<Integer> listVoltageNum = Stream.of(1, 2, 3, 4, 5, 6,7,8,9,10).collect(Collectors.toList());
|
||||
List<Integer> listVoltageNum = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect(Collectors.toList());
|
||||
//标识当前装置下的监测点数量
|
||||
int lineNum = 0, voltageNum = 0;
|
||||
|
||||
@@ -446,10 +448,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
}
|
||||
List<DeviceParam> devIpList = addTerminalParam.getDeviceParam().stream().filter((dev -> dev.getDevIndex() == null)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(devIpList)) {
|
||||
for(DeviceParam deviceParam : devIpList){
|
||||
List<Device> deviceListIpRes = deviceMapper.getDeviceBySubId(subIndex, deviceParam.getIp(),deviceParam.getPort(),null);
|
||||
if(CollectionUtil.isNotEmpty(deviceListIpRes)){
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP,deviceListIpRes.get(0).getIp());
|
||||
for (DeviceParam deviceParam : devIpList) {
|
||||
List<Device> deviceListIpRes = deviceMapper.getDeviceBySubId(subIndex, deviceParam.getIp(), deviceParam.getPort(), null);
|
||||
if (CollectionUtil.isNotEmpty(deviceListIpRes)) {
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, deviceListIpRes.get(0).getIp());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -542,8 +544,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
.filter(item -> item.getUpdateFlag() == 1).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(devIpList)) {
|
||||
Set<String> set = new HashSet<>();
|
||||
devIpList.forEach(item-> set.add(item.getIp()+item.getPort()));
|
||||
if(devIpList.size()!=set.size()){
|
||||
devIpList.forEach(item -> set.add(item.getIp() + item.getPort()));
|
||||
if (devIpList.size() != set.size()) {
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_IP_REPETITION);
|
||||
}
|
||||
}
|
||||
@@ -565,8 +567,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_NAME, "重复装置:" + String.join(";", repeatDevNames));
|
||||
}
|
||||
//校验装置ip
|
||||
for(DeviceParam deviceParam:devIpList){
|
||||
List<Device> deviceIpList = deviceMapper.getDeviceBySubId(deviceValid.getPid(), deviceParam.getIp(),deviceParam.getPort(),deviceParam.getDevIndex());
|
||||
for (DeviceParam deviceParam : devIpList) {
|
||||
List<Device> deviceIpList = deviceMapper.getDeviceBySubId(deviceValid.getPid(), deviceParam.getIp(), deviceParam.getPort(), deviceParam.getDevIndex());
|
||||
if (CollectionUtil.isNotEmpty(deviceIpList)) {
|
||||
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, "重复IP:" + deviceIpList.get(0).getIp());
|
||||
}
|
||||
@@ -693,9 +695,17 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
if (Objects.isNull(scaleResult.getData())) {
|
||||
throw new BusinessException(CommonResponseEnum.DIC_DATA);
|
||||
}
|
||||
Overlimit overlimit = new Overlimit(line.getId(),scaleResult.getData().getValue(), lineDetail.getShortCapacity(), lineDetail.getStandardCapacity(), lineDetail.getDealCapacity(), lineDetail.getDevCapacity());
|
||||
Overlimit overlimit = new Overlimit(line.getId(), scaleResult.getData().getValue(), lineDetail.getShortCapacity(), lineDetail.getStandardCapacity(), lineDetail.getDealCapacity(), lineDetail.getDevCapacity());
|
||||
overlimitMapper.insert(overlimit);
|
||||
}
|
||||
//todo 插入日志
|
||||
String userId = RequestUtil.getUserIndex();
|
||||
//String userId = "5dd232f9a70c49c58d2f9e7f69776394";
|
||||
Map<String, Object> map = userMapper.getUser(userId);
|
||||
String userName = map.get("name").toString();
|
||||
String loginName = map.get("loginName").toString();
|
||||
LineDetail lineDetailResOld = lineDetailMapper.selectById(lineId);
|
||||
queryUpdateAndInsertLog(userName, loginName, lineDetailRes, lineDetailResOld);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -705,6 +715,68 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监测点信息修改处,并新增日志
|
||||
*
|
||||
* @param userName
|
||||
* @param newLine
|
||||
* @param oldLine
|
||||
* @return
|
||||
*/
|
||||
@Async
|
||||
public void queryUpdateAndInsertLog(String userName, String loginName, LineDetail newLine, LineDetail oldLine) {
|
||||
Map<String, Object> map = userMapper.getPointSuper(newLine.getId());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(userName).append("修改了").append(map.get("urbanName")).append(" - ")
|
||||
.append(map.get("subName")).append(" - ").append(map.get("devName")).append(" - ").append(map.get("pName"))
|
||||
.append(" - ").append(map.get("mName")).append(" - 监测点的参数;");
|
||||
StringBuilder sbNew = new StringBuilder();
|
||||
StringBuilder sbOld = new StringBuilder();
|
||||
sbNew.append("操作历史,");
|
||||
sbOld.append("修改后参数,");
|
||||
//pt变化
|
||||
if (!Objects.equals(newLine.getPt1(), oldLine.getPt1()) || !Objects.equals(newLine.getPt2(), oldLine.getPt2())) {
|
||||
sbNew.append("pt变比: ").append(newLine.getPt1()).append(" : ").append(newLine.getPt2()).append(";");
|
||||
sbOld.append("pt变比: ").append(oldLine.getPt1()).append(" : ").append(oldLine.getPt2()).append(";");
|
||||
}
|
||||
//ct变化
|
||||
if (!Objects.equals(newLine.getCt1(), oldLine.getCt1()) || !Objects.equals(newLine.getCt2(), oldLine.getCt2())) {
|
||||
sbNew.append("ct变比: ").append(newLine.getCt1()).append(" : ").append(newLine.getCt2()).append(";");
|
||||
sbOld.append("ct变比: ").append(oldLine.getCt1()).append(" : ").append(oldLine.getCt2()).append(";");
|
||||
}
|
||||
//设备容量
|
||||
if (!Objects.equals(newLine.getDealCapacity(), oldLine.getDealCapacity())) {
|
||||
sbNew.append("设备容量: ").append(newLine.getDealCapacity()).append(";");
|
||||
sbOld.append("设备容量: ").append(oldLine.getDealCapacity()).append(";");
|
||||
}
|
||||
//短路容量
|
||||
if (!Objects.equals(newLine.getShortCapacity(), oldLine.getShortCapacity())) {
|
||||
sbNew.append("短路容量: ").append(newLine.getShortCapacity()).append(";");
|
||||
sbOld.append("短路容量: ").append(oldLine.getShortCapacity()).append(";");
|
||||
}
|
||||
//基准容量
|
||||
if (!Objects.equals(newLine.getStandardCapacity(), oldLine.getStandardCapacity())) {
|
||||
sbNew.append("基准容量: ").append(newLine.getStandardCapacity()).append(";");
|
||||
sbOld.append("基准容量: ").append(oldLine.getStandardCapacity()).append(";");
|
||||
}
|
||||
//协议容量
|
||||
if (!Objects.equals(newLine.getDealCapacity(), oldLine.getDealCapacity())) {
|
||||
sbNew.append("协议容量: ").append(newLine.getDealCapacity()).append(";");
|
||||
sbOld.append("协议容量: ").append(oldLine.getDealCapacity()).append(";");
|
||||
}
|
||||
sb.append(sbNew).append(sbOld);
|
||||
HttpResult<DictData> dicDataByCode = dicDataFeignClient.getDicDataByCode(DicDataEnum.LINE_PARAMETER.getCode());
|
||||
DictData data = dicDataByCode.getData();
|
||||
//创建对象
|
||||
PqsTerminalLogs terminalLogsNew = new PqsTerminalLogs();
|
||||
terminalLogsNew.setObjIndex(newLine.getId());
|
||||
terminalLogsNew.setTerminalDescribe(sb.toString());
|
||||
terminalLogsNew.setCreateBy(loginName);
|
||||
terminalLogsNew.setCreateTime(LocalDateTime.now());
|
||||
terminalLogsNew.setTerminalType(data.getId());
|
||||
terminalLogsNew.setState(1);
|
||||
iPqsTerminalLogsService.save(terminalLogsNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端查询操作
|
||||
@@ -1556,7 +1628,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
if (Objects.isNull(temp)) {
|
||||
temp = assembleLine(deviceName, LineBaseEnum.DEVICE_LEVEL.getCode(), pids.get(LineBaseEnum.SUB_LEVEL.getCode()), pids);
|
||||
this.baseMapper.insert(temp);
|
||||
List<Device> existIp = deviceMapper.getDeviceBySubId(pids.get(LineBaseEnum.SUB_LEVEL.getCode()),oracleTerminalExcel.getIp(),oracleTerminalExcel.getPort(),null);
|
||||
List<Device> existIp = deviceMapper.getDeviceBySubId(pids.get(LineBaseEnum.SUB_LEVEL.getCode()), oracleTerminalExcel.getIp(), oracleTerminalExcel.getPort(), null);
|
||||
if (CollectionUtil.isNotEmpty(existIp)) {
|
||||
Device device = existIp.get(0);
|
||||
if (!device.getId().equalsIgnoreCase(temp.getId())) {
|
||||
@@ -1994,7 +2066,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
lineDetail.setCt1(Float.valueOf(ct[0]));
|
||||
lineDetail.setCt2(Float.valueOf(ct[1]));
|
||||
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(terminalBaseExcel.getSubvScale(),DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
|
||||
|
||||
lineDetailMapper.insert(lineDetail);
|
||||
Overlimit overlimit = new Overlimit(temp.getId(), dictData.getValue(), terminalBaseExcel.getShortCapacity(), terminalBaseExcel.getStandardCapacity(), terminalBaseExcel.getDealCapacity(), terminalBaseExcel.getDevCapacity());
|
||||
|
||||
@@ -302,6 +302,11 @@ public enum DicDataEnum {
|
||||
*/
|
||||
TRANS_BUSINESS("运检业务","Trans_Business"),
|
||||
|
||||
/**
|
||||
* 日志字典类型
|
||||
*/
|
||||
LINE_PARAMETER("监测点参数修改","Line_Parameter"),
|
||||
|
||||
/**
|
||||
* 接线方式
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user