| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.BaseRes; |
| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.WrkCancel; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.*; |
| | |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.WcsController; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Value("${wcs-slave.cancel}") |
| | | private String cancel; |
| | | @Value("${wcs-slave.url}") |
| | | private String url; |
| | | @Value("${wcs-slave.warehouse}") |
| | | private String warehouse; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | |
| | | //wms取消任务 同时调用wcs任务取消接口通知wcs |
| | | WrkCancel wrkCancel = new WrkCancel(); |
| | | Date date = new Date(); |
| | | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | wrkCancel.setTaskId(workNo); // 任务号 |
| | | wrkCancel.setMsgTime(dateFormat.format(date)); // 取消时间 |
| | | wrkCancel.setWarehouse(warehouse); // 仓库编码 |
| | | |
| | | String response = ""; |
| | | boolean flag = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(cancel) |
| | | .setJson(JSON.toJSONString(wrkCancel)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("returnStatus") == 0){ |
| | | flag = true; |
| | | }else { |
| | | log.error("wms取消任务下发wcs失败--->url:{};request:{};response:{}", url+"/"+cancel, JSON.toJSONString(wrkCancel), response); |
| | | throw new CoolException("wms取消任务下发wcs失败"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("fail", e); |
| | | }finally { |
| | | try { |
| | | //保存接口日志 |
| | | apiLogService.save( |
| | | "wms下发任务给wcs", |
| | | url+"/"+cancel, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(wrkCancel), |
| | | response, |
| | | flag |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("",e); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |