自动化立体仓库 - WMS系统
skyouc
昨天 1fdb053b64a033280a8ffe0ea10ad54b604e58cd
src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -19,6 +19,8 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.enums.OrderTypeEnum;
import com.zy.asrs.service.*;
import com.zy.asrs.service.impl.TaskDetlLogServiceImpl;
import com.zy.asrs.service.impl.TaskDetlServiceImpl;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.utils.OrderInAndOutUtil;
@@ -69,6 +71,8 @@
    private LocDetlService locDetlService;
    @Autowired
    CheckOrderDetlService checkOrderDetlService;
    @Autowired
    private TaskDetlLogService taskDetlLogService;
    @Transactional
@@ -140,6 +144,7 @@
                orderDetlList.add(detail);
            }
        }
        for (OrderDetl orderDetl : orderDetlList) {
            orderDetl.setWorkQty(0D);
            OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(), order, orderDetl);
@@ -161,21 +166,24 @@
    @Transactional(rollbackFor = Exception.class)
    public void ifTransfetInsertStockIn(Order order, OrderDetl orderDetl) {
        OrderPakin orderPakin = new OrderPakin();
        BeanUtils.copyProperties(order, orderPakin);
        orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
        if (!orderPakinService.insert(orderPakin)) {
            throw new CoolException("插入备货入库单失败");
        OrderPakin pakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>()
                .eq("order_no", order.getOrderNo())
                .eq("doc_type", OrderTypeEnum.STOCK_IN.type.longValue()));
        if (Objects.isNull(pakin)) {
            OrderPakin orderPakin = new OrderPakin();
            BeanUtils.copyProperties(order, orderPakin);
            orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
            if (!orderPakinService.insert(orderPakin)) {
                throw new CoolException("插入备货入库单失败");
            }
        }
        OrderDetlPakin orderDetlPakin = new OrderDetlPakin();
        BeanUtils.copyProperties(orderDetl, orderDetlPakin);
        orderDetlPakin.setOrderId(orderPakin.getId());
        orderDetlPakin.setOrderId(pakin.getId());
        if (!orderDetlPakinService.insert(orderDetlPakin)) {
            throw new CoolException("插入备货入库单失败");
        }
    }
    @Transactional
@@ -255,7 +263,6 @@
            ReportOrderParam orderParam = new ReportOrderParam();
            orderParam.setCompany_id(order.getCstmrName())
                    .setWms_id(order.getId() + "")
//                    .setOrder_no(order.getOrderNo())
                    .setDispatch_no(order.getOrderNo())
                    .setType(order.getDocType() + "")
                    .setInv_no(order.getNumber())
@@ -276,29 +283,46 @@
                        .eq("supp_code", detl.getSuppCode())
                        .eq("order_no", detl.getOrderNo()));
                if (Objects.isNull(locDetl)) {
                    throw new CoolException("库存明细不存在 ,请检查单据是否完成!!");
                    // BS Code
                    itemParam.setTotal_serial(detl.getThreeCode())
                            // 上报时,默认产品类型是null
                            .setPro_type(material.getProType())
                            // 上报时,默认产品编码
                            .setPro_komcode(detl.getMatnr())
                            // 上报时,默认产品id是供应商编码
                            .setPro_id(detl.getSuppCode())
                            .setLocation_no("LX000000000")
                            .setSj_emp("9527")
                            .setLocation_type(MatLocType.getMatTag(material.getTagId() + ""))
                            // 上报时,默认上报时间是更新时间
                            .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"))
                            // 上报时,如果为空默认上报 0
                            .setPick_qty(0)
                            // 上报时,默认损坏数量是0
                            .setDamage_qty(0)
                            // 上报时,默认差异数量是0
                            .setDiff_qty(0);
                } else {
                    // BS Code
                    itemParam.setTotal_serial(detl.getThreeCode())
                            // 上报时,默认产品类型是null
                            .setPro_type(material.getProType())
                            // 上报时,默认产品编码
                            .setPro_komcode(detl.getMatnr())
                            // 上报时,默认产品id是供应商编码
                            .setPro_id(detl.getSuppCode())
                            .setLocation_no(locDetl.getZpallet())
                            .setSj_emp(locDetl.getModiUser$())
                            .setLocation_type(MatLocType.getMatTag(material.getTagId() + ""))
                            // 上报时,默认上报时间是更新时间
                            .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss"))
                            // 上报时,默认上报数量是订单数量
                            .setPick_qty(locDetl.getAnfme().intValue())
                            // 上报时,默认损坏数量是0
                            .setDamage_qty(0)
                            // 上报时,默认差异数量是0
                            .setDiff_qty(0);
                }
                // BS Code
                itemParam.setTotal_serial(detl.getThreeCode())
                        // 上报时,默认产品类型是null
                        .setPro_type(material.getProType())
                        // 上报时,默认产品编码
                        .setPro_komcode(detl.getMatnr())
                        // 上报时,默认产品id是供应商编码
                        .setPro_id(detl.getSuppCode())
                        .setLocation_no(locDetl.getZpallet())
                        .setSj_emp(locDetl.getModiUser$())
                        .setLocation_type(MatLocType.getMatTag(material.getTagId()  + ""))
                        // 上报时,默认上报时间是更新时间
                        .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss") )
                        // 上报时,默认上报数量是订单数量
                        .setPick_qty(detl.getQty().intValue())
                        // 上报时,默认损坏数量是0
                        .setDamage_qty(0)
                        // 上报时,默认差异数量是0
                        .setDiff_qty(0);
                reportOrderParams.add(itemParam);
            });
