From 64b432916af9c9218ab3f3eca614e26c542142ae Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 07 十一月 2023 15:47:13 +0800
Subject: [PATCH] bug

---
 server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java
index 1e80882..a5931f2 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/WorkPlansExtServiceImpl.java
@@ -32,6 +32,8 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -96,7 +98,9 @@
                 || Objects.isNull(workPlansSaveDTO.getNum())
                 || Objects.isNull(workPlansSaveDTO.getFactoryId())
                 || Objects.isNull(workPlansSaveDTO.getUnitId())
-                || Objects.isNull(workPlansSaveDTO.getMaterialId())){
+                || Objects.isNull(workPlansSaveDTO.getMaterialId())
+                || Objects.isNull(workPlansSaveDTO.getStartDate())
+                || workPlansSaveDTO.getStartDate().getTime() > workPlansSaveDTO.getPlanDate().getTime()){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         WorkPlans workPlans = new WorkPlans();
@@ -172,6 +176,16 @@
                     i.setFinishUnQualifiedNum(Objects.isNull(plansExtListVO.getUnqulifiedNum())?Constants.ZERO:plansExtListVO.getUnqulifiedNum());
                     i.setFinishNum(Objects.isNull(plansExtListVO.getDoneNum())?Constants.ZERO:plansExtListVO.getDoneNum());
                 }
+                i.setHasExpire(false);
+                i.setStatus(Constants.formatIntegerNum(i.getStatus()));
+                if ( !i.getStatus().equals(Constants.WORKPLANHISTORY_TYPE.done) &&
+                        !i.getStatus().equals(Constants.WORKPLANHISTORY_TYPE.close)){
+                    if (Objects.nonNull(i.getPlanDate())){
+                        i.setHasExpire(DateUtil.toDateLocalDateTime(i.getPlanDate()).toLocalDate().isBefore(LocalDate.now()));
+                    }
+                }
+
+
             });
         }
         return PageData.from(new PageInfo<>(result));
@@ -365,8 +379,14 @@
         if(Constants.formatIntegerNum(p.getNum())<=0){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愯鍒掔敓浜ф暟閲忋�戞暟鎹敊璇紒");
         }
+        if(p.getStartDate() == null){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愯鍒掑紑濮嬫棩鏈熴�戞暟鎹敊璇紝姝g‘鏍煎紡涓猴細yyyy-MM-dd锛堝2022-06-07锛夛紒");
+        }
         if(p.getPlanDate() == null){
-            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愯鍒掓棩鏈熴�戞暟鎹敊璇紝姝g‘鏍煎紡涓猴細yyyy-MM-dd锛堝2022-06-07锛夛紒");
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愯鍒掔粨鏉熸棩鏈熴�戞暟鎹敊璇紝姝g‘鏍煎紡涓猴細yyyy-MM-dd锛堝2022-06-07锛夛紒");
+        }
+        if(p.getPlanDate().getTime() < p.getStartDate().getTime()){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愯鍒掑紑濮嬫棩鏈熴�戣鏃╀簬銆愯鍒掔粨鏉熸棩鏈熴�戯紒");
         }
         if(StringUtils.isBlank(p.getMaterialCode())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愪骇鍝佺紪鐮併�戞暟鎹敊璇紒");
@@ -378,9 +398,8 @@
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(index+2)+"銆戣銆愮敓浜ф壒娆°�戞暟鎹敊璇紒");
         }
 
-        Date pDate = DateUtil.getDateFromString(DateUtil.getShortTime(p.getPlanDate()) +" 00:00:00");
-        Date nDate =  DateUtil.getDateFromString(DateUtil.getShortTime(DateUtil.getCurrentDate()) +" 00:00:00");
-        if( nDate.getTime() > pDate.getTime()){
+        LocalDateTime localLocalDateTime = DateUtil.toDateLocalDateTime(p.getStartDate());
+        if( localLocalDateTime.toLocalDate().isBefore(LocalDate.now())){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璁″垝鐢熶骇鏃ユ湡蹇呴』涓轰粖澶╀互鍚庣殑鏃ユ湡锛�");
         }
         p.setMaterialCode(p.getMaterialCode().trim());

--
Gitblit v1.9.3