| | |
| | | } |
| | | |
| | | 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>() |
| | | |
| | | //当搜索不限制类型时,默认每种类型只获取前5项;当限制类型时,则根据前端请求分页数返回 |
| | | val _perPage = if (type == null) 5 else perPage |
| | | val _page = page |
| | | |
| | | //法律法规文件 |
| | | if (type == null || type == ConsultResultType.TYPE1.value) { |
| | | val p = PageHelper.startPage<MgtFile>(_page, _perPage) |
| | | val example = Example(MgtFile::class.java).apply { |
| | | 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}%") |
| | | .orEqualTo("mfExtension1", "") |
| | | .orIsNull("mfExtension1") |
| | | } |
| | | } |
| | | mgtFileMapper.selectByExample(example).forEach { |
| | | result.add(ConsultResultFileVo().apply { |
| | | id = it.mfGuid |
| | | name = it.mfName |
| | | des = it.mfSummary |
| | | typeId = ConsultResultType.TYPE1.value |
| | | typeName = ConsultResultType.TYPE1.des |
| | | |
| | | fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.mfEpItemType) |
| | | itemSubType = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype) |
| | | fileUrl = it.mfFileUrl |
| | | val keyList = it.mfKeywordLv1.split("、") |
| | | for (i in keyList.indices) { |
| | | if (i < 5) { |
| | | keywords.add(keyList[i]) |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | time = it.mfUpdateTime |
| | | fileType = ConsultFileType.getNameByValue(it.mfFileType) |
| | | referenceNumber = it.mfReferenceNumber |
| | | effectiveDate = DateUtil.DateToString(it.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | closingDate = DateUtil.DateToString(it.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | effective = Date().time > (it.mfClosingDate?.time ?: 0) |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //法律法规条目 |
| | | if (type == null || type == ConsultResultType.TYPE2.value) { |
| | | val map = mutableMapOf<String, MgtFile>() |
| | | val p = PageHelper.startPage<MgtItem>(_page, _perPage) |
| | | val example = Example(MgtItem::class.java).apply { |
| | | 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) |
| | | } |
| | | result.add(ConsultResultItemVo().apply { |
| | | id = it.miGuid |
| | | name = it.miItemName |
| | | des = it.miItemContent |
| | | typeId = ConsultResultType.TYPE2.value |
| | | typeName = ConsultResultType.TYPE2.des |
| | | |
| | | // 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>() |
| | | // |
| | | // //当搜索不限制类型时,默认每种类型只获取前5项;当限制类型时,则根据前端请求分页数返回 |
| | | // val _perPage = if (type == null) 5 else perPage |
| | | // val _page = page |
| | | // |
| | | // //法律法规文件 |
| | | // if (type == null || type == ConsultResultType.TYPE1.value) { |
| | | // val p = PageHelper.startPage<MgtFile>(_page, _perPage) |
| | | // val example = Example(MgtFile::class.java).apply { |
| | | // 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}%") |
| | | // .orEqualTo("mfExtension1", "") |
| | | // .orIsNull("mfExtension1") |
| | | // } |
| | | // } |
| | | // mgtFileMapper.selectByExample(example).forEach { |
| | | // result.add(ConsultResultFileVo().apply { |
| | | // id = it.mfGuid |
| | | // name = it.mfName |
| | | // des = it.mfSummary |
| | | // typeId = ConsultResultType.TYPE1.value |
| | | // typeName = ConsultResultType.TYPE1.des |
| | | // |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | // itemType = EnElementType.getNameByValue(it.mfEpItemType) |
| | | // fileUrl = it.mfFileUrl |
| | | val keyList = it.miKeyword.split("、") |
| | | for (i in keyList.indices) { |
| | | if (i < 5) { |
| | | keywords.add(keyList[i]) |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | time = it.miUpdateTime |
| | | |
| | | chapterName = it.miChapterName |
| | | fileId = it.mfGuid |
| | | fileName = it.mfName |
| | | referenceNumber = it.mfReferenceNumber |
| | | effectiveDate = DateUtil.DateToString(map[it.mfGuid]?.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | closingDate = DateUtil.DateToString(map[it.mfGuid]?.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | effective = Date().time > (map[it.mfGuid]?.mfClosingDate?.time ?: 0) |
| | | relatedItems = it.miRelatedItems?.split(";")?.size ?: 0 |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //环保问题 |
| | | if (type == null || type == ConsultResultType.TYPE4.value) { |
| | | val p = PageHelper.startPage<CstQuestion>(_page, _perPage) |
| | | val example = Example(CstQuestion::class.java).apply { |
| | | if (keywordList.isNotEmpty()) { |
| | | createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("cqScenes", "") |
| | | .orIsNull("cqScenes") |
| | | and( |
| | | createCriteria().apply { |
| | | keywordList.forEach { k -> |
| | | orLike("cqContent", "%${k}%") |
| | | orLike("cqKeywords", "%${k}%") |
| | | } |
| | | } |
| | | ) |
| | | } else { |
| | | // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | orderBy("cqTotalnum") |
| | | } |
| | | } |
| | | cstQuestionMapper.selectByExample(example).forEach { |
| | | val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply { |
| | | createCriteria().andEqualTo("cqGuid", it.cqGuid) |
| | | }) |
| | | |
| | | result.add(ConsultResultQAVo().apply { |
| | | id = it.cqGuid |
| | | name = it.cqContent |
| | | if (answers.isNotEmpty()) { |
| | | des = answers[0].saContent |
| | | } |
| | | typeId = ConsultResultType.TYPE4.value |
| | | typeName = ConsultResultType.TYPE4.des |
| | | |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.cqKind) |
| | | itemSubType = EnElementSubType.getSubType(it.cqKind, it.cqSubkind) |
| | | // itemSubType = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype) |
| | | // fileUrl = it.mfFileUrl |
| | | // val keyList = it.mfKeywordLv1.split("、") |
| | | // for (i in keyList.indices) { |
| | |
| | | // break |
| | | // } |
| | | // } |
| | | time = it.cqCreateTime |
| | | punish = it.cqIsPunish |
| | | illegal = it.cqIsIllegal |
| | | shotSpot = it.cqIsShotspot |
| | | supervise = it.cqIsSupervise |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //执法案例 |
| | | if (type == null || type == ConsultResultType.TYPE3.value) { |
| | | val p = PageHelper.startPage<EnforceCase>(_page, _perPage) |
| | | val example = Example(EnforceCase::class.java).apply { |
| | | if (keywordList.isNotEmpty()) { |
| | | createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("ecScenes", "") |
| | | .orIsNull("ecScenes") |
| | | and( |
| | | createCriteria().apply { |
| | | keywordList.forEach { k -> |
| | | orLike("ecTitle", "%${k}%") |
| | | orLike("ecKeywords", "%${k}%") |
| | | } |
| | | } |
| | | ) |
| | | } else { |
| | | // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("ecScenes", "") |
| | | .orIsNull("ecScenes") |
| | | orderBy("ecOccurDate").desc() |
| | | } |
| | | } |
| | | enforceCaseMapper.selectByExample(example).forEach { |
| | | result.add(ConsultResultCaseVo().apply { |
| | | id = it.ecGuid |
| | | name = it.ecTitle |
| | | des = it.ecSummary |
| | | typeId = ConsultResultType.TYPE3.value |
| | | typeName = ConsultResultType.TYPE3.des |
| | | // time = it.mfUpdateTime |
| | | // fileType = ConsultFileType.getNameByValue(it.mfFileType) |
| | | // referenceNumber = it.mfReferenceNumber |
| | | // effectiveDate = DateUtil.DateToString(it.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | // closingDate = DateUtil.DateToString(it.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | // effective = Date().time > (it.mfClosingDate?.time ?: 0) |
| | | // }) |
| | | // } |
| | | // response.success = true |
| | | // response.head?.run { |
| | | // this.page = p.pageNum |
| | | // this.totalPage = p.pages |
| | | // } |
| | | // } |
| | | // //法律法规条目 |
| | | // if (type == null || type == ConsultResultType.TYPE2.value) { |
| | | // val map = mutableMapOf<String, MgtFile>() |
| | | // val p = PageHelper.startPage<MgtItem>(_page, _perPage) |
| | | // val example = Example(MgtItem::class.java).apply { |
| | | // if (keywordList.isNotEmpty()) { |
| | | // createCriteria().apply { |
| | | // keywordList.forEach { k -> |
| | | // orLike("miChapterKeyword", "%${k}%") |
| | | // orLike("miKeyword", "%${k}%") |
| | | // orLike("miItemContent", "%${k}%") |
| | | // } |
| | | // } |
| | | // } else { |
| | | // // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取条目 |
| | | // } |
| | | // } |
| | | // mgtItemMapper.selectByExample(example).forEach { |
| | | // |
| | | // if (!map.containsKey(it.mfGuid)) { |
| | | // map[it.mfGuid] = mgtFileMapper.selectByPrimaryKey(it.mfGuid) |
| | | // } |
| | | // result.add(ConsultResultItemVo().apply { |
| | | // id = it.miGuid |
| | | // name = it.miItemName |
| | | // des = it.miItemContent |
| | | // typeId = ConsultResultType.TYPE2.value |
| | | // typeName = ConsultResultType.TYPE2.des |
| | | // |
| | | //// fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | //// itemType = EnElementType.getNameByValue(it.mfEpItemType) |
| | | //// fileUrl = it.mfFileUrl |
| | | // val keyList = it.miKeyword.split("、") |
| | | // for (i in keyList.indices) { |
| | | // if (i < 5) { |
| | | // keywords.add(keyList[i]) |
| | | // } else { |
| | | // break |
| | | // } |
| | | // } |
| | | // time = it.miUpdateTime |
| | | // |
| | | // chapterName = it.miChapterName |
| | | // fileId = it.mfGuid |
| | | // fileName = it.mfName |
| | | // referenceNumber = it.mfReferenceNumber |
| | | // effectiveDate = DateUtil.DateToString(map[it.mfGuid]?.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | // closingDate = DateUtil.DateToString(map[it.mfGuid]?.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | // effective = Date().time > (map[it.mfGuid]?.mfClosingDate?.time ?: 0) |
| | | // relatedItems = it.miRelatedItems?.split(";")?.size ?: 0 |
| | | // }) |
| | | // } |
| | | // response.success = true |
| | | // response.head?.run { |
| | | // this.page = p.pageNum |
| | | // this.totalPage = p.pages |
| | | // } |
| | | // } |
| | | // //环保问题 |
| | | // if (type == null || type == ConsultResultType.TYPE4.value) { |
| | | // val p = PageHelper.startPage<CstQuestion>(_page, _perPage) |
| | | // val example = Example(CstQuestion::class.java).apply { |
| | | // if (keywordList.isNotEmpty()) { |
| | | // createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | // .orEqualTo("cqScenes", "") |
| | | // .orIsNull("cqScenes") |
| | | // and( |
| | | // createCriteria().apply { |
| | | // keywordList.forEach { k -> |
| | | // orLike("cqContent", "%${k}%") |
| | | // orLike("cqKeywords", "%${k}%") |
| | | // } |
| | | // } |
| | | // ) |
| | | // } else { |
| | | // // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | // createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | // orderBy("cqTotalnum") |
| | | // } |
| | | // } |
| | | // cstQuestionMapper.selectByExample(example).forEach { |
| | | // val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply { |
| | | // createCriteria().andEqualTo("cqGuid", it.cqGuid) |
| | | // }) |
| | | // |
| | | // result.add(ConsultResultQAVo().apply { |
| | | // id = it.cqGuid |
| | | // name = it.cqContent |
| | | // if (answers.isNotEmpty()) { |
| | | // des = answers[0].saContent |
| | | // } |
| | | // typeId = ConsultResultType.TYPE4.value |
| | | // typeName = ConsultResultType.TYPE4.des |
| | | // |
| | | //// fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | // itemType = EnElementType.getNameByValue(it.cqKind) |
| | | // itemSubType = EnElementSubType.getSubType(it.cqKind, it.cqSubkind) |
| | | //// fileUrl = it.mfFileUrl |
| | | //// val keyList = it.mfKeywordLv1.split("、") |
| | | //// for (i in keyList.indices) { |
| | | //// if (i < 5) { |
| | | //// keywords.add(keyList[i]) |
| | | //// } else { |
| | | //// break |
| | | //// } |
| | | //// } |
| | | // time = it.cqCreateTime |
| | | // punish = it.cqIsPunish |
| | | // illegal = it.cqIsIllegal |
| | | // shotSpot = it.cqIsShotspot |
| | | // supervise = it.cqIsSupervise |
| | | // }) |
| | | // } |
| | | // response.success = true |
| | | // response.head?.run { |
| | | // this.page = p.pageNum |
| | | // this.totalPage = p.pages |
| | | // } |
| | | // } |
| | | // //执法案例 |
| | | // if (type == null || type == ConsultResultType.TYPE3.value) { |
| | | // val p = PageHelper.startPage<EnforceCase>(_page, _perPage) |
| | | // val example = Example(EnforceCase::class.java).apply { |
| | | // if (keywordList.isNotEmpty()) { |
| | | // createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | // .orEqualTo("ecScenes", "") |
| | | // .orIsNull("ecScenes") |
| | | // and( |
| | | // createCriteria().apply { |
| | | // keywordList.forEach { k -> |
| | | // orLike("ecTitle", "%${k}%") |
| | | // orLike("ecKeywords", "%${k}%") |
| | | // } |
| | | // } |
| | | // ) |
| | | // } else { |
| | | // // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | // createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | // .orEqualTo("ecScenes", "") |
| | | // .orIsNull("ecScenes") |
| | | // orderBy("ecOccurDate").desc() |
| | | // } |
| | | // } |
| | | // enforceCaseMapper.selectByExample(example).forEach { |
| | | // result.add(ConsultResultCaseVo().apply { |
| | | // id = it.ecGuid |
| | | // name = it.ecTitle |
| | | // des = it.ecSummary |
| | | // typeId = ConsultResultType.TYPE3.value |
| | | // typeName = ConsultResultType.TYPE3.des |
| | | // |
| | | //// fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | // itemType = EnElementType.getNameByValue(it.ecEpItemType) |
| | | // itemSubType = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype) |
| | | // imgUrl = it.ecAppendixUrl?.split(";")?.get(0) |
| | | // time = it.ecCreateTime |
| | | // |
| | | // provinceName = it.ecProvinceName |
| | | // cityName = it.ecCityName |
| | | // occurDate = DateUtil.DateToString(it.ecOccurDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | // punish = it.ecIsPunish |
| | | // detained = it.ecIsDetained |
| | | // illegal = it.ecIsIllegal |
| | | // shotSpot = it.ecIsShotspot |
| | | // supervise = it.ecIsSupervise |
| | | // minor = it.ecIsMinor |
| | | // }) |
| | | // } |
| | | // response.success = true |
| | | // response.head?.run { |
| | | // this.page = p.pageNum |
| | | // this.totalPage = p.pages |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | // return response.apply { data = result } |
| | | |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.ecEpItemType) |
| | | itemSubType = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype) |
| | | imgUrl = it.ecAppendixUrl?.split(";")?.get(0) |
| | | time = it.ecCreateTime |
| | | |
| | | provinceName = it.ecProvinceName |
| | | cityName = it.ecCityName |
| | | occurDate = DateUtil.DateToString(it.ecOccurDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | punish = it.ecIsPunish |
| | | detained = it.ecIsDetained |
| | | illegal = it.ecIsIllegal |
| | | shotSpot = it.ecIsShotspot |
| | | supervise = it.ecIsSupervise |
| | | minor = it.ecIsMinor |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | |
| | | |
| | | return response.apply { data = result } |
| | | return searchLaw2(userId, keyword, type, page, perPage) |
| | | } |
| | | |
| | | override fun getTopicLaw(userId: String): List<MgtFileVo> { |
| | |
| | | // } |
| | | // result.add(vo) |
| | | } |
| | | val totalCount = cstQuestionMapper.selectCountByExample(example) |
| | | return BaseResponse(true, head = DataHead(p.pageNum, p.pages, totalCount), data = result) |
| | | return BaseResponse(true, head = DataHead(p.pageNum, p.pages, p.total), data = result) |
| | | } |
| | | |
| | | override fun getQuestion(userId: String, qId: String): CstQuestionVo { |
| | |
| | | } |
| | | return result |
| | | } |
| | | |
| | | private fun searchLaw2(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>() |
| | | |
| | | //当搜索不限制类型时,默认每种类型只获取前5项;当限制类型时,则根据前端请求分页数返回 |
| | | val _perPage = if (type == null) 5 else perPage |
| | | val _page = page |
| | | |
| | | //法律法规文件 |
| | | if (type == null || type == ConsultResultType.TYPE1.value) { |
| | | val p = PageHelper.startPage<MgtFile>(_page, _perPage) |
| | | val resultMap = mutableMapOf<String, Pair<MgtFile, Int>>() |
| | | val tempList = mutableListOf<Pair<MgtFile, Int>>() |
| | | if (keywordList.isNotEmpty()) { |
| | | keywordList.forEach { k -> |
| | | mgtFileMapper.selectByExample(Example(MgtFile::class.java).apply { |
| | | createCriteria().orLike("mfName", "%${k}%") |
| | | .orLike("mfShortName", "%${k}%") |
| | | .orLike("mfSummary", "%${k}%") |
| | | .orLike("mfKeywordLv1", "%${k}%") |
| | | .orLike("mfKeywordLv2", "%${k}%") |
| | | .orLike("mfKeywordLv3", "%${k}%") |
| | | .orLike("mfKeywordLv4", "%${k}%") |
| | | }).forEach { f -> |
| | | if (!resultMap.containsKey(f.mfGuid)) { |
| | | resultMap[f.mfGuid] = Pair(f, 0) |
| | | } |
| | | resultMap[f.mfGuid] = Pair(f, resultMap[f.mfGuid]?.second?.plus(1) ?: 0) |
| | | } |
| | | } |
| | | resultMap.forEach { (_, u) -> |
| | | tempList.add(u) |
| | | } |
| | | tempList.sortWith { o1, o2 -> |
| | | //排序条件一:关键词匹配次数 |
| | | if (o1.second != o2.second) { |
| | | return@sortWith o2.second - o1.second |
| | | } |
| | | //排序条件二:浏览量 |
| | | if (o1.first.mfRemark != o2.first.mfRemark) { |
| | | return@sortWith o2.first.mfRemark.toIntOrNull()?.minus(o1.first.mfRemark.toIntOrNull() ?: 0) ?: 0 |
| | | } |
| | | //排序条件三:文件发布时间 |
| | | (o2.first.mfReleaseDate.time - o1.first.mfReleaseDate.time).toInt() |
| | | } |
| | | } else { |
| | | mgtFileMapper.selectByExample(Example(MgtFile::class.java).apply { |
| | | createCriteria().orLike("mfExtension1", "%${userInfo.extension2}%") |
| | | .orEqualTo("mfExtension1", "") |
| | | .orIsNull("mfExtension1") |
| | | }).forEach { |
| | | tempList.add(Pair(it, 0)) |
| | | } |
| | | } |
| | | |
| | | tempList.forEach {p -> |
| | | val it = p.first |
| | | result.add(ConsultResultFileVo().apply { |
| | | id = it.mfGuid |
| | | name = it.mfName |
| | | des = it.mfSummary |
| | | typeId = ConsultResultType.TYPE1.value |
| | | typeName = ConsultResultType.TYPE1.des |
| | | |
| | | fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.mfEpItemType) |
| | | itemSubType = EnElementSubType.getSubType(it.mfEpItemType, it.mfEpItemSubtype) |
| | | fileUrl = it.mfFileUrl |
| | | val keyList = it.mfKeywordLv1.split("、") |
| | | for (i in keyList.indices) { |
| | | if (i < 5) { |
| | | keywords.add(keyList[i]) |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | time = it.mfUpdateTime |
| | | fileType = ConsultFileType.getNameByValue(it.mfFileType) |
| | | referenceNumber = it.mfReferenceNumber |
| | | effectiveDate = DateUtil.DateToString(it.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | closingDate = DateUtil.DateToString(it.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | effective = Date().time > (it.mfClosingDate?.time ?: 0) |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //法律法规条目 |
| | | if (type == null || type == ConsultResultType.TYPE2.value) { |
| | | val map = mutableMapOf<String, MgtFile>() |
| | | val p = PageHelper.startPage<MgtItem>(_page, _perPage) |
| | | |
| | | val resultMap = mutableMapOf<String, Pair<MgtItem, Int>>() |
| | | val tempList = mutableListOf<Pair<MgtItem, Int>>() |
| | | if (keywordList.isNotEmpty()) { |
| | | mgtItemMapper.selectByExample(Example(MgtItem::class.java).apply { |
| | | createCriteria().apply { |
| | | keywordList.forEach { k -> |
| | | orLike("miChapterKeyword", "%${k}%") |
| | | orLike("miKeyword", "%${k}%") |
| | | orLike("miItemContent", "%${k}%") |
| | | } |
| | | } |
| | | }).forEach { f -> |
| | | if (!resultMap.containsKey(f.miGuid)) { |
| | | resultMap[f.miGuid] = Pair(f, 0) |
| | | } |
| | | resultMap[f.miGuid] = Pair(f, resultMap[f.miGuid]?.second?.plus(1) ?: 0) |
| | | } |
| | | resultMap.forEach { (_, u) -> |
| | | tempList.add(u) |
| | | } |
| | | tempList.sortWith { o1, o2 -> |
| | | //排序条件一:关键词匹配次数 |
| | | if (o1.second != o2.second) { |
| | | return@sortWith o2.second - o1.second |
| | | } |
| | | //排序条件二:浏览量 |
| | | return@sortWith o2.first.miRemark.toIntOrNull()?.minus(o1.first.miRemark.toIntOrNull() ?: 0) ?: 0 |
| | | } |
| | | } else { |
| | | // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取条目 |
| | | mgtItemMapper.selectByExample(Example(MgtItem::class.java).apply { |
| | | orderBy("miCreateTime").desc() |
| | | }).forEach { |
| | | tempList.add(Pair(it, 0)) |
| | | } |
| | | } |
| | | |
| | | tempList.forEach {p -> |
| | | val it = p.first |
| | | if (!map.containsKey(it.mfGuid)) { |
| | | map[it.mfGuid] = mgtFileMapper.selectByPrimaryKey(it.mfGuid) |
| | | } |
| | | result.add(ConsultResultItemVo().apply { |
| | | id = it.miGuid |
| | | name = it.miItemName |
| | | des = it.miItemContent |
| | | typeId = ConsultResultType.TYPE2.value |
| | | typeName = ConsultResultType.TYPE2.des |
| | | |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | // itemType = EnElementType.getNameByValue(it.mfEpItemType) |
| | | // fileUrl = it.mfFileUrl |
| | | val keyList = it.miKeyword.split("、") |
| | | for (i in keyList.indices) { |
| | | if (i < 5) { |
| | | keywords.add(keyList[i]) |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | time = it.miUpdateTime |
| | | |
| | | chapterName = it.miChapterName |
| | | fileId = it.mfGuid |
| | | fileName = it.mfName |
| | | referenceNumber = it.mfReferenceNumber |
| | | effectiveDate = DateUtil.DateToString(map[it.mfGuid]?.mfEffectiveDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | closingDate = DateUtil.DateToString(map[it.mfGuid]?.mfClosingDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | effective = Date().time > (map[it.mfGuid]?.mfClosingDate?.time ?: 0) |
| | | relatedItems = it.miRelatedItems?.split(";")?.size ?: 0 |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //环保问题 |
| | | if (type == null || type == ConsultResultType.TYPE4.value) { |
| | | val p = PageHelper.startPage<CstQuestion>(_page, _perPage) |
| | | |
| | | val resultMap = mutableMapOf<String, Pair<CstQuestion, Int>>() |
| | | val tempList = mutableListOf<Pair<CstQuestion, Int>>() |
| | | if (keywordList.isNotEmpty()) { |
| | | cstQuestionMapper.selectByExample(Example(CstQuestion::class.java).apply { |
| | | createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("cqScenes", "") |
| | | .orIsNull("cqScenes") |
| | | and( |
| | | createCriteria().apply { |
| | | keywordList.forEach { k -> |
| | | orLike("cqContent", "%${k}%") |
| | | orLike("cqKeywords", "%${k}%") |
| | | } |
| | | } |
| | | ) |
| | | }).forEach { f -> |
| | | if (!resultMap.containsKey(f.cqGuid)) { |
| | | resultMap[f.cqGuid] = Pair(f, 0) |
| | | } |
| | | resultMap[f.cqGuid] = Pair(f, resultMap[f.cqGuid]?.second?.plus(1) ?: 0) |
| | | } |
| | | resultMap.forEach { (_, u) -> |
| | | tempList.add(u) |
| | | } |
| | | tempList.sortWith { o1, o2 -> |
| | | //排序条件一:关键词匹配次数 |
| | | if (o1.second != o2.second) { |
| | | return@sortWith o2.second - o1.second |
| | | } |
| | | //排序条件二:浏览量 |
| | | return@sortWith o2.first.cqRemark?.toIntOrNull()?.minus(o1.first.cqRemark.toIntOrNull() ?: 0) ?: 0 |
| | | } |
| | | } else { |
| | | // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | cstQuestionMapper.selectByExample(Example(CstQuestion::class.java).apply { |
| | | createCriteria().orLike("cqScenes", "%${userInfo.extension2}%") |
| | | orderBy("cqTotalnum") |
| | | }).forEach { |
| | | tempList.add(Pair(it, 0)) |
| | | } |
| | | } |
| | | tempList.forEach {p -> |
| | | val it = p.first |
| | | val answers = settingAnswerMapper.selectByExample(Example(SettingAnswer::class.java).apply { |
| | | createCriteria().andEqualTo("cqGuid", it.cqGuid) |
| | | }) |
| | | |
| | | result.add(ConsultResultQAVo().apply { |
| | | id = it.cqGuid |
| | | name = it.cqContent |
| | | if (answers.isNotEmpty()) { |
| | | des = answers[0].saContent |
| | | } |
| | | typeId = ConsultResultType.TYPE4.value |
| | | typeName = ConsultResultType.TYPE4.des |
| | | |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.cqKind) |
| | | itemSubType = EnElementSubType.getSubType(it.cqKind, it.cqSubkind) |
| | | // fileUrl = it.mfFileUrl |
| | | // val keyList = it.mfKeywordLv1.split("、") |
| | | // for (i in keyList.indices) { |
| | | // if (i < 5) { |
| | | // keywords.add(keyList[i]) |
| | | // } else { |
| | | // break |
| | | // } |
| | | // } |
| | | time = it.cqCreateTime |
| | | punish = it.cqIsPunish |
| | | illegal = it.cqIsIllegal |
| | | shotSpot = it.cqIsShotspot |
| | | supervise = it.cqIsSupervise |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | //执法案例 |
| | | if (type == null || type == ConsultResultType.TYPE3.value) { |
| | | val p = PageHelper.startPage<EnforceCase>(_page, _perPage) |
| | | |
| | | val resultMap = mutableMapOf<String, Pair<EnforceCase, Int>>() |
| | | val tempList = mutableListOf<Pair<EnforceCase, Int>>() |
| | | if (keywordList.isNotEmpty()) { |
| | | enforceCaseMapper.selectByExample(Example(EnforceCase::class.java).apply { |
| | | |
| | | createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("ecScenes", "") |
| | | .orIsNull("ecScenes") |
| | | and( |
| | | createCriteria().apply { |
| | | keywordList.forEach { k -> |
| | | orLike("ecTitle", "%${k}%") |
| | | orLike("ecKeywords", "%${k}%") |
| | | } |
| | | } |
| | | ) |
| | | }).forEach { f -> |
| | | if (!resultMap.containsKey(f.ecGuid)) { |
| | | resultMap[f.ecGuid] = Pair(f, 0) |
| | | } |
| | | resultMap[f.ecGuid] = Pair(f, resultMap[f.ecGuid]?.second?.plus(1) ?: 0) |
| | | } |
| | | resultMap.forEach { (_, u) -> |
| | | tempList.add(u) |
| | | } |
| | | tempList.sortWith { o1, o2 -> |
| | | //排序条件一:关键词匹配次数 |
| | | if (o1.second != o2.second) { |
| | | return@sortWith o2.second - o1.second |
| | | } |
| | | //排序条件二:浏览量 |
| | | return@sortWith o2.first.ecRemark.toIntOrNull()?.minus(o1.first.ecRemark.toIntOrNull() ?: 0) ?: 0 |
| | | } |
| | | } else { |
| | | // TODO: 2022/9/8 没有关键字时,按照热门获取机制获取 |
| | | enforceCaseMapper.selectByExample(Example(EnforceCase::class.java).apply { |
| | | createCriteria().orLike("ecScenes", "%${userInfo.extension2}%") |
| | | .orEqualTo("ecScenes", "") |
| | | .orIsNull("ecScenes") |
| | | orderBy("ecOccurDate").desc() |
| | | }).forEach { |
| | | tempList.add(Pair(it, 0)) |
| | | } |
| | | } |
| | | tempList.forEach {p -> |
| | | val it = p.first |
| | | result.add(ConsultResultCaseVo().apply { |
| | | id = it.ecGuid |
| | | name = it.ecTitle |
| | | des = it.ecSummary |
| | | typeId = ConsultResultType.TYPE3.value |
| | | typeName = ConsultResultType.TYPE3.des |
| | | |
| | | // fileIndustry = IndustryType.getNameByValue(it.mfFileIndustry) |
| | | itemType = EnElementType.getNameByValue(it.ecEpItemType) |
| | | itemSubType = EnElementSubType.getSubType(it.ecEpItemType, it.ecEpItemSubtype) |
| | | imgUrl = it.ecAppendixUrl?.split(";")?.get(0) |
| | | time = it.ecCreateTime |
| | | |
| | | provinceName = it.ecProvinceName |
| | | cityName = it.ecCityName |
| | | occurDate = DateUtil.DateToString(it.ecOccurDate, DateUtil.DateStyle.YYYY_MM_DD) |
| | | punish = it.ecIsPunish |
| | | detained = it.ecIsDetained |
| | | illegal = it.ecIsIllegal |
| | | shotSpot = it.ecIsShotspot |
| | | supervise = it.ecIsSupervise |
| | | minor = it.ecIsMinor |
| | | }) |
| | | } |
| | | response.success = true |
| | | response.head?.run { |
| | | this.page = p.pageNum |
| | | this.totalPage = p.pages |
| | | } |
| | | } |
| | | |
| | | |
| | | return response.apply { data = result } |
| | | } |
| | | } |