diff --git a/laws-base/laws-base-core/src/main/java/com/jero/common/api/vo/ResultCommon.java b/laws-base/laws-base-core/src/main/java/com/jero/common/api/vo/ResultCommon.java index 8980955d..3ab2ba59 100644 --- a/laws-base/laws-base-core/src/main/java/com/jero/common/api/vo/ResultCommon.java +++ b/laws-base/laws-base-core/src/main/java/com/jero/common/api/vo/ResultCommon.java @@ -223,5 +223,7 @@ public class ResultCommon { public static final String NODE_EXIST_SUBSETS = "node.exist.subsets"; // 社团名称不能重复 public static final String CLUB_ALREADY_EXISTS = "club.already.exists"; + // 根节点不能删除 + public static final String ROOT_NODE_CANNOT_BE_DELETE = "root.node.cannot.be.delete"; // 根节点不能编辑 } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/config/CustomExcelExportStyler.java b/laws-modules/src/main/java/com/jero/modules/laws/club/config/CustomExcelExportStyler.java index 8a5c1fbf..29bd6217 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/config/CustomExcelExportStyler.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/config/CustomExcelExportStyler.java @@ -1,6 +1,8 @@ package com.jero.modules.laws.club.config; import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.Workbook; import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; @@ -17,8 +19,15 @@ public class CustomExcelExportStyler extends ExcelExportStylerDefaultImpl { // 设置标题的左对齐样式 @Override public HSSFCellStyle getHeaderStyle(short color) { - HSSFCellStyle headerStyle = (HSSFCellStyle) super.getHeaderStyle(color); + HSSFCellStyle headerStyle = (HSSFCellStyle) super.getHeaderStyle(color); // 确保 getHeaderStyle 返回的是 HSSFCellStyle headerStyle.setAlignment(HorizontalAlignment.LEFT); // 左对齐 + // 将 workbook 转换为 HSSFWorkbook,以便创建 HSSFFont + if (workbook instanceof HSSFWorkbook) { + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; + HSSFFont font = hssfWorkbook.createFont(); // 创建 HSSFFont + font.setFontHeightInPoints((short) 10); // 设置字体大小为10 + headerStyle.setFont(font); // 将字体设置到样式中 + } return headerStyle; } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubController.java b/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubController.java index 02e5af5b..4f8096b7 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubController.java @@ -141,8 +141,8 @@ public class LawsClubController extends JeroController + * 社团管理-支付信息表 前端控制器 + *

+ * + * @author sz + * @since 2024-08-29 + */ +@Api(tags="社团管理-支付信息表") +@RestController +@RequestMapping("/club/payment") +@Slf4j +public class LawsClubJoinPaymentController { + + @Resource + private ILawsClubPaymentService lawsClubPaymentService; + + /** + * 模板下载 + */ + @AutoLog(value = "社团管理-支付信息表-模板下载") + @ApiOperation(value="社团管理-支付信息表-模板下载", notes="社团管理-支付信息表-模板下载") + @GetMapping(value = "/exportTemplate") + public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { + lawsClubPaymentService.exportTemplate(request,response); + } + + /** + * 导入 + */ + @AutoLog(value = "社团管理-支付信息表-导入") + @ApiOperation(value="社团管理-支付信息表-导入", notes="社团管理-支付信息表-导入") + @PostMapping(value = "/importExcel") + @Translation + public Result excelimport(HttpServletRequest request) { + return lawsClubPaymentService.importExcel(request); + } + +} diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubWorkingGroupFileController.java b/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubWorkingGroupFileController.java new file mode 100644 index 00000000..8a44ab97 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/controller/LawsClubWorkingGroupFileController.java @@ -0,0 +1,56 @@ +package com.jero.modules.laws.club.controller; + +import com.jero.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.aspect.annotation.Translation; +import com.jero.modules.laws.club.service.ILawsClubWorkingGroupFileService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + *

+ * 社团管理-工作组资料表 前端控制器 + *

+ * + * @author sz + * @since 2024-08-29 + */ +@Api(tags="社团管理-工作组资料表") +@RestController +@RequestMapping("/club/workingGroupFile") +@Slf4j +public class LawsClubWorkingGroupFileController { + + @Resource + private ILawsClubWorkingGroupFileService lawsClubWorkingGroupFileService; + + /** + * 模板下载 + */ + @AutoLog(value = "社团管理-工作组资料表-模板下载") + @ApiOperation(value="社团管理-参会信息表-模板下载", notes="社团管理-参会信息表-模板下载") + @GetMapping(value = "/exportTemplate") + public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { + lawsClubWorkingGroupFileService.exportTemplate(request,response); + } + + /** + * 导入 + */ + @AutoLog(value = "社团管理-工作组资料表-导入") + @ApiOperation(value="社团管理-参会信息表-导入", notes="社团管理-参会信息表-导入") + @PostMapping(value = "/importExcel") + @Translation + public Result excelimport(HttpServletRequest request) { + return lawsClubWorkingGroupFileService.importExcel(request); + } + +} diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubPayment.java b/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubPayment.java index 7bbfc0d7..6d11190c 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubPayment.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubPayment.java @@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; /** @@ -35,17 +36,21 @@ public class LawsClubPayment implements Serializable { private String id; @ApiModelProperty(value = "社团id") + @Excel(name = "社团名称", width = 20, dicText = "club_name", dicCode = "id", dictTable = "laws_club") private String clubId; @ApiModelProperty(value = "缴费金额") + @Excel(name = "缴费金额", width = 20) private String paymentAmount; @ApiModelProperty(value = "缴费时间") @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd") + @Excel(name = "缴费时间", width = 20, format = "yyyy-MM-dd") private Date paymentTime; @ApiModelProperty(value = "备注") + @Excel(name = "备注", width = 20) private String remark; @ApiModelProperty(value = "创建人") diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubWorkingGroupFile.java b/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubWorkingGroupFile.java index 69446fb6..7aacccde 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubWorkingGroupFile.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/entity/LawsClubWorkingGroupFile.java @@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; /** @@ -36,14 +37,17 @@ public class LawsClubWorkingGroupFile implements Serializable { private String id; @ApiModelProperty(value = "社团id") + @Excel(name = "社团名称", width = 20, dicText = "club_name", dicCode = "id", dictTable = "laws_club") private String clubId; @ApiModelProperty(value = "文件id") @Dict(dictTable = "oss_file", dicCode = "id", dicText = "file_name") + @Excel(name = "文件名称", width = 20, dicText = "file_name", dicCode = "id", dictTable = "oss_file") private String fileId; @ApiModelProperty(value = "文件类型 1:报批稿 2:送审稿 3:征求意见稿 4:月报 5:咨询月报 6:会议资料 7:通知 8:其他") @Dict(dicCode = "club_file_type") + @Excel(name = "文件类型", width = 20, dicCode = "club_file_type") private String fileType; @ApiModelProperty(value = "创建人") diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/enums/FieldTypeEnum.java b/laws-modules/src/main/java/com/jero/modules/laws/club/enums/FieldTypeEnum.java index 0084a58b..aabb92c2 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/enums/FieldTypeEnum.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/enums/FieldTypeEnum.java @@ -5,7 +5,8 @@ public enum FieldTypeEnum { TEXT_INPUT("文本输入","1","文本输入"), DATE_INPUT("日期输入","2","日期输入"), - TEXT_INPUT_NAME("文本输入,姓名(工号)","3","文本输入,姓名(工号)") + TEXT_INPUT_NAME("文本输入,姓名(工号)","3","文本输入,姓名(工号)"), + FILE_UPLOAD("文件上传","4","文件上传"), ; final String name; diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubPaymentService.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubPaymentService.java index 2d7e755e..c7d0b50d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubPaymentService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubPaymentService.java @@ -1,7 +1,10 @@ package com.jero.modules.laws.club.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.common.api.vo.Result; import com.jero.modules.laws.club.entity.LawsClubPayment; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** *

@@ -13,4 +16,7 @@ import com.jero.modules.laws.club.entity.LawsClubPayment; */ public interface ILawsClubPaymentService extends IService { + void exportTemplate(HttpServletRequest request, HttpServletResponse response); + + Result importExcel(HttpServletRequest request); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubService.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubService.java index 637bd741..cb368e2d 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubService.java @@ -31,9 +31,9 @@ public interface ILawsClubService extends IService { IPage queryPageList(LawsClub lawsClub, Integer pageNo, Integer pageSize, HttpServletRequest req); - ModelAndView exportAll(LawsClub lawsClub, HttpServletRequest request); + void exportAll(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response); - ModelAndView exportMeetingXls(LawsClub lawsClub, HttpServletRequest request); + void exportMeetingXls(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response); ModelAndView exportresearchXls(LawsClub lawsClub, HttpServletRequest request); @@ -42,4 +42,8 @@ public interface ILawsClubService extends IService { Result importExcel(HttpServletRequest request); List getTreeStructure(String part, String nodeType); + + ModelAndView exportPaymentXls(LawsClub lawsClub, HttpServletRequest request); + + void exportWorkingGroupFileXls(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubWorkingGroupFileService.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubWorkingGroupFileService.java index c1d66a91..308dd824 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubWorkingGroupFileService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/ILawsClubWorkingGroupFileService.java @@ -1,7 +1,10 @@ package com.jero.modules.laws.club.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.common.api.vo.Result; import com.jero.modules.laws.club.entity.LawsClubWorkingGroupFile; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** *

@@ -13,4 +16,7 @@ import com.jero.modules.laws.club.entity.LawsClubWorkingGroupFile; */ public interface ILawsClubWorkingGroupFileService extends IService { + void exportTemplate(HttpServletRequest request, HttpServletResponse response); + + Result importExcel(HttpServletRequest request); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubJoinTeamServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubJoinTeamServiceImpl.java index 8f9b8680..dbf94191 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubJoinTeamServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubJoinTeamServiceImpl.java @@ -19,12 +19,14 @@ import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysUserService; import com.jero.modules.tag.entity.LawsTag; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Workbook; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.entity.ImportParams; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -38,6 +40,8 @@ import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -49,6 +53,8 @@ import java.util.stream.Collectors; * @since 2024-08-29 */ @Service +@Slf4j +@Transactional(rollbackFor = JeroBootException.class) public class LawsClubJoinTeamServiceImpl extends ServiceImpl implements ILawsClubJoinTeamService { @Resource @@ -74,7 +80,7 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists); try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "入团信息", describe); OutputStream out = response.getOutputStream()) { @@ -165,11 +171,13 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl sysUser = sysUserService.list(new LambdaQueryWrapper().eq(SysUser::getRealname, lawsClubJoinTeamExcel.getLeadId())); - if (CollectionUtils.isEmpty(sysUser)) { + String leadName = extractEmployeeId(lawsClubJoinTeamExcel.getLeadId()); + String fullName = extractFullName(lawsClubJoinTeamExcel.getLeadId()); + SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper().eq(SysUser::getUsername, leadName).eq(SysUser::getRealname,fullName),false); + if (Objects.isNull(sysUser)) { msgSub.append(getErrorMsg(i, "社团职务担任者不存在;")); }else { - lawsClubJoinTeamExcel.setLeadId(sysUser.get(0).getId()); + lawsClubJoinTeamExcel.setLeadId(sysUser.getId()); } } // 校验部门名称 @@ -192,11 +200,13 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl sysUser = sysUserService.list(new LambdaQueryWrapper().eq(SysUser::getRealname, lawsClubJoinTeamExcel.getProposerId())); - if (CollectionUtils.isEmpty(sysUser)) { + String proposerName = extractEmployeeId(lawsClubJoinTeamExcel.getProposerId()); + String fullName = extractFullName(lawsClubJoinTeamExcel.getProposerId()); + SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper().eq(SysUser::getUsername, proposerName).eq(SysUser::getRealname,fullName),false); + if (Objects.isNull(sysUser)) { msgSub.append(getErrorMsg(i, "申请人不存在;")); }else { - lawsClubJoinTeamExcel.setProposerId(sysUser.get(0).getId()); + lawsClubJoinTeamExcel.setProposerId(sysUser.getId()); } } if (msgSub.length() > 0) { @@ -225,4 +235,22 @@ public class LawsClubJoinTeamServiceImpl extends ServiceImpl implements ILawsClubMeetingService { @Resource @@ -95,7 +98,7 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists); // 生成 Excel 文件并写入字节数组 try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "参会信息", describe); @@ -107,7 +110,13 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl entity : fileMap.entrySet()) { MultipartFile file = entity.getValue();// 获取上传文件对象 try { - Map unZipFileMap = analyzeZipFile(file); + String templateName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + templateName = "参会信息导入模板.xls"; + }else{ + templateName = "Conference InformationImport Template.xls"; + } + Map unZipFileMap = ZipUtils.analyzeZipFile(file,uploadpath,templateName); saveDirectory = unZipFileMap.get("saveDirectory"); // 移除键为 "saveDirectory" 的文件 unZipFileMap.remove("saveDirectory"); // 拿到excel的导入文件 - File meetingCnTemplate = unZipFileMap.get("参会信息导入模板.xls"); - File meetingEnTemplate = unZipFileMap.get("Conference InformationImport Template.xls"); - // 确定哪个文件不为空,并赋值给 excelImportFile - File excelImportFile = (meetingCnTemplate != null) ? meetingCnTemplate : meetingEnTemplate; + File templateFile = unZipFileMap.get(templateName); // 将模板文件移除 - unZipFileMap.remove("参会信息导入模板.xls"); - unZipFileMap.remove("Conference InformationImport Template.xls"); + unZipFileMap.remove(templateFile); ImportParams params = new ImportParams(); params.setNeedSave(false); - List excelList = ExcelImportUtil.importExcel(new FileInputStream(excelImportFile), LawsClubMeetingExcel.class, params); + List excelList = ExcelImportUtil.importExcel(new FileInputStream(templateFile), LawsClubMeetingExcel.class, params); excelList = excelList.stream().skip(2).filter(item -> !Objects.isNull(item)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(excelList)) { throw new JeroBootException("没有数据可导入"); @@ -203,73 +214,6 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl analyzeZipFile(MultipartFile file) throws IOException { - int pos = file.getOriginalFilename().lastIndexOf("."); - String str = file.getOriginalFilename().substring(pos+1).toLowerCase(); - String filenameorg = file.getOriginalFilename().substring(0,pos); - String resultMsg = ""; - if (!str.equals("zip")) { - if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ - resultMsg = "请上传zip文件"; - }else{ - resultMsg = "Please upload a zip file"; - } - throw new JeroBootException(resultMsg); - } - String path = uploadpath + File.separator + "modal" + File.separator + filenameorg + System.currentTimeMillis(); - File saveDirectory = new File(path); - if(!saveDirectory.isDirectory()){ - saveDirectory.mkdir(); - } - FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +File.separator+ file.getOriginalFilename())); - try { - //解压缩 - String zipEntryName = FileUnZip.unZipFiles2(path +File.separator+ file.getOriginalFilename(), path); - // 1.获取其中的文件, - File zipFile = new File(zipEntryName); - List fileList = new ArrayList<>(); - if (zipFile.isDirectory()) { - File[] files = zipFile.listFiles(); - for (File fi : files) { - fileList.add(fi); - } - } - if (fileList.size() < 1) { - FileUnZip.deleteDir(saveDirectory); - if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ - resultMsg = "没有可导入的数据,请检查!"; - }else{ - resultMsg = "No data to import, please check"; - } - throw new JeroBootException(resultMsg); - } - Map fileMap = fileList.stream().collect(Collectors.toMap(File::getName, Function.identity())); - File meetingCnTemplate = fileMap.get("参会信息导入模板.xls"); - File meetingEnTemplate = fileMap.get("Conference InformationImport Template.xls"); - if (Objects.isNull(meetingCnTemplate) && Objects.isNull(meetingEnTemplate)) { - //删除原上传文件 - FileUnZip.deleteDir(saveDirectory); - if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ - resultMsg = "压缩包内没有Excel模板文件"; - }else{ - resultMsg = "In the cabinet did not upload the Excel template file"; - } - throw new JeroBootException(resultMsg); - } - fileMap.put("saveDirectory", saveDirectory); - return fileMap; - } catch (StringIndexOutOfBoundsException e){ - //删除原上传文件 - FileUnZip.deleteDir(saveDirectory); - if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ - resultMsg = "读取失败,压缩包内需要把所有导入文件放入一个父级文件夹下"; - }else{ - resultMsg = "The data fails to be read. In the compressed package, all imported files need to be placed in a parent folder"; - } - throw new JeroBootException(resultMsg); - } - } - private StringBuilder validateExcelData(List meetingExcels, Map unZipFileMap) throws IOException{ StringBuilder msg = new StringBuilder(); // 拿到这个流程的名称 @@ -375,7 +319,7 @@ public class LawsClubMeetingServiceImpl extends ServiceImpl ossFileResult = iossFileService.commonUpload(multipartFile, ""); + Result ossFileResult = iossFileService.commonUpload(multipartFile, "temp"); lawsClubMeetingMemberExcel.setMeetingFileId(ossFileResult.getResult().getId()); } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubPaymentServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubPaymentServiceImpl.java index e72e4142..6d6a8cf0 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubPaymentServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubPaymentServiceImpl.java @@ -1,10 +1,39 @@ package com.jero.modules.laws.club.service.impl; 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.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.LawsClubPaymentExcel; +import com.jero.modules.tag.entity.LawsTag; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; /** *

@@ -15,6 +44,136 @@ import org.springframework.stereotype.Service; * @since 2024-08-29 */ @Service +@Slf4j +@Transactional(rollbackFor = JeroBootException.class) public class LawsClubPaymentServiceImpl extends ServiceImpl implements ILawsClubPaymentService { + @Resource + private RolePermissionService rolePermissionService; + + @Override + @SneakyThrows + public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { + // 先验证权限, 只有有社团管理新增或修改的其中之一即可 + boolean result = validatingPermission(); + if (!result) { + throw new JeroBootException(ResultCommon.NO_PERMISSION); + } + // 创建一个Excel工作簿 + String describe = "填写说明:\n" + + "1.所有带星号的为必填\n" + + "2.导入数据从第四行开始,第一行为表头,第二行为填写说明,第三行为示例。第四行才是正式数据"; + String fieldTxts = "缴费金额,缴费时间,备注"; + String mustInputFlags = "no,no,no"; + String fieldTypeLists = "2,1,1"; // 1代表是文本输入类型 2代表日期输入 + List lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists); + try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "支付信息", describe); + OutputStream out = response.getOutputStream()) { + // 设置HTTP响应头 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("UTF-8"); // 确保响应流使用UTF-8编码 + // 处理文件名乱码问题 + String encodedFileName = URLEncoder.encode("支付信息表", StandardCharsets.UTF_8.name()).replace("+", "%20"); + response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName + ".xls"); + // 写入Excel并输出 + workbook.write(out); + out.flush(); + } catch (IOException e) { + log.error("导出Excel失败", e); + } + } + + @Override + public Result importExcel(HttpServletRequest request) { + // 先验证权限, 只有有社团管理新增或修改的其中之一即可 + boolean result = validatingPermission(); + if (!result) { + throw new JeroBootException(ResultCommon.NO_PERMISSION); + } + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + List lawsClubPaymentList = new ArrayList<>(); + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + try { + ImportParams params = new ImportParams(); + params.setNeedSave(true); + List excelList = ExcelImportUtil.importExcel(file.getInputStream(), LawsClubPaymentExcel.class, params); + excelList = excelList.stream().skip(2).filter(item -> !Objects.isNull(item)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(excelList)) { + throw new JeroBootException("没有数据可导入"); + } + StringBuilder msg = validateExcelData(excelList); // 校验数据 + if (StringUtils.isNotEmpty(msg.toString())) { + return Result.error(msg.toString()); + } + // 保存数据 + for (LawsClubPaymentExcel lawsClubPaymentExcel : excelList) { + LawsClubPayment lawsClubPayment = new LawsClubPayment(); + BeanUtils.copyProperties(lawsClubPaymentExcel, lawsClubPayment); + lawsClubPayment.setPaymentTime(convertStringToDate(lawsClubPaymentExcel.getPaymentTime())); + lawsClubPaymentList.add(lawsClubPayment); + } + }catch (Exception e) { + log.error(e.getMessage(),e); + return Result.error("文件导入失败:"+e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.OK(lawsClubPaymentList); + } + + // 校验Excel数据 + private StringBuilder validateExcelData(List excelList) { + StringBuilder msg = new StringBuilder(); + for (int i = 0; i < excelList.size(); i++) { + LawsClubPaymentExcel lawsClubPaymentExcel = excelList.get(i); + StringBuilder msgSub = new StringBuilder(); + // 校验缴费日期格 + if (StringUtils.isNotBlank(lawsClubPaymentExcel.getPaymentTime())) { + try { + LocalDate.parse(lawsClubPaymentExcel.getPaymentTime()); + } catch (Exception e) { + msgSub.append(getErrorMsg(i, "缴费日期格式不正确;")); + } + } + if (msgSub.length() > 0) { + msg.append(msgSub).append("
"); + } + } + return msg; + } + + private boolean validatingPermission() { + String addPermission = "clubManagement:clubManagement:add"; + String editPermission = "clubManagement:clubManagement:edit"; + boolean add = rolePermissionService.getRolePermission(addPermission); + boolean edit = rolePermissionService.getRolePermission(editPermission); + boolean result = add || edit; + return result; + } + + private Date convertStringToDate(String dateStr) { + if (StringUtils.isBlank(dateStr)) { + return null; + } + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = simpleDateFormat.parse(dateStr); + return date; + }catch (Exception e) { + log.error("日期转换异常"); + } + return null; + } + + // 错误消息格式化 + private String getErrorMsg(int rowIndex, String errorMsg) { + return "第" + (rowIndex + 4) + "行" + errorMsg; + } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubResearchInformationServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubResearchInformationServiceImpl.java index 821b5b9c..7399bd00 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubResearchInformationServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubResearchInformationServiceImpl.java @@ -19,12 +19,14 @@ import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysUserService; import com.jero.modules.tag.entity.LawsTag; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Workbook; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.entity.ImportParams; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -51,6 +53,8 @@ import java.util.stream.Collectors; * @since 2024-08-29 */ @Service +@Slf4j +@Transactional(rollbackFor = JeroBootException.class) public class LawsClubResearchInformationServiceImpl extends ServiceImpl implements ILawsClubResearchInformationService { @Resource diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubServiceImpl.java index 442a35e5..66c203c8 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubServiceImpl.java @@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.constant.enums.LanguageEnum; import com.jero.common.exception.JeroBootException; import com.jero.common.system.base.controller.JeroController; import com.jero.common.util.*; +import com.jero.common.util.obs.ObsBootUtil; import com.jero.modules.laws.club.config.CustomExcelExportStyler; import com.jero.modules.laws.club.entity.*; import com.jero.modules.laws.club.mapper.LawsClubMapper; @@ -16,11 +18,15 @@ import com.jero.modules.laws.club.service.*; import com.jero.modules.laws.club.utils.ExcelUtil; 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.tag.entity.LawsTag; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.*; +import org.apache.tools.zip.ZipEntry; +import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; @@ -43,6 +49,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.zip.ZipOutputStream; /** *

@@ -71,6 +78,8 @@ public class LawsClubServiceImpl extends ServiceImpl i private ILawsClubResearchInformationService lawsClubResearchInformationService; @Resource private RedisUtil redisUtil; + @Resource + private IOSSFileService iossFileService; @Override public List getTreeStructure(String parentId, String nodeType) { @@ -420,6 +429,10 @@ public class LawsClubServiceImpl extends ServiceImpl i if(StringUtils.isBlank(id)){ return Result.error(ResultCommon.PLEASE_SELECT_DATA); } + LawsClub lawsClub = getOne(new LambdaQueryWrapper().eq(LawsClub::getId, id)); + if (!Objects.isNull(lawsClub) && "Part".equals(lawsClub.getParentId())) { + return Result.error(ResultCommon.ROOT_NODE_CANNOT_BE_DELETE); + } List list = list(new LambdaQueryWrapper().eq(LawsClub::getParentId, id)); if (!CollectionUtils.isEmpty(list)) { return Result.error(ResultCommon.NODE_EXIST_SUBSETS); @@ -430,10 +443,8 @@ public class LawsClubServiceImpl extends ServiceImpl i } @Override - public ModelAndView exportAll(LawsClub lawsClub, HttpServletRequest request) { - // Step.1 组装查询条件 + public void exportAll(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response) { LambdaQueryWrapper lawsClubQueryWrapper = createLawsClubQueryWrapper(lawsClub); - //Step.2 AutoPoi 导出Excel String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ lawsClubQueryWrapper.in(LawsClub::getId, Arrays.asList(selections.split(","))); @@ -441,6 +452,8 @@ public class LawsClubServiceImpl extends ServiceImpl i List clubList = list(lawsClubQueryWrapper); List lawsClubJoinTeams = new ArrayList<>(); List lawsClubMeetings = new ArrayList<>(); + List lawsClubPayments = new ArrayList<>(); + List lawsClubWorkingGroupFiles = new ArrayList<>(); List lawsClubResearchInformations = new ArrayList<>(); for (LawsClub club : clubList) { // 如果是根节点那么上级节点为空 @@ -454,66 +467,83 @@ public class LawsClubServiceImpl extends ServiceImpl i club.setContactNumber(encryptNumber); } } + List fileIdList = new ArrayList<>(); List ids = clubList.stream().map(LawsClub::getId).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(ids)) { lawsClubJoinTeams = lawsClubJoinTeamService.list(new LambdaQueryWrapper().in(LawsClubJoinTeam::getClubId, ids)); lawsClubMeetings = lawsClubMeetingService.list(new LambdaQueryWrapper().in(LawsClubMeeting::getClubId, ids)); + lawsClubPayments = lawsClubPaymentService.list(new LambdaQueryWrapper().in(LawsClubPayment::getClubId, ids)); for (LawsClubMeeting lawsClubMeeting : lawsClubMeetings) { List memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId())); + List meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList()); + fileIdList.addAll(meetingFileIds); lawsClubMeeting.setMeetingMemberList(memberList); } + lawsClubWorkingGroupFiles = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper().in(LawsClubWorkingGroupFile::getClubId, ids)); + List fileIds = lawsClubWorkingGroupFiles.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList()); + fileIdList.addAll(fileIds); lawsClubResearchInformations = lawsClubResearchInformationService.list(new LambdaQueryWrapper().in(LawsClubResearchInformation::getClubId, ids)); } //导出文件名称 - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - mv.addObject(JeroController.FILE_NAME, "社团管理信息"); List> sheetList = new ArrayList<>(); // 基本信息 Map basicSheet = new HashMap<>(); basicSheet.put(NormalExcelConstants.DATA_LIST, clubList); - basicSheet.put(JeroController.CLASS, LawsClub.class); - basicSheet.put(JeroController.PARAMS, createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "基本信息")); - basicSheet.put(JeroController.FILE_NAME, "基本信息"); + basicSheet.put("entity", LawsClub.class); + basicSheet.put("title", createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "基本信息")); sheetList.add(basicSheet); // 入团信息 Map joinTeamSheet = new HashMap<>(); joinTeamSheet.put(NormalExcelConstants.DATA_LIST, lawsClubJoinTeams); joinTeamSheet.put(JeroController.CLASS, LawsClubJoinTeam.class); - joinTeamSheet.put(JeroController.PARAMS, createExportParams(null, "入团信息")); - joinTeamSheet.put(JeroController.FILE_NAME, "入团信息"); + joinTeamSheet.put("title", createExportParams(null, "入团信息")); sheetList.add(joinTeamSheet); + // 支付信息 + Map paymentSheet = new HashMap<>(); + paymentSheet.put(NormalExcelConstants.DATA_LIST, lawsClubPayments); + paymentSheet.put(JeroController.CLASS, LawsClubPayment.class); + paymentSheet.put("title", createExportParams(null, "支付信息")); + sheetList.add(paymentSheet); // 参会信息 Map meetingSheet = new HashMap<>(); meetingSheet.put(NormalExcelConstants.DATA_LIST, lawsClubMeetings); meetingSheet.put(JeroController.CLASS, LawsClubMeeting.class); - meetingSheet.put(JeroController.PARAMS, createExportParams(null, "参会信息")); - meetingSheet.put(JeroController.FILE_NAME, "参会信息"); + meetingSheet.put("title", createExportParams(null, "参会信息")); sheetList.add(meetingSheet); + // 工作组资料 + Map workingGroupFileSheet = new HashMap<>(); + workingGroupFileSheet.put(NormalExcelConstants.DATA_LIST, lawsClubWorkingGroupFiles); + workingGroupFileSheet.put(JeroController.CLASS, LawsClubWorkingGroupFile.class); + workingGroupFileSheet.put("title", createExportParams(null, "工作组资料")); + sheetList.add(workingGroupFileSheet); // 征集调研信息 Map researchSheet = new HashMap<>(); researchSheet.put(NormalExcelConstants.DATA_LIST, lawsClubResearchInformations); researchSheet.put(JeroController.CLASS, LawsClubResearchInformation.class); - researchSheet.put(JeroController.PARAMS, createExportParams(null, "征集调研信息")); - researchSheet.put(JeroController.FILE_NAME, "征集调研信息"); + researchSheet.put("title", createExportParams(null, "征集调研信息")); sheetList.add(researchSheet); - mv.addObject(NormalExcelConstants.MAP_LIST, sheetList); - return mv; - } - - private ExportParams createExportParams(String title, String sheetName) { - ExportParams exportParams = new ExportParams(); - exportParams.setTitle(title); - exportParams.setType(ExcelType.HSSF); - exportParams.setSheetName(sheetName); - exportParams.setStyle(CustomExcelExportStyler.class); // 使用自定义的样式 - return exportParams; + // 生成 Workbook + Workbook workbook = ExcelExportUtil.exportExcel(sheetList, ExcelType.HSSF); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + // 将 Excel 写入到字节数组 + workbook.write(baos); + byte[] excelBytes = baos.toByteArray(); + workbook.close(); + String excelName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + excelName = "社团管理表.xls"; + }else{ + excelName = "Club Management Form.xls"; + } + createZipWithAttachments(response, excelBytes, excelName, "参会信息", fileIdList); + } catch (IOException e) { + log.error("导出失败" + e.getMessage()); + } } @Override public ModelAndView exportTeamXls(LawsClub lawsClub, HttpServletRequest request) { - // Step.1 组装查询条件 LambdaQueryWrapper lawsClubQueryWrapper = createLawsClubQueryWrapper(lawsClub); - //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ @@ -534,10 +564,8 @@ public class LawsClubServiceImpl extends ServiceImpl i } @Override - public ModelAndView exportMeetingXls(LawsClub lawsClub, HttpServletRequest request) { - // Step.1 组装查询条件 + public ModelAndView exportPaymentXls(LawsClub lawsClub, HttpServletRequest request) { LambdaQueryWrapper lawsClubQueryWrapper = createLawsClubQueryWrapper(lawsClub); - //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ @@ -545,20 +573,91 @@ public class LawsClubServiceImpl extends ServiceImpl i } List list = list(lawsClubQueryWrapper); List ids = list.stream().map(LawsClub::getId).collect(Collectors.toList()); + List excelList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(ids)) { + excelList = lawsClubPaymentService.list(new LambdaQueryWrapper().in(LawsClubPayment::getClubId, ids)); + } + //导出文件名称 + mv.addObject(JeroController.FILE_NAME, "支付信息统计表"); + mv.addObject(JeroController.CLASS, LawsClubPayment.class); + mv.addObject(JeroController.PARAMS, createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "支付信息")); + mv.addObject(NormalExcelConstants.DATA_LIST, excelList); + return mv; + } + + @Override + public void exportMeetingXls(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response) { + LambdaQueryWrapper lawsClubQueryWrapper = createLawsClubQueryWrapper(lawsClub); + String selections = request.getParameter("selections"); + if(!oConvertUtils.isEmpty(selections)){ + lawsClubQueryWrapper.in(LawsClub::getId, Arrays.asList(selections.split(","))); + } + List list = list(lawsClubQueryWrapper); + List ids = list.stream().map(LawsClub::getId).collect(Collectors.toList()); List excelList = new ArrayList<>(); + List fileIdList = new ArrayList<>(); if (!CollectionUtils.isEmpty(ids)) { excelList = lawsClubMeetingService.list(new LambdaQueryWrapper().in(LawsClubMeeting::getClubId, ids)); for (LawsClubMeeting lawsClubMeeting : excelList) { List memberList = lawsClubMeetingMemberService.list(new LambdaQueryWrapper().eq(LawsClubMeetingMember::getMeetingId, lawsClubMeeting.getId())); + List meetingFileIds = memberList.stream().map(LawsClubMeetingMember::getMeetingFileId).filter(Objects::nonNull).collect(Collectors.toList()); + fileIdList.addAll(meetingFileIds); lawsClubMeeting.setMeetingMemberList(memberList); } } - //导出文件名称 - mv.addObject(JeroController.FILE_NAME, "参会记录表"); - mv.addObject(JeroController.CLASS, LawsClubMeeting.class); - mv.addObject(JeroController.PARAMS, createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "参会信息")); - mv.addObject(NormalExcelConstants.DATA_LIST, excelList); - return mv; + // 生成 Workbook + Workbook workbook = ExcelExportUtil.exportExcel(createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "参会信息"), LawsClubMeeting.class,excelList); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + // 将 Excel 写入到字节数组 + workbook.write(baos); + byte[] excelBytes = baos.toByteArray(); + workbook.close(); + String excelName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + excelName = "参会信息表.xls"; + }else{ + excelName = "Participation Information Form.xls"; + } + createZipWithAttachments(response, excelBytes, excelName, "参会信息", fileIdList); + } catch (IOException e) { + log.error("导出失败" + e.getMessage()); + } + } + + @Override + public void exportWorkingGroupFileXls(LawsClub lawsClub, HttpServletRequest request, HttpServletResponse response) { + // Step.1 组装查询条件 + LambdaQueryWrapper lawsClubQueryWrapper = createLawsClubQueryWrapper(lawsClub); + //Step.2 AutoPoi 导出Excel + String selections = request.getParameter("selections"); + if(!oConvertUtils.isEmpty(selections)){ + lawsClubQueryWrapper.in(LawsClub::getId, Arrays.asList(selections.split(","))); + } + List list = list(lawsClubQueryWrapper); + List ids = list.stream().map(LawsClub::getId).collect(Collectors.toList()); + List excelList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(ids)) { + excelList = lawsClubWorkingGroupFileService.list(new LambdaQueryWrapper().in(LawsClubWorkingGroupFile::getClubId, ids)); + } + List fileIdList = excelList.stream().map(LawsClubWorkingGroupFile::getFileId).filter(Objects::nonNull).collect(Collectors.toList()); + // 生成 Workbook + Workbook workbook = ExcelExportUtil.exportExcel(createExportParams("密级:核心商密□普通商密□内部资料■外部公开□", "工作组资料"), LawsClubWorkingGroupFile.class,excelList); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayOutputStream baosZip = new ByteArrayOutputStream()) { + // 将 Excel 写入到字节数组 + workbook.write(baos); + byte[] excelBytes = baos.toByteArray(); + workbook.close(); + String excelName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + excelName = "工作组资料表.xls"; + }else{ + excelName = "WorkingGroup File Form.xls"; + } + createZipWithAttachments(response, excelBytes, excelName, "工作组资料", fileIdList); + } catch (IOException e) { + log.error("导出失败" + e.getMessage()); + } } @Override @@ -595,7 +694,6 @@ public class LawsClubServiceImpl extends ServiceImpl i String fieldTxts = "上级节点,节点类型,社团名称,社团地址,社团联系人,联系电话,编号"; String mustInputFlags = "yes,yes,yes,no,no,no,no"; String fieldTypeLists = "1,1,1,1,1,1,1"; // 1 代表是文本输入类型 - boolean mergeAttendees = false; List lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists); try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "基础信息", describe); OutputStream out = response.getOutputStream()) { @@ -695,6 +793,73 @@ public class LawsClubServiceImpl extends ServiceImpl i return msg; } + private void createZipWithAttachments(HttpServletResponse response, byte[] excelBytes, String excelName, String zipFileName, List fileIdList) throws IOException { + try (ByteArrayOutputStream baosZip = new ByteArrayOutputStream(); + ZipOutputStream zos = new ZipOutputStream(baosZip)) { + // 将 Excel 文件写入 ZIP + ZipEntry entry = new ZipEntry(excelName); + zos.putNextEntry(entry); + zos.write(excelBytes); + zos.closeEntry(); // 必须关闭当前的 ZipEntry + // 创建 “附件” 文件夹并添加文件 + String folderPath = "附件/"; + Set addedEntries = new HashSet<>(); + for (String fileId : fileIdList) { + addFileToZip(fileId, zos, folderPath, addedEntries); + } + // 确保关闭所有条目后再关闭 ZipOutputStream + zos.finish(); + // 设置 HTTP 响应头,处理文件名乱码 + response.setContentType("application/zip;charset=UTF-8"); + response.setCharacterEncoding("UTF-8"); + String encodedFileName = URLEncoder.encode(zipFileName, StandardCharsets.UTF_8.name()).replace("+", "%20"); + response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName + ".zip"); + // 输出 ZIP 文件到响应流中 + try (OutputStream out = response.getOutputStream()) { + baosZip.writeTo(out); // 将最终的 ZIP 字节流写入响应 + out.flush(); // 确保输出完整 + } + } + } + + + // 将文件添加到 ZIP 中,放入指定的文件夹内,处理文件重复和 null 的情况 + private void addFileToZip(String fileId, ZipOutputStream zipos, String folderPath, Set addedEntries) throws IOException { + OSSFile ossFile = iossFileService.getById(fileId); + if (ossFile == null) { + return; + } + InputStream inputStream = ObsBootUtil.getOssFile(ossFile.getUrl()); + if (Objects.isNull(inputStream)) { + return; + } + String entryPath = folderPath + ossFile.getFileName(); + if (addedEntries.contains(entryPath)) { + return; // 如果文件已经被添加,跳过 + } + zipos.putNextEntry(new ZipEntry(entryPath)); + try (InputStream is = inputStream) { + byte[] buffer = new byte[1024]; + int length; + while ((length = is.read(buffer)) != -1) { + zipos.write(buffer, 0, length); + } + } catch (Exception e) { + e.printStackTrace(); + } + zipos.closeEntry(); + addedEntries.add(entryPath); // 记录已添加的文件,防止重复添加 + } + + private ExportParams createExportParams(String title, String sheetName) { + ExportParams exportParams = new ExportParams(); + exportParams.setTitle(title); + exportParams.setType(ExcelType.HSSF); + exportParams.setSheetName(sheetName); + exportParams.setStyle(CustomExcelExportStyler.class); // 使用自定义的样式 + return exportParams; + } + // 错误消息格式化 private String getErrorMsg(int rowIndex, String errorMsg) { return "第" + (rowIndex + 4) + "行" + errorMsg; diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubWorkingGroupFileServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubWorkingGroupFileServiceImpl.java index 3d0dfd1d..c1b6319b 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubWorkingGroupFileServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsClubWorkingGroupFileServiceImpl.java @@ -1,10 +1,51 @@ package com.jero.modules.laws.club.service.impl; 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.constant.enums.LanguageEnum; +import com.jero.common.exception.JeroBootException; +import com.jero.common.system.vo.DictModel; +import com.jero.common.util.MessageUtils; import com.jero.modules.laws.club.entity.LawsClubWorkingGroupFile; import com.jero.modules.laws.club.mapper.LawsClubWorkingGroupFileMapper; 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.LawsClubWorkingGroupFileExcel; +import com.jero.modules.oss.entity.OSSFile; +import com.jero.modules.oss.service.IOSSFileService; +import com.jero.modules.split.common.FileUnZip; +import com.jero.modules.system.service.ISysDictService; +import com.jero.modules.tag.entity.LawsTag; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.tools.zip.ZipEntry; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.zip.ZipOutputStream; /** *

@@ -15,6 +56,185 @@ import org.springframework.stereotype.Service; * @since 2024-08-29 */ @Service +@Slf4j +@Transactional(rollbackFor = JeroBootException.class) public class LawsClubWorkingGroupFileServiceImpl extends ServiceImpl implements ILawsClubWorkingGroupFileService { + @Resource + private ISysDictService sysDictService; + @Resource + private IOSSFileService iossFileService; + @Value(value = "${jero.path.upload}") + private String uploadpath; + @Resource + private RolePermissionService rolePermissionService; + + + @Override + @SneakyThrows + public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { + // 先验证权限, 只有有社团管理新增或修改的其中之一即可 + boolean result = validatingPermission(); + if (!result) { + throw new JeroBootException(ResultCommon.NO_PERMISSION); + } + // 创建一个Excel工作簿 + String describe = "填写说明:\n" + + "1.所有带星号的为必填\n" + + "2.导入数据从第四行开始,第一行为表头,第二行为填写说明,第三行为示例。第四行才是正式数据"; + String fieldTxts = "文件名称,文件类型"; + String mustInputFlags = "no,no"; + String fieldTypeLists = "4,1"; // 1代表文本输入类型, 4代表文件上传 + List lawsTags = ExcelUtil.createLawsTags(fieldTxts, mustInputFlags, fieldTypeLists); + // 生成 Excel 文件并写入字节数组 + try (Workbook workbook = ExcelUtil.createWorkBookWithLawsTags(lawsTags, "工作组资料", describe); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + // 将Excel写入到字节数组 + workbook.write(baos); + byte[] excelBytes = baos.toByteArray(); + // 生成ZIP文件 + ByteArrayOutputStream baosZip = new ByteArrayOutputStream(); + try (ZipOutputStream zos = new ZipOutputStream(baosZip)) { + // 将Excel文件放入ZIP包中的目录下 + String templateName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + templateName = "工作组资料导入模板.xls"; + }else{ + templateName = "WorkingGroup File Template.xls"; + } + ZipEntry entry = new ZipEntry( templateName); + zos.putNextEntry(entry); + zos.write(excelBytes); + zos.closeEntry(); + } + // 设置HTTP响应头 + response.setContentType("application/zip;charset=UTF-8"); + response.setCharacterEncoding("UTF-8"); // 确保响应流使用UTF-8编码 + // 处理文件名乱码问题 + String encodedFileName = URLEncoder.encode("工作组资料导入模板", StandardCharsets.UTF_8.name()).replace("+", "%20"); + response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName + ".zip"); + // 输出ZIP文件到响应流中 + try (OutputStream out = response.getOutputStream()) { + baosZip.writeTo(out); + out.flush(); + } + } catch (IOException e) { + log.error("导出模板失败", e); + } + } + + @Override + public Result importExcel(HttpServletRequest request) { + // 先验证权限, 只有有社团管理新增或修改的其中之一即可 + boolean result = validatingPermission(); + if (!result) { + throw new JeroBootException(ResultCommon.NO_PERMISSION); + } + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + List lawsClubWorkingGroupFileList = new ArrayList<>(); + File saveDirectory = null; + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + try { + String templateName = ""; + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + templateName = "工作组资料导入模板.xls"; + }else{ + templateName = "WorkingGroup File Template.xls"; + } + Map unZipFileMap = ZipUtils.analyzeZipFile(file, uploadpath, templateName); + saveDirectory = unZipFileMap.get("saveDirectory"); + // 移除键为 "saveDirectory" 的文件 + unZipFileMap.remove("saveDirectory"); + // 拿到excel的导入文件 + File templateFile = unZipFileMap.get(templateName); + // 将模板文件移除 + unZipFileMap.remove(templateName); + ImportParams params = new ImportParams(); + params.setNeedSave(false); + List excelList = ExcelImportUtil.importExcel(new FileInputStream(templateFile), LawsClubWorkingGroupFileExcel.class, params); + excelList = excelList.stream().skip(2).filter(item -> !Objects.isNull(item)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(excelList)) { + throw new JeroBootException("没有数据可导入"); + } + // 校验数据 + StringBuilder msg = validateExcelData(excelList, unZipFileMap); + if (StringUtils.isNotEmpty(msg.toString())) { + return Result.error(msg.toString()); + } + // 保存数据 + for (LawsClubWorkingGroupFileExcel lawsClubMeetingExcel : excelList) { + LawsClubWorkingGroupFile lawsClubWorkingGroupFile = new LawsClubWorkingGroupFile(); + BeanUtils.copyProperties(lawsClubMeetingExcel, lawsClubWorkingGroupFile); + lawsClubWorkingGroupFileList.add(lawsClubWorkingGroupFile); + } + }catch (Exception e) { + log.error(e.getMessage(),e); + return Result.error("文件导入失败:"+e.getMessage()); + } finally { + //删除原上传文件 + if (!Objects.isNull(saveDirectory)) { + FileUnZip.deleteDir(saveDirectory); + } + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.OK(lawsClubWorkingGroupFileList); + } + + private StringBuilder validateExcelData(List excelList, Map unZipFileMap) throws IOException{ + StringBuilder msg = new StringBuilder(); + // 拿到这个流程的名称 + List fileTypeList = sysDictService.getDictItems("club_file_type"); + Map fileTypeMap = fileTypeList.stream().collect(Collectors.toMap(DictModel::getText, DictModel::getValue)); + 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)) { + msgSub.append(getErrorMsg(i, "文件类型不存在;")); + }else { + lawsClubWorkingGroupFileExcel.setFileType(fileType); + } + } + // 校验参会报告 + if (StringUtils.isNotBlank(lawsClubWorkingGroupFileExcel.getFileId())) { + File file = unZipFileMap.get(lawsClubWorkingGroupFileExcel.getFileId()); + if (Objects.isNull(file)) { + msgSub.append(getErrorMsg(i, "参会报告:" + lawsClubWorkingGroupFileExcel.getFileId() + "在压缩包内不存在;")); + }else { + FileInputStream input = new FileInputStream(file); + MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(), "application/octet-stream", input); + // 上传该文件 + Result ossFileResult = iossFileService.commonUpload(multipartFile, "temp"); + lawsClubWorkingGroupFileExcel.setFileId(ossFileResult.getResult().getId()); + } + } + if (msgSub.length() > 0) { + msg.append(msgSub).append("
"); + } + } + return msg; + } + + // 错误消息格式化 + private String getErrorMsg(int rowIndex, String errorMsg) { + return "第" + (rowIndex + 4) + "行" + errorMsg; + } + + private boolean validatingPermission() { + String addPermission = "clubManagement:clubManagement:add"; + String editPermission = "clubManagement:clubManagement:edit"; + boolean add = rolePermissionService.getRolePermission(addPermission); + boolean edit = rolePermissionService.getRolePermission(editPermission); + boolean result = add || edit; + return result; + } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsCompanyStandardStatisticsServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsCompanyStandardStatisticsServiceImpl.java index db30a604..d1dac2b0 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsCompanyStandardStatisticsServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/service/impl/LawsCompanyStandardStatisticsServiceImpl.java @@ -13,11 +13,13 @@ import com.jero.common.util.oConvertUtils; import com.jero.modules.laws.club.entity.LawsCompanyStandardStatistics; import com.jero.modules.laws.club.mapper.LawsCompanyStandardStatisticsMapper; import com.jero.modules.laws.club.service.ILawsCompanyStandardStatisticsService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import java.util.Arrays; @@ -33,6 +35,8 @@ import java.util.Objects; * @since 2024-08-28 */ @Service +@Slf4j +@Transactional(rollbackFor = JeroBootException.class) public class LawsCompanyStandardStatisticsServiceImpl extends ServiceImpl implements ILawsCompanyStandardStatisticsService { @Override diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/utils/ZipUtils.java b/laws-modules/src/main/java/com/jero/modules/laws/club/utils/ZipUtils.java new file mode 100644 index 00000000..a554f242 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/utils/ZipUtils.java @@ -0,0 +1,135 @@ +package com.jero.modules.laws.club.utils; + +import com.jero.common.constant.enums.LanguageEnum; +import com.jero.common.exception.JeroBootException; +import com.jero.common.util.MessageUtils; +import com.jero.modules.split.common.FileUnZip; +import org.apache.commons.io.FileUtils; +import org.apache.tools.zip.ZipEntry; +import org.apache.tools.zip.ZipFile; +import org.springframework.web.multipart.MultipartFile; +import java.io.*; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class ZipUtils { + + + public static Map analyzeZipFile(MultipartFile file, String uploadpath, String templateName) throws IOException { + int pos = file.getOriginalFilename().lastIndexOf("."); + String str = file.getOriginalFilename().substring(pos+1).toLowerCase(); + String filenameorg = file.getOriginalFilename().substring(0,pos); + String resultMsg = ""; + if (!str.equals("zip")) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + resultMsg = "请上传zip文件"; + }else{ + resultMsg = "Please upload a zip file"; + } + throw new JeroBootException(resultMsg); + } + String path = uploadpath + File.separator + "modal" + File.separator + filenameorg + System.currentTimeMillis(); + File saveDirectory = new File(path); + if(!saveDirectory.isDirectory()){ + saveDirectory.mkdir(); + } + FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +File.separator+ file.getOriginalFilename())); + try { + //解压缩 + unZipFiles2(path +File.separator+ file.getOriginalFilename(), path); + // 获取其中的文件, + File zipFile = new File(path); + List fileList = new ArrayList<>(); + if (zipFile.isDirectory()) { + traverseDirectory(zipFile, fileList); + } + if (fileList.size() < 1) { + FileUnZip.deleteDir(saveDirectory); + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + resultMsg = "没有可导入的数据,请检查!"; + }else{ + resultMsg = "No data to import, please check"; + } + throw new JeroBootException(resultMsg); + } + Map fileMap = fileList.stream().collect(Collectors.toMap(File::getName, Function.identity(), (existing, replacement) -> existing)); + File templateFile = fileMap.get(templateName); + if (Objects.isNull(templateFile)) { + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + resultMsg = "压缩包内没有Excel模板文件"; + }else{ + resultMsg = "In the cabinet did not upload the Excel template file"; + } + throw new JeroBootException(resultMsg); + } + fileMap.put("saveDirectory", saveDirectory); + return fileMap; + } catch (Exception e){ + //删除原上传文件 + FileUnZip.deleteDir(saveDirectory); + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())){ + resultMsg = "读取失败,请严格按照模板文件导入数据"; + }else{ + resultMsg = "The data fails to be read. Import data strictly according to the template file"; + } + throw new JeroBootException(resultMsg); + } + } + + private static void traverseDirectory(File dir, List fileList) { + for (File file : dir.listFiles()) { + if (file.isDirectory()) { + // 递归遍历子文件夹 + traverseDirectory(file, fileList); + } else { + // 添加文件到fileList中 + fileList.add(file); + } + } + } + + public static void unZipFiles2(String sourceFile, String descDir) throws IOException { + File zipFile = new File(sourceFile); + File pathFile = new File(descDir); + if (!pathFile.exists()) { + pathFile.mkdirs(); + } + try (ZipFile zip = new ZipFile(zipFile, "gbk")) { + for (Enumeration entries = zip.getEntries(); entries.hasMoreElements(); ) { + ZipEntry entry = entries.nextElement(); + String zipEntryName = entry.getName(); + // 修正文件路径,避免重复文件夹 + String outPath = (descDir + File.separator + zipEntryName).replaceAll("\\*", "/"); + File outFile = new File(outPath); + // 判断是否为文件夹 + if (entry.isDirectory()) { + if (!outFile.exists()) { + outFile.mkdirs(); // 创建文件夹 + } + } else { + // 如果是文件,确保父级目录存在 + File parentDir = outFile.getParentFile(); + if (!parentDir.exists()) { + parentDir.mkdirs(); // 创建父级目录 + } + // 解压文件 + try (InputStream in = zip.getInputStream(entry); + OutputStream out = new FileOutputStream(outFile)) { + byte[] buffer = new byte[1024]; + int len; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } + } + } + } + // 删除压缩包自身 + if (zipFile.exists()) { + zipFile.delete(); + } + } +} diff --git a/laws-modules/src/main/java/com/jero/modules/laws/club/vo/excel/LawsClubWorkingGroupFileExcel.java b/laws-modules/src/main/java/com/jero/modules/laws/club/vo/excel/LawsClubWorkingGroupFileExcel.java new file mode 100644 index 00000000..da0cfc18 --- /dev/null +++ b/laws-modules/src/main/java/com/jero/modules/laws/club/vo/excel/LawsClubWorkingGroupFileExcel.java @@ -0,0 +1,19 @@ +package com.jero.modules.laws.club.vo.excel; + +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import java.io.Serializable; + +@Data +public class LawsClubWorkingGroupFileExcel implements Serializable { + + @Excel(name = "社团名称", width = 20) + private String clubId; + + @Excel(name = "文件名称", width = 20) + private String fileId; + + @Excel(name = "文件类型", width = 20) + private String fileType; + +} diff --git a/laws-single-startup/src/main/resources/i18n/messages.properties b/laws-single-startup/src/main/resources/i18n/messages.properties index 097f36b8..ee476743 100644 --- a/laws-single-startup/src/main/resources/i18n/messages.properties +++ b/laws-single-startup/src/main/resources/i18n/messages.properties @@ -90,4 +90,5 @@ can_not_find_template_file=\u627E\u4E0D\u5230\u540D\u4E3A{0}\u7684\u6A21\u677F\u can_not_find_field=\u627E\u4E0D\u5230\u540D\u4E3A{0}\u7684\u5B57\u6BB5 tree.node.exists=\u5DF2\u5B58\u5728\u540D\u4E3A"{0}"\u7684\u8282\u70B9" node.exist.subsets=\u5f53\u524d\u8282\u70b9\u4e0b\u5b58\u5728\u5b50\u96c6 -club.already.exists=\u793e\u56e2\u540d\u79f0\u5df2\u5b58\u5728 \ No newline at end of file +club.already.exists=\u793e\u56e2\u540d\u79f0\u5df2\u5b58\u5728 +root.node.cannot.be.delete=\u6839\u8282\u70b9\u4e0d\u80fd\u5220\u9664 \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/i18n/messages_en.properties b/laws-single-startup/src/main/resources/i18n/messages_en.properties index 1a5b6e96..78fe66ba 100644 --- a/laws-single-startup/src/main/resources/i18n/messages_en.properties +++ b/laws-single-startup/src/main/resources/i18n/messages_en.properties @@ -109,4 +109,5 @@ tag.add.error.1=The attribute name is too long tree.node.exists=Name {0} tree node exists data.mismatch={0} Data mismatch node.exist.subsets=Node exist subsets -club.already.exists=Club already exists \ No newline at end of file +club.already.exists=Club already exists +root.node.cannot.be.delete=Root node cannot be delete \ No newline at end of file diff --git a/laws-single-startup/src/main/resources/i18n/messages_zh.properties b/laws-single-startup/src/main/resources/i18n/messages_zh.properties index f210c729..1befc456 100644 --- a/laws-single-startup/src/main/resources/i18n/messages_zh.properties +++ b/laws-single-startup/src/main/resources/i18n/messages_zh.properties @@ -108,4 +108,5 @@ tag.add.error.1=\u5C5E\u6027\u540D\u79F0\u592A\u957F tree.node.exists=\u5DF2\u5B58\u5728\u540D\u4E3A"{0}"\u7684\u8282\u70B9" data.mismatch={0}\u6570\u636E\u4E0D\u5339\u914D node.exist.subsets=\u5f53\u524d\u8282\u70b9\u4e0b\u5b58\u5728\u5b50\u96c6 -club.already.exists=\u793e\u56e2\u540d\u79f0\u5df2\u5b58\u5728 \ No newline at end of file +club.already.exists=\u793e\u56e2\u540d\u79f0\u5df2\u5b58\u5728 +root.node.cannot.be.delete=\u6839\u8282\u70b9\u4e0d\u80fd\u5220\u9664 \ No newline at end of file