|
|
@@ -14,9 +14,10 @@ import com.ktg.iscs.domain.dto.ticket.PageTicketDTO;
|
|
|
import com.ktg.iscs.domain.enums.JobStatusEnum;
|
|
|
import com.ktg.iscs.domain.enums.TicketStatusEnum;
|
|
|
import com.ktg.iscs.domain.vo.points.PointDetailVO;
|
|
|
-import com.ktg.iscs.domain.vo.ticket.JobTicketDetailVO;
|
|
|
-import com.ktg.iscs.domain.vo.ticket.JobTicketUpdateProgressReqVO;
|
|
|
-import com.ktg.iscs.domain.vo.ticket.PageTicketVO;
|
|
|
+import com.ktg.iscs.domain.vo.ticket.*;
|
|
|
+import com.ktg.iscs.domain.vo.ticketKey.IsJobTicketKeyVO;
|
|
|
+import com.ktg.iscs.domain.vo.ticketLockset.IsJobTicketLocksetVO;
|
|
|
+import com.ktg.iscs.domain.vo.ticketPoints.IsJobTicketPointsVO;
|
|
|
import com.ktg.iscs.mapper.IsJobTicketMapper;
|
|
|
import com.ktg.iscs.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -25,7 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ktg.iscs.domain.constant.ErrorCodeConstants.*;
|
|
|
@@ -58,6 +61,8 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
|
|
|
private IIsJobTicketLockService iIsJobTicketLockService;
|
|
|
@Autowired
|
|
|
private IIsJobTicketLocksetService iIsJobTicketLocksetService;
|
|
|
+ @Autowired
|
|
|
+ private IIsWorkareaService iIsWorkareaService;
|
|
|
|
|
|
/**
|
|
|
* 查询作业票
|
|
|
@@ -71,6 +76,13 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
|
|
|
// 1.查询基础数据
|
|
|
IsJobTicket jobTicket = isJobTicketMapper.selectIsJobTicketByTicketId(ticketId);
|
|
|
JobTicketDetailVO jobTicketDetailVO = BeanUtils.toBean(jobTicket, JobTicketDetailVO.class);
|
|
|
+ // 1.1 查询工作区域数据
|
|
|
+ if (jobTicket != null && jobTicket.getWorkareaId() != null) {
|
|
|
+ IsWorkarea workarea = iIsWorkareaService.getById(jobTicket.getWorkareaId());
|
|
|
+ if (workarea != null) {
|
|
|
+ jobTicketDetailVO.setWorkareaName(workarea.getWorkareaName());
|
|
|
+ }
|
|
|
+ }
|
|
|
// 2.查询作业票和隔离点的关联关系
|
|
|
List<IsJobTicketPoints> isJobTicketPoints = iIsJobTicketPointsService.list(Wrappers.<IsJobTicketPoints>lambdaQuery()
|
|
|
.eq(IsJobTicketPoints::getTicketId, ticketId));
|
|
|
@@ -255,7 +267,7 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
|
|
|
jobTicketPoints.setWorkareaId(dto.getWorkareaId());
|
|
|
jobTicketPoints.setPointId(isJobTicketPoints.getPointId());
|
|
|
jobTicketPoints.setPrePointId(isJobTicketPoints.getPrePointId());
|
|
|
- iIsJobTicketPointsService.save(isJobTicketPoints);
|
|
|
+ iIsJobTicketPointsService.save(jobTicketPoints);
|
|
|
}
|
|
|
}
|
|
|
// 4.修改人员信息,先删后增
|
|
|
@@ -459,4 +471,96 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
|
|
|
}
|
|
|
return isCoLockerDone;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<MonitorTicketPageVO> getMonitorJobTicketPage(Page<IsJobTicket> page, PageTicketDTO dto) {
|
|
|
+ Page<MonitorTicketPageVO> monitorJobTicketPage = isJobTicketMapper.getMonitorJobTicketPage(page, dto);
|
|
|
+ for (MonitorTicketPageVO record : monitorJobTicketPage.getRecords()) {
|
|
|
+ // 初始值
|
|
|
+ record.setLockNum(0);
|
|
|
+ record.setLockedNum(0);
|
|
|
+ record.setRemoveLockNum(0);
|
|
|
+ record.setColockNum(0);
|
|
|
+ record.setColockedNum(0);
|
|
|
+ record.setRemoveColockNum(0);
|
|
|
+ // 1.获取关联的上锁人信息
|
|
|
+ List<IsJobTicketUser> jtlockerList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery()
|
|
|
+ .eq(IsJobTicketUser::getTicketId, record.getTicketId())
|
|
|
+ .eq(IsJobTicketUser::getUserRole, JTLOCKER.key));
|
|
|
+ if (!jtlockerList.isEmpty()) {
|
|
|
+ // 上锁总数
|
|
|
+ record.setLockNum(jtlockerList.size());
|
|
|
+ // 已上锁数
|
|
|
+ int lockedNum = (int) jtlockerList.stream()
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus().equals(JobStatusEnum.READY_TO_UNLOCK.status))
|
|
|
+ .count();
|
|
|
+ record.setLockedNum(lockedNum);
|
|
|
+ // 已完成(解锁)上锁数
|
|
|
+ int removeLockNum = (int) jtlockerList.stream()
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus().equals(JobStatusEnum.UNLOCKED.status))
|
|
|
+ .count();
|
|
|
+ record.setRemoveLockNum(removeLockNum);
|
|
|
+ }
|
|
|
+ //2.获取关联的共锁人信息
|
|
|
+ List<IsJobTicketUser> jtcolockerList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery()
|
|
|
+ .eq(IsJobTicketUser::getTicketId, record.getTicketId())
|
|
|
+ .eq(IsJobTicketUser::getUserRole, JTCOLOCKER.key));
|
|
|
+ if (!jtcolockerList.isEmpty()) {
|
|
|
+ // 上锁总数
|
|
|
+ record.setColockNum(jtcolockerList.size());
|
|
|
+ // 已上锁数
|
|
|
+ int colockedNum = (int) jtcolockerList.stream()
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus().equals(JobStatusEnum.READY_TO_UNLOCK.status))
|
|
|
+ .count();
|
|
|
+ record.setColockedNum(colockedNum);
|
|
|
+ // 已完成(解锁)上锁数
|
|
|
+ int removeColockNum = (int) jtcolockerList.stream()
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus().equals(JobStatusEnum.UNLOCKED.status))
|
|
|
+ .count();
|
|
|
+ record.setRemoveColockNum(removeColockNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return monitorJobTicketPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MonitorJobTicketDetailVO selectMonitorJobTicketDetail(Long ticketId) {
|
|
|
+ Assert.notNull(ticketId, "作业票id不可为空!");
|
|
|
+ // 1.获取作业票
|
|
|
+ IsJobTicket isJobTicket = getById(ticketId);
|
|
|
+ Assert.notNull(isJobTicket, "作业票信息丢失了!");
|
|
|
+ // 2.获取关联钥匙
|
|
|
+ List<IsJobTicketKeyVO> listByTicketId = iIsJobTicketKeyService.getListByTicketId(ticketId);
|
|
|
+ // 3.获取上锁人信息
|
|
|
+ List<IsJobTicketUser> lockUserList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery()
|
|
|
+ .eq(IsJobTicketUser::getTicketId, ticketId)
|
|
|
+ .eq(IsJobTicketUser::getUserRole, JTLOCKER.key));
|
|
|
+ // 4.获取共锁人信息
|
|
|
+ List<IsJobTicketUser> colockUserList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery()
|
|
|
+ .eq(IsJobTicketUser::getTicketId, ticketId)
|
|
|
+ .eq(IsJobTicketUser::getUserRole, JTCOLOCKER.key));
|
|
|
+ // 5.关联隔离点信息
|
|
|
+ List<IsJobTicketPointsVO> jobTicketPointsVOList = iIsJobTicketPointsService.getListByTicketId(ticketId);
|
|
|
+ // 5.1获取隔离点关联的锁具数据
|
|
|
+ List<IsJobTicketLocksetVO> ticketLocksetVOList = iIsJobTicketLocksetService.getListByTicketId(ticketId);
|
|
|
+ for (IsJobTicketPointsVO vo : jobTicketPointsVOList) {
|
|
|
+ String collect = ticketLocksetVOList.stream()
|
|
|
+ .filter(o -> o.getPointId() != null && o.getPointId().equals(vo.getPointId()))
|
|
|
+ .map(IsJobTicketLocksetVO::getLocksetName)
|
|
|
+ .collect(Collectors.joining(", "));
|
|
|
+ vo.setLocksetName(collect);
|
|
|
+ }
|
|
|
+ MonitorJobTicketDetailVO vo = new MonitorJobTicketDetailVO();
|
|
|
+ vo.setJobTicket(isJobTicket);
|
|
|
+ if (!listByTicketId.isEmpty()) {
|
|
|
+ vo.setLockKeyName(listByTicketId.get(0).getKeyName());
|
|
|
+ vo.setColockKeyName(listByTicketId.get(1).getKeyName());
|
|
|
+ }
|
|
|
+ vo.setLockUserList(lockUserList);
|
|
|
+ vo.setColockUserList(colockUserList);
|
|
|
+ vo.setTicketPointsList(jobTicketPointsVOList);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|