package com.gkhy.safePlatform.safeCheck.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountGroupService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.AccountUserService;
|
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.*;
|
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
|
import com.gkhy.safePlatform.commons.enums.E;
|
import com.gkhy.safePlatform.commons.exception.AusinessException;
|
import com.gkhy.safePlatform.commons.utils.StringUtils;
|
import com.gkhy.safePlatform.commons.vo.ResultVO;
|
import com.gkhy.safePlatform.safeCheck.common.RocketMQTemplateHelper;
|
import com.gkhy.safePlatform.safeCheck.entity.*;
|
import com.gkhy.safePlatform.safeCheck.model.dto.req.*;
|
import com.gkhy.safePlatform.safeCheck.model.dto.resp.*;
|
import com.gkhy.safePlatform.safeCheck.model.query.MobileTaskDataDBQuery;
|
import com.gkhy.safePlatform.safeCheck.mq.msg.SafeCheckSmartScreenDataPushMsg;
|
import com.gkhy.safePlatform.safeCheck.service.SafeCheckMinioAccessService;
|
import com.gkhy.safePlatform.safeCheck.service.baseService.*;
|
import com.gkhy.safePlatform.safeCheck.enums.*;
|
import com.gkhy.safePlatform.safeCheck.model.query.MobileUserTaskDBQuery;
|
import com.gkhy.safePlatform.safeCheck.service.SafeCheckSmartScreenService;
|
import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskMobileManagerService;
|
import com.gkhy.safePlatform.safeCheck.util.SendMessageUtil;
|
import com.gkhy.safePlatform.safeCheck.util.UserInfoUtil;
|
import javafx.scene.input.DataFormat;
|
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.redisson.api.RLock;
|
import org.redisson.api.RedissonClient;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
import java.text.DecimalFormat;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.*;
|
import java.util.concurrent.TimeUnit;
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
import java.util.stream.Collectors;
|
|
|
@Service
|
public class SafeCheckTaskMobileManagerServiceImpl implements SafeCheckTaskMobileManagerService {
|
|
|
@DubboReference(check = false)
|
private AccountAuthService accountAuthService;
|
|
@DubboReference(check = false)
|
private AccountGroupService accountGroupService;
|
|
@DubboReference(check = false)
|
private AccountUserService accountUserService;
|
|
@DubboReference(check = false)
|
private AccountDepartmentService accountDepartmentService;
|
|
@Autowired
|
private RedissonClient redissonClient;
|
|
@Autowired
|
private RocketMQTemplateHelper rocketMQTemplateHelper;
|
|
@Value("${rocketmq.topic.safeCheckSmartScreenDataPushTopic}")
|
private String safeCheckSmartScreenDataPushTopic;
|
|
@Autowired
|
private SafeCheckTaskService safeCheckTaskService;
|
|
@Autowired
|
private SafeCheckRfidService safeCheckRfidService;
|
|
// @Autowired
|
// private SafeCheckWebSocketServer webSocketServer;
|
|
@Autowired
|
private AbnormalWorkOrderService abnormalWorkOrderService;
|
|
@Autowired
|
private SendMessageUtil sendMessageUtil;
|
|
@Autowired
|
private AbnormalWorkOrderImagesService abnormalWorkOrderImagesService;
|
|
@Autowired
|
private SafeCheckSmartScreenService smartScreenService;
|
|
@Autowired
|
private SafeCheckMinioAccessService minioAccessService;
|
|
@Autowired
|
private SafeCheckTaskAndQuotaService safeCheckTaskAndQuotaService;
|
|
|
/**
|
* @description 查询用户所属的班组,用户上班时间的任务信息
|
*/
|
@Transactional
|
@Override
|
public IPage listUserTaskByPage(ContextCacheUser currentUser,Page pageInfo, SafeCheckMobilePageReqDTO safeCheckMobilePageReqDTO) {
|
|
//获取用户信息
|
ResultVO<UserRPCRespDTO> rpcResult = accountAuthService.getUserById(currentUser.getUid());
|
UserRPCRespDTO userInfo = UserInfoUtil.judgeUserInfo(rpcResult);
|
|
Long uid = currentUser.getUid();
|
ResultVO<List<GroupRPCRespDTO>> listResultVO = accountGroupService.listGroupInfoByUid(uid);
|
List<GroupRPCRespDTO> groupInfo = (List<GroupRPCRespDTO>) listResultVO.getData();
|
if (CollectionUtils.isEmpty(groupInfo)){
|
return null;
|
}
|
//String groupName = groupInfo.getGroupName();
|
List<Long> execClassgroupids = groupInfo.stream().map(e -> e.getGroupId()).collect(Collectors.toList());
|
Map<Long, String> stringMap = groupInfo.stream().collect(Collectors.toMap(GroupRPCRespDTO::getGroupId, GroupRPCRespDTO::getGroupName));
|
//LocalDate now = LocalDate.now();
|
//ResultVO<UserGroupTimTableRPCRespDTO> timeTable = accountUserService.getUserGroupWorkTimeTable(uid, now, now);
|
//UserGroupTimTableRPCRespDTO data = (UserGroupTimTableRPCRespDTO) timeTable.getData();
|
//List<UserTimeTableRPCRespDTO> timeDetails = data.getTimeDetails();
|
//
|
//if (timeDetails == null || timeDetails.size()==0){
|
// return null;
|
//}
|
////todo 获取当天的第一个排班
|
//UserTimeTableRPCRespDTO userTimeTable = timeDetails.get(0);
|
//LocalDateTime startTime = userTimeTable.getStartTime();
|
//LocalDateTime endTime = userTimeTable.getEndTime();
|
|
MobileUserTaskDBQuery taskDBQuery = new MobileUserTaskDBQuery();
|
taskDBQuery.setExecClassgroupId(execClassgroupids);
|
//taskDBQuery.setStartTime(startTime);
|
//taskDBQuery.setEndTime(endTime);
|
taskDBQuery.setTaskStatus(safeCheckMobilePageReqDTO.getTaskStatus());
|
taskDBQuery.setTaskClaim(safeCheckMobilePageReqDTO.getTaskClaim());
|
taskDBQuery.setTaskType(safeCheckMobilePageReqDTO.getTaskType());
|
IPage taskIPage = safeCheckTaskService.listUserTaskByPage(pageInfo, taskDBQuery);
|
List<SafeCheckTaskMobileDO> records = taskIPage.getRecords();
|
if (records == null || records.size() == 0 ){
|
return null;
|
}
|
List<SafeCheckTaskMobilePageRespDTO> taskMobilePages = records.stream().map((record)->{
|
SafeCheckTaskMobilePageRespDTO pageRespDTO = new SafeCheckTaskMobilePageRespDTO();
|
BeanUtils.copyProperties(record,pageRespDTO);
|
List<SafeCheckTaskAndQuota> points = record.getPoints();
|
if (points != null && points.size() > 0){
|
List<SafeCheckTaskAndQuotaMobileRespDTO> mobileRespDTOS = points.stream().map((point)->{
|
SafeCheckTaskAndQuotaMobileRespDTO mobileRespDTO = new SafeCheckTaskAndQuotaMobileRespDTO();
|
BeanUtils.copyProperties(point,mobileRespDTO);
|
return mobileRespDTO;
|
}).collect(Collectors.toList());
|
pageRespDTO.setPoints(mobileRespDTOS);
|
}
|
pageRespDTO.setExecClassgroup(stringMap.get(record.getExecClassgroupId()));
|
return pageRespDTO;
|
}).collect(Collectors.toList());
|
taskIPage.setRecords(taskMobilePages);
|
return taskIPage;
|
}
|
|
/**
|
* @description 用户认领任务
|
*/
|
@Override
|
public void updateTaskClaimById(ContextCacheUser currentUser, Long taskId) {
|
if (taskId == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"任务id不能为空");
|
}
|
|
//0、加分布式锁
|
String lockName = "SAFECHECK_CLAIM_TASK_"+taskId;
|
RLock claimTaskLock = redissonClient.getLock(lockName);
|
claimTaskLock.lock(3, TimeUnit.SECONDS);
|
|
SafeCheckTask task = safeCheckTaskService.getTaskById(taskId);
|
if (task == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"任务不存在");
|
}
|
if (task.getTaskClaim().intValue() == 2){
|
throw new AusinessException(E.DATA_DATABASE_EXIST,"任务已被认领");
|
}
|
task.setTaskClaimTime(new Date());
|
task.setExecUserId(currentUser.getUid());
|
task.setExecUserName(currentUser.getRealName());
|
task.setTaskClaim(TaskClaimStatusEnum.TASK_CLAIM_STATUS_YES.getCode());
|
task.setEnterpriseId(currentUser.getDepId());
|
safeCheckTaskService.updateTaskClaimById(task);
|
|
//1、释放分布式锁
|
claimTaskLock.unlock();
|
}
|
|
/**
|
* @description 用户单个提交巡检点巡检结果
|
*/
|
@Transactional
|
@Override
|
public void updateTaskAndQuotaResultById(ContextCacheUser currentUser, SafeCheckTaskAndQuotaSubmitReqDTO safeCheckTaskAndQuotaSubmitReqDTO) {
|
if (safeCheckTaskAndQuotaSubmitReqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
SafeCheckTaskAndQuota safeCheckTaskAndQuota = new SafeCheckTaskAndQuota();
|
BeanUtils.copyProperties(safeCheckTaskAndQuotaSubmitReqDTO,safeCheckTaskAndQuota);
|
List<String> images = safeCheckTaskAndQuotaSubmitReqDTO.getImages();
|
//获取用户信息
|
ResultVO<UserRPCRespDTO> rpcResult = accountAuthService.getUserById(currentUser.getUid());
|
UserRPCRespDTO userInfo = UserInfoUtil.judgeUserInfo(rpcResult);
|
|
Long uid = currentUser.getUid();
|
this.taskAndQuotaResultParamCheck(safeCheckTaskAndQuota);
|
|
int taskAndQuotaId = safeCheckTaskAndQuota.getId();
|
SafeCheckTaskAndQuota referenceTaskAndQuota = safeCheckTaskAndQuotaService.getTaskAndQuotaById(taskAndQuotaId);
|
if (referenceTaskAndQuota == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"数据库无此巡检任务生成的巡检点信息");
|
}
|
|
//提交用户必须是执行用户
|
SafeCheckTask task = safeCheckTaskService.getTaskById(safeCheckTaskAndQuota.getTaskId());
|
if (task == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"任务不存在");
|
}
|
if (!task.getExecUserId().equals(uid)){
|
throw new AusinessException(E.UPDATE_FAIL,"不是任务认领人,无法提交巡检点巡检结果");
|
}
|
|
Byte reportResult = referenceTaskAndQuota.getReportResult();
|
if (reportResult != null){
|
throw new AusinessException(E.UPDATE_FAIL,"巡检点巡检结果已经提交,请勿重复提交");
|
}
|
Byte dataReportType = safeCheckTaskAndQuota.getDataReportType();
|
|
SafeCheckTaskAndQuota resultTaskAndQuota = null;
|
if (dataReportType.intValue() == 1){
|
resultTaskAndQuota = this.optResultIsAbnormal(safeCheckTaskAndQuota, referenceTaskAndQuota);
|
}
|
if (dataReportType.intValue() == 2){
|
resultTaskAndQuota = this.fillBlankResultIsAbnormal(safeCheckTaskAndQuota, referenceTaskAndQuota);
|
}
|
if (dataReportType.intValue() == 3){
|
resultTaskAndQuota = this.optResultIsAbnormal(safeCheckTaskAndQuota, referenceTaskAndQuota);
|
//选择的结果(0-正常;1-异常;3-备)
|
Byte optResult = resultTaskAndQuota.getReportResult();
|
//填空的结果(0-正常;1-异常)
|
resultTaskAndQuota = this.fillBlankResultIsAbnormal(safeCheckTaskAndQuota, referenceTaskAndQuota);
|
Byte blankResult = resultTaskAndQuota.getReportResult();
|
if (TaskResultEnum.TASK_RESULT_BEI.getCode().equals(optResult)){
|
if (TaskResultEnum.TASK_RESULT_NORMAL.getCode().equals(blankResult)){
|
resultTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}else {
|
resultTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}
|
|
}else {
|
if (optResult.intValue() != TaskResultEnum.TASK_RESULT_NORMAL.getCode().intValue()
|
|| blankResult.intValue() != TaskResultEnum.TASK_RESULT_NORMAL.getCode().intValue()) {
|
resultTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
} else {
|
resultTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}
|
}
|
}
|
Byte rfidPosition = resultTaskAndQuota.getRfidPosition();
|
if (rfidPosition == RfidPositionEnum.RFID_POSITION_YES.getCode()){
|
String rfid = resultTaskAndQuota.getRfid();
|
Long taskId = resultTaskAndQuota.getTaskId();
|
//将任务关联的巡检点rfid相同的数据rfid定位状态都改为已定位
|
int countResult = safeCheckTaskAndQuotaService.countRfidSameByTaskId(taskId, rfid);
|
int updateResult = safeCheckTaskAndQuotaService.updateRfidPositionStatusByTaskIdAndRfid(taskId, rfid, RfidPositionEnum.RFID_POSITION_YES.getCode());
|
if (countResult != updateResult){
|
throw new AusinessException(E.UPDATE_FAIL,"部分巡检点定位状态修改失败");
|
}
|
}
|
resultTaskAndQuota.setPointCheckStatus(PointCheckStatusEnum.POINT_CHECK_STATUS_FINISHED.getCode());
|
//最后将巡检点检查结果信息进行修改
|
safeCheckTaskAndQuotaService.updatePointCheckResultByIdAndTaskId(resultTaskAndQuota);
|
if (TaskResultEnum.TASK_RESULT_UNUSUAL.getCode().equals(resultTaskAndQuota.getReportResult())){
|
//如果结果异常走异常处理流程
|
workOrderExceptionHandlingProcess(uid,resultTaskAndQuota,images);
|
//异常发送短信
|
workOrderExceptionSendMesProcess(task,resultTaskAndQuota);
|
}
|
|
|
// 整个巡检链数据发过去
|
// Long taskId = safeCheckTaskAndQuota.getTaskId();
|
// List<SafeCheckTaskAndQuota> taskAndQuotas = safeCheckTaskAndQuotaService.listTaskAndQuotaByTaskId(taskId);
|
// if (taskAndQuotas == null && taskAndQuotas.size() ==0){
|
// throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"当前任务无关联巡检链");
|
// }
|
// List<SafeCheckSmartScreenRepsDTO> smartScreenData = taskAndQuotas.stream().map((taskAndQuota)->{
|
// SafeCheckSmartScreenRepsDTO smartScreenRepsDTO = new SafeCheckSmartScreenRepsDTO();
|
// BeanUtils.copyProperties(taskAndQuota,smartScreenRepsDTO);
|
// return smartScreenRepsDTO;
|
// }).collect(Collectors.toList());
|
|
// 根据任务id以及巡检链中对应的巡检点id,推送一条巡检记录
|
// SafeCheckTaskAndQuota taskAndQuota = safeCheckTaskAndQuotaService.getTaskAndQuotaByIdAndTaskId(resultTaskAndQuota.getId(),referenceTaskAndQuota.getTaskId());
|
// SafeCheckSmartScreenRepsDTO smartScreenRepsDTO = new SafeCheckSmartScreenRepsDTO();
|
// BeanUtils.copyProperties(taskAndQuota,smartScreenRepsDTO);
|
// String msg = JsonUtils.toJson(smartScreenRepsDTO);
|
|
|
// 首先判断当前的任务id是否已经连接到websocket todo 之前使用的直推
|
// String taskId = Long.toString(referenceTaskAndQuota.getTaskId());
|
// if (SafeCheckWebSocketServer.taskIsconnectByTaskId(taskId)){
|
// List<SafeCheckTaskAndQuota> taskAndQuotas = safeCheckTaskAndQuotaService.listTaskAndQuotaByTaskId(referenceTaskAndQuota.getTaskId());
|
// List<SafeCheckSmartScreenRepsDTO> screenDataByTaskId = SafeCheckSmartScreenServiceImpl.getSmartScreenDataByTaskId(taskAndQuotas);
|
// String msg = JsonUtils.toJson(screenDataByTaskId);
|
// //调用websocket发送消息
|
// try {
|
// webSocketServer.sendInfo(msg,taskId);
|
// }catch (Exception e){
|
// throw new AusinessException(E.DATA_STATUS_NOT_EXIST,"websocket消息fa发送失败");
|
// }
|
|
// todo 现在直接是把消息发给mq 由wenscoket上的消费者监听到消息后推送消息
|
//1、mq发送生成推送消息
|
SafeCheckSmartScreenDataPushMsg screenDataPushMsg = new SafeCheckSmartScreenDataPushMsg();
|
screenDataPushMsg.setTaskId(referenceTaskAndQuota.getTaskId());
|
//先提交后再推送消息
|
rocketMQTemplateHelper.syncSend(safeCheckSmartScreenDataPushTopic,screenDataPushMsg);
|
// Runnable runnable = new Runnable(){
|
// @Override
|
// public void run() {
|
// while (true) {
|
// System.out.println("【websocket】"+new Date()+ "定时发送消息中.......");
|
// try {
|
// webSocketServer.sendInfo(msg,taskId);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// try {
|
// Thread.sleep(10000);
|
// } catch (InterruptedException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// }
|
// };
|
// Thread thread = new Thread(runnable);
|
// thread.start();
|
// }
|
}
|
|
/**
|
* @description 异常工单发送短信
|
*/
|
private void workOrderExceptionSendMesProcess(SafeCheckTask task,SafeCheckTaskAndQuota safeCheckTaskAndQuota){
|
String taskName = task.getTaskName();
|
SafeCheckRfid rfid = safeCheckRfidService.getRfidById(safeCheckTaskAndQuota.getRfidId(), DelectStatusEnum.DELECT_NO.getStatus());
|
if (rfid != null){
|
ResultVO<UserInfoRPCRespDTO> info = accountUserService.getUserInfoByUid(rfid.getExceptionHandlerId());
|
UserInfoRPCRespDTO data = (UserInfoRPCRespDTO) info.getData();
|
if (data != null && StringUtils.isNotBlank(data.getPhone())){
|
String[] phone = {data.getPhone()};
|
Map<String, String> map = new HashMap<>();
|
map.put("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒")));
|
map.put("task", taskName);
|
map.put("rfid", safeCheckTaskAndQuota.getRfidName());
|
map.put("point", safeCheckTaskAndQuota.getPoint());
|
sendMessageUtil.sendMessageCheck(phone,map);
|
}
|
}
|
}
|
|
/**
|
* 工单异常处理流程
|
*/
|
private void workOrderExceptionHandlingProcess(Long uid,SafeCheckTaskAndQuota resultTaskAndQuota,List<String> images) {
|
ResultVO<UserInfoRPCRespDTO> userInfoByUid = accountUserService.getUserInfoByUid(uid);
|
UserInfoRPCRespDTO userInfo = (UserInfoRPCRespDTO) userInfoByUid.getData();
|
AbnormalWorkOrder order = new AbnormalWorkOrder();
|
SafeCheckTaskAndQuota taskAndQuotaById = safeCheckTaskAndQuotaService.getTaskAndQuotaById(resultTaskAndQuota.getId());
|
if (taskAndQuotaById == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"巡检点记录不存在");
|
}
|
Date date = new Date();
|
WorkOrderRelatedDataDO workOrderRelatedDataDO = safeCheckTaskAndQuotaService.getWorkOrderRelatedData(resultTaskAndQuota.getId());
|
BeanUtils.copyProperties(workOrderRelatedDataDO,order,"id");
|
order.setFirstReferenceResult(resultTaskAndQuota.getFirstReferenceResult());
|
order.setSecondReferenceResult(resultTaskAndQuota.getSecondReferenceResult());
|
order.setTaskAndQuotaId(workOrderRelatedDataDO.getId());
|
order.setWorkOrderTime(date);
|
|
|
//0、加分布式锁
|
String lockName = "SAFECHECK_WORK_ORDER_EXCEPTION";
|
RLock workOrderExceptionLock = redissonClient.getLock(lockName);
|
workOrderExceptionLock.lock(3, TimeUnit.SECONDS);
|
|
GetLastWorkOrderSortDO getLastWorkOrderSortDO = abnormalWorkOrderService.getLastWorkOrderSort();
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
|
if (getLastWorkOrderSortDO == null){
|
order.setWorkOrderSort(1L);
|
}else {
|
//todo: 增加了非空判断,但空值处理未实现
|
if(date != null && getLastWorkOrderSortDO != null && getLastWorkOrderSortDO.getWorkOrderTime() != null){
|
if (fmt.format(date).equals(fmt.format(getLastWorkOrderSortDO.getWorkOrderTime()))){
|
order.setWorkOrderSort(getLastWorkOrderSortDO.getWorkOrderSort()+1);
|
}else {
|
order.setWorkOrderSort(1L);
|
}
|
}
|
}
|
order.setOccurrenceTime(date);
|
SafeCheckTask task = safeCheckTaskService.getTaskById(workOrderRelatedDataDO.getTaskId());
|
if (task == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"任务不存在");
|
}
|
order.setTaskName(task.getTaskName());
|
order.setExecDepId(task.getExecDepId());
|
order.setExecClassgroupId(task.getExecClassgroupId());
|
ResultVO<UserInfoRPCRespDTO> infoByUid = accountUserService.getUserInfoByUid(workOrderRelatedDataDO.getExceptionHandlerId());
|
UserInfoRPCRespDTO userInfoRPCRespDTO = (UserInfoRPCRespDTO) infoByUid.getData();
|
if (userInfoRPCRespDTO != null){
|
order.setHiddenDangerHandlerId(userInfoRPCRespDTO.getUid());
|
order.setHiddenDangerHandlerName(userInfoRPCRespDTO.getRealName());
|
order.setHiddenDangerHandlerPhone(userInfoRPCRespDTO.getPhone());
|
}
|
order.setHandlerStatus(ExceptionHandleStatusEnum.TO_BE_RESPONDED.getStatus());
|
order.setGmtCreate(date);
|
order.setGmtModitify(date);
|
order.setCreateUserName(userInfo.getRealName());
|
order.setLastEditUserName(userInfo.getRealName());
|
abnormalWorkOrderService.save(order);
|
Long id = order.getId();
|
if (CollectionUtils.isNotEmpty(images)){
|
List<AbnormalWorkOrderImages> workOrderImages = new ArrayList<>();
|
for (String image : images) {
|
AbnormalWorkOrderImages orderImages = new AbnormalWorkOrderImages();
|
orderImages.setAbnormalImage(image);
|
orderImages.setAbnormalWorkOrderId(id);
|
orderImages.setTaskAndQuotaId(resultTaskAndQuota.getId());
|
orderImages.setGmtCreate(date);
|
orderImages.setCreateUserName(userInfo.getRealName());
|
orderImages.setImageTimeStatus(ImageTimeStatusEnum.BEFORE_PROCESSING.getStatus());
|
orderImages.setCreateUserId(uid);
|
workOrderImages.add(orderImages);
|
}
|
abnormalWorkOrderImagesService.saveBatch(workOrderImages);
|
}
|
//1、释放分布式锁
|
workOrderExceptionLock.unlock();
|
}
|
|
/**
|
* @description 最终任务提交:是否还有rfid未定位 是否还有巡检点没有提交
|
*/
|
@Override
|
public void updateTaskResultById(ContextCacheUser currentUser, Long taskId) {
|
|
//获取用户信息
|
ResultVO<UserRPCRespDTO> rpcResult = accountAuthService.getUserById(currentUser.getUid());
|
UserRPCRespDTO userInfo = UserInfoUtil.judgeUserInfo(rpcResult);
|
|
Long uid = currentUser.getUid();
|
|
//提交用户必须是执行用户
|
SafeCheckTask task = safeCheckTaskService.getTaskById(taskId);
|
if (task == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"任务不存在");
|
}
|
if (!task.getExecUserId().equals(uid)){
|
throw new AusinessException(E.UPDATE_FAIL,"不是任务认领人,无法提交");
|
}
|
|
//查询该任务下巡检点是否还有没有定位的
|
// List<String> points = safeCheckTaskAndQuotaService.selectNoRfidPositionByTaskId(taskId);
|
// if (points != null && points.size()>0){
|
// String pointNoPosition = "";
|
// for (String point : points) {
|
// pointNoPosition = pointNoPosition + point + " ";
|
// }
|
// throw new AusinessException(E.UPDATE_FAIL,"【"+pointNoPosition+"】等巡检点未完成定位,请定位后提交");
|
// }
|
//查询该任务下巡检点是否还有没提交的
|
List<String> pointsNoReports = safeCheckTaskAndQuotaService.selectRfidNoReportByTaskId(taskId);
|
if (pointsNoReports != null && pointsNoReports.size() > 0){
|
String pointNoReport = "";
|
for (String point : pointsNoReports) {
|
pointNoReport = pointNoReport + point + " ";
|
}
|
throw new AusinessException(E.UPDATE_FAIL,"【"+pointNoReport+"】等巡检点未提交,请提交后重试");
|
}
|
//统计巡检点中是否存在巡检异常的数据
|
int abnormalPoint = safeCheckTaskAndQuotaService.countRfidReportIsAbnormalByTaskId(taskId,TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
if (abnormalPoint > 0){
|
safeCheckTaskService.updateTaskCheckResultByTaskId(taskId, TaskStatusEnum.TASK_CHECK_FINISHED.getStatus(),TaskResultEnum.TASK_RESULT_UNUSUAL.getCode(),new Date());
|
}else {
|
safeCheckTaskService.updateTaskCheckResultByTaskId(taskId, TaskStatusEnum.TASK_CHECK_FINISHED.getStatus(), TaskResultEnum.TASK_RESULT_NORMAL.getCode(), new Date());
|
}
|
}
|
|
/**
|
* @description 查询用户工单列表
|
*/
|
@Override
|
public IPage listUserExcepOrderByPage(ContextCacheUser currentUser, Page pageInfo) {
|
Long uid = currentUser.getUid();
|
IPage orderIPage = abnormalWorkOrderService.listUserExcepOrderByPage(pageInfo,uid);
|
List<AbnormalWorkOrder> records = orderIPage.getRecords();
|
if (CollectionUtils.isEmpty(records)){
|
return orderIPage;
|
}
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd分");
|
|
List<ListUserExcepOrderByPageRespDTO> dtos = records.stream().map((record) -> {
|
ListUserExcepOrderByPageRespDTO dto = new ListUserExcepOrderByPageRespDTO();
|
String dateTime = dateFormat.format(record.getWorkOrderTime());
|
dto.setWorkOrderTime(dateTime);
|
BeanUtils.copyProperties(record, dto);
|
return dto;
|
}).collect(Collectors.toList());
|
orderIPage.setRecords(dtos);
|
return orderIPage;
|
}
|
|
/**
|
* 响应回执
|
*/
|
@Override
|
public void updateExcepOrderhandleStatusById(ContextCacheUser currentUser, ExcepOrderhandleStatusByIdReqDTO reqDTO) {
|
if (reqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
if (reqDTO.getId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"工单id不能为空");
|
}
|
AbnormalWorkOrder workOrder = abnormalWorkOrderService.getById(reqDTO.getId());
|
if (workOrder == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"工单不存在");
|
}
|
if (!currentUser.getUid().equals(workOrder.getHiddenDangerHandlerId())){
|
throw new AusinessException(E.DATA_OPERATION_NO_PERMISSION,"提交人必须为异常处理人");
|
}
|
AbnormalWorkOrder order = new AbnormalWorkOrder();
|
order.setId(reqDTO.getId());
|
order.setHandlerStatus(reqDTO.getHandlerStatus());
|
Byte handlerStatus = reqDTO.getHandlerStatus();
|
if (ExceptionHandleStatusEnum.SUBMITTED.getStatus().equals(handlerStatus)){
|
Long hiddenDangerTransferHandlerId = reqDTO.getHiddenDangerTransferHandlerId();
|
if (hiddenDangerTransferHandlerId == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"移交用户id不能为空");
|
}
|
ResultVO<UserInfoRPCRespDTO> userInfoByUid = accountUserService.getUserInfoByUid(hiddenDangerTransferHandlerId);
|
UserInfoRPCRespDTO userInfoRPCRespDTO = (UserInfoRPCRespDTO) userInfoByUid.getData();
|
if (userInfoRPCRespDTO == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"移交用户不存在");
|
}else {
|
order.setHiddenDangerTransferHandlerId(hiddenDangerTransferHandlerId);
|
order.setHiddenDangerTransferHandlerName(userInfoRPCRespDTO.getRealName());
|
order.setHiddenDangerTransferHandlerPhone(userInfoRPCRespDTO.getPhone());
|
}
|
}
|
Date date = new Date();
|
if (ExceptionHandleStatusEnum.MARK_FALSE_ALARM.getStatus().equals(handlerStatus)){
|
order.setAccepterStatus(ExceptionAccepterStatusEnum.MARK_FALSE_ALARM.getStatus());
|
order.setHiddenDangerAccepterId(currentUser.getUid());
|
order.setHiddenDangerAccepterName(currentUser.getRealName());
|
order.setHiddenDangerAccepterPhone(currentUser.getPhone());
|
order.setGmtHiddenDangerAccept(date);
|
}
|
order.setHandlerStatusSubmiter(currentUser.getRealName());
|
order.setGmtHandlerStatusSubmit(date);
|
order.setGmtModitify(date);
|
order.setLastEditUserName(currentUser.getRealName());
|
LambdaQueryWrapper<AbnormalWorkOrder> wrapper = new LambdaQueryWrapper<>();
|
wrapper.eq(AbnormalWorkOrder::getId,reqDTO.getId()).
|
eq(AbnormalWorkOrder::getHandlerStatus,ExceptionHandleStatusEnum.TO_BE_RESPONDED.getStatus());
|
boolean update = abnormalWorkOrderService.update(order, wrapper);
|
if (!update){
|
throw new AusinessException(E.UPDATE_FAIL,"数据修改失败");
|
}
|
}
|
|
/**
|
* @description 处理后填报
|
*/
|
@Override
|
@Transactional
|
public void updateExcepOrderHandledAfterStatusById(ContextCacheUser currentUser, ExcepOrderHandledAfterStatusByIdReqDTO reqDTO) {
|
if (reqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
if (reqDTO.getId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"工单id不能为空");
|
}
|
AbnormalWorkOrder workOrder = abnormalWorkOrderService.getById(reqDTO.getId());
|
if (workOrder == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"工单不存在");
|
}
|
if (!currentUser.getUid().equals(workOrder.getHiddenDangerHandlerId())){
|
throw new AusinessException(E.DATA_OPERATION_NO_PERMISSION,"提交人必须为异常处理人");
|
}
|
if (StringUtils.isBlank(reqDTO.getHandlerDesc())){
|
throw new AusinessException(E.DATA_PARAM_NULL,"处置反馈不能为空");
|
}
|
Date date = new Date();
|
AbnormalWorkOrder order = new AbnormalWorkOrder();
|
order.setId(reqDTO.getId());
|
order.setHandlerDesc(reqDTO.getHandlerDesc());
|
order.setGmtModitify(date);
|
order.setLastEditUserName(currentUser.getRealName());
|
order.setHandlerCompletedTime(date);
|
order.setHandlerStatus(ExceptionHandleStatusEnum.TO_BE_ACCEPTED.getStatus());
|
LambdaQueryWrapper<AbnormalWorkOrder> wrapper = new LambdaQueryWrapper<>();
|
wrapper.eq(AbnormalWorkOrder::getId,reqDTO.getId())
|
.eq(AbnormalWorkOrder::getHandlerStatus,ExceptionHandleStatusEnum.SELF_INSPECTION_PROCESSING.getStatus())
|
.or()
|
.eq(AbnormalWorkOrder::getHandlerStatus,ExceptionHandleStatusEnum.SUBMITTED.getStatus());
|
abnormalWorkOrderService.update(order,wrapper);
|
Integer taskAndQuotaId = workOrder.getTaskAndQuotaId();
|
List<String> images = reqDTO.getImages();
|
LambdaQueryWrapper<AbnormalWorkOrderImages> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
lambdaQueryWrapper.eq(AbnormalWorkOrderImages::getAbnormalWorkOrderId,reqDTO.getId())
|
.eq(AbnormalWorkOrderImages::getImageTimeStatus,ImageTimeStatusEnum.AFTER_PROCESSING.getStatus());
|
abnormalWorkOrderImagesService.remove(lambdaQueryWrapper);
|
//List<AbnormalWorkOrderImages> oldImages = abnormalWorkOrderImagesService.list(lambdaQueryWrapper);
|
//if (CollectionUtils.isNotEmpty(oldImages)) {
|
// for (AbnormalWorkOrderImages image : oldImages) {
|
// LambdaQueryWrapper<AbnormalWorkOrderImages> queryWrapper = new LambdaQueryWrapper<>();
|
// queryWrapper.eq(AbnormalWorkOrderImages::getAbnormalImage, image);
|
// abnormalWorkOrderImagesService.remove(queryWrapper);
|
// }
|
//}
|
String pattern = "\\w{4}[-]\\w{2}[-]\\w{2}[_]\\w{8}[.]\\w{3}";
|
if (CollectionUtils.isNotEmpty(images)){
|
//如果反馈时间为空的话 说明没有提交过
|
if (workOrder.getHandlerCompletedTime() == null){
|
List<AbnormalWorkOrderImages> list = images.stream().map((image) -> {
|
AbnormalWorkOrderImages orderImages = new AbnormalWorkOrderImages();
|
orderImages.setAbnormalWorkOrderId(reqDTO.getId());
|
orderImages.setTaskAndQuotaId(taskAndQuotaId);
|
orderImages.setAbnormalImage(image);
|
orderImages.setImageTimeStatus(ImageTimeStatusEnum.AFTER_PROCESSING.getStatus());
|
orderImages.setCreateUserId(currentUser.getUid());
|
orderImages.setCreateUserName(currentUser.getRealName());
|
orderImages.setGmtCreate(date);
|
return orderImages;
|
}).collect(Collectors.toList());
|
abnormalWorkOrderImagesService.saveBatch(list);
|
}else {
|
List<String> newImages = new ArrayList<>();
|
for (String image : images) {
|
if (image.startsWith("http")){
|
Pattern r = Pattern.compile(pattern);
|
Matcher m = r.matcher(image);
|
m.find();
|
newImages.add(m.group());
|
}else {
|
newImages.add(image);
|
}
|
}
|
List<AbnormalWorkOrderImages> list = newImages.stream().map((image) -> {
|
AbnormalWorkOrderImages orderImages = new AbnormalWorkOrderImages();
|
orderImages.setAbnormalWorkOrderId(reqDTO.getId());
|
orderImages.setTaskAndQuotaId(taskAndQuotaId);
|
orderImages.setAbnormalImage(image);
|
orderImages.setImageTimeStatus(ImageTimeStatusEnum.AFTER_PROCESSING.getStatus());
|
orderImages.setCreateUserId(currentUser.getUid());
|
orderImages.setCreateUserName(currentUser.getRealName());
|
orderImages.setGmtCreate(date);
|
return orderImages;
|
}).collect(Collectors.toList());
|
abnormalWorkOrderImagesService.saveBatch(list);
|
}
|
}
|
}
|
|
/**
|
* @description 根据工单id查询现场照片
|
*/
|
@Override
|
public ListImagesByIdRespDTO listImagesById(Long id) {
|
if (id == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
LambdaQueryWrapper<AbnormalWorkOrderImages> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(AbnormalWorkOrderImages::getAbnormalWorkOrderId,id);
|
List<AbnormalWorkOrderImages> images = abnormalWorkOrderImagesService.list(queryWrapper);
|
ListImagesByIdRespDTO dto = new ListImagesByIdRespDTO();
|
if (CollectionUtils.isNotEmpty(images)){
|
List<String> beforeImages = new ArrayList<>();
|
List<String> afterImages = new ArrayList<>();
|
dto.setId(id);
|
for (AbnormalWorkOrderImages image : images) {
|
String file = minioAccessService.viewExceFile(image.getAbnormalImage());
|
if (ImageTimeStatusEnum.BEFORE_PROCESSING.getStatus().equals(image.getImageTimeStatus())){
|
beforeImages.add(file);
|
}
|
if (ImageTimeStatusEnum.AFTER_PROCESSING.getStatus().equals(image.getImageTimeStatus())){
|
afterImages.add(file);
|
}
|
}
|
dto.setBeforeImages(beforeImages);
|
dto.setAfterImages(afterImages);
|
}
|
return dto;
|
}
|
|
/**
|
* @description 将状态改为标记误报
|
*/
|
@Override
|
public void updateFalseAlarmStatusById(ContextCacheUser currentUser, FalseAlarmStatusByIdReqDTO reqDTO) {
|
if (reqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
if (reqDTO.getId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"工单id不能为空");
|
}
|
AbnormalWorkOrder workOrder = abnormalWorkOrderService.getById(reqDTO.getId());
|
if (workOrder == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"工单不存在");
|
}
|
Date date = new Date();
|
AbnormalWorkOrder order = new AbnormalWorkOrder();
|
order.setHandlerStatus(ExceptionHandleStatusEnum.MARK_FALSE_ALARM.getStatus());
|
order.setHandlerStatusSubmiter(currentUser.getRealName());
|
order.setGmtHandlerStatusSubmit(date);
|
order.setGmtHiddenDangerAccept(date);
|
order.setAccepterStatus(ExceptionAccepterStatusEnum.MARK_FALSE_ALARM.getStatus());
|
order.setLastEditUserName(currentUser.getRealName());
|
order.setGmtModitify(date);
|
LambdaQueryWrapper<AbnormalWorkOrder> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(AbnormalWorkOrder::getId,reqDTO.getId())
|
.eq(AbnormalWorkOrder::getHandlerStatus,ExceptionHandleStatusEnum.TO_BE_RESPONDED.getStatus());
|
boolean update = abnormalWorkOrderService.update(order, queryWrapper);
|
if (!update){
|
throw new AusinessException(E.UPDATE_FAIL,"状态更改失败");
|
}
|
}
|
|
/**
|
* @description 将状态改为已验收
|
*/
|
@Override
|
public void updateAcceptedStatusById(ContextCacheUser currentUser, UpdateAcceptedStatusByIdReqDTO reqDTO) {
|
if (reqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
if (reqDTO.getId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"工单id不能为空");
|
}
|
AbnormalWorkOrder workOrder = abnormalWorkOrderService.getById(reqDTO.getId());
|
if (workOrder == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"工单不存在");
|
}
|
Date date = new Date();
|
AbnormalWorkOrder order = new AbnormalWorkOrder();
|
order.setHandlerStatus(ExceptionHandleStatusEnum.COMPLETED.getStatus());
|
order.setHandlerStatusSubmiter(currentUser.getRealName());
|
order.setGmtHandlerStatusSubmit(date);
|
order.setHiddenDangerAccepterId(currentUser.getUid());
|
order.setHiddenDangerAccepterName(currentUser.getRealName());
|
order.setHiddenDangerAccepterPhone(currentUser.getPhone());
|
order.setGmtHiddenDangerAccept(date);
|
order.setAccepterStatus(ExceptionAccepterStatusEnum.YES_ACCEPTED.getStatus());
|
order.setLastEditUserName(currentUser.getRealName());
|
order.setGmtModitify(date);
|
LambdaQueryWrapper<AbnormalWorkOrder> queryWrapper = new LambdaQueryWrapper<>();
|
queryWrapper.eq(AbnormalWorkOrder::getId,reqDTO.getId())
|
.eq(AbnormalWorkOrder::getHandlerStatus,ExceptionHandleStatusEnum.TO_BE_ACCEPTED.getStatus());
|
boolean update = abnormalWorkOrderService.update(order, queryWrapper);
|
if (!update){
|
throw new AusinessException(E.UPDATE_FAIL,"状态更改失败");
|
}
|
}
|
|
|
/**
|
* @description 查询巡检异常清单
|
*/
|
@Override
|
public IPage listExcepOrderByPage(ContextCacheUser currentUser, Page pageInfo) {
|
List<Long> depIds = null;
|
if (UserTypeEnum.STAFF.getCode() == currentUser.getType()){
|
ResultVO<List<Long>> resultVO = accountDepartmentService.listDepAndSubDepIds(currentUser.getDepId());
|
depIds = (List<Long>) resultVO.getData();
|
}
|
IPage orderIPage = abnormalWorkOrderService.listExcepOrderByPage(pageInfo,depIds);
|
List<AbnormalWorkOrder> records = orderIPage.getRecords();
|
if (CollectionUtils.isEmpty(records)){
|
return orderIPage;
|
}
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
List<ListExcepOrderByPageRespDTO> dtos = records.stream().map((record) -> {
|
ListExcepOrderByPageRespDTO dto = new ListExcepOrderByPageRespDTO();
|
BeanUtils.copyProperties(record, dto);
|
String time = dateFormat.format(record.getWorkOrderTime());
|
dto.setWorkOrderNum(time + new DecimalFormat("0000").format(record.getWorkOrderSort()));
|
return dto;
|
}).collect(Collectors.toList());
|
orderIPage.setRecords(dtos);
|
return orderIPage;
|
}
|
|
|
/**
|
* @description 根据id获取反馈填报信息内容
|
*/
|
@Override
|
public ExcepOrderHandledDataByIdRespDTO getExcepOrderHandledDataById(ExcepOrderHandledDataByIdReqDTO reqDTO) {
|
if (reqDTO == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"关键参数不能为空");
|
}
|
if (reqDTO.getId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"工单id不能为空");
|
}
|
AbnormalWorkOrder workOrder = abnormalWorkOrderService.getById(reqDTO.getId());
|
if (workOrder == null){
|
throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"工单不存在");
|
}
|
ExcepOrderHandledDataByIdRespDTO dto = new ExcepOrderHandledDataByIdRespDTO();
|
BeanUtils.copyProperties(workOrder,dto);
|
LambdaQueryWrapper<AbnormalWorkOrderImages> wrapper = new LambdaQueryWrapper<>();
|
wrapper.eq(AbnormalWorkOrderImages::getAbnormalWorkOrderId,reqDTO.getId())
|
.eq(AbnormalWorkOrderImages::getImageTimeStatus,ImageTimeStatusEnum.AFTER_PROCESSING.getStatus());
|
List<AbnormalWorkOrderImages> images = abnormalWorkOrderImagesService.list(wrapper);
|
if (CollectionUtils.isEmpty(images)){
|
return dto;
|
}
|
List<String> collect = images.stream().map((image) -> {
|
String abnormalImage = image.getAbnormalImage();
|
String file = minioAccessService.viewExceFile(abnormalImage);
|
return file;
|
}).collect(Collectors.toList());
|
dto.setImages(collect);
|
return dto;
|
}
|
|
/**
|
* @description 根据部门,班组和状态作为条件查询任务以及任务相关的巡检点
|
*/
|
@Override
|
public IPage listTaskDataByCondition(ContextCacheUser currentUser, Page pageInfo, ListTaskDataByConditionReqDTO reqDTO) {
|
//获取用户信息
|
ResultVO<UserRPCRespDTO> rpcResult = accountAuthService.getUserById(currentUser.getUid());
|
UserRPCRespDTO userInfo = UserInfoUtil.judgeUserInfo(rpcResult);
|
|
|
MobileTaskDataDBQuery taskDBQuery = new MobileTaskDataDBQuery();
|
taskDBQuery.setExecClassgroupId(reqDTO.getExecClassgroupId());
|
taskDBQuery.setTaskStatus(reqDTO.getTaskStatus());
|
taskDBQuery.setExcDepId(reqDTO.getExcDepId());
|
IPage taskIPage = safeCheckTaskService.listTaskDataByCondition(pageInfo, taskDBQuery);
|
|
List<SafeCheckTaskDataMobileDO> records = taskIPage.getRecords();
|
if (records == null || records.size() == 0 ){
|
return null;
|
}
|
|
List<Long> execClassgroupids = records.stream().map(e -> e.getExecClassgroupId()).collect(Collectors.toList());
|
ResultVO<Map<Long, GroupRPCRespDTO>> mapResultVO = accountGroupService.listGroupMapByGroupIds(execClassgroupids);
|
Map<Long, GroupRPCRespDTO> groupInfos = (Map<Long, GroupRPCRespDTO>) mapResultVO.getData();
|
List<SafeCheckTaskDataByConditionMobileRespDTO> taskMobilePages = records.stream().map((record)->{
|
SafeCheckTaskDataByConditionMobileRespDTO pageRespDTO = new SafeCheckTaskDataByConditionMobileRespDTO();
|
BeanUtils.copyProperties(record,pageRespDTO);
|
List<SafeCheckTaskAndQuota> points = record.getPoints();
|
if (points != null && points.size() > 0){
|
List<SafeCheckTaskDataAndQuotaRespDTO> mobileRespDTOS = points.stream().map((point)->{
|
SafeCheckTaskDataAndQuotaRespDTO mobileRespDTO = new SafeCheckTaskDataAndQuotaRespDTO();
|
BeanUtils.copyProperties(point,mobileRespDTO);
|
return mobileRespDTO;
|
}).collect(Collectors.toList());
|
pageRespDTO.setPoints(mobileRespDTOS);
|
}
|
if (groupInfos != null){
|
GroupRPCRespDTO dto = groupInfos.get(record.getExecClassgroupId());
|
if (dto != null){
|
pageRespDTO.setExecClassgroup(dto.getGroupName());
|
}
|
}
|
return pageRespDTO;
|
}).collect(Collectors.toList());
|
taskIPage.setRecords(taskMobilePages);
|
return taskIPage;
|
}
|
|
|
// /**
|
// * @description 判断巡检结果是否正常
|
// */
|
// private SafeCheckTaskAndQuota taskAndQuotaResultIsAbnormal(SafeCheckTaskAndQuota safeCheckTaskAndQuota){
|
// int taskAndQuotaId = safeCheckTaskAndQuota.getId();
|
// SafeCheckTaskAndQuota referenceTaskAndQuota = safeCheckTaskAndQuotaService.getTaskAndQuotaById(taskAndQuotaId);
|
// if (referenceTaskAndQuota == null){
|
// throw new AusinessException(E.DATA_DATABASE_NO_EXISTENT,"数据库无此巡检任务生成的巡检点信息");
|
// }
|
//
|
// Byte dataReportType = safeCheckTaskAndQuota.getDataReportType();
|
// if (dataReportType.intValue() == 1){
|
// if (safeCheckTaskAndQuota.getFirstReferenceResult() != referenceTaskAndQuota.getFirstReferenceValue()){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// }else {
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// }
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
//
|
// if (dataReportType.intValue() == 2){
|
// Byte secondReferenceSign = referenceTaskAndQuota.getSecondReferenceSign();
|
// BigDecimal secondReferenceValue = referenceTaskAndQuota.getSecondReferenceValue();
|
// Byte thirdReferenceSign = referenceTaskAndQuota.getThirdReferenceSign();
|
// BigDecimal thirdReferenceValue = referenceTaskAndQuota.getThirdReferenceValue();
|
// BigDecimal result = safeCheckTaskAndQuota.getSecondReferenceResult();
|
//
|
// //如果第二参考值为为空,那肯定只有第三参考值了
|
// if (secondReferenceValue == null){
|
// //第三参考值的话需要 实际值< 或者 <= 参考值
|
// if (thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
// int flag = result.compareTo(thirdReferenceValue);
|
// if (flag < 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// }else {
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// }
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
//
|
// int flag = result.compareTo(thirdReferenceValue);
|
// if (flag <= 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// }else {
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// }
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// //如果第三参考值为为空,第二参考值不为空
|
// if (thirdReferenceValue == null){
|
// //第二参考值的话需要 实际值> 或者 >= 参考值 这里是>
|
// if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue()){
|
// int flag = result.compareTo(secondReferenceValue);
|
// if (flag > 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// }else {
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// }
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// int flag = result.compareTo(secondReferenceValue);
|
// if (flag >= 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// }else {
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// }
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// //第二参考值和第三参考值
|
// if (secondReferenceValue == null && thirdReferenceValue == null){
|
// //参考值 < 数据 < 参考值
|
// if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue() &&
|
// thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
// if (result.compareTo(secondReferenceValue) > 0 && result.compareTo(thirdReferenceValue) < 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
//
|
// }
|
// //参考值 < 数据 <= 参考值
|
// if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue() &&
|
// thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LE.getCode().intValue()){
|
// if (result.compareTo(secondReferenceValue) > 0 && result.compareTo(thirdReferenceValue) <= 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
//
|
// }
|
// //参考值 <= 数据 < 参考值
|
// if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GE.getCode().intValue() &&
|
// thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
// if (result.compareTo(secondReferenceValue) >= 0 && result.compareTo(thirdReferenceValue) < 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
//
|
// }
|
// //参考值 <= 数据 <= 参考值
|
// if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GE.getCode().intValue() &&
|
// thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LE.getCode().intValue()){
|
// if (result.compareTo(secondReferenceValue) >= 0 && result.compareTo(thirdReferenceValue) <= 0 ){
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
// }
|
// safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
// safeCheckTaskAndQuota.setReportTime(new Date());
|
// return safeCheckTaskAndQuota;
|
//
|
// }
|
// }
|
// }
|
// return null;
|
// }
|
|
/**
|
* @description 判断选择结果是否正常
|
*/
|
private SafeCheckTaskAndQuota optResultIsAbnormal(SafeCheckTaskAndQuota safeCheckTaskAndQuota,SafeCheckTaskAndQuota referenceTaskAndQuota){
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
if (referenceTaskAndQuota.getFirstReferenceValue().equals(TaskResultEnum.TASK_RESULT_BEI.getCode())){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_BEI.getCode());
|
return safeCheckTaskAndQuota;
|
}
|
if (safeCheckTaskAndQuota.getFirstReferenceResult() != referenceTaskAndQuota.getFirstReferenceValue()){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}else {
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}
|
return safeCheckTaskAndQuota;
|
}
|
|
/**
|
* @description 判断填空结果是否正常
|
*/
|
private SafeCheckTaskAndQuota fillBlankResultIsAbnormal(SafeCheckTaskAndQuota safeCheckTaskAndQuota,SafeCheckTaskAndQuota referenceTaskAndQuota){
|
Byte secondReferenceSign = referenceTaskAndQuota.getSecondReferenceSign();
|
BigDecimal secondReferenceValue = referenceTaskAndQuota.getSecondReferenceValue();
|
Byte thirdReferenceSign = referenceTaskAndQuota.getThirdReferenceSign();
|
BigDecimal thirdReferenceValue = referenceTaskAndQuota.getThirdReferenceValue();
|
BigDecimal result = safeCheckTaskAndQuota.getSecondReferenceResult();
|
|
//如果第二参考值为为空,那肯定只有第三参考值了
|
if (secondReferenceValue == null){
|
//第三参考值的话需要 实际值< 或者 <= 参考值
|
if (thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
int flag = result.compareTo(thirdReferenceValue);
|
if (flag < 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}else {
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
|
int flag = result.compareTo(thirdReferenceValue);
|
if (flag <= 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}else {
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
//如果第三参考值为为空,第二参考值不为空
|
if (thirdReferenceValue == null){
|
//第二参考值的话需要 实际值> 或者 >= 参考值 这里是>
|
if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue()){
|
int flag = result.compareTo(secondReferenceValue);
|
if (flag > 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}else {
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
int flag = result.compareTo(secondReferenceValue);
|
if (flag >= 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
}else {
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
}
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
//第二参考值和第三参考值
|
if (secondReferenceValue != null && thirdReferenceValue != null){
|
//参考值 < 数据 < 参考值
|
if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue() &&
|
thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
if (result.compareTo(secondReferenceValue) > 0 && result.compareTo(thirdReferenceValue) < 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
|
}
|
//参考值 < 数据 <= 参考值
|
if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GT.getCode().intValue() &&
|
thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LE.getCode().intValue()){
|
if (result.compareTo(secondReferenceValue) > 0 && result.compareTo(thirdReferenceValue) <= 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
|
}
|
//参考值 <= 数据 < 参考值
|
if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GE.getCode().intValue() &&
|
thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LT.getCode().intValue()){
|
if (result.compareTo(secondReferenceValue) >= 0 && result.compareTo(thirdReferenceValue) < 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
|
}
|
//参考值 <= 数据 <= 参考值
|
if (secondReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_GE.getCode().intValue() &&
|
thirdReferenceSign.intValue() == ReferenceValueTypeEnum.REFERENCE_VALUE_TYPE_LE.getCode().intValue()){
|
if (result.compareTo(secondReferenceValue) >= 0 && result.compareTo(thirdReferenceValue) <= 0 ){
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_NORMAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
safeCheckTaskAndQuota.setReportResult(TaskResultEnum.TASK_RESULT_UNUSUAL.getCode());
|
safeCheckTaskAndQuota.setReportTime(new Date());
|
return safeCheckTaskAndQuota;
|
}
|
}
|
return null;
|
}
|
|
/**
|
* @description 巡检点结果数据校验
|
*/
|
private void taskAndQuotaResultParamCheck(SafeCheckTaskAndQuota safeCheckTaskAndQuota){
|
if (safeCheckTaskAndQuota == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"巡检点巡检结果不能为空");
|
}
|
if (safeCheckTaskAndQuota.getId() == 0){
|
throw new AusinessException(E.DATA_PARAM_NULL,"任务关联的巡检点主键id不能为空");
|
}
|
if (safeCheckTaskAndQuota.getTaskId() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"任务id不能为空");
|
}
|
if (safeCheckTaskAndQuota.getDataReportType() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"数据填报类型不能为空");
|
}
|
int dataReportType = safeCheckTaskAndQuota.getDataReportType().intValue();
|
switch (dataReportType){
|
case 1:
|
if (safeCheckTaskAndQuota.getFirstReferenceResult() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"数据填报类型【选择结果】不能为空");
|
}
|
break;
|
case 2:
|
if (safeCheckTaskAndQuota.getSecondReferenceResult() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"数据填报类型【填空结果】不能为空");
|
}
|
break;
|
case 3:
|
if (safeCheckTaskAndQuota.getSecondReferenceResult() == null || safeCheckTaskAndQuota.getFirstReferenceResult() == null){
|
throw new AusinessException(E.DATA_PARAM_NULL,"数据填报类型【选择或填空结果】不能为空");
|
}
|
break;
|
}
|
}
|
}
|