update:添加导入前的表头校验

This commit is contained in:
sunzheng
2024-09-23 11:26:53 +08:00
parent e43f3546d1
commit 0427e9fa22
14 changed files with 260 additions and 23 deletions
@@ -48,7 +48,7 @@ public class LawsClubJoinTeam implements Serializable {
@ApiModelProperty(value = "社团职务担任者id")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "社团职务担任者", width = 20, dicCode = "id", dicText= "realname",dictTable = "sys_user")
@Excel(name = "社团职务担任者", width = 20)
private String leadId;
@ApiModelProperty(value = "入团经费")
@@ -70,7 +70,7 @@ public class LawsClubJoinTeam implements Serializable {
private String specializedModule;
@ApiModelProperty(value = "申请人的id")
@Excel(name = "申请人", width = 20, dicText = "realname", dicCode = "id", dictTable = "sys_user")
@Excel(name = "申请人", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
private String proposerId;
@@ -69,7 +69,7 @@ public class LawsClubMeeting implements Serializable {
@ApiModelProperty(value = "通知人id")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "通知人", width = 20, dicCode = "id", dicText= "realname",dictTable = "sys_user")
@Excel(name = "通知人", width = 20)
private String notifierId;
@ApiModelProperty(value = "通知部门id")
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
@@ -41,7 +40,7 @@ public class LawsClubMeetingMember implements Serializable {
private String meetingId;
@ApiModelProperty(value = "参会人员的id")
@Excel(name = "参会人员", width = 20, dicText = "realname", dicCode = "id", dictTable = "sys_user")
@Excel(name = "参会人员", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
private String memberId;
@@ -62,7 +62,7 @@ public class LawsClubResearchInformation implements Serializable {
@ApiModelProperty(value = "专业接口人")
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
@Excel(name = "专业接口人", width = 20, dicText = "realname", dicCode = "id", dictTable = "sys_user")
@Excel(name = "专业接口人", width = 20)
private String specializedInterfacePerson;
@ApiModelProperty(value = "专业模块")
@@ -71,7 +71,7 @@ public class LawsClubResearchInformation implements Serializable {
private String specializedModule;
@ApiModelProperty(value = "反馈人")
@Excel(name = "反馈人", width = 20, dicText = "realname", dicCode = "id", dictTable = "sys_user")
@Excel(name = "反馈人", width = 20)
@Dict(dictTable = "sys_user", dicCode = "id", dicText = "realname")
private String feedbackPerson;
@@ -6,6 +6,8 @@ import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.ImportExcelUtil;
import com.jero.modules.activiti.process.standardinterpret.vo.FlowImportExcel;
import com.jero.modules.laws.club.entity.LawsClubJoinTeam;
import com.jero.modules.laws.club.mapper.LawsClubJoinTeamMapper;
import com.jero.modules.laws.club.service.ILawsClubJoinTeamService;
@@ -119,6 +121,8 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl<LawsClubJoinTeamMap
List<LawsClubJoinTeam> lawsClubJoinTeamList = new ArrayList<>();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 校验表头
excelHeadVerify(file, LawsClubJoinTeamExcel.class, 0 ,0 );
try {
ImportParams params = new ImportParams();
params.setNeedSave(true);
@@ -180,6 +184,14 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl<LawsClubJoinTeamMap
lawsClubJoinTeamExcel.setLeadId(sysUser.getId());
}
}
// 校验入团经费
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getJoinCast()) && lawsClubJoinTeamExcel.getJoinCast().length() > 50) {
msgSub.append(getErrorMsg(i, "入团经费长度不能超过50;"));
}
// 校验社团简介
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getClubProfile()) && lawsClubJoinTeamExcel.getClubProfile().length() > 500) {
msgSub.append(getErrorMsg(i, "社团简介长度不能超过500;"));
}
// 校验部门名称
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getDepartId())) {
List<SysDepart> sysDepart = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getDepartName, lawsClubJoinTeamExcel.getDepartId()));
@@ -209,6 +221,18 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl<LawsClubJoinTeamMap
lawsClubJoinTeamExcel.setProposerId(sysUser.getId());
}
}
// 校验秘书处
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getSecretariat()) && lawsClubJoinTeamExcel.getSecretariat().length() > 50) {
msgSub.append(getErrorMsg(i, "秘书处长度不能超过500;"));
}
// 校验联系人
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getContacts()) && lawsClubJoinTeamExcel.getContacts().length() > 50) {
msgSub.append(getErrorMsg(i, "联系人长度不能超过50;"));
}
// 校验备注
if (StringUtils.isNotBlank(lawsClubJoinTeamExcel.getRemark()) && lawsClubJoinTeamExcel.getRemark().length() > 500) {
msgSub.append(getErrorMsg(i, "备注长度不能超过500;"));
}
if (msgSub.length() > 0) {
msg.append(msgSub).append("</br>");
}
@@ -253,4 +277,15 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl<LawsClubJoinTeamMap
return notifierId; // 如果没有括号,则返回整个字符串
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubJoinTeamExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}
@@ -7,6 +7,7 @@ import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.enums.LanguageEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.ImportExcelUtil;
import com.jero.common.util.MessageUtils;
import com.jero.modules.laws.club.entity.LawsClubMeeting;
import com.jero.modules.laws.club.mapper.LawsClubMeetingMapper;
@@ -16,6 +17,7 @@ import com.jero.modules.laws.club.utils.ExcelUtil;
import com.jero.modules.laws.club.utils.ZipUtils;
import com.jero.modules.laws.club.vo.excel.LawsClubMeetingExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubMeetingMemberExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubPaymentExcel;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.split.common.FileUnZip;
@@ -172,6 +174,10 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
unZipFileMap.remove("saveDirectory");
// 拿到excel的导入文件
File templateFile = unZipFileMap.get(templateName);
// 校验模板表头
FileInputStream input = new FileInputStream(templateFile);
MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(), "application/octet-stream", input);
excelHeadVerify(multipartFile, LawsClubMeetingExcel.class, 0 ,0);
// 将模板文件移除
unZipFileMap.remove(templateFile);
ImportParams params = new ImportParams();
@@ -224,6 +230,10 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
for (int i = 0; i < meetingExcels.size(); i++) {
LawsClubMeetingExcel lawsClubMeetingExcel = meetingExcels.get(i);
StringBuilder msgSub = new StringBuilder();
// 校验会议名称
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingName()) && lawsClubMeetingExcel.getMeetingName().length() > 50) {
msgSub.append(getErrorMsg(i, "会议名称长度不能超过50;"));
}
// 校验会议日期
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingDate())) {
try {
@@ -232,6 +242,14 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
msgSub.append(getErrorMsg(i, "会议日期格式不正确;"));
}
}
// 校验会议费用
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingCost()) && lawsClubMeetingExcel.getMeetingCost().length() > 50) {
msgSub.append(getErrorMsg(i, "会议费用长度不能超过50;"));
}
// 校验线下/线上地点
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingPlace()) && lawsClubMeetingExcel.getMeetingPlace().length() > 50) {
msgSub.append(getErrorMsg(i, "线下/线上地点长度不能超过50;"));
}
// 校验计划完成日期
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getPlanCompletionDate())) {
try {
@@ -278,6 +296,14 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
lawsClubMeetingExcel.setIsPublicize(isPublicize);
}
}
// 校验会议组织人
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingOrganizer()) && lawsClubMeetingExcel.getMeetingOrganizer().length() > 50) {
msgSub.append(getErrorMsg(i, "会议组织人长度不能超过50;"));
}
// 校验会议内容
if (StringUtils.isNotBlank(lawsClubMeetingExcel.getMeetingContent()) && lawsClubMeetingExcel.getMeetingContent().length() > 500) {
msgSub.append(getErrorMsg(i, "会议内容长度不能超过500;"));
}
List<LawsClubMeetingMemberExcel> meetingMemberList = lawsClubMeetingExcel.getMeetingMemberList();
// 校验参会人员的信息
for (LawsClubMeetingMemberExcel lawsClubMeetingMemberExcel : meetingMemberList) {
@@ -323,6 +349,9 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
lawsClubMeetingMemberExcel.setMeetingFileId(ossFileResult.getResult().getId());
}
}
if (StringUtils.isNotBlank(lawsClubMeetingMemberExcel.getRemark()) && lawsClubMeetingMemberExcel.getRemark().length() > 500) {
msgSub.append(getErrorMsg(i, "备注长度不能超过500;"));
}
}
if (msgSub.length() > 0) {
msg.append(msgSub).append("</br>");
@@ -461,4 +490,15 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl<LawsClubMeetingMappe
return null;
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubMeetingExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.ImportExcelUtil;
import com.jero.modules.laws.club.entity.LawsClubPayment;
import com.jero.modules.laws.club.mapper.LawsClubPaymentMapper;
import com.jero.modules.laws.club.service.ILawsClubPaymentService;
import com.jero.modules.laws.club.service.RolePermissionService;
import com.jero.modules.laws.club.utils.ExcelUtil;
import com.jero.modules.laws.club.vo.excel.LawsClubJoinTeamExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubPaymentExcel;
import com.jero.modules.tag.entity.LawsTag;
import lombok.SneakyThrows;
@@ -65,7 +67,7 @@ public class LawsClubPaymentServiceImpl extends ServiceImpl<LawsClubPaymentMappe
"2.导入数据从第四行开始,第一行为表头,第二行为填写说明,第三行为示例。第四行才是正式数据";
String fieldTxts = "缴费金额,缴费时间,备注";
String mustInputFlags = "no,no,no";
String fieldTypeLists = "2,1,1"; // 1代表是文本输入类型 2代表日期输入
String fieldTypeLists = "1,2,1"; // 1代表是文本输入类型 2代表日期输入
List<LawsTag> lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists);
try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "支付信息", describe);
OutputStream out = response.getOutputStream()) {
@@ -95,6 +97,8 @@ public class LawsClubPaymentServiceImpl extends ServiceImpl<LawsClubPaymentMappe
List<LawsClubPayment> lawsClubPaymentList = new ArrayList<>();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 校验模板表头
excelHeadVerify(file, LawsClubPaymentExcel.class, 0 ,0);
try {
ImportParams params = new ImportParams();
params.setNeedSave(true);
@@ -134,6 +138,10 @@ public class LawsClubPaymentServiceImpl extends ServiceImpl<LawsClubPaymentMappe
for (int i = 0; i < excelList.size(); i++) {
LawsClubPaymentExcel lawsClubPaymentExcel = excelList.get(i);
StringBuilder msgSub = new StringBuilder();
// 校验缴费金额
if (StringUtils.isNotBlank(lawsClubPaymentExcel.getPaymentAmount()) && lawsClubPaymentExcel.getPaymentAmount().length() > 50) {
msgSub.append(getErrorMsg(i, "缴费金额长度不能超过50;"));
}
// 校验缴费日期格
if (StringUtils.isNotBlank(lawsClubPaymentExcel.getPaymentTime())) {
try {
@@ -142,6 +150,10 @@ public class LawsClubPaymentServiceImpl extends ServiceImpl<LawsClubPaymentMappe
msgSub.append(getErrorMsg(i, "缴费日期格式不正确;"));
}
}
// 校验备注
if (StringUtils.isNotBlank(lawsClubPaymentExcel.getRemark()) && lawsClubPaymentExcel.getRemark().length() > 50) {
msgSub.append(getErrorMsg(i, "备注长度不能超过500;"));
}
if (msgSub.length() > 0) {
msg.append(msgSub).append("</br>");
}
@@ -176,4 +188,15 @@ public class LawsClubPaymentServiceImpl extends ServiceImpl<LawsClubPaymentMappe
private String getErrorMsg(int rowIndex, String errorMsg) {
return "" + (rowIndex + 4) + "" + errorMsg;
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubPaymentExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}
@@ -6,11 +6,14 @@ import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.ImportExcelUtil;
import com.jero.modules.laws.club.entity.LawsClubResearchInformation;
import com.jero.modules.laws.club.mapper.LawsClubResearchInformationMapper;
import com.jero.modules.laws.club.service.ILawsClubResearchInformationService;
import com.jero.modules.laws.club.service.RolePermissionService;
import com.jero.modules.laws.club.utils.ExcelUtil;
import com.jero.modules.laws.club.vo.excel.LawsClubMeetingExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubPaymentExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubResearchInformationExcel;
import com.jero.modules.system.entity.SysDepart;
import com.jero.modules.system.entity.SysUser;
@@ -119,6 +122,8 @@ public class LawsClubResearchInformationServiceImpl extends ServiceImpl<LawsClub
List<LawsClubResearchInformation> lawsClubResearchInformationList = new ArrayList<>();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 校验模板表头
excelHeadVerify(file, LawsClubResearchInformationExcel.class, 0 ,0);
try {
ImportParams params = new ImportParams();
params.setNeedSave(true);
@@ -164,6 +169,14 @@ public class LawsClubResearchInformationServiceImpl extends ServiceImpl<LawsClub
for (int i = 0; i < excelList.size(); i++) {
LawsClubResearchInformationExcel lawsClubResearchInformationExcel = excelList.get(i);
StringBuilder msgSub = new StringBuilder();
// 校验名称
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getResearchName()) && lawsClubResearchInformationExcel.getResearchName().length() > 50) {
msgSub.append(getErrorMsg(i, "名称长度不能超过50;"));
}
// 校验内容
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getResearchContent()) && lawsClubResearchInformationExcel.getResearchContent().length() > 500) {
msgSub.append(getErrorMsg(i, "内容长度不能超过500;"));
}
// 校验接收日期
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getReceiveDate())) {
try {
@@ -229,6 +242,18 @@ public class LawsClubResearchInformationServiceImpl extends ServiceImpl<LawsClub
lawsClubResearchInformationExcel.setFeedbackSpecializedModule(feedbackSpecializedModule);
}
}
// 校验反馈情况
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getFeedbackSituation()) && lawsClubResearchInformationExcel.getFeedbackSituation().length() > 500) {
msgSub.append(getErrorMsg(i, "反馈情况长度不能超过500;"));
}
// 校验盖章流程完成情况
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getSealSituation()) && lawsClubResearchInformationExcel.getSealSituation().length() > 50) {
msgSub.append(getErrorMsg(i, "盖章流程完成情况长度不能超过50;"));
}
// 校验所属设社团
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getClubName()) && lawsClubResearchInformationExcel.getClubName().length() > 50) {
msgSub.append(getErrorMsg(i, "所属设社团长度不能超过50;"));
}
// 校验任务来源
if (StringUtils.isNotBlank(lawsClubResearchInformationExcel.getTaskSource())) {
String taskSource = clubTaskSourceMap.get(lawsClubResearchInformationExcel.getTaskSource());
@@ -281,4 +306,15 @@ public class LawsClubResearchInformationServiceImpl extends ServiceImpl<LawsClub
}
return null;
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubResearchInformationExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}
@@ -20,6 +20,8 @@ import com.jero.modules.laws.club.vo.LawsClubTreeNodeModel;
import com.jero.modules.laws.club.vo.excel.*;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.tag.entity.LawsTag;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@@ -80,6 +82,8 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
private RedisUtil redisUtil;
@Resource
private IOSSFileService iossFileService;
@Resource
private ISysUserService sysUserService;
@Override
public List<LawsClubTreeNodeModel> getTreeStructure(String parentId, String nodeType) {
@@ -468,21 +472,56 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
}
}
List<String> fileIdList = new ArrayList<>();
List<String> userIds = new ArrayList<>();
List<String> ids = clubList.stream().map(LawsClub::getId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(ids)) {
// 入团信息
lawsClubJoinTeams = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids));
lawsClubMeetings = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids));
List<String> leadIds = lawsClubJoinTeams.stream().map(LawsClubJoinTeam::getLeadId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> proposerId = lawsClubJoinTeams.stream().map(LawsClubJoinTeam::getProposerId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(leadIds);
userIds.addAll(proposerId);
// 支付信息
lawsClubPayments = lawsClubPaymentService.list(new LambdaQueryWrapper<LawsClubPayment>().in(LawsClubPayment::getClubId, ids));
// 参会信息
lawsClubMeetings = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids));
List<String> notifierIds = lawsClubMeetings.stream().map(LawsClubMeeting::getNotifierId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(notifierIds);
for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) {
List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId()));
List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> memberIds = memberList.stream().map(LawsClubMeetingMember::getMemberId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(memberIds);
fileIdList.addAll(meetingFileIds);
lawsClubMeeting.setMeetingMemberList(memberList);
}
// 征集调研信息
lawsClubResearchInformations = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids));
List<String> interFacePersonIds = lawsClubResearchInformations.stream().map(LawsClubResearchInformation::getSpecializedInterfacePerson).filter(Objects::nonNull).collect(Collectors.toList());
List<String> feedBackPersonIds = lawsClubResearchInformations.stream().map(LawsClubResearchInformation::getFeedbackPerson).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(interFacePersonIds);
userIds.addAll(feedBackPersonIds);
// 工作组资料信息
lawsClubWorkingGroupFiles = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper<LawsClubWorkingGroupFile>().in(LawsClubWorkingGroupFile::getClubId, ids));
List<String> fileIds = lawsClubWorkingGroupFiles.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList());
fileIdList.addAll(fileIds);
lawsClubResearchInformations = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids));
// 赋值用户相关字段,变为真实姓名(工作)的格式
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubJoinTeam lawsClubJoinTeam : lawsClubJoinTeams) {
lawsClubJoinTeam.setLeadId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getLeadId()));
lawsClubJoinTeam.setProposerId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getProposerId()));
}
for (LawsClubResearchInformation lawsClubResearchInformation : lawsClubResearchInformations) {
lawsClubResearchInformation.setSpecializedInterfacePerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getSpecializedInterfacePerson()));
lawsClubResearchInformation.setFeedbackPerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getFeedbackPerson()));
}
for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) {
lawsClubMeeting.setNotifierId(userRealNameAndUsernameMap.get(lawsClubMeeting.getNotifierId()));
List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList();
for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) {
lawsClubMeetingMember.setMemberId(userRealNameAndUsernameMap.get(lawsClubMeetingMember.getMemberId()));
}
}
}
//导出文件名称
List<Map<String, Object>> sheetList = new ArrayList<>();
@@ -555,6 +594,16 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubJoinTeamService.list(new LambdaQueryWrapper<LawsClubJoinTeam>().in(LawsClubJoinTeam::getClubId, ids));
}
List<String> userIds = new ArrayList<>();
List<String> leadIds = excelList.stream().map(LawsClubJoinTeam::getLeadId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> proposerId = excelList.stream().map(LawsClubJoinTeam::getProposerId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(leadIds);
userIds.addAll(proposerId);
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubJoinTeam lawsClubJoinTeam : excelList) {
lawsClubJoinTeam.setLeadId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getLeadId()));
lawsClubJoinTeam.setProposerId(userRealNameAndUsernameMap.get(lawsClubJoinTeam.getProposerId()));
}
//导出文件名称
mv.addObject(JeroController.FILE_NAME, "入团信息统计表");
mv.addObject(JeroController.CLASS, LawsClubJoinTeam.class);
@@ -596,15 +645,28 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
List<String> ids = list.stream().map(LawsClub::getId).collect(Collectors.toList());
List<LawsClubMeeting> excelList = new ArrayList<>();
List<String> fileIdList = new ArrayList<>();
List<String> userIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubMeetingService.list(new LambdaQueryWrapper<LawsClubMeeting>().in(LawsClubMeeting::getClubId, ids));
List<String> userIds1 = excelList.stream().map(LawsClubMeeting::getNotifierId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(userIds1);
for (LawsClubMeeting lawsClubMeeting : excelList) {
List<LawsClubMeetingMember> memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper<LawsClubMeetingMember>().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId()));
List<String> meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> memberIds = memberList.stream().map(LawsClubMeetingMember::getMemberId).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(memberIds);
fileIdList.addAll(meetingFileIds);
lawsClubMeeting.setMeetingMemberList(memberList);
}
}
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubMeeting lawsClubMeeting : excelList) {
lawsClubMeeting.setNotifierId(userRealNameAndUsernameMap.get(lawsClubMeeting.getNotifierId()));
List<LawsClubMeetingMember> meetingMemberList = lawsClubMeeting.getMeetingMemberList();
for (LawsClubMeetingMember lawsClubMeetingMember : meetingMemberList) {
lawsClubMeetingMember.setMemberId(userRealNameAndUsernameMap.get(lawsClubMeetingMember.getMemberId()));
}
}
// 生成 Workbook
Workbook workbook = ExcelExportUtil.exportExcel(createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "参会信息"), LawsClubMeeting.class,excelList);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
@@ -676,6 +738,16 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
if (!CollectionUtils.isEmpty(ids)) {
excelList = lawsClubResearchInformationService.list(new LambdaQueryWrapper<LawsClubResearchInformation>().in(LawsClubResearchInformation::getClubId, ids));
}
List<String> userIds = new ArrayList<>();
List<String> userId1 = excelList.stream().map(LawsClubResearchInformation::getSpecializedInterfacePerson).filter(Objects::nonNull).collect(Collectors.toList());
List<String> userId2 = excelList.stream().map(LawsClubResearchInformation::getFeedbackPerson).filter(Objects::nonNull).collect(Collectors.toList());
userIds.addAll(userId1);
userIds.addAll(userId2);
Map<String, String> userRealNameAndUsernameMap = getUserRealNameAndUsernameMap(userIds);
for (LawsClubResearchInformation lawsClubResearchInformation : excelList) {
lawsClubResearchInformation.setSpecializedInterfacePerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getSpecializedInterfacePerson()));
lawsClubResearchInformation.setFeedbackPerson(userRealNameAndUsernameMap.get(lawsClubResearchInformation.getFeedbackPerson()));
}
//导出文件名称
mv.addObject(JeroController.FILE_NAME, "征集调研信统计表");
mv.addObject(JeroController.CLASS, LawsClubResearchInformation.class);
@@ -770,22 +842,35 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
// 校验节点类型
if (StringUtils.isBlank(lawsClubExcel.getNodeType())) {
msgSub.append(getErrorMsg(i, "节点类型不能为空;"));
} else if (lawsClubExcel.getNodeType().length() > 50){
msgSub.append(getErrorMsg(i, "节点类型长度不能超过50;"));
}
// 校验社团名称
if (StringUtils.isBlank(lawsClubExcel.getClubName())) {
msgSub.append(getErrorMsg(i, "社团名称不能为空;"));
}else if (lawsClubExcel.getClubName().length() > 50) {
msgSub.append(getErrorMsg(i, "社团名称长度不能超过50;"));
}else {
LawsClub lawsClub = getOne(new LambdaQueryWrapper<LawsClub>()
.eq(LawsClub::getClubName, lawsClubExcel.getClubName()));
LawsClub lawsClub = getOne(new LambdaQueryWrapper<LawsClub>().eq(LawsClub::getClubName, lawsClubExcel.getClubName()));
if (!Objects.isNull(lawsClub)) {
msgSub.append(getErrorMsg(i, "社团名称已存在;"));
}
}
// 校验社团地址
if (StringUtils.isNotBlank(lawsClubExcel.getClubAddress()) && lawsClubExcel.getClubAddress().length() > 50) {
msgSub.append(getErrorMsg(i, "社团地址长度不能超过50;"));
}
// 校验联系方式
String contactNumber = lawsClubExcel.getContactNumber();
if (StringUtils.isNotBlank(contactNumber) && !contactNumber.matches("^(?:(0\\d{2,3}-)?\\d{7,8}|1[3-9]\\d{9})$")) {
msgSub.append(getErrorMsg(i, "联系方式格式不正确;"));
} else {
lawsClubExcel.setContactNumber(PasswordUtil.encrypt(contactNumber));
}
// 校验编号
if (StringUtils.isNotBlank(lawsClubExcel.getNumber()) && lawsClubExcel.getNumber().length() > 50) {
msgSub.append(getErrorMsg(i, "编号长度不能超过50;"));
}
if (msgSub.length() > 0) {
msg.append(msgSub).append("</br>");
}
@@ -865,4 +950,14 @@ public class LawsClubServiceImpl extends ServiceImpl<LawsClubMapper, LawsClub> i
return "" + (rowIndex + 4) + "" + errorMsg;
}
private Map<String, String> getUserRealNameAndUsernameMap(List<String> userIds) {
// 假设这里是根据 leadIds 批量查询用户信息的逻辑
List<SysUser> users = sysUserService.list(new LambdaQueryWrapper<SysUser>().in(SysUser::getId, userIds));
// 将用户信息拼接为 "realname(username)" 形式
return users.stream().collect(Collectors.toMap(
SysUser::getId,
user -> user.getRealname() + "(" + user.getUsername() + ")"
));
}
}
@@ -6,6 +6,7 @@ import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.enums.LanguageEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.ImportExcelUtil;
import com.jero.common.util.MessageUtils;
import com.jero.modules.laws.club.entity.LawsClubWorkingGroupFile;
import com.jero.modules.laws.club.mapper.LawsClubWorkingGroupFileMapper;
@@ -13,6 +14,9 @@ import com.jero.modules.laws.club.service.ILawsClubWorkingGroupFileService;
import com.jero.modules.laws.club.service.RolePermissionService;
import com.jero.modules.laws.club.utils.ExcelUtil;
import com.jero.modules.laws.club.utils.ZipUtils;
import com.jero.modules.laws.club.vo.excel.LawsClubMeetingExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubPaymentExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubResearchInformationExcel;
import com.jero.modules.laws.club.vo.excel.LawsClubWorkingGroupFileExcel;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
@@ -151,6 +155,10 @@ public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl<LawsClubWor
File templateFile = unZipFileMap.get(templateName);
// 将模板文件移除
unZipFileMap.remove(templateName);
// 校验模板表头
FileInputStream input = new FileInputStream(templateFile);
MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(), "application/octet-stream", input);
excelHeadVerify(multipartFile, LawsClubWorkingGroupFileExcel.class, 0 ,0);
ImportParams params = new ImportParams();
params.setNeedSave(false);
List<LawsClubWorkingGroupFileExcel> excelList = ExcelImportUtil.importExcel(new FileInputStream(templateFile), LawsClubWorkingGroupFileExcel.class, params);
@@ -195,7 +203,7 @@ public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl<LawsClubWor
for (int i = 0; i < excelList.size(); i++) {
LawsClubWorkingGroupFileExcel lawsClubWorkingGroupFileExcel = excelList.get(i);
StringBuilder msgSub = new StringBuilder();
// 校验通知部门专业模块
// 校验文件类型
if (StringUtils.isNotBlank(lawsClubWorkingGroupFileExcel.getFileType())) {
String fileType = fileTypeMap.get(lawsClubWorkingGroupFileExcel.getFileType());
if (StringUtils.isBlank(fileType)) {
@@ -237,4 +245,15 @@ public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl<LawsClubWor
boolean result = add || edit;
return result;
}
private void excelHeadVerify(MultipartFile file, Class<LawsClubWorkingGroupFileExcel> clazz, int titleRows, int i) {
try {
if (!(boolean) ImportExcelUtil.checkTemplateTitle(file, clazz, titleRows, i)){
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}catch (Exception e) {
e.printStackTrace();
throw new JeroBootException(ResultCommon.IMPORT_TEMPLATE_ERROR);
}
}
}
@@ -8,9 +8,6 @@ import java.io.Serializable;
@Data
public class LawsClubJoinTeamExcel implements Serializable {
@Excel(name = "*社团名称", width = 20)
private String clubId;
@Excel(name = "入团日期", width = 20)
private String joinDate;
@@ -8,7 +8,6 @@ import java.util.List;
@Data
public class LawsClubMeetingExcel implements Serializable {
@Excel(name = "*社团名称", width = 20)
private String clubId;
@Excel(name = "会议名称", width = 20)
@@ -7,9 +7,6 @@ import java.io.Serializable;
@Data
public class LawsClubPaymentExcel implements Serializable {
@Excel(name = "*社团名称", width = 20)
private String clubId;
@Excel(name = "缴费金额", width = 20)
private String paymentAmount;
@@ -7,9 +7,6 @@ import java.io.Serializable;
@Data
public class LawsClubWorkingGroupFileExcel implements Serializable {
@Excel(name = "社团名称", width = 20)
private String clubId;
@Excel(name = "文件名称", width = 20)
private String fileId;