基于云平台功能调整

This commit is contained in:
xy
2026-01-07 19:20:11 +08:00
parent 6b0feb1320
commit b774b7ce91
14 changed files with 196 additions and 62 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.controller.line;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,8 +12,8 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.utils.COverlimitUtil;
@@ -27,8 +28,10 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Description:
@@ -160,6 +163,16 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOverLimitData")
@ApiOperation("根据监测点id获取国标限值")
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
public HttpResult<Overlimit> getOverLimitData(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getOverLimitData");
Overlimit result = overlimitMapper.selectById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/getLinesByDevList")
// @ApiOperation("根据装置id集合获取监测点id集合")
@@ -188,7 +201,7 @@ public class CslineController extends BaseController {
String methodDescribe = getMethodDescribe("addCldLine");
csLinePOService.addCldLine(param);
//新增监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),param.getProtocolCapacity().floatValue(),param.getDevCapacity().floatValue(),param.getShortCircuitCapacity().floatValue(),0,0);
overlimit.setId(param.getLineId());
overlimitMapper.deleteById(param.getLineId());
overlimitMapper.insert(overlimit);
@@ -203,7 +216,7 @@ public class CslineController extends BaseController {
String methodDescribe = getMethodDescribe("updateCldLine");
csLinePOService.updateCldLine(param);
//修改监测点限值
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),param.getProtocolCapacity().floatValue(),param.getDevCapacity().floatValue(),param.getShortCircuitCapacity().floatValue(),0,0);
overlimit.setId(param.getLineId());
overlimitMapper.deleteById(param.getLineId());
overlimitMapper.insert(overlimit);
@@ -217,6 +230,7 @@ public class CslineController extends BaseController {
public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delCldLine");
csLinePOService.deleteCldLine(id);
overlimitMapper.deleteById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@@ -270,9 +284,15 @@ public class CslineController extends BaseController {
@ApiImplicitParam(name = "param", value = "param", required = true)
public HttpResult<List<CsLinePO>> list(@RequestBody CsLinePO param) {
String methodDescribe = getMethodDescribe("list");
List<String> keywordsLineIds = new ArrayList<>();
List<CsLinePO> poList = csLinePOService.getSimpleLine();
if (CollUtil.isNotEmpty(poList)) {
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
}
List<CsLinePO> list = csLinePOService.list(new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
.eq(StrUtil.isNotBlank(param.getPosition()), CsLinePO::getPosition, param.getPosition())
.in(CsLinePO::getLineId, keywordsLineIds)
.orderByAsc(CsLinePO::getName));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@@ -292,7 +312,7 @@ public class CslineController extends BaseController {
@ApiOperation("获取敏感负荷用户监测点列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqSensitiveUserLineVO>> getSensitiveUserLineList(@RequestBody BaseParam param) {
String methodDescribe = getMethodDescribe("getList");
String methodDescribe = getMethodDescribe("getSensitiveUserLineList");
Page<PqSensitiveUserLineVO> page = csLinePOService.getSensitiveUserLineList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}

View File

@@ -117,8 +117,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = {Exception.class})
public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){
List<CsEquipmentDeliveryPO> one = this.lambdaQuery()
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
.list();
if(CollUtil.isNotEmpty(one)){
throw new BusinessException ("设备名称不能重复");
}
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid());
@@ -259,12 +263,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
result = this.updateById(csEquipmentDeliveryPo);
//修改台账树中的设备名称
//如果是已经接入的设备需要修改台账树中的设备名称
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam);
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
csLedgerService.updateLedgerTree(csLedgerParam);
if (ObjectUtil.isNotNull(csLedger)) {
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam);
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
csLedgerService.updateLedgerTree(csLedgerParam);
}
if (result) {
refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),csEquipmentDeliveryAuditParm.getUsageStatus())) {
@@ -990,17 +996,33 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) {
List<CsEquipmentDeliveryPO> result = new ArrayList<>();
DictTreeVO vo = dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData();
if (ObjectUtil.isNotNull(vo)) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId())
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1);
//获取用户已经绑定的便携式设备
List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) {
lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId,devList);
if (ObjectUtil.isNull(vo)) {
throw new BusinessException("便携式设备类型字典缺失");
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId())
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1);
//获取用户已经绑定的便携式设备
List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) {
lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId,devList);
}
result = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(result)) {
//获取已经接入过系统的设备,未接入的不给分配
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
List<String> ids = result.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
queryWrapper.in(CsLedger::getId,ids);
List<CsLedger> list = csLedgerService.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
Set<String> idSet = list.stream()
.map(CsLedger::getId)
.collect(Collectors.toSet());
return result.stream()
.filter(data -> idSet.contains(data.getId()))
.collect(Collectors.toList());
}
result = this.list(lambdaQueryWrapper);
}
return result;
}

View File

