Administrator
2024-05-30 451abd5bc732aed5854b62e30bc2fb7cff3e1922
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java
@@ -9,6 +9,7 @@
import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
import com.dy.pipIrrGlobal.pojoPr.PrController;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
@@ -40,12 +41,21 @@
    private final PrIntakeMapper prIntakeMapper;
    /**
     * 根据取水口ID获取阀控器地址
     * @param intakeId 取水口ID
     * @return 阀控器地址
     * 根据取水口ID获取阀控器对象
     * @param intakeId
     * @return
     */
    public String getRtuAddrByIntakeId(Long intakeId) {
        return prControllerMapper.getRtuAddrByIntakeId(intakeId);
    public PrController getControllerByIntakeId(Long intakeId) {
        return prControllerMapper.getControllerByIntakeId(intakeId);
    }
    /**
     * 根据RTU地址获取阀控器对象
     * @param rtuAddr
     * @return
     */
    public PrController getControllerByRtuAddr(String rtuAddr) {
        return prControllerMapper.getControllerByRtuAddr(rtuAddr);
    }
    /**
@@ -53,9 +63,9 @@
     * @param po 命令日志对象
     * @return 字符串类型的主键
     */
    public String insert(RmCommandHistory po) {
    public Long insert(RmCommandHistory po) {
        rmCommandHistoryMapper.insert(po);
        return (po.getId()).toString();
        return po.getId();
    }
    /**
@@ -65,16 +75,6 @@
     */
    public Integer update(RmCommandHistory po) {
        return rmCommandHistoryMapper.updateByPrimaryKeySelective(po);
    }
    /**
     * 根据操作员ID获取未关阀记录
     * @param operator
     * @return
     */
    public List<VoUnclosedValve> getUnclosedValves(Long operator) {
        return rmCommandHistoryMapper.getUnclosedValves(operator);
    }
    /**
@@ -146,4 +146,41 @@
        }
    }
    /**
     * 根据操作员ID获取未关阀记录(包含在线情况)
     * @param operator
     * @return
     */
    public List<VoUnclosedValve> getUnclosedValves(Long operator) {
        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);
            }
            List<VoUnclosedValve> res = rmCommandHistoryMapper.getUnclosedValves(jsonArray.toJSONString(), operator);
            if(res != null) {
                return res;
            } else {
                return new ArrayList<>();
            }
        } else {
            QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
            return new ArrayList<>();
        }
    }
}