|
@@ -11,20 +11,27 @@ import com.factory.base.entity.po.benteler.BentelerPlan;
|
|
|
import com.factory.base.entity.po.remote.UserInfo;
|
|
|
import com.factory.base.util.res.ResponseBeanBuilder;
|
|
|
import com.factory.user.mapper.UserInfoMapper;
|
|
|
+import com.factory.web.entity.fa.*;
|
|
|
import com.factory.web.entity.pm.*;
|
|
|
import com.factory.web.entity.pm.res.ApprovalUserRes;
|
|
|
import com.factory.web.mapper.BentelerPlanMapper;
|
|
|
+import com.factory.web.mapper.fa.FirstArticleApprovalTaskMapper;
|
|
|
+import com.factory.web.mapper.fa.FirstArticleCalendarMapper;
|
|
|
import com.factory.web.mapper.pm.ApprovalRuleMapper;
|
|
|
import com.factory.web.mapper.pm.OnsiteApprovalTaskMapper;
|
|
|
import com.factory.web.mapper.pm.OnsiteCalendarMapper;
|
|
|
import com.factory.web.mapper.pm.OnsiteTaskMapper;
|
|
|
+import com.factory.web.service.BentelerPlanService;
|
|
|
+import com.factory.web.service.fa.*;
|
|
|
import com.factory.web.service.pm.PreventMistakeService;
|
|
|
import com.factory.wx.entity.req.PlanApprovalTaskReq;
|
|
|
import com.factory.wx.entity.req.PlanInfoReq;
|
|
|
import com.factory.wx.entity.req.PlanPageReq;
|
|
|
import com.factory.wx.entity.res.PlanApprovalTaskRes;
|
|
|
import com.factory.wx.entity.res.PlanPassDetailRes;
|
|
|
-import com.factory.wx.mapper.PlanMapper;
|
|
|
+import com.factory.wx.entity.res.PlanPassRes;
|
|
|
+import com.factory.wx.mapper.PlanApprovalMapper;
|
|
|
+import com.factory.wx.mapper.PlanPassMapper;
|
|
|
import com.factory.wx.service.PlanPassService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -32,6 +39,8 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ObjectInputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -54,7 +63,7 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
*/
|
|
|
private static int APPROVAL_TYPE_PM = 3;
|
|
|
@Autowired
|
|
|
- private PlanMapper planMapper;
|
|
|
+ private PlanApprovalMapper planApprovalMapper;
|
|
|
@Autowired
|
|
|
private BentelerPlanMapper bentelerPlanMapper;
|
|
|
@Autowired
|
|
@@ -70,6 +79,26 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
private OnsiteApprovalTaskMapper onsiteApprovalTaskMapper;
|
|
|
@Autowired
|
|
|
private OnsiteTaskMapper onsiteTaskMapper;
|
|
|
+ @Autowired
|
|
|
+ private PlanPassMapper planPassMapper;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleCalendarMapper firstArticleCalendarMapper;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleApprovalTaskMapper firstArticleApprovalTaskMapper;
|
|
|
+ @Autowired
|
|
|
+ private BentelerPlanService planService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleCalendarService firstArticleCalendarService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleTitleBlobService firstArticleTitleBlobService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleWorkshopService firstArticleWorkshopService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleItemService firstArticleItemService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleItemResultService firstArticleItemResultService;
|
|
|
+ @Autowired
|
|
|
+ private FirstArticleService firstArticleService;
|
|
|
|
|
|
private static IPage<BentelerPlan> getBentelerPlanIPage(PlanPageReq planPageReq, List<OnsiteCalendar> onsiteCalendarList, BentelerPlanMapper bentelerPlanMapper) {
|
|
|
IPage<BentelerPlan> bentelerPlanIPage;
|
|
@@ -118,14 +147,78 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 计划放行详情
|
|
|
- *
|
|
|
+ * 计划放行详情-首件
|
|
|
* @param planInfoReq
|
|
|
* @return
|
|
|
*/
|
|
|
+
|
|
|
@Override
|
|
|
public PlanPassDetailRes getPassDetail(PlanInfoReq planInfoReq) {
|
|
|
BentelerPlan bentelerPlan = bentelerPlanMapper.selectById(planInfoReq.getPlanId());
|
|
|
+
|
|
|
+ List<FirstArticleCalendar> firstArticleCalendarList = firstArticleCalendarMapper.selectList(Wrappers.<FirstArticleCalendar>lambdaQuery()
|
|
|
+ .eq(FirstArticleCalendar::getBentelerPlanId, planInfoReq.getPlanId()));
|
|
|
+ List<String> usersName = new ArrayList<>();
|
|
|
+ firstArticleCalendarList.forEach(onsiteCalendar -> {
|
|
|
+ UserInfo userInfo = userInfoMapper.selectById(onsiteCalendar.getUserId());
|
|
|
+ usersName.add(StringUtils.join(userInfo.getName(), " ", onsiteCalendar.getShift(), "班"));
|
|
|
+ });
|
|
|
+
|
|
|
+ //工作站
|
|
|
+ List<FirstArticleWorkshop> firstArticleWorkshopList = firstArticleWorkshopService.list(Wrappers.<FirstArticleWorkshop>lambdaQuery()
|
|
|
+ .eq(FirstArticleWorkshop::getBentelerPlanId, planInfoReq.getPlanId()));
|
|
|
+ // 每个workshop下的item
|
|
|
+ firstArticleWorkshopList.forEach(workshop -> {
|
|
|
+ List<FirstArticleItem> firstArticleItemList = firstArticleItemService.list(Wrappers.<FirstArticleItem>lambdaQuery()
|
|
|
+ .eq(FirstArticleItem::getWorkshopId, workshop.getId()));
|
|
|
+ workshop.setFirstArticleItemList(firstArticleItemList);
|
|
|
+ //每个item下的结果
|
|
|
+ firstArticleItemList.forEach(item -> {
|
|
|
+ List<FirstArticleItemResult> firstArticleItemResults = firstArticleItemResultService.list(Wrappers.<FirstArticleItemResult>lambdaQuery()
|
|
|
+ .eq(FirstArticleItemResult::getFirstArticleItemId, item.getId())
|
|
|
+ .eq(FirstArticleItemResult::getResult, 1));
|
|
|
+ // 首件列表
|
|
|
+ if (item.getFirstFlag() == 1 && firstArticleItemResults.stream().count() > 0) {
|
|
|
+ item.setFirstItemResultList(firstArticleItemResults);
|
|
|
+ }
|
|
|
+ // 200件
|
|
|
+ if (item.getTwoHundredFlag() == 1 && firstArticleItemResults.stream().count() > 0) {
|
|
|
+ item.setTwoHundredItemResultList(firstArticleItemResults);
|
|
|
+ }
|
|
|
+ // 中断
|
|
|
+ if (item.getCatchFlag() == 1 && firstArticleItemResults.stream().count() > 0) {
|
|
|
+ item.setCatchItemResultList(firstArticleItemResults);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //获取title
|
|
|
+ FirstArticleTitle title = firstArticleService.getFaTitle(planInfoReq.getPlanId());
|
|
|
+
|
|
|
+ List<FirstArticleApprovalTask> firstArticleApprovalTaskList = planPassMapper.getFirstArticleApprovalTaskList(planInfoReq.getUserId());
|
|
|
+//
|
|
|
+ return PlanPassDetailRes.builder()
|
|
|
+ .planId(bentelerPlan.getId())
|
|
|
+ .planName(bentelerPlan.getName())
|
|
|
+ .effectiveDate(bentelerPlan.getEffectiveDate())
|
|
|
+ .usersName(usersName)
|
|
|
+ .firstArticleTitle(title)
|
|
|
+ .firstArticleCalendars(firstArticleCalendarList)
|
|
|
+ .firstArticleWorkshops(firstArticleWorkshopList)
|
|
|
+ .firstArticleApprovalTasks(firstArticleApprovalTaskList)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计划放行详情-防错
|
|
|
+ *
|
|
|
+ * @param planInfoReq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PlanPassDetailRes getPassDetailPM(PlanInfoReq planInfoReq) {
|
|
|
+ BentelerPlan bentelerPlan = bentelerPlanMapper.selectById(planInfoReq.getPlanId());
|
|
|
List<OnsiteCalendar> onsiteCalendarList = onsiteCalendarMapper.selectList(Wrappers.<OnsiteCalendar>lambdaQuery()
|
|
|
.eq(OnsiteCalendar::getBentelerPlanId, planInfoReq.getPlanId()));
|
|
|
|
|
@@ -137,7 +230,7 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
|
|
|
//获取title
|
|
|
OnsiteTitle title = preventMistakeService.getTitle(planInfoReq.getPlanId());
|
|
|
- List<PlanApprovalTaskRes> planApprovalTaskResList = planMapper.getApprovalTaskList(planInfoReq.getUserId());
|
|
|
+ List<PlanApprovalTaskRes> planApprovalTaskResList = planPassMapper.getApprovalTaskList(planInfoReq.getUserId());
|
|
|
|
|
|
PlanPassDetailRes planPassDetailRes = PlanPassDetailRes.builder()
|
|
|
.planId(bentelerPlan.getId())
|
|
@@ -160,13 +253,26 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
@Override
|
|
|
public ResponseBean approvalTaskOperate(PlanApprovalTaskReq planApprovalTaskReq) {
|
|
|
|
|
|
- OnsiteApprovalTask ot = new OnsiteApprovalTask();
|
|
|
- ot.setOnsiteTaskId(planApprovalTaskReq.getTaskId());
|
|
|
- ot.setReason(planApprovalTaskReq.getReason());
|
|
|
- ot.setStatus(planApprovalTaskReq.getStatus());
|
|
|
- int updateStatus = onsiteApprovalTaskMapper.update(ot, Wrappers.<OnsiteApprovalTask>lambdaQuery()
|
|
|
- .eq(OnsiteApprovalTask::getOnsiteTaskId, planApprovalTaskReq.getTaskId())
|
|
|
- .eq(OnsiteApprovalTask::getApprovalUserId, planApprovalTaskReq.getUserId()));
|
|
|
+ int updateStatus = 0;
|
|
|
+ if (planApprovalTaskReq.getPlanType() == 1) {
|
|
|
+ OnsiteApprovalTask ot = new OnsiteApprovalTask();
|
|
|
+ ot.setOnsiteTaskId(planApprovalTaskReq.getTaskId());
|
|
|
+ ot.setReason(planApprovalTaskReq.getReason());
|
|
|
+ ot.setStatus(planApprovalTaskReq.getStatus());
|
|
|
+ updateStatus = onsiteApprovalTaskMapper.update(ot, Wrappers.<OnsiteApprovalTask>lambdaQuery()
|
|
|
+ .eq(OnsiteApprovalTask::getOnsiteTaskId, planApprovalTaskReq.getTaskId())
|
|
|
+ .eq(OnsiteApprovalTask::getApprovalUserId, planApprovalTaskReq.getUserId()));
|
|
|
+ }
|
|
|
+ if (planApprovalTaskReq.getPlanType() == 2) {
|
|
|
+ FirstArticleApprovalTask ot = new FirstArticleApprovalTask();
|
|
|
+ ot.setFirstArticleTaskId(planApprovalTaskReq.getTaskId());
|
|
|
+ ot.setReason(planApprovalTaskReq.getReason());
|
|
|
+ ot.setStatus(planApprovalTaskReq.getStatus());
|
|
|
+ updateStatus = firstArticleApprovalTaskMapper.update(ot, Wrappers.<FirstArticleApprovalTask>lambdaQuery()
|
|
|
+ .eq(FirstArticleApprovalTask::getFirstArticleTaskId, planApprovalTaskReq.getTaskId())
|
|
|
+ .eq(FirstArticleApprovalTask::getApprovalUserId, planApprovalTaskReq.getUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
if (updateStatus > 0) {
|
|
|
//审批不通过触发下一级别
|
|
|
if (planApprovalTaskReq.getStatus() == 2) {
|
|
@@ -199,4 +305,37 @@ public class PlanPassServiceImpl implements PlanPassService {
|
|
|
return ResponseBeanBuilder.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 计划放行列表
|
|
|
+ *
|
|
|
+ * @param planPageReq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PlanPassRes> getPassList(PlanPageReq planPageReq) {
|
|
|
+ List<PlanPassRes> planPassResList = new ArrayList<>();
|
|
|
+ //首件列表
|
|
|
+ if (planPageReq.getCheckType() == 1) {
|
|
|
+ planPassResList = planPassMapper.getPlanPassList(planPageReq);
|
|
|
+ }
|
|
|
+ //防错列表
|
|
|
+ if (planPageReq.getCheckType() == 2) {
|
|
|
+ planPassResList = planPassMapper.getPlanPassPMList(planPageReq);
|
|
|
+ }
|
|
|
+ return planPassResList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * byte[]转成Object
|
|
|
+ * @param buffer byte[]
|
|
|
+ * @return Object
|
|
|
+ */
|
|
|
+ private Object byteArrayToObject(byte[] buffer) throws Exception {
|
|
|
+ Object ob = null;
|
|
|
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer));
|
|
|
+ ob = ois.readObject();
|
|
|
+ ois.close();
|
|
|
+ return ob;
|
|
|
+ }
|
|
|
+
|
|
|
}
|