自动化立体仓库 - WMS系统
zhou zhou
13 小时以前 071b6b6eb7add4aa6e067b87259697101bff4119
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,13 +8,16 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.enums.CommonEnum;
import com.zy.asrs.entity.result.ForwardAGVTaskDTO;
import com.zy.asrs.entity.result.HIKApiDTO;
import com.zy.asrs.entity.result.HIKResultDTO;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
import com.zy.asrs.utils.OrderInAndOutUtil;
import com.zy.common.constant.HIKApiConstant;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
@@ -683,17 +686,16 @@
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "商品档案不存在");
                }
                //最多可放数量
                Double singleMax = mat.getUpQty() * suplus;
                if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
                    throw new CoolException("单次最大组托上限为:" + singleMax);
                    throw new CoolException("物料:" + detlDto.getMatnr() + "单次组托上限为:" + mat.getUpQty() + ",当前总量超出托盘装载上限!!");
                }
                BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
                //当前物料需要占用料箱格数
                Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
                suplus = suplus - curr;
                if (suplus == 0 || suplus < 0) {
                if (suplus < 0) {
                    throw new CoolException("物料:" + detlDto.getMatnr() + ", 超出当前托盘装载上限!!");
                }
@@ -1273,6 +1275,31 @@
        return R.ok();
    }
    @Override
    public R callEmptyCar(AgvCallParams params) {
        List<LocCache> locSts = locCacheService.selectList(new EntityWrapper<LocCache>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type));
        if (locSts.isEmpty()){
            throw new CoolException("暂无空板库位");
        }
        HIKApiDTO hikApiDTO =new HIKApiDTO()
                .setOrg(locSts.get(0).getLocNo())
                .setOrgType("05")
                .setTar(params.getTarSite())
                .setTarType("05")
                .setTaskType("GT5")
                .setPriority("1")
                .setCtnrType("2")
                ;
        HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
        if (!hikResultDTO.isSuccess()){
            return R.error(hikResultDTO.getMessage());
        }
        return R.ok();
    }
    /**
     * @author Ryan
     * @date 2025/9/25
@@ -1375,7 +1402,7 @@
        task.setWrkNo(workNo)
                .setIoTime(new Date())
                .setWrkSts(1L) // 工作状态:11.生成出库ID
                .setIoType(11) // 入出库状态: 11.库格移载
                .setIoType(1) // 入出库状态: 11.库格移载
                .setTaskType("agv")
                .setIoPri(10D)
                .setLocNo(loc.getLocNo()) // 目标库位
@@ -1430,4 +1457,58 @@
            throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$());
        }
    }
    public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO,String path){
        HIKResultDTO result = new HIKResultDTO();
        ForwardAGVTaskDTO forwardAGVTaskParam = new ForwardAGVTaskDTO();
        forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", ""));
        forwardAGVTaskParam.setClientCode("IWMS");
        forwardAGVTaskParam.setTaskTyp(haiKangApiDTO.getTaskType());
        forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType());
        forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority());
        List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>();
        positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType()));
        positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType()));
        forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
        String body = JSON.toJSONString(forwardAGVTaskParam);
        String response = "";
        try {
            response = new HttpHandler.Builder()
                    .setUri(HIKApiConstant.AGV_IP)
                    .setPath(path)
                    .setJson(body)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.getInteger("code").equals(0)) {
                result.setSuccess(true);
            } else {
                result.setMessage(jsonObject.getString("message"));
                log.error("发送agv任务失败!!!url:{};request:{};response:{}", HIKApiConstant.AGV_IP + path, body, response);
            }
//            {"code":"1","data":"","interrupt":false,"message":"重复提交","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"}
        } catch (Exception e) {
            result.setMessage(e.getMessage());
            log.error("发送agv任务异常", e);
        } finally {
            try {
                // 保存接口日志
                apiLogService.save(
                        "发送agv任务",
                        HIKApiConstant.AGV_IP + path,
                        null,
                        "127.0.0.1",
                        body,
                        response,
                        result.isSuccess()
                );
            } catch (Exception e) {
                log.error("", e);
            }
        }
        return result;
    }
}