Quellcode durchsuchen

feat: 查法规

许家凯 vor 2 Jahren
Ursprung
Commit
ca2aea9167

+ 57 - 0
src/main/java/com/winhc/phoenix/example/controller/IndexController.java

@@ -0,0 +1,57 @@
+package com.winhc.phoenix.example.controller;
+
+import com.winhc.phoenix.example.util.JsonUtils;
+import com.winhc.phoenix.example.vo.SearchIndexModel;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author: XuJiakai
+ * 2022/9/14 16:05
+ */
+@Controller
+@RequestMapping("index")
+@AllArgsConstructor
+public class IndexController {
+
+    private final HttpServletRequest request;
+
+
+    @RequestMapping("/search-{template}.html")
+    public String search(Model model, @PathVariable String template) {
+        String serverName = request.getServerName();
+        String scheme = request.getScheme();
+        int serverPort = request.getServerPort();
+
+        String prefix = scheme + "://" + serverName + ":" + serverPort;
+
+        Map<String, SearchIndexModel> models =
+                SearchIndexModel.getModels();
+        SearchIndexModel searchIndexModel = models.get(template);
+
+        String columnsJs = searchIndexModel.getColumnsJs().stream().map(SearchIndexModel.ColumnInfo::toString).collect(Collectors.joining(",\n", "[", "]"));
+        String highlightMapping = JsonUtils.jsonObjToString(searchIndexModel.getHighlightMapping());
+
+        model.addAttribute("title", searchIndexModel.getTitle());
+        model.addAttribute("formHtml", StringUtils.defaultString(searchIndexModel.getFormHtml(), SearchIndexModel.defaultFormHtml));
+        model.addAttribute("historyForm", StringUtils.defaultString(searchIndexModel.getFormHtml(), ""));
+        model.addAttribute("initJs", StringUtils.defaultString(searchIndexModel.getInitJs()));
+        model.addAttribute("method", searchIndexModel.getMethod());
+        model.addAttribute("url", prefix + searchIndexModel.getUrl());
+        model.addAttribute("queryParamsFunc", StringUtils.defaultString(searchIndexModel.getQueryParamsFunc(), SearchIndexModel.defaultQueryParamsFunc));
+        model.addAttribute("responseHandlerFunc", searchIndexModel.getResponseHandlerFunc());
+        model.addAttribute("columnsJs", columnsJs);
+        model.addAttribute("highlightMapping", highlightMapping);
+        model.addAttribute("jsFunction", String.join("\n", searchIndexModel.getJsFunction()));
+        return "search-templates";
+    }
+
+}

+ 32 - 0
src/main/java/com/winhc/phoenix/example/controller/LegislationController.java

@@ -0,0 +1,32 @@
+package com.winhc.phoenix.example.controller;
+
+import com.winhc.phoenix.example.aspect.Timer;
+import com.winhc.phoenix.example.service.LegislationService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author: XuJiakai
+ * 2022/9/2 11:42
+ */
+@Slf4j
+@AllArgsConstructor
+@RestController
+@Api(tags = "法规查询", value = "legislation")
+@RequestMapping("legislation")
+public class LegislationController {
+    private final LegislationService legislationService;
+
+    @Timer
+    @ApiOperation(value = "法规查询")
+    @GetMapping("query")
+    public Object query(String content
+            , @RequestParam(defaultValue = "0") int from
+            , @RequestParam(defaultValue = "10") int size
+    ) {
+        return legislationService.search(content, from, size);
+    }
+}

+ 10 - 0
src/main/java/com/winhc/phoenix/example/service/LegislationService.java

@@ -0,0 +1,10 @@
+package com.winhc.phoenix.example.service;
+
+/**
+ * @author: XuJiakai
+ * 2022/9/2 11:37
+ */
+public interface LegislationService {
+
+    Object search(String content, int from, int size);
+}

+ 4 - 7
src/main/java/com/winhc/phoenix/example/service/impl/JudgmentDocumentsServiceImpl.java

@@ -23,7 +23,6 @@ import org.springframework.stereotype.Service;
 
 import java.util.*;
 
-import static com.winhc.phoenix.example.util.QueryBuilderUtils.existField;
 import static com.winhc.phoenix.example.util.QueryBuilderUtils.spanNearQuery4StandardAnalyzer;
 import static org.elasticsearch.index.query.QueryBuilders.*;
 
@@ -92,7 +91,7 @@ public class JudgmentDocumentsServiceImpl implements JudgmentDocumentsService {
         }
 
 
-        boolQuery.filter(existField("court_level", Arrays.asList("", "-1")));
+//        boolQuery.filter(existField("court_level", Arrays.asList("", "-1")));
 
 
         int from = searchContent.getFrom();
@@ -119,16 +118,14 @@ public class JudgmentDocumentsServiceImpl implements JudgmentDocumentsService {
                     ScriptSortBuilder order = SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.DESC);
                     sortBuilders.add(order);
                 }
-
-                FieldSortBuilder order = SortBuilders.fieldSort("case_score").order(SortOrder.DESC);
-                sortBuilders.add(order);
             }
+            FieldSortBuilder order = SortBuilders.fieldSort("case_score").order(SortOrder.DESC);
+            sortBuilders.add(order);
         }
         List<AggregationBuilder> aggList = null;
         if (QueryOrAgg.AGG.equals(searchContent.getQueryOrAgg())) {
             aggList = agg();
-            from = 0;
-            size = 0;
+            from = size = 0;
         } else if (QueryOrAgg.QUERY_AND_AGG.equals(searchContent.getQueryOrAgg())) {
             aggList = agg();
         }

Datei-Diff unterdrückt, da er zu groß ist
+ 94 - 0
src/main/java/com/winhc/phoenix/example/service/impl/LegislationServiceImpl.java


