| | |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | 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.OffSaleParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | // if(param.getCombMats().size()>1){ |
| | | // throw new CoolException("response.extract_one_product_or_refresh"); |
| | | // } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | throw new CoolException("response.data_processing_inbound"); |
| | | } |
| | | |
| | | if(param.getBarcode().length()!=8){ |
| | | throw new CoolException("response.barcode_length_invalid"); |
| | | } |
| | | // if (param.getCombMats().size()>1){ |
| | | // throw new CoolException("response.mix_material_not_allowed"); |
| | | // } |
| | | |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | if (countLoc > 0 || countWrk > 0) { |
| | | throw new CoolException("工作档/库存条码数据已存在===>>" + param.getBarcode()); |
| | | int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode())); |
| | | if (countLoc > 0 || countWrk > 0 || countwait > 0) { |
| | | throw new CoolException("response.pallet_data_exists"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | throw new CoolException("response.material_not_exist"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | throw new CoolException("response.save_wait_pakin_failed"); |
| | | } |
| | | } |
| | | // 关联组托 |
| | | } else { |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("response.order_expired"); |
| | | } |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | throw new CoolException("response.inbound_qty_invalid"); |
| | | } |
| | | // 修改订单作业数量 |
| | | if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | throw new CoolException("修改单据作业数量失败"); |
| | | throw new CoolException("response.update_doc_qty_failed"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | throw new CoolException("response.material_not_exist"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | throw new CoolException("response.save_wait_pakin_failed"); |
| | | } |
| | | } |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void cartonComb(List<CombCartonParam> params, Long userId) { |
| | | for (CombCartonParam param : params) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCartons())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException("response.data_processing_inbound"); |
| | | } |
| | | |
| | | if(param.getBarcode().length()!=8){ |
| | | throw new CoolException("response.barcode_length_invalid"); |
| | | } |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode())); |
| | | if (countLoc > 0 || countWrk > 0 || countwait > 0) { |
| | | throw new CoolException("response.pallet_data_exists"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("response.order_expired"); |
| | | } |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCartons().forEach(elem -> { |
| | | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),elem.getCartonLabel()); |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException("response.inbound_qty_invalid"); |
| | | } |
| | | // 修改订单作业数量 |
| | | if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCartonLabel())) { |
| | | throw new CoolException("response.update_doc_qty_failed"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCartonLabel()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCartonLabel()); |
| | | assert one != null; |
| | | one.setAreaId(param.getZoneId()); |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException("response.material_not_exist"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("order_no",order.getOrderNo()) |
| | | .eq("matnr",mat.getMatnr()) |
| | | .eq("barcode",detlDto.getCartonLabel())); |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.sync(orderDetl); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setAreaId(param.getZoneId()); //区域 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("response.save_wait_pakin_failed"); |
| | | } |
| | | } |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public OrderDetl cartonScan(ScanParam scanParam , Long userId) { |
| | | String cartonLabel = scanParam.getCartonLabel(); |
| | | if(cartonLabel == null){ |
| | | throw new CoolException("Label can not be null"); |
| | | } |
| | | List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("barcode",cartonLabel)); |
| | | if(waitPakins.size() > 0){ |
| | | throw new CoolException("Label has already been in system"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("barcode",cartonLabel)); |
| | | if(orderDetl == null){ |
| | | throw new CoolException("OrderDetl can not be found"); |
| | | } |
| | | return orderDetl; |
| | | } |
| | | |
| | | // 商品上架 |
| | |
| | | String locno = param.getLocno(); |
| | | Node node = nodeService.selectByUuid(locno); |
| | | if (Cools.isEmpty(node)) { |
| | | throw new CoolException(param.getLocno() + ":库位不存在"); |
| | | throw new CoolException("response.location_not_exist"); |
| | | } |
| | | |
| | | // 获取商品列表 |
| | | for(CombParam.CombMat combMat : param.getCombMats()){ |
| | | Mat mat = matService.selectByMatnr(combMat.getMatnr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | throw new CoolException(combMat.getMatnr() + ":商品档案不存在!"); |
| | | throw new CoolException("response.material_not_exist"); |
| | | } |
| | | if (Cools.isEmpty(combMat.getAnfme()) || combMat.getAnfme()==0){ |
| | | throw new CoolException(combMat.getMatnr() + ":商品数量有误!"); |
| | | throw new CoolException("response.material_qty_error"); |
| | | } |
| | | if (Cools.isEmpty(combMat.getBatch())){ |
| | | // throw new CoolException(combMat.getMatnr() + ":商品批号有误!"); |
| | |
| | | manLocDetl.setAnfme(combMat.getAnfme()); |
| | | manLocDetl.setModiTime(now); |
| | | if (!manLocDetlService.insert(manLocDetl)) { |
| | | throw new CoolException("商品上架失败!"); |
| | | throw new CoolException("response.putaway_failed"); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void offSale(OffSaleParam offSaleParam) { |
| | | ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); |
| | | if (Cools.isEmpty(manLocDetl)){ |
| | | throw new CoolException("无此商品!"); |
| | | throw new CoolException("response.no_such_product"); |
| | | } |
| | | double anfme = manLocDetl.getAnfme() - offSaleParam.getAnfme(); |
| | | if (anfme < 0) { |
| | | throw new CoolException("商品库存不足!"); |
| | | throw new CoolException("response.stock_insufficient"); |
| | | } else if (anfme == 0){ |
| | | manLocDetlMapper.deleteLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); |
| | | } |
| | |
| | | public void adjust(MobileAdjustParam param, Long userId) { |
| | | BasDevp basDevp = basDevpService.selectById(param.getStaNo()); |
| | | if (null == basDevp || basDevp.getWrkNo() == null) { |
| | | throw new CoolException(param.getStaNo() + "盘点站无效"); |
| | | throw new CoolException("response.stocktake_station_invalid"); |
| | | } |
| | | if (!param.getWrkNo().equals(basDevp.getWrkNo())) { |
| | | throw new CoolException(param.getStaNo() + "盘点站更新,请重新检索"); |
| | | throw new CoolException("response.stocktake_station_updated"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectById(param.getWrkNo()); |
| | | if (wrkMast.getWrkSts() < 10) { |
| | | throw new CoolException("盘点无效,任务已盘点再入库"); |
| | | throw new CoolException("response.stocktake_invalid_re_inbound"); |
| | | } |
| | | Date now = new Date(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | |
| | | // todo 盘点记录、保存调整记录 |
| | | // 修改明细 |
| | | if (!wrkDetlService.updateAnfme(wrkDetl1.getAnfme(), wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "批号修改数量失败"); |
| | | throw new CoolException("response.stocktake_update_qty_failed"); |
| | | } |
| | | } |
| | | iterator.remove(); |
| | |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | // todo 盘点记录、保存调整记录 |
| | | if (!wrkDetlService.updateAnfme(-1.0D, wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) { |
| | | throw new CoolException("删除" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "批号任务明细失败"); |
| | | throw new CoolException("response.delete_stocktake_detail_failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("添加" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "批号任务明细失败"); |
| | | throw new CoolException("response.add_stocktake_detail_failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("修改盘点任务主档失败"); |
| | | throw new CoolException("response.update_stocktake_master_failed"); |
| | | } |
| | | |
| | | } |
| | |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | throw new CoolException("response.data_processing_inbound"); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | |
| | | if (packDown) { |
| | | Pack pack = packService.selectByBarcode(elem.getMatnr()); |
| | | if (pack == null) { |
| | | throw new CoolException(elem.getMatnr() + "条码冗余,请检查!"); |
| | | throw new CoolException("response.barcode_redundant"); |
| | | } |
| | | if (pack.getSettle() != 1) { |
| | | throw new CoolException(elem.getMatnr() + "条码已下线,请检查!"); |
| | | throw new CoolException("response.barcode_offline"); |
| | | } |
| | | } |
| | | Mat analyse = MatUtils.analyseMat(elem.getMatnr()); |
| | |
| | | throw new CoolException(jsonObject.getString("msg")); |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); |
| | | throw new CoolException("上报mes系统失败"); |
| | | throw new CoolException("response.report_mes_failed"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | |
| | | OpenOrderPakinParam openParam = new OpenOrderPakinParam(); |
| | | openParam.setOrderNo(orderNo); |
| | | openParam.setOrderTime(DateUtils.convert(now)); |
| | | openParam.setOrderType("打包入库单"); |
| | | openParam.setOrderType("response.package_inbound_order_type"); |
| | | openParam.setOrderDetails(detlDtos); |
| | | openService.pakinOrderCreate(openParam); |
| | | Order order = orderService.selectByNo(orderNo); |
| | | if (null == order) { |
| | | throw new CoolException("生成单据失败"); |
| | | throw new CoolException("response.generate_order_failed"); |
| | | } |
| | | if (!orderService.updateSettle(order.getId(), 2L, userId)) { |
| | | throw new CoolException("修改单据状态失败"); |
| | | throw new CoolException("response.update_order_status_failed"); |
| | | } |
| | | |
| | | // 生成入库通知档 |
| | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch()); |
| | | if (detlDto.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | throw new CoolException("response.inbound_qty_invalid"); |
| | | } |
| | | // 修改订单作业数量 |
| | | if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) { |
| | | throw new CoolException("修改单据作业数量失败"); |
| | | throw new CoolException("response.update_doc_qty_failed"); |
| | | } |
| | | |
| | | // 保存入库通知档 |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | throw new CoolException("response.material_not_exist"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | throw new CoolException("response.save_wait_pakin_failed"); |
| | | } |
| | | // 修改打包数据状态 |
| | | Pack pack = packService.selectByBarcode(detlDto.getOrderNo()); |
| | |
| | | pack.setUpdateTime(now); |
| | | pack.setUpdateBy(userId); |
| | | if (!packService.updateById(pack)) { |
| | | throw new CoolException("修改打包数据异常"); |
| | | throw new CoolException("response.update_pack_data_exception"); |
| | | } |
| | | } |
| | | |
| | |
| | | //根据订单号生成出库任务工作档 |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo)); |
| | | if (order.getSettle() != 1 && order.getSettle() != 2){ |
| | | throw new CoolException("该订单已处理"); |
| | | throw new CoolException("response.order_processed"); |
| | | } |
| | | |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo)); |
| | |
| | | //查询所有库位状态为F的库位信息 |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(),orderDetl.getBatch(),null,null); |
| | | if (locDetls.size() == 0) { |
| | | throw new CoolException("库存中没有该物料"); |
| | | throw new CoolException("response.material_not_in_stock"); |
| | | } |
| | | for(LocDetl locDetl : locDetls){ |
| | | //如果该库位出库路线所用的堆垛机out_enable不为Y,跳过该循环 |
| | |
| | | order.setUpdateBy(userId); |
| | | order.setUpdateTime(now); |
| | | if(!orderService.update(order, new EntityWrapper<Order>().eq("order_no", orderNo))){ |
| | | throw new CoolException("更新订单状态失败"); |
| | | throw new CoolException("response.update_order_status_failed"); |
| | | } |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + curOutQty); |
| | | orderDetl.setUpdateBy(userId); |
| | |
| | | wrapper.eq("batch", orderDetl.getBatch()); |
| | | } |
| | | if(!orderDetlService.update(orderDetl, wrapper)){ |
| | | throw new CoolException("更新订单明细失败"); |
| | | throw new CoolException("response.update_order_detail_failed"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("出库路径不存在"); |
| | | throw new CoolException("response.outbound_path_not_exist"); |
| | | } |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(2); |
| | |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:" + locDetl.getLocNo()); |
| | | throw new CoolException("response.save_work_master_failed_loc"); |
| | | } |
| | | |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | throw new CoolException("response.save_work_detail_failed"); |
| | | } |
| | | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:" + locDetl.getLocNo()); |
| | | throw new CoolException("response.reserve_loc_status_failed"); |
| | | } |
| | | } else { |
| | | throw new CoolException(locDetl.getLocNo() + "库位不是在库状态"); |
| | | throw new CoolException("response.loc_not_in_stock_status"); |
| | | } |
| | | } |
| | | } |