瀏覽代碼

进出扫码1分钟内视为重复

peiguo 5 年之前
父節點
當前提交
b045027070

+ 8 - 0
whepi-web/src/main/java/com/bofeng/dao/OutScanEstateMapper.java

@@ -20,4 +20,12 @@ public interface OutScanEstateMapper extends BaseMapper<OutScanEstate> {
      */
     @Select("select * from out_scan_estate where day_date=curdate() and user_id=#{userId}")
     List<OutScanEstate> getOutScanEstateTodayByUser(@Param("userId") Long userId);
+
+    /**
+     * 最进一次扫码
+     * @param userId
+     * @return
+     */
+    @Select("SELECT * FROM out_scan_estate WHERE user_id = #{userId} order by time_create desc LIMIT 1")
+    OutScanEstate getOutScanEstatLately(@Param("userId") Long userId);
 }

+ 8 - 0
whepi-web/src/main/java/com/bofeng/dao/OutScanMapper.java

@@ -35,4 +35,12 @@ public interface OutScanMapper extends BaseMapper<OutScan> {
      */
     @Select("SELECT * FROM out_scan WHERE user_id = #{userId} and in_type = #{inType} and day_date > date_sub(curdate(),interval #{goOutFre} day) ORDER BY time_create DESC LIMIT 1")
     OutScan getOutScanThreeday(@Param("userId") Long userId, @Param("inType") Integer inType, @Param("goOutFre") Integer goOutFre);
+
+    /**
+     * 最进一次进出扫码
+     * @param userId
+     * @return
+     */
+    @Select("SELECT * FROM out_scan WHERE user_id = #{userId} and in_type = #{inType} order by time_create desc LIMIT 1")
+    OutScan getOutScanLately(@Param("userId") Long userId, @Param("inType") Integer inType);
 }

+ 40 - 8
whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java

@@ -105,12 +105,20 @@ public class ScanController {
                 model.put("errorMsg", "非本小区居民,禁止" + getMsg(inType) + "。");
                 return new ModelAndView("/user/scan.ftl", model);
             }
+            OutScan o = outScanMapper.getOutScanLately(userOpen.getUserId(), inType);
+            if (o != null && compareTime(o.getDate(),1)) {
+                model.put("collor", "orange");
+                model.put("into", "允许" + getMsg(inType));
+                model.put("errorMsg", "您最近一分钟已经扫码,本次扫码重复。");
+                return new ModelAndView("/user/scan.ftl", model);
+            }
             if (inType == 1) {
                 OutScan outScan = outScanMapper.getOutScanByUserlimit(userOpen.getUserId());
                 if (outScan != null && new Date(outScan.getDate().getMillis() + 3600L * 1000 * 24).compareTo(new Date()) == -1) {
                     model.put("collor", "orange");
                     model.put("into", "允许进入");
                     model.put("errorMsg", "您在外驻留时间超过1日,请尽快上报您的健康状况,防止在外长时间逗留。");
+                    scanService.saveOutScan(userOpen.getUserId(), inType, uptownDoor.getUptownId(), uptownDoor.getDoorId());
                     return new ModelAndView("/user/scan.ftl", model);
                 }
             }
@@ -131,6 +139,13 @@ public class ScanController {
                     model.put("errorMsg", "距您上次外出时间未满"+outScanConf.getGoOutFre()+"日,禁止外出,请配合。上次外出登记时间 "+sdf.format(new Date(outScan.getDate().getMillis()))+"。");
                     return new ModelAndView("/user/scan.ftl", model);
                 }
+                MsReport msReport = msReportMapper.selectMsReportToday(userOpen.getUserId());
+                if (msReport != null && msReport.getMsStatus() == 2) {
+                    model.put("collor", "red");
+                    model.put("into", "禁止通行");
+                    model.put("errorMsg", "健康日报提示您存在健康问题,禁止外出,请配合。");
+                    return new ModelAndView("/user/scanEstate.ftl", model);
+                }
                 List<MsReport> msReports = msReportMapper.selectMsReportLate(userOpen.getUserId());
                 if (msReports.size() == 0) {
                     model.put("collor", "red");
@@ -141,15 +156,9 @@ public class ScanController {
                     model.put("collor", "orange");
                     model.put("into", "可以" + getMsg(inType));
                     model.put("errorMsg", "您最近三日健康日报漏报,请说明原因并及时填报,配合监测人员。");
+                    scanService.saveOutScan(userOpen.getUserId(), inType, uptownDoor.getUptownId(), uptownDoor.getDoorId());
                     return new ModelAndView("/user/scan.ftl", model);
                 }
-                MsReport msReport = msReportMapper.selectMsReportToday(userOpen.getUserId());
-                if (msReport != null && msReport.getMsStatus() == 2) {
-                    model.put("collor", "red");
-                    model.put("into", "禁止通行");
-                    model.put("errorMsg", "健康日报提示您存在健康问题,禁止外出,请配合。");
-                    return new ModelAndView("/user/scanEstate.ftl", model);
-                }
             }
             model.put("collor", "green");
             model.put("into", "允许" + getMsg(inType));
@@ -181,8 +190,16 @@ public class ScanController {
             model.put("name", uptownHomes.get(0).getLinkman());
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             model.put("now", format.format(new Date()));
+            OutScanEstate o = outScanEstateMapper.getOutScanEstatLately(userOpen.getUserId());
+            if (o != null && compareTime(o.getScanDate(),1)) {
+                model.put("collor", "orange");
+                model.put("into", "允许通行");
+                model.put("errorMsg", "您最近一分钟已经扫码,本次扫码重复。");
+                return new ModelAndView("/user/scanEstate.ftl", model);
+            }
             OutUser outUser = outUserMapper.getOutUserByUserId(userOpen.getUserId());
             if (outUser != null) {
+                scanService.saveOutScanEstate(userOpen.getUserId());
                 model.put("collor", "green");
                 model.put("into", "允许通行");
                 model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,保生产同时注意自身安全。");
@@ -192,7 +209,7 @@ public class ScanController {
             if (msReports.size() != 3) {
                 model.put("collor", "red");
                 model.put("into", "禁止通行");
-                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请尽快返回住处。");
+                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请尽快返回住处。");
                 return new ModelAndView("/user/scanEstate.ftl", model);
             }
             MsReport msReport = msReportMapper.selectMsReportToday(userOpen.getUserId());
@@ -230,6 +247,21 @@ public class ScanController {
         }
     }
 
+    /**
+     * 判断传入的时间和现在相差是否在i分钟内
+     * @param date
+     * @param i
+     * @return
+     */
+    public Boolean compareTime(DateTime date, Integer i) {
+        Date date1 = new Date(date.getMillis());
+        if ((date1.getTime() + 1000L * 60 * i) > System.currentTimeMillis()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     public String getMsg(Integer inType) {
         if (inType == 1) {
             return "进入";