+ 10 - 0
src/main/resources/application.yml

@@ -4,6 +4,16 @@ spring:
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: GMT+8
+
+  thymeleaf:
+    prefix: classpath:/templates/
+    check-template-location: true
+    cache: false
+    suffix: .html
+    encoding: UTF-8
+    content-type: text/html
+    mode: HTML5
+
 server:
   port: 8288
 

+ 116 - 0
src/main/resources/static/js/xjk.js

@@ -0,0 +1,116 @@
+function highlight() {
+
+}
+function tags_func() {
+
+}
+function option() {
+
+}
+
+let m = {
+    "cname.value": "名称",
+    "cname.show": "名称",
+    "name_alias": "字号",
+    "cname.show.keyword": "名称",
+    "cname.value.pinyin": "名称拼音",
+    "cname.show.pinyin": "名称拼音",
+    "history_name.value": "曾用名",
+    "history_name.show": "曾用名",
+    "history_name.value.pinyin": "曾用名拼音",
+    "history_name.show.pinyin": "曾用名拼音",
+    "legal_entity_name": "法人",
+    "holder.name": "股东",
+    "holder_history.name": "历史股东",
+    "staff.name": "主要成员",
+    "staff_history.name": "历史主要成员",
+    "company_tm": "商标",
+    "app_info": "产品",
+    "icp": "ICP",
+    "icp_domain": "网址",
+    "icp_domain.keyword": "网址",
+    "emails": "邮箱",
+    "emails.keyword": "邮箱",
+    "phones": "电话",
+    "reg_number": "工商注册号",
+    "reg_location": "注册地址",
+    "reg_location.keyword": "注册地址",
+    "org_number": "组织机构代码",
+    "credit_code": "统一信用代码",
+}
+
+
+for (const mKey in m) {
+    console.log('put("'+mKey+'","'+m[mKey]+'");')
+}
+
+
+
+
+let a = [
+    {
+        title: 'id',
+        field: 'company_id',
+        visible: false
+    },
+    {
+        title: '公司id',
+        field: 'company_id',
+
+    },
+    {
+        title: '公司名称',
+        field: 'company_name',
+    },
+    {
+        title: '法定代表人',
+        field: 'legal_entity_name',
+    },
+    {
+        title: '来源',
+        field: 'highlight',
+        formatter: highlight
+    },
+    {
+        title: '标签',
+        field: 'company_id',
+        formatter: tags_func
+    },
+    {
+        title: 'company_rank',
+        field: 'company_rank',
+    },
+    {
+        title: 'company_rank_sec',
+        field: 'company_rank_sec',
+    },
+    {
+        title: 'company_score_weight',
+        field: 'company_score_weight',
+    },
+    {
+        title: '排序分',
+        field: 'score',
+    }
+    , {
+        title: '操作',
+        field: 'record',
+        formatter: option
+    }
+
+]
+
+a.map(function (value, index, array){
+    if(value.visible==false){
+        console.log('new ColumnInfo("'+value.title+'","'+value.field+'").hide(),')
+    }else if(value.formatter !=null){
+        console.log('new ColumnInfo("'+value.title+'","'+value.field+'","'+value.formatter.name+'"),')
+    }
+    else{
+        console.log('new ColumnInfo("'+value.title+'","'+value.field+'"),')
+    }
+
+})
+
+
+

+ 0 - 4
src/main/resources/static/search-company.html

@@ -15,10 +15,6 @@
 
 <div id="search">
     <div id="search-wrap">
-        <!-- <select id="search-select" class="search-choise">
-             <option></option>
-             <option>资源</option>
-         </select>-->
         <input id="search-content" class="search-content" type="text" placeholder="输入搜索内容" name="word">
         <button class="search-btn" type="submit" onclick="search()">搜索</button>
     </div>

+ 295 - 0
src/main/resources/static/search-fg.html

@@ -0,0 +1,295 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8"/>
+    <title>法规查询</title>
+    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
+    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap-table/1.15.4/bootstrap-table.min.css">
+    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
+    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
+    <script src="https://cdn.bootcss.com/bootstrap-table/1.15.4/bootstrap-table.min.js"></script>
+    <script src="https://cdn.bootcss.com/bootstrap-table/1.15.4/locale/bootstrap-table-zh-CN.min.js"></script>
+    <script src="js/base64.min.js"></script>
+    <link href="https://cdn.bootcss.com/bootstrap-switch/4.0.0-alpha.1/css/bootstrap-switch.min.css" rel="stylesheet">
+    <script src="https://cdn.bootcss.com/bootstrap-switch/4.0.0-alpha.1/js/bootstrap-switch.min.js"></script>
+</head>
+<body>
+
+<div id="search">
+    <div id="search-wrap">
+        <input id="search-content" class="search-content" type="text" placeholder="输入搜索内容" name="word">
+        <button class="search-btn" type="submit" onclick="search()">搜索</button>
+    </div>
+</div>
+
+
+<br>
+
+
+<div id="model">
+
+</div>
+<br>
+<table id="search-result" class="table table-hover"></table>
+<script>
+    let flag = false;
+
+    function init() {
+        $('#search-result').bootstrapTable({
+            method: 'get',
+            url: "http://xjk:8288/legislation/query", // 请求路径
+            striped: true, // 是否显示行间隔色
+            pageNumber: 1, // 初始化加载第一页
+            pagination: true, // 是否分页
+            sidePagination: 'server', // server:服务器端分页|client:前端分页
+            pageSize: 10, // 单页记录数
+            pageList: [10, 20, 30],
+            /* onClickRow: function (row, value, r, index) {
+                 console.log("click :")
+                 record_click(row.record, row, index)
+             },*/
+            queryParams: function (params) { // 上传服务器的参数
+                var temp = {
+                    content: $("#search-content").val(),
+                    size: params.limit,
+                    from: params.offset,
+                };
+                console.log(temp)
+                return temp;
+            },
+            onLoadSuccess: function () {  //加载成功时执行
+                // alert("加载数据成功");
+            },
+            onLoadError: function () {  //加载失败时执行
+                alert("加载数据失败");
+            },
+            responseHandler: function (res) {
+                console.log(res.hits.hits)
+                console.log('查询耗时:', res.took)
+                var rows = res.hits.hits.map(function (value, index, array) {
+                    return {
+                        "id": value._id,
+                        "title": value._source.title,
+                        "effect": value._source.effect,
+                        "timeliness": value._source.timeliness,
+                        "implement_date": value._source.implement_date,
+                        "publish_date": value._source.publish_date,
+                        "agency": value._source.agency,
+                        "score": value._score,
+                        "record": value._source,
+                        "highlight": value.highlight,
+                    };
+                });
+                $("#model").html('召回数量:' + res.hits.total + "<br/>查询耗时:" + res.took)
+                return {
+                    "total": res.hits.total,
+                    "rows": rows
+                }
+            },
+            columns: [
+                {
+                    title: 'id',
+                    field: 'id',
+                    visible: false
+                },
+                {
+                    title: '法规id',
+                    field: 'id',
+
+                },
+                {
+                    title: '法规名称',
+                    field: 'title',
+                },
+                {
+                    title: '文件类型',
+                    field: 'effect',
+                },
+                {
+                    title: '时效',
+                    field: 'timeliness',
+                },
+                {
+                    title: '来源',
+                    field: 'highlight',
+                    formatter: highlight
+                },
+
+                {
+                    title: '发布日期',
+                    field: 'publish_date',
+                },
+                {
+                    title: '实施日期',
+                    field: 'implement_date',
+                },
+                {
+                    title: '排序分',
+                    field: 'score',
+                }
+                , {
+                    title: '操作',
+                    field: 'record',
+                    formatter: option
+                }
+
+            ]
+        })
+        flag = true
+    }
+
+
+    $("#search").keypress(function (event) {
+        if (event.which === 13) {
+            search();
+        }
+    })
+
+    function highlight(value, row, index) {
+        let m = {
+            "title.keyword": "标题",
+            "title": "标题",
+            "content": "正文",
+
+        }
+        if (!value) {
+            return '';
+        }
+        let htm =
+            '<div class="row my-label" style="overflow:scroll;overflow-y:hidden">'
+
+        for (let mKey in m) {
+            if (value[mKey]) {
+                let s = value[mKey].map(function (v, i, a) {
+                    v = v.replaceAll(")", ")").replaceAll("(", "(");
+                    if (v.indexOf("</font>)<font class='my-bold'>") > 0 && v.indexOf("</font>(<font class='my-bold'>") > 0) {
+                        v = v.replaceAll("</font>)<font class='my-bold'>", ")").replaceAll("</font>(<font class='my-bold'>", "(")
+                    }
+                    return '<span class="my-badge">' + v + '</span>'
+                }).join(',')
+                s = s.replaceAll("<font class='my-bold'>",'\001');
+                s = s.replaceAll("</font>",'\002');
+                s = s.replace(/<[^>]+>/g,"");;
+
+                s = s.replaceAll('\001',"<font class='my-bold'>");
+                s = s.replaceAll('\002',"</font>");
+
+                htm += '<p>' + m[mKey] + ':' + s + '</p>'
+            }
+        }
+        htm += '</div>'
+        return htm;
+    }
+
+
+
+
+    // 定义删除、更新按钮
+    function option(value, row, index) {
+        var p = 'https://www.winhc.cn/searchLawRule/' + Base64.encodeURI(row.id);
+        return '<button class="btn btn-primary btn-lg" onclick="javascript:window.open(\'' + p + '\')">详情</button>';
+    }
+
+    function search() {
+        if (!flag) {
+            console.info('init...')
+            init()
+        } else {
+            console.info('search...')
+            $('#search-result').bootstrapTable('refresh', {pageSize: 10, pageNumber: 1});
+        }
+    }
+
+
+</script>
+
+<style>
+    #search {
+        position: relative;
+        width: 680px;
+        height: 160px;
+        left: 30px;
+        top: 60px;
+        margin: 0 auto;
+    }
+
+    #search-wrap {
+        position: absolute;
+        /* margin-top: -10px; */
+        width: 460px;
+        height: 36px;
+        margin-left: 16px;
+        border-radius: 18px;
+        box-shadow: 0 0 3px rgba(0, 0, 0, .14);
+        background-color: #FFF;
+
+    }
+
+    #search-wrap .search-content {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+        margin-top: 3px;
+        margin-left: 18px;
+        width: 298px;
+        height: 30px;
+    }
+
+    .my-label {
+        margin-left: 2px;
+    }
+
+    .my-bold {
+        font-weight: bold;
+        color: black;
+    }
+
+    .my-badge {
+        display: inline-block;
+        min-width: 10px;
+        padding: 3px 7px;
+        font-size: 12px;
+        font-weight: 700;
+        line-height: 1;
+        color: #fff;
+        text-align: center;
+        white-space: nowrap;
+        vertical-align: baseline;
+        background-color: #49AF4F;
+        border-radius: 10px;
+    }
+
+    #search-wrap .search-choise {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-choise option {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-btn {
+        border: 0px;
+        float: right;
+        /* margin: 4px 4px 4px 0; */
+        width: 66px;
+        outline: none;
+        height: 36px;
+        border-radius: 0px 18px 18px 0px;
+        background-color: #49AF4F;
+        color: #FFF;
+        text-align: center;
+        line-height: 28px;
+    }
+</style>
+</body>
+
+</html>