@@ -1135,6 +1135,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
@Override
public Map<String, List<ThdDataVO>> sensitiveUserTrendData(SensitiveUserTrendDataQueryParam param) {
Map<String, List<ThdDataVO>> result = new HashMap<>();
if (Objects.isNull(param.getSensitiveUserId())) {
return result;
}
result.put("before", new ArrayList<>());
result.put("after", new ArrayList<>());
String sensitiveUserId = param.getSensitiveUserId();

View File

@@ -275,7 +275,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
public List<CsLinePO> getSimpleLine() {
List<String> devIds = commGetDevIds(RequestUtil.getUserIndex());
if(CollUtil.isNotEmpty(devIds)){
List<CsLinePO> poList = this.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getName).in(CsLinePO::getDeviceId,devIds)
List<CsLinePO> poList = this.lambdaQuery().select(CsLinePO::getLineId,CsLinePO::getName,CsLinePO::getMonitorUser).in(CsLinePO::getDeviceId,devIds)
.eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode()).list();
return poList;
}else {
@@ -287,8 +287,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
UserVO userVO = userFeignClient.getUserById(userId).getData();
List<String> devIds;
if(userVO.getType().equals(UserType.SUPER_ADMINISTRATOR ) || userVO.getType().equals(UserType.ADMINISTRATOR )){
devIds = csEquipmentDeliveryMapper.selectList(new LambdaQueryWrapper<CsEquipmentDeliveryPO>().eq(CsEquipmentDeliveryPO::getStatus,DataStateEnum.ENABLE)).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
}else {
devIds = csEquipmentDeliveryMapper.selectList(new LambdaQueryWrapper<CsEquipmentDeliveryPO>().ne(CsEquipmentDeliveryPO::getRunStatus,DataStateEnum.DELETED.getCode())).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
} else {
LambdaQueryWrapper<CsDeviceUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(CsDeviceUserPO::getDeviceId)
.and(w->w.eq(CsDeviceUserPO::getPrimaryUserId,userId).or().eq(CsDeviceUserPO::getSubUserId,userId))
@@ -313,14 +313,20 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
result.setCurrent(param.getPageNum());
result.setSize(param.getPageSize());
Page<CsLinePO> linePage = this.page(new Page<>(param.getPageNum(), param.getPageSize()),
new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
// 关联敏感用户
.isNotNull(CsLinePO::getMonitorUser)
.orderByAsc(CsLinePO::getMonitorUser)
);
// 查询登录用户拥有的监测点台账
List<CsLinePO> poList = getSimpleLine();
// 构建基础查询条件
LambdaQueryWrapper<CsLinePO> lambdaQueryWrapper = new LambdaQueryWrapper<CsLinePO>()
.eq(CsLinePO::getStatus, 1)
// 关联敏感用户
//.isNotNull(CsLinePO::getMonitorUser)
.orderByAsc(CsLinePO::getMonitorUser);
// 只有当lineList不为空时才添加in条件
if (CollUtil.isNotEmpty(poList)) {
List<String> lineList = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
lambdaQueryWrapper.in(CsLinePO::getLineId, lineList);
}
Page<CsLinePO> linePage = this.page(new Page<>(param.getPageNum(), param.getPageSize()), lambdaQueryWrapper);
BeanUtil.copyProperties(linePage, result);
List<CsLinePO> records = linePage.getRecords();
if (CollUtil.isEmpty(records)) {
@@ -349,15 +355,21 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
}
}
// 监测类型
sensitiveUserLineVO.setPosition(record.getPosition());
DictData positionDictData = dicDataFeignClient.getDicDataById(record.getPosition()).getData();
if (positionDictData != null) {
sensitiveUserLineVO.setPosition(positionDictData.getName());
if (ObjectUtil.isNotNull(record.getPosition())) {
sensitiveUserLineVO.setPosition(record.getPosition());
DictData positionDictData = dicDataFeignClient.getDicDataById(record.getPosition()).getData();
if (positionDictData != null) {
sensitiveUserLineVO.setPosition(positionDictData.getName());
}
}
// 电压等级
sensitiveUserLineVO.setVolGrade(record.getVolGrade());
if (ObjectUtil.isNotNull(record.getVolGrade())) {
sensitiveUserLineVO.setVolGrade(record.getVolGrade());
}
// 运行状态
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(record.getRunStatus()));
if (ObjectUtil.isNotNull(record.getRunStatus())) {
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(record.getRunStatus()));
}
// 报告文件
sensitiveUserLineVO.setReportFilePath(record.getReportFilePath());
// 最新数据时间
@@ -377,7 +389,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
@Override
public boolean uploadReport(MultipartFile file, String lineId) {
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.GOVERN_HARMONIC_FILE);
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.GOVERN_HARMONIC_FILE, true);
return this.update(new LambdaUpdateWrapper<CsLinePO>().eq(CsLinePO::getLineId, lineId).set(CsLinePO::getReportFilePath, filePath));
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.po.Overlimit;
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
* @author cdf
* @date 2023/6/7
*/
@DS("sjzx")
@Service
@RequiredArgsConstructor
public class OverLimitServiceImpl extends ServiceImpl<OverlimitMapper, Overlimit> implements IOverLimitService {