wuzeyu
2024-05-28 bf079a83490bcdb46504b09925d29671d7769895
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
6个文件已修改
2个文件已添加
225 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoOnLineIntake.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuOnLineDeal.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/qo/OnLineIntakesQO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
@@ -3,6 +3,7 @@
import com.dy.pipIrrGlobal.pojoPr.PrIntake;
import com.dy.pipIrrGlobal.voPr.VoIntake;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -110,4 +111,19 @@
     * @return
     */
    List<Map<String, Object>> getNoBindingIntakes();
    /**
     * 获取取水口数量(在线和不在线)
     * @param params
     * @return
     */
    Long getOnLineIntakesCount(Map<?, ?> params);
    /**
     * 获取取水口列表(在线和不在线)
     * @param params
     * @return
     */
    //List<VoOnLineIntake> getOnLineIntakes(@Param("onLineMap") String onLineMap, @Param("isOnLine") Boolean isOnLine);
    List<VoOnLineIntake> getOnLineIntakes(Map<?, ?> params);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoOnLineIntake.java
New file
@@ -0,0 +1,36 @@
package com.dy.pipIrrGlobal.voPr;
import com.dy.common.po.BaseEntity;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-05-27 17:02
 * @LastEditTime 2024-05-27 17:02
 * @Description 在线取水口对象
 */