+ 331 - 328
src/main/resources/static/search-wenshu.html

@@ -66,357 +66,360 @@
         <table id="search-result" class="table table-hover"></table>
     </div>
 
-
-    <script>
-        let authorityCase = false;
-        let notSort = false;
-        $("[name='my-checkbox']").bootstrapSwitch({
-            onText: "普通案例",      // 设置ON文本
-            offText: "权威案例",    // 设置OFF文本
-            onColor: "success",// 设置ON文本颜色(info/success/warning/danger/primary)
-            offColor: "info",  // 设置OFF文本颜色 (info/success/warning/danger/primary)
-            size: "large",    // 设置控件大小,从小到大  (mini/small/normal/large)
-            // 当开关状态改变时触发
-            onSwitchChange: function (event, state) {
-                if (state == true) {
-                    authorityCase = false;
-                } else {
-                    authorityCase = true;
-                }
+</div>
+
+
+
+<script>
+    let authorityCase = false;
+    let notSort = false;
+    $("[name='my-checkbox']").bootstrapSwitch({
+        onText: "普通案例",      // 设置ON文本
+        offText: "权威案例",    // 设置OFF文本
+        onColor: "success",// 设置ON文本颜色(info/success/warning/danger/primary)
+        offColor: "info",  // 设置OFF文本颜色 (info/success/warning/danger/primary)
+        size: "large",    // 设置控件大小,从小到大  (mini/small/normal/large)
+        // 当开关状态改变时触发
+        onSwitchChange: function (event, state) {
+            if (state == true) {
+                authorityCase = false;
+            } else {
+                authorityCase = true;
             }
-        });
-        $("[name='sort-checkbox']").bootstrapSwitch({
-            onText: "排序",      // 设置ON文本
-            offText: "不排序",    // 设置OFF文本
-            onColor: "success",// 设置ON文本颜色(info/success/warning/danger/primary)
-            offColor: "warning",  // 设置OFF文本颜色 (info/success/warning/danger/primary)
-            size: "large",    // 设置控件大小,从小到大  (mini/small/normal/large)
-            // 当开关状态改变时触发
-            onSwitchChange: function (event, state) {
-                if (state == true) {
-                    notSort = false;
-                } else {
-                    notSort = true;
-                }
+        }
+    });
+    $("[name='sort-checkbox']").bootstrapSwitch({
+        onText: "排序",      // 设置ON文本
+        offText: "不排序",    // 设置OFF文本
+        onColor: "success",// 设置ON文本颜色(info/success/warning/danger/primary)
+        offColor: "warning",  // 设置OFF文本颜色 (info/success/warning/danger/primary)
+        size: "large",    // 设置控件大小,从小到大  (mini/small/normal/large)
+        // 当开关状态改变时触发
+        onSwitchChange: function (event, state) {
+            if (state == true) {
+                notSort = false;
+            } else {
+                notSort = true;
             }
-        });
-        let flag = false;
-
-        function init() {
-            $('#search-result').bootstrapTable({
-                method: 'post',
-                dataType: "json",
-                // url: "http://xjk:8288/judgment/query", // 请求路径
-                url: "/judgment/query", // 请求路径
-                striped: true, // 是否显示行间隔色
-                pageNumber: 1, // 初始化加载第一页
-                pagination: true, // 是否分页
-                sidePagination: 'server', // server:服务器端分页|client:前端分页
-                pageSize: 10, // 单页记录数
-                pageList: [10, 20, 30],
-                /* onClickRow: function (row, value, r, index) {
-                     console.log("click :")
-                     record_click(row.record, row, index)
-                 },*/
-                queryParams: function (params) { // 上传服务器的参数
-                    let map = {}
-                    let search_list = $('#search-list').children();
-                    for (let i = 0; i < search_list.length; i++) {
-                        map[search_list[i].getAttribute('search_content').trim()] = search_list[i].getAttribute('search_enum').trim();
-                    }
-                    var temp = {
-                        content: map,
-                        authorityCase: authorityCase,
-                        sort: notSort ? "NOT_SORT" : null,
-                        size: params.limit,
-                        from: params.offset,
+        }
+    });
+    let flag = false;
+
+    function init() {
+        $('#search-result').bootstrapTable({
+            method: 'post',
+            dataType: "json",
+            // url: "http://xjk:8288/judgment/query", // 请求路径
+            url: "/judgment/query", // 请求路径
+            striped: true, // 是否显示行间隔色
+            pageNumber: 1, // 初始化加载第一页
+            pagination: true, // 是否分页
+            sidePagination: 'server', // server:服务器端分页|client:前端分页
+            pageSize: 10, // 单页记录数
+            pageList: [10, 20, 30],
+            /* onClickRow: function (row, value, r, index) {
+                 console.log("click :")
+                 record_click(row.record, row, index)
+             },*/
+            queryParams: function (params) { // 上传服务器的参数
+                let map = {}
+                let search_list = $('#search-list').children();
+                for (let i = 0; i < search_list.length; i++) {
+                    map[search_list[i].getAttribute('search_content').trim()] = search_list[i].getAttribute('search_enum').trim();
+                }
+                var temp = {
+                    content: map,
+                    authorityCase: authorityCase,
+                    sort: notSort ? "NOT_SORT" : null,
+                    size: params.limit,
+                    from: params.offset,
+                };
+                console.log(temp)
+                return temp;
+            },
+            onLoadSuccess: function () {  //加载成功时执行
+                // alert("加载数据成功");
+            },
+            onLoadError: function () {  //加载失败时执行
+                alert("加载数据失败");
+            },
+            responseHandler: function (res) {
+                console.log(res.hits.hits)
+                console.log('查询耗时:', res.took)
+                var rows = res.hits.hits.map(function (value, index, array) {
+                    return {
+                        "doc_id": value._id,
+                        "title": value._source.title,
+                        "case_no": value._source.case_no,
+                        "court_name": value._source.court_name,
+                        "judge_date": value._source.judge_date ? value._source.judge_date.split(' ')[0] : value._source.judge_date,
+                        "score": value._score,
+                        "record": value._source,
+                        "highlight": value.highlight,
                     };
-                    console.log(temp)
-                    return temp;
+                });
+                $("#model").html('召回数量:' + res.hits.total + "<br/>查询耗时:" + res.took)
+                return {                            //return bootstrap-table能处理的数据格式
+                    "total": res.hits.total,
+                    "rows": rows
+                }
+            },
+            columns: [
+                {
+                    title: 'id',
+                    field: 'doc_id',
+                    visible: false
                 },
-                onLoadSuccess: function () {  //加载成功时执行
-                    // alert("加载数据成功");
+                {
+                    title: '案件doc_id',
+                    field: 'doc_id',
+
                 },
-                onLoadError: function () {  //加载失败时执行
-                    alert("加载数据失败");
+                {
+                    title: 'title',
+                    field: 'title',
                 },
-                responseHandler: function (res) {
-                    console.log(res.hits.hits)
-                    console.log('查询耗时:', res.took)
-                    var rows = res.hits.hits.map(function (value, index, array) {
-                        return {
-                            "doc_id": value._id,
-                            "title": value._source.title,
-                            "case_no": value._source.case_no,
-                            "court_name": value._source.court_name,
-                            "judge_date": value._source.judge_date ? value._source.judge_date.split(' ')[0] : value._source.judge_date,
-                            "score": value._score,
-                            "record": value._source,
-                            "highlight": value.highlight,
-                        };
-                    });
-                    $("#model").html('召回数量:' + res.hits.total + "<br/>查询耗时:" + res.took)
-                    return {                            //return bootstrap-table能处理的数据格式
-                        "total": res.hits.total,
-                        "rows": rows
-                    }
+                {
+                    title: '案号',
+                    field: 'case_no',
                 },
-                columns: [
-                    {
-                        title: 'id',
-                        field: 'doc_id',
-                        visible: false
-                    },
-                    {
-                        title: '案件doc_id',
-                        field: 'doc_id',
-
-                    },
-                    {
-                        title: 'title',
-                        field: 'title',
-                    },
-                    {
-                        title: '案号',
-                        field: 'case_no',
-                    },
-                    {
-                        title: '来源',
-                        field: 'highlight',
-                        formatter: highlight,
-                        cellStyle: formatTableUnit,
-                        // formatter :paramsMatter,
-                    },
-                    {
-                        title: '法院',
-                        field: 'court_name',
-                    },
-                    {
-                        title: '审理日期',
-                        field: 'judge_date',
-                    },
-                    // {
-                    //     title: '排序分',
-                    //     field: 'score',
-                    // } ,
-                    {
-                        title: '操作',
-                        field: 'record',
-                        formatter: option
-                    }
-
-                ]
-            })
-            flag = true
-        }
-
+                {
+                    title: '来源',
+                    field: 'highlight',
+                    formatter: highlight,
+                    cellStyle: formatTableUnit,
+                    // formatter :paramsMatter,
+                },
+                {
+                    title: '法院',
+                    field: 'court_name',
+                },
+                {
+                    title: '审理日期',
+                    field: 'judge_date',
+                },
+                // {
+                //     title: '排序分',
+                //     field: 'score',
+                // } ,
+                {
+                    title: '操作',
+                    field: 'record',
+                    formatter: option
+                }
 
-        $("#search").keypress(function (event) {
-            if (event.which === 13) {
-                search(true);
-            }
+            ]
         })
+        flag = true
+    }
 
-        $("[name='click_menu']").click(function () {
-            $('#search-scope').text($(this).text());
-            $('#search-scope').attr('enum_value', $(this).attr('enum_value'));
-        });
-
-
-        function highlight(value, row, index) {
-            let m = {
-                "addenda": "附录文本",
-                "case_no": "案号",
-                "case_no.keyword": "案号",
-                "clerk": "书记员",
-                "court_name.keyword": "法院",
-                "court_name": "法院",
-                "court_view": "法院观点",
-                "fact": "审理经过",
-                "judge": "承办法官",
-                "judge_result": "裁判结果",
-                "party_info": "当事人",
-                "title": "标题",
-            }
-            if (!value) {
-                return '';
-            }
-            let htm =
-                '<div class="row my-label" style="overflow:scroll;overflow-y:hidden">'
-
-            for (let mKey in m) {
-                if (value[mKey]) {
-                    let s = value[mKey].map(function (v, i, a) {
-                        v = v.replaceAll(")", ")").replaceAll("(", "(");
-                        if (v.indexOf("</font>)<font class='my-bold'>") > 0 && v.indexOf("</font>(<font class='my-bold'>") > 0) {
-                            v = v.replaceAll("</font>)<font class='my-bold'>", ")").replaceAll("</font>(<font class='my-bold'>", "(")
-                        }
-                        return '<span class="my-badge">' + v + '</span>'
-                    }).join(',')
-                    htm += '<p>' + m[mKey] + ':' + s + '</p>'
-                }
-            }
-            htm += '</div>'
-            return htm;
-        }
 
-        // 定义删除、更新按钮
-        function option(value, row, index) {
-            console.log(row.doc_id)
-            var p = 'https://www.winhc.cn/searchCase/' + Base64.encodeURI(row.doc_id);
-            return '<button class="btn btn-primary btn-lg" onclick="javascript:window.open(\'' + p + '\')">详情</button>';
+    $("#search").keypress(function (event) {
+        if (event.which === 13) {
+            search(true);
         }
-
-
-        function search(clear = false) {
-
-            let search_scope = $('#search-scope').text();
-            let search_enum = $('#search-scope').attr('enum_value');
-            let search_content = $('#search-content').val();
-            if (search_content !== '') {
-                if (clear) {
-                    $('#search-list').empty();
-                }
-                $('#search-list').html($('#search-list').html() + ' <span class="my-badge" search_enum="' + search_enum + '" search_content="' + search_content + '">' + search_scope + ': ' + search_content + '</span>')
-            }
-
-            if (!flag) {
-                console.info('init...')
-                init()
-            } else {
-                console.info('search...')
-                $('#search-result').bootstrapTable('refresh', {pageSize: 10, pageNumber: 1});
-            }
-            $('#search-scope').text('全部内容');
-            $('#search-scope').attr('enum_value', 'ALL');
-            $('#search-content').val("");
+    })
+
+    $("[name='click_menu']").click(function () {
+        $('#search-scope').text($(this).text());
+        $('#search-scope').attr('enum_value', $(this).attr('enum_value'));
+    });
+
+
+    function highlight(value, row, index) {
+        let m = {
+            "addenda": "附录文本",
+            "case_no": "案号",
+            "case_no.keyword": "案号",
+            "clerk": "书记员",
+            "court_name.keyword": "法院",
+            "court_name": "法院",
+            "court_view": "法院观点",
+            "fact": "审理经过",
+            "judge": "承办法官",
+            "judge_result": "裁判结果",
+            "party_info": "当事人",
+            "title": "标题",
         }
-
-        //表格超出宽度鼠标悬停显示td内容
-        function paramsMatter(value, row, index) {
-            let m = {
-                "addenda": "附录文本",
-                "case_no": "案号",
-                "case_no.keyword": "案号",
-                "clerk": "书记员",
-                "court_name.keyword": "法院",
-                "court_name": "法院",
-                "court_view": "法院观点",
-                "fact": "审理经过",
-                "judge": "承办法官",
-                "judge_result": "裁判结果",
-                "party_info": "当事人",
-                "title": "标题",
-            }
-            if (!value) {
-                return '';
-            }
-            let htm =
-                '<div class="row my-label" style="overflow:scroll;">'
-
-            for (let mKey in m) {
-                if (value[mKey]) {
-                    let s = value[mKey].map(function (v, i, a) {
-                        v = v.replaceAll(")", ")").replaceAll("(", "(");
-                        if (v.indexOf("</font>)<font class='my-bold'>") > 0 && v.indexOf("</font>(<font class='my-bold'>") > 0) {
-                            v = v.replaceAll("</font>)<font class='my-bold'>", ")").replaceAll("</font>(<font class='my-bold'>", "(")
-                        }
-                        return '<span class="my-badge">' + v + '</span>'
-                    }).join(',')
-                    htm += '<p>' + m[mKey] + ':' + s + '</p>'
-                }
-            }
-            htm += '</div>'
-
-
-            var span = document.createElement("span");
-            span.setAttribute("title", htm);
-            span.innerHTML = htm;
-            return span.outerHTML;
+        if (!value) {
+            return '';
         }
-
-        //td宽度以及内容超过宽度隐藏
-        function formatTableUnit(value, row, index) {
-            return {
-                css: {
-                    "white-space": "nowrap",
-                    "text-overflow": "ellipsis",
-                    "overflow": "hidden",
-                    "max-width": "240px"
-                }
+        let htm =
+            '<div class="row my-label" style="overflow:scroll;overflow-y:hidden">'
+
+        for (let mKey in m) {
+            if (value[mKey]) {
+                let s = value[mKey].map(function (v, i, a) {
+                    v = v.replaceAll(")", ")").replaceAll("(", "(");
+                    if (v.indexOf("</font>)<font class='my-bold'>") > 0 && v.indexOf("</font>(<font class='my-bold'>") > 0) {
+                        v = v.replaceAll("</font>)<font class='my-bold'>", ")").replaceAll("</font>(<font class='my-bold'>", "(")
+                    }
+                    return '<span class="my-badge">' + v + '</span>'
+                }).join(',')
+                htm += '<p>' + m[mKey] + ':' + s + '</p>'
             }
         }
-
-
-    </script>
-
-    <style>
-
-        #search-wrap .search-content {
-            box-shadow: none;
-            border: 0 none;
-            outline: none;
-            font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
-            margin-top: 3px;
-            margin-left: 18px;
-            width: 298px;
-            height: 30px;
-        }
-
-        .my-label {
-            margin-left: 2px;
+        htm += '</div>'
+        return htm;
+    }
+
+    // 定义删除、更新按钮
+    function option(value, row, index) {
+        console.log(row.doc_id)
+        var p = 'https://www.winhc.cn/searchCase/' + Base64.encodeURI(row.doc_id);
+        return '<button class="btn btn-primary btn-lg" onclick="javascript:window.open(\'' + p + '\')">详情</button>';
+    }
+
+
+    function search(clear = false) {
+
+        let search_scope = $('#search-scope').text();
+        let search_enum = $('#search-scope').attr('enum_value');
+        let search_content = $('#search-content').val();
+        if (search_content !== '') {
+            if (clear) {
+                $('#search-list').empty();
+            }
+            $('#search-list').html($('#search-list').html() + ' <span class="my-badge" search_enum="' + search_enum + '" search_content="' + search_content + '">' + search_scope + ': ' + search_content + '</span>')
         }
 
-        .my-bold {
-            font-weight: bold;
-            color: black;
+        if (!flag) {
+            console.info('init...')
+            init()
+        } else {
+            console.info('search...')
+            $('#search-result').bootstrapTable('refresh', {pageSize: 10, pageNumber: 1});
         }
-
-        .my-badge {
-            display: inline-block;
-            min-width: 10px;
-            padding: 3px 7px;
-            font-size: 12px;
-            font-weight: 700;
-            line-height: 1;
-            color: #fff;
-            text-align: center;
-            white-space: nowrap;
-            vertical-align: baseline;
-            background-color: #49AF4F;
-            border-radius: 10px;
+        $('#search-scope').text('全部内容');
+        $('#search-scope').attr('enum_value', 'ALL');
+        $('#search-content').val("");
+    }
+
+    //表格超出宽度鼠标悬停显示td内容
+    function paramsMatter(value, row, index) {
+        let m = {
+            "addenda": "附录文本",
+            "case_no": "案号",
+            "case_no.keyword": "案号",
+            "clerk": "书记员",
+            "court_name.keyword": "法院",
+            "court_name": "法院",
+            "court_view": "法院观点",
+            "fact": "审理经过",
+            "judge": "承办法官",
+            "judge_result": "裁判结果",
+            "party_info": "当事人",
+            "title": "标题",
         }
-
-        #search-wrap .search-choise {
-            box-shadow: none;
-            border: 0 none;
-            outline: none;
-            margin-left: 18px;
-            font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+        if (!value) {
+            return '';
         }
-
-        #search-wrap .search-choise option {
-            box-shadow: none;
-            border: 0 none;
-            outline: none;
-            margin-left: 18px;
-            font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+        let htm =
+            '<div class="row my-label" style="overflow:scroll;">'
+
+        for (let mKey in m) {
+            if (value[mKey]) {
+                let s = value[mKey].map(function (v, i, a) {
+                    v = v.replaceAll(")", ")").replaceAll("(", "(");
+                    if (v.indexOf("</font>)<font class='my-bold'>") > 0 && v.indexOf("</font>(<font class='my-bold'>") > 0) {
+                        v = v.replaceAll("</font>)<font class='my-bold'>", ")").replaceAll("</font>(<font class='my-bold'>", "(")
+                    }
+                    return '<span class="my-badge">' + v + '</span>'
+                }).join(',')
+                htm += '<p>' + m[mKey] + ':' + s + '</p>'
+            }
         }
-
-        #search-wrap .search-btn {
-            border: 0px;
-            float: right;
-            /* margin: 4px 4px 4px 0; */
-            width: 66px;
-            outline: none;
-            height: 36px;
-            border-radius: 0px 18px 18px 0px;
-            background-color: #49AF4F;
-            color: #FFF;
-            text-align: center;
-            line-height: 28px;
+        htm += '</div>'
+
+
+        var span = document.createElement("span");
+        span.setAttribute("title", htm);
+        span.innerHTML = htm;
+        return span.outerHTML;
+    }
+
+    //td宽度以及内容超过宽度隐藏
+    function formatTableUnit(value, row, index) {
+        return {
+            css: {
+                "white-space": "nowrap",
+                "text-overflow": "ellipsis",
+                "overflow": "hidden",
+                "max-width": "240px"
+            }
         }
-    </style>
+    }
+
+
+</script>
+
+<style>
+
+    #search-wrap .search-content {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+        margin-top: 3px;
+        margin-left: 18px;
+        width: 298px;
+        height: 30px;
+    }
+
+    .my-label {
+        margin-left: 2px;
+    }
+
+    .my-bold {
+        font-weight: bold;
+        color: black;
+    }
+
+    .my-badge {
+        display: inline-block;
+        min-width: 10px;
+        padding: 3px 7px;
+        font-size: 12px;
+        font-weight: 700;
+        line-height: 1;
+        color: #fff;
+        text-align: center;
+        white-space: nowrap;
+        vertical-align: baseline;
+        background-color: #49AF4F;
+        border-radius: 10px;
+    }
+
+    #search-wrap .search-choise {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-choise option {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-btn {
+        border: 0px;
+        float: right;
+        /* margin: 4px 4px 4px 0; */
+        width: 66px;
+        outline: none;
+        height: 36px;
+        border-radius: 0px 18px 18px 0px;
+        background-color: #49AF4F;
+        color: #FFF;
+        text-align: center;
+        line-height: 28px;
+    }
+</style>
 </body>
 
 </html>

+ 220 - 0
src/main/resources/templates/search-templates.html

@@ -0,0 +1,220 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8"/>
+    <title th:text="${title}"></title>
+    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
+    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap-table/1.15.4/bootstrap-table.min.css">
+    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
+    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
+    <script src="https://cdn.bootcss.com/bootstrap-table/1.15.4/bootstrap-table.min.js"></script>
+    <script src="https://cdn.bootcss.com/bootstrap-table/1.15.4/locale/bootstrap-table-zh-CN.min.js"></script>
+    <script src="/js/base64.min.js"></script>
+    <link href="https://cdn.bootcss.com/bootstrap-switch/4.0.0-alpha.1/css/bootstrap-switch.min.css" rel="stylesheet">
+    <script src="https://cdn.bootcss.com/bootstrap-switch/4.0.0-alpha.1/js/bootstrap-switch.min.js"></script>
+</head>
+<body>
+
+
+
+<div id="search" style="margin-top:80px;margin-left: 80px;margin-right: 80px">
+    <div class="container">
+        <div class="row .col-md-3">
+            <xjk id="search-form">
+
+            </xjk>
+        </div>
+    </div>
+
+
+    <xjk id="history-form">
+
+    </xjk>
+
+
+    <br>
+
+    <div class="row">
+        <div id="model">
+        </div>
+    </div>
+
+    <div class="row">
+        <table id="search-result" class="table table-hover"></table>
+    </div>
+
+</div>
+
+
+
+<script type="text/javascript" th:inline="javascript">
+    $("#search-form").html([[${formHtml}]])
+    $("#history-form").html([[${historyForm}]])
+    let tmpStr = "";
+    if([[${method}]]=='POST'||[[${method}]]=='post'){
+        tmpStr='dataType: "json",\n';
+    }
+
+    var  myScript=  document.createElement("script");
+    myScript.type  =  "text/javascript";
+    var scriptStr =
+        "function init() {\n" +
+        "$('#search-result').bootstrapTable({\n" +
+        "            method: '" +[[${method}]]+
+        "',\n" +
+        tmpStr+
+        "            url: \""+[[${url}]] +
+        "\", \n" +
+        "            striped: true, \n" +
+        "            pageNumber: 1, \n" +
+        "            pagination: true, \n" +
+        "            sidePagination: 'server', \n" +
+        "            pageSize: 10, \n" +
+        "            pageList: [10, 20, 30],\n" +
+        "\n" +
+        "            queryParams: queryParamsFunc,\n" +
+        "            onLoadSuccess: function () {  //加载成功时执行\n" +
+        "                // alert(\"加载数据成功\");\n" +
+        "            },\n" +
+        "            onLoadError: function () {  //加载失败时执行\n" +
+        "                alert(\"加载数据失败\");\n" +
+        "            },\n" +
+        "            responseHandler: responseHandlerFunc,\n" +
+        "            columns: "+[[${columnsJs}]] +
+        "        })\n" +
+        "        flag = true\n" +
+        "    }\n" +
+        "\n" +
+
+
+        "    function highlight(value, row, index) {\n" +
+        "        let m = "+[[${highlightMapping}]] +";\n"+
+        "        if (!value) {\n" +
+        "            return '';\n" +
+        "        }\n" +
+        "        let htm =\n" +
+        "            '<div class=\"row my-label\" style=\"overflow:scroll;overflow-y:hidden\">'\n" +
+        "\n" +
+        "        for (let mKey in m) {\n" +
+        "            if (value[mKey]) {\n" +
+        "                let s = value[mKey].map(function (v, i, a) {\n" +
+        "                    v = v.replaceAll(\")\", \")\").replaceAll(\"(\", \"(\");\n" +
+        "                    if (v.indexOf(\"</font>)<font class='my-bold'>\") > 0 && v.indexOf(\"</font>(<font class='my-bold'>\") > 0) {\n" +
+        "                        v = v.replaceAll(\"</font>)<font class='my-bold'>\", \")\").replaceAll(\"</font>(<font class='my-bold'>\", \"(\")\n" +
+        "                    }\n" +
+        "                    return '<span class=\"my-badge\">' + v + '</span>'\n" +
+        "                }).join(',')\n" +
+        "                s = s.replaceAll(\"<font class='my-bold'>\",'\\001');\n" +
+        "                s = s.replaceAll(\"</font>\",'\\002');\n" +
+        "                s = s.replace(/<[^>]+>/g,\"\");;\n" +
+        "\n" +
+        "                s = s.replaceAll('\\001',\"<font class='my-bold'>\");\n" +
+        "                s = s.replaceAll('\\002',\"</font>\");\n" +
+        "\n" +
+        "                htm += '<p>' + m[mKey] + ':' + s + '</p>'\n" +
+        "            }\n" +
+        "        }\n" +
+        "        htm += '</div>'\n" +
+        "        return htm;\n" +
+        "    }\n"
+       ;
+
+
+    scriptStr+= [[${responseHandlerFunc}]];
+    scriptStr+= [[${queryParamsFunc}]];
+    scriptStr+= [[${jsFunction}]];
+    scriptStr+= 'function initJs() {\n'+[[${initJs}]]+'\n}';
+
+
+    myScript.text=scriptStr;
+    document.body.appendChild(myScript);
+    initJs();
+</script>
+<script type="text/javascript" >
+    let flag = false;
+    $("#search").keypress(function (event) {
+        if (event.which === 13) {
+            search();
+        }
+    })
+    function search() {
+        if (!flag) {
+            console.info('init...')
+            init()
+        } else {
+            console.info('search...')
+            $('#search-result').bootstrapTable('refresh', {pageSize: 10, pageNumber: 1});
+        }
+    }
+</script>
+
+
+<style>
+    #search-wrap .search-content {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+        margin-top: 3px;
+        margin-left: 18px;
+        width: 298px;
+        height: 30px;
+    }
+
+    .my-label {
+        margin-left: 2px;
+    }
+
+    .my-bold {
+        font-weight: bold;
+        color: black;
+    }
+
+    .my-badge {
+        display: inline-block;
+        min-width: 10px;
+        padding: 3px 7px;
+        font-size: 12px;
+        font-weight: 700;
+        line-height: 1;
+        color: #fff;
+        text-align: center;
+        white-space: nowrap;
+        vertical-align: baseline;
+        background-color: #49AF4F;
+        border-radius: 10px;
+    }
+
+    #search-wrap .search-choise {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-choise option {
+        box-shadow: none;
+        border: 0 none;
+        outline: none;
+        margin-left: 18px;
+        font-family: "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", Arial, Helvetica, sans-serif;
+    }
+
+    #search-wrap .search-btn {
+        border: 0px;
+        float: right;
+        /* margin: 4px 4px 4px 0; */
+        width: 66px;
+        outline: none;
+        height: 36px;
+        border-radius: 0px 18px 18px 0px;
+        background-color: #49AF4F;
+        color: #FFF;
+        text-align: center;
+        line-height: 28px;
+    }
+</style>
+</body>
+
+</html>