fix: 修改优化当流程归档或者编辑数据时,将标准文件表中的数据清空导致之前同步老系统的数据全部被删除,导致下次同步的时候直接又同步一次

This commit is contained in:
zyd
2022-07-27 23:41:45 +08:00
parent 49edfdad8a
commit 1053529d99
5 changed files with 67 additions and 41 deletions
@@ -2,6 +2,7 @@ package com.adc.da.slrs.sarBussionessStand.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.search.entity.SarBussionessStandEO;
import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStandExport;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
@@ -46,5 +47,7 @@ public interface ISarBussionessStandService extends IService<SarBussionessStand>
boolean checkIsShow(SarBussionessStandEOPage page) throws Exception;
List<SarBussionessStand> getSarBussionStandPageQd(SarBussionessStandEOPage page) throws Exception;
void convertDocAllQB(List<SarBussStandFile> list);
}
@@ -42,6 +42,7 @@ import com.adc.da.slrs.sarMenuStandard.service.ISarMenuStandardNewService;
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.SarAdvanceSearchVO;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
@@ -299,7 +300,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
// writeWarnings(sarBussionessStandEO);
// 处理属性表信息
if (StringUtils.isNotBlank(sarBussionessStandEO.getSarStandAttrEOStr())) {
createStandAttrInfo(sarBussionessStandEO);
createStandAttrInfo(sarBussionessStandEO,false);
}
// 增加关联事件
String sortName = sysInfoEOService.getDicNamesByCodes(sarBussionessStandEO.getStandSort(),"JKSADFH564S");
@@ -599,8 +600,8 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
sarBussStandValEODao.deleteDataByStandId(standId);
//删除文件详情表数据
sarBussStandFileEODao.deleteByStandId(standId);
// //删除文件详情表数据
// sarBussStandFileEODao.deleteByStandId(standId);
SarBussStandFile sarBussStandFileEO = new SarBussStandFile();
sarBussStandFileEO.setStandId(standId);
sarBussStandFileEO.setIdList(null);
@@ -615,7 +616,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
}
}
}
createStandAttrInfo(sarBussionessStandEO);
createStandAttrInfo(sarBussionessStandEO,true);
//修改收藏分享编号名称
updateCollectAndShare(sarBussionessStandEO);
@@ -989,7 +990,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
* @Param: [sarStandardsInfoEO]
* @Return: void
*/
public void createStandAttrInfo (SarBussionessStand sarBussionessStandEO) throws Exception {
public void createStandAttrInfo (SarBussionessStand sarBussionessStandEO,boolean upFlag) throws Exception {
String sarStandAttrEOStr = sarBussionessStandEO.getSarStandAttrEOStr();
String mustFields = FieldConvertUtil.mustFields;
String mustValues = FieldConvertUtil.mustValues(sarBussionessStandEO.getId());
@@ -1038,7 +1039,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
// 多选项处理
createStandVal(sarBussionessStandEO.getId(),selectionMap);
// 文件处理
createStandFile(sarBussionessStandEO.getId(),fileMap);
createStandFile(sarBussionessStandEO.getId(),fileMap,upFlag);
// 多时间处理
// createStandPutTime(sarBussionessStandEO.getId(),multiTimeMap);
}
@@ -1085,7 +1086,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
* @Param: [standId, fileMap]
* @Return: void
*/
public void createStandFile (String standId,Map<String,String> fileMap) throws Exception {
public void createStandFile (String standId,Map<String,String> fileMap,boolean upFlag) throws Exception {
if (fileMap != null && fileMap.size() > 0) {
List<SarBussStandFile> standFileList = new ArrayList<>();
for (Map.Entry<String,String> entry : fileMap.entrySet()) {
@@ -1094,7 +1095,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
if (StringUtils.isNotBlank(value)) {
List<AttFileEO> fileList = attFileEOService.getMultiFileInfos(value);
if (fileList != null && !fileList.isEmpty()) {
createStandFileAppend(standId,field,fileList,standFileList);
createStandFileAppend(standId,field,fileList,standFileList,upFlag);
}
}
}
@@ -1104,8 +1105,20 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
}
}
public void createStandFileAppend (String standId,String field,List<AttFileEO> fileList,List<SarBussStandFile> standFileList) throws Exception {
public void createStandFileAppend (String standId,String field,List<AttFileEO> fileList,List<SarBussStandFile> standFileList,boolean upFlag) throws Exception {
for (AttFileEO fileInfo : fileList) {
//TODO 20220727 此处为兼容老系统数据 将编辑去掉了先删除再添加的操作
if(upFlag){
QueryWrapper<SarBussStandFile> fileQueryWrapper = new QueryWrapper<>();
fileQueryWrapper.eq("STAND_ID",standId);
fileQueryWrapper.eq("VALID_FLAG",0);
fileQueryWrapper.eq("USE_MODEL","SOURCE_FILE");
fileQueryWrapper.eq("ATT_ID",fileInfo.getId());
int fileExist = sarBussStandFileEODao.selectCount(fileQueryWrapper);
if(fileExist>0){
continue;
}
}
SarBussStandFile sarStandFileEO = new SarBussStandFile();
sarStandFileEO.setCreationUser(LoginUserUtil.getUserId());
sarStandFileEO.setCreationTime(new Date());
@@ -1737,4 +1750,21 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
public List<SarBussionessStand> queryByList(SarBussionessStandEOPage sarBussionessStandEOPage){
return this.baseMapper.queryByList(sarBussionessStandEOPage);
}
@Override
public void convertDocAllQB(List<SarBussStandFile> list) {
try{
for(SarBussStandFile sarStandFile : list){
logger.error("QB++++++++++++++++:" + sarStandFile.getStandId());
AttFileEO temp = attFileEOService.getFileInfo(sarStandFile.getAttId());
createStandFileAppend(sarStandFile.getStandId(), sarStandFile.getStandFileClassify(), Arrays.asList(temp), new ArrayList<>(),true);
sarStandFile.setPassword("1");
sarBussStandFileEODao.updateById(sarStandFile);
}
}catch(Exception e){
logger.error(e.getMessage(),e);
}
}
}
@@ -895,7 +895,7 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
}
List<SarBussStandFile> list = sarBussStandFileService.list(qw);
logger.error("doc轉換共多少:"+list.size());
sarStandardsInfoEOService.convertDocAllQB(list);
iSarBussionessStandService.convertDocAllQB(list);
return "1";
}
@@ -69,5 +69,5 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
void convertDocAll(List<SarStandFile> list);
void convertDocAllQB(List<SarBussStandFile> list);
}
@@ -530,36 +530,17 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
AttFileEO attFileEO = new AttFileEO();
attFileEO.setId(sarStandFile.getAttId());
AttFileEO temp = attFileEODao.selectFileInfoById(attFileEO);
createStandFileAppend(sarStandFile.getStandId(), sarStandFile.getStandFileClassify(), Arrays.asList(temp), new ArrayList<>());
createStandFileAppend(sarStandFile.getStandId(), sarStandFile.getStandFileClassify(), Arrays.asList(temp), new ArrayList<>(),true);
sarStandFile.setPassword("1");
sarStandFileService.updateById(sarStandFile);
}
}catch(Exception e){
e.printStackTrace();
logger.error(e.getMessage(),e);
}
}
@Autowired
private ISarStandFileService sarStandFileService;
@Autowired
private ISarBussStandFileService sarBussStandFileService;
@Override
public void convertDocAllQB(List<SarBussStandFile> list) {
try{
for(SarBussStandFile sarStandFile : list){
logger.error("QB++++++++++++++++:" + sarStandFile.getStandId());
AttFileEO attFileEO = new AttFileEO();
attFileEO.setId(sarStandFile.getAttId());
AttFileEO temp = attFileEODao.selectFileInfoById(attFileEO);
createStandFileAppend(sarStandFile.getStandId(), sarStandFile.getStandFileClassify(), Arrays.asList(temp), new ArrayList<>());
sarStandFile.setPassword("1");
sarBussStandFileService.updateById(sarStandFile);
}
}catch(Exception e){
e.printStackTrace();
}
}
private String convertStandCodeHandle(String standCode) {
if (StringUtils.isNotBlank(standCode)) {
@@ -1248,7 +1229,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
// writeWarnings(sarStandardsInfoEO);
// 处理属性表信息
if (StringUtils.isNotBlank(sarStandardsInfoEO.getSarStandAttrEOStr())) {
createStandAttrInfo(sarStandardsInfoEO);
createStandAttrInfo(sarStandardsInfoEO,false);
}
// 根据引用标准修改其他被引用标准
@@ -1302,7 +1283,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
* @Param: [sarStandardsInfoEO]
* @Return: void
*/
public void createStandAttrInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception {
public void createStandAttrInfo(SarStandardsInfo sarStandardsInfoEO,boolean upFlag) throws Exception {
String sarStandAttrEOStr = sarStandardsInfoEO.getSarStandAttrEOStr();
String mustFields = FieldConvertUtil.mustFields;
String mustValues = FieldConvertUtil.mustValues(sarStandardsInfoEO.getId());
@@ -1370,7 +1351,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
// 多选项处理
createStandVal(sarStandardsInfoEO.getId(), selectionMap);
// 文件处理
createStandFile(sarStandardsInfoEO.getId(), fileMap);
createStandFile(sarStandardsInfoEO.getId(), fileMap,upFlag);
// 多时间处理
createStandPutTime(sarStandardsInfoEO.getId(), multiTimeMap);
}
@@ -1417,7 +1398,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
* @Param: [standId, fileMap]
* @Return: void
*/
public void createStandFile(String standId, Map<String, String> fileMap) throws Exception {
public void createStandFile(String standId, Map<String, String> fileMap,boolean upFlag) throws Exception {
if (fileMap != null && fileMap.size() > 0) {
List<SarStandFile> standFileList = new ArrayList<>();
List<AttFileEO> fileList = new ArrayList<>();
@@ -1427,7 +1408,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
if (StringUtils.isNotBlank(value)) {
fileList = attFileEOService.getMultiFileInfos(value);
if (fileList != null && !fileList.isEmpty()) {
createStandFileAppend(standId, field, fileList, standFileList);
createStandFileAppend(standId, field, fileList, standFileList,upFlag);
}
}
}
@@ -1437,8 +1418,20 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
}
public void createStandFileAppend(String standId, String field, List<AttFileEO> fileList, List<SarStandFile> standFileList) throws Exception {
public void createStandFileAppend(String standId, String field, List<AttFileEO> fileList, List<SarStandFile> standFileList,boolean upFlag) throws Exception {
for (AttFileEO fileInfo : fileList) {
//TODO 20220727 此处为兼容老系统数据 将编辑去掉了先删除再添加的操作
if(upFlag){
QueryWrapper<SarStandFile> fileQueryWrapper = new QueryWrapper<>();
fileQueryWrapper.eq("STAND_ID",standId);
fileQueryWrapper.eq("VALID_FLAG","0");
fileQueryWrapper.eq("USE_MODEL","SOURCE_FILE");
fileQueryWrapper.eq("ATT_ID",fileInfo.getId());
int fileExist = sarStandFileService.count(fileQueryWrapper);
if(fileExist>0){
continue;
}
}
SarStandFile sarStandFileEO = new SarStandFile();
sarStandFileEO.setCreationUser(LoginUserUtil.getUserId());
sarStandFileEO.setCreationTime(new Date());
@@ -1909,8 +1902,8 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
int result = dao.updateById(sarStandardsInfoEO);
//先删除标准关联表,然后插入数据
sarStandValEODao.deleteDataByStandid(standId);
//删除文件详情表数据
sarStandFileEODao.deleteByStandId(standId);
// //删除文件详情表数据
// sarStandFileEODao.deleteByStandId(standId);
SarStandFile sarStandFileEO = new SarStandFile();
sarStandFileEO.setStandId(sarStandardsInfoEO.getId());
Map map = (Map) JSONObject.fromObject(sarStandardsInfoEO.getSarStandAttrEOStr());
@@ -1929,7 +1922,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
sarStandPutTimeEODao.deleteByStandId(standId);
// 修改属性表数据
sarStandAttrInfoEODao.deleteStandAttrByStandId(standId);
createStandAttrInfo(sarStandardsInfoEO);
createStandAttrInfo(sarStandardsInfoEO,true);
/**
* 编辑体系目录 当代替的标准号在我的收藏中时,此条标准也需要在我的收藏中
*/