部门管理,人员类别管理,人员导入添加部门和人员类别
diff --git a/config/application-devel-pg.properties b/config/application-devel-pg.properties
index e3330f9..d06cff6 100644
--- a/config/application-devel-pg.properties
+++ b/config/application-devel-pg.properties
@@ -11,9 +11,9 @@
 database.dbtype=postgresql
 # Redis settings
 # spring.redis.host=172.28.201.101
-spring.redis.host=127.0.0.1
+spring.redis.host=172.28.201.70
 spring.redis.port=6379
-spring.redis.password=123456
+spring.redis.password=
 spring.redis.database=2
 
 
@@ -23,7 +23,7 @@
 jwt.expiration=3600
 auth.password.bcrypt.seed=
 spring.jackson.serialization.fail-on-empty-beans=false
-server.port=8099
+server.port=8080
 
 payapi.url=https://yy.dlsmk.cn/payapi
 
diff --git a/src/main/java/com/supwisdom/dlpay/customermanage/controller/CustomerController.java b/src/main/java/com/supwisdom/dlpay/customermanage/controller/CustomerController.java
new file mode 100644
index 0000000..b3fd236
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/customermanage/controller/CustomerController.java
@@ -0,0 +1,155 @@
+/*
+package com.supwisdom.dlpay.customermanage.controller;
+
+
+import com.google.gson.Gson;
+import com.supwisdom.dlpay.api.bean.JsonResult;
+import com.supwisdom.dlpay.framework.util.ExportExcel;
+import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.framework.util.WebConstant;
+import com.supwisdom.dlpay.restaurant.bean.CustomerSaveBean;
+import com.supwisdom.dlpay.restaurant.bean.CustomerSearchBean;
+import com.supwisdom.dlpay.restaurant.bean.CustomerShowBean;
+import com.supwisdom.dlpay.restaurant.domain.TCustType;
+import com.supwisdom.dlpay.restaurant.service.CustTypeService;
+import com.supwisdom.dlpay.restaurant.service.CustomerService;
+import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Controller
+@RequestMapping("/customer")
+public class CustomerController {
+
+    @Autowired
+    private CustomerService customerService;
+
+    @Autowired
+    private CustTypeService custTypeService;
+
+    @RequestMapping("/index")
+    public String indexView(ModelMap model) {
+        List<TCustType> lst = custTypeService.findAll();
+        Map<Integer, String> map = new HashMap<>();
+        for (TCustType type : lst) {
+            map.put(type.getCusttypeid(), type.getCusttypename());
+        }
+        Gson gson = new Gson();
+        String gsonString = gson.toJson(map);
+        model.put("custtypelist", gsonString);
+
+        return "restaurant/customer/index";
+    }
+
+    @RequestMapping("/list")
+    @PreAuthorize("hasPermission('/customer/list','')")
+    @ResponseBody
+    public PageResult<CustomerShowBean> getDataList(@RequestParam("page") Integer pageNo,
+                                                    @RequestParam("limit") Integer pageSize,
+                                                    @RequestParam(value = "searchkey", required = false) String searchKey) {
+        try {
+            if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;
+            if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;
+            CustomerSearchBean searchBean = new CustomerSearchBean();
+            searchBean.setPageNo(pageNo);
+            searchBean.setCustname(searchKey);
+            searchBean.setPageSize(pageSize);
+            PageResult<CustomerShowBean> bean= customerService.getCustomerPage(searchBean);
+
+            return bean;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new PageResult<>(99, "系统查询错误");
+        }
+    }
+
+
+    @GetMapping("/loadadd")
+    @PreAuthorize("hasPermission('/customer/loadadd','')")
+    public String loadadd(Model model) {
+        List<TCustType> list=custTypeService.findAll();
+        model.addAttribute("typelist",list);
+        return "restaurant/customer/form";
+    }
+
+    @PostMapping("/add")
+    @PreAuthorize("hasPermission('/customer/add','')")
+    @ResponseBody
+    public JsonResult add(@RequestBody CustomerSaveBean customer) {
+        if (customer != null) {
+            customer.setSavecardflag(0);
+            customer.setStatus(RestaurantConstant.STATUS_CARD_NORMAL);
+            customer.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_UNCHECK);
+            return customerService.saveCustomer(customer);
+        } else {
+            return JsonResult.error("添加失败");
+        }
+    }
+
+    @PostMapping("/delete")
+    @PreAuthorize("hasPermission('/customer/delete','')")
+    @ResponseBody
+    public JsonResult delete(@RequestParam String  custid) {
+        return customerService.deleteCustomer(custid);
+    }
+
+
+    @GetMapping("/loadimport")
+
+    @PreAuthorize("hasPermission('/customer/loadimport','')")
+
+    public String loadimport(Model model) {
+        return "restaurant/customer/import";
+    }
+
+
+    @RequestMapping("/download")
+    @PreAuthorize("hasPermission('/customer/download','')")
+    @ResponseBody
+    public JsonResult downloadfile(HttpServletRequest request, HttpServletResponse response) throws Exception{
+        String[] titles0 = {"姓名",	"市名卡号",	"市名卡银行卡号","人员类别号","手机(选填)"
+        }; //表头
+        String[][] info0 = {{"张三",	"123456",	"3000000","1","12341234123"
+        }}; // 示例内容
+        String fileName0 = "客户导入模板";// 保存数据
+
+        try {
+            ExportExcel.queryexcel(fileName0, titles0,info0,request, response);
+            return JsonResult.ok("操作成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return JsonResult.error("操作失败");
+    }
+
+    @PostMapping("/import")
+    @PreAuthorize("hasPermission('/customer/import','')")
+    @ResponseBody
+    public JsonResult importFile(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletRequest request) throws Exception{
+//    System.out.println("---------under the upload file:"+file);
+        return customerService.importFile(file,request);
+    }
+
+
+    @RequestMapping("/export")
+    @ResponseBody
+    public JsonResult exportCustomerExcel(
+                                   HttpServletRequest request, HttpServletResponse response) {
+
+        return customerService.export( request, response);
+    }
+
+
+}
+*/
diff --git a/src/main/java/com/supwisdom/dlpay/doorlist/bean/CustomerListBean.java b/src/main/java/com/supwisdom/dlpay/doorlist/bean/CustomerListBean.java
index cdaeb2e..5c0da93 100644
--- a/src/main/java/com/supwisdom/dlpay/doorlist/bean/CustomerListBean.java
+++ b/src/main/java/com/supwisdom/dlpay/doorlist/bean/CustomerListBean.java
@@ -11,6 +11,10 @@
     private String cardno;

     @Excel(name = "银行卡号")

     private String bankcardno;

+    @Excel(name="部门代码")

+    private String deptno;

+    @Excel(name = "客户类别号")

+    private String custtypeid;

     /*//@Excel(name = "物理卡号")

     private String cardphyid;

     //@Excel(name = "性别")

@@ -51,6 +55,22 @@
         this.bankcardno = bankcardno;

     }

 

+    public String getDeptno() {

+        return deptno;

+    }

+

+    public void setDeptno(String deptno) {

+        this.deptno = deptno;

+    }

+

+    public String getCusttypeid() {

+        return custtypeid;

+    }

+

+    public void setCusttypeid(String custtypeid) {

+        this.custtypeid = custtypeid;

+    }

+

     /*public String getCardphyid() {

         return cardphyid;

     }

diff --git a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
index ee1b19b..1455d88 100644
--- a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
@@ -27,6 +27,7 @@
 import com.supwisdom.dlpay.paysdk.ApiLoginHelper;

 import com.supwisdom.dlpay.paysdk.proxy.ApiLoginProxy;

 import com.supwisdom.dlpay.paysdk.proxy.UserProxy;

+import com.supwisdom.dlpay.system.domain.TDept;

 import com.supwisdom.dlpay.system.domain.TDictionaryId;

 import com.supwisdom.dlpay.system.domain.TRegion;

 import com.supwisdom.dlpay.system.domain.TSystemParam;

@@ -74,22 +75,22 @@
 

     @RequestMapping("/downDoorList")

     public String downDoorList(ModelMap model) {

-      return "doorlist/addDoorlist";

+        return "doorlist/addDoorlist";

     }

 

     @RequestMapping("/deleteDoorList")

     public String deleteDoorList(ModelMap model) {

-      return "doorlist/deleteDoorlist";

+        return "doorlist/deleteDoorlist";

     }

 

     @RequestMapping("/searchDoorlist")

     public String searchDoorlist(ModelMap model) {

-      return "doorlist/searchDoorlist";

+        return "doorlist/searchDoorlist";

     }

 

     @RequestMapping("/impCustomerlistindex")

-    public String impCustomerlistindex(){

-      return "doorlist/impCustomerlist";

+    public String impCustomerlistindex() {

+        return "doorlist/impCustomerlist";

     }

 

     /**

@@ -101,41 +102,41 @@
     @ResponseBody

     @RequestMapping(value = "/getFillFormList")

     public Map getFillFormList(@AuthenticationPrincipal TOperator operUser) throws Exception {

-      Map map = new HashMap();

-      try {

-        String opertype = operUser.getOpertype();

-        //名单状态

-        List<TDictionaryId> syncDicts = systemService.findTDictionaryByType(3);

-        map.put("syncDicts", syncDicts);

-        //操作标记

-        List<TDictionaryId> operDicts = new ArrayList<TDictionaryId>();

-        operDicts.addAll(systemService.findByType(2, "A"));

-        operDicts.addAll(systemService.findByType(2, "D"));

-        operDicts.addAll(systemService.findByType(2, "C"));

-        map.put("operDicts", operDicts);

+        Map map = new HashMap();

+        try {

+            String opertype = operUser.getOpertype();

+            //名单状态

+            List<TDictionaryId> syncDicts = systemService.findTDictionaryByType(3);

+            map.put("syncDicts", syncDicts);

+            //操作标记

+            List<TDictionaryId> operDicts = new ArrayList<TDictionaryId>();

+            operDicts.addAll(systemService.findByType(2, "A"));

+            operDicts.addAll(systemService.findByType(2, "D"));

+            operDicts.addAll(systemService.findByType(2, "C"));

+            map.put("operDicts", operDicts);

 

-        List<TRegion> regions = null;

-        List<TBuilding> buildings = null;

-        if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

-          regions = systemService.getAllRegions();

-          buildings = ncService.getAllBuilding();

-          map.put("regions", regions);

-          map.put("buildings", buildings);

-        } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

-          regions = systemService.getRegionListById(operUser.getRegionid());

-          map.put("regions", regions);

-          buildings = systemService.getBuildingByRegionId(operUser.getRegionid());

-          map.put("buildings", buildings);

-        }else if (opertype.equals("L")){

-            map.put("regions", regions);

-            buildings = systemService.getBuildingOperBuildings(operUser.getOperid());

-            map.put("buildings", buildings);

+            List<TRegion> regions = null;

+            List<TBuilding> buildings = null;

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

+                regions = systemService.getAllRegions();

+                buildings = ncService.getAllBuilding();

+                map.put("regions", regions);

+                map.put("buildings", buildings);

+            } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

+                regions = systemService.getRegionListById(operUser.getRegionid());

+                map.put("regions", regions);

+                buildings = systemService.getBuildingByRegionId(operUser.getRegionid());

+                map.put("buildings", buildings);

+            } else if (opertype.equals("L")) {

+                map.put("regions", regions);

+                buildings = systemService.getBuildingOperBuildings(operUser.getOperid());

+                map.put("buildings", buildings);

+            }

+

+        } catch (Exception e) {

+            e.printStackTrace();

         }

-

-      } catch (Exception e) {

-        e.printStackTrace();

-      }

-      return map;

+        return map;

     }

 

     /**

@@ -167,27 +168,27 @@
                               @RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize,

                               @AuthenticationPrincipal TOperator operUser) {

 

-      Map map = new HashMap();

-      try {

-        String opertype = operUser.getOpertype();

-        boolean flag = true;

-        Pagination pResult = new Pagination();

-        if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

-          pResult = webInterfaceService.getSystemCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname,cardno, syncflag, operflag, buildingid, regionid, pageNo, pageSize);

-        } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

-          pResult = webInterfaceService.getOperatorCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, regionid, pageNo, pageSize, operUser.getRegionid());

-        }else if (opertype.equals("L")){

-            pResult = webInterfaceService.getBuildingOperCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, operUser.getOperid(), pageNo, pageSize);

+        Map map = new HashMap();

+        try {

+            String opertype = operUser.getOpertype();

+            boolean flag = true;

+            Pagination pResult = new Pagination();

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

+                pResult = webInterfaceService.getSystemCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, regionid, pageNo, pageSize);

+            } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

+                pResult = webInterfaceService.getOperatorCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, regionid, pageNo, pageSize, operUser.getRegionid());

+            } else if (opertype.equals("L")) {

+                pResult = webInterfaceService.getBuildingOperCardListFrSearch(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, operUser.getOperid(), pageNo, pageSize);

+            }

+            map.put("PageResult", pResult);

+            map.put("index", flag);

+            map.put("result", "查询设备名单成功!");

+        } catch (Exception e) {

+            e.printStackTrace();

+            map.put("result", "查询设备名单失败!");

+            logger.error("查询设备名单失败:" + e.getMessage());

         }

-        map.put("PageResult", pResult);

-        map.put("index", flag);

-        map.put("result", "查询设备名单成功!");

-      } catch (Exception e) {

-        e.printStackTrace();

-        map.put("result", "查询设备名单失败!");

-        logger.error("查询设备名单失败:" + e.getMessage());

-      }

-      return map;

+        return map;

     }

 

     /**

@@ -214,31 +215,31 @@
                          @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,

                          @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,

                          @AuthenticationPrincipal TOperator operUser) {

-      String opertype = operUser.getOpertype();

-      /**

-       * 1.查询值

-       */

