From 68057e752bd9767e76c021610966719e3a227467 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 20 二月 2025 10:31:49 +0800
Subject: [PATCH] 111

---
 server/web/src/main/java/com/doumee/api/web/BusinessApi.java               |   13 +++++-
 server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java |    2 
 server/web/src/main/java/com/doumee/task/ScheduleTool.java                 |   27 +++++++++----
 server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java  |   32 +++++++++++----
 server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java |   22 +++++++++++
 server/services/src/main/java/com/doumee/core/utils/PositionUtil.java      |    1 
 6 files changed, 77 insertions(+), 20 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java b/server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java
index 583a55a..6db6cd0 100644
--- a/server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java
+++ b/server/services/src/main/java/com/doumee/core/dingding/DingDingNotice.java
@@ -10,6 +10,7 @@
 import com.doumee.dao.business.model.Sites;
 import com.doumee.dao.business.web.request.RepairRequest;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
@@ -18,6 +19,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Created by IntelliJ IDEA.
@@ -91,6 +93,26 @@
     }
 
 
+    public static void lowVoltageNotice(String bikeCode,String place,String siteName,String token,String robotCode,String chatToken)throws Exception{
+        String desc = "銆愪綆鐢甸噺鎻愰啋銆戣溅杈嗙紪鍙凤細{杞﹁締缂栧彿}锛屽綋鍓嶄綅缃細{瀹氫綅浣嶇疆}锛屽綋鍓嶇珯鐐癸細{绔欑偣鍚嶇О}銆�";
+        if(StringUtils.isBlank(bikeCode)){
+            return;
+        }
+        desc.replace("{杞﹁締缂栧彿}",bikeCode);
+        if(StringUtils.isNotBlank(place)){
+           desc.replace("{瀹氫綅浣嶇疆}",place);
+        }else{
+            desc.replace("{瀹氫綅浣嶇疆}","鏈煡");
+        }
+        if(StringUtils.isNotBlank(siteName)){
+            desc.replace("{绔欑偣鍚嶇О}",siteName);
+        }else{
+            desc.replace("{绔欑偣鍚嶇О}","鏈煡");
+        }
+        sendNoticeNew(desc,token,robotCode,chatToken);
+    }
+
+
     /**
      * 閽夐拤閫氱煡 - 绔欑偣鍌ㄨ溅鍛婅
      * @param siteName
diff --git a/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java b/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
index fdd1f5f..98f387a 100644
--- a/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
+++ b/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
@@ -13,6 +13,7 @@
  * 璁$畻璺濈
  */
 public class PositionUtil {
+
     public static String getTxMapAddrByLatAndLng(Double lat,Double lng,String host,String mapkey){
         try {
             if(lat == null || lng ==null){
diff --git a/server/web/src/main/java/com/doumee/api/web/BusinessApi.java b/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
index 8aa7b36..e4e531a 100644
--- a/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
@@ -136,7 +136,7 @@
 
     @LoginRequired
     @ApiOperation(value = "鐑攢濂楅", notes = "鐑攢濂楅")
-    @GetMapping("/discountPage")
+    @PostMapping("/discountPage")
     @ApiImplicitParams({
             @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true)
     })
@@ -147,7 +147,16 @@
         return ApiResponse.success(discountService.findPage(pageWrap));
     }
 
-
+    @LoginRequired
+    @ApiOperation(value = "濂楅璇︽儏", notes = "濂楅璇︽儏")
+    @GetMapping("/discountDetail")
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true),
+            @ApiImplicitParam(paramType = "query", dataType = "String", name = "id", value = "濂楅涓婚敭", required = true)
+    })
+    public ApiResponse<Discount> discountPage (@RequestParam String id) {
+        return ApiResponse.success(discountService.findById(id));
+    }
 
 
     @LoginRequired
diff --git a/server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java b/server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java
index 87e908e..c565b42 100644
--- a/server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java
+++ b/server/web/src/main/java/com/doumee/jtt808/web/endpoint/JT808Endpoint.java
@@ -130,7 +130,7 @@
      */
     @AsyncBatch(poolSize = 2, maxElements = 4000, maxWait = 1000)
     @Mapping(types = 浣嶇疆淇℃伅姹囨姤, desc = "浣嶇疆淇℃伅姹囨姤")
