#
vincentlu
7 天以前 e9e8c6915e0f46d4ee9d4b0c8e0d7da77e35bba5
#
2个文件已添加
5个文件已修改
209 ■■■■ 已修改文件
version/doc/RCS开发进度表.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/common/config/ConveyorProperties.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/common/config/UplinkProperties.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/common/utils/HttpGo.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/resources/application.yml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
version/doc/RCS¿ª·¢½ø¶È±í.xlsx
Binary files differ
zy-acs-manager/src/main/java/com/zy/acs/manager/common/config/ConveyorProperties.java
@@ -1,5 +1,6 @@
package com.zy.acs.manager.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@@ -10,6 +11,7 @@
 * è¾“送线plc系统配置
 * Created by luxiaotao on 2018/10/15
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "convey-plc")
public class ConveyorProperties {
@@ -28,27 +30,7 @@
    private Integer port;
    public static String getHostName() {
        return HOST_NAME;
    }
    // millisecond
    private Integer timeout = 15 * 1000;
    public static void setHostName(String hostName) {
        HOST_NAME = hostName;
    }
    public String getHost() {
        return host;
    }
    public void setHost(String host) {
        this.host = host;
    }
    public Integer getPort() {
        return port;
    }
    public void setPort(Integer port) {
        this.port = port;
    }
}
zy-acs-manager/src/main/java/com/zy/acs/manager/common/config/UplinkProperties.java
New file
@@ -0,0 +1,38 @@
package com.zy.acs.manager.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
 * ä¸Šæ¸¸æœåŠ¡ç³»ç»Ÿé…ç½®
 * Created by luxiaotao on 2018/10/15
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "uplink")
public class UplinkProperties {
    public static String HOST_NAME;
    static {
        try {
            HOST_NAME = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            System.err.println("find hostname err");
        }
    }
    private Boolean enabled;
    private String host;
    private Integer port;
    // millisecond
    private Integer timeout = 60 * 1000;
}
zy-acs-manager/src/main/java/com/zy/acs/manager/common/utils/HttpGo.java
@@ -264,6 +264,16 @@
        }
    }
    // ======================== tools ========================
    public String buildUrl(String host, Integer port, String path) {
        return buildUrl(host, port, path, false);
    }
    public String buildUrl(String host, Integer port, String path, boolean ssl) {
        String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path));
        return (ssl ? "https" : "http") + "://" + host + ":" + port + p;
    }
    // ===================== Demo (main) =====================
    public static void main(String[] args) throws Exception {
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/conveyor/SiemensConveyorStationService.java
@@ -33,20 +33,22 @@
    @PostConstruct
    public void init() {
        int timeoutSeconds = conveyorProperties.getTimeout() / 1000;
        this.http = HttpGo.builder()
                .connectTimeout(Duration.ofSeconds(8))
                .readTimeout(Duration.ofSeconds(15))
                .connectTimeout(Duration.ofSeconds(timeoutSeconds))
                .readTimeout(Duration.ofSeconds(timeoutSeconds))
//                .defaultHeader("User-Agent", "HttpGo/1.0")
                // .trustAllSsl(true) // ONLY if you really need it (self-signed internal)
//                .trustAllSsl(true) // ONLY if you really need it (self-signed internal)
                .build();
    }
    @Override
    public boolean allowAgvWork(Sta sta, Task task, Segment seg, StaReserveType type) {
        final String staNo = sta.getStaNo();
        // url
        String url = this.buildUrl("/cv/station/query");
        String url = this.http.buildUrl(conveyorProperties.getHost(), conveyorProperties.getPort(), "/cv/station/query");
        // headers
        Map<String, String> headers = new HashMap<>();
        // params
@@ -104,14 +106,6 @@
        }
        // ok
        return true;
    }
    private String buildUrl(String path) {
        String host = conveyorProperties.getHost();
        Integer port = conveyorProperties.getPort();
        String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path));
        return "http://" + host + ":" + port + p;
    }
    private HttpResult<List<ConveyorStaDto>> postForResult(String url
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java
New file
@@ -0,0 +1,110 @@
package com.zy.acs.manager.core.integrate.wms;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.manager.common.config.UplinkProperties;
import com.zy.acs.manager.common.utils.HttpGo;
import com.zy.acs.manager.core.integrate.dto.HttpResult;
import com.zy.acs.manager.core.service.ThreadPoolRegulator;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@Slf4j
@Service
public class TaskReportService {
    @Autowired
    private UplinkProperties uplinkProperties;
    @Autowired
    private TaskService taskService;
    @Autowired
    private ThreadPoolRegulator threadPoolRegulator;
    private HttpGo http;
    @PostConstruct
    public void init() {
        int timeoutSeconds = uplinkProperties.getTimeout() / 1000;
        this.http = HttpGo.builder()
                .connectTimeout(Duration.ofSeconds(timeoutSeconds))
                .readTimeout(Duration.ofSeconds(timeoutSeconds))
//                .defaultHeader("User-Agent", "HttpGo/1.0")
//                .trustAllSsl(true) // ONLY if you really need it (self-signed internal)
                .build();
    }
    public boolean reportFinished(Task task) {
        // block
//        Future<R> future = threadPoolRegulator.getInstance().submit(() -> {
//            mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true);
//            return success();
//        });
//        System.out.println(JSON.toJSONString(future.get()));
        // non-block
        CompletableFuture<?> completableFuture = CompletableFuture.supplyAsync(() -> {
//            mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true);
//            avoidWaveCalculator.calcDynamicNodeByVehicle(agv, null);
            return R.ok();
        }, threadPoolRegulator.getInstance());
        // url
        String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), "/cv/station/query");
        // headers
        Map<String, String> headers = new HashMap<>();
        // params
        Map<String, Object> params = new HashMap<>();
        HttpResult<?> result;
        try {
            result = postForResult(url, headers, params);
            Integer code = result.getCode();
            if (null == code || 200 != code) {
                return false;
            }
            Object data = result.getData();
            if (Cools.isEmpty(data)) {
                return false;
            }
        } catch (Exception e) {
            log.error("");
            return false;
        }
        return true;
    }
    private HttpResult<?> postForResult(String url
            , Map<String, String> headers, Map<String, Object> params) throws Exception {
        String json = JSON.toJSONString(params);
        HttpGo.HttpResponse response = this.http.postJson(url, headers, json);
        int status = response.statusCode();
        if (status != 200) {
            throw new RuntimeException("Uplink HTTP error: status=" + status + ", body=" + response.body());
        }
        String body = response.body();
        if (Cools.isEmpty(body)) {
            throw new RuntimeException("Uplink empty response body.");
        }
        HttpResult<?> result = JSON.parseObject(body, new TypeReference<HttpResult<?>>() {});
        if (result == null) {
            throw new RuntimeException("Uplink parse HttpResult failed: body=" + body);
        }
        return result;
    }
}
zy-acs-manager/src/main/resources/application.yml
@@ -53,6 +53,13 @@
convey-plc:
  host: 10.10.10.222
  port: 9090
  timeout: 15000
uplink:
  enabled: true
  host: 10.10.10.222
  port: 9090
  timeout: 30000
floyd:
  enable: false