Compare commits
8 Commits
895755b7e1
...
2026-04
| Author | SHA1 | Date | |
|---|---|---|---|
| 57cb6a2900 | |||
| 3990ad2b9a | |||
| a054a20e8a | |||
| db2821347d | |||
|
|
058229e8c4 | ||
| 13b9981c72 | |||
| e364ca1cae | |||
| 8b183d84e9 |
@@ -1,16 +1,14 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.param.CsEdDataQueryParm;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,7 +16,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class,contextId = "edData")
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/edData", fallbackFactory = CsEdDataFeignClientFallbackFactory.class, contextId = "edData")
|
||||
public interface CsEdDataFeignClient {
|
||||
|
||||
@PostMapping("/findByDevTypeId")
|
||||
@@ -26,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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -61,7 +61,7 @@ public class CsEdDataPO extends BaseEntity {
|
||||
* 版本日期
|
||||
*/
|
||||
@TableField(value = "version_date")
|
||||
private Date versionDate;
|
||||
private LocalDateTime versionDate;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
@@ -94,5 +94,4 @@ public class CsEdDataPO extends BaseEntity {
|
||||
private String crc;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -34,7 +33,8 @@ public class DevVersionVO {
|
||||
/**
|
||||
* 版本日期
|
||||
*/
|
||||
private Date versionDate;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime versionDate;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
|
||||
public boolean addEdData(CsEdDataAddParm csEdDataAddParm) {
|
||||
CsEdDataPO csEdDataPO = new CsEdDataPO();
|
||||
BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
|
||||
String remoteDir = OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH;
|
||||
String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir);
|
||||
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");
|
||||
@@ -58,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);
|
||||
|
||||
@@ -15,6 +15,7 @@ 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;
|
||||
@@ -25,14 +26,15 @@ 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.api.EngineeringFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
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.*;
|
||||
@@ -47,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;
|
||||
@@ -121,9 +124,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final AppProjectService appProjectService;
|
||||
private final CsEdDataService csEdDataService;
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
private final EngineeringFeignClient engineeringFeignClient;
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final OverLimitWlMapper overLimitWlMapper;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
@Override
|
||||
public void refreshDeviceDataCache() {
|
||||
@@ -190,7 +194,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@DSTransactional
|
||||
public Boolean AuditEquipmentDelivery(String id) {
|
||||
//物理删除
|
||||
boolean update = false;
|
||||
@@ -201,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);
|
||||
@@ -685,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<>();
|
||||
/**
|
||||
@@ -712,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);
|
||||
@@ -821,11 +831,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
|
||||
boolean result;
|
||||
//设备名称可以重复
|
||||
//CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
|
||||
//if(Objects.nonNull (one)){
|
||||
// throw new BusinessException ("设备名称不能重复");
|
||||
//}
|
||||
StringUtil.containsSpecialCharacters(param.getNdid());
|
||||
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(param.getNdid());
|
||||
if (!Objects.isNull(po)) {
|
||||
@@ -871,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();
|
||||
@@ -881,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<>();
|
||||
@@ -893,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();
|
||||
@@ -905,6 +932,10 @@ 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.setDeviceId(id);
|
||||
|
||||
@@ -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,22 +290,24 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
tree.addAll(new ArrayList<>(engineeringMap.values()));
|
||||
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
portable1.setName("便携式工程");
|
||||
portable1.setPid("0");
|
||||
portable1.setId(id);
|
||||
if (CollUtil.isNotEmpty(portables)) {
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
portable1.setName("便携式工程");
|
||||
portable1.setPid("0");
|
||||
portable1.setId(id);
|
||||
|
||||
CsLedgerVO portable2 = new CsLedgerVO();
|
||||
portable2.setLevel(1);
|
||||
portable2.setName("便携式项目");
|
||||
portable2.setPid(id);
|
||||
portable2.setId(IdUtil.simpleUUID());
|
||||
portable2.setChildren(portables);
|
||||
CsLedgerVO portable2 = new CsLedgerVO();
|
||||
portable2.setLevel(1);
|
||||
portable2.setName("便携式项目");
|
||||
portable2.setPid(id);
|
||||
portable2.setId(IdUtil.simpleUUID());
|
||||
portable2.setChildren(portables);
|
||||
|
||||
portable1.setChildren(Collections.singletonList(portable2));
|
||||
tree.add(portable1);
|
||||
portable1.setChildren(Collections.singletonList(portable2));
|
||||
tree.add(portable1);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
csUserPinsService.channelTree(list, tree, 4);
|
||||
@@ -703,24 +704,26 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
|
||||
tree.addAll(new ArrayList<>(engineeringMap.values()));
|
||||
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
portable1.setName("便携式工程");
|
||||
portable1.setPid("0");
|
||||
portable1.setId(id);
|
||||
if (CollUtil.isNotEmpty(portables)) {
|
||||
String id = IdUtil.simpleUUID();
|
||||
CsLedgerVO portable1 = new CsLedgerVO();
|
||||
portable1.setLevel(0);
|
||||
portable1.setName("便携式工程");
|
||||
portable1.setPid("0");
|
||||
portable1.setId(id);
|
||||
|
||||
CsLedgerVO portable2 = new CsLedgerVO();
|
||||
portable2.setLevel(1);
|
||||
portable2.setName("便携式项目");
|
||||
portable2.setPid(id);
|
||||
portable2.setId(IdUtil.simpleUUID());
|
||||
portable2.setChildren(portables);
|
||||
CsLedgerVO portable2 = new CsLedgerVO();
|
||||
portable2.setLevel(1);
|
||||
portable2.setName("便携式项目");
|
||||
portable2.setPid(id);
|
||||
portable2.setId(IdUtil.simpleUUID());
|
||||
portable2.setChildren(portables);
|
||||
|
||||
List<CsLedgerVO> portable2List = new ArrayList<>();
|
||||
portable2List.add(portable2);
|
||||
portable1.setChildren(portable2List);
|
||||
tree.add(portable1);
|
||||
List<CsLedgerVO> portable2List = new ArrayList<>();
|
||||
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,48 +59,94 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
|
||||
return;
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(devList)) {
|
||||
//获取需要计算的时间
|
||||
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
|
||||
for (String time : dateRange) {
|
||||
List<PqsCommunicateDto> outCommunicateData = new ArrayList<>();
|
||||
int onlineMinutes = 0;
|
||||
//获取需要计算的时间
|
||||
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
|
||||
for (String time : dateRange) {
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
// 处理后续段:根据上一条记录的状态判断
|
||||
if (online.equals(dayData.get(i - 1).getType())) {
|
||||
totalOnlineMinutes += intervalMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
outCommunicateData.addAll(data);
|
||||
}
|
||||
Date dateOut = DateUtil.parse(time);
|
||||
for (PqsCommunicateDto pqsCommunicate : outCommunicateData) {
|
||||
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());
|
||||
list.add(po);
|
||||
}
|
||||
|
||||
RStatOnlineRateD po = new RStatOnlineRateD();
|
||||
po.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
|
||||
po.setDevIndex(device.getId());
|
||||
po.setOnlineMin(onlineMinutes);
|
||||
po.setOfflineMin(1440 - onlineMinutes);
|
||||
list.add(po);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
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