Bläddra i källkod

校园巡逻人员巡检扫码

peiguo 5 år sedan
förälder
incheckning
3cab6ef999

+ 15 - 1
whepi-doc/login.sql

@@ -192,7 +192,7 @@ CREATE TABLE sys_uptown_house  (
 DROP TABLE IF EXISTS out_scan;
 CREATE TABLE out_scan  (
   scan_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码ID',
-  user_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 '进入时间',
@@ -205,6 +205,20 @@ CREATE TABLE out_scan  (
   PRIMARY KEY (scan_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 '当天时间',
+  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 '新增时间',
+  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 (se_id) USING BTREE,
+  INDEX user_id(user_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '校园公共区域巡检扫码信息';
+
 DROP TABLE IF EXISTS out_scan_conf;
 CREATE TABLE out_scan_conf  (
   sc_id        		bigint(20) NOT NULL DEFAULT 0 COMMENT '扫码配置ID',

+ 0 - 35
whepi-ui/templates/user/scan.ftl

@@ -3,9 +3,6 @@
 
 <div class="weui-tab">
     <div class="weui-tab__bd">
-        <input id="userId" type="text" hidden="hidden" value=${user_id!}/>
-        <input id="uptownId" type="text" hidden="hidden" value=${uptown_id!}/>
-        <input id="uptownName" type="text" hidden="hidden" value=${uptown_name!}/>
         <div class="weui-tab__bd-item weui-tab__bd-item--active">
             <div class="page__bd">
                 <header class="user-header">
@@ -23,22 +20,6 @@
                     <br/>
                     <br/>
                     <p class="user-title-long  ${collor!''}">${errorMsg!""}</p>
-
-
-<#--                    <#if (inType?? )&&(inType = 1) >-->
-<#--                        <#if (type?? )&&(type !="1") ><h1 class="user-title green">可以进入</h1></#if>-->
-<#--                        <#if (type?? )&&(type ="-1") ><h1 class="user-title red">禁止进入</h1></#if>-->
-<#--                        <#if (type?? )&&(type ="-1") ><p class="user-title-long">非本小区居民,禁止进入。</p></#if>-->
-<#--                    </#if>-->
-<#--                    <#if (inType?? )&&(inType != 1) ><#if (type?? )&&(type ="1") ><h1 class="user-title green">可以外出</h1></#if>-->
-<#--                            <#if (type?? )&&(type !="1") ><h1 class="user-title red">禁止外出</h1></#if>-->
-
-<#--                    <#if (type?? )&&(type ="1") ><p class="user-title-long">请佩戴口罩,避免近距离接触,不得长时间在外逗留。</p></#if>-->
-<#--                    <#if (type?? )&&(type ="-1") ><p class="user-title-long">非本小区居民,禁止外出。</p></#if>-->
-<#--                    <#if (type?? )&&(type ="-2") ><p class="user-title-long">外出时间间隔不满三日,禁止外出,请配合,上次外出时间 ${lastTime!''}。</p></#if>-->
-<#--                    <#if (type?? )&&(type ="-3") ><p class="user-title-long">因近期您未提交健康日报,无法确认您当前健康状态,静止外出,请配合。</p></#if>-->
-
-<#--                    </#if>-->
                     <br/>
                     <br/>
                 </header>
@@ -53,20 +34,4 @@
 </body>
 <#include "/home/frag.foot.ftl" />
 <script>
-
-    (function ($) {
-        if ($("#uptownId").val() == '1238790987234') {
-            $("#adminName").text('管理员');
-            $("#homeName").text('员工');
-        }
-    })(jQuery);
-
-    function yes() {
-        var userType = $('input:radio:checked').val();
-        if (!userType) {
-            $.alert("请选择用户角色!")
-            return false;
-        }
-        window.location.href = "/user/homeIndex.html?userId=" + $("#userId").val() + "&userType=" + userType;
-    }
 </script>

+ 36 - 0
whepi-ui/templates/user/scanEstate.ftl

@@ -0,0 +1,36 @@
+<#assign title="校园公共区域巡检"/>
+<#include "/home/frag.head.ftl" />
+
+<div class="weui-tab">
+    <div class="weui-tab__bd">
+        <div class="weui-tab__bd-item weui-tab__bd-item--active">
+            <div class="page__bd">
+                <header class="user-header">
+                    <br/>
+                    <br/>
+                    <br/>
+                    <br/>
+                    <br/>
+                    <p class="user-title-long">${doorplate!''}
+                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${name!''}</p>
+                    <br/>
+                    <br/>
+                    <h1 class="user-title ${collor!''}">${into!""}</h1>
+                    <br/>
+                    <br/>
+                    <p class="user-title-long  ${collor!''}">${errorMsg!""}</p>
+                    <br/>
+                    <br/>
+                </header>
+                <br/>
+                <br/>
+                <p class="user-title-long">${now!''}</p>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+</body>
+<#include "/home/frag.foot.ftl" />
+<script>
+</script>

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

@@ -53,4 +53,12 @@ public interface MsReportMapper extends BaseMapper<MsReport> {
             "select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 3 day) and user_create=#{userId}")
     List<MsReport> selectMsReportLate(@Param("userId") Long userId);
 
+    /**
+     * 用户自身的健康状态, list大于0健康,等于0不健康
+     * @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);
+
 }

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

@@ -0,0 +1,23 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.OutScanEstate;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface OutScanEstateMapper extends BaseMapper<OutScanEstate> {
+
+    /**
+     * 该人员今天扫码次数
+     * @param userId
+     * @return
+     */
+    @Select("select * from out_scan_estate where now_date=curdate() and user_id=#{userId}")
+    List<OutScanEstate> getOutScanEstateTodayByUser(@Param("userId") Long userId);
+}

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

@@ -0,0 +1,48 @@
+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;
+
+import java.util.Date;
+
+/**
+ * 校园公共区域巡检扫码信息
+ */
+@Getter
+@Setter
+@TableName("out_scan_estate")
+public class OutScanEstate {
+
+    @ApiModelProperty("扫码ID")
+    @TableId("se_id")
+    private Long seId;
+
+    @ApiModelProperty("用户ID")
+    @TableField("user_id")
+    private Long userId;
+
+    @ApiModelProperty("当天时间")
+    @TableField("now_date")
+    private Date nowDate;
+
+    @ApiModelProperty("扫码时间")
+    @TableField("scan_date")
+    private DateTime scanDate;
+
+    @TableField("user_create")
+    private Long userCreate;
+
+    @TableField(exist = false)
+    private DateTime timeCreate;
+
+    @TableField("user_update")
+    private Long userUpdate;
+
+    @TableField(exist = false)
+    private DateTime timeUpdate;
+}

+ 18 - 0
whepi-web/src/main/java/com/bofeng/service/ScanService.java

@@ -1,20 +1,26 @@
 package com.bofeng.service;
 
 import com.baomidou.mybatisplus.toolkit.IdWorker;
+import com.bofeng.dao.OutScanEstateMapper;
 import com.bofeng.dao.OutScanMapper;
 import com.bofeng.entity.OutScan;
+import com.bofeng.entity.OutScanEstate;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
+
 @Service
 @Transactional(readOnly = true)
 public class ScanService {
 
     @Autowired
     private OutScanMapper outScanMapper;
+    @Autowired
+    private OutScanEstateMapper outScanEstateMapper;
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public void saveOutScan(Long userId, Integer inType, Long uptownId, Long doorId) {
@@ -56,4 +62,16 @@ public class ScanService {
             outScanMapper.insert(outScan);
         }
     }
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public void saveOutScanEstate(Long userId) {
+        OutScanEstate o = new OutScanEstate();
+        o.setSeId(IdWorker.getId());
+        o.setUserId(userId);
+        o.setNowDate(new Date());
+        o.setScanDate(new DateTime());
+        o.setUserCreate(userId);
+        o.setUserUpdate(userId);
+        outScanEstateMapper.insert(o);
+    }
 }

+ 41 - 6
whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.http.HttpServletRequest;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -49,11 +50,14 @@ public class ScanController {
     private MsReportMapper msReportMapper;
     @Autowired
     private ScanService scanService;
+    @Autowired
+    private OutScanEstateMapper outScanEstateMapper;
 
     @ApiOperation("进出扫码页面")
     @GetMapping("/user/scan.html")
-    public ModelAndView home(ModelMap model, @RequestParam(value = "doorId", required = false, defaultValue = "0") Long doorId,
-            @RequestParam(value = "inType", required = false, defaultValue = "0") Integer inType) {
+    public ModelAndView scan(HttpServletRequest request, ModelMap model, @RequestParam(value = "doorId", required = false, defaultValue = "0") Long doorId,
+                             @RequestParam(value = "inType", required = false, defaultValue = "0") Integer inType) {
+//        String code = request.getParameter("code");
         UserOpen userOpen = homeService.getUserOpen();
         List<UserRole> list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
 //        List<UserRole> list = userRoleMapper.getUserRoleByUserId(1L);
@@ -73,7 +77,6 @@ public class ScanController {
             model.put("now", format.format(new Date()));
             model.put("inType", inType);
             if (!unit.getUptownId().equals(uptownDoor.getUptownId())) {
-                model.put("type", "-1");//小区不对
                 model.put("into", "禁止" + getMsg(inType));
                 model.put("collor", "red");
                 model.put("errorMsg", "非本小区居民,禁止" + getMsg(inType) + "。");
@@ -83,7 +86,6 @@ public class ScanController {
                 OutScanConf outScanConf = outScanConfMapper.getOutScanConfByUptown(uptownDoor.getUptownId());
                 OutScan outScan = outScanMapper.getOutScanByUserlimit(userOpen.getUserId());
                 if (outScan != null && !compareTime(new Date(), outScan.getOutDate(), outScanConf.getGoOutFre())) {
-                    model.put("type", "-2");//时间短了
                     model.put("collor", "red");
                     model.put("into", "禁止" + getMsg(inType));
                     model.put("errorMsg", "外出时间间隔不满三日,禁止外出,请配合,上次外出时间 "+format.format(new Date(outScan.getOutDate().getMillis()))+"。");
@@ -91,14 +93,12 @@ public class ScanController {
                 }
                 List<MsReport> msReports = msReportMapper.selectMsReportLate(userOpen.getUserId());
                 if (msReports.size() != 3) {
-                    model.put("type", "-3");//最近3天未提交健康日报
                     model.put("collor", "red");
                     model.put("into", "禁止" + getMsg(inType));
                     model.put("errorMsg", "因近期您未提交健康日报,无法确认您当前健康状态,禁止外出,请配合。");
                     return new ModelAndView("/user/scan.ftl", model);
                 }
             }
-            model.put("type", "1");
             model.put("collor", "green");
             model.put("into", "可以" + getMsg(inType));
             if (inType == 2) {
@@ -109,6 +109,41 @@ public class ScanController {
         }
     }
 
+    @ApiOperation("巡检人员检查扫码信息")
+    @GetMapping("/user/scanEstate.html")
+    public ModelAndView scanEstate(HttpServletRequest request, ModelMap model) {
+        String code = request.getParameter("code");
+        UserOpen userOpen = homeService.getUserOpen();
+        List<UserRole> list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
+//        List<UserRole> list = userRoleMapper.getUserRoleByUserId(1L);
+//        UserOpen userOpen = userOpenMapper.selectByUserId(1L);
+        model.put("user", userOpen);
+        model.put("user_id", "\"" + userOpen.getUserId() + "\"");
+        if (list.size() == 0) {
+            return new ModelAndView("/user/home.ftl", model);
+        } else {
+            List<UptownHome> uptownHomes =  uptownHomeMapper.getUptownHomeByUserId(userOpen.getUserId());
+            UptownUnit unit = uptownUnitMapper.getUptownUnitByUser(userOpen.getUserId());
+            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()));
+            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 + "次出行,允许同行,注意安全。");
+            } else {
+                model.put("collor", "red");
+                model.put("into", "劝您回家");
+                model.put("errorMsg", "这是您今天第" + conut + "次出行,为了您的安全,请尽快回家。");
+            }
+            scanService.saveOutScanEstate(userOpen.getUserId());
+            return new ModelAndView("/user/scanEstate.ftl", model);
+        }
+    }
+
     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))) {