1.综合评估省级趋势展示
2.技术监督-终端周期检测
This commit is contained in:
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -39,4 +40,7 @@ public class DevDetail {
|
||||
@ApiModelProperty("通讯状态(0:中断;1:正常)")
|
||||
private Integer comFlag;
|
||||
|
||||
@ApiModelProperty("定检时间")
|
||||
private LocalDate nextTimeCheck;
|
||||
|
||||
}
|
||||
|
||||
@@ -231,7 +231,8 @@
|
||||
lineDetail.Line_Grade AS lineGrade,
|
||||
deviceDetail.Update_Time AS timeID,
|
||||
deviceDetail.ip as ip,
|
||||
deviceDetail.Com_Flag as comFlag
|
||||
deviceDetail.Com_Flag as comFlag,
|
||||
deviceDetail.Next_Time_Check as nextTimeCheck
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_line voltage,
|
||||
|
||||
@@ -47,4 +47,7 @@ public class AssessParam {
|
||||
@ApiModelProperty(name="type",value="类型(1年 2季度 3月份 4周 5日)")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(name="areaType",value="0:省份 1:市级")
|
||||
private Integer areaType;
|
||||
|
||||
}
|
||||
|
||||
@@ -200,6 +200,23 @@ public class GridServiceImpl implements IGridService {
|
||||
});
|
||||
}
|
||||
//数据处理
|
||||
if (param.getAreaType() == 0) {
|
||||
AssessVo.AssessTrendVo vo = new AssessVo.AssessTrendVo();
|
||||
vo.setDeptId(param.getDeptIndex());
|
||||
vo.setDeptName("冀北");
|
||||
List<AssessVo> children = new ArrayList<>();
|
||||
map.forEach((k1,v1)->{
|
||||
AssessVo assessVo = new AssessVo();
|
||||
assessVo.setDataTime(k1);
|
||||
List<PqsComasses> communicateList = BeanUtil.copyToList(v1,PqsComasses.class);
|
||||
float synData = comAssesUtil.getAllComAss(communicateList);
|
||||
assessVo.setScore(CollUtil.isEmpty(communicateList)?3.14159f:PubUtils.floatRound(2,synData));
|
||||
assessVo.setLevel(getLevel(assessVo.getScore()));
|
||||
children.add(assessVo);
|
||||
});
|
||||
vo.setChildren(children);
|
||||
result.add(vo);
|
||||
} else {
|
||||
deptList.forEach(item->{
|
||||
if (lineDetailMap.containsKey(item.getArea())) {
|
||||
AssessVo.AssessTrendVo vo = new AssessVo.AssessTrendVo();
|
||||
@@ -211,12 +228,10 @@ public class GridServiceImpl implements IGridService {
|
||||
AssessVo assessVo = new AssessVo();
|
||||
assessVo.setDataTime(k1);
|
||||
List<PQSComAssesPO> poList = v1.stream().filter(it->ll.contains(it.getLineId())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(poList)){
|
||||
List<PqsComasses> communicateList = BeanUtil.copyToList(poList,PqsComasses.class);
|
||||
float synData = comAssesUtil.getAllComAss(communicateList);
|
||||
assessVo.setScore(PubUtils.floatRound(2,synData));
|
||||
assessVo.setLevel(getLevel(synData));
|
||||
}
|
||||
assessVo.setScore(CollUtil.isEmpty(communicateList)?3.14159f:PubUtils.floatRound(2,synData));
|
||||
assessVo.setLevel(getLevel(assessVo.getScore()));
|
||||
children.add(assessVo);
|
||||
});
|
||||
vo.setChildren(children);
|
||||
@@ -224,6 +239,7 @@ public class GridServiceImpl implements IGridService {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -762,10 +778,7 @@ public class GridServiceImpl implements IGridService {
|
||||
*/
|
||||
private String getLevel(float synDatas) {
|
||||
if(synDatas==3.14159f){
|
||||
return "(暂无数据)";
|
||||
}
|
||||
if(synDatas==3.1415f){
|
||||
return "/";
|
||||
return "暂无数据";
|
||||
}
|
||||
if(0<=synDatas&&synDatas<2){
|
||||
return "极差";
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.supervision.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.fallback.CheckDeviceFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例 Api 接口
|
||||
*
|
||||
* @author hongawen
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SUPERVISION, path = "/checkDevice", fallbackFactory = CheckDeviceFeignClientFallbackFactory.class)
|
||||
public interface CheckDeviceFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
HttpResult<String> add();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.supervision.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.supervision.api.CheckDeviceFeignClient;
|
||||
import com.njcn.supervision.utils.SupervisionEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CheckDeviceFeignClientFallbackFactory implements FallbackFactory<CheckDeviceFeignClient> {
|
||||
@Override
|
||||
public CheckDeviceFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CheckDeviceFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> add() {
|
||||
log.error("{}异常,降级处理,异常为:{}", "新增终端检测数据", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ public enum SupervisionKeyEnum {
|
||||
SURVEY_TEST("survey_test","survey","监督测试流程","SurveyTestServiceImpl"),
|
||||
USER_GO_NET("user_go_net","user","入网设计方案流程","UserReportNormalServiceImpl"),
|
||||
USER_TREAT_CHECK("user_treat_check","user","治理工程流程","UserReportNormalServiceImpl"),
|
||||
BUILD_USER_INFO("build_user_info","user","干扰源建档流程","UserReportPOServiceImpl");
|
||||
|
||||
BUILD_USER_INFO("build_user_info","user","干扰源建档流程","UserReportPOServiceImpl"),
|
||||
TIMING_CHECK_DEVICE("timing_check_device","device","终端周期检测","CheckDeviceServiceImpl");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.supervision.pojo.param.device;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author 徐扬
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CheckDeviceParam extends BaseParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "部门id")
|
||||
private String deptId;
|
||||
|
||||
@ApiModelProperty(value = "流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "历史流程实例编号")
|
||||
private String historyInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "审批状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "报告文件地址")
|
||||
private String reportPath;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.njcn.supervision.pojo.po.device;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("supervision_check_device")
|
||||
public class CheckDevice extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置id
|
||||
*/
|
||||
@MppMultiId("device_id")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 定检时间
|
||||
*/
|
||||
@MppMultiId("check_time")
|
||||
private LocalDate checkTime;
|
||||
|
||||
/**
|
||||
* 逾期天数
|
||||
*/
|
||||
private Integer overdueDay;
|
||||
|
||||
/**
|
||||
* 装置定检报告
|
||||
*/
|
||||
private String checkFilePath;
|
||||
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
/**
|
||||
* 历史流程实例
|
||||
*/
|
||||
private String historyInstanceId;
|
||||
|
||||
/**
|
||||
* 1:审批中;2:审批通过;3:审批不通过;4:已取消
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.supervision.pojo.vo.device;
|
||||
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CheckDeviceVo extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("部门")
|
||||
private String dept;
|
||||
|
||||
@ApiModelProperty("变电站")
|
||||
private String substation;
|
||||
|
||||
@ApiModelProperty("装置id")
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty("装置名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("逾期天数")
|
||||
private Integer overdueDay;
|
||||
|
||||
@ApiModelProperty("装置定检报告路径")
|
||||
private String checkFilePath;
|
||||
|
||||
@ApiModelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty("历史流程实例")
|
||||
private String historyInstanceId;
|
||||
|
||||
@ApiModelProperty("状态 1:审批中;2:审批通过;3:审批不通过;4:已取消")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.njcn.supervision.controller.device;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||
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.supervision.pojo.param.device.CheckDeviceParam;
|
||||
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
||||
import com.njcn.supervision.service.device.ICheckDeviceService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/checkDevice")
|
||||
@Api(tags = "终端周期检测")
|
||||
@AllArgsConstructor
|
||||
public class CheckDeviceController extends BaseController {
|
||||
|
||||
private final ICheckDeviceService checkDeviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增需要检测的终端表")
|
||||
public HttpResult<String> add() {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
checkDeviceService.addCheckDevice();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询当前用户需要检测的终端表")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<Page<CheckDeviceVo>> checkDeviceList(@RequestBody @Validated CheckDeviceParam param) {
|
||||
String methodDescribe = getMethodDescribe("checkDeviceList");
|
||||
Page<CheckDeviceVo> list = checkDeviceService.getCheckDeviceList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getInfoById")
|
||||
@ApiOperation("根据id查询详情")
|
||||
@ApiImplicitParam(name = "id", value = "参数", required = true)
|
||||
public HttpResult<CheckDeviceVo> getInfoById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getInfoById");
|
||||
CheckDeviceVo vo = checkDeviceService.getInfoById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/submit")
|
||||
@ApiOperation("提交检测报告")
|
||||
public HttpResult<String> submit(@RequestBody @Validated CheckDeviceParam param) {
|
||||
String methodDescribe = getMethodDescribe("submit");
|
||||
checkDeviceService.submitReport(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/reload")
|
||||
@ApiOperation("重新发起")
|
||||
public HttpResult<String> reload(@RequestBody @Validated CheckDeviceParam param) {
|
||||
String methodDescribe = getMethodDescribe("reload");
|
||||
checkDeviceService.reloadReport(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/cancel")
|
||||
@ApiOperation("取消流程")
|
||||
@ApiImplicitParam(name = "cancelReqVO", value = "取消原因", required = true)
|
||||
public HttpResult<String> cancel(@Validated @RequestBody BpmProcessInstanceCancelParam cancelReqVO) {
|
||||
String methodDescribe = getMethodDescribe("cancel");
|
||||
String result = checkDeviceService.cancel(cancelReqVO);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.supervision.mapper.device;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.supervision.pojo.po.device.CheckDevice;
|
||||
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
public interface CheckDeviceMapper extends MppBaseMapper<CheckDevice> {
|
||||
|
||||
Page<CheckDeviceVo> page(@Param("page") Page<UserVO> page, @Param("ew") QueryWrapper<CheckDeviceVo> queryWrapper);
|
||||
|
||||
CheckDeviceVo getInfo(@Param("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.supervision.mapper.device.CheckDeviceMapper">
|
||||
|
||||
<select id="page" resultType="CheckDeviceVo">
|
||||
select
|
||||
A.*,
|
||||
B.Name deviceName,
|
||||
B1.Name substation,
|
||||
B2.Name dept
|
||||
from
|
||||
supervision_check_device A
|
||||
left join pq_line B on A.device_id = B.Id
|
||||
left join pq_line B1 on B.Pid = B1.Id
|
||||
left join pq_line B2 on B1.Pid = B2.Id
|
||||
<where>
|
||||
and ${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getInfo" resultType="CheckDeviceVo">
|
||||
select
|
||||
A.*,
|
||||
B.Name deviceName,
|
||||
B1.Name substation,
|
||||
B2.Name dept
|
||||
from
|
||||
supervision_check_device A
|
||||
left join pq_line B on A.device_id = B.Id
|
||||
left join pq_line B1 on B.Pid = B1.Id
|
||||
left join pq_line B2 on B1.Pid = B2.Id
|
||||
where A.Id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.supervision.service.device;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||
import com.njcn.bpm.service.IBpmService;
|
||||
import com.njcn.supervision.pojo.param.device.CheckDeviceParam;
|
||||
import com.njcn.supervision.pojo.po.device.CheckDevice;
|
||||
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
public interface ICheckDeviceService extends IBpmService<CheckDevice> {
|
||||
|
||||
/**
|
||||
* 每日定时查询需要检测的终端装置
|
||||
*/
|
||||
void addCheckDevice();
|
||||
|
||||
Page<CheckDeviceVo> getCheckDeviceList(CheckDeviceParam param);
|
||||
|
||||
CheckDeviceVo getInfoById(String id);
|
||||
|
||||
/**
|
||||
* 地市上传终端检测报告
|
||||
*/
|
||||
void submitReport(CheckDeviceParam param);
|
||||
|
||||
/**
|
||||
* 重新发起
|
||||
*/
|
||||
void reloadReport(CheckDeviceParam param);
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
String cancel(BpmProcessInstanceCancelParam cancelReqVO);
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.njcn.supervision.service.device.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.bpm.api.BpmProcessFeignClient;
|
||||
import com.njcn.bpm.enums.BpmProcessInstanceStatusEnum;
|
||||
import com.njcn.bpm.enums.BpmTaskStatusEnum;
|
||||
import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.pojo.vo.DevDetail;
|
||||
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
||||
import com.njcn.supervision.mapper.device.CheckDeviceMapper;
|
||||
import com.njcn.supervision.pojo.param.device.CheckDeviceParam;
|
||||
import com.njcn.supervision.pojo.po.device.CheckDevice;
|
||||
import com.njcn.supervision.pojo.po.device.QuitRunningDevice;
|
||||
import com.njcn.supervision.pojo.po.survey.SurveyTest;
|
||||
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
||||
import com.njcn.supervision.service.device.ICheckDeviceService;
|
||||
import com.njcn.supervision.utils.InstanceUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端周期检测表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2024-06-13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, CheckDevice> implements ICheckDeviceService {
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
private final BpmProcessFeignClient bpmProcessFeignClient;
|
||||
|
||||
@Override
|
||||
public void addCheckDevice() {
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(RequestUtil.getDeptIndex());
|
||||
List<String> devList = commTerminalGeneralClient.deptGetDevice(deptGetLineParam)
|
||||
.getData()
|
||||
.stream()
|
||||
.flatMap(item -> item.getDeviceList().stream())
|
||||
.map(LineDevGetDTO::getDevId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<DevDetail> detail = generalDeviceInfoClient.getDevInfoByIds(devList).getData();
|
||||
List<CheckDevice> checkDevices = detail.stream()
|
||||
.filter(item -> item.getNextTimeCheck().isBefore(LocalDate.now()) || LocalDate.now().isEqual(item.getNextTimeCheck()))
|
||||
.map(item -> {
|
||||
CheckDevice checkDevice = new CheckDevice();
|
||||
checkDevice.setDeviceId(item.getDevIndex());
|
||||
checkDevice.setCheckTime(item.getNextTimeCheck());
|
||||
checkDevice.setOverdueDay(new Long(item.getNextTimeCheck().until(LocalDate.now(), ChronoUnit.DAYS)).intValue());
|
||||
return checkDevice;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
this.saveOrUpdateBatchByMultiId(checkDevices,100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CheckDeviceVo> getCheckDeviceList(CheckDeviceParam param) {
|
||||
QueryWrapper<CheckDeviceVo> queryWrapper = new QueryWrapper<>();
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(param.getDeptId());
|
||||
List<String> devList = commTerminalGeneralClient.deptGetDevice(deptGetLineParam)
|
||||
.getData()
|
||||
.stream()
|
||||
.flatMap(item -> item.getDeviceList().stream())
|
||||
.map(LineDevGetDTO::getDevId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(devList)) {
|
||||
queryWrapper.in("A.device_id",devList);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(param.getSearchValue())) {
|
||||
queryWrapper
|
||||
.and(par -> par.like("B.Name", param.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(param.getSortBy(), param.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, param.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(param.getSortBy()));
|
||||
} else {
|
||||
//默认根据逾期天数排序
|
||||
queryWrapper.orderBy(true, false, "A.overdue_day");
|
||||
}
|
||||
}
|
||||
if (!Objects.isNull(param.getStatus())) {
|
||||
queryWrapper.eq("A.status", param.getStatus());
|
||||
}
|
||||
queryWrapper.le("A.check_time", LocalDate.now());
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckDeviceVo getInfoById(String id) {
|
||||
return this.baseMapper.getInfo(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitReport(CheckDeviceParam param) {
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(param.getId());
|
||||
checkDevice.setCheckFilePath(param.getReportPath());
|
||||
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.TIMING_CHECK_DEVICE.getKey());
|
||||
bpmProcessInstanceCreateReqDTO.setBusinessKey(checkDevice.getId());
|
||||
bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>());
|
||||
bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables);
|
||||
String processInstanceId = bpmProcessFeignClient.createProcessInstance(RequestUtil.getUserIndex(), bpmProcessInstanceCreateReqDTO).getData();
|
||||
// 将工作流的编号,更新到流程单中
|
||||
checkDevice.setProcessInstanceId(processInstanceId);
|
||||
checkDevice.setDescription(param.getDescription());
|
||||
checkDevice.setCreateBy(RequestUtil.getUserIndex());
|
||||
this.baseMapper.updateById(checkDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadReport(CheckDeviceParam param) {
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(param.getId());
|
||||
//判断是否有权限操作
|
||||
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(),checkDevice.getCreateBy());
|
||||
//处理历史流程id列表
|
||||
String historyInstanceIds = InstanceUtil.dealHistoryId(checkDevice.getProcessInstanceId(), checkDevice.getHistoryInstanceId());
|
||||
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
checkDevice.setCheckFilePath(param.getReportPath());
|
||||
checkDevice.setDescription(param.getDescription());
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.TIMING_CHECK_DEVICE.getKey());
|
||||
bpmProcessInstanceCreateReqDTO.setBusinessKey(checkDevice.getId());
|
||||
bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>());
|
||||
bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables);
|
||||
String processInstanceId = bpmProcessFeignClient.createProcessInstance(checkDevice.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData();
|
||||
// 将工作流的编号,更新到流程单中
|
||||
checkDevice.setProcessInstanceId(processInstanceId);
|
||||
//保存历史流程id列表
|
||||
checkDevice.setHistoryInstanceId(historyInstanceIds);
|
||||
this.baseMapper.updateById(checkDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel(BpmProcessInstanceCancelParam cancelReqVO) {
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(cancelReqVO.getId());
|
||||
//判断是否有权限操作
|
||||
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(), checkDevice.getCreateBy());
|
||||
//取消流程
|
||||
bpmProcessFeignClient.cancelProcessInstanceByStartUser(cancelReqVO);
|
||||
checkDevice.setStatus(BpmProcessInstanceStatusEnum.CANCEL.getStatus());
|
||||
this.updateById(checkDevice);
|
||||
return checkDevice.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessStatus(String businessId, Integer status) {
|
||||
CheckDevice checkDevice = this.baseMapper.selectById(businessId);
|
||||
checkDevice.setStatus(status);
|
||||
this.updateById(checkDevice);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import com.njcn.supervision.api.CheckDeviceFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CheckDeviceTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final CheckDeviceFeignClient checkDeviceFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
checkDeviceFeignClient.add();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user