瀏覽代碼

Merge branch 'master' of http://git.yvanui.com/hust/wuhan_epi

hudingbo 5 年之前
父節點
當前提交
5e3363143b
共有 27 個文件被更改,包括 986 次插入190 次删除
  1. 8 0
      admin-ui/app/whepi/mock/menu.json
  2. 94 0
      admin-ui/app/whepi/scan/addDoor.js
  3. 39 3
      admin-ui/app/whepi/scan/qrImg.js
  4. 22 0
      admin-ui/app/whepi/scan/uptownWidget.js
  5. 197 0
      admin-ui/app/whepi/scan/xqmanage.js
  6. 50 51
      admin-ui/app/whepi/tugou/dialogTugou.js
  7. 2 0
      whepi-doc/login.sql
  8. 1 1
      whepi-ui/templates/home/ribao.js
  9. 8 0
      whepi-web/src/main/java/com/bofeng/dao/OutScanEstateMapper.java
  10. 8 0
      whepi-web/src/main/java/com/bofeng/dao/OutScanMapper.java
  11. 3 1
      whepi-web/src/main/java/com/bofeng/dao/SweepCodeMapper.java
  12. 12 0
      whepi-web/src/main/java/com/bofeng/dao/UptownDoorMapper.java
  13. 1 1
      whepi-web/src/main/java/com/bofeng/dao/UptownUnitMapper.java
  14. 8 5
      whepi-web/src/main/java/com/bofeng/entity/SysUptownHouse.java
  15. 8 7
      whepi-web/src/main/java/com/bofeng/entity/UptownDoor.java
  16. 9 9
      whepi-web/src/main/java/com/bofeng/excel/ExcelUtils.java
  17. 38 0
      whepi-web/src/main/java/com/bofeng/service/ScanAdminService.java
  18. 19 2
      whepi-web/src/main/java/com/bofeng/service/SweepCodeService.java
  19. 214 0
      whepi-web/src/main/java/com/bofeng/unit/QRCode.java
  20. 89 25
      whepi-web/src/main/java/com/bofeng/wx/controller/ScanAdminController.java
  21. 72 40
      whepi-web/src/main/java/com/bofeng/wx/controller/ScanController.java
  22. 1 1
      whepi-web/src/main/resources/application.yml
  23. 49 27
      whepi-web/src/main/resources/mapper/SweepCodeMapper.xml
  24. 7 2
      whepi-web/src/main/resources/mapper/UptownDoorMapper.xml
  25. 10 0
      yvan-platform/src/main/java/com/yvan/mvc/JztdMvcAutoConfigration.java
  26. 8 6
      yvan-platform/src/main/java/com/yvan/mvc/PageDbResolver.java
  27. 9 9
      yvan-platform/src/main/java/com/yvan/springmvc/HttpUtils.java

+ 8 - 0
admin-ui/app/whepi/mock/menu.json

@@ -24,6 +24,14 @@
           "iconCls": "icon-blank fa fa-align-justify",
           "state": "close",
           "children": []
+        },
+        {
+          "id": "ENT100022",
+          "text": "小区管理",
+          "href": "/app/whepi/scan/xqmanage.js",
+          "iconCls": "icon-blank fa fa-align-justify",
+          "state": "close",
+          "children": []
         }
       ]
     },

+ 94 - 0
admin-ui/app/whepi/scan/addDoor.js

@@ -0,0 +1,94 @@
+define(function (require) {
+    return function (context) {
+
+        var $dlg, $form, isEdit = false;
+
+        var widgets = {
+            // 小区搜索
+            selectUptownWidget: {
+                url: '/app/whepi/scan/uptownWidget.js',
+                bind: {
+                    uptownId: 'uptownId',
+                    uptownName: 'uptownName'
+                }
+            },
+        };
+
+        return {
+            xtype: 'dialog',
+            dialogId: 'dialogEnvLog',
+            title: context.isEdit ? '编辑大门基本信息' : '新增大门基本信息',
+            width: 450,
+            height: 300,
+            onOpen: function () {
+                $dlg = $(this);
+                if (context.isEdit) {
+                    $.yvan.ajax({
+                        loadingMask: false,
+                        url: api('/qrImg/getDoorById'),
+                        type: 'GET',
+                        data: {doorId: context.doorId},
+                        success: function (data) {
+                            $dlg.find('form');
+                            $form.formSet(data.data);
+                        }
+                    });
+                }
+            },
+            center: {
+                items: {
+                    width: 450,
+                    height: 756,
+                    autoSizeColumns: true,
+                    xtype: 'formgroup',
+                    onRender: function () {
+                        $form = $(this);
+                    },
+                    items: [
+                        [
+                            {name: 'doorId', xtype: 'hidden'},
+                            {label: '小区ID', name: 'uptownId', xtype: 'hidden', widget: widgets.selectUptownWidget},
+                            {
+                                name: 'uptownName',
+                                label: '小区名称',
+                                xtype: 'searchbox',
+                                maxlength: 60,
+                                width: 350,
+                                required: true,
+                                widget: widgets.selectUptownWidget
+                            },
+                            {
+                                name: 'doorName',
+                                label: '大门名称',
+                                required: true,
+                                maxlength: 60,
+                                width: 350,
+                            },]
+                    ],
+                }
+            },
+            buttons: [
+                {
+                    text: "保存", iconCls: "fa fa-save", onClick: function () {
+                        $.yvan.postForm($form, {
+                            url: (context.isEdit ? api('/qrImg/updateDoor') : api('/qrImg/insertDoor')),
+                            success: function (data) {
+                                if (data.data == 1) {
+                                    $.yvan.msg('保存成功');
+                                    $dlg.window('close');
+                                    if ($.type(context.confirm) === 'function') {
+                                        context.confirm();
+                                    }
+                                }
+                            }
+                        });
+                    }
+                }, {
+                    text: "关闭", iconCls: "fa fa-times", onClick: function () {
+                        $dlg.dialog('close');
+                    }
+                }
+            ]
+        };
+    };
+});

+ 39 - 3
admin-ui/app/whepi/scan/qrImg.js

