|
@@ -1,8 +1,17 @@
|
|
|
package com.factory.wx.service.impl;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.factory.base.entity.po.benteler.BentelerPlan;
|
|
|
import com.factory.base.util.res.ResponseBeanBuilder;
|
|
|
+import com.factory.base.util.time.TimeUtils;
|
|
|
import com.factory.web.entity.fa.FirstArticleApprovalTask;
|
|
|
import com.factory.web.entity.fa.FirstArticleTitle;
|
|
|
import com.factory.web.entity.fa.FirstArticleWorkshop;
|
|
@@ -10,7 +19,12 @@ import com.factory.web.entity.pm.OnsiteApprovalTask;
|
|
|
import com.factory.web.entity.pm.OnsiteTitle;
|
|
|
import com.factory.web.entity.pm.OnsiteWorkshop;
|
|
|
import com.factory.web.entity.pm.req.SearchAbnormalReq;
|
|
|
-import com.factory.web.entity.pm.res.*;
|
|
|
+import com.factory.web.entity.pm.res.AbnormalApprovalTaskRes;
|
|
|
+import com.factory.web.entity.pm.res.AbnormalItemRes;
|
|
|
+import com.factory.web.entity.pm.res.AbnormalItemResultRes;
|
|
|
+import com.factory.web.entity.pm.res.AbnormalTaskInfoRes;
|
|
|
+import com.factory.web.entity.pm.res.AbnormalWorkshopRes;
|
|
|
+import com.factory.web.entity.statistics.StatisticsDateReq;
|
|
|
import com.factory.web.mapper.BentelerPlanMapper;
|
|
|
import com.factory.web.mapper.FileMapper;
|
|
|
import com.factory.web.mapper.pm.PreventMistakeMapper;
|
|
@@ -28,21 +42,15 @@ import com.factory.wx.entity.res.AbnormalPlanRes;
|
|
|
import com.factory.wx.mapper.AbnormalStatisticsMapper;
|
|
|
import com.factory.wx.service.AbnormalStatisticsService;
|
|
|
import com.factory.wx.service.WxPlanService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
|
* @author sMArT
|
|
|
* @version 1.0
|
|
|
* @date 2021-07-23 1:33 上午
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service("abnormalStatisticsService")
|
|
|
public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService {
|
|
|
@Autowired
|
|
@@ -76,9 +84,11 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
*/
|
|
|
@Override
|
|
|
public List<AbnormalPlanRes> getExceptionPlansByMonth(AbnormalPlanReq abnormalPlanReq) {
|
|
|
- String month = getMonth(abnormalPlanReq);
|
|
|
- abnormalPlanReq.setMonth(month);
|
|
|
-
|
|
|
+ LocalDateTime month = getMonth(abnormalPlanReq);
|
|
|
+
|
|
|
+ LocalDateTime[] se = TimeUtils.getStartAndEndDayTime(month, 3, 0);
|
|
|
+ abnormalPlanReq.setSdate(se[0]);
|
|
|
+ abnormalPlanReq.setEdate(se[1]);
|
|
|
List<AbnormalPlanRes> releasedAbnormalPlans = new ArrayList<>();
|
|
|
//已重检
|
|
|
if (abnormalPlanReq.getAbnormalType() == 1) {
|
|
@@ -103,8 +113,8 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
BentelerPlan bentelerPlan = bentelerPlanMapper.selectById(abnormalDetailReq.getPlanId());
|
|
|
abnormalDetailRes.setPlanId(bentelerPlan.getId());
|
|
|
abnormalDetailRes.setPlanName(bentelerPlan.getName());
|
|
|
-
|
|
|
- if (abnormalDetailReq.getCheckType() == 1) {
|
|
|
+ abnormalDetailRes.setPlanType(bentelerPlan.getPlanType());
|
|
|
+ if (bentelerPlan.getPlanType() == 1) {
|
|
|
//获取title
|
|
|
FirstArticleTitle title = firstArticleService.getFaTitle(abnormalDetailReq.getPlanId());
|
|
|
//判断是否有附件
|
|
@@ -115,8 +125,7 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
//取放行信息
|
|
|
List<AbnormalTaskInfoRes> abnormalTaskInfoResList = getFaAbnormalTaskInfoRes(abnormalDetailReq);
|
|
|
abnormalDetailRes.setAbnormalTaskInfos(abnormalTaskInfoResList);
|
|
|
- }
|
|
|
- if (abnormalDetailReq.getCheckType() == 2) {
|
|
|
+ }else if (bentelerPlan.getPlanType() == 2) {
|
|
|
//获取title
|
|
|
OnsiteTitle title = preventMistakeService.getTitle(abnormalDetailReq.getPlanId());
|
|
|
//判断是否有附件
|
|
@@ -142,11 +151,10 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
List<AbnormalTaskInfoRes> faList = new ArrayList<>();
|
|
|
if (abnormalDetailReq.getAbnormalType() == 1) {
|
|
|
//重检内容
|
|
|
- faList = abnormalStatisticsMapper.getFaRecheckedListByPlanId(abnormalDetailReq.getPlanId());
|
|
|
- }
|
|
|
- if (abnormalDetailReq.getAbnormalType() == 2) {
|
|
|
+ faList = abnormalStatisticsMapper.getFaRecheckedListByPlanId(abnormalDetailReq.getPlanId(),abnormalDetailReq.getTaskId());
|
|
|
+ }else {//if (abnormalDetailReq.getAbnormalType() == 2)
|
|
|
//放行内容
|
|
|
- faList = abnormalStatisticsMapper.getFaReleaseListByPlanId(abnormalDetailReq.getPlanId());
|
|
|
+ faList = abnormalStatisticsMapper.getFaReleaseListByPlanId(abnormalDetailReq.getPlanId(),abnormalDetailReq.getTaskId());
|
|
|
}
|
|
|
|
|
|
for (AbnormalTaskInfoRes faInfo : faList) {
|
|
@@ -230,11 +238,10 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
List<AbnormalTaskInfoRes> pmList = new ArrayList<>();
|
|
|
if (abnormalDetailReq.getAbnormalType() == 1) {
|
|
|
//重检内容
|
|
|
- pmList = abnormalStatisticsMapper.getPmRecheckedListByPlanId(abnormalDetailReq.getPlanId());
|
|
|
- }
|
|
|
- if (abnormalDetailReq.getAbnormalType() == 2) {
|
|
|
+ pmList = abnormalStatisticsMapper.getPmRecheckedListByPlanId(abnormalDetailReq.getPlanId(),abnormalDetailReq.getTaskId());
|
|
|
+ }else {//if (abnormalDetailReq.getAbnormalType() == 2)
|
|
|
//放行内容
|
|
|
- pmList = abnormalStatisticsMapper.getPmReleaseListByPlanId(abnormalDetailReq.getPlanId());
|
|
|
+ pmList = abnormalStatisticsMapper.getPmReleaseListByPlanId(abnormalDetailReq.getPlanId(),abnormalDetailReq.getTaskId());
|
|
|
}
|
|
|
for (AbnormalTaskInfoRes pmInfo : pmList) {
|
|
|
List<OnsiteWorkshop> onsiteWorkshopList = onsiteWorkshopService.list(Wrappers.<OnsiteWorkshop>lambdaQuery()
|
|
@@ -309,14 +316,12 @@ public class AbnormalStatisticsServiceImpl implements AbnormalStatisticsService
|
|
|
* @param abnormalPlanReq 默认2021-06
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getMonth(AbnormalPlanReq abnormalPlanReq) {
|
|
|
- String month = "2021-06";
|
|
|
+ private LocalDateTime getMonth(AbnormalPlanReq statisticsDateReq) {
|
|
|
+ LocalDateTime month = LocalDateTime.now();
|
|
|
try {
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
- Date date = simpleDateFormat.parse(abnormalPlanReq.getMonth());
|
|
|
- month = simpleDateFormat.format(date);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ month = TimeUtils.paserMonthString(statisticsDateReq.getMonth());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("年月格式错误",e);
|
|
|
ResponseBeanBuilder.fail("年月格式错误");
|
|
|
}
|
|
|
return month;
|