feat: There is no way the Buss export and delete es index

This commit is contained in:
super_liu
2021-08-23 14:43:58 +08:00
parent fe89ba9c60
commit 38f4fc3674
12 changed files with 1131 additions and 18 deletions
@@ -1,6 +1,7 @@
package com.adc.da.slrs.sarBussionessStand.controller;
import com.adc.da.common.ReadExcel;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
import com.adc.da.slrs.sarResource.entity.TsResource;
@@ -14,17 +15,27 @@ 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.exception.AdcDaBaseException;
import com.adc.da.util.utils.IOUtils;
import com.adc.da.util.utils.StringUtils;
import com.adc.da.utils.util.BussStandExportUtil;
import com.adc.da.utils.util.SarAdvanceSearchUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
@@ -41,6 +52,8 @@ import java.util.List;
@RequestMapping("/${restPath}/lawss/sarBussionessStand")
public class SarBussionessStandController extends BaseController<SarBussionessStand> {
private static final Logger logger = LoggerFactory.getLogger(SarBussionessStandController.class);
@Autowired
private ISarBussionessStandService sarBussionessStandEOService;
@@ -57,6 +70,54 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
@Autowired
private IDicTypeEOService dicTypeEOService;
@ApiOperation(value = "|SarBussionessStandEO|删除")
@PostMapping("deleteSarBussionessStand")
//401问题2021-03-31暂时注释掉 liuhuiwen
// @RequiresPermissions("lawss:sarBussionessStand:delete")
public ResponseMessage delete(String ids) throws Exception {
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
sarBussionessStandEOPage.setIdlist(ids.split(","));
ResponseMessage<SarBussionessStand> result = sarBussionessStandEOService.deleteSarBussionessStand(sarBussionessStandEOPage);
logger.info("delete from SAR_BUSSIONESS_STAND where id = {}", ids);
return result;
}
/**
* 将查询出来的数据导出到EXCEL表格中
* @param
* @return
* @author gaoyan
* date 2018-09-04
*/
@ApiOperation(value = "|SarBussionessStandEO|导出excel")
@GetMapping(value = "/exportSarBussionessStand")
public void exportSarBussionessStand(String exportContent, String exportType, String exportName,String userId, HttpServletResponse response, HttpServletRequest request)throws Exception {
OutputStream os = null;
Workbook workbook = null;
try {
if(StringUtils.isEmpty(exportName)||exportName.equals("null")){
exportName="企业标准库";
}
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName(exportName+".xlsx",request));
response.setContentType("application/force-download");
//导出数据
List<SarBussionessStand> datas = sarBussionessStandEOService.getSarBussionessStand(exportType,exportContent,userId);
workbook = BussStandExportUtil.exportDatas(datas);
os = response.getOutputStream();
workbook.write(os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
if (workbook != null) {
workbook.close();
}
}
}
@ApiOperation(value = "|SarBussionessStandEO|企业标准修改")
@PostMapping(value = "/updateSarBussionessStand")
//401问题2021-03-31暂时注释掉 liuhuiwen
@@ -95,5 +95,7 @@ public interface SarBussionessStandDao extends BaseMapper<SarBussionessStand> {
int updateByPrimaryKeySelectiveTimeNotNull(SarBussionessStand sarBussionessStandEO);
int updateByPrimaryKeySelective(SarBussionessStand sarBussionessStandEO);
}
@@ -1,5 +1,6 @@
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.sarBussionessStand.entity.SarBussionessStand;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
@@ -17,6 +18,10 @@ import java.util.List;
*/
public interface ISarBussionessStandService extends IService<SarBussionessStand> {
ResponseMessage<SarBussionessStand> deleteSarBussionessStand(SarBussionessStandEOPage page) throws Exception;
List<SarBussionessStand> getSarBussionessStand(String exportType, String exportContent,String userId) throws Exception;
SarBussionessStand updateSarBussionessStand(SarBussionessStand sarBussionessStandEO) throws Exception;
List<SarBussionessStand> selectStandardsByStandNumber(String replaceStandNum);
@@ -6,16 +6,22 @@ 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.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.mq.CreateMQService;
import com.adc.da.mq.CreateStandMQService;
import com.adc.da.person.dao.PersonCollectEODao;
import com.adc.da.person.entity.TsPersonCollect;
import com.adc.da.person.page.PersonCollectEOPage;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.search.entity.StandLawsEO;
import com.adc.da.search.service.StandLawsSearchService;
import com.adc.da.slrs.otConvertMq.dao.OtConvertMqDao;
import com.adc.da.slrs.otConvertMq.entity.OtConvertMq;
import com.adc.da.slrs.sarBussStandAttrInfo.dao.SarBussStandAttrInfoDao;
import com.adc.da.slrs.sarBussStandFile.dao.SarBussStandFileDao;
import com.adc.da.slrs.sarBussStandFile.entity.SarBussStandFile;
import com.adc.da.slrs.sarBussStandItems.dao.SarBussStandItemsDao;
import com.adc.da.slrs.sarBussStandMenu.dao.SarBussStandMenuDao;
import com.adc.da.slrs.sarBussStandMenu.entity.SarBussStandMenu;
import com.adc.da.slrs.sarBussStandVal.dao.SarBussStandValDao;
@@ -27,6 +33,7 @@ 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.sarStandardsInfo.dao.SarStandardsInfoDao;
import com.adc.da.slrs.sarStandardsInfo.entity.SarAdvanceSearchVO;
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.sarUser.service.ITsUserService;
@@ -38,6 +45,7 @@ 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.adc.da.utils.util.SarAdvanceSearchUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sf.json.JSONObject;
@@ -120,9 +128,169 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired
private ISarUpdLogService sarUpdLogEOService;
@Autowired
private ITsResourceService sarMenuEOService;
@Autowired
private PersonCollectEODao personCollectEODao;
@Autowired
private SarBussStandAttrInfoDao sarBussStandAttrInfoEODao;
@Autowired
private SarBussStandItemsDao sarBussStandItemsEODao;
@Autowired
private StandLawsSearchService standLawsSearchService;
public ResponseMessage<SarBussionessStand> deleteSarBussionessStand(SarBussionessStandEOPage page) throws Exception {
SarBussionessStand sarStandardsInfoEO = new SarBussionessStand();
sarStandardsInfoEO.setValidFlag(1);
sarStandardsInfoEO.setModifyTime(new Date());
for (String id : page.getIdlist()) {
//删除标准表
sarStandardsInfoEO.setId(id);
sarBussionessStandEODao.updateByPrimaryKeySelective(sarStandardsInfoEO);
// 删除标准属性表
sarBussStandAttrInfoEODao.deleteStandAttrByStandId(id);
// 删除条款
sarBussStandItemsEODao.deleteByStandIdAndFileType(id,null);
// 删除标准台账表
// sarBusSarCompileEODao.deleteByBussStandId(id);
//删除收藏表中数据
personCollectEODao.deleteByResId(id);
// 删除分享表中数据
// personShareEODao.deleteByResId(id);
//删除标准关联的value表
sarBussStandValEODao.deleteDataByStandId(id);
List<SarBussStandFile> listFile = sarBussStandFileEODao.selectFileByStandId(id);
if (listFile != null) {
if (!listFile.isEmpty()) {
for (int f = 0; f < listFile.size(); f++) {
sarBussStandFileEODao.deleteByPrimaryKey(listFile.get(f).getId());
//删除文件信息表数据
// sarFileInfoEODao.deleteByfileId(listFile.get(f).getId());
//删除转换表ot_convert数据
otConvertEODao.deleteByAttId(listFile.get(f).getAttId());
}
}
}
if(elasflag) {
//删除成功后,将索引中对应数据删除
StandLawsEO standLawsEO = new StandLawsEO();
standLawsEO.setId(sarStandardsInfoEO.getId());
standLawsEO.setType("bussstand");
standLawsSearchService.deleteStandLawsSearch(standLawsEO);
}
}
return Result.success("0", "删除成功", sarStandardsInfoEO);
}
@Override
public List<SarBussionessStand> getSarBussionessStand(String exportType, String exportContent,String userId) throws Exception {
SarBussionessStandEOPage page = new SarBussionessStandEOPage();
if ("apart".equals(exportType)) {
page.setIdlist(exportContent.split(","));
} else {
JSONObject jsonObject = JSONObject.fromObject(exportContent);
page = (SarBussionessStandEOPage)JSONObject.toBean(jsonObject, SarBussionessStandEOPage.class);
page.setPage(1);
page.setPageSize(10000);
if (StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) {
List<SarAdvanceSearchVO> searchList = com.alibaba.fastjson.JSONObject.parseArray(page.getAdvanceSearchVOStr(),SarAdvanceSearchVO.class);
String advanceStr = SarAdvanceSearchUtil.createSql(searchList);
if (com.adc.da.util.utils.StringUtils.isNotBlank(advanceStr)) {
page.setAdvanceSearchStr(advanceStr);
} else {
page.setAdvanceSearchStr(null);
}
}
}
page.setOrderBy("SAR_BUSSIONESS_STAND.issue_time is null,SAR_BUSSIONESS_STAND.issue_time desc,SAR_BUSSIONESS_STAND.id");
List<String> getMenuIdList = new ArrayList<>();
if(userId != null){
getMenuIdList= tsUserService.getResourceUserId(userId);
}
// List<String> getMenuIdList = sarMenuEOService.queryRoleMenuIdList(page.getStandType() + "_STAND", null);
if (getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
} else {
page.setMenuRoleList(null);
}
// List<String> getMenuIdList = sarMenuEOService.queryRoleMenuIdList("BUSINESS_STAND",page.getMenuId());
if(getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
}
List<String> ids = sarMenuEOService.getChildMenuList(page.getMenuId());
if (ids != null && !ids.isEmpty()) {
page.setMenuAllChildrenIdList(ids);
}
if (StringUtils.isNotBlank(page.getAdvanceSearchVOStr())) {
List<SarAdvanceSearchVO> searchList = com.alibaba.fastjson.JSONObject.parseArray(page.getAdvanceSearchVOStr(), SarAdvanceSearchVO.class);
String advanceStr = SarAdvanceSearchUtil.createSql(searchList);
if (StringUtils.isNotBlank(advanceStr)) {
page.setAdvanceSearchStr(advanceStr);
} else {
page.setAdvanceSearchStr(null);
}
}
page.setUserId(userId);
List<SarBussionessStand> getList = sarBussionessStandEODao.getSarBussionessStand(page);
attrInfoShow(getList);
return getList;
}
public void attrInfoShow (List<SarBussionessStand> sarlist) throws Exception {
for(SarBussionessStand row : sarlist){
attrInfoDetails(row);
Map<String, Object> getAttrMap = row.getAttrInfoMap();
Map<String, Object> getNewMap = new LinkedHashMap<>();
if (getAttrMap != null && getAttrMap.size() > 0) {
String svppsTip = "";
for (Map.Entry<String,Object> entry : getAttrMap.entrySet()) {
String name = entry.getKey();
String value = "";
if ("SVPPS".equals(name)) {
Object svpps = entry.getValue();
if (svpps != null && StringUtils.isNotBlank(svpps.toString())) {
svppsTip = svpps.toString();
}
if (StringUtils.isNotBlank(svppsTip)) {
svppsTip = sysInfoEOService.getSvppsNamesTipByIds(svppsTip);
}
value = String.valueOf(getAttrMap.get("SVPPSName"));
entry.setValue(value);
} else if (entry.getValue() != null && InitStandAttrUtil.fileFieldListBuss != null && InitStandAttrUtil.fileFieldListBuss.size() > 0 && InitStandAttrUtil.fileFieldListBuss.contains(name)) {
value = entry.getValue().toString();
if (StringUtils.isNotBlank(value)) {
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
entry.setValue(fileObj);
}
} else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
value = entry.getValue().toString();
String selVal = InitStandAttrUtil.selectFieldMapBuss.get(name);
if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) {
if("ZYQCR".equals(name)||"QTQCR".equals(name)){
if(getAttrMap.get(name + "Name")!=null && !getAttrMap.get(name + "Name").equals("")){
value = String.valueOf(getAttrMap.get(name + "Name"));
}
}else{
value = String.valueOf(getAttrMap.get(name + "Name"));
}
} else {
List<String> valArr = Arrays.asList(value.split(","));
value = dicTypeEODao.getDicNamesByCodes(valArr);
}
entry.setValue(value);
}
}
getAttrMap.put("SVPPSTips",svppsTip);
}
}
}
public SarBussionessStand updateSarBussionessStand(SarBussionessStand sarBussionessStandEO) throws Exception {
String standId = sarBussionessStandEO.getId();
SarBussionessStand beforeStandEO = this.baseMapper.selectByPrimaryKey(standId);