Explorar el Código

微信端上报地址增加时间段

peiguo hace 3 años
padre
commit
0efbae121a

+ 2 - 3
whepi-web/src/main/java/com/bofeng/dao/MsSuspectedMapper.java

@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Author: xielianghe
@@ -65,7 +66,5 @@ public interface MsSuspectedMapper extends BaseMapper<MsSuspected> {
     List<MsTripDet> selectTripSuspected(@Param("suspectedId") Long suspectedId);
 
     //获取最近的定位
-    @Select("SELECT a.*,c.auto_local from ms_report a LEFT JOIN ms_suspected b ON a.report_id = b.report_id LEFT JOIN ms_trip c ON b.suspected_id " +
-            "= c.trip_id WHERE a.report_status = 1 AND a.user_create = #{userId} and c.auto_local != '' ORDER BY a.report_date DESC LIMIT 1")
-    MsSuspected selectLatelyAutoLocal(@Param("userId") Long userId);
+    MsSuspected selectLatelyAutoLocal(Map map);
 }

+ 21 - 2
whepi-web/src/main/java/com/bofeng/service/MsSuspectedService.java

@@ -10,14 +10,18 @@ import com.bofeng.entity.MsTripDet;
 import com.yvan.platform.Conv;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Author: xielianghe
@@ -28,6 +32,13 @@ import java.util.List;
 @Transactional(readOnly = true)
 public class MsSuspectedService {
 
+    /**
+     * 上报确定位置是否变更增加时间段判断
+     */
+    @Value("${submit.startTime}")
+    private String startTime;
+    @Value("${submit.endTime}")
+    private String endTime;
     @Autowired
     private MsSuspectedMapper msSuspectedMapper;
     @Autowired
@@ -43,8 +54,16 @@ public class MsSuspectedService {
 
     //获取最近的定位
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
-    public String getLatelyAutoLocal(long userId) {
-        MsSuspected msSuspected = msSuspectedMapper.selectLatelyAutoLocal(userId);
+    public String getLatelyAutoLocal(long userId) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Long now = System.currentTimeMillis();
+        Map map = new HashMap();
+        if (now >= sdf.parse(startTime).getTime() && now <= sdf.parse(endTime).getTime()) {
+            map.put("startTime", startTime);
+            map.put("endTime", endTime);
+        }
+        map.put("userId", userId);
+        MsSuspected msSuspected = msSuspectedMapper.selectLatelyAutoLocal(map);
         if (msSuspected != null) {
             return msSuspected.getAutoLocal();
         } else {

+ 2 - 1
whepi-web/src/main/java/com/bofeng/wx/controller/MsReportController.java

@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.servlet.http.HttpServletRequest;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -90,7 +91,7 @@ public class MsReportController {
 
     //查询家人
     @GetMapping("/home/selectSuspected")
-    public MsSuspected selectSuspected(HttpServletRequest request) {
+    public MsSuspected selectSuspected(HttpServletRequest request) throws ParseException {
         //初始化今日日报
         Long suspectedId = Long.parseLong(request.getParameter("suspectedId"));
         MsSuspected msSuspected = msSuspectedService.selectSuspected(suspectedId);

+ 3 - 0
whepi-web/src/main/resources/application.yml

@@ -39,6 +39,9 @@ server:
 endpoints:
   shutdown.enabled: false
 
+submit:
+  startTime: 2022-01-19 00:00:00
+  endTime: 2022-01-31 23:59:59
 #error:
 #  whitelabel.enabled: false
 

+ 16 - 0
whepi-web/src/main/resources/mapper/MsSuspected.xml

@@ -4,4 +4,20 @@
     <select id="selectByReportId" resultType="com.bofeng.entity.MsSuspected">
         select a.*,b.* from ms_suspected a left join ms_trip b on a.suspected_id=b.trip_id where a.report_id = #{reportId}
     </select>
+
+    <select id="selectLatelyAutoLocal" resultType="com.bofeng.entity.MsSuspected">
+        SELECT a.*,c.auto_local
+        from ms_report a
+            LEFT JOIN ms_suspected b ON a.report_id = b.report_id
+            LEFT JOIN ms_trip c ON b.suspected_id = c.trip_id
+        WHERE a.report_status = 1 AND a.user_create = #{userId}
+          and c.auto_local != ''
+        <if test="startTime!=null and startTime!=''">
+            and a.time_create <![CDATA[ >= ]]> #{startTime}
+        </if>
+        <if test="endTime!=null and endTime!=''">
+            and a.time_create <![CDATA[ <= ]]> #{endTime}
+        </if>
+        ORDER BY a.report_date DESC LIMIT 1
+    </select>
 </mapper>