@@ -345,64 +369,68 @@
                }
            }
        } else if (Integer.valueOf(docType.getDocId() + "").equals(OrderTypeEnum.TRANSFER.type)) {
            // 备货派工单(出库)
            // 备货指示派工单(出库)
            ReportOrderParam orderParam = new ReportOrderParam();
            orderParam.setCompany_id(order.getCstmrName())
                    .setWms_id(order.getId() + "")
                    .setOrder_no(order.getOrderNo())
                    .setDispatch_no(order.getOrderNo())
                    .setType(order.getDocType() + "")
                    .setInv_no(order.getNumber())
                    .setPm_tktid(order.getItemName())
                    .setUpdate_time(Utils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"))
                    .setTarget_location("");
                    //目标库区
                    .setTarget_location("")
                    .setSource_location("1");
            List<ReportOrderParams> reportOrderParams = new ArrayList<>();
            List<OrderItemsParam> reportOrderParams = new ArrayList<>();
            orderDetls.forEach(detl -> {
                Mat material = matService.selectByMatnr(detl.getMatnr());
                if (Objects.isNull(material)) {
                    throw new CoolException("物料不存在");
                }
                ReportOrderParams itemParam = new ReportOrderParams();
                TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>()
                        .eq("matnr", detl.getMatnr())
                        .eq("supp_code", detl.getStandby1())
                        .eq("order_no", detl.getOrderNo()));
                if (Objects.isNull(detlLog)) {
                    throw new CoolException("数据错误 ,请检查AGV任务档是否已完成!!");
                }
                //目标库区
                orderParam.setTarget_location(detlLog.getAreaType());
                OrderItemsParam itemParam = new OrderItemsParam();
                // BS Code
                itemParam.setTotal_serial(detl.getThreeCode())
                itemParam
                        // 上报时,默认产品类型是null
                        .setPro_type(material.getProType())
                        // 上报时,默认产品编码
                        .setPro_komcode(detl.getMatnr())
                        // 上报时,默认产品id是供应商编码
                        .setPro_id(detl.getSuppCode())
                        // 上报时,默认来源位置是null
                        .setLocation_no(null)
                        // 上报时,默认目标位置是null
                        .setLocation_type(null)
                        // 上报时,默认上报时间是更新时间
                        .setSj_date(order.getUpdateBy().toString())
                        // 上报时,默认上报人是更新人
                        .setSj_emp(order.getUpdateBy$())
//                        // 上报时,默认来源位置是null
                        .setLocation_no(detlLog.getZpallet())
                        // 上报时,默认上报数量是订单数量
                        .setPick_qty(detl.getQty().intValue())
                        // 上报时,默认损坏数量是0
                        .setDamage_qty(0)
                        // 上报时,默认差异数量是0
                        .setDiff_qty(0);
                        .setPick_qty(detl.getQty().intValue());
                reportOrderParams.add(itemParam);
            });
            orderParam.setDetails(reportOrderParams);
            if (orderParam.getTarget_location().equals("2")) {
                orderParam.setType("11");
            } else if (orderParam.getTarget_location().equals("3")) {
                orderParam.setType("12");
            } else {
                orderParam.setType("13");
            }
            orderParam.setPartList(reportOrderParams);
            XSR response = null;
            boolean success = false;
            try {
                // response = new HttpHandler.Builder()
                // .setUri(MesConstant.URL)
                // .setPath(MesConstant.PAKOUT_URL)
                // .setJson(JSON.toJSONString(pakoutParam))
                // .build()
                // .doPost();
                // JSONObject jsonObject = JSON.parseObject(response);
                // if (jsonObject.getInteger("code").equals(200)) {
                if (true) {
                List<ReportOrderParam> orderParams = new ArrayList<>();
                orderParams.add(orderParam);
                if (order.getReportOnce() < 4) {
                    response = kopenApiService.reportOutDetailsResult(orderParams, order);
                } else {
                    return FAIL;
                }
                if (response.getSuccess()) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), settle, null)) {
@@ -410,8 +438,8 @@
                    }
                } else {
                    log.error("请求接口失败!!!url:{};request:{};response:{}",
                            MesConstant.URL + MesConstant.OUT_DISPATCH_RESULT,
                            JSON.toJSONString(orderParam), JSON.toJSONString(response));
                            MesConstant.URL + MesConstant.OUT_DETAILS_RESULT,
                            JSON.toJSONString(orderParams), JSON.toJSONString(response));
                    throw new CoolException("上报KOPEN系统失败");
                }
            } catch (Exception e) {
@@ -451,6 +479,14 @@
                if (Objects.isNull(material)) {
                    throw new CoolException("物料不存在");
                }
                TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>()
                        .eq("matnr", detl.getMatnr())
                        .eq("supp_code", detl.getStandby1())
                        .eq("order_no", detl.getOrderNo()));
                if (Objects.isNull(detlLog)) {
                    throw new CoolException("数据错误 ,请检查AGV任务档是否已完成!!");
                }
                OrderItemsParam itemParam = new OrderItemsParam();
                // 上报时,默认产品类型是null
                itemParam.setPro_type(material.getProType());
