From ff08d741fcec20ebb6ef95514a59704a06a13a8b Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 20 六月 2024 10:47:06 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml | 4
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeVerifyDTO.java | 2
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java | 2
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeLoginDTO.java | 20
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/util/RestTemplateUtil.java | 115 +++++
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientSv.java | 52 --
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java | 231 +++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/qo/OnLineIntakesQO.java | 33 +
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java | 208 ---------
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerSv.java | 90 +++
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/QueryVo.java | 18
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java | 76 +++
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/config/WebFilterConfiguration.java | 35 -
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java | 41 +
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/RandomCode.java | 2
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoController.java | 24
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java | 134 ++++++
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/AliyunSmsSv.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml | 34 +
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java | 17
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java | 18
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml | 7
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 2
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java | 63 +++
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml | 4
26 files changed, 899 insertions(+), 337 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java
new file mode 100644
index 0000000..3b127ad
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java
@@ -0,0 +1,41 @@
+package com.dy.common.webFilter;
+
+import com.dy.common.multiDataSource.DataSourceContext;
+import jakarta.servlet.*;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-19 11:02
+ * @LastEditTime 2024-06-19 11:02
+ * @Description
+ */
+
+@Slf4j
+public class WXDataSourceNameSetFilter implements Filter {
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
+ String wxDataSourceName = httpRequest.getHeader("tag");
+ if(wxDataSourceName != null && wxDataSourceName.trim().length() > 0){
+ log.info("寰俊寮�鍙戯紝璁剧疆鏁版嵁婧愬悕绉颁负:" + wxDataSourceName);
+ //鎶婄粍缁囧崟浣嶆爣绛句綔涓烘暟鎹簮鍚嶇О
+ DataSourceContext.set(wxDataSourceName);
+ } else {
+ log.info("鐢ㄦ埛鏈�夋嫨鏁版嵁婧�");
+ }
+
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+
+ @Override
+ public void destroy() {
+ }
+}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoController.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoController.java
index 3b870e8..1042061 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoController.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoController.java
@@ -51,8 +51,24 @@
@ColumnWidth(30)
private Date findDt;
- @Schema(title = "鍦ㄧ嚎鐘舵��")
- @ExcelProperty("鍦ㄧ嚎鐘舵��")
- @ColumnWidth(6)
- private String onlineState;
+// @Schema(title = "鍦ㄧ嚎鐘舵��")
+// @ExcelProperty("鍦ㄧ嚎鐘舵��")
+// @ColumnWidth(6)
+// private String onlineState;
+
+ /**
+ * 鏄惁鍦ㄧ嚎
+ */
+ private Boolean isOnLine;
+
+
+ @Schema(title = "閫氳鍗忚")
+ @ExcelProperty("閫氳鍗忚")
+ @ColumnWidth(10)
+ private String protocol;
+
+ @Schema(title = "澶囨敞")
+ @ExcelProperty("澶囨敞")
+ @ColumnWidth(10)
+ private String remarks;
}
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
index 29fac5c..700142f 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,8 +5,8 @@
#name: ym
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
-# url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
- url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+ url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+# url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: root
password: dysql,;.abc!@#
druid:
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
index 9fd4b6a..01b83ee 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -72,7 +72,7 @@
pipIrr:
global:
- dev: true #鏄惁寮�鍙戦樁娈碉紝true鎴杅alse
+ dev: false #鏄惁寮�鍙戦樁娈碉紝true鎴杅alse
dsName: ym #寮�鍙戦樁娈碉紝璁剧疆涓存椂鐨勬暟鎹簱鍚嶇О
mw:
webPort: 8070
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
index c0f940b..a663b66 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerMapper.xml
@@ -168,19 +168,28 @@
SELECT
COUNT(*) AS recordCount
FROM pr_controller con
- LEFT JOIN pr_intake_controller ic ON ic.controllerId = con.id
- INNER JOIN pr_intake inta ON con.intakeId = inta.id
+ LEFT JOIN pr_intake_controller ic ON ic.controllerId = con.id
+ INNER JOIN pr_intake inta ON con.intakeId = inta.id
+ left 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>
AND con.deleted = 0
<if test = "id != null and id > 0">
AND con.id = ${id}
</if>
-
<if test = "rtuAddr != null and rtuAddr !=''">
AND con.rtuAddr like CONCAT('%',#{rtuAddr},'%')
</if>
-
+ <if test="isOnLine != null and isOnLine !='' ">
+ AND rtus.isOnLine = #{isOnLine}
+ </if>
<if test = "bindNumber != null and bindNumber > 0">
AND (SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) = ${bindNumber}
</if>
@@ -193,23 +202,34 @@
CAST(con.id AS char) AS id,
con.rtuAddr AS rtuAddr,
inta.name AS intakeName,
- "鍦ㄧ嚎" AS onlineState,
+ con.protocol,
+ inta.remarks,
+ rtus.isOnLine,
(SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) AS bindNumber,
con.findDt AS findDt
FROM pr_controller con
LEFT JOIN pr_intake_controller ic ON ic.controllerId = con.id
INNER JOIN pr_intake inta ON con.intakeId = inta.id
+ left 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>
AND con.deleted = 0
<if test = "id != null and id > 0">
AND con.id = ${id}
</if>
-
<if test = "rtuAddr != null and rtuAddr !=''">
AND con.rtuAddr like CONCAT('%',#{rtuAddr},'%')
</if>
-
+ <if test="isOnLine != null and isOnLine !='' ">
+ AND rtus.isOnLine = #{isOnLine}
+ </if>
<if test = "bindNumber != null and bindNumber > 0">
AND (SELECT COUNT(*) FROM pr_intake_controller WHERE controllerId = con.id AND intakeId = inta.id AND operateType = 1) = ${bindNumber}
</if>
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml
index c487a86..fcd9d78 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/application-database.yml
@@ -3,8 +3,8 @@
datasource: #閰嶇疆鏁版嵁婧�
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
-# url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
- url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+ url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+# url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: root
password: dysql,;.abc!@#
druid:
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
index 31be279..8a57433 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
@@ -76,7 +76,7 @@
}
//return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
- log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);
+ log.error("鑾峰彇鎺у埗鍣ㄨ褰曞紓甯�", e);
return BaseResponseUtils.buildException(e.getMessage());
}
}
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..e21fdae 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;
}
/**
@@ -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();
+ }
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/QueryVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/QueryVo.java
index 10edbd8..60ac5bd 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/QueryVo.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/QueryVo.java
@@ -2,6 +2,8 @@
import com.dy.common.webUtil.QueryConditionVo;
import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Max;
+import jakarta.validation.constraints.Min;
import lombok.*;
/**
@@ -29,9 +31,21 @@
@Schema(description = "鎺у埗鍣ㄥ湴鍧�")
private String rtuAddr;
- @Schema(description = "鍦ㄧ嚎鐘舵��")
- public Integer onlineState;
+// @Schema(description = "鍦ㄧ嚎鐘舵��")
+// public Integer onlineState;
@Schema(description = "缁戝畾鏁伴噺")
public Integer bindNumber;
+
+ /**
+ * 涓棿浠惰繑鍥炵殑RTU鍦ㄧ嚎鎯呭喌瀵硅薄鏁扮粍
+ */
+ private String onLineMap;
+
+ /**
+ * 鏄惁鍦ㄧ嚎
+ */
+ @Max(value = 1,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
+ @Min(value = 0,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
+ private Boolean isOnLine;
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java
index 196f207..f0abe8f 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java
@@ -1,8 +1,5 @@
package com.dy.pipIrrSell.client;
-import com.alibaba.fastjson2.JSONObject;
-import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
-import com.aliyuncs.exceptions.ClientException;
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
@@ -10,16 +7,7 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.pojoSe.SeClient;
-import com.dy.pipIrrGlobal.pojoSe.SeCodeVerify;
-import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
import com.dy.pipIrrGlobal.voSe.VoClient;
-import com.dy.pipIrrGlobal.voSe.VoClientWechat;
-import com.dy.pipIrrSell.client.dto.CodeVerifyDTO;
-import com.dy.pipIrrSell.result.SellResultCode;
-import com.dy.pipIrrSell.sms.AliyunSmsSv;
-import com.dy.pipIrrSell.sms.RandomCode;
-import com.dy.pipIrrSell.util.RestTemplateUtil;
-import com.dy.pipIrrSell.wechatpay.PayInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -35,7 +23,6 @@
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
-import java.io.IOException;
import java.util.*;
/**
@@ -52,20 +39,7 @@
@RequiredArgsConstructor
public class ClientCtrl {
private final ClientSv clientSv;
- private final AliyunSmsSv aliyunSmsSv;
//private final RedisUtils redisUtils;
- private final RestTemplateUtil restTemplateUtil;
-
- private final String privateCertFileName = PayInfo.privateCertFileName;
- private final String appid = PayInfo.appid;
- private final String secret = PayInfo.secret;
- private final String mchid = PayInfo.mchid;
- private final String schema = PayInfo.schema;
- private final String signType = PayInfo.signType;
- private final String description = PayInfo.description;
- private final String loginUrl = PayInfo.loginUrl;
- private final String notifyUrl = PayInfo.notifyUrl;
- private final String grantType = PayInfo.grantType;
/**
* 鑾峰彇鍐滄埛鍒楄〃
@@ -401,186 +375,4 @@
map.put("projectNo",projectNo3);
return BaseResponseUtils.buildSuccess(map);
}
-
- /**
- * 鍙戦�侀獙璇佺爜
- * @param phoneNumber
- * @return
- */
- @Operation(summary = "鍙戦�侀獙璇佺爜", description = "鍙戦�侀獙璇佺爜")
- @ApiResponses(value = {
- @ApiResponse(
- responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
- description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
- content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
- schema = @Schema(implementation = Boolean.class))}
- )
- })
- @PostMapping(path = "send_sms")
- @SsoAop()
- public BaseResponse<Boolean> sendSms(@RequestParam(name = "phoneNumber", required = true) String phoneNumber) throws ClientException {
- if(phoneNumber == null || phoneNumber.length() <= 0) {
- return BaseResponseUtils.buildFail(SellResultCode.PHONE_NUMBER_CANNOT_BE_NULL.getMessage());
- }
-
- // 鐢熸垚6浣嶉獙璇佺爜骞惰浆涓篔son鏍煎紡
- String securityCode = String.valueOf(RandomCode.genCode());
- JSONObject param = new JSONObject();
- param.put("code", securityCode);
- String templateParam = param.toJSONString();
-
- //redisUtils.set(phoneNumber, securityCode, 60);
-
- // 鑾峰彇褰撳墠鏃堕棿鎴冲苟寤跺悗3鍒嗛挓
- Long timestamp = System.currentTimeMillis();
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(timestamp);
- calendar.add(Calendar.SECOND, 180);
- Long expires = calendar.getTimeInMillis();
-
- SeCodeVerify codeVerify = new SeCodeVerify();
- codeVerify.setPhoneNumber(phoneNumber);
- codeVerify.setSecurityCode(securityCode);
- codeVerify.setExpires(expires);
- clientSv.addCodeVerify(codeVerify);
-
- SendSmsResponse response = aliyunSmsSv.sendSms(phoneNumber, templateParam);
- if (response.getCode().equals("OK")) {
- // 鍙戦�佹垚鍔熷鐞嗛�昏緫
- return BaseResponseUtils.buildSuccess(true) ;
- } else {
- // 鍙戦�佸け璐ュ鐞嗛�昏緫
- return BaseResponseUtils.buildFail(SellResultCode.SECURITY_CODE_SEND_FAIL.getMessage()) ;
- }
- }
-
- /**
- * 鏍¢獙楠岃瘉鐮�
- * @param po
- * @param bindingResult
- * @return
- * @throws IOException
- */
- @Operation(summary = "鏍¢獙楠岃瘉鐮�", description = "鏍¢獙楠岃瘉鐮�")
- @ApiResponses(value = {
- @ApiResponse(
- responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
- description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
- content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
- schema = @Schema(implementation = Boolean.class))}
- )
- })
- @PostMapping(path = "verify", consumes = MediaType.APPLICATION_JSON_VALUE)
- @Transactional(rollbackFor = Exception.class)
- @SsoAop()
- public BaseResponse<Boolean> verify(@RequestBody @Valid CodeVerifyDTO po, BindingResult bindingResult) throws IOException {
- if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
-
- String phoneNumber = po.getPhoneNumber();
- String securityCode = po.getSecurityCode();
- String code = po.getCode();
-
- // 杩涜鎵嬫満鍙枫�侀獙璇佺爜銆佽繃鏈熸椂闂存牎楠�
- SeCodeVerify codeVerify = clientSv.getCodeVerify(phoneNumber);
- if(codeVerify == null) {
- return BaseResponseUtils.buildFail(SellResultCode.NO_SECURITY_CODE_FOR_PHONE.getMessage());
- }
-
- if(!codeVerify.getSecurityCode().equals(securityCode)) {
- return BaseResponseUtils.buildFail(SellResultCode.SECURITY_CODE_ERROR.getMessage());
- }
-
- Long currentTimestamp = System.currentTimeMillis();
- if(currentTimestamp > codeVerify.getExpires() ) {
- return BaseResponseUtils.buildFail(SellResultCode.VALIDATION_TIMEOUT.getMessage());
- }
-
- // 鏍¢獙閫氳繃锛岃繘琛岀櫥褰曞嚟璇佹牎楠�
- Map<String, Object> queryParams = new HashMap<>();
- queryParams.put("appid", appid);
- queryParams.put("secret", secret);
- queryParams.put("js_code", code);
- queryParams.put("grant_type", grantType);
- Map<String, String> headerParams = new HashMap<>();
- JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams);
-
- if(job.getLong("errcode") != null && job.getLong("errcode") >= -1) {
- return BaseResponseUtils.buildFail("鐧诲綍鍑瘉鏍¢獙澶辫触");
- }
- String openid = job.getString("openid");
- String sessionKey = job.getString("session_key");
-
- Long clientId = clientSv.getClientIdByPhone(phoneNumber);
- String SessionId = "";
- if(clientId != null) {
- // 娣诲姞寰俊鐢ㄦ埛璐︽埛璁板綍
- SeOpenId seOpenId = new SeOpenId();
- seOpenId.setClientId(clientId);
- seOpenId.setOpenId(openid);
- seOpenId.setSessionKey(sessionKey);
- seOpenId.setCreateTime(new Date());
- //Long SessionId = clientSv.addOpenId(seOpenId);
- Long rec = clientSv.addOpenId(seOpenId);
- if(rec != null) {
- SessionId = String.valueOf(rec);
- }
- return BaseResponseUtils.buildSuccess(SessionId);
-
- } else {
- return BaseResponseUtils.buildError(SellResultCode.PHONE_NUMBER_IS_ERROR.getMessage());
- }
- }
-
- /**
- * 鑾峰彇鍐滄埛鍩烘湰淇℃伅锛屽皬绋嬪簭棣栭〉浣跨敤
- * @param sessionId
- * @return
- */
- @GetMapping(path = "/simple_info")
- @SsoAop()
- public BaseResponse<VoClientWechat> getSimpleClientInfo(@RequestParam Long sessionId){
- try {
- VoClientWechat res = clientSv.getSimpleClientInfo(sessionId, null);
- return BaseResponseUtils.buildSuccess(res);
- } catch (Exception e) {
- log.error("鏌ヨ鍐滄埛寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
- }
- }
-
- /**
- * 鐧诲綍鍑瘉鐧诲綍
- * @param code 涓存椂鐧诲綍鍑瘉
- * @return
- */
- @GetMapping(path = "/code_login")
- @SsoAop()
- public BaseResponse<VoClientWechat> codeLogin(@RequestParam String code) throws IOException {
-
- // 鐧诲綍鍑瘉鏍¢獙
- Map<String, Object> queryParams = new HashMap<>();
- queryParams.put("appid", appid);
- queryParams.put("secret", secret);
- queryParams.put("js_code", code);
- queryParams.put("grant_type", grantType);
- Map<String, String> headerParams = new HashMap<>();
- JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams);
-
- String openId = job.getString("openid");
- if(openId == null) {
- return BaseResponseUtils.buildFail(SellResultCode.LOGIN_FAIL.getMessage());
- }
-
- try {
- VoClientWechat res = clientSv.getSimpleClientInfo(null, openId);
- return BaseResponseUtils.buildSuccess(res);
- } catch (Exception e) {
- log.error("鏌ヨ鍐滄埛寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
- }
- }
-
-
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientSv.java
index 1753ae1..0ae07c7 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientSv.java
@@ -4,13 +4,10 @@
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper;
import com.dy.pipIrrGlobal.daoSe.SeClientMapper;
-import com.dy.pipIrrGlobal.daoSe.SeCodeVerifyMapper;
import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper;
import com.dy.pipIrrGlobal.pojoSe.SeClient;
-import com.dy.pipIrrGlobal.pojoSe.SeCodeVerify;
import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
import com.dy.pipIrrGlobal.voSe.VoClient;
-import com.dy.pipIrrGlobal.voSe.VoClientWechat;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,13 +33,10 @@
private BaDistrictMapper baDistrictMapper;
@Autowired
- private SeCodeVerifyMapper seCodeVerifyMapper;
+ private BaSettingsMapper baSettingsMapper;
@Autowired
private SeOpenIdMapper seOpenIdMapper;
-
- @Autowired
- private BaSettingsMapper baSettingsMapper;
/**
* 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍐滄埛鏁版嵁
@@ -82,23 +76,6 @@
return seClientMapper.insertSelective(po);
}
- /**
- * 娣诲姞楠岃瘉鐮佽褰�
- * @param po
- * @return
- */
- public Integer addCodeVerify(SeCodeVerify po) {
- return seCodeVerifyMapper.insert(po);
- }
-
- /**
- * 鏍规嵁鎵嬫満鍙疯幏鍙栭獙璇佺爜楠岃瘉瀵硅薄
- * @param phoneNumber
- * @return
- */
- public SeCodeVerify getCodeVerify(String phoneNumber) {
- return seCodeVerifyMapper.getCodeVerify(phoneNumber);
- }
/**
* 鏍规嵁6浣嶅尯鍒掍覆妯$硦鏌ヨ鍐滄埛缂栧彿
* @param district6
@@ -159,6 +136,15 @@
}
/**
+ * 鏍规嵁閰嶇疆椤硅幏鍙栭厤缃」鍊�
+ * @param itemName
+ * @return
+ */
+ public String getItemValue(String itemName) {
+ return baSettingsMapper.getItemValue(itemName);
+ }
+
+ /**
* 鏍规嵁鐢佃瘽鍙风爜鑾峰彇鍐滄埛ID
* @param phoneNumber
* @return
@@ -176,23 +162,5 @@
seOpenIdMapper.insert(po);
//return po.getClientId();
return po.getId();
- }
-
- /**
- * 鏍规嵁閰嶇疆椤硅幏鍙栭厤缃」鍊�
- * @param itemName
- * @return
- */
- public String getItemValue(String itemName) {
- return baSettingsMapper.getItemValue(itemName);
- }
-
- /**
- * 鑾峰彇鍐滄埛鍩烘湰淇℃伅锛屽皬绋嬪簭棣栭〉浣跨敤
- * @param sessionId
- * @return
- */
- public VoClientWechat getSimpleClientInfo(Long sessionId, String openId) {
- return seClientMapper.getSimpleClientInfo(sessionId, openId);
}
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java
index f991269..cbd7e67 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java
@@ -124,23 +124,7 @@
No_TRADE_SUMMARIES(100001, "娌℃湁绗﹀悎鏉′欢鐨勪氦鏄撴眹鎬昏褰�"),
No_TRADE_DETAILS(100001, "娌℃湁绗﹀悎鏉′欢鐨勪氦鏄撴槑缁�"),
- /**
- * 寰俊鐢ㄦ埛
- */
- PHONE_NUMBER_CANNOT_BE_NULL(20001, "鎵嬫満鍙蜂笉鑳戒负绌�"),
- SECURITY_CODE_SEND_FAIL(20001, "楠岃瘉鐮佸彂閫佸け璐�"),
- VERIFY_PARAMS_INCOMPLETE(20001, "楠岃瘉鍙傛暟涓嶅畬鏁�"),
- CODE_VERIFY_FAIL(20001, "楠岃瘉鐮佹牎楠屽け璐�"),
-
- NO_SECURITY_CODE_FOR_PHONE(20002, "璇ユ墜鏈哄彿鏈彂閫侀獙璇佺爜"),
- SECURITY_CODE_ERROR(20003, "楠岃瘉鐮侀敊璇�"),
- VALIDATION_TIMEOUT(20004, "楠岃瘉瓒呮椂"),
- PHONE_NUMBER_IS_ERROR(20004, "鎵嬫満鍙烽敊璇紝闈炴敞鍐屽啘鎴�"),
-
- /**
- * 灏忕▼搴�
- */
- LOGIN_FAIL(20004, "鐧诲綍澶辫触");
+ PHONE_NUMBER_IS_ERROR(20004, "鎵嬫満鍙烽敊璇紝闈炴敞鍐屽啘鎴�");
private final Integer code;
private final String message;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java
new file mode 100644
index 0000000..aa43460
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java
@@ -0,0 +1,231 @@
+package com.dy.pipIrrWechat.client;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pipIrrGlobal.pojoSe.SeCodeVerify;
+import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
+import com.dy.pipIrrGlobal.voSe.VoClientWechat;
+import com.dy.pipIrrSell.wechatpay.PayInfo;
+import com.dy.pipIrrWechat.client.dto.CodeLoginDTO;
+import com.dy.pipIrrWechat.client.dto.CodeVerifyDTO;
+import com.dy.pipIrrWechat.result.WechatResultCode;
+import com.dy.pipIrrWechat.sms.AliyunSmsSv;
+import com.dy.pipIrrWechat.sms.RandomCode;
+import com.dy.pipIrrWechat.util.RestTemplateUtil;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-19 14:21
+ * @LastEditTime 2024-06-19 14:21
+ * @Description
+ */
+
+@Slf4j
+@Tag(name = "鍐滄埛鏁版嵁鎿嶄綔", description = "鍐滄埛鏁版嵁鎿嶄綔")
+@RestController
+@RequestMapping(path="client")
+@RequiredArgsConstructor
+public class ClientCtrl {
+ private final ClientSv clientSv;
+ private final AliyunSmsSv aliyunSmsSv;
+ private final RestTemplateUtil restTemplateUtil;
+ private final String privateCertFileName = PayInfo.privateCertFileName;
+ private final String appid = PayInfo.appid;
+ private final String secret = PayInfo.secret;
+ private final String mchid = PayInfo.mchid;
+ private final String schema = PayInfo.schema;
+ private final String signType = PayInfo.signType;
+ private final String description = PayInfo.description;
+ private final String loginUrl = PayInfo.loginUrl;
+ private final String notifyUrl = PayInfo.notifyUrl;
+ private final String grantType = PayInfo.grantType;
+
+ /**
+ * 鐧诲綍鍑瘉鐧诲綍
+ * @param po
+ * @param bindingResult
+ * @return
+ * @throws IOException
+ */
+ @PostMapping(path = "code_login", consumes = MediaType.APPLICATION_JSON_VALUE)
+ public BaseResponse<JSONObject> codeLogin(@RequestBody @Valid CodeLoginDTO po, BindingResult bindingResult) throws IOException {
+ if(bindingResult != null && bindingResult.hasErrors()){
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ String code = po.getCode();
+
+ // 鐧诲綍鍑瘉鏍¢獙
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("appid", appid);
+ queryParams.put("secret", secret);
+ queryParams.put("js_code", code);
+ queryParams.put("grant_type", grantType);
+ Map<String, String> headerParams = new HashMap<>();
+ JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams);
+
+ if(job.containsKey("errmsg ")) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.INVALID_CODE.getMessage());
+ }
+
+ String openId = job.getString("openid");
+ if(openId == null) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.LOGIN_FAIL.getMessage());
+ }
+
+ try {
+ JSONObject job_client = new JSONObject();
+ VoClientWechat res = clientSv.getSimpleClientInfo(null, openId);
+ if(res != null) {
+ job_client.put("client", res);
+ } else {
+ VoClientWechat voClientWechat = new VoClientWechat();
+ job_client.put("client", voClientWechat);
+ }
+ return BaseResponseUtils.buildSuccess(job_client);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍐滄埛寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ }
+
+ /**
+ * 鍙戦�侀獙璇佺爜
+ * @param phoneNumber
+ * @return
+ */
+ @PostMapping(path = "send_sms")
+ public BaseResponse<Boolean> sendSms(@RequestParam(name = "phoneNumber", required = true) String phoneNumber) throws ClientException {
+ if(phoneNumber == null || phoneNumber.length() <= 0) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.PHONE_NUMBER_CANNOT_BE_NULL.getMessage());
+ }
+
+ // 鐢熸垚6浣嶉獙璇佺爜骞惰浆涓篔son鏍煎紡
+ String securityCode = String.valueOf(RandomCode.genCode());
+ JSONObject param = new JSONObject();
+ param.put("code", securityCode);
+ String templateParam = param.toJSONString();
+
+ //redisUtils.set(phoneNumber, securityCode, 60);
+
+ // 鑾峰彇褰撳墠鏃堕棿鎴冲苟寤跺悗3鍒嗛挓
+ Long timestamp = System.currentTimeMillis();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(timestamp);
+ calendar.add(Calendar.SECOND, 180);
+ Long expires = calendar.getTimeInMillis();
+
+ SeCodeVerify codeVerify = new SeCodeVerify();
+ codeVerify.setPhoneNumber(phoneNumber);
+ codeVerify.setSecurityCode(securityCode);
+ codeVerify.setExpires(expires);
+ clientSv.addCodeVerify(codeVerify);
+
+ SendSmsResponse response = aliyunSmsSv.sendSms(phoneNumber, templateParam);
+ if (response.getCode().equals("OK")) {
+ // 鍙戦�佹垚鍔熷鐞嗛�昏緫
+ return BaseResponseUtils.buildSuccess(true) ;
+ } else {
+ // 鍙戦�佸け璐ュ鐞嗛�昏緫
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.SECURITY_CODE_SEND_FAIL.getMessage()) ;
+ }
+ }
+
+ /**
+ * 鏍¢獙楠岃瘉鐮�
+ * @param po
+ * @param bindingResult
+ * @return
+ * @throws IOException
+ */
+ @PostMapping(path = "verify", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ public BaseResponse<Boolean> verify(@RequestBody @Valid CodeVerifyDTO po, BindingResult bindingResult) throws IOException {
+ if(bindingResult != null && bindingResult.hasErrors()){
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+
+ String phoneNumber = po.getPhoneNumber();
+ String securityCode = po.getSecurityCode();
+ String code = po.getCode();
+
+ // 杩涜鎵嬫満鍙枫�侀獙璇佺爜銆佽繃鏈熸椂闂存牎楠�
+ SeCodeVerify codeVerify = clientSv.getCodeVerify(phoneNumber);
+ if(codeVerify == null) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.NO_SECURITY_CODE_FOR_PHONE.getMessage());
+ }
+
+ if(!codeVerify.getSecurityCode().equals(securityCode)) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.SECURITY_CODE_ERROR.getMessage());
+ }
+
+ Long currentTimestamp = System.currentTimeMillis();
+ if(currentTimestamp > codeVerify.getExpires() ) {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.VALIDATION_TIMEOUT.getMessage());
+ }
+
+ // 鏍¢獙閫氳繃锛岃繘琛岀櫥褰曞嚟璇佹牎楠�
+ Map<String, Object> queryParams = new HashMap<>();
+ queryParams.put("appid", appid);
+ queryParams.put("secret", secret);
+ queryParams.put("js_code", code);
+ queryParams.put("grant_type", grantType);
+ Map<String, String> headerParams = new HashMap<>();
+ JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams);
+
+ if(job.getLong("errcode") != null && job.getLong("errcode") >= -1) {
+ return BaseResponseUtils.buildErrorMsg("鐧诲綍鍑瘉鏍¢獙澶辫触");
+ }
+ String openid = job.getString("openid");
+ String sessionKey = job.getString("session_key");
+
+ Long clientId = clientSv.getClientIdByPhone(phoneNumber);
+ String SessionId = "";
+ if(clientId != null) {
+ // 娣诲姞寰俊鐢ㄦ埛璐︽埛璁板綍
+ SeOpenId seOpenId = new SeOpenId();
+ seOpenId.setClientId(clientId);
+ seOpenId.setOpenId(openid);
+ seOpenId.setSessionKey(sessionKey);
+ seOpenId.setCreateTime(new Date());
+ //Long SessionId = clientSv.addOpenId(seOpenId);
+ Long rec = clientSv.addOpenId(seOpenId);
+ if(rec != null) {
+ SessionId = String.valueOf(rec);
+ }
+ return BaseResponseUtils.buildSuccess(SessionId);
+
+ } else {
+ return BaseResponseUtils.buildErrorMsg(WechatResultCode.PHONE_NUMBER_IS_ERROR.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇鍐滄埛鍩烘湰淇℃伅锛屽皬绋嬪簭棣栭〉浣跨敤
+ * @param sessionId
+ * @return
+ */
+ @GetMapping(path = "/simple_info")
+ public BaseResponse<VoClientWechat> getSimpleClientInfo(@RequestParam Long sessionId){
+ try {
+ VoClientWechat res = clientSv.getSimpleClientInfo(sessionId, null);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍐滄埛寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java
new file mode 100644
index 0000000..fbe5234
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java
@@ -0,0 +1,76 @@
+package com.dy.pipIrrWechat.client;
+
+import com.dy.pipIrrGlobal.daoSe.SeClientMapper;
+import com.dy.pipIrrGlobal.daoSe.SeCodeVerifyMapper;
+import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper;
+import com.dy.pipIrrGlobal.pojoSe.SeCodeVerify;
+import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
+import com.dy.pipIrrGlobal.voSe.VoClientWechat;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-19 14:25
+ * @LastEditTime 2024-06-19 14:25
+ * @Description
+ */
+
+@Slf4j
+@Service
+public class ClientSv {
+ @Autowired
+ private SeClientMapper seClientMapper;
+ @Autowired
+ private SeCodeVerifyMapper seCodeVerifyMapper;
+ @Autowired
+ private SeOpenIdMapper seOpenIdMapper;
+
+ /**
+ * 鏍规嵁鐢佃瘽鍙风爜鑾峰彇鍐滄埛ID
+ * @param phoneNumber
+ * @return
+ */
+ public Long getClientIdByPhone(String phoneNumber) {
+ return seClientMapper.getClientIdByPhone(phoneNumber);
+ }
+
+ /**
+ * 娣诲姞寰俊鐢ㄦ埛璐︽埛璁板綍
+ * @param po
+ * @return
+ */
+ public Long addOpenId(SeOpenId po) {
+ seOpenIdMapper.insert(po);
+ //return po.getClientId();
+ return po.getId();
+ }
+
+ /**
+ * 娣诲姞楠岃瘉鐮佽褰�
+ * @param po
+ * @return
+ */
+ public Integer addCodeVerify(SeCodeVerify po) {
+ return seCodeVerifyMapper.insert(po);
+ }
+
+ /**
+ * 鏍规嵁鎵嬫満鍙疯幏鍙栭獙璇佺爜楠岃瘉瀵硅薄
+ * @param phoneNumber
+ * @return
+ */
+ public SeCodeVerify getCodeVerify(String phoneNumber) {
+ return seCodeVerifyMapper.getCodeVerify(phoneNumber);
+ }
+
+ /**
+ * 鑾峰彇鍐滄埛鍩烘湰淇℃伅锛屽皬绋嬪簭棣栭〉浣跨敤
+ * @param sessionId
+ * @return
+ */
+ public VoClientWechat getSimpleClientInfo(Long sessionId, String openId) {
+ return seClientMapper.getSimpleClientInfo(sessionId, openId);
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeLoginDTO.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeLoginDTO.java
new file mode 100644
index 0000000..9eb554a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeLoginDTO.java
@@ -0,0 +1,20 @@
+package com.dy.pipIrrWechat.client.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-19 15:57
+ * @LastEditTime 2024-06-19 15:57
+ * @Description
+ */
+
+@Data
+public class CodeLoginDTO {
+ /**
+ * 涓存椂鐧诲綍鍑瘉
+ */
+ @NotBlank(message = "涓存椂鐧诲綍鍑瘉涓嶈兘涓虹┖")
+ private String code;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/dto/CodeVerifyDTO.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeVerifyDTO.java
similarity index 93%
rename from pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/dto/CodeVerifyDTO.java
rename to pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeVerifyDTO.java
index fa660bf..603073a 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/dto/CodeVerifyDTO.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/dto/CodeVerifyDTO.java
@@ -1,4 +1,4 @@
-package com.dy.pipIrrSell.client.dto;
+package com.dy.pipIrrWechat.client.dto;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
index d881f14..d3fc309 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
@@ -476,7 +476,7 @@
* @return
*/
@GetMapping(path = "/get")
- @SsoAop()
+ //@SsoAop()
public BaseResponse<List<VoUnclosedValve>> getUnclosedValves(@RequestParam Long operator){
try {
List<VoUnclosedValve> res = commandSv.getUnclosedValves(operator);
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/config/WebFilterConfiguration.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/config/WebFilterConfiguration.java
index c724dae..b0f0226 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/config/WebFilterConfiguration.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/config/WebFilterConfiguration.java
@@ -1,9 +1,7 @@
package com.dy.pipIrrWechat.config;
-import com.dy.common.webFilter.DevOfDataSourceNameSetFilter;
-import com.dy.common.webFilter.UserTokenFilter;
+import com.dy.common.webFilter.WXDataSourceNameSetFilter;
import jakarta.servlet.Filter;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -16,35 +14,14 @@
*/
@Configuration
public class WebFilterConfiguration {
-
- @Value("${pipIrr.global.dev}")
- public String isDevStage ;//鏄惁涓哄紑鍙戦樁娈�
- @Value("${pipIrr.global.dsName}")
- public String dsName ;//寮�鍙戦樁娈电殑鏁版嵁婧愬悕绉�
-
- /**
- * DevOfDataSourceNameSetFilter涓嶶serTokenFilter鍙兘涓�涓閰嶇疆涓婏紝
- * 鎵�浠ヤ粬浠殑order閮芥槸1
- */
- private static final int order_UserTokenFilter = 1 ;//涓庝笅闈�
- private static final int order_DevOfDataSourceNameSetFilter = 1 ;
-
-
@Bean
public FilterRegistrationBean<? extends Filter> RegFilter() {
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
- if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){
- filterRegistrationBean.setFilter(new DevOfDataSourceNameSetFilter());
- filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯
- filterRegistrationBean.addInitParameter("dataSourceName",dsName);//璁剧疆init鍙傛暟
- filterRegistrationBean.setName("DevOfDataSourceNameSetFilter");//璁剧疆杩囨护鍣ㄥ悕绉�
- filterRegistrationBean.setOrder(order_DevOfDataSourceNameSetFilter);//鎵ц娆″簭
- }else{
- filterRegistrationBean.setFilter(new UserTokenFilter());
- filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯
- filterRegistrationBean.setName("UserTokenFilter");//璁剧疆杩囨护鍣ㄥ悕绉�
- filterRegistrationBean.setOrder(order_UserTokenFilter);//鎵ц娆″簭
- }
+ filterRegistrationBean.setFilter(new WXDataSourceNameSetFilter());
+ filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯
+ filterRegistrationBean.setName("WXDataSourceNameSetFilter");//璁剧疆杩囨护鍣ㄥ悕绉�
+ filterRegistrationBean.setOrder(1);//鎵ц娆″簭
+
return filterRegistrationBean;
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java
new file mode 100644
index 0000000..45ee4ed
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeCtrl.java
@@ -0,0 +1,63 @@
+package com.dy.pipIrrWechat.intake;
+
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
+import com.dy.pipIrrWechat.intake.qo.OnLineIntakesQO;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-20 8:37
+ * @LastEditTime 2024-06-20 8:37
+ * @Description
+ */
+
+@Slf4j
+@Tag(name = "鍙栨按鍙f暟鎹搷浣�", description = "鍙栨按鍙f暟鎹搷浣�")
+@RestController
+@RequestMapping(path="intake")
+@RequiredArgsConstructor
+public class IntakeCtrl {
+ private final IntakeSv intakeSv;
+
+ /**
+ * 鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鍜屼笉鍦ㄧ嚎锛�
+ * @param qo
+ * @return
+ */
+ @GetMapping(path = "all_intakes")
+ public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
+ try {
+ QueryResultVo<List<VoOnLineIntake>> res = intakeSv.selectOnLineIntakes(qo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛锛堝湪绾垮拰涓嶅湪绾匡級
+ * @param operator
+ * @return
+ */
+ @GetMapping(path = "used_intakes")
+ public BaseResponse<List<VoOnLineIntake>> getUsedIntakes(Long operator) {
+ try {
+ List<VoOnLineIntake> res = intakeSv.getUsedIntakes(operator);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java
new file mode 100644
index 0000000..0e6fd7f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/IntakeSv.java
@@ -0,0 +1,134 @@
+package com.dy.pipIrrWechat.intake;
+
+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.PrIntakeMapper;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
+import com.dy.pipIrrWechat.intake.qo.OnLineIntakesQO;
+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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-20 8:37
+ * @LastEditTime 2024-06-20 8:37
+ * @Description
+ */
+
+@Slf4j
+@Service
+public class IntakeSv {
+ @Autowired
+ private PrIntakeMapper prIntakeMapper;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send" ;
+
+ /**
+ * 鑾峰彇鍙栨按鍙e垪琛�
+ * @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;
+ }
+ }
+
+ /**
+ * 鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛
+ * @param operator
+ * @return
+ */
+ public List<VoOnLineIntake> getUsedIntakes(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);
+ }
+ return prIntakeMapper.getUsedIntakes(jsonArray.toJSONString(), operator);
+ } else {
+ return new ArrayList<>();
+ }
+ }
+
+ /**
+ * 鍙戦�佸懡浠�
+ * @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();
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/qo/OnLineIntakesQO.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/qo/OnLineIntakesQO.java
new file mode 100644
index 0000000..e305015
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/intake/qo/OnLineIntakesQO.java
@@ -0,0 +1,33 @@
+package com.dy.pipIrrWechat.intake.qo;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import jakarta.validation.constraints.Max;
+import jakarta.validation.constraints.Min;
+import lombok.Data;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-06-20 8:53
+ * @LastEditTime 2024-06-20 8:53
+ * @Description
+ */
+
+@Data
+public class OnLineIntakesQO extends QueryConditionVo {
+ /**
+ * 涓棿浠惰繑鍥炵殑RTU鍦ㄧ嚎鎯呭喌瀵硅薄鏁扮粍
+ */
+ private String onLineMap;
+
+ /**
+ * 鍙栨按鍙g紪鍙�
+ */
+ private String intakeNum;
+
+ /**
+ * 鏄惁鍦ㄧ嚎
+ */
+ @Max(value = 1,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
+ @Min(value = 0,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
+ private Boolean isOnLine;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java
index 7c23a12..1b61317 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java
@@ -25,9 +25,24 @@
/**
* RTU
*/
- RTU_NOT_EXIST(20001, "闃�鎺у櫒涓嶅瓨鍦�");
+ RTU_NOT_EXIST(20001, "闃�鎺у櫒涓嶅瓨鍦�"),
//RTU_ADDR_CANNOT_BE_NULL(20002, "闃�鎺у櫒鍦板潃涓嶈兘涓虹┖");
+ /**
+ * 寰俊鐢ㄦ埛
+ */
+ PHONE_NUMBER_CANNOT_BE_NULL(20001, "鎵嬫満鍙蜂笉鑳戒负绌�"),
+ SECURITY_CODE_SEND_FAIL(20001, "楠岃瘉鐮佸彂閫佸け璐�"),
+ VERIFY_PARAMS_INCOMPLETE(20001, "楠岃瘉鍙傛暟涓嶅畬鏁�"),
+ CODE_VERIFY_FAIL(20001, "楠岃瘉鐮佹牎楠屽け璐�"),
+
+ NO_SECURITY_CODE_FOR_PHONE(20002, "璇ユ墜鏈哄彿鏈彂閫侀獙璇佺爜"),
+ SECURITY_CODE_ERROR(20003, "楠岃瘉鐮侀敊璇�"),
+ VALIDATION_TIMEOUT(20004, "楠岃瘉瓒呮椂"),
+ PHONE_NUMBER_IS_ERROR(20004, "鎵嬫満鍙烽敊璇紝闈炴敞鍐屽啘鎴�"),
+ INVALID_CODE(20004, "鏃犳晥鐨勪复鏃剁櫥褰曞嚟璇�"),
+ LOGIN_FAIL(20004, "鐧诲綍澶辫触");
+
private final Integer code;
private final String message;
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/AliyunSmsSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/AliyunSmsSv.java
similarity index 97%
rename from pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/AliyunSmsSv.java
rename to pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/AliyunSmsSv.java
index 6012b0b..a0de838 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/AliyunSmsSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/AliyunSmsSv.java
@@ -1,4 +1,4 @@
-package com.dy.pipIrrSell.sms;
+package com.dy.pipIrrWechat.sms;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/RandomCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/RandomCode.java
similarity index 89%
rename from pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/RandomCode.java
rename to pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/RandomCode.java
index f2049c8..7cc3f9b 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/RandomCode.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/sms/RandomCode.java
@@ -1,4 +1,4 @@
-package com.dy.pipIrrSell.sms;
+package com.dy.pipIrrWechat.sms;
/**
* @author ZhuBaoMin
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/util/RestTemplateUtil.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/util/RestTemplateUtil.java
new file mode 100644
index 0000000..04710fd
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/util/RestTemplateUtil.java
@@ -0,0 +1,115 @@
+package com.dy.pipIrrWechat.util;
+
+import com.alibaba.fastjson2.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.stereotype.Component;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-03-06 13:47
+ * @LastEditTime 2024-03-06 13:47
+ * @Description
+ */
+
+@Component
+public class RestTemplateUtil {
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ //@Qualifier("RestTemplateWithCert")
+ //@Resource
+ //private RestTemplate restTemplate;
+
+ public JSONObject get(String url, Map<String, Object> queryParams) throws IOException {
+ return get(url, queryParams, new HashMap<>(1));
+ }
+
+ public JSONObject get(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException {
+ String tempUrl = setParamsByAppendUrl(queryParams, url);
+ HttpHeaders headers = new HttpHeaders();
+ headerParams.forEach(headers::add);
+ HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers);
+ ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class);
+ return JSONObject.parseObject(response.getBody());
+ }
+
+ public JSONObject getHeaders(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException {
+ String tempUrl = setParamsByAppendUrl(queryParams, url);
+ HttpHeaders headers = new HttpHeaders();
+ headerParams.forEach(headers::add);
+ HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers);
+ ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("headers", response.getHeaders());
+ jsonObject.put("body", response.getBody());
+ return jsonObject;
+ }
+
+ public JSONObject get2(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException {
+ String tempUrl = setParamsByPath(queryParams, url);
+ HttpHeaders headers = new HttpHeaders();
+ headerParams.forEach(headers::add);
+ HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers);
+ ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class, queryParams);
+ return JSONObject.parseObject(response.getBody());
+ }
+
+ public JSONObject post(String url, String json, Map<String, String> headerParams) {
+ HttpHeaders headers = new HttpHeaders();
+ headerParams.forEach(headers::add);
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+ HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
+ ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+ return JSONObject.parseObject(response.getBody());
+ }
+
+ private String setParamsByPath(Map<String, Object> queryParams, String url) {
+ // url?id={id}&name={name}
+ if (queryParams == null || queryParams.isEmpty()) {
+ return url;
+ }
+ StringBuilder sb = new StringBuilder();
+ try {
+ for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+ sb.append("&").append(entry.getKey()).append("=").append("{").append(entry.getKey()).append("}");
+ }
+ if (!url.contains("?")) {
+ sb.deleteCharAt(0).insert(0, "?");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return url + sb;
+ }
+
+ private String setParamsByAppendUrl(Map<String, Object> queryParams, String url) {
+ // url?id=1&name=zzc
+ if (queryParams == null || queryParams.isEmpty()) {
+ return url;
+ }
+ StringBuilder sb = new StringBuilder();
+ try {
+ for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+ sb.append("&").append(entry.getKey()).append("=");
+ sb.append(entry.getValue());
+ }
+ if (!url.contains("?")) {
+ sb.deleteCharAt(0).insert(0, "?");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return url + sb;
+ }
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
index f36e52a..a591cdf 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/resources/application.yml
@@ -16,3 +16,10 @@
idSuffix: ${pipIrr.wechat.idSuffix}
#ConfigListener涓簲鐢�
#configFileNames: config-global.xml,config-demo.xml
+#闃块噷鐭俊鏈嶅姟
+aliyun:
+ sms:
+ sms-access-key-id: LTAI5tPCmHqfyJ9YnoPorEwt
+ sms-access-key-secret: sU2CoLdNgcjnf5uPPU2dY7NNGNvOIX
+ sms-template-code: SMS_460776024
+ sms-sign-name: 澶х鑺傛按
\ No newline at end of file
--
Gitblit v1.8.0