Administrator
2024-05-30 11c7a9b0270cbf529ebb5e434b5fe0593dd209f0
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/ComSupport.java
@@ -6,7 +6,6 @@
import com.dy.common.mw.protocol.CommandType;
import com.dy.common.mw.protocol.Data;
import com.dy.common.mw.protocol.p206V202404.CodeV202404;
import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
@@ -52,15 +51,14 @@
    protected static String controllerType = "57" ;//控制器类型
    protected static Integer projectNo = 100 ;//项目编码
    protected static String icCardAddr = "04BEA5BB" ;//IC卡地址
    protected static String icCardNo = "37142501020500001" ;//IC卡编号(用户卡序列号)
    protected String protocolName = ProtocolConstantV206V202404.protocolName;
    //protected static String icCardAddr = "04BEA5BB" ;//IC卡地址
    //protected static String icCardNo = "37142501020500001" ;//IC卡编号(用户卡序列号)
    //protected String protocolName = ProtocolConstantV206V202404.protocolName;
    protected String commandTypeOuter = CommandType.outerCommand;
    // 存储实例化的 CompletableFuture<Data> 对象
    protected static Map<String, Object> features = new HashMap<>();
    protected static Map<Long, Object> features = new HashMap<>();
    protected static Boolean setuped = false;
    @Autowired
@@ -83,7 +81,7 @@
     * 获取系统配置参数
     */
    public void setUp() {
        protocolName = comSupport.baSettingsMapper.getItemValue("protocolName");
        //protocolName = comSupport.baSettingsMapper.getItemValue("protocolName");
        controllerType = comSupport.baSettingsMapper.getItemValue("controllerType");
        projectNo = Integer.parseInt(comSupport.baSettingsMapper.getItemValue("projectNo"));
        setuped = true;
@@ -98,18 +96,22 @@
    /**
     * 创建命令日志对象
     * @param comId 主键
     * @param commandCode 功能码
     * @param rtuAddr 阀控器地址
     * @param protocol 通讯协议名称
     * @param param 参数数据
     * @param operator 操作员
     * @return 零零日志对象
     * @return
     */
    protected RmCommandHistory getComHistory(String commandCode, String rtuAddr, Object param, Long operator ) {
    protected RmCommandHistory getComHistory(Long comId, String commandCode, Long intakeId, String rtuAddr, String protocol, Object param, Long operator ) {
        RmCommandHistory rmCommandHistory = new RmCommandHistory();
        rmCommandHistory.setId(comId);
        rmCommandHistory.setCommandCode(commandCode);
        rmCommandHistory.setCommandName(CodeV202404.getCodeName(commandCode));
        rmCommandHistory.setRtuaddr(rtuAddr);
        rmCommandHistory.setProtocol(protocolName);
        rmCommandHistory.setIntakeId(intakeId);
        rmCommandHistory.setRtuAddr(rtuAddr);
        rmCommandHistory.setProtocol(protocol);
        rmCommandHistory.setParam((JSONObject) JSON.toJSON(param));
        rmCommandHistory.setSendTime(new Date());
        rmCommandHistory.setOperator(operator);
@@ -124,13 +126,13 @@
     * @param param 参数数据
     * @return 构造好的命令对象
     */
    protected Command command(String comId, String commandCode, String rtuAddr, Object param){
    protected Command command(Long comId, String commandCode, String rtuAddr, String protocol, Object param){
        Command com = new Command() ;
        com.id = comId==null?Command.defaultId:(comId.trim().equals("")?Command.defaultId:comId);
        com.id = String.valueOf(comId);
        com.code = commandCode ;
        com.rtuAddr = rtuAddr ;
        com.protocol = protocolName;
        com.protocol = protocol;
        com.type = commandTypeOuter;
        com.rtuResultSendWebUrl = rtuResultSendWebUrl ;
@@ -144,13 +146,13 @@
     * @param comId
     * @return
     */
    protected BaseResponse<Data> dealWithCallBack(String comId) {
    protected BaseResponse<Data> dealWithCallBack(Long comId) {
        CompletableFuture<Data> featureObject = new CompletableFuture<>();
        features.put(comId, featureObject);
        try {
            CompletableFuture<Data> feature = (CompletableFuture<Data>) features.get(comId);
            System.out.println("receive result ID:" + comId);
            Data resultData = feature.get(30, TimeUnit.SECONDS);
            Data resultData = feature.get(10, TimeUnit.SECONDS);
            features.remove(comId);
            String commandId = resultData.getCommandId();
            if(commandId.equals(comId)) {