#
luxiaotao1123
2 天以前 3e6cd2231fc99a855129d1a293b8d65adf1683b5
#
1个文件已添加
5个文件已修改
95 ■■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/common/constant/Constants.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/NamespaceType.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/enums/IntegrationDirectionType.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/IntegrationRecordServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/common/constant/Constants.java
@@ -12,6 +12,8 @@
    public static final String LIMIT_ONE = "limit 1";
    public static final String RCS = "RCS";
    /**
     * 默认成功码
     */
zy-acs-manager/src/main/java/com/zy/acs/manager/core/domain/type/NamespaceType.java
New file
@@ -0,0 +1,15 @@
package com.zy.acs.manager.core.domain.type;
public enum NamespaceType {
    RCS_TASK_REPORT("任务完成上报"),
    ;
    public String name;
    NamespaceType(String name) {
        this.name = name;
    }
}
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java
@@ -10,6 +10,7 @@
import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam;
import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.manager.entity.Bus;
import com.zy.acs.manager.manager.entity.IntegrationRecord;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.enums.TaskStsType;
import com.zy.acs.manager.manager.service.BusService;
@@ -41,6 +42,26 @@
    @PostMapping("/bus/submit")
    @OperationLog("generate task from open api")
    public R submit(@RequestBody OpenBusSubmitParam param) {
        IntegrationRecord integrationRecord = new IntegrationRecord(
                null,    // 编号
                null,    // 名称空间
                null,    // 接口地址
                null,    // 平台密钥
                null,    // 调用方标识
                null,    // 方向[非空]
                null,    // 时间戳
                null,    // 客户端IP
                null,    // 请求内容
                null,    // 响应内容
                null,    // 异常内容
                null,    // 结果
                null,    // 耗时
                null,    // 状态
                null,    // 添加时间[非空]
                null,    // 修改时间[非空]
                null    // 备注
        );
        mainService.generateBusAndTask(param, null);
        return R.ok("generate tasks success");
    }
zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java
@@ -4,16 +4,23 @@
import com.alibaba.fastjson.TypeReference;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.framework.common.SnowflakeIdWorker;
import com.zy.acs.manager.common.config.UplinkProperties;
import com.zy.acs.manager.common.constant.Constants;
import com.zy.acs.manager.common.utils.HttpGo;
import com.zy.acs.manager.core.domain.type.NamespaceType;
import com.zy.acs.manager.core.integrate.dto.HttpResult;
import com.zy.acs.manager.core.integrate.dto.TaskUplinkParam;
import com.zy.acs.manager.core.service.ThreadPoolRegulator;
import com.zy.acs.manager.manager.entity.Bus;
import com.zy.acs.manager.manager.entity.IntegrationRecord;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.enums.IntegrationDirectionType;
import com.zy.acs.manager.manager.enums.StatusType;
import com.zy.acs.manager.manager.enums.TaskStsType;
import com.zy.acs.manager.manager.enums.TaskUplinkStateType;
import com.zy.acs.manager.manager.service.BusService;
import com.zy.acs.manager.manager.service.IntegrationRecordService;
import com.zy.acs.manager.manager.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +28,7 @@
import javax.annotation.PostConstruct;
import java.time.Duration;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -37,6 +45,10 @@
    private ThreadPoolRegulator threadPoolRegulator;
    @Autowired
    private BusService busService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private IntegrationRecordService integrationRecordService;
    private HttpGo http;
@@ -68,7 +80,7 @@
        ) {
            return false;
        }
        Date now = new Date();
        // block
//        Future<R> future = threadPoolRegulator.getInstance().submit(() -> {
//            mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true);
@@ -96,9 +108,30 @@
        param.setTaskNo(task.getSeqNum());
        param.setTimestamp(null == task.getEndTime() ? System.currentTimeMillis() : task.getEndTime().getTime());
        IntegrationRecord integrationRecord = new IntegrationRecord(
                String.valueOf(snowflakeIdWorker.nextId()).substring(3),    // 编号
                NamespaceType.RCS_TASK_REPORT.name,    // 名称空间
                uplinkProperties.getUrl(),    // 接口地址
                null,    // 平台密钥
                Constants.RCS,    // 调用方标识
                IntegrationDirectionType.OUTBOUND.value,    // 方向[非空]
                String.valueOf(now.getTime()),    // 时间戳
                uplinkProperties.getHost(),    // 客户端IP
                JSON.toJSONString(param),    // 请求内容
                null,    // 响应内容
                null,    // 异常内容
                0,    // 结果
                null,    // 耗时
                StatusType.ENABLE.val,    // 状态
                now,    // 添加时间[非空]
                now,    // 修改时间[非空]
                null    // 备注
        );
        HttpResult<?> result;
        try {
            result = postForResult(url, headers, param);
            integrationRecord.setResponse(JSON.toJSONString(result));
            Integer code = result.getCode();
            if (null == code || 200 != code) {
                return false;
@@ -107,11 +140,17 @@
//            if (Cools.isEmpty(data)) {
//                return false;
//            }
            integrationRecord.setResult(1);
        } catch (Exception e) {
            log.error("Uplink report failed, taskId={}",
                    JSON.toJSONString(task),
                    e);
            integrationRecord.setErr(e.getMessage());
            return false;
        } finally {
            integrationRecord.setCostMs((int) (System.currentTimeMillis() - now.getTime()));
            integrationRecordService.syncRecord(integrationRecord);
        }
        return true;
    }
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/enums/IntegrationDirectionType.java
@@ -2,9 +2,9 @@
public enum IntegrationDirectionType {
    NONE(0),
    INBOUND(1),
    OUTBOUND(2),
    NONE(0),        // 未知
    INBOUND(1),     // 接收
    OUTBOUND(2),    // 调用
    ;
    public int value;
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/IntegrationRecordServiceImpl.java
@@ -1,16 +1,19 @@
package com.zy.acs.manager.manager.service.impl;
import com.alibaba.fastjson.JSON;
import com.zy.acs.framework.common.R;
import com.zy.acs.manager.core.service.ThreadPoolRegulator;
import com.zy.acs.manager.manager.mapper.IntegrationRecordMapper;
import com.zy.acs.manager.manager.entity.IntegrationRecord;
import com.zy.acs.manager.manager.service.IntegrationRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.CompletableFuture;
@Slf4j
@Service("integrationRecordService")
public class IntegrationRecordServiceImpl extends ServiceImpl<IntegrationRecordMapper, IntegrationRecord> implements IntegrationRecordService {
@@ -21,14 +24,15 @@
    public Boolean syncRecord(IntegrationRecord record) {
        CompletableFuture<?> completableFuture = CompletableFuture.supplyAsync(() -> {
            if (!this.save(record)) {
                log.error("failed to save record {}", JSON.toJSONString(record));
            }
//            mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true);
//            avoidWaveCalculator.calcDynamicNodeByVehicle(agv, null);
            return R.ok();
        }, threadPoolRegulator.getInstance());
        return false;
        return true;
    }
}