chenlu
2025-11-21 d473c7b2b07cfeee3740f40dfdc95d722d8da3c2
north-glass-erp/src/main/java/com/example/erp/service/pp/GlassOptimizeService.java
@@ -18,6 +18,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
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 org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -45,6 +46,9 @@
    GlassOptimizeMapper glassOptimizeMapper;
    @Autowired
    SysErrorService sysErrorService;
    @Value("${mesIp:localhost}")  // 注入mesIp配置,默认值为10.153.19.31
    private String mesIp;
    RabbitMQUtil rabbitMQUtil;
    //模拟计算
@@ -653,7 +657,10 @@
                }
            }
        }
        map.put("optimizeState", Integer.parseInt(stringObjectMap.get("optimize_state").toString()));
        map.put("data", dataList);
        map.put("project", glassOptimizeMapper.selectProjectCount(projectNo));
        map.put("grindingTrimming", glassOptimizeMapper.getGrindingTrimming(username));
        return map;
    }
@@ -772,13 +779,15 @@
                Map<String, Object> cancelResult = issuingCancelProject(projectNumber);
                // 获取返回结果中的data字段
                Map<String, Object> responseData = (Map<String, Object>) cancelResult.get("data");
                // 检查响应中的code字段,只有当code为200或202时才允许更新状态
                if (responseData != null && responseData.containsKey("code")) {
                    Object responseCode = responseData.get("code");
                    if (responseCode.equals(200) || responseCode.equals(202)) {
                        glassOptimizeMapper.updateProjectStateMp(projectNumber, state);
                    }else {
                    } else if (responseCode.equals(201)) {
                        // 当返回201时,抛出自定义异常或返回错误信息
                        throw new RuntimeException(responseData.get("message").toString());
                    } else {
                        return false;
                    }
                } else {
@@ -1241,8 +1250,7 @@
        boolean  saveState=false;
        try {
            // 1. 创建URL对象
//            URL url = new URL("http://10.153.19.31:88/api/loadGlass/engineering/importEngineer");
            URL url = new URL("http://localhost:88/api/loadGlass/engineering/importEngineer");
            URL url = new URL("http://" + mesIp + ":88/api/loadGlass/engineering/importEngineer");
            // 2. 打开连接
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -1480,8 +1488,8 @@
        try {
            // 1. 创建URL对象
//            URL url = new URL("http://10.153.19.31:88/api/loadGlass/engineering/optimizeCancelTask");
            URL url = new URL("http://localhost:88/api/loadGlass/engineering/optimizeCancelTask");
            URL url = new URL("http://" + mesIp + ":88/api/loadGlass/engineering/optimizeCancelTask");
//            URL url = new URL("http://localhost:88/api/loadGlass/engineering/optimizeCancelTask");
            // 2. 打开连接