Compare commits
4 Commits
2025-09
...
2a0367f1ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a0367f1ff | |||
| 0e1605d9b3 | |||
|
|
e0cfcbccf8 | ||
|
|
43e7bc0e39 |
@@ -18,14 +18,17 @@
|
||||
b.logic_next nodeNext,
|
||||
d.Algo_Describe type
|
||||
FROM
|
||||
pqs_tflgploy ploy,
|
||||
pqs_tflgployass a,
|
||||
pqs_tflgass b,
|
||||
pqs_transformer c,
|
||||
sys_dict_data d
|
||||
WHERE
|
||||
a.tf_index = b.tf_index
|
||||
ploy.TP_Index = a.TP_Index
|
||||
and a.tf_index = b.tf_index
|
||||
AND b.tf_index = c.tf_index
|
||||
and c.Wiring = d.id
|
||||
and ploy.Status = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -78,14 +78,6 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
public void processEvents(LocalDateTime startTime, LocalDateTime endTime, String deptId) {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
|
||||
//获取节点和变压器配置信息
|
||||
Map<String, Map<String, Integer>> nodeMap1 = getBeforeNodeInfo();
|
||||
Set<Map.Entry<String, Map<String, Integer>>> nodeSort1 = nodeMap1.entrySet();
|
||||
System.out.println(nodeSort1);
|
||||
|
||||
Map<String, EntityMtrans> entityMtransMap1 = getNodeInfo();
|
||||
Set<Map.Entry<String, EntityMtrans>> setMtrans1 = entityMtransMap1.entrySet();
|
||||
System.out.println(setMtrans1);
|
||||
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
HandleEvent handleEvent = new HandleEvent();
|
||||
@@ -117,6 +109,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
|
||||
for (Map.Entry<String, Integer> mm : mapValue) {
|
||||
for (EntityGroupEvtData groupEvtData : baseList) {
|
||||
//矩阵只计算短路故障相关的事件,其他事件另行计算
|
||||
if (groupEvtData.getNodePhysics().equals(mm.getKey()) && dictData.getId().equals(groupEvtData.getSagReason())) {
|
||||
groupEvtData.setNode(mm.getValue());
|
||||
list.add(groupEvtData);
|
||||
|
||||
@@ -1498,6 +1498,10 @@ public class RespDataServiceImpl extends ServiceImpl<RespDataMapper, RespData> i
|
||||
param.setLineIds(userList);
|
||||
List<DataHarmPowerP> dataHarmPList = historyHarmonicService.getHarmonicPData(param);
|
||||
Map<String, List<DataHarmPowerP>> collect = dataHarmPList.stream().collect(Collectors.groupingBy(DataHarmPowerP::getLineId));
|
||||
Set<String> lineIds = collect.keySet();
|
||||
|
||||
|
||||
|
||||
List<DataHarmPowerP> result = new ArrayList<>();
|
||||
collect.forEach((k,v)->{
|
||||
LineDetailDataVO lineDetailData = lineService.getLineDetailData(k);
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.njcn.product.terminal.mysqlTerminal.pojo.param.UserReportParam;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.Device;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.Line;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.LineDetail;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.po.UserReportPO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.LineDataVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalTree;
|
||||
@@ -58,6 +59,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
private final LineDetailMapper lineDetailMapper;
|
||||
private final AreaMapper areaMapper;
|
||||
private final VoltageMapper voltageMapper;
|
||||
private final UserReportPOMapper userReportPOMapper;
|
||||
|
||||
@Override
|
||||
public List<LedgerTreeDTO> getTree() {
|
||||
@@ -261,7 +263,12 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
lineDetailDataVO.setDevId(device.getId());
|
||||
lineDetailDataVO.setBusinessType(dictDataMapper.selectById(lineDetail.getBusinessType()).getName());
|
||||
lineDetailDataVO.setLoadType(dictDataMapper.selectById(lineDetail.getLoadType()).getName());
|
||||
lineDetailDataVO.setObjName(lineDetail.getObjName());
|
||||
UserReportPO userReportPO = userReportPOMapper.selectById(lineDetail.getObjId());
|
||||
if(Objects.nonNull(userReportPO)){
|
||||
lineDetailDataVO.setObjName(userReportPO.getProjectName());
|
||||
}else {
|
||||
lineDetailDataVO.setObjName("/");
|
||||
}
|
||||
lineDetailDataVO.setId(lineDetail.getNum());
|
||||
lineDetailDataVO.setPtType(TerminalUtils.ptType(lineDetail.getPtType()));
|
||||
lineDetailDataVO.setPt(lineDetail.getPt1() + "/" + lineDetail.getPt2());
|
||||
|
||||
@@ -55,6 +55,9 @@ public class CsPagePO extends BaseEntity {
|
||||
private String status;
|
||||
|
||||
|
||||
private Integer sort;
|
||||
|
||||
|
||||
|
||||
public static final String COL_ID = "id";
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement
|
||||
csElement.setPath(path);
|
||||
csElement.setStatus(1);
|
||||
this.saveOrUpdate(csElement);
|
||||
csElement.setPath(path);
|
||||
return csElement;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
/**
|
||||
@@ -68,11 +70,14 @@ public class CsPagePOServiceImpl extends ServiceImpl<CsPagePOMapper, CsPagePO> i
|
||||
.lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
List<CsPagePO> csPagePOS = JSONUtil.toList(text, CsPagePO.class);
|
||||
// 倒序排列
|
||||
csPagePOS.forEach(temp->{
|
||||
String s = fileStorageUtil.uploadStream(writeJsonStringToInputStream(temp.getPath()), OssPath.CONFIGURATIONPATH, OssPath.CONFIGURATIONNAME);
|
||||
temp.setPid(pid);
|
||||
temp.setStatus("1");
|
||||
temp.setPath(s);
|
||||
temp.setCreateTime(LocalDateTime.now());
|
||||
temp.setUpdateTime(LocalDateTime.now());
|
||||
this.save(temp);
|
||||
});
|
||||
} catch (IOException e) {
|
||||
@@ -109,8 +114,8 @@ public class CsPagePOServiceImpl extends ServiceImpl<CsPagePOMapper, CsPagePO> i
|
||||
QueryWrapper<CsPagePO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank (csPageParam.getPid()),CsPagePO.COL_PID,csPageParam.getPid()).
|
||||
like(StrUtil.isNotBlank (csPageParam.getSearchValue()),CsPagePO.COL_NAME,csPageParam.getSearchValue()).
|
||||
eq ("status",1);
|
||||
// orderByAsc(CsPagePO.COL_KID)
|
||||
eq ("status",1).
|
||||
orderByAsc("sort");
|
||||
|
||||
IPage<CsPagePO> pageData = this.page(new Page<>(csPageParam.getPageNum(), csPageParam.getPageSize()), queryWrapper);
|
||||
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.njcn.product.event.dataTransmit;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.product.event.transientes.mapper.PqsEventDetailStatusMapper;
|
||||
import com.njcn.product.event.transientes.mapper.PqsEventdetailMapper;
|
||||
import com.njcn.product.event.transientes.pojo.po.PqsEventDetailStatusPO;
|
||||
import com.njcn.product.event.transientes.pojo.po.PqsEventdetail;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-20
|
||||
* @Description: 暂降事件同步
|
||||
*/
|
||||
@Service
|
||||
@EnableScheduling
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class dataSynchronization {
|
||||
|
||||
private final PqsEventdetailMapper pqsEventdetailMapper;
|
||||
|
||||
private final PqsEventDetailStatusMapper pqsEventDetailStatusMapper;
|
||||
|
||||
// 文件配置
|
||||
@Value("${business.wavePath}")
|
||||
private String sourceWaveDir;
|
||||
|
||||
@Value("${business.exportBaseDir}")
|
||||
private String exportBaseDir;
|
||||
|
||||
// 定时任务配置
|
||||
// 默认每2小时执行一次
|
||||
private String cronExpression = "0 0 */2 * * ?";
|
||||
|
||||
private volatile boolean isRunning = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 定时执行的同步任务
|
||||
*/
|
||||
@Scheduled(cron = "${sag.sync.cronExpression}")
|
||||
@Transactional
|
||||
public void syncPqsEventdetails() {
|
||||
// 防止任务并发执行
|
||||
if (isRunning) {
|
||||
log.warn("同步任务正在执行中,跳过本次调度");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isRunning = true;
|
||||
log.info("=== 开始暂降事件波形文件同步任务 ===");
|
||||
|
||||
// 初始化
|
||||
initialize();
|
||||
|
||||
// 同步最近N天的事件,因为存在事件补招,延迟的原因,采用大范围扫描
|
||||
LocalDateTime end = LocalDateTime.now();
|
||||
LocalDateTime start = end.minusHours(24);
|
||||
syncEvents(start, end);
|
||||
|
||||
log.info("=== 同步任务完成 ===");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步任务执行失败", e);
|
||||
} finally {
|
||||
isRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化操作
|
||||
*/
|
||||
private void initialize() throws Exception {
|
||||
// 检查目录
|
||||
checkDirectories();
|
||||
|
||||
// 检查同步状态表
|
||||
checkSyncStatusTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步指定时间范围内的事件
|
||||
*/
|
||||
public void syncEvents(LocalDateTime startTime, LocalDateTime endTime) throws Exception {
|
||||
// 创建导出目录
|
||||
String startStr = startTime.format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN));
|
||||
String endStr = startTime.format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN));
|
||||
|
||||
String exportDirName = String.format("%s_%s.json", startStr,endStr);
|
||||
Path exportDir = Paths.get(exportBaseDir, exportDirName);
|
||||
Files.createDirectories(exportDir);
|
||||
log.info("创建导出目录: " + exportDir.toAbsolutePath());
|
||||
|
||||
// 查询未同步的事件
|
||||
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid,startTime,endTime);
|
||||
List<PqsEventdetail> unsyncedEvents = pqsEventdetailMapper.selectList(lambdaQueryWrapper);
|
||||
log.info("查询到 " + unsyncedEvents.size() + " 个暂降事件");
|
||||
if(CollUtil.isEmpty(unsyncedEvents)){
|
||||
return ;
|
||||
}
|
||||
|
||||
// 查询已经存在记录的暂降事件
|
||||
LambdaQueryWrapper<PqsEventDetailStatusPO> statusPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
statusPOLambdaQueryWrapper.between(PqsEventDetailStatusPO::getEventTime,startTime,endTime);
|
||||
List<PqsEventDetailStatusPO> hasList = pqsEventDetailStatusMapper.selectList(statusPOLambdaQueryWrapper);
|
||||
log.info("查询到 " + hasList.size() + "条已存在记录事件");
|
||||
//波形文件失败的事件id
|
||||
List<String> waveFailEventDetailIds = hasList.stream().filter(it->it.getWaveFlag() == 0).map(PqsEventDetailStatusPO::getEventDetailId).collect(Collectors.toList());
|
||||
|
||||
|
||||
//排除已经成功的事件
|
||||
if(CollUtil.isNotEmpty(hasList)){
|
||||
List<String> hasIds = hasList.stream().map(PqsEventDetailStatusPO::getEventDetailId).collect(Collectors.toList());
|
||||
unsyncedEvents = unsyncedEvents.stream().filter(it->!hasIds.contains(it.getEventdetailIndex())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//对为上传的事件进行上传操作
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查必要的目录是否存在
|
||||
*/
|
||||
private void checkDirectories() throws IOException {
|
||||
// 检查源目录
|
||||
Path sourceDir = Paths.get(sourceWaveDir);
|
||||
if (!Files.exists(sourceDir)) {
|
||||
throw new IOException("源波形文件目录不存在: " + sourceDir);
|
||||
}
|
||||
|
||||
// 检查导出基础目录
|
||||
Path exportDir = Paths.get(exportBaseDir);
|
||||
if (!Files.exists(exportDir)) {
|
||||
Files.createDirectories(exportDir);
|
||||
log.info("创建导出基础目录: " + exportDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查同步状态表是否存在
|
||||
*/
|
||||
private void checkSyncStatusTable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出单个事件
|
||||
*/
|
||||
private void exportSingleEvent(Path exportDir, PqsEventdetail event) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成事件信息文件
|
||||
*/
|
||||
private void generateEventInfoFile(Path eventDir, PqsEventdetail event) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成同步报告
|
||||
*/
|
||||
private void generateSyncReport(Path exportDir, int totalEvents, int successCount, int failureCount) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新事件同步状态
|
||||
*/
|
||||
private void updateSyncStatus(PqsEventdetail event, int status, String errorMessage) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取波形类型描述
|
||||
*/
|
||||
private String getWaveTypeDesc(Integer waveType) {
|
||||
if (waveType == null) return "未知";
|
||||
|
||||
switch (waveType) {
|
||||
case 1: return "电压暂降";
|
||||
case 2: return "电压暂升";
|
||||
case 3: return "电压中断";
|
||||
case 4: return "电压波动";
|
||||
default: return "未知类型(" + waveType + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务运行状态
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -25,6 +26,7 @@ import com.njcn.product.event.transientes.pojo.po.*;
|
||||
import com.njcn.product.event.transientes.service.CommGeneralService;
|
||||
import com.njcn.product.event.transientes.service.MsgEventConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
|
||||
@@ -35,6 +37,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.DoubleStream;
|
||||
@@ -47,6 +51,7 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
|
||||
|
||||
private final CommGeneralService commGeneralService;
|
||||
@@ -71,7 +76,7 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
|
||||
|
||||
@Override
|
||||
public void exportWordReport(HttpServletResponse response, ReportExportParam param) {
|
||||
|
||||
log.info(LocalDateTime.now()+"开始导出word报告");
|
||||
try {
|
||||
List<Integer> deptIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
@@ -154,7 +159,18 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
|
||||
|
||||
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex, lineIds));
|
||||
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId, userIds));
|
||||
LambdaQueryWrapper<PqUserLedgerPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (userIds.size() > 1000) {
|
||||
List<List<String>> listUserIds = CollUtil.split(userIds, 1000);
|
||||
queryWrapper.and(w -> {
|
||||
for (List<String> ids : listUserIds) {
|
||||
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
queryWrapper.in(PqUserLedgerPO::getId, userIds);
|
||||
}
|
||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(queryWrapper);
|
||||
Map<String, List<PqUserLedgerPO>> stringListMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
|
||||
|
||||
String treeStr = userToStr(stringListMap, treePOMap);
|
||||
@@ -167,12 +183,18 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
|
||||
Map<String,Object> map = mapper.convertValue(bjReportDTO,Map.class);
|
||||
|
||||
WordTemplate.generateWordDownload("template/bj_report.docx", response, bjReportDTO.getDateFormat()+"重要敏感用户电压暂降事件监测情况.docx", map);
|
||||
log.info(LocalDateTime.now()+"结束导出word报告");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(LocalDateTime.now()+"导出word报告出现异常:"+e.getMessage());
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void areaAssemble(BjCustomReportDTO bjReportDTO, ReportExportParam param, Map<String, PqsDicData> pqsDicDataMap) {
|
||||
log.info(LocalDateTime.now()+"组装word报告");
|
||||
|
||||
List<PqsDeptDTO> pqsDeptsList = pqsDeptsMapper.getDeptList(param.getDeptList());
|
||||
Map<String,String> deptMap = pqsDeptsList.stream().collect(Collectors.toMap(PqsDeptDTO::getDeptsIndex,PqsDeptDTO::getDeptsname));
|
||||
List<String> areaContentList = new ArrayList<>();
|
||||
@@ -233,9 +255,18 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
|
||||
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,lineIds));
|
||||
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<PqUserLedgerPO> pqUserLedgerPOLambdaQueryWrapper = new LambdaQueryWrapper<PqUserLedgerPO>();
|
||||
pqUserLedgerPOLambdaQueryWrapper.in(PqUserLedgerPO::getId,userIds).eq(PqUserLedgerPO::getIsShow,1);
|
||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(pqUserLedgerPOLambdaQueryWrapper);
|
||||
LambdaQueryWrapper<PqUserLedgerPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (userIds.size() > 1000) {
|
||||
List<List<String>> listUserIds = CollUtil.split(userIds, 1000);
|
||||
queryWrapper.eq(PqUserLedgerPO::getIsShow,1).and(w -> {
|
||||
for (List<String> ids : listUserIds) {
|
||||
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
queryWrapper.eq(PqUserLedgerPO::getIsShow,1).in(PqUserLedgerPO::getId, userIds);
|
||||
}
|
||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(queryWrapper);
|
||||
if(CollectionUtils.isEmpty(pqUserLedgerPOList)){
|
||||
userContext ="不涉及半导体及重点关注用户。";
|
||||
}else {
|
||||
|
||||
@@ -68,6 +68,7 @@ public class WordTemplate {
|
||||
MyXWPFDocument document = new MyXWPFDocument (temPath);
|
||||
|
||||
WordExportUtil.exportWord07(document, data);
|
||||
System.out.println("开始合并单元格");
|
||||
mergeTableCells(document);
|
||||
try (OutputStream outputStream = response.getOutputStream()) {
|
||||
document.write(outputStream);
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
@@ -19,11 +20,15 @@ import com.njcn.product.event.devcie.pojo.po.PqsDeptsline;
|
||||
import com.njcn.product.event.devcie.service.PqsDeptslineService;
|
||||
import com.njcn.product.event.transientes.mapper.PqUserLedgerMapper;
|
||||
import com.njcn.product.event.transientes.mapper.PqUserLineAssMapper;
|
||||
import com.njcn.product.event.transientes.pojo.dto.MsgDTO;
|
||||
import com.njcn.product.event.transientes.pojo.dto.SmsResponseDTO;
|
||||
import com.njcn.product.event.transientes.pojo.dto.SmsSendDTO;
|
||||
import com.njcn.product.event.transientes.pojo.param.MonitorTerminalParam;
|
||||
import com.njcn.product.event.transientes.pojo.param.SimulationMsgParam;
|
||||
import com.njcn.product.event.transientes.pojo.po.*;
|
||||
import com.njcn.product.event.transientes.service.*;
|
||||
import com.njcn.product.event.transientes.service.impl.MsgEventInfoServiceImpl;
|
||||
import com.njcn.product.event.transientes.utils.SmsUtils;
|
||||
import com.njcn.product.event.transientes.websocket.WebSocketServer;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -34,12 +39,15 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -64,6 +72,7 @@ public class EventGateController extends BaseController {
|
||||
@Value("${SYS_TYPE_ZT}")
|
||||
private String sysTypeZt;
|
||||
|
||||
|
||||
private final WebSocketServer webSocketServer;
|
||||
|
||||
private final PqsDeptslineService pqsDeptslineService;
|
||||
@@ -84,6 +93,8 @@ public class EventGateController extends BaseController {
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final SmsUtils smsUtils;
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/eventMsg")
|
||||
@@ -174,6 +185,7 @@ public class EventGateController extends BaseController {
|
||||
try {
|
||||
sendMessage(jsonObject);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("短信组装发送失败!失败原因{}",e.getMessage());
|
||||
}
|
||||
|
||||
@@ -275,7 +287,7 @@ public class EventGateController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
private void sendMessage(JSONObject jsonObject) throws Exception{
|
||||
private void sendMessage(JSONObject jsonObject){
|
||||
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());
|
||||
@@ -300,19 +312,38 @@ public class EventGateController extends BaseController {
|
||||
// System.out.println(stringBuilder);
|
||||
|
||||
List<MsgEventInfo> resultList = new ArrayList<>();
|
||||
List<MsgDTO> msgDTOList = new ArrayList<>();
|
||||
for (PqsUser user : pqsUserList) {
|
||||
String msgId = IdUtil.simpleUUID();
|
||||
|
||||
MsgDTO dto = new MsgDTO();
|
||||
dto.setMessage(stringBuilder.toString());
|
||||
dto.setPhone(user.getPhone());
|
||||
dto.setCustomMsgID(msgId);
|
||||
msgDTOList.add(dto);
|
||||
|
||||
MsgEventInfo msgEventInfo = new MsgEventInfo();
|
||||
msgEventInfo.setEventIndex(jsonObject.get("eventdetail_index").toString());
|
||||
msgEventInfo.setMsgIndex(msgId);
|
||||
msgEventInfo.setMsgContent(stringBuilder.toString());
|
||||
msgEventInfo.setMsgIndex(IdUtil.simpleUUID());
|
||||
msgEventInfo.setPhone(user.getPhone());
|
||||
msgEventInfo.setSendResult(0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -326,6 +357,10 @@ public class EventGateController extends BaseController {
|
||||
}
|
||||
|
||||
private boolean apiSend(){
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.njcn.product.event.transientes.job;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-16
|
||||
* @Description: 定时同步暂降数据包
|
||||
*/
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@RequiredArgsConstructor
|
||||
public class ScheduledEvent implements SchedulingConfigurer {
|
||||
|
||||
@Value("${}")
|
||||
private final String cronStr = "";
|
||||
|
||||
// 源文件夹路径
|
||||
private final String sourceFolderPath = "D:\\";
|
||||
// 压缩文件输出路径
|
||||
private final String zipOutputPath = "./output_zips";
|
||||
// 最终存放压缩文件的目录
|
||||
private final String finalDestination = "./archive";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
taskRegistrar.addTriggerTask(
|
||||
() -> dataToFile(),
|
||||
triggerContext -> {
|
||||
CronTrigger trigger = new CronTrigger(cronStr);
|
||||
return trigger.nextExecutionTime(triggerContext);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void dataToFile() {
|
||||
try {
|
||||
// 1. 创建临时文件夹并写入测试文件
|
||||
String folderName = "data_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
||||
Path sourceDir = Paths.get(sourceFolderPath, folderName);
|
||||
Files.createDirectories(sourceDir);
|
||||
|
||||
// 模拟生成文件(例如:log.txt)
|
||||
Path testFile = sourceDir.resolve("log.txt");
|
||||
Files.write(testFile, "This is a test log file.".getBytes(), StandardOpenOption.CREATE);
|
||||
|
||||
// 2. 压缩文件夹
|
||||
Path zipOutputDir = Paths.get(zipOutputPath);
|
||||
Files.createDirectories(zipOutputDir);
|
||||
Path zipFile = zipOutputDir.resolve(folderName + ".zip");
|
||||
|
||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile.toFile()))) {
|
||||
Files.walk(sourceDir)
|
||||
.filter(path -> !Files.isDirectory(path))
|
||||
.forEach(path -> {
|
||||
String zipEntryName = sourceDir.relativize(path).toString();
|
||||
try {
|
||||
zos.putNextEntry(new ZipEntry(zipEntryName));
|
||||
Files.copy(path, zos);
|
||||
zos.closeEntry();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to add file to zip: " + path, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 3. 移动压缩文件到最终目录
|
||||
Path finalDir = Paths.get(finalDestination);
|
||||
Files.createDirectories(finalDir);
|
||||
Path targetPath = finalDir.resolve(zipFile.getFileName());
|
||||
Files.move(zipFile, targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
// 4. 删除临时文件夹(可选)
|
||||
deleteDirectory(sourceDir.toFile());
|
||||
|
||||
System.out.println("Task completed: " + targetPath);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归删除目录
|
||||
*/
|
||||
private void deleteDirectory(File directory) {
|
||||
File[] allContents = directory.listFiles();
|
||||
if (allContents != null) {
|
||||
for (File file : allContents) {
|
||||
deleteDirectory(file);
|
||||
}
|
||||
}
|
||||
directory.delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.product.event.transientes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.product.event.transientes.pojo.po.PqsEventDetailStatusPO;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-20
|
||||
* @Description:
|
||||
*/
|
||||
public interface PqsEventDetailStatusMapper extends BaseMapper<PqsEventDetailStatusPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.product.event.transientes.pojo.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-15
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class MsgDTO {
|
||||
|
||||
private String message;
|
||||
|
||||
private String phone;
|
||||
|
||||
@JsonProperty(value = "customMsgID")
|
||||
private String customMsgID;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.product.event.transientes.pojo.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-15
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class SmsResponseDTO {
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
private String batchId;
|
||||
private List<SmsItem> items;
|
||||
|
||||
|
||||
@Data
|
||||
public static class SmsItem {
|
||||
private String msg;
|
||||
|
||||
private String code;
|
||||
|
||||
@JsonProperty(value = "customMsgID")
|
||||
private String customMsgID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.product.event.transientes.pojo.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-15
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class SmsSendDTO {
|
||||
|
||||
private String serviceCode;
|
||||
|
||||
private String account;
|
||||
|
||||
private String token;
|
||||
|
||||
private String ts;
|
||||
|
||||
private List<ItemInner> items;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class ItemInner{
|
||||
private String content;
|
||||
|
||||
@JsonProperty(value = "customMsgID")
|
||||
private String customMsgID;
|
||||
|
||||
private String to;
|
||||
|
||||
private String ext;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.product.event.transientes.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-20
|
||||
* @Description: 暂降事件同步记录
|
||||
*/
|
||||
@Data
|
||||
public class PqsEventDetailStatusPO {
|
||||
|
||||
@TableId(value = "EVENT_DETAIL_ID")
|
||||
private String eventDetailId;
|
||||
|
||||
@TableField(value = "EVENT_TIME")
|
||||
private Date eventTime;
|
||||
|
||||
@TableField(value = "WAVE_FLAG")
|
||||
private int waveFlag;
|
||||
|
||||
@TableField(value = "SYNC_STATUE")
|
||||
private int syncStatus;
|
||||
|
||||
@TableField(value = "SYNC_TIME")
|
||||
private LocalDateTime syncTime;
|
||||
|
||||
@TableField(value = "REMARK")
|
||||
private String remark;
|
||||
|
||||
@TableField(value = "RETRY_COUNT")
|
||||
private int retryCount;
|
||||
|
||||
}
|
||||
@@ -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").permitAll() // 允许访问认证接口
|
||||
.antMatchers("/**").permitAll() // 允许访问认证接口
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.sessionManagement()
|
||||
|
||||
@@ -38,8 +38,15 @@ public class EventGateServiceImpl implements EventGateService {
|
||||
private final WaveFileComponent waveFileComponent;
|
||||
private final PqLineService pqLineService;
|
||||
private final PqLinedetailMapper pqLinedetailMapper;
|
||||
@Value("${WAVEPATH}")
|
||||
@Value("${business.wavePath}")
|
||||
private String WAVEPATH;
|
||||
|
||||
|
||||
/**
|
||||
* 波形分析
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) {
|
||||
WaveDataDTO waveDataDTO;
|
||||
|
||||
@@ -502,7 +502,18 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex, ids));
|
||||
if (CollUtil.isNotEmpty(assList)) {
|
||||
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId, userIds));
|
||||
LambdaQueryWrapper<PqUserLedgerPO> wrapper = new LambdaQueryWrapper<>();
|
||||
if(userIds.size()>1000){
|
||||
List<List<String>> userIdsList = CollUtil.split(userIds, 1000);
|
||||
wrapper.and(w -> {
|
||||
for (List<String> teIds : userIdsList) {
|
||||
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, teIds));
|
||||
}
|
||||
});
|
||||
}else {
|
||||
wrapper.in(PqUserLedgerPO::getId, userIds);
|
||||
}
|
||||
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(wrapper);
|
||||
userMap = poList.stream().collect(Collectors.toMap(PqUserLedgerPO::getId, Function.identity()));
|
||||
assMap = assList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex));
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.njcn.product.event.transientes.utils;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.crypto.digest.SM3;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.product.event.transientes.pojo.dto.MsgDTO;
|
||||
import com.njcn.product.event.transientes.pojo.dto.SmsResponseDTO;
|
||||
import com.njcn.product.event.transientes.pojo.dto.SmsSendDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-10-15
|
||||
* @Description: 短信工具
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsUtils {
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Value("${smsServer.info}")
|
||||
private String smsServer;
|
||||
|
||||
@Value("${smsServer.account}")
|
||||
private String account;
|
||||
|
||||
@Value("${smsServer.password}")
|
||||
private String password;
|
||||
|
||||
|
||||
public List<SmsResponseDTO.SmsItem> sendSmSToUser(List<MsgDTO> msgDTOList) {
|
||||
SmsSendDTO smsSendDTO = new SmsSendDTO();
|
||||
smsSendDTO.setServiceCode("101001101");
|
||||
smsSendDTO.setAccount(account);
|
||||
|
||||
String nowTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN));
|
||||
String sm3Hash = new SM3().digestHex(account + password + nowTime);
|
||||
smsSendDTO.setToken(sm3Hash);
|
||||
smsSendDTO.setTs(nowTime);
|
||||
|
||||
List<SmsSendDTO.ItemInner> temList = new ArrayList<>();
|
||||
for (MsgDTO dto : msgDTOList) {
|
||||
SmsSendDTO.ItemInner inner = new SmsSendDTO.ItemInner();
|
||||
inner.setTo(dto.getPhone());
|
||||
inner.setContent(dto.getMessage());
|
||||
temList.add(inner);
|
||||
}
|
||||
smsSendDTO.setItems(temList);
|
||||
|
||||
String url = smsServer + "/sms/msg";
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(new JSONObject(smsSendDTO).toString(), headers);
|
||||
|
||||
ResponseEntity<SmsResponseDTO> response = restTemplate.exchange(
|
||||
url,
|
||||
HttpMethod.POST,
|
||||
requestEntity,
|
||||
SmsResponseDTO.class
|
||||
);
|
||||
// 处理响应
|
||||
return handleSmsResponse(response);
|
||||
} catch (RestClientException e) {
|
||||
log.error("短信接口调用失败", e);
|
||||
throw new RuntimeException("短信发送异常", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<SmsResponseDTO.SmsItem> handleSmsResponse(ResponseEntity<SmsResponseDTO> response) {
|
||||
if (response.getStatusCode() == HttpStatus.OK) {
|
||||
SmsResponseDTO smsResponse = response.getBody();
|
||||
if (smsResponse != null && "0".equals(smsResponse.getCode())) {
|
||||
log.info("短信发送成功,batchId: {}", smsResponse.getBatchId());
|
||||
return smsResponse.getItems();
|
||||
} else {
|
||||
log.error("短信发送失败: {}", (smsResponse != null ? smsResponse.getMessage() : "API 返回异常"));
|
||||
throw new BusinessException("调用短信服务失败");
|
||||
}
|
||||
} else {
|
||||
log.error("HTTP 请求失败,状态码: {}", response.getStatusCode());
|
||||
throw new BusinessException("调用短信服务失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,3 +51,8 @@ spring:
|
||||
min-idle: 0
|
||||
|
||||
|
||||
smsServer:
|
||||
info: http://22.33.194.50:18096
|
||||
netInfo: http://22.33.191.206:18096
|
||||
account: sms
|
||||
password: aaa
|
||||
|
||||
@@ -53,3 +53,8 @@ spring:
|
||||
min-idle: 0
|
||||
|
||||
|
||||
smsServer:
|
||||
info: http://22.33.194.49:18095
|
||||
netInfo: http://20.33.234.143:18095
|
||||
account: sms
|
||||
password: aaa
|
||||
|
||||
@@ -38,6 +38,9 @@ db:
|
||||
business:
|
||||
#处理波形数据位置
|
||||
wavePath: D://Comtrade
|
||||
|
||||
exportBaseDir: D://exportComtrade
|
||||
cronExpression:
|
||||
#wavePath: /usr/local/comtrade
|
||||
#处理临时数据
|
||||
tempPath: D://file
|
||||
@@ -67,7 +70,7 @@ threadPool:
|
||||
maxPoolSize: 20
|
||||
queueCapacity: 500
|
||||
keepAliveSeconds: 60
|
||||
WAVEPATH: D:/Comtrade
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user