From e061d201decb0c3344d1bfc2237081a7edc0aa0d Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 15 四月 2024 14:51:48 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 145 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 127 insertions(+), 18 deletions(-) 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 230163d..afb1de2 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -96,8 +96,8 @@ // } // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). - eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { - throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); + eq("zpallet", param.getBarcode())) > 0) { + throw new CoolException(param.getBarcode() + "鏉$爜宸茬粍鎵�"); } try{ param.setOrderNo(param.getCombMats().get(0).getOrderNo()); @@ -106,12 +106,16 @@ } int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); + int countLoc2 = manLocDetlMapper.selectCount(new EntityWrapper<ManLocDetl>().eq("zpallet",param.getBarcode())); WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); if (wrkMast != null && wrkMast.getIoType() < 100){ throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); } if (countLoc > 0 ) { + throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); + } + if (countLoc2 > 0 ) { throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); } @@ -175,11 +179,11 @@ } Double anfme = orderDetl.getAnfme(); Double workQty = orderDetl.getWorkQty(); - BigDecimal a1 = new BigDecimal(orderDetl.getAnfme()); - BigDecimal b1 = new BigDecimal(orderDetl.getWorkQty()); - BigDecimal c1 = new BigDecimal(combMat.getAnfme()); + BigDecimal a1 = new BigDecimal(orderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); + BigDecimal b1 = new BigDecimal(orderDetl.getWorkQty()).setScale(2,BigDecimal.ROUND_HALF_UP); + BigDecimal c1 = new BigDecimal(combMat.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); double e1 = b1.add(c1).doubleValue(); - BigDecimal f1 = new BigDecimal(e1); + BigDecimal f1 = new BigDecimal(e1).setScale(2,BigDecimal.ROUND_HALF_UP); Double d1 = a1.subtract(f1).doubleValue(); if ( d1 < 0.0) { throw new CoolException("缁勬墭鏁伴噺宸茶秴鍑鸿鍗曢渶姹傞噺锛岃妫�鏌ユ槸鍚︽湁鍏朵粬鐨勭粍鎵樺凡瀹屾垚"); @@ -556,12 +560,23 @@ if (orderDetl.getAnfme() - (jsonOrderDetl.getAnfme() + orderDetl.getWorkQty()) < 0) { return R.error("鍏ュ簱鏁伴噺澶т簬鍙叆鏁伴噺"); } + + //鏌ヨ骞冲簱涓槸鍚︽湁涓�鏍风殑鐗╂枡鍙凤紝鏈夌殑璇濈洿鎺ュ鍔犳暟閲� ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),jsonOrderDetl.getBatch()); if (checkManLocDetl == null) { - ManLocDetl manLocDetl = new ManLocDetl(); Synchro.Copy(orderDetl, manLocDetl); + + BigDecimal decimal = BigDecimal.valueOf(jsonOrderDetl.getAnfme()).subtract(BigDecimal.valueOf(jsonOrderDetl.getAnfme()).setScale(0,BigDecimal.ROUND_DOWN)); + if (decimal.doubleValue() > 0){ + manLocDetl.setPrice(1.0); + }else { + manLocDetl.setPrice(2.0); + } + + + manLocDetl.setLocNo(node.getName()); manLocDetl.setNodeId(node.getId()); manLocDetl.setMatnr(orderDetl.getMatnr()); @@ -661,16 +676,16 @@ // if (jsonOrderDetl.getAnfme() > manPakOut.getAnfme()) { //鍒ゆ柇宸ヤ綔鏁伴噺鏄惁澶т簬鎷h揣鍗曠殑鏁伴噺 // return R.error("鍑哄簱鏁伴噺澶т簬鎷h揣鍗曟�绘暟閲�"); // } - BigDecimal a1 = new BigDecimal(manPakOut.getAnfme()); - BigDecimal b1 = new BigDecimal(manPakOut.getCount()); - Double c1 = a1.subtract(b1).doubleValue(); + BigDecimal a1 = new BigDecimal(manPakOut.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); + BigDecimal b1 = new BigDecimal(manPakOut.getCount()).setScale(2,BigDecimal.ROUND_HALF_UP); + Double c1 = a1.subtract(b1).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); if (jsonOrderDetl.getAnfme() > c1) { //鍒ゆ柇宸ヤ綔鏁伴噺鏄惁澶т簬鎷h揣鍗曞墿浣欏彲鍑虹殑鏁伴噺 return R.error("鍑哄簱鏁伴噺澶т簬鎷h揣鍗曞墿浣欏彲鍑烘暟閲�"); } - BigDecimal e1 = new BigDecimal(orderDetl.getWorkQty()); - BigDecimal f1 = new BigDecimal(orderDetl.getQty()); - Double g1 = e1.subtract(f1).doubleValue(); + BigDecimal e1 = new BigDecimal(orderDetl.getWorkQty()).setScale(2,BigDecimal.ROUND_HALF_UP); + BigDecimal f1 = new BigDecimal(orderDetl.getQty()).setScale(2,BigDecimal.ROUND_HALF_UP); + Double g1 = e1.subtract(f1).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); if ( g1 <jsonOrderDetl.getAnfme() ){ return R.error("鍑哄簱鏁伴噺澶т簬鍗曟嵁鍓╀綑鍙嚭鏁伴噺"); } @@ -688,8 +703,8 @@ if(jsonOrderDetl.getWeight() == null){ jsonOrderDetl.setWeight(0.0); } - Double finalQty = new BigDecimal(checkManLocDetl.getAnfme()).subtract(new BigDecimal(jsonOrderDetl.getAnfme())).doubleValue() ; - Double weight = new BigDecimal(checkManLocDetl.getWeight()).subtract(new BigDecimal(jsonOrderDetl.getWeight())).doubleValue() ; + Double finalQty = new BigDecimal(checkManLocDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ; + Double weight = new BigDecimal(checkManLocDetl.getWeight()).setScale(2,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(jsonOrderDetl.getWeight()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ; checkManLocDetl.setAnfme(finalQty); checkManLocDetl.setWeight(weight); if (weight < 0){ @@ -704,7 +719,7 @@ return R.error("淇敼骞冲簱鐗╂枡澶辫触锛�"); } } - orderDetl.setQty( new BigDecimal(orderDetl.getQty()).add(new BigDecimal(jsonOrderDetl.getAnfme())).doubleValue() ); + orderDetl.setQty( new BigDecimal(orderDetl.getQty()).setScale(2,BigDecimal.ROUND_HALF_UP).add(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ); orderDetl.setUpdateTime(date); orderDetlService.updateById(orderDetl); //鏇存柊璁㈠崟鐘舵�� @@ -727,7 +742,7 @@ manPakOut.setCount(0.0); } - manPakOut.setCount(new BigDecimal(manPakOut.getCount()).add(new BigDecimal(jsonOrderDetl.getAnfme())).doubleValue()); + manPakOut.setCount(new BigDecimal(manPakOut.getCount()).setScale(2,BigDecimal.ROUND_HALF_UP).add(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); if (!manPakOutService.update(manPakOut,manPakOutEntityWrapper)){ return R.error("鏇存柊鎷h揣鍗曞畬鎴愭暟鐩け璐�"); } @@ -791,8 +806,19 @@ if (node.equals(null)){ return R.error("鏈煡璇㈠埌搴撲綅淇℃伅"); } - Date date = new Date(); ManLocDetl manLocDetl = new ManLocDetl(); //鍒濆鍖栧簱瀛樺疄浣撶被 + //鑾峰彇缁勬墭灏忔暟浣� + BigDecimal decimal = BigDecimal.valueOf(waitPakin.getAnfme()).subtract(BigDecimal.valueOf(waitPakin.getAnfme()).setScale(0,BigDecimal.ROUND_DOWN)); + if (decimal.doubleValue() > 0){ + manLocDetl.setPrice(1.0); + }else { + manLocDetl.setPrice(2.0); + } + + + + Date date = new Date(); + manLocDetl.setLocNo(node.getName()); manLocDetl.setNodeId(node.getId()); manLocDetl.setZpallet(waitPakin.getZpallet()); @@ -858,4 +884,87 @@ } 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("璁㈠崟涓湭鏌ヨ鍒颁笅鏋舵暟鎹�"); + + } + EntityWrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<>(); + manLocDetlWrapper.eq("zpallet",jsonBarcode); + manLocDetlWrapper.eq("matnr",jsonManLocDetl.getMatnr()); + ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); + if (Cools.isEmpty(manLocDetl)){ + 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("宸ヤ綔鏁伴噺澶т簬璁㈠崟鏁伴噺"); + } + 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)){ + throw new RuntimeException("鍒犻櫎搴撳瓨鏄庣粏澶辫触"); + } + } else if (diffAnfme.doubleValue() > 0) { + manLocDetl.setAnfme(diffAnfme.doubleValue()); + if (!manLocDetlService.update(manLocDetl,manLocDetlWrapper)){ + throw new RuntimeException("鏇存柊搴撳瓨鏄庣粏澶辫触"); + } + } + orderDetl.setQty(diffQty.doubleValue()); + orderDetl.setWorkQty(diffWorkQty.doubleValue()); + if (!orderDetlService.updateById(orderDetl)){ + 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