| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.*; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | 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.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.Synchro; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private ManLocDetlService manLocDetlService; |
| | | @Autowired |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private MatV2Service matV2Service; |
| | | @Override |
| | | @Transactional |
| | | public void comb(CombParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | if(param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)){ |
| | | throw new CoolException("入库物料数量不能为空"); |
| | | } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | |
| | | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | if (Cools.isEmpty(mat)) { |
| | | MatV2 matV2 = matV2Service.selectOne(new EntityWrapper<MatV2>().eq("matnr", detlDto.getMatnr())); |
| | | if(Cools.isEmpty(matV2)){ |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | waitPakin.sync(matV2); |
| | | waitPakin.setBrand("组件"); |
| | | } else { |
| | | waitPakin.sync(mat); |
| | | } |
| | | waitPakin.setBatch(detlDto.getBatch()); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | |
| | | return R.error("该订单是出库订单,无法入库"); |
| | | } |
| | | |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("order_no", jsonOrderDetl.getOrderNo()) |
| | | .and() |
| | | .eq("maktx",jsonOrderDetl.getMaktx())); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(jsonOrderDetl.getOrderNo(),jsonOrderDetl.getMatnr(),jsonOrderDetl.getBatch()); |
| | | if (Cools.isEmpty(orderDetl)) { |
| | | return R.error("单据明细有误,请检查"); |
| | | } |
| | | if (Cools.isEmpty(orderDetl.getAnfme())) { |
| | | return R.error("数量为空!"); |
| | | } |
| | | if (orderDetl.getAnfme() - (jsonOrderDetl.getAnfme() + orderDetl.getWorkQty()) < 0) { |
| | | return R.error("入库数量大于可入数量"); |
| | | } |
| | | ManLocDetl checkManLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>() |
| | | .eq("loc_no", jsonLocNo) |
| | | .eq("matnr", orderDetl.getMatnr()) |
| | | .eq("batch",orderDetl.getBatch())); |
| | | //查询平库中是否有一样的物料号,有的话直接增加数量 |
| | | ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),jsonOrderDetl.getBatch()); |
| | | if (checkManLocDetl == null) { |
| | | ManLocDetl manLocDetl = new ManLocDetl(); |
| | | Synchro.Copy(orderDetl, manLocDetl); |
| | |
| | | manLocDetl.setModiTime(date); |
| | | manLocDetl.setCreateTime(date); |
| | | manLocDetl.setBatch(jsonOrderDetl.getBatch()); |
| | | manLocDetlService.insert(manLocDetl); |
| | | if(!manLocDetlService.insert(manLocDetl)){ |
| | | return R.error("修改平库物料失败!"); |
| | | } |
| | | } else { |
| | | checkManLocDetl.setAnfme(checkManLocDetl.getAnfme() + jsonOrderDetl.getAnfme()); |
| | | checkManLocDetl.setModiTime(date); |
| | | manLocDetlService.update(checkManLocDetl, new EntityWrapper<ManLocDetl>() |
| | | .eq("loc_no", jsonLocNo) |
| | | .eq("matnr", orderDetl.getMatnr())); |
| | | if(manLocDetlService.increase(checkManLocDetl.getAnfme() + jsonOrderDetl.getAnfme(), jsonOrderDetl.getOrderNo(), jsonOrderDetl.getMaktx(), jsonOrderDetl.getBatch())<=0){ |
| | | return R.error("修改平库物料失败!"); |
| | | } |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty() + jsonOrderDetl.getAnfme()); |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + jsonOrderDetl.getAnfme()); |
| | |
| | | if (Cools.isEmpty(node, order)) { |
| | | return R.error("参数为空"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>() |
| | | .eq("order_no", jsonOrderDetl.getOrderNo()) |
| | | .and() |
| | | .eq("maktx",jsonOrderDetl.getMaktx()) |
| | | .and() |
| | | .eq("batch",jsonOrderDetl.getBatch())); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(jsonOrderDetl.getOrderNo(),jsonOrderDetl.getMatnr(),jsonOrderDetl.getBatch()); |
| | | if (Cools.isEmpty(orderDetl)) { |
| | | return R.error("单据明细有误,请检查"); |
| | | } |
| | | if (jsonOrderDetl.getAnfme() > (orderDetl.getAnfme() - orderDetl.getWorkQty())) { |
| | | return R.error("出库数量大于单据可出数量"); |
| | | } |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>() |
| | | .eq("loc_no", jsonLocNo) |
| | | .and() |
| | | .eq("maktx", jsonOrderDetl.getMaktx()) |
| | | .and() |
| | | .eq("batch",jsonOrderDetl.getBatch())); |
| | | if (manLocDetl == null) { |
| | | //查询平库中是否有一样的物料号 |
| | | ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),orderDetl.getBatch()); |
| | | if (checkManLocDetl == null) { |
| | | return R.error("该库位没有出库的物料信息"); |
| | | } |
| | | if (jsonOrderDetl.getAnfme() > manLocDetl.getAnfme()) { |
| | | if (jsonOrderDetl.getAnfme() > checkManLocDetl.getAnfme()) { |
| | | return R.error("出库数量大于可出数量"); |
| | | } |
| | | Double finalQty = manLocDetl.getAnfme() - jsonOrderDetl.getAnfme(); |
| | | Double finalQty = checkManLocDetl.getAnfme() - jsonOrderDetl.getAnfme(); |
| | | if (finalQty <= 0){ |
| | | manLocDetlService.delete(new EntityWrapper<ManLocDetl>() |
| | | .eq("loc_no", jsonLocNo) |
| | | .and() |
| | | .eq("matnr", orderDetl.getMatnr()) |
| | | .and() |
| | | .eq("batch",jsonOrderDetl.getBatch())); |
| | | if(manLocDetlService.deleteDatailed(jsonLocNo, jsonOrderDetl.getMatnr(), jsonOrderDetl.getBatch())<=0){ |
| | | return R.error("修改平库物料失败!"); |
| | | } |
| | | }else { |
| | | manLocDetl.setAnfme(finalQty); |
| | | manLocDetl.setModiTime(date); |
| | | manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>() |
| | | .eq("loc_no", jsonLocNo) |
| | | .eq("matnr", orderDetl.getMatnr()) |
| | | .and() |
| | | .eq("batch",jsonOrderDetl.getBatch())); |
| | | if(manLocDetlService.increase(finalQty, jsonLocNo, jsonOrderDetl.getMatnr(), jsonOrderDetl.getBatch())<=0){ |
| | | return R.error("修改平库物料失败!"); |
| | | } |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty() + jsonOrderDetl.getAnfme()); |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + jsonOrderDetl.getAnfme()); |
| | |
| | | return R.ok("下架完成"); |
| | | } |
| | | |
| | | |
| | | } |