feat: 迁移国内标准法规部分4 国内标准法规-删除功能

This commit is contained in:
super_liu
2021-06-03 14:16:02 +08:00
parent aded9a3e47
commit 3666dda9de
4 changed files with 116 additions and 2 deletions
@@ -167,6 +167,18 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
}
}
@ApiOperation(value = "|SarStandardsInfoEO|删除")
@PostMapping("/deleteSarStandards")
//401问题2021-03-31暂时注释掉 liuhuiwen
// @RequiresPermissions("lawss:sarStandardsInfo:delete")
public ResponseMessage delete(String ids) throws Exception {
int result = sarStandardsInfoEOService.deleteSarStandards(ids);
if (result > 0) {
return Result.success("0", "删除成功", result);
} else {
return Result.error("删除失败");
}
}
}
@@ -17,7 +17,6 @@ import java.util.List;
* @author super_liu
* @since 2021-05-31
*/
@Resource
public interface SarStandardsInfoDao extends BaseMapper<SarStandardsInfo> {
List<SarStandardsInfo> getSarStandardsInfoPage(SarStandardsInfoEOPage page);
@@ -26,7 +26,7 @@ public interface ISarStandardsInfoService extends IService<SarStandardsInfo> {
int updateSarStandardsInfo(SarStandardsInfo sarStandardsInfoEO) throws Exception;
//
// int deleteSarStandards(String ids);
int deleteSarStandards(String ids);
//
// List<SarStandardsInfo> getExportDatas (StandardsInfoExcelVO standardsInfoExcelVO) throws Exception;
//
@@ -3,6 +3,8 @@ package com.adc.da.slrs.sarStandardsInfo.service.impl;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.common.*;
import com.adc.da.person.dao.PersonCollectEODao;
import com.adc.da.person.dao.PersonShareEODao;
import com.adc.da.person.entity.PersonMsgEO;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.slrs.sarStandAttrInfo.dao.SarStandAttrInfoDao;
@@ -72,6 +74,12 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
@Autowired
private ISarUpdLogService sarUpdLogEOService;
@Autowired
private PersonCollectEODao personCollectEODao;
@Autowired
private PersonShareEODao personShareEODao;
@Autowired
private SarStandFileDao sarStandFileEODao;
@@ -941,4 +949,99 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
return map;
}
public int deleteSarStandards(String ids) {
String[] idArr = ids.split(",");
SarStandardsInfo sarStandardsInfoEO = new SarStandardsInfo();
sarStandardsInfoEO.setValidFlag("1");
sarStandardsInfoEO.setModifyTime(new Date());
int countResult = 0;
for (String id : idArr) {
countResult++;
//查询删除的标准信息(为删除代替关系)
SarStandardsInfo getDelStandInfoList = dao.selectById(id);
//删除标准与菜单关联数据
sarStandMenuEODao.deleteByStandId(id);
//删除标准表
sarStandardsInfoEO.setId(id);
dao.updateById(sarStandardsInfoEO);
// 删除标准属性表
sarStandAttrInfoEODao.deleteStandAttrByStandId(id);
// 删除标准下条款
sarStandItemsEODao.deleteByStandIdAndFileType(id,null);
//删除标准关联的value表
sarStandValEODao.deleteDataByStandid(id);
sarStandPutTimeEODao.deleteByStandId(id);
//删除文件详情表数据
sarStandFileEODao.deleteByStandId(id);
// List<SarStandFile> listFile = sarStandFileEODao.selectFileByStandId(id);
// if (listFile != null) {
// if (!listFile.isEmpty()) {
// for (int f = 0; f < listFile.size(); f++) {
// //删除文件信息表数据
// sarFileInfoEODao.deleteByfileId(listFile.get(f).getId());
// //删除转换表ot_convert数据
// otConvertEODao.deleteByAttId(listFile.get(f).getAttId());
// }
// }
// }
//删除代替关系
updateStandReplaceConnect(getDelStandInfoList);
//删除收藏表中数据
personCollectEODao.deleteByResId(id);
// 删除分享表中数据
personShareEODao.deleteByResId(id);
// if(elasflag) {
// //删除成功后,将索引中对应数据删除
// StandLawsEO standLawsEO = new StandLawsEO();
// standLawsEO.setId(sarStandardsInfoEO.getId());
// standLawsEO.setType("stand");
// sarStandAndLawsEOService.deleteFomrIndex(standLawsEO);
// }
}
return countResult;
}
/**
* 删除标准同时删除代替关系
* @param getDelStandInfo
*/
public void updateStandReplaceConnect(SarStandardsInfo getDelStandInfo){
if(getDelStandInfo != null){
//查询该条标准代替过的标准
SarStandardsInfoEOPage sarStandardsInfoEOPage = new SarStandardsInfoEOPage();
String standNum = "";
if(StringUtils.isNotEmpty(getDelStandInfo.getStandYear())){
standNum = getDelStandInfo.getStandSort()+" "+getDelStandInfo.getStandNumber()+"-"+getDelStandInfo.getStandYear();
}else{
standNum = getDelStandInfo.getStandSort()+" "+getDelStandInfo.getStandNumber();
}
sarStandardsInfoEOPage.setReplacedStandNum(standNum);
List<SarStandardsInfo> getReplacedStands = dao.getSarStandardsInfoPage(sarStandardsInfoEOPage);
if(getReplacedStands != null && !getReplacedStands.isEmpty()){
for(SarStandardsInfo stand : getReplacedStands){
SarStandardsInfo newStand = new SarStandardsInfo();
newStand.setId(stand.getId());
String replacedNum = stand.getReplacedStandNum();
List<String> numList = Arrays.asList(replacedNum.split(","));
if(numList.contains(standNum)){
//被代替标准号都已逗号分隔存在一个字段里,如果存在字符串中间,后面会有一个逗号,
// 存在字符串末尾则没有逗号
if(numList.contains(standNum+",")){
newStand.setReplacedStandNum(stand.getReplacedStandNum().replaceAll(standNum+",",""));
dao.updateById(newStand);
} else {
if (numList.contains(","+standNum)) {
newStand.setReplacedStandNum(stand.getReplacedStandNum().replace(","+standNum,""));
} else {
newStand.setReplacedStandNum(stand.getReplacedStandNum().replace(standNum,""));
}
dao.updateById(newStand);
}
}
}
}
}
}
}