-      List<TDoorcardlstInfo> cardList = null;

-      if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

-        cardList = webInterfaceService.getSystemCardListMap(allocatStartDate, allocatEndDate,

-            devname, custname, cardno, syncflag, operflag, buildingid, regionid);

-      } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

-        cardList = webInterfaceService.getOperatorCardListMap( allocatStartDate, allocatEndDate,

-            devname, custname, cardno, syncflag, operflag, buildingid, regionid, operUser.getRegionid());

-      }else if (opertype.equals("L")){

-        cardList = webInterfaceService.getBuildingOperCardListMap(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, operUser.getOperid());

-      }

+        String opertype = operUser.getOpertype();

+        /**

+         * 1.查询值

+         */

+        List<TDoorcardlstInfo> cardList = null;

+        if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

+            cardList = webInterfaceService.getSystemCardListMap(allocatStartDate, allocatEndDate,

+                    devname, custname, cardno, syncflag, operflag, buildingid, regionid);

+        } else if (!StringUtil.isEmpty(operUser.getRegionid()) && opertype.equals("H")) {

+            cardList = webInterfaceService.getOperatorCardListMap(allocatStartDate, allocatEndDate,

+                    devname, custname, cardno, syncflag, operflag, buildingid, regionid, operUser.getRegionid());

+        } else if (opertype.equals("L")) {

+            cardList = webInterfaceService.getBuildingOperCardListMap(allocatStartDate, allocatEndDate, devname, custname, cardno, syncflag, operflag, buildingid, operUser.getOperid());

+        }

 

-      /**

-       * 2.设置表格属性: title:标题  sheetName:工作簿名 type:表格类型

-       */

-      ExportParams params = new ExportParams("设备名单列表", "设备名单", ExcelType.XSSF);

+        /**

+         * 2.设置表格属性: title:标题  sheetName:工作簿名 type:表格类型

+         */

+        ExportParams params = new ExportParams("设备名单列表", "设备名单", ExcelType.XSSF);

 

-      modelMap.put(NormalExcelConstants.DATA_LIST, cardList);//设置值

-      modelMap.put(NormalExcelConstants.PARAMS, params);//设置属性

-      modelMap.put(NormalExcelConstants.CLASS, TDoorcardlstInfo.class);

-      modelMap.put(NormalExcelConstants.FILE_NAME, "下发设备名单");

-      PoiBaseView.render(modelMap, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);

+        modelMap.put(NormalExcelConstants.DATA_LIST, cardList);//设置值

+        modelMap.put(NormalExcelConstants.PARAMS, params);//设置属性

+        modelMap.put(NormalExcelConstants.CLASS, TDoorcardlstInfo.class);

+        modelMap.put(NormalExcelConstants.FILE_NAME, "下发设备名单");

+        PoiBaseView.render(modelMap, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);

 

     }

 

