|
|
|
|
@@ -1,11 +1,13 @@
|
|
|
|
|
package com.njcn.supervision.service.device.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.text.StrPool;
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
|
|
|
|
import com.njcn.bpm.api.BpmProcessFeignClient;
|
|
|
|
|
@@ -18,6 +20,7 @@ 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.DeviceFeignClient;
|
|
|
|
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.DevDetail;
|
|
|
|
|
import com.njcn.supervision.enums.SupervisionKeyEnum;
|
|
|
|
|
@@ -26,15 +29,20 @@ 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.po.user.UserReportNormalPO;
|
|
|
|
|
import com.njcn.supervision.pojo.vo.device.CheckDeviceVo;
|
|
|
|
|
import com.njcn.supervision.service.device.ICheckDeviceService;
|
|
|
|
|
import com.njcn.supervision.utils.InstanceUtil;
|
|
|
|
|
import com.njcn.user.api.DeptFeignClient;
|
|
|
|
|
import com.njcn.user.pojo.po.Dept;
|
|
|
|
|
import com.njcn.web.factory.PageFactory;
|
|
|
|
|
import com.njcn.web.utils.RequestUtil;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -60,10 +68,15 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
|
|
|
|
|
private final BpmProcessFeignClient bpmProcessFeignClient;
|
|
|
|
|
|
|
|
|
|
private final DeptFeignClient deptFeignClient;
|
|
|
|
|
|
|
|
|
|
private final DeviceFeignClient deviceFeignClient;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addCheckDevice() {
|
|
|
|
|
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
|
|
|
|
deptGetLineParam.setDeptId(RequestUtil.getDeptIndex());
|
|
|
|
|
Dept data = deptFeignClient.getRootDept().getData();
|
|
|
|
|
deptGetLineParam.setDeptId(data.getId());
|
|
|
|
|
List<String> devList = commTerminalGeneralClient.deptGetDevice(deptGetLineParam)
|
|
|
|
|
.getData()
|
|
|
|
|
.stream()
|
|
|
|
|
@@ -79,6 +92,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
checkDevice.setDeviceId(item.getDevIndex());
|
|
|
|
|
checkDevice.setCheckTime(item.getNextTimeCheck());
|
|
|
|
|
checkDevice.setOverdueDay(new Long(item.getNextTimeCheck().until(LocalDate.now(), ChronoUnit.DAYS)).intValue());
|
|
|
|
|
checkDevice.setState(0);
|
|
|
|
|
return checkDevice;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
@@ -113,9 +127,12 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
//默认根据逾期天数排序
|
|
|
|
|
queryWrapper.orderBy(true, false, "A.overdue_day");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.isNull(param.getStatus())) {
|
|
|
|
|
queryWrapper.eq("A.status", param.getStatus());
|
|
|
|
|
if (!Objects.isNull(param.getStatus())) {
|
|
|
|
|
queryWrapper.eq("A.status", param.getStatus());
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.isNull(param.getState())) {
|
|
|
|
|
queryWrapper.eq("A.state", param.getState());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
queryWrapper.le("A.check_time", LocalDate.now());
|
|
|
|
|
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
|
|
|
|
@@ -131,6 +148,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
CheckDevice checkDevice = this.baseMapper.selectById(param.getId());
|
|
|
|
|
checkDevice.setCheckFilePath(param.getReportPath());
|
|
|
|
|
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
|
|
|
|
checkDevice.setNowCheckTime(LocalDate.parse(param.getNowCheckTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
|
|
|
|
// 发起 BPM 流程
|
|
|
|
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
|
|
|
|
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
|
|
|
|
@@ -156,6 +174,7 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
checkDevice.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
|
|
|
|
checkDevice.setCheckFilePath(param.getReportPath());
|
|
|
|
|
checkDevice.setDescription(param.getDescription());
|
|
|
|
|
checkDevice.setNowCheckTime(LocalDate.parse(param.getNowCheckTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
|
|
|
|
// 发起 BPM 流程
|
|
|
|
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
|
|
|
|
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
|
|
|
|
|
@@ -184,10 +203,17 @@ public class CheckDeviceServiceImpl extends MppServiceImpl<CheckDeviceMapper, Ch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void updateProcessStatus(String businessId, Integer status) {
|
|
|
|
|
//流程状态整改
|
|
|
|
|
CheckDevice checkDevice = this.baseMapper.selectById(businessId);
|
|
|
|
|
checkDevice.setStatus(status);
|
|
|
|
|
checkDevice.setState(1);
|
|
|
|
|
this.updateById(checkDevice);
|
|
|
|
|
//修改pq_device定检时间和下次定检时间 5年
|
|
|
|
|
String nowCheckTime = checkDevice.getNowCheckTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
|
|
|
|
String nextCheckTime = checkDevice.getNowCheckTime().plusYears(5).format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
|
|
|
|
deviceFeignClient.updateDevCheckTime(checkDevice.getDeviceId(),nowCheckTime,nextCheckTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|