@@ -46,7 +46,7 @@ define(function (require) {
             }
 
             // 搜索按钮
-            var queryToolbarTitle = '团购信息管理';// 自行替换此参数
+            var queryToolbarTitle = '进出门二维码';// 自行替换此参数
             var queryToolbar = {
                 xtype: 'toolbar', title: queryToolbarTitle, items: [
                     {
@@ -103,6 +103,42 @@ define(function (require) {
                                 queryGrid1()
                             },
                             xtype: 'grid',
+                            toolbar: {
+                                xtype: 'toolbar',
+                                title: '小区大门详情',
+                                items: [
+                                    // {
+                                    //     text: '添加大门', iconCls: 'fa fa-plus-circle fa-lg', onClick: function () {
+                                    //         $.yvan.showDialog(this,
+                                    //             require('/app/whepi/scan/addDoor.js')({
+                                    //                 isEdit: false,
+                                    //                 confirm: function () {
+                                    //                     queryGrid1();
+                                    //                 }
+                                    //             })
+                                    //         );
+                                    //     }
+                                    // },
+                                    // {
+                                    //     text: '编辑大门', iconCls: 'fa fa fa-pencil-square-o fa-lg', onClick: function () {
+                                    //         var row = $grid1.rowData();
+                                    //         if (!row) {
+                                    //             $.yvan.msg('请先选择一行数据');
+                                    //             return;
+                                    //         }
+                                    //         $.yvan.showDialog(this,
+                                    //             require('/app/whepi/scan/addDoor.js')({
+                                    //                 confirm: function () {
+                                    //                     queryGrid1();
+                                    //                 },
+                                    //                 isEdit: true,
+                                    //                 doorId: row.doorId
+                                    //             })
+                                    //         );
+                                    //     }
+                                    // }
+                                ]
+                            },
                             idField: 'doorId',
                             autoSizeColumns: true,
                             columns:
@@ -114,12 +150,12 @@ define(function (require) {
                                         {
                                             field: 'outImg', title: '外出二维码', minWidth: 300, maxWidth: 400,
                                             formatter: function (value) {
-                                                return "<img  src='" + value + "'/>";
+                                                return "<img  src='/whepi" + value + "'/>";
                                             },
                                         },
                                         {field: 'inImg', title: '进入二维码', minWidth: 300, maxWidth: 400,
                                             formatter: function (value) {
-                                                return "<img  src='" + value + "'/>";
+                                                return "<img  src='/whepi" + value + "'/>";
                                             },},
                                         {field: 'timeUpdate', title: '修改时间', maxWidth: 200, formatter: $.fn.fmatter.ts},
                                     ]

+ 22 - 0
admin-ui/app/whepi/scan/uptownWidget.js

@@ -0,0 +1,22 @@
+define(function (require) {
+    return function (context) {
+
+        return {
+            xtype: 'widget',
+            title: '人员信息搜索',
+            width: 600,
+            height: 600,
+            grid: {
+                url: api('/qrImg/getUptown'),
+                mtype: 'POST',
+                queryParams: {query: context.query, status: 1},
+                idField: 'uptownId',
+                columns: [[
+                    {title: '小区ID', field: 'uptownId', hidden: true},
+                    {title: '小区名称', field: 'uptownName'},
+                    {title: '更新时间', field: 'timeUpdate', formatter: 'ts'}
+                ]]
+            }
+        };
+    };
+});

+ 197 - 0
admin-ui/app/whepi/scan/xqmanage.js

@@ -0,0 +1,197 @@
+define(function (require) {
+        return function (context) {
+
+            var $grid1, $form;
+
+
+            // 导出
+            function exportExcel() {
+                var row = $grid1.rowData();
+                if (!row) {
+                    $.yvan.msg('请先选择一行数据');
+                    return;
+                }
+                var queryForm = $form.formGet();
+                $.yvan.download({
+                    method: 'post',
+                    url: api('/sweepCode/export?queryProperties=' + queryForm.queryProperties + '&dateSta=' + queryForm.dateSta + '&dateEnd=' + queryForm.dateEnd),
+                    fileName: '进出管理-' + $.yvan.getMoment().format('YYYY-MM-DD HH:mm:ss') + '.xlsx'
+
+                });
+            }
+
+            // 输入搜索文本后点击回车按钮查询列表
+            function enterQueryGrid1(e) {
+                if (e.keyCode === 13) {
+                    var tmp = $(this).val();
+                    $form.formSet({queryProperties: tmp});
+                    queryGrid1();
+                }
+            }
+
+            // 检索条件查询
+            function queryGrid1() {
+                var queryUrl = '/sweepCode/selectCode';// 自行替换此参数
+                var queryForm = $form.formGet();
+                queryForm.roleCode = App.currentRoleCode;
+                $grid1.reload({
+                    mtype: 'POST',
+                    url: api(queryUrl),
+                    queryParams: queryForm
+                }, true);
+            }
+
+            // 搜索按钮
+            var queryToolbarTitle = '进出管理';// 自行替换此参数
+            var queryToolbar = {
+                xtype: 'toolbar', title: queryToolbarTitle, items: [
+                    {
+                        text: '查询', iconCls: 'fa fa-search', onClick: function () {
+                            queryGrid1();
+                        }
+                    }, {
+                        text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
+                            $form.formClear();
+                            queryGrid1();
+                        }
+                    }, {
+                        text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
+                            App.closeMe(this);
+                        }
+                    }
+                ]
+            };
+
+            // 搜索条件
+            var queryFormPrompt = '名称';// 自行替换此参数
+            var queryForm = {
+                onRender: function () {
+                    $form = $(this);
+                },
+                xtype: 'form',
+                items: [[
+                    {
+                        xtype: 'textbox',
+                        label: '小区名称',
+                        name: 'queryProperties',
+                        prompt: queryFormPrompt,
+                        labelWidth: 'auto',
+                        events: {keydown: enterQueryGrid1}, width: 350
+                    },
+                    {
+                        xtype: 'datebox',
+                        name: 'dateSta',
+                        label: '进出时间',
+                        labelWidth: 'auto',
+                        width: 230,
+                        onChange: function (data) {
+                          /*  var expDateStart = $form.formGet().nextRepairDate;
+                            var expDateEnd = $form.formGet().expDateEnd;
+                            var expDateStart = new Date(expDateStart.replace("-", "/"));
+                            var expDateEnd = new Date(expDateEnd.replace("-", "/"));
+                            if (expDateStart > expDateEnd) {
+                                $.yvan.msg('起止日期必须大于起始日期');
+                                return;
+                            }*/
+                        }
+                    },
+                    {
+                        xtype: 'datebox', label: '--', name: 'dateEnd', labelWidth: 'auto', width: 180,
+                        onChange: function (data) {
+                           /* var expDateStart = $form.formGet().nextRepairDate;
+                            var expDateEnd = $form.formGet().expDateEnd;
+                            var expDateStart = new Date(expDateStart.replace("-", "/"));
+                            var expDateEnd = new Date(expDateEnd.replace("-", "/"));
+                            if (expDateStart > expDateEnd) {
+                                $.yvan.msg('起止日期必须大于起始日期');
+                                return;
+                            }*/
+                        }
+                    }
+                ]]
+            };
+
+            var gridToolbarTitle = '出入列表';// 自行替换此参数
+            var gridToolbar = {
+                xtype: 'toolbar',
+                title: gridToolbarTitle,
+                items: [
+                    {
+                        text: '导出', iconCls: 'fa fa-cloud-upload', onClick: function () {
+                            exportExcel();
+                        }
+                    },
+                ]
+            };
+
+            return {
+                north: {
+                    height: 88,
+                    /* split: true,
+                     border: false,*///底框是否可变动
+                    items: [
+                        queryToolbar,
+                        queryForm
+                    ]
+                },
+                center: {
+                    height: '60%',
+                    split: true,
+                    items:
+                        {
+                            onRender: function () {
+                                $grid1 = $(this);
+                                queryGrid1()
+                            },
+                            xtype: 'grid',
+                            toolbar:
+                            gridToolbar,
+                            idField: 'joId',
+                            autoSizeColumns: true,//序号多  正确显示
+                            columns:
+                                [
+                                    [
+                                        {field: 'uptownId', title: '小区id', maxWidth: 200, align: 'left', hidden: true},
+                                        {field: 'uptownName', title: '小区名称', maxWidth: 200, align: 'left',},
+                                        {field: 'ridgepole', title: '楼栋', maxWidth: 200, align: 'left',},
+                                        {field: 'unit', title: '单元', maxWidth: 200,},
+                                        {
+                                            field: 'doorplate',
+                                            title: '房间号', maxWidth: 200,
+                                        },
+                                        {
+                                            field: 'linkman',
+                                            title: '用户名',
+                                        },
+                                        {
+                                            field: 'doorName',
+                                            title: '小区大门',
+                                            align: 'left',
+                                        },
+                                        {
+                                            field: 'date',
+                                            title: '进出时间',
+                                            align: 'left',
+                                        },
+                                        {
+                                            field: 'inType',
+                                            title: '记录状态',
+                                            align: 'center',
+                                            formatter:function (value) {
+                                                if(value==1){
+                                                    return "进入"
+                                                }else if(value ==2){
+                                                    return "外出"
+                                                }
+
+                                            }
+                                        }
+
+                                    ]
+                                ]
+                        }
+                }
+            };
+        };
+    }
+);

+ 50 - 51
admin-ui/app/whepi/tugou/dialogTugou.js

@@ -93,65 +93,65 @@ define(function (require) {
               {
                 name: 'tgSupplier', label: '组织者', maxlength: 20,
                 width: 450, height: 35,
-                required: true,value:'指挥部',
-                readonly:  true ,
-              },
-              [{
-                name: 'tgGoods', label: '团购套餐',
-                required: true, width: 900, height: 35,
-                maxlength: 50,
-                readonly: context.isEdit ? true : false,
-                height: '100px', multiline: true,
+                required: true, value: '指挥部',
+                readonly: true,
               }],
-              {
-                name: 'tgPrice',
-                label: '单价',
-                readonly: context.isEdit ? true : false,
-                maxlength: 4, validType: 'integer',
-                required: true, width: 450, height: 35,
-              },
+            [{
+              name: 'tgGoods', label: '团购套餐',
+              required: true, width: 900, height: 35,
+              maxlength: 50,
+              readonly: context.isEdit ? true : false,
+              height: '100px', multiline: true,
+            }],
+            [{
+              name: 'tgPrice',
+              label: '单价',
+              readonly: context.isEdit ? true : false,
+              maxlength: 4, validType: 'integer',
+              required: true, width: 450, height: 35,
+            },
               {
                 name: 'tgMinNum',
                 label: '最小起订量',
                 readonly: context.isEdit ? true : false,
                 maxlength: 4, validType: 'integer',
                 required: true, width: 450, height: 35,
-              },
-              [{
-                name: 'tgMaxNum',
-                readonly: context.isEdit ? true : false,
-                label: '最大上限', required: true, validType: 'integer',
-                maxlength: 4, width: 450, height: 35,
-              },
-                {
-                  name: 'tgEndTime',
-                  label: '团购截止时间',
-                  readonly: context.isEdit ? true : false,
-                  xtype: 'datetimebox',
-                  required: true, width: 450, height: 35,
-                },],
-              [{
-                name: 'tgDeliverTime',
-                multiline: true,
+              }],
+            [{
+              name: 'tgMaxNum',
+              readonly: context.isEdit ? true : false,
+              label: '最大上限', required: true, validType: 'integer',
+              maxlength: 4, width: 450, height: 35,
+            },
+              {
+                name: 'tgEndTime',
+                label: '团购截止时间',
                 readonly: context.isEdit ? true : false,
                 xtype: 'datetimebox',
-                label: '预计送货时间',
                 required: true, width: 450, height: 35,
-              },
-                {
-                  name: 'tgPhoneNumber', validType: 'telNum',
-                  label: '联系电话', width: 450, height: 35,
-                  readonly: context.isEdit ? true : false,
-                  required: true, maxlength: 11,
-                }],
-              [{
-                name: 'remark',
-                label: '备注',
-                multiline: true,
-                width: 900,
-                height: '100px',
-                maxlength: 100,
-              }]]
+              }],
+            [{
+              name: 'tgDeliverTime',
+              multiline: true,
+              readonly: context.isEdit ? true : false,
+              xtype: 'datetimebox',
+              label: '预计送货时间',
+              required: true, width: 450, height: 35,
+            },
+              {
+                name: 'tgPhoneNumber', validType: 'telNum',
+                label: '联系电话', width: 450, height: 35,
+                readonly: context.isEdit ? true : false,
+                required: true, maxlength: 11,
+              }],
+            [{
+              name: 'remark',
+              label: '备注',
+              multiline: true,
+              width: 900,
+              height: '100px',
+              maxlength: 100,
+            }]
           ],
         }
       },
@@ -163,14 +163,13 @@ define(function (require) {
               return;
             }
             if ($form.formGet().tgMinNum > $form.formGet().tgMaxNum) {
-              $.yvan.msg('最大上线必须大于等于最小起订量');
+              $.yvan.msg('最大上必须大于等于最小起订量');
               return;
             }
             if ($form.formGet().tgEndTime > $form.formGet().tgDeliverTime) {
               $.yvan.msg('团购截止时间必须小于预计送货时间');
               return;
             }
-
             console.log($form.formGet())
             $.yvan.postForm($form, {
               url: (context.isEdit ? api('/yeweihui/tgStatus') : api('/yeweihui/tgPublish')),

+ 2 - 0
whepi-doc/login.sql

@@ -243,6 +243,8 @@ CREATE TABLE sys_uptown_door  (
   door_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '小区大门ID',
   uptown_id         bigint(20) NOT NULL DEFAULT 0 COMMENT '小区ID',
   door_name         varchar(20)  NOT NULL DEFAULT '' COMMENT '大门名称',
+  in_img            varchar(100)  NOT NULL DEFAULT '' COMMENT '入口二维码',
+  out_img           varchar(100)  NOT NULL DEFAULT '' COMMENT '出口二维码',
   status            int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
   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 '修改时间',

+ 1 - 1
whepi-ui/templates/home/ribao.js

@@ -726,7 +726,7 @@ function getGreder(greder) {
 
 function getFamilyStatus(familyStatus) {
   var familyStatusList = familyStatus.split(",");
-  var familyStatusString = "";
+  var familyStatusString = "无病史,";
   if (familyStatusList[0] == 1)
     familyStatusString += "心脑血管疾病(服用ARB),";
   if (familyStatusList[1] == 1)

+ 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);
 }

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

@@ -1,6 +1,7 @@
 package com.bofeng.dao;
 
 import com.bofeng.entity.SysUptownHouse;
+import com.yvan.PageDb;
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
@@ -10,5 +11,6 @@ import java.util.Map;
 @Mapper
 @Repository
 public interface SweepCodeMapper {
-    List<SysUptownHouse> selectCode(Map<String, Object> queryParam);
+    List<SysUptownHouse> selectCode(PageDb pageDb, Map<String, Object> queryParam);
+    List<SysUptownHouse> export(Map<String, Object> queryParam);
 }

+ 12 - 0
whepi-web/src/main/java/com/bofeng/dao/UptownDoorMapper.java

@@ -6,6 +6,7 @@ import com.yvan.PageDb;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -21,4 +22,15 @@ public interface UptownDoorMapper extends BaseMapper<UptownDoor> {
 
     List<UptownDoor> getAllUptownDoor(PageDb pagination, Map<String, Object> map);
 
+    /**
+     * 更改小区大门的二维码
+     * @param doorId
+     * @return
+     */
+    Integer updateDoorQc(@Param("qcName") String qcName, @Param("img") String img, @Param("doorId") Long doorId);
+
+
+    @Select("select * from sys_uptown_door where door_name = #{doorName} and uptown_id = #{uptownId}")
+    List<UptownDoor> getUptownDoor(@Param("doorName") String doorName, @Param("uptownId") Long uptownId);
+
 }

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

@@ -35,7 +35,7 @@ public interface UptownUnitMapper extends BaseMapper<UptownUnit> {
 
     List<UptownUnit> queryYiChangList(@Param("uptownId") Long uptownId, @Param("reportDate") String reportDate);
 
-    @Select("SELECT u.uptown_id,uu.ridgepole,uu.unit,uh.doorplate FROM sys_user_role ur INNER JOIN sys_uptown_house uh " +
+    @Select("SELECT u.uptown_id,u.uptown_name as uptownName,uu.ridgepole,uu.unit,uh.doorplate FROM sys_user_role ur INNER JOIN sys_uptown_house uh " +
             "ON uh.house_id = ur.property_id INNER JOIN sys_uptown_unit uu ON uh.unit_id = uu.unit_id INNER JOIN " +
             "sys_uptown u ON u.uptown_id = uu.uptown_id WHERE ur.user_id = #{userId} AND ur.role_id = 1")
     UptownUnit getUptownUnitByUser(@Param("userId") Long userId);

+ 8 - 5
whepi-web/src/main/java/com/bofeng/entity/SysUptownHouse.java

@@ -62,16 +62,19 @@ public class SysUptownHouse implements Serializable {
     private String doorName;
 
     @TableField(exist = false)
-    @ExcelProperty(value = {"进时间"}, index = 6)
-    private String intoDate;
+    @ExcelProperty(value = {"进时间"}, index = 6)
+    private String date;
 
     @TableField(exist = false)
-    @ExcelProperty(value = {"外出时间"}, index = 7)
-    private String outDate;
+    private Integer inType;
+
+    @TableField(exist = false)
+    @ExcelProperty(value = {"记录状态"}, index = 7)
+    private String inTypeStr;
 
     @TableField(exist = false)
     @ExcelProperty(value = {"用户名"}, index = 4)
-    private String nickName;
+    private String linkman;
 
     @TableField(exist = false)
     private String jcStatus;

+ 8 - 7
whepi-web/src/main/java/com/bofeng/entity/UptownDoor.java

@@ -28,6 +28,14 @@ public class UptownDoor {
     @TableField("door_name")
     private String doorName;
 
+    @ApiModelProperty("入口二维码")
+    @TableField("in_img")
+    private String inImg;
+
+    @ApiModelProperty("出口二维码")
+    @TableField("out_img")
+    private String outImg;
+
     @ApiModelProperty("状态:1正常,0草稿,-1删除")
     @TableField("status")
     private Integer status;
@@ -45,11 +53,4 @@ public class UptownDoor {
     @ApiModelProperty("出门间隔时间")
     @TableField(exist = false)
     private Integer goOutFre;
-
-    @TableField(exist = false)
-    private String inImg;
-
-    @TableField(exist = false)
-    private String outImg;
-
 }

+ 9 - 9
whepi-web/src/main/java/com/bofeng/excel/ExcelUtils.java

@@ -244,15 +244,15 @@ public class ExcelUtils {
     /**
      * 从当前请求中获取分页方法和内容
      */
-    public static PageDb parsePagination() {
-        HttpServletRequest request = currentRequest();
-        HttpParameterParser parser = HttpParameterParser.newInstance(request);
-        int page = parser.getIntValue("page", 1);
-        int start = parser.getIntValue("start", 0);
-        int limit = parser.getIntValue("limit", 10);
-
-        return new PageDb(page, limit);
-    }
+//    public static PageDb parsePagination() {
+//        HttpServletRequest request = currentRequest();
+//        HttpParameterParser parser = HttpParameterParser.newInstance(request);
+//        int page = parser.getIntValue("page", 1);
+//        int start = parser.getIntValue("start", 0);
+//        int limit = parser.getIntValue("limit", 10);
+//
+//        return new PageDb(page, limit);
+//    }
 
 
     /**

+ 38 - 0
whepi-web/src/main/java/com/bofeng/service/ScanAdminService.java

@@ -0,0 +1,38 @@
+package com.bofeng.service;
+
+import com.baomidou.mybatisplus.toolkit.IdWorker;
+import com.bofeng.dao.OutScanConfMapper;
+import com.bofeng.dao.UptownDoorMapper;
+import com.bofeng.entity.OutScanConf;
+import com.bofeng.entity.UptownDoor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@Transactional(readOnly = true)
+public class ScanAdminService {
+
+    @Autowired
+    private UptownDoorMapper uptownDoorMapper;
+    @Autowired
+    private OutScanConfMapper outScanConfMapper;
+
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public Integer saveUptownDoor(UptownDoor uptownDoor) {
+        uptownDoor.setDoorId(IdWorker.getId());
+        uptownDoor.setInImg("");
+        uptownDoor.setOutImg("");
+        uptownDoor.setStatus(1);
+        OutScanConf outScanConf = outScanConfMapper.getOutScanConfByUptown(uptownDoor.getUptownId());
+        if (outScanConf == null) {
+            OutScanConf scanConf = new OutScanConf();
+            scanConf.setScId(IdWorker.getId());
+            scanConf.setUptownId(uptownDoor.getUptownId());
+            scanConf.setGoOutFre(3);
+            outScanConfMapper.insert(scanConf);
+        }
+        return uptownDoorMapper.insert(uptownDoor);
+    }
+}

+ 19 - 2
whepi-web/src/main/java/com/bofeng/service/SweepCodeService.java

@@ -3,6 +3,7 @@ package com.bofeng.service;
 
 import com.bofeng.dao.SweepCodeMapper;
 import com.bofeng.entity.SysUptownHouse;
+import com.yvan.PageDb;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -18,8 +19,24 @@ public class SweepCodeService {
     private SweepCodeMapper sweepCodeMapper;
 
 
-    public List<SysUptownHouse> selectCode(Map<String, Object> queryParam) {
-        List<SysUptownHouse> sysUptownHouses = sweepCodeMapper.selectCode(queryParam);
+    public List<SysUptownHouse> selectCode(PageDb pageDb, Map<String, Object> queryParam) {
+        List<SysUptownHouse> sysUptownHouses = sweepCodeMapper.selectCode(pageDb,queryParam);
+
+        return sysUptownHouses;
+    }
+
+
+    public List<SysUptownHouse> export(Map<String, Object> queryParam) {
+        List<SysUptownHouse> sysUptownHouses = sweepCodeMapper.export(queryParam);
+        if(sysUptownHouses.size() != 0){
+            for (int i = 0; i < sysUptownHouses.size(); i++) {
+                if(sysUptownHouses.get(i).getInType() == 1 ){
+                    sysUptownHouses.get(i).setInTypeStr("进入");
+                }else if(sysUptownHouses.get(i).getInType() == 2 ){
+                    sysUptownHouses.get(i).setInTypeStr("外出");
+                }
+            }
+        }
 
         return sysUptownHouses;
     }

+ 214 - 0
whepi-web/src/main/java/com/bofeng/unit/QRCode.java

@@ -0,0 +1,214 @@
+package com.bofeng.unit;
+
+import com.baomidou.mybatisplus.toolkit.IdWorker;
+import com.google.common.base.Strings;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class QRCode {
+
+    public static String programUploadPath = "/home/www/upload/whepi";
+
+    /**
+     * CODE_WIDTH:二维码宽度,单位像素
+     * CODE_HEIGHT:二维码高度,单位像素
+     * FRONT_COLOR:二维码前景色,0x000000 表示黑色
+     * BACKGROUND_COLOR:二维码背景色,0xFFFFFF 表示白色
+     * 演示用 16 进制表示,和前端页面 CSS 的取色是一样的,注意前后景颜色应该对比明显,如常见的黑白
+     */
+    private static final int CODE_WIDTH = 256;
+    private static final int CODE_HEIGHT = 256;
+    private static final int FRONT_COLOR = 0x000000;
+    private static final int BACKGROUND_COLOR = 0xFFFFFF;
+
+    public static BufferedImage createQRCode(String content, BufferedImage bufferedImage, int topFontWidth, int topFontHeight, int bottomFontWidth, int bottomFontHeight) throws WriterException {
+        //检验参数
+        if (content == null || "".equals(content)) {
+            return null;
+        }
+        if (bufferedImage == null) {
+            return null;
+        }
+        content = content.trim();
+        int width = bufferedImage.getWidth();
+        int height = bufferedImage.getHeight();
+        int startBottomY = height + topFontHeight;
+        height = startBottomY + bottomFontHeight;
+        /**com.google.zxing.EncodeHintType:编码提示类型,枚举类型
+         * EncodeHintType.CHARACTER_SET:设置字符编码类型
+         * EncodeHintType.ERROR_CORRECTION:设置误差校正
+         * ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction
+         * 不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的
+         * EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近
+         * */
+        Map<EncodeHintType, Object> hints = new HashMap();
+        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
+        hints.put(EncodeHintType.MARGIN, 1);
+
+        /**
+         * MultiFormatWriter:多格式写入,这是一个工厂类,里面重载了两个 encode 方法,用于写入条形码或二维码
+         * encode(String contents,BarcodeFormat format,int width, int height,Map<EncodeHintType,?> hints)
+         *  contents:条形码/二维码内容
+         *  format:编码类型,如 条形码,二维码 等
+         *  width:码的宽度
+         *  height:码的高度
+         *  hints:码内容的编码类型
+         * BarcodeFormat:枚举该程序包已知的条形码格式,即创建何种码,如 1 维的条形码,2 维的二维码 等
+         * BitMatrix:位(比特)矩阵或叫2D矩阵,也就是需要的二维码
+         */
+        MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
+        BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
+
+        /**java.awt.image.BufferedImage:具有图像数据的可访问缓冲图像,实现了 RenderedImage 接口
+         * BitMatrix 的 get(int x, int y) 获取比特矩阵内容,指定位置有值,则返回true,将其设置为前景色,否则设置为背景色
+         * BufferedImage 的 setRGB(int x, int y, int rgb) 方法设置图像像素
+         * x:像素位置的横坐标,即列
+         * y:像素位置的纵坐标,即行
+         * rgb:像素的值,采用 16 进制,如 0xFFFFFF 白色
+         */
+        BufferedImage newBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
+        for (int x = 0; x < width; x++) {
+            for (int y = 0; y < height; y++) {
+                //顶部文字填充区域设置为空白
+                if (y <= topFontHeight) {
+                    newBufferedImage.setRGB(x, y, BACKGROUND_COLOR);
+                }
+                //底部文字填充区域设置为空白
+                else if (y > startBottomY) {
+                    newBufferedImage.setRGB(x, y, BACKGROUND_COLOR);
+                } else {
+                    newBufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR);
+                }
+            }
+        }
+        bufferedImage = null; //主动释放
+        return newBufferedImage;
+    }
+
+    public static String createBase64Img(String content, String topFont, String bottomFont) throws WriterException, IOException {
+        BufferedImage bufferedImage = new BufferedImage(CODE_WIDTH, CODE_HEIGHT, BufferedImage.TYPE_INT_RGB);
+        if (content == null || "".equals(content)) {
+            return  null;
+        }
+        topFont = topFont == null ? "" : topFont;
+        bottomFont = bottomFont == null ? "" : bottomFont;
+        bufferedImage = pressTextInImage(bufferedImage, content, topFont, bottomFont);
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        //写入流中
+        ImageIO.write(bufferedImage, "jpg", outputStream);
+        //转换成字节
+        byte[] bytes = outputStream.toByteArray();
+        //对字节数组Base64编码  -- 转换成base64串
+	   /* BASE64Encoder encoder = new BASE64Encoder();
+	    String base64Img = encoder.encodeBuffer(bytes).trim();*/
+        Base64 encoder = new Base64();
+        String base64Img = encoder.encodeToString(bytes);
+
+        //删除 \r\n
+        base64Img = base64Img.replaceAll("\n", "").replaceAll("\r", "");
+        //前面加 data:image/jpg;base64,
+        String res = "data:image/jpg;base64," + base64Img.toString();
+        //关闭流
+        if (outputStream != null) {
+            outputStream.close();
+        }
+//        System.out.println(res);
+        return decryptByBase64(res);
+    }
+
+    public static BufferedImage pressTextInImage(BufferedImage bufferedImage, String content, String topFont, String bottomFont) throws WriterException {
+        if (bufferedImage == null) {
+            return null;
+        }
+        //图片绘制对象 Color.RED
+        Graphics graphics = bufferedImage.createGraphics();
+        Font font = new Font("黑体", 5, 18);
+        FontMetrics metrics = graphics.getFontMetrics(font);
+        //获取底部字体的宽和高
+        int bottomFontWidth = metrics.stringWidth(bottomFont);
+        int bottomFontHeight = metrics.getHeight();
+        //获取顶部字体的宽和高
+        int topFontWidth = metrics.stringWidth(topFont);
+        int topFontHeight = metrics.getHeight();
+        //将image生成二维码图片对象
+        bufferedImage = createQRCode(content, bufferedImage, topFontWidth, topFontHeight, bottomFontWidth, bottomFontHeight);
+        //获取二维码图片的宽和高
+        int imageW = bufferedImage.getWidth();
+        int imageH = bufferedImage.getHeight();
+        //计算顶部文字填充位置
+        int topStartX = (imageW - topFontWidth) / 2; //居中显示
+        int topStartY = topFontHeight;
+        //计算底部文字填充位置
+        int bottomStartX = (imageW - bottomFontWidth) / 2; //居中显示
+        int bottomStartY = (imageH - bottomFontHeight) + 2;
+
+        //文字图片对象
+        BufferedImage textImag = new BufferedImage(imageW, imageH, BufferedImage.TYPE_INT_RGB);
+        Graphics textGraphics = textImag.createGraphics();
+        //画图
+        textGraphics.drawImage(bufferedImage, 0, 0, imageW, imageH, null);
+        // 写底部文字
+        textGraphics.setColor(Color.RED);
+        textGraphics.setFont(font);
+        textGraphics.drawString(bottomFont, bottomStartX, bottomStartY);
+        //写顶部字体
+        textGraphics.setColor(Color.RED);
+        textGraphics.setFont(font);
+        textGraphics.drawString(topFont, topStartX, topStartY);
+        graphics.dispose();
+        return textImag;
+    }
+
+    /**
+     * base64转存文件
+     * @param base64
+     * @return
+     */
+    public static String decryptByBase64(String base64) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+        if (Strings.isNullOrEmpty(base64)) {
+            return "";
+        }
+        String filePath = programUploadPath + "/upload/" + sdf.format(new Date()) + "/" + IdWorker.getId() + ".jpg";
+        File path = new File(programUploadPath  + "/upload/" + sdf.format(new Date()));
+        if (!path.exists()) {
+            path.mkdirs();
+        }
+        try {
+            Files.write(Paths.get(filePath),
+                    Base64.decodeBase64(base64.substring(base64.indexOf(",") + 1)), StandardOpenOption.CREATE);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return filePath.replace(programUploadPath, "");
+    }
+
+//    public static void main(String[] args) throws IOException, WriterException {
+//        Long startTime = System.currentTimeMillis();
+//        System.out.println("******************************");
+//        String file = createBase64Img("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx02a4ee296708dfd4&redirect_uri=http%3A%2F%2Fpeiguo.ng.yvanui.com%2Fuser%2FscanEstate.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect", "家园互助平台", "巡检扫码");
+//        Long endTime = System.currentTimeMillis();
+//        System.out.println(file);
+//        System.out.println((endTime - startTime) + " |" +(endTime - startTime)/ 1000);
+//    }
+}

+ 89 - 25
whepi-web/src/main/java/com/bofeng/wx/controller/ScanAdminController.java

@@ -1,10 +1,18 @@
 package com.bofeng.wx.controller;
 
+import cn.afterturn.easypoi.cache.manager.IFileLoader;
+import com.baomidou.mybatisplus.toolkit.IdWorker;
+import com.bofeng.dao.OutScanConfMapper;
 import com.bofeng.dao.UptownDoorMapper;
+import com.bofeng.dao.UptownMapper;
+import com.bofeng.entity.OutScanConf;
 import com.bofeng.entity.SysUptownHouse;
+import com.bofeng.entity.Uptown;
 import com.bofeng.entity.UptownDoor;
 import com.bofeng.excel.ExcelUtils;
+import com.bofeng.service.ScanAdminService;
 import com.bofeng.service.SweepCodeService;
+import com.bofeng.unit.QRCode;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.MultiFormatWriter;
 import com.google.zxing.WriterException;
@@ -13,6 +21,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
 import com.google.zxing.common.BitMatrix;
 import com.yvan.Model;
 import com.yvan.PageDb;
+import com.yvan.mvc.JsonBody;
 import com.yvan.mvc.Pd;
 import com.yvan.springmvc.HttpParameterParser;
 import io.swagger.annotations.Api;
@@ -22,8 +31,10 @@ import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.ServletOutputStream;
@@ -41,34 +52,68 @@ public class ScanAdminController {
     private SweepCodeService sweepCodeService;
     @Autowired
     private UptownDoorMapper uptownDoorMapper;
+    @Autowired
+    private UptownMapper uptownMapper;
+    @Autowired
+    private ScanAdminService scanAdminService;
 
     @ApiOperation("出入查询")
-    @GetMapping("/whepi/sweepCode/selectCode")
-    public Model<List<SysUptownHouse>> selectCode(HttpParameterParser parser) {
+    @PostMapping("/whepi/sweepCode/selectCode")
+    public Model<List<SysUptownHouse>> selectCode(PageDb pageDb,HttpParameterParser parser) {
 //        HttpServletResponse response,HttpServletRequest request
-        List<SysUptownHouse> sysUptownHouses = sweepCodeService.selectCode(parser.getMap());
-        return Model.newSuccess(sysUptownHouses);
+        List<SysUptownHouse> sysUptownHouses = sweepCodeService.selectCode(pageDb,parser.getMap());
+        return Model.newSuccess(pageDb,sysUptownHouses);
     }
 
     @ApiOperation("导出")
-    @GetMapping("/whepi/sweepCode/export")
+    @PostMapping("/whepi/sweepCode/export")
     @SneakyThrows
     public void export(HttpParameterParser parser,HttpServletResponse resp) {
-        List<SysUptownHouse> sysUptownHouses = sweepCodeService.selectCode(parser.getMap());
-        ExcelUtils.writeSheet(SysUptownHouse.class, sysUptownHouses).export(resp,"扫码导出");
+        List<SysUptownHouse> sysUptownHouses = sweepCodeService.export(parser.getMap());
+        ExcelUtils.writeSheet(SysUptownHouse.class, sysUptownHouses).export(resp,"出入管理");
     }
 
     @ApiOperation("小区进出二维码")
     @PostMapping("/whepi/qrImg/scanQrImg")
-    public Model<List<UptownDoor>> scanQrImg(HttpParameterParser parser, PageDb pagination) {
+    public Model<List<UptownDoor>> scanQrImg(HttpParameterParser parser, PageDb pagination) throws IOException, WriterException {
         List<UptownDoor> list = uptownDoorMapper.getAllUptownDoor(pagination, parser.getMap());
         for (UptownDoor door : list) {
-            door.setInImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=1");
-            door.setOutImg("/whepi/scan/scan_qr.png?doorId=" + door.getDoorId() + "&inType=2");
+            if (door.getInImg().equals("")) {
+                String img = scan_qr(door.getDoorId(),1,door.getUptownName()+door.getDoorName()+getName(1));
+                uptownDoorMapper.updateDoorQc("in_img", img, door.getDoorId());
+                door.setInImg(img);
+            }
+            if (door.getOutImg().equals("")) {
+                String img = scan_qr(door.getDoorId(),2,door.getUptownName()+door.getDoorName()+getName(2));
+                uptownDoorMapper.updateDoorQc("out_img", img, door.getDoorId());
+                door.setOutImg(img);
+            }
         }
         return Model.newSuccess(pagination, list);
     }
 
+    @ApiOperation("获取小区大门详细")
+    @GetMapping("/whepi/qrImg/getDoorById")
+    public Model<UptownDoor> getDoorById(HttpParameterParser parser,  @Pd(name = "doorId") Long doorId) {
+        return Model.newSuccess(uptownDoorMapper.getUptownDoorById(doorId));
+    }
+
+    @ApiOperation("保存小区大门信息")
+    @PostMapping("/whepi/qrImg/insertDoor")
+    public Model insert(@JsonBody UptownDoor uptownDoor) {
+        List<UptownDoor> list = uptownDoorMapper.getUptownDoor(uptownDoor.getDoorName(), uptownDoor.getUptownId());
+        if (list.size() > 0) {
+            return Model.newFail("当前小区已经添加该门");
+        }
+        return Model.newSuccess(scanAdminService.saveUptownDoor(uptownDoor));
+    }
+
+    @ApiOperation("获取小区大门详细")
+    @PostMapping("/whepi/qrImg/getUptown")
+    public Model<List<Uptown>> getUptown(HttpParameterParser parser, PageDb pagination) {
+        return Model.newSuccess(pagination, uptownMapper.getUptowns(pagination, parser.getMap()));
+    }
+
     // 获取code
     private static final String oauth2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=";
     private static final String moreUrl = "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
@@ -85,14 +130,18 @@ public class ScanAdminController {
      * @throws IOException
      * @throws WriterException
      */
-    @GetMapping(value = "/whepi/scan/scan_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
-    public void scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType,
-                          HttpServletResponse response) throws IOException, WriterException {
-        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
-        String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
-        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
-                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
-        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+//    @GetMapping(value = "/whepi/scan/scan_qr")
+//    public String scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType, @Pd(name = "name") String name,
+//                          HttpServletResponse response) throws IOException, WriterException {
+//        String url = oauth2+appId +"&redirect_uri="+URLEncoder.encode(domain()+"user/scan.html?doorId="+doorId+"&inType="+inType,"utf-8")+moreUrl;
+//        String file = QRCode.createBase64Img(url, "家园互助平台", name);
+//        return file;
+//    }
+    public String scan_qr(Long doorId, Integer inType, String name)
+            throws IOException, WriterException {
+        String url = oauth2+appId +"&redirect_uri="+URLEncoder.encode(domain()+"user/scan.html?doorId="+doorId+"&inType="+inType,"utf-8")+moreUrl;
+        String file = QRCode.createBase64Img(url, "家园互助平台", name);
+        return file;
     }
 
     /**
@@ -100,13 +149,28 @@ public class ScanAdminController {
      * @throws IOException
      * @throws WriterException
      */
-    @GetMapping(value = "/whepi/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
-    public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
-        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
-        String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
-        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
-                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
-        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+    @GetMapping(value = "/whepi/scan/scanEstate_qr")
+    public String scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
+        String url = oauth2 + appId + "&redirect_uri=" + URLEncoder.encode( domain() + "user/scanEstate.html","utf-8") + moreUrl;
+        String file = QRCode.createBase64Img(url, "家园互助平台", "校园巡检二维码");
+        return file;
+    }
+
+    public String domain() {
+        if (domain.substring(domain.length()-1).equals("/")) {
+            return domain;
+        } else {
+            return domain + "/";
+        }
+    }
+
+    public String getName(Integer inType) {
+        if (inType == 1) {
+            return "入口";
+        } else if (inType == 2) {
+            return "出口";
+        }
+        return null;
     }
 
 }

+ 72 - 40
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,8 +209,8 @@ public class ScanController {
             if (msReports.size() != 3) {
                 model.put("collor", "red");
                 model.put("into", "禁止通行");
-                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请尽快返回住处。");
-                return new ModelAndView("/user/scan.ftl", model);
+                model.put("errorMsg", "您近期未提交健康日报,无法判断您健康状态,请尽快返回住处。");
+                return new ModelAndView("/user/scanEstate.ftl", model);
             }
             MsReport msReport = msReportMapper.selectMsReportToday(userOpen.getUserId());
             if (msReport != null && msReport.getMsStatus() == 2) {
@@ -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 "进入";
@@ -249,35 +281,35 @@ public class ScanController {
         return time.substring(0, time.length() - 1);
     }
 
-    /**
-     * 生成进出门二维码
-     * @param doorId 小区大门ID
-     * @param inType 1进入;2外出
-     * @param response
-     * @throws IOException
-     * @throws WriterException
-     */
-    @GetMapping(value = "/scan/scan_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
-    public void scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType,
-                            HttpServletResponse response) throws IOException, WriterException {
-        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
-        String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
-        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
-                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
-        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
-    }
-
-    /**
-     * 生成校园巡逻二维码
-     * @throws IOException
-     * @throws WriterException
-     */
-    @GetMapping(value = "/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
-    public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
-        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
-        String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
-        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
-                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
-        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
-    }
+//    /**
+//     * 生成进出门二维码
+//     * @param doorId 小区大门ID
+//     * @param inType 1进入;2外出
+//     * @param response
+//     * @throws IOException
+//     * @throws WriterException
+//     */
+//    @GetMapping(value = "/scan/scan_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
+//    public void scanQrImg(@Pd(name = "doorId") Long doorId, @Pd(name = "inType") Integer inType,
+//                            HttpServletResponse response) throws IOException, WriterException {
+//        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
+//        String msg = URLEncoder.encode( domain + "user/scan.html?doorId=" + doorId + "&inType=" + inType,"utf-8");
+//        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+//                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+//        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+//    }
+//
+//    /**
+//     * 生成校园巡逻二维码
+//     * @throws IOException
+//     * @throws WriterException
+//     */
+//    @GetMapping(value = "/scan/scanEstate_qr.png", produces = MediaType.IMAGE_PNG_VALUE)
+//    public void scanEstateQrImg(HttpServletResponse response) throws IOException, WriterException {
+//        @Cleanup ServletOutputStream outputStream = response.getOutputStream();
+//        String msg = URLEncoder.encode( domain + "user/scanEstate.html","utf-8");
+//        BitMatrix matrix = new MultiFormatWriter().encode(oauth2 + appId + "&redirect_uri=" +
+//                msg + moreUrl, BarcodeFormat.QR_CODE, 256, 256);
+//        MatrixToImageWriter.writeToStream(matrix, MediaType.IMAGE_PNG.getSubtype(), outputStream, new MatrixToImageConfig());
+//    }
 }

+ 1 - 1
whepi-web/src/main/resources/application.yml

@@ -43,7 +43,7 @@ endpoints:
 #  whitelabel.enabled: false
 
 spring:
-  profiles.active: guojing
+  profiles.active: maoyunfeng
 
   application:
     name: bofeng-web

+ 49 - 27
whepi-web/src/main/resources/mapper/SweepCodeMapper.xml

@@ -2,38 +2,60 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.bofeng.dao.SweepCodeMapper">
     <select id="selectCode" resultType="com.bofeng.entity.SysUptownHouse">
-       select
-        a.uptown_name,
-        d.ridgepole,
-        d.unit,
-        e.doorplate,
-        b.door_name,
-        c.into_date,
-        h.out_date,
-        g.nick_name
-        from sys_uptown a
-        inner join sys_uptown_door b on a.uptown_id = b.uptown_id
-        inner join out_scan c on c.into_door_id = b.door_id
-        inner join out_scan h on h.out_door_id = b.door_id
-        inner join sys_uptown_unit d on d.uptown_id = a.uptown_id
-        inner join sys_uptown_house e on e.unit_id = d.unit_id
-        inner join sys_user_role j on j.property_id = e.house_id and j.role_id = 1
-        inner join sys_user_open g on g.user_id = j.user_id
+     select DISTINCT
+     a.uptown_name,
+     d.ridgepole,
+     d.unit,
+     e.doorplate,
+     b.door_name,
+     c.date,
+     c.in_type,
+     g.linkman
+     from out_scan c
+     inner join sys_user_role t on c.user_id = t.user_id and role_id =1
+     inner join sys_uptown_home g on g.house_id = t.property_id
+     inner join sys_uptown a on c.uptown_id = a.uptown_id
+     inner join sys_uptown_door b on c.door_id = b.door_id
+     inner join sys_uptown_house e on e.house_id = t.property_id
+     inner join sys_uptown_unit d on d.unit_id = e.unit_id
         <where>
-         <if test="uptownName != null and uptownName != ''">
-          a.uptown_name like concat('%',#{uptownName},'%')
+         <if test="queryProperties != null and queryProperties != ''">
+          a.uptown_name like concat('%',#{queryProperties},'%')
          </if>
-         <if test="intoDate != null and intoDate !=''">
-          and c.into_date >= #{intoDate}
+         <if test="dateSta != null and dateSta !=''">
+          and c.date >= #{dateSta}
          </if>
-         <if test="intoDate != null and intoDate !=''">
-          and c.into_date &lt; #{intoDate}
+         <if test="dateEnd != null and dateEnd !=''">
+          and c.date &lt; #{dateEnd}
          </if>
-         <if test="outDate != null and outDate !=''">
-          and h.out_date &lt; #{outDate}
+        </where>
+    </select>
+    <select id="export" resultType="com.bofeng.entity.SysUptownHouse">
+     select DISTINCT
+     a.uptown_name,
+     d.ridgepole,
+     d.unit,
+     e.doorplate,
+     b.door_name,
+     c.date,
+     c.in_type,
+     g.linkman
+     from out_scan c
+     inner join sys_user_role t on c.user_id = t.user_id and role_id =1
+     inner join sys_uptown_home g on g.house_id = t.property_id
+     inner join sys_uptown a on c.uptown_id = a.uptown_id
+     inner join sys_uptown_door b on c.door_id = b.door_id
+     inner join sys_uptown_house e on e.house_id = t.property_id
+     inner join sys_uptown_unit d on d.unit_id = e.unit_id
+        <where>
+         <if test="queryProperties != null and queryProperties != ''">
+          a.uptown_name like concat('%',#{queryProperties},'%')
+         </if>
+         <if test="dateSta != null and dateSta !=''">
+          and c.date >= #{dateSta}
          </if>
-         <if test="outDate != null and outDate !=''">
-          and h.out_date >= #{outDate}
+         <if test="dateEnd != null and dateEnd !=''">
+          and c.date &lt; #{dateEnd}
          </if>
         </where>
     </select>

+ 7 - 2
whepi-web/src/main/resources/mapper/UptownDoorMapper.xml

@@ -3,7 +3,8 @@
 <mapper namespace="com.bofeng.dao.UptownDoorMapper">
 
     <select id="getAllUptownDoor" resultType="com.bofeng.entity.UptownDoor">
-        SELECT ud.*,u.uptown_name as uptownName FROM sys_uptown_door ud left join sys_uptown u on u.uptown_id =
+        SELECT ud.*,u.uptown_name as uptownName FROM sys_uptown_door ud
+        left join sys_uptown u on u.uptown_id =
         ud.uptown_id
         <where>
             and ud.status = 1
@@ -11,7 +12,11 @@
                 and u.uptown_name like concat('%',#{queryProperties},'%')
             </if>
         </where>
-        order by ud.time_update desc
+        order by ud.time_create desc
     </select>
 
+    <update id="updateDoorQc">
+        update sys_uptown_door set ${qcName} = #{img} where door_id = #{doorId}
+    </update>
+
 </mapper>

+ 10 - 0
yvan-platform/src/main/java/com/yvan/mvc/JztdMvcAutoConfigration.java

@@ -8,6 +8,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
 import java.util.List;
@@ -26,6 +27,15 @@ public class JztdMvcAutoConfigration extends WebMvcConfigurerAdapter {
     }
 
     /**
+     * 本机图片映射
+     * @param registry
+     */
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler("/whepi/upload/**").addResourceLocations("file:"+ "/home/www/upload/whepi" + "/upload/");
+    }
+
+    /**
      * 默认输出 json
      */
     @Override

+ 8 - 6
yvan-platform/src/main/java/com/yvan/mvc/PageDbResolver.java

@@ -22,13 +22,15 @@ public class PageDbResolver implements HandlerMethodArgumentResolver {
         //offset=20 limit=10 page=3 rows=10
         //offset=60 limit=10 page=7 rows=10
 
-        Object arg = webRequest.getParameter("offset");
-        if (arg == null) {
-            return new PageDb(false);
-        }
+//        Object arg = webRequest.getParameter("offset");
+//        if (arg == null) {
+//            return new PageDb(false);
+//        }
+//        int limit = Conv.NI(webRequest.getParameter("limit"), 10);
+//        int page = Conv.NI(arg, 1)/limit + 1;
 
-        int limit = Conv.NI(webRequest.getParameter("limit"), 10);
-        int page = Conv.NI(arg, 1)/limit + 1;
+        int limit = Conv.NI(webRequest.getParameter("rows"), 10);
+        int page = Integer.parseInt(webRequest.getParameter("page"));
         return new PageDb(page, limit);
     }
 }

+ 9 - 9
yvan-platform/src/main/java/com/yvan/springmvc/HttpUtils.java

@@ -144,15 +144,15 @@ public class HttpUtils {
     /**
      * 从当前请求中获取分页方法和内容
      */
-    public static PageDb parsePagination() {
-        HttpServletRequest request = currentRequest();
-        HttpParameterParser parser = HttpParameterParser.newInstance(request);
-        int page = parser.getIntValue("page", 1);
-        int start = parser.getIntValue("start", 0);
-        int limit = parser.getIntValue("limit", 10);
-
-        return new PageDb(page, limit);
-    }
+//    public static PageDb parsePagination() {
+//        HttpServletRequest request = currentRequest();
+//        HttpParameterParser parser = HttpParameterParser.newInstance(request);
+//        int page = parser.getIntValue("page", 1);
+//        int start = parser.getIntValue("start", 0);
+//        int limit = parser.getIntValue("limit", 10);
+//
+//        return new PageDb(page, limit);
+//    }
 
 
     /**