| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.NodeUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private BasAgvMastService basAgvMastService; |
| | | @Autowired |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean taskAgvCreate(TaskAgvCreateParam param) { |
| | | // 参数检查 |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | Integer devpId = 1; |
| | | // 创建对象(构造函数中已生成 timestamp) |
| | | BasAgvMast basAgvMast = new BasAgvMast(); |
| | | // 生成 WMS 任务号(如无外部传入,可以使用雪花ID 或自增) |
| | | basAgvMast.setTaskNo(commonService.getWorkNo(0)); |
| | | // 赋值参数 |
| | | basAgvMast.setSourceStaNo(param.getSourceStaNo()); |
| | | basAgvMast.setStaNo(param.getStaNo()); |
| | | basAgvMast.setSourceLocNo(param.getSourceLocNo()); |
| | | basAgvMast.setLocNo(param.getLocNo()); |
| | | // 默认值 |
| | | basAgvMast.setPriority(1L); // 默认优先级 |
| | | basAgvMast.setStatus(0); // 初始状态 |
| | | basAgvMast.setAppeTime(new Date()); // 添加时间 |
| | | basAgvMast.setModiTime(new Date()); // 修改时间 |
| | | basAgvMast.setIoType(param.getIoType());// 任务类型 |
| | | basAgvMast.setDevpId(devpId); |
| | | |
| | | // 插入数据库 |
| | | basAgvMastService.insert(basAgvMast); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public List<AgvLocListDetlParam> getAgvLocList(AgvLocListParam param){ |
| | | |
| | | if (param == null || Cools.isEmpty(param.getLocNoList())) { |
| | | throw new CoolException("库位号不能为空"); |
| | | } |
| | | |
| | | List<String> locNos = param.getLocNoList(); |
| | | |
| | | List<AgvLocListDetlParam> result = new ArrayList<>(); |
| | | |
| | | for (String locNo : locNos) { |
| | | |
| | | // 查询该库位 detail |
| | | List<LocDetl> detlList = locDetlService.selectList( |
| | | new EntityWrapper<LocDetl>().eq("loc_no", locNo) |
| | | ); |
| | | |
| | | AgvLocListDetlParam dto = new AgvLocListDetlParam(); |
| | | dto.setLocNo(locNo); |
| | | dto.setAgvDetlList(detlList); |
| | | result.add(dto); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean bindCtnrAndBin(bindCtnrAndBinParam param) { |
| | | // 参数检查 |
| | | if (param == null) { |
| | | throw new CoolException("参数不能为空"); |
| | | } |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(); |
| | | BasAgvLocNoService basAgvLocNoService = SpringUtils.getBean(BasAgvLocNoService.class); |
| | | BasAgvLocNo basAgvLocNoSou = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("loc_no", param.getLocNo())); |
| | | BasAgvLocNo basAgvLocNoEnd = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("sta_no", param.getStaNo())); |
| | | agvBindCtnrAndBinParam.setReqCode(String.valueOf(System.currentTimeMillis())); |
| | | agvBindCtnrAndBinParam.setCtnrCode(param.getBarcode()); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | agvBindCtnrAndBinParam.setPositionCode( |
| | | basAgvLocNoSou != null && basAgvLocNoSou.getAgvLocNo() != null |
| | | ? basAgvLocNoSou.getAgvLocNo() |
| | | : "" |
| | | ); |
| | | agvBindCtnrAndBinParam.setStgBinCode( |
| | | basAgvLocNoEnd != null && basAgvLocNoEnd.getAgvLocNo() != null |
| | | ? basAgvLocNoEnd.getAgvLocNo() |
| | | : "" |
| | | ); |
| | | agvBindCtnrAndBinParam.setIndBind(param.getIndBind()); |
| | | try { |
| | | String URL = "http://10.10.10.200:8181/rcms/services/rest/hikRpcService"; // AGV接口地址 |
| | | String mesPath = "bindCtnrAndBin"; // 接口路径 |
| | | String response = ""; |
| | | boolean success = false; |
| | | |
| | | try { |
| | | log.info("AGV绑定容器接口请求参数: {}", JSON.toJSONString(agvBindCtnrAndBinParam)); |
| | | |
| | | response = new HttpHandler.Builder() |
| | | .setUri(URL) |
| | | .setPath(mesPath) |
| | | .setJson(JSON.toJSONString(agvBindCtnrAndBinParam)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | log.info("AGV绑定容器接口响应: {}", response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | |
| | | if (jsonObject.getInteger("code") != null && jsonObject.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("AGV绑定容器失败!!!url:{};request:{};response:{}", URL + "/" + mesPath, JSON.toJSONString(agvBindCtnrAndBinParam), response); |
| | | throw new CoolException("AGV绑定容器失败: " + jsonObject.getString("msg")); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("AGV绑定容器接口调用异常!!!url:{};request:{};response:{}", URL + "/" + mesPath, JSON.toJSONString(agvBindCtnrAndBinParam), response, e); |
| | | throw new CoolException("AGV绑定容器接口调用异常: " + e.getMessage()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | } |