| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | 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.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.WorkLogHandler; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.SaasUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | 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.utils.HttpHandler; |
| | | import com.zy.system.entity.User; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private PackService packService; |
| | | @Autowired |
| | | private OpenService openService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private WorkLogHandler workLogHandler; |
| | | @Autowired |
| | | private ManLocDetlService manLocDetlService; |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private ManPakOutService manPakOutService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void comb(CombParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | // if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | // throw new CoolException(BaseRes.PARAM); |
| | | // } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | |
| | | //判断托盘是否已经在库 |
| | | if (locDetlService.selectCount(new EntityWrapper<LocDetl>() |
| | | .eq("zpallet", param.getBarcode())) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据已经在库"); |
| | | } |
| | | |
| | | //判断是否存在料箱码 => 存在料箱码则要求提交上来的物料list必须全部都有料箱码 |
| | | boolean hasContainerCode = false; |
| | | int containerCodeCount = 0;//料箱码数量 |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | if (combMat.getContainerCode() != null) { |
| | | hasContainerCode = true; |
| | | containerCodeCount++; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | //判断料箱是否已经出现在入库通知档、库存中 |
| | | if (hasContainerCode) { |
| | | if (containerCodeCount != param.getCombMats().size()) { |
| | | throw new CoolException(param.getBarcode() + "托盘有" + (param.getCombMats().size()-containerCodeCount) + "个未扫描的料箱"); |
| | | } |
| | | |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | //判断料箱是否正在入库 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("supp_code", combMat.getContainerCode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(combMat.getContainerCode() + "料箱正在进行入库"); |
| | | } |
| | | |
| | | //判断料箱是否已经在库 |
| | | if (locDetlService.selectCount(new EntityWrapper<LocDetl>() |
| | | .eq("supp_code", combMat.getContainerCode())) > 0) { |
| | | throw new CoolException(combMat.getContainerCode() + "料箱已经在库"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // todo: 不下线重新入库 |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); |
| | | if (wrkMast != null && wrkMast.getWrkSts() == 18) { |
| | | ReturnT<String> start = workLogHandler.start(wrkMast); |
| | | if (!start.isSuccess()) { |
| | | log.error("工作档[workNo={}]历史档处理失败", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | |
| | | // 无单组托 |
| | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), elem.getCsocode(), elem.getIsoseq(),elem.getContainerCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | |
| | | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | |
| | | waitPakin.setThreeCode(detlDto.getCsocode()); |
| | | waitPakin.setDeadTime(detlDto.getIsoseq()); |
| | | waitPakin.setSuppCode(detlDto.getContainerCode()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | |
| | | param.getCombMats().forEach(elem -> { |
| | | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),elem.getCsocode(),elem.getIsoseq()); |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单明细数量 |
| | | if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq(),elem.getContainerCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 批号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | |
| | | waitPakin.setThreeCode(detlDto.getCsocode()); |
| | | waitPakin.setDeadTime(detlDto.getIsoseq()); |
| | | waitPakin.setSuppCode(detlDto.getContainerCode()); |
| | | |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void adjust(MobileAdjustParam param, Long userId) { |
| | | BasDevp basDevp = basDevpService.selectById(param.getStaNo()); |
| | | if (null == basDevp || basDevp.getWrkNo() == null) { |
| | |
| | | if (wrkMast.getWrkSts() < 10) { |
| | | throw new CoolException("盘点无效,任务已盘点再入库"); |
| | | } |
| | | Date now = new Date(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | |
| | | List<WrkDetl> list = param.getWrkDetls(); |
| | | |
| | | // 修改数量 |
| | | Iterator<WrkDetl> iterator = wrkDetls.iterator(); |
| | | while (iterator.hasNext()) { |
| | | WrkDetl wrkDetl = iterator.next(); |
| | | Iterator<WrkDetl> iterator1 = list.iterator(); |
| | | while (iterator1.hasNext()) { |
| | | WrkDetl wrkDetl1 = iterator1.next(); |
| | | if (wrkDetl1.getAnfme() == 0) { |
| | | iterator1.remove(); |
| | | } |
| | | if (wrkDetl.getMatnr().equals(wrkDetl1.getMatnr()) && Cools.eq(wrkDetl.getBatch(), wrkDetl1.getBatch())) { |
| | | if (!wrkDetl.getAnfme().equals(wrkDetl1.getAnfme())) { |
| | | // todo 盘点记录、保存调整记录 |
| | | // 修改明细 |
| | | if (!wrkDetlService.updateAnfme(wrkDetl1.getAnfme(), wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "序列码修改数量失败"); |
| | | } |
| | | } |
| | | iterator.remove(); |
| | | iterator1.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() + "序列码任务明细失败"); |
| | | } |
| | | } |
| | | |
| | | // 添加明细 |
| | | for (WrkDetl wrkDetl : list) { |
| | | if (wrkDetl.getAnfme() == 0.0D) { continue; } |
| | | // todo 盘点记录、保存调整记录 |
| | | String orderNo = wrkDetl.getOrderNo(); |
| | | Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); |
| | | wrkDetl.sync(mat); |
| | | wrkDetl.setOrderNo(orderNo); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("添加" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "序列码任务明细失败"); |
| | | } |
| | | } |
| | | |
| | | // 修改盘点任务主档状态 |
| | | wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0?"Y":"N"); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("修改盘点任务主档失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void packComb(CombParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | | boolean packDown = Parameter.get().getPackDown().equals("true"); |
| | | |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | // 打包上线数据校验 |
| | | if (packDown) { |
| | | Pack pack = packService.selectByBarcode(elem.getMatnr()); |
| | | if (pack == null) { |
| | | throw new CoolException(elem.getMatnr() + "条码冗余,请检查!"); |
| | | } |
| | | if (pack.getSettle() != 1) { |
| | | throw new CoolException(elem.getMatnr() + "条码已下线,请检查!"); |
| | | } |
| | | } |
| | | Mat analyse = MatUtils.analyseMat(elem.getMatnr()); |
| | | // 条码、物料代码、序列号、数量 |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq()); |
| | | // DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | detlDto.setContainerCode(elem.getContainerCode()); |
| | | |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | |
| | | if (packDown) { |
| | | MesCombParam mesCombParam = new MesCombParam(); |
| | | mesCombParam.setZpallet(param.getBarcode()); |
| | | mesCombParam.setPakinTime(DateUtils.convert(now)); |
| | | mesCombParam.setLgort("5008"); |
| | | mesCombParam.setPlantCode("5000"); |
| | | mesCombParam.setFromCode("5012-20"); |
| | | mesCombParam.setStationCode("JJQ-PFZPDB-XX"); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme())); |
| | | } |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setPath(MesConstant.PACK_DOWN_URL) |
| | | .setJson(JSON.toJSONString(mesCombParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | success = true; |
| | | } else if (jsonObject.getInteger("code").equals(500)) { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); |
| | | 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系统失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | throw new CoolException(e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "打包下线帮托上报", |
| | | MesConstant.URL + MesConstant.PACK_DOWN_URL, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(mesCombParam), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { log.error("", e); } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 生成入库单据 |
| | | String orderNo = "PACK" + snowflakeIdWorker.nextId(); |
| | | OpenOrderPakinParam openParam = new OpenOrderPakinParam(); |
| | | openParam.setOrderNo(orderNo); |
| | | openParam.setOrderTime(DateUtils.convert(now)); |
| | | openParam.setOrderType("打包入库单"); |
| | | openParam.setOrderDetails(detlDtos); |
| | | openService.pakinOrderCreate(openParam); |
| | | Order order = orderService.selectByNo(orderNo); |
| | | if (null == order) { |
| | | throw new CoolException("生成单据失败"); |
| | | } |
| | | if (!orderService.updateSettle(order.getId(), 2L, userId)) { |
| | | throw new CoolException("修改单据状态失败"); |
| | | } |
| | | |
| | | // 生成入库通知档 |
| | | for (DetlDto detlDto : detlDtos) { |
| | | |
| | | // 修改作业数量 ---------------------------------------- |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq()); |
| | | if (detlDto.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单明细数量 |
| | | if (!orderDetlService.increase(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme(),detlDto.getCsocode(),detlDto.getIsoseq())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | |
| | | // 保存入库通知档 |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(orderNo); |
| | | waitPakin.setBatch(detlDto.getBatch()); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | |
| | | waitPakin.setThreeCode(detlDto.getCsocode()); |
| | | waitPakin.setDeadTime(detlDto.getIsoseq()); |
| | | waitPakin.setSuppCode(detlDto.getContainerCode()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | // 修改打包数据状态 |
| | | Pack pack = packService.selectByBarcode(detlDto.getOrderNo()); |
| | | pack.setSettle(2L); |
| | | pack.setUpdateTime(now); |
| | | pack.setUpdateBy(userId); |
| | | if (!packService.updateById(pack)) { |
| | | throw new CoolException("修改打包数据异常"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | public void nodePutway(String zpallet, String locNo, User user) { |
| | | Date now = new Date(); |
| | | |
| | | //增加平库库存 |
| | | List<WaitPakin> waitPakinList = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", zpallet)); |
| | | |
| | | if(Cools.isEmpty(waitPakinList)){ |
| | | throw new CoolException("该托盘码未组托"); |
| | | } |
| | | |
| | | waitPakinList.forEach(waitPakin -> { |
| | | //料想码 |
| | | String containerCode = waitPakin.getSuppCode(); |
| | | //如果当前库位已存在货物 |
| | | Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", locNo).eq("matnr",waitPakin.getMatnr()); |
| | | Utils.wapperSetCondition(wrapper,"container_code",containerCode); |
| | | Utils.wapperSetCondition(wrapper,"batch",waitPakin.getBatch()); |
| | | Utils.wapperSetCondition(wrapper,"csocode",waitPakin.getThreeCode()); |
| | | Utils.wapperSetCondition(wrapper,"isoseq",waitPakin.getDeadTime()); |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(wrapper); |
| | | if(Cools.isEmpty(manLocDetl)){ |
| | | saveManlocDetl(waitPakin,now,locNo); |
| | | }else{ |
| | | manLocDetl.setAnfme(manLocDetl.getAnfme() + waitPakin.getAnfme()); |
| | | manLocDetlService.update(manLocDetl,wrapper); |
| | | |
| | | } |
| | | //生成平库入出库日志 |
| | | SaasUtils.insertLog(0,locNo,waitPakin.getMatnr(), waitPakin.getAnfme(),user.getUsername()); |
| | | |
| | | }); |
| | | Node node = nodeService.selectByUuid(locNo); |
| | | node.setStatus(0); |
| | | nodeService.updateById(node); |
| | | |
| | | //生成入库通知历史档 |
| | | waitPakinLogService.save(zpallet); |
| | | //删除入库通知档 |
| | | waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", zpallet)); |
| | | |
| | | orderService.checkComplete(waitPakinList.get(0).getOrderNo()); |
| | | |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | public void nodePakout(NodePakoutParam param, User user) { |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", param.getLocNo())); |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", param.getOrderNo())); |
| | | if (Cools.isEmpty(node, order)) { |
| | | throw new CoolException("参数为空"); |
| | | } |
| | | //查询当前物料的订单详情 |
| | | Wrapper<OrderDetl> orderDetlWrapper = new EntityWrapper<OrderDetl>().eq("order_no", param.getOrderNo()).eq(false, "status", 1); |
| | | Utils.wapperSetCondition(orderDetlWrapper,"three_code",param.getCsocode()); |
| | | Utils.wapperSetCondition(orderDetlWrapper,"dead_time",param.getIsoseq()); |
| | | Utils.wapperSetCondition(orderDetlWrapper,"matnr",param.getMatnr()); |
| | | |
| | | //Utils.confirmOnlyMat(orderDetlWrapper,param.getMatnr(),param.getCsocode(),param.getIsoseq()); |
| | | OrderDetl orderDetl = orderDetlService.selectOne(orderDetlWrapper); |
| | | //查询当前拣货单信息 |
| | | Wrapper<ManPakOut> manPakOutWrapper = new EntityWrapper<ManPakOut>().eq("wrk_no", param.getWrkNo()); |
| | | ManPakOut manPakOut = manPakOutService.selectOne(manPakOutWrapper); |
| | | if(Cools.isEmpty(manPakOut) || manPakOut.getStatus() == 1){ |
| | | throw new CoolException("当前拣货码已经完成拣货"); |
| | | } |
| | | //查询库存信息 |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocNo()); |
| | | Utils.confirmOnlyMat(manLocDetlWrapper,param.getMatnr(),param.getCsocode(),param.getIsoseq()); |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); |
| | | |
| | | //根据实际出库数量扣减库存 |
| | | if(Double.doubleToLongBits(param.getAnfme()) != Double.doubleToLongBits(manPakOut.getAnfme())){ |
| | | if(param.getAnfme() > manLocDetl.getAnfme() || (param.getAnfme() - manPakOut.getAnfme()) > (orderDetl.getAnfme() - orderDetl.getQty())){ |
| | | throw new CoolException("出库数量不得大于订单数量或者库存数量"); |
| | | } |
| | | //根据实际出库数量回写拣货单 |
| | | manPakOut.setCount(param.getAnfme()); |
| | | if(manPakOut.getCount() < manPakOut.getAnfme()){ |
| | | manPakOut.setStatus(8); |
| | | } |
| | | //根据实际出库数量回写订单详情 |
| | | orderDetl.setQty(orderDetl.getQty() - (param.getAnfme()-manPakOut.getAnfme())); |
| | | orderDetlService.update(orderDetl,orderDetlWrapper); |
| | | |
| | | }else { |
| | | manPakOut.setCount(param.getAnfme()); |
| | | manPakOut.setStatus(1); |
| | | } |
| | | |
| | | manPakOutService.update(manPakOut,manPakOutWrapper); |
| | | //检查该订单下的拣货单是否已经全部出库 |
| | | int status = checkManPakoutByOrder(param.getOrderNo()); |
| | | manPakOutService.updateAllStatus(param.getOrderNo(),status); |
| | | |
| | | |
| | | //修改库存 |
| | | manLocDetl.setAnfme(manLocDetl.getAnfme()-manPakOut.getCount()); |
| | | if (manLocDetl.getAnfme() == 0 ){ |
| | | checkNodeStatus(manLocDetl.getLocNo()); |
| | | manLocDetlService.delete(manLocDetlWrapper); |
| | | }else{ |
| | | manLocDetl.setStatus(1); |
| | | manLocDetlService.update(manLocDetl,manLocDetlWrapper); |
| | | } |
| | | SaasUtils.insertLog(1,manLocDetl.getLocNo(),manLocDetl.getMatnr(), manLocDetl.getAnfme(),user.getUsername()); |
| | | manLocDetl.setStatus(1); |
| | | manLocDetlService.update(manLocDetl,manLocDetlWrapper); |
| | | |
| | | //检测订单是否完成 |
| | | orderService.checkComplete(param.getOrderNo()); |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | public void modifyWrkDetl(List<WrkDetl> wrkDetls, List<ModifyPakoutParam.CA> params, Long userId) { |
| | | |
| | | wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("wrk_no",wrkDetls.get(0).getWrkNo())); |
| | | |
| | | params.forEach(param ->{ |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | LocDetl locDetl = locDetlService.selectByContainerCode(param.getContainerCode()); |
| | | BeanUtils.copyProperties(locDetl,wrkDetl); |
| | | wrkDetl.setWrkNo(wrkDetls.get(0).getWrkNo()); |
| | | if(wrkDetl.getAnfme() < param.getAnfme()){ |
| | | throw new CoolException("料箱"+param.getContainerCode()+"的物料数量小于拣料数量,请重新核对"); |
| | | } |
| | | wrkDetl.setAnfme(param.getAnfme()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiUser(userId); |
| | | wrkDetlService.insert(wrkDetl); |
| | | |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void nodePakinNoComb(CombParam param) { |
| | | if(Cools.isEmpty(param.getLocno())){ |
| | | throw new CoolException("库位号未填写,无法入库"); |
| | | } |
| | | param.getCombMats().forEach(combMat -> { |
| | | Wrapper<ManLocDetl> wrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", param.getLocno()).eq("matnr",combMat.getMatnr()); |
| | | Utils.wapperSetCondition(wrapper,"container_code",combMat.getContainerCode()); |
| | | Utils.wapperSetCondition(wrapper,"batch",combMat.getBatch()); |
| | | Utils.wapperSetCondition(wrapper,"csocode",combMat.getCsocode()); |
| | | Utils.wapperSetCondition(wrapper,"isoseq",combMat.getIsoseq()); |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(wrapper); |
| | | if(Cools.isEmpty(manLocDetl)){ |
| | | saveManlocDetl(combMat,param.getLocno()); |
| | | }else{ |
| | | manLocDetl.setAnfme(manLocDetl.getAnfme() + combMat.getAnfme()); |
| | | manLocDetlService.update(manLocDetl,wrapper); |
| | | } |
| | | //生成平库入出库日志 |
| | | SaasUtils.insertLog(0,param.getLocno(),combMat.getMatnr(), combMat.getAnfme(),""); |
| | | }); |
| | | |
| | | } |
| | | |
| | | private boolean saveManlocDetl(CombParam.CombMat combMat, String locNo){ |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("name", locNo)); |
| | | Mat mat = matService.selectByMatnr(combMat.getMatnr()); |
| | | ManLocDetl manLocDetl = new ManLocDetl(); |
| | | BeanUtils.copyProperties(mat,manLocDetl); |
| | | manLocDetl.setAnfme(combMat.getAnfme()); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | manLocDetl.setContainerCode(combMat.getContainerCode()); |
| | | manLocDetl.setCsocode(combMat.getCsocode()); |
| | | manLocDetl.setIsoseq(combMat.getIsoseq()); |
| | | manLocDetl.setCreateTime(new Date()); |
| | | manLocDetl.setModiTime(new Date()); |
| | | manLocDetl.setLocNo(locNo); |
| | | manLocDetl.setStatus(1); |
| | | return manLocDetlService.insert(manLocDetl); |
| | | } |
| | | |
| | | private void saveManlocDetl(WaitPakin waitPakin, Date now, String locNo){ |
| | | |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("name", locNo)); |
| | | |
| | | ManLocDetl manLocDetl = new ManLocDetl(); |
| | | BeanUtils.copyProperties(waitPakin,manLocDetl); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | manLocDetl.setContainerCode(waitPakin.getSuppCode()); |
| | | manLocDetl.setCsocode(waitPakin.getThreeCode()); |
| | | manLocDetl.setIsoseq(waitPakin.getDeadTime()); |
| | | manLocDetl.setCreateTime(now); |
| | | manLocDetl.setModiTime(now); |
| | | manLocDetl.setLocNo(locNo); |
| | | manLocDetl.setStatus(1); |
| | | manLocDetlService.insert(manLocDetl); |
| | | } |
| | | |
| | | private int checkManPakoutByOrder(String orderNo){ |
| | | int status = 0; |
| | | List<ManPakOut> manPakOutList = manPakOutService.selectList(new EntityWrapper<ManPakOut>().eq("doc_num", orderNo)); |
| | | |
| | | for(int i=0; i<manPakOutList.size(); i++){ |
| | | if(i == 0){ |
| | | status = manPakOutList.get(i).getStatus(); |
| | | }else { |
| | | if(manPakOutList.get(i).getStatus() != status){ |
| | | status = 8; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return status; |
| | | |
| | | } |
| | | |
| | | private void checkNodeStatus(String locNo){ |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>().eq("loc_no", locNo)); |
| | | //如果库存信息中没有改库位,则修改库位状态为1 |
| | | if(Cools.isEmpty(manLocDetl)){ |
| | | Node node = nodeService.selectByUuid(locNo); |
| | | node.setStatus(1); |
| | | nodeService.updateById(node); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |