分阶段实施-法规预警修改展示逻辑,处理文档库插入ES数据逻辑。

This commit is contained in:
wangzhijiang
2023-02-28 17:55:40 +08:00
parent 70404ef599
commit f5a416378d
2 changed files with 180 additions and 14 deletions
@@ -1735,9 +1735,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
StringBuilder fieldsBuilder = new StringBuilder();
//数据值
StringBuilder valuesBuilder = new StringBuilder();
//sbCn sbEn 这两个字段作为es中英文切换
StringBuilder sbCn = new StringBuilder();
StringBuilder sbEn = new StringBuilder();
List<List<String>> fileTextList = new ArrayList<>();
List<OSSFile> oSSFileAll = new ArrayList<>();
Map<String,Object> stringObjectMap = new HashMap<>();
@@ -1750,7 +1748,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
Object value = entry.getValue();
//es全文新增数据(数据转换)
esFullText(cut, fieldList, categoryList, dictItemList, mapList, sbCn,sbEn, entry);
// esFullText(cut, fieldList, categoryList, dictItemList, mapList, sbCn,sbEn, entry);
if (ObjectUtils.isNotEmpty(value)) {
//处理日期格式
@@ -1798,6 +1796,27 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
e.printStackTrace();
}
// 将用户选择输入的新车型实施日期在产车实施日期备份出来如果不处理的话插入ES时会报 解析失败 错误
String implement_time = (String) map.get("implement_time");
String xin1_che1_xing2_shi2_shi1_ri4_qi1 = (String) map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1");
map.put("id", idTemp);
// 批量添加分阶段实施明细信息
this.insertBatchPhasedImplementationDetailsInfo(map);
//sbCn sbEn 这两个字段作为es中英文切换
StringBuilder sbCn = new StringBuilder();
StringBuilder sbEn = new StringBuilder();
for (Map.Entry<String, Object> entry : map.entrySet()) {
//es全文新增数据(数据转换)
esFullText(cut, fieldList, categoryList, dictItemList, mapList, sbCn,sbEn, entry);
}
// 将用户选择输入的在产车实施日期新车型实施日期恢复
map.put("implement_time",implement_time);
map.put("xin1_che1_xing2_shi2_shi1_ri4_qi1",xin1_che1_xing2_shi2_shi1_ri4_qi1);
//多文件es
List<String> fileIdList = oSSFileAll.stream().map(OSSFile::getId).collect(Collectors.toList());
@@ -1953,9 +1972,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String insertValue = mustValues + valuesBuilder.toString();
bussDocumentLibraryEOMapper.insertInfo(insertField, insertValue);
map.put("id", idTemp);
List<PhasedImplementationDetailsEO> phasedImplementationDetailsEOS = this.insertBatchPhasedImplementationDetailsInfo(map);
String replaceStandard = StringUtils.valueOf(map.get("replace_standard"));
if (StringUtils.isNotBlank(replaceStandard)) {
//新增时如果填写代替标准,需要向填写的代替标准的负责人发消息
@@ -2462,14 +2478,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
}
List<OSSFile> oSSFileAll = new ArrayList<>();
StringBuilder sbCn = new StringBuilder();
StringBuilder sbEn = new StringBuilder();
Map<String,Object> stringObjectMap = new HashMap<>();
for (Map.Entry<String, Object> entry : mapNew.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
//es全文新增数据(数据转换)
esFullText(cut, fieldList, categoryList, dictItemList, listMap, sbCn,sbEn, entry);
// esFullText(cut, fieldList, categoryList, dictItemList, listMap, sbCn,sbEn, entry);
if (ObjectUtils.isNotEmpty(value)) {
//处理修改人和修改时间
@@ -2535,6 +2549,24 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
//处理文件排序(发布稿 增补件 报批稿 征求意见稿 测试程序)
List<OSSFile> ossFileList = fileSort(fieldFileList, fileInfos, stringObjectMap);
// 将用户选择输入的新车型实施日期在产车实施日期备份出来如果不处理的话插入ES时会报 解析失败 错误
String implement_time = (String) map.get("implement_time");
String xin1_che1_xing2_shi2_shi1_ri4_qi1 = (String) map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1");
// 批量添加分阶段实施明细信息
this.insertBatchPhasedImplementationDetailsInfo(map);
StringBuilder sbCn = new StringBuilder();
StringBuilder sbEn = new StringBuilder();
for (Map.Entry<String, Object> entry : map.entrySet()) {
//es全文新增数据(数据转换)
esFullText(cut, fieldList, categoryList, dictItemList, listMap, sbCn,sbEn, entry);
}
// 将用户选择输入的在产车实施日期新车型实施日期恢复
map.put("implement_time",implement_time);
map.put("xin1_che1_xing2_shi2_shi1_ri4_qi1",xin1_che1_xing2_shi2_shi1_ri4_qi1);
List<Map<String, Object>> mapListTempCn = new ArrayList<>();
List<Map<String, Object>> mapListTempEn = new ArrayList<>();
String fileTextAll = "";
@@ -2650,8 +2682,6 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
bussDocumentLibraryEOMapper.deleteById((String) map.get("id"));
bussDocumentLibraryEOMapper.insertInfo(insertField, insertValue);
// 批量添加分阶段实施明细信息
List<PhasedImplementationDetailsEO> phasedImplDetailsEOList = this.insertBatchPhasedImplementationDetailsInfo(map);
map.put("module_type", "文档库");
map.put("module_type_flag", ModuleTypeFlagEnum.DOCUMENT_LIBRARY.getValue());
@@ -4870,6 +4900,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
QueryWrapper<PhasedImplementationDetailsEO> phasedImplDetailsQueryWrap = new QueryWrapper<>();
phasedImplDetailsQueryWrap.lambda().in(PhasedImplementationDetailsEO::getBussDocumentLibraryId,idList);
phasedImplDetailsEOList = this.phasedImplementationDetailsEOService.list(phasedImplDetailsQueryWrap);
this.phasedImplementationDetailsEOService.disposeData(phasedImplDetailsEOList,cut);
}
for (Map<String, Object> data : datas) {
@@ -4901,8 +4932,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if(StringUtils.isNotEmpty(detailsEO.getStandNumberOrClause())){
phasedImplDetailsSbTemp.append(detailsEO.getStandNumberOrClause()).append("<n>");
}
if(StringUtils.isNotEmpty(detailsEO.getImplementationType())){
phasedImplDetailsSbTemp.append(detailsEO.getImplementationType()).append("<n>");
if(StringUtils.isNotEmpty(detailsEO.getImplementationTypeText())){
phasedImplDetailsSbTemp.append(detailsEO.getImplementationTypeText()).append("<n>");
}
if(detailsEO.getImplementationDate()!=null){
phasedImplDetailsSbTemp.append(DateUtils.formatTime(detailsEO.getImplementationDate())).append("<n>");
@@ -6874,6 +6905,55 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if(!insertPhasedBatchFlag){
throw new JeroBootException("添加分阶段实施详情信息失败!");
}
// 处理插入ES数据的正文 新车型在产车实施日期信息
// 处理新车型实施日期
List<Date> newCarModelDateList = phasedImplDetailsEOList.stream().filter(phasedDetails -> {
boolean flag = false;
if (StringUtils.contains(phasedDetails.getImplementationType(), ImplementationTypeEnum.NEW_CAR_MODEL.getItemValue())) {
flag = true;
}
return flag;
}).map(PhasedImplementationDetailsEO::getImplementationDate).collect(Collectors.toList());
Date newCarModelDate = null;
try {
if (StringUtils.isNotEmpty((String) map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"))) {
newCarModelDate = DateUtils.parseDate((String) map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"), "yyyy-MM-dd");
}
} catch (ParseException e) {
e.printStackTrace();
}
if(newCarModelDate != null){
newCarModelDateList.add(newCarModelDate);
}
String newCarModelDateStr = DateUtils.formatDateList(newCarModelDateList);
map.put("xin1_che1_xing2_shi2_shi1_ri4_qi1",newCarModelDateStr);
// 处理在产车实施日期
List<Date> carInProductionDateList = phasedImplDetailsEOList.stream().filter(phasedDetails -> {
boolean flag = false;
if (StringUtils.contains(phasedDetails.getImplementationType(), ImplementationTypeEnum.CAR_IN_PRODUCTION.getItemValue())) {
flag = true;
}
return flag;
}).map(PhasedImplementationDetailsEO::getImplementationDate).collect(Collectors.toList());
Date carInProductionDateDate = null;
try {
if (StringUtils.isNotEmpty((String) map.get("implement_time"))) {
carInProductionDateDate = DateUtils.parseDate((String) map.get("implement_time"), "yyyy-MM-dd");
}
} catch (ParseException e) {
e.printStackTrace();
}
if(carInProductionDateDate != null){
carInProductionDateList.add(carInProductionDateDate);
}
String carInProductionDateStr = DateUtils.formatDateList(carInProductionDateList);
map.put("implement_time",carInProductionDateStr);
}
return phasedImplDetailsEOList;
@@ -1,5 +1,6 @@
package com.jero.modules.warn.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.constant.enums.CutEnum;
@@ -7,11 +8,16 @@ import com.jero.common.constant.enums.MessageTypeEnum;
import com.jero.common.constant.enums.ModuleEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.DateUtils;
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
import com.jero.modules.document.entity.PhasedImplementationDetailsEO;
import com.jero.modules.document.enums.FieldTypeEnum;
import com.jero.modules.document.enums.ImplementationTypeEnum;
import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper;
import com.jero.modules.document.service.IPhasedImplementationDetailsEOService;
import com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl;
import com.jero.modules.dummy.entity.DummyInventoryInfoEO;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.feishu.vo.FeishuMsgVo;
import com.jero.modules.system.entity.SysAnnouncement;
@@ -24,6 +30,7 @@ import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
@@ -82,6 +89,8 @@ public class LawsWarnService {
private ISysAnnouncementService sysAnnouncementService;
@Resource
private IFeishuService iFeishuService;
@Autowired
private IPhasedImplementationDetailsEOService phasedImplementationDetailsEOService;
public IPage getInfoPage(Map<String, Object> parameter) {
String cut = (String) parameter.get("cut");//中英文切换标识
@@ -183,8 +192,85 @@ public class LawsWarnService {
}
}
}
this.disposeData(records,cut);
return infoPage;
}
private void disposeData(List<Map> datas, String cut) {
if(CollectionUtils.isNotEmpty(datas)){
List<String> bussDocumentLibraryIdList = datas.stream().map(data -> (String) data.get("id")).distinct().collect(Collectors.toList());
QueryWrapper<PhasedImplementationDetailsEO> phasedDetailsQueryWrap = new QueryWrapper<>();
phasedDetailsQueryWrap.lambda().in(PhasedImplementationDetailsEO::getBussDocumentLibraryId,bussDocumentLibraryIdList);
List<PhasedImplementationDetailsEO> phasedDetailsList = this.phasedImplementationDetailsEOService.list(phasedDetailsQueryWrap);
// 新车型分阶段实施数据信息
List<PhasedImplementationDetailsEO> newCarModelPhasedDetailsList = phasedDetailsList.stream().filter(phasedDetails -> {
boolean flag = false;
if(org.apache.commons.lang3.StringUtils.contains(phasedDetails.getImplementationType(), ImplementationTypeEnum.NEW_CAR_MODEL.getItemValue())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
// 在产车分阶段实施数据信息
List<PhasedImplementationDetailsEO> carInProductionPhasedDetailsList = phasedDetailsList.stream().filter(phasedDetails -> {
boolean flag = false;
if(org.apache.commons.lang3.StringUtils.contains(phasedDetails.getImplementationType(), ImplementationTypeEnum.CAR_IN_PRODUCTION.getItemValue())){
flag = true;
}
return flag;
}).collect(Collectors.toList());
for (Map data : datas) {
String bussDocumentLibraryId = (String) data.get("id");
// 处理新车型实施日期展示
List<Date> newCarModelDateList = newCarModelPhasedDetailsList.stream().filter(phasedDetails -> {
boolean flag = false;
if (org.apache.commons.lang3.StringUtils.equals(phasedDetails.getBussDocumentLibraryId(), bussDocumentLibraryId)) {
flag = true;
}
return flag;
}).map(PhasedImplementationDetailsEO::getImplementationDate).collect(Collectors.toList());
Date newCarModelDate = null;
try {
newCarModelDate = DateUtils.parseDate((String) data.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"), "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
if(newCarModelDate != null){
newCarModelDateList.add(newCarModelDate);
}
String newCarModelDateStr = DateUtils.formatDateList(newCarModelDateList);
data.put("xin1_che1_xing2_shi2_shi1_ri4_qi1",newCarModelDateStr);
// 处理在产车实施日期展示
List<Date> carInProductionDateList = carInProductionPhasedDetailsList.stream().filter(phasedDetails -> {
boolean flag = false;
if (org.apache.commons.lang3.StringUtils.equals(phasedDetails.getBussDocumentLibraryId(), bussDocumentLibraryId)) {
flag = true;
}
return flag;
}).map(PhasedImplementationDetailsEO::getImplementationDate).collect(Collectors.toList());
Date implementTime = null;
try {
implementTime = DateUtils.parseDate((String) data.get("implement_time"), "yyyy-MM-dd");
} catch (ParseException e) {
e.printStackTrace();
}
if(implementTime != null){
carInProductionDateList.add(implementTime);
}
String carInProductionDateStr = DateUtils.formatDateList(carInProductionDateList);
data.put("implement_time",carInProductionDateStr);
}
}
}
private String beforeTime (int month, Date date){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendarBefore = Calendar.getInstance();