浏览代码

学区查询

liuyuqiang 2 年之前
父节点
当前提交
b8bb128bdf
共有 16 个文件被更改,包括 511 次插入231 次删除
  1. 0 128
      sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpSchoolPvController.java
  2. 1 1
      sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpPolicestationVillageController.java
  3. 1 8
      sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpSchoolController.java
  4. 133 0
      sooka-admin/src/main/java/com/sooka/web/controller/schooldistrict/BtpSchoolPvController.java
  5. 86 0
      sooka-admin/src/main/resources/templates/schooldistrict/index/add.html
  6. 79 0
      sooka-admin/src/main/resources/templates/schooldistrict/index/edit.html
  7. 112 0
      sooka-admin/src/main/resources/templates/schooldistrict/index/index.html
  8. 1 1
      sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/add.html
  9. 1 1
      sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/edit.html
  10. 0 29
      sooka-admin/src/main/resources/templates/schooldistrict/school/add.html
  11. 0 29
      sooka-admin/src/main/resources/templates/schooldistrict/school/edit.html
  12. 52 9
      sooka-business/src/main/java/com/sooka/business/schooldistrict/domain/BtpSchoolPv.java
  13. 2 2
      sooka-business/src/main/java/com/sooka/business/schooldistrict/mapper/BtpSchoolPvMapper.java
  14. 2 2
      sooka-business/src/main/java/com/sooka/business/schooldistrict/service/IBtpSchoolPvService.java
  15. 14 6
      sooka-business/src/main/java/com/sooka/business/schooldistrict/service/impl/BtpSchoolPvServiceImpl.java
  16. 27 15
      sooka-business/src/main/resources/mapper/schooldistrict/BtpSchoolPvMapper.xml

+ 0 - 128
sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpSchoolPvController.java

@@ -1,128 +0,0 @@
-//package com.sooka.web.controller.business.schooldistrict;
-//
-//import java.util.List;
-//
-//import com.sooka.business.schooldistrict.domain.BtpSchoolPv;
-//import com.sooka.business.schooldistrict.service.IBtpSchoolPvService;
-//import com.sooka.common.utils.poi.ExcelUtil;
-//import org.apache.shiro.authz.annotation.RequiresPermissions;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Controller;
-//import org.springframework.ui.ModelMap;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.PathVariable;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.ResponseBody;
-//import com.sooka.common.annotation.Log;
-//import com.sooka.common.enums.BusinessType;
-//import com.sooka.common.core.controller.BaseController;
-//import com.sooka.common.core.domain.AjaxResult;
-//import com.sooka.common.core.page.TableDataInfo;
-//
-///**
-// * 关系中间Controller
-// *
-// * @author lyq
-// * @date 2023-02-20
-// */
-//@Controller
-//@RequestMapping("/schooldistrict/school")
-//public class BtpSchoolPvController extends BaseController
-//{
-//    private String prefix = "schooldistrict/school";
-//
-//    @Autowired
-//    private IBtpSchoolPvService btpSchoolPvService;
-//
-//    @RequiresPermissions("schooldistrict:school:view")
-//    @GetMapping()
-//    public String school()
-//    {
-//        return prefix + "/school";
-//    }
-//
-//    /**
-//     * 查询关系中间列表
-//     */
-//    @RequiresPermissions("schooldistrict:school:list")
-//    @PostMapping("/list")
-//    @ResponseBody
-//    public TableDataInfo list(BtpSchoolPv btpSchoolPv)
-//    {
-//        startPage();
-//        List<BtpSchoolPv> list = btpSchoolPvService.selectBtpSchoolPvList(btpSchoolPv);
-//        return getDataTable(list);
-//    }
-//
-//    /**
-//     * 导出关系中间列表
-//     */
-//    @RequiresPermissions("schooldistrict:school:export")
-//    @Log(title = "关系中间", businessType = BusinessType.EXPORT)
-//    @PostMapping("/export")
-//    @ResponseBody
-//    public AjaxResult export(BtpSchoolPv btpSchoolPv)
-//    {
-//        List<BtpSchoolPv> list = btpSchoolPvService.selectBtpSchoolPvList(btpSchoolPv);
-//        ExcelUtil<BtpSchoolPv> util = new ExcelUtil<BtpSchoolPv>(BtpSchoolPv.class);
-//        return util.exportExcel(list, "关系中间数据");
-//    }
-//
-//    /**
-//     * 新增关系中间
-//     */
-//    @GetMapping("/add")
-//    public String add()
-//    {
-//        return prefix + "/add";
-//    }
-//
-//    /**
-//     * 新增保存关系中间
-//     */
-//    @RequiresPermissions("schooldistrict:school:add")
-//    @Log(title = "关系中间", businessType = BusinessType.INSERT)
-//    @PostMapping("/add")
-//    @ResponseBody
-//    public AjaxResult addSave(BtpSchoolPv btpSchoolPv)
-//    {
-//        return toAjax(btpSchoolPvService.insertBtpSchoolPv(btpSchoolPv));
-//    }
-//
-//    /**
-//     * 修改关系中间
-//     */
-//    @RequiresPermissions("schooldistrict:school:edit")
-//    @GetMapping("/edit/{pId}")
-//    public String edit(@PathVariable("pId") Long pId, ModelMap mmap)
-//    {
-//        BtpSchoolPv btpSchoolPv = btpSchoolPvService.selectBtpSchoolPvByPId(pId);
-//        mmap.put("btpSchoolPv", btpSchoolPv);
-//        return prefix + "/edit";
-//    }
-//
-//    /**
-//     * 修改保存关系中间
-//     */
-//    @RequiresPermissions("schooldistrict:school:edit")
-//    @Log(title = "关系中间", businessType = BusinessType.UPDATE)
-//    @PostMapping("/edit")
-//    @ResponseBody
-//    public AjaxResult editSave(BtpSchoolPv btpSchoolPv)
-//    {
-//        return toAjax(btpSchoolPvService.updateBtpSchoolPv(btpSchoolPv));
-//    }
-//
-//    /**
-//     * 删除关系中间
-//     */
-//    @RequiresPermissions("schooldistrict:school:remove")
-//    @Log(title = "关系中间", businessType = BusinessType.DELETE)
-//    @PostMapping( "/remove")
-//    @ResponseBody
-//    public AjaxResult remove(String ids)
-//    {
-//        return toAjax(btpSchoolPvService.deleteBtpSchoolPvByPIds(ids));
-//    }
-//}

