Bläddra i källkod

修改扫码特殊人员表,增加外出查询菜单

peiguo 5 år sedan
förälder
incheckning
47332f933c

+ 3 - 1
whepi-doc/login.sql

@@ -208,7 +208,9 @@ CREATE TABLE out_scan  (
 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',
+  phone             bigint(20) NOT NULL DEFAULT 0 COMMENT '电话号码',
+  end_date          date NOT NULL DEFAULT '0000-01-01' COMMENT '结束时间',
+  time              int(11) NOT NULL DEFAULT 0 COMMENT '总共时间(天)',
   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

+ 36 - 0
whepi-ui/templates/user/goOut.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!''}</p>
+                    <br/>
+                    <p class="user-title-long">${name!''}</p>
+                    <br/>
+                    <h1 class="user-title-big ${collor!''}">${into!""}</h1>
+                    <br/>
+                    <br/>
+                    <p class="user-title-long">${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>

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

@@ -11,6 +11,6 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface OutUserMapper extends BaseMapper<OutUser> {
 
-    @Select("SELECT * FROM out_user WHERE user_id = #{userId}")
-    OutUser getOutUserByUserId(@Param("userId") Long userId);
+    @Select("SELECT * FROM out_user WHERE phone = #{phone} and end_date >= curdate()")
+    OutUser getOutUserByPhone(@Param("phone") Long phone);
 }

+ 13 - 3
whepi-web/src/main/java/com/bofeng/entity/OutUser.java

@@ -8,6 +8,8 @@ import lombok.Getter;
 import lombok.Setter;
 import org.joda.time.DateTime;
 
+import java.util.Date;
+
 /**
  * 进出扫码特殊人员
  */
@@ -20,9 +22,17 @@ public class OutUser {
     @TableId("tu_id")
     private Long tu_id;
 
-    @ApiModelProperty("用户ID")
-    @TableField("user_id")
-    private Long userId;
+    @ApiModelProperty("电话号码")
+    @TableField("phone")
+    private Long phone;
+
+    @ApiModelProperty("结束时间")
+    @TableField("end_date")
+    private Date endDate;
+
+    @ApiModelProperty("总共时间(天)")
+    @TableField("time")
+    private Integer time;
 
     @TableField(exist = false)
     private DateTime timeCreate;

+ 27 - 17
whepi-web/src/main/java/com/bofeng/wx/WxController.java

@@ -130,35 +130,45 @@ public class WxController {
                                 "/user/home.html",
                         WxConsts.OAuth2Scope.SNSAPI_USERINFO, null)
         );
-//        val btn2 = new WxMenuButton();
-//        btn2.setName("商品团购");
-//        btn2.setType(WxConsts.MenuButtonType.VIEW);
-//        btn2.setUrl(
+
+//        val btnDesc = new WxMenuButton();
+//        btnDesc.setName("平台简介");
+//        btnDesc.setType(WxConsts.MenuButtonType.VIEW);
+//        btnDesc.setUrl(
 //                wxService.oauth2buildAuthorizationUrl(weChatProperties.getDomain() +
-//                                "/tuangou/home.html",
+//                                "/home/desc.html",
 //                        WxConsts.OAuth2Scope.SNSAPI_USERINFO, null)
 //        );
 
-//        val btn3 = new WxMenuButton();
-//        btn3.setName("我的");
+        val bt2 = new WxMenuButton();
+        bt2.setName("外出查询");
+        bt2.setType(WxConsts.MenuButtonType.VIEW);
+        bt2.setUrl(
+                wxService.oauth2buildAuthorizationUrl(weChatProperties.getDomain() +
+                                "/user/goOut.html",
+                        WxConsts.OAuth2Scope.SNSAPI_USERINFO, null)
+        );
 
         val btnDesc = new WxMenuButton();
         btnDesc.setName("平台简介");
-        btnDesc.setType(WxConsts.MenuButtonType.VIEW);
-        btnDesc.setUrl(
+        val btn31 = new WxMenuButton();
+        btn31.setName("帮助");
+        btn31.setType(WxConsts.MenuButtonType.VIEW);
+        btn31.setUrl(
                 wxService.oauth2buildAuthorizationUrl(weChatProperties.getDomain() +
-                                "/home/desc.html",
+                                "/home/testOk.html",
                         WxConsts.OAuth2Scope.SNSAPI_USERINFO, null)
         );
-
-        val btnHelp = new WxMenuButton();
-        btnHelp.setName("帮助");
-        btnHelp.setType(WxConsts.MenuButtonType.VIEW);
-        btnHelp.setUrl(
+        val btn32 = new WxMenuButton();
+        btn32.setName("简介");
+        btn32.setType(WxConsts.MenuButtonType.VIEW);
+        btn32.setUrl(
                 wxService.oauth2buildAuthorizationUrl(weChatProperties.getDomain() +
-                                "/home/testOk.html",
+                                "/home/desc.html",
                         WxConsts.OAuth2Scope.SNSAPI_USERINFO, null)
         );
+        btnDesc.getSubButtons().add(btn31);
+        btnDesc.getSubButtons().add(btn32);
 //        btn3.getSubButtons().add(btnDesc);
 //        btn3.getSubButtons().add(btnHelp);
 
@@ -223,8 +233,8 @@ public class WxController {
 //        btn3.getSubButtons().add(btn33);
 
         menu.getButtons().add(btn1);
+        menu.getButtons().add(bt2);
         menu.getButtons().add(btnDesc);
-        menu.getButtons().add(btnHelp);
 //        menu.getButtons().add(btn2);
 //        menu.getButtons().add(btn3);
         wxService.getMenuService().menuCreate(menu);

+ 69 - 2
whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java

@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -123,7 +124,7 @@ public class ScanController {
                 }
             }
             if (inType == 2) {
-                OutUser outUser = outUserMapper.getOutUserByUserId(userOpen.getUserId());
+                OutUser outUser = outUserMapper.getOutUserByPhone(Long.parseLong(uptownHomes.get(0).getPhone()));
                 if (outUser != null) {
                     model.put("collor", "green");
                     model.put("into", "允许通行");
@@ -197,7 +198,7 @@ public class ScanController {
                 model.put("errorMsg", "您最近一分钟已经扫码,本次扫码重复。");
                 return new ModelAndView("/user/scanEstate.ftl", model);
             }
-            OutUser outUser = outUserMapper.getOutUserByUserId(userOpen.getUserId());
+            OutUser outUser = outUserMapper.getOutUserByPhone(Long.parseLong(uptownHomes.get(0).getPhone()));
             if (outUser != null) {
                 scanService.saveOutScanEstate(userOpen.getUserId());
                 model.put("collor", "green");
@@ -247,6 +248,72 @@ public class ScanController {
         }
     }
 
+    @ApiOperation("外出查询")
+    @GetMapping("/user/goOut.html")
+    public ModelAndView goOut(HttpServletRequest request, ModelMap model) throws ParseException {
+        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.getUptownName() + "小区" +unit.getRidgepole() + "栋" + unit.getUnit() + "单元" +unit.getDoorplate() + "号");
+            model.put("name", uptownHomes.get(0).getLinkman());
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            model.put("now", sdf.format(new Date()));
+            OutUser outUser = outUserMapper.getOutUserByPhone(Long.parseLong(uptownHomes.get(0).getPhone()));
+            if (outUser != null) {
+                model.put("collor", "green");
+                model.put("into", "允许外出");
+                model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,保生产同时注意自身安全。");
+                return new ModelAndView("/user/goOut.ftl", model);
+            }
+            List<MsReport> msReports = msReportMapper.selectMsReportLate(userOpen.getUserId());
+            if (msReports.size() == 0) {
+                model.put("collor", "red");
+                model.put("into", "禁止外出");
+                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请提交健康日报。");
+                return new ModelAndView("/user/goOut.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/goOut.ftl", model);
+            }
+            OutScanConf outScanConf = outScanConfMapper.getOutScanConfByUptown(unit.getUptownId());
+            OutScan outScan = outScanMapper.getOutScanThreeday(userOpen.getUserId(), 2, outScanConf.getGoOutFre());
+            if (outScan != null) {
+                model.put("collor", "red");
+                model.put("into", "禁止外出");
+                model.put("errorMsg", "您今日健康状态评估正常,最近可外出时间"+sdf.format(new Date(outScan.getDayDate().getTime() + 1000L  *3600*24 * outScanConf.getGoOutFre()))+
+                        ",距今日还差"+differentDays(outScan.getDayDate(), sdf.parse(sdf.format(new Date())), outScanConf.getGoOutFre())+"天。");
+                return new ModelAndView("/user/goOut.ftl", model);
+            }
+            model.put("collor", "green");
+            model.put("into", "允许外出");
+            model.put("errorMsg", "外出请佩戴口罩,避免近距离接触,不得长时间在外逗留。");
+            return new ModelAndView("/user/goOut.ftl", model);
+        }
+    }
+
+    /**
+     * 通过时间秒毫秒数判断两个时间的间隔
+     * @param date1
+     * @param i
+     * @return
+     */
+    public static int differentDays(Date date1, Date date2, Integer i) {
+        int days = (int) ((date1.getTime() - date2.getTime()) / (1000*3600*24)) + i;
+        return days;
+    }
+
     /**
      * 判断传入的时间和现在相差是否在i分钟内
      * @param date