From 608c29d1138d4e24356bb7e4b258e1401eb05c39 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期一, 20 十二月 2021 12:55:58 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/ints/controller/WaitMatoutController.java |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 102 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/zy/ints/controller/WaitMatoutController.java b/src/main/java/com/zy/ints/controller/WaitMatoutController.java
index b9f5ab7..3b149a3 100644
--- a/src/main/java/com/zy/ints/controller/WaitMatoutController.java
+++ b/src/main/java/com/zy/ints/controller/WaitMatoutController.java
@@ -9,16 +9,16 @@
 import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.common.R;
+import com.core.exception.CoolException;
 import com.zy.common.web.BaseController;
+import com.zy.ints.entity.WaitMatin;
 import com.zy.ints.entity.WaitMatout;
 import com.zy.ints.service.WaitMatoutService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RestController
 public class WaitMatoutController extends BaseController {
@@ -30,6 +30,24 @@
     @ManagerAuth
     public R get(@PathVariable("id") String id) {
         return R.ok(waitMatoutService.selectById(String.valueOf(id)));
+    }
+
+
+    @RequestMapping(value = "/waitMatout/head/page/auth")
+    @ManagerAuth
+    public R headPage(@RequestParam(defaultValue = "1")Integer curr,
+                      @RequestParam(defaultValue = "10")Integer limit,
+                      @RequestParam Map<String, Object> param){
+        if (!Cools.isEmpty(param.get("appe_time"))){
+            String val = String.valueOf(param.get("appe_time"));
+            if (val.contains(RANGE_TIME_LINK)) {
+                String[] dates = val.split(RANGE_TIME_LINK);
+                param.put("startTime", DateUtils.convert(dates[0]));
+                param.put("endTime", DateUtils.convert(dates[1]));
+                param.remove("appe_time");
+            }
+        }
+        return R.ok(waitMatoutService.getHeadPage(toPage(curr, limit, param, WaitMatout.class)));
     }
 
     @RequestMapping(value = "/waitMatout/list/auth")
@@ -44,6 +62,20 @@
         excludeTrash(param);
         convert(param, wrapper);
         allLike(WaitMatout.class, param.keySet(), wrapper, condition);
+        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+        return R.ok(waitMatoutService.selectPage(new Page<>(curr, limit), wrapper));
+    }
+
+    @RequestMapping(value = "/waitMatout/list/auth2")
+    @ManagerAuth
+    public R list(@RequestParam(defaultValue = "1")Integer curr,
+                  @RequestParam(defaultValue = "10")Integer limit,
+                  @RequestParam(required = false)String orderByField,
+                  @RequestParam(required = false)String orderByType,
+                  @RequestParam(required = false)String condition,
+                  @RequestParam(name = "billNo") String bill_no){
+        EntityWrapper<WaitMatout> wrapper = new EntityWrapper<>();
+        wrapper.eq("bill_no", bill_no);
         if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
         return R.ok(waitMatoutService.selectPage(new Page<>(curr, limit), wrapper));
     }
@@ -63,28 +95,81 @@
 
     @RequestMapping(value = "/waitMatout/add/auth")
     @ManagerAuth
-    public R add(WaitMatout waitMatout) {
-        waitMatoutService.insert(waitMatout);
-        return R.ok();
+    @Transactional
+    public R add(@RequestBody List<WaitMatout> waitMatouts) {
+        if (Cools.isEmpty(waitMatouts)) {
+            return R.parse(BaseRes.PARAM);
+        }
+        if (waitMatoutService.selectCount(new EntityWrapper<WaitMatout>().eq("bill_no", waitMatouts.get(0).getBillNo())) > 0) {
+            return R.error("鍗曟嵁缂栧彿宸插瓨鍦�");
+        }
+        int i = 1;
+        Date now = new Date();
+        for (WaitMatout waitMatout : waitMatouts) {
+            waitMatout.setSeqNo(i);
+            waitMatout.setAppeTime(now);
+            waitMatout.setAppeUser(getUserId());
+            waitMatout.setModiTime(now);
+            waitMatout.setModiUser(getUserId());
+            if (!waitMatoutService.insert(waitMatout)) {
+                throw new CoolException("娣诲姞鍗曟嵁鏄庣粏澶辫触");
+            }
+            i++;
+        }
+        return R.ok("娣诲姞鎴愬姛");
     }
 
-	@RequestMapping(value = "/waitMatout/update/auth")
-	@ManagerAuth
-    public R update(WaitMatout waitMatout){
-        if (Cools.isEmpty(waitMatout) || null==waitMatout.getSeqNo()){
+    @RequestMapping(value = "/waitMatout/modify/auth")
+    @ManagerAuth
+    @Transactional
+    public R update(@RequestBody List<WaitMatout> waitMatouts){
+        if (Cools.isEmpty(waitMatouts)) {
+            return R.parse(BaseRes.PARAM);
+        }
+        Date now = new Date();
+        List<WaitMatout> oldWaitMatouts = waitMatoutService.selectList(new EntityWrapper<WaitMatout>().eq("bill_no", waitMatouts.get(0).getBillNo()));
+        Date appeTime = oldWaitMatouts!=null?oldWaitMatouts.get(0).getAppeTime():now;
+        Long appeUser = oldWaitMatouts!=null?oldWaitMatouts.get(0).getAppeUser():getUserId();
+        if (!waitMatoutService.delete(new EntityWrapper<WaitMatout>().eq("bill_no", waitMatouts.get(0).getBillNo()))) {
             return R.error();
         }
-        waitMatoutService.updateById(waitMatout);
-        return R.ok();
+        int i = 1;
+        for (WaitMatout waitMatout : waitMatouts) {
+            waitMatout.setSeqNo(i);
+            waitMatout.setAppeTime(appeTime);
+            waitMatout.setAppeUser(appeUser);
+            waitMatout.setModiTime(now);
+            waitMatout.setModiUser(getUserId());
+            if (!waitMatoutService.insert(waitMatout)) {
+                throw new CoolException("淇敼鍗曟嵁鏄庣粏澶辫触");
+            }
+            i++;
+        }
+        return R.ok("淇敼鎴愬姛");
     }
+
+    @RequestMapping(value = "/waitMatout/detl/list/auth")
+    @ManagerAuth
+    public R detlPage(@RequestParam String billNo){
+        if (Cools.isEmpty(billNo)){
+            return R.parse(BaseRes.PARAM);
+        }
+        List<WaitMatout> waitMatins = waitMatoutService.selectList(new EntityWrapper<WaitMatout>().eq("bill_no", billNo));
+        if (Cools.isEmpty(waitMatins)) {
+            return R.parse(BaseRes.EMPTY);
+        }
+        return R.ok().add(waitMatins);
+    }
+
+
 
     @RequestMapping(value = "/waitMatout/delete/auth")
     @ManagerAuth
-    public R delete(@RequestParam(value="ids[]") Long[] ids){
-         for (Long id : ids){
-            waitMatoutService.deleteById(id);
+    public R delete(@RequestParam String billNo){
+        if (!waitMatoutService.delete(new EntityWrapper<WaitMatout>().eq("bill_no", billNo))) {
+            throw new CoolException("鍒犻櫎鍗曟嵁鏄庣粏澶辫触");
         }
-        return R.ok();
+        return R.ok("鍒犻櫎鎴愬姛");
     }
 
     @RequestMapping(value = "/waitMatout/export/auth")

--
Gitblit v1.9.1