设备程序版本分页程序

This commit is contained in:
caozehui
2026-04-23 08:47:19 +08:00
parent 3df7d91e4c
commit 87b91382a8
10 changed files with 146 additions and 144 deletions

View File

@@ -106,4 +106,9 @@ public class CsEquipmentDeliveryAddParm implements Serializable {
@ApiModelProperty(value="所属项目")
private String associatedProject;
@ApiModelProperty(value="icd")
private String icd;
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
private Integer upgrade;
}

View File

@@ -110,4 +110,10 @@ public class CsEquipmentDeliveryAuditParm {
@ApiModelProperty(value="所属项目")
private String associatedProject;
@ApiModelProperty(value="icd")
private String icd;
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
private Integer upgrade;
}

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -40,4 +41,9 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam {
@ApiModelProperty("物联通讯状态 0:未连接 1:已连接")
private Integer connectStatus;
@ApiModelProperty("ICD")
private String icd;
@ApiModelProperty("是否支持升级(0:否 1:是)")
private Integer upgrade;
}

View File

@@ -147,4 +147,15 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
*/
@TableField(value = "associated_project")
private String associatedProject;
/**
* icd模型
*/
@TableField(value = "icd")
private String icd;
/**
* 是否支持升级(0:否 1:是)
*/
private Integer upgrade;
}

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
@@ -43,10 +44,10 @@ public class DevVersionVO {
/**
* 设备类型名称
*/
private String devTypeName;
private String devModelName;
/**
* ICD型号
* icd型号
*/
private String icd;
@@ -69,10 +70,31 @@ public class DevVersionVO {
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
/**
* 修改人员
*/
private String updateBy;
/**
* 修改人名称
*/
private String updateByName;
/**
* 设备运行状态(0:删除 1:离线 2:在线)
*/
private Integer runStatus;
/**
* 是否支持升级(0:否 1:是)
*/
private Integer upgrade;
/**
* 设备与MQTT服务器连接状态 (0:未连接 1:已连接)
*/
private Integer connectStatus;
}

View File

@@ -23,6 +23,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -45,9 +47,9 @@ public class DevModelController extends BaseController {
@ApiOperation("新增设备模板")
@ApiImplicitParam(name = "csDevModelAddParm", value = "新增设备模板参数", required = true)
@Deprecated
public HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm){
public HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm) {
String methodDescribe = getMethodDescribe("addDevModel");
CsDevModelPO flag = csDevModelService.addDevModel (csDevModelAddParm);
CsDevModelPO flag = csDevModelService.addDevModel(csDevModelAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@@ -56,7 +58,7 @@ public class DevModelController extends BaseController {
@PostMapping("/AuditDevModel")
@ApiOperation("更新/删除设备模板参数")
@ApiImplicitParam(name = "csDevModelAuditParm", value = "更新/删除设备模板参数", required = true)
public HttpResult<Boolean> AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm ){
public HttpResult<Boolean> AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm) {
String methodDescribe = getMethodDescribe("AuditDevModel");
Boolean flag = csDevModelService.AuditDevModel(csDevModelAuditParm);
@@ -64,15 +66,14 @@ public class DevModelController extends BaseController {
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDevModelPage")
@ApiOperation("设备模板分页查询")
@ApiImplicitParam(name = "csDevModelQueryParm", value = "设备模板查询参数", required = true)
public HttpResult<IPage<CsDevModelPageVO>> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm ){
public HttpResult<IPage<CsDevModelPageVO>> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm) {
String methodDescribe = getMethodDescribe("queryDevModelPage");
IPage<CsDevModelPageVO> page = csDevModelService.queryPage (csDevModelQueryParm);
IPage<CsDevModelPageVO> page = csDevModelService.queryPage(csDevModelQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@@ -80,10 +81,10 @@ public class DevModelController extends BaseController {
@PostMapping("/queryDevModelOne")
@ApiOperation("设备模板查询")
@ApiImplicitParam(name = "csDevModelQueryListParm", value = "设备模板信息", required = true)
public HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm){
public HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm) {
String methodDescribe = getMethodDescribe("queryDevModelOne");
CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm);
CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPageVO, methodDescribe);
}
@@ -91,13 +92,13 @@ public class DevModelController extends BaseController {
@PostMapping("/findModel")
@ApiOperation("根据条件查询模板")
@ApiImplicitParams({
@ApiImplicitParam(name = "devType", value = "装置类型", required = true),
@ApiImplicitParam(name = "version", value = "版本", required = true),
@ApiImplicitParam(name = "time", value = "时间", required = true)
@ApiImplicitParam(name = "devType", value = "装置类型", required = true),
@ApiImplicitParam(name = "version", value = "版本", required = true),
@ApiImplicitParam(name = "time", value = "时间", required = true)
})
public HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType,@RequestParam("version") String version,@RequestParam("time") String time){
public HttpResult<CsDevModelPO> findModel(@RequestParam("devType") String devType, @RequestParam("version") String version, @RequestParam("time") String time) {
String methodDescribe = getMethodDescribe("findModel");
CsDevModelPO csDevModelPo = csDevModelService.findModel(devType,version,time);
CsDevModelPO csDevModelPo = csDevModelService.findModel(devType, version, time);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPo, methodDescribe);
}
@@ -105,10 +106,9 @@ public class DevModelController extends BaseController {
@PostMapping("/getModelById")
@ApiOperation("根据模板Id获取模板数据")
@ApiImplicitParam(name = "id", value = "模板id", required = true)
public HttpResult<CsDevModelPO> getModelById(@RequestParam("id") String id){
public HttpResult<CsDevModelPO> getModelById(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getModelById");
CsDevModelPO po = csDevModelService.getModelById(id);
CsDevModelPO po = csDevModelService.getModelById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
}

View File

@@ -425,7 +425,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/version/page")
@ApiOperation("查询设备版本信息")
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody BaseParam baseParam) {
public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody CsEquipmentDeliveryQueryParm baseParam) {
String methodDescribe = getMethodDescribe("versionPage");
IPage<DevVersionVO> list = csEquipmentDeliveryService.versionPage(baseParam);

View File

@@ -196,5 +196,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);
IPage<DevVersionVO> versionPage(BaseParam baseParam);
IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam);
}

View File

@@ -45,6 +45,7 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
String remoteDir = OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH;
String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir);
csEdDataPO.setCrc(csEdDataAddParm.getCrcInfo());
csEdDataPO.setFilePath(filePath);
csEdDataPO.setStatus("1");
boolean save = this.save(csEdDataPO);

View File

@@ -10,7 +10,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
@@ -27,6 +26,7 @@ import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLogsFeignClient;
import com.njcn.csdevice.api.EngineeringFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
@@ -57,9 +57,10 @@ import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.enums.AppRoleEnum;
import com.njcn.user.pojo.po.User;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
@@ -122,6 +123,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final ICsSoftInfoService csSoftInfoService;
private final EngineeringFeignClient engineeringFeignClient;
private final EventUserFeignClient eventUserFeignClient;
private final UserFeignClient userFeignClient;
@Override
public void refreshDeviceDataCache() {
@@ -135,11 +137,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = {Exception.class})
public CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
boolean result;
List<CsEquipmentDeliveryPO> one = this.lambdaQuery()
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
.list();
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("设备名称不能重复");
}
@@ -171,12 +169,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
csEquipmentProcess.setStartTime(LocalDateTime.now());
csEquipmentProcess.setProcess(4);
csEquipmentProcess.setStatus (1);
csEquipmentProcess.setStatus(1);
csEquipmentProcessPOService.save(csEquipmentProcess);
result = this.save (csEquipmentDeliveryPo);
result = this.save(csEquipmentDeliveryPo);
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),code) && Objects.equals(csEquipmentDeliveryAddParm.getDevAccessMethod(),"CLD")) {
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) && Objects.equals(csEquipmentDeliveryAddParm.getDevAccessMethod(), "CLD")) {
//谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
boolean addUser = csDeviceUserPOService.add(csEquipmentDeliveryPo.getId());
if (result && addUser) {
@@ -197,11 +195,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//物理删除
boolean update = false;
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsEquipmentDeliveryPO::getId,id);
wrapper.eq(CsEquipmentDeliveryPO::getId, id);
CsEquipmentDeliveryPO po = this.getOne(wrapper);
if (po != null) {
update = this.remove(wrapper);
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+po.getNdid());
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION + po.getNdid());
}
//删除监测点表、监测点拓扑图关系
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
@@ -216,7 +214,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
}
//清空关系表
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper);
@@ -226,12 +224,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//删除设备和模板的关系
LambdaQueryWrapper<CsDevModelRelationPO> csDevModelRelationPOQueryWrapper = new LambdaQueryWrapper<>();
csDevModelRelationPOQueryWrapper.clear();
csDevModelRelationPOQueryWrapper.eq(CsDevModelRelationPO::getDevId,id);
csDevModelRelationPOQueryWrapper.eq(CsDevModelRelationPO::getDevId, id);
csDevModelRelationService.remove(csDevModelRelationPOQueryWrapper);
//删除设备/用户关系
QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>();
csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("device_id",id);
csDeviceUserPOQueryWrapper.eq("device_id", id);
csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper);
//删除游客
QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>();
@@ -251,11 +249,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return result;
}
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
BeanUtils.copyProperties (csEquipmentDeliveryPO,result);
if(!Objects.isNull (csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(),"")) {
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(), "")) {
result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName());
}
if(!Objects.isNull (csEquipmentDeliveryPO.getAssociatedProject()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedProject(),"")) {
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedProject()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedProject(), "")) {
result.setAssociatedProjectName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedProject()).getName());
}
return result;
@@ -286,19 +284,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
param.setEndTime(LocalDateTime.now().format(DatePattern.NORM_DATETIME_FORMATTER));
param.setEventIds(lineIds.stream().map(CsLinePO::getLineId).collect(Collectors.toList()));
List<CsEventPO> eventList = eventUserFeignClient.queryTempEventDetail(param).getData();
Map<String, List<CsEventPO>> eventMap = Optional.ofNullable(eventList)
.orElse(Collections.emptyList())
.stream()
.collect(Collectors.groupingBy(CsEventPO::getDeviceId));
Map<String, List<CsEventPO>> eventMap = Optional.ofNullable(eventList).orElse(Collections.emptyList()).stream().collect(Collectors.groupingBy(CsEventPO::getDeviceId));
List<ProjectEquipmentVO> recordList = new ArrayList<>();
list.getRecords().forEach(temp->{
list.getRecords().forEach(temp -> {
temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId()));
//获取设备类型
SysDicTreePO po = dictTreeFeignClient.queryById(temp.getDevType()).getData();
temp.setDevType(po.getCode());
temp.setLineList(lineIds.stream().filter(line -> line.getDevId().equals(temp.getEquipmentId())).sorted(Comparator.comparing(CsLinePO::getLineId)).collect(Collectors.toList()));
if (!Objects.equals(DicDataEnum.PORTABLE.getCode(),temp.getDevType())) {
if (!Objects.equals(DicDataEnum.PORTABLE.getCode(), temp.getDevType())) {
recordList.add(temp);
}
//判断设备是否存在告警
@@ -307,10 +302,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//获取用户置顶的设备
List<CsUserPins> topList = csUserPinsService.getPinToTopList();
List<String> targetIdList = topList.stream()
.filter(item -> Objects.equals(item.getTargetType(), 1))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
List<String> targetIdList = topList.stream().filter(item -> Objects.equals(item.getTargetType(), 1)).map(CsUserPins::getTargetId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
List<ProjectEquipmentVO> matchedList = new ArrayList<>();
List<ProjectEquipmentVO> unmatchedList = new ArrayList<>();
@@ -341,9 +333,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
@@ -352,11 +342,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId())
.ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException("设备名称不能重复");
}
@@ -406,13 +392,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (total > 0) {
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
//新增逻辑(针对便携式设备、监测设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList){
for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) {
String code = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode();
if((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)){
if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)) {
csEquipmentDeliveryVO.setStatus(5);
} else if((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)){
} else if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)
|| (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)) {
csEquipmentDeliveryVO.setStatus(6);
}
//判断装置是否已经连接上mqtt服务器
@@ -425,11 +411,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
}
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
recordList = recordList.stream()
.filter(item -> queryParam.getConnectStatus() == 0
? "未连接".equals(item.getConnectStatus())
: "已连接".equals(item.getConnectStatus()))
.collect(Collectors.toList());
recordList = recordList.stream().filter(item -> queryParam.getConnectStatus() == 0 ? "未连接".equals(item.getConnectStatus()) : "已连接".equals(item.getConnectStatus())).collect(Collectors.toList());
}
page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size());
page.setRecords(recordList);
@@ -454,7 +436,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
List<CsDataSet> dataSet = new ArrayList<>();
//如果没有传lineId(测点ID) 则根据设备ID获取对应的模板 select modelId from cs_dev_model_relation where dev_id = ?
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){
if (CollUtil.isNotEmpty(modelId)) {
for (CsDevModelRelationPO item : modelId) {
//再根据模板ID获取数据集 作为页面展示的Tab项 SELECT * FROM cs_data_set WHERE (pid = ? AND type IN (0,2))
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId()));
@@ -532,9 +514,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//限制角色展示
String role = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(role, String.class);
if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode())
|| strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode())
|| strings.contains(AppRoleEnum.ROOT.getCode())) {
if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) || strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || strings.contains(AppRoleEnum.ROOT.getCode())) {
addDataSet(dataSetList, item, "模块数据", "moduleData");
}
}
@@ -744,20 +724,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class)
public void testCompletion(String deviceId, Integer type, String remark) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId, deviceId).
set(CsEquipmentDeliveryPO::getStatus, 1).
set(CsEquipmentDeliveryPO::getRunStatus, 1).
set(CsEquipmentDeliveryPO::getProcess, type + 1).update();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId, deviceId).set(CsEquipmentDeliveryPO::getStatus, 1).set(CsEquipmentDeliveryPO::getRunStatus, 1).set(CsEquipmentDeliveryPO::getProcess, type + 1).update();
this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).
set(CsEquipmentProcessPO::getStatus, 1).
set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark, remark).
update();
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 1).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update();
}
@Override
@@ -768,24 +740,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
// set(CsEquipmentDeliveryPO::getRunStatus,1).
set(CsEquipmentDeliveryPO::getProcess, type).update();
this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).
set(CsEquipmentProcessPO::getStatus, 0).
set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark, remark).
update();
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 0).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update();
}
@Override
public void updateSoftInfo(String nDid, String id) {
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.set(CsEquipmentDeliveryPO::getSoftinfoId, id);
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getSoftinfoId, id);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
@@ -796,9 +761,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateModuleNumber(String nDid, Integer number) {
boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.set(CsEquipmentDeliveryPO::getModuleNumber, number);
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getModuleNumber, number);
result = this.update(lambdaUpdateWrapper);
if (result) {
refreshDeviceDataCache();
@@ -832,11 +795,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
public List<CsEquipmentDeliveryPO> getAllOnline() {
return this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.isNotNull(CsEquipmentDeliveryPO::getNodeId)
.list();
return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).isNotNull(CsEquipmentDeliveryPO::getNodeId).list();
}
@Override
@@ -974,9 +933,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(param.getNdid());
boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
.ne(CsEquipmentDeliveryPO::getId, param.getId());
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, param.getId());
int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
@@ -985,11 +942,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId());
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getId, param.getId())
.ne(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.eq(CsEquipmentDeliveryPO::getName, param.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, param.getId()).ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()).eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException("设备名称不能重复");
}
@@ -1041,9 +994,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
state.add(9);
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id)
.in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD");
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, id).in(ObjectUtil.isNotEmpty(state), CsEquipmentDeliveryPO::getUsageStatus, state).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
return this.list(lambdaQueryWrapper);
}
@@ -1052,10 +1003,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateCldDevStatus(String nodeId, Integer processNo) {
//获取需要修改的设备信息
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo)
.eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.eq(CsEquipmentDeliveryPO::getRunStatus, 2);
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).eq(CsEquipmentDeliveryPO::getNodeProcess, processNo).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).eq(CsEquipmentDeliveryPO::getRunStatus, 2);
List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(devList)) {
//修改设备运行状态
@@ -1071,9 +1019,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class)
public void flipCldDevStatus(String time, String devId, Integer status) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId)
.eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.ne(CsEquipmentDeliveryPO::getUsageStatus, 0);
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).ne(CsEquipmentDeliveryPO::getUsageStatus, 0);
CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper);
if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status);
@@ -1109,9 +1055,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override
public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
if (ObjectUtil.isNotNull(processNo)) {
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo);
}
@@ -1124,23 +1068,29 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
@Override
public IPage<DevVersionVO> versionPage(BaseParam baseParam) {
public IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(StrUtil.isNotBlank(baseParam.getDevModel()), CsEquipmentDeliveryPO::getDevModel, baseParam.getDevModel())
.eq(StrUtil.isNotBlank(baseParam.getIcd()), CsEquipmentDeliveryPO::getIcd, baseParam.getIcd())
.eq(ObjectUtil.isNotNull(baseParam.getUpgrade()), CsEquipmentDeliveryPO::getUpgrade, baseParam.getUpgrade())
.like(StrUtil.isNotBlank(baseParam.getSearchValue()), CsEquipmentDeliveryPO::getName, baseParam.getSearchValue());
Page<CsEquipmentDeliveryPO> page = this.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), wrapper);
List<DevVersionVO> records = new ArrayList<>();
List<DevVersionVO> finalRecords = records;
page.getRecords().forEach(item -> {
DevVersionVO devVersionVO = BeanUtil.copyProperties(item, DevVersionVO.class);
List<User> userData = userFeignClient.getUserByIdList(Collections.singletonList(item.getUpdateBy())).getData();
if (CollectionUtil.isNotEmpty(userData)) {
devVersionVO.setUpdateByName(userData.get(0).getName());
}
if (StrUtil.isNotBlank(item.getSoftinfoId())) {
// CsEdDataVO csEdDataVO = csEdDataService.findByDevTypeId(item.getDevModel());
CsSoftInfoPO softInfoPO = csSoftInfoService.getById(item.getSoftinfoId());
if (ObjectUtil.isNotNull(softInfoPO)) {
CsEdDataPO csEdDataPO = csEdDataService.findByDevTypeIdAndVersionNo(item.getDevModel(), softInfoPO.getAppVersion());
if (ObjectUtil.isNotNull(csEdDataPO)) {
devVersionVO.setDevTypeName(csEdDataPO.getDevTypeName());
devVersionVO.setVersion(csEdDataPO.getVersionNo());
devVersionVO.setProtocolVersion(csEdDataPO.getVersionAgreement());
devVersionVO.setVersionDate(csEdDataPO.getVersionDate());
@@ -1149,11 +1099,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
devVersionVO.setStatus(item.getUsageStatus());
devVersionVO.setIcd("aaa");
devVersionVO.setIcd(item.getIcd());
if (StrUtil.isNotBlank(item.getDevModel())) {
SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(item.getDevModel()).getData();
if (ObjectUtil.isNotNull(sysDicTreePO)) {
devVersionVO.setDevModel(sysDicTreePO.getName());
devVersionVO.setDevModelName(sysDicTreePO.getName());
}
}
@@ -1163,11 +1113,23 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (StrUtil.isNotBlank(item.getAssociatedProject())) {
devVersionVO.setAssociatedProject(appProjectService.getById(item.getAssociatedProject()).getName());
}
records.add(devVersionVO);
//判断装置是否已经连接上mqtt服务器
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (mqttClient) {
devVersionVO.setConnectStatus(1);
} else {
devVersionVO.setConnectStatus(0);
}
finalRecords.add(devVersionVO);
});
Page<DevVersionVO> resultPage = new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam));
if (ObjectUtil.isNotNull(baseParam.getConnectStatus())) {
records = records.stream().filter(item -> baseParam.getConnectStatus().equals(item.getConnectStatus())).collect(Collectors.toList());
}
resultPage.setTotal(CollectionUtil.isEmpty(records) ? 0 : records.size());
resultPage.setRecords(records);
resultPage.setTotal(page.getTotal());
resultPage.setMaxLimit(page.getMaxLimit());
@@ -1184,9 +1146,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
throw new BusinessException("便携式设备类型字典缺失");
}
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getUsageStatus, 1);
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1);
//获取用户已经绑定的便携式设备
List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) {
@@ -1200,12 +1160,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
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());
Set<String> idSet = list.stream().map(CsLedger::getId).collect(Collectors.toSet());
return result.stream().filter(data -> idSet.contains(data.getId())).collect(Collectors.toList());
} else {
result.clear();
return result;
@@ -1217,22 +1173,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2));
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2));
return this.list(lambdaQueryWrapper);
}
public int findLeastFrequentProcess(List<CsEquipmentDeliveryPO> items, Integer process) {
Map<Integer, Long> processCounts = items.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting()));
Map<Integer, Long> processCounts = items.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting()));
for (int i = 1; i <= process; i++) {
processCounts.putIfAbsent(i, 0L);
}
//如果列表为空默认返回1
return processCounts.entrySet().stream()
.min(Comparator.comparingLong(Map.Entry::getValue))
.map(Map.Entry::getKey)
.orElse(1);
return processCounts.entrySet().stream().min(Comparator.comparingLong(Map.Entry::getValue)).map(Map.Entry::getKey).orElse(1);
}
/**