Kaynağa Gözat

feat:测试短信

wangweiyu 4 yıl önce
ebeveyn
işleme
95627fa3e1

+ 56 - 1
src/main/java/com/aoyang/tms/controller/TestController.java

@@ -1,8 +1,11 @@
 package com.aoyang.tms.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.aoyang.common.result.Result;
-import com.aoyang.tms.entity.WorkSpot;
+import com.aoyang.tms.entity.*;
+import com.aoyang.tms.feign.MessageFeign;
+import com.aoyang.tms.feign.result.SmsSendLog;
 import com.aoyang.tms.feign.result.TmsMongoDoc;
 import com.aoyang.tms.service.*;
 import com.aoyang.tms.util.RegionUtil;
@@ -38,7 +41,13 @@ public class TestController {
     @Resource
     private MongoTemplate mongoTemplate;
     @Resource
+    private MessageFeign messageFeign;
+    @Resource
     private CommonService commonService;
+    @Resource
+    private TruckEscortService truckEscortService;
+    @Resource
+    private TruckDriverService truckDriverService;
 
     @ApiOperation(value = "mongo查询车辆最新位置", notes = "")
     @PostMapping("/query_truck")
@@ -120,4 +129,50 @@ public class TestController {
         return new Result<>(commonService.longitudeToAddress(lat, lon));
     }
 
+    @ApiOperation(value = "根据经纬度查询位置", notes = "根据经纬度查询位置")
+    @PostMapping("/testSms")
+    public Result testSms(@RequestParam Long truckId) {
+        Truck truck = new Truck();
+        truck.setTruckId(truckId);
+        StringBuffer monbiles = new StringBuffer();
+        TruckEscort query = new TruckEscort();
+        query.setTruckId(truck.getTruckId());
+        TruckEscort truckEscort = truckEscortService.findTruckEscort(query);
+        if (truckEscort != null) {
+            log.info("Test truckEscort :{}", JSON.toJSONString(truckEscort));
+            monbiles.append("," + truckEscort.getMobile());
+        }
+        log.info("Test truckDrivers param truckId:{}", truck.getTruckId());
+        List<TruckDriver> truckDrivers = truckDriverService.findTruckDrivers(truck.getTruckId());
+        log.info("Test truckDrivers:{}", JSON.toJSONString(truckDrivers));
+        if (truckDrivers != null && truckDrivers.size() > 0) {
+            User user = commonService.findUser(truckDrivers.get(0).getDriverId());
+            log.info("Test get Dirver user:{} , param:{}", JSON.toJSONString(user), truckDrivers.get(0).getDriverId());
+            if (user != null) {
+                monbiles.append("," + user.getMobile());
+            }
+            if (truckDrivers.size() > 1) {
+                User user2 = commonService.findUser(truckDrivers.get(1).getDriverId());
+                if (user2 != null) {
+                    monbiles.append("," + user2.getMobile());
+                }
+            }
+        }
+
+        if (monbiles.length() > 0) {
+            // 发送短信
+            SmsSendLog smsSend = new SmsSendLog();
+            smsSend.setType(30);
+            JSONObject content = new JSONObject();
+            content.put("type", "装");
+            content.put("trans_id", "测试Test运单");
+            smsSend.setContent(JSON.toJSONString(content));
+            smsSend.setMobile(monbiles.substring(1));
+            log.info("Test 发送装车运单短信:{}", JSON.toJSONString(smsSend));
+            Result<Boolean> send = messageFeign.send(smsSend, null, null, null);
+            return send;
+        }
+        return new Result<>(false);
+    }
+
 }