自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-07-11 db68c17a0780f30daeef1d1c4ee715bb8dac398c
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -13,6 +13,7 @@
import com.zy.asrs.entity.param.MobileAdjustParam;
import com.zy.asrs.entity.param.OpenOrderPakinParam;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
@@ -56,6 +57,8 @@
    private OpenService openService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private ApiLogService apiLogService;
    @Override
    @Transactional
@@ -144,7 +147,7 @@
                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());  // 数量
@@ -196,7 +199,7 @@
                        // todo 盘点记录、保存调整记录
                        // 修改明细
                        if (!wrkDetlService.updateAnfme(wrkDetl1.getAnfme(), wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) {
                            throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "批号修改数量失败");
                            throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "序列码修改数量失败");
                        }
                    }
                    iterator.remove();
@@ -209,7 +212,7 @@
        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("删除" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "序列码任务明细失败");
            }
        }
@@ -226,7 +229,7 @@
            wrkDetl.setAppeTime(now);
            wrkDetl.setAppeUser(userId);
            if (!wrkDetlService.insert(wrkDetl)) {
                throw new CoolException("添加" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "批号任务明细失败");
                throw new CoolException("添加" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," + wrkDetl.getBatch() + "序列码任务明细失败");
            }
        }
@@ -271,7 +274,10 @@
                        throw new CoolException(elem.getMatnr() + "条码已下线,请检查!");
                    }
                }
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                Mat analyse = MatUtils.analyseMat(elem.getMatnr());
                // 条码、物料代码、序列号、数量
                DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme());
//                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                if (DetlDto.has(detlDtos, detlDto)) {
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                    assert one != null;
@@ -284,14 +290,18 @@
            if (packDown) {
                MesCombParam mesCombParam = new MesCombParam();
                mesCombParam.setZpallet(param.getBarcode());
                mesCombParam.setCombTime(DateUtils.convert(now));
                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.getMatnr(), detlDto.getAnfme()));
                    mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme()));
                }
                String response;
                String response = "";
                boolean success = false;
                try {
                    response  = new HttpHandler.Builder()
                    response = new HttpHandler.Builder()
                            .setUri(MesConstant.URL)
                            .setPath(MesConstant.PACK_DOWN_URL)
                            .setJson(JSON.toJSONString(mesCombParam))
@@ -299,16 +309,30 @@
                            .doPost();
                    JSONObject jsonObject = JSON.parseObject(response);
                    if (jsonObject.getInteger("code").equals(200)) {
                        log.info("请求接口成功!!!");
//                        log.info("请求接口成功!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
                        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);
                    e.printStackTrace();
                    throw new CoolException("上报mes系统失败");
                    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); }
                }
            }
@@ -364,7 +388,7 @@
                    throw new CoolException("保存入库通知档失败");
                }
                // 修改打包数据状态
                Pack pack = packService.selectByBarcode(detlDto.getMatnr());
                Pack pack = packService.selectByBarcode(detlDto.getOrderNo());
                pack.setSettle(2L);
                pack.setUpdateTime(now);
                pack.setUpdateBy(userId);