Compare commits
15 Commits
8ccdb84ea9
...
2026-01
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99ab77dcf0 | ||
|
|
c772c9cd81 | ||
| 996ec87ea8 | |||
|
|
b6eaff3b1e | ||
|
|
56bf5bb7c9 | ||
|
|
7410d32241 | ||
|
|
41ba37b723 | ||
|
|
3f77d30cfd | ||
| f71f87ced4 | |||
| 32295f60c0 | |||
|
|
d2945b0fb2 | ||
|
|
133766a2c7 | ||
| 2a5a5087ad | |||
| 4edb27d20b | |||
| 71d6636be0 |
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||||
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
|
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
|
||||||
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||||
|
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
|
||||||
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||||
|
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
|
||||||
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
|
||||||
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
import com.njcn.advance.service.govern.voltage.ISgMachineService;
|
||||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||||
@@ -56,12 +58,34 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
|||||||
@Override
|
@Override
|
||||||
public String addMachine(SgMachineParam sgMachineParam) {
|
public String addMachine(SgMachineParam sgMachineParam) {
|
||||||
SgMachine sgMachine = new SgMachine();
|
SgMachine sgMachine = new SgMachine();
|
||||||
|
checkMachineName(sgMachineParam, false);
|
||||||
|
|
||||||
BeanUtil.copyProperties(sgMachineParam, sgMachine);
|
BeanUtil.copyProperties(sgMachineParam, sgMachine);
|
||||||
//默认为正常状态
|
//默认为正常状态
|
||||||
sgMachine.setState(DataStateEnum.ENABLE.getCode());
|
sgMachine.setState(DataStateEnum.ENABLE.getCode());
|
||||||
this.save(sgMachine);
|
this.save(sgMachine);
|
||||||
return sgMachine.getId();
|
return sgMachine.getId();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 校验参数,检查是否存在相同名称的业务用户
|
||||||
|
*/
|
||||||
|
private void checkMachineName(SgMachineParam sgMachineParam, boolean isExcludeSelf) {
|
||||||
|
LambdaQueryWrapper<SgMachine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
sgUserLambdaQueryWrapper
|
||||||
|
.eq(SgMachine::getName, sgMachineParam.getName())
|
||||||
|
.eq(SgMachine::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
//更新的时候,需排除当前记录
|
||||||
|
if (isExcludeSelf) {
|
||||||
|
if (sgMachineParam instanceof SgMachineParam.SgMachineUpdateParam) {
|
||||||
|
sgUserLambdaQueryWrapper.ne(SgMachine::getId, ((SgMachineParam.SgMachineUpdateParam) sgMachineParam).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||||
|
//大于等于1个则表示重复
|
||||||
|
if (countByAccount >= 1) {
|
||||||
|
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新设备
|
* 更新设备
|
||||||
@@ -70,6 +94,8 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
|
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
|
||||||
SgMachine sgMachine = new SgMachine();
|
SgMachine sgMachine = new SgMachine();
|
||||||
|
checkMachineName(updateParam, true);
|
||||||
|
|
||||||
BeanUtil.copyProperties(updateParam, sgMachine);
|
BeanUtil.copyProperties(updateParam, sgMachine);
|
||||||
return this.updateById(sgMachine);
|
return this.updateById(sgMachine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package com.njcn.advance.service.govern.voltage.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||||
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
|
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
|
||||||
|
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
|
||||||
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
|
||||||
|
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
|
||||||
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
|
||||||
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
|
||||||
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
|
||||||
@@ -54,12 +57,34 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
|||||||
@Override
|
@Override
|
||||||
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
|
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
|
||||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||||
|
checkSensitiveUnitName(sgSensitiveUnitParam, false);
|
||||||
|
|
||||||
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
|
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
|
||||||
//默认为正常状态
|
//默认为正常状态
|
||||||
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
|
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
|
||||||
this.save(sgSensitiveUnit);
|
this.save(sgSensitiveUnit);
|
||||||
return sgSensitiveUnit.getId();
|
return sgSensitiveUnit.getId();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 校验参数,检查是否存在相同名称的业务用户
|
||||||
|
*/
|
||||||
|
private void checkSensitiveUnitName(SgSensitiveUnitParam sgSensitiveUnitParam, boolean isExcludeSelf) {
|
||||||
|
LambdaQueryWrapper<SgSensitiveUnit> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
sgUserLambdaQueryWrapper
|
||||||
|
.eq(SgSensitiveUnit::getName, sgSensitiveUnitParam.getName())
|
||||||
|
.eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
//更新的时候,需排除当前记录
|
||||||
|
if (isExcludeSelf) {
|
||||||
|
if (sgSensitiveUnitParam instanceof SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) {
|
||||||
|
sgUserLambdaQueryWrapper.ne(SgSensitiveUnit::getId, ((SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) sgSensitiveUnitParam).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int countByAccount = this.count(sgUserLambdaQueryWrapper);
|
||||||
|
//大于等于1个则表示重复
|
||||||
|
if (countByAccount >= 1) {
|
||||||
|
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新元器件
|
* 更新元器件
|
||||||
@@ -69,6 +94,8 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
|
|||||||
@Override
|
@Override
|
||||||
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
|
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
|
||||||
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
|
||||||
|
checkSensitiveUnitName(updateParam, true);
|
||||||
|
|
||||||
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
|
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
|
||||||
return this.updateById(sgSensitiveUnit);
|
return this.updateById(sgSensitiveUnit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import io.swagger.models.auth.In;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -511,7 +512,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
|||||||
lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue());
|
lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue());
|
||||||
}
|
}
|
||||||
lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1))
|
lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1))
|
||||||
.orderByAsc(RmpEventDetailAssPO::getTimeId);
|
.orderByDesc(RmpEventDetailAssPO::getTimeId);
|
||||||
return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper);
|
return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,7 +734,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
|||||||
|
|
||||||
List<AdvanceEventDetailVO> advanceEventDetailVOLsit = querySagEventsAll(startTime, endTime);
|
List<AdvanceEventDetailVO> advanceEventDetailVOLsit = querySagEventsAll(startTime, endTime);
|
||||||
|
|
||||||
|
advanceEventDetailVOLsit = advanceEventDetailVOLsit.stream().filter(temp-> StringUtils.isNotEmpty(temp.getAdvanceType())).collect(Collectors.toList());
|
||||||
for (AdvanceEventDetailVO advanceEventDetailVO : advanceEventDetailVOLsit) { // 获取监测点线路序号
|
for (AdvanceEventDetailVO advanceEventDetailVO : advanceEventDetailVOLsit) { // 获取监测点线路序号
|
||||||
//母线id
|
//母线id
|
||||||
String nodePhysics = advanceEventDetailVO.getVoltageId();
|
String nodePhysics = advanceEventDetailVO.getVoltageId();
|
||||||
|
|||||||
@@ -81,7 +81,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
|||||||
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
|
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
|
||||||
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
try {
|
||||||
|
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
|
||||||
|
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
|
||||||
|
} catch (Exception e1) {
|
||||||
|
|
||||||
|
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取
|
//读取
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class BpmSignParam extends BaseEntity implements Serializable {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty("标识key")
|
@ApiModelProperty("标识key")
|
||||||
private String key;
|
private String signKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
|
|||||||
@Override
|
@Override
|
||||||
public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) {
|
public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) {
|
||||||
QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>();
|
||||||
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getName())) {
|
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getSearchValue())) {
|
||||||
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getName());
|
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getSearchValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {
|
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public class BpmSignServiceImpl extends ServiceImpl<BpmSignMapper, BpmSign> impl
|
|||||||
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
|
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(bpmSignQueryParam.getKey())) {
|
if (StrUtil.isNotBlank(bpmSignQueryParam.getSignKey())) {
|
||||||
bpmSignVOQueryWrapper.like("bpm_sign.signKey", bpmSignQueryParam.getKey());
|
bpmSignVOQueryWrapper.like("bpm_sign.sign_key", bpmSignQueryParam.getSignKey());
|
||||||
}
|
}
|
||||||
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
|
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
|
||||||
bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort");
|
bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort");
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public interface PatternRegex {
|
|||||||
/**
|
/**
|
||||||
* 任意字符,长度在1-20位,常用于名称、编码等常规录入
|
* 任意字符,长度在1-20位,常用于名称、编码等常规录入
|
||||||
*/
|
*/
|
||||||
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$";
|
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,32}$";
|
||||||
|
|
||||||
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
|
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class PieGenerator {
|
|||||||
Option reasonOption = new Option();
|
Option reasonOption = new Option();
|
||||||
//取消渲染动画
|
//取消渲染动画
|
||||||
reasonOption.setAnimation(false);
|
reasonOption.setAnimation(false);
|
||||||
|
String[] colorArr = {"#526ADE", "#00BFF5","#FFBF00","#77DA63","#D5FF6B"};
|
||||||
|
reasonOption.setColor(colorArr);
|
||||||
//背景色
|
//背景色
|
||||||
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||||
//标题
|
//标题
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public interface OssPath {
|
|||||||
*/
|
*/
|
||||||
String WAVE_DIR="comtrade/";
|
String WAVE_DIR="comtrade/";
|
||||||
|
|
||||||
|
String WAVE_FILE="wave/";
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 下载文件
|
* 下载文件
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.njcn.web.utils;
|
package com.njcn.web.utils;
|
||||||
|
|
||||||
import org.springframework.http.HttpEntity;
|
import org.slf4j.Logger;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -15,8 +15,11 @@ import java.util.Map;
|
|||||||
* @createDate 2019-02-08
|
* @createDate 2019-02-08
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class RestTemplateUtil {
|
public class RestTemplateUtil {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RestTemplateUtil.class);
|
||||||
|
|
||||||
private static final RestTemplate restTemplate = new RestTemplate();
|
private static final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
// ----------------------------------GET-------------------------------------------------------
|
// ----------------------------------GET-------------------------------------------------------
|
||||||
@@ -263,6 +266,24 @@ public class RestTemplateUtil {
|
|||||||
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
|
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T> ResponseEntity<T> post(String url, Object requestBody, HttpHeaders headers, Class<T> responseType) {
|
||||||
|
try {
|
||||||
|
if (headers == null) {
|
||||||
|
headers = new HttpHeaders();
|
||||||
|
}
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<Object> entity = new HttpEntity<>(requestBody, headers);
|
||||||
|
log.info("发送POST请求到: {}", url);
|
||||||
|
ResponseEntity<T> response = restTemplate.postForEntity(url, entity, responseType);
|
||||||
|
log.info("POST请求响应状态: {}", response.getStatusCode());
|
||||||
|
return response;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("POST请求异常: {}", e.getMessage(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------PUT-------------------------------------------------------
|
// ----------------------------------PUT-------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
@@ -72,7 +74,7 @@ public class DataVerifyExcel implements Serializable {
|
|||||||
|
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
@ExcelProperty(value = "总指标异常时间")
|
@ExcelProperty(value = "总指标异常时间")
|
||||||
@Excel(name = "总")
|
@Excel(name = "总指标异常时间")
|
||||||
private Integer allTime;
|
private Integer allTime;
|
||||||
|
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
@@ -191,4 +193,33 @@ public class DataVerifyExcel implements Serializable {
|
|||||||
private Integer riseTime;
|
private Integer riseTime;
|
||||||
|
|
||||||
|
|
||||||
|
// 字段名 ↔ Excel列名 映射
|
||||||
|
public static final Map<String, String> FIELD_COLUMN_MAP = new HashMap<>();
|
||||||
|
static {
|
||||||
|
// 按代码中字段顺序整理,确保一一对应
|
||||||
|
FIELD_COLUMN_MAP.put("freqTime", "频率");
|
||||||
|
FIELD_COLUMN_MAP.put("freqDevTime", "频率偏差");
|
||||||
|
FIELD_COLUMN_MAP.put("vRmsTime", "相电压有效值");
|
||||||
|
FIELD_COLUMN_MAP.put("vPosTime", "正序电压");
|
||||||
|
FIELD_COLUMN_MAP.put("vNegTime", "负序电压");
|
||||||
|
FIELD_COLUMN_MAP.put("vZeroTime", "零序电压");
|
||||||
|
FIELD_COLUMN_MAP.put("vUnbalanceTime", "电压不平衡度");
|
||||||
|
FIELD_COLUMN_MAP.put("rmsLvrTime", "线电压有效值");
|
||||||
|
FIELD_COLUMN_MAP.put("vuDevTime", "电压正偏差");
|
||||||
|
FIELD_COLUMN_MAP.put("vlDevTime", "电压负偏差");
|
||||||
|
FIELD_COLUMN_MAP.put("vThdTime", "电压总谐波畸变率");
|
||||||
|
FIELD_COLUMN_MAP.put("vTime", "相电压基波有效值");
|
||||||
|
FIELD_COLUMN_MAP.put("iRmsTime", "电流有效值");
|
||||||
|
FIELD_COLUMN_MAP.put("pltTime", "长时闪变");
|
||||||
|
FIELD_COLUMN_MAP.put("vInharmTime", "间谐波电压含有率");
|
||||||
|
FIELD_COLUMN_MAP.put("vHarmTime", "谐波电压含有率");
|
||||||
|
FIELD_COLUMN_MAP.put("pfTime", "功率因数");
|
||||||
|
FIELD_COLUMN_MAP.put("vPhasicTime", "谐波电压相角");
|
||||||
|
FIELD_COLUMN_MAP.put("v1PhasicTime", "谐波电压基波相角");
|
||||||
|
FIELD_COLUMN_MAP.put("flucTime", "电压波动");
|
||||||
|
FIELD_COLUMN_MAP.put("pstTime", "短时闪变");
|
||||||
|
FIELD_COLUMN_MAP.put("dipTime", "电压暂降");
|
||||||
|
FIELD_COLUMN_MAP.put("riseTime", "电压暂升");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,206 @@
|
|||||||
|
package com.njcn.device.pq.utils;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||||
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
|
||||||
|
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修复版:按数据量动态排序Excel列,解决列挤在一行的问题
|
||||||
|
* 关键改动:表头构建方式 + 列宽匹配逻辑
|
||||||
|
*/
|
||||||
|
public class FixedDynamicExcelExport {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// 1. 模拟测试数据(相电压数据量最多,频率次之,频率偏差最少)
|
||||||
|
List<DataVerifyExcel> dataList = EasyExcel.read("F:\\usr\\response.xlsx")
|
||||||
|
.head(DataVerifyExcel.class)
|
||||||
|
.doReadAllSync();
|
||||||
|
// 2. 导出Excel(替换为你的本地路径,比如桌面)
|
||||||
|
dataList.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
||||||
|
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
||||||
|
);
|
||||||
|
exportExcelByDataSize(dataList, "D:/dynamic_excel_fixed.xlsx");
|
||||||
|
System.out.println("导出完成!打开桌面的「测试导出.xlsx」查看效果");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核心方法:按数据量排序导出Excel
|
||||||
|
*/
|
||||||
|
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, String outputPath) throws Exception {
|
||||||
|
// 步骤1:统计每个字段的有效数据量
|
||||||
|
Map<String, Integer> fieldCount = countValidData(dataList);
|
||||||
|
// 步骤2:按数据量降序排序字段名
|
||||||
|
List<String> sortedFields = sortFields(fieldCount);
|
||||||
|
// 步骤3:构建正确的动态表头
|
||||||
|
List<List<String>> head = buildCorrectHead(sortedFields);
|
||||||
|
// 步骤4:构建对应顺序的行数据
|
||||||
|
List<List<Object>> data = buildRowData(dataList, sortedFields);
|
||||||
|
|
||||||
|
// 步骤5:导出Excel(含列宽设置)
|
||||||
|
try (FileOutputStream out = new FileOutputStream(outputPath)) {
|
||||||
|
EasyExcel.write(out)
|
||||||
|
.head(head)
|
||||||
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
|
||||||
|
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
|
||||||
|
.sheet("数据统计")
|
||||||
|
.doWrite(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, OutputStream outputStream) {
|
||||||
|
// 步骤1:统计每个字段的有效数据量
|
||||||
|
Map<String, Integer> fieldCount = countValidData(dataList);
|
||||||
|
// 步骤2:按数据量降序排序字段名
|
||||||
|
List<String> sortedFields = sortFields(fieldCount);
|
||||||
|
// 步骤3:构建正确的动态表头
|
||||||
|
List<List<String>> head = buildCorrectHead(sortedFields);
|
||||||
|
// 步骤4:构建对应顺序的行数据
|
||||||
|
List<List<Object>> data = buildRowData(dataList, sortedFields);
|
||||||
|
|
||||||
|
// 步骤5:导出Excel(含列宽设置)
|
||||||
|
EasyExcel.write(outputStream)
|
||||||
|
.head(head)
|
||||||
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
|
||||||
|
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
|
||||||
|
.sheet("数据统计")
|
||||||
|
.doWrite(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FreezeHeaderHandler implements SheetWriteHandler {
|
||||||
|
@Override
|
||||||
|
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||||
|
// 表格创建前无需操作
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
|
||||||
|
Sheet sheet = writeSheetHolder.getSheet();
|
||||||
|
// freezePane(c, r):c=冻结列数,r=冻结行数;这里r=1表示冻结第1行(表头),c=0表示不冻结列
|
||||||
|
// 比如 freezePane(1, 1) 表示冻结第一列+第一行
|
||||||
|
sheet.createFreezePane(0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ★ 修复点1:构建正确的表头(每个列名独立成List)
|
||||||
|
private static List<List<String>> buildCorrectHead(List<String> allFields) {
|
||||||
|
List<List<String>> head = new ArrayList<>();
|
||||||
|
head.add(Collections.singletonList("供电公司"));
|
||||||
|
head.add(Collections.singletonList("所属变电站"));
|
||||||
|
head.add(Collections.singletonList("终端名称"));
|
||||||
|
head.add(Collections.singletonList("监测点名称"));
|
||||||
|
head.add(Collections.singletonList("IP"));
|
||||||
|
head.add(Collections.singletonList("干扰源类型"));
|
||||||
|
head.add(Collections.singletonList("监测对象名称"));
|
||||||
|
head.add(Collections.singletonList("电网侧变电站"));
|
||||||
|
head.add(Collections.singletonList("厂商"));
|
||||||
|
head.add(Collections.singletonList("总指标异常时间"));
|
||||||
|
List<String> sortedFields = allFields.subList(10, allFields.size());
|
||||||
|
for (String field : sortedFields) {
|
||||||
|
// 每个列名单独封装成List,EasyExcel才能识别为不同列
|
||||||
|
head.add(Collections.singletonList(DataVerifyExcel.FIELD_COLUMN_MAP.get(field)));
|
||||||
|
}
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 统计有效数据量(无改动,保留)
|
||||||
|
private static Map<String, Integer> countValidData(List<DataVerifyExcel> dataList) {
|
||||||
|
// 1. 初始化计数字典(反射自动提取所有Time结尾的Integer字段,初始值0)
|
||||||
|
Map<String, Integer> countMap = initCountMap();
|
||||||
|
// 2. 判空,避免空指针异常
|
||||||
|
if (dataList == null || dataList.isEmpty()) {
|
||||||
|
return countMap;
|
||||||
|
}
|
||||||
|
// 3. 获取DataStatistic类的所有字段
|
||||||
|
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
|
||||||
|
try {
|
||||||
|
// 4. 遍历每个数据对象
|
||||||
|
for (DataVerifyExcel data : dataList) {
|
||||||
|
// 5. 遍历每个字段,累加数值
|
||||||
|
for (Field field : fields) {
|
||||||
|
// 过滤条件:Integer类型 + 以Time结尾
|
||||||
|
if (field.getType() == Integer.class && field.getName().endsWith("Time") ) {
|
||||||
|
if(!field.getName().equals("allTime")){
|
||||||
|
// 设置可访问私有字段
|
||||||
|
field.setAccessible(true);
|
||||||
|
// 获取当前对象的该字段值
|
||||||
|
Integer value = (Integer) field.get(data);
|
||||||
|
// 非空则累加
|
||||||
|
if (value != null) {
|
||||||
|
String fieldName = field.getName();
|
||||||
|
countMap.put(fieldName, countMap.get(fieldName) + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
// 捕获反射访问异常,便于排查问题
|
||||||
|
throw new RuntimeException("统计字段时反射访问失败", e);
|
||||||
|
}
|
||||||
|
return countMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 反射初始化计数字典(复用之前的逻辑)
|
||||||
|
private static Map<String, Integer> initCountMap() {
|
||||||
|
Map<String, Integer> countMap = new HashMap<>();
|
||||||
|
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
if (field.getType() == Integer.class && field.getName().endsWith("Time")) {
|
||||||
|
if(!field.getName().equals("allTime")){
|
||||||
|
countMap.put(field.getName(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return countMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 按数据量排序字段(无改动,保留)
|
||||||
|
private static List<String> sortFields(Map<String, Integer> fieldCount) {
|
||||||
|
List<String> fields = new ArrayList<>(fieldCount.keySet());
|
||||||
|
fields.sort((f1, f2) -> fieldCount.get(f2) - fieldCount.get(f1)); // 降序
|
||||||
|
List<String> fieldAlls=new ArrayList<>();
|
||||||
|
fieldAlls.add("city");
|
||||||
|
fieldAlls.add("stationName");
|
||||||
|
fieldAlls.add("devName");
|
||||||
|
fieldAlls.add("lineName");
|
||||||
|
fieldAlls.add("ip");
|
||||||
|
fieldAlls.add("loadType");
|
||||||
|
fieldAlls.add("objName");
|
||||||
|
fieldAlls.add("powerSubstationName");
|
||||||
|
fieldAlls.add("manufacturer");
|
||||||
|
fieldAlls.add("allTime");
|
||||||
|
fieldAlls.addAll(fields);
|
||||||
|
return fieldAlls;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建行数据(无改动,保留)
|
||||||
|
private static List<List<Object>> buildRowData(List<DataVerifyExcel> dataList, List<String> sortedFields) {
|
||||||
|
List<List<Object>> rows = new ArrayList<>();
|
||||||
|
for (DataVerifyExcel data : dataList) {
|
||||||
|
List<Object> row = new ArrayList<>();
|
||||||
|
for (String field : sortedFields) {
|
||||||
|
try {
|
||||||
|
Field f = DataVerifyExcel.class.getDeclaredField(field);
|
||||||
|
f.setAccessible(true);
|
||||||
|
row.add(f.get(data));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("导出异常数据转换异常:"+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.add(row);
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
STATUS = 1
|
STATUS = 1
|
||||||
</select>
|
</select>
|
||||||
<select id="sortTransformer" resultType="java.lang.Integer">
|
<select id="sortTransformer" resultType="java.lang.Integer">
|
||||||
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer order by update_time desc
|
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer
|
||||||
|
<!-- order by update_time desc-->
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
@@ -392,14 +394,16 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
|
|||||||
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
|
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<String> excludeColumnFiledNames = new HashSet<>(1);
|
dataVerifyExcels.sort(Comparator
|
||||||
excludeColumnFiledNames.add("lineId");
|
.comparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
||||||
dataVerifyExcels.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
.thenComparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
|
||||||
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
|
|
||||||
);
|
);
|
||||||
EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
|
exportExcelByDataSize(dataVerifyExcels,response.getOutputStream());
|
||||||
.excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
|
// Set<String> excludeColumnFiledNames = new HashSet<>(1);
|
||||||
.doWrite(dataVerifyExcels);
|
// excludeColumnFiledNames.add("lineId");
|
||||||
|
// EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
|
||||||
|
// .excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
|
||||||
|
// .doWrite(dataVerifyExcels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) {
|
private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) {
|
||||||
if(save){
|
// if(save){
|
||||||
List<String> tfIndexs = param.getTfIndexs();
|
List<String> tfIndexs = param.getTfIndexs();
|
||||||
if(CollUtil.isNotEmpty(tfIndexs)){
|
if(CollUtil.isNotEmpty(tfIndexs)){
|
||||||
PqsTflgployass ass;
|
PqsTflgployass ass;
|
||||||
@@ -129,7 +129,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
|
|||||||
ass.setTfIndex(tfIndex);
|
ass.setTfIndex(tfIndex);
|
||||||
info.add(ass);
|
info.add(ass);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ public class DeviceController extends BaseController {
|
|||||||
@ApiOperation("修改装置通讯状态及时间")
|
@ApiOperation("修改装置通讯状态及时间")
|
||||||
public HttpResult<Boolean> updateDevComFlag(@RequestBody DevComFlagDTO devComFlagDTO) {
|
public HttpResult<Boolean> updateDevComFlag(@RequestBody DevComFlagDTO devComFlagDTO) {
|
||||||
String methodDescribe = getMethodDescribe("updateDevComFlag");
|
String methodDescribe = getMethodDescribe("updateDevComFlag");
|
||||||
boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update();
|
boolean update = iDeviceService.lambdaUpdate().set(Objects.nonNull(devComFlagDTO.getStatus()),Device::getComFlag,devComFlagDTO.getStatus() ).set(Objects.nonNull(devComFlagDTO.getDate()),Device::getUpdateTime, devComFlagDTO.getDate()).eq(Device::getId, devComFlagDTO.getId()).update();
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, update, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.njcn.device.device.service.impl;
|
package com.njcn.device.device.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.device.device.service.DeviceProcessService;
|
import com.njcn.device.device.service.DeviceProcessService;
|
||||||
import com.njcn.device.device.service.IDeviceService;
|
import com.njcn.device.device.service.IDeviceService;
|
||||||
@@ -28,10 +30,7 @@ import org.apache.commons.collections4.ListUtils;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -73,31 +72,59 @@ public class NodeDeviceServiceImpl implements NodeDeviceService {
|
|||||||
Integer nodeDevNum = node.getNodeDevNum();
|
Integer nodeDevNum = node.getNodeDevNum();
|
||||||
Integer maxProcessNum = node.getMaxProcessNum();
|
Integer maxProcessNum = node.getMaxProcessNum();
|
||||||
List<Device> list = iDeviceService.lambdaQuery().eq(Device::getNodeId, nodeId).list();
|
List<Device> list = iDeviceService.lambdaQuery().eq(Device::getNodeId, nodeId).list();
|
||||||
if(CollectionUtils.isEmpty(list)){
|
if(CollectionUtils.isEmpty(list)){
|
||||||
throw new BusinessException(PvDeviceResponseEnum.NO_DEVICE);
|
throw new BusinessException(PvDeviceResponseEnum.NO_DEVICE);
|
||||||
|
|
||||||
}
|
}
|
||||||
List<String> deviceIdList = list.stream().map(Device::getId).collect(Collectors.toList());
|
if(nodeDevNum<list.size()){
|
||||||
List<DeviceProcess> deviceProcessList = deviceProcessService.lambdaQuery().in(DeviceProcess::getId, deviceIdList).list();
|
|
||||||
Integer devNum = list.size();
|
|
||||||
if(nodeDevNum<devNum){
|
|
||||||
throw new BusinessException(PvDeviceResponseEnum.OVER_LIMIT);
|
throw new BusinessException(PvDeviceResponseEnum.OVER_LIMIT);
|
||||||
}
|
}
|
||||||
//单个进程支持最大装置数
|
List<String> deviceIdList = list.stream().map(Device::getId).collect(Collectors.toList());
|
||||||
int maxDevNum = nodeDevNum / maxProcessNum;
|
List<DeviceProcess> existingProcesses = deviceProcessService.lambdaQuery().in(DeviceProcess::getId, deviceIdList).list();
|
||||||
|
if(existingProcesses.size() >= nodeDevNum){
|
||||||
List<List<DeviceProcess>> partition = ListUtils.partition(deviceProcessList, maxProcessNum);
|
throw new BusinessException(PvDeviceResponseEnum.OVER_LIMIT);
|
||||||
for (int i = 0; i < partition.size(); i++) {
|
}
|
||||||
int processNo = i+1;
|
List<String> hasProcess = existingProcesses.stream().map(DeviceProcess::getId).distinct().collect(Collectors.toList());
|
||||||
partition.get(i).forEach(temp->{
|
|
||||||
temp.setProcessNo(processNo);
|
//过滤掉已经分配的装置
|
||||||
});
|
List<String> needDevice = deviceIdList.stream().filter(it->!hasProcess.contains(it)).collect(Collectors.toList());
|
||||||
|
// 无待分配设备直接抛出异常(保留你的原判断)
|
||||||
|
if (CollUtil.isEmpty(needDevice)) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "不存在未分配的进程的装置");
|
||||||
|
}
|
||||||
|
//单个进程支持最大装置数
|
||||||
|
int maxDevNumPerProcess = (int) Math.ceil((double) nodeDevNum / maxProcessNum);
|
||||||
|
Map<Integer, Long> mapCount = existingProcesses.stream().collect(Collectors.groupingBy(DeviceProcess::getProcessNo,Collectors.counting()));
|
||||||
|
List<DeviceProcess> poList = new ArrayList<>();
|
||||||
|
Iterator<String> deviceIterator = needDevice.iterator();
|
||||||
|
|
||||||
|
for (int processNo = 1; processNo <= maxProcessNum && deviceIterator.hasNext(); processNo++) {
|
||||||
|
Long usedCount = mapCount.getOrDefault(processNo, 0L);
|
||||||
|
int remainingCapacity = (int) (maxDevNumPerProcess - usedCount);
|
||||||
|
|
||||||
|
if (remainingCapacity <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 分配设备给当前进程
|
||||||
|
for (int i = 0; i < remainingCapacity && deviceIterator.hasNext(); i++) {
|
||||||
|
String deviceId = deviceIterator.next();
|
||||||
|
DeviceProcess deviceProcess = buildDeviceProcess(deviceId, processNo);
|
||||||
|
poList.add(deviceProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollUtil.isEmpty(poList)){
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL,"不存在可以分配的进程或装置");
|
||||||
}
|
}
|
||||||
List<DeviceProcess> collect = partition.stream().flatMap(List::stream).collect(Collectors.toList());
|
|
||||||
|
|
||||||
//更新进程号
|
//更新进程号
|
||||||
deviceProcessService.updateBatchById(collect);
|
deviceProcessService.saveBatch(poList,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DeviceProcess buildDeviceProcess(String deviceId, Integer processNo) {
|
||||||
|
DeviceProcess deviceProcess = new DeviceProcess();
|
||||||
|
deviceProcess.setId(deviceId); // 核心修复:设置设备关联字段,而非主键id
|
||||||
|
deviceProcess.setProcessNo(processNo);
|
||||||
|
return deviceProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class TerminalVersionServiceImpl implements TerminalVersionService {
|
|||||||
|
|
||||||
List<TerminalVersionVO> devList = terminalVersionMapper.getTerminalVersionInfo(terminalMainQueryParam);
|
List<TerminalVersionVO> devList = terminalVersionMapper.getTerminalVersionInfo(terminalMainQueryParam);
|
||||||
if(CollectionUtil.isEmpty(devList)){
|
if(CollectionUtil.isEmpty(devList)){
|
||||||
throw new BusinessException(DeviceResponseEnum.DEVICE_EMPTY);
|
return devList;
|
||||||
}
|
}
|
||||||
List<String> subIndexes = devList.stream().map(TerminalVersionVO::getPid).collect(Collectors.toList());
|
List<String> subIndexes = devList.stream().map(TerminalVersionVO::getPid).collect(Collectors.toList());
|
||||||
List<TerminalVersionVO> subList =terminalVersionMapper.getPqLineGdAndSubList(subIndexes);
|
List<TerminalVersionVO> subList =terminalVersionMapper.getPqLineGdAndSubList(subIndexes);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
a.name lineName,
|
a.name lineName,
|
||||||
c.Time_Interval,
|
c.Time_Interval,
|
||||||
d.Scale AS scale,
|
d.Scale AS scale,
|
||||||
c.Obj_Id obyId,
|
c.Obj_Id objId,
|
||||||
c.Big_Obj_Type bigObjType
|
c.Big_Obj_Type bigObjType
|
||||||
from pq_line a
|
from pq_line a
|
||||||
inner join pq_line b on a.pid = b.id
|
inner join pq_line b on a.pid = b.id
|
||||||
|
|||||||
@@ -1269,7 +1269,8 @@
|
|||||||
SELECT
|
SELECT
|
||||||
voltage.id as id,
|
voltage.id as id,
|
||||||
sub.id as pid,
|
sub.id as pid,
|
||||||
concat( sub.NAME, " ", voltage.NAME ) as name,
|
<!-- 兼容国产数据库-->
|
||||||
|
concat( sub.NAME, ' ', voltage.NAME ) as name,
|
||||||
voltage.Sort as sort
|
voltage.Sort as sort
|
||||||
FROM
|
FROM
|
||||||
pq_line voltage
|
pq_line voltage
|
||||||
@@ -1513,14 +1514,14 @@
|
|||||||
line.id AS lineId,
|
line.id AS lineId,
|
||||||
CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName,
|
CONCAT(sub.NAME, '_', vo.NAME, '_', line.NAME) AS lineName,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
IFNULL(CAST(detail.pt1 AS CHAR), 'N/A'),
|
IFNULL(CAST(detail.pt1 AS VARCHAR), 'N/A'),
|
||||||
':',
|
':',
|
||||||
IFNULL(CAST(detail.pt2 AS CHAR), 'N/A')
|
IFNULL(CAST(detail.pt2 AS VARCHAR), 'N/A')
|
||||||
) AS pt,
|
) AS pt,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
IFNULL(CAST(detail.ct1 AS CHAR), 'N/A'),
|
IFNULL(CAST(detail.ct1 AS VARCHAR), 'N/A'),
|
||||||
':',
|
':',
|
||||||
IFNULL(CAST(detail.ct2 AS CHAR), 'N/A')
|
IFNULL(CAST(detail.ct2 AS VARCHAR), 'N/A')
|
||||||
) AS ct,
|
) AS ct,
|
||||||
detail.Dev_Capacity AS Dev_Capacity,
|
detail.Dev_Capacity AS Dev_Capacity,
|
||||||
detail.Short_Capacity AS Short_Capacity,
|
detail.Short_Capacity AS Short_Capacity,
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
|
|
||||||
<select id="getMonthFlow" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
<select id="getMonthFlow" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
||||||
select t.*,
|
select t.*,
|
||||||
(t.statisValue)/t.flowMeal flowProportion
|
(t.statisValue / t.flowMeal) as flowProportion
|
||||||
from (
|
from (
|
||||||
SELECT
|
SELECT
|
||||||
a.id id,
|
a.id id,
|
||||||
@@ -158,8 +158,6 @@
|
|||||||
gd.name electricPowerCompany,
|
gd.name electricPowerCompany,
|
||||||
b.IP DeviceIP,
|
b.IP DeviceIP,
|
||||||
b.id deviceId,
|
b.id deviceId,
|
||||||
-- ifnull(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) + ifnull(d1.flow, 0) flowMeal,
|
|
||||||
-- ifnull(convert(m.Actual_Value/1024/1024,decimal(7,2)),0) statisValue
|
|
||||||
COALESCE(d.flow, (SELECT flow FROM cld_flow_meal WHERE type = 0 AND flag = 1)) + COALESCE(d1.flow, 0) AS flowMeal,
|
COALESCE(d.flow, (SELECT flow FROM cld_flow_meal WHERE type = 0 AND flag = 1)) + COALESCE(d1.flow, 0) AS flowMeal,
|
||||||
COALESCE(CAST(m.Actual_Value / 1024 / 1024 AS DECIMAL(7, 2)), 0) AS statisValue
|
COALESCE(CAST(m.Actual_Value / 1024 / 1024 AS DECIMAL(7, 2)), 0) AS statisValue
|
||||||
FROM pq_line a
|
FROM pq_line a
|
||||||
@@ -170,16 +168,20 @@
|
|||||||
LEFT JOIN cld_dev_meal c ON b.id = c.line_id
|
LEFT JOIN cld_dev_meal c ON b.id = c.line_id
|
||||||
LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
|
LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
|
||||||
LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
|
LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
|
||||||
WHERE a.id IN
|
<where>
|
||||||
|
a.id IN
|
||||||
<foreach item="item" collection="devs" separator="," open="(" close=")">
|
<foreach item="item" collection="devs" separator="," open="(" close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND
|
<if test="startTime != null and endTime != null">
|
||||||
m.Time_Id between #{startTime} and #{endTime}
|
AND
|
||||||
AND
|
m.Time_Id between #{startTime} and #{endTime}
|
||||||
|
</if>
|
||||||
|
AND
|
||||||
b.Run_Flag != 2
|
b.Run_Flag != 2
|
||||||
|
</where>
|
||||||
) t
|
) t
|
||||||
ORDER BY flowProportion DESC
|
ORDER BY flowProportion DESC ;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMonthFlowNew" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
<select id="getMonthFlowNew" resultType="com.njcn.device.pq.pojo.vo.LineFlowMealDetailVO">
|
||||||
|
|||||||
@@ -291,7 +291,14 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
|
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
|
||||||
.orderByDesc(RmpEventDetailPO::getSeverity).last(" limit 20")
|
.orderByDesc(RmpEventDetailPO::getSeverity).last(" limit 20")
|
||||||
);
|
);
|
||||||
info = BeanUtil.copyToList(eventDetails, EventDetailNew.class);
|
info = eventDetails.stream().map(temp->{
|
||||||
|
EventDetailNew eventDetailNew = new EventDetailNew();
|
||||||
|
BeanUtils.copyProperties(temp,eventDetailNew);
|
||||||
|
eventDetailNew.setStartTime(LocalDateTimeUtil.format(temp.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||||
|
return eventDetailNew;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// info = BeanUtil.copyToList(eventDetails, EventDetailNew.class);
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
|
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
|
||||||
}
|
}
|
||||||
@@ -309,6 +316,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
if (detail.getLineId().equals(vo.getLineId())) {
|
if (detail.getLineId().equals(vo.getLineId())) {
|
||||||
BeanUtils.copyProperties(detail, waveTypeVO);
|
BeanUtils.copyProperties(detail, waveTypeVO);
|
||||||
BeanUtils.copyProperties(vo, waveTypeVO);
|
BeanUtils.copyProperties(vo, waveTypeVO);
|
||||||
|
waveTypeVO.setStartTime(LocalDateTimeUtil.parse(detail.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||||
result.add(waveTypeVO);
|
result.add(waveTypeVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,7 +351,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
count.put(datum.getName(), 0);
|
count.put(datum.getName(), 0);
|
||||||
}
|
}
|
||||||
//过滤掉原因的是空的
|
//过滤掉原因的是空的
|
||||||
info = info.stream().filter(temp->Objects.nonNull(temp.getAdvanceReason())).collect(Collectors.toList());
|
info = info.stream().filter(temp->StringUtils.isNotEmpty(temp.getAdvanceReason())).collect(Collectors.toList());
|
||||||
//替值
|
//替值
|
||||||
for (EventDetail eventDetail : info) {
|
for (EventDetail eventDetail : info) {
|
||||||
// if (dictData.getId().equals(eventDetail.getEventType())) {
|
// if (dictData.getId().equals(eventDetail.getEventType())) {
|
||||||
@@ -739,8 +747,8 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
bodyFont.setFontHeightInPoints((short) 9);
|
bodyFont.setFontHeightInPoints((short) 9);
|
||||||
bodyStyle.setFont(bodyFont);
|
bodyStyle.setFont(bodyFont);
|
||||||
|
|
||||||
sheet2(sheets, cellStyle, bodyStyle, businessParam);
|
|
||||||
sheet3(sheets, cellStyle, bodyStyle, businessParam);
|
sheet3(sheets, cellStyle, bodyStyle, businessParam);
|
||||||
|
sheet2(sheets, cellStyle, bodyStyle, businessParam);
|
||||||
sheet4(sheets, cellStyle, bodyStyle, businessParam);
|
sheet4(sheets, cellStyle, bodyStyle, businessParam);
|
||||||
sheet5(sheets, cellStyle, bodyStyle, businessParam);
|
sheet5(sheets, cellStyle, bodyStyle, businessParam);
|
||||||
sheet6(sheets, cellStyle, bodyStyle, businessParam);
|
sheet6(sheets, cellStyle, bodyStyle, businessParam);
|
||||||
@@ -901,7 +909,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
|
|
||||||
public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
|
public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
|
||||||
sheets.createSheet("暂态严重度统计");
|
sheets.createSheet("暂态严重度统计");
|
||||||
HSSFSheet sheetAt = sheets.getSheetAt(1);
|
HSSFSheet sheetAt = sheets.getSheetAt(2);
|
||||||
sheetAt.setColumnWidth(0, 24 * 256);
|
sheetAt.setColumnWidth(0, 24 * 256);
|
||||||
sheetAt.setColumnWidth(1, 24 * 256);
|
sheetAt.setColumnWidth(1, 24 * 256);
|
||||||
sheetAt.setColumnWidth(2, 24 * 256);
|
sheetAt.setColumnWidth(2, 24 * 256);
|
||||||
@@ -978,7 +986,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
cell9.setCellStyle(bodyStyle);
|
cell9.setCellStyle(bodyStyle);
|
||||||
|
|
||||||
cell0.setCellValue(i + 1);
|
cell0.setCellValue(i + 1);
|
||||||
cell1.setCellValue(vo.getStartTime());
|
cell1.setCellValue(LocalDateTimeUtil.format(vo.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||||
cell2.setCellValue(vo.getGdName());
|
cell2.setCellValue(vo.getGdName());
|
||||||
cell3.setCellValue(vo.getSubName());
|
cell3.setCellValue(vo.getSubName());
|
||||||
cell4.setCellValue(vo.getLineName());
|
cell4.setCellValue(vo.getLineName());
|
||||||
@@ -993,7 +1001,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
|
|
||||||
public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
|
public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
|
||||||
sheets.createSheet("暂态原因统计");
|
sheets.createSheet("暂态原因统计");
|
||||||
HSSFSheet sheetAt = sheets.getSheetAt(2);
|
HSSFSheet sheetAt = sheets.getSheetAt(1);
|
||||||
sheetAt.setColumnWidth(0, 40 * 256);
|
sheetAt.setColumnWidth(0, 40 * 256);
|
||||||
sheetAt.setColumnWidth(1, 40 * 256);
|
sheetAt.setColumnWidth(1, 40 * 256);
|
||||||
sheetAt.setColumnWidth(2, 40 * 256);
|
sheetAt.setColumnWidth(2, 40 * 256);
|
||||||
@@ -1101,7 +1109,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sheet4(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
|
public void sheet4(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
|
||||||
sheets.createSheet("详细事件列表");
|
sheets.createSheet("暂降事件列表");
|
||||||
HSSFSheet sheetAt = sheets.getSheetAt(3);
|
HSSFSheet sheetAt = sheets.getSheetAt(3);
|
||||||
sheetAt.setColumnWidth(0, 24 * 256);
|
sheetAt.setColumnWidth(0, 24 * 256);
|
||||||
sheetAt.setColumnWidth(1, 24 * 256);
|
sheetAt.setColumnWidth(1, 24 * 256);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.event.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂态事件明细
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @date 2022/10/12
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@DS("sjzx")
|
||||||
|
public interface WlRmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -949,7 +949,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
|||||||
Map<String, Integer> reasonMap = new LinkedHashMap<>();
|
Map<String, Integer> reasonMap = new LinkedHashMap<>();
|
||||||
Map<String, Integer> typeMap = new LinkedHashMap<>();
|
Map<String, Integer> typeMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
info = info.stream().filter(temp->Objects.nonNull(temp.getAdvanceReason())||Objects.nonNull(temp.getAdvanceType())).collect(Collectors.toList());
|
info = info.stream().filter(temp->StringUtils.isNotEmpty(temp.getAdvanceReason())||StringUtils.isNotEmpty(temp.getAdvanceType())).collect(Collectors.toList());
|
||||||
//添加detail
|
//添加detail
|
||||||
for (RmpEventDetailPO detail : info) {
|
for (RmpEventDetailPO detail : info) {
|
||||||
EventDetail details = null;
|
EventDetail details = null;
|
||||||
@@ -975,13 +975,13 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
|||||||
|
|
||||||
//添加reason到map
|
//添加reason到map
|
||||||
for (EventDetail data : list) {
|
for (EventDetail data : list) {
|
||||||
if (Objects.nonNull(data.getAdvanceReason())&&reasonMap.get(data.getAdvanceReason()) != null) {
|
if (StringUtils.isNotEmpty(data.getAdvanceReason())&&reasonMap.get(data.getAdvanceReason()) != null) {
|
||||||
reasonMap.put(data.getAdvanceReason(), reasonMap.get(data.getAdvanceReason()) + 1);
|
reasonMap.put(data.getAdvanceReason(), reasonMap.get(data.getAdvanceReason()) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//添加type到map
|
//添加type到map
|
||||||
for (EventDetail data : list) {
|
for (EventDetail data : list) {
|
||||||
if (Objects.nonNull(data.getAdvanceType())&&typeMap.get(data.getAdvanceType()) != null) {
|
if (StringUtils.isNotEmpty(data.getAdvanceType())&&typeMap.get(data.getAdvanceType()) != null) {
|
||||||
typeMap.put(data.getAdvanceType(), typeMap.get(data.getAdvanceType()) + 1);
|
typeMap.put(data.getAdvanceType(), typeMap.get(data.getAdvanceType()) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -995,7 +995,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
|||||||
}
|
}
|
||||||
result.setTypes(typesVOS);
|
result.setTypes(typesVOS);
|
||||||
result.setReason(reasonsVOS);
|
result.setReason(reasonsVOS);
|
||||||
//result.setDetail(list);
|
result.setDetail(list);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,11 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
|||||||
}
|
}
|
||||||
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||||
|
if(Objects.equals(result.getCauseFlag(),1)&&Objects.equals(result.getTypeFlag(),1)){
|
||||||
|
rmpEventDetailPO.setDealFlag(1);
|
||||||
|
}else {
|
||||||
|
rmpEventDetailPO.setDealFlag(0);
|
||||||
|
}
|
||||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||||
|
|
||||||
|
|||||||
@@ -883,7 +883,7 @@ public class EventReportServiceImpl implements EventReportService {
|
|||||||
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
|
||||||
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
|
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
|
||||||
|
|
||||||
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s -> s.getStartTime().substring(0, 10)));
|
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s ->s.getStartTime().substring(0, 10)));
|
||||||
Set<String> keySet = map.keySet();
|
Set<String> keySet = map.keySet();
|
||||||
|
|
||||||
LocalDate parse1 = LocalDate.parse(startTime);
|
LocalDate parse1 = LocalDate.parse(startTime);
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.njcn.harmonic.pojo.param.excel;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExcelParam implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("模板分类名称")
|
||||||
|
@NotBlank(message = "模板分类名称不可为空")
|
||||||
|
private String modelTypeName;
|
||||||
|
|
||||||
|
@ApiModelProperty("模板分类类型")
|
||||||
|
private String modelType;
|
||||||
|
|
||||||
|
@ApiModelProperty("排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ListExcelParam implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("模板分类id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("模板id")
|
||||||
|
private List<String> modelIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class UpdateExcelParam extends ExcelParam implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("模板id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,4 +34,6 @@ public class ExcelRptTemp extends BaseEntity {
|
|||||||
|
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
private String wiringMethod;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.njcn.harmonic.pojo.po.excel;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("sys_excel")
|
||||||
|
public class SysExcel extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表类型名称
|
||||||
|
*/
|
||||||
|
private String excelName;
|
||||||
|
|
||||||
|
private String excelType;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.njcn.harmonic.pojo.po.excel;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("sys_excel_relation")
|
||||||
|
public class SysExcelRelation implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sys_excel的主键id
|
||||||
|
*/
|
||||||
|
private String sysExcelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sys_excel_rpt_temp的主键id
|
||||||
|
*/
|
||||||
|
private String sysExcelRptTempId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -862,10 +862,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
|||||||
String id = historyParam.getLineId();
|
String id = historyParam.getLineId();
|
||||||
String starTime = historyParam.getStartTime();
|
String starTime = historyParam.getStartTime();
|
||||||
String endTime = historyParam.getEndTime();
|
String endTime = historyParam.getEndTime();
|
||||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||||
String secret = "383b4b2536234d84ac909cd605762061";
|
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
|
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGvol_zl_ds";
|
||||||
String apiId = "46e61646481c0146e26ba79bb5c8fa05";
|
String apiId = "0644f1c6abd65d3a3a81eb3314390e14";
|
||||||
String apiName = "电能质量谐波监测系统_分布式光伏台区电压日数据_e_mp_TGvol_zl_时间";
|
String apiName = "电能质量谐波监测系统_分布式光伏台区电压日数据_e_mp_TGvol_zl_时间";
|
||||||
List<HarmonicHistoryV> harmonicHistory = adsDiList(HarmonicHistoryV.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
List<HarmonicHistoryV> harmonicHistory = adsDiList(HarmonicHistoryV.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||||
return ztDataV(harmonicHistory);
|
return ztDataV(harmonicHistory);
|
||||||
@@ -875,10 +875,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
|||||||
String id = historyParam.getLineId();
|
String id = historyParam.getLineId();
|
||||||
String starTime = historyParam.getStartTime();
|
String starTime = historyParam.getStartTime();
|
||||||
String endTime = historyParam.getEndTime();
|
String endTime = historyParam.getEndTime();
|
||||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||||
String secret = "383b4b2536234d84ac909cd605762061";
|
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
|
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGpower_zl_ds";
|
||||||
String apiId = "9db49fdc30dbc3bf6fa4f5cce141416c";
|
String apiId = "f9f0eb9627410c0ad4a66ae33a75e2c9";
|
||||||
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率日数据_e_mp_TGpower_zl_时间";
|
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率日数据_e_mp_TGpower_zl_时间";
|
||||||
List<HarmonicHistoryP> harmonicHistory = adsDiList(HarmonicHistoryP.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
List<HarmonicHistoryP> harmonicHistory = adsDiList(HarmonicHistoryP.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||||
return ztDataP(harmonicHistory,type);
|
return ztDataP(harmonicHistory,type);
|
||||||
@@ -888,10 +888,10 @@ public class OracleResultServiceImpl implements OracleResultService {
|
|||||||
String id = historyParam.getLineId();
|
String id = historyParam.getLineId();
|
||||||
String starTime = historyParam.getStartTime();
|
String starTime = historyParam.getStartTime();
|
||||||
String endTime = historyParam.getEndTime();
|
String endTime = historyParam.getEndTime();
|
||||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
String key = "a1a69c93c11e4910aa247087c261bec5";
|
||||||
String secret = "383b4b2536234d84ac909cd605762061";
|
String secret = "038de3c27cc54489862d181470e3ad92";
|
||||||
String url = "http://8d051549520e423ab8dccf8b3d457c74.apigw.he-region-2.sgic.sgcc.com.cn/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
|
String url = "https://25.37.90.72/ast/ydxxcjxt/dws/get_e_mp_TGfactor_zl_ds";
|
||||||
String apiId = "9c3ebd9c19dc0eb8e24385e40bd50a53";
|
String apiId = "bf6cc99505f93c355baad9926b61f17e";
|
||||||
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率因数日数据_e_mp_TGfactor_zl_时间";
|
String apiName = "get_电能质量谐波监测系统_分布式光伏台区功率因数日数据_e_mp_TGfactor_zl_时间";
|
||||||
List<HarmonicHistoryC> harmonicHistory = adsDiList(HarmonicHistoryC.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
List<HarmonicHistoryC> harmonicHistory = adsDiList(HarmonicHistoryC.class, id, starTime, endTime, key, secret, url, apiId, apiName);
|
||||||
return ztDataC(harmonicHistory,type);
|
return ztDataC(harmonicHistory,type);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
|
|||||||
|
|
||||||
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
|
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
List<ReportTemplateVO> getReportTemplateByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
@Select("${sqlStr}")
|
@Select("${sqlStr}")
|
||||||
StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
|
StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.harmonic.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
public interface SysExcelMapper extends BaseMapper<SysExcel> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.harmonic.common.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
public interface SysExcelRelationMapper extends BaseMapper<SysExcelRelation> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,9 +8,11 @@
|
|||||||
a.name,
|
a.name,
|
||||||
a.dept_id,
|
a.dept_id,
|
||||||
b.name deptName,
|
b.name deptName,
|
||||||
a.activation,
|
a.activation,,
|
||||||
|
a.wiring_method wiringMethod
|
||||||
a.update_time,
|
a.update_time,
|
||||||
c.name updateBy
|
c.name updateBy,
|
||||||
|
a.sort sort
|
||||||
from sys_excel_rpt_temp a
|
from sys_excel_rpt_temp a
|
||||||
left join sys_dept b on a.dept_id = b.id
|
left join sys_dept b on a.dept_id = b.id
|
||||||
left join sys_user c on a.update_by = c.id
|
left join sys_user c on a.update_by = c.id
|
||||||
@@ -21,6 +23,7 @@
|
|||||||
b.name like CONCAT('%', #{baseParam.searchValue},'%')
|
b.name like CONCAT('%', #{baseParam.searchValue},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
order by a.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getReportTemplateList" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
<select id="getReportTemplateList" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||||
@@ -32,12 +35,15 @@
|
|||||||
d.NAME updateBy,
|
d.NAME updateBy,
|
||||||
a.Activation,
|
a.Activation,
|
||||||
a.Report_Type,
|
a.Report_Type,
|
||||||
a.Report_Form
|
a.Report_Form,
|
||||||
|
a.wiring_method wiringMethod,
|
||||||
|
a.sort sort
|
||||||
FROM
|
FROM
|
||||||
sys_excel_rpt_temp a
|
sys_excel_rpt_temp a
|
||||||
LEFT JOIN sys_user d ON a.update_by = d.id
|
LEFT JOIN sys_user d ON a.update_by = d.id
|
||||||
WHERE
|
WHERE
|
||||||
a.state = 1
|
a.state = 1
|
||||||
|
order by a.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getReportTemplateByDept" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
<select id="getReportTemplateByDept" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||||
@@ -47,7 +53,8 @@
|
|||||||
a.NAME,
|
a.NAME,
|
||||||
a.activation,
|
a.activation,
|
||||||
a.report_form,
|
a.report_form,
|
||||||
a.sort
|
a.sort,
|
||||||
|
a.wiring_method wiringMethod
|
||||||
FROM
|
FROM
|
||||||
sys_excel_rpt_temp a
|
sys_excel_rpt_temp a
|
||||||
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
|
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
|
||||||
@@ -55,4 +62,27 @@
|
|||||||
a.activation = 1
|
a.activation = 1
|
||||||
order by a.sort asc
|
order by a.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getReportTemplateByIds" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
|
||||||
|
SELECT
|
||||||
|
DISTINCT
|
||||||
|
a.id,
|
||||||
|
a.NAME,
|
||||||
|
a.activation,
|
||||||
|
a.report_form,
|
||||||
|
a.sort,
|
||||||
|
a.report_type reportType,
|
||||||
|
a.wiring_method wiringMethod
|
||||||
|
FROM
|
||||||
|
sys_excel_rpt_temp a
|
||||||
|
WHERE
|
||||||
|
a.activation = 1 and a.state = 1
|
||||||
|
<if test="ids!=null and ids.size()!=0">
|
||||||
|
and a.id IN
|
||||||
|
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
order by a.sort asc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -31,4 +31,7 @@ public class ReportTemplateVO extends BaseEntity {
|
|||||||
|
|
||||||
private String reportForm;
|
private String reportForm;
|
||||||
|
|
||||||
|
private String wiringMethod;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.harmonic.common.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysExcelRelationVO implements Serializable {
|
||||||
|
|
||||||
|
private String sysExcelId;
|
||||||
|
|
||||||
|
private List<String> relationIds;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.njcn.harmonic.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
|
||||||
|
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
public interface ISysExcelRelationService extends IService<SysExcelRelation> {
|
||||||
|
|
||||||
|
//查询已绑定的关系
|
||||||
|
SysExcelRelationVO getRelation(String id);
|
||||||
|
|
||||||
|
//重新绑定模板
|
||||||
|
boolean bandRelation(ExcelParam.ListExcelParam param);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.harmonic.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.device.pq.pojo.vo.LineStateVO;
|
||||||
|
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
public interface ISysExcelService extends IService<SysExcel> {
|
||||||
|
|
||||||
|
//新增
|
||||||
|
boolean addSysExcel(ExcelParam param);
|
||||||
|
|
||||||
|
//删除
|
||||||
|
boolean deleteSysExcel(String id);
|
||||||
|
|
||||||
|
//修改
|
||||||
|
boolean updateSysExcel(ExcelParam.UpdateExcelParam param);
|
||||||
|
|
||||||
|
//查询
|
||||||
|
List<SysExcel> querySysExcel();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,14 +19,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
||||||
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
|
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
|
||||||
|
import com.njcn.harmonic.common.service.CustomReportTableService;
|
||||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||||
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
|
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
|
||||||
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||||
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
|
||||||
import com.njcn.harmonic.common.service.CustomReportTableService;
|
|
||||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
import com.njcn.oss.enums.OssResponseEnum;
|
import com.njcn.oss.enums.OssResponseEnum;
|
||||||
@@ -91,6 +90,12 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
private final String STR_FOUR = "%";
|
private final String STR_FOUR = "%";
|
||||||
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
|
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
|
||||||
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
|
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
|
||||||
|
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||||
|
put("AB", "A");
|
||||||
|
put("BC", "B");
|
||||||
|
put("CA", "C");
|
||||||
|
put("M", "T");
|
||||||
|
}};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getCustomReport(ReportSearchParam reportSearchParam,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
public void getCustomReport(ReportSearchParam reportSearchParam,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||||
@@ -141,9 +146,20 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||||
|
|
||||||
|
Map<String, String> tMap = new HashMap<>();
|
||||||
|
eleEpdPqdList.forEach(item->{
|
||||||
|
String phase;
|
||||||
|
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||||
|
phase = item.getPhase();
|
||||||
|
} else {
|
||||||
|
phase = PHASE_MAPPING.get(item.getPhase());
|
||||||
|
}
|
||||||
|
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||||
|
});
|
||||||
|
|
||||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -173,13 +189,13 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||||
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -453,6 +469,37 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Double getData(String data) {
|
||||||
|
double ratio = 1.0;
|
||||||
|
String[] parts = data.split(":");
|
||||||
|
if (parts.length == 2) {
|
||||||
|
try {
|
||||||
|
int num1 = Integer.parseInt(parts[0]);
|
||||||
|
int num2 = Integer.parseInt(parts[1]);
|
||||||
|
// 如果需要计算比值
|
||||||
|
ratio = (double) num1 / num2;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
System.out.println("字符串格式错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String appendData(Map<String,String> tMap,String name, double pt, double ct) {
|
||||||
|
String result;
|
||||||
|
String format = tMap.get(name);
|
||||||
|
if (Objects.equals(format, "*PT")) {
|
||||||
|
result = "*"+pt+"/1000";
|
||||||
|
} else if (Objects.equals(format, "*CT")) {
|
||||||
|
result = "*"+ct;
|
||||||
|
} else if (Objects.equals(format, "*PT*CT")) {
|
||||||
|
result = "*"+pt+"*"+ct+"/1000";
|
||||||
|
} else {
|
||||||
|
result = "";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param data 同类型的cell模板
|
* @param data 同类型的cell模板
|
||||||
* @param sql 单个cell模板
|
* @param sql 单个cell模板
|
||||||
@@ -461,8 +508,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
* @param assNoPassMap 用于存储不合格的指标
|
* @param assNoPassMap 用于存储不合格的指标
|
||||||
* @date 2023/10/20
|
* @date 2023/10/20
|
||||||
*/
|
*/
|
||||||
|
private void assSqlByMysql(Map<String,String> tMap, String dataLevel, String pt, String ct, List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
|
||||||
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
|
|
||||||
//sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
//sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
||||||
if (InfluxDbSqlConstant.CP95.equals(method)) {
|
if (InfluxDbSqlConstant.CP95.equals(method)) {
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
@@ -471,6 +517,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
.append(InfluxDbSqlConstant.LBK)
|
.append(InfluxDbSqlConstant.LBK)
|
||||||
.append(data.get(i).getTemplateName())
|
.append(data.get(i).getTemplateName())
|
||||||
.append(InfluxDbSqlConstant.RBK)
|
.append(InfluxDbSqlConstant.RBK)
|
||||||
|
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||||
.append(InfluxDbSqlConstant.AS)
|
.append(InfluxDbSqlConstant.AS)
|
||||||
.append("\""+data.get(i).getItemName()+"\"");
|
.append("\""+data.get(i).getItemName()+"\"");
|
||||||
} else {
|
} else {
|
||||||
@@ -478,6 +525,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
.append(InfluxDbSqlConstant.LBK)
|
.append(InfluxDbSqlConstant.LBK)
|
||||||
.append(data.get(i).getTemplateName())
|
.append(data.get(i).getTemplateName())
|
||||||
.append(InfluxDbSqlConstant.RBK)
|
.append(InfluxDbSqlConstant.RBK)
|
||||||
|
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||||
.append(InfluxDbSqlConstant.AS)
|
.append(InfluxDbSqlConstant.AS)
|
||||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||||
}
|
}
|
||||||
@@ -489,6 +537,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
.append(InfluxDbSqlConstant.LBK)
|
.append(InfluxDbSqlConstant.LBK)
|
||||||
.append(data.get(i).getTemplateName())
|
.append(data.get(i).getTemplateName())
|
||||||
.append(InfluxDbSqlConstant.RBK)
|
.append(InfluxDbSqlConstant.RBK)
|
||||||
|
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||||
.append(InfluxDbSqlConstant.AS)
|
.append(InfluxDbSqlConstant.AS)
|
||||||
.append("\""+data.get(i).getItemName()+"\"");
|
.append("\""+data.get(i).getItemName()+"\"");
|
||||||
} else {
|
} else {
|
||||||
@@ -496,6 +545,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
|||||||
.append(InfluxDbSqlConstant.LBK)
|
.append(InfluxDbSqlConstant.LBK)
|
||||||
.append(data.get(i).getTemplateName())
|
.append(data.get(i).getTemplateName())
|
||||||
.append(InfluxDbSqlConstant.RBK)
|
.append(InfluxDbSqlConstant.RBK)
|
||||||
|
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||||
.append(InfluxDbSqlConstant.AS)
|
.append(InfluxDbSqlConstant.AS)
|
||||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.njcn.harmonic.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
|
||||||
|
import com.njcn.harmonic.common.pojo.vo.SysExcelRelationVO;
|
||||||
|
import com.njcn.harmonic.common.service.ISysExcelRelationService;
|
||||||
|
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@DS("sjzx")
|
||||||
|
public class SysExcelRelationServiceImpl extends ServiceImpl<SysExcelRelationMapper, SysExcelRelation> implements ISysExcelRelationService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysExcelRelationVO getRelation(String id) {
|
||||||
|
SysExcelRelationVO vo = new SysExcelRelationVO();
|
||||||
|
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysExcelRelation::getSysExcelId, id);
|
||||||
|
List<SysExcelRelation> list = this.list(queryWrapper);
|
||||||
|
vo.setSysExcelId(id);
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
vo.setRelationIds(list.stream().map(SysExcelRelation::getSysExcelRptTempId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean bandRelation(ExcelParam.ListExcelParam param) {
|
||||||
|
//先删除
|
||||||
|
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysExcelRelation::getSysExcelId, param.getId());
|
||||||
|
this.remove(queryWrapper);
|
||||||
|
//再绑定
|
||||||
|
if (!param.getModelIds().isEmpty()) {
|
||||||
|
List<SysExcelRelation> list = param.getModelIds().stream().map(id -> {
|
||||||
|
SysExcelRelation relation = new SysExcelRelation();
|
||||||
|
relation.setSysExcelId(param.getId());
|
||||||
|
relation.setSysExcelRptTempId(id);
|
||||||
|
return relation;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
this.saveBatch(list);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.njcn.harmonic.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.harmonic.common.mapper.SysExcelMapper;
|
||||||
|
import com.njcn.harmonic.common.mapper.SysExcelRelationMapper;
|
||||||
|
import com.njcn.harmonic.common.service.ISysExcelService;
|
||||||
|
import com.njcn.harmonic.pojo.param.excel.ExcelParam;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||||
|
import com.njcn.harmonic.pojo.po.excel.SysExcelRelation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2026-01-27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@DS("sjzx")
|
||||||
|
public class SysExcelServiceImpl extends ServiceImpl<SysExcelMapper, SysExcel> implements ISysExcelService {
|
||||||
|
|
||||||
|
private final SysExcelRelationMapper sysExcelRelationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addSysExcel(ExcelParam param) {
|
||||||
|
LambdaQueryWrapper<SysExcel> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysExcel::getExcelName, param.getModelTypeName());
|
||||||
|
if (this.count(queryWrapper) > 0) {
|
||||||
|
throw new BusinessException("名称重复");
|
||||||
|
}
|
||||||
|
|
||||||
|
SysExcel sysExcel = new SysExcel();
|
||||||
|
sysExcel.setExcelName(param.getModelTypeName());
|
||||||
|
sysExcel.setExcelType(param.getModelType());
|
||||||
|
sysExcel.setSort(param.getSort());
|
||||||
|
return this.save(sysExcel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteSysExcel(String id) {
|
||||||
|
LambdaQueryWrapper<SysExcelRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysExcelRelation::getSysExcelId, id);
|
||||||
|
if (sysExcelRelationMapper.selectCount(queryWrapper) > 0) {
|
||||||
|
throw new BusinessException("请先删除关联关系");
|
||||||
|
}
|
||||||
|
return this.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateSysExcel(ExcelParam.UpdateExcelParam param) {
|
||||||
|
LambdaQueryWrapper<SysExcel> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysExcel::getExcelName, param.getModelTypeName()).ne(SysExcel::getId, param.getId());
|
||||||
|
if (this.count(queryWrapper) > 0) {
|
||||||
|
throw new BusinessException("名称重复");
|
||||||
|
}
|
||||||
|
SysExcel sysExcel = new SysExcel();
|
||||||
|
sysExcel.setId(param.getId());
|
||||||
|
sysExcel.setExcelName(param.getModelTypeName());
|
||||||
|
sysExcel.setExcelType(param.getModelType());
|
||||||
|
sysExcel.setSort(param.getSort());
|
||||||
|
return this.updateById(sysExcel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysExcel> querySysExcel() {
|
||||||
|
return this.list().stream().sorted(Comparator.comparing(SysExcel::getSort)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.njcn.user.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送的一些常量,微服务添加在nacos中
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2023年08月24日 18:25
|
||||||
|
*/
|
||||||
|
public interface SmsConstant {
|
||||||
|
|
||||||
|
String DEFAULT_CONNECT_TIME_OUT = "sun.net.client.defaultConnectTimeout";
|
||||||
|
String DEFAULT_READ_TIME_OUT = "sun.net.client.defaultReadTimeout";
|
||||||
|
//短信API产品名称(短信产品名固定,无需修改)
|
||||||
|
String PRODUCT = "Dysmsapi";
|
||||||
|
//短信API产品域名(接口地址固定,无需修改)
|
||||||
|
String DOMAIN = "dysmsapi.aliyuncs.com";
|
||||||
|
//accessKeyId
|
||||||
|
String ACCESS_KEY_ID = "LTAI4FxsR76x2dq3w9c5puUe";
|
||||||
|
//accessKeySecret
|
||||||
|
String ACCESS_KEY_SECRET = "GxkTR8fsrvHtixTlD9UPmOGli35tZs";
|
||||||
|
//短信所属地
|
||||||
|
String LOCATION = "cn-hangzhou";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知签名
|
||||||
|
*/
|
||||||
|
String SGIN = "灿能云";
|
||||||
|
String CNWL = "灿能物联";
|
||||||
|
String NJCNDL = "南京灿能电力";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码签名
|
||||||
|
*/
|
||||||
|
String VERIFICATION_SIGNATURE = "南京灿能电力自动化股份";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接口地址
|
||||||
|
*/
|
||||||
|
String SMS_API_URL = "https://sms.ymeeting.cn/smsv2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接口内容类型
|
||||||
|
*/
|
||||||
|
String SMS_CONTENT_TYPE = "application/json;charset=utf-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口编码方式
|
||||||
|
*/
|
||||||
|
String SMS_CHARSET = "UTF-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接口账号
|
||||||
|
*/
|
||||||
|
String SMS_ACCOUNT = "925631";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接口密码
|
||||||
|
*/
|
||||||
|
String SMS_PASSWORD = "AMW2pOVrdky";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 虚拟接入码
|
||||||
|
*/
|
||||||
|
String SMS_ACCESS_CODE = "106905631";
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ public interface UserValidMessage {
|
|||||||
|
|
||||||
String LOGIN_NAME_NOT_BLANK = "登录名不能为空,请检查loginName参数";
|
String LOGIN_NAME_NOT_BLANK = "登录名不能为空,请检查loginName参数";
|
||||||
|
|
||||||
String LOGIN_NAME_FORMAT_ERROR = "登录名格式错误,需3-16位的英文字母或数字,请检查loginName参数";
|
String LOGIN_NAME_FORMAT_ERROR = "登录名格式错误,首字符必须是字母,需3-16位的英文字母或数字,请检查loginName参数";
|
||||||
|
|
||||||
String PASSWORD_NOT_BLANK = "密码不能为空,请检查password参数";
|
String PASSWORD_NOT_BLANK = "密码不能为空,请检查password参数";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.njcn.user.service.impl;
|
package com.njcn.user.service.impl;
|
||||||
|
|
||||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||||
import com.aliyuncs.exceptions.ClientException;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
@@ -22,11 +21,13 @@ import com.njcn.user.pojo.po.UserSet;
|
|||||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||||
import com.njcn.user.pojo.po.app.AppSendMsg;
|
import com.njcn.user.pojo.po.app.AppSendMsg;
|
||||||
import com.njcn.user.service.*;
|
import com.njcn.user.service.*;
|
||||||
|
import com.njcn.user.util.SmsApiUtil;
|
||||||
import com.njcn.user.util.SmsUtil;
|
import com.njcn.user.util.SmsUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -63,6 +64,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
|
|
||||||
private final SmsUtil smsUtil;
|
private final SmsUtil smsUtil;
|
||||||
|
|
||||||
|
private final SmsApiUtil smsApiUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String setMessage(String phone, String devCode, String type) {
|
public String setMessage(String phone, String devCode, String type) {
|
||||||
@@ -70,6 +73,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
}
|
}
|
||||||
SendSmsResponse sendSmsResponse = null;
|
SendSmsResponse sendSmsResponse = null;
|
||||||
|
ResponseEntity<String> response = null;
|
||||||
String msgTemplate = SmsUtil.getMessageTemplate(type);
|
String msgTemplate = SmsUtil.getMessageTemplate(type);
|
||||||
String vcode = null;
|
String vcode = null;
|
||||||
try {
|
try {
|
||||||
@@ -91,27 +95,75 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//开始执行短信发送
|
||||||
vcode = getMessageCode();
|
vcode = getMessageCode();
|
||||||
//获取短信发送结果
|
//开始执行短信发送
|
||||||
sendSmsResponse = smsUtil.sendSms(phone,msgTemplate,"code",vcode);
|
String mobiles = phone;
|
||||||
|
String content = SmsUtil.getLianTongMessageTemplate(type, vcode);
|
||||||
|
response = smsApiUtil.sendBatchSms(mobiles, content);
|
||||||
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
||||||
if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
//成功发送短信验证码后,保存进redis
|
||||||
//成功发送短信验证码后,保存进redis,验证码失效为5分钟
|
redisUtil.saveByKeyWithExpire(key, vcode, 300L);
|
||||||
redisUtil.saveByKeyWithExpire(key, vcode,300L);
|
|
||||||
} else {
|
|
||||||
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
|
||||||
}
|
|
||||||
//短信入库
|
//短信入库
|
||||||
addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
addZdSendMessage(phone,vcode,msgTemplate,response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("发送短信异常,异常为:"+e.getMessage());
|
logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||||
//短信入库
|
//短信入库
|
||||||
addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
addZdSendMessage(phone,vcode,msgTemplate,response);
|
||||||
throw new BusinessException(e.getMessage());
|
throw new BusinessException(e.getMessage());
|
||||||
}
|
}
|
||||||
return sendSmsResponse.getCode();
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
|
// public String setMessage(String phone, String devCode, String type) {
|
||||||
|
// if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
|
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
|
// }
|
||||||
|
// SendSmsResponse sendSmsResponse = null;
|
||||||
|
// String msgTemplate = SmsUtil.getMessageTemplate(type);
|
||||||
|
// String vcode = null;
|
||||||
|
// try {
|
||||||
|
// //type为4,账号替换为新手机号
|
||||||
|
// if (!msgTemplate.equalsIgnoreCase(MessageEnum.REGISTER.getTemplateCode())) {
|
||||||
|
// User user = this.lambdaQuery().eq(User::getPhone,phone).one();
|
||||||
|
// if ("4".equalsIgnoreCase(type)) {
|
||||||
|
// //注册,无需判断手机号与设备的匹配
|
||||||
|
// if (user != null) {
|
||||||
|
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_FAIL);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (null == user) {
|
||||||
|
// throw new BusinessException(UserResponseEnum.LOGIN_PHONE_NOT_REGISTER);
|
||||||
|
// } else {
|
||||||
|
// user.setDevCode(devCode);
|
||||||
|
// logger.info("更新手机id:" + devCode);
|
||||||
|
// this.updateById(user);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// vcode = getMessageCode();
|
||||||
|
// //获取短信发送结果
|
||||||
|
// sendSmsResponse = smsUtil.sendSms(phone,msgTemplate,"code",vcode);
|
||||||
|
// String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
||||||
|
// if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||||
|
// //成功发送短信验证码后,保存进redis,验证码失效为5分钟
|
||||||
|
// redisUtil.saveByKeyWithExpire(key, vcode,300L);
|
||||||
|
// } else {
|
||||||
|
// throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||||
|
// }
|
||||||
|
// //短信入库
|
||||||
|
// addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||||
|
// //短信入库
|
||||||
|
// addSendMessage(phone,vcode,msgTemplate,sendSmsResponse);
|
||||||
|
// throw new BusinessException(e.getMessage());
|
||||||
|
// }
|
||||||
|
// return sendSmsResponse.getCode();
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void register(String phone, String code, String devCode) {
|
public void register(String phone, String code, String devCode) {
|
||||||
@@ -123,7 +175,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
}
|
}
|
||||||
judgeCode(phone, code);
|
judgeCode(phone, code);
|
||||||
String password = null;
|
String password = null;
|
||||||
SendSmsResponse sendSmsResponse = null;
|
ResponseEntity<String> response = null;
|
||||||
//先根据手机号查询是否已被注册
|
//先根据手机号查询是否已被注册
|
||||||
User user = this.lambdaQuery().eq(User::getPhone,phone).ne(User::getState,0).one();
|
User user = this.lambdaQuery().eq(User::getPhone,phone).ne(User::getState,0).one();
|
||||||
if (!Objects.isNull(user)){
|
if (!Objects.isNull(user)){
|
||||||
@@ -147,25 +199,75 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
appInfoSet.setExFactoryBug(0);
|
appInfoSet.setExFactoryBug(0);
|
||||||
appInfoSetService.save(appInfoSet);
|
appInfoSetService.save(appInfoSet);
|
||||||
//发送用户初始密码
|
//发送用户初始密码
|
||||||
try {
|
password = redisUtil.getStringByKey(newUser.getId());
|
||||||
password = redisUtil.getStringByKey(newUser.getId());
|
String content = SmsUtil.getLianTongMessageTemplate("3", password);
|
||||||
sendSmsResponse = smsUtil.sendSms(phone,MessageEnum.getTemplateByCode(3),"pwd",password);
|
response = smsApiUtil.sendBatchSms(phone, content);
|
||||||
if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
if (response != null && response.getStatusCodeValue() == 200) {
|
||||||
//成功发送短信验证码后,删除用户密码信息
|
//成功发送短信验证码后,删除用户密码信息
|
||||||
redisUtil.delete(newUser.getId());
|
redisUtil.delete(newUser.getId());
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||||
}
|
|
||||||
addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
|
||||||
} catch (ClientException e) {
|
|
||||||
logger.error("发送短信异常,异常为:"+e.getMessage());
|
|
||||||
addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
|
||||||
}
|
}
|
||||||
|
addZdSendMessage(phone,password,MessageEnum.getTemplateByCode(3),response);
|
||||||
//删除验证码
|
//删除验证码
|
||||||
deleteCode(phone);
|
deleteCode(phone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// @Transactional(rollbackFor = {Exception.class})
|
||||||
|
// public void register(String phone, String code, String devCode) {
|
||||||
|
// if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
|
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
|
// }
|
||||||
|
// if (StringUtils.isBlank(devCode)) {
|
||||||
|
// throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
|
// }
|
||||||
|
// judgeCode(phone, code);
|
||||||
|
// String password = null;
|
||||||
|
// SendSmsResponse sendSmsResponse = null;
|
||||||
|
// //先根据手机号查询是否已被注册
|
||||||
|
// User user = this.lambdaQuery().eq(User::getPhone,phone).ne(User::getState,0).one();
|
||||||
|
// if (!Objects.isNull(user)){
|
||||||
|
// throw new BusinessException(UserResponseEnum.REGISTER_PHONE_REPEAT);
|
||||||
|
// } else {
|
||||||
|
// //新增用户配置表
|
||||||
|
// UserSet userSet = userSetService.addAppUserSet();
|
||||||
|
// //新增用户表
|
||||||
|
// User newUser = cloneUserBoToUser(phone,devCode,userSet);
|
||||||
|
// //新增用户角色关系表
|
||||||
|
// Role role = roleService.getRoleByCode(AppRoleEnum.TOURIST.getCode());
|
||||||
|
// userRoleService.addUserRole(newUser.getId(), Collections.singletonList(role.getId()));
|
||||||
|
// //消息默认配置
|
||||||
|
// AppInfoSet appInfoSet = new AppInfoSet();
|
||||||
|
// appInfoSet.setUserId(newUser.getId());
|
||||||
|
// appInfoSet.setHarmonicInfo(1);
|
||||||
|
// appInfoSet.setEventInfo(1);
|
||||||
|
// appInfoSet.setRunInfo(1);
|
||||||
|
// appInfoSet.setAlarmInfo(1);
|
||||||
|
// appInfoSet.setFunctionBug(0);
|
||||||
|
// appInfoSet.setExFactoryBug(0);
|
||||||
|
// appInfoSetService.save(appInfoSet);
|
||||||
|
// //发送用户初始密码
|
||||||
|
// try {
|
||||||
|
// password = redisUtil.getStringByKey(newUser.getId());
|
||||||
|
// sendSmsResponse = smsUtil.sendSms(phone,MessageEnum.getTemplateByCode(3),"pwd",password);
|
||||||
|
// if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||||
|
// //成功发送短信验证码后,删除用户密码信息
|
||||||
|
// redisUtil.delete(newUser.getId());
|
||||||
|
// } else {
|
||||||
|
// throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||||
|
// }
|
||||||
|
// addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||||
|
// } catch (ClientException e) {
|
||||||
|
// logger.error("发送短信异常,异常为:"+e.getMessage());
|
||||||
|
// addSendMessage(phone,password,MessageEnum.getTemplateByCode(3),sendSmsResponse);
|
||||||
|
// }
|
||||||
|
// //删除验证码
|
||||||
|
// deleteCode(phone);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyPsd(String userId, String phone, String code, String password, String devCode) {
|
public void modifyPsd(String userId, String phone, String code, String password, String devCode) {
|
||||||
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
@@ -346,4 +448,22 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
appSendMsgService.save(appSendMsg);
|
appSendMsgService.save(appSendMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中国电信验证码入库
|
||||||
|
*/
|
||||||
|
public void addZdSendMessage(String phone, String vcode, String template, ResponseEntity<String> response) {
|
||||||
|
AppSendMsg appSendMsg = new AppSendMsg();
|
||||||
|
appSendMsg.setPhone(phone);
|
||||||
|
appSendMsg.setMessage(vcode);
|
||||||
|
appSendMsg.setSendTime(LocalDateTime.now());
|
||||||
|
if (Objects.isNull(response)){
|
||||||
|
appSendMsg.setSendStatus("无状态");
|
||||||
|
appSendMsg.setRemark(null);
|
||||||
|
} else {
|
||||||
|
appSendMsg.setSendStatus(String.valueOf(response.getStatusCodeValue()));
|
||||||
|
}
|
||||||
|
appSendMsg.setTemplate(template);
|
||||||
|
appSendMsgService.save(appSendMsg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package com.njcn.user.util;
|
||||||
|
|
||||||
|
import com.njcn.user.constant.SmsConstant;
|
||||||
|
import com.njcn.web.utils.RestTemplateUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信接口管理静态工具类
|
||||||
|
* 统一管理各种短信接口操作
|
||||||
|
*
|
||||||
|
* @date 2025-08-25
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SmsApiUtil {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RestTemplateUtil restTemplateUtil;
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(SmsApiUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群发短信接口
|
||||||
|
*
|
||||||
|
* @param mobiles 手机号列表,多个手机号用逗号分隔
|
||||||
|
* @param content 短信内容
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
public ResponseEntity<String> sendBatchSms(String mobiles, String content) {
|
||||||
|
return sendBatchSms(SmsConstant.SMS_ACCOUNT, SmsConstant.SMS_PASSWORD, mobiles, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群发短信接口
|
||||||
|
*
|
||||||
|
* @param account 账号
|
||||||
|
* @param password 密码
|
||||||
|
* @param mobiles 手机号列表,多个手机号用逗号分隔
|
||||||
|
* @param content 短信内容
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
public ResponseEntity<String> sendBatchSms(String account, String password, String mobiles, String content) {
|
||||||
|
try {
|
||||||
|
String[] mobileArray = mobiles.split(",");
|
||||||
|
log.info("开始群发短信,手机号数量: {}, 扩展号码: {}", mobileArray.length, SmsConstant.SMS_ACCESS_CODE);
|
||||||
|
|
||||||
|
// 构建请求参数
|
||||||
|
Map<String, Object> request = new HashMap<>();
|
||||||
|
request.put("action", "send");
|
||||||
|
request.put("account", account);
|
||||||
|
request.put("password", password);
|
||||||
|
request.put("mobile", mobiles);
|
||||||
|
request.put("content", content);
|
||||||
|
request.put("extno", SmsConstant.SMS_ACCESS_CODE);
|
||||||
|
|
||||||
|
// 设置请求头
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", SmsConstant.SMS_CONTENT_TYPE);
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
ResponseEntity<String> response = restTemplateUtil.post(
|
||||||
|
SmsConstant.SMS_API_URL,
|
||||||
|
request,
|
||||||
|
headers,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
log.info("群发短信完成,响应状态: {}, 响应内容: {}",
|
||||||
|
response.getStatusCode(), response.getBody());
|
||||||
|
|
||||||
|
return response;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("群发短信失败: {}", e.getMessage(), e);
|
||||||
|
throw new RuntimeException("群发短信失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息状态报告查询接口
|
||||||
|
*
|
||||||
|
* @param size 查询数量,建议不超过1000
|
||||||
|
* @return 状态报告查询结果
|
||||||
|
*/
|
||||||
|
public ResponseEntity<String> messageReport(Integer size) {
|
||||||
|
return messageReport(SmsConstant.SMS_ACCOUNT, SmsConstant.SMS_PASSWORD, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息状态报告查询接口
|
||||||
|
*
|
||||||
|
* @param account 账号
|
||||||
|
* @param password 密码
|
||||||
|
* @param size 查询数量,建议不超过1000
|
||||||
|
* @return 状态报告查询结果
|
||||||
|
*/
|
||||||
|
public ResponseEntity<String> messageReport(String account, String password, Integer size) {
|
||||||
|
try {
|
||||||
|
log.info("开始查询消息状态报告,查询数量: {}", size);
|
||||||
|
|
||||||
|
// 构建请求参数
|
||||||
|
Map<String, Object> request = new HashMap<>();
|
||||||
|
request.put("action", "report");
|
||||||
|
request.put("account", account);
|
||||||
|
request.put("password", password);
|
||||||
|
request.put("size", size != null ? size : 1000);
|
||||||
|
|
||||||
|
// 设置请求头
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", SmsConstant.SMS_CONTENT_TYPE);
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
ResponseEntity<String> response = restTemplateUtil.post(
|
||||||
|
SmsConstant.SMS_API_URL,
|
||||||
|
request,
|
||||||
|
headers,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
log.info("消息状态报告查询完成,响应状态: {}, 响应内容: {}",
|
||||||
|
response.getStatusCode(), response.getBody());
|
||||||
|
|
||||||
|
return response;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("消息状态报告查询失败: {}", e.getMessage(), e);
|
||||||
|
throw new RuntimeException("消息状态报告查询失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import com.aliyuncs.profile.DefaultProfile;
|
|||||||
import com.aliyuncs.profile.IClientProfile;
|
import com.aliyuncs.profile.IClientProfile;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.user.config.Message;
|
import com.njcn.user.config.Message;
|
||||||
|
import com.njcn.user.constant.SmsConstant;
|
||||||
import com.njcn.user.enums.MessageEnum;
|
import com.njcn.user.enums.MessageEnum;
|
||||||
import com.njcn.user.enums.UserResponseEnum;
|
import com.njcn.user.enums.UserResponseEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -92,6 +93,37 @@ public class SmsUtil {
|
|||||||
return msgTemplate;
|
return msgTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//验证码类型(0:登录 1:注册 2:修改密码 4:换绑新手机 5.老手机校验 6:忘记密码)
|
||||||
|
public static String getLianTongMessageTemplate(String type, String vcode) {
|
||||||
|
String msgTemplate = null;
|
||||||
|
switch (type) {
|
||||||
|
case "0":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在登录,若非本人操作,请勿泄露!";
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在注册成为平台会员,感谢您的支持!";
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
case "6":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在修改密码,如非本人操作,请忽略本短信!";
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "恭喜您注册成功,您的初始密码为:"+vcode+",请及时修改为常用密码,避免遗忘,感谢您的支持!";
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
|
case "8":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在进行敏感操作,如非本人操作,请忽略本短信!";
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
case "5":
|
||||||
|
msgTemplate = "【" + SmsConstant.NJCNDL + "】" + "验证码为:" + vcode + ",您正在尝试重新绑定手机号,请妥善保管账户信息!";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BusinessException(UserResponseEnum.CODE_TYPE_ERROR);
|
||||||
|
}
|
||||||
|
return msgTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息
|
* 发送消息
|
||||||
* @param phone 手机号
|
* @param phone 手机号
|
||||||
|
|||||||
Reference in New Issue
Block a user