-    public void T0200(List<T0200> list) {
+    public void T0200(List<T0200> list) throws Exception {
         jtt808Service.updateBikesInfo(list);
         System.out.println(JSONObject.toJSONString(list)
       );
diff --git a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
index 5e9d50d..f0138dd 100644
--- a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
+++ b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
@@ -8,12 +8,14 @@
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.Constants;
 import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.dingding.DingDingNotice;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.PositionUtil;
 import com.doumee.core.utils.StringTools;
 import com.doumee.core.wx.WxMiniUtilService;
 import com.doumee.dao.business.*;
+import com.doumee.dao.business.join.BikesJoinMapper;
 import com.doumee.dao.business.join.GoodsorderJoinMapper;
 import com.doumee.dao.business.join.MemberRidesJoinMapper;
 import com.doumee.dao.business.join.RefundJoinMapper;
@@ -51,9 +53,9 @@
 
 @Service
 public class Jtt808Service {
-    @Value("${tencent.map.remoteHost:}")
+    @Value("${tencent.map.remoteHost}")
     private String mapHost;
-    @Value("${tencent.map.appKey:}")
+    @Value("${tencent.map.appKey}")
     private String mapKey;
     @Autowired
     private MessageManager messageManager;
@@ -61,6 +63,8 @@
     private GoodsorderService goodsorderService;
     @Autowired
     private BikesMapper bikesMapper;
+    @Autowired
+    private BikesJoinMapper bikesJoinMapper;
 
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
@@ -279,8 +283,12 @@
         }
     }
 
-    public void updateBikesInfo(List<T0200> list) {
+    public void updateBikesInfo(List<T0200> list) throws Exception{
         Date date = new Date();
+        BigDecimal lowVoltage = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.LOW_VOLTAGE).getCode());
+        String ddToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_TOKEN).getCode();
+        String ddRobotCode = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_ROBOTCODE).getCode();
+        String ddChatToken = systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_CHATTOKEN).getCode();
         for(T0200 m : list){
             Bikes bike = new Bikes();
             bike.setDeviceSn(m.getClientId());
@@ -321,6 +329,17 @@
                     .set(Bikes::getSiteId,site ==null?null:site.getId())
                     .set( Bikes::getHeartDate,date)
                     .eq(Bikes::getId,bikes.getId()));
+
+            if(bikes.getVoltage().compareTo(lowVoltage)>=Constants.ZERO
+                    && bike.getVoltage().compareTo(lowVoltage)<Constants.ZERO){
+                //鍙戦�侀拤閽夐�氱煡
+                DingDingNotice.lowVoltageNotice(bikes.getCode(),
+                        PositionUtil.getTxMapAddrByLatAndLng(Double.valueOf(bike.getLatitude().toString()),Double.valueOf(bike.getLongitude().toString()),mapHost,mapKey)
+                        ,Objects.nonNull(site)?site.getName():null,
+                        ddToken,
+                        ddRobotCode,
+                        ddChatToken);
+            }
         }
     }
 
@@ -503,7 +522,7 @@
                 .eq(Goodsorder::getStatus,Constants.ONE)
                 .eq(MemberRides::getIsdeleted,Constants.ZERO)
                 .eq(MemberRides::getType,Constants.ONE)
-                .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING)
+                .eq(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey())
                 .apply(" NOW() >= t.create_date  + INTERVAL '2 hours' ")
         );
 
@@ -536,11 +555,6 @@
             goodsorder.setEditor(null);
             goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides);
         }
-
-
-
-
-
     }
 
 
diff --git a/server/web/src/main/java/com/doumee/task/ScheduleTool.java b/server/web/src/main/java/com/doumee/task/ScheduleTool.java
index 006068b..51654b8 100644
--- a/server/web/src/main/java/com/doumee/task/ScheduleTool.java
+++ b/server/web/src/main/java/com/doumee/task/ScheduleTool.java
@@ -10,6 +10,7 @@
 import com.doumee.core.wx.WxPayProperties;
 import com.doumee.dao.business.model.Sites;
 import com.doumee.dao.system.model.SystemDictData;
+import com.doumee.jtt808.web.service.Jtt808Service;
 import com.doumee.service.business.*;
 import com.doumee.service.system.SystemDictDataService;
 import lombok.extern.slf4j.Slf4j;
@@ -30,22 +31,32 @@
  * @date 2021-10-10 14:40:35
  * https://www.bejson.com/othertools/cron/  cron 琛ㄨ揪寮忕敓鎴愬湴鍧�
  */
-//@Component
-//@EnableScheduling
+@Component
+@EnableScheduling
 @Slf4j
 public class ScheduleTool {
+
+    @Autowired
+    private Jtt808Service jtt808Service;
 
     /**
      * 绔欑偣杞﹁締婊℃灦鐜囬璀�
      * @throws Exception
      */
-    @Scheduled(fixedDelay = 1000L *20L )
-    public void reSubMqtt() throws Exception {
-        log.info("=====================妫�鏌ユ槸鍚﹂渶瑕侀噸鏂拌闃�===========start============");
-        MqttClientInit.isSubClientValid();
-        log.info("=====================妫�鏌ユ槸鍚﹂渶瑕侀噸鏂拌闃�===========end============");
-    }
+//    @Scheduled(fixedDelay = 1000L *20L )
+//    public void reSubMqtt() throws Exception {
+//        log.info("=====================妫�鏌ユ槸鍚﹂渶瑕侀噸鏂拌闃�===========start============");
+//        MqttClientInit.isSubClientValid();
+//        log.info("=====================妫�鏌ユ槸鍚﹂渶瑕侀噸鏂拌闃�===========end============");
+//    }
 
 
+    @Scheduled(fixedDelay = 1000L * 5L )
+    public void autoBackBike() throws Exception {
+        log.info("=====================涓存椂鍋滆溅瓒呮椂 鑷姩杩樿溅===========start============");
+        jtt808Service.autoBackBike();
+        log.info("=====================涓存椂鍋滆溅瓒呮椂 鑷姩杩樿溅===========end============");
+    }
+
 
 }

--
Gitblit v1.9.3