|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.CombParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.MobileAdjustParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.ModifyPakoutParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.NodePakoutParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.result.MobileAdjustResult; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.common.model.WrkDto; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import com.zy.system.entity.User; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | 
|---|
|  |  |  | private BasDevpService basDevpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PackService packService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ManLocDetlTempService manLocDetlTempService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocRuleService locRuleService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NodeService nodeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 组托 ---------------------------------------------------------------------------------------------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping("/order/search/orderNo/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R orderSearchByBarcode(@RequestParam String orderNo){ | 
|---|
|  |  |  | Order order = orderService.selectByNo(orderNo); | 
|---|
|  |  |  | if (order == null) { | 
|---|
|  |  |  | if (Cools.isEmpty(orderNo)){ | 
|---|
|  |  |  | orderNo=null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Order> orders = orderService.selectorderNoL(orderNo); | 
|---|
|  |  |  | if (Cools.isEmpty(orders)){ | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DocType docType = docTypeService.selectById(order.getDocType()); | 
|---|
|  |  |  | if (docType.getPakin() == null || docType.getPakin() != 1) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | LinkedList<CombParam> combParams = new LinkedList<>(); | 
|---|
|  |  |  | if (!Cools.isEmpty(orders)){ | 
|---|
|  |  |  | for (Order order:orders){ | 
|---|
|  |  |  | CombParam combParam=new CombParam(); | 
|---|
|  |  |  | if (order == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DocType docType = docTypeService.selectById(order.getDocType()); | 
|---|
|  |  |  | if (docType.getPakin() == null || docType.getPakin() != 1) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (order.getSettle() > 2) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); | 
|---|
|  |  |  | if (!Cools.isEmpty(orderDetls)) { | 
|---|
|  |  |  | LinkedList<CombParam.CombMat> combMats = new LinkedList<>(); | 
|---|
|  |  |  | for (OrderDetl orderDetl:orderDetls){ | 
|---|
|  |  |  | CombParam.CombMat combMat = new CombParam.CombMat(); | 
|---|
|  |  |  | combMat.setMatnr(orderDetl.getMatnr()); | 
|---|
|  |  |  | combMat.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | combMat.setAnfme(orderDetl.getAnfme()-orderDetl.getQty()); | 
|---|
|  |  |  | combMat.setMaktx(orderDetl.getMaktx()); | 
|---|
|  |  |  | combMat.setSpecs(orderDetl.getSpecs()); | 
|---|
|  |  |  | combMat.setCsocode(orderDetl.getThreeCode()); | 
|---|
|  |  |  | combMat.setIsoseq(orderDetl.getDeadTime()); | 
|---|
|  |  |  | combMats.add(combMat); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | combParam.setCombMats(combMats); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | combParam.setOrderNo(order.getOrderNo()); | 
|---|
|  |  |  | combParams.add(combParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (order.getSettle() > 2) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetls)) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(orderDetls); | 
|---|
|  |  |  | return R.ok().add(combParams); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "组托") | 
|---|
|  |  |  | //    @ManagerAuth(memo = "组托") | 
|---|
|  |  |  | public R comb(@RequestBody CombParam combParam){ | 
|---|
|  |  |  | mobileService.comb(combParam, getUserId()); | 
|---|
|  |  |  | mobileService.comb(combParam, 1l); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 出库确认 - 扫托盘码 | 
|---|
|  |  |  | * 出库确认 - 扫货架码 | 
|---|
|  |  |  | * 1.全板 返回 101 | 
|---|
|  |  |  | * 2.拣料 返回 103 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | if (wrkMast != null) { | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | // 去除已出库确认的明细 | 
|---|
|  |  |  | wrkDetls.removeIf(wrkDetl -> wrkDetl.getInspect() == 1); | 
|---|
|  |  |  | wrkDetls.removeIf(wrkDetl -> wrkDetl.getInspect() != null && wrkDetl.getInspect() != 0); | 
|---|
|  |  |  | return R.ok().add(Cools.add("wrkNo", wrkMast.getWrkNo()).add("ioType", wrkMast.getIoType()).add("list", wrkDetls)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("盘点成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 平库 库位推荐 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/node/recommend/loc") | 
|---|
|  |  |  | //@ManagerAuth(memo = "库位推荐") | 
|---|
|  |  |  | public R recommendNodeLoc(@RequestBody HashMap<String,String> param){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String zpallet = param.get("zpallet"); | 
|---|
|  |  |  | List<WaitPakin> waitPakinList = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", zpallet)); | 
|---|
|  |  |  | for (WaitPakin waitPakin : waitPakinList){ | 
|---|
|  |  |  | List<LocRule> locRules = locRuleService.find(waitPakin.getMatnr()); | 
|---|
|  |  |  | if(!Cools.isEmpty(locRules)){ | 
|---|
|  |  |  | if(!Cools.isEmpty(findNodeLoc(locRules))){ | 
|---|
|  |  |  | return R.ok(findNodeLoc(locRules)).add(waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet",zpallet))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!Cools.isEmpty(waitPakin.getBrand())){ | 
|---|
|  |  |  | List<LocRule> locCodeRules = locRuleService.find(waitPakin.getBrand().substring(0, 4)); | 
|---|
|  |  |  | if(!Cools.isEmpty(locRules)){ | 
|---|
|  |  |  | if(!Cools.isEmpty(findNodeLoc(locRules))){ | 
|---|
|  |  |  | return R.ok(findNodeLoc(locRules)).add(waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet",zpallet))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("").add(waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet",zpallet))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 平库 订单上架 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/node/puttway") | 
|---|
|  |  |  | //@ManagerAuth(memo = "订单上架") | 
|---|
|  |  |  | public R putway(@RequestBody HashMap<String,String> params){ | 
|---|
|  |  |  | String zpallet = params.get("zpallet"); | 
|---|
|  |  |  | String locNo = params.get("locNo"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mobileService.nodePutway(zpallet,locNo,new User()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("订单上架成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 平库 订单下架 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/node/pakout") | 
|---|
|  |  |  | public R nodePakout(@RequestBody NodePakoutParam param){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mobileService.nodePakout(param,new User()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("订单下架成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 平库临时上架 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("/node/putway1") | 
|---|
|  |  |  | public R putway1(@RequestBody CombParam combParam){ | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | List<CombParam.CombMat> combMats = combParam.getCombMats(); | 
|---|
|  |  |  | combMats.forEach(combMat -> { | 
|---|
|  |  |  | if(Cools.isEmpty(combMat.getBatch())){ | 
|---|
|  |  |  | combMat.setBatch("-1"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ManLocDetlTemp manLocDetlTemp = manLocDetlTempService.selectOne(new EntityWrapper<ManLocDetlTemp>() | 
|---|
|  |  |  | .eq("matnr", combMat.getMatnr()) | 
|---|
|  |  |  | .eq("batch",combMat.getBatch())); | 
|---|
|  |  |  | if(Cools.isEmpty(manLocDetlTemp)){ | 
|---|
|  |  |  | manLocDetlTemp = new ManLocDetlTemp(); | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(combMat.getMatnr()); | 
|---|
|  |  |  | BeanUtils.copyProperties(mat,manLocDetlTemp); | 
|---|
|  |  |  | manLocDetlTemp.setLocNo("A-010101"); | 
|---|
|  |  |  | manLocDetlTemp.setAnfme(combMat.getAnfme()); | 
|---|
|  |  |  | manLocDetlTemp.setBatch(combMat.getBatch()); | 
|---|
|  |  |  | manLocDetlTemp.setCreateTime(now); | 
|---|
|  |  |  | manLocDetlTemp.setModiTime(now); | 
|---|
|  |  |  | manLocDetlTempService.insert(manLocDetlTemp); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | manLocDetlTemp.setAnfme(manLocDetlTemp.getAnfme()+combMat.getAnfme()); | 
|---|
|  |  |  | manLocDetlTempService.update(manLocDetlTemp,new EntityWrapper<ManLocDetlTemp>() | 
|---|
|  |  |  | .eq("matnr", combMat.getMatnr()) | 
|---|
|  |  |  | .eq("batch",combMat.getBatch())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("上架成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/check/waitPakin/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "查询货架是否组托") | 
|---|
|  |  |  | public R waitPakins(@RequestBody String barcode){ | 
|---|
|  |  |  | return R.ok().add(waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/untie/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "解绑") | 
|---|
|  |  |  | public R untie(@RequestBody String barcode){ | 
|---|
|  |  |  | List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); | 
|---|
|  |  |  | for (WaitPakin waitPakin : waitPakins) { | 
|---|
|  |  |  | if (!waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", barcode))) { | 
|---|
|  |  |  | return R.error("解绑失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(waitPakins); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/wrkdetl/auth") | 
|---|
|  |  |  | //@ManagerAuth(memo = "拣料信息") | 
|---|
|  |  |  | public R checkWrkDetl(@RequestBody String barcode){ | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectByBarcode(barcode); | 
|---|
|  |  |  | if(Cools.isEmpty(wrkMast)){ | 
|---|
|  |  |  | return R.error("该货架没有工作档"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | return R.ok().add(wrkDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/modify/wrkdetl/auth") | 
|---|
|  |  |  | //@ManagerAuth(memo = "修改拣料信息") | 
|---|
|  |  |  | public R modifyWrkDetl(@RequestBody ModifyPakoutParam param){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String barcode = param.getBarcode(); | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectByBarcode(barcode); | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Double allPakoutAnfme = 0.0; | 
|---|
|  |  |  | Double allModifyPakoutAnfme = 0.0; | 
|---|
|  |  |  | for (WrkDetl wrkDetl : wrkDetls){ | 
|---|
|  |  |  | allPakoutAnfme += wrkDetl.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (ModifyPakoutParam.CA ca : param.getParams()){ | 
|---|
|  |  |  | allModifyPakoutAnfme += ca.getAnfme(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!allPakoutAnfme.equals(allModifyPakoutAnfme)){ | 
|---|
|  |  |  | return R.error("修改后拣料的数量与原数量不符合,请重新核对拣料数量"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mobileService.modifyWrkDetl(wrkDetls,param.getParams(),getUserId()); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //平库上架(无组托上架) | 
|---|
|  |  |  | @RequestMapping("/node/pakin/v1") | 
|---|
|  |  |  | public R nodePakinNoComb(@RequestBody CombParam param){ | 
|---|
|  |  |  | mobileService.nodePakinNoComb(param); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String findNodeLoc(List<LocRule> locRules){ | 
|---|
|  |  |  | for (LocRule locRule : locRules) { | 
|---|
|  |  |  | if (Cools.isEmpty(locRule.getOther())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | EntityWrapper<Node> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.between("row1", locRule.getRowBeg(), locRule.getRowEnd()) | 
|---|
|  |  |  | .between("bay1", locRule.getBayBeg(), locRule.getBayEnd()) | 
|---|
|  |  |  | .between("lev1", locRule.getLevBeg(), locRule.getLevEnd()) | 
|---|
|  |  |  | .eq("parent_name", locRule.getOther()) | 
|---|
|  |  |  | .eq("status", "1"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Node node = nodeService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(node)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return node.getName(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|