| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.domain.enums.WorkNoType; |
| | | 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; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.Synchro; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | @Service("toWmsService") |
| | | public class ToWmsServiceImpl implements ToWmsService { |
| | | |
| | | |
| | | @Autowired |
| | | private TaskWrkService taskWrkService; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | |
| | | @Autowired |
| | | private TaskWrkReportService taskWrkReportService; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | /** |
| | | * 任务开始时,WCS回调WMS |
| | | */ |
| | | @Value("${wms.taskExecCallback}") |
| | | @Value("${wms.TaskExecCallback}") |
| | | private String taskExecCallback; |
| | | /** |
| | | * 任务完成结束时,WCS回调WMS |
| | |
| | | @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) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public WmsResult getLocNoFromWms(StorageEscalationParam wmsParam) { |
| | | String response = ""; |
| | | Boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(wmsParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (!Cools.isEmpty(response) && !Cools.isEmpty(jsonObject.get(code)) && jsonObject.get(code).equals(successCode)) { |
| | | WmsResult result = JSON.parseObject(jsonObject.get(data).toString(), WmsResult.class); |
| | | return result; |
| | | } |
| | | } catch (IOException e) { |
| | | |
| | | } finally { |
| | | addApiLog("入库任务请求获取库位", wmsUrl + inboundTaskApplyPath, JSON.toJSONString(wmsParam), response, success); |
| | | } |
| | | return null; |
| | | 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; |
| | | } |
| | | |
| | | |
| | | private TaskWrk createInTask(WmsResult result, String barcode, Integer startPoint) { |
| | | //String locNo = Utils.Fusion(result.getRow(), result.getFloor(), result.getColumn()); |
| | | String locNo = result.getLocNo(); |
| | | Date now = new Date(); |
| | | TaskWrk taskWrk = new TaskWrk(); |
| | | int workNo1 = commonService.getWorkNo(WorkNoType.PAKIN.type);//获取入库工作号 |
| | | taskWrk.setTaskNo(result.getTaskNo());//任务号 |
| | | taskWrk.setWrkNo(workNo1); |
| | | taskWrk.setStatus(TaskStatusType.DISTRIBUTE.id);//任务状态:派发 |
| | | taskWrk.setCreateTime(now); |
| | | taskWrk.setIoType(1);//任务类型 |
| | | taskWrk.setIoPri(13);//优先级 |
| | | taskWrk.setBarcode(barcode);//条码 |
| | | LocMast locMast = locMastService.selectByLocNo(locNo); |
| | | taskWrk.setCrnNo(locMast.getCrnNo()); |
| | | taskWrk.setTargetPoint(locNo); |
| | | taskWrk.setStartPoint(startPoint + ""); |
| | | taskWrk.setCrnNo(result.getCrnNo()); |
| | | if (taskWrk.getIoType() == 1) { |
| | | taskWrk.setWrkSts(2); |
| | | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { |
| | | taskWrk.setOriginTargetPoint(taskWrk.getTargetPoint()); |
| | | } |
| | | } |
| | | return taskWrk; |
| | | } |
| | | |
| | | private void addApiLog(String nameSpace, String url, String param, String response, Boolean success) { |
| | | apiLogService.save(nameSpace, url, null, "127.0.0.1", param, response, success); |
| | | } |