@@ -253,97 +254,101 @@
     @RequestMapping(value = "/reSaveDoorCardList", method = {RequestMethod.POST})

     public Map reSaveDoorCardList(HttpServletRequest request,

                                   @RequestBody TDoorcardlstInfo[] tDoorcardlstInfos) {

-      Map map = new HashMap();

-      String msg = "";

-      try {

-        List<Long> listIds = new ArrayList<>();

-        for (TDoorcardlstInfo tDoorcardlstInfo : tDoorcardlstInfos) {

-          listIds.add(Long.valueOf(tDoorcardlstInfo.getListid()));

+        Map map = new HashMap();

+        String msg = "";

+        try {

+            List<Long> listIds = new ArrayList<>();

+            for (TDoorcardlstInfo tDoorcardlstInfo : tDoorcardlstInfos) {

+                listIds.add(Long.valueOf(tDoorcardlstInfo.getListid()));

+            }

+            webInterfaceService.updateDoorcardlstToNoWithIds(listIds);

+            RedisUtil.incr("zcard_max_version");

+            map.put("result", "重新下发设备名单成功!");

+        } catch (Exception e) {

+            e.printStackTrace();

+            map.put("result", "重新下发设备名单失败!");

+            msg = "重新下发设备名单异常";

+            logger.error("重定向出错:" + e.getMessage());

         }

-        webInterfaceService.updateDoorcardlstToNoWithIds(listIds);

-        RedisUtil.incr("zcard_max_version");

-        map.put("result", "重新下发设备名单成功!");

-      } catch (Exception e) {

-        e.printStackTrace();

-        map.put("result", "重新下发设备名单失败!");

-        msg = "重新下发设备名单异常";

-        logger.error("重定向出错:" + e.getMessage());

-      }

-      map.put("msg", msg);

-      return map;

+        map.put("msg", msg);

+        return map;

     }

 

     /**

      * 人员名单导入模板

+     *

      * @param request

      * @param response

      * @param map

      */

     @RequestMapping(value = "/downImpTemplate")

     public void downImpTemplate(HttpServletRequest request, HttpServletResponse response, ModelMap map) {

-      try {

-        List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();

-        /**

-         * 1. 设置列信息:name:列标题   key:	列属性

-         */

-          entity.add(new ExcelExportEntity("市民卡号(必填)", "cardno"));

-        entity.add(new ExcelExportEntity("姓名", "custname"));

-        entity.add(new ExcelExportEntity("银行卡号", "bankcarno"));

+        try {

+            List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();

+            /**

+             * 1. 设置列信息:name:列标题   key:	列属性

+             */

+            entity.add(new ExcelExportEntity("市民卡号(必填)", "cardno"));

+            entity.add(new ExcelExportEntity("姓名", "custname"));

+            entity.add(new ExcelExportEntity("银行卡号", "bankcarno"));

+            entity.add(new ExcelExportEntity("部门代码", "deptno"));

+            entity.add(new ExcelExportEntity("客户类别号", "custtypeid"));

 //        entity.add(new ExcelExportEntity("物理卡号()","cardphyid"));

 //        entity.add(new ExcelExportEntity("性别", "sex"));

 //        entity.add(new ExcelExportEntity("电子邮箱", "email"));

 //        entity.add(new ExcelExportEntity("手机", "mobile"));

 //        entity.add(new ExcelExportEntity("地址", "addr"));

 //        entity.add(new ExcelExportEntity("注销日期", "closedate"));

-        entity.add(new ExcelExportEntity("备注", "remarks"));

-        List<Map> personList = new ArrayList<Map>();

+            entity.add(new ExcelExportEntity("备注", "remarks"));

+            List<Map> personList = new ArrayList<Map>();

 

-        /**

-         * 3.设置表格属性: title:标题  sheetName:工作簿名 type:表格类型

-         */

-        ExportParams params = new ExportParams(null, "sheet1", ExcelType.HSSF);

-        map.put(MapExcelConstants.MAP_LIST, personList);

-        map.put(MapExcelConstants.ENTITY_LIST, entity);

-        map.put(MapExcelConstants.PARAMS, params);

-        map.put(MapExcelConstants.FILE_NAME, "人员名单导入模板");//文件名

-        map.put("result", "导出excel文件完成");

-        PoiBaseView.render(map, request, response, MapExcelConstants.EASYPOI_MAP_EXCEL_VIEW);

+            /**

+             * 3.设置表格属性: title:标题  sheetName:工作簿名 type:表格类型

+             */

+            ExportParams params = new ExportParams(null, "sheet1", ExcelType.HSSF);

+            map.put(MapExcelConstants.MAP_LIST, personList);

+            map.put(MapExcelConstants.ENTITY_LIST, entity);

+            map.put(MapExcelConstants.PARAMS, params);

+            map.put(MapExcelConstants.FILE_NAME, "人员名单导入模板");//文件名

+            map.put("result", "导出excel文件完成");

+            PoiBaseView.render(map, request, response, MapExcelConstants.EASYPOI_MAP_EXCEL_VIEW);

 

-      } catch (Exception e) {

-        e.printStackTrace();

-        map.put("result", "导出excel文件失败");

-      }

+        } catch (Exception e) {

+            e.printStackTrace();

+            map.put("result", "导出excel文件失败");

+        }

     }

 

-  /**

-   * 人员名单导入

-   * @param file

-   * @param request

-   * @return

-   */

-  @ResponseBody

+    /**

+     * 人员名单导入

+     *

+     * @param file

+     * @param request

+     * @return

+     */

+    @ResponseBody

     @RequestMapping(value = "/impDoorCardList", method = {RequestMethod.POST})

     public Map impDoorCardList(@RequestParam(value = "impCustomerlist_file", required = false) MultipartFile file,

-                                  HttpServletRequest request,@AuthenticationPrincipal TOperator operUser) {

-      Map map = new HashMap();

-      try {

-        //String sheetName = request.getParameter("sheetname");

+                               HttpServletRequest request, @AuthenticationPrincipal TOperator operUser) {

+        Map map = new HashMap();

+        try {

+            //String sheetName = request.getParameter("sheetname");

 

-        String path = request.getSession().getServletContext().getRealPath("upload");

-        String fileName = file.getOriginalFilename();

-        File targetFile = new File(path, fileName);

-        if (!targetFile.exists()) {

-          targetFile.mkdirs();

+            String path = request.getSession().getServletContext().getRealPath("upload");

+            String fileName = file.getOriginalFilename();

+            File targetFile = new File(path, fileName);

+            if (!targetFile.exists()) {

+                targetFile.mkdirs();

+            }

+            file.transferTo(targetFile);

+            map = impCardList(path + "/" + fileName, operUser.getOperid(), map);

+

+

+        } catch (Exception e) {

+            e.printStackTrace();

+

         }

-        file.transferTo(targetFile);

-        map = impCardList(path+"/"+fileName,operUser.getOperid(),map);

-

-

-      } catch (Exception e) {

-        e.printStackTrace();

-

-      }

-      return map;

+        return map;

     }

 

 

@@ -351,166 +356,178 @@
     private UserProxy userProxy;

 

 

-  private Map impCardList(String fpath,String operid,Map map) {

+    private Map impCardList(String fpath, String operid, Map map) {

 

-    String firstTime = "";

-    ImportParams params = new ImportParams();

-    params.setTitleRows(0);

-    List<CustomerListBean> doorList = ExcelImportUtil.importExcel(new File(fpath), CustomerListBean.class, params);

-    int totCnt = doorList.size();

-    int flag =0;

-    if (doorList.size() <= 0) {

-      flag = -1;

-      map.put("flag", flag);

-      return map;

-    }

-    try {

-

-      String now = DateUtil.getNow();

-      List<TNcCardlist> tmpNcCardList = new ArrayList<TNcCardlist>();

-      List<TCard> tmpCardList = new ArrayList<TCard>();

-      List<CustomerListBean> tCustomerNoExistInfos = new ArrayList<CustomerListBean>();

-      int tmpi = 0;

-      int succCnt = 0;

-      int errCnt = 0;

-      long startTime = System.currentTimeMillis();

-        if (logger.isInfoEnabled()){

-            logger.info("开始进行名单导入");

+        String firstTime = "";

+        ImportParams params = new ImportParams();

+        params.setTitleRows(0);

+        List<CustomerListBean> doorList = ExcelImportUtil.importExcel(new File(fpath), CustomerListBean.class, params);

+        int totCnt = doorList.size();

+        int flag = 0;

+        if (doorList.size() <= 0) {

+            flag = -1;

+            map.put("flag", flag);

+            return map;

         }

-      for (CustomerListBean list : doorList) {

+        try {

 

-        String cardno = list.getCardno();

-        //String bankcardno = list.getBankcardno();

-

-        if (StringUtil.isEmpty(cardno)){

-          errCnt++;

-          tCustomerNoExistInfos.add(list);

-          continue;

-        }

-        //从核心平台验证此卡号用户是否存在

-        QueryUserParam queryUserParam = new QueryUserParam();

-          queryUserParam.setCitizencardno(cardno);

-          UserInforResponse response = userProxy.querybycardno(queryUserParam);

-        if (response.getRetcode() != 0){

-            errCnt++;

-            tCustomerNoExistInfos.add(list);

-            if (logger.isInfoEnabled()){

-                logger.info(cardno+"--核心平台验证失败,已统计!");

+            String now = DateUtil.getNow();

+            List<TNcCardlist> tmpNcCardList = new ArrayList<TNcCardlist>();

+            List<TCard> tmpCardList = new ArrayList<TCard>();

+            List<CustomerListBean> tCustomerNoExistInfos = new ArrayList<CustomerListBean>();

+            int tmpi = 0;

+            int succCnt = 0;

+            int errCnt = 0;

+            long startTime = System.currentTimeMillis();

+            if (logger.isInfoEnabled()) {

+                logger.info("开始进行名单导入");

             }

-            continue;

-        }

-          if (logger.isInfoEnabled()){

-              logger.info(cardno+"--核心平台验证通过,开始进行导入!");

-          }

-        succCnt++;

-        tmpi++;

-        TCustomer customer = webInterfaceService.findCustomerById(response.getUserid());

-        if (customer != null) {//此用户已存在

-            TCard card = webInterfaceService.findCardByCustid(customer.getCustid());

+            for (CustomerListBean list : doorList) {

 

-            customer.setStatus(customer.getStatus());

-            customer.setCustname(response.getUsername());

+                String deptcode=list.getDeptno();

+                TDept dept=systemService.getDeptByDeptno(list.getDeptno());

+                if(null!=dept){

+                    deptcode=dept.getDeptcode();

+                }

+

+

+                String cardno = list.getCardno();

+                //String bankcardno = list.getBankcardno();

+

+                if (StringUtil.isEmpty(cardno)) {

+                    errCnt++;

+                    tCustomerNoExistInfos.add(list);

+                    continue;

+                }

+                //从核心平台验证此卡号用户是否存在

+                QueryUserParam queryUserParam = new QueryUserParam();

+                queryUserParam.setCitizencardno(cardno);

+                UserInforResponse response = userProxy.querybycardno(queryUserParam);

+                if (response.getRetcode() != 0) {

+                    errCnt++;

+                    tCustomerNoExistInfos.add(list);

+                    if (logger.isInfoEnabled()) {

+                        logger.info(cardno + "--核心平台验证失败,已统计!");

+                    }

+                    continue;

+                }

+                if (logger.isInfoEnabled()) {

+                    logger.info(cardno + "--核心平台验证通过,开始进行导入!");

+                }

+                succCnt++;

+                tmpi++;

+                TCustomer customer = webInterfaceService.findCustomerById(response.getUserid());

+                if (customer != null) {//此用户已存在

+                    TCard card = webInterfaceService.findCardByCustid(customer.getCustid());

+

+                    customer.setStatus(customer.getStatus());

+                    customer.setCustname(response.getUsername());

 //            customer.setSex(list.getSex());

 //            customer.setEmail(list.getEmail());

 //            customer.setMobile(list.getMobile());

 //            customer.setAddr(list.getAddr());

-            customer.setClosedate(response.getExpiredate());

-            customer.setLastsavedtime(now);

-            customer.setAddoperid(operid);

-            customer.setRemark(list.getRemarks());

-            webInterfaceService.saveCustomer(customer);

+                    customer.setClosedate(response.getExpiredate());

+                    customer.setLastsavedtime(now);

+                    customer.setAddoperid(operid);

+                    customer.setRemark(list.getRemarks());

+                    customer.setDeptcode(deptcode);

+                    customer.setCusttypeid(list.getCusttypeid());

+                    webInterfaceService.saveCustomer(customer);

 

-            //一个用户可能会有多个卡,补办新卡新增一条信息

-            if (card!=null) {

-                card.setCardphyid(response.getCardphyid());

-                card.setExpiredate(response.getExpiredate());

-                card.setStatus(response.getCardstatus());

-                card.setTranstatus(response.getTransstatus());

-                card.setCardverno(Integer.parseInt(card.getCardverno()) + 1 + "");

-                card.setLastsavedtime(now);

-                webInterfaceService.saveCard(card);

-            }else {

-                TCard cardTmp = new TCard();

-                cardTmp.setCardno(list.getCardno());

-                cardTmp.setBankcardno(response.getBankcardno());

-                cardTmp.setCustid(response.getUserid());

-                cardTmp.setCardphyid(response.getCardphyid());

-                cardTmp.setExpiredate(response.getExpiredate());

-                cardTmp.setStatus(response.getCardstatus());

-                cardTmp.setTranstatus(response.getTransstatus());

-                cardTmp.setCardverno("1");

-                cardTmp.setLastsavedtime(now);

-                webInterfaceService.saveCard(cardTmp);

-            }

+                    //一个用户可能会有多个卡,补办新卡新增一条信息

+                    if (card != null) {

+                        card.setCardphyid(response.getCardphyid());

+                        card.setExpiredate(response.getExpiredate());

+                        card.setStatus(response.getCardstatus());

+                        card.setTranstatus(response.getTransstatus());

+                        card.setCardverno(Integer.parseInt(card.getCardverno()) + 1 + "");

+                        card.setLastsavedtime(now);

+                        webInterfaceService.saveCard(card);

+                    } else {

+                        TCard cardTmp = new TCard();

+                        cardTmp.setCardno(list.getCardno());

+                        cardTmp.setBankcardno(response.getBankcardno());

+                        cardTmp.setCustid(response.getUserid());

+                        cardTmp.setCardphyid(response.getCardphyid());

+                        cardTmp.setExpiredate(response.getExpiredate());

+                        cardTmp.setStatus(response.getCardstatus());

+                        cardTmp.setTranstatus(response.getTransstatus());

+                        cardTmp.setCardverno("1");

+                        cardTmp.setLastsavedtime(now);

+                        webInterfaceService.saveCard(cardTmp);

+                    }

 

-        }else {

-            TCustomer customerTmp = new TCustomer();

-            customerTmp.setCustid(response.getUserid());

-            customerTmp.setStatus("1");

-            customerTmp.setCustname(response.getUsername());

+                } else {

+                    TCustomer customerTmp = new TCustomer();

+                    customerTmp.setCustid(response.getUserid());

+                    customerTmp.setStatus("1");

+                    customerTmp.setCustname(response.getUsername());

 //            customerTmp.setSex(list.getSex());

 //            customerTmp.setEmail(list.getEmail());

 //            customerTmp.setMobile(list.getMobile());

 //            customerTmp.setAddr(list.getAddr());

-            customerTmp.setOpendate(now.substring(0, 8));

-            customerTmp.setClosedate(response.getExpiredate());

-            customerTmp.setLastsavedtime(now);

-            customerTmp.setAddoperid(operid);

-            customerTmp.setRemark(list.getRemarks());

-            webInterfaceService.saveCustomer(customerTmp);

+                    customerTmp.setOpendate(now.substring(0, 8));

+                    customerTmp.setClosedate(response.getExpiredate());

+                    customerTmp.setLastsavedtime(now);

+                    customerTmp.setAddoperid(operid);

+                    customerTmp.setRemark(list.getRemarks());

+                    customer.setDeptcode(deptcode);

+                    customer.setCusttypeid(list.getCusttypeid());

+                    webInterfaceService.saveCustomer(customerTmp);

 

-            TCard cardTmp = new TCard();

-            cardTmp.setCardno(list.getCardno());

-            cardTmp.setBankcardno(response.getBankcardno());

-            cardTmp.setCustid(customerTmp.getCustid());

-            cardTmp.setCardphyid(response.getCardphyid());

-            cardTmp.setExpiredate(response.getExpiredate());

-            cardTmp.setStatus(response.getCardstatus());

-            cardTmp.setTranstatus(response.getTransstatus());

-            cardTmp.setCardverno("1");

-            cardTmp.setLastsavedtime(now);

-            //cardTmp.setBankcardno(response.getBankcardno());

-            webInterfaceService.saveCard(cardTmp);

+                    TCard cardTmp = new TCard();

+                    cardTmp.setCardno(list.getCardno());

+                    cardTmp.setBankcardno(response.getBankcardno());

+                    cardTmp.setCustid(customerTmp.getCustid());

+                    cardTmp.setCardphyid(response.getCardphyid());

+                    cardTmp.setExpiredate(response.getExpiredate());

+                    cardTmp.setStatus(response.getCardstatus());

+                    cardTmp.setTranstatus(response.getTransstatus());

+                    cardTmp.setCardverno("1");

+                    cardTmp.setLastsavedtime(now);

+                    //cardTmp.setBankcardno(response.getBankcardno());

+                    webInterfaceService.saveCard(cardTmp);

+                }

+            }

+            //获取结束时间

+            long endTime = System.currentTimeMillis();

+            logger.info("名单导入消耗时间: " + (endTime - startTime) + "ms");

+            flag = 1;

+

+            //判断是否为第一次名单导入

+            TSystemParam param = systemService.getSystemParamByKey(impcustomeFirstFlag);

+            if ("0".equals(param.getParamValue())) {

+                systemService.updateSystemParamValueByKey(impcustomeFirstFlag, "1");

+                systemService.updateSystemParamValueByKey(impcustomeFirstTime, now);//保存第一次名单导入时间

+            }

+

+            map.put("imp_totCnt", totCnt);

+            map.put("imp_succCnt", succCnt);

+            map.put("imp_errCnt", errCnt);

+            map.put("tCustomerNoExistInfos", tCustomerNoExistInfos);

+        } catch (Exception ex) {

+            logger.error("名单导入失败--" + ex.getMessage());

+            flag = -2;

+            map.put("flag", flag);

+            return map;

         }

-      }

-      //获取结束时间

-      long endTime = System.currentTimeMillis();

-      logger.info("名单导入消耗时间: " + (endTime - startTime) + "ms");

-      flag=1;

-

-      //判断是否为第一次名单导入

-        TSystemParam param = systemService.getSystemParamByKey(impcustomeFirstFlag);

-        if ("0".equals(param.getParamValue())){

-            systemService.updateSystemParamValueByKey(impcustomeFirstFlag, "1");

-            systemService.updateSystemParamValueByKey(impcustomeFirstTime, now);//保存第一次名单导入时间

-        }

-

-      map.put("imp_totCnt",totCnt);

-      map.put("imp_succCnt",succCnt);

-      map.put("imp_errCnt",errCnt);

-      map.put("tCustomerNoExistInfos", tCustomerNoExistInfos);

-    }catch (Exception ex){

-      logger.error("名单导入失败--"+ex.getMessage());

-      flag=-2;

-      map.put("flag", flag);

-      return map;

+        map.put("flag", flag);

+        return map;

     }

-    map.put("flag", flag);

-   return map;

-  }

 

     /**

      * 获取要下发的人员名单

+     *

      * @param perName

      * @param cardno

      * @param bankcardno

      * @return

      */

-  @ResponseBody

-  @RequestMapping(value = "/getAllTCustomerList",method = RequestMethod.POST)

-  public Map getAllTCustomerList(@RequestParam(value = "perName", required = false, defaultValue = "") String perName,

-                                 @RequestParam(value = "cardno", required = false, defaultValue = "") String cardno,

-                                 @RequestParam(value = "bankcardno", required = false, defaultValue = "") String bankcardno) {

+    @ResponseBody

+    @RequestMapping(value = "/getAllTCustomerList", method = RequestMethod.POST)

+    public Map getAllTCustomerList(@RequestParam(value = "perName", required = false, defaultValue = "") String perName,

+                                   @RequestParam(value = "cardno", required = false, defaultValue = "") String cardno,

+                                   @RequestParam(value = "bankcardno", required = false, defaultValue = "") String bankcardno) {

         Map map = new HashMap();

         try {

             List<TCustomerInfo> pNotInResult = webInterfaceService.getAllTCustomerList(perName, cardno, bankcardno);

@@ -520,15 +537,16 @@
             }

             map.put("pNotInResult", pNotInResult);

             map.put("countIndex", countIndex);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

-            logger.error("名单查询失败--"+e.getMessage());

+            logger.error("名单查询失败--" + e.getMessage());

         }

         return map;

     }

 

     /**

      * 下发名单导入查询模板下载

+     *

      * @param request

      * @param response

      * @return

@@ -536,14 +554,14 @@
     @ResponseBody

     @RequestMapping(value = "/exportExcelTemplet")

     public Map exportExcelTemplet(HttpServletRequest request, HttpServletResponse response) {

-      Map map = new HashMap();

+        Map map = new HashMap();

         try {

             List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();

             /**

              * 1. 设置列信息:name:列标题   key:	列属性

              */

             entity.add(new ExcelExportEntity("卡号(必须项)", "cardno"));

-            entity.add(new ExcelExportEntity("银行卡号(可选项)","bankcardno"));

+            entity.add(new ExcelExportEntity("银行卡号(可选项)", "bankcardno"));

             entity.add(new ExcelExportEntity("姓名", "custname"));

             List<Map> personList = new ArrayList<Map>();

 

@@ -567,6 +585,7 @@
 

     /**

      * 导入查询人员名单

+     *

      * @param file

      * @param request

      * @return

@@ -574,7 +593,7 @@
     @ResponseBody

     @RequestMapping(value = "/addexcel", method = {RequestMethod.POST})

     public Map addExcel(@RequestParam(value = "file", required = false, defaultValue = "") MultipartFile file,

-                           HttpServletRequest request) {

+                        HttpServletRequest request) {

         // 保存

         Map map = new HashMap();

         try {

@@ -610,7 +629,7 @@
             }

             int sumNum = excelList.size();

             int cardno = -1;

-            int bankcardno =-1;

+            int bankcardno = -1;

             int custnameNo = -1;

             List columlst = excelList.get(0);

             int i = 0;

@@ -623,7 +642,7 @@
                         cardno = j;

                         contentidex = false;

                     }

-                    if (columlst.get(j).toString().equals("银行卡号(可选项)")){

+                    if (columlst.get(j).toString().equals("银行卡号(可选项)")) {

                         bankcardno = j;

                         contentidex = false;

                     }

@@ -662,7 +681,7 @@
                     queryNoNum++;

                     TCustomerNoExistInfo tCustomerNoExistInfo = new TCustomerNoExistInfo();

                     tCustomerNoExistInfo.setCardno(cardStr);

-                    if (bankcardno > 0){

+                    if (bankcardno > 0) {

                         tCustomerNoExistInfo.setBankcardno(columlst.get(bankcardno).toString());

                     }

                     if (custnameNo > 0) {

@@ -688,30 +707,31 @@
 

     /**

      * 获取设备查询区域和楼栋填充列表

+     *

      * @param operUser

      * @return

      */

     @ResponseBody

     @RequestMapping(value = "/getRegionAndBuildingList")

-    public Map getRegionAndBuildingList(@AuthenticationPrincipal TOperator operUser){

+    public Map getRegionAndBuildingList(@AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

-        try{

+        try {

             String opertype = operUser.getOpertype();

             List<TRegion> regions = null;

             List<TBuilding> buildings = null;

-            if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))){

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

                 regions = systemService.getAllRegions();

                 buildings = systemService.getAllBuildings();

 

-            }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

+            } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

                 regions = systemService.getRegionListById(operUser.getRegionid());

                 buildings = systemService.getOperatorBuildings(operUser.getRegionid());

-            }else if (opertype.equals("L")){

+            } else if (opertype.equals("L")) {

                 buildings = systemService.getBuildingOperBuildings(operUser.getOperid());

             }

             map.put("regions", regions);

             map.put("buildings", buildings);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("获取区域和楼栋列表失败!", e.getMessage());

         }

@@ -720,6 +740,7 @@
 

     /**

      * 获取要分配的设备列表 --读头设备

+     *

      * @param request

      * @param deviceName

      * @param regionid

@@ -731,24 +752,24 @@
     @ResponseBody

     @RequestMapping(value = "/getAllTDevgroupdtlList")

     public Map getAllTDevgroupdtlList(HttpServletRequest request,

-                                         @RequestParam(value = "deviceName", required = false, defaultValue = "") String deviceName,

-                                         @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,

-                                         @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,

-                                         @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

-                                         @AuthenticationPrincipal TOperator operUser) {

+                                      @RequestParam(value = "deviceName", required = false, defaultValue = "") String deviceName,

+                                      @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,

+                                      @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,

+                                      @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

+                                      @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

         try {

             String opertype = operUser.getOpertype();

             List<TDoordevInfo> pResult = null;

-            if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))){

-                pResult = ncService.getSystemDevList(deviceName,regionid,buildingid);

-            }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

-                pResult = ncService.getOperatorDevList(deviceName,regionid,buildingid,operUser.getRegionid());

-            }else if (opertype.equals("L")){

-                pResult = ncService.getBuildingOperDevList(deviceName,regionid,buildingid,operUser.getOperid());

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

+                pResult = ncService.getSystemDevList(deviceName, regionid, buildingid);

+            } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

+                pResult = ncService.getOperatorDevList(deviceName, regionid, buildingid, operUser.getRegionid());

+            } else if (opertype.equals("L")) {

+                pResult = ncService.getBuildingOperDevList(deviceName, regionid, buildingid, operUser.getOperid());

             }

             map.put("pResult", pResult);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("获取要分配设备列表失败!", e.getMessage());

         }

@@ -757,6 +778,7 @@
 

     /**

      * 分页获取要分配的时间段信息

+     *

      * @param timeName

      * @param pageNo

      * @param pageSize

@@ -765,9 +787,9 @@
     @ResponseBody

     @RequestMapping(value = "/getAllTDoortimeList")

     public Map getAllTDoortimeList(

-                                      @RequestParam(value = "timeName", required = false, defaultValue = "") String timeName,

-                                      @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,

-                                      @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {

+            @RequestParam(value = "timeName", required = false, defaultValue = "") String timeName,

+            @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,

+            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {

         Map map = new HashMap();

         Pagination pResult = ncService.getNcWeekTimeWithPage(timeName, pageNo, pageSize, map);

         map.put("pResult", pResult);

@@ -777,6 +799,7 @@
 

     /**

      * 门禁名单下发

+     *

      * @param cardlistInfoModel

      * @param timeId

      * @param holidayId

@@ -789,12 +812,12 @@
     @ResponseBody

     @RequestMapping(value = "/saveDoorCardlist", method = {RequestMethod.POST})

     public Map saveDoorCardlist(

-                                   @RequestBody CardlistInfoModel cardlistInfoModel,

-                                   @RequestParam(value = "timeId", required = false, defaultValue = "") String timeId,

-                                   @RequestParam(value = "holidayId", required = false, defaultValue = "") String holidayId,

-                                   @RequestParam(value = "devGroupId", required = false, defaultValue = "") String devGroupId,

-                                   @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

-                                   HttpServletRequest request,@AuthenticationPrincipal TOperator operUser) {

+            @RequestBody CardlistInfoModel cardlistInfoModel,

+            @RequestParam(value = "timeId", required = false, defaultValue = "") String timeId,

+            @RequestParam(value = "holidayId", required = false, defaultValue = "") String holidayId,

+            @RequestParam(value = "devGroupId", required = false, defaultValue = "") String devGroupId,

+            @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

+            HttpServletRequest request, @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

         String msg = "";

         boolean okFlag = false;

@@ -835,9 +858,9 @@
             String now = DateUtil.getNow();

             List<TNcCardlist> tNcCardlists = new ArrayList<TNcCardlist>();

             List<TNcAllottime> tNcAllottimes = new ArrayList<TNcAllottime>();

-            int tmpi=0;

+            int tmpi = 0;

             //long listid =0;

-            long startTime=System.currentTimeMillis();   //获取开始时间

+            long startTime = System.currentTimeMillis();   //获取开始时间

             for (TCustomerInfo card : tCustomerInfos) {

                 for (TDoordevInfo dev : tDevgroupdtlInfos) {

                     //存在则直接更新状态,否则添加新记录

@@ -853,7 +876,7 @@
                             cardlist.setSynctime("");

                             cardlist.setRectime(now);

                             cardlist.setReason(reason);

-                            cardlist.setVersion(cardlist.getVersion()+1);

+                            cardlist.setVersion(cardlist.getVersion() + 1);

                             tNcCardlists.add(cardlist);

                             //webInterfaceService.saveTDoorcardlst(doorlst);

                         } else {

@@ -861,7 +884,7 @@
                             //从缓存读取列表值并加1

                             long listid = RedisUtil.incr("seq_cardlist");

                             TNcCardlist tmpCardlist = new TNcCardlist();

-                            tmpCardlist.setListid(listid+"");

+                            tmpCardlist.setListid(listid + "");

                             tmpCardlist.setCustid(card.getCustid());

                             tmpCardlist.setCustname(card.getCustname());

                             tmpCardlist.setCardno(card.getCardno());

@@ -884,7 +907,7 @@
                             //webInterfaceService.saveTDoorcardlst(tDoorcardlst);

 

                             TNcAllottimeId tNcAllottimeId = new TNcAllottimeId();

-                            tNcAllottimeId.setListid(listid+"");

+                            tNcAllottimeId.setListid(listid + "");

                             tNcAllottimeId.setTimeid(timeIdArray[i]);

                             TNcAllottime tNcAllottime = new TNcAllottime();

                             tNcAllottime.setDeviceid(dev.getDeviceid());

@@ -893,13 +916,13 @@
                             tNcAllottimes.add(tNcAllottime);

                             //long end1=System.currentTimeMillis(); //获取结束时间

                             //System.out.println("程序运行时间: "+(end1-start1)+"ms");

-                            if (tmpi>=500){

+                            if (tmpi >= 500) {

                                 doorlistMgrService.batchSaveCardList(tNcCardlists);

                                 doorlistMgrService.batchSaveAllotTime(tNcAllottimes);

                                 RedisUtil.incr("zcard_max_version");

                                 tNcCardlists.clear();

                                 tNcAllottimes.clear();

-                                tmpi=0;

+                                tmpi = 0;

                             }

 

                             //webInterfaceService.saveTAllottime(tAllottime);

@@ -922,18 +945,17 @@
 

                 }

             }

-            long endTime=System.currentTimeMillis(); //获取结束时间

-            System.out.println("下发名单消耗时间: "+(endTime-startTime)+"ms");

-            if (tNcCardlists.size()>0) {

+            long endTime = System.currentTimeMillis(); //获取结束时间

+            System.out.println("下发名单消耗时间: " + (endTime - startTime) + "ms");

+            if (tNcCardlists.size() > 0) {

                 doorlistMgrService.batchSaveCardList(tNcCardlists);

                 RedisUtil.incr("zcard_max_version");

             }

-            if (tNcAllottimes.size()>0) {

+            if (tNcAllottimes.size() > 0) {

                 doorlistMgrService.batchSaveAllotTime(tNcAllottimes);

             }

 

 

-

             map.put("result", "下发设备名单成功!");

             okFlag = true;

             msg = "下发设备名单成功!";

@@ -951,6 +973,7 @@
 

     /**

      * 分页获取要删除的名单列表

+     *

      * @param request

      * @param devname

      * @param custname

@@ -968,19 +991,19 @@
      */

     @ResponseBody

     @RequestMapping(value = "/getAllCardListFrDelete", method = RequestMethod.POST)

-    public Map getAllCardListFrDelete( HttpServletRequest request,

-                                         @RequestParam(value = "devname", required = false, defaultValue = "") String devname,

-                                         @RequestParam(value = "custname", required = false, defaultValue = "") String custname,

-                                         @RequestParam(value = "cardno", required = false, defaultValue = "") String cardno,

-                                         @RequestParam(value = "syncflag", required = false, defaultValue = "") String syncflag,

-                                         @RequestParam(value = "regionid",required = false,defaultValue = "") String regionid,

-                                         @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,

-                                         @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,

-                                         @RequestParam(value = "operflag", required = false, defaultValue = "") String operflag,

-                                         @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,

-                                         @RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize,

-                                         @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

-                                         @AuthenticationPrincipal TOperator operUser) {

+    public Map getAllCardListFrDelete(HttpServletRequest request,

+                                      @RequestParam(value = "devname", required = false, defaultValue = "") String devname,

+                                      @RequestParam(value = "custname", required = false, defaultValue = "") String custname,

+                                      @RequestParam(value = "cardno", required = false, defaultValue = "") String cardno,

+                                      @RequestParam(value = "syncflag", required = false, defaultValue = "") String syncflag,

+                                      @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,

+                                      @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,

+                                      @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,

+                                      @RequestParam(value = "operflag", required = false, defaultValue = "") String operflag,

+                                      @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,

+                                      @RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize,

+                                      @RequestParam(value = "usetype", required = false, defaultValue = "MJ") String usetype,

+                                      @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

         Pagination pResult = null;

         boolean index = true;

@@ -996,14 +1019,14 @@
             }*/

 

             String opertype = operUser.getOpertype();

-            if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))){

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

                 pResult = doorlistMgrService.getSystemCardList(devname, custname, cardno, syncflag, regionid, allocatStartDate, allocatEndDate, operflag, pageNo, pageSize);

-            }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

+            } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

                 pResult = doorlistMgrService.getOperatorCardList(devname, custname, cardno, syncflag, regionid, allocatStartDate, allocatEndDate, operflag, pageNo, pageSize, operUser.getRegionid());

-            }else if (opertype.equals("L")){

+            } else if (opertype.equals("L")) {

                 pResult = doorlistMgrService.getBuildingOperCardList(devname, custname, cardno, syncflag, allocatStartDate, allocatEndDate, operflag, pageNo, pageSize, operUser.getOperid());

             }

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("查询删除名单失败!", e.getMessage());

         }

@@ -1021,6 +1044,7 @@
 

     /**

      * 获取删除名单填充数据

+     *

      * @param operUser

      * @return

      */

@@ -1040,13 +1064,13 @@
         //区域

         String opertype = operUser.getOpertype();

         List<TRegion> regions = null;

-        if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))) {

+        if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

             regions = systemService.getAllRegions();

             map.put("regions", regions);

-        }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

+        } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

             regions = systemService.getRegionListById(operUser.getRegionid());

             map.put("regions", regions);

-        }else if (opertype.equals("L")){

+        } else if (opertype.equals("L")) {

             map.put("regions", regions);

         }

         return map;

@@ -1054,6 +1078,7 @@
 

     /**

      * 删除设备名单

+     *

      * @param tNcCardlistDeleteInfos

      * @param operUser

      * @return

@@ -1061,12 +1086,12 @@
     @ResponseBody

     @RequestMapping(value = "/saveDoorDeleteCardlist", method = {RequestMethod.POST})

     public Map saveDoorDeleteCardlist(

-                                         @RequestBody TNcCardlistDeleteInfo[] tNcCardlistDeleteInfos,

-                                         @AuthenticationPrincipal TOperator operUser) {

+            @RequestBody TNcCardlistDeleteInfo[] tNcCardlistDeleteInfos,

+            @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

         try {

             String now = DateUtil.getNow();

-            for (TNcCardlistDeleteInfo card:tNcCardlistDeleteInfos) {

+            for (TNcCardlistDeleteInfo card : tNcCardlistDeleteInfos) {

                 String listid = card.getListid();

                 TNcCardlist ncCardlist = doorlistMgrService.getNcCardlistById(listid);

                 if (ncCardlist != null) {

@@ -1075,7 +1100,7 @@
                     ncCardlist.setSyncflag("N");

                     ncCardlist.setSynctime("");

                     ncCardlist.setOperid(operUser.getOperid());

-                    ncCardlist.setVersion(ncCardlist.getVersion()+1);

+                    ncCardlist.setVersion(ncCardlist.getVersion() + 1);

                     doorlistMgrService.updateNcCardlist(ncCardlist);

                     RedisUtil.incr("zcard_max_version");

                 }

diff --git a/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java b/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
index ddc4d15..4933c59 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/filter/XssHttpServletRequestWrapper.java
@@ -111,6 +111,7 @@
     value = value.replaceAll("eval\\((.*)\\)", "");
     value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
     value = value.replaceAll("script", "");
+    value = value.replaceAll(" ","");
     value = cleanSqlKeyWords(value);
     return value;
   }
diff --git a/src/main/java/com/supwisdom/dlpay/hk/service/ApiService.java b/src/main/java/com/supwisdom/dlpay/hk/service/ApiService.java
index a751ed7..c09a97d 100644
--- a/src/main/java/com/supwisdom/dlpay/hk/service/ApiService.java
+++ b/src/main/java/com/supwisdom/dlpay/hk/service/ApiService.java
@@ -57,7 +57,7 @@
 

     /******人员******/

 

-    //新增人员

-    public Resp addPerson(String token, PersonBean bean) throws Exception;

+//    //新增人员

+//    public Resp addPerson(String token, PersonBean bean) throws Exception;

 

 }

diff --git a/src/main/java/com/supwisdom/dlpay/mainservice/domain/TCustomer.java b/src/main/java/com/supwisdom/dlpay/mainservice/domain/TCustomer.java
index 6810fe9..edf0e6a 100644
--- a/src/main/java/com/supwisdom/dlpay/mainservice/domain/TCustomer.java
+++ b/src/main/java/com/supwisdom/dlpay/mainservice/domain/TCustomer.java
@@ -27,33 +27,11 @@
 	private String lastsavedtime;
 	private String addoperid;
 	private String remark;
+	private String deptcode;
+	private String custtypeid;
 
 	// Constructors
 
-	/** default constructor */
-	public TCustomer() {
-	}
-
-	/** full constructor */
-	public TCustomer(String custid, String status, String custname, String sex,  String email, String mobile, String addr, String indate, String outdate, String opendate, String closedate, String lastsavedtime, String addoperid, String remark) {
-		this.custid = custid;
-		this.status = status;
-		this.custname = custname;
-		this.sex = sex;
-		this.email = email;
-		this.mobile = mobile;
-		this.addr = addr;
-		this.indate = indate;
-		this.outdate = outdate;
-		this.opendate = opendate;
-		this.closedate = closedate;
-		this.lastsavedtime = lastsavedtime;
-		this.addoperid = addoperid;
-		this.remark = remark;
-	}
-
-
-
 
 	// Property accessors
 	@Id
@@ -187,4 +165,22 @@
 	public void setRemark(String remark) {
 		this.remark = remark;
 	}
+
+	@Column(name = "DEPTCODE",length = 32)
+	public String getDeptcode() {
+		return deptcode;
+	}
+
+	public void setDeptcode(String deptcode) {
+		this.deptcode = deptcode;
+	}
+
+	@Column(name = "CUSTTYPEID",length = 9)
+	public String getCusttypeid() {
+		return custtypeid;
+	}
+
+	public void setCusttypeid(String custtypeid) {
+		this.custtypeid = custtypeid;
+	}
 }
\ No newline at end of file
diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/CustTypeSearchBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/CustTypeSearchBean.java
new file mode 100644
index 0000000..f070da9
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/bean/CustTypeSearchBean.java
@@ -0,0 +1,13 @@
+package com.supwisdom.dlpay.system.bean;
+
+public class CustTypeSearchBean extends PageBean {
+    private String custtypename;
+
+    public String getCusttypename() {
+        return custtypename;
+    }
+
+    public void setCusttypename(String custtypename) {
+        this.custtypename = custtypename;
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/CustomerSearchBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/CustomerSearchBean.java
new file mode 100644
index 0000000..2a69580
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/bean/CustomerSearchBean.java
@@ -0,0 +1,22 @@
+package com.supwisdom.dlpay.system.bean;
+
+public class CustomerSearchBean extends PageBean {
+    private String custname;
+    private String checkstatus;
+
+    public String getCustname() {
+        return custname;
+    }
+
+    public void setCustname(String custname) {
+        this.custname = custname;
+    }
+
+    public String getCheckstatus() {
+        return checkstatus;
+    }
+
+    public void setCheckstatus(String checkstatus) {
+        this.checkstatus = checkstatus;
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/DeptSearchBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/DeptSearchBean.java
new file mode 100644
index 0000000..718640b
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/bean/DeptSearchBean.java
@@ -0,0 +1,13 @@
+package com.supwisdom.dlpay.system.bean;
+
+public class DeptSearchBean extends PageBean {
+    private String searchkey;
+
+    public String getSearchkey() {
+        return searchkey;
+    }
+
+    public void setSearchkey(String searchkey) {
+        this.searchkey = searchkey;
+    }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
index 111302f..cbdfec5 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
@@ -1,15 +1,16 @@
 package com.supwisdom.dlpay.system.controller;

 

+import com.google.gson.Gson;

+import com.supwisdom.dlpay.api.bean.JsonResult;

 import com.supwisdom.dlpay.framework.domain.TOperator;

 import com.supwisdom.dlpay.framework.util.DateUtil;

+import com.supwisdom.dlpay.framework.util.PageResult;

 import com.supwisdom.dlpay.framework.util.StringUtil;

+import com.supwisdom.dlpay.framework.util.WebConstant;

 import com.supwisdom.dlpay.ncmgr.domain.TBuilding;

 import com.supwisdom.dlpay.ncmgr.domain.TNcDevice;

 import com.supwisdom.dlpay.ncmgr.service.NcService;

-import com.supwisdom.dlpay.system.bean.AllotBuildingBean;

-import com.supwisdom.dlpay.system.bean.BuildingBean;

-import com.supwisdom.dlpay.system.bean.RegionBean;

-import com.supwisdom.dlpay.system.bean.RegionZTreeNodes;

+import com.supwisdom.dlpay.system.bean.*;

 import com.supwisdom.dlpay.system.domain.*;

 import com.supwisdom.dlpay.system.page.Pagination;

 import com.supwisdom.dlpay.system.service.SystemService;

@@ -19,6 +20,7 @@
 import org.springframework.beans.factory.annotation.Autowired;

 import org.springframework.security.core.annotation.AuthenticationPrincipal;

 import org.springframework.stereotype.Controller;

+import org.springframework.ui.Model;

 import org.springframework.ui.ModelMap;

 import org.springframework.web.bind.annotation.*;

 

@@ -39,6 +41,7 @@
     @Autowired

     private NcService ncService;

 

+

     @RequestMapping("/dictionary")

     public String dictionary(ModelMap model){

         return "system/dictionary";

@@ -64,6 +67,20 @@
         return "system/remote/remoteCtrl";

     }

 

+    @RequestMapping("/deptindex")

+    public String deptindex(ModelMap map){

+        List<TDept> dept=systemService.findAllDept();

+        Gson gson = new Gson();

+        String gsonString = gson.toJson(dept);

+        map.put("deptList", gsonString);

+        return "system/dept/index";

+    }

+

+    @RequestMapping("/custtypeindex")

+    public String custtypeIndex(ModelMap model) {

+        return "system/custtype/index";

+    }

+

     /**

      * 获取字典列表

      * @param dicttype

@@ -803,4 +820,112 @@
         }

         return map;

     }

+

+

+

+

+    @RequestMapping("/listcusttype")

+    @ResponseBody

+    public PageResult<TCustType> listCusttype(@RequestParam("page") Integer pageNo,

+                                             @RequestParam("limit") Integer pageSize,

+                                             @RequestParam(value = "searchkey", required = false) String searchKey) {

+        try {

+            if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;

+            if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;

+            CustTypeSearchBean searchBean = new CustTypeSearchBean();

+            searchBean.setPageNo(pageNo);

+            searchBean.setCusttypename(searchKey);

+            searchBean.setPageSize(pageSize);

+            return systemService.getCustTypeByKey(searchBean);

+

+

+        } catch (Exception e) {

+            e.printStackTrace();

+            return new PageResult<>(99, "系统查询错误");

+        }

+    }

+

+

+    @GetMapping("/loadcusttypeadd")

+    public String loadCusttypeAdd(Model model) {

+        return "system/custtype/form";

+    }

+

+    @PostMapping("/addcusttype")

+    @ResponseBody

+    public JsonResult addCusttype(@RequestBody TCustType custType) {

+        if (custType != null) {

+            return systemService.saveCusttype(custType);

+        } else {

+            return JsonResult.error("添加失败");

+        }

+    }

+

+    @PostMapping("/deletecusttype")

+    @ResponseBody

+    public JsonResult deleteCusttype(@RequestParam Integer id) {

+        return systemService.deleteCusttype(id);

+    }

+

+

+    @RequestMapping("/listdept")

+    @ResponseBody

+    public PageResult<TDept> getDataList(@RequestParam("page") Integer pageNo,

+                                         @RequestParam("limit") Integer pageSize,

+                                         @RequestParam(value = "searchkey", required = false) String searchKey) {

+        try {

+            if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT;

+            if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT;

+            DeptSearchBean searchBean = new DeptSearchBean();

+            searchBean.setPageNo(pageNo);

+            searchBean.setSearchkey(searchKey);

+            searchBean.setPageSize(pageSize);

+            return systemService.getDeptByKey(searchBean);

+        } catch (Exception e) {

+            e.printStackTrace();

+            return new PageResult<>(99, "系统查询错误");

+        }

+    }

+

+

+    @GetMapping("/loaddeptadd")

+    public String loadDeptadd(Model model) {

+        List<TDept> list = systemService.findAllDept();

+        model.addAttribute("deptlist", list);

+        return "system/dept/form";

+    }

+

+    @PostMapping("/adddept")

+    @ResponseBody

+    public JsonResult addDept(@RequestBody TDept dept) {

+        if (dept != null) {

+            return systemService.saveDept(dept);

+        } else {

+            return JsonResult.error("添加失败");

+        }

+    }

+

+    @PostMapping("/deletedept")

+    @ResponseBody

+    public JsonResult deleteDept(@RequestParam String deptcode) {

+        return systemService.deleteDept(deptcode);

+    }

+

+    @GetMapping("/checkdeptno")

+    @ResponseBody

+    public JsonResult checkDeptno(@RequestParam("deptno") String deptno) {

+        try {

+            if (StringUtil.isEmpty(deptno)) {

+                return JsonResult.error("部门代码不能为空");

+            }

+            if (systemService.checkDeptnoExist(deptno.trim())) {

+                return JsonResult.error("部门代码已存在");

+            } else {

+                return JsonResult.ok("success");

+            }

+        } catch (Exception e) {

+            e.printStackTrace();

+            return JsonResult.error("系统处理异常").put("exception", e);

+        }

+    }

 }

diff --git a/src/main/java/com/supwisdom/dlpay/system/dao/CustTypeDao.java b/src/main/java/com/supwisdom/dlpay/system/dao/CustTypeDao.java
new file mode 100644
index 0000000..883dbe6
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/dao/CustTypeDao.java
@@ -0,0 +1,15 @@
+package com.supwisdom.dlpay.system.dao;
+
+
+import com.supwisdom.dlpay.system.domain.TCustType;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface CustTypeDao extends JpaRepository<TCustType, Integer> {
+    Page<TCustType> findAllByCusttypenameContaining(String custtypename, Pageable pageable);
+
+
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/dao/DeptDao.java b/src/main/java/com/supwisdom/dlpay/system/dao/DeptDao.java
new file mode 100644
index 0000000..9c99e27
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/dao/DeptDao.java
@@ -0,0 +1,25 @@
+package com.supwisdom.dlpay.system.dao;
+
+import com.supwisdom.dlpay.framework.util.PageResult;
+import com.supwisdom.dlpay.system.domain.TDept;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface DeptDao extends JpaRepository<TDept, String> {
+
+  @Query("from TDept t where t.status='normal' ")
+  List<TDept> findNormalDept();
+
+  Page<TDept> findAllByDeptnameContainingOrDeptnoContaining(String name,String deptno, Pageable pageable);
+
+  @Query("select count(t.deptno) from TDept t where t.deptno=?1 ")
+  long checkDeptnoExists(String deptno);
+
+  List<TDept> findByDeptno(String deptno);
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/domain/TCustType.java b/src/main/java/com/supwisdom/dlpay/system/domain/TCustType.java
new file mode 100644
index 0000000..8eb098a
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/domain/TCustType.java
@@ -0,0 +1,33 @@
+package com.supwisdom.dlpay.system.domain;
+
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "TB_CUSTTYPE")
+@SequenceGenerator(name="SEQ_CUSTTYPE",sequenceName="SEQ_CUSTTYPE",allocationSize=1)
+public class TCustType {
+    private Integer custtypeid;
+    private String custtypename;
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_CUSTTYPE")
+    @Column(name = "custtypeid", unique = true, nullable = false, length = 9)
+    public Integer getCusttypeid() {
+        return custtypeid;
+    }
+
+    public void setCusttypeid(Integer custtypeid) {
+        this.custtypeid = custtypeid;
+    }
+
+    @Column(name = "custtypename" ,length = 20)
+    public String getCusttypename() {
+        return custtypename;
+    }
+
+    public void setCusttypename(String custtypename) {
+        this.custtypename = custtypename;
+    }
+
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/domain/TDept.java b/src/main/java/com/supwisdom/dlpay/system/domain/TDept.java
new file mode 100644
index 0000000..fd825c1
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/system/domain/TDept.java
@@ -0,0 +1,90 @@
+package com.supwisdom.dlpay.system.domain;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "TB_DEPT",
+    indexes = {@Index(name = "UK_DEPT_DEPTCODE", unique = true, columnList = "DEPTCODE")})
+public class TDept {
+  @Id
+  @GenericGenerator(name = "idGenerator", strategy = "uuid")
+  @GeneratedValue(generator = "idGenerator")
+  @Column(name="DEPTCODE", nullable = false, length = 32)
+  private String deptcode; //ID
+
+  @Column(name="DEPTNO", nullable = false, length = 20)
+  private String deptno;  //部门编号,可能会要修改,不能为主键,唯一索引
+
+  @Column(name="DEPTNAME", precision = 600)
+  private String deptname; //部门名称
+
+  @Column(name="FDEPTCODE", nullable = false, length = 32)
+  private String fdeptcode; //上级部门
+
+  @Column(name="ENAME", precision = 600)
+  private String ename; //部门英文名称
+
+  @Column(name="STATUS", nullable = false, precision = 600)
+  private String status; //normal-正常;closed-删除
+
+  @Column(name="LASTSAVED", length = 20)
+  private String lastsaved; //最后更新时间
+
+  public String getDeptcode() {
+    return deptcode;
+  }
+
+  public void setDeptcode(String deptcode) {
+    this.deptcode = deptcode;
+  }
+
+  public String getDeptno() {
+    return deptno;
+  }
+
+  public void setDeptno(String deptno) {
+    this.deptno = deptno;
+  }
+
+  public String getDeptname() {
+    return deptname;
+  }
+
+  public void setDeptname(String deptname) {
+    this.deptname = deptname;
+  }
+
+  public String getFdeptcode() {
+    return fdeptcode;
+  }
+
+  public void setFdeptcode(String fdeptcode) {
+    this.fdeptcode = fdeptcode;
+  }
+
+  public String getEname() {
+    return ename;
+  }
+
+  public void setEname(String ename) {
+    this.ename = ename;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public String getLastsaved() {
+    return lastsaved;
+  }
+
+  public void setLastsaved(String lastsaved) {
+    this.lastsaved = lastsaved;
+  }
+}
diff --git a/src/main/java/com/supwisdom/dlpay/system/service/SystemService.java b/src/main/java/com/supwisdom/dlpay/system/service/SystemService.java
index b78ad54..4d0dfe1 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/SystemService.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/SystemService.java
@@ -1,8 +1,12 @@
 package com.supwisdom.dlpay.system.service;

 

 

+import com.supwisdom.dlpay.api.bean.JsonResult;

+import com.supwisdom.dlpay.framework.util.PageResult;

 import com.supwisdom.dlpay.ncmgr.domain.TBuilding;

 import com.supwisdom.dlpay.system.bean.AllotBuildingBean;

+import com.supwisdom.dlpay.system.bean.CustTypeSearchBean;

+import com.supwisdom.dlpay.system.bean.DeptSearchBean;

 import com.supwisdom.dlpay.system.bean.RegionZTreeNodes;

 import com.supwisdom.dlpay.system.domain.*;

 import com.supwisdom.dlpay.system.page.Pagination;

@@ -207,4 +211,36 @@
     //获取楼栋管理员权限下的楼栋

     @Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})

     public List<TBuilding> getBuildingOperBuildings(String operid);

+

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)

+    PageResult<TCustType> getCustTypeByKey(CustTypeSearchBean param);

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

+    JsonResult saveCusttype(TCustType custType);

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

+    JsonResult deleteCusttype(Integer id);

+

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

+    List<TCustType> findAllCusttype();

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)

+    PageResult<TDept> getDeptByKey(DeptSearchBean param);

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)

+    List<TDept> findAllDept();

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

+    JsonResult saveDept(TDept area);

+

+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

+    JsonResult deleteDept(String deptcode);

+

+    @Transactional(rollbackFor = Exception.class, readOnly = true)

+    boolean checkDeptnoExist(String deptno);

+

+    @Transactional(rollbackFor = Exception.class, readOnly = true)

+    TDept getDeptByDeptno(String deptno);

 }

diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/SystemServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/SystemServiceImpl.java
index 083c7ca..369a23f 100644
--- a/src/main/java/com/supwisdom/dlpay/system/service/impl/SystemServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/SystemServiceImpl.java
@@ -1,7 +1,13 @@
 package com.supwisdom.dlpay.system.service.impl;

 

+import com.supwisdom.dlpay.api.bean.JsonResult;

+import com.supwisdom.dlpay.framework.util.DateUtil;

+import com.supwisdom.dlpay.framework.util.PageResult;

+import com.supwisdom.dlpay.framework.util.StringUtil;

 import com.supwisdom.dlpay.ncmgr.domain.TBuilding;

 import com.supwisdom.dlpay.system.bean.AllotBuildingBean;

+import com.supwisdom.dlpay.system.bean.CustTypeSearchBean;

+import com.supwisdom.dlpay.system.bean.DeptSearchBean;

 import com.supwisdom.dlpay.system.bean.RegionZTreeNodes;

 import com.supwisdom.dlpay.system.dao.*;

 import com.supwisdom.dlpay.system.domain.*;

@@ -10,6 +16,9 @@
 import org.springframework.beans.factory.annotation.Autowired;

 import org.springframework.cache.annotation.CacheEvict;

 import org.springframework.cache.annotation.Cacheable;

+import org.springframework.data.domain.PageRequest;

+import org.springframework.data.domain.Pageable;

+import org.springframework.data.domain.Sort;

 import org.springframework.stereotype.Service;

 

 import java.util.ArrayList;

@@ -27,6 +36,10 @@
     private BuildingDao buildingDao;

     @Autowired

     private SystemParamDao systemParamDao;

+    @Autowired

+    private CustTypeDao custTypeDao;

+    @Autowired

+    private DeptDao deptDao;

 

     @Override

     @CacheEvict(cacheNames = "door_dictionary_cache", key = "'.*'", allEntries = true)

@@ -120,11 +133,11 @@
 

     @Override

     public List<TBuilding> getOperatorBuildingByRegionId(String regionid, String operRegionid) {

-        return buildingDao.getOperatorBuildingByRegionId(regionid,operRegionid);

+        return buildingDao.getOperatorBuildingByRegionId(regionid, operRegionid);

     }

 

     @Override

-    public List<TBuilding> getBuildingOperBuildingByRegionId(String regionid,String operid) {

+    public List<TBuilding> getBuildingOperBuildingByRegionId(String regionid, String operid) {

         return buildingDao.getBuildingOperBuildingByRegionId(regionid, operid);

     }

 

@@ -197,10 +210,10 @@
     public List<RegionZTreeNodes> getAllRegionTreeList() {

         List<RegionZTreeNodes> regionZTreeNodesList = new ArrayList<>();

         List<TRegion> regions = regionDao.getAllRegions();

-        for (TRegion region:regions){

+        for (TRegion region : regions) {

             RegionZTreeNodes node = new RegionZTreeNodes();

             node.setId(region.getRegionid());

-            node.setName(region.getRegionname()+"-"+region.getLevel()+"级");

+            node.setName(region.getRegionname() + "-" + region.getLevel() + "级");

             node.setpId(region.getParentid());

             node.setParent(false);

             regionZTreeNodesList.add(node);

@@ -295,4 +308,79 @@
         return buildingDao.getBuildingOperBuildings(operid);

     }

 

+

+    @Override

+    public PageResult<TCustType> getCustTypeByKey(CustTypeSearchBean param) {

+        Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()

+                , Sort.by("custtypeid"));

+        if (!StringUtil.isEmpty(param.getCusttypename())) {

+            return new PageResult<>(custTypeDao.findAllByCusttypenameContaining(param.getCusttypename(), pageable));

+        }

+        return new PageResult<>(custTypeDao.findAll(pageable));

+    }

+

+    @Override

+    public JsonResult saveCusttype(TCustType custType) {

+        custTypeDao.save(custType);

+        return JsonResult.ok("成功");

+    }

+

+    @Override

+    public JsonResult deleteCusttype(Integer id) {

+        custTypeDao.deleteById(id);

+        return JsonResult.ok("成功");

+    }

+

+    @Override

+    public List<TCustType> findAllCusttype() {

+        return custTypeDao.findAll();

+    }

+

+    @Override

+    public PageResult<TDept> getDeptByKey(DeptSearchBean param) {

+        Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()

+                , Sort.by("deptno"));

+        if (!StringUtil.isEmpty(param.getSearchkey())) {

+            return new PageResult<>(deptDao.findAllByDeptnameContainingOrDeptnoContaining(param.getSearchkey(), param.getSearchkey(), pageable));

+        }

+

+        return new PageResult<>(deptDao.findAll(pageable));

+    }

+

+    @Override

+    public List<TDept> findAllDept() {

+        return deptDao.findAll();

+    }

+

+    @Override

+    public JsonResult saveDept(TDept dept) {

+       /* TArea temp = areaDao.findByAreaname(area.getAreaname());

+        if (temp != null) {

+            return JsonResult.error("地区名重复");

+        }*/

+        dept.setLastsaved(DateUtil.getNow());

+        dept.setStatus("normal");

+        deptDao.save(dept);

+        return JsonResult.ok("成功");

+    }

+

+    @Override

+    public JsonResult deleteDept(String deptcode) {

+        deptDao.deleteById(deptcode);

+        return JsonResult.ok("成功");

+    }

+

+    @Override

+    public boolean checkDeptnoExist(String deptno) {

+        if (deptDao.checkDeptnoExists(deptno) > 0) {

+            return true;

+        }

+        return false;

+    }

+

+    @Override

+    public TDept getDeptByDeptno(String deptno) {

+        List<TDept> dept=deptDao.findByDeptno(deptno);

+        return dept.size()>0?dept.get(0):null;

+    }

 }

diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 5f23126..16d3b2b 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -4,8 +4,8 @@
 spring.datasource.hikari.connection-timeout=60000
 spring.datasource.hikari.maximum-pool-size=5
 spring.datasource.continue-on-error=true
-spring.datasource.initialization-mode=always
-spring.jpa.hibernate.ddl-auto=update
+#spring.datasource.initialization-mode=always
+#spring.jpa.hibernate.ddl-auto=update
 
 spring.flyway.locations=classpath:db/migration
 spring.flyway.baseline-version=0
diff --git a/src/main/resources/templates/system/custtype/form.html b/src/main/resources/templates/system/custtype/form.html
new file mode 100644
index 0000000..74bdbe4
--- /dev/null
+++ b/src/main/resources/templates/system/custtype/form.html
@@ -0,0 +1,69 @@
+<!-- operator表单弹窗 -->
+<form id="custtype-form" lay-filter="custtype-form" class="layui-form model-form">
+    <input name="custtypeid" id="custtypeid" type="hidden"/>
+    <div class="layui-form-item">
+        <label class="layui-form-label">客户类别名称</label>
+        <div class="layui-input-block">
+            <input name="custtypename" placeholder="" type="text" class="layui-input" maxlength="20"
+                   lay-verify="required" required/>
+        </div>
+    </div>
+
+    <div class="layui-form-item model-form-footer">
+        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
+        <button class="layui-btn" lay-filter="custtype-form-submit" lay-submit id="custtype-submitbtn">保存</button>
+    </div>
+</form>
+
+<script>
+    layui.use(['layer', 'admin', 'form', 'formSelects'], function () {
+        var layer = layui.layer;
+        var admin = layui.admin;
+        var form = layui.form;
+
+
+        var url = '[[@{/system/addcusttype}]]';
+        // 回显user数据
+        var ct = admin.getTempData('t_ct');
+        if (ct) {
+            $('input[name="custtypeid"]').attr('readonly', 'readonly');
+            form.val('custtype-form', ct);
+        }
+        // 表单提交事件
+        form.on('submit(custtype-form-submit)', function (data) {
+            layer.load(2);
+            let token = $("meta[name='_csrf_token']").attr("value");
+            $.ajax({
+                type: "POST",
+                dataType: "json",
+                url: url,
+                headers: {
+                    'Accept': 'application/json',
+                    'Content-Type': 'application/json',
+                    'X-CSRF-TOKEN': token,
+                },
+                data: JSON.stringify(data.field),
+                success: function (result) {
+                    layer.closeAll('loading');
+                    if (result.code == 200) {
+                        layer.msg(result.msg, {icon: 1});
+                        admin.finishPopupCenter();
+                    } else if (result.code == 401) {
+                        layer.msg(result.msg, {icon: 2, time: 1500}, function () {
+                            location.replace('/login');
+                        }, 1000);
+                        return;
+                    } else {
+                        console.log('err:' + result.code);
+                        layer.msg(result.msg, {icon: 2});
+                    }
+                },
+                error: function () {
+                    layer.closeAll('loading');
+                    layer.msg("请求服务器失败!", {icon: 2});
+                }
+            });
+            return false;
+        });
+    });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/system/custtype/index.html b/src/main/resources/templates/system/custtype/index.html
new file mode 100644
index 0000000..f119c28
--- /dev/null
+++ b/src/main/resources/templates/system/custtype/index.html
@@ -0,0 +1,109 @@
+<div class="layui-card">
+    <div class="layui-card-header">
+        <h2 class="header-title">客户类别维护</h2>
+        <span class="layui-breadcrumb pull-right">
+          <a href="#">客户类别维护</a>
+          <a><cite>客户类别维护</cite></a>
+        </span>
+    </div>
+    <div class="layui-card-body">
+        <div class="layui-form toolbar">
+            搜索:
+            <input id="custtype-search-value" class="layui-input search-input" type="text" placeholder="输入类别名称"/>&emsp;
+            <button id="custtype-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon">&#xe615;</i>搜索
+            </button>
+            <button id="custtype-btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加类别</button>
+        </div>
+        <table class="layui-table" id="custtype-table" lay-filter="custtype-table"></table>
+    </div>
+</div>
+<script>
+
+    layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
+        let form = layui.form;
+        let table = layui.table;
+        let admin = layui.admin;
+
+       // form.render('select');
+
+        // 渲染表格
+        table.render({
+            elem: '#custtype-table',
+            url: '[[@{/system/listcusttype}]]',
+            page: true,
+            cols: [
+                [
+                    {field: 'custtypeid', title: '类别号',  fixed: 'left', sort: true},
+                    {field: 'custtypename', title: '类别名称', sort: true},
+                    {
+                        field: 'custtypeid', align: 'center',width:160, title: '操作', fixed: 'right', templet: function (item) {
+                            return ' <a class="layui-btn  layui-btn-xs" lay-event="custtype-edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> ' +
+                                ' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="custtype-del"><i class="layui-icon layui-icon-delete"></i>删除</a>'
+                        }
+                    }
+                ]
+            ]
+        });
+        // 搜索按钮点击事件
+        $('#custtype-btn-search').click(function () {
+            let key = $('#custtype-search-value').val();
+            table.reload('custtype-table', {where: {searchkey: key}, page: {curr: 1}});
+        });
+        $('#custtype-btn-add').click(function () {
+            showModel();
+        });
+        let showModel = function (data) {
+            let title = data ? '修改客户类别' : '添加客户类别';
+            admin.putTempData('t_ct', data);
+            admin.popupCenter({
+                title: title,
+                path: '[[@{/system/loadcusttypeadd}]]',
+                finish: function () {
+                    table.reload('custtype-table', {});
+                }
+            });
+        };
+
+
+        // 工具条点击事件
+        table.on('tool(custtype-table)', function (obj) {
+            let data = obj.data;
+            let layEvent = obj.event;
+            console.log(data);
+            if (layEvent === 'custtype-edit') {
+                showModel(data);
+            } else if (layEvent === 'custtype-del') {
+                showDelete(data);
+            }
+        });
+        let showDelete = function (data) {
+            layer.confirm('确定要删除吗?', function (i) {
+                layer.close(i);
+                layer.load(2);
+                let token = $("meta[name='_csrf_token']").attr("value");
+                admin.go('[[@{/system/deletecusttype}]]', {
+                    id: data.custtypeid,
+                    _csrf: token
+                }, function (data) {
+                    console.log(data.code);
+                    layer.closeAll('loading');
+                    if (data.code == 200) {
+                        layer.msg(data.msg, {icon: 1});
+                    } else if (data.code == 401) {
+                        layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+                            location.replace('/login');
+                        }, 1000);
+                        return;
+                    } else {
+                        layer.msg(data.msg, {icon: 2});
+                    }
+                    table.reload('custtype-table', {});
+                }, function (ret) {
+                    console.log(ret);
+                    layer.closeAll('loading');
+                    layer.msg('请求失败了,请稍后再试', {icon: 2});
+                });
+            });
+        }
+    });
+</script>
diff --git a/src/main/resources/templates/system/dept/form.html b/src/main/resources/templates/system/dept/form.html
new file mode 100644
index 0000000..2f89041
--- /dev/null
+++ b/src/main/resources/templates/system/dept/form.html
@@ -0,0 +1,127 @@
+<!-- operator表单弹窗 -->
+<form id="dept-form" lay-filter="dept-form" class="layui-form model-form">
+    <input name="deptcode" id="deptcode" type="hidden"/>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label">部门代码</label>
+        <div class="layui-input-block">
+            <input name="deptno" placeholder="" type="text" class="layui-input"
+                   lay-verify="deptcode" />
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label">部门名称</label>
+        <div class="layui-input-block">
+            <input name="deptname" placeholder="" type="text" class="layui-input"
+                   lay-verify="required" />
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label">父区域</label>
+        <div class="layui-input-block">
+            <select name="fdeptcode" id="fdeptcode" lay-verify="required">
+                <option value="0">根部门</option>
+                <option th:each="dept : ${deptlist}" th:value="${dept.deptcode}">[[${dept.deptname}]]</option>
+            </select>
+        </div>
+    </div>
+
+    <div class="layui-form-item model-form-footer">
+        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
+        <button class="layui-btn" lay-filter="dept-form-submit" lay-submit id="dept-submitbtn">保存</button>
+    </div>
+</form>
+
+<script>
+    layui.use(['layer', 'admin', 'form', 'formSelects'], function () {
+        var layer = layui.layer;
+        var admin = layui.admin;
+        var form = layui.form;
+
+        form.render('select');
+
+        form.verify({
+            "deptcode": function (e) {
+                if ("" == e || "" == $.trim(e)) {
+                    return "部门代码不能为空";
+                }
+                var msg = "";
+                if(ct){
+                    return;
+                }
+                $.ajax({
+                    type: "GET",
+                    url: '[[@{/system/checkdeptno}]]',
+                    async: false, //同步提交。不设置则默认异步,异步的话,最后执行ajax
+                    data: {
+                        deptno: e
+                    },
+                    success: function (result) {
+                        if (result.code != 200) {
+                            msg = result.msg;
+                        }
+                    },
+                    error: function (error) {
+                        msg = "请求服务器校验账号失败";
+                    }
+                });
+                if (msg != "") {
+                    return msg;
+                }
+            }
+        });
+
+
+        var url = '[[@{/system/adddept}]]';
+        // 回显user数据
+        var ct = admin.getTempData('t_ct');
+        if (ct) {
+          //  $('input[name="deptid"]').attr('readonly', 'readonly');
+            form.val('dept-form', ct);
+        }
+        // 表单提交事件
+        form.on('submit(dept-form-submit)', function (data) {
+            layer.load(2);
+            let token = $("meta[name='_csrf_token']").attr("value");
+            $.ajax({
+                type: "POST",
+                dataType: "json",
+                url: url,
+                headers: {
+                    'Accept': 'application/json',
+                    'Content-Type': 'application/json',
+                    'X-CSRF-TOKEN': token,
+                },
+                data: JSON.stringify(data.field),
+                success: function (result) {
+                    layer.closeAll('loading');
+                    if (result.code == 200) {
+                        layer.msg(result.msg, {icon: 1});
+                        admin.finishPopupCenter();
+                    } else if (result.code == 401) {
+                        layer.msg(result.msg, {icon: 2, time: 1500}, function () {
+                            location.replace('/login');
+                        }, 1000);
+                        return;
+                    } else {
+                        console.log('err:' + result.code);
+                        layer.msg(result.msg, {icon: 2});
+                    }
+                },
+                error: function () {
+                    layer.closeAll('loading');
+                    layer.msg("请求服务器失败!", {icon: 2});
+                }
+            });
+            return false;
+        });
+    });
+</script>
+
+<style>
+    .layui-form-label {
+        width: 100px;
+    }
+</style>
\ No newline at end of file
diff --git a/src/main/resources/templates/system/dept/index.html b/src/main/resources/templates/system/dept/index.html
new file mode 100644
index 0000000..47683b9
--- /dev/null
+++ b/src/main/resources/templates/system/dept/index.html
@@ -0,0 +1,131 @@
+<div class="layui-card">
+    <div class="layui-card-header">
+        <h2 class="header-title">部门管理</h2>
+        <span class="layui-breadcrumb pull-right">
+          <a href="#">部门管理</a>
+          <a><cite>部门管理</cite></a>
+        </span>
+    </div>
+    <div class="layui-card-body">
+        <div class="layui-form toolbar">
+            搜索:
+            <input id="dept-search-value" class="layui-input search-input" type="text" placeholder="输入部门代码或名称"/>&emsp;
+            <button id="dept-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon">&#xe615;</i>搜索
+            </button>
+            <button id="dept-btn-add" class="layui-btn icon-btn" data-type="add"><i class="layui-icon"></i>添加部门</button>
+        </div>
+        <table class="layui-table" id="dept-table" lay-filter="dept-table"></table>
+    </div>
+</div>
+<input hidden th:value="${deptList}" id="dplist">
+<script>
+    var rawlist=$("#dplist").val();
+    var dplist=JSON.parse(rawlist);
+
+    layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
+        let form = layui.form;
+        let table = layui.table;
+        let admin = layui.admin;
+
+       // form.render('select');
+
+        // 渲染表格
+        table.render({
+            elem: '#dept-table',
+            url: '[[@{/system/listdept}]]',
+            page: true,
+            cols: [
+                [
+                    {field: 'deptno', title: '部门代码', sort: true},
+                    {field: 'deptname', title: '部门名称', sort: true},
+                    {
+                        field: 'fdeptcode',
+                        title: '上级部门',
+                        sort: true,
+
+                        align: 'center',
+                        templet: function (item) {
+                            console.log(dplist);
+                            for(var i=0 ;i<dplist.length;i++){
+                                if(item.fdeptcode==dplist[i].deptcode){
+                                    return dplist[i].deptname;
+                                }
+                            }
+
+                            return item.deptno;
+                        }
+                    },
+                    {field: 'lastsaved', title: '修改日期', sort: true},
+
+                    {
+                        field: 'deptcode', align: 'center',width:160, title: '操作', fixed: 'right', templet: function (item) {
+                            return ' <a class="layui-btn  layui-btn-xs" lay-event="dept-edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> ' +
+                                ' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="dept-del"><i class="layui-icon layui-icon-delete"></i>删除</a>'
+                        }
+                    }
+                ]
+            ]
+        });
+        // 搜索按钮点击事件
+        $('#dept-btn-search').click(function () {
+            let key = $('#dept-search-value').val();
+            table.reload('dept-table', {where: {searchkey: key}, page: {curr: 1}});
+        });
+        $('#dept-btn-add').click(function () {
+            showModel();
+        });
+        let showModel = function (data) {
+            let title = data ? '修改客户部门' : '添加客户部门';
+            admin.putTempData('t_ct', data);
+            admin.popupCenter({
+                title: title,
+                path: '[[@{/system/loaddeptadd}]]',
+                finish: function () {
+                    table.reload('dept-table', {});
+                }
+            });
+        };
+
+
+        // 工具条点击事件
+        table.on('tool(dept-table)', function (obj) {
+            let data = obj.data;
+            let layEvent = obj.event;
+            console.log(data);
+            if (layEvent === 'dept-edit') {
+                showModel(data);
+            } else if (layEvent === 'dept-del') {
+                showDelete(data);
+            }
+        });
+        let showDelete = function (data) {
+            layer.confirm('确定要删除吗?', function (i) {
+                layer.close(i);
+                layer.load(2);
+                let token = $("meta[name='_csrf_token']").attr("value");
+                admin.go('[[@{/system/deletedept}]]', {
+                    deptcode: data.deptcode,
+                    _csrf: token
+                }, function (data) {
+                    console.log(data.code);
+                    layer.closeAll('loading');
+                    if (data.code == 200) {
+                        layer.msg(data.msg, {icon: 1});
+                    } else if (data.code == 401) {
+                        layer.msg(data.msg, {icon: 2, time: 1500}, function () {
+                            location.replace('/login');
+                        }, 1000);
+                        return;
+                    } else {
+                        layer.msg(data.msg, {icon: 2});
+                    }
+                    table.reload('dept-table', {});
+                }, function (ret) {
+                    console.log(ret);
+                    layer.closeAll('loading');
+                    layer.msg('请求失败了,请稍后再试', {icon: 2});
+                });
+            });
+        }
+    });
+</script>