From 7d05aad173c1e605419ea38ff598b9c7572c611d Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 15 八月 2024 08:36:20 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java | 94 +++++++++++++++++++++++++++++++++++++---------
1 files changed, 75 insertions(+), 19 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
index 90767c5..a6bbf1c 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java
@@ -2,6 +2,9 @@
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.BaseResponse;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
import com.dy.pipIrrGlobal.daoPr.PrIntakeControllerMapper;
@@ -9,16 +12,19 @@
import com.dy.pipIrrGlobal.pojoPr.PrController;
import com.dy.pipIrrGlobal.pojoPr.PrIntakeController;
import com.dy.pipIrrGlobal.voPr.VoController;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
/**
* @author ZhuBaoMin
@@ -42,6 +48,8 @@
@Autowired
private RestTemplate restTemplate;
+ protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send";
+
/**
* 鏍规嵁鎸囧畾鑾峰彇鎺у埗鍣ㄨ褰�
@@ -50,18 +58,42 @@
* @return
*/
public QueryResultVo<List<VoController>> getControllers(QueryVo queryVo) {
- Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
- Long itemTotal = prControllerMapper.getRecordCount(params);
+ Command com = new Command();
+ com.id = Command.defaultId;
+ com.code = "LCD0001";
+ com.type = "innerCommand";
- QueryResultVo<List<VoController>> rsVo = new QueryResultVo<>();
- rsVo.pageSize = queryVo.pageSize;
- rsVo.pageCurr = queryVo.pageCurr;
+ JSONObject response = (JSONObject) JSON.toJSON(sendCom2Mw(com));
- rsVo.calculateAndSet(itemTotal, params);
- rsVo.obj = prControllerMapper.getControllers(params);
+ 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);
- return rsVo;
+ 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);
+ }
+ queryVo.setOnLineMap(jsonArray.toJSONString());
+
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ Long itemTotal = prControllerMapper.getRecordCount(params);
+
+ QueryResultVo<List<VoController>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = prControllerMapper.getControllers(params);
+ return rsVo;
+ } else {
+ QueryResultVo<List<VoController>> rsVo = new QueryResultVo<>();
+ return rsVo;
+ }
}
/**
@@ -72,7 +104,7 @@
*/
public Integer addController(PrController po) {
int rows = prControllerMapper.insert(po);
- if(rows == 0) {
+ if (rows == 0) {
return 0;
}
PrIntakeController addPrIntakeController = new PrIntakeController();
@@ -83,10 +115,10 @@
addPrIntakeController.setOperatedt(po.getOperateDt());
addPrIntakeController.setRemarks("缁戝畾");
int rec = prIntakeControllerMapper.insert(addPrIntakeController);
- if(rec == 0) {
+ if (rec == 0) {
return 0;
}
- return 1 ;
+ return 1;
}
/**
@@ -100,13 +132,13 @@
}
/**
- * 鏍规嵁鎺у埗鍣ㄧ紪鍙烽�昏緫鍒犻櫎鎺у埗
+ * 鏍规嵁鎺у埗鍣ㄧ紪鍙风墿鐞嗗垹闄ゆ帶鍒�
*
* @param controllerId
* @return
*/
public Integer deleteControllerById(Long controllerId) {
- return prControllerMapper.deleteControllerById(controllerId);
+ return prControllerMapper.deleteByPrimaryKey(controllerId);
}
/**
@@ -168,7 +200,8 @@
/**
* 鏍规嵁鎺у埗鍣ㄧ紪鍙风墿鐞嗗垹闄ゆ帶鍒�
- *2024-6-7
+ * 2024-6-7
+ *
* @param controllerId
* @return
*/
@@ -178,11 +211,34 @@
/**
* 鏍规嵁涓婚敭鏌ヨ鎺у埗鍣ㄥ垪琛�
- *2024-6-7
+ * 2024-6-7
+ *
* @param controllerId
* @return
*/
public PrController getByControllerId(Long controllerId) {
return prControllerMapper.selectByPrimaryKey(controllerId);
}
+
+
+ /**
+ * 鍙戦�佸懡浠�
+ *
+ * @return
+ */
+ protected BaseResponse sendCom2Mw(Command com) {
+ String url = UriComponentsBuilder.fromUriString(mwUrlSendCom)
+ .build()
+ .toUriString();
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response.getBody();
+ }
}
--
Gitblit v1.8.0