@@ -458,9 +494,11 @@
                itemParam.setPro_komcode(material.getMatnr());
                // 上报时,默认产品id是供应商编码
                itemParam.setPro_id(detl.getSuppCode());
                //todo 台车编码
                itemParam.setTruck_no(detlLog.getZpallet());
                // 上报时,默认上报时间是更新时间
                itemParam.setPick_qty(detl.getQty().intValue());
                reportOrderParams.add(itemParam);
            });
            pubOrderParams.setPartList(reportOrderParams);
@@ -469,7 +507,7 @@
            pubOrderParamsList.add(pubOrderParams);
            // 设置派工单明细
            stockUpOrderParams.setDetails(pubOrderParamsList);
            stockUpOrderParams.setUpdate_time(order.getUpdateBy$());
            stockUpOrderParams.setUpdate_time(order.getUpdateTime$());
            XSR response = null;
            boolean success = false;
@@ -482,7 +520,16 @@
                // .doPost();
                // JSONObject jsonObject = JSON.parseObject(response);
                // if (jsonObject.getInteger("code").equals(200)) {
                if (true) {
                List<StockUpOrderParams> orderParams = new ArrayList<>();
                orderParams.add(stockUpOrderParams);
                if (order.getReportOnce() < 4) {
                    response = kopenApiService.getOutDetailsResult(orderParams, order);
                } else {
                    return FAIL;
                }
                if (response.getSuccess()) {
                    success = true;
                    // 修改订单状态 4.完成 ===>> 6.已上报
                    if (!orderService.updateSettle(order.getId(), settle, null)) {
@@ -519,7 +566,7 @@
    /**
     * 损溢单完结上报
     *
     *
     * @param order
     * @return
     */
@@ -532,10 +579,11 @@
        adjustParam.setCompany_id(order.getCstmrName())
                .setWms_id(order.getId() + "")
                .setType(0 + "")
                .setCompany_id(order.getCstmrName());
                .setUpdate_time(order.getUpdateTime$());
//                .setKopen_id(order.getDefNumber());
        adjustParam.setBsby_no(order.getNumber())
                .setResason("")
        adjustParam.setBsby_no(order.getOrderNo())
                .setReason("")
                .setReason_name("");
        List<CheckOrderDetl> detls = checkOrderDetlService
                .selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", order.getId()));
@@ -559,7 +607,14 @@
        adjustParams.add(adjustParam);
        XSR response = kopenApiService.reportCheckOrder(adjustParams, order);
        if (order.getReportOnce() < 3) {
            XSR response = kopenApiService.reportCheckOrder(adjustParams, order);
            if (response.getSuccess()) {
                return SUCCESS;
            } else {
                return FAIL;
            }
        }
        return SUCCESS;
        // TODO Auto-generated method stub