Browse Source

Merge remote-tracking branch 'origin/master'

yuliang 5 years ago
parent
commit
2fa61b00b8

+ 46 - 18
admin-ui/app/whepi/index.js

@@ -1,3 +1,4 @@
+var userRole = 0;
 $(function () {
   //隐藏角色上的提示红点
   $('#role-name-num').hide();
@@ -25,26 +26,51 @@ $(function () {
         }]
     });
     $('.easyui-menubutton').menubutton();
-    $('#menutree').tree({
-      url: '/app/whepi/mock/menu.json', //api('/menu_tree'),
-      onDblClick: function (node) {
-        var $this = $(this);
-        if (!$this.tree('isLeaf', node.target)) {
-          $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+    // 根据userRole读取不同的菜单
+    if (userRole == "1") {
+      $('#menutree').tree({
+        url: '/app/whepi/mock/menu.json', //api('/menu_tree'),
+        onDblClick: function (node) {
+          var $this = $(this);
+          if (!$this.tree('isLeaf', node.target)) {
+            $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+          }
+        },
+        onSelect: function () {
+          return false;
+        },
+        onClick: function (node) {
+          var href = node.href;
+          if ($.trim(href)) {
+            App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+          }
+        },
+        onLoadSuccess: function (node, data) {
         }
-      },
-      onSelect: function () {
-        return false;
-      },
-      onClick: function (node) {
-        var href = node.href;
-        if ($.trim(href)) {
-          App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+      });
+    } else if (userRole == "2") {
+      $('#menutree').tree({
+        url: '/app/whepi/mock/menu2.json', //api('/menu_tree'),
+        onDblClick: function (node) {
+          var $this = $(this);
+          if (!$this.tree('isLeaf', node.target)) {
+            $this.tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
+          }
+        },
+        onSelect: function () {
+          return false;
+        },
+        onClick: function (node) {
+          var href = node.href;
+          if ($.trim(href)) {
+            App.addTab({title: node.text, url: node.href, id: node.id, iconCls: node.iconCls});
+          }
+        },
+        onLoadSuccess: function (node, data) {
         }
-      },
-      onLoadSuccess: function (node, data) {
-      }
-    });
+      });
+    }
+
 
     $('#mm').menu({
       onClick: function (item) {
@@ -90,6 +116,8 @@ var App = {
       method: 'get',
       loadingMask: false,
       success: function (data) {
+        userRole = data.data.user.userType;
+        console.log(data.data.user.userType);
         if (!$.trim(data.data.userId)) {
           top.window.location.href = jumpApi(YJYDLOGINURL);
           return;

+ 14 - 0
admin-ui/app/whepi/mock/menu2.json

@@ -0,0 +1,14 @@
+{
+  "success": true,
+  "msg": "",
+  "data": [
+    {
+      "id": "ENT10000",
+      "text": "系统首页",
+      "href": "/app/whepi/home/home.js",
+      "iconCls": "icon-blank fa fa-desktop",
+      "state": "close",
+      "children": []
+    }
+  ]
+}

+ 16 - 7
whepi-doc/login.sql

@@ -7,7 +7,7 @@ create table sys_user
   user_id             BIGINT          not null             comment '用户编号',
   login_name          VARCHAR(50)     not null default ''  comment '登录账户',
   login_pwd           VARCHAR(50)     not null default '123456'  comment '登录密码',
-  user_type           VARCHAR(1)      not null             comment '角色ID:1居民,2业委会,3商家',
+  user_type           VARCHAR(1)      not null             comment '角色ID:1管理员,2业委会,3居民,4巡逻检查人员',
   staff_name          VARCHAR(20)     not null             comment '用户姓名',
 
   be_active           CHAR(1)         not null default 'Y' comment '是否活动 Y=活动/N=禁用/D=删除',
@@ -194,22 +194,31 @@ CREATE TABLE out_scan  (
   scan_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码ID',
   user_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
   uptown_id         bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID,下拉选ID',
-  into_door_id      bigint(20) NOT NULL DEFAULT 0 COMMENT '进入小区大门ID',
-  into_date         datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '进入时间',
-  out_door_id       bigint(20) NOT NULL DEFAULT 0 COMMENT '出去小区大门ID',
-  out_date          datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '出时间',
+  door_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '小区大门ID',
+  in_type           int(11) NOT NULL DEFAULT 0 COMMENT '进出状态:1进,2出',
+  day_date          date NOT NULL DEFAULT '0000-01-01' COMMENT '当天时间',
+  date              datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '出时间',
   user_create       bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
   user_update       bigint(20) NOT NULL DEFAULT 0 COMMENT '修改人',
   time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
   PRIMARY KEY (scan_id) USING BTREE
-) ENGINE = InnoDB default charset=utf8mb4 comment = '用户外出扫码信息';
+) ENGINE = InnoDB default charset=utf8mb4 comment = '用户进出扫码信息';
+
+DROP TABLE IF EXISTS out_user;
+CREATE TABLE out_user  (
+  tu_id             bigint(20) NOT NULL DEFAULT 0 COMMENT '特殊ID',
+  user_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
+  time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
+  time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
+  PRIMARY KEY (tu_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '进出扫码特殊人员';
 
 DROP TABLE IF EXISTS out_scan_estate;
 CREATE TABLE out_scan_estate  (
   se_id             bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码ID',
   user_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
-  now_date          date NOT NULL DEFAULT '0000-01-01' COMMENT '当天时间',
+  day_date          date NOT NULL DEFAULT '0000-01-01' COMMENT '当天时间',
   scan_date         datetime(0) NOT NULL DEFAULT '0000-01-01 00:00:00' COMMENT '扫码时间',
   user_create       bigint(20) NOT NULL DEFAULT 0 COMMENT '新增人',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',

+ 10 - 0
whepi-ui/templates/home/frag.head.ftl

@@ -41,12 +41,22 @@
             font-weight: 900;
             margin: 0 15%;
         }
+        .user-title-big {
+            text-align: center;
+            font-size: 30px;
+            color: #000000;
+            font-weight: 900;
+            margin: 0 15%;
+        }
         .red {
             color: red;
         }
         .green {
             color: green;
         }
+        .orange {
+            color: orange;
+        }
         .user-hr {
             align: center;
             width: 100%;

+ 2 - 1
whepi-ui/templates/home/home.ftl

@@ -157,8 +157,9 @@
             type: 'GET',
             success: function (data) {
                 console.log(data);
-                if (v.userId != data.data.userId) {
+                if ($('#userId').val() != data.data.userId) {
                     $.alert('当前求助信息不是你的')
+                    return;
                 } else {
                     window.location.href = "/quzhu/home/quxiao.html?taskId=" + v.taskId + "&userId=" + v.userId;
                     familyClick()

+ 2 - 2
whepi-ui/templates/user/scan.ftl

@@ -16,10 +16,10 @@
                     <br/>
                     <h1 class="user-title-long ${collor!''}">${door!''}</h1>
                     <br/>
-                    <h1 class="user-title ${collor!''}">${into!""}</h1>
+                    <h1 class="user-title-big ${collor!''}">${into!""}</h1>
                     <br/>
                     <br/>
-                    <p class="user-title-long  ${collor!''}">${errorMsg!""}</p>
+                    <p class="user-title-long">${errorMsg!""}</p>
                     <br/>
                     <br/>
                 </header>

+ 2 - 2
whepi-ui/templates/user/scanEstate.ftl

@@ -15,10 +15,10 @@
                         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${name!''}</p>
                     <br/>
                     <br/>
-                    <h1 class="user-title ${collor!''}">${into!""}</h1>
+                    <h1 class="user-title-big ${collor!''}">${into!""}</h1>
                     <br/>
                     <br/>
-                    <p class="user-title-long  ${collor!''}">${errorMsg!""}</p>
+                    <p class="user-title-long">${errorMsg!""}</p>
                     <br/>
 <#--                    <img id="qr" src="${img!''}"/>-->
                     <br/>

+ 1 - 0
whepi-web/src/main/java/com/bofeng/controller/LoginController.java

@@ -50,6 +50,7 @@ public class LoginController {
         model.put("userId", JwtHelper.getUserId());
         model.put("staffName", JwtHelper.getStaffName());
         model.put("expireTime", JwtHelper.getExpireTime());
+        model.put("user", userMapper.selectById(JwtHelper.getUserId()));
 //        ResultModel model = new ResultModel()
 //                .set("userId", JwtHelper.getUserId())
 //                .set("staffName", JwtHelper.getStaffName())

+ 3 - 5
whepi-web/src/main/java/com/bofeng/dao/MsReportMapper.java

@@ -49,7 +49,6 @@ public interface MsReportMapper extends BaseMapper<MsReport> {
 
     /**
      * 最近3天是否都有上报
-     *
      * @param userId
      * @return
      */
@@ -61,12 +60,11 @@ public interface MsReportMapper extends BaseMapper<MsReport> {
     List<MsReport> selectMsReportLate(@Param("userId") Long userId);
 
     /**
-     * 用户自身的健康状态, list大于0健康,等于0不健康
-     *
+     * 最近提交的日报, msStatus 健康状态:1正常,2异常
      * @param userId
      * @return
      */
-    @Select("select * from ms_report where report_status=1 and report_date=curdate() and ms_status=1 and user_create=#{userId}")
-    List<MsReport> selectMsReportToday(@Param("userId") Long userId);
+    @Select("select * from ms_report where user_create=#{userId} and report_status=1 order by report_date desc limit 1")
+    MsReport selectMsReportToday(@Param("userId") Long userId);
 
 }

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

@@ -18,6 +18,6 @@ public interface OutScanEstateMapper extends BaseMapper<OutScanEstate> {
      * @param userId
      * @return
      */
-    @Select("select * from out_scan_estate where now_date=curdate() and user_id=#{userId}")
+    @Select("select * from out_scan_estate where day_date=curdate() and user_id=#{userId}")
     List<OutScanEstate> getOutScanEstateTodayByUser(@Param("userId") Long userId);
 }

+ 23 - 1
whepi-web/src/main/java/com/bofeng/dao/OutScanMapper.java

@@ -11,6 +11,28 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface OutScanMapper extends BaseMapper<OutScan> {
 
-    @Select("SELECT s.* FROM out_scan s WHERE s.user_id = #{userId} ORDER BY s.time_create DESC LIMIT 1")
+    /**
+     * 最近一次出去的时间
+     * @param userId
+     * @return
+     */
+    @Select("SELECT s.* FROM out_scan s WHERE s.user_id = #{userId} and in_type = 2 ORDER BY s.time_create DESC LIMIT 1")
     OutScan getOutScanByUserlimit(@Param("userId") Long userId);
+
+
+    /**
+     * 今天是否出去
+     * @param userId
+     * @return
+     */
+    @Select("SELECT * FROM out_scan WHERE user_id = #{userId} and in_type = 2 and day_date = curdate()")
+    OutScan getOutScanToday(@Param("userId") Long userId);
+
+    /**
+     * 最近几天外出/进入 OutScan为空否
+     * @param userId
+     * @return
+     */
+    @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);
 }

+ 16 - 0
whepi-web/src/main/java/com/bofeng/dao/OutUserMapper.java

@@ -0,0 +1,16 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.OutUser;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface OutUserMapper extends BaseMapper<OutUser> {
+
+    @Select("SELECT * FROM out_user WHERE user_id = #{userId}")
+    OutUser getOutUserByUserId(@Param("userId") Long userId);
+}

+ 14 - 12
whepi-web/src/main/java/com/bofeng/entity/OutScan.java

@@ -8,6 +8,8 @@ import lombok.Getter;
 import lombok.Setter;
 import org.joda.time.DateTime;
 
+import java.util.Date;
+
 /**
  * 用户外出扫码信息
  */
@@ -28,21 +30,21 @@ public class OutScan {
     @TableField("uptown_id")
     private Long uptownId;
 
-    @ApiModelProperty("进入小区大门ID")
-    @TableField("into_door_id")
-    private Long intoDoorId;
+    @ApiModelProperty("小区大门ID")
+    @TableField("door_id")
+    private Long doorId;
 
-    @ApiModelProperty("进入时间")
-    @TableField("into_date")
-    private DateTime intoDate;
+    @ApiModelProperty("进出状态:1进,2出")
+    @TableField("in_type")
+    private Integer inType;
 
-    @ApiModelProperty("出去小区大门ID")
-    @TableField("out_door_id")
-    private Long outDoorId;
+    @ApiModelProperty("当天时间")
+    @TableField("day_date")
+    private Date dayDate;
 
-    @ApiModelProperty("出时间")
-    @TableField("out_date")
-    private DateTime outDate;
+    @ApiModelProperty("出时间")
+    @TableField("date")
+    private DateTime date;
 
     @TableField("user_create")
     private Long userCreate;

+ 2 - 2
whepi-web/src/main/java/com/bofeng/entity/OutScanEstate.java

@@ -27,8 +27,8 @@ public class OutScanEstate {
     private Long userId;
 
     @ApiModelProperty("当天时间")
-    @TableField("now_date")
-    private Date nowDate;
+    @TableField("day_date")
+    private Date dayDate;
 
     @ApiModelProperty("扫码时间")
     @TableField("scan_date")

+ 32 - 0
whepi-web/src/main/java/com/bofeng/entity/OutUser.java

@@ -0,0 +1,32 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import org.joda.time.DateTime;
+
+/**
+ * 进出扫码特殊人员
+ */
+@Getter
+@Setter
+@TableName("out_user")
+public class OutUser {
+
+    @ApiModelProperty("特殊ID")
+    @TableId("tu_id")
+    private Long tu_id;
+
+    @ApiModelProperty("用户ID")
+    @TableField("user_id")
+    private Long userId;
+
+    @TableField(exist = false)
+    private DateTime timeCreate;
+
+    @TableField(exist = false)
+    private DateTime timeUpdate;
+}

+ 12 - 38
whepi-web/src/main/java/com/bofeng/service/ScanService.java

@@ -24,43 +24,17 @@ public class ScanService {
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public void saveOutScan(Long userId, Integer inType, Long uptownId, Long doorId) {
-        if (inType == 1) {
-            // 进出的时候修改数据,但若是第一次进去就需要加一条出去的数据
-            OutScan outScan1 = outScanMapper.getOutScanByUserlimit(userId);
-            if (outScan1 == null) {
-                OutScan outScan = new OutScan();
-                outScan.setScanId(IdWorker.getId());
-                outScan.setUserId(userId);
-                outScan.setUptownId(uptownId);
-                outScan.setIntoDoorId(doorId);
-                outScan.setIntoDate(new DateTime());
-                outScan.setOutDoorId(doorId);
-                outScan.setOutDate(new DateTime());
-                outScan.setUserCreate(userId);
-                outScan.setUserUpdate(userId);
-                outScanMapper.insert(outScan);
-            } else {
-                outScan1.setIntoDoorId(doorId);
-                outScan1.setIntoDate(new DateTime());
-                outScan1.setUserUpdate(userId);
-                outScanMapper.updateById(outScan1);
-            }
-        } else if (inType == 2) {
-            // 出去的时候添加数据
-            OutScan outScan = new OutScan();
-            outScan.setScanId(IdWorker.getId());
-            outScan.setUserId(userId);
-            outScan.setUptownId(uptownId);
-            outScan.setOutDoorId(doorId);
-            outScan.setOutDate(new DateTime());
-
-            outScan.setIntoDoorId(0L);
-            outScan.setIntoDate(null);
-
-            outScan.setUserCreate(userId);
-            outScan.setUserUpdate(userId);
-            outScanMapper.insert(outScan);
-        }
+        OutScan outScan = new OutScan();
+        outScan.setScanId(IdWorker.getId());
+        outScan.setUserId(userId);
+        outScan.setUptownId(uptownId);
+        outScan.setDoorId(doorId);
+        outScan.setInType(inType);
+        outScan.setDayDate(new Date());
+        outScan.setDate(new DateTime());
+        outScan.setUserCreate(userId);
+        outScan.setUserUpdate(userId);
+        outScanMapper.insert(outScan);
     }
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
@@ -68,7 +42,7 @@ public class ScanService {
         OutScanEstate o = new OutScanEstate();
         o.setSeId(IdWorker.getId());
         o.setUserId(userId);
-        o.setNowDate(new Date());
+        o.setDayDate(new Date());
         o.setScanDate(new DateTime());
         o.setUserCreate(userId);
         o.setUserUpdate(userId);

+ 88 - 27
whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java

@@ -67,6 +67,8 @@ public class ScanController {
     private ScanService scanService;
     @Autowired
     private OutScanEstateMapper outScanEstateMapper;
+    @Autowired
+    private OutUserMapper outUserMapper;
 
     /**
      * @param doorId 小区大门ID
@@ -94,8 +96,8 @@ public class ScanController {
             model.put("door", uptownDoor.getUptownName() + uptownDoor.getDoorName());
             model.put("doorplate", unit.getRidgepole() + "栋" + unit.getUnit() + "单元" +unit.getDoorplate() + "号");
             model.put("name", uptownHomes.get(0).getLinkman());
-            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            model.put("now", format.format(new Date()));
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            model.put("now", sdf.format(new Date()));
             model.put("inType", inType);
             if (!unit.getUptownId().equals(uptownDoor.getUptownId())) {
                 model.put("into", "禁止" + getMsg(inType));
@@ -103,27 +105,58 @@ public class ScanController {
                 model.put("errorMsg", "非本小区居民,禁止" + getMsg(inType) + "。");
                 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日,请尽快上报您的健康状况,防止在外长时间逗留。");
+                    return new ModelAndView("/user/scan.ftl", model);
+                }
+            }
             if (inType == 2) {
+                OutUser outUser = outUserMapper.getOutUserByUserId(userOpen.getUserId());
+                if (outUser != null) {
+                    model.put("collor", "green");
+                    model.put("into", "允许通行");
+                    model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,保生产同时注意自身安全。");
+                    scanService.saveOutScan(userOpen.getUserId(), inType, uptownDoor.getUptownId(), uptownDoor.getDoorId());
+                    return new ModelAndView("/user/scan.ftl", model);
+                }
                 OutScanConf outScanConf = outScanConfMapper.getOutScanConfByUptown(uptownDoor.getUptownId());
-                OutScan outScan = outScanMapper.getOutScanByUserlimit(userOpen.getUserId());
-                if (outScan != null && !compareTime(new Date(), outScan.getOutDate(), outScanConf.getGoOutFre())) {
+                OutScan outScan = outScanMapper.getOutScanThreeday(userOpen.getUserId(), 2, outScanConf.getGoOutFre());
+                if (outScan != null) {
                     model.put("collor", "red");
                     model.put("into", "禁止" + getMsg(inType));
-                    model.put("errorMsg", "外出时间间隔不满三日,禁止外出,请配合,上次外出时间 "+format.format(new Date(outScan.getOutDate().getMillis()))+"。");
+                    model.put("errorMsg", "距您上次外出时间未满"+outScanConf.getGoOutFre()+"日,禁止外出,请配合。上次外出登记时间 "+sdf.format(new Date(outScan.getDate().getMillis()))+"。");
                     return new ModelAndView("/user/scan.ftl", model);
                 }
                 List<MsReport> msReports = msReportMapper.selectMsReportLate(userOpen.getUserId());
-                if (msReports.size() != 3) {
+                if (msReports.size() == 0) {
                     model.put("collor", "red");
                     model.put("into", "禁止" + getMsg(inType));
-                    model.put("errorMsg", "因近期您未提交健康日报,无法确认您当前健康状态,禁止外出,请配合。");
+                    model.put("errorMsg", "您最近三日未上报健康日报,请说明原因,配合监测人员。");
                     return new ModelAndView("/user/scan.ftl", model);
+                } else if (msReports.size() < 3) {
+                    model.put("collor", "orange");
+                    model.put("into", "可以" + getMsg(inType));
+                    model.put("errorMsg", "您最近三日健康日报漏报,请说明原因并及时填报,配合监测人员。");
+                    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));
+            model.put("into", "允许" + getMsg(inType));
             if (inType == 2) {
-                model.put("errorMsg", "请佩戴口罩,避免近距离接触,不得长时间在外逗留。");
+                model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,保生产同时注意自身安全。");
+            } else if (inType == 1) {
+                model.put("errorMsg", "欢迎归来,注意防护。");
             }
             scanService.saveOutScan(userOpen.getUserId(), inType, uptownDoor.getUptownId(), uptownDoor.getDoorId());
             return new ModelAndView("/user/scan.ftl", model);
@@ -148,16 +181,48 @@ 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()));
+            OutUser outUser = outUserMapper.getOutUserByUserId(userOpen.getUserId());
+            if (outUser != null) {
+                model.put("collor", "green");
+                model.put("into", "允许通行");
+                model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,保生产同时注意自身安全。");
+                return new ModelAndView("/user/scanEstate.ftl", model);
+            }
+            List<MsReport> msReports = msReportMapper.selectMsReportLate(userOpen.getUserId());
+            if (msReports.size() != 3) {
+                model.put("collor", "red");
+                model.put("into", "禁止通行");
+                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请尽快返回住处。");
+                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);
+            }
+            OutScan outScan = outScanMapper.getOutScanToday(userOpen.getUserId());
+            if (outScan == null) {
+                model.put("collor", "red");
+                model.put("into", "禁止通行");
+                model.put("errorMsg", "您今日没有正常出门记录,为自身及家人安全,请赶紧回家。");
+                return new ModelAndView("/user/scanEstate.ftl", model);
+            }
             List<OutScanEstate> list1 = outScanEstateMapper.getOutScanEstateTodayByUser(userOpen.getUserId());
             int conut = list1.size() + 1;
             if (list1.size() < 2) {
                 model.put("collor", "green");
-                model.put("into", "允许行动");
-                model.put("errorMsg", "这是您今天第" + conut + "次出行,允许同行,注意安全。");
+                model.put("into", "允许通行");
+                if (list1.size() == 0) {
+                    model.put("errorMsg", "您今日已"+conut+"次被问讯,请说明外出原因,尽快回家。");
+                } else {
+                    model.put("errorMsg", "您今日已"+conut+"次被问讯,请说明外出原因,尽快回家。问询时间:"+queryTime(list1)+"。");
+                }
             } else {
                 model.put("collor", "red");
-                model.put("into", "劝您回家");
-                model.put("errorMsg", "这是您今天第" + conut + "次出行,为了您的安全,请尽快回家。");
+                model.put("into", "禁止通行");
+                model.put("errorMsg", "您今日已被巡检人员问讯超过2次,为自身及家人安全,请赶紧回家。问询时间:"+queryTime(list1)+"。");
             }
             scanService.saveOutScanEstate(userOpen.getUserId());
 //            model.put("img", "/scan/scanEstate_qr.png");
@@ -165,20 +230,6 @@ public class ScanController {
         }
     }
 
-    public Boolean compareTime(Date time1, DateTime time2, Integer day) {
-        Date date = new Date(time2.getMillis() + 1000L*3600*24*day);
-        if (changeTime(date).equals(changeTime(time1))) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    public String changeTime(Date date) {
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-        return format.format(date);
-    }
-
     public String getMsg(Integer inType) {
         if (inType == 1) {
             return "进入";
@@ -188,6 +239,16 @@ public class ScanController {
         return "";
     }
 
+    public String queryTime (List<OutScanEstate> list) {
+        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
+        String time = "";
+        for (OutScanEstate o : list) {
+            String date = format.format(new Date(o.getScanDate().getMillis()));
+            time += date + "、";
+        }
+        return time.substring(0, time.length() - 1);
+    }
+
     /**
      * 生成进出门二维码
      * @param doorId 小区大门ID