diff --git a/adc-da-slrs/src/main/java/com/adc/da/search/server/ResetSearchCenterService.java b/adc-da-slrs/src/main/java/com/adc/da/search/server/ResetSearchCenterService.java index b60c00a5..92863c62 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/search/server/ResetSearchCenterService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/search/server/ResetSearchCenterService.java @@ -1,27 +1,42 @@ package com.adc.da.search.server; +import com.adc.da.att.entity.AttFileEO; +import com.adc.da.att.service.IAttFileEOService; import com.adc.da.mq.CreateStandMQService; +import com.adc.da.person.service.IPersonCollectEOService; import com.adc.da.search.bean.SearchCenter; import com.adc.da.search.service.ElasticsearchService; +import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao; import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand; import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService; +import com.adc.da.slrs.sarLawsAttrInfo.dao.SarLawsAttrInfoDao; import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo; import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage; +import com.adc.da.slrs.sarLawsItems.dao.SarLawsItemsDao; +import com.adc.da.slrs.sarLawsItems.entity.SarLawsItems; import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfo; import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage; import com.adc.da.slrs.sarLawsStandInfo.service.ISarLawsStandInfoService; +import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao; +import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao; +import com.adc.da.slrs.sarStandItems.entity.FindSarItemsPageReqDTO; +import com.adc.da.slrs.sarStandItems.entity.SarStandItems; import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage; import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; +import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.util.http.ResponseMessage; import com.adc.da.util.http.Result; import com.adc.da.utils.util.DateUtil; +import com.adc.da.utils.util.FieldConvertUtil; +import com.adc.da.utils.util.InitStandAttrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.gson.JsonObject; import org.apache.commons.lang3.StringUtils; import org.elasticsearch.client.transport.TransportClient; +import org.json.JSONTokener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +46,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; +import java.sql.Clob; import java.util.*; import java.util.stream.Collectors; @@ -48,6 +64,21 @@ public class ResetSearchCenterService { @Autowired private TransportClient client; + @Autowired + private DicTypeEODao dicTypeEODao; + + @Autowired + private SarStandItemsDao standItemsDao; + + @Autowired + private SarLawsItemsDao sarLawsItemsDao; + + @Autowired + private IAttFileEOService attFileEOService; + + @Autowired + private SarLawsAttrInfoDao sarLawsAttrInfoDao; + @Autowired private ISarStandardsInfoService iSarStandardsInfoService; @@ -60,6 +91,15 @@ public class ResetSearchCenterService { @Autowired private CreateStandMQService createStandMQService; + @Autowired + private IPersonCollectEOService personCollectEOService; + + @Autowired + private SarStandAttrInfoDao sarStandAttrInfoEODao; + + @Autowired + private SarBussStandAttrInfoDao sarBussStandAttrInfoEODao; + @PostConstruct public void init() { @@ -227,9 +267,7 @@ public class ResetSearchCenterService { if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarStandardsInfo sarStandardsInfoEO : updList){ countUpdateSuccess++; - if (sarStandardsInfoEO.getAttrInfoMap() != null) { - sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap())); - } + standFunc(sarStandardsInfoEO); createStandMQService.sendStandMQ(sarStandardsInfoEO,"update"); } } @@ -237,6 +275,7 @@ public class ResetSearchCenterService { if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarStandardsInfo sarStandardsInfoEO : insList){ countAddSuccess++; + standFunc(sarStandardsInfoEO); if (sarStandardsInfoEO.getAttrInfoMap() != null) { sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap())); } @@ -258,6 +297,75 @@ public class ResetSearchCenterService { } + private void standFunc(SarStandardsInfo sarStandardsInfoEO) throws Exception { + attrInfoSearchDetails(sarStandardsInfoEO); + FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO(); + pageInfo.setStandId(sarStandardsInfoEO.getId()); + pageInfo.setFileType("FBGBJBD"); + + /** + * SarItemVO换为sarItemVOS + * List sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo); + * .collect(Collectors.toMap(SarItemVO::getItemsNum, SarItemVO::getItemsName)); + */ + + List sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo); + if (!sarItemVOS.isEmpty()) { + Map collectMap = sarItemVOS.stream().filter((e) -> e.getItemsNum() != null && e.getItemsName() != null) + .collect(Collectors.toMap(SarStandItems::getItemsNum, SarStandItems::getTermsConditions)); + sarStandardsInfoEO.setMapItems(collectMap); + } + if (sarStandardsInfoEO.getAttrInfoMap() != null) { + sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap())); + } + } + + public void attrInfoSearchDetails(SarStandardsInfo row) throws Exception { + if (row != null) { + String fieldInfo = InitStandAttrUtil.queryField; + String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); + row.setCollectId(collectId); + // 查询属性表数据 + if (StringUtils.isNotBlank(fieldInfo)) { + Map getAttrMap = sarStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId()); + if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) { + // 遍历修改所有clob类型的值 + for (String clobField : InitStandAttrUtil.clobFieldList) { + Clob clobValue = (Clob) getAttrMap.get(clobField); + String fieldValue = FieldConvertUtil.ClobToString(clobValue); + getAttrMap.put(clobField, fieldValue); + } + } + + row.setAttrInfoMap(getAttrMap); + } + + Map getAttrMap = row.getAttrInfoMap(); + if (getAttrMap != null && getAttrMap.size() > 0) { + for (Map.Entry entry : getAttrMap.entrySet()) { + String name = entry.getKey(); + String value = ""; + List valArr = new ArrayList<>(); + if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { + if (StringUtils.isNotBlank(entry.getValue().toString())) { + Object json = new JSONTokener(entry.getValue().toString()).nextValue(); + if (json instanceof org.json.JSONArray) { + valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class); + } else { + value = entry.getValue().toString(); + valArr = Arrays.asList(value.split(",")); + } + if (!valArr.isEmpty()) { + value = dicTypeEODao.getDicNamesByCodes(valArr, ""); + } + } + entry.setValue(value); + } + } + } + } + } + @Async public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage,SearchCenter searchCenter) throws Exception{ Boolean getLawsIndex = elasticsearchService.isIndexExist("laws"); @@ -334,9 +442,7 @@ public class ResetSearchCenterService { if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarLawsStandInfo sarLawsInfoEO : updList){ countUpdateSuccess++; - if (sarLawsInfoEO.getAttrInfoMap() != null) { - sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap())); - } + lawsAttrInfoShowSearchDetails(sarLawsInfoEO); createStandMQService.sendLawsMQ(sarLawsInfoEO,"update"); } } @@ -344,6 +450,26 @@ public class ResetSearchCenterService { if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarLawsStandInfo sarLawsInfoEO : insList){ countAddSuccess++; + lawsAttrInfoShowSearchDetails(sarLawsInfoEO); + FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO(); + pageInfo.setStandId(sarLawsInfoEO.getId()); + pageInfo.setFileType("FBGBJBD"); + + /** + * SarItemVO换为sarItemVOS + * List sarItemVOS = standItemsDao.querySarItemAndInterpretation(pageInfo); + * .collect(Collectors.toMap(SarItemVO::getItemsNum, SarItemVO::getItemsName)); + */ + + List sarItemVOS = sarLawsItemsDao.querySarItemAndInterpretation(pageInfo); + if(!sarItemVOS.isEmpty()){ + Map collectMap = sarItemVOS.stream().filter((e) -> e.getItemsNum() != null && e.getItemsName() != null) + .collect(Collectors.toMap(SarLawsItems::getItemsNum, SarLawsItems::getTermsConditions)); + sarLawsInfoEO.setMapItems(collectMap); + } + if (sarLawsInfoEO.getAttrInfoMap() != null) { + sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap())); + } if (sarLawsInfoEO.getAttrInfoMap() != null) { sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap())); } @@ -366,6 +492,79 @@ public class ResetSearchCenterService { } + public void lawsAttrInfoSearchDetails(SarLawsStandInfo row) throws Exception { + String fieldInfo = InitStandAttrUtil.queryFieldLaws; + String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); + row.setCollectId(collectId); + // 查询属性表数据 + if (org.apache.commons.lang.StringUtils.isNotBlank(fieldInfo)) { + Map getAttrMap = sarLawsAttrInfoDao.selectLawsFieldAndData(fieldInfo, row.getId()); + if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) { + // 遍历修改所有clob类型的值 + for (String clobField : InitStandAttrUtil.clobFieldList) { + Clob clobValue = (Clob) getAttrMap.get(clobField); + String fieldValue = FieldConvertUtil.ClobToString(clobValue); + getAttrMap.put(clobField, fieldValue); + } + } + + if (getAttrMap != null && !getAttrMap.isEmpty()) { + row.setAttrInfoCaseMap(transformUpperCase(getAttrMap)); + } + +// row.setAttrInfoMap(getAttrMap); + } + } + + private Map transformUpperCase(Map orgMap) { + Map resultMap = new HashMap<>(); + + for (Map.Entry entry : orgMap.entrySet()) { + String newKey = entry.getKey().toLowerCase(); + resultMap.put(newKey, orgMap.get(entry.getKey())); + if (entry.getValue() != null && InitStandAttrUtil.fileFieldListLaws != null && !InitStandAttrUtil.fileFieldListLaws.isEmpty() && InitStandAttrUtil.fileFieldListLaws.contains(entry.getKey())) { + String value = entry.getValue().toString(); + if (org.apache.commons.lang.StringUtils.isNotBlank(value)) { + List fileObj = attFileEOService.getMultiFileInfos(value); + if(!fileObj.isEmpty()){ + resultMap.put(newKey + "Name", fileObj.get(0).getOldFileName()); + } + } + } + } + + return resultMap; + } + + public void lawsAttrInfoShowSearchDetails(SarLawsStandInfo row) throws Exception { + if (row != null) { + lawsAttrInfoSearchDetails(row); + Map getAttrMap = row.getAttrInfoCaseMap(); + if (getAttrMap != null && getAttrMap.size() > 0) { + for (Map.Entry entry : getAttrMap.entrySet()) { + String name = entry.getKey().toUpperCase(); + String value = ""; + List valArr = new ArrayList<>(); + if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) { + if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ + Object json= new JSONTokener(entry.getValue().toString()).nextValue(); + if(json instanceof org.json.JSONArray){ + valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); + }else { + value = entry.getValue().toString(); + valArr = Arrays.asList(value.split(",")); + } + if(!valArr.isEmpty()){ + value = dicTypeEODao.getDicNamesByCodes(valArr,""); + } + } + entry.setValue(value); + } + } + } + } + } + private void idListFunc(SarLawsStandInfoPage sarLawsInfoEOPage, SearchCenter searchCenter) { if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty()){ String[] result = searchCenter.getIdList().toArray(new String[0]); @@ -456,6 +655,7 @@ public class ResetSearchCenterService { if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarBussionessStand sarBussionessStandEO : updList){ countUpdateSuccess++; + bussAttrInfoShowSearchDetails(sarBussionessStandEO); if (sarBussionessStandEO.getAttrInfoMap() != null) { sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap())); } @@ -466,6 +666,7 @@ public class ResetSearchCenterService { if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){ for(SarBussionessStand sarBussionessStandEO : insList){ countAddSuccess++; + bussAttrInfoShowSearchDetails(sarBussionessStandEO); if (sarBussionessStandEO.getAttrInfoMap() != null) { sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap())); } @@ -487,6 +688,55 @@ public class ResetSearchCenterService { } + public void bussAttrInfoShowSearchDetails(SarBussionessStand row) throws Exception { + if (row != null) { + bussAttrInfoSearchDetails(row); + Map getAttrMap = row.getAttrInfoCaseMap(); + if (getAttrMap != null && getAttrMap.size() > 0) { + for (Map.Entry entry : getAttrMap.entrySet()) { + String name = entry.getKey().toUpperCase(); + String value = ""; + List valArr = new ArrayList<>(); + if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { + if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ + Object json= new JSONTokener(entry.getValue().toString()).nextValue(); + if(json instanceof org.json.JSONArray){ + valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); + }else { + value = entry.getValue().toString(); + valArr = Arrays.asList(value.split(",")); + } + if(!valArr.isEmpty()){ + value = dicTypeEODao.getDicNamesByCodes(valArr,""); + } + } + entry.setValue(value); + } + } + } + } + } + + public void bussAttrInfoSearchDetails(SarBussionessStand row) throws Exception { + String fieldInfo = InitStandAttrUtil.queryFieldBuss; + String collectId = personCollectEOService.queryCollectByUserAndId(row.getId()); + row.setCollectId(collectId); + // 查询属性表数据 + if (org.apache.commons.lang.StringUtils.isNotBlank(fieldInfo)) { + Map getAttrMap = sarBussStandAttrInfoEODao.selectStandFieldAndData(fieldInfo, row.getId()); + if (InitStandAttrUtil.clobFieldList != null && !InitStandAttrUtil.clobFieldList.isEmpty()) { + // 遍历修改所有clob类型的值 + for (String clobField : InitStandAttrUtil.clobFieldList) { + Clob clobValue = (Clob) getAttrMap.get(clobField); + String fieldValue = FieldConvertUtil.ClobToString(clobValue); + getAttrMap.put(clobField, fieldValue); + } + } + + row.setAttrInfoMap(getAttrMap); + } + } + /** * 同步添加标准搜索中心数据内容 * @param standId diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java index 204645aa..63a74ddf 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussionessStand/service/impl/SarBussionessStandServiceImpl.java @@ -1404,7 +1404,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl