17 Commits

Author SHA1 Message Date
a96fce38be 测试事件bug修改 2026-03-03 13:43:56 +08:00
hzj
27841f0f4e 修改时间同步频次为10分钟 2025-11-19 15:41:14 +08:00
hzj
35cd056870 用户上送逻辑修改 2025-11-17 14:42:27 +08:00
3d29e5a64c 北京暂降平台短信功能加固 2025-11-17 14:37:48 +08:00
hzj
a7d34296c7 用户上送逻辑修改 2025-11-17 11:14:03 +08:00
hzj
cf7a2e04d5 用户上送逻辑修改 2025-11-14 15:12:53 +08:00
hzj
8f0a739564 添加字段 2025-11-14 14:37:00 +08:00
hzj
a627125a9e 添加字段 2025-11-14 14:20:16 +08:00
ab1c777432 北京暂降平台短信功能加固 2025-11-14 14:18:40 +08:00
000e201ed7 北京暂降平台短信功能加固 2025-11-13 16:04:45 +08:00
hzj
9501880933 缓存手动刷新接口 2025-11-12 13:46:26 +08:00
c9896fd52d 北京暂降平台 2025-11-11 11:13:55 +08:00
hzj
2524b13661 暂态事件同步排除以同步的事件 2025-11-11 11:00:04 +08:00
hzj
55f03e3244 修改前端显示bug 2025-11-10 14:12:53 +08:00
cdf
8f5d9a13d8 bug修改 2025-11-05 15:39:35 +08:00
hzj
a8c1498738 变电站绑定 2025-11-04 13:57:15 +08:00
00fabe3b6b 1.无锡地图电站打点接口 2025-11-03 10:24:01 +08:00
68 changed files with 836 additions and 236 deletions

View File

@@ -49,11 +49,11 @@ public class RespDataResultServiceImpl extends ServiceImpl<RespDataResultMapper,
@Override
public List<ResponsibilityResult> displayHistoryData(String id, Integer time) {
List<ResponsibilityResult> responsibilityResults = new ArrayList<>();
//if (Objects.isNull(time)) {
RespData respDataQuery = respDataService.getById(id);
String[] split = respDataQuery.getDataTimes().split(StrPool.COMMA);
RespData respDataQuery = respDataService.getById(id);
String[] split = respDataQuery.getDataTimes().split(StrPool.COMMA);
if (Objects.isNull(time)) {
time = Integer.parseInt(split[0]);
//}
}
LambdaQueryWrapper<RespDataResult> respDataResultLambdaQueryWrapper = new LambdaQueryWrapper<>();
respDataResultLambdaQueryWrapper.eq(RespDataResult::getResDataId, id)
.eq(RespDataResult::getTime, time);

View File

@@ -10,7 +10,7 @@ import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.PqStation;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
import com.njcn.product.diagram.LedgerScale.service.LedgerScaleService;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
@@ -94,12 +94,12 @@ public class LedgerScaleController extends BaseController {
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/clickImage")
@PostMapping("/clickImage")
@ApiOperation("一次接线图点击事件")
@ApiImplicitParam(name = "lineId", value = "查询参数", required = true)
public HttpResult<EventLedgerVO> clickImage(@RequestParam("lineId")String lineId) {
public HttpResult<EventLedgerVO> clickImage(@RequestBody LargeScreenCountParam param) {
String methodDescribe = getMethodDescribe("clickImage");
EventLedgerVO result = ledgerScaleService.clickImage(lineId);
EventLedgerVO result = ledgerScaleService.clickImage(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -168,4 +168,16 @@ public class LedgerScaleController extends BaseController {
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/stationMap")
@ApiOperation("获取变电站详情")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<List<PqStation>> stationMap(@RequestBody LargeScreenCountParam param) {
String methodDescribe = getMethodDescribe("stationMap");
List<PqStation> result = ledgerScaleService.stationMap(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -6,7 +6,7 @@ import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.PqStation;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
@@ -30,8 +30,7 @@ public interface LedgerScaleService {
List<EventLedgerVO> hasUpEventList(LargeScreenCountParam param);
EventLedgerVO clickImage(String lineId);
EventLedgerVO clickImage(LargeScreenCountParam param);
Page<EventDetailVO> eventList(LargeScreenCountParam param);
Page<EventDetailVO> eventListByLineId(LargeScreenCountParam param);
@@ -44,4 +43,6 @@ public interface LedgerScaleService {
List<CustomerResponsibility> harmOneImage(String id, Integer time);
List<PqStation> stationMap(LargeScreenCountParam param);
}

View File

@@ -3,7 +3,6 @@ package com.njcn.product.diagram.LedgerScale.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
@@ -20,24 +19,25 @@ import com.njcn.product.advance.eventSource.pojo.po.RmpEventDetailAssPO;
import com.njcn.product.advance.harmonicUp.mapper.UpHarmonicDetailMapper;
import com.njcn.product.advance.harmonicUp.pojo.po.UpHarmonicDetail;
import com.njcn.product.advance.responsility.mapper.RespDataResultMapper;
import com.njcn.product.advance.responsility.pojo.dto.CustomerData;
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
import com.njcn.product.advance.responsility.pojo.dto.ResponsibilityResult;
import com.njcn.product.advance.responsility.pojo.po.RespDataResult;
import com.njcn.product.cnzutai.zutai.pojo.po.CsConfigurationPO;
import com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss;
import com.njcn.product.cnzutai.zutai.service.CsConfigurationService;
import com.njcn.product.cnzutai.zutai.service.CsSubConfigurationAssService;
import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
import com.njcn.product.terminal.mysqlTerminal.mapper.LineMapper;
import com.njcn.product.terminal.mysqlTerminal.mapper.UserReportPOMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.UserReportPO;
import com.njcn.product.terminal.mysqlTerminal.mapper.*;
import com.njcn.product.terminal.mysqlTerminal.pojo.enums.LineBaseEnum;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.Line;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.PqStation;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
import com.njcn.product.diagram.LedgerScale.service.LedgerScaleService;
import com.njcn.product.system.dict.mapper.DictDataMapper;
import com.njcn.product.system.dict.pojo.enums.DicDataTypeEnum;
import com.njcn.product.system.dict.pojo.po.DictData;
import com.njcn.product.terminal.mysqlTerminal.mapper.LedgerScaleMapper;
import com.njcn.product.terminal.mysqlTerminal.mapper.RmpEventDetailMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerBaseInfo;
import com.njcn.product.terminal.mysqlTerminal.pojo.enums.RunFlagEnum;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
@@ -51,7 +51,6 @@ import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -80,9 +79,10 @@ public class LedgerScaleServiceImpl implements LedgerScaleService {
private final RespDataResultMapper respDataResultMapper;
private final FileStorageUtil fileStorageUtil;
private final UserReportPOMapper userReportPOMapper;
private final UpHarmonicDetailMapper upHarmonicDetailMapper;
private final PqStationMapper pqStationMapper;
private final CsSubConfigurationAssService csSubConfigurationAssService;
private final CsConfigurationService csConfigurationService;
@Override
public LedgerScaleDTO ledgerScaleStatistic(LargeScreenCountParam param) {
@@ -281,16 +281,18 @@ public class LedgerScaleServiceImpl implements LedgerScaleService {
}
@Override
public EventLedgerVO clickImage(String lineId) {
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(Stream.of(lineId).collect(Collectors.toList()));
public EventLedgerVO clickImage(LargeScreenCountParam param) {
List<LedgerBaseInfo> ledgerBaseInfoList = ledgerScaleMapper.getLedgerBaseInfo(Stream.of(param.getLineId()).collect(Collectors.toList()));
if (CollUtil.isEmpty(ledgerBaseInfoList)) {
throw new BusinessException(CommonResponseEnum.FAIL, "当前节点未查询到测点信息");
}
EventLedgerVO eventLedgerVO = new EventLedgerVO();
BeanUtil.copyProperties(ledgerBaseInfoList.get(0), eventLedgerVO);
DateTime start = DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()));
DateTime end = DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()));
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RmpEventDetailPO::getLineId, lineId);
lambdaQueryWrapper.eq(RmpEventDetailPO::getLineId, param.getLineId()).between(RmpEventDetailPO::getStartTime, start, end).orderByDesc(RmpEventDetailPO::getStartTime);;
List<RmpEventDetailPO> rmpEventDetailPOList = rmpEventDetailMapper.selectList(lambdaQueryWrapper);
List<DictData> dictDataList = dictDataMapper.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode());
@@ -301,6 +303,7 @@ public class LedgerScaleServiceImpl implements LedgerScaleService {
}
@Override
public Page<EventDetailVO> eventList(LargeScreenCountParam param) {
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param));
@@ -489,5 +492,42 @@ public class LedgerScaleServiceImpl implements LedgerScaleService {
return new ArrayList<>();
}
@Override
public List<PqStation> stationMap(LargeScreenCountParam param) {
List<PqStation> result = new ArrayList<>();
List<String> runIds = commGeneralService.getRunLineIdsByDept(param.getDeptId());
if(CollUtil.isEmpty(runIds)){
return result;
}
List<Line> lineList = lineMapper.selectList(new LambdaQueryWrapper<Line>().in(Line::getId,runIds));
List<String> stationIds = lineList.stream().map(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.SUB_LEVEL.getCode()]).distinct().collect(Collectors.toList());
List<Line> stationResult = lineMapper.selectList(new LambdaQueryWrapper<Line>().in(Line::getId,stationIds));
List<String> ids = stationResult.stream().map(Line::getId).distinct().collect(Collectors.toList());
List<PqStation> pqStationList = pqStationMapper.selectList(new LambdaQueryWrapper<PqStation>().in(PqStation::getId,ids));
Map<String, PqStation> substationMap = pqStationList.stream().collect(Collectors.toMap(PqStation::getId, po->po));
stationResult.forEach(it->{
PqStation pqStation = new PqStation();
if(substationMap.containsKey(it.getId())){
PqStation tem = substationMap.get(it.getId());
pqStation.setLng(tem.getLng());
pqStation.setLat(tem.getLat());
}
pqStation.setId(it.getId());
pqStation.setName(it.getName());
CsSubConfigurationAss one = csSubConfigurationAssService.lambdaQuery().eq(CsSubConfigurationAss::getSubId, it.getId()).one();
if(Objects.isNull(one)){
pqStation.setBindFlag(false);
}else {
CsConfigurationPO csConfigurationPO = csConfigurationService.lambdaQuery().eq(CsConfigurationPO::getId, one.getConfigId()).one();
pqStation.setBindFlag(true);
pqStation.setConfigId(csConfigurationPO.getId());
pqStation.setConfigName(csConfigurationPO.getName());
}
result.add(pqStation);
});
return result;
}
}

View File

@@ -1,10 +0,0 @@
package com.njcn.product.terminal.device.service;
import com.njcn.product.terminal.device.pojo.dto.OracleLedgerTreeDTO;
import java.util.List;
public interface LedgerTreeService {
List<OracleLedgerTreeDTO> getTree();
}

View File

@@ -1,12 +1,10 @@
package com.njcn.product.terminal.mysqlTerminal.controller;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.product.terminal.device.service.LedgerTreeService;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerTreeDTO;
import com.njcn.product.terminal.mysqlTerminal.pojo.enums.StatisticsEnum;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.DeviceInfoParam;

View File

@@ -5,7 +5,6 @@ import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.product.terminal.device.pojo.dto.OracleLedgerTreeDTO;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LedgerTreeDTO;
import com.njcn.product.terminal.mysqlTerminal.service.LineService;
import com.njcn.web.controller.BaseController;

View File

@@ -0,0 +1,8 @@
package com.njcn.product.terminal.mysqlTerminal.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.PqStation;
public interface PqStationMapper extends BaseMapper<PqStation> {
}

View File

@@ -93,7 +93,7 @@
and (dev.name like CONCAT('%', #{searchValue}, '%')
or a.name like CONCAT('%', #{searchValue}, '%'))
</if>
order by c.name,a.name
<!-- order by c.name,a.name-->
</select>
<select id="getLineList" resultType="TerminalShowVO">
@@ -131,7 +131,7 @@
or a.name like CONCAT('%', #{searchValue}, '%')
or c.name like CONCAT('%', #{searchValue}, '%'))
</if>
order by c.name,a.name
<!-- order by c.name,a.name-->
</select>
<select id="getMonitorDetail" resultType="com.njcn.product.terminal.mysqlTerminal.pojo.dto.LineDevGetDTO">

View File

@@ -1,6 +1,5 @@
package com.njcn.product.terminal.mysqlTerminal.pojo.dto;
import com.njcn.product.terminal.device.pojo.dto.OracleLedgerTreeDTO;
import lombok.Data;
import java.util.ArrayList;

View File

@@ -0,0 +1,58 @@
package com.njcn.product.terminal.mysqlTerminal.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* <p>
*
* </p>
*
* @author cdf
* @since 2022-01-04
*/
@Data
@TableName("pq_substation")
public class PqStation implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 变电站序号
*/
private String id;
/**
* 电压等级Id字典表
*/
private String scale;
/**
* 经度
*/
private BigDecimal lng;
/**
* 纬度
*/
private BigDecimal lat;
@TableField(exist = false)
private String name;
@TableField(exist = false)
private boolean bindFlag;
@TableField(exist = false)
private String configId;
@TableField(exist = false)
private String configName;
}

View File

@@ -1,7 +1,7 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.po.PqDeviceDetail;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqDeviceDetail;
/**
* CN_Gather

View File

@@ -1,11 +1,11 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.terminal.device.pojo.dto.DeviceDTO;
import com.njcn.product.terminal.device.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.device.pojo.po.PqDevice;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDTO;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqDevice;
import org.apache.ibatis.annotations.Param;
import java.util.List;

View File

@@ -1,7 +1,7 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.po.PqGdCompany;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqGdCompany;
/**
*

View File

@@ -1,8 +1,8 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.device.pojo.po.PqLine;
import com.njcn.product.terminal.oracleDevice.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqLine;
import org.apache.ibatis.annotations.Param;
import java.util.List;

View File

@@ -1,7 +1,7 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.po.PqLinedetail;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqLinedetail;
import org.apache.ibatis.annotations.Mapper;
@Mapper

View File

@@ -1,9 +1,9 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.device.pojo.po.PqSubstation;
import com.njcn.product.terminal.oracleDevice.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqSubstation;
import org.apache.ibatis.annotations.Param;
import java.util.List;

View File

@@ -1,7 +1,7 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.po.PqsDeptsline;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqsDeptsline;
/**
*

View File

@@ -1,8 +1,8 @@
package com.njcn.product.terminal.device.mapper;
package com.njcn.product.terminal.oracleDevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.terminal.device.pojo.po.PqsStationMap;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqsStationMap;
/**
*

View File

@@ -1,7 +1,7 @@
<?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.product.terminal.device.mapper.PqDeviceMapper">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.device.pojo.po.PqDevice">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.oracleDevice.pojo.po.PqDevice">
<!--@mbg.generated-->
<!--@Table PQ_DEVICE-->
<id column="DEV_INDEX" jdbcType="DECIMAL" property="devIndex" />
@@ -28,7 +28,7 @@
NODE_INDEX, PORTID, DEVFLAG, DEV_SERIES, DEV_KEY, IP, DEVMODEL, CALLFLAG, DATATYPE
</sql>
<select id="queryListByIds" resultType="com.njcn.product.terminal.device.pojo.dto.DeviceDTO">
<select id="queryListByIds" resultType="com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDTO">
select
pq_device.dev_index devId,
pq_device.name devName,
@@ -52,7 +52,7 @@
</foreach>
</select>
<select id="selectDeviceDTOPage" resultType="com.njcn.product.terminal.device.pojo.dto.DeviceDTO">
<select id="selectDeviceDTOPage" resultType="com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDTO">
SELECT DISTINCT
pq_device.dev_index devId,

View File

@@ -1,7 +1,7 @@
<?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.product.terminal.device.mapper.PqLineMapper">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.device.pojo.po.PqLine">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.oracleDevice.pojo.po.PqLine">
<!--@mbg.generated-->
<!--@Table PQ_LINE-->
<id column="LINE_INDEX" jdbcType="DECIMAL" property="lineIndex" />
@@ -29,7 +29,7 @@
</sql>
<select id="getBaseLineInfo" resultType="com.njcn.product.terminal.device.pojo.dto.LedgerBaseInfoDTO">
<select id="getBaseLineInfo" resultType="com.njcn.product.terminal.oracleDevice.pojo.dto.LedgerBaseInfoDTO">
WITH temp AS(
select PQ_USER_LINE_ASS.LINE_INDEX LINE_INDEX,listagg(PQ_USER_LEDGER.CUSTOMER_NAME,';') within GROUP (order by PQ_USER_LEDGER.CUSTOMER_NAME) objName from PQ_USER_LINE_ASS ,PQ_USER_LEDGER where PQ_USER_LINE_ASS.USER_INDEX=PQ_USER_LEDGER.ID group by PQ_USER_LINE_ASS.LINE_INDEX
@@ -62,7 +62,7 @@ where 1=1
</select>
<select id="getBaseLedger" resultType="com.njcn.product.terminal.device.pojo.dto.LedgerBaseInfoDTO">
<select id="getBaseLedger" resultType="com.njcn.product.terminal.oracleDevice.pojo.dto.LedgerBaseInfoDTO">
select
PQ_GDINFORMATION.name gdName,
pq_line.GD_INDEX gdIndex,

View File

@@ -1,7 +1,7 @@
<?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.product.terminal.device.mapper.PqSubstationMapper">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.device.pojo.po.PqSubstation">
<resultMap id="BaseResultMap" type="com.njcn.product.terminal.oracleDevice.pojo.po.PqSubstation">
<!--@mbg.generated-->
<!--@Table PQ_SUBSTATION-->
<id column="SUB_INDEX" jdbcType="DECIMAL" property="subIndex" />
@@ -14,7 +14,7 @@
SUB_INDEX, GD_INDEX, "NAME", "SCALE"
</sql>
<select id="queryListByIds" resultType="com.njcn.product.terminal.device.pojo.dto.SubstationDTO">
<select id="queryListByIds" resultType="com.njcn.product.terminal.oracleDevice.pojo.dto.SubstationDTO">
select
PQ_SUBSTATION.sub_index stationId,
PQ_SUBSTATION.name stationName,

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.dto;
package com.njcn.product.terminal.oracleDevice.pojo.dto;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
/**
* @Author: cdf

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;

View File

@@ -1,9 +1,8 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*

View File

@@ -1,4 +1,4 @@
package com.njcn.product.terminal.device.pojo.po;
package com.njcn.product.terminal.oracleDevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@@ -0,0 +1,10 @@
package com.njcn.product.terminal.oracleDevice.service;
import com.njcn.product.terminal.oracleDevice.pojo.dto.OracleLedgerTreeDTO;
import java.util.List;
public interface LedgerTreeService {
List<OracleLedgerTreeDTO> getTree();
}

View File

@@ -1,11 +1,11 @@
package com.njcn.product.terminal.device.service;
package com.njcn.product.terminal.oracleDevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.terminal.device.pojo.dto.DeviceDTO;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDTO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.terminal.device.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.device.pojo.po.PqDevice;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqDevice;
import java.util.List;

View File

@@ -1,9 +1,9 @@
package com.njcn.product.terminal.device.service;
package com.njcn.product.terminal.oracleDevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.terminal.device.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.device.pojo.po.PqLine;
import com.njcn.product.terminal.oracleDevice.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqLine;
import org.apache.ibatis.annotations.Param;
import java.util.List;

View File

@@ -1,9 +1,9 @@
package com.njcn.product.terminal.device.service;
package com.njcn.product.terminal.oracleDevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.terminal.device.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.device.pojo.po.PqSubstation;
import com.njcn.product.terminal.oracleDevice.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqSubstation;
import java.util.List;

View File

@@ -1,7 +1,7 @@
package com.njcn.product.terminal.device.service;
package com.njcn.product.terminal.oracleDevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.terminal.device.pojo.po.PqsDeptsline;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqsDeptsline;
/**
*

View File

@@ -1,17 +1,17 @@
package com.njcn.product.terminal.device.service.impl;
package com.njcn.product.terminal.oracleDevice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.product.terminal.device.mapper.PqDeviceMapper;
import com.njcn.product.terminal.device.mapper.PqGdCompanyMapper;
import com.njcn.product.terminal.device.mapper.PqLineMapper;
import com.njcn.product.terminal.device.mapper.PqSubstationMapper;
import com.njcn.product.terminal.device.pojo.dto.OracleLedgerTreeDTO;
import com.njcn.product.terminal.device.pojo.po.PqDevice;
import com.njcn.product.terminal.device.pojo.po.PqGdCompany;
import com.njcn.product.terminal.device.pojo.po.PqLine;
import com.njcn.product.terminal.device.pojo.po.PqSubstation;
import com.njcn.product.terminal.device.service.LedgerTreeService;
import com.njcn.product.terminal.oracleDevice.mapper.PqDeviceMapper;
import com.njcn.product.terminal.oracleDevice.mapper.PqGdCompanyMapper;
import com.njcn.product.terminal.oracleDevice.mapper.PqLineMapper;
import com.njcn.product.terminal.oracleDevice.mapper.PqSubstationMapper;
import com.njcn.product.terminal.oracleDevice.pojo.dto.OracleLedgerTreeDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqDevice;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqGdCompany;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqLine;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqSubstation;
import com.njcn.product.terminal.oracleDevice.service.LedgerTreeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@@ -1,12 +1,12 @@
package com.njcn.product.terminal.device.service.impl;
package com.njcn.product.terminal.oracleDevice.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.terminal.device.mapper.PqDeviceMapper;
import com.njcn.product.terminal.device.pojo.dto.DeviceDTO;
import com.njcn.product.terminal.device.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.device.pojo.po.PqDevice;
import com.njcn.product.terminal.device.service.PqDeviceService;
import com.njcn.product.terminal.oracleDevice.mapper.PqDeviceMapper;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDTO;
import com.njcn.product.terminal.oracleDevice.pojo.dto.DeviceDeptDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqDevice;
import com.njcn.product.terminal.oracleDevice.service.PqDeviceService;
import org.springframework.stereotype.Service;
import java.util.List;

View File

@@ -1,12 +1,12 @@
package com.njcn.product.terminal.device.service.impl;
package com.njcn.product.terminal.oracleDevice.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.product.terminal.device.mapper.PqLineMapper;
import com.njcn.product.terminal.device.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.device.pojo.po.PqLine;
import com.njcn.product.terminal.device.service.PqLineService;
import com.njcn.product.terminal.oracleDevice.mapper.PqLineMapper;
import com.njcn.product.terminal.oracleDevice.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqLine;
import com.njcn.product.terminal.oracleDevice.service.PqLineService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;

View File

@@ -1,9 +1,9 @@
package com.njcn.product.terminal.device.service.impl;
package com.njcn.product.terminal.oracleDevice.service.impl;
import com.njcn.product.terminal.device.mapper.PqSubstationMapper;
import com.njcn.product.terminal.device.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.device.pojo.po.PqSubstation;
import com.njcn.product.terminal.device.service.PqSubstationService;
import com.njcn.product.terminal.oracleDevice.mapper.PqSubstationMapper;
import com.njcn.product.terminal.oracleDevice.pojo.dto.SubstationDTO;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqSubstation;
import com.njcn.product.terminal.oracleDevice.service.PqSubstationService;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

View File

@@ -1,8 +1,8 @@
package com.njcn.product.terminal.device.service.impl;
package com.njcn.product.terminal.oracleDevice.service.impl;
import com.njcn.product.terminal.device.mapper.PqsDeptslineMapper;
import com.njcn.product.terminal.device.pojo.po.PqsDeptsline;
import com.njcn.product.terminal.device.service.PqsDeptslineService;
import com.njcn.product.terminal.oracleDevice.mapper.PqsDeptslineMapper;
import com.njcn.product.terminal.oracleDevice.pojo.po.PqsDeptsline;
import com.njcn.product.terminal.oracleDevice.service.PqsDeptslineService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

View File

@@ -54,6 +54,12 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn.product</groupId>
<artifactId>cn-terminal</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -0,0 +1,15 @@
package com.njcn.product.cnzutai.zutai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss;
/**
*
* Description:
* Date: 2025/11/04 上午 11:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsSubConfigurationAssMapper extends BaseMapper<CsSubConfigurationAss> {
}

View File

@@ -0,0 +1,14 @@
<?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.product.cnzutai.zutai.mapper.CsSubConfigurationAssMapper">
<resultMap id="BaseResultMap" type="com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss">
<!--@mbg.generated-->
<!--@Table cs_sub_configuration_ass-->
<id column="sub_id" jdbcType="VARCHAR" property="subId" />
<result column="config_id" jdbcType="VARCHAR" property="configId" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
sub_id, config_id
</sql>
</mapper>

View File

@@ -30,6 +30,8 @@ public class CsConfigurationParm {
private List<String> projectIds;
private List<String> substionIds;
private Integer orderBy;

View File

@@ -0,0 +1,33 @@
package com.njcn.product.cnzutai.zutai.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
* Description:
* Date: 2025/11/04 上午 11:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
@TableName(value = "cs_sub_configuration_ass")
@Data
public class CsSubConfigurationAss {
/**
* 变电站序号
*/
@TableId(value = "sub_id", type = IdType.INPUT)
private String subId;
/**
* 组态id
*/
@TableField(value = "config_id")
private String configId;
}

View File

@@ -37,6 +37,9 @@ public class CsConfigurationVO extends BaseEntity {
private List<String> projectIds;
private List<String> substionIds;
private List<String> substionName;
@ApiModelProperty(value = "操作人")
private String operater;

View File

@@ -0,0 +1,16 @@
package com.njcn.product.cnzutai.zutai.service;
import com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2025/11/04 上午 11:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsSubConfigurationAssService extends IService<CsSubConfigurationAss>{
}

View File

@@ -1,6 +1,7 @@
package com.njcn.product.cnzutai.zutai.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,11 +12,16 @@ import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.product.cnzutai.zutai.mapper.CsPagePOMapper;
import com.njcn.product.cnzutai.zutai.pojo.po.CsPagePO;
import com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss;
import com.njcn.product.cnzutai.zutai.service.CsConfigurationService;
import com.njcn.product.cnzutai.zutai.mapper.CsConfigurationMapper;
import com.njcn.product.cnzutai.zutai.pojo.param.CsConfigurationParm;
import com.njcn.product.cnzutai.zutai.pojo.po.CsConfigurationPO;
import com.njcn.product.cnzutai.zutai.pojo.vo.CsConfigurationVO;
import com.njcn.product.cnzutai.zutai.service.CsSubConfigurationAssService;
import com.njcn.product.terminal.mysqlTerminal.mapper.LineMapper;
import com.njcn.product.terminal.mysqlTerminal.mapper.PqStationMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.Line;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -46,6 +52,8 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
private final FileStorageUtil fileStorageUtil;
private final CsPagePOMapper csPagePOMapper;
private final CsSubConfigurationAssService csSubConfigurationAssService;
private final LineMapper lineMapper;
//private final UserFeignClient userFeignClient;
@@ -72,21 +80,44 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
csConfigurationPO.setStatus("1");
boolean save = this.save(csConfigurationPO);
String name = csConfigurationPO.getName();
Integer count = this.lambdaQuery().eq(CsConfigurationPO::getName, name).eq(CsConfigurationPO::getStatus, "1").count();
if(count>1){
throw new BusinessException("存在相同的组态项目名称");
}
//添加变电站绑定
if(!CollectionUtils.isEmpty(csConfigurationParm.getSubstionIds())){
List<CsSubConfigurationAss> list = csSubConfigurationAssService.lambdaQuery().in(CsSubConfigurationAss::getSubId, csConfigurationParm.getSubstionIds()).list();
if (!CollectionUtils.isEmpty(list)){
List<Line> stationResult = lineMapper.selectList(new LambdaQueryWrapper<Line>().in(Line::getId,list));
String subNameList = stationResult.stream().map(Line::getName).collect(Collectors.joining(StrUtil.COMMA));
throw new BusinessException("变电站"+subNameList+"已绑定其他项目请修改");
}else {
List<CsSubConfigurationAss> csSubConfigurationAsses = csConfigurationParm.getSubstionIds().stream().map(temp -> {
CsSubConfigurationAss csSubConfigurationAss = new CsSubConfigurationAss();
csSubConfigurationAss.setSubId(temp);
csSubConfigurationAss.setConfigId(csConfigurationPO.getId());
return csSubConfigurationAss;
}).collect(Collectors.toList());
csSubConfigurationAssService.saveBatch(csSubConfigurationAsses);
}
}
return save;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean audit(CsConfigurationParm.CsConfigurationAuditParam auditParm) {
CsConfigurationPO tem = this.getById(auditParm.getId());
if(Objects.isNull(tem)){
throw new BusinessException(CommonResponseEnum.FAIL,"未查询到项目信息,无法操作!");
}
//删除关联表信息
csSubConfigurationAssService.lambdaUpdate().eq(CsSubConfigurationAss::getConfigId,tem.getId()).remove();
CsConfigurationPO csConfigurationPO = new CsConfigurationPO();
if(Objects.equals(auditParm.getStatus(),"0")){
@@ -126,6 +157,26 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
boolean b = this.updateById(csConfigurationPO);
//添加变电站绑定
if(!CollectionUtils.isEmpty(auditParm.getSubstionIds())){
List<CsSubConfigurationAss> list = csSubConfigurationAssService.lambdaQuery().in(CsSubConfigurationAss::getSubId, auditParm.getSubstionIds()).list();
if (!CollectionUtils.isEmpty(list)){
List<Line> stationResult = lineMapper.selectList(new LambdaQueryWrapper<Line>().in(Line::getId,list));
String subNameList = stationResult.stream().map(Line::getName).collect(Collectors.joining(StrUtil.COMMA));
throw new BusinessException("变电站"+subNameList+"已绑定其他项目请修改");
}else {
List<CsSubConfigurationAss> csSubConfigurationAsses = auditParm.getSubstionIds().stream().map(temp -> {
CsSubConfigurationAss csSubConfigurationAss = new CsSubConfigurationAss();
csSubConfigurationAss.setSubId(temp);
csSubConfigurationAss.setConfigId(csConfigurationPO.getId());
return csSubConfigurationAss;
}).collect(Collectors.toList());
csSubConfigurationAssService.saveBatch(csSubConfigurationAsses);
}
}
return b;
}
@@ -198,7 +249,14 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
}
}
List<CsSubConfigurationAss> csSubConfigurationAssList = csSubConfigurationAssService.lambdaQuery().eq(CsSubConfigurationAss::getConfigId, page.getId()).list();
if(!CollectionUtils.isEmpty(csSubConfigurationAssList)){
List<String> subIds = csSubConfigurationAssList.stream().map(CsSubConfigurationAss::getSubId).collect(Collectors.toList());
csDevModelPageVO.setSubstionIds(subIds);
// List<Line> stationResult = lineMapper.selectList(new LambdaQueryWrapper<Line>().in(Line::getId,subIds));
// csDevModelPageVO.setSubstionName();
}
csDevModelPageVO.setOperater(collect2.get(csDevModelPageVO.getCreateBy()));
return csDevModelPageVO;

View File

@@ -0,0 +1,21 @@
package com.njcn.product.cnzutai.zutai.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.product.cnzutai.zutai.mapper.CsSubConfigurationAssMapper;
import com.njcn.product.cnzutai.zutai.pojo.po.CsSubConfigurationAss;
import com.njcn.product.cnzutai.zutai.service.CsSubConfigurationAssService;
/**
*
* Description:
* Date: 2025/11/04 上午 11:07【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class CsSubConfigurationAssServiceImpl extends ServiceImpl<CsSubConfigurationAssMapper, CsSubConfigurationAss> implements CsSubConfigurationAssService{
}

View File

@@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.product.event.devcie.mapper.PqGdCompanyMapper;
import com.njcn.product.event.devcie.mapper.PqLineMapper;
import com.njcn.product.event.devcie.mapper.PqLinedetailMapper;
import com.njcn.product.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.event.devcie.pojo.po.PqGdCompany;
@@ -23,6 +24,7 @@ import com.njcn.product.event.config.RedisUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@@ -41,6 +43,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
@@ -60,6 +63,7 @@ public class DataSynchronization {
private final OssFileStorageUtils ossFileStorageUtils;
private final PqLinedetailMapper pqLinedetailMapper;
private final PqLineMapper pqLineMapper;
private final PqUserLineAssMapper pqUserLineAssMapper;
private final PqUserLedgerMapper pqUserLedgerMapper;
@@ -159,8 +163,8 @@ public class DataSynchronization {
String exportDirName = "/pq_user/pq_user.json";
UpLoadUserDTO result = new UpLoadUserDTO();
QueryWrapper<PqUserLedgerPO> pqUserLedgerPOQueryWrapper = new QueryWrapper<>();
pqUserLedgerPOQueryWrapper.lambda().eq(PqUserLedgerPO::getIsShow,1);
List<PqUserLedgerPO> pqUserLedgerPOS = pqUserLedgerMapper.selectList(pqUserLedgerPOQueryWrapper);
// pqUserLedgerPOQueryWrapper.lambda().eq(PqUserLedgerPO::getIsShow,1);
List<PqUserLedgerPO> pqUserLedgerPOS = pqUserLedgerMapper.selectList(null);
if(!CollectionUtils.isEmpty(pqUserLedgerPOS)){
List<String> showIds =new ArrayList<>();
List<UserLegerDTO> userLegerDTOList =new ArrayList<>();
@@ -178,11 +182,28 @@ public class DataSynchronization {
userLegerDTO.setBigObjType(pqsDicTreePOMap.get(temp.getBigObjType()).getName());
userLegerDTO.setSmallObjType(pqsDicTreePOMap.get(temp.getSmallObjType()).getName());
userLegerDTO.setCustomerNo("");
userLegerDTO.setIsShow(temp.getIsShow());
userLegerDTOList.add(userLegerDTO);
});
QueryWrapper<PqUserLineAssPO> userLineAssPOQueryWrapper = new QueryWrapper<>();
userLineAssPOQueryWrapper.lambda().in(PqUserLineAssPO::getUserIndex,showIds);
// userLineAssPOQueryWrapper.lambda().in(PqUserLineAssPO::getUserIndex,showIds);
if (showIds.size() > 1000) {
List<List<String>> splitList = CollUtil.split(showIds, 1000);
userLineAssPOQueryWrapper.lambda().and(ew -> {
for (int i = 0; i < splitList.size(); i++) {
List<String> batch = splitList.get(i);
if (i == 0) {
ew.in(PqUserLineAssPO::getUserIndex, batch); // 第一个条件不加 or
} else {
ew.or().in(PqUserLineAssPO::getUserIndex, batch); // 后续条件加 or
}
}
});
} else {
userLineAssPOQueryWrapper.lambda().in(PqUserLineAssPO::getUserIndex, showIds);
}
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(userLineAssPOQueryWrapper);
List<UserLineAssDTO> userLineAssDTOS = pqUserLineAssPOS.stream().map(temp -> {
UserLineAssDTO userLineAssDTO = new UserLineAssDTO();
@@ -215,19 +236,19 @@ public class DataSynchronization {
String exportDirName = String.format("%s/%s/%s.json","/event", filePath,"bz_"+fileName);
// 查询失败的暂降事件
LambdaQueryWrapper<PqsEventDetailStatusPO> statusPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
statusPOLambdaQueryWrapper.between(PqsEventDetailStatusPO::getEventTime,start,end);
statusPOLambdaQueryWrapper.between(PqsEventDetailStatusPO::getSyncTime,start,end);
List<PqsEventDetailStatusPO> hasList = pqsEventDetailStatusService.list(statusPOLambdaQueryWrapper);
Map<String, PqsEventDetailStatusPO> pqsEventDetailStatusPOMap = hasList.stream().collect(Collectors.toMap(PqsEventDetailStatusPO::getEventDetailId, Function.identity()));
// 查询事件
LambdaQueryWrapper<PqsEventdetail> pqsEventdetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
pqsEventdetailLambdaQueryWrapper.between(PqsEventdetail::getCreateTime,start,end);
pqsEventdetailLambdaQueryWrapper.between(PqsEventdetail::getCreateTime,start.minusMinutes(6*10),end);
List<PqsEventdetail> unsyncedEvents = pqsEventdetailMapper.selectList(pqsEventdetailLambdaQueryWrapper);
List<String> tempEvetIds = unsyncedEvents.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
//查询日志
List<String> allEventIds = hasList.stream().map(PqsEventDetailStatusPO::getEventDetailId).collect(Collectors.toList());
List<String> unSyncIds = tempEvetIds.stream().filter(temp -> !allEventIds.contains(temp)).collect(Collectors.toList());
List<String> failIds = hasList.stream().filter(temp -> temp.getRetryCount() <= 2 && temp.getSyncStatus() == 0).map(PqsEventDetailStatusPO::getEventDetailId).collect(Collectors.toList());
List<String> failIds = hasList.stream().filter(temp -> temp.getRetryCount() <= 5 && temp.getSyncStatus() == 0).map(PqsEventDetailStatusPO::getEventDetailId).collect(Collectors.toList());
unSyncIds.addAll(failIds);
List<UpLoadEvent> result = new ArrayList<>();
@@ -259,13 +280,13 @@ public class DataSynchronization {
List<PqLinedetail> pqLinedetails = pqLinedetailMapper.selectList(null);
Map<Integer, PqLinedetail> lineDetailMap = pqLinedetails.stream().collect(Collectors.toMap(PqLinedetail::getLineIndex, Function.identity()));
unSyncIds.forEach(temp->{
eventIds.forEach(temp->{
PqsEventdetail pqsEventdetail = pqsEventdetailMap.get(temp);
if(pqsEventDetailStatusPOMap.containsKey(temp)){
PqsEventDetailStatusPO pqsEventDetailStatusPO = pqsEventDetailStatusPOMap.get(temp);
pqsEventDetailStatusPO.setRetryCount(pqsEventDetailStatusPO.getRetryCount()+1);
if(Objects.nonNull(pqsEventdetail.getWavename())||pqsEventDetailStatusPO.getRetryCount()>2){
if(Objects.nonNull(pqsEventdetail.getWavename())||pqsEventDetailStatusPO.getRetryCount()>5){
pqsEventDetailStatusPO.setSyncStatus(1);
pqsEventDetailStatusPO.setWaveFlag(0);
UpLoadEvent upLoadEvent = new UpLoadEvent();
@@ -275,13 +296,18 @@ public class DataSynchronization {
upLoadEvent.setMs(pqsEventdetail.getMs());
upLoadEvent.setDescribe(pqsEventdetail.getDescribe());
upLoadEvent.setWavetype(pqsEventdetail.getWavetype());
upLoadEvent.setPersisttime(pqsEventdetail.getPersisttime());
upLoadEvent.setPersisttime( pqsEventdetail.getPersisttime()/ 1000);
upLoadEvent.setEventvalue(pqsEventdetail.getEventvalue());
upLoadEvent.setEventreason(pqsEventdetail.getEventreason());
upLoadEvent.setEventtype(pqsEventdetail.getEventtype());
LedgerBaseInfoDTO ledgerBaseInfoDTO = LedgerBaseInfoDTOMap.get(pqsEventdetail.getLineid());
if(Objects.isNull(ledgerBaseInfoDTO)){
List<LedgerBaseInfoDTO> baseLineInfo = pqLineMapper.getBaseLineInfo(Stream.of(pqsEventdetail.getLineid()).collect(Collectors.toList()));
ledgerBaseInfoDTO = baseLineInfo.get(0);
}
upLoadEvent.setGdname(ledgerBaseInfoDTO.getGdName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getStationName());
upLoadEvent.setBusname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setPointname(ledgerBaseInfoDTO.getLineName());
upLoadEvent.setIp(ledgerBaseInfoDTO.getIp());
upLoadEvent.setPt(ledgerBaseInfoDTO.getPt());
@@ -316,13 +342,18 @@ public class DataSynchronization {
upLoadEvent.setMs(pqsEventdetail.getMs());
upLoadEvent.setDescribe(pqsEventdetail.getDescribe());
upLoadEvent.setWavetype(pqsEventdetail.getWavetype());
upLoadEvent.setPersisttime(pqsEventdetail.getPersisttime());
upLoadEvent.setPersisttime(pqsEventdetail.getPersisttime()/ 1000);
upLoadEvent.setEventvalue(pqsEventdetail.getEventvalue());
upLoadEvent.setEventreason(pqsEventdetail.getEventreason());
upLoadEvent.setEventtype(pqsEventdetail.getEventtype());
LedgerBaseInfoDTO ledgerBaseInfoDTO = LedgerBaseInfoDTOMap.get(pqsEventdetail.getLineid());
if(Objects.isNull(ledgerBaseInfoDTO)){
List<LedgerBaseInfoDTO> baseLineInfo = pqLineMapper.getBaseLineInfo(Stream.of(pqsEventdetail.getLineid()).collect(Collectors.toList()));
ledgerBaseInfoDTO = baseLineInfo.get(0);
}
upLoadEvent.setGdname(ledgerBaseInfoDTO.getGdName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getStationName());
upLoadEvent.setBusname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setPointname(ledgerBaseInfoDTO.getLineName());
upLoadEvent.setIp(ledgerBaseInfoDTO.getIp());
upLoadEvent.setPt(ledgerBaseInfoDTO.getPt());
@@ -431,13 +462,18 @@ public class DataSynchronization {
upLoadEvent.setMs(unsyncedEvent.getMs());
upLoadEvent.setDescribe(unsyncedEvent.getDescribe());
upLoadEvent.setWavetype(unsyncedEvent.getWavetype());
upLoadEvent.setPersisttime(unsyncedEvent.getPersisttime());
upLoadEvent.setPersisttime(unsyncedEvent.getPersisttime()/ 1000);
upLoadEvent.setEventvalue(unsyncedEvent.getEventvalue());
upLoadEvent.setEventreason(unsyncedEvent.getEventreason());
upLoadEvent.setEventtype(unsyncedEvent.getEventtype());
LedgerBaseInfoDTO ledgerBaseInfoDTO = LedgerBaseInfoDTOMap.get(unsyncedEvent.getLineid());
if(Objects.isNull(ledgerBaseInfoDTO)){
List<LedgerBaseInfoDTO> baseLineInfo = pqLineMapper.getBaseLineInfo(Stream.of(unsyncedEvent.getLineid()).collect(Collectors.toList()));
ledgerBaseInfoDTO = baseLineInfo.get(0);
}
upLoadEvent.setGdname(ledgerBaseInfoDTO.getGdName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setBdname(ledgerBaseInfoDTO.getStationName());
upLoadEvent.setBusname(ledgerBaseInfoDTO.getBusBarName());
upLoadEvent.setPointname(ledgerBaseInfoDTO.getLineName());
upLoadEvent.setIp(ledgerBaseInfoDTO.getIp());
upLoadEvent.setPt(ledgerBaseInfoDTO.getPt());
@@ -504,6 +540,11 @@ public class DataSynchronization {
}
}
public static void main(String[] args) {
double a =3.00;
System.out.println(a/1000);
}
}

View File

@@ -45,7 +45,7 @@ public class PqlineCache {
private String sysTypeZt;
@PostConstruct
public void init() {
log.info("系统启动中。。。加载pqline");
log.info("初始化刷新redis缓存----------------------");
List<PqLine> pqLines = pqLineMapper.selectList(null);
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+"pqLineList",pqLines);
List<PqsDepts> list = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState, 1).list();

View File

@@ -14,6 +14,8 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.product.event.devcie.config.PqlineCache;
import com.njcn.product.event.devcie.job.LineCacheJob;
import com.njcn.product.event.devcie.mapper.PqLineMapper;
import com.njcn.product.event.devcie.pojo.dto.LedgerBaseInfoDTO;
import com.njcn.product.event.devcie.pojo.po.PqLine;
@@ -93,7 +95,7 @@ public class EventGateController extends BaseController {
private final SmsUtils smsUtils;
private final ThreadPoolTaskExecutor smsTaskExecutor;
private final PqlineCache pqlineCache;
@OperateInfo
@GetMapping("/eventMsg")
@@ -114,6 +116,8 @@ public class EventGateController extends BaseController {
&& Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()
&& (Float.parseFloat(jsonObject.get("persisttime").toString()) * 1000) >= msgEventConfigService.getEventDuration()) {
//过滤重要暂降事件
jsonObject.set("persisttime",new BigDecimal(jsonObject.get("persisttime").toString()).setScale(3,RoundingMode.HALF_UP).toString());
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().eq(PqUserLineAssPO::getLineIndex, lineId));
@@ -137,6 +141,7 @@ public class EventGateController extends BaseController {
webSocketServer.sendMessageToAll(jsonObject.toString());
//针对前置推送的暂降事件进行短信发送功能
smsTaskExecutor.execute(() -> {
sendMessage(jsonObject, str);
});
@@ -182,8 +187,12 @@ public class EventGateController extends BaseController {
try {
//下面一行代码正式环境需要放开
jsonObject = test();
List<PqsDepts> deptsList = (List<PqsDepts>) redisUtil.getObjectByKey(REDIS_DEPT_INDEX + StrUtil.DASHED + "AllDept");
List<String> deptIds = deptsList.stream().map(PqsDepts::getDeptsIndex).distinct().collect(Collectors.toList());
jsonObject.putOpt("dept", String.join(StrUtil.COMMA,deptIds));
if (msgEventConfigService.getEventType().contains(jsonObject.get("wavetype").toString()) && Float.parseFloat(jsonObject.get("eventvalue").toString()) <= msgEventConfigService.getEventValue()) {
log.info("122345678788999999----------测试发送数据成功: {}",jsonObject);
webSocketServer.sendMessageToAll(jsonObject.toString());
//开始发送短信
@@ -202,6 +211,8 @@ public class EventGateController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
private static final int MAX_RETRY_COUNT = 3; // 最大重试次数
//测试模拟,正式环境删除
private PqsEventdetail createEvent(JSONObject jsonObject, LocalDateTime now) {
@@ -225,8 +236,19 @@ public class EventGateController extends BaseController {
//以下部分为测试数据后续删除
List<PqLine> pqLineList = pqLineMapper.selectList(new LambdaQueryWrapper<>());
List<Integer> lineList = pqLineList.stream().map(PqLine::getLineIndex).collect(Collectors.toList());
List<LedgerBaseInfoDTO> baseInfoDTOList = pqLineMapper.getBaseLineInfo(lineList);
Map<Integer, LedgerBaseInfoDTO> map = baseInfoDTOList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
List<LedgerBaseInfoDTO> ledgerBaseInfoDTOS = new ArrayList<>();
if(lineList.size()>1000){
List<List<Integer>> listIds = CollUtil.split(lineList,1000);
for(List<Integer> itemIds : listIds){
List<LedgerBaseInfoDTO> temp =pqLineMapper.getBaseLineInfo(itemIds);
ledgerBaseInfoDTOS.addAll(temp);
}
}else {
List<LedgerBaseInfoDTO> temp =pqLineMapper.getBaseLineInfo(lineList);
ledgerBaseInfoDTOS.addAll(temp);
}
Map<Integer, LedgerBaseInfoDTO> map = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
Random random = new Random();
Integer lineId = lineList.get(random.nextInt(lineList.size()));
@@ -296,7 +318,7 @@ public class EventGateController extends BaseController {
upLoadEvent.setMs(pqsEventdetail.getMs());
upLoadEvent.setBdname("测试电站");
upLoadEvent.setLineid(pqsEventdetail.getLineid());
upLoadEvent.setTimeid(LocalDateTimeUtil.format(pqsEventdetail.getTimeid(),DatePattern.NORM_DATETIME_PATTERN));
upLoadEvent.setTimeid(LocalDateTimeUtil.format(pqsEventdetail.getTimeid(), DatePattern.NORM_DATETIME_PATTERN));
upLoadEvent.setWavetype(pqsEventdetail.getWavetype());
upLoadEvent.setPersisttime(pqsEventdetail.getPersisttime());
upLoadEvent.setEventvalue(pqsEventdetail.getEventvalue());
@@ -328,85 +350,76 @@ public class EventGateController extends BaseController {
private void sendMessage(JSONObject jsonObject, String objStr) {
try {
if (!"/".equals(objStr)) {
log.info("-------------------------开始执行短信发送逻辑{}", System.currentTimeMillis());
TimeInterval timeInterval = new TimeInterval();
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqsDeptsline> pqLineDept = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex, lineId).eq(PqsDeptsline::getSystype, sysTypeZt).list();
Set<String> deptIds = pqLineDept.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toSet());
Set<String> resultIds = getAllParentDeptIds(deptIds);
List<PqsUserSet> pqsUserSetList = pqsUsersetService.lambdaQuery().eq(PqsUserSet::getIsNotice, 1).in(PqsUserSet::getDeptsIndex, resultIds).list();
if (CollUtil.isEmpty(pqsUserSetList)) {
//当前事件未找到用户信息,判断为不需要发送短信用户
return;
}
List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex, PqsUser::getPhone, PqsUser::getName).in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
List<String> userIds = pqsUserList.stream().map(PqsUser::getUserIndex).collect(Collectors.toList());
List<PqsUserSet> poList = pqsUserSetList.stream().filter(it -> userIds.contains(it.getUserIndex())).collect(Collectors.toList());
TimeInterval timeInterval = new TimeInterval();
log.info("-------------------------开始执行短信发送逻辑{}",System.currentTimeMillis());
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
List<PqsDeptsline> pqLineDept = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex, lineId).eq(PqsDeptsline::getSystype, sysTypeZt).list();
Set<String> deptIds = pqLineDept.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toSet());
Set<String> resultIds = getAllParentDeptIds(deptIds);
List<PqsUserSet> pqsUserSetList = pqsUsersetService.lambdaQuery().eq(PqsUserSet::getIsNotice, 1).in(PqsUserSet::getDeptsIndex, resultIds).list();
if (CollUtil.isEmpty(pqsUserSetList)) {
//当前事件未找到用户信息,判断为不需要发送短信用户
return;
}
List<PqsUser> pqsUserList = pqsUserService.lambdaQuery().select(PqsUser::getUserIndex, PqsUser::getPhone, PqsUser::getName).in(PqsUser::getUserIndex, pqsUserSetList.stream().map(PqsUserSet::getUserIndex).collect(Collectors.toList())).list();
List<String> userIds = pqsUserList.stream().map(PqsUser::getUserIndex).collect(Collectors.toList());
List<PqsUserSet> poList = pqsUserSetList.stream().filter(it -> userIds.contains(it.getUserIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(poList)) {
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
List<LedgerBaseInfoDTO> list = pqLineMapper.getBaseLineInfo(Stream.of(lineId).collect(Collectors.toList()));
LedgerBaseInfoDTO ledgerBaseInfoDTO = list.get(0);
BigDecimal bigDecimal = new BigDecimal(jsonObject.get("eventvalue").toString()).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(",").append(ledgerBaseInfoDTO.getStationName()).append(ledgerBaseInfoDTO.getLineName())
.append("发生暂降事件,事件特征幅值").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;影响用户:");
if ("/".equals(objStr)) {
stringBuilder.append("/");
} else {
if (CollUtil.isNotEmpty(poList)) {
StringBuilder stringBuilder = new StringBuilder(jsonObject.get("timeid").toString());
String busName = jsonObject.containsKey("busname")? "_"+jsonObject.get("busname").toString():"";
BigDecimal bigDecimal = new BigDecimal(jsonObject.get("eventvalue").toString()).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
stringBuilder.append(".").append(jsonObject.get("ms").toString()).append(",").append(jsonObject.get("bdname").toString()).append(busName).append("_").append(jsonObject.get("pointname").toString())
.append("发生电压暂降事件,事件残余电压").append(bigDecimal).append("%,持续时间:").append(jsonObject.get("persisttime").toString()).append("S;影响用户:");
stringBuilder.append(objStr);
}
String message;
if (stringBuilder.length() > 500) {
message = stringBuilder.substring(0, 490).concat(";详情请登录电压暂降监测平台查看。");
} else {
message = stringBuilder.toString();
}
List<MsgEventInfo> resultList = new ArrayList<>();
List<SmsSendDTO.ItemInner> msgDTOList = new ArrayList<>();
for (PqsUser user : pqsUserList) {
String msgId = IdUtil.simpleUUID();
SmsSendDTO.ItemInner dto = new SmsSendDTO.ItemInner();
dto.setContent(message);
dto.setTo(user.getPhone());
dto.setCustomMsgID(msgId);
msgDTOList.add(dto);
MsgEventInfo msgEventInfo = new MsgEventInfo();
msgEventInfo.setMsgIndex(msgId);
msgEventInfo.setMsgContent(message);
msgEventInfo.setPhone(user.getPhone());
msgEventInfo.setUserId(user.getUserIndex());
msgEventInfo.setUserName(user.getName());
msgEventInfo.setIsHandle(0);
msgEventInfo.setSendResult(0);
msgEventInfo.setSendTime(LocalDateTime.now());
msgEventInfo.setEventIndex(jsonObject.get("eventdetail_index").toString());
resultList.add(msgEventInfo);
}
List<SmsResponseDTO.SmsItem> result = smsUtils.sendSmSToUser(msgDTOList);
Map<String, SmsResponseDTO.SmsItem> stringSmsItemMap = result.stream().collect(Collectors.toMap(SmsResponseDTO.SmsItem::getCustomMsgID, Function.identity()));
resultList.forEach(item -> {
if (stringSmsItemMap.containsKey(item.getMsgIndex())) {
SmsResponseDTO.SmsItem smsItem = stringSmsItemMap.get(item.getMsgIndex());
item.setSendResult(Objects.equals(smsItem.getCode(), "0") ? 1 : 0);
String message;
if (stringBuilder.length() > 500) {
message = stringBuilder.substring(0, 490).concat(";详情请登录电压暂降监测平台查看。");
} else {
message = stringBuilder.toString();
}
});
msgEventInfoService.saveBatch(resultList);
}
log.info("{}-------------短信发送执行结束,执行时长{}s",System.currentTimeMillis(), timeInterval.intervalSecond());
List<MsgEventInfo> resultList = new ArrayList<>();
List<SmsSendDTO.ItemInner> msgDTOList = new ArrayList<>();
for (PqsUser user : pqsUserList) {
String msgId = IdUtil.simpleUUID();
SmsSendDTO.ItemInner dto = new SmsSendDTO.ItemInner();
dto.setContent(message);
dto.setTo(user.getPhone());
dto.setCustomMsgID(msgId);
msgDTOList.add(dto);
MsgEventInfo msgEventInfo = new MsgEventInfo();
msgEventInfo.setMsgIndex(msgId);
msgEventInfo.setMsgContent(message);
msgEventInfo.setPhone(user.getPhone());
msgEventInfo.setUserId(user.getUserIndex());
msgEventInfo.setUserName(user.getName());
msgEventInfo.setIsHandle(0);
msgEventInfo.setSendResult(0);
msgEventInfo.setSendTime(LocalDateTime.now());
msgEventInfo.setEventIndex(jsonObject.get("eventdetail_index").toString());
resultList.add(msgEventInfo);
}
List<SmsResponseDTO.SmsItem> result = smsUtils.sendSmSToUser(msgDTOList);
Map<String, SmsResponseDTO.SmsItem> stringSmsItemMap = result.stream().collect(Collectors.toMap(SmsResponseDTO.SmsItem::getCustomMsgID, Function.identity()));
resultList.forEach(item -> {
if (stringSmsItemMap.containsKey(item.getMsgIndex())) {
SmsResponseDTO.SmsItem smsItem = stringSmsItemMap.get(item.getMsgIndex());
item.setSendResult(Objects.equals(smsItem.getCode(), "0") ? 1 : 0);
}
});
msgEventInfoService.saveBatch(resultList);
}
log.info("{}-------------短信发送执行结束,执行时长{}s", System.currentTimeMillis(), timeInterval.intervalSecond());
}
} catch (Exception e) {
e.printStackTrace();
log.error("---------短信发送异常,异常信息", e);
@@ -458,6 +471,11 @@ public class EventGateController extends BaseController {
}
return result;
}
@GetMapping("/refreshIdCache")
@ApiOperation("刷新缓存")
public Boolean refreshIdCache() {
pqlineCache.init();
return true;// HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "数据同步");
}
}

View File

@@ -2,7 +2,6 @@ package com.njcn.product.event.transientes.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.event.dataTransmit.DataSynchronization;
import com.njcn.product.event.transientes.pojo.param.PqUserLedgerParam;
import com.njcn.product.event.transientes.pojo.po.PqUserLedgerPO;
import com.njcn.product.event.transientes.service.PqUserLedgerService;

View File

@@ -44,6 +44,7 @@ public class UpLoadEvent {
private String eventtype;
private String gdname;
private String bdname;
private String busname;
private String pointname;
private String wavePath;
private String ip;

View File

@@ -19,6 +19,8 @@ public class UserLegerDTO {
private String powerSupplyArea;
private String customerNo;
private String customerName;
private String electricityAddress;
@@ -27,4 +29,6 @@ public class UserLegerDTO {
private String smallObjType;
private Integer isShow;
}

View File

@@ -47,6 +47,8 @@ public class AuthController extends BaseController {
//针对系统推送的认证特殊处理
if ("system_event".equals(authRequest.getUsername())) {
pass = authRequest.getPassword();
} else if ("cn_test_a".equals(authRequest.getUsername())) {
pass = authRequest.getPassword();
} else {
hasFlag = redisUtil.hasKey(eventRedisKey + authRequest.getUsername());
if (hasFlag) {

View File

@@ -39,6 +39,13 @@ public class MyUserDetailsService implements UserDetailsService {
new ArrayList<>());
}
if("cn_test_a".equals(username)){
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
return new MyUserDetails("12345678910","system_event",encodedPassword,"10001",
new ArrayList<>());
}
if(redisUtil.hasKey("event_smart_"+username)){
String password = redisUtil.getRawValue("event_smart_"+username);

View File

@@ -34,8 +34,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
// .antMatchers("/cn_authenticate","/ws/**","/accept/testEvent","/accept/eventMsg").permitAll() // 允许访问认证接口
.antMatchers("/**").permitAll() // 允许访问认证接口
.antMatchers("/cn_authenticate","/ws/**","/accept/testEvent","/accept/eventMsg","/accept/simpleTest","/accept/phoneSend","/accept/refreshIdCache","/largescreen/sycnUser").permitAll() // 允许访问认证接口
// .antMatchers("/**").permitAll() // 允许访问认证接口
.anyRequest().authenticated()
.and()
.sessionManagement()

View File

@@ -700,6 +700,9 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
LambdaQueryWrapper<MsgEventInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(!StringUtils.isEmpty(largeScreenCountParam.getSendResult()), MsgEventInfo::getSendResult, largeScreenCountParam.getSendResult());
lambdaQueryWrapper.orderByDesc(MsgEventInfo::getSendTime).between(MsgEventInfo::getSendTime, start, end);
if(StrUtil.isNotBlank(largeScreenCountParam.getSearchValue())){
lambdaQueryWrapper.and(w->w.like(MsgEventInfo::getUserName,largeScreenCountParam.getSearchValue()).or().like(MsgEventInfo::getPhone,largeScreenCountParam.getSearchValue()));
}
return msgEventInfoService.page(new Page<>(PageFactory.getPageNum(largeScreenCountParam), PageFactory.getPageSize(largeScreenCountParam)), lambdaQueryWrapper);
}

View File

@@ -1,7 +1,9 @@
package com.njcn.product.event.transientes.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.SM3;
import cn.hutool.json.JSONObject;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
@@ -20,8 +22,8 @@ import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: cdf
@@ -33,8 +35,13 @@ import java.util.List;
@RequiredArgsConstructor
public class SmsUtils {
private final RestTemplate restTemplate;
// 最大重试次数
private static final int MAX_RETRY_COUNT = 2;
//短信平台成功返回码
private static final String SUCCESS_CODE = "0";
//短信平台业务码
private static final String SERVICE_CODE = "01001101";
@Value("${smsServer.info}")
private String smsServer;
@@ -46,7 +53,223 @@ public class SmsUtils {
private String password;
public List<SmsResponseDTO.SmsItem> sendSmSToUser(List<SmsSendDTO.ItemInner> temList) {
/**
* 发送短信给用户
*
* @param itemList 短信内容列表
* @return 发送结果列表
*/
public List<SmsResponseDTO.SmsItem> sendSmSToUser(List<SmsSendDTO.ItemInner> itemList) {
if (CollUtil.isEmpty(itemList)) {
log.info("短信发送列表为空");
return Collections.emptyList();
}
return sendSmSToUserWithRetry(itemList, MAX_RETRY_COUNT);
}
/**
* 带重试机制的短信发送
*
* @param itemList 短信内容列表
* @param retryCount 剩余重试次数
* @return 发送结果列表
*/
private List<SmsResponseDTO.SmsItem> sendSmSToUserWithRetry(List<SmsSendDTO.ItemInner> itemList, int retryCount) {
if (retryCount <= 0) {
log.error("短信发送重试次数耗尽,剩余{}条短信发送失败", itemList.size());
return buildFailedResponse(itemList);
}
try {
SmsSendDTO smsSendDTO = buildSmsRequest(itemList);
ResponseEntity<SmsResponseDTO> response = executeSmsRequest(smsSendDTO);
return processSmsResponse(response, itemList, retryCount);
} catch (RestClientException e) {
log.error("第{}次短信发送网络异常,剩余重试次数: {}",
MAX_RETRY_COUNT - retryCount + 1, retryCount - 1, e);
return sendSmSToUserWithRetry(itemList, retryCount - 1);
} catch (Exception e) {
log.error("第{}次短信发送系统异常,剩余重试次数: {}",
MAX_RETRY_COUNT - retryCount + 1, retryCount - 1, e);
return sendSmSToUserWithRetry(itemList, retryCount - 1);
}
}
/**
* 构建短信请求参数
*/
private SmsSendDTO buildSmsRequest(List<SmsSendDTO.ItemInner> itemList) {
String nowTime = LocalDateTime.now().format(
DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN));
String sm3Hash = new SM3().digestHex(account + password + nowTime);
SmsSendDTO smsSendDTO = new SmsSendDTO();
smsSendDTO.setServiceCode(SERVICE_CODE);
smsSendDTO.setAccount(account);
smsSendDTO.setToken(sm3Hash);
smsSendDTO.setTs(nowTime);
smsSendDTO.setItems(itemList);
log.info("短信请求实体{}", smsSendDTO);
return smsSendDTO;
}
/**
* 执行短信请求
*/
private ResponseEntity<SmsResponseDTO> executeSmsRequest(SmsSendDTO smsSendDTO) {
String url = smsServer + "/sms/msg";
log.info("调用短信接口: {}", url);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
String requestBody = new JSONObject(smsSendDTO).toString();
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody, headers);
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, SmsResponseDTO.class);
}
/**
* 处理短信响应
*/
private List<SmsResponseDTO.SmsItem> processSmsResponse(
ResponseEntity<SmsResponseDTO> response,
List<SmsSendDTO.ItemInner> originalList,
int retryCount) {
// 检查HTTP状态码
if (response.getStatusCode() != HttpStatus.OK) {
log.error("短信接口HTTP状态码异常: {}", response.getStatusCode());
return sendSmSToUserWithRetry(originalList, retryCount - 1);
}
// 检查响应体
SmsResponseDTO smsResponse = response.getBody();
if (smsResponse == null) {
log.error("短信接口返回体为空");
return sendSmSToUserWithRetry(originalList, retryCount - 1);
}
// 检查业务状态码
if (!SUCCESS_CODE.equals(smsResponse.getCode())) {
log.error("短信发送业务失败: {} - {}", smsResponse.getCode(), smsResponse.getMessage());
return sendSmSToUserWithRetry(originalList, retryCount - 1);
}
log.info("短信发送接口调用成功batchId: {}, 发送条数: {}",
smsResponse.getBatchId(), smsResponse.getItems().size());
// 处理部分失败的情况
return handlePartialFailures(smsResponse, originalList);
}
/**
* 处理部分短信发送失败的情况
*/
private List<SmsResponseDTO.SmsItem> handlePartialFailures(
SmsResponseDTO smsResponse,
List<SmsSendDTO.ItemInner> originalList) {
List<SmsResponseDTO.SmsItem> allItems = smsResponse.getItems();
// 找出发送失败的短信ID
List<String> failedIds = allItems.stream()
.filter(item -> !SUCCESS_CODE.equals(item.getCode()))
.map(SmsResponseDTO.SmsItem::getCustomMsgID)
.filter(StrUtil::isNotBlank)
.collect(Collectors.toList());
if (CollUtil.isEmpty(failedIds)) {
log.info("所有短信发送成功!");
return allItems;
}
log.info("发现{}条短信发送失败,尝试重新发送", failedIds.size());
// 找出需要重发的短信内容
List<SmsSendDTO.ItemInner> failedItems = originalList.stream()
.filter(item -> failedIds.contains(item.getCustomMsgID()))
.collect(Collectors.toList());
if (CollUtil.isEmpty(failedItems)) {
log.info("未找到对应的失败短信内容,直接返回原始结果");
return allItems;
}
// 对失败的消息重新发送
List<SmsResponseDTO.SmsItem> retryResults = sendSmSToUserWithRetry(failedItems, MAX_RETRY_COUNT);
// 合并结果:用重试结果替换原有的失败结果
return mergeSmsResults(allItems, retryResults, failedIds);
}
/**
* 合并短信发送结果
*/
private List<SmsResponseDTO.SmsItem> mergeSmsResults(
List<SmsResponseDTO.SmsItem> originalResults,
List<SmsResponseDTO.SmsItem> retryResults,
List<String> originalFailedIds) {
// 创建结果副本
List<SmsResponseDTO.SmsItem> mergedResults = new ArrayList<>(originalResults);
// 构建重试结果的映射,便于查找
Map<String, SmsResponseDTO.SmsItem> retryResultMap = retryResults.stream()
.collect(Collectors.toMap(
SmsResponseDTO.SmsItem::getCustomMsgID,
item -> item,
(existing, replacement) -> replacement
));
// 用重试结果替换原有的失败结果
for (int i = 0; i < mergedResults.size(); i++) {
SmsResponseDTO.SmsItem originalItem = mergedResults.get(i);
String msgId = originalItem.getCustomMsgID();
if (originalFailedIds.contains(msgId)) {
SmsResponseDTO.SmsItem retryItem = retryResultMap.get(msgId);
if (retryItem != null) {
mergedResults.set(i, retryItem);
}
// 如果重试结果中没有找到对应的消息,保持原失败结果
}
}
log.info("结果合并完成,原始结果数: {}, 重试结果数: {}, 合并后结果数: {}",
originalResults.size(), retryResults.size(), mergedResults.size());
return mergedResults;
}
/**
* 构建失败响应
*/
private List<SmsResponseDTO.SmsItem> buildFailedResponse(List<SmsSendDTO.ItemInner> itemList) {
return itemList.stream()
.map(item -> {
SmsResponseDTO.SmsItem failedItem = new SmsResponseDTO.SmsItem();
failedItem.setCustomMsgID(item.getCustomMsgID());
failedItem.setCode("-1");
failedItem.setMsg("短信发送失败,重试次数耗尽");
return failedItem;
})
.collect(Collectors.toList());
}
/* public List<SmsResponseDTO.SmsItem> sendSmSToUser(List<SmsSendDTO.ItemInner> temList,Boolean failFlag) {
if (CollUtil.isEmpty(temList)) {
log.error("短信发送列表为空");
return Collections.emptyList();
}
SmsSendDTO smsSendDTO = new SmsSendDTO();
smsSendDTO.setServiceCode("01001101");
smsSendDTO.setAccount(account);
@@ -60,6 +283,7 @@ public class SmsUtils {
log.info("短信请求实体{}", smsSendDTO);
String url = smsServer + "/sms/msg";
System.out.println(url);
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
@@ -72,27 +296,46 @@ public class SmsUtils {
SmsResponseDTO.class
);
// 处理响应
return handleSmsResponse(response);
return handleSmsResponse(response,failFlag,temList);
} catch (Exception e) {
log.error("短信接口调用失败", e);
return new ArrayList<>();
}
}
private List<SmsResponseDTO.SmsItem> handleSmsResponse(ResponseEntity<SmsResponseDTO> response) {
private List<SmsResponseDTO.SmsItem> handleSmsResponse(ResponseEntity<SmsResponseDTO> response,Boolean failFlag,List<SmsSendDTO.ItemInner> msgList) {
if (response.getStatusCode() == HttpStatus.OK) {
SmsResponseDTO smsResponse = response.getBody();
List<SmsSendDTO.ItemInner> failList = new ArrayList<>();
if (smsResponse != null && "0".equals(smsResponse.getCode())) {
log.info("短信发送成功batchId: {},发送条数{}", smsResponse.getBatchId(),smsResponse.getItems().size());
List<String> ids = smsResponse.getItems().stream().filter(it->!"0".equals(it.getCode())).map(SmsResponseDTO.SmsItem::getCustomMsgID).collect(Collectors.toList());
if(CollUtil.isNotEmpty(ids)){
//调用成功的情况下,依然会存在个别短信发送失败
List<SmsSendDTO.ItemInner> faliList = msgList.stream().filter(it->ids.contains(it.getCustomMsgID())).collect(Collectors.toList());
sendSmSToUser(faliList,false);
}
return smsResponse.getItems();
} else {
log.error("短信发送失败: {}", (smsResponse != null ? smsResponse.getMessage() : "API 返回异常"));
//全部失败重新发送一次
if(failFlag){
//失败重新发送
sendSmSToUser(msgList,false);
}
return new ArrayList<>();
}
} else {
log.error("HTTP 请求失败,状态码: {}", response.getStatusCode());
if(failFlag){
//全部失败重新发送一次
sendSmSToUser(msgList,false);
}
return new ArrayList<>();
}
}
*/
}

View File

@@ -57,10 +57,10 @@ spring:
smsServer:
info: http://22.33.194.50:18096
netInfo: http://22.33.191.206:18096
info: http://22.33.194.49:18095
netInfo: http://20.33.234.143:18095
account: xbjbpt
password: WLv8w071
password: ihS2b73v
aliyun:
oss:

View File

@@ -40,10 +40,10 @@ business:
wavePath: D://Comtrade
targetPath: /pqmonitor
exportBaseDir: D://exportComtrade
eventCronExpression: 0 9 0/1 * * ?
failCronExpression: 0 16 0/1 * * ?
userCronExpression: 0 5 0/1 * * ?
syncinterval: 60
eventCronExpression: 0 0/10 * * * ?
failCronExpression: 0 5/10 * * * ?
userCronExpression: 0 5 1 * * ?
syncinterval: 10
failsyncinterval: 1440
#wavePath: /usr/local/comtrade
#处理临时数据