Merge branch 'develop_master' into FOTON

This commit is contained in:
super_liu
2022-06-06 11:42:54 +08:00
13 changed files with 411 additions and 109 deletions
@@ -1,5 +1,6 @@
package com.adc.da.main.config;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
@@ -19,4 +20,14 @@ public class MybatisPlusConfig {
return new PaginationInterceptor();
}
/***
* 增加乐观锁机制
* @return
*/
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor(){
return new OptimisticLockerInterceptor();
}
}
@@ -1333,7 +1333,19 @@ public class SearchCenterServiceImpl implements SearchCenterService {
QueryBuilder multiQueryBuilder1;
QueryBuilder queryBuilder1 = QueryBuilders.multiMatchQuery("");
if(StringUtils.isNotBlank(searchInfoEO.getSelectValue())){
queryBuilder1 = QueryBuilders.multiMatchQuery(searchInfoEO.getSelectValue(),
if(searchInfoEO.getSelectValue().length() > 1){
String str0 = searchInfoEO.getSelectValue().substring(0,1);
String Str1 = searchInfoEO.getSelectValue().substring(1,2);
String reg = ".*[0-9].*";
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(str0).matches() && Str1.matches(reg)) {
String value = searchInfoEO.getSelectValue().replace(str0,str0+" ");
searchInfoEO.setSelectValue(value);
}
}
queryBuilder1 = QueryBuilders.multiMatchQuery(searchInfoEO.getSelectValue().toUpperCase(),
"title"
).minimumShouldMatch("100%").field("title",1000f);
boolQueryBuilder.must(queryBuilder1);
@@ -27,7 +27,7 @@ public class ScheduledSync {
@Scheduled(cron="0 0 2 * * ?")
@Async
public void syncSchedulingTasks() throws Exception {
public void syncSchedulingTasks() {
iDataSyncService.orgDataSync(); //时间短
iDataSyncService.dataSync(); //时间长
}
@@ -2,7 +2,7 @@ package com.adc.da.slrs.DataSync.service;
public interface IDataSyncService {
public String dataSync() throws Exception;
public String dataSync();
public String orgDataSync() throws Exception;
public String orgDataSync();
}
@@ -1,5 +1,6 @@
package com.adc.da.slrs.DataSync.service.impl;
import com.adc.da.login.util.UserUtils;
import com.adc.da.slrs.DataSync.service.IDataSyncService;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
@@ -12,8 +13,13 @@ import com.adc.da.sys.entity.UserOrgEO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.log4j.Log4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.sql.Timestamp;
import java.util.*;
@@ -29,77 +35,80 @@ public class DataSyncServiceImpl implements IDataSyncService {
@Autowired
ITsInstitutionService tsInstitutionService;
private static Logger logger = LoggerFactory.getLogger(DataSyncServiceImpl.class);
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
@Override
public String dataSync() throws Exception {
SyncUserService syncUserService = new SyncUserService();
List<String> res = syncUserService.syncFotonUser();
//存放岗位信息
Map<String, String> positionMap = new HashMap<>();
Map<String, String> useDistinct = new HashMap<>();
TsPosition position = new TsPosition();
position.setCurrent(1);
position.setPageSize(100000);
IPage<TsPosition> iPage = tsPositionService.getPosition(position);
List<TsPosition> positions=iPage.getRecords();
if (!positions.isEmpty()) {
positions.forEach(tsPosition -> {
positionMap.put(tsPosition.getName(), tsPosition.getId());
});
}
public String dataSync(){
try{
SyncUserService syncUserService = new SyncUserService();
List<String> res = syncUserService.syncFotonUser();
//存放岗位信息
Map<String, String> positionMap = new HashMap<>();
Map<String, String> useDistinct = new HashMap<>();
TsPosition position = new TsPosition();
position.setCurrent(1);
position.setPageSize(100000);
IPage<TsPosition> iPage = tsPositionService.getPosition(position);
List<TsPosition> positions=iPage.getRecords();
if (!positions.isEmpty()) {
positions.forEach(tsPosition -> {
positionMap.put(tsPosition.getName(), tsPosition.getId());
});
}
/**
* 得到数据时,删除系统表中所有用户信息
*/
if (res.size()>0){
tsUserService.deleteUser();
}
for (String s : res) {
//获取到所有用户数据
List<TsUser> tsUsers = new ArrayList<>();
/**
* 得到数据时,删除系统表中所有用户信息
*/
if (res.size()>0){
tsUserService.deleteUser();
}
for (String s : res) {
//获取到所有用户数据
List<TsUser> tsUsers = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
//先获取岗位以及岗位id
TsUser tsUser = new TsUser();
UserOrgEO userOrgEO = new UserOrgEO();
//设置岗位
if (null != jsonObject.getString("title")) {
//通过岗位名称查询系统表中是否有岗位,有则设定用户的岗位为系统中的岗位,否则新增
if (null == positionMap.get(jsonObject.getString("title"))) {
TsPosition tsPosition = new TsPosition();
tsPosition.setId(String.valueOf(UUID.randomUUID()));
tsPosition.setName(jsonObject.getString("title"));
tsPositionService.addPosition(tsPosition);
//放入岗位的map集合中
positionMap.put(tsPosition.getName(), tsPosition.getId());
//放入类中
tsUser.setPositionName(tsPosition.getName());
tsUser.setPositionId(tsPosition.getId());
} else {
tsUser.setPositionName(jsonObject.getString("title").trim());
tsUser.setPositionId(positionMap.get(jsonObject.getString("title").trim()));
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
//先获取岗位以及岗位id
TsUser tsUser = new TsUser();
UserOrgEO userOrgEO = new UserOrgEO();
//设置岗位
if (null != jsonObject.getString("title")) {
//通过岗位名称查询系统表中是否有岗位,有则设定用户的岗位为系统中的岗位,否则新增
if (null == positionMap.get(jsonObject.getString("title"))) {
TsPosition tsPosition = new TsPosition();
tsPosition.setId(String.valueOf(UUID.randomUUID()));
tsPosition.setName(jsonObject.getString("title"));
tsPositionService.addPosition(tsPosition);
//放入岗位的map集合中
positionMap.put(tsPosition.getName(), tsPosition.getId());
//放入类中
tsUser.setPositionName(tsPosition.getName());
tsUser.setPositionId(tsPosition.getId());
} else {
tsUser.setPositionName(jsonObject.getString("title").trim());
tsUser.setPositionId(positionMap.get(jsonObject.getString("title").trim()));
}
}
}
//设置其他数据
Timestamp createTime = new Timestamp(new Date().getTime());
tsUser.setState(jsonObject.getString("userStatus"));
tsUser.setUname(null!=jsonObject.getString("name")?jsonObject.getString("name"):"");
tsUser.setValidFlag("0");
tsUser.setDisableFlag("0");
tsUser.setCreationTime(createTime);
tsUser.setUserId(jsonObject.getString("userid"));
tsUser.setAccount(jsonObject.getString("userid"));
tsUser.setInstitutionId(null!=jsonObject.getString("orgNumber")?jsonObject.getString("orgNumber"):"" );
tsUser.setInstitutionName(null!=jsonObject.getString("orgName")?jsonObject.getString("orgName"):"" );
//2022-05-23:用户同步增加状态标识,将停用的用户过滤掉
if (null == useDistinct.get(jsonObject.getString("userid")) && "1".equals(jsonObject.getString("userStatus"))) {
tsUsers.add(tsUser);
//设置其他数据
Timestamp createTime = new Timestamp(new Date().getTime());
tsUser.setState(jsonObject.getString("userStatus"));
tsUser.setUname(null!=jsonObject.getString("name")?jsonObject.getString("name"):"");
tsUser.setValidFlag("0");
tsUser.setDisableFlag("0");
tsUser.setCreationTime(createTime);
tsUser.setUserId(jsonObject.getString("userid"));
tsUser.setAccount(jsonObject.getString("userid"));
tsUser.setInstitutionId(null!=jsonObject.getString("orgNumber")?jsonObject.getString("orgNumber"):"" );
tsUser.setInstitutionName(null!=jsonObject.getString("orgName")?jsonObject.getString("orgName"):"" );
//2022-05-23:用户同步增加状态标识,将停用的用户过滤掉
if (null == useDistinct.get(jsonObject.getString("userid")) && "1".equals(jsonObject.getString("userStatus"))) {
tsUsers.add(tsUser);
}
}
// //测试数据删除
// if (! "anbin".equals(jsonObject.getString("userid"))){
@@ -113,12 +122,12 @@ public class DataSyncServiceImpl implements IDataSyncService {
//
// }
// }
useDistinct.put(tsUser.getUserId(),tsUser.getUserId());
});
tsUserService.saveBatch(tsUsers);
}
useDistinct.put(tsUser.getUserId(),tsUser.getUserId());
});
tsUserService.saveBatch(tsUsers);
}
//测试数据添加
//测试数据添加
// TsUser addUser = new TsUser();
// addUser.setState("FFFFFFF");
// addUser.setUname("zhaokaiyao");
@@ -132,42 +141,80 @@ public class DataSyncServiceImpl implements IDataSyncService {
//
// List<TsUser> addUserList = Arrays.asList(addUser);
// tsUserService.saveBatch(addUserList);
}catch(Exception e){
logger.error(e.getMessage(),e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return "1";
}
public String orgDataSync() throws Exception {
SyncUserService syncUserService = new SyncUserService();
List<String> res = syncUserService.syncFotonOrg();
//获取到所有用户数据
List<String> strings=new ArrayList<>();
tsInstitutionService.clearData();
for (String s : res) {
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
strings.add(jsonObject.getString("parentOrgNumber"));
});
}
for (String s : res) {
List<TsInstitution> tsInstitutions = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
TsInstitution tsInstitution=new TsInstitution();
tsInstitution.setId(jsonObject.getString("orgNumber"));
tsInstitution.setName(jsonObject.getString("orgName"));
tsInstitution.setHasChild(strings.contains(jsonObject.getString("orgNumber"))?"1":"0");
tsInstitution.setParentId(jsonObject.getString("parentOrgNumber"));
//部门为"null"的数据不保存
if (!"null".equals(jsonObject.getString("orgName"))){
tsInstitutions.add(tsInstitution);
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
public String orgDataSync(){
try{
SyncUserService syncUserService = new SyncUserService();
List<String> res = syncUserService.syncFotonOrg();
//获取到所有用户数据
List<String> strings=new ArrayList<>();
//tsInstitutionService.clearData();
for (String s : res) {
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
strings.add(jsonObject.getString("parentOrgNumber"));
});
}
List<TsInstitution> allTsInstitutionList = tsInstitutionService.list();
List<TsInstitution> addTsInstitutionList = new ArrayList<>();
List<TsInstitution> updateTsInstitutionList = new ArrayList<>();
List<TsInstitution> delTsInstitutionList = new ArrayList<>();
Set<String> syncAllIdList = new HashSet<>();
for (String s : res) {
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
if(jsonArray!=null){
jsonArray.forEach(object -> {
JSONObject jsonObject = JSONObject.parseObject(object.toString());
TsInstitution tsInstitution=new TsInstitution();
tsInstitution.setId(jsonObject.getString("orgNumber"));
tsInstitution.setName(jsonObject.getString("orgName"));
tsInstitution.setHasChild(strings.contains(jsonObject.getString("orgNumber"))?"1":"0");
tsInstitution.setParentId(jsonObject.getString("parentOrgNumber"));
//部门为"null"的数据不保存
if (!"null".equals(jsonObject.getString("orgName"))){
TsInstitution institution = tsInstitutionService.getById(tsInstitution.getId());
if(institution!=null){
updateTsInstitutionList.add(tsInstitution);
}else{
addTsInstitutionList.add(tsInstitution);
}
syncAllIdList.add(tsInstitution.getId());
}
});
}
});
tsInstitutionService.saveBatch(tsInstitutions);
}
//遍历出来需要删除的数据
for(TsInstitution data :allTsInstitutionList){
if(!syncAllIdList.contains(data.getId())){
delTsInstitutionList.add(data);
}
}
//需要新增的数据
if(!addTsInstitutionList.isEmpty()){
tsInstitutionService.saveBatch(addTsInstitutionList);
}
//需要更新的数据
if(!updateTsInstitutionList.isEmpty()){
tsInstitutionService.updateBatchById(updateTsInstitutionList);
}
//需要删除的数据
if(!delTsInstitutionList.isEmpty()){
tsInstitutionService.updateBatchById(delTsInstitutionList);
}
}catch(Exception e){
logger.error(e.getMessage(),e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return "1";
}
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
@@ -38,13 +39,27 @@ public class NewsFeedController extends BaseController<NewsFeed> {
@GetMapping("/getNewsFeed")
public ResponseMessage<IPage<NewsFeed>> NewFeedPage(NewsFeedPage page){
IPage<NewsFeed> iPage = new Page<>();
iPage.setCurrent(page.getPage());
iPage.setSize(page.getPageSize());
iPage.setTotal(page.getPage());
List<String> list = new ArrayList<>();
if("GNWBZFG".equals(page.getMessageType())){
list.add("hc99551723c");
}else if("ZYBZFG".equals(page.getMessageType())){
list.add("hya6gay4vx");
list.add("8rjsx83ows");
list.add("ncb6osftj8");
list.add("3dx7oy5jff");
}else if("QYBZFB".equals(page.getMessageType())){
list.add("6jnqba2mby");
}
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(StringUtils.isNotEmpty(page.getStandardId()),"STANDARD_ID",page.getStandardId());
queryWrapper.eq(StringUtils.isNotEmpty(page.getStandardName()),"STANDARD_NAME",page.getStandardName());
queryWrapper.eq("MESSAGE_TYPE",page.getMessageType());
queryWrapper.orderByDesc("UPDATE_TIME");
if(StringUtils.isNotBlank(page.getMessageType())){
queryWrapper.in("TEXT_STATE",list);
}
queryWrapper.orderByDesc("RENEW_TIME");
IPage<NewsFeed> newsFeedList = newsFeedService.page(iPage,queryWrapper);
return Result.success(newsFeedList);
}
@@ -3,6 +3,7 @@ package com.adc.da.slrs.NewsFeed.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -59,5 +60,6 @@ public class NewsFeed extends BaseEntity {
@TableField("RENEW_TIME")
@ApiModelProperty(value = "更新时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date renewTime;
}
@@ -9,7 +9,6 @@ import org.springframework.stereotype.Service;
* @Date: 2022/5/23 0023 15:01
* @Version 1.0
*/
@Service
public interface INewsFeedService extends IService<NewsFeed> {
int insertNewsFeed(NewsFeed newsFeed);
}
@@ -18,6 +18,8 @@ import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.search.entity.SarBussionessStandEO;
import com.adc.da.search.entity.StandLawsEO;
import com.adc.da.search.service.StandLawsSearchService;
import com.adc.da.slrs.NewsFeed.entity.NewsFeed;
import com.adc.da.slrs.NewsFeed.service.INewsFeedService;
import com.adc.da.slrs.otConvertMq.dao.OtConvertMqDao;
import com.adc.da.slrs.otConvertMq.entity.OtConvertMq;
import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
@@ -155,6 +157,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired
private ISarMenuStandardService iSarMenuStandardService;
@Autowired
private INewsFeedService iNewsFeedService;
@Override
public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus){
return sarBussionessStandEODao.getStandInfoByReviseStatus(reviseStatus);
@@ -238,6 +243,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
String content = "入库" + number + "" + sarBussionessStandEO.getStandName() + "";
String prcCreateUser = StringUtils.isNotBlank(sarBussionessStandEO.getPrcCreateUser()) ? sarBussionessStandEO.getPrcCreateUser() : "";
sarUpdLogEOService.createBaseProcessLog(sarBussionessStandEO.getId(),"BUSINESS",content,prcCreateUser);
saveNewFeed(sarBussionessStandEO,"2");
if(elasflag) {
attrInfoShowSearchDetails(sarBussionessStandEO,"add");
createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
@@ -550,6 +556,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
// 记录修改日志
saveUpdateLog(sarBussionessStandEO,beforeStandEO);
// saveNewFeed(sarBussionessStandEO,"2");
if (elasflag) {
attrInfoShowSearchDetails(sarBussionessStandEO,"upd");
createStandMQService.sendBussStandMQ(sarBussionessStandEO, "update");
@@ -558,6 +565,80 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
return sarBussionessStandEO;
}
public void filterNewFeed(SarBussionessStand sarStandardsInfoEO,SarBussionessStand beforeSarStandardsInfo) throws Exception {
Map<String, Object> newMap = new HashMap<>();
Map<String, Object> oldMap = beforeSarStandardsInfo.getAttrInfoMap();
String attrStr = sarStandardsInfoEO.getSarStandAttrEOStr();
if (org.apache.commons.lang3.StringUtils.isNotBlank(attrStr)) {
newMap = JSONObject.fromObject(attrStr);
}
// 发布稿
List<String> fbgNew = Arrays.stream(newMap.getOrDefault("FBGBJBD", "").toString().split(","))
.map(String::trim).collect(Collectors.toList());
List<String> fbgOld = Arrays.stream(oldMap.getOrDefault("FBGBJBD", "").toString().split(","))
.map(String::trim).collect(Collectors.toList());
// 取差集 判断是否有新的发布稿
List<String> filterDisunityFbg = fbgNew.stream()
.filter(item -> !new ArrayList<>(fbgOld)
.contains(item))
.collect(Collectors.toList());
// 在研稿件
String strUsNew = newMap.getOrDefault("CA", "").toString()+
","+newMap.getOrDefault("GLWJ", "").toString()+
","+newMap.getOrDefault("XGD", "").toString()+
","+newMap.getOrDefault("BPG", "").toString()+
","+newMap.getOrDefault("ZQYJG", "").toString()+
","+newMap.getOrDefault("SSG", "").toString()+
","+newMap.getOrDefault("JDWJ", "").toString()+
","+newMap.getOrDefault("KWJ", "").toString()+
","+newMap.getOrDefault("XDB", "").toString()+
","+newMap.getOrDefault("ZBJBD", "").toString();
String strUsOld = oldMap.getOrDefault("CA", "").toString()+
","+oldMap.getOrDefault("GLWJ", "").toString()+
","+oldMap.getOrDefault("XGD", "").toString()+
","+oldMap.getOrDefault("BPG", "").toString()+
","+oldMap.getOrDefault("ZQYJG", "").toString()+
","+oldMap.getOrDefault("SSG", "").toString()+
","+oldMap.getOrDefault("JDWJ", "").toString()+
","+oldMap.getOrDefault("KWJ", "").toString()+
","+oldMap.getOrDefault("XDB", "").toString()+
","+oldMap.getOrDefault("ZBJBD", "").toString();
List<String> usNew = Arrays.stream(strUsNew.split(","))
.map(String::trim).collect(Collectors.toList());
List<String> usOld = Arrays.stream(strUsOld.split(","))
.map(String::trim).collect(Collectors.toList());
// 取差集 判断是否有新的在研稿件
List<String> filterDisunityUs = usNew.stream()
.filter(item -> !new ArrayList<>(usOld)
.contains(item))
.collect(Collectors.toList());
// 0 发布稿件 新的文件数量 大于等于 在研稿件 就属于发布动态消息 则 为 1 在研
if(filterDisunityFbg.size() >= filterDisunityUs.size()){
saveNewFeed(sarStandardsInfoEO, "2");
}else {
saveNewFeed(sarStandardsInfoEO, "");
}
}
private void saveNewFeed(SarBussionessStand sarStandardsInfoEO, String s) {
NewsFeed newsFeed = new NewsFeed();
newsFeed.setId(UUIDUtils.randomUUID20());
newsFeed.setRenewTime(new Date());
newsFeed.setStandardId(sarStandardsInfoEO.getId());
newsFeed.setResourceType("BUSINESS");
newsFeed.setMessageType(s);
newsFeed.setStandard(verifyObj(sarStandardsInfoEO.getStandCode()).toString());
newsFeed.setStandardName(verifyObj(sarStandardsInfoEO.getStandName()).toString());
newsFeed.setReleaseDate(verifyObj(sarStandardsInfoEO.getIssueTime()).toString());
// 企标 技术标准或产品标准走完流程 文本状态默认 发布状态
newsFeed.setTextState("6jnqba2mby");
iNewsFeedService.insertNewsFeed(newsFeed);
}
public void saveUpdateLog(SarBussionessStand sarStandardsInfoEO,SarBussionessStand beforeSarStandardsInfo) throws Exception{
Map<String,Object> newMap = new HashMap<>();
Map<String,Object> oldMap = beforeSarStandardsInfo.getAttrInfoMap();
@@ -47,7 +47,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl<SarMenuStandar
if(sarMenuStandardNew.getDicId()!=null){
queryWrapper.eq("DIC_ID", sarMenuStandardNew.getDicId());
}
queryWrapper.in(null!=access,"ID",access);
queryWrapper.in(null!=access && !access.isEmpty(),"ID",access);
queryWrapper.isNull("PARENT_ID");
queryWrapper.orderByAsc("DISPLAY_SEQ");
TsResources=dao.selectList(queryWrapper);
@@ -268,7 +268,7 @@ public class TsResourceServiceImpl extends ServiceImpl<TsResourceDao, TsResource
}
queryWrapper.isNull("PARENT_ID");
queryWrapper.eq("VALID_FLAG","0");
queryWrapper.in(null!=access,"ID",access);
queryWrapper.in(null!=access && !access.isEmpty(),"ID",access);
queryWrapper.orderByAsc("DISPLAY_SEQ");
TsResources=dao.selectList(queryWrapper);
@@ -4,6 +4,8 @@ import com.adc.da.att.dao.AttFileEODao;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.person.entity.StandInfo;
import com.adc.da.person.entity.TsPersonCollect;
import com.adc.da.slrs.NewsFeed.entity.NewsFeed;
import com.adc.da.slrs.NewsFeed.service.INewsFeedService;
import com.adc.da.slrs.regulations.dao.StandDataDao;
import com.adc.da.slrs.regulations.entity.SearchStandContext;
import com.adc.da.slrs.regulations.entity.StandData;
@@ -105,11 +107,13 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.json.JSONArray;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@@ -278,6 +282,10 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Autowired
private AttFileEODao attFileEODao;
@Autowired
private INewsFeedService iNewsFeedService;
// /**
// * 反向操作标准
// */
@@ -1018,7 +1026,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
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) {
if (json instanceof JSONArray) {
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class);
} else {
value = entry.getValue().toString();
@@ -1214,7 +1222,12 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
createStandAttrInfo(sarStandardsInfoEO);
}
// 根据引用标准修改其他被引用标准
updateCiteStand(sarStandardsInfoEO, null, "YYBJ", "BYYBJ");
/**
* 新增代替标准号修改其他被代替标准号
*/
updateCiteStand(sarStandardsInfoEO, null, "DTBZH", "BDTBZH");
updateCiteStand(sarStandardsInfoEO, null, "BFDTBZ", "BBFDTBZ");
// updateRelateStand(sarStandardsInfoEO, "CBBH");
// 根据代替标准号修改被代替的标准的状态 修改为已修订状态
@@ -1227,6 +1240,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
String content = "入库" + number + "" + sarStandardsInfoEO.getStandName() + "";
sarUpdLogEOService.createBaseLog(sarStandardsInfoEO.getId(), sarStandardsInfoEO.getStandType() + "_STAND", content);
SarStandardsInfo old = new SarStandardsInfo();
filterNewFeed(sarStandardsInfoEO,old);
if (elasflag) {
// 消息队列
attrInfoShowSearchDetails(sarStandardsInfoEO, "add");
@@ -1927,6 +1942,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
// replaseStandState(sarStandardsInfoEO);
// 记录修改日志
saveUpdateLog(sarStandardsInfoEO, beforeSarStandardsInfo);
filterNewFeed(sarStandardsInfoEO, beforeSarStandardsInfo);
if (elasflag) { //what?
attrInfoShowSearchDetails(sarStandardsInfoEO, "upd");
FindSarItemsPageReqDTO pageInfo = new FindSarItemsPageReqDTO();
@@ -1949,6 +1965,92 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
return result;
}
public void filterNewFeed(SarStandardsInfo sarStandardsInfoEO, SarStandardsInfo beforeSarStandardsInfo) throws Exception {
Map<String, Object> newMap = new HashMap<>();
Map<String, Object> oldMap = beforeSarStandardsInfo.getAttrInfoMap();
String attrStr = sarStandardsInfoEO.getSarStandAttrEOStr();
if (StringUtils.isNotBlank(attrStr)) {
newMap = JSONObject.fromObject(attrStr);
}
// 发布稿
List<String> fbgNew = Arrays.stream(newMap.getOrDefault("FBGBJBD", "").toString().split(","))
.map(String::trim).collect(Collectors.toList());
List<String> fbgOld = Arrays.stream(oldMap.getOrDefault("FBGBJBD", "").toString().split(","))
.map(String::trim).collect(Collectors.toList());
// 取差集 判断是否有新的发布稿
List<String> filterDisunityFbg = fbgNew.stream()
.filter(item -> !new ArrayList<>(fbgOld)
.contains(item))
.collect(Collectors.toList());
filterDisunityFbg = filterDisunityFbg.stream().filter(s -> !s.equals("")).collect(Collectors.toList());
// 在研稿件
String strUsNew = newMap.getOrDefault("CA", "").toString()+
","+newMap.getOrDefault("GLWJ", "").toString()+
","+newMap.getOrDefault("XGD", "").toString()+
","+newMap.getOrDefault("BPG", "").toString()+
","+newMap.getOrDefault("ZQYJG", "").toString()+
","+newMap.getOrDefault("SSG", "").toString()+
","+newMap.getOrDefault("JDWJ", "").toString()+
","+newMap.getOrDefault("KWJ", "").toString()+
","+newMap.getOrDefault("XDB", "").toString()+
","+newMap.getOrDefault("ZBJBD", "").toString();
String strUsOld = oldMap.getOrDefault("CA", "").toString()+
","+oldMap.getOrDefault("GLWJ", "").toString()+
","+oldMap.getOrDefault("XGD", "").toString()+
","+oldMap.getOrDefault("BPG", "").toString()+
","+oldMap.getOrDefault("ZQYJG", "").toString()+
","+oldMap.getOrDefault("SSG", "").toString()+
","+oldMap.getOrDefault("JDWJ", "").toString()+
","+oldMap.getOrDefault("KWJ", "").toString()+
","+oldMap.getOrDefault("XDB", "").toString()+
","+oldMap.getOrDefault("ZBJBD", "").toString();
List<String> usNew = Arrays.stream(strUsNew.split(","))
.map(String::trim).collect(Collectors.toList());
List<String> usOld = Arrays.stream(strUsOld.split(","))
.map(String::trim).collect(Collectors.toList());
// 取差集 判断是否有新的在研稿件
List<String> filterDisunityUs = usNew.stream()
.filter(item -> !new ArrayList<>(usOld)
.contains(item))
.collect(Collectors.toList());
filterDisunityUs = filterDisunityUs.stream().filter(s -> !s.equals("")).collect(Collectors.toList());
// 0 发布稿件 新的文件数量 大于等于 在研稿件 就属于发布动态消息 则 为 1 在研
if(filterDisunityFbg.size() >= filterDisunityUs.size()){
saveNewFeed(sarStandardsInfoEO, "0");
}else {
saveNewFeed(sarStandardsInfoEO, "1");
}
}
private void saveNewFeed(SarStandardsInfo sarStandardsInfoEO, String s) {
NewsFeed newsFeed = new NewsFeed();
newsFeed.setId(UUIDUtils.randomUUID20());
newsFeed.setRenewTime(new Date());
newsFeed.setStandardId(sarStandardsInfoEO.getId());
newsFeed.setResourceType(verifyObj(sarStandardsInfoEO.getStandType()).toString());
newsFeed.setMessageType(s);
String standard = "";
if(StringUtils.isNotBlank(sarStandardsInfoEO.getStandYear())){
standard = verifyObj(sarStandardsInfoEO.getStandSort()).toString() +" "+ verifyObj(sarStandardsInfoEO.getStandNumber()).toString()+"-"+verifyObj(sarStandardsInfoEO.getStandYear()).toString();
}else {
standard = verifyObj(sarStandardsInfoEO.getStandSort()).toString() +" "+ verifyObj(sarStandardsInfoEO.getStandNumber()).toString();
}
newsFeed.setStandard(standard);
newsFeed.setStandardName(verifyObj(sarStandardsInfoEO.getStandName()).toString());
newsFeed.setReleaseDate(verifyObj(sarStandardsInfoEO.getIssueTime()).toString());
newsFeed.setTextState(verifyObj(sarStandardsInfoEO.getTextStatus()).toString());
iNewsFeedService.insertNewsFeed(newsFeed);
}
public void saveUpdateLog(SarStandardsInfo sarStandardsInfoEO, SarStandardsInfo beforeSarStandardsInfo) throws Exception {
Map<String, Object> newMap = new HashMap<>();
Map<String, Object> oldMap = beforeSarStandardsInfo.getAttrInfoMap();
@@ -0,0 +1,33 @@
/*
Navicat MySQL Data Transfer
Source Server : 123.56.177.15_new_测试
Source Server Version : 50736
Source Host : 123.56.177.15:3306
Source Database : foton_slrs_test2
Target Server Type : MYSQL
Target Server Version : 50736
File Encoding : 65001
Date: 2022-06-02 12:17:37
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for news_feed
-- ----------------------------
DROP TABLE IF EXISTS `news_feed`;
CREATE TABLE `news_feed` (
`ID` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT 'ID',
`RESOURCE_TYPE` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '资源类型',
`MESSAGE_TYPE` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '消息类型',
`STANDARD_ID` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '标准类型',
`STANDARD` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '标准号',
`STANDARD_NAME` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '标准名称',
`RELEASE_DATE` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '发布日期',
`TEXT_STATE` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '文本状态',
`RENEW_TIME` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='动态消息表';