zwl
2025-07-02 4282d15a5e69a6b4c822c87d27a1ed6e7e618f00
src/main/java/com/zy/asrs/service/impl/ToWmsServiceImpl.java
@@ -8,7 +8,7 @@
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.TaskWrk;
import com.zy.asrs.entity.TaskWrkReport;
import com.zy.asrs.entity.wms.StorageEscalationParam;
import com.zy.asrs.entity.param.StorageEscalationParam;
import com.zy.asrs.entity.wms.WmsResult;
import com.zy.asrs.service.*;
import com.zy.common.service.CommonService;
@@ -54,7 +54,7 @@
    /**
     * 任务开始时,WCS回调WMS
     */
    @Value("${wms.taskExecCallback}")
    @Value("${wms.TaskExecCallback}")
    private String taskExecCallback;
    /**
     * 任务完成结束时,WCS回调WMS
@@ -62,17 +62,17 @@
    @Value("${wms.taskStatusFeedbackPath}")
    private String taskStatusFeedbackPath;
    @Value("${wms.code}")
    private String code;
//    @Value("${wms.code}")
//    private String code;
    @Value("${wms.successCode}")
    private String successCode;
    @Value("${wms.msg}")
    private String msg;
    @Value("${wms.data}")
    private String data;
//    @Value("${wms.successCode}")
//    private String successCode;
//
//    @Value("${wms.msg}")
//    private String msg;
//
//    @Value("${wms.data}")
//    private String data;
    @Override
    public void addReportLog(TaskWrk taskWrk) {
@@ -84,44 +84,44 @@
    @Override
    public TaskWrk getLocNoFromWms(StorageEscalationParam wmsParam) {
        String response = "";
        Boolean success = false;
        try {
            response = new HttpHandler.Builder()
                    .setUri(wmsUrl)
                    .setPath(inboundTaskApplyPath)
                    .setJson(JSON.toJSONString(wmsParam))
                    .build()
                    .doPost();
            if (!Cools.isEmpty(response)) {
                JSONObject jsonObject = JSON.parseObject(response);
                if (!Cools.isEmpty(jsonObject.get(code)) && jsonObject.get(code).equals(successCode)) {
                    //有些三方wms系统不能及时返回库位号,这时候就需要
                    //ZWmsResult result = JSON.parseObject(jsonObject.get(data).toString(), WmsResult.class);
                    TaskWrk taskWrk = null;
                    int i = 1;
                    while (i < 10) {
                        taskWrk = taskWrkService.selectByBarcode(wmsParam.getBarcode());
                        if (taskWrk != null) {
                            break;
                        }
                        try {
                            i++;
                            Thread.sleep(500L);
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    return taskWrk;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            log.info("请求wms报错,{}", e.getMessage());
        } finally {
            addApiLog("入库任务请求获取库位", wmsUrl + inboundTaskApplyPath, JSON.toJSONString(wmsParam), response, success);
        }
        return null;
//        String response = "";
//        Boolean success = false;
//        try {
//            response = new HttpHandler.Builder()
//                    .setUri(wmsUrl)
//                    .setPath(inboundTaskApplyPath)
//                    .setJson(JSON.toJSONString(wmsParam))
//                    .build()
//                    .doPost();
//            if (!Cools.isEmpty(response)) {
//                JSONObject jsonObject = JSON.parseObject(response);
//                if (!Cools.isEmpty(jsonObject.get(code)) && jsonObject.get(code).equals(successCode)) {
//                    //有些三方wms系统不能及时返回库位号,这时候就需要
//                    //ZWmsResult result = JSON.parseObject(jsonObject.get(data).toString(), WmsResult.class);
//                    TaskWrk taskWrk = null;
//                    int i = 1;
//                    while (i < 10) {
//                        taskWrk = taskWrkService.selectByBarcode(wmsParam.getBarcode());
//                        if (taskWrk != null) {
//                            break;
//                        }
//                        try {
//                            i++;
//                            Thread.sleep(500L);
//                        } catch (InterruptedException e) {
//                            throw new RuntimeException(e);
//                        }
//                    }
//                    return taskWrk;
//                }
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//            log.info("请求wms报错,{}", e.getMessage());
//        } finally {
//            addApiLog("入库任务请求获取库位", wmsUrl + inboundTaskApplyPath, JSON.toJSONString(wmsParam), response, success);
//        }
          return null;
    }