From 320ed3f4782f9662f79ecfe14d2cf3f34dd288c5 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期二, 01 八月 2023 19:52:36 +0800
Subject: [PATCH] #

---
 src/main/java/zy/cloud/wms/manager/controller/ItemController.java |   60 +++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/src/main/java/zy/cloud/wms/manager/controller/ItemController.java b/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
index 20bfcff..3dad197 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -19,6 +19,7 @@
 import zy.cloud.wms.manager.service.*;
 
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 
 @RestController
@@ -115,9 +116,7 @@
         /**
          * 鎺х
          */
-        if (Cools.isEmpty(item.getHostId()) || item.getHostId() == 0){
-            item.setHostId(1L);
-        }
+
         if (Cools.isEmpty(item)) {
             return R.error("鍙傛暟涓虹┖,璇疯仈绯荤鐞嗗憳");
         }
@@ -131,9 +130,9 @@
         if (!Cools.isEmpty(name)) {
             throw new CoolException("涓嶅彲鏈夐噸澶嶉」鐩悕");
         }
-        if (item.getRealMonth() < 0){
-            throw new CoolException("瀹炴柦鍛ㄦ湡涓嶅彲涓鸿礋鏁�");
-        }
+//        if (item.getRealMonth() < 0){
+//            throw new CoolException("瀹炴柦鍛ㄦ湡涓嶅彲涓鸿礋鏁�");
+//        }
         if (Cools.isEmpty(item.getCstmrUuid())) {
             throw new CoolException("璇烽�夋嫨瀹㈡埛");
         }
@@ -142,17 +141,21 @@
         if (Cools.isEmpty(cstmr)) {
             throw new CoolException("鎵句笉鍒拌瀹㈡埛,璇锋鏌�");
         }
-
-
         item.setCustMan(cstmr.getName());
         item.setCustMobile(cstmr.getTel());
         item.setCustAdress(cstmr.getAddr());
-        item.setHostId(getHostId());
+        if (Cools.isEmpty(item.getHostId()) || item.getHostId() == 0){
+            item.setHostId(1L);
+        }else {
+            item.setHostId(getHostId());
+        }
         item.setCreateBy(getUserId());
         item.setCreateTime(new Date());
         item.setStatus(1);
         item.setUpdateBy(getUserId());
         item.setUpdateTime(new Date());
+        Long span = (item.getEndTime().getTime() - item.getStartTime().getTime()) / 1000 / 60 / 60 / 24;
+        item.setRealMonth(Math.toIntExact(span));
         itemService.insertAll(item);
         return R.ok();
     }
@@ -174,12 +177,17 @@
 //        if (item.getRealMonth() < 0){
 //            throw new CoolException("瀹炴柦鍛ㄦ湡涓嶅彲涓鸿礋鏁�");
 //        }
-        if(!(newitem.getStartTime()==null || newitem.getEndTime()==null || newitem.getRealStartTime()==null || newitem.getRealEndTime()==null)){
-            item.setStartTime(newitem.getStartTime());
-            item.setEndTime(newitem.getEndTime());
-            item.setRealEndTime(newitem.getRealEndTime());
-            item.setRealStartTime(newitem.getRealStartTime());
-        }
+
+
+        //鈫撯啌鈫撳啓杩欐浠g爜鐨勭湡璇ユ娊澶у槾宸村瓙
+//        if(!(newitem.getStartTime()==null || newitem.getEndTime()==null || newitem.getRealStartTime()==null || newitem.getRealEndTime()==null)){
+//            item.setStartTime(newitem.getStartTime());
+//            item.setEndTime(newitem.getEndTime());
+//            item.setRealEndTime(newitem.getRealEndTime());
+//            item.setRealStartTime(newitem.getRealStartTime());
+//        }
+
+
         //瓒呭嚭杩愯垂
         if(item.getPlandeAmt()!=null && item.getRealdeAmt()!=null){
             item.setExcessAmount(item.getRealdeAmt()-item.getPlandeAmt());
@@ -306,4 +314,26 @@
         return R.ok(result);
     }
 
+    @RequestMapping("/item/initAll")
+    public R initAll() {
+        List<Item> items = itemService.selectList(null);
+        for (Item item : items) {
+            Integer isAsrs = item.getType().equals("10")? 1: 0;
+            List<FlowStatus> allTypes = flowStatusService.selectList(new EntityWrapper<FlowStatus>()
+                    .eq("is_asrs", isAsrs)
+                    .orderBy("weight_num",true));
+            for (FlowStatus oneType : allTypes) {
+                ProjectPlan projectPlan = new ProjectPlan();
+                projectPlan.setItemId(item.getId());
+                projectPlan.setWeightNum(oneType.getWeightNum());
+                projectPlan.setFlowId(oneType.getId());
+                projectPlan.setCreateId(item.getCreateBy());
+                projectPlan.setCreateTime(item.getCreateTime());
+                projectPlan.setModifyId(item.getUpdateBy());
+                projectPlan.setModifyTime(item.getUpdateTime());
+                planService.insert(projectPlan);
+            }
+        }
+        return R.ok("鍏辫鎻掑叆:"+items.size()+"鏉℃暟鎹�");
+    }
 }

--
Gitblit v1.9.1