add: 政策导入导出

This commit is contained in:
wxyclub
2023-10-30 09:12:32 +08:00
parent c342f88f2c
commit 40ded57e5b
30 changed files with 1564 additions and 243 deletions
@@ -188,6 +188,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
// 标准法规库-企标计划导出接口
addInterceptor.excludePathPatterns("/api/esRevisePlan/es-revise-plan/exportEsRevisePlanInfoExcel");
// 内外部会议导出接口
addInterceptor.excludePathPatterns("/api/lawss/insideOutsideMeeting/exportMeetingInfo");
// 政策课题导出接口
addInterceptor.excludePathPatterns("/api/lawss/sarLawsTopic/exportLawsTopicInfo");
addInterceptor.excludePathPatterns("/api/lawss/sarLawsInformation/exportLawsInformationInfo");
// // 添加自定义拦截器,并拦截对应 url
addInterceptor.addPathPatterns("/**");
@@ -1,6 +1,10 @@
package com.adc.da.slrs.InsideOntSideMeeting.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.base.web.BaseController;
import com.adc.da.common.ReadExcel;
import com.adc.da.exception.AdcDaBaseException;
@@ -10,22 +14,27 @@ import com.adc.da.http.Result;
import com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeeting;
import com.adc.da.slrs.InsideOntSideMeeting.entity.InsideOutsideMeetingVO;
import com.adc.da.slrs.InsideOntSideMeeting.service.InsideOutsideMeetingService;
import com.adc.da.utils.util.InsideOutsideMeetingExportUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
@@ -44,6 +53,9 @@ public class InsideOutSideMeetingController extends BaseController<InsideOutside
@Resource
private InsideOutsideMeetingService meetingService;
@Value("${file.path}")
private String filePath;
@ApiOperation(value = "根据会议ID查询会议信息")
@GetMapping("/getMeetingInfo")
public ResponseMessage<InsideOutsideMeeting> getMeetingInfo(String meetingId){
@@ -110,7 +122,11 @@ public class InsideOutSideMeetingController extends BaseController<InsideOutside
// 导出所有数据
datas = meetingService.queryAllMeeting(insideOutsideMeetingVO);
}
workbook = InsideOutsideMeetingExportUtil.exportDatas(datas);
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
exportParams.setSheetName(insideOutsideMeetingVO.getExportName());
// workbook = InsideOutsideMeetingExportUtil.exportDatas(datas);
workbook = ExcelExportUtil.exportExcel(exportParams, InsideOutsideMeetingVO.class, datas);
os = response.getOutputStream();
workbook.write(os);
os.flush();
@@ -131,4 +147,73 @@ public class InsideOutSideMeetingController extends BaseController<InsideOutside
}
return meetingService.importMeetingInfo(file);
}
@ApiOperation(value = "内外部会议导入模板下载")
@GetMapping("/exportTemplateFile")
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request)throws Exception{
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "内外部会议导入模板";
if (StringUtils.isNotEmpty(fileName)) {
fileOriName = fileName;
}
try{
//创建临时文件夹
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName2 = "导入模板.xls";
HSSFSheet sheetItems = workbook.createSheet("模板");
sheetItems.setDefaultColumnWidth(13);
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 13));
Row row2 = sheetItems.createRow(0);//开始创建填写说明
String exportFieldName = FieldConvertUtil.exportFieldNamesInsideOutsideMeeting + FieldConvertUtil.exportFieldNamesMeetingTopic;
if (StringUtils.isNotBlank(exportFieldName)) {
String[] headerArr = exportFieldName.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
Cell cellA2 = row2.createCell(0);
cellA2.setCellValue(FieldConvertUtil.exportInsideOutsideMeetingDesc);
//sheetItems.setColumnWidth(0, 20 * 150);
row2.setHeight((short) (100 * 25));
HSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
cellStyle.setWrapText(true);
cellA2.setCellStyle(cellStyle);
String repFileName = fileName2.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(excelOS);
}
}
}
@@ -80,12 +80,17 @@ public class InsideOutsideMeeting extends BaseEntity {
private String firstMeetingType;
@ApiModelProperty(value = "1级会议类别名称")
@TableField(exist = false)
private String firstMeetingTypeName;
@ApiModelProperty(value = "2级会议类别")
@TableField("SECOND_MEETING_TYPE")
private String secondMeetingType;
@ApiModelProperty(value = "2级会议类别名称")
@TableField(exist = false)
private String secondMeetingTypeName;
@ApiModelProperty(value = "会议议题")
@TableField(exist = false)
private List<MeetingTopic> meetingTopicList;
@@ -1,5 +1,7 @@
package com.adc.da.slrs.InsideOntSideMeeting.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.base.page.BasePage;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -22,17 +24,23 @@ public class InsideOutsideMeetingVO extends BasePage {
private String id;
@Excel(name = "会议名称", needMerge = true)
private String meetingName;
@Excel(name = "课题名称", needMerge = true)
private String topicName;
@Excel(name = "会议主办单位", needMerge = true)
private String meetingOrganizer;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@Excel(name = "会议时间", exportFormat = "yyyy-MM-dd", needMerge = true)
private Date meetingTime;
@Excel(name = "会议地点", needMerge = true)
private String meetingAddress;
@Excel(name = "参会人员", needMerge = true)
private String participants;
private List<String> participantsList;
@@ -40,12 +48,20 @@ public class InsideOutsideMeetingVO extends BasePage {
private List<AttFileEO> meetingMinutesList;
@Excel(name = "会议主要内容", needMerge = true)
private String meetingContent;
private String firstMeetingType;
@Excel(name = "1级会议类别", needMerge = true)
private String firstMeetingTypeName;
private String secondMeetingType;
@Excel(name = "2级会议类别", needMerge = true)
private String secondMeetingTypeName;
@ExcelCollection(name = "会议议题")
private List<MeetingTopic> meetingTopicList;
private String agendaName;
@@ -1,19 +1,17 @@
package com.adc.da.slrs.InsideOntSideMeeting.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author tjzdw
* @description
@@ -36,6 +34,7 @@ public class MeetingTopic extends BaseEntity {
@ApiModelProperty(value = "议题名称")
@TableField("AGENDA_NAME")
@Excel(name = "议题名称")
private String agendaName;
@ApiModelProperty(value = "议题材料")
@@ -44,27 +43,16 @@ public class MeetingTopic extends BaseEntity {
@ApiModelProperty(value = "汇报人")
@TableField("REPORTER")
@Excel(name = "汇报人")
private String reporter;
@ApiModelProperty(value = "汇报单位")
@TableField("REPORTING_UNIT")
@Excel(name = "汇报单位")
private String reportingUnit;
@ApiModelProperty(value = "议题主要内容")
@TableField("AGENDA_CONTENT")
@Excel(name = "议题主要内容")
private String agendaContent;
@ApiModelProperty(value = "逻辑删除,0可用,1不可用")
@TableField("VALID_FLAG")
private Integer validFlag;
@ApiModelProperty(value = "创建时间")
@TableField("CREATE_TIME")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "修改时间")
@TableField("MODIFY_TIME")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
}
@@ -12,7 +12,12 @@ import com.adc.da.slrs.InsideOntSideMeeting.entity.MeetingTopic;
import com.adc.da.slrs.InsideOntSideMeeting.service.InsideOutsideMeetingService;
import com.adc.da.slrs.InsideOntSideMeeting.service.MeetingTopicService;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -36,6 +41,7 @@ import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author tjzdw
@@ -47,34 +53,38 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
@Resource
private MeetingTopicService meetingTopicService;
@Resource
private IAttFileEOService attFileEOService;
@Resource
private ITsDicTypeService dicTypeService;
@Resource
private ISarUpdLogService updLogService;
@Value("${file.path}")
private String filePath;//文件存储路径
@Override
public InsideOutsideMeeting getMeetingInfo(String meetingId){
InsideOutsideMeeting insideOutSideMeeting = this.baseMapper.selectById(meetingId);
if (insideOutSideMeeting != null) {
if (StringUtils.isNotBlank(insideOutSideMeeting.getMeetingMinutes())) {
InsideOutsideMeeting insideOutsideMeeting = this.baseMapper.selectById(meetingId);
if (insideOutsideMeeting != null) {
// 获取会议纪要文件对象
if (StringUtils.isNotBlank(insideOutsideMeeting.getMeetingMinutes())) {
List<AttFileEO> meetingMinutesList = new ArrayList<>();
for (String attId : insideOutSideMeeting.getMeetingMinutes().split(",")) {
for (String attId : insideOutsideMeeting.getMeetingMinutes().split(",")) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
meetingMinutesList.add(fileInfo);
}
insideOutSideMeeting.setMeetingMinutesList(meetingMinutesList);
insideOutsideMeeting.setMeetingMinutesList(meetingMinutesList);
}
// 获取会议类别值
getTypeByCode(insideOutsideMeeting);
// 获取会议课题列表
LambdaQueryWrapper<MeetingTopic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MeetingTopic::getMeetingId, meetingId);
List<MeetingTopic> meetingTopicList = meetingTopicService.list(wrapper);
insideOutSideMeeting.setMeetingTopicList(meetingTopicList);
insideOutsideMeeting.setMeetingTopicList(meetingTopicList);
}
return insideOutSideMeeting;
return insideOutsideMeeting;
}
@Transactional
@@ -85,73 +95,78 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
wrapper.set(InsideOutsideMeeting::getValidFlag,1);
boolean update = update(wrapper);
if (update) {
LambdaUpdateWrapper<MeetingTopic> topicWrapper = new LambdaUpdateWrapper<>();
LambdaQueryWrapper<MeetingTopic> topicWrapper = new LambdaQueryWrapper<>();
topicWrapper.eq(MeetingTopic::getMeetingId, meetingId);
topicWrapper.set(MeetingTopic::getValidFlag,1);
meetingTopicService.update(topicWrapper);
meetingTopicService.remove(topicWrapper);
}
return update;
}
@Transactional
@Override
public Boolean updateMeetingInfo(InsideOutsideMeeting insideOutSideMeeting) {
if (StringUtils.isBlank(insideOutSideMeeting.getId())) {
public Boolean updateMeetingInfo(InsideOutsideMeeting insideOutsideMeeting) {
if (StringUtils.isBlank(insideOutsideMeeting.getId())) {
return false;
}
insideOutSideMeeting.setModifyTime(new Date());
int update = this.baseMapper.updateById(insideOutSideMeeting);
if (update > 0) {
LambdaQueryWrapper<MeetingTopic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MeetingTopic::getMeetingId,insideOutSideMeeting.getId());
// 先删除会议信息
meetingTopicService.remove(wrapper);
// 再添加会议信息
for (MeetingTopic meetingTopic : insideOutSideMeeting.getMeetingTopicList()) {
meetingTopic.setCreateTime(new Date());
meetingTopic.setModifyTime(new Date());
meetingTopic.setValidFlag(0);
meetingTopic.setMeetingId(insideOutSideMeeting.getId());
meetingTopicService.save(meetingTopic);
InsideOutsideMeeting insideOutsideMeetingDB = this.baseMapper.selectById(insideOutsideMeeting.getId());
List<String> diffList = compareInsideOutsideMeeting(insideOutsideMeetingDB, insideOutsideMeeting);
if (diffList.size() > 0) {
insideOutsideMeeting.setModifyTime(new Date());
int update = this.baseMapper.updateById(insideOutsideMeeting);
if (update > 0) {
LambdaQueryWrapper<MeetingTopic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MeetingTopic::getMeetingId,insideOutsideMeeting.getId());
// 先删除会议信息
meetingTopicService.remove(wrapper);
// 再添加会议信息
for (MeetingTopic meetingTopic : insideOutsideMeeting.getMeetingTopicList()) {
meetingTopic.setMeetingId(insideOutsideMeeting.getId());
meetingTopicService.save(meetingTopic);
}
// 存储修改记录
SarUpdLog sarUpdLogEO = new SarUpdLog();
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
sarUpdLogEO.setSarId(insideOutsideMeetingDB.getId());
sarUpdLogEO.setSarType("INSIDE_OUTSIDE_MEETING");
sarUpdLogEO.setCreationTime(new Date());
sarUpdLogEO.setCreationUser(LoginUserUtil.getUserId());
sarUpdLogEO.setContent(insideOutsideMeetingDB.getMeetingName() + "," + String.join(",",diffList));
updLogService.save(sarUpdLogEO);
}
}
return true;
}
// 用于Excel文件导出
@Override
public List<InsideOutsideMeetingVO> queryAllMeeting(InsideOutsideMeetingVO insideOutsideMeetingVO) {
List<InsideOutsideMeetingVO> insideOutsideMeetingVOList = this.baseMapper.queryAllMeeting(insideOutsideMeetingVO);
for (InsideOutsideMeetingVO meetingVO : insideOutsideMeetingVOList) {
if (StringUtils.isNotBlank(meetingVO.getMeetingMinutes())) {
List<AttFileEO> meetingMinutesList = new ArrayList<>();
for (String attId : meetingVO.getMeetingMinutes().split(",")) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
meetingMinutesList.add(fileInfo);
}
meetingVO.setMeetingMinutesList(meetingMinutesList);
}
// 获取会议类别值
getTypeByCode(meetingVO);
}
return insideOutsideMeetingVOList;
}
@Override
public List<InsideOutsideMeetingVO> queryMeetingById(List<String> exportIdList) {
return this.baseMapper.queryMeetingById(exportIdList);
List<InsideOutsideMeetingVO> insideOutsideMeetingVOList = this.baseMapper.queryMeetingById(exportIdList);
for (InsideOutsideMeetingVO meetingVO : insideOutsideMeetingVOList) {
getTypeByCode(meetingVO);
}
return insideOutsideMeetingVOList;
}
@Transactional
@Override
public Integer addMeetingInfo(InsideOutsideMeeting insideOutSideMeeting) {
insideOutSideMeeting.setCreateTime(new Date());
insideOutSideMeeting.setModifyTime(new Date());
insideOutSideMeeting.setValidFlag(0);
int insert = this.baseMapper.insert(insideOutSideMeeting);
if (!insideOutSideMeeting.getMeetingTopicList().isEmpty()) {
for (MeetingTopic meetingTopic : insideOutSideMeeting.getMeetingTopicList()) {
meetingTopic.setMeetingId(insideOutSideMeeting.getId());
meetingTopic.setCreateTime(new Date());
meetingTopic.setModifyTime(new Date());
meetingTopic.setValidFlag(0);
public Integer addMeetingInfo(InsideOutsideMeeting insideOutsideMeeting) {
insideOutsideMeeting.setCreateTime(new Date());
insideOutsideMeeting.setModifyTime(new Date());
insideOutsideMeeting.setValidFlag(0);
int insert = this.baseMapper.insert(insideOutsideMeeting);
if (!insideOutsideMeeting.getMeetingTopicList().isEmpty()) {
for (MeetingTopic meetingTopic : insideOutsideMeeting.getMeetingTopicList()) {
meetingTopic.setMeetingId(insideOutsideMeeting.getId());
meetingTopicService.save(meetingTopic);
}
}
@@ -174,7 +189,21 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
Integer rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount);
return this.baseMapper.queryByPage(page);
List<InsideOutsideMeetingVO> insideOutsideMeetingVOList = this.baseMapper.queryByPage(page);
for (InsideOutsideMeetingVO insideOutsideMeeting : insideOutsideMeetingVOList) {
// 获取会议纪要文件对象
if (StringUtils.isNotBlank(insideOutsideMeeting.getMeetingMinutes())) {
List<AttFileEO> meetingMinutesList = new ArrayList<>();
for (String attId : insideOutsideMeeting.getMeetingMinutes().split(",")) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
meetingMinutesList.add(fileInfo);
}
insideOutsideMeeting.setMeetingMinutesList(meetingMinutesList);
}
// 获取会议类别值
getTypeByCode(insideOutsideMeeting);
}
return insideOutsideMeetingVOList;
}
@Override
@@ -282,6 +311,9 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
rowMap.put(headerCell.getStringCellValue(), sdf.format(d));
} else {
cell.setCellType(CellType.STRING);
if (cell.getStringCellValue().length() > 500) {
return Result.error("单元格输入过长");
}
rowMap.put(headerCell.getStringCellValue(), cell.getStringCellValue());
}
} else {
@@ -290,50 +322,81 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
importDataList.add(rowMap);
}
for (Map<String, String> stringStringMap : importDataList) {
LambdaQueryWrapper<InsideOutsideMeeting> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(InsideOutsideMeeting::getMeetingName, stringStringMap.get("会议名称"));
List<InsideOutsideMeeting> insideOutsideMeetingList = this.baseMapper.selectList(wrapper);
if (insideOutsideMeetingList.size() > 0) {
InsideOutsideMeeting insideOutsideMeeting = insideOutsideMeetingList.get(0);
// 获取需要校验的字段
List<TsDicType> firstMeetingTypeList = dicTypeService.selectAllDicTypeNameByDicCode("firstMeetingType");
Set<String> firstMeetingTypeNameSet = firstMeetingTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
List<TsDicType> secondMeetingTypeList = dicTypeService.selectAllDicTypeNameByDicCode("secondMeetingType");
Set<String> secondMeetingTypeNameSet = secondMeetingTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
// 计数器,用于处理出现多条会议课题的情况
int count = 0;
// InsideOutsideMeeting insideOutsideMeetingDB = null;
InsideOutsideMeeting insideOutsideMeeting = new InsideOutsideMeeting();
List<MeetingTopic> meetingTopicList = new ArrayList<>();
for (Map<String, String> dataMap : importDataList) {
String meetingName = dataMap.get("会议名称");
// 如果会议名称为空,则表示该行为会议课题行,是之前会议的会议课题,不提交之前的会议信息。不为空则进入
if (StringUtils.isNotBlank(meetingName)) {
// 如果计数器大于0,表示进入了新的会议信息中,提交之前的会议信息
if (count > 0) {
insideOutsideMeeting.setMeetingTopicList(meetingTopicList);
addMeetingInfo(insideOutsideMeeting);
// 初始化会议课题列表
meetingTopicList.clear();
// 初始化会议对象
insideOutsideMeeting = new InsideOutsideMeeting();
// 计数器归零
count = 0;
}
insideOutsideMeeting.setMeetingName(meetingName);
insideOutsideMeeting.setTopicName(dataMap.get("课题名称"));
insideOutsideMeeting.setMeetingOrganizer(dataMap.get("会议主办单位"));
insideOutsideMeeting.setMeetingTime(sdf.parse(dataMap.get("会议时间")));
insideOutsideMeeting.setMeetingAddress(dataMap.get("会议地点"));
insideOutsideMeeting.setParticipants(dataMap.get("参会人员"));
insideOutsideMeeting.setMeetingContent(dataMap.get("会议主要内容"));
if (StringUtils.isNotBlank(dataMap.get("一级会议类别"))) {
if (!firstMeetingTypeNameSet.contains(dataMap.get("一级会议类别"))){
return Result.error("一级会议类别不符合输入要求");
}
for (TsDicType tsDicType : firstMeetingTypeList) {
if (dataMap.get("一级会议类别").equals(tsDicType.getDicTypeName())) {
insideOutsideMeeting.setFirstMeetingType(tsDicType.getDicTypeCode());
}
}
}
if (StringUtils.isNotBlank(dataMap.get("二级会议类别"))) {
if (!secondMeetingTypeNameSet.contains(dataMap.get("二级会议类别"))){
return Result.error("二级会议类别不符合输入要求");
}
for (TsDicType tsDicType : secondMeetingTypeList) {
if (dataMap.get("二级会议类别").equals(tsDicType.getDicTypeName())) {
insideOutsideMeeting.setSecondMeetingType(tsDicType.getDicTypeCode());
}
}
}
// 会议课题信息
MeetingTopic meetingTopic = new MeetingTopic();
meetingTopic.setAgendaName(stringStringMap.get("议题名称"));
meetingTopic.setReporter("汇报人");
meetingTopic.setReportingUnit("汇报单位");
meetingTopic.setAgendaContent("议题主要内容");
meetingTopic.setValidFlag(0);
meetingTopic.setMeetingId(insideOutsideMeeting.getId());
meetingTopic.setCreateTime(new Date());
meetingTopic.setModifyTime(new Date());
meetingTopicService.save(meetingTopic);
meetingTopic.setAgendaName(dataMap.get("议题名称"));
meetingTopic.setReporter(dataMap.get("汇报人"));
meetingTopic.setReportingUnit(dataMap.get("汇报单位"));
meetingTopic.setAgendaContent(dataMap.get("议题主要内容"));
meetingTopicList.add(meetingTopic);
count++;
} else {
InsideOutsideMeeting insideOutsideMeeting = new InsideOutsideMeeting();
insideOutsideMeeting.setMeetingTopicList(new ArrayList<>());
insideOutsideMeeting.setMeetingName(stringStringMap.get("会议名称"));
insideOutsideMeeting.setTopicName(stringStringMap.get("课题名称"));
insideOutsideMeeting.setMeetingOrganizer(stringStringMap.get("会议主办单位"));
insideOutsideMeeting.setMeetingTime(sdf.parse(stringStringMap.get("会议时间")));
insideOutsideMeeting.setMeetingAddress(stringStringMap.get("会议地点"));
insideOutsideMeeting.setParticipants(stringStringMap.get("参会人员"));
insideOutsideMeeting.setMeetingContent(stringStringMap.get("会议主要内容"));
insideOutsideMeeting.setFirstMeetingType(stringStringMap.get("一级会议类别"));
insideOutsideMeeting.setSecondMeetingType(stringStringMap.get("二级会议类别"));
insideOutsideMeeting.setValidFlag(0);
insideOutsideMeeting.setCreateTime(new Date());
insideOutsideMeeting.setModifyTime(new Date());
this.baseMapper.insert(insideOutsideMeeting);
// 进入else 表示该行是会议课题行
MeetingTopic meetingTopic = new MeetingTopic();
meetingTopic.setAgendaName(stringStringMap.get("议题名称"));
meetingTopic.setReporter("汇报人");
meetingTopic.setReportingUnit("汇报单位");
meetingTopic.setAgendaContent("议题主要内容");
meetingTopic.setValidFlag(0);
meetingTopic.setMeetingId(insideOutsideMeeting.getId());
meetingTopic.setCreateTime(new Date());
meetingTopic.setModifyTime(new Date());
meetingTopicService.save(meetingTopic);
meetingTopic.setAgendaName(dataMap.get("议题名称"));
meetingTopic.setReporter(dataMap.get("汇报人"));
meetingTopic.setReportingUnit(dataMap.get("汇报单位"));
meetingTopic.setAgendaContent(dataMap.get("议题主要内容"));
meetingTopicList.add(meetingTopic);
count++;
}
}
// 插入最后一条记录
insideOutsideMeeting.setMeetingTopicList(meetingTopicList);
addMeetingInfo(insideOutsideMeeting);
return Result.success("导入完成");
}
@@ -364,10 +427,10 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
public List<String> compareInsideOutsideMeeting(InsideOutsideMeeting oldMeeting, InsideOutsideMeeting newMeeting) {
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","validFlag","createTime","modifyTime","meetingTopicList"};
String[] ignoreFields = {"id","validFlag","createTime","modifyTime", "firstMeetingTypeName", "secondMeetingTypeName"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields();
Field[] fields = InsideOutsideMeeting.class.getDeclaredFields();
for (Field field : fields) {
if (!ignoreFieldList.contains(field.getName())) {
try {
@@ -382,7 +445,7 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name");
Method method = InsideOutsideMeeting.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldMeeting);
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldTypeName + "\"改为\"" + typeName + "\"");
@@ -397,24 +460,22 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldMeeting);
Method method = InsideOutsideMeeting.class.getMethod("get" + fieldName + "List");
List<?> oldFileList = (List)method.invoke(oldMeeting);
List<String> oldFileNameList = new ArrayList<>();
if (oldFileList != null && oldFileList.size() > 0) {
for (Object oldFile : oldFileList) {
AttFileEO oldFile1 = (AttFileEO) oldFile;
oldFileNameList.add(oldFile1.getOldFileName());
}
}
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldTypeName + "\"改为\"" + String.join(",",fileNameList) + "\"");
changes.add(annotationsByType.value() + "\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
}
else if ("meetingTopicList".equals(field.getName())) {
// // 获取会议列表内容
// String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
// Method method = SarLawsInformation.class.getMethod("get" + fieldName);
// List<?> oldMeetingTopicList = (List<?>)method.invoke(oldMeeting);
// List<?> newMeetingTopicList = (List<?>)method.invoke(newMeeting);
// for (Object meetingTopic : oldMeetingTopicList) {
// meetingTopicService.compareMeetingTopic(meetingTopic, oldMeeting);
// }
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldValue + "\"改为\"" + newValue + "\"");
changes.add(annotationsByType.value() + "被变更");
}
else {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
@@ -429,4 +490,23 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
return changes;
}
public void getTypeByCode(InsideOutsideMeetingVO meetingVO) {
// 获取会议类别值
if (StringUtils.isNotBlank(meetingVO.getFirstMeetingType())) {
meetingVO.setFirstMeetingTypeName(dicTypeService.getDicTypeNameByDicCode(meetingVO.getFirstMeetingType()));
}
if (StringUtils.isNotBlank(meetingVO.getSecondMeetingType())) {
meetingVO.setSecondMeetingTypeName(dicTypeService.getDicTypeNameByDicCode(meetingVO.getSecondMeetingType()));
}
}
public void getTypeByCode(InsideOutsideMeeting meeting) {
// 获取会议类别值
if (StringUtils.isNotBlank(meeting.getFirstMeetingType())) {
meeting.setFirstMeetingTypeName(dicTypeService.getDicTypeNameByDicCode(meeting.getFirstMeetingType()));
}
if (StringUtils.isNotBlank(meeting.getSecondMeetingType())) {
meeting.setSecondMeetingTypeName(dicTypeService.getDicTypeNameByDicCode(meeting.getSecondMeetingType()));
}
}
}
@@ -36,7 +36,7 @@ public class MeetingTopicServiceImpl extends ServiceImpl<MeetingTopicDao, Meetin
public List<String> compareMeetingTopic(InsideOutsideMeeting oldTopic, InsideOutsideMeeting newTopic) {
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","meetingId","validFlag","createTime","modifyTime"};
String[] ignoreFields = {"id","meetingId"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 获取SarLawsInformation类的所有字段
Field[] fields = SarLawsInformation.class.getDeclaredFields();
@@ -1,17 +1,41 @@
package com.adc.da.slrs.sarLawsInformation.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.base.web.BaseController;
import com.adc.da.common.ReadExcel;
import com.adc.da.exception.AdcDaBaseException;
import com.adc.da.http.PageInfo;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationService;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
/**
@@ -23,9 +47,14 @@ import java.util.List;
@RequestMapping("/${restPath}/lawss/sarLawsInformation")
public class SarLawsInformationController extends BaseController<SarLawsInformation> {
private static final Logger logger = LoggerFactory.getLogger(SarLawsInformationController.class);
@Resource
private SarLawsInformationService informationService;
@Value("${file.path}")
private String filePath;
@ApiOperation(value = "根据政策资料ID查询资料信息")
@GetMapping("/getLawsInformationInfo")
public ResponseMessage<SarLawsInformation> getLawsInformationInfo(String id){
@@ -69,4 +98,120 @@ public class SarLawsInformationController extends BaseController<SarLawsInformat
Boolean updateResult = informationService.updateLawsInformationInfo(lawsInformation);
return updateResult ? Result.success() : Result.error("更新失败");
}
@ApiOperation("导出政策法规资料信息")
@GetMapping("/exportLawsInformationInfo")
public ResponseMessage<?> exportLawsInformationInfo(SarLawsInformation sarLawsInformation, HttpServletResponse response,
HttpServletRequest request) {
OutputStream os = null;
Workbook workbook = null;
List<SarLawsInformation> datas;
try {
if(StringUtils.isEmpty(sarLawsInformation.getExportName())||sarLawsInformation.getExportName().equals("null")){
sarLawsInformation.setExportName("政策法规资料信息");
}
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName(sarLawsInformation.getExportName()+".xlsx",
request));
// 导出数据,若指定了值则使用ids字段条件导出,否则根据条件导出
if (StrUtil.isNotBlank(sarLawsInformation.getExportIds())) {
List<String> idList = Arrays.asList(sarLawsInformation.getExportIds().split(","));
datas = informationService.getLawsInformationByIds(idList);
} else {
// 导出所有数据
datas = informationService.getAllLawsInformation(sarLawsInformation);
}
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
exportParams.setSheetName(sarLawsInformation.getExportName());
workbook = ExcelExportUtil.exportExcel(exportParams,SarLawsInformation.class,datas);
os = response.getOutputStream();
workbook.write(os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
}
return Result.success();
}
@ApiOperation("Excel文件导入政策资料信息")
@PostMapping("/importLawsInformationInfo")
public ResponseMessage<?> importLawsInformationInfo(@RequestParam(value = "file",required = false) MultipartFile file) throws ParseException {
if (file == null) {
return Result.error("文件为空,请重新上传");
}
return informationService.importLawsInformationInfo(file);
}
@ApiOperation(value = "政策法规资料导入模板下载")
@GetMapping("/exportTemplateFile")
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request)throws Exception{
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "政策法规资料导入模板";
if (StringUtils.isNotEmpty(fileName)) {
fileOriName = fileName;
}
try{
//创建临时文件夹
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName2 = "导入模板.xls";
HSSFSheet sheetItems = workbook.createSheet("模板");
sheetItems.setDefaultColumnWidth(13);
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
Row row2 = sheetItems.createRow(0);//开始创建填写说明
String exportFieldName = FieldConvertUtil.exportFieldLawsInformation;
if (StringUtils.isNotBlank(exportFieldName)) {
String[] headerArr = exportFieldName.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
Cell cellA2 = row2.createCell(0);
cellA2.setCellValue(FieldConvertUtil.exportLawsInformationDesc);
//sheetItems.setColumnWidth(0, 20 * 150);
row2.setHeight((short) (100 * 25));
HSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
cellStyle.setWrapText(true);
cellA2.setCellStyle(cellStyle);
String repFileName = fileName2.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(excelOS);
}
}
}
@@ -18,6 +18,8 @@ public interface SarLawsInformationDao extends BaseMapper<SarLawsInformation> {
Integer queryByPageCount(SarLawsInformation page);
List<SarLawsInformation> queryByPage(SarLawsInformation page);
List<SarLawsInformation> getAllLawsInformation(SarLawsInformation sarLawsInformation);
}
@@ -1,5 +1,7 @@
package com.adc.da.slrs.sarLawsInformation.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.base.page.BasePage;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -7,6 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
@@ -43,6 +46,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "一级资料类别名称")
@TableField(exist = false)
@Excel(name = "一级资料类别", orderNum = "0")
private String firstTypeName;
/**
@@ -57,6 +61,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "二级资料类别名称")
@TableField(exist = false)
@Excel(name = "二级资料类别", orderNum = "1")
private String secondTypeName;
/**
@@ -71,6 +76,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "三级资料类别名称")
@TableField(exist = false)
@Excel(name = "三级资料类别", orderNum = "2")
private String thirdTypeName;
/**
@@ -85,6 +91,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "四级资料类别名称")
@TableField(exist = false)
@Excel(name = "四级资料类别", orderNum = "3")
private String fourthTypeName;
/**
@@ -92,6 +99,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "资料名称")
@TableField(value = "NAME")
@Excel(name = "资料名称", orderNum = "4")
private String name;
/**
@@ -99,6 +107,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "资料归属部门")
@TableField(value = "DEPARTMENT")
@Excel(name = "资料归属部门", orderNum = "5")
private String department;
/**
@@ -106,6 +115,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "作者")
@TableField(value = "AUTHOR")
@Excel(name = "作者", orderNum = "6")
private String author;
/**
@@ -115,6 +125,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@TableField(value = "UPLOAD_TIME")
@Excel(name = "上传时间", orderNum = "7", exportFormat = "yyyy-MM-dd")
private Date uploadTime;
/**
@@ -122,6 +133,7 @@ public class SarLawsInformation extends BasePage implements Serializable {
*/
@ApiModelProperty(value = "资料说明")
@TableField(value = "DESCRIPTION")
@Excel(name = "资料说明", orderNum = "8")
private String description;
/**
@@ -134,9 +146,9 @@ public class SarLawsInformation extends BasePage implements Serializable {
/**
* 资料文件名称
*/
@ApiModelProperty(value = "资料文件名称")
@ApiModelProperty(value = "资料文件对象列表")
@TableField(exist = false)
private String informationFileName;
private List<AttFileEO> informationFileList;
/**
* 可查看者,若设置为空则所有用户均可查看,若设置人员后,仅有可查看者可以查看文件信息。
@@ -219,6 +231,15 @@ public class SarLawsInformation extends BasePage implements Serializable {
@TableField(exist = false)
private String collectId;
// Excel导出使用字段
@ApiModelProperty("导出文件名")
@TableField(exist = false)
private String exportName;
@ApiModelProperty("导出的文件Ids")
@TableField(exist = false)
private String exportIds;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
@@ -1,7 +1,9 @@
package com.adc.da.slrs.sarLawsInformation.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -21,4 +23,20 @@ public interface SarLawsInformationService extends IService<SarLawsInformation>
Boolean deleteInformation(String id);
Boolean updateLawsInformationInfo(SarLawsInformation lawsInformation);
/**
* 根据法规资料id列表查询资料信息,用于导出,不包含文件信息
* @param idList 法规资料Id列表
* @return 法规资料列表
*/
List<SarLawsInformation> getLawsInformationByIds(List<String> idList);
/**
* 查询法规资料信息,用于导出,不包含文件信息
* @param sarLawsInformation 法规资料对象,用于查询
* @return 法规资料列表
*/
List<SarLawsInformation> getAllLawsInformation(SarLawsInformation sarLawsInformation);
ResponseMessage<?> importLawsInformationInfo(MultipartFile file);
}
@@ -1,31 +1,53 @@
package com.adc.da.slrs.sarLawsInformation.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.common.FileUnZip;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.person.entity.TsPersonCollect;
import com.adc.da.person.service.IPersonCollectEOService;
import com.adc.da.slrs.sarLawsInformationCenterTree.entity.SarLawsInformationCenterTree;
import com.adc.da.slrs.sarLawsInformationCenterTree.service.SarLawsInformationCenterTreeService;
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsInformation.service.SarLawsInformationService;
import com.adc.da.slrs.sarLawsInformation.dao.SarLawsInformationDao;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author tjzdw
@@ -46,6 +68,10 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
private IPersonCollectEOService collectEOService;
@Resource
private ISarUpdLogService updLogService;
@Resource
private ITsUserService userService;
@Value("${file.path}")
private String filePath;//文件存储路径
@Override
public SarLawsInformation getLawsInformationInfo(String id) {
@@ -55,12 +81,12 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
// 查询资料文件信息
if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) {
String[] split = sarLawsInformation.getInformationFile().split(",");
List<String> fileNameList = new ArrayList<>();
List<AttFileEO> fileNameList = new ArrayList<>();
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo.getOldFileName());
fileNameList.add(fileInfo);
}
sarLawsInformation.setInformationFileName(String.join(",",fileNameList));
sarLawsInformation.setInformationFileList(fileNameList);
}
// 查询体系节点信息
if (StringUtils.isNotBlank(sarLawsInformation.getTreeNodeId())) {
@@ -89,10 +115,20 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
Integer rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount);
// 将字典编号变更为字典值
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.queryByPage(page);
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值
convertCodeToName(sarLawsInformation);
// 查询文件信息
if (StringUtils.isNotBlank(sarLawsInformation.getInformationFile())) {
String[] split = sarLawsInformation.getInformationFile().split(",");
List<AttFileEO> fileNameList = new ArrayList<>();
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo);
}
sarLawsInformation.setInformationFileList(fileNameList);
}
}
return sarLawsInformationList;
}
@@ -101,8 +137,14 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
public Integer addLawsInformation(SarLawsInformation sarLawsInformation) {
sarLawsInformation.setCreateTime(new Date());
sarLawsInformation.setModifyTime(new Date());
sarLawsInformation.setUploadTime(new Date());
if (sarLawsInformation.getUploadTime() == null) {
sarLawsInformation.setUploadTime(new Date());
}
sarLawsInformation.setValidFlag(0);
String userId = LoginUserUtil.getUserId();
TsUser tsUser = userService.getById(userId);
sarLawsInformation.setViewableBy(tsUser.getUname() + "(" + userId + ")");
sarLawsInformation.setDownloadableBy(tsUser.getUname() + "(" + userId + ")");
// 若体系类别不存在,则默认属于根节点
if (StringUtils.isBlank(sarLawsInformation.getTreeNodeId())) {
LambdaQueryWrapper<SarLawsInformationCenterTree> wrapper = new LambdaQueryWrapper<>();
@@ -146,6 +188,204 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
return true;
}
@Override
public List<SarLawsInformation> getLawsInformationByIds(List<String> idList) {
LambdaQueryWrapper<SarLawsInformation> wrapper = new LambdaQueryWrapper<>();
wrapper.in(SarLawsInformation::getId, idList);
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.selectList(wrapper);
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值
convertCodeToName(sarLawsInformation);
}
return sarLawsInformationList;
}
@Override
public List<SarLawsInformation> getAllLawsInformation(SarLawsInformation sarLawsInformation) {
List<SarLawsInformation> sarLawsInformationList = this.baseMapper.getAllLawsInformation(sarLawsInformation);
for (SarLawsInformation lawsInformation : sarLawsInformationList) {
// 将字典编号变更为字典值
convertCodeToName(lawsInformation);
// 查询文件信息
if (StringUtils.isNotBlank(lawsInformation.getInformationFile())) {
String[] split = lawsInformation.getInformationFile().split(",");
List<AttFileEO> fileNameList = new ArrayList<>();
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo);
}
lawsInformation.setInformationFileList(fileNameList);
}
}
return sarLawsInformationList;
}
@Override
public ResponseMessage<?> importLawsInformationInfo(MultipartFile file) {
//获取文件全称
String fileNameStr = file.getOriginalFilename();
//获取最后.的位置
assert fileNameStr != null;
int pos = fileNameStr.lastIndexOf(".");
//获取压缩文件名称并以小写显示
String fileStr = fileNameStr.substring(pos + 1).toLowerCase();
//校验是否是zip文件
if (!fileStr.equals("zip")) {
return Result.error("请上传zip格式的文件");
}
//进行拼接获取文件名称
String fileName = fileNameStr.substring(0, pos);
//获取路径和文件名称
String path = filePath + "/" + fileName;
File saveDirectory = new File(path);
//判断saveDirectory中是否是文件夹
if (!saveDirectory.isDirectory()) {
saveDirectory.mkdir();
}
//将文件写入到指定路径中
try {
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + "/" + fileNameStr));
} catch (IOException e) {
return Result.error("文件存储失败!");
}
//解压缩
String zipEntryName = null;
try {
zipEntryName = FileUnZip.unZipFiles(path + "/" + fileNameStr, path);
FileUnZip.delete(new File(path + "/" + fileNameStr));
} catch (IOException e) {
return Result.error("文件解压失败");
}
//获取文件信息
List<File> fileList = readImpExcelFile(zipEntryName);
//判断获取到的文件数量
if (fileList.size() != 1) {
return Result.error("上传的文件只能有一个");
}
File importFile = fileList.get(0);
if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) {
return Result.error("文件必须是EXCEL文件");
}
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(importFile);
} catch (IOException e) {
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Sheet sheet = workbook.getSheetAt(0);
if (sheet == null) {
return Result.error("工作表为空");
}
StringBuilder sb = new StringBuilder();
List<String> headerList = new ArrayList<>();
// 获取excel表头
Row headerRow = sheet.getRow(1);
for (int i = 0; i < 8; i++) {
headerList.add(headerRow.getCell(i).getStringCellValue());
}
// 判断表头字段是否相同
if (!String.join(",",headerList).equals(FieldConvertUtil.exportFieldLawsInformation)) {
try {
workbook.close();
} catch (IOException e) {
return Result.error("文件关闭出错");
}
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
return Result.error("fail", "读取失败,请严格按照模板文件导入数据");
}
ImportParams importParams = new ImportParams();
importParams.setTitleRows(1);
List<SarLawsInformation> sarLawsInformationList = ExcelImportUtil.importExcel(readImpExcelFile(zipEntryName).get(0), SarLawsInformation.class, importParams);
// 获取需要校验的字段
List<TsDicType> firstMaterialTypeList = dicTypeService.selectAllDicTypeNameByDicCode("firstMaterialType");
Set<String> firstMaterialTypeNameSet = firstMaterialTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
List<TsDicType> secondMaterialTypeList = dicTypeService.selectAllDicTypeNameByDicCode("secondMaterialType");
Set<String> secondMaterialTypeNameSet = secondMaterialTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
List<TsDicType> thirdMaterialTypeList = dicTypeService.selectAllDicTypeNameByDicCode("thirdMaterialType");
Set<String> thirdMaterialTypeNameSet = thirdMaterialTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
List<TsDicType> fourthMaterialTypeList = dicTypeService.selectAllDicTypeNameByDicCode("fourthMaterialType");
Set<String> fourthMaterialTypeNameSet = fourthMaterialTypeList.stream().map(TsDicType::getDicTypeName).collect(Collectors.toSet());
// 遍历索引
int index = 1;
// 去除空数据
List<SarLawsInformation> sarLawsInformationListNew = new ArrayList<>();
for (SarLawsInformation sarLawsInformation : sarLawsInformationList) {
if (StringUtils.isNotBlank(sarLawsInformation.getName())) {
sarLawsInformationListNew.add(sarLawsInformation);
}
}
for (SarLawsInformation sarLawsInformation : sarLawsInformationListNew){
// 把excel表中的类别名转换为类别编号,并对类别名做检测
if (StringUtils.isNotBlank(sarLawsInformation.getFirstTypeName())) {
List<String> firstTypeCodeList = new ArrayList<>();
for (String firstTypeName : sarLawsInformation.getFirstTypeName().split(",")) {
if (!firstMaterialTypeNameSet.contains(firstTypeName)){
return Result.error("" + index + "条记录的一级会议类别不符合输入要求");
}
for (TsDicType tsDicType : firstMaterialTypeList) {
if (firstTypeName.equals(tsDicType.getDicTypeName())) {
firstTypeCodeList.add(tsDicType.getDicTypeCode());
}
}
}
sarLawsInformation.setFirstType(String.join(",", firstTypeCodeList));
}
if (StringUtils.isNotBlank(sarLawsInformation.getSecondTypeName())) {
List<String> secondTypeCodeList = new ArrayList<>();
for (String secondTypeName : sarLawsInformation.getSecondTypeName().split(",")) {
if (!secondMaterialTypeNameSet.contains(secondTypeName)){
return Result.error("" + index + "条记录的二级会议类别不符合输入要求");
}
for (TsDicType tsDicType : secondMaterialTypeList) {
if (secondTypeName.equals(tsDicType.getDicTypeName())) {
secondTypeCodeList.add(tsDicType.getDicTypeCode());
}
}
}
sarLawsInformation.setSecondType(String.join(",", secondTypeCodeList));
}
if (StringUtils.isNotBlank(sarLawsInformation.getThirdTypeName())) {
List<String> thirdTypeCodeList = new ArrayList<>();
for (String thirdTypeName : sarLawsInformation.getThirdTypeName().split(",")) {
if (!thirdMaterialTypeNameSet.contains(thirdTypeName)){
return Result.error("" + index + "条记录的三级会议类别不符合输入要求");
}
for (TsDicType tsDicType : thirdMaterialTypeList) {
if (thirdTypeName.equals(tsDicType.getDicTypeName())) {
thirdTypeCodeList.add(tsDicType.getDicTypeCode());
}
}
}
sarLawsInformation.setThirdType(String.join(",", thirdTypeCodeList));
}
if (StringUtils.isNotBlank(sarLawsInformation.getFourthTypeName())) {
List<String> fourthTypeCodeList = new ArrayList<>();
for (String fourthTypeName : sarLawsInformation.getFourthTypeName().split(",")) {
if (!fourthMaterialTypeNameSet.contains(fourthTypeName)){
return Result.error("" + index + "条记录的四级会议类别不符合输入要求");
}
for (TsDicType tsDicType : fourthMaterialTypeList) {
if (fourthTypeName.equals(tsDicType.getDicTypeName())) {
fourthTypeCodeList.add(tsDicType.getDicTypeCode());
}
}
}
sarLawsInformation.setFourthType(String.join(",", fourthTypeCodeList));
}
// 索引 +1
index++;
// 存入数据库
addLawsInformation(sarLawsInformation);
}
return Result.success("导入成功");
}
public void convertCodeToName(SarLawsInformation sarLawsInformation) {
List<String> firstTypeList = new ArrayList<>();
for (String type : sarLawsInformation.getFirstType().split(",")) {
@@ -187,7 +427,7 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","firstTypeName","secondTypeName","thirdTypeName","fourthTypeName","uploadTime",
"informationFileName","createAndApproveBy","treeNodeId","treeNodeName","validFlag","createTime",
"informationFileList","createAndApproveBy","treeNodeId","treeNodeName","validFlag","createTime",
"modifyTime","sortField","sortMode","collectId","serialVersionUID"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 获取SarLawsInformation类的所有字段
@@ -227,10 +467,17 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsInformation.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldInfo);
List<?> oldFileList = (List)method.invoke(oldInfo);
List<String> oldFileNameList = new ArrayList<>();
if (oldFileList != null && oldFileList.size() > 0) {
for (Object oldFile : oldFileList) {
AttFileEO oldFile1 = (AttFileEO) oldFile;
oldFileNameList.add(oldFile1.getOldFileName());
}
}
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldTypeName + "\"改为\"" + String.join(",",fileNameList) + "\"");
changes.add(annotationsByType.value() + "\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
}
else {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
@@ -245,6 +492,23 @@ public class SarLawsInformationServiceImpl extends ServiceImpl<SarLawsInformatio
}
return changes;
}
private static List<File> readImpExcelFile(String path) {
File file = new File(path);
List<File> resultlist = new ArrayList<>();
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File fi : files) {
// 对文件进行过滤,读取所有文件
String name = fi.getName();
//文件不为空 添加
if (name != null){
resultlist.add(fi);
}
}
}
return resultlist;
}
}
@@ -1,19 +1,44 @@
package com.adc.da.slrs.sarLawsTopic.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.base.web.BaseController;
import com.adc.da.common.ReadExcel;
import com.adc.da.exception.AdcDaBaseException;
import com.adc.da.http.PageInfo;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO;
import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicService;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
/**
@@ -26,9 +51,14 @@ import java.util.List;
@RequestMapping("/${restPath}/lawss/sarLawsTopic")
public class SarLawsTopicController extends BaseController<SarLawsTopicVO> {
private static final Logger logger = LoggerFactory.getLogger(SarLawsTopicController.class);
@Resource
private SarLawsTopicService lawsTopicService;
@Value("${file.path}")
private String filePath;
@ApiOperation(value = "根据政策课题ID查询会议信息")
@GetMapping("/getLawsTopicInfo")
public ResponseMessage<SarLawsTopic> getLawsTopicInfo(String id) throws Exception{
@@ -72,4 +102,120 @@ public class SarLawsTopicController extends BaseController<SarLawsTopicVO> {
Boolean updateResult = lawsTopicService.updateLawsTopicInfo(lawsTopic);
return updateResult ? Result.success() : Result.error("更新失败");
}
@ApiOperation("导出政策课题信息")
@GetMapping("/exportLawsTopicInfo")
public ResponseMessage<?> exportLawsTopicInfo(SarLawsTopicVO sarLawsTopicVO, HttpServletResponse response,
HttpServletRequest request) {
OutputStream os = null;
Workbook workbook = null;
List<SarLawsTopicVO> datas;
try {
if(StringUtils.isEmpty(sarLawsTopicVO.getExportName())||sarLawsTopicVO.getExportName().equals("null")){
sarLawsTopicVO.setExportName("政策课题信息");
}
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName(sarLawsTopicVO.getExportName()+".xlsx",
request));
// 导出数据,若指定了值则使用ids字段条件导出,否则根据条件导出
if (StrUtil.isNotBlank(sarLawsTopicVO.getExportIds())) {
List<String> idList = Arrays.asList(sarLawsTopicVO.getExportIds().split(","));
datas = lawsTopicService.getLawsTopicByIds(idList);
} else {
// 导出所有数据
datas = lawsTopicService.getAllLawsTopic(sarLawsTopicVO);
}
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
exportParams.setSheetName(sarLawsTopicVO.getExportName());
workbook = ExcelExportUtil.exportExcel(exportParams, SarLawsTopicVO.class, datas);
os = response.getOutputStream();
workbook.write(os);
os.flush();
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
}
return Result.success();
}
@ApiOperation("Excel文件导入政策资料信息")
@PostMapping("/importLawsTopicInfo")
public ResponseMessage<?> importLawsTopicInfo(@RequestParam(value = "file",required = false) MultipartFile file) throws ParseException {
if (file == null) {
return Result.error("文件为空,请重新上传");
}
return lawsTopicService.importLawsTopicInfo(file);
}
@ApiOperation(value = "政策课题导入模板下载")
@GetMapping("/exportTemplateFile")
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request)throws Exception{
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "政策课题导入模板";
if (StringUtils.isNotEmpty(fileName)) {
fileOriName = fileName;
}
try{
//创建临时文件夹
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName2 = "导入模板.xls";
HSSFSheet sheetItems = workbook.createSheet("模板");
sheetItems.setDefaultColumnWidth(13);
Row rowHeader = sheetItems.createRow(1);//开始创建标题行
sheetItems.addMergedRegion(new CellRangeAddress(0, 0, 0, 13));
Row row2 = sheetItems.createRow(0);//开始创建填写说明
String exportFieldName = FieldConvertUtil.exportFieldLawsTopic;
if (StringUtils.isNotBlank(exportFieldName)) {
String[] headerArr = exportFieldName.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
Cell cellA2 = row2.createCell(0);
cellA2.setCellValue(FieldConvertUtil.exportLawsInformationDesc);
//sheetItems.setColumnWidth(0, 20 * 150);
row2.setHeight((short) (100 * 25));
HSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.LEFT);
cellStyle.setVerticalAlignment(VerticalAlignment.TOP);
cellStyle.setWrapText(true);
cellA2.setCellStyle(cellStyle);
String repFileName = fileName2.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
} finally {
IOUtils.closeQuietly(os);
IOUtils.closeQuietly(excelOS);
}
}
}
@@ -4,6 +4,7 @@ import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -19,6 +20,10 @@ public interface SarLawsTopicMapper extends BaseMapper<SarLawsTopic> {
Integer queryByPageCount(SarLawsTopicVO page);
List<SarLawsTopicVO> queryByPage(SarLawsTopicVO page);
List<SarLawsTopicVO> getLawsTopicByIds(@Param("idList") List<String> idList);
List<SarLawsTopicVO> getAllLawsTopic(SarLawsTopicVO sarLawsTopicVO);
}
@@ -1,5 +1,6 @@
package com.adc.da.slrs.sarLawsTopic.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -36,30 +37,35 @@ public class SarLawsContactInformation implements Serializable {
* 姓名
*/
@TableField(value = "NAME")
@Excel(name = "姓名", orderNum = "0", type = 1)
private String name;
/**
* 单位
*/
@TableField(value = "DEPARTMENT")
@Excel(name = "单位", orderNum = "1", type = 1)
private String department;
/**
* 电话
*/
@TableField(value = "PHONE")
@Excel(name = "电话", orderNum = "2", type = 1)
private String phone;
/**
* 邮箱
*/
@TableField(value = "EMAIL")
@Excel(name = "邮箱", orderNum = "3", type = 1)
private String email;
/**
* 身份
*/
@TableField(value = "IDENTITY")
@Excel(name = "身份", orderNum = "4", type = 1)
private String identity;
@TableField(exist = false)
@@ -1,5 +1,6 @@
package com.adc.da.slrs.sarLawsTopic.entity;
import com.adc.da.att.entity.AttFileEO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -9,6 +10,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -21,36 +23,42 @@ public class SarLawsTopic implements Serializable {
/**
* 主键
*/
@ApiModelProperty(value = "主键")
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
/**
* 课题名称
*/
@ApiModelProperty(value = "课题名称")
@TableField(value = "TOPIC_NAME")
private String topicName;
/**
* 课题承办单位
*/
@ApiModelProperty(value = "课题承办单位")
@TableField(value = "ORGANIZER")
private String organizer;
/**
* 课题指导单位
*/
@ApiModelProperty(value = "课题指导单位")
@TableField(value = "GUIDANCE_UNIT")
private String guidanceUnit;
/**
* 课题参与单位
*/
@ApiModelProperty(value = "课题参与单位")
@TableField(value = "PARTICIPATING_UNIT")
private String participatingUnit;
/**
* 开始时间
*/
@ApiModelProperty(value = "开始时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@TableField(value = "START_TIME")
private Date startTime;
@@ -58,6 +66,7 @@ public class SarLawsTopic implements Serializable {
/**
* 结题时间
*/
@ApiModelProperty(value = "结题时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@TableField(value = "CLOSE_TIME")
private Date closeTime;
@@ -65,162 +74,162 @@ public class SarLawsTopic implements Serializable {
/**
* 课题状态
*/
@ApiModelProperty(value = "课题状态")
@TableField(value = "TOPIC_STATUS")
private String topicStatus;
/**
* 课题费用(万元)
*/
@ApiModelProperty(value = "课题费用")
@TableField(value = "TOPIC_COST")
private String topicCost;
/**
* 协议
*/
@ApiModelProperty("协议文件")
@TableField(value = "AGREEMENT")
private String agreement;
/**
* 协议真实文件名
*/
@ApiModelProperty(value = "协议文件列表")
@TableField(exist = false)
private String agreementName;
private List<AttFileEO> agreementList;
/**
* 课题组会议列表
*/
@ApiModelProperty(value = "课题组会议列表")
@TableField(exist = false)
private List<SarLawsTopicMeeting> meetingList;
/**
* 课题组研究方案
*/
@ApiModelProperty(value = "课题研究方案")
@TableField(value = "RESEARCH_PLAN")
private String researchPlan;
/**
* 课题组研究方案真实文件名
*/
@ApiModelProperty(value = "课题组研究方案文件列表")
@TableField(exist = false)
private String researchPlanName;
private List<AttFileEO> researchPlanList;
/**
* 课题组研究成果
*/
@ApiModelProperty(value = "课题组研究成果")
@TableField(value = "RESEARCH_FINDINGS")
private String researchFindings;
/**
* 课题组研究成果真实文件名
*/
@ApiModelProperty(value = "课题组研究成果文件列表")
@TableField(exist = false)
private String researchFindingsName;
private List<AttFileEO> researchFindingsList;
/**
* 课题组其他
*/
@ApiModelProperty(value = "课题组其他文件")
@TableField(value = "RESEARCH_GROUP_OTHER")
private String researchGroupOther;
/**
* 课题组其他真实文件名
*/
@ApiModelProperty(value = "课题组其他文件列表")
@TableField(exist = false)
private String researchGroupOtherName;
private List<AttFileEO> researchGroupOtherList;
/**
* 课题组会议资料
*/
@ApiModelProperty(value = "课题组会议资料")
@TableField(value = "CONFERENCE_MATERIALS")
private String conferenceMaterials;
/**
* 课题组会议资料真实文件名
*/
@ApiModelProperty(value = "课题组会议资料文件列表")
@TableField(exist = false)
private String conferenceMaterialsName;
private List<AttFileEO> conferenceMaterialsList;
/**
* 课题组联系方式
*/
@ApiModelProperty(value = "课题组联系方式列表")
@TableField(exist = false)
private List<SarLawsContactInformation> topicContactInformationList;
/**
* 内部资料立项报告
*/
@ApiModelProperty(value = "内部资料立项报告")
@TableField(value = "INSIDE_PROJECT_PROPOSAL_REPORT")
private String insideProjectProposalRepost;
/**
* 内部资料立项报告真实文件名
*/
@ApiModelProperty(value = "内部资料立项报告文件列表")
@TableField(exist = false)
private String insideProjectProposalRepostName;
private List<AttFileEO> insideProjectProposalRepostList;
/**
* 内部资料研究方案
*/
@ApiModelProperty(value = "内部资料研究方案")
@TableField(value = "INSIDE_RESEARCH_PLAN")
private String insideResearchPlan;
/**
* 内部资料研究方案真实文件名
*/
@ApiModelProperty(value = "内部资料研究方案文件列表")
@TableField(exist = false)
private String insideResearchPlanName;
private List<AttFileEO> insideResearchPlanList;
/**
* 内部资料会议资料
*/
@ApiModelProperty(value = "内部资料会议资料")
@TableField(value = "INSIDE_CONFERENCE_MATERIALS")
private String insideConferenceMaterials;
/**
* 内部资料会议资料真实文件名
*/
@ApiModelProperty(value = "内部资料会议资料文件列表")
@TableField(exist = false)
private String insideConferenceMaterialsName;
private List<AttFileEO> insideConferenceMaterialsList;
/**
* 内部会议研究成果
*/
@ApiModelProperty(value = "内部会议研究成果")
@TableField(value = "INSIDE_RESEARCH_FINDINGS")
private String insideResearchFindings;
/**
* 内部会议研究成果真实文件名
*/
@ApiModelProperty(value = "内部会议研究成果文件列表")
@TableField(exist = false)
private String insideResearchFindingsName;
private List<AttFileEO> insideResearchFindingsList;
/**
* 内部会议其他
*/
@ApiModelProperty(value = "内部会议其他文件")
@TableField(value = "INSIDE_OTHER")
private String insideOther;
/**
* 内部会议其他真实文件名
*/
@ApiModelProperty(value = "内部会议其他文件列表")
@TableField(exist = false)
private String insideOtherName;
private List<AttFileEO> insideOtherList;
/**
* 内部联系方式
*/
@ApiModelProperty(value = "内部联系方式列表")
@TableField(exist = false)
private List<SarLawsContactInformation> insideContactInformationList;
/**
* 逻辑删除,0可用,1不可用
*/
@ApiModelProperty(value = "逻辑删除")
@TableField(value = "VALID_FLAG")
private Integer validFlag;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "CREATE_TIME")
private Date createTime;
@@ -228,6 +237,7 @@ public class SarLawsTopic implements Serializable {
/**
* 修改时间
*/
@ApiModelProperty(value = "修改时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "MODIFY_TIME")
private Date modifyTime;
@@ -1,13 +1,12 @@
package com.adc.da.slrs.sarLawsTopic.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/**
@@ -33,30 +32,35 @@ public class SarLawsTopicMeeting implements Serializable {
* 会议名称
*/
@TableField(value = "MEETING_NAME")
@Excel(name = "会议名称", orderNum = "0", type = 1)
private String meetingName;
/**
* 会议时间
*/
@TableField(value = "MEETING_TIME")
@Excel(name = "会议时间", orderNum = "1", type = 1)
private String meetingTime;
/**
* 会议地点
*/
@TableField(value = "MEETING_ADDRESS")
@Excel(name = "会议地点", orderNum = "2", type = 1)
private String meetingAddress;
/**
* 参会人员(内部)
*/
@TableField(value = "PARTICIPANTS")
@Excel(name = "参会人员(内部)", orderNum = "3", type = 1)
private String participants;
/**
* 会议主要内容
*/
@TableField(value = "MEETING_CONTENT")
@Excel(name = "会议主要内容", orderNum = "4", type = 1)
private String meetingContent;
@TableField(exist = false)
@@ -1,5 +1,8 @@
package com.adc.da.slrs.sarLawsTopic.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.base.page.BasePage;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@@ -27,21 +30,25 @@ public class SarLawsTopicVO extends BasePage {
/**
* 课题名称
*/
@Excel(name = "课题名称", orderNum = "0", type = 1, needMerge = true)
private String topicName;
/**
* 课题承办单位
*/
@Excel(name = "课题承办单位", orderNum = "1",type = 1, needMerge = true)
private String organizer;
/**
* 课题指导单位
*/
@Excel(name = "课题指导单位", orderNum = "2", type = 1, needMerge = true)
private String guidanceUnit;
/**
* 课题参与单位
*/
@Excel(name = "课题参与单位", orderNum = "3", type = 1, needMerge = true)
private String participatingUnit;
/**
@@ -49,6 +56,7 @@ public class SarLawsTopicVO extends BasePage {
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始时间", orderNum = "4", exportFormat = "yyyy-MM-dd", needMerge = true)
private Date startTime;
/**
@@ -56,16 +64,19 @@ public class SarLawsTopicVO extends BasePage {
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "结题时间", orderNum = "5", exportFormat = "yyyy-MM-dd", needMerge = true)
private Date closeTime;
/**
* 课题状态
*/
@Excel(name = "课题状态", orderNum = "6", type = 1, needMerge = true)
private String topicStatus;
/**
* 课题费用(万元)
*/
@Excel(name = "课题费用(万元)", orderNum = "7", type = 1, needMerge = true)
private String topicCost;
/**
@@ -73,9 +84,12 @@ public class SarLawsTopicVO extends BasePage {
*/
private String agreement;
private List<AttFileEO> agreementList;
/**
* 课题组会议列表
*/
@ExcelCollection(name = "课题组会议列表", orderNum = "8")
private List<SarLawsTopicMeeting> meetingList;
/**
@@ -111,24 +125,33 @@ public class SarLawsTopicVO extends BasePage {
*/
private String researchPlan;
private List<AttFileEO> researchPlanList;
/**
* 课题组研究成果
*/
private String researchFindings;
private List<AttFileEO> researchFindingsList;
/**
* 课题组其他
*/
private String researchGroupOther;
private List<AttFileEO> researchGroupOtherList;
/**
* 课题组会议资料
*/
private String conferenceMaterials;
private List<AttFileEO> conferenceMaterialsList;
/**
* 课题组联系方式
*/
@ExcelCollection(name = "课题组联系方式", orderNum = "9")
private List<SarLawsContactInformation> topicContactInformationList;
// 课题组用户名称
@@ -147,29 +170,40 @@ public class SarLawsTopicVO extends BasePage {
*/
private String insideProjectProposalRepost;
private List<AttFileEO> insideProjectProposalRepostList;
/**
* 内部资料研究方案
*/
private String insideResearchPlan;
private List<AttFileEO> insideResearchPlanList;
/**
* 内部资料会议资料
*/
private String insideConferenceMaterials;
private List<AttFileEO> insideConferenceMaterialsList;
/**
* 内部会议研究成果
*/
private String insideResearchFindings;
private List<AttFileEO> insideResearchFindingsList;
/**
* 内部会议其他
*/
private String insideOther;
private List<AttFileEO> insideOtherList;
/**
* 内部联系方式
*/
@ExcelCollection(name = "内部联系方式", orderNum = "10")
private List<SarLawsContactInformation> insideContactInformationList;
// 内部人员名称
@@ -206,4 +240,10 @@ public class SarLawsTopicVO extends BasePage {
private String startTimeOperator = "=";
private String closeTimeOperator = "=";
// 导出使用的属性
// 导出文件名
private String exportName;
// 导出的ID列表字符串
private String exportIds;
}
@@ -1,8 +1,11 @@
package com.adc.da.slrs.sarLawsTopic.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -22,4 +25,10 @@ public interface SarLawsTopicService extends IService<SarLawsTopic> {
Boolean updateLawsTopicInfo(SarLawsTopic lawsTopic);
List<SarLawsTopicVO> queryByPage(SarLawsTopicVO sarLawsTopicVO);
List<SarLawsTopicVO> getLawsTopicByIds(List<String> idList);
List<SarLawsTopicVO> getAllLawsTopic(SarLawsTopicVO sarLawsTopicVO);
ResponseMessage<?> importLawsTopicInfo(MultipartFile file);
}
@@ -1,28 +1,49 @@
package com.adc.da.slrs.sarLawsTopic.service.impl;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.impl.AttFileEOServiceImpl;
import com.adc.da.common.FileUnZip;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsContactInformation;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicMeeting;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO;
import com.adc.da.slrs.sarLawsTopic.service.SarLawsContactInformationService;
import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicMeetingService;
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic;
import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicService;
import com.adc.da.slrs.sarLawsTopic.dao.SarLawsTopicMapper;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author tjzdw
@@ -37,33 +58,17 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
private SarLawsTopicMeetingService meetingService;
@Resource
private AttFileEOServiceImpl attFileEOService;
@Resource
private ISarUpdLogService updLogService;
@Value("${file.path}")
private String filePath;//文件存储路径
@Resource
private SarLawsContactInformationService contactInformationService;
@Override
public SarLawsTopic getLawsTopicInfo(String lawsTopicId) throws Exception {
String[] fileFieldArray = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials",
"insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"};
public SarLawsTopic getLawsTopicInfo(String lawsTopicId) {
SarLawsTopic sarLawsTopic = this.baseMapper.selectById(lawsTopicId);
Class<? extends SarLawsTopic> aClass = sarLawsTopic.getClass();
for (String fileField : fileFieldArray) {
fileField = fileField.substring(0,1).toUpperCase() + fileField.substring(1);
Method getMethod = aClass.getMethod("get" + fileField);
String attIds = (String) getMethod.invoke(sarLawsTopic, null);
if (StringUtils.isNotBlank(attIds)) {
String[] split = attIds.split(",");
List<String> tempList = new ArrayList<>();
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
tempList.add(fileInfo.getOldFileName());
}
Method setMethod = aClass.getMethod("set" + fileField + "Name", String.class);
String join = String.join(",", tempList);
System.out.println(fileField+""+join);
setMethod.invoke(sarLawsTopic,join);
}
}
// 查询课题组会议
LambdaQueryWrapper<SarLawsTopicMeeting> meetingWrapper = new LambdaQueryWrapper<>();
meetingWrapper.eq(SarLawsTopicMeeting::getLawsTopicId, lawsTopicId);
@@ -72,15 +77,17 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
// 查询课题组联系方式
LambdaQueryWrapper<SarLawsContactInformation> topicGroupWrapper = new LambdaQueryWrapper<>();
topicGroupWrapper.eq(SarLawsContactInformation::getLawsTopicId, lawsTopicId);
topicGroupWrapper.eq(SarLawsContactInformation::getGroupType,"lawsTopic");
topicGroupWrapper.eq(SarLawsContactInformation::getGroupType,"topicGroup");
List<SarLawsContactInformation> lawsTopicContactInformation = contactInformationService.list(topicGroupWrapper);
sarLawsTopic.setTopicContactInformationList(lawsTopicContactInformation);
// 查询内部联系房方式
LambdaQueryWrapper<SarLawsContactInformation> insideWrapper = new LambdaQueryWrapper<>();
topicGroupWrapper.eq(SarLawsContactInformation::getLawsTopicId, lawsTopicId);
topicGroupWrapper.eq(SarLawsContactInformation::getGroupType,"lawsTopic");
List<SarLawsContactInformation> insideContactInformation = contactInformationService.list(topicGroupWrapper);
insideWrapper.eq(SarLawsContactInformation::getLawsTopicId, lawsTopicId);
insideWrapper.eq(SarLawsContactInformation::getGroupType,"inside");
List<SarLawsContactInformation> insideContactInformation = contactInformationService.list(insideWrapper);
sarLawsTopic.setInsideContactInformationList(insideContactInformation);
// 获取文件信息
getFileListByAttFile(sarLawsTopic);
return sarLawsTopic;
}
@@ -93,22 +100,28 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
int insert = this.baseMapper.insert(lawsTopic);
if (lawsTopic.getMeetingList() != null && !lawsTopic.getMeetingList().isEmpty()) {
for (SarLawsTopicMeeting meeting : lawsTopic.getMeetingList()) {
meeting.setLawsTopicId(lawsTopic.getId());
meetingService.save(meeting);
if (StringUtils.isNotBlank(meeting.getMeetingName())) {
meeting.setLawsTopicId(lawsTopic.getId());
meetingService.save(meeting);
}
}
}
if (lawsTopic.getTopicContactInformationList() != null && !lawsTopic.getTopicContactInformationList().isEmpty()) {
for (SarLawsContactInformation information : lawsTopic.getTopicContactInformationList()) {
information.setLawsTopicId(lawsTopic.getId());
information.setGroupType("topicGroup");
contactInformationService.save(information);
if (StringUtils.isNotBlank(information.getName())) {
information.setLawsTopicId(lawsTopic.getId());
information.setGroupType("topicGroup");
contactInformationService.save(information);
}
}
}
if (lawsTopic.getInsideContactInformationList() != null && !lawsTopic.getInsideContactInformationList().isEmpty()) {
for (SarLawsContactInformation information : lawsTopic.getInsideContactInformationList()) {
information.setLawsTopicId(lawsTopic.getId());
information.setGroupType("inside");
contactInformationService.save(information);
if (StringUtils.isNotBlank(information.getName())) {
information.setLawsTopicId(lawsTopic.getId());
information.setGroupType("inside");
contactInformationService.save(information);
}
}
}
return insert;
@@ -139,33 +152,54 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
if (StringUtils.isBlank(lawsTopic.getId())) {
return false;
}
lawsTopic.setModifyTime(new Date());
int update = this.baseMapper.updateById(lawsTopic);
if (update <= 0) {
SarLawsTopic lawsTopicInfoDB = getLawsTopicInfo(lawsTopic.getId());
List<String> compareList = compareLawsTopic(lawsTopicInfoDB, lawsTopic);
if (compareLawsTopic(lawsTopicInfoDB, lawsTopic).size() == 0) {
return true;
}
// 先删除关联信息
LambdaQueryWrapper<SarLawsTopicMeeting> topicWrapper = new LambdaQueryWrapper<>();
topicWrapper.eq(SarLawsTopicMeeting::getLawsTopicId,lawsTopic.getId());
meetingService.remove(topicWrapper);
LambdaQueryWrapper<SarLawsContactInformation> informationWrapper = new LambdaQueryWrapper<>();
informationWrapper.eq(SarLawsContactInformation::getLawsTopicId,lawsTopic.getId());
contactInformationService.remove(informationWrapper);
// 再添加关联信息
for (SarLawsTopicMeeting meeting : lawsTopic.getMeetingList()) {
meeting.setLawsTopicId(lawsTopic.getId());
meetingService.save(meeting);
lawsTopic.setModifyTime(new Date());
int update = this.baseMapper.updateById(lawsTopic);
// 比较列表字段是否经过修改,如果经过修改,先删除,再添加
if (compareList.contains("课题组会议列表被变更")) {
LambdaQueryWrapper<SarLawsTopicMeeting> topicWrapper = new LambdaQueryWrapper<>();
topicWrapper.eq(SarLawsTopicMeeting::getLawsTopicId,lawsTopic.getId());
meetingService.remove(topicWrapper);
for (SarLawsTopicMeeting meeting : lawsTopic.getMeetingList()) {
meeting.setLawsTopicId(lawsTopic.getId());
meetingService.save(meeting);
}
}
for (SarLawsContactInformation information : lawsTopic.getTopicContactInformationList()) {
information.setGroupType("topicGroup");
information.setLawsTopicId(lawsTopic.getId());
contactInformationService.save(information);
if (compareList.contains("课题组联系方式列表被变更")) {
LambdaQueryWrapper<SarLawsContactInformation> informationWrapper = new LambdaQueryWrapper<>();
informationWrapper.eq(SarLawsContactInformation::getLawsTopicId,lawsTopic.getId());
informationWrapper.eq(SarLawsContactInformation::getGroupType,"topicGroup");
contactInformationService.remove(informationWrapper);
for (SarLawsContactInformation information : lawsTopic.getTopicContactInformationList()) {
information.setGroupType("topicGroup");
information.setLawsTopicId(lawsTopic.getId());
contactInformationService.save(information);
}
}
for (SarLawsContactInformation information : lawsTopic.getInsideContactInformationList()) {
information.setGroupType("inside");
information.setLawsTopicId(lawsTopic.getId());
contactInformationService.save(information);
if (compareList.contains("内部联系方式列表被变更")) {
LambdaQueryWrapper<SarLawsContactInformation> informationWrapper = new LambdaQueryWrapper<>();
informationWrapper.eq(SarLawsContactInformation::getLawsTopicId,lawsTopic.getId());
informationWrapper.eq(SarLawsContactInformation::getGroupType,"inside");
contactInformationService.remove(informationWrapper);
for (SarLawsContactInformation information : lawsTopic.getInsideContactInformationList()) {
information.setGroupType("inside");
information.setLawsTopicId(lawsTopic.getId());
contactInformationService.save(information);
}
}
// 存储修改记录
SarUpdLog sarUpdLogEO = new SarUpdLog();
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
sarUpdLogEO.setSarId(lawsTopicInfoDB.getId());
sarUpdLogEO.setSarType("LAWS_TOPIC");
sarUpdLogEO.setCreationTime(new Date());
sarUpdLogEO.setCreationUser(LoginUserUtil.getUserId());
sarUpdLogEO.setContent(lawsTopicInfoDB.getTopicName() + "," + String.join(",",compareList));
updLogService.save(sarUpdLogEO);
return true;
}
@@ -185,7 +219,264 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
}
Integer rowCount = this.baseMapper.queryByPageCount(page);
page.getPager().setRowCount(rowCount);
return this.baseMapper.queryByPage(page);
List<SarLawsTopicVO> sarLawsTopicVOList = this.baseMapper.queryByPage(page);
for (SarLawsTopicVO lawsTopicVO : sarLawsTopicVOList) {
getFileListByAttFile(lawsTopicVO);
}
return sarLawsTopicVOList;
}
@Override
public List<SarLawsTopicVO> getLawsTopicByIds(List<String> idList) {
return this.baseMapper.getLawsTopicByIds(idList);
}
@Override
public List<SarLawsTopicVO> getAllLawsTopic(SarLawsTopicVO sarLawsTopicVO) {
return this.baseMapper.getAllLawsTopic(sarLawsTopicVO);
}
@Override
public ResponseMessage<?> importLawsTopicInfo(MultipartFile file) {
//获取文件全称
String fileNameStr = file.getOriginalFilename();
//获取最后.的位置
assert fileNameStr != null;
int pos = fileNameStr.lastIndexOf(".");
//获取压缩文件名称并以小写显示
String fileStr = fileNameStr.substring(pos + 1).toLowerCase();
//校验是否是zip文件
if (!fileStr.equals("zip")) {
return Result.error("请上传zip格式的文件");
}
//进行拼接获取文件名称
String fileName = fileNameStr.substring(0, pos);
//获取路径和文件名称
String path = filePath + "/" + fileName;
File saveDirectory = new File(path);
//判断saveDirectory中是否是文件夹
if (!saveDirectory.isDirectory()) {
saveDirectory.mkdir();
}
//将文件写入到指定路径中
try {
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + "/" + fileNameStr));
} catch (IOException e) {
return Result.error("文件存储失败!");
}
//解压缩
String zipEntryName = null;
try {
zipEntryName = FileUnZip.unZipFiles(path + "/" + fileNameStr, path);
FileUnZip.delete(new File(path + "/" + fileNameStr));
} catch (IOException e) {
return Result.error("文件解压失败");
}
//获取文件信息
List<File> fileList = readImpExcelFile(zipEntryName);
//判断获取到的文件数量
if (fileList.size() != 1) {
return Result.error("上传的文件只能有一个");
}
File importFile = fileList.get(0);
if (!importFile.getName().contains(".xls") && !importFile.getName().contains(".xlsx")) {
return Result.error("文件必须是EXCEL文件");
}
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(importFile);
} catch (IOException e) {
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,需要导入的数据有问题或导入的企标标号和企标名称已存在");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Sheet sheet = workbook.getSheetAt(0);
if (sheet == null) {
return Result.error("工作表为空");
}
StringBuilder sb = new StringBuilder();
// 获取excel表头
List<String> headerList = new ArrayList<>();
Row headerRow = sheet.getRow(1);
for (int i = 0; i < 22; i++) {
headerList.add(headerRow.getCell(i).getStringCellValue());
}
// 获取关联表表头
Row relationRow = sheet.getRow(2);
List<String> relationList = new ArrayList<>();
for (int i = 7; i < 22; i++) {
relationList.add(relationRow.getCell(i).getStringCellValue());
}
// 判断表头字段是否相同
if (!String.join(",",headerList).equals(FieldConvertUtil.exportFieldLawsTopic)
&& !String.join(",",relationList).equals(FieldConvertUtil.exportFieldLawsTopicRelation)) {
try {
workbook.close();
} catch (IOException e) {
return Result.error("文件关闭出错");
}
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
return Result.error("fail", "读取失败,请严格按照模板文件导入数据");
}
ImportParams importParams = new ImportParams();
importParams.setTitleRows(1);
importParams.setHeadRows(2);
List<SarLawsTopicVO> lawsTopicVOList = ExcelImportUtil.importExcel(readImpExcelFile(zipEntryName).get(0), SarLawsTopicVO.class, importParams);
// 去除空数据
for (SarLawsTopicVO lawsTopicVO : lawsTopicVOList) {
if (StringUtils.isNotBlank(lawsTopicVO.getTopicName())) {
// 存入数据库
SarLawsTopic sarLawsTopic = new SarLawsTopic();
BeanUtils.copyProperties(lawsTopicVO,sarLawsTopic);
if (sarLawsTopic.getStartTime() != null && sarLawsTopic.getCloseTime() != null) {
sarLawsTopic.setTopicStatus("已结题");
} else {
sarLawsTopic.setTopicStatus("进行中");
}
addLawsTopicInfo(sarLawsTopic);
}
}
return Result.success("导入成功");
}
// 通过反射获取文件内容
public void getFileListByAttFile(SarLawsTopic lawsTopic) {
String[] fileField = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials",
"insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"};
try {
for (String field : fileField) {
String getMethod = "get" + StringUtils.capitalize(field);
Method method = SarLawsTopic.class.getMethod(getMethod);
String fileAttId = String.valueOf(method.invoke(lawsTopic));
if (StringUtils.isNotBlank(fileAttId) && !"null".equals(fileAttId)) {
List<AttFileEO> fileList = new ArrayList<>();
for (String attId : fileAttId.split(",")) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileList.add(fileInfo);
}
String setMethod = "set" + StringUtils.capitalize(field) + "List";
method = SarLawsTopic.class.getMethod(setMethod, List.class);
method.invoke(lawsTopic, fileList);
}
}
}catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
public void getFileListByAttFile(SarLawsTopicVO lawsTopic) {
String[] fileField = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials",
"insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"};
try {
for (String field : fileField) {
String getMethod = "get" + StringUtils.capitalize(field);
Method method = SarLawsTopicVO.class.getMethod(getMethod);
String fileAttId = String.valueOf(method.invoke(lawsTopic));
if (StringUtils.isNotBlank(fileAttId) && !"null".equals(fileAttId)) {
List<AttFileEO> fileList = new ArrayList<>();
for (String attId : fileAttId.split(",")) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileList.add(fileInfo);
}
String setMethod = "set" + StringUtils.capitalize(field) + "List";
method = SarLawsTopicVO.class.getMethod(setMethod, List.class);
method.invoke(lawsTopic, fileList);
}
}
}catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
}
/**
* 比较两个SarLawsTopic 对象
* @param oldLawsTopic 数据库中存储的对象
* @param newLawsTopic 更新后的对象
* @return 差异
*/
public List<String> compareLawsTopic(SarLawsTopic oldLawsTopic, SarLawsTopic newLawsTopic) {
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","validFlag","createTime","modifyTime","agreementList","researchPlanList",
"researchFindingsList","researchGroupOtherList","conferenceMaterialsList","insideProjectProposalRepostList",
"insideResearchPlanList","insideConferenceMaterialsList","insideResearchFindingsList","insideOtherList","serialVersionUID"};
String[] fileAttIdFields = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials",
"insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
List<String> fileAttIdFieldList = Arrays.asList(fileAttIdFields);
// 获取SarLawsTopic类的所有字段
Field[] fields = SarLawsTopic.class.getDeclaredFields();
for (Field field : fields) {
if (!ignoreFieldList.contains(field.getName())) {
try {
field.setAccessible(true);
String oldValue = String.valueOf(field.get(oldLawsTopic));
String newValue = String.valueOf(field.get(newLawsTopic));
if (!Objects.equals(oldValue, newValue)) {
// 对比文件字段
if (fileAttIdFieldList.contains(field.getName())) {
List<String> fileNameList = new ArrayList<>();
if (StringUtils.isNotBlank(newValue)) {
String[] split = newValue.split(",");
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo.getOldFileName());
}
}
// 获取文件字段名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = SarLawsTopic.class.getMethod("get" + fieldName + "List");
// 获取旧的文件名
List<?> oldFileList = (List)method.invoke(oldLawsTopic);
List<String> oldFileNameList = new ArrayList<>();
if (oldFileList != null && oldFileList.size() > 0) {
for (Object oldFile : oldFileList) {
AttFileEO oldFile1 = (AttFileEO) oldFile;
oldFileNameList.add(oldFile1.getOldFileName());
}
}
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
// 对比列表字段
} else if ("meetingList".equals(field.getName()) || "topicContactInformationList".equals(field.getName())
|| "insideContactInformationList".equals(field.getName())) {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "被变更");
} else {
// 对比其他字段
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldValue + "\"改为\"" + newValue + "\"");
}
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
// 处理异常
e.printStackTrace();
}
}
}
return changes;
}
private static List<File> readImpExcelFile(String path) {
File file = new File(path);
List<File> resultlist = new ArrayList<>();
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File fi : files) {
// 对文件进行过滤,读取所有文件
String name = fi.getName();
//文件不为空 添加
if (name != null){
resultlist.add(fi);
}
}
}
return resultlist;
}
}
@@ -3,8 +3,10 @@ package com.adc.da.slrs.tsDictionaryType.dao;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.entity.TsSearchMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -18,4 +20,6 @@ public interface TsDicTypeDao extends BaseMapper<TsDicType> {
public List<TsSearchMenu> getSearchMenu();
String selectDicTypeNameByDicCode(String typeCode);
List<TsDicType> selectAllDicTypeNameByDicCode(String dicCode);
}
@@ -5,6 +5,7 @@ import com.adc.da.slrs.tsDictionaryType.entity.TsSearchMenu;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -25,4 +26,11 @@ public interface ITsDicTypeService extends IService<TsDicType> {
*/
public String getDicTypeNameByDicCode(String typeCode);
/**
* 根据字典值类别查询指定类别的所有类别名
* @param dicCode 字典类别编号
* @return 字典值列表
*/
List<TsDicType> selectAllDicTypeNameByDicCode(String dicCode);
}
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -30,4 +31,9 @@ public class TsDicTypeServiceImpl extends ServiceImpl<TsDicTypeDao, TsDicType> i
public String getDicTypeNameByDicCode(String typeCode) {
return this.baseMapper.selectDicTypeNameByDicCode(typeCode);
}
@Override
public List<TsDicType> selectAllDicTypeNameByDicCode(String dicCode) {
return this.baseMapper.selectAllDicTypeNameByDicCode(dicCode);
}
}
@@ -0,0 +1,112 @@
package com.adc.da.utils.util;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.adc.da.slrs.processModel.utils.TrainFormDate;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author tjzdw
* @description
* @date 2023/10/28
*/
@Slf4j
public class ExcelExportUtil {
private ExcelExportUtil() {
}
/**
* 导出Excel文件
* @param params 导出参数,主要包含,导出的文件名,导出类型
* @param tClass 导出文件的对象类
* @param datas 数据
* @return 工作簿
*/
public static Workbook exportWithData(ExportParams params, Class<?> tClass , List<?> datas) {
Workbook wb = null;
if (params.getType().equals(ExcelType.XSSF)) {
wb = new XSSFWorkbook();
} else {
wb = new HSSFWorkbook();
}
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
Sheet sheet = wb.createSheet(params.getSheetName());
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
Row row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中
CellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
//声明列对象
Cell cell = null;
Map<Integer, Excel> map = new HashMap<>();
Map<Integer, Field> mapField = new HashMap<>();
Field[] fields = tClass.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
Excel excel = field.getAnnotation(Excel.class);
if (null != excel) {
map.put(Integer.valueOf(excel.orderNum()), excel);
mapField.put(Integer.valueOf(excel.orderNum()), field);
}
}
//创建标题行
DataFormat df = wb.createDataFormat();
for (Integer i : map.keySet()) {
sheet.setColumnWidth(i, (int) (map.get(i).width() * 256));
cell = row.createCell(i);
cell.setCellValue(map.get(i).name());
if (null != map.get(i).exportFormat()) {
CellStyle style1 = wb.createCellStyle();
style1.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
style1.setDataFormat(df.getFormat(map.get(i).exportFormat()));
sheet.setDefaultColumnStyle(i, style1);
}
cell.setCellStyle(style);
}
//赋值数据
int rowNum = 1;
for (Object o : datas) {
Row row1 = sheet.createRow(rowNum);
for (Integer i : map.keySet()) {
Cell cell1 = row1.createCell(i);
Field field = null;
try {
field = o.getClass().getDeclaredField(mapField.get(i).getName());
} catch (NoSuchFieldException e) {
log.warn(e.getMessage());
}
if (null != field) {
field.setAccessible(true);
try {
Object fieldVal = field.get(o);
if (null != map.get(i).exportFormat() && !"".equals(map.get(i).exportFormat())) {
cell1.setCellValue("null".equals(String.valueOf(fieldVal)) ? "" : TrainFormDate.dealWithTimeZoneyyyy(String.valueOf(fieldVal), map.get(i).exportFormat()));
} else {
cell1.setCellValue("null".equals(String.valueOf(fieldVal)) ? "" : String.valueOf(fieldVal));
}
} catch (IllegalAccessException e) {
log.warn(e.getMessage());
}
}
}
System.out.println(o.toString());
rowNum++;
}
return wb;
}
}
@@ -63,6 +63,14 @@ public class FieldConvertUtil {
// 内外部会议关联表 表头
public static String exportFieldNamesMeetingTopic = "议题名称,汇报人,汇报单位,议题主要内容";
// 政策法规资料 表头
public static String exportFieldLawsInformation = "一级资料类别,二级资料类别,三级资料类别,四级资料类别,资料名称,资料归属部门,作者,资料说明";
// 政策课题 表头
public static String exportFieldLawsTopic = "课题名称,课题承办单位,课题指导单位,课题参与单位,开始时间,结题时间,课题费用(万元),课题组会议列表,课题组联系方式,内部联系方式";
// 政策课题关联表 表头
public static String exportFieldLawsTopicRelation = "会议名称,会议时间,会议地点,参会人员(内部),会议主要内容,姓名,单位,电话,邮箱,身份,姓名,单位,电话,邮箱,身份";
public static String exportBaseFieldNamesBussCode = "起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车VPPS编码,关联模块--卡车vpps中文名称";
public static String exportAttrFieldNamesBuss = "SVPPS,规范性引用文件,废止日期,复审日期,密级,授权,相关部门," +
@@ -85,6 +93,11 @@ public class FieldConvertUtil {
"7.关联模块-乘用车VPPS编码和关联模块--卡车VPPS编码是填写数据库中已有的编码从而带出乘用车VPPS名称和卡车VPPS名称\n" +
"8.发布稿,编制说明,历史版本,其他文件,修改单,关联文件为附件文件,需要放在Excel文档同级目录中";
// TODO
public static String exportInsideOutsideMeetingDesc = "内部会议,外部会议";
public static String exportLawsInformationDesc = "";
public static String exportFieldName = "*企标类别,*企标编号,*标准年份,*企标名称,企标英文名称,*文本状态,发布日期,企标实施日期,起草部门,起草人,适用车型,能源类型,适用产品线,体系类别,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿,编制说明,历史版本,其他文件,修改单,代替企标编号,采用标准,采标程度,引用标准,关联文件,";
/***
@@ -138,10 +138,10 @@ public class InsideOutsideMeetingExportUtil {
value = insideOutsideMeeting.getMeetingContent();
break;
case "一级会议类别":
value = insideOutsideMeeting.getFirstMeetingType();
value = insideOutsideMeeting.getFirstMeetingTypeName();
break;
case "二级会议类别":
value = insideOutsideMeeting.getSecondMeetingType();
value = insideOutsideMeeting.getSecondMeetingTypeName();
break;
default:
value = null;
@@ -26,9 +26,6 @@
<result column="REPORTER" property="reporter" />
<result column="REPORTING_UNIT" property="reportingUnit" />
<result column="AGENDA_CONTENT" property="agendaContent" />
<result column="VALID_FLAG" property="validFlag" />
<result column="CREATE_TIME" property="createTime" />
<result column="MODIFY_TIME" property="modifyTime" />
</collection>
</resultMap>
<sql id="Base_Column_List">
@@ -39,7 +36,7 @@
iom.ID,iom.MEETING_NAME,iom.TOPIC_NAME,iom.MEETING_ORGANIZER,iom.MEETING_TIME,iom.MEETING_ADDRESS,
iom.PARTICIPANTS,iom.MEETING_MINUTES,iom.MEETING_CONTENT,iom.FIRST_MEETING_TYPE,iom.SECOND_MEETING_TYPE,
mt.ID as mtId,mt.MEETING_ID,mt.AGENDA_NAME,mt.AGENDA_MATERIALS,mt.REPORTER,mt.REPORTING_UNIT,
mt.AGENDA_CONTENT,mt.VALID_FLAG,mt.CREATE_TIME,mt.MODIFY_TIME,
mt.AGENDA_CONTENT,
iom.VALID_FLAG,iom.CREATE_TIME,iom.MODIFY_TIME
</sql>
<sql id="Base_Where_Clause">
@@ -71,4 +71,12 @@
order by ${sortField} ${sortMode}
limit ${pager.startIndex-1},${pageSize}
</select>
<select id="getAllLawsInformation"
resultType="com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation">
select <include refid="Base_Column_List" />
from sar_laws_information
where VALID_FLAG = 0
<include refid="Base_Where_Clause" />
order by ID asc
</select>
</mapper>
@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.slrs.sarLawsTopic.dao.SarLawsTopicMapper">
<resultMap id="BaseResultMap" type="com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic">
<resultMap id="BaseResultMap" type="com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicVO">
<id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="topicName" column="TOPIC_NAME" jdbcType="VARCHAR"/>
<result property="organizer" column="ORGANIZER" jdbcType="VARCHAR"/>
@@ -205,4 +205,26 @@
order by slt.${sortField} ${sortMode}
limit ${pager.startIndex-1},${pageSize}
</select>
<select id="getLawsTopicByIds" resultMap="BaseResultMap">
select <include refid="Base_Join_Column_List" />
from sar_laws_topic slt left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID
left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup'
left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
where slt.VALID_FLAG = 0 and slt.ID in
<foreach collection="idList" open="(" close=")" separator="," item="id">
#{id}
</foreach>
order by slt.ID asc
</select>
<select id="getAllLawsTopic" resultMap="BaseResultMap">
select <include refid="Base_Join_Column_List" />
from sar_laws_topic slt left join sar_laws_topic_meeting sltm on slt.ID = sltm.LAWS_TOPIC_ID
left join sar_laws_contact_information slci1 on slt.ID = slci1.LAWS_TOPIC_ID and slci1.GROUP_TYPE = 'topicGroup'
left join sar_laws_contact_information slci2 on slt.ID = slci2.LAWS_TOPIC_ID and slci2.GROUP_TYPE = 'inside'
where slt.VALID_FLAG = 0
<include refid="Base_Where_Clause"/>
<include refid="TopicMeeting_where" />
<include refid="ContactInformation_where" />
order by slt.ID asc
</select>
</mapper>
@@ -14,6 +14,11 @@
</collection>
</resultMap>
<resultMap id="codeAndName" type="com.adc.da.slrs.tsDictionaryType.entity.TsDicType">
<result property="dicTypeCode" column="dicTypeCode"/>
<result property="dicTypeName" column="dicTypeName"/>
</resultMap>
<select id="getSearchMenu" resultMap="searchMenu">
select t_d.ID as id,
t_d.DICTIONARY_CODE as dictionary_code,
@@ -31,4 +36,8 @@
<select id="selectDicTypeNameByDicCode" resultType="java.lang.String">
select DIC_TYPE_NAME from ts_dictype where DIC_TYPE_CODE = #{typeCode}
</select>
<select id="selectAllDicTypeNameByDicCode" resultMap="codeAndName">
select DIC_TYPE_CODE as dicTypeCode, DIC_TYPE_NAME as dicTypeName from ts_dictype
where DIC_ID = (select id from ts_dictionary where DICTIONARY_CODE = #{dicCode})
</select>
</mapper>