| | |
| | | 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; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | |
| | | // 计算优先级 |
| | | dto.setPriority(priority); |
| | | priority++; // 下一个任务优先级递增 |
| | | priority--; // 下一个任务优先级递增 |
| | | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | |
| | | |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | String pick = ioType == 101 ? "N":"Y"; |
| | | |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | |
| | | wrkMast.setStaNo(staDesc.getStnNo()); |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); |
| | | wrkMast.setFullPlt("Y"); |
| | | wrkMast.setPicking("N"); |
| | | wrkMast.setPicking(pick); |
| | | wrkMast.setExitMk("N"); |
| | | wrkMast.setEmptyMk("N"); |
| | | wrkMast.setLinkMis("N"); |
| | |
| | | } else if (wrkMast.getIoType() > 100 && wrkMast.getWrkSts() != 14) { |
| | | locNo = wrkMast.getSourceLocNo(); |
| | | // 出库 ===>> F.在库 |
| | | if (wrkMast.getIoType() == 101) { |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103) { |
| | | locSts = "F"; |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 110) { |
| | |
| | | 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)); // 取消时间 |
| | | |
| | | 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 |