+ 1 - 1
sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpPolicestationVillageController.java

@@ -1,4 +1,4 @@
-package com.sooka.web.controller.business.schooldistrict;
+package com.sooka.web.controller.schooldistrict;
 
 import com.sooka.business.schooldistrict.domain.BtpPolicestationVillage;
 import com.sooka.business.schooldistrict.service.IBtpPolicestationVillageService;

+ 1 - 8
sooka-admin/src/main/java/com/sooka/web/controller/business/schooldistrict/BtpSchoolController.java

@@ -1,7 +1,6 @@
-package com.sooka.web.controller.business.schooldistrict;
+package com.sooka.web.controller.schooldistrict;
 
 import com.sooka.business.schooldistrict.domain.BtpSchool;
-import com.sooka.business.schooldistrict.service.IBtpPolicestationVillageService;
 import com.sooka.business.schooldistrict.service.IBtpSchoolService;
 import com.sooka.common.annotation.Log;
 import com.sooka.common.core.controller.BaseController;
@@ -32,9 +31,6 @@ public class BtpSchoolController extends BaseController {
     @Autowired
     private IBtpSchoolService btpSchoolService;
 
-    @Autowired
-    private IBtpPolicestationVillageService btpPolicestationVillageService;
-
     @RequiresPermissions("schooldistrict:school:view")
     @GetMapping()
     public String school() {
@@ -71,7 +67,6 @@ public class BtpSchoolController extends BaseController {
      */
     @GetMapping("/add")
     public String add(ModelMap mmap) {
-        mmap.put("policestations", btpPolicestationVillageService.getAllByParentId(0L));
         return prefix + "/add";
     }
 
@@ -94,8 +89,6 @@ public class BtpSchoolController extends BaseController {
     public String edit(@PathVariable("schoolId") Long schoolId, ModelMap mmap) {
         BtpSchool btpSchool = btpSchoolService.selectBtpSchoolBySchoolId(schoolId);
         mmap.put("btpSchool", btpSchool);
-        mmap.put("policestations", btpPolicestationVillageService.getAllByParentId(0L));
-//        mmap.put("villages", btpPolicestationVillageService.getAllByParentId(btpSchool.getSchoolId()));
         return prefix + "/edit";
     }
 

+ 133 - 0
sooka-admin/src/main/java/com/sooka/web/controller/schooldistrict/BtpSchoolPvController.java

@@ -0,0 +1,133 @@
+package com.sooka.web.controller.schooldistrict;
+
+import com.sooka.business.schooldistrict.domain.BtpPolicestationVillage;
+import com.sooka.business.schooldistrict.domain.BtpSchool;
+import com.sooka.business.schooldistrict.domain.BtpSchoolPv;
+import com.sooka.business.schooldistrict.service.IBtpPolicestationVillageService;
+import com.sooka.business.schooldistrict.service.IBtpSchoolPvService;
+import com.sooka.business.schooldistrict.service.IBtpSchoolService;
+import com.sooka.common.annotation.Log;
+import com.sooka.common.core.controller.BaseController;
+import com.sooka.common.core.domain.AjaxResult;
+import com.sooka.common.core.page.TableDataInfo;
+import com.sooka.common.enums.BusinessType;
+import com.sooka.common.utils.poi.ExcelUtil;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 关系中间Controller
+ *
+ * @author lyq
+ * @date 2023-02-20
+ */
+@Controller
+@RequestMapping("/schooldistrict/index")
+public class BtpSchoolPvController extends BaseController {
+
+    private String prefix = "schooldistrict/index";
+
+    @Autowired
+    private IBtpSchoolPvService btpSchoolPvService;
+
+    @Autowired
+    private IBtpPolicestationVillageService btpPolicestationVillageService;
+
+    @Autowired
+    private IBtpSchoolService btpSchoolService;
+
+    @RequiresPermissions("schooldistrict:index:view")
+    @GetMapping()
+    public String index() {
+        return prefix + "/index";
+    }
+
+    /**
+     * 查询关系中间列表
+     */
+    @RequiresPermissions("schooldistrict:index:list")
+    @PostMapping("/list")
+    @ResponseBody
+    public TableDataInfo list(BtpSchoolPv btpSchoolPv) {
+        startPage();
+        List<BtpSchoolPv> list = btpSchoolPvService.selectBtpSchoolPvList(btpSchoolPv);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出关系中间列表
+     */
+    @RequiresPermissions("schooldistrict:index:export")
+    @Log(title = "关系中间", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ResponseBody
+    public AjaxResult export(BtpSchoolPv btpSchoolPv) {
+        List<BtpSchoolPv> list = btpSchoolPvService.selectBtpSchoolPvList(btpSchoolPv);
+        ExcelUtil<BtpSchoolPv> util = new ExcelUtil<>(BtpSchoolPv.class);
+        return util.exportExcel(list, "关系中间数据");
+    }
+
+    /**
+     * 新增关系中间
+     */
+    @GetMapping("/add")
+    public String add(ModelMap mmap) {
+        mmap.put("policestations", btpPolicestationVillageService.getAllByParentId(0L));
+        mmap.put("villages", Arrays.asList(new BtpPolicestationVillage()));
+        mmap.put("schools", btpSchoolService.selectBtpSchoolList(new BtpSchool()));
+        return prefix + "/add";
+    }
+
+    /**
+     * 新增保存关系中间
+     */
+    @RequiresPermissions("schooldistrict:index:add")
+    @Log(title = "关系中间", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    @ResponseBody
+    public AjaxResult addSave(BtpSchoolPv btpSchoolPv) {
+        return toAjax(btpSchoolPvService.insertBtpSchoolPv(btpSchoolPv));
+    }
+
+    /**
+     * 修改关系中间
+     */
+    @RequiresPermissions("schooldistrict:index:edit")
+    @GetMapping("/edit/{vIds}")
+    public String edit(@PathVariable("vIds") String vIds, ModelMap mmap) {
+        BtpSchoolPv btpSchoolPv = btpSchoolPvService.selectBtpSchoolPvInVIds(vIds);
+        mmap.put("btpSchoolPv", btpSchoolPv);
+        mmap.put("policestations", btpPolicestationVillageService.getAllByParentId(0L));
+        mmap.put("villages", btpPolicestationVillageService.getAllByParentId(btpSchoolPv.getpId()));
+        mmap.put("schools", btpSchoolService.selectBtpSchoolList(new BtpSchool()));
+        return prefix + "/edit";
+    }
+
+    /**
+     * 修改保存关系中间
+     */
+    @RequiresPermissions("schooldistrict:index:edit")
+    @Log(title = "关系中间", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    @ResponseBody
+    public AjaxResult editSave(BtpSchoolPv btpSchoolPv) {
+        return toAjax(btpSchoolPvService.updateBtpSchoolPv(btpSchoolPv));
+    }
+
+    /**
+     * 删除关系中间
+     */
+    @RequiresPermissions("schooldistrict:index:remove")
+    @Log(title = "关系中间", businessType = BusinessType.DELETE)
+    @PostMapping("/remove")
+    @ResponseBody
+    public AjaxResult remove(String ids) {
+        return toAjax(btpSchoolPvService.deleteBtpSchoolPvByVIds(ids));
+    }
+}

+ 86 - 0
sooka-admin/src/main/resources/templates/schooldistrict/index/add.html

@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('新增关系中间')" />
+    <th:block th:include="include :: select2-css" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-pv-add">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">派出所:</label>
+                <div class="col-sm-8">
+                    <select id="pId" name="pId" class="form-control select2-multiple">
+                        <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
+                    </select>
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">委(村):</label>
+                <div class="col-sm-8">
+                    <select id="vId" class="form-control select2-multiple" multiple>
+                        <option th:each="village:${villages}" th:value="${village.pvId}" th:text="${village.pvName}" ></option>
+                    </select>
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">学校:</label>
+                <div class="col-sm-8">
+                    <select id="schoolId" name="schoolId" class="form-control select2-multiple">
+                        <option th:each="school:${schools}" th:value="${school.schoolId}" th:text="${school.schoolName}"></option>
+                    </select>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <th:block th:include="include :: select2-js" />
+    <script th:inline="javascript">
+        var prefix = ctx + "schooldistrict/index"
+        $("#form-pv-add").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                var data = $("#form-pv-add").serializeArray();
+                var vIds = $.form.selectSelects("vId");
+                data.push({"name": "id", "value": vIds});
+                $.operate.save(prefix + "/add", data);
+            }
+        }
+
+        function getData(array) {
+            $.each(array, function (index, item) {
+                item.id = item.pvId;
+                item.text = item.pvName;
+            })
+            return array;
+        }
+
+        $(function() {
+            $('#pId').select2({
+                placeholder: "请选择派出所",
+                allowClear: true
+            }).on('select2:select', function (e) {
+                //处理自己的业务
+                $.get("/schooldistrict/policestationvillage/getAllByParentId?parentId=" + this.value, function(result) {
+                    $('#vId').empty().select2({
+                        data: getData(result),
+                        placeholder: "请选择委(村)",
+                        allowClear: true
+                    });
+                });
+            });
+            $('#vId').select2({
+                placeholder: "请选择委(村)",
+                allowClear: true
+            });
+            $('#schoolId').select2({
+                placeholder: "请选择学校",
+                allowClear: true
+            });
+        })
+    </script>
+</body>
+</html>

+ 79 - 0
sooka-admin/src/main/resources/templates/schooldistrict/index/edit.html

@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
+<head>
+    <th:block th:include="include :: header('修改关系中间')" />
+    <th:block th:include="include :: select2-css" />
+</head>
+<body class="white-bg">
+    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
+        <form class="form-horizontal m" id="form-pv-edit" th:object="${btpSchoolPv}">
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">派出所:</label>
+                <div class="col-sm-8">
+                    <select id="pId" name="pId" th:field="*{pId}" class="form-control select2-multiple">
+                        <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
+                    </select>
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">委(村):</label>
+                <div class="col-sm-8">
+                    <select id="vId" class="form-control select2-multiple" multiple>
+                        <option th:each="village:${villages}" th:value="${village.pvId}" th:text="${village.pvName}"
+                                th:selected="${#arrays.contains(btpSchoolPv.id.split(','),village.pvId.toString())}"></option>
+                    </select>
+                </div>
+            </div>
+            <div class="form-group">
+                <label class="col-sm-3 control-label is-required">学校:</label>
+                <div class="col-sm-8">
+                    <select id="schoolId" name="schoolId" th:field="*{schoolId}" class="form-control select2-multiple">
+                        <option th:each="school:${schools}" th:value="${school.schoolId}" th:text="${school.schoolName}"></option>
+                    </select>
+                </div>
+            </div>
+        </form>
+    </div>
+    <th:block th:include="include :: footer" />
+    <th:block th:include="include :: select2-js" />
+    <script th:inline="javascript">
+        var prefix = ctx + "schooldistrict/index", ids = '[[${btpSchoolPv.id}]]'.split(",");
+        $("#form-pv-edit").validate({
+            focusCleanup: true
+        });
+
+        function submitHandler() {
+            if ($.validate.form()) {
+                var data = $("#form-pv-edit").serializeArray();
+                var vIds = $.form.selectSelects("vId");
+                data.push({"name": "id", "value": vIds});
+                $.operate.save(prefix + "/edit", data);
+            }
+        }
+
+        $(function() {
+            $('#pId').select2({
+                placeholder: "请选择派出所",
+                allowClear: true
+            }).on('select2:select', function (e) {
+                //处理自己的业务
+                $.get("/schooldistrict/policestationvillage/getAllByParentId?parentId=" + this.value, function(result) {
+                    $('#vId').empty().select2({
+                        data: getData(result),
+                        placeholder: "请选择委(村)",
+                        allowClear: true
+                    });
+                });
+            });
+            $('#vId').select2({
+                placeholder: "请选择委(村)",
+                allowClear: true
+            });
+            $('#schoolId').select2({
+                placeholder: "请选择学校",
+                allowClear: true
+            });
+        })
+    </script>
+</body>
+</html>

+ 112 - 0
sooka-admin/src/main/resources/templates/schooldistrict/index/index.html

@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<head>
+    <th:block th:include="include :: header('关系中间列表')" />
+</head>
+<body class="gray-bg">
+     <div class="container-div">
+        <div class="row">
+            <div class="col-sm-12 search-collapse">
+                <form id="formId">
+                    <div class="select-list">
+                        <ul>
+                            <li>
+                                派出所:
+                                <input type="text" name="pName"/>
+                            </li>
+                            <li>
+                                委(村):
+                                <input type="text" name="vName"/>
+                            </li>
+                            <li>
+                                学校:
+                                <input type="text" name="schoolName"/>
+                            </li>
+                            <li>
+                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
+                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
+                            </li>
+                        </ul>
+                    </div>
+                </form>
+            </div>
+
+            <div class="btn-group-sm" id="toolbar" role="group">
+                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="schooldistrict:index:add">
+                    <i class="fa fa-plus"></i> 添加
+                </a>
+                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="schooldistrict:index:edit">
+                    <i class="fa fa-edit"></i> 修改
+                </a>
+                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="schooldistrict:index:remove">
+                    <i class="fa fa-remove"></i> 删除
+                </a>
+                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="schooldistrict:index:export">
+                    <i class="fa fa-download"></i> 导出
+                </a>
+            </div>
+            <div class="col-sm-12 select-table table-striped">
+                <table id="bootstrap-table"></table>
+            </div>
+        </div>
+    </div>
+    <th:block th:include="include :: footer" />
+    <script th:inline="javascript">
+        var editFlag = [[${@permission.hasPermi('schooldistrict:index:edit')}]];
+        var removeFlag = [[${@permission.hasPermi('schooldistrict:index:remove')}]];
+        var prefix = ctx + "schooldistrict/index";
+
+        $(function() {
+            var options = {
+                url: prefix + "/list",
+                createUrl: prefix + "/add",
+                updateUrl: prefix + "/edit/{id}",
+                removeUrl: prefix + "/remove",
+                exportUrl: prefix + "/export",
+                modalName: "关系中间",
+                columns: [{
+                    checkbox: true
+                },
+                {
+                    field: 'id',
+                    title: '委(村)id',
+                    visible: false
+                },
+                {
+                    field: 'pId',
+                    title: '派出所id',
+                    visible: false
+                },
+                {
+                    field: 'pName',
+                    title: '派出所'
+                },
+                {
+                    field: 'vName',
+                    title: '委(村)',
+                },
+                {
+                    field: 'schoolId',
+                    title: '学校id',
+                    visible: false
+                },
+                {
+                    field: 'schoolName',
+                    title: '学校',
+                },
+                {
+                    title: '操作',
+                    align: 'center',
+                    formatter: function(value, row, index) {
+                        var actions = [];
+                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
+                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
+                        return actions.join('');
+                    }
+                }]
+            };
+            $.table.init(options);
+        });
+    </script>
+</body>
+</html>

+ 1 - 1
sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/add.html

@@ -16,7 +16,7 @@
         <div class="form-group" th:style="'display:' + ${display}">
             <label class="col-sm-3 control-label is-required">所属派出所:</label>
             <div class="col-sm-8">
-                <select id="parentId" class="form-control select2-multiple" required>
+                <select id="parentId" name="parentId" class="form-control select2-multiple" required>
                     <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
                 </select>
             </div>

+ 1 - 1
sooka-admin/src/main/resources/templates/schooldistrict/policestationvillage/edit.html

@@ -17,7 +17,7 @@
         <div class="form-group" th:style="'display:' + ${display}">
             <label class="col-sm-3 control-label is-required">所属派出所:</label>
             <div class="col-sm-8">
-                <select id="parentId" class="form-control select2-multiple" required>
+                <select id="parentId" name="parentId" class="form-control select2-multiple" required>
                     <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
                 </select>
             </div>

+ 0 - 29
sooka-admin/src/main/resources/templates/schooldistrict/school/add.html

@@ -2,7 +2,6 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
 <head>
     <th:block th:include="include :: header('新增学校')" />
-    <th:block th:include="include :: select2-css" />
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
@@ -21,26 +20,9 @@
                     </select>
                 </div>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label is-required">所属派出所:</label>
-                <div class="col-sm-8">
-                    <select id="policestation" class="form-control select2-multiple" required>
-                        <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
-                    </select>
-                </div>
-            </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label is-required">所属委(村):</label>
-                <div class="col-sm-8">
-                    <select id="village" class="form-control select2-multiple" required>
-                        <option th:each="village:${villages}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
-                    </select>
-                </div>
-            </div>
         </form>
     </div>
     <th:block th:include="include :: footer" />
-    <th:block th:include="include :: select2-js" />
     <script th:inline="javascript">
         var prefix = ctx + "schooldistrict/school"
         $("#form-school-add").validate({
@@ -52,17 +34,6 @@
                 $.operate.save(prefix + "/add", $('#form-school-add').serialize());
             }
         }
-
-        $(function() {
-            $('#policestation').select2({
-                placeholder: "请选择所属派出所",
-                allowClear: true
-            });
-            $('#village').select2({
-                placeholder: "请选择所属委(村)",
-                allowClear: true
-            });
-        })
     </script>
 </body>
 </html>

+ 0 - 29
sooka-admin/src/main/resources/templates/schooldistrict/school/edit.html

@@ -2,7 +2,6 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
 <head>
     <th:block th:include="include :: header('修改学校')" />
-    <th:block th:include="include :: select2-css" />
 </head>
 <body class="white-bg">
     <div class="wrapper wrapper-content animated fadeInRight ibox-content">
@@ -22,26 +21,9 @@
                     </select>
                 </div>
             </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label is-required">所属派出所:</label>
-                <div class="col-sm-8">
-                    <select id="policestation" class="form-control select2-multiple" required>
-                        <option th:each="policestation:${policestations}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
-                    </select>
-                </div>
-            </div>
-            <div class="form-group">
-                <label class="col-sm-3 control-label is-required">所属委(村):</label>
-                <div class="col-sm-8">
-                    <select id="village" class="form-control select2-multiple" required>
-                        <option th:each="village:${villages}" th:value="${policestation.pvId}" th:text="${policestation.pvName}"></option>
-                    </select>
-                </div>
-            </div>
         </form>
     </div>
     <th:block th:include="include :: footer" />
-    <th:block th:include="include :: select2-js" />
     <script th:inline="javascript">
         var prefix = ctx + "schooldistrict/school";
         $("#form-school-edit").validate({
@@ -53,17 +35,6 @@
                 $.operate.save(prefix + "/edit", $('#form-school-edit').serialize());
             }
         }
-
-        $(function() {
-            $('#policestation').select2({
-                placeholder: "请选择所属派出所",
-                allowClear: true
-            });
-            $('#village').select2({
-                placeholder: "请选择所属委(村)",
-                allowClear: true
-            });
-        })
     </script>
 </body>
 </html>

+ 52 - 9
sooka-business/src/main/java/com/sooka/business/schooldistrict/domain/BtpSchoolPv.java

@@ -15,54 +15,97 @@ public class BtpSchoolPv extends BaseEntity {
 
     private static final long serialVersionUID = 1L;
 
+    private String id;
+
     /**
      * 派出所id
      */
-    @Excel(name = "派出所id")
     private Long pId;
 
+    @Excel(name = "派出所")
+    private String pName;
+
     /**
      * 委(村)id
      */
-    @Excel(name = "委(村)id")
     private Long vId;
 
+    @Excel(name = "委(村)")
+    private String vName;
+
     /**
      * 学校id
      */
-    @Excel(name = "学校id")
     private Long schoolId;
 
-    public void setpId(Long pId) {
-        this.pId = pId;
+    @Excel(name = "学校")
+    private String schoolName;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
     }
 
     public Long getpId() {
         return pId;
     }
 
-    public void setvId(Long vId) {
-        this.vId = vId;
+    public void setpId(Long pId) {
+        this.pId = pId;
+    }
+
+    public String getpName() {
+        return pName;
+    }
+
+    public void setpName(String pName) {
+        this.pName = pName;
     }
 
     public Long getvId() {
         return vId;
     }
 
-    public void setSchoolId(Long schoolId) {
-        this.schoolId = schoolId;
+    public void setvId(Long vId) {
+        this.vId = vId;
+    }
+
+    public String getvName() {
+        return vName;
+    }
+
+    public void setvName(String vName) {
+        this.vName = vName;
     }
 
     public Long getSchoolId() {
         return schoolId;
     }
 
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                 .append("pId", getpId())
+                .append("pName", getpName())
                 .append("vId", getvId())
+                .append("vName", getvName())
                 .append("schoolId", getSchoolId())
+                .append("schoolName", getSchoolName())
                 .toString();
     }
 }

+ 2 - 2
sooka-business/src/main/java/com/sooka/business/schooldistrict/mapper/BtpSchoolPvMapper.java

@@ -18,7 +18,7 @@ public interface BtpSchoolPvMapper {
      * @param pId 关系中间主键
      * @return 关系中间
      */
-    public BtpSchoolPv selectBtpSchoolPvByPId(Long pId);
+    public BtpSchoolPv selectBtpSchoolPvInVIds(String vIds);
 
     /**
      * 查询关系中间列表
@@ -58,5 +58,5 @@ public interface BtpSchoolPvMapper {
      * @param pIds 需要删除的数据主键集合
      * @return 结果
      */
-    public int deleteBtpSchoolPvByPIds(String[] pIds);
+    public int deleteBtpSchoolPvByVIds(String[] vIds);
 }

+ 2 - 2
sooka-business/src/main/java/com/sooka/business/schooldistrict/service/IBtpSchoolPvService.java

@@ -18,7 +18,7 @@ public interface IBtpSchoolPvService {
      * @param pId 关系中间主键
      * @return 关系中间
      */
-    public BtpSchoolPv selectBtpSchoolPvByPId(Long pId);
+    public BtpSchoolPv selectBtpSchoolPvInVIds(String vIds);
 
     /**
      * 查询关系中间列表
@@ -50,7 +50,7 @@ public interface IBtpSchoolPvService {
      * @param pIds 需要删除的关系中间主键集合
      * @return 结果
      */
-    public int deleteBtpSchoolPvByPIds(String pIds);
+    public int deleteBtpSchoolPvByVIds(String vIds);
 
     /**
      * 删除关系中间信息

+ 14 - 6
sooka-business/src/main/java/com/sooka/business/schooldistrict/service/impl/BtpSchoolPvServiceImpl.java

@@ -6,6 +6,7 @@ import com.sooka.business.schooldistrict.service.IBtpSchoolPvService;
 import com.sooka.common.core.text.Convert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -28,8 +29,8 @@ public class BtpSchoolPvServiceImpl implements IBtpSchoolPvService {
      * @return 关系中间
      */
     @Override
-    public BtpSchoolPv selectBtpSchoolPvByPId(Long pId) {
-        return btpSchoolPvMapper.selectBtpSchoolPvByPId(pId);
+    public BtpSchoolPv selectBtpSchoolPvInVIds(String vIds) {
+        return btpSchoolPvMapper.selectBtpSchoolPvInVIds(vIds);
     }
 
     /**
@@ -51,7 +52,12 @@ public class BtpSchoolPvServiceImpl implements IBtpSchoolPvService {
      */
     @Override
     public int insertBtpSchoolPv(BtpSchoolPv btpSchoolPv) {
-        return btpSchoolPvMapper.insertBtpSchoolPv(btpSchoolPv);
+        int result = 0;
+        for (String vId : btpSchoolPv.getId().split(",")) {
+            btpSchoolPv.setvId(Long.parseLong(vId));
+            result += btpSchoolPvMapper.insertBtpSchoolPv(btpSchoolPv);
+        }
+        return result;
     }
 
     /**
@@ -60,9 +66,11 @@ public class BtpSchoolPvServiceImpl implements IBtpSchoolPvService {
      * @param btpSchoolPv 关系中间
      * @return 结果
      */
+    @Transactional
     @Override
     public int updateBtpSchoolPv(BtpSchoolPv btpSchoolPv) {
-        return btpSchoolPvMapper.updateBtpSchoolPv(btpSchoolPv);
+        this.deleteBtpSchoolPvByVIds(btpSchoolPv.getId());
+        return this.insertBtpSchoolPv(btpSchoolPv);
     }
 
     /**
@@ -72,8 +80,8 @@ public class BtpSchoolPvServiceImpl implements IBtpSchoolPvService {
      * @return 结果
      */
     @Override
-    public int deleteBtpSchoolPvByPIds(String pIds) {
-        return btpSchoolPvMapper.deleteBtpSchoolPvByPIds(Convert.toStrArray(pIds));
+    public int deleteBtpSchoolPvByVIds(String vIds) {
+        return btpSchoolPvMapper.deleteBtpSchoolPvByVIds(Convert.toStrArray(vIds));
     }
 
     /**

+ 27 - 15
sooka-business/src/main/resources/mapper/schooldistrict/BtpSchoolPvMapper.xml

@@ -3,11 +3,15 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sooka.business.schooldistrict.mapper.BtpSchoolPvMapper">
-    
+
     <resultMap type="BtpSchoolPv" id="BtpSchoolPvResult">
+        <result property="id"    column="id"    />
         <result property="pId"    column="p_id"    />
+        <result property="pName"    column="p_name"    />
         <result property="vId"    column="v_id"    />
+        <result property="vName"    column="v_name"    />
         <result property="schoolId"    column="school_id"    />
+        <result property="schoolName"    column="school_name"    />
     </resultMap>
 
     <sql id="selectBtpSchoolPvVo">
@@ -15,19 +19,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectBtpSchoolPvList" parameterType="BtpSchoolPv" resultMap="BtpSchoolPvResult">
-        <include refid="selectBtpSchoolPvVo"/>
-        <where>  
-            <if test="pId != null "> and p_id = #{pId}</if>
-            <if test="vId != null "> and v_id = #{vId}</if>
-            <if test="schoolId != null "> and school_id = #{schoolId}</if>
+        select group_concat(a.v_id) id, a.p_id, b.pv_name p_name, group_concat(c.pv_name) v_name, a.school_id, d.school_name
+        from btp_school_pv a
+        left join btp_policestation_village b on b.pv_id = a.p_id
+        left join btp_policestation_village c on c.pv_id = a.v_id
+        left join btp_school d on d.school_id = a.school_id
+        <where>
+            <if test="pName != null "> and b.pv_name like concat('%', #{pName}, '%')</if>
+            <if test="vName != null "> and c.pv_name like concat('%', #{vName}, '%')</if>
+            <if test="schoolName != null "> and d.school_name like concat('%', #{schoolName}, '%')</if>
         </where>
+        group by a.p_id, a.school_id
     </select>
-    
-    <select id="selectBtpSchoolPvByPId" parameterType="Long" resultMap="BtpSchoolPvResult">
-        <include refid="selectBtpSchoolPvVo"/>
-        where p_id = #{pId}
+
+    <select id="selectBtpSchoolPvInVIds" parameterType="Long" resultMap="BtpSchoolPvResult">
+        select group_concat(v_id) id, p_id, school_id from btp_school_pv
+        where v_id in
+        <foreach item="item" index="index" collection="vIds.split(',')"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
     </select>
-        
+
     <insert id="insertBtpSchoolPv" parameterType="BtpSchoolPv">
         insert into btp_school_pv
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -55,10 +67,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from btp_school_pv where p_id = #{pId}
     </delete>
 
-    <delete id="deleteBtpSchoolPvByPIds" parameterType="String">
-        delete from btp_school_pv where p_id in 
-        <foreach item="pId" collection="array" open="(" separator="," close=")">
-            #{pId}
+    <delete id="deleteBtpSchoolPvByVIds" parameterType="String">
+        delete from btp_school_pv where v_id in
+        <foreach item="vId" collection="array" open="(" separator="," close=")">
+            #{vId}
         </foreach>
     </delete>