| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.result.WorkIssuedResult; |
| | | import com.zy.asrs.entity.result.WrkPriority; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private String url; |
| | | @Value("${wcs-slave.workIssued}") |
| | | private String workIssued; |
| | | @Value("${wcs-slave.priority}") |
| | | private String priority; |
| | | @Value("${wcs-slave.inDevp}") |
| | | private String inDevp; |
| | | @Value("${wcs-slave.outDevp}") |
| | | private String outDevp; |
| | | @Value("${wcs-slave.warehouse}") |
| | | private String warehouse; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | |
| | | WorkIssuedResult.Tasks task = new WorkIssuedResult.Tasks(); |
| | | task.setTaskId(wrkMast.getWrkNo().toString()); |
| | | task.setBarCode(wrkMast.getBarcode()); |
| | | task.setOrder(i); |
| | | // task.setOrder(i); |
| | | task.setOrder((int) (100 - wrkMast.getIoPri())); |
| | | |
| | | //优先级排序 15.出库>14.入库>13.空板出库>12.空板入库>11.移库 |
| | | if(wrkMast.getIoType() == 1 || wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57){//入库 |
| | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | //任务优先级调整 调用wcs接口 通知wcs |
| | | public ReturnT<String> notice(WrkMast wrkMast) { |
| | | WrkPriority wrkPriority = new WrkPriority(); |
| | | Date date = new Date(); |
| | | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | wrkPriority.setTaskId(wrkMast.getWrkNo().toString()); // 任务号 |
| | | wrkPriority.setWarehouse(warehouse); // 仓库编码 |
| | | wrkPriority.setPriorityCode(wrkMast.getIoPri().intValue()); // 优先级 |
| | | wrkPriority.setMsgTime(dateFormat.format(date)); // 调整时间 |
| | | |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(priority) |
| | | .setJson(JSON.toJSONString(wrkPriority)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("returnStatus").equals(0)) { |
| | | success = true; |
| | | wrkMast.setWrkSts(1L); |
| | | wrkMastService.updateById(wrkMast); |
| | | } else { |
| | | log.error("wms调整优先级下发给wcs失败!!!url:{};request:{};response:{}", url + "/" + workIssued, JSON.toJSONString(wrkPriority), response); |
| | | throw new CoolException("wms调整优先级下发给wcs失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "wms调整优先级下发给wcs", |
| | | url + "/" + workIssued, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(wrkPriority), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |