feat: There is no way the Buss and Convert

This commit is contained in:
super_liu
2021-08-20 14:07:37 +08:00
parent 97b1b92acc
commit d176d93d6b
24 changed files with 1046 additions and 673 deletions
@@ -1,408 +1,291 @@
//package com.adc.da.mq.service;
//
//import com.adc.da.lawss.entity.OtSvppsEO;
//import com.adc.da.lawss.entity.SarBussionessStandEO;
//import com.adc.da.lawss.entity.SarFullNumEO;
//import com.adc.da.lawss.page.SarFullNumEOPage;
//import com.adc.da.lawss.service.OtSvppsEOService;
//import com.adc.da.lawss.service.SarFullNumEOService;
//import com.adc.da.lawss.service.SarStandAndLawsEOService;
//import com.adc.da.lawss.service.SysInfoEOService;
//import com.adc.da.search.entity.StandLawsEO;
//import com.adc.da.slrs.otSvpps.service.IOtSvppsService;
//import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
//import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
//import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
//import com.adc.da.sys.dao.DicTypeEODao;
//import com.adc.da.utils.util.InitStandAttrUtil;
//import com.rabbitmq.client.Channel;
//import net.sf.json.JSONObject;
//import org.apache.commons.lang.StringUtils;
//import org.json.JSONTokener;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.rabbit.annotation.Exchange;
//import org.springframework.amqp.rabbit.annotation.Queue;
//import org.springframework.amqp.rabbit.annotation.QueueBinding;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.support.AmqpHeaders;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.messaging.Message;
//import org.springframework.stereotype.Component;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import java.util.stream.Collectors;
//
//@Component
//public class SendBussMQService {
//
// @Autowired
// private ISarStandardsInfoService sarStandardsInfoService;
//
// @Autowired
// private SysInfoEOService sysInfoEOService;
//
// @Autowired
// private DicTypeEODao dicTypeEODao;
//
// @Autowired
// private IOtSvppsService otSvppsEOService;
//
// private static final Logger logger = LoggerFactory.getLogger(SendBussMQService.class);
//
//
// @RabbitListener(bindings = @QueueBinding(
// value = @Queue(value = "createBussMQ_SQ_GSAR", durable = "true"),
// exchange = @Exchange(value = "buss-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
// key = "buss-key_SQ_GSAR"))
// public void createMQ(Map<String,Object> bussMap, Message message, Channel channel) throws Exception{
// try{
// try{
// Thread.sleep(5000);
// insertOrUpdateBussInfo(bussMap);
// }catch(InterruptedException e){
// logger.error(e.toString());
// Thread.currentThread().interrupt();
// }
// } catch (Exception e) {
// logger.error("搜索中心企业标准消息队列进入转换前失败!");
// logger.error(e.getMessage(),e);
// } finally {
// Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
// channel.basicAck(tag,false);
// logger.debug("消息确认成功!!!!!!!!!");
// }
// }
//
// public void insertOrUpdateBussInfo(Map<String,Object> bussMap) throws Exception {
// String addOrUpdate = bussMap.get("addOrUpdate").toString();
// String FZRQFSRQ = null;
// if ("updateFromAct".equals(addOrUpdate)){
// addOrUpdate = "update";
// FZRQFSRQ = "1";
// }
// String sarBuss = bussMap.get("sarBuss").toString();
// JSONObject jsonobject = JSONObject.fromObject(sarBuss);
// SarBussionessStand infoEO = (SarBussionessStand) JSONObject.toBean(jsonobject, SarBussionessStand.class);
// String jsonobject1 = infoEO.getSarStandAttrEOStr();
// Map<String,Object> map1 = new HashMap<>();
// if (StringUtils.isEmpty(jsonobject1)){
// map1.put("null","null");
// }else {
// map1 = JSONObject.fromObject(jsonobject1);
// }
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// //修改索引信息表
// // 往索引表中插入数据
// String baseSearchContent = "";
// String getCodeName = "";
// Map<String,Object> saveMap = new HashMap<>();
// String a = null;
// try{
// a = sdf.format(infoEO.getIssueTime());
// saveMap.put("issue_time"," "+a);
// }catch (Exception e){
// saveMap.put("issue_time"," ");
// }
//
//
//
// //发布日期 高级查询
// Date issue_time_data = null;
// if (StringUtils.isNotBlank(a)) {
// try {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// issue_time_data = format.parse(saveMap.get("issue_time")+" 00:00:00");
// } catch (ParseException ignored) {
// }
// }
// if (issue_time_data != null) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(issue_time_data);
// int month = calendar.get(Calendar.MONTH)+1;
// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
// saveMap.put("issue_time_data",Long.valueOf(times));
// }else{
// saveMap.put("issue_time_data",-1000000000000000000L);
// }
//
// try{
// saveMap.put("put_time"," "+ sdf.format(infoEO.getPutTime()));
// }catch (Exception e){
// saveMap.put("put_time"," ");
// }
//
// //实施日期 高级查询
// Date put_time_data = null;
// if (StringUtils.isNotBlank(a)) {
// try {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// put_time_data = format.parse(saveMap.get("put_time")+" 00:00:00");
// } catch (ParseException ignored) {
// }
// }
// if (put_time_data != null) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(put_time_data);
// int month = calendar.get(Calendar.MONTH)+1;
// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
// saveMap.put("put_time_data",Long.valueOf(times));
// }else{
// saveMap.put("put_time_data",-1000000000000000000L);
// }
//// saveMap.put("put_time",sdf.format(infoEO.getPutTime()));
//
// saveMap.put("id",infoEO.getId());
// saveMap.put("standSort",infoEO.getStandSort());
// saveMap.put("stand_sort",infoEO.getStandSort());
// if(StringUtils.isNotEmpty(infoEO.getStandSort())){
// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort());
// saveMap.put("standSortShow",codeName);
// getCodeName = codeName;
// }
// String realContent = "";
// if (map1.containsKey("QBWB")) {
// String content = String.valueOf(map1.get("QBWB"));
// String[] ids = content.split(",");
// for (String id :ids) {
// if (!"null".equals(id) && StringUtils.isNotBlank(id)) {
// if ("".equals(realContent)) {
// realContent += id;
// } else {
// realContent = realContent + "," + id;
// }
// }
// }
// }
// if (map1.containsKey("GCWB")) {
// String content = String.valueOf(map1.get("GCWB"));
// String[] ids = content.split(",");
// for (String id :ids) {
// if (!"null".equals(id) && StringUtils.isNotBlank(id)) {
// if ("".equals(realContent)) {
// realContent += id;
// } else {
// realContent = realContent + "," + id;
// }
// }
// }
// }
// saveMap.put("content",realContent);
// saveMap.put("standYear",infoEO.getStandYear());
// saveMap.put("stand_year",infoEO.getStandYear());
// saveMap.put("standNumber",infoEO.getStandCode());
// saveMap.put("stand_code",infoEO.getStandCode());
// saveMap = dealNumberMsg(saveMap,infoEO,getCodeName);
// saveMap.put("nameshow",infoEO.getStandName());
// saveMap.put("stand_name",infoEO.getStandName());
// saveMap.put("standEnName",infoEO.getStandEnName());
// saveMap.put("stand_en_name",infoEO.getStandEnName());
// saveMap.put("replaceStandNum",infoEO.getReplaceStandNum());
// saveMap.put("replace_stand_num",infoEO.getReplaceStandNum());
// saveMap.put("replacedStandNum",infoEO.getReplacedStandNum());
// saveMap.put("replaced_stand_num",infoEO.getReplacedStandNum());
// saveMap.put("statecode",infoEO.getStandStatus());
// saveMap.put("stand_status",infoEO.getStandStatus());
// if (StringUtils.isNotEmpty(infoEO.getStandStatus())) {
// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandStatus());
// saveMap.put("standstateshow",codeName);
// }
// //新加字段
// saveMap.put("country",infoEO.getApplyCountry());
// if(StringUtils.isNotEmpty(infoEO.getApplyCountry())){
// String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getApplyCountry());
// saveMap.put("countryShow",codeName);
// }
// // 自定义属性字段
// String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
// Map<String,Object> attrInfoMap = new HashMap<>();
// if (StringUtils.isEmpty(sarStandAttrEOStr)){
// attrInfoMap.put("null","null");
// }else {
// attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
// }
// if (attrInfoMap != null && !attrInfoMap.isEmpty()) {
// attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "bussstand",baseSearchContent);
// saveMap.putAll(attrInfoMap);
// }
// String FSRQ = null;
// if (attrInfoMap != null) {
// if (attrInfoMap.containsKey("FSRQ")){
// if ("1".equals(FZRQFSRQ)){
// Long times = Long.valueOf(String.valueOf(attrInfoMap.get("FSRQ")).trim());
// Date fsrq1 = new Date(times);
// attrInfoMap.put("FSRQ",sdf.format(fsrq1));
// }
// try{
// if (String.valueOf(attrInfoMap.get("FSRQ")).trim().length()>10) {
// FSRQ = String.valueOf(attrInfoMap.get("FSRQ")).trim().substring(0, 10) + " 00:00:00";
// }else{
// FSRQ = String.valueOf(attrInfoMap.get("FSRQ")).trim() + " 00:00:00";
// }
//
// saveMap.put("FSRQString"," "+FSRQ.substring(0, 10));
// saveMap.put("FSRQDate"," "+FSRQ.substring(0, 10).replace("-",""));
// FSRQ = String.valueOf(FSRQ.substring(0, 10).replace("-",""));
// saveMap.put("FSRQ"," "+FSRQ);
// }catch (Exception e){
// saveMap.put("FSRQString"," ");
// saveMap.put("FSRQDate"," "+" ");
// }
// }else{
// saveMap.put("FSRQString"," ");
// saveMap.put("FSRQDate"," "+" ");
// }
// }
//
// String FZRQ = null;
// if (attrInfoMap != null && attrInfoMap.containsKey("FZRQ")) {
// if ("1".equals(FZRQFSRQ)){
// Long times = Long.valueOf(String.valueOf(attrInfoMap.get("FZRQ")).trim());
// Date fzrq1 = new Date(times);
// String timeFzrq = sdf.format(fzrq1);
// if (timeFzrq.trim().length()>10){
// timeFzrq = timeFzrq.trim().substring(0,10);
// }
// attrInfoMap.put("FZRQ",timeFzrq);
// }
//
// try{
// if (String.valueOf(attrInfoMap.get("FZRQ")).trim().length()>10) {
// FZRQ = String.valueOf(attrInfoMap.get("FZRQ")).trim().substring(0, 10) + " 00:00:00";
// }else{
// FZRQ = String.valueOf(attrInfoMap.get("FZRQ")).trim() + " 00:00:00";
// }
//
// saveMap.put("FZRQString"," "+FZRQ.substring(0,10));
// saveMap.put("FZRQDate"," "+FZRQ.replace("-",""));
// FZRQ = String.valueOf(sdf.parse(FZRQ).getTime());
// saveMap.put("FZRQ"," "+FZRQ);
// }catch (Exception e) {
// saveMap.put("FZRQString", " " + FZRQ);
// saveMap.put("FZRQDate"," "+" ");
// }
// } else {
// saveMap.put("FZRQString", " ");
// saveMap.put("FZRQDate"," "+" ");
// }
//
// //废止日期 高级查询
// Date fzrq_time_data = null;
// if (StringUtils.isNotBlank(a)) {
// try {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// fzrq_time_data = format.parse(saveMap.get("FZRQString")+" 00:00:00");
// } catch (ParseException ignored) {
// }
// }
// if (fzrq_time_data != null) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(fzrq_time_data);
// int month = calendar.get(Calendar.MONTH)+1;
// String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
// saveMap.put("FZRQ",Long.valueOf(times));
// }else{
// saveMap.put("FZRQ",-1000000000000000000L);
// }
// saveMap.put("type","bussstand");
//
// String fieldInfo = InitStandAttrUtil.queryField;
// List<String> fieldInfoList = Arrays.asList(fieldInfo .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList());
//
// // 动态存储属性字段
// for (String field : fieldInfoList) {
// saveMap.put(field,attrInfoMap.getOrDefault(field,""));
// String fieldValue = "";
// if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){
// Object json= new JSONTokener(infoMap.get(field).toString()).nextValue();
// if(!json.toString().equals("null")){
// fieldValue = infoMap.get(field).toString();
// }
// }
// saveMap.put(field+"Name",fieldValue);
// }
//
// //添加次数
// SarFullNumEOPage sarFullNumEOPage = new SarFullNumEOPage();
// sarFullNumEOPage.setSarId(infoEO.getId());
// List<SarFullNumEO> sarFullNumEOList = sarFullNumEOService.queryByList(sarFullNumEOPage);
// String num = "";
// if (null != sarFullNumEOList && !sarFullNumEOList.isEmpty()){
// num = sarFullNumEOList.get(0).getReadNum();
// }
// if (StringUtils.isEmpty(num)){
// saveMap.put("readNum", 0L);
// }else {
// saveMap.put("readNum", Long.valueOf(num));
// }
// if (saveMap.containsKey("QBMJ") && null != saveMap.get("QBMJ") && !String.valueOf(saveMap.get("QBMJ")).equals("ACF675Z88W")) {
// saveMap.put("baseSearchContent", baseSearchContent);
// saveMap.put("validFlag", "0");
// saveMap.put("content", infoEO.getFileIds());
// if ("add".equals(addOrUpdate)) {
// sarStandAndLawsEOService.insertIntoIndexForMap(saveMap);
// } else {
// sarStandAndLawsEOService.updateIntoIndexForMap(saveMap);
// }
// }else{
// if (saveMap.containsKey("QBMJ") && null != saveMap.get("QBMJ") && String.valueOf(saveMap.get("QBMJ")).equals("ACF675Z88W")){
// StandLawsEO standLawsEO = new StandLawsEO();
// standLawsEO.setId(infoEO.getId());
// standLawsEO.setType("bussstand");
// sarStandAndLawsEOService.deleteFomrIndex(standLawsEO);
// }else{
// if ("add".equals(addOrUpdate)) {
// sarStandAndLawsEOService.insertIntoIndexForMap(saveMap);
// } else {
// sarStandAndLawsEOService.updateIntoIndexForMap(saveMap);
// }
// }
// }
// }
//
// public Map<String,Object> dealNumberMsg (Map<String,Object> saveMap,SarBussionessStand infoEO,String getCodeName) {
// /*if(StringUtils.isNotEmpty(infoEO.getStandYear())){
// String num = getCodeName + " " + infoEO.getStandCode() + "-" + infoEO.getStandYear();
// saveMap.put("numbershow",num);
// int index = infoEO.getStandCode().indexOf(".");
// int index1 = infoEO.getStandCode().indexOf(":");
// String numberExpNull = "";
// if(index > -1){
// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
// + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
// }else if(index1 > -1){
// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
// + "-" + getCodeName + infoEO.getStandCode().substring(0,index1) + "-" + infoEO.getStandCode().substring(0,index1);
// }else{
// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","");
// }
// } else {
// String number = getCodeName + " " + infoEO.getStandCode();
// saveMap.put("numbershow",number);
// String numberExpNull = "";
// int index = infoEO.getStandCode().indexOf(".");
// if(index > -1){
// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","")
// + "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
// }else{
// numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","");
// }
// saveMap.put("numberExpNull",numberExpNull);
// }*/
// String number = infoEO.getStandCode();
// saveMap.put("numbershow",number);
// String numberExpNull = "";
// int index = infoEO.getStandCode().indexOf(".");
// if(index > -1){
// numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","")
// + "-" + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
// }else{
// numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","");
// }
// saveMap.put("numberExpNull",numberExpNull);
// return saveMap;
// }
//
//}
package com.adc.da.mq.service;
import com.adc.da.search.entity.StandLawsEO;
import com.adc.da.slrs.otSvpps.service.IOtSvppsService;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.utils.util.InitStandAttrUtil;
import com.rabbitmq.client.Channel;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class SendBussMQService {
@Autowired
private ISarStandardsInfoService sarStandardsInfoService;
@Autowired
private SysInfoEOService sysInfoEOService;
@Autowired
private DicTypeEODao dicTypeEODao;
@Autowired
private IOtSvppsService otSvppsEOService;
private static final Logger logger = LoggerFactory.getLogger(SendBussMQService.class);
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "createBussMQ_SQ_GSAR", durable = "true"),
exchange = @Exchange(value = "buss-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
key = "buss-key_SQ_GSAR"))
public void createMQ(Map<String,Object> bussMap, Message message, Channel channel) throws Exception{
try{
try{
Thread.sleep(5000);
insertOrUpdateBussInfo(bussMap);
}catch(InterruptedException e){
logger.error(e.toString());
Thread.currentThread().interrupt();
}
} catch (Exception e) {
logger.error("搜索中心企业标准消息队列进入转换前失败!");
logger.error(e.getMessage(),e);
} finally {
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
channel.basicAck(tag,false);
logger.debug("消息确认成功!!!!!!!!!");
}
}
public void insertOrUpdateBussInfo(Map<String,Object> bussMap) throws Exception {
String addOrUpdate = bussMap.get("addOrUpdate").toString();
String FZRQFSRQ = null;
if ("updateFromAct".equals(addOrUpdate)){
addOrUpdate = "update";
FZRQFSRQ = "1";
}
String sarBuss = bussMap.get("sarBuss").toString();
JSONObject jsonobject = JSONObject.fromObject(sarBuss);
SarBussionessStand infoEO = (SarBussionessStand) JSONObject.toBean(jsonobject, SarBussionessStand.class);
String jsonobject1 = infoEO.getSarStandAttrEOStr();
Map<String,Object> map1 = new HashMap<>();
if (StringUtils.isEmpty(jsonobject1)){
map1.put("null","null");
}else {
map1 = JSONObject.fromObject(jsonobject1);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//修改索引信息表
// 往索引表中插入数据
String baseSearchContent = "";
String getCodeName = "";
Map<String,Object> saveMap = new HashMap<>();
String a = null;
try{
a = sdf.format(infoEO.getIssueTime());
saveMap.put("issue_time"," "+a);
}catch (Exception e){
saveMap.put("issue_time"," ");
}
//发布日期 高级查询
Date issue_time_data = null;
if (StringUtils.isNotBlank(a)) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
issue_time_data = format.parse(saveMap.get("issue_time")+" 00:00:00");
} catch (ParseException ignored) {
}
}
if (issue_time_data != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(issue_time_data);
int month = calendar.get(Calendar.MONTH)+1;
String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
saveMap.put("issue_time_data",Long.valueOf(times));
}else{
saveMap.put("issue_time_data",-1000000000000000000L);
}
try{
saveMap.put("put_time"," "+ sdf.format(infoEO.getPutTime()));
}catch (Exception e){
saveMap.put("put_time"," ");
}
//实施日期 高级查询
Date put_time_data = null;
if (StringUtils.isNotBlank(a)) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
put_time_data = format.parse(saveMap.get("put_time")+" 00:00:00");
} catch (ParseException ignored) {
}
}
if (put_time_data != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(put_time_data);
int month = calendar.get(Calendar.MONTH)+1;
String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
saveMap.put("put_time_data",Long.valueOf(times));
}else{
saveMap.put("put_time_data",-1000000000000000000L);
}
// saveMap.put("put_time",sdf.format(infoEO.getPutTime()));
saveMap.put("id",infoEO.getId());
saveMap.put("standSort",infoEO.getStandSort());
saveMap.put("stand_sort",infoEO.getStandSort());
if(StringUtils.isNotEmpty(infoEO.getStandSort())){
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort());
saveMap.put("standSortShow",codeName);
getCodeName = codeName;
}
saveMap.put("standYear",infoEO.getStandYear());
saveMap.put("stand_year",infoEO.getStandYear());
saveMap.put("standNumber",infoEO.getStandCode());
saveMap.put("stand_code",infoEO.getStandCode());
saveMap = dealNumberMsg(saveMap,infoEO,getCodeName);
saveMap.put("nameshow",infoEO.getStandName());
saveMap.put("stand_name",infoEO.getStandName());
saveMap.put("standEnName",infoEO.getStandEnName());
saveMap.put("stand_en_name",infoEO.getStandEnName());
saveMap.put("replaceStandNum",infoEO.getReplaceStandNum());
saveMap.put("replace_stand_num",infoEO.getReplaceStandNum());
saveMap.put("replacedStandNum",infoEO.getReplacedStandNum());
saveMap.put("replaced_stand_num",infoEO.getReplacedStandNum());
saveMap.put("statecode",infoEO.getStandStatus());
saveMap.put("stand_status",infoEO.getStandStatus());
if (StringUtils.isNotEmpty(infoEO.getStandStatus())) {
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandStatus());
saveMap.put("standstateshow",codeName);
}
//新加字段
saveMap.put("country",infoEO.getApplyCountry());
if(StringUtils.isNotEmpty(infoEO.getApplyCountry())){
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getApplyCountry());
saveMap.put("countryShow",codeName);
}
// 自定义属性字段
String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
Map<String,Object> attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
Map<String,Object> infoMap = infoEO.getAttrInfoMap();
if (attrInfoMap != null && !attrInfoMap.isEmpty()) {
attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "stand",baseSearchContent);
saveMap.putAll(attrInfoMap);
}
saveMap.put("type","bussstand");
saveMap.put("validFlag","0");
saveMap.put("content",infoEO.getFileIds());
String fieldInfo = InitStandAttrUtil.queryField;
List<String> fieldInfoList = Arrays.asList(fieldInfo .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList());
// 动态存储属性字段
for (String field : fieldInfoList) {
saveMap.put(field,attrInfoMap.getOrDefault(field,""));
String fieldValue = "";
if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){
Object json= new JSONTokener(infoMap.get(field).toString()).nextValue();
if(!json.toString().equals("null")){
fieldValue = infoMap.get(field).toString();
}
}
saveMap.put(field+"Name",fieldValue);
}
//当建立代替时,产生的没有文件的问题
if (StringUtils.isBlank(String.valueOf(saveMap.get("content")))) {
String context = filterStringIsNotBlank(String.valueOf(saveMap.get("FBGBUSS")),true)
+ filterStringIsNotBlank(String.valueOf(saveMap.get("BZSMBUSS")),true)
+ filterStringIsNotBlank(String.valueOf(saveMap.get("LSBBBUSS")),true)
+ filterStringIsNotBlank(String.valueOf(saveMap.get("QTWJBUSS")),true)
+ filterStringIsNotBlank(String.valueOf(saveMap.get("GLWJBUSS")),true);
context = context.replace(",,", ",");
saveMap.put("content", context);
}
if("add".equals(addOrUpdate)){
sarStandardsInfoService.insertIntoIndexForMap(saveMap);
} else {
sarStandardsInfoService.updateIntoIndexForMap(saveMap);
}
}
private String filterStringIsNotBlank(String str,boolean boo){
String f = ",";
return (str == null || str.equals("") || str.equals("null")) ? "" : (boo ? str+f : str);
}
private String dateFormatToStr(String dateStr){
if(dateStr == null || dateStr.equals("")){
return "";
}
String dateToStr = "";
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateToStr = dateFormat.format(dateFormat.parse(dateStr.trim().substring(0,10)));
}catch (Exception e){
e.getMessage();
}
return dateToStr;
}
public Map<String,Object> dealNumberMsg (Map<String,Object> saveMap,SarBussionessStand infoEO,String getCodeName) {
/*if(StringUtils.isNotEmpty(infoEO.getStandYear())){
String num = getCodeName + " " + infoEO.getStandCode() + "-" + infoEO.getStandYear();
saveMap.put("numbershow",num);
int index = infoEO.getStandCode().indexOf(".");
int index1 = infoEO.getStandCode().indexOf(":");
String numberExpNull = "";
if(index > -1){
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
}else if(index1 > -1){
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index1) + "-" + infoEO.getStandCode().substring(0,index1);
}else{
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","");
}
} else {
String number = getCodeName + " " + infoEO.getStandCode();
saveMap.put("numbershow",number);
String numberExpNull = "";
int index = infoEO.getStandCode().indexOf(".");
if(index > -1){
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
}else{
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","");
}
saveMap.put("numberExpNull",numberExpNull);
}*/
String number = infoEO.getStandCode();
saveMap.put("numbershow",number);
String numberExpNull = "";
int index = infoEO.getStandCode().indexOf(".");
if(index > -1){
numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","")
+ "-" + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
}else{
numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","");
}
saveMap.put("numberExpNull",numberExpNull);
return saveMap;
}
}
@@ -67,7 +67,7 @@ public class SarBussStandFile extends BaseEntity {
@ApiModelProperty(value = "是否有效")
@TableField("VALID_FLAG")
private String validFlag;
private Integer validFlag;
@ApiModelProperty(value = "创建时间")
@TableField("CREATION_TIME")
@@ -86,4 +86,13 @@ public class SarBussStandFile extends BaseEntity {
@TableField(exist = false)
private List<String> idList = new ArrayList<>();
@TableField(exist = false)
private String useModule;
@TableField(exist = false)
private String resId;
@TableField(exist = false)
private Integer pageCount;
@TableField(exist = false)
private String fileOldName;
}
@@ -10,10 +10,10 @@ import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.sys.entity.DicTypeEO;
import com.adc.da.sys.service.IDicTypeEOService;
import com.adc.da.sys.util.LoginUserUtil;
import com.adc.da.http.PageInfo;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.utils.StringUtils;
import com.adc.da.utils.util.SarAdvanceSearchUtil;
import com.alibaba.fastjson.JSONObject;
@@ -168,33 +168,15 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
page.setAdvanceSearchStr(null);
}
}
page.setUserId(LoginUserUtil.getUserId());
if(page.getUserId() == null || page.getUserId().equals("")){
page.setUserId(LoginUserUtil.getUserId());
}
if(StringUtils.isNotBlank(page.getPaixu())){
String sql = page.getPaixu()+" "+page.getShunxu();
page.setSql(sql);
}else{
page.setOrderBy("SAR_BUSSIONESS_STAND.MODIFY_TIME DESC");
}
if(page.getMenuId() != null ){
QueryWrapper<TsResource> qw = new QueryWrapper<>();
qw.eq("ID",page.getMenuId());
qw.isNull("PARENT_ID");
List<TsResource> children = iTsResourceService.list(qw);
if(!children.isEmpty() || page.getMenuId().equals("nomenu")){
List<SarBussionessStand> rows = sarBussionessStandEOService.getSarBussionStandPage(page);
return Result.success(getPageInfo(page.getPager(), rows));
}
List<String> getMenuIdList = tsUserService.getResourceId(new TsResource());
if (getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
} else {
page.setMenuRoleList(null);
}
List<String> ids = iTsResourceService.getChildMenuList(page.getMenuId());
if (ids != null && !ids.isEmpty()) {
page.setMenuAllChildrenIdList(ids);
}
}
List<SarBussionessStand> rows = sarBussionessStandEOService.getSarBussionStandPage(page);
return Result.success(getPageInfo(page.getPager(), rows));
// if (StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) {
@@ -180,6 +180,9 @@ public class SarBussionessStand extends BaseEntity {
@TableField(exist = false)
private Map<String, Object> attrInfoMap = new LinkedHashMap<>(); //属性表字段与值
@TableField(exist = false)
private Map<String, Object> attrInfoCaseMap = new LinkedHashMap<>(); //属性表字段与值小写前端带入渲染
@TableField(exist = false)
private String sarStandAttrEOStr; //新增修改时属性表信息
@@ -6,6 +6,7 @@ import com.adc.da.common.ConvertMqEO;
import com.adc.da.common.SarTypeEnum;
import com.adc.da.common.SelectionTypeEnum;
import com.adc.da.common.UseModuleEnum;
import com.adc.da.http.Result;
import com.adc.da.mq.dao.OtConvertEODao;
import com.adc.da.mq.service.CreateMQService;
import com.adc.da.mq.service.CreateStandMQService;
@@ -27,6 +28,7 @@ import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarResource.entity.TsResource;
import com.adc.da.slrs.sarResource.service.ITsResourceService;
import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
import com.adc.da.slrs.sarStandFile.entity.SarStandFile;
import com.adc.da.slrs.sarStandardsInfo.dao.SarStandardsInfoDao;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
@@ -42,9 +44,11 @@ import com.adc.da.sys.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -89,6 +93,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired
private ITsResourceService iTsResourceService;
@Autowired
private SarStandAttrInfoDao sarStandAttrInfoEODao;
@Autowired
private SysInfoEOService sysInfoEOService;
@@ -423,7 +430,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
sarStandFileEO.setCreationUser(LoginUserUtil.getUserId());
sarStandFileEO.setCreationTime(new Date());
sarStandFileEO.setModifyTime(new Date());
sarStandFileEO.setValidFlag("0");
sarStandFileEO.setValidFlag(0);
sarStandFileEO.setStandId(standId); //标准ID
sarStandFileEO.setUseModel(UseModuleEnum.SOURCE_FILE.getValue()); //文件使用模式
sarStandFileEO.setId(com.adc.da.sys.util.UUIDUtils.randomUUID20());
@@ -439,7 +446,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
newFileEO.setCreationUser(LoginUserUtil.getUserId());
newFileEO.setCreationTime(new Date());
newFileEO.setModifyTime(new Date());
newFileEO.setValidFlag("0");
newFileEO.setValidFlag(0);
newFileEO.setStandId(standId); //标准ID
newFileEO.setId(com.adc.da.sys.util.UUIDUtils.randomUUID20());
newFileEO.setAttId(fileInfo.getId()); //文件ID
@@ -501,13 +508,13 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
for (Map.Entry<String, Object> entry : getAttrMap.entrySet()) {
String name = entry.getKey();
String value = "";
if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) {
if (entry.getValue() != null && InitStandAttrUtil.fileFieldListBuss != null && InitStandAttrUtil.fileFieldListBuss.size() > 0 && InitStandAttrUtil.fileFieldListBuss.contains(name)) {
value = entry.getValue().toString();
if (org.apache.commons.lang3.StringUtils.isNotBlank(value)) {
if (StringUtils.isNotBlank(value)) {
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
entry.setValue(fileObj);
}
}else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
}else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
value = entry.getValue().toString();
List<String> valArr = Arrays.asList(value.split(","));
value = dicTypeEODao.getDicNamesByCodes(valArr);
@@ -564,6 +571,26 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Override
public List<SarBussionessStand> getSarBussionStandPage(SarBussionessStandEOPage page) throws Exception {
//查询当前登录人角色拥有权限的菜单
if(page.getMenuId() != null && page.getUserId() != null && StringUtils.isNotBlank(page.getUserId())){
QueryWrapper<TsResource> qw = new QueryWrapper<>();
qw.eq("ID",page.getMenuId());
qw.isNull("PARENT_ID");
List<TsResource> children = iTsResourceService.list(qw);
if(children.isEmpty() && !page.getMenuId().equals("nomenu")){
List<String> getMenuIdList = tsUserService.getResourceUserId(page.getUserId());
if (getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
} else {
page.setMenuRoleList(null);
}
List<String> ids = iTsResourceService.getChildMenuList(page.getMenuId());
if (ids != null && !ids.isEmpty()) {
page.setMenuAllChildrenIdList(ids);
}
}
}
Integer rowCount = this.baseMapper.getBussionessStandInfoCount(page);
page.getPager().setRowCount(rowCount);
List<SarBussionessStand> sarlist = this.baseMapper.getBussionessStandInfoPage(page);
@@ -578,7 +605,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
*/
public void attrInfo (List<SarBussionessStand> sarlist) throws Exception {
for(SarBussionessStand row : sarlist){
attrInfo1(row);
attrInfoDetails(row);
}
}
@@ -601,6 +628,85 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
}
}
public void attrInfoShowSearchDetails(SarBussionessStand row,String type) throws Exception {
if (row != null) {
attrInfoSearchDetails(row,type);
Map<String, Object> getAttrMap = row.getAttrInfoMap();
if (getAttrMap != null && getAttrMap.size() > 0) {
for (Map.Entry<String, Object> entry : getAttrMap.entrySet()) {
String name = entry.getKey();
String value = "";
List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.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);
}
}
}
}
}
public void attrInfoSearchDetails(SarBussionessStand row,String type) throws Exception {
String fieldInfo = InitStandAttrUtil.queryField;
String collectId = personCollectEOService.queryCollectByUserAndId(row.getId());
row.setCollectId(collectId);
// 查询属性表数据
if (StringUtils.isNotBlank(fieldInfo)) {
Map<String, Object> getAttrMap = new TreeMap<>();
if(type.equals("add")){
String sarStandAttrEOStr = row.getSarStandAttrEOStr();
getAttrMap = JSONObject.fromObject(sarStandAttrEOStr);
}else {
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);
}
}
if (getAttrMap != null && !getAttrMap.isEmpty()) {
row.setAttrInfoCaseMap(transformUpperCase(getAttrMap));
}
row.setAttrInfoMap(getAttrMap);
}
}
private Map<String, Object> transformUpperCase(Map<String, Object> orgMap) {
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<String, Object> entry : orgMap.entrySet()) {
String newKey = entry.getKey().toLowerCase();
resultMap.put(newKey, orgMap.get(entry.getKey()));
if (entry.getValue() != null && InitStandAttrUtil.fileFieldListBuss != null && !InitStandAttrUtil.fileFieldListBuss.isEmpty() && InitStandAttrUtil.fileFieldListBuss.contains(entry.getKey())) {
String value = entry.getValue().toString();
if (StringUtils.isNotBlank(value)) {
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
if(!fileObj.isEmpty()){
resultMap.put(newKey + "Name", fileObj.get(0).getOldFileName());
}
}
}
}
return resultMap;
}
public void attrInfoDetails (SarBussionessStand row) throws Exception {
String fieldInfo = InitStandAttrUtil.queryFieldBuss;
String collectId = personCollectEOService.queryCollectByUserAndId(row.getId());
@@ -649,6 +755,10 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
getAttrMap.putAll(newMap);
}
if (getAttrMap != null && !getAttrMap.isEmpty()) {
row.setAttrInfoCaseMap(transformUpperCase(getAttrMap));
}
row.setAttrInfoMap(getAttrMap);
}
}
@@ -4,6 +4,7 @@ import com.adc.da.slrs.sarStandAttrInfo.entity.SarStandAttrInfo;
import com.adc.da.sys.common.SelectionResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@@ -16,6 +17,7 @@ import java.util.Map;
* @author super_liu
* @since 2021-06-01
*/
@Repository
public interface SarStandAttrInfoDao extends BaseMapper<SarStandAttrInfo> {
void alterStandAttr(@Param("fieldInfo") String fieldInfo);
@@ -2,6 +2,7 @@ package com.adc.da.slrs.sarStandFile.dao;
import com.adc.da.slrs.sarStandFile.entity.SarStandFile;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -13,6 +14,7 @@ import java.util.List;
* @author super_liu
* @since 2021-06-02
*/
@Repository
public interface SarStandFileDao extends BaseMapper<SarStandFile> {
List<SarStandFile> selectFileByStandId(String lawsId);