| | |
| | | * 根据操作员获取常用取水口 |
| | | * @return |
| | | */ |
| | | List<VoOnLineIntake> getUsedIntakes(@Param("onLineMap") String onLineMap, @Param("operator") Long operator); |
| | | List<VoOnLineIntake> getUsedIntakes(@Param("onLineMap") String onLineMap, @Param("operatorId") Long operatorId); |
| | | |
| | | /** |
| | | * 取水口名称换取水口ID,扫码开阀使用 |
| | |
| | | package com.dy.pipIrrGlobal.voPr; |
| | | |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | */ |
| | | |
| | | @Data |
| | | @JsonPropertyOrder({ "intakeId", "rtuAddr", "intakeNum", "isOnLine"}) |
| | | public class VoOnLineIntake implements BaseEntity { |
| | | private static final long serialVersionUID = 202405271703001L; |
| | | |
| | |
| | | FROM pr_common_intakes com |
| | | INNER JOIN pr_intake inta ON inta.id = com.intake_id |
| | | INNER JOIN pr_controller con ON con.intakeId = com.intake_id |
| | | INNER JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"620201000030","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | LEFT JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"530115059980","isOnLine":true},{"rtuAddr":"620201000030","isOnLine":true}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | |
| | | ) |
| | | ) rtus ON con.rtuAddr = rtus.rtuAddr |
| | | <where> |
| | | <if test="operator != null"> |
| | | com.operator_id = #{operator} |
| | | <if test="operatorId != null"> |
| | | AND com.operator_id = #{operatorId} |
| | | </if> |
| | | </where> |
| | | ORDER BY com.last_used_time DESC,com.usage_count DESC |
| | |
| | | END) AS state |
| | | FROM se_virtual_card vc |
| | | INNER JOIN se_client cli ON cli.id = vc.client_id |
| | | WHERE vc.client_id = #{clientId,jdbcType=BIGINT} |
| | | WHERE vc.state = 1 AND vc.client_id = #{clientId,jdbcType=BIGINT} |
| | | ) card |
| | | ORDER BY card.Money DESC, card.State DESC |
| | | </select> |
| | |
| | | |
| | | /** |
| | | * 根据操作员获取常用取水口(在线和不在线) |
| | | * @param operator |
| | | * @param operatorId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "used_intakes") |
| | | public BaseResponse<List<VoOnLineIntake>> getUsedIntakes(Long operator) { |
| | | if(operator == null || operator <= 0) { |
| | | public BaseResponse<List<VoOnLineIntake>> getUsedIntakes(Long operatorId) { |
| | | if(operatorId == null || operatorId <= 0) { |
| | | return BaseResponseUtils.buildErrorMsg("操作员不能为空"); |
| | | } |
| | | |
| | | try { |
| | | List<VoOnLineIntake> res = intakeSv.getUsedIntakes(operator); |
| | | List<VoOnLineIntake> res = intakeSv.getUsedIntakes(operatorId); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询取水口异常", e); |
| | |
| | | |
| | | /** |
| | | * 根据操作员获取常用取水口 |
| | | * @param operator |
| | | * @param operatorId |
| | | * @return |
| | | */ |
| | | public List<VoOnLineIntake> getUsedIntakes(Long operator) { |
| | | public List<VoOnLineIntake> getUsedIntakes(Long operatorId) { |
| | | Command com = new Command() ; |
| | | com.id = Command.defaultId; |
| | | com.code = "LCD0001"; |
| | | com.type = "innerCommand"; |
| | | comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw); |
| | | |
| | | JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com)); |
| | | //String response_Str = "{\"code\": \"0001\",\"content\": {\"attachment\": {\"530115059980\": true,\"620201000030\": true},\"code\": \"LCD0001\",\"id\": \"999999999\",\"param\": {\"message\": \"查询所有RTU在线情况结果\",\"success\": true},\"protocol\": \"\",\"rtuAddr\": \"\",\"rtuResultSendWebUrl\": \"\",\"type\": \"resultCommand\"},\"msg\": \"请求成功\",\"success\": true}"; |
| | | //JSONObject response = JSON.parseObject(response_Str); |
| | | //String test = response.toJSONString(); |
| | | |
| | | if(response != null && response.getString("code").equals("0001")) { |
| | | JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap"); |
| | | JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment"); |
| | | |
| | | JSONArray jsonArray = new JSONArray(); |
| | | if(attachment != null) { |
| | | HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class); |
| | | for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) { |
| | | attachment.forEach((key, value) -> { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("rtuAddr", entry.getKey()); |
| | | jsonObject.put("isOnLine", entry.getValue()); |
| | | jsonObject.put("rtuAddr", key); |
| | | jsonObject.put("isOnLine", value); |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | return prIntakeMapper.getUsedIntakes(jsonArray.toJSONString(), operator); |
| | | System.out.println(jsonArray.toJSONString()); |
| | | return prIntakeMapper.getUsedIntakes(jsonArray.toJSONString(), operatorId); |
| | | } else { |
| | | return new ArrayList<>(); |
| | | } |