From a546b70a863e44c2e8735b3cfc9da45a781b735f Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期五, 03 十一月 2023 10:10:33 +0800 Subject: [PATCH] #托盘码下架 --- src/main/java/com/zy/asrs/controller/LocDetlController.java | 9 ++++ src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 82 +++++++++++++++++++++++++++++++++++++++++ src/main/java/com/zy/asrs/controller/MobileController.java | 8 ++++ src/main/java/com/zy/asrs/service/MobileService.java | 1 4 files changed, 100 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/LocDetlController.java b/src/main/java/com/zy/asrs/controller/LocDetlController.java index bb9dc62..b3b35d6 100644 --- a/src/main/java/com/zy/asrs/controller/LocDetlController.java +++ b/src/main/java/com/zy/asrs/controller/LocDetlController.java @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.math.BigDecimal; import java.net.URLEncoder; import java.util.*; @@ -42,6 +43,14 @@ private MatService matService; @Autowired private ManLocDetlService manLocDetlService; + @RequestMapping(value = "/locDetl/list/barcode") + public R getBarcodeList(@RequestParam String barcode) { + List<ManLocDetl> manLocDetls = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>().eq("zpallet", barcode)); + if (Cools.isEmpty(manLocDetls)){ + return R.error("鎵樼洏鐮佹暟鎹负绌�"); + } + return R.ok(manLocDetls); + } @RequestMapping(value = "/locDetl/update") public R update1() { diff --git a/src/main/java/com/zy/asrs/controller/MobileController.java b/src/main/java/com/zy/asrs/controller/MobileController.java index d091ace..bbb9f32 100644 --- a/src/main/java/com/zy/asrs/controller/MobileController.java +++ b/src/main/java/com/zy/asrs/controller/MobileController.java @@ -367,6 +367,14 @@ } return mobileService.manDetlOut(json , getUser()); } + @RequestMapping("/manDetl/barcode/out") + @ManagerAuth(memo = "璁㈠崟涓嬫灦(鎵樼洏鐮�)") + public R barcodeDelete(@RequestBody JSONObject json){ + if (json == null){ + return R.error("浼犲叆鏁版嵁涓虹┖"); + } + return mobileService.barcodeDelete(json , getUser()); + } @RequestMapping("/manDetl/in/barcode") @ManagerAuth(memo = "璁㈠崟涓婃灦(鎵樼洏鐮�)") diff --git a/src/main/java/com/zy/asrs/service/MobileService.java b/src/main/java/com/zy/asrs/service/MobileService.java index c57dcae..d1d65fc 100644 --- a/src/main/java/com/zy/asrs/service/MobileService.java +++ b/src/main/java/com/zy/asrs/service/MobileService.java @@ -46,4 +46,5 @@ R manDetlOut(JSONObject json,User user); R manDetlInBarcode(JSONObject json ,User user); + R barcodeDelete(JSONObject json, User user); } diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java index ff4db4a..2b49f04 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -884,4 +884,86 @@ } return R.ok("涓婃灦鎴愬姛"); } + + @Override + @Transactional + public R barcodeDelete(JSONObject json, User user) { + String jsonBarcode = (String) json.get("barcode"); + String jsonOrderNo = (String) json.get("orderNo"); + JSONArray combMats = json.getJSONArray("combMats"); + for (int i = 0; i < combMats.size(); i++) { + ManLocDetl jsonManLocDetl = combMats.getObject(i, ManLocDetl.class); + Wrapper<OrderDetl> orderDetlWrapper = new EntityWrapper<OrderDetl>() + .eq("order_no", jsonOrderNo) + .eq("matnr", jsonManLocDetl.getMatnr()); + OrderDetl orderDetl = orderDetlService.selectOne(orderDetlWrapper); + if (Cools.isEmpty(orderDetl)){ + return R.error("璁㈠崟涓湭鏌ヨ鍒颁笅鏋舵暟鎹�"); + } + BigDecimal orderQty = new BigDecimal(orderDetl.getQty()); + BigDecimal orderWorkQty = new BigDecimal(orderDetl.getWorkQty()); + BigDecimal anfme = new BigDecimal(jsonManLocDetl.getAnfme()); + BigDecimal diffQty = orderQty.add(anfme); + BigDecimal diffWorkQty = orderWorkQty.add(anfme); + if (diffQty.doubleValue() > orderDetl.getAnfme()){ + return R.error("瀹屾垚鏁伴噺澶т簬璁㈠崟鏁伴噺"); + } + if (diffWorkQty.doubleValue() > orderDetl.getAnfme()){ + return R.error("宸ヤ綔鏁伴噺澶т簬璁㈠崟鏁伴噺"); + } + orderDetl.setQty(diffQty.doubleValue()); + orderDetl.setWorkQty(diffWorkQty.doubleValue()); + if (!orderDetlService.updateById(orderDetl)){ + return R.error("璁㈠崟鏄庣粏鏇存柊澶辫触"); + } + EntityWrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<>(); + manLocDetlWrapper.eq("zpallet",jsonBarcode); + manLocDetlWrapper.eq("matnr",jsonManLocDetl.getMatnr()); + ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); + BigDecimal locDetlAnfme = new BigDecimal(manLocDetl.getAnfme()); + + BigDecimal diffAnfme = locDetlAnfme.subtract(anfme); + if (diffAnfme.doubleValue() <0){ + return R.error("鍑哄簱鏁伴噺澶т簬搴撳瓨鏁伴噺"); + } + if (diffAnfme.doubleValue() == 0){ + if (!manLocDetlService.delete(manLocDetlWrapper)){ + return R.error("鍒犻櫎搴撳瓨鏄庣粏澶辫触"); + } + + } else if (diffAnfme.doubleValue() > 0) { + manLocDetl.setAnfme(diffAnfme.doubleValue()); + if (!manLocDetlService.update(manLocDetl,manLocDetlWrapper)){ + return R.error("鏇存柊搴撳瓨鏄庣粏澶辫触"); + } + + + } + Order order = orderService.selectByNo(jsonOrderNo); + if (IsOrderStatus(jsonOrderNo)){ + order.setSettle(4L); + }else { + order.setSettle(2L); + } + if(!orderService.update(order,new EntityWrapper<Order>().eq("order_no", jsonOrderNo))){ + throw new RuntimeException("鏇存柊璁㈠崟鐘舵�佸け璐�"); + } + } + + return R.ok(); + } + + public Boolean IsOrderStatus(String order){ + //鍒ゆ柇璁㈠崟鏄惁瀹屾垚 + boolean log =true; + //璁㈠崟鏄惁瀹屾垚 + List<OrderDetl> or = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", order)); + for (OrderDetl o: or) { + if(o.getAnfme()-o.getQty()>0){ + log=false; + break; + } + } + return log; + } } -- Gitblit v1.9.1