From fffbbc439d9bebf9ca916a5b0a585b7864b50803 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期四, 07 四月 2022 16:43:23 +0800
Subject: [PATCH] .

---
 src/main/java/zy/cloud/wms/manager/controller/ItemController.java |   84 +++++++++++++++++++++++++++++++++---------
 1 files changed, 66 insertions(+), 18 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 e783404..d75ccbf 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -15,14 +15,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import zy.cloud.wms.common.web.BaseController;
-import zy.cloud.wms.manager.entity.Cstmr;
-import zy.cloud.wms.manager.entity.Item;
-import zy.cloud.wms.manager.entity.ProjectPlan;
-import zy.cloud.wms.manager.entity.ProjectType;
-import zy.cloud.wms.manager.service.CstmrService;
-import zy.cloud.wms.manager.service.ItemService;
-import zy.cloud.wms.manager.service.ProjectPlanService;
-import zy.cloud.wms.manager.service.ProjectTypeService;
+import zy.cloud.wms.manager.entity.*;
+import zy.cloud.wms.manager.service.*;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -34,6 +28,10 @@
     private ItemService itemService;
     @Autowired
     private ProjectPlanService planService;
+    @Autowired
+    private FlowStatusService flowStatusService;
+    @Autowired
+    private CstmrService cstmrService;
 
     @RequestMapping(value = "/item/{id}/auth")
     @ManagerAuth
@@ -47,11 +45,13 @@
                   @RequestParam(defaultValue = "10")Integer limit,
                   @RequestParam(required = false)String orderByField,
                   @RequestParam(required = false)String orderByType,
+                  @RequestParam(required = false)String condition,
                   @RequestParam Map<String, Object> param){
         EntityWrapper<Item> wrapper = new EntityWrapper<>();
         HashSet<String> excludeField = new HashSet<>();
 
-        allLike(Item.class,excludeField,wrapper, (String) param.get("id"));
+        allLike(Item.class, param.keySet(), wrapper, condition);
+//        allLike(Item.class,excludeField,wrapper, (String) param.get("id"));
         excludeTrash(param);
         convert(param, wrapper);
         hostEq(wrapper);
@@ -110,10 +110,13 @@
     @RequestMapping(value = "/item/add/auth")
     @ManagerAuth
     public R add(Item item) {
-
+        /**
+         * 鎺х
+         */
         if (Cools.isEmpty(item)) {
             return R.error("鍙傛暟涓虹┖,璇疯仈绯荤鐞嗗憳");
         }
+
         //item.setType("1");
 //        if (!item.getType().equals("1")) {
 //            throw new CoolException("鐩墠浠呮敮鎸侀泦鎴愰」鐩�");
@@ -126,21 +129,24 @@
         if (item.getRealMonth() < 0){
             throw new CoolException("瀹炴柦鍛ㄦ湡涓嶅彲涓鸿礋鏁�");
         }
+        if (Cools.isEmpty(item.getCstmrUuid())) {
+            throw new CoolException("璇烽�夋嫨瀹㈡埛");
+        }
+        Cstmr cstmr = cstmrService.selectOne(new EntityWrapper<Cstmr>()
+                .eq("id",Long.parseLong(item.getUuid())));
+        if (Cools.isEmpty(cstmr)) {
+            throw new CoolException("鎵句笉鍒拌瀹㈡埛,璇锋鏌�");
+        }
 
+        item.setCustMan(cstmr.getName());
+        item.setCustMobile(cstmr.getTel());
+        item.setCustAdress(cstmr.getAddr());
         item.setHostId(getHostId());
         item.setCreateBy(getUserId());
         item.setCreateTime(new Date());
         item.setStatus(1);
         item.setUpdateBy(getUserId());
         item.setUpdateTime(new Date());
-        if(item.getPlandeAmt()!=null && item.getRealdeAmt()!=null){
-            item.setExcessAmount(item.getRealdeAmt()-item.getPlandeAmt());
-        }
-        if(item.getPlandeDate()!=null && item.getRealinDate()!=null){
-            Integer days = (int) ((item.getRealinDate().getTime() - item.getPlandeDate().getTime()) / (1000*3600*24));
-            item.setExcessTime(days);
-        }
-
         itemService.insertAll(item);
         return R.ok();
     }
@@ -166,6 +172,16 @@
             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());
+        }
+        //瓒呭嚭澶╂暟
+        if(item.getRealinDate()!=null && item.getPlaninDate()!=null){
+            Double days = (double) ((item.getRealinDate().getTime() - item.getPlaninDate().getTime()) / (1000*3600*24));      
+            Integer day= (int) Math.ceil(days);
+            item.setExcessTime(day);
         }
         item.setUpdateBy(getUserId());
         item.setUpdateTime(new Date());
@@ -237,4 +253,36 @@
         return R.ok();
     }
 
+    /**
+     * 鍒濆鍖栫敓鎴愰」鐩妭鐐�
+     * @param param
+     * @return
+     */
+    @RequestMapping(value = "/item/initPlan/auth")
+    @ManagerAuth
+    public R initPlan(@RequestParam("id") String param){
+        if (param != null){
+            List<ProjectPlan> projectPlans = planService.selectList(new EntityWrapper<ProjectPlan>().eq("item_id",param));
+            if(!Cools.isEmpty(projectPlans) && projectPlans.size()>0){
+                return R.error("璇ラ」鐩凡鏈夎妭鐐硅鍒�");
+            }
+            List<FlowStatus> flowStatuses = flowStatusService.selectList(new EntityWrapper<FlowStatus>());
+            if(!Cools.isEmpty(flowStatuses) && flowStatuses.size()>0){
+                for(FlowStatus flowStatus : flowStatuses){
+                    ProjectPlan projectPlan = new ProjectPlan();
+                    projectPlan.setItemId(Long.parseLong(param));
+                    projectPlan.setWeightNum(flowStatus.getWeightNum());
+                    projectPlan.setFlowId(flowStatus.getId());
+                    planService.insert(projectPlan);
+                }
+            } else {
+                return R.error("椤圭洰璁″垝鑺傜偣鍩虹鏁版嵁涓虹┖");
+            }
+        } else {
+            return R.error("椤圭洰鍙傛暟閿欒");
+        }
+
+        return R.ok();
+    }
+
 }

--
Gitblit v1.9.1