|
@@ -3,13 +3,22 @@ package com.ktg.iscs.service.impl;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ktg.common.utils.bean.BeanUtils;
|
|
|
|
|
+import com.ktg.iscs.domain.IsJobTicketPoints;
|
|
|
import com.ktg.iscs.domain.IsJobTicketStep;
|
|
import com.ktg.iscs.domain.IsJobTicketStep;
|
|
|
|
|
+import com.ktg.iscs.domain.IsJobTicketUser;
|
|
|
import com.ktg.iscs.domain.dto.step.IsJobTicketStepDTO;
|
|
import com.ktg.iscs.domain.dto.step.IsJobTicketStepDTO;
|
|
|
|
|
+import com.ktg.iscs.domain.vo.step.IsJobTicketStepVO;
|
|
|
import com.ktg.iscs.mapper.IsJobTicketStepMapper;
|
|
import com.ktg.iscs.mapper.IsJobTicketStepMapper;
|
|
|
|
|
+import com.ktg.iscs.service.IIsJobTicketPointsService;
|
|
|
import com.ktg.iscs.service.IIsJobTicketStepService;
|
|
import com.ktg.iscs.service.IIsJobTicketStepService;
|
|
|
|
|
+import com.ktg.iscs.service.IIsJobTicketUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 作业票执行步骤Service业务层处理
|
|
* 作业票执行步骤Service业务层处理
|
|
|
*
|
|
*
|
|
@@ -21,14 +30,59 @@ public class IsJobTicketStepServiceImpl extends ServiceImpl<IsJobTicketStepMappe
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IsJobTicketStepMapper isJobTicketStepMapper;
|
|
private IsJobTicketStepMapper isJobTicketStepMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsJobTicketPointsService iIsJobTicketPointsService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsJobTicketUserService iIsJobTicketUserService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateJobStep(IsJobTicketStepDTO dto) {
|
|
public Boolean updateJobStep(IsJobTicketStepDTO dto) {
|
|
|
Assert.notNull(dto.getStepId(), "步骤Id不可为空!");
|
|
Assert.notNull(dto.getStepId(), "步骤Id不可为空!");
|
|
|
Assert.notNull(dto.getStepStatus(), "状态不可为空!");
|
|
Assert.notNull(dto.getStepStatus(), "状态不可为空!");
|
|
|
- update(Wrappers.<IsJobTicketStep>lambdaUpdate()
|
|
|
|
|
- .eq(IsJobTicketStep::getStepId, dto.getStepId())
|
|
|
|
|
- .set(IsJobTicketStep::getStepStatus, dto.getStepStatus()));
|
|
|
|
|
|
|
+ update(Wrappers.<IsJobTicketStep>lambdaUpdate().eq(IsJobTicketStep::getStepId, dto.getStepId()).set(IsJobTicketStep::getStepStatus, dto.getStepStatus()));
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<IsJobTicketStepVO> selectStepsByTicketId(Long ticketId) {
|
|
|
|
|
+ Assert.notNull(ticketId, "作业票id不能为空!");
|
|
|
|
|
+ List<IsJobTicketStep> stepList = list(Wrappers.<IsJobTicketStep>lambdaQuery().eq(IsJobTicketStep::getTicketId, ticketId));
|
|
|
|
|
+ List<IsJobTicketStepVO> stepVOList = BeanUtils.toBean(stepList, IsJobTicketStepVO.class);
|
|
|
|
|
+ // 1.获取需要分析的数据
|
|
|
|
|
+ List<IsJobTicketPoints> pointList = iIsJobTicketPointsService.list(Wrappers.<IsJobTicketPoints>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketPoints::getTicketId, ticketId));
|
|
|
|
|
+ List<IsJobTicketUser> userList = iIsJobTicketUserService.list(Wrappers.<IsJobTicketUser>lambdaQuery()
|
|
|
|
|
+ .eq(IsJobTicketUser::getTicketId, ticketId));
|
|
|
|
|
+ // 1.1读取第三步的计数
|
|
|
|
|
+ int oneLockNum = pointList.size();
|
|
|
|
|
+ int oneUserNum = userList.size();
|
|
|
|
|
+ stepVOList.get(2).setLockNum(oneLockNum).setUserNum(oneUserNum);
|
|
|
|
|
+ // 1.2读取第五步的计数
|
|
|
|
|
+ int twoLockNum = (int) pointList.stream()
|
|
|
|
|
+ .filter(o -> o.getPointStatus() != null && Integer.parseInt(o.getPointStatus()) >= 1).count();
|
|
|
|
|
+ int twoUserNum = (int) userList.stream()
|
|
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus() >= 4).count();
|
|
|
|
|
+ stepVOList.get(4).setLockNum(twoLockNum).setUserNum(twoUserNum);
|
|
|
|
|
+ // 1.3读取第八步的计数
|
|
|
|
|
+ int threeLockNum = (int) pointList.stream()
|
|
|
|
|
+ .filter(o -> o.getPointStatus() != null && Integer.parseInt(o.getPointStatus()) != 2).count();
|
|
|
|
|
+ int threeUserNum = (int) userList.stream()
|
|
|
|
|
+ .filter(o -> o.getJobStatus() != null && o.getJobStatus() != 5).count();
|
|
|
|
|
+ stepVOList.get(7).setLockNum(threeLockNum).setUserNum(threeUserNum).setConflictJobNum(0);
|
|
|
|
|
+ // 2读取第八步的作业票干扰,判断该作业票点位被哪些额外作业票锁定了
|
|
|
|
|
+ // 2.1获取被其他作业票锁定的隔离点
|
|
|
|
|
+ if (!pointList.isEmpty()) {
|
|
|
|
|
+ List<Long> pointIds = pointList.stream().map(IsJobTicketPoints::getPointId).collect(Collectors.toList());
|
|
|
|
|
+ List<IsJobTicketPoints> conflictPoints = iIsJobTicketPointsService.list(Wrappers.<IsJobTicketPoints>lambdaQuery()
|
|
|
|
|
+ .in(IsJobTicketPoints::getPointId, pointIds)
|
|
|
|
|
+ .ne(IsJobTicketPoints::getTicketId, ticketId)
|
|
|
|
|
+ .eq(IsJobTicketPoints::getPointStatus, 1));
|
|
|
|
|
+ if (!conflictPoints.isEmpty()) {
|
|
|
|
|
+ int conflictJobNum = (int) conflictPoints.stream().map(IsJobTicketPoints::getTicketId).distinct().count();
|
|
|
|
|
+ stepVOList.get(7).setConflictJobNum(conflictJobNum);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return stepVOList;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|