@Data
public class VoOnLineIntake implements BaseEntity {
    private static final long serialVersionUID = 202405271703001L;
    /**
     * 取水口ID
     */
    private String intakeId;
    /**
     * 阀控器地址
     */
    private String rtuAddr;
    /**
     * 取水口编号
     */
    private String intakeNum;
    /**
     * 是否在线
     */
    private Boolean isOnLine;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -358,4 +358,57 @@
    WHERE id NOT IN(SELECT intakeId FROM pr_controller) AND deleted = 0
  </select>
  <!--获取取水口数量(在线和不在先)-->
  <select id="getOnLineIntakesCount" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM pr_controller con
        INNER JOIN pr_intake inta ON con.intakeId = inta.id
        INNER JOIN JSON_TABLE(
        <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
        #{onLineMap},
        '$[*]' COLUMNS(
            rtuAddr VARCHAR(20) PATH '$.rtuAddr',
            isOnLine BOOLEAN PATH '$.isOnLine'
        )
    ) rtus ON con.rtuAddr = rtus.rtuAddr
    <where>
      <if test="isOnLine != null">
        rtus.isOnLine = #{isOnLine}
      </if>
      <if test="intakeNum != null and intakeNum != ''">
        AND inta.name LIKE CONCAT('%', #{intakeNum}, '%')
      </if>
    </where>
  </select>
  <!--获取取水口列表(在线和不在先)-->
  <select id="getOnLineIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
    SELECT
      con.intakeId,
      con.rtuAddr,
      inta.name AS intakeNum,
      rtus.isOnLine
    FROM pr_controller con
        INNER JOIN pr_intake inta ON con.intakeId = inta.id
        INNER JOIN JSON_TABLE(
            <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
            #{onLineMap},
            '$[*]' COLUMNS(
                rtuAddr VARCHAR(20) PATH '$.rtuAddr',
                isOnLine BOOLEAN PATH '$.isOnLine'
            )
        ) rtus ON con.rtuAddr = rtus.rtuAddr
    <where>
      <if test="isOnLine != null">
        rtus.isOnLine = #{isOnLine}
      </if>
      <if test="intakeNum != null and intakeNum != ''">
        AND inta.name LIKE CONCAT('%', #{intakeNum}, '%')
      </if>
    </where>
    <if test="pageCurr != null and pageSize != null">
      LIMIT ${(pageCurr-1)*pageSize}, ${pageSize}
    </if>
  </select>
</mapper>
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java
@@ -1,7 +1,7 @@
package com.dy.rtuMw.server.local;
import com.dy.rtuMw.server.local.localProtocol.*;
import com.dy.common.mw.protocol.Command;
import com.dy.rtuMw.server.local.localProtocol.*;
/**
 * @Author liurunyu
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuOnLineDeal.java
@@ -1,6 +1,6 @@
package com.dy.rtuMw.server.local.localProtocol;
import com.dy.rtuMw.server.forTcp.TcpSessionCache;
import java.util.HashMap;
public class RtuOnLineDeal {
@@ -8,6 +8,13 @@
     * 查询在线与不在线情况
     */
    public RtuOnLineVo deal(){
        return (new RtuOnLineVo()).setOnLine(TcpSessionCache.allOnLine());
        //return (new RtuOnLineVo()).setOnLine(TcpSessionCache.allOnLine());
        // 返回值测试代码
        HashMap<String , Boolean> onLineMap = new HashMap<>() ;
        onLineMap.put("37142501020100215", true);
        onLineMap.put("dy20240325", false);
        onLineMap.put("4000004", true);
        return (new RtuOnLineVo()).setOnLine(onLineMap);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
@@ -1,15 +1,26 @@
package com.dy.pipIrrRemote.common;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Command;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
import com.dy.pipIrrRemote.common.qo.OnLineIntakesQO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author ZhuBaoMin
@@ -21,10 +32,11 @@
@Slf4j
@Service
@RequiredArgsConstructor
public class CommandSv {
public class CommandSv extends ComSupport {
    private final RmCommandHistoryMapper rmCommandHistoryMapper;
    private final PrControllerMapper prControllerMapper;
    private final SeVirtualCardMapper seVirtualCardMapper;
    private final PrIntakeMapper prIntakeMapper;
    /**
     * 根据取水口ID获取阀控器地址
@@ -64,5 +76,44 @@
        return rmCommandHistoryMapper.getUnclosedValves(operator);
    }
    /**
     * 获取取水口列表
     * @return
     */
    public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(OnLineIntakesQO qo) {
        Command com = new Command() ;
        com.id = Command.defaultId;
        com.code = "LCD0001";
        com.type = "innerCommand";
        JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
        if(response != null && response.getString("code").equals("0001")) {
            JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
            HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
            JSONArray jsonArray = new JSONArray();
            for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("rtuAddr", entry.getKey());
                jsonObject.put("isOnLine", entry.getValue());
                jsonArray.add(jsonObject);
            }
            qo.setOnLineMap(jsonArray.toJSONString());
            Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
            Long itemTotal = prIntakeMapper.getOnLineIntakesCount(params);
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>() ;
            rsVo.pageSize = qo.pageSize ;
            rsVo.pageCurr = qo.pageCurr ;
            rsVo.calculateAndSet(itemTotal, params);
            rsVo.obj = prIntakeMapper.getOnLineIntakes(params);
            return rsVo;
        } else {
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
            return rsVo;
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/qo/OnLineIntakesQO.java
New file
@@ -0,0 +1,33 @@
package com.dy.pipIrrRemote.common.qo;
import com.dy.common.webUtil.QueryConditionVo;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-05-27 20:32
 * @LastEditTime 2024-05-27 20:32
 * @Description
 */
@Data
public class OnLineIntakesQO extends QueryConditionVo {
    /**
     * 中间件返回的RTU在线情况对象数组
     */
    private String onLineMap;
    /**
     * 取水口编号
     */
    private String intakeNum;
    /**
     * 是否在线
     */
    @Max(value = 1,message = "是否在线仅允许为真或假")
    @Min(value = 0,message = "是否在线仅允许为真或假")
    private Boolean isOnLine;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuCtrl.java
@@ -10,11 +10,14 @@
import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrRemote.common.ComSupport;
import com.dy.pipIrrRemote.common.CommandSv;
import com.dy.pipIrrRemote.common.dto.Addr;
import com.dy.pipIrrRemote.common.dto.DtoBase;
import com.dy.pipIrrRemote.common.qo.OnLineIntakesQO;
import com.dy.pipIrrRemote.result.RemoteResultCode;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@@ -24,6 +27,7 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -65,6 +69,23 @@
    }
    /**
     * 获取取水口列表(在线和不在线)
     * @param qo
     * @return
     */
    @GetMapping(path = "get_online_intakes")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getOnLineIntakes(OnLineIntakesQO qo) {
        try {
            QueryResultVo<List<VoOnLineIntake>> res = commandSv.selectOnLineIntakes(qo);
            return BaseResponseUtils.buildSuccess(res);
            } catch (Exception e) {
            log.error("查询取水口异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
    /**
     * 设置设备终端地址
     * @param addr 设置设备终端地址传入对象
     * @param bindingResult