Compare commits
13 Commits
6bb9d932b8
...
2026-04
| Author | SHA1 | Date | |
|---|---|---|---|
| 57cb6a2900 | |||
| 3990ad2b9a | |||
| a054a20e8a | |||
| db2821347d | |||
|
|
058229e8c4 | ||
| 13b9981c72 | |||
| e364ca1cae | |||
| 8b183d84e9 | |||
|
|
895755b7e1 | ||
|
|
87b91382a8 | ||
|
|
3df7d91e4c | ||
|
|
ae220ceeea | ||
|
|
00ccff18c0 |
@@ -59,6 +59,11 @@
|
||||
<version>4.4.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsEdDataPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEdDataVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -22,4 +24,7 @@ public interface CsEdDataFeignClient {
|
||||
|
||||
@PostMapping("/getAll")
|
||||
HttpResult<List<CsEdDataPO>> getAll(@RequestParam("devType") String devType);
|
||||
|
||||
@GetMapping("/getById")
|
||||
HttpResult<CsEdDataPO> getById(@RequestParam("id") String id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsUpgradeLogsClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csUpgradeLogs", fallbackFactory = CsUpgradeLogsClientFallbackFactory.class,contextId = "csSoftInfo")
|
||||
public interface CsUpgradeLogsFeignClient {
|
||||
@PostMapping("/add")
|
||||
HttpResult add(@RequestBody CsUpgradeLogs csUpgradeLogs);
|
||||
|
||||
}
|
||||
@@ -39,6 +39,12 @@ public class CsEdDataFeignClientFallbackFactory implements FallbackFactory<CsEdD
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置型号获取装置类型",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsEdDataPO> getById(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id获取装置类型",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsUpgradeLogsFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsUpgradeLogsClientFallbackFactory implements FallbackFactory<CsUpgradeLogsFeignClient> {
|
||||
@Override
|
||||
public CsUpgradeLogsFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
|
||||
return new CsUpgradeLogsFeignClient() {
|
||||
@Override
|
||||
public HttpResult add(CsUpgradeLogs csUpgradeLogs) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "新增升级日志异常", cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -115,4 +115,9 @@ public class CsEquipmentDeliveryDTO {
|
||||
* 日志等级(NORMAL、DEBUG、WARN、ERROR)
|
||||
*/
|
||||
private String devLogLevel;
|
||||
|
||||
/**
|
||||
* 设备软件信息id
|
||||
*/
|
||||
private String softinfoId;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-07
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DevVersionParam extends BaseParam {
|
||||
private String keyword;
|
||||
}
|
||||
@@ -7,10 +7,9 @@ import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2023/4/7 11:29【需求编号】
|
||||
@@ -62,7 +61,7 @@ public class CsEdDataPO extends BaseEntity {
|
||||
* 版本日期
|
||||
*/
|
||||
@TableField(value = "version_date")
|
||||
private Date versionDate;
|
||||
private LocalDateTime versionDate;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
@@ -95,5 +94,4 @@ public class CsEdDataPO extends BaseEntity {
|
||||
private String crc;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -148,4 +148,14 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
|
||||
@TableField(value = "associated_project")
|
||||
private String associatedProject;
|
||||
|
||||
/**
|
||||
* icd模型
|
||||
*/
|
||||
@TableField(value = "icd")
|
||||
private String icd;
|
||||
|
||||
/**
|
||||
* 是否支持升级(0:否 1:是)
|
||||
*/
|
||||
private Integer upgrade;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
* @description 设备升级日志
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "cs_upgrade_logs")
|
||||
public class CsUpgradeLogs {
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@TableField(value = "dev_id")
|
||||
private String devId;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@TableField(value = "version_no")
|
||||
private String versionNo;
|
||||
|
||||
/**
|
||||
* 升级结果(0:失败 1:成功)
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@TableField(value = "user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 登录名称
|
||||
*/
|
||||
@TableField(value = "login_name")
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT, insertStrategy = FieldStrategy.IGNORED)
|
||||
private String createBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT, insertStrategy = FieldStrategy.IGNORED)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE, insertStrategy = FieldStrategy.IGNORED)
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE, insertStrategy = FieldStrategy.IGNORED)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -70,12 +70,11 @@ public class CsEdDataVO extends BaseEntity {
|
||||
@ApiModelProperty(value = "版本类型")
|
||||
private String versionType;
|
||||
|
||||
@ApiModelProperty(value = "crc信息")
|
||||
private String crcInfo;
|
||||
|
||||
@ApiModelProperty(value = ".bin文件")
|
||||
private String filePath;
|
||||
|
||||
@ApiModelProperty(value = "CRC校验")
|
||||
private String crc;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-07
|
||||
*/
|
||||
@Data
|
||||
public class DevVersionVO {
|
||||
/**
|
||||
* 设备Id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 协议版本号
|
||||
*/
|
||||
private String protocolVersion;
|
||||
|
||||
/**
|
||||
* 版本日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime versionDate;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
private String devModel;
|
||||
|
||||
/**
|
||||
* 设备类型名称
|
||||
*/
|
||||
private String devModelName;
|
||||
|
||||
/**
|
||||
* icd型号
|
||||
*/
|
||||
private String icd;
|
||||
|
||||
|
||||
/**
|
||||
* 所属工程
|
||||
*/
|
||||
private String associatedEngineering;
|
||||
|
||||
/**
|
||||
* 所属项目
|
||||
*/
|
||||
private String associatedProject;
|
||||
|
||||
/**
|
||||
* 装置启用状态(0:停用 1:启用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
@@ -66,7 +66,5 @@ public class CsSoftInfoController extends BaseController {
|
||||
csSoftInfoService.removeById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
import com.njcn.csdevice.service.CsUpgradeLogsService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csUpgradeLogs")
|
||||
@Api(tags = "装置升级日志")
|
||||
@AllArgsConstructor
|
||||
@Validated
|
||||
public class CsUpgradeLogsController extends BaseController {
|
||||
private final CsUpgradeLogsService csUpgradeLogsService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增升级日志")
|
||||
@ApiImplicitParam(name = "csUpgradeLogs", value = "日志参数", required = true)
|
||||
public HttpResult add(@RequestBody CsUpgradeLogs csUpgradeLogs) {
|
||||
csUpgradeLogs.setUserName(RequestUtil.getUsername());
|
||||
csUpgradeLogs.setLoginName(RequestUtil.getLoginName());
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
return HttpResultUtil.assembleCommonResponseResult(csUpgradeLogsService.save(csUpgradeLogs) ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@GetMapping("/getByDevId")
|
||||
@ApiOperation("查询指定devId的所有升级日志")
|
||||
@ApiImplicitParam(name = "devId", value = "装置Id", required = true)
|
||||
public HttpResult<List<CsUpgradeLogs>> getByDevId(@RequestBody String devId) {
|
||||
String methodDescribe = getMethodDescribe("getByDevId");
|
||||
List<CsUpgradeLogs> result = csUpgradeLogsService.lambdaQuery().eq(CsUpgradeLogs::getDevId, devId).list();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -64,7 +66,6 @@ public class DevModelController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryDevModelPage")
|
||||
@ApiOperation("设备模板分页查询")
|
||||
@@ -110,5 +111,4 @@ public class DevModelController extends BaseController {
|
||||
CsDevModelPO po = csDevModelService.getModelById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevVersionVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.csdevice.service.CsDevModelRelationService;
|
||||
@@ -28,6 +30,7 @@ import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -46,6 +49,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
@@ -416,4 +420,16 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/version/page")
|
||||
@ApiOperation("查询设备版本信息")
|
||||
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
|
||||
public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody CsEquipmentDeliveryQueryParm baseParam) {
|
||||
String methodDescribe = getMethodDescribe("versionPage");
|
||||
|
||||
IPage<DevVersionVO> list = csEquipmentDeliveryService.versionPage(baseParam);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.CsEdDataAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEdDataAuditParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEdDataQueryParm;
|
||||
import com.njcn.csdevice.pojo.po.CsEdDataPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEdDataVO;
|
||||
import com.njcn.csdevice.service.CsEdDataService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -79,4 +80,14 @@ public class CsEdDataController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<CsEdDataPO> getById(@Validated @RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
CsEdDataPO dataPO = csEdDataService.getById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dataPO, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
public interface CsUpgradeLogsMapper extends BaseMapper<CsUpgradeLogs> {
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
t1.*
|
||||
from
|
||||
cs_equipment_delivery t0
|
||||
left join cs_line t1 on
|
||||
right join cs_line t1 on
|
||||
t0.id = t1.device_id
|
||||
where
|
||||
t0.ndid = #{id}
|
||||
|
||||
@@ -55,4 +55,10 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
void channelDevByUserId(UserDevParam param);
|
||||
|
||||
List<CsDeviceUserPO> getList(UserDevParam param);
|
||||
|
||||
/**
|
||||
* 新增用户设备关系表数据 新增主用户信息 && 新增已关联工程的用户的设备关系
|
||||
* @return
|
||||
*/
|
||||
Boolean addRelation(UserDevParam param);
|
||||
}
|
||||
|
||||
@@ -48,5 +48,13 @@ public interface CsEdDataService extends IService<CsEdDataPO> {
|
||||
* @author: xuyang
|
||||
*/
|
||||
CsEdDataVO findByDevTypeId(String devType);
|
||||
|
||||
/**
|
||||
* @Description: 根据装置型号和版本号获取装置类型
|
||||
* @param devTypeId 装置型号
|
||||
* @param versionNo 版本号
|
||||
* @return
|
||||
*/
|
||||
CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,15 @@ package com.njcn.csdevice.service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevVersionVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -195,4 +196,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
|
||||
List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);
|
||||
|
||||
IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
public interface CsUpgradeLogsService extends IService<CsUpgradeLogs> {
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.param.LineCountEvaluateParam;
|
||||
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,6 +21,13 @@ public interface ICsCommunicateService {
|
||||
*/
|
||||
List<PqsCommunicateDto> getRawDataLatest(LineCountEvaluateParam lineParam);
|
||||
|
||||
/**
|
||||
* 取出第一条装置数据
|
||||
* @param lineParam
|
||||
* @return
|
||||
*/
|
||||
List<PqsCommunicateDto> getRawDataOne(LineCountEvaluateParam lineParam);
|
||||
|
||||
/**
|
||||
* 获取时间范围数据
|
||||
* @param lineParam
|
||||
@@ -27,6 +35,8 @@ public interface ICsCommunicateService {
|
||||
*/
|
||||
List<PqsCommunicateDto> getRawData(LineCountEvaluateParam lineParam);
|
||||
|
||||
List<PqsCommunicateDto> getRawData2(LineCountEvaluateParam lineParam);
|
||||
|
||||
/**
|
||||
*是否有当天最后一条数据
|
||||
* @param lineParam
|
||||
|
||||
@@ -16,6 +16,19 @@ import java.util.List;
|
||||
*/
|
||||
public interface IRStatOnlineRateDService extends IService<RStatOnlineRateD> {
|
||||
|
||||
/**
|
||||
* 1.查询该设备当前计算周期是否存在上下线记录
|
||||
* 2.
|
||||
* a.存在记录,如果只有1条数据,则根据这一条记录的状态计算在线时长;如果是多条数据,则根据上下线时间计算在线时长;
|
||||
* b.不存在记录,则需要借助历史记录判断:
|
||||
* 1) 先查询设备第一条记录时间
|
||||
* - 如果统计日期 < 第一条记录时间 → 设备未上线 → 离线
|
||||
* 2) 再查询最新记录时间和状态
|
||||
* - 如果统计日期 > 最新记录时间 → 延续最新状态
|
||||
* * 最新是在线 → 全天在线
|
||||
* * 最新是离线 → 全天离线
|
||||
* @param param
|
||||
*/
|
||||
void addData(StatisticsDataParam param);
|
||||
|
||||
List<RStatOnlineRateD> getData(List<String> list, String startTime, String endTime);
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Objects.isNull;
|
||||
@@ -545,4 +546,59 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
queryWrapper.eq(CsDeviceUserPO::getStatus, "1");
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId 这边放设备id
|
||||
* @param list 这边放用户id集合
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean addRelation(UserDevParam param) {
|
||||
String userIndex;
|
||||
CsDeviceUserPO existingRecord = this.lambdaQuery()
|
||||
.eq(CsDeviceUserPO::getDeviceId, param.getUserId())
|
||||
.one();
|
||||
|
||||
if (existingRecord != null && Objects.equals(existingRecord.getPrimaryUserId(), existingRecord.getSubUserId())) {
|
||||
userIndex = existingRecord.getPrimaryUserId();
|
||||
} else {
|
||||
userIndex = RequestUtil.getUserIndex();
|
||||
if (userIndex == null) {
|
||||
throw new IllegalArgumentException("当前用户信息获取失败");
|
||||
}
|
||||
|
||||
CsDeviceUserPO mainDeviceRelation = new CsDeviceUserPO();
|
||||
mainDeviceRelation.setDeviceId(param.getUserId());
|
||||
mainDeviceRelation.setPrimaryUserId(userIndex);
|
||||
mainDeviceRelation.setSubUserId(userIndex);
|
||||
mainDeviceRelation.setStatus("1");
|
||||
boolean mainSaveSuccess = this.save(mainDeviceRelation);
|
||||
if (!mainSaveSuccess) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(param.getList())) {
|
||||
List<CsDeviceUserPO> batchRecords = param.getList().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> !Objects.equals(item, userIndex))
|
||||
.map(item -> {
|
||||
CsDeviceUserPO relation = new CsDeviceUserPO();
|
||||
relation.setDeviceId(param.getUserId());
|
||||
relation.setPrimaryUserId(userIndex);
|
||||
relation.setSubUserId(item);
|
||||
relation.setStatus("1");
|
||||
return relation;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!batchRecords.isEmpty()) {
|
||||
return this.saveBatch(batchRecords);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -42,7 +43,9 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
|
||||
public boolean addEdData(CsEdDataAddParm csEdDataAddParm) {
|
||||
CsEdDataPO csEdDataPO = new CsEdDataPO();
|
||||
BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
|
||||
String filePath = fileStorageUtil.uploadMultipart (csEdDataAddParm.getFile (), OssPath.EDDATA);
|
||||
String remoteDir = StrUtil.SLASH + OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH;
|
||||
String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir, true);
|
||||
csEdDataPO.setCrc(csEdDataAddParm.getCrcInfo());
|
||||
csEdDataPO.setFilePath(filePath);
|
||||
csEdDataPO.setStatus("1");
|
||||
boolean save = this.save(csEdDataPO);
|
||||
@@ -55,7 +58,7 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
|
||||
CsEdDataPO csEdDataPO = new CsEdDataPO();
|
||||
BeanUtils.copyProperties(csEdDataAuditParm, csEdDataPO);
|
||||
if (!Objects.isNull(csEdDataAuditParm.getFile())) {
|
||||
String filePath = fileStorageUtil.uploadMultipart (csEdDataAuditParm.getFile (), OssPath.EDDATA);
|
||||
String filePath = fileStorageUtil.uploadMultipart(csEdDataAuditParm.getFile(), StrUtil.SLASH + OssPath.EDDATA + csEdDataAuditParm.getDevTypeName() + StrUtil.SLASH + csEdDataAuditParm.getVersionNo() + StrUtil.SLASH, true);
|
||||
csEdDataPO.setFilePath(filePath);
|
||||
}
|
||||
boolean b = this.updateById(csEdDataPO);
|
||||
@@ -84,5 +87,11 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
|
||||
BeanUtils.copyProperties(csEdDataPo, csEdDataVo);
|
||||
return csEdDataVo;
|
||||
}
|
||||
|
||||
public CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo) {
|
||||
return this.lambdaQuery().eq(CsEdDataPO::getDevType, devTypeId)
|
||||
.eq(CsEdDataPO::getVersionNo, versionNo)
|
||||
.eq(CsEdDataPO::getStatus, 1).one();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,17 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.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;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -24,6 +26,7 @@ import com.njcn.access.api.AskDeviceDataFeignClient;
|
||||
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.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
@@ -31,10 +34,12 @@ import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.mapper.CsSoftInfoMapper;
|
||||
import com.njcn.csdevice.mapper.CsTerminalLogsMapper;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevVersionVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
@@ -44,6 +49,7 @@ import com.njcn.csdevice.utils.StringUtil;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.device.biz.mapper.OverLimitWlMapper;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -54,7 +60,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.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -76,8 +85,8 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2023/3/30 16:23【需求编号】
|
||||
@@ -111,7 +120,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
private final ICsCommunicateService csCommunicateService;
|
||||
private final ICsUserPinsService csUserPinsService;
|
||||
private final CsEngineeringService csEngineeringService;
|
||||
private final AppProjectService appProjectService;
|
||||
private final CsEdDataService csEdDataService;
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final OverLimitWlMapper overLimitWlMapper;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
@Override
|
||||
public void refreshDeviceDataCache() {
|
||||
@@ -125,11 +141,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("设备名称不能重复");
|
||||
}
|
||||
@@ -182,7 +194,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@DSTransactional
|
||||
public Boolean AuditEquipmentDelivery(String id) {
|
||||
//物理删除
|
||||
boolean update = false;
|
||||
@@ -193,13 +205,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
update = this.remove(wrapper);
|
||||
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION + po.getNdid());
|
||||
}
|
||||
//删除监测点表、监测点拓扑图关系
|
||||
//删除监测点表、监测点拓扑图关系、监测点限值
|
||||
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
|
||||
csLinePOService.remove(csLinePOLambdaQueryWrapper);
|
||||
//删除监测点限值
|
||||
overLimitWlMapper.deleteBatchIds(collect);
|
||||
|
||||
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
|
||||
appLineTopologyDiagramPOQueryWrapper.clear();
|
||||
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
|
||||
@@ -241,6 +256,7 @@ 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(), "")) {
|
||||
result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName());
|
||||
}
|
||||
@@ -275,10 +291,7 @@ 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 -> {
|
||||
@@ -296,10 +309,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<>();
|
||||
@@ -330,9 +340,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) {
|
||||
@@ -341,11 +349,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("设备名称不能重复");
|
||||
}
|
||||
@@ -414,11 +418,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);
|
||||
@@ -521,9 +521,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");
|
||||
}
|
||||
}
|
||||
@@ -694,7 +692,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
* 6.删除cs_device_user
|
||||
* */
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@DSTransactional
|
||||
public void delete(String devId) {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
/**
|
||||
@@ -721,6 +719,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csLinePOQueryWrapper.clear();
|
||||
csLinePOQueryWrapper.in("line_id", collect);
|
||||
csLinePOService.remove(csLinePOQueryWrapper);
|
||||
//删除监测点限值
|
||||
overLimitWlMapper.deleteBatchIds(collect);
|
||||
|
||||
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
|
||||
appLineTopologyDiagramPOQueryWrapper.clear();
|
||||
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
|
||||
@@ -733,20 +734,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
|
||||
@@ -757,24 +750,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();
|
||||
@@ -785,9 +771,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();
|
||||
@@ -821,11 +805,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
|
||||
@@ -896,8 +876,28 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csLedger.setSort(0);
|
||||
int addLedger = csLedgerMapper.insert(csLedger);
|
||||
|
||||
//谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
|
||||
boolean addUser = csDeviceUserPOService.add(csEquipmentDeliveryPo.getId());
|
||||
//1.谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
|
||||
//2.获取当前工程已经关注的用户列表,新增用户和设备的关系
|
||||
boolean addUser = false;
|
||||
List<DevDetailDTO> devDetailList = csLedgerFeignClient.getDevInfoByEngineerIds(Collections.singletonList(param.getEngineeringId())).getData();
|
||||
if (!CollectionUtils.isEmpty(devDetailList)) {
|
||||
List<String> devIds = devDetailList.stream().map(DevDetailDTO::getEquipmentId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsDeviceUserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CsDeviceUserPO::getDeviceId, devIds);
|
||||
List<CsDeviceUserPO> csDeviceUserPOList = csDeviceUserPOService.list(wrapper);
|
||||
if (!CollectionUtils.isEmpty(csDeviceUserPOList)) {
|
||||
List<String> userIds = csDeviceUserPOList.stream().map(CsDeviceUserPO::getSubUserId).distinct().collect(Collectors.toList());
|
||||
UserDevParam param1 = new UserDevParam();
|
||||
param1.setUserId(csEquipmentDeliveryPo.getId());
|
||||
param1.setList(userIds);
|
||||
addUser = csDeviceUserPOService.addRelation(param1);
|
||||
}
|
||||
} else {
|
||||
UserDevParam param1 = new UserDevParam();
|
||||
param1.setUserId(csEquipmentDeliveryPo.getId());
|
||||
param1.setList(null);
|
||||
addUser = csDeviceUserPOService.addRelation(param1);
|
||||
}
|
||||
|
||||
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0 && addUser) {
|
||||
refreshDeviceDataCache();
|
||||
@@ -906,7 +906,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@DSTransactional
|
||||
public Boolean delCldDev(String id) {
|
||||
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -918,6 +918,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
|
||||
csLinePOService.remove(csLinePOLambdaQueryWrapper);
|
||||
//删除监测点限值
|
||||
overLimitWlMapper.deleteBatchIds(collect);
|
||||
}
|
||||
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
csLedgerLambdaQueryWrapper.clear();
|
||||
@@ -930,9 +932,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
if (update) {
|
||||
refreshDeviceDataCache();
|
||||
}
|
||||
//删除用户设备关系表数据
|
||||
LambdaQueryWrapper<CsDeviceUserPO> csDeviceUserPOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
csDeviceUserPOLambdaQueryWrapper.eq(CsDeviceUserPO::getDeviceId, id);
|
||||
csDeviceUserPOService.remove(csDeviceUserPOLambdaQueryWrapper);
|
||||
//新增操作日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setId(IdUtil.simpleUUID());
|
||||
csTerminalLogs.setDeviceId(id);
|
||||
csTerminalLogs.setOperateType(2);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
@@ -959,9 +964,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) {
|
||||
@@ -970,11 +973,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("设备名称不能重复");
|
||||
}
|
||||
@@ -1026,9 +1025,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);
|
||||
}
|
||||
|
||||
@@ -1037,10 +1034,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)) {
|
||||
//修改设备运行状态
|
||||
@@ -1056,9 +1050,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);
|
||||
@@ -1094,9 +1086,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);
|
||||
}
|
||||
@@ -1108,6 +1098,77 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId, devList).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
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())) {
|
||||
CsSoftInfoPO softInfoPO = csSoftInfoService.getById(item.getSoftinfoId());
|
||||
|
||||
if (ObjectUtil.isNotNull(softInfoPO)) {
|
||||
CsEdDataPO csEdDataPO = csEdDataService.findByDevTypeIdAndVersionNo(item.getDevModel(), softInfoPO.getAppVersion());
|
||||
if (ObjectUtil.isNotNull(csEdDataPO)) {
|
||||
devVersionVO.setVersion(csEdDataPO.getVersionNo());
|
||||
devVersionVO.setProtocolVersion(csEdDataPO.getVersionAgreement());
|
||||
devVersionVO.setVersionDate(csEdDataPO.getVersionDate());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
devVersionVO.setStatus(item.getUsageStatus());
|
||||
devVersionVO.setIcd(item.getIcd());
|
||||
if (StrUtil.isNotBlank(item.getDevModel())) {
|
||||
SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(item.getDevModel()).getData();
|
||||
if (ObjectUtil.isNotNull(sysDicTreePO)) {
|
||||
devVersionVO.setDevModelName(sysDicTreePO.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(item.getAssociatedEngineering())) {
|
||||
devVersionVO.setAssociatedEngineering(csEngineeringService.getById(item.getAssociatedEngineering()).getName());
|
||||
}
|
||||
if (StrUtil.isNotBlank(item.getAssociatedProject())) {
|
||||
devVersionVO.setAssociatedProject(appProjectService.getById(item.getAssociatedProject()).getName());
|
||||
}
|
||||
|
||||
//判断装置是否已经连接上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());
|
||||
resultPage.setPages(page.getPages());
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsEquipmentDeliveryPO> getRunPortableDev(String userId) {
|
||||
List<CsEquipmentDeliveryPO> result = new ArrayList<>();
|
||||
@@ -1116,9 +1177,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)) {
|
||||
@@ -1132,12 +1191,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;
|
||||
@@ -1149,26 +1204,22 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ndid生成二维码
|
||||
*
|
||||
* @param ndid
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -71,7 +71,6 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final ICsUserPinsService csUserPinsService;
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
private final CsMarketDataFeignClient csMarketDataFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -291,6 +290,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
tree.addAll(new ArrayList<>(engineeringMap.values()));
|
||||
|
||||
if (CollUtil.isNotEmpty(portables)) {
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
@@ -307,6 +307,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
portable1.setChildren(Collections.singletonList(portable2));
|
||||
tree.add(portable1);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
csUserPinsService.channelTree(list, tree, 4);
|
||||
@@ -703,6 +704,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
tree.addAll(new ArrayList<>(engineeringMap.values()));
|
||||
|
||||
if (CollUtil.isNotEmpty(portables)) {
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
@@ -721,6 +723,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
portable2List.add(portable2);
|
||||
portable1.setChildren(portable2List);
|
||||
tree.add(portable1);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
csUserPinsService.channelTree(list, tree, 4);
|
||||
|
||||
@@ -158,7 +158,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
po.setClDid(param.getLineNo());
|
||||
//监测位置
|
||||
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
|
||||
po.setPosition(param.getPosition());
|
||||
po.setPosition(param.getPosition().isEmpty()?null:param.getPosition());
|
||||
this.save(po);
|
||||
|
||||
//2.新增台账树信息
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsUpgradeLogsMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||
import com.njcn.csdevice.service.CsUpgradeLogsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-23
|
||||
*/
|
||||
@Service
|
||||
public class CsUpgradeLogsServiceImpl extends ServiceImpl<CsUpgradeLogsMapper, CsUpgradeLogs> implements CsUpgradeLogsService {
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class DeviceMessageServiceImpl implements DeviceMessageService {
|
||||
throw new BusinessException("监测点为空");
|
||||
}
|
||||
for (CsLinePO item : lineList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
if (Objects.isNull(item.getPosition()) || item.getPosition().isEmpty()){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
@@ -103,6 +103,8 @@ class DeviceMessageServiceImpl implements DeviceMessageService {
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
} else {
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
/**
|
||||
@@ -67,6 +66,27 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqsCommunicateDto> getRawDataOne(LineCountEvaluateParam lineParam) {
|
||||
List<PqsCommunicateDto> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
influxQueryWrapper.regular(PqsCommunicate::getDevId, lineParam.getLineId())
|
||||
.select(PqsCommunicate::getTime)
|
||||
.select(PqsCommunicate::getDevId)
|
||||
.select(PqsCommunicate::getDescription)
|
||||
.select(PqsCommunicate::getType)
|
||||
.timeAsc()
|
||||
.limit(1);
|
||||
List<PqsCommunicate> list = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
list.forEach(item -> {
|
||||
PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||
BeanUtils.copyProperties(item, dto);
|
||||
dto.setTime(DATE_TIME_FORMATTER.format(item.getTime()));
|
||||
result.add(dto);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 获取时间段内的数据
|
||||
* @Param:
|
||||
@@ -88,6 +108,18 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqsCommunicateDto> getRawData2(LineCountEvaluateParam lineParam) {
|
||||
List<PqsCommunicateDto> result = new ArrayList<>();
|
||||
List<PqsCommunicate> list = getPqsCommunicateData(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
result.add(convertToDto(item));
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理有数据的情况
|
||||
*/
|
||||
@@ -95,6 +127,20 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
List<PqsCommunicateDto> result = new ArrayList<>();
|
||||
int lastIndex = list.size() - 1;
|
||||
|
||||
// 获取第一条数据,补充0点数据(状态与第一条相反)
|
||||
PqsCommunicate firstItem = list.get(0);
|
||||
PqsCommunicateDto firstData = new PqsCommunicateDto();
|
||||
firstData.setTime(lineParam.getStartTime() + " 00:00:00");
|
||||
firstData.setDevId(lineParam.getLineId().get(0));
|
||||
if (Objects.equals(firstItem.getType(), 0)) {
|
||||
firstData.setType(1);
|
||||
firstData.setDescription("通讯正常");
|
||||
} else {
|
||||
firstData.setType(0);
|
||||
firstData.setDescription("通讯中断");
|
||||
}
|
||||
result.add(firstData);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
PqsCommunicate item = list.get(i);
|
||||
PqsCommunicateDto dto = convertToDto(item);
|
||||
@@ -106,10 +152,10 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
result.add(endData);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理无数据的情况
|
||||
*/
|
||||
|
||||
@@ -68,8 +68,8 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
List<CsLinePO> csLinePOList = csLineFeignClient.getLinesByDevList(devIdList).getData();
|
||||
csLinePOList.forEach(item->{
|
||||
//没有统计间隔就计算下一次监测点
|
||||
if (Objects.isNull(item.getLineInterval())) {
|
||||
return;
|
||||
if (Objects.isNull(item.getLineInterval()) || item.getLineInterval() == 0) {
|
||||
item.setLineInterval(1);
|
||||
}
|
||||
//应收数据
|
||||
int dueCount = 1440 / item.getLineInterval();
|
||||
|
||||
@@ -16,13 +16,10 @@ import com.njcn.csdevice.service.ICsCommunicateService;
|
||||
import com.njcn.csdevice.service.IRStatOnlineRateDService;
|
||||
import com.njcn.csdevice.util.TimeUtil;
|
||||
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
|
||||
import com.njcn.influx.deprecated.InfluxDBPublicParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -62,46 +59,92 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
|
||||
return;
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(devList)) {
|
||||
int onlineMinutes = 0;
|
||||
//获取需要计算的时间
|
||||
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
|
||||
for (String time : dateRange) {
|
||||
List<PqsCommunicateDto> outCommunicateData = new ArrayList<>();
|
||||
Date statDate = DateUtil.parse(time);
|
||||
// 按设备分别统计
|
||||
for (CsEquipmentDeliveryPO device : devList) {
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
lineParam.setStartTime(time + " 00:00:00");
|
||||
lineParam.setEndTime(time + " 23:59:59");
|
||||
for (CsEquipmentDeliveryPO s : devList) {
|
||||
lineParam.setLineId(Collections.singletonList(s.getId()));
|
||||
List<PqsCommunicateDto> data = pqsCommunicateService.getRawDataLatest(lineParam);
|
||||
if (CollectionUtil.isEmpty(data)) {
|
||||
PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||
dto.setTime(time + " 00:00:00");
|
||||
dto.setDevId(s.getId());
|
||||
if (s.getRunStatus() == 1) {
|
||||
dto.setType(0);
|
||||
dto.setDescription("通讯中断");
|
||||
} else if (s.getRunStatus() == 2) {
|
||||
dto.setType(1);
|
||||
dto.setDescription("通讯正常");
|
||||
lineParam.setLineId(Collections.singletonList(device.getId()));
|
||||
lineParam.setStartTime(time);
|
||||
lineParam.setEndTime(time);
|
||||
List<PqsCommunicateDto> dayData = pqsCommunicateService.getRawData2(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(dayData)) {
|
||||
if (dayData.size() == 1) {
|
||||
PqsCommunicateDto singleRecord = dayData.get(0);
|
||||
long minutesFromMidnight = DateUtil.between(statDate, DateUtil.parse(singleRecord.getTime()), DateUnit.MINUTE);
|
||||
if (online.equals(singleRecord.getType())) {
|
||||
// 如果是在线状态,则从该时间点之后都在线
|
||||
onlineMinutes = 1440 - (int) minutesFromMidnight;
|
||||
} else {
|
||||
// 如果是离线状态,则从该时间点之前都在线(假设之前是在线的)
|
||||
onlineMinutes = (int) minutesFromMidnight;
|
||||
}
|
||||
outCommunicateData.add(dto);
|
||||
} else {
|
||||
// 多条记录,逐段计算
|
||||
long totalOnlineMinutes = 0L;
|
||||
Date lastTime = statDate;
|
||||
|
||||
for (int i = 0; i < dayData.size(); i++) {
|
||||
PqsCommunicateDto current = dayData.get(i);
|
||||
Date currentTime = DateUtil.parse(current.getTime());
|
||||
long intervalMinutes = DateUtil.between(lastTime, currentTime, DateUnit.MINUTE);
|
||||
|
||||
if (i == 0) {
|
||||
// 处理第一段:从0点到第一条记录
|
||||
// 如果第一条记录是离线(type=0),则之前是在线;如果第一条是在线(type=1),则之前是离线
|
||||
if (!online.equals(current.getType())) {
|
||||
totalOnlineMinutes += intervalMinutes;
|
||||
}
|
||||
outCommunicateData.addAll(data);
|
||||
} else {
|
||||
// 处理后续段:根据上一条记录的状态判断
|
||||
if (online.equals(dayData.get(i - 1).getType())) {
|
||||
totalOnlineMinutes += intervalMinutes;
|
||||
}
|
||||
Date dateOut = DateUtil.parse(time);
|
||||
for (PqsCommunicateDto pqsCommunicate : outCommunicateData) {
|
||||
}
|
||||
|
||||
lastTime = currentTime;
|
||||
}
|
||||
|
||||
// 处理最后一段:从最后一条记录到当天结束
|
||||
Date endOfDay = DateUtil.beginOfDay(DateUtil.offsetDay(statDate, 1));
|
||||
long lastInterval = DateUtil.between(lastTime, endOfDay, DateUnit.MINUTE);
|
||||
if (online.equals(dayData.get(dayData.size() - 1).getType())) {
|
||||
totalOnlineMinutes += lastInterval;
|
||||
}
|
||||
|
||||
onlineMinutes = (int) Math.min(totalOnlineMinutes, 1440);
|
||||
}
|
||||
} else {
|
||||
List<PqsCommunicateDto> firstData = pqsCommunicateService.getRawDataOne(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(firstData)) {
|
||||
Date statDate2 = DateUtil.parse(firstData.get(0).getTime());
|
||||
if (statDate.before(statDate2)) {
|
||||
onlineMinutes = 0;
|
||||
} else {
|
||||
List<PqsCommunicateDto> latestData = pqsCommunicateService.getRawDataLatest(lineParam);
|
||||
if (online.equals(latestData.get(0).getType())){
|
||||
onlineMinutes = 1440;
|
||||
} else {
|
||||
onlineMinutes = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onlineMinutes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
RStatOnlineRateD po = new RStatOnlineRateD();
|
||||
Date newDate = DateUtil.parse(pqsCommunicate.getTime());
|
||||
lineParam.setLineId(Collections.singletonList(pqsCommunicate.getDevId()));
|
||||
RStatOnlineRateD onLineRate = onLineMinute(newDate, dateOut, pqsCommunicate.getType(), lineParam);
|
||||
po.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
|
||||
po.setDevIndex(pqsCommunicate.getDevId());
|
||||
po.setOnlineMin(onLineRate.getOnlineMin());
|
||||
po.setOfflineMin(onLineRate.getOfflineMin());
|
||||
po.setDevIndex(device.getId());
|
||||
po.setOnlineMin(onlineMinutes);
|
||||
po.setOfflineMin(1440 - onlineMinutes);
|
||||
list.add(po);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.saveOrUpdateBatchByMultiId(list, 1000);
|
||||
}
|
||||
@@ -114,97 +157,4 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
|
||||
.between(RStatOnlineRateD::getTimeId,startTime,endTime)
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* new的时间和当前统计时间 不是/是 同一天
|
||||
*/
|
||||
private RStatOnlineRateD onLineMinute(Date newDate, Date date, Integer type, LineCountEvaluateParam lineParam) {
|
||||
RStatOnlineRateD onLineRate = new RStatOnlineRateD();
|
||||
Integer minute = 0;
|
||||
/*new的时间和当前统计时间是同一天*/
|
||||
if (DateUtil.isSameDay(newDate, date)) {
|
||||
minute = processData(newDate, date, type, lineParam);
|
||||
} else {
|
||||
/*new的时间和当前统计时间不是同一天*/
|
||||
Date nowDate = new Date();
|
||||
/*数据补招的情况下*/
|
||||
if (DateUtil.between(date, nowDate, DateUnit.DAY) > DateUtil.between(newDate, nowDate, DateUnit.DAY)) {
|
||||
minute = processData(newDate, date, null, lineParam);
|
||||
} else {
|
||||
if (online.equals(type)) {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE;
|
||||
}
|
||||
}
|
||||
}
|
||||
onLineRate.setOnlineMin(minute);
|
||||
onLineRate.setOfflineMin(InfluxDBPublicParam.DAY_MINUTE - minute);
|
||||
return onLineRate;
|
||||
}
|
||||
|
||||
private Integer processData(Date newDate, Date date, Integer type,LineCountEvaluateParam lineParam) {
|
||||
int minute = 0;
|
||||
List<PqsCommunicateDto> communicateData = pqsCommunicateService.getRawData(lineParam);
|
||||
/*当前统计时间内存在多条数据*/
|
||||
if (communicateData.size() > 1) {
|
||||
Date lastTime = null;
|
||||
long onlineTime = 0;
|
||||
long offlineTime = 0;
|
||||
for (int i = 0; i < communicateData.size(); i++) {
|
||||
long differ;
|
||||
if (i == 0) {
|
||||
/*首次比较取统计时间*/
|
||||
differ = DateUtil.between(date, DateUtil.parse(communicateData.get(i).getTime()), DateUnit.MINUTE);
|
||||
} else {
|
||||
/*后续取上一次数据时间*/
|
||||
differ = DateUtil.between(lastTime, DateUtil.parse(communicateData.get(i).getTime()), DateUnit.MINUTE);
|
||||
}
|
||||
if (online.equals(communicateData.get(i).getType())) {
|
||||
offlineTime = offlineTime + differ;
|
||||
} else {
|
||||
onlineTime = onlineTime + differ;
|
||||
}
|
||||
lastTime = DateUtil.parse(communicateData.get(i).getTime());
|
||||
}
|
||||
if (online.equals(communicateData.get(communicateData.size() - 1).getType())) {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE - (int) offlineTime;
|
||||
} else {
|
||||
minute = (int) onlineTime;
|
||||
}
|
||||
}
|
||||
/*当前统计时间内仅有一条数据*/
|
||||
else {
|
||||
if (type != null) {
|
||||
long differ = DateUtil.between(date, newDate, DateUnit.MINUTE);
|
||||
if (online.equals(type)) {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ;
|
||||
} else {
|
||||
minute = (int) differ;
|
||||
}
|
||||
} else {
|
||||
List<PqsCommunicateDto> communicateDataOld = pqsCommunicateService.getRawDataEnd(lineParam);
|
||||
// if (!communicateDataOld.isEmpty()){
|
||||
// if (online.equals(communicateDataOld.get(0).getType())){
|
||||
// minute = InfluxDBPublicParam.DAY_MINUTE;
|
||||
// }
|
||||
// }
|
||||
if (!communicateDataOld.isEmpty()){
|
||||
try {
|
||||
if (online.equals(communicateDataOld.get(0).getType())){
|
||||
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getEndTime()), DateUnit.MINUTE);
|
||||
} else {
|
||||
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getStartTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), DateUnit.MINUTE);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return minute;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,24 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
List<String> collect = new ArrayList<>();
|
||||
if(Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER_8000.getCode())){
|
||||
if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
|
||||
Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
|
||||
csMarketDataQueryWrapper.eq("user_id", userIndex);
|
||||
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
|
||||
collect = csMarketData.stream().map(CsMarketData::getEngineerId).collect(Collectors.toList());
|
||||
|
||||
} else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
|
||||
//todo查询配置的游客工程
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
// ||Objects.equals(role,"bxs_user")
|
||||
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode()) || Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
|
||||
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
|
||||
collect =csEngineeringPOS.stream().filter(temp->Objects.equals(temp.getStatus(),"1")).map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
} else {
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csEngineeringUserPOQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.clear();
|
||||
@@ -79,24 +96,6 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
collect = collect.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return collect;
|
||||
|
||||
} else if ( Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
|
||||
Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
|
||||
csMarketDataQueryWrapper.eq("user_id", userIndex);
|
||||
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
|
||||
collect = csMarketData.stream().map(CsMarketData::getEngineerId).collect(Collectors.toList());
|
||||
|
||||
} else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
|
||||
//todo查询配置的游客工程
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
// ||Objects.equals(role,"bxs_user")
|
||||
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode()) || Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER.getCode()) ){
|
||||
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
|
||||
collect =csEngineeringPOS.stream().filter(temp->Objects.equals(temp.getStatus(),"1")).map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return collect;
|
||||
@@ -115,37 +114,11 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
List<String> collect = new ArrayList<>();
|
||||
if(
|
||||
Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER_8000.getCode()) || Objects.equals(role,"bxs_user")){
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
});
|
||||
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
if(CollectionUtils.isEmpty(csDeviceUserPOS)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
return collect1;
|
||||
|
||||
}
|
||||
//fix 新需求 工程用户可以看到关注工程的设备和对应的主用户和子用户的设备
|
||||
//note 这边工程用户不查询主设备,只看关注的工程,做下调整,不然会出现工程用户未关注任何工程,但是有一台主设备,导致界面有数据
|
||||
else if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
if (Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
List<String> sumDevId = new ArrayList<>();
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
// csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
// wq.eq("primary_user_id", userIndex)
|
||||
// .or()
|
||||
// .eq("sub_user_id",userIndex);
|
||||
// });
|
||||
// List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
// if(!CollectionUtils.isEmpty(csDeviceUserPOS)){
|
||||
// sumDevId = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
QueryWrapper<CsMarketData> csMarketDataQueryWrapper = new QueryWrapper<>();
|
||||
csMarketDataQueryWrapper.eq("user_id", userIndex);
|
||||
List<CsMarketData> csMarketData = csMarketDataMapper.selectList(csMarketDataQueryWrapper);
|
||||
@@ -198,15 +171,25 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
// ||Objects.equals(role,"bxs_user")
|
||||
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode()) || Objects.equals(role,AppRoleEnum.REGULAR_USER.getCode())){
|
||||
else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
|
||||
csLedgerQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.eq("level",2).eq("state",1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
collect = csLedgers.stream().map(CsLedger::getId).distinct().collect(Collectors.toList());
|
||||
} else {
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csDeviceUserPOQueryWrapper.eq("status","1").and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
});
|
||||
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
if(CollectionUtils.isEmpty(csDeviceUserPOS)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
return collect1;
|
||||
}
|
||||
|
||||
|
||||
return collect;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,13 @@ public class EventDetailVO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 事件时间 不带毫秒
|
||||
*/
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private LocalDateTime startTime2;
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@@ -123,4 +130,10 @@ public class EventDetailVO {
|
||||
@ApiModelProperty("逻辑子设备编码")
|
||||
private Integer clDid;
|
||||
|
||||
@ApiModelProperty("ITIC描述")
|
||||
private String itic;
|
||||
|
||||
@ApiModelProperty("F47描述")
|
||||
private String f47;
|
||||
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
cs_event b
|
||||
inner join cs_equipment_delivery c on b.device_id=c.id
|
||||
<if test="csEventUserQueryPage != null and csEventUserQueryPage.type != null and csEventUserQueryPage.type != '' and csEventUserQueryPage.type ==0">
|
||||
inner join cs_line d on d.device_id=b.device_id
|
||||
inner join cs_line d on d.device_id = b.device_id and d.clDid=b.cl_did
|
||||
</if>
|
||||
where 1=1
|
||||
and b.process=c.process
|
||||
@@ -374,7 +374,7 @@
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_DipStr' THEN 1 ELSE 0 END) AS eventDown,
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_IntrStr' THEN 1 ELSE 0 END) AS eventOff,
|
||||
SUM(CASE WHEN tag = 'Evt_Sys_SwlStr' THEN 1 ELSE 0 END) AS eventUp,
|
||||
COUNT(*) AS allNum
|
||||
SUM(CASE WHEN tag IN ('Evt_Sys_DipStr', 'Evt_Sys_IntrStr', 'Evt_Sys_SwlStr') THEN 1 ELSE 0 END) AS allNum
|
||||
FROM
|
||||
cs_event
|
||||
WHERE
|
||||
|
||||
@@ -459,7 +459,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(RmpEventDetailPO::getEventId,id);
|
||||
RmpEventDetailPO po2 = wlRmpEventDetailMapper.selectOne(wrapper);
|
||||
po2.setWavePath(po2.getWavePath());
|
||||
po2.setWavePath(po.getWavePath());
|
||||
po2.setFileFlag(1);
|
||||
int row = wlRmpEventDetailMapper.updateById(po2);
|
||||
if (row > 0) {
|
||||
|
||||
@@ -46,6 +46,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -350,6 +352,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
List<String> ids = returnpage.getRecords().stream().map(EventDetailVO::getId).collect(Collectors.toList());
|
||||
List<CsEventUserPO> userEvents = this.queryEventListByUserId(RequestUtil.getUserIndex(),ids);
|
||||
returnpage.getRecords().forEach(temp -> {
|
||||
if (!Objects.equals(csEventUserQueryPage.getType(),"0")) {
|
||||
temp.setStartTime2(temp.getStartTime());
|
||||
}
|
||||
//台账信息
|
||||
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
|
||||
temp.setEquipmentName(devDetail.getEquipmentName());
|
||||
|
||||
@@ -549,57 +549,115 @@ public class DataTaskServiceImpl implements IDataTaskService {
|
||||
Map<String, List<PqsCommunicate>> deviceCommMap = pqsCommunicates.stream()
|
||||
.collect(Collectors.groupingBy(PqsCommunicate::getDevId));
|
||||
|
||||
// deviceCommMap.forEach((devId, commList) -> {
|
||||
// // 按时间排序
|
||||
// commList.sort(Comparator.comparing(PqsCommunicate::getTime));
|
||||
//
|
||||
// List<String> offlinePeriods = new ArrayList<>();
|
||||
// String offlineStartTime = null;
|
||||
// String offlineEndTime = null;
|
||||
//
|
||||
// if (commList.size() == 1) {
|
||||
// // 只有一条数据的情况
|
||||
// PqsCommunicate singleRecord = commList.get(0);
|
||||
// if (singleRecord.getType() == 0) {
|
||||
// // 掉线:从掉线时间到 24 点
|
||||
// offlineStartTime = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
// offlineEndTime = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 23:59:59";
|
||||
// } else {
|
||||
// // 上线:从 0 点到上线时间
|
||||
// offlineStartTime = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 00:00:00";
|
||||
// offlineEndTime = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
// }
|
||||
// offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
// } else {
|
||||
// // 多条数据的情况
|
||||
// for (int i = 0; i < commList.size(); i++) {
|
||||
// PqsCommunicate current = commList.get(i);
|
||||
//
|
||||
// if (current.getType() == 0) {
|
||||
// // 掉线记录
|
||||
// if (offlineStartTime == null) {
|
||||
// offlineStartTime = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
// }
|
||||
// // 如果是最后一条记录,结束时间为 24 点
|
||||
// if (i == commList.size() - 1) {
|
||||
// offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 23:59:59";
|
||||
// offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
// }
|
||||
// } else {
|
||||
// // 上线记录
|
||||
// if (offlineStartTime != null) {
|
||||
// // 有对应的掉线记录,形成完整时间段
|
||||
// offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
// offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
// offlineStartTime = null;
|
||||
// offlineEndTime = null;
|
||||
// } else {
|
||||
// // 没有对应的掉线记录,说明是从 0 点开始掉线
|
||||
// offlineStartTime = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 00:00:00";
|
||||
// offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime());;
|
||||
// offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (CollUtil.isNotEmpty(offlinePeriods)) {
|
||||
// result.put(devId, offlinePeriods);
|
||||
// }
|
||||
// });
|
||||
deviceCommMap.forEach((devId, commList) -> {
|
||||
// 按时间排序
|
||||
commList.sort(Comparator.comparing(PqsCommunicate::getTime));
|
||||
|
||||
List<String> offlinePeriods = new ArrayList<>();
|
||||
String offlineStartTime = null;
|
||||
String offlineEndTime = null;
|
||||
|
||||
if (commList.size() == 1) {
|
||||
// 只有一条数据的情况
|
||||
PqsCommunicate singleRecord = commList.get(0);
|
||||
if (singleRecord.getType() == 0) {
|
||||
// 掉线:从掉线时间到 24 点
|
||||
offlineStartTime = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
offlineEndTime = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 23:59:59";
|
||||
String startTime1 = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
String endTime1 = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 23:59:59";
|
||||
offlinePeriods.add(startTime1 + " ~ " + endTime1);
|
||||
} else {
|
||||
// 上线:从 0 点到上线时间
|
||||
offlineStartTime = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 00:00:00";
|
||||
offlineEndTime = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
String startTime1 = DATE_TIME_FORMATTER.format(singleRecord.getTime()).substring(0, 10) + " 00:00:00";
|
||||
String endTime1 = DATE_TIME_FORMATTER.format(singleRecord.getTime());
|
||||
offlinePeriods.add(startTime1 + " ~ " + endTime1);
|
||||
}
|
||||
offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
} else {
|
||||
// 多条数据的情况
|
||||
// 多条数据的情况:遍历每相邻两条记录
|
||||
for (int i = 0; i < commList.size(); i++) {
|
||||
PqsCommunicate current = commList.get(i);
|
||||
|
||||
if (current.getType() == 0) {
|
||||
// 掉线记录
|
||||
// 掉线记录:开始计时
|
||||
if (offlineStartTime == null) {
|
||||
offlineStartTime = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
}
|
||||
// 如果是最后一条记录,结束时间为 24 点
|
||||
if (i == commList.size() - 1) {
|
||||
offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 23:59:59";
|
||||
offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
}
|
||||
} else {
|
||||
// 上线记录
|
||||
// 上线记录:结算离线时段
|
||||
if (offlineStartTime != null) {
|
||||
// 有对应的掉线记录,形成完整时间段
|
||||
offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
// 有未结算的离线时段,进行结算
|
||||
String offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
offlineStartTime = null;
|
||||
offlineEndTime = null;
|
||||
} else {
|
||||
// 没有对应的掉线记录,说明是从 0 点开始掉线
|
||||
offlineStartTime = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 00:00:00";
|
||||
offlineEndTime = DATE_TIME_FORMATTER.format(current.getTime());;
|
||||
offlinePeriods.add(offlineStartTime + " ~ " + offlineEndTime);
|
||||
// 没有对应的掉线记录,说明是从 0 点开始掉线到当前上线时间
|
||||
String startTime1 = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 00:00:00";
|
||||
String endTime1 = DATE_TIME_FORMATTER.format(current.getTime());
|
||||
offlinePeriods.add(startTime1 + " ~ " + endTime1);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是最后一条记录且仍在离线状态,结算到 24 点
|
||||
if (i == commList.size() - 1 && offlineStartTime != null) {
|
||||
String endTime1 = DATE_TIME_FORMATTER.format(current.getTime()).substring(0, 10) + " 23:59:59";
|
||||
offlinePeriods.add(offlineStartTime + " ~ " + endTime1);
|
||||
offlineStartTime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(offlinePeriods)) {
|
||||
|
||||
Reference in New Issue
Block a user