自动化立体仓库 - WMS系统
zhangc
2025-02-27 d0d64cf47ce37027307ceb64dc72e3ae36796a92
src/main/java/com/zy/asrs/service/impl/AgvWrkMastServiceImp.java
@@ -16,6 +16,8 @@
import com.zy.asrs.service.*;
import com.zy.common.service.AgvCommonService;
import com.zy.common.utils.HttpHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -28,6 +30,9 @@
@Service
@Slf4j
public class AgvWrkMastServiceImp extends ServiceImpl<AgvWrkMastMapper, AgvWrkMast> implements AgvWrkMastService {
    @Value("${agv.flag}")
    private boolean flag;
    @Value("${agv.url}")
    private String url;
@@ -61,15 +66,17 @@
    private AgvCommonService agvCommonService;
    @Autowired
    private AgvWrkMastService agvWrkMastService;
    @Autowired
    private ConfigService configService;
    public void updateWrkStsByWrkNo(int wrkNo, long wrkSts) {
    public Boolean updateWrkStsByWrkNo(int wrkNo, long wrkSts) {
        AgvWrkMast agvWrkMast = this.selectById(wrkNo);
        //判断要修改的工作档状态是否合理,如果不合理则抛出异常
        checkWrkSts(agvWrkMast, wrkSts);
        agvWrkMast.setWrkSts(wrkSts);
        agvWrkMast.setModiTime(new Date());
        this.updateById(agvWrkMast);
        return this.updateById(agvWrkMast);
    }
    public void updateWrkStsByWrkNo(int wrkNo, long wrkSts, String manuType, long userId) {
@@ -262,15 +269,56 @@
                }
                break;
            default:
                agvTaskCreateParam.setTaskTyp("F01");
                if (processUseTiShengJi(agvWrkMast.getSourceLocNo(), agvWrkMast.getLocNo())) {
                    agvTaskCreateParam.setTaskTyp("F06");
                } else {
                    agvTaskCreateParam.setTaskTyp("F01");
                }
                break;
        }
        agvTaskCreateParam.setPositionCodePath(agvTaskParamList);
    }
    // TODO 四期
    private boolean processUseTiShengJi(String sourceLocNo, String locNo) {
        // 判断是否是提升机
        if (sourceLocNo.startsWith("YZ")) {
            if (sourceLocNo.endsWith("01F2") && !locNo.startsWith("YZ") && locNo.endsWith("F4")) {
                // 从生产二厂的库位到吸塑二厂的点位上
                return true;
            } else if (sourceLocNo.endsWith("01F2") && locNo.startsWith("YZ") && locNo.endsWith("02F1")) {
                // 从生产二厂的库位到吸塑二厂的库位
                return true;
            } else if (sourceLocNo.endsWith("02F1") && locNo.startsWith("YZ") && locNo.endsWith("01F2")) {
                // 吸塑二楼的库位到生产二厂的库位
                return true;
            } else if (sourceLocNo.endsWith("02F1") && !locNo.startsWith("YZ") && locNo.endsWith("F2")) {
                // 吸塑二楼的库位到生产二厂的点位
                return true;
            } else if (sourceLocNo.endsWith("01F1") && !locNo.startsWith("YZ") && locNo.endsWith("F4")) {
                // 从吸塑一楼的库位到吸塑二楼的点位上
                return true;
            }
        } else {
            if (sourceLocNo.endsWith("F4") && locNo.startsWith("YZ") && locNo.endsWith("01F2")) {
                // 从吸塑二楼的点位到生产二厂的库位
                return true;
            } else if (sourceLocNo.endsWith("F2") && locNo.startsWith("YZ") && locNo.endsWith("02F1")) {
                // 从生产二厂的点位到吸塑二楼的库位
                return true;
            } else if (sourceLocNo.endsWith("F4") && locNo.startsWith("YZ") && locNo.endsWith("01F1")) {
                // 从吸塑二楼的点位到吸塑一楼的库位
                return true;
            }
        }
        return false;
    }
    private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip) {
        if (!flag) {
            return 1;
        }
        String response = "";
        boolean success = false;
        int code = 0;
@@ -284,7 +332,7 @@
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
             code = Integer.parseInt(jsonObject.get("code").toString());
            code = Integer.parseInt(jsonObject.get("code").toString());
            if (code != 0) {
                if (code == 6) {
                    log.info("AGV任务单号已上报:{}", response);
@@ -304,7 +352,7 @@
            throw new CoolException("调用AGV响应错误");
            //return 1;
        } finally {
            if(code !=6){
            if (code != 6) {
                apiLogService.save(
                        namespace,
                        url + path,