| | |
| | | // } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | eq("zpallet", param.getBarcode())) > 0) { |
| | | throw new CoolException(param.getBarcode() + "条码已组托"); |
| | | } |
| | | try{ |
| | | param.setOrderNo(param.getCombMats().get(0).getOrderNo()); |
| | |
| | | } |
| | | |
| | | 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()); |
| | | } |
| | | |
| | |
| | | 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()); |
| | |
| | | } |
| | | 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; |
| | | } |
| | | } |