From 23bd719cebe5feeff4e48fde925b0b39755eea93 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 15 十一月 2022 10:59:50 +0800
Subject: [PATCH] 2022.11.15

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OnLineQuestionServiceImpl.kt |   89 ++++++++++++++++++++++++++++++--------------
 1 files changed, 60 insertions(+), 29 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OnLineQuestionServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OnLineQuestionServiceImpl.kt
index d9fba46..4fea98a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OnLineQuestionServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OnLineQuestionServiceImpl.kt
@@ -1,5 +1,6 @@
 package cn.flightfeather.supervision.lightshare.service.Impl
 
+import cn.flightfeather.supervision.common.nlp.NlpController
 import cn.flightfeather.supervision.domain.entity.*
 import cn.flightfeather.supervision.domain.enumeration.*
 import cn.flightfeather.supervision.domain.mapper.*
@@ -26,7 +27,8 @@
     private val userinfoMapper: UserinfoMapper,
     private val cstQuestionMapper: CstQuestionMapper,
     private val settingAnswerMapper: SettingAnswerMapper,
-    private val enforceCaseMapper: EnforceCaseMapper
+    private val enforceCaseMapper: EnforceCaseMapper,
+    private val nlpController: NlpController
 ) : OnLineQuestionService {
     @Resource
     private val onLineQuestionMapper: OnLineQuestionMapper? = null
@@ -100,6 +102,11 @@
     }
 
     override fun searchLaw(userId: String, keyword: String, type: Byte?, page: Int, perPage: Int): BaseResponse<List<ConsultResultVo>> {
+        val keywordList = if (keyword.isBlank()) {
+            emptyList()
+        } else {
+            nlpController.execute(keyword)
+        }
         val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return BaseResponse(false)
         val response = BaseResponse<List<ConsultResultVo>>(false, head = DataHead(page, perPage))
         val result = mutableListOf<ConsultResultVo>()
@@ -112,14 +119,21 @@
         if (type == null || type == ConsultResultType.TYPE1.value) {
             val p = PageHelper.startPage<MgtFile>(_page, _perPage)
             val example = Example(MgtFile::class.java).apply {
-                if (keyword.isNotBlank()) {
-                    createCriteria().orLike("mfName", "%${keyword}%")
-                        .orLike("mfShortName", "%${keyword}%")
-                        .orLike("mfSummary", "%${keyword}%")
-                        .orLike("mfKeywordLv1", "%${keyword}%")
-                        .orLike("mfKeywordLv2", "%${keyword}%")
-                        .orLike("mfKeywordLv3", "%${keyword}%")
-                        .orLike("mfKeywordLv4", "%${keyword}%")
+                if (keywordList.isNotEmpty()) {
+                    createCriteria().apply {
+                        keywordList.forEach { k ->
+                            orLike("mfName", "%${k}%")
+                            orLike("mfShortName", "%${k}%")
+                            orLike("mfSummary", "%${k}%")
+                            orLike("mfKeywordLv1", "%${k}%")
+                            orLike("mfKeywordLv2", "%${k}%")
+                            orLike("mfKeywordLv3", "%${k}%")
+                            orLike("mfKeywordLv4", "%${k}%")
+                        }
+                    }
+                    and(createCriteria().orLike("mfExtension1", "%${userInfo.extension2}%")
+                        .orEqualTo("mfExtension1", "")
+                        .orIsNull("mfExtension1"))
                 } else {
                     // TODO: 2022/9/8 娌℃湁鍏抽敭瀛楁椂锛屾寜鐓х儹闂ㄨ幏鍙栨満鍒惰幏鍙�
                     createCriteria().orLike("mfExtension1", "%${userInfo.extension2}%")
@@ -137,7 +151,7 @@
 
                     fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                     itemType = EnElementType.getNameByValue(it.mfEpItemType)
-                    itemSubType = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
+                    itemSubType = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype)
                     fileUrl = it.mfFileUrl
                     val keyList = it.mfKeywordLv1.split("銆�")
                     for (i in keyList.indices) {
@@ -166,14 +180,19 @@
             val map = mutableMapOf<String, MgtFile>()
             val p = PageHelper.startPage<MgtItem>(_page, _perPage)
             val example = Example(MgtItem::class.java).apply {
-                if (keyword.isNotBlank()) {
-                    createCriteria().orLike("miChapterKeyword", "%${keyword}%")
-                        .orLike("miKeyword", "%${keyword}%")
+                if (keywordList.isNotEmpty()) {
+                    createCriteria().apply {
+                        keywordList.forEach { k ->
+                            orLike("miChapterKeyword", "%${k}%")
+                            orLike("miKeyword", "%${k}%")
+                        }
+                    }
                 } else {
                     // TODO: 2022/9/8 娌℃湁鍏抽敭瀛楁椂锛屾寜鐓х儹闂ㄨ幏鍙栨満鍒惰幏鍙栨潯鐩�
                 }
             }
             mgtItemMapper.selectByExample(example).forEach {
+
                 if (!map.containsKey(it.mfGuid)) {
                     map[it.mfGuid] = mgtFileMapper.selectByPrimaryKey(it.mfGuid)
                 }
@@ -217,13 +236,17 @@
         if (type == null || type == ConsultResultType.TYPE4.value) {
             val p = PageHelper.startPage<CstQuestion>(_page, _perPage)
             val example = Example(CstQuestion::class.java).apply {
-                if (keyword.isNotBlank()) {
+                if (keywordList.isNotEmpty()) {
                     createCriteria().orLike("cqScenes", "%${userInfo.extension2}%")
                         .orEqualTo("cqScenes", "")
                         .orIsNull("cqScenes")
                     and(
-                        createCriteria().orLike("cqContent", "%${keyword}%")
-                            .orLike("cqKeywords", "%${keyword}%")
+                        createCriteria().apply {
+                            keywordList.forEach { k ->
+                                orLike("cqContent", "%${k}%")
+                                orLike("cqKeywords", "%${k}%")
+                            }
+                        }
                     )
                 } else {
                     // TODO: 2022/9/8 娌℃湁鍏抽敭瀛楁椂锛屾寜鐓х儹闂ㄨ幏鍙栨満鍒惰幏鍙�
@@ -247,7 +270,7 @@
 
 //                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                     itemType = EnElementType.getNameByValue(it.cqKind)
-                    itemSubType = EnElementSubType.getNameByValue(it.cqSubkind)
+                    itemSubType = EnElementSubType.getSubType(it.cqKind, it.cqSubkind)
 //                    fileUrl = it.mfFileUrl
 //                    val keyList = it.mfKeywordLv1.split("銆�")
 //                    for (i in keyList.indices) {
@@ -258,6 +281,10 @@
 //                        }
 //                    }
                     time = it.cqCreateTime
+                    punish = it.cqIsPunish
+                    illegal = it.cqIsIllegal
+                    shotSpot = it.cqIsShotspot
+                    supervise = it.cqIsSupervise
                 })
             }
             response.success = true
@@ -270,13 +297,17 @@
         if (type == null || type == ConsultResultType.TYPE3.value) {
             val p = PageHelper.startPage<EnforceCase>(_page, _perPage)
             val example = Example(EnforceCase::class.java).apply {
-                if (keyword.isNotBlank()) {
+                if (keywordList.isNotEmpty()) {
                     createCriteria().orLike("ecScenes", "%${userInfo.extension2}%")
                         .orEqualTo("ecScenes", "")
                         .orIsNull("ecScenes")
                     and(
-                        createCriteria().orLike("ecTitle", "%${keyword}%")
-                            .orLike("ecKeywords", "%${keyword}%")
+                        createCriteria().apply {
+                            keywordList.forEach { k ->
+                                orLike("ecTitle", "%${k}%")
+                                orLike("ecKeywords", "%${k}%")
+                            }
+                        }
                     )
                 } else {
                     // TODO: 2022/9/8 娌℃湁鍏抽敭瀛楁椂锛屾寜鐓х儹闂ㄨ幏鍙栨満鍒惰幏鍙�
@@ -296,7 +327,7 @@
 
 //                    fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry)
                     itemType = EnElementType.getNameByValue(it.ecEpItemType)
-                    itemSubType = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
+                    itemSubType = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype)
                     imgUrl = it.ecAppendixUrl?.split(";")?.get(0)
                     time = it.ecCreateTime
 
@@ -339,7 +370,7 @@
                 mfMgtLevel = ManageLevelType.getNameByValue(it.mfMgtLevel)
                 mfFileType = ConsultFileType.getNameByValue(it.mfFileType)
                 mfEpItemType = EnElementType.getNameByValue(it.mfEpItemType)
-                mfEpItemSubtype = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
+                mfEpItemSubtype = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype)
                 mfSaveType = FileSaveType.getNameByValue(it.mfSaveType)
             }
             result.add(vo)
@@ -356,7 +387,7 @@
                 mfMgtLevel = ManageLevelType.getNameByValue(it.mfMgtLevel)
                 mfFileType = ConsultFileType.getNameByValue(it.mfFileType)
                 mfEpItemType = EnElementType.getNameByValue(it.mfEpItemType)
-                mfEpItemSubtype = EnElementSubType.getNameByValue(it.mfEpItemSubtype)
+                mfEpItemSubtype = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype)
                 mfSaveType = FileSaveType.getNameByValue(it.mfSaveType)
             }
         }
@@ -390,7 +421,7 @@
             BeanUtils.copyProperties(it, vo)
             vo.apply {
                 cqKind = EnElementType.getNameByValue(it.cqKind)
-                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
+                cqSubkind = EnElementSubType.getSubType(it.cqKind, it.cqSubkind)
             }
 
             if (answers.isNotEmpty()) {
@@ -427,7 +458,7 @@
                 typeId = ConsultResultType.TYPE4.value
                 typeName = ConsultResultType.TYPE4.des
                 itemType = EnElementType.getNameByValue(it.cqKind)
-                itemSubType = EnElementSubType.getNameByValue(it.cqSubkind)
+                itemSubType = EnElementSubType.getSubType(it.cqKind, it.cqSubkind)
                 time = it.cqCreateTime
             })
 
@@ -435,7 +466,7 @@
 //            BeanUtils.copyProperties(it, vo)
 //            vo.apply {
 //                cqKind = EnElementType.getNameByValue(it.cqKind)
-//                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
+//                cqSubkind = EnElementSubType.getSubType(it.ecEpItemType, it.cqSubkind)
 //            }
 //
 //            if (answers.isNotEmpty()) {
@@ -453,7 +484,7 @@
             BeanUtils.copyProperties(it, result)
             result.apply {
                 cqKind = EnElementType.getNameByValue(it.cqKind)
-                cqSubkind = EnElementSubType.getNameByValue(it.cqSubkind)
+                cqSubkind = EnElementSubType.getSubType(it.cqKind, it.cqSubkind)
             }
         }
 
@@ -481,7 +512,7 @@
             BeanUtils.copyProperties(it, vo)
             vo.apply {
                 ecEpItemType = EnElementType.getNameByValue(it.ecEpItemType)
-                ecEpItemSubtype = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
+                ecEpItemSubtype = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype)
                 ecType = EnforceCaseType.getNameByValue(it.ecType)
             }
             result.add(vo)
@@ -495,7 +526,7 @@
             BeanUtils.copyProperties(it, result)
             result.apply {
                 ecEpItemType = EnElementType.getNameByValue(it.ecEpItemType)
-                ecEpItemSubtype = EnElementSubType.getNameByValue(it.ecEpItemSubtype)
+                ecEpItemSubtype = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype)
                 ecType = EnforceCaseType.getNameByValue(it.ecType)
             }
         }

--
Gitblit v1.9.3