Browse Source

首件创建问题和获取详情缺少字段

baihe 3 years ago
parent
commit
7c39844674

+ 3 - 4
application-facade/src/main/java/com/factory/controller/web/FirstArticleController.java

@@ -64,7 +64,6 @@ import lombok.extern.slf4j.Slf4j;
 @Api(tags = "首件")
 @RestController
 @RequestMapping("/benteler/fa")
-@Slf4j
 public class FirstArticleController {
 
 	@Autowired
@@ -76,7 +75,7 @@ public class FirstArticleController {
 	@ApiOperation(value = "新建首件计划")
 	@PostMapping("/addFaPlan")
 	@ApiOperationSupport(order = 1)
-	public ResponseBean addFaPlan(@RequestBody AddFaPlanReq req) {
+	public ResponseBean<Void> addFaPlan(@RequestBody AddFaPlanReq req){
 		return firstArticleService.addFaPlan(req);
 	}
 
@@ -91,14 +90,14 @@ public class FirstArticleController {
 	@ApiOperation(value = "修改首件计划")
 	@PostMapping("/editFaPlan")
 	@ApiOperationSupport(order = 3)
-	public ResponseBean editFaPlan(@RequestBody EditFaPlanReq req) {
+	public ResponseBean<Void> editFaPlan(@RequestBody EditFaPlanReq req) {
 		return firstArticleService.editFaPlan(req);
 	}
 
 	@ApiOperation(value = "禁用解禁首件计划")
 	@PostMapping("/disableFaPlan")
 	@ApiOperationSupport(order = 4)
-	public ResponseBean disableFaPlan(@RequestBody PmPlanPauseFlagReq req) {
+	public ResponseBean<Void> disableFaPlan(@RequestBody PmPlanPauseFlagReq req) {
 		return preventMistakeService.disablePmPlan(req);
 	}
 

+ 1 - 1
application-facade/src/main/java/com/factory/controller/web/PreventMistakeController.java

@@ -70,7 +70,7 @@ public class PreventMistakeController {
 	@ApiOperation(value = "新建防错计划")
 	@PostMapping("/addPmPlan")
 	@ApiOperationSupport(order = 1)
-	public ResponseBean addPmPlan(@RequestBody AddPmPlanReq req) {
+	public ResponseBean<Void> addPmPlan(@RequestBody AddPmPlanReq req) {
 		return preventMistakeService.addPmPlan(req);
 	}
 

+ 34 - 4
application-facade/src/main/java/com/factory/web/entity/fa/FirstArticleCalendar.java

@@ -1,18 +1,21 @@
 package com.factory.web.entity.fa;
 
+import java.io.Serializable;
+
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.factory.base.util.time.TimeUtils;
+import com.fasterxml.jackson.annotation.JsonAlias;
 import com.fasterxml.jackson.annotation.JsonInclude;
+
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
-import java.io.Serializable;
-import java.time.LocalTime;
-
 /**
  * 这个表日月周目前都只设置一个,目前对应useid也是一个本项目,但之后应该是
  * 每个人可以有一套信息的这个时间表是为了扩展和满足现有设计
@@ -46,6 +49,7 @@ public class FirstArticleCalendar implements Serializable {
     @ApiModelProperty(value = "首件(检测结束时间)")
     private String firstEnd;
 
+    @JsonAlias("twoHundredSubmitTime")
     @ApiModelProperty(value = "200件提交时间(pad提醒时间)")
     private String twoRemind;
 
@@ -66,5 +70,31 @@ public class FirstArticleCalendar implements Serializable {
 
     @ApiModelProperty(value = "责任人2id")
     private Long principalTwoId;
-
+    
+    @ApiModelProperty(value = "责任人2id")
+    @TableField(exist = false)
+    private int firstCheck;
+    
+    public int getFirstCheck() {
+    	int firstCheck = 0;
+    	if(firstRemind!=null&&firstStart!=null) {
+    		firstCheck = (int)java.time.Duration.between(TimeUtils.paserLocalTime(firstStart+":00"),TimeUtils.paserLocalTime(firstRemind+":00")).toMinutes();
+    		if(firstCheck<0) {
+    			firstCheck = (int)java.time.Duration.ofDays(1).toMinutes()+firstCheck;
+    		}
+    	}
+    	return firstCheck;
+    }
+    public static void main(String[] args) {
+    	String firstStart = "23:30";
+    	String firstRemind = "00:00";
+    	System.out.println(TimeUtils.paserLocalTime(firstStart+":00"));
+    	System.out.println(TimeUtils.paserLocalTime(firstRemind+":00"));
+    	int firstCheck = (int)java.time.Duration.between(TimeUtils.paserLocalTime(firstStart+":00"),TimeUtils.paserLocalTime(firstRemind+":00")).toMinutes();
+		if(firstCheck<0) {
+			firstCheck = (int)java.time.Duration.ofDays(1).toMinutes()+firstCheck;
+		}
+		System.out.println(firstCheck);
+    	
+    }
 }

+ 5 - 5
application-facade/src/main/java/com/factory/web/service/fa/FirstArticleService.java

@@ -37,7 +37,7 @@ public interface FirstArticleService extends IService<BentelerPlan> {
 	 * @param req
 	 * @return
 	 */
-	public ResponseBean addFaPlan(AddFaPlanReq req);
+	public ResponseBean<Void> addFaPlan(AddFaPlanReq req);
 
 	/**
 	 * 校验计划名是否存在
@@ -77,7 +77,7 @@ public interface FirstArticleService extends IService<BentelerPlan> {
      * @param req
      * @return
      */
-    public ResponseBean editFaPlan(EditFaPlanReq req);
+    public ResponseBean<Void> editFaPlan(EditFaPlanReq req);
 
     /**
      * 取得首件计划点检列表
@@ -117,7 +117,7 @@ public interface FirstArticleService extends IService<BentelerPlan> {
      * @param req
      * @return
      */
-    public ResponseBean addFaItemResult(AddFaItemResultListReq req);
+    public ResponseBean<Void> addFaItemResult(AddFaItemResultListReq req);
 
     /**
      * 任务提交
@@ -125,7 +125,7 @@ public interface FirstArticleService extends IService<BentelerPlan> {
      * @param req
      * @return
      */
-    public ResponseBean submitFaTask(SubmitFaTaskReq req);
+    public ResponseBean<Void> submitFaTask(SubmitFaTaskReq req);
 
     /**
      * 取得不放行任务对应的工作站
@@ -149,7 +149,7 @@ public interface FirstArticleService extends IService<BentelerPlan> {
      * @param req
      * @return
      */
-    public ResponseBean editFaItemResult(EditFaItemResultListReq req);
+    public ResponseBean<Void> editFaItemResult(EditFaItemResultListReq req);
 
     /**
      * 任务和巡检结果记录历史

+ 12 - 9
application-facade/src/main/java/com/factory/web/service/impl/fa/FirstArticleServiceImpl.java

@@ -183,12 +183,12 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
      * @return
      */
     @Override
-    public ResponseBean addFaPlan(AddFaPlanReq req) {
+    public ResponseBean<Void> addFaPlan(AddFaPlanReq req){
         // 校验计划名称是否存在
         if (this.checkPlanNameExist(req.getBentelerPlanName(), null)) {
             return ResponseBeanBuilder.fail("计划名称已存在");
         }
-        try {
+        
             // 添加首件计划
             BentelerPlan plan = BentelerPlan.builder()
                     .planType(PlanType.首件.value)
@@ -214,11 +214,15 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
                     .build();
             firstArticleCalendarService.save(firstArticleCalendar);
             // 添加表头信息
+            try {
             FirstArticleTitleBlob firstArticleTitleBlob = FirstArticleTitleBlob.builder()
                     .bentelerPlanId(plan.getId())
                     .titleContent(this.objectToByteArray(req.getFirstArticleTitle()))
                     .build();
             firstArticleTitleBlobService.save(firstArticleTitleBlob);
+            }catch (Exception e) {
+            	e.printStackTrace();
+			}
             // 添加工作站信息
             List<FirstArticleWorkshopReq> firstArticleWorkshopList = req.getFirstArticleWorkshopList();
             for (FirstArticleWorkshopReq firstArticleWorkshopReq : firstArticleWorkshopList) {
@@ -260,9 +264,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
                     .originalId(plan.getId())
                     .build());
             onsiteApprovalPlanService.setApprovalFirst(plan.getId(), false);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+      
         return ResponseBeanBuilder.ok();
     }
 
@@ -321,6 +323,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
 
         List<FirstArticleCalendar> firstArticleCalendarList = firstArticleCalendarService.list(Wrappers.<FirstArticleCalendar>lambdaQuery()
                 .eq(FirstArticleCalendar::getBentelerPlanId, plan.getId()));
+        
         faPlanRes.setFirstArticleCalendarList(firstArticleCalendarList);
 
         try {
@@ -378,7 +381,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
      * @return
      */
     @Override
-    public ResponseBean editFaPlan(EditFaPlanReq req) {
+    public ResponseBean<Void> editFaPlan(EditFaPlanReq req) {
         try {
             BentelerPlan plan = null;
             BentelerPlan oldPlan = planService.getById(req.getBentelerPlanId());
@@ -736,7 +739,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
      * @return
      */
     @Override
-    public ResponseBean addFaItemResult(AddFaItemResultListReq req) {
+    public ResponseBean<Void> addFaItemResult(AddFaItemResultListReq req) {
         /* 取得task信息 */
         SearchFaTaskInfoReq searchFaTaskInfoReq = new SearchFaTaskInfoReq();
         searchFaTaskInfoReq.setBentelerPlanId(req.getBentelerPlanId());
@@ -819,7 +822,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
      * @return
      */
     @Override
-    public ResponseBean submitFaTask(SubmitFaTaskReq req) {
+    public ResponseBean<Void> submitFaTask(SubmitFaTaskReq req) {
         /* 取得task信息 */
         SearchFaTaskInfoReq searchFaTaskInfoReq = new SearchFaTaskInfoReq();
         searchFaTaskInfoReq.setBentelerPlanId(req.getBentelerPlanId());
@@ -965,7 +968,7 @@ public class FirstArticleServiceImpl extends ServiceImpl<FirstArticleMapper, Ben
      * @return
      */
     @Override
-    public ResponseBean editFaItemResult(EditFaItemResultListReq req) {
+    public ResponseBean<Void> editFaItemResult(EditFaItemResultListReq req) {
         /* 更新巡检项目检查结果 */
         List<EditFaItemResultReq> editFaItemResultList = req.getEditFaItemResultList();
         for (EditFaItemResultReq editFaItemResult : editFaItemResultList) {

+ 7 - 40
application-facade/src/main/java/com/factory/web/service/impl/pm/PreventMistakeServiceImpl.java

@@ -330,47 +330,14 @@ public class PreventMistakeServiceImpl extends ServiceImpl<PreventMistakeMapper,
 			searchPmPlanReq = new SearchPmPlanReq();
 			searchPmPlanReq.setBentelerPlanId(pmPlan.getBentelerPlanId());
 			OnsiteApprovalPlan latestApprovalInfo = this.getLatestApprovalInfo(searchPmPlanReq);
-
-			pmPlan.setApprovalLevel(latestApprovalInfo.getApprovalLevel());
-			pmPlan.setApprovalUserId(latestApprovalInfo.getApprovalUserId());
-			pmPlan.setStatus(latestApprovalInfo.getStatus());
-			pmPlan.setReason(latestApprovalInfo.getReason());
-			pmPlan.setUpdatedTime(latestApprovalInfo.getUpdatedTime());
+			if(latestApprovalInfo!=null) {
+				pmPlan.setApprovalLevel(latestApprovalInfo.getApprovalLevel());
+				pmPlan.setApprovalUserId(latestApprovalInfo.getApprovalUserId());
+				pmPlan.setStatus(latestApprovalInfo.getStatus());
+				pmPlan.setReason(latestApprovalInfo.getReason());
+				pmPlan.setUpdatedTime(latestApprovalInfo.getUpdatedTime());
+			}
 		}
-
-//		// TODO 测一下status值是都设置成功
-//		SearchPmPlanReq searchPmPlanReq = null;
-//		for (PmPlanListRes pmPlan : listResPage.getRecords()) {
-//			searchPmPlanReq = new SearchPmPlanReq();
-//			searchPmPlanReq.setBentelerPlanId(pmPlan.getBentelerPlanId());
-//			List<PmTaskListRes> listRes = this.getTaskList(searchPmPlanReq);
-//			int planStatus = 0; // 计划今天的状态,0未完成 1已完成 2待重检
-//			int count0 = 0; // 任务的task.getStatus=0初始化
-//			int count1 = 0; // 任务的task.getStatus=1待审核状态
-//            int count2 = 0; // 任务的task.getStatus=2放行
-//            int count3 = 0; // 任务的task.getStatus=3不放行
-//			for (PmTaskListRes task : listRes) {
-//				if (task.getStatus() == 0) {
-//					count0++;
-//				} else if (task.getStatus() == 1) {
-//					count1++;
-//				} else if (task.getStatus() == 2) {
-//					count2++;
-//				} else if (task.getStatus() == 3) {
-//					count3++;
-//				}
-//			}
-//			if (count0 > 0 || count1 > 0) {
-//				planStatus = 0; // 存在未完成的任务,计划状态0未完成
-//			} else if (count2 == listRes.size()) {
-//				planStatus = 1; // 所有任务都检查完毕,都放行,计划状态1已完成
-//			} else if (count3 > 0) {
-//				planStatus = 2; // 所有任务都检查完毕,存在不放行记录,计划状态2待重检
-//			}
-//
-//			pmPlan.setPlanStatus(planStatus);
-//		}
-
         return ResponseBeanBuilder.ok(listResPage, Function.identity());
     }