diff --git a/jero-boot/db/蔚来标准sql/dev_third_record.sql b/jero-boot/db/蔚来标准sql/dev_third_record.sql index 6722f97f8..fa55336d4 100644 --- a/jero-boot/db/蔚来标准sql/dev_third_record.sql +++ b/jero-boot/db/蔚来标准sql/dev_third_record.sql @@ -494,3 +494,58 @@ INSERT INTO `laws_weilai`.`sys_dict_item` (`id`, `dict_id`, `item_text`, `item_v ALTER TABLE `laws_weilai`.`doc_translation` ADD COLUMN `serial_number` varchar(255) NULL COMMENT '编号' AFTER `buss_document_library_id`, ADD COLUMN `title` varchar(255) NULL COMMENT '标题' AFTER `serial_number`; + +-- 菜单管理 添加上报库按钮 2022-07-28 +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552487817415819266', '1552487412749369345', '自定义导出', NULL, NULL, NULL, NULL, 2, 'report:detail:export:custom', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:55:14', NULL, NULL, 0, 0, '1', 0, 'Custom Export'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552487616038895618', '1552487412749369345', '常规导出', NULL, NULL, NULL, NULL, 2, 'report:detail:export:normal', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:54:26', NULL, NULL, 0, 0, '1', 0, 'Normal Export'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552487412749369345', '1539429224550457346', '查看', NULL, NULL, NULL, NULL, 2, 'report:detail:list', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2022-07-28 10:53:38', NULL, NULL, 0, 0, '1', 0, 'Detail'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552487236076896257', '1539429224550457346', '导出历史', NULL, NULL, NULL, NULL, 2, 'params:report:history', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:52:56', NULL, NULL, 0, 0, '1', 0, 'Export History'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552484580440735746', '1539426795780005889', '批量删除', NULL, NULL, NULL, NULL, 2, 'report:exportTemplate:deleteBatch', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:42:22', NULL, NULL, 0, 0, '1', 0, 'Batch Delete'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552484462484324353', '1539426795780005889', '删除', NULL, NULL, NULL, NULL, 2, 'report:exportTemplate:delete', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:41:54', NULL, NULL, 0, 0, '1', 0, 'Delete'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552484292065558530', '1539426795780005889', '编辑', NULL, NULL, NULL, NULL, 2, 'report:exportTemplate:edit', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:41:14', NULL, NULL, 0, 0, '1', 0, 'Edit'); +INSERT INTO `laws_weilai`.`sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`, `menu_en`) VALUES ('1552484136976973825', '1539426795780005889', '新增', NULL, NULL, NULL, NULL, 2, 'report:exportTemplate:add', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-07-28 10:40:37', NULL, NULL, 0, 0, '1', 0, 'Add'); +UPDATE `laws_weilai`.`sys_permission` SET `parent_id` = '1516964175944798210', `name` = '上报库管理', `url` = '/escalationlibrary', `component` = 'parameter/escalationlibrary/index', `component_name` = NULL, `redirect` = NULL, `menu_type` = 1, `perms` = 'params:report:page', `perms_type` = '1', `sort_no` = 3.00, `always_show` = 0, `icon` = NULL, `is_route` = 1, `is_leaf` = 0, `keep_alive` = 0, `hidden` = 0, `description` = NULL, `create_by` = 'admin', `create_time` = '2022-06-22 10:05:03', `update_by` = 'admin', `update_time` = '2022-07-28 10:52:00', `del_flag` = 0, `rule_flag` = 0, `status` = '1', `internal_or_external` = 0, `menu_en` = 'Escalation library management' WHERE `id` = '1539429224550457346'; +UPDATE `laws_weilai`.`sys_permission` SET `parent_id` = '1516964175944798210', `name` = '参数导出模板管理', `url` = '/Parameterexport', `component` = 'parameter/parameterexport/index', `component_name` = NULL, `redirect` = NULL, `menu_type` = 1, `perms` = 'report:exportTemplate:page', `perms_type` = '1', `sort_no` = 2.00, `always_show` = 0, `icon` = NULL, `is_route` = 1, `is_leaf` = 0, `keep_alive` = 0, `hidden` = 0, `description` = NULL, `create_by` = 'admin', `create_time` = '2022-06-22 09:55:24', `update_by` = 'admin', `update_time` = '2022-07-28 10:40:02', `del_flag` = 0, `rule_flag` = 0, `status` = '1', `internal_or_external` = 0, `menu_en` = 'Parameter export template management' WHERE `id` = '1539426795780005889'; + +-- 角色表-增加对外报告管理员角色 2022-7-28 已同步生产环境 +INSERT INTO `sys_role` VALUES ('1552536424587862017', '对外报告管理员', 'ExternalReportsManager', '对外报告文件夹列表的管理员', 'admin', '2022-7-28 14:08:23', NULL, NULL, NULL, NULL); + +-- 菜单管理 添加对外报告文件夹管理按钮权限 2022-07-28 已同步生产环境 +INSERT INTO `sys_permission` VALUES ('1552182885208608770', '1549937961282908162', '对外报告文件夹管理', '', NULL, NULL, NULL, 2, 'externalReports:folder', '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2022-7-27 14:43:33', NULL, NULL, 0, 0, '1', 0, 'External Report Folder Management '); + +-- 对外报告文件夹表 2022-7-29 已同步生产环境 +DROP TABLE IF EXISTS `ext_repo_folder`; +CREATE TABLE `ext_repo_folder` ( + `id` varchar(36) NOT NULL, + `create_by` varchar(50) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建日期', + `update_by` varchar(50) DEFAULT NULL COMMENT '更新人', + `update_time` datetime DEFAULT NULL COMMENT '更新日期', + `sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门', + `folder_name` varchar(255) DEFAULT NULL COMMENT '文件夹名称', + `order_id` int(11) DEFAULT NULL COMMENT '文件夹排序', + `sup_folder` varchar(36) DEFAULT NULL COMMENT '所属文件夹', + `auth_view_ids_name` varchar(2000) DEFAULT NULL COMMENT '查看权限人员', + `auth_manage_ids_name` varchar(2000) DEFAULT NULL COMMENT '管理权限人员', + `auth_view_ids` varchar(2000) DEFAULT NULL COMMENT '查看权限人员id', + `auth_manage_ids` varchar(2000) DEFAULT NULL COMMENT '管理权限人员id', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +INSERT INTO `ext_repo_folder` VALUES ('1552846304994131970', 'admin', '2022-07-01 11:11:11', 'admin', '2022-11-11 11:11:11', 'A01', '文件夹', '1', 'root', '', '', '', ''); + +-- 对外报告数据表 2022-7-29 已同步生产环境 +DROP TABLE IF EXISTS `ext_repo_data`; +CREATE TABLE `ext_repo_data` ( + `id` varchar(36) NOT NULL, + `create_by` varchar(50) DEFAULT NULL COMMENT '创建人', + `create_time` datetime DEFAULT NULL COMMENT '创建日期', + `update_by` varchar(50) DEFAULT NULL COMMENT '更新人', + `update_time` datetime DEFAULT NULL COMMENT '更新日期', + `sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门', + `file_key` varchar(255) DEFAULT NULL COMMENT '文件标识', + `file_name` varchar(255) DEFAULT NULL COMMENT '文件名称', + `file_description` varchar(255) DEFAULT NULL COMMENT '文件说明', + `sup_folder` varchar(36) DEFAULT NULL COMMENT '所属文件夹', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java index b9a2956e3..15938c07a 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/enums/CollectManifestUserTypeEnum.java @@ -14,7 +14,7 @@ public enum CollectManifestUserTypeEnum { DRE("填写人", "Dre People","dre"), STUDIO("R&H Studio","R&H Studio","studio"), MANAGER("R&H Manager","R&H Manager","manager"), - ADMIN("系统管理员","Administrator","admin"), + ADMIN("系统","Administrator","admin"), GUEST("游客", "Guest","guest"); String name; diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java index 4456a79fb..91bfb3d99 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java @@ -676,6 +676,7 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl queryPageList(ParamsExportTemplateEO paramsExportTemplateEO, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @@ -111,7 +112,7 @@ public class ParamsExportTemplateEOController extends JeroController add(@Validated @RequestBody ParamsExportTemplateEO paramsExportTemplateEO) { boolean isSuccess = paramsExportTemplateEOService.add(paramsExportTemplateEO); if (isSuccess) { @@ -130,7 +131,7 @@ public class ParamsExportTemplateEOController extends JeroController edit(@Validated @RequestBody ParamsExportTemplateEO paramsExportTemplateEO) { boolean isSuccess = paramsExportTemplateEOService.editById(paramsExportTemplateEO); if (isSuccess) { @@ -149,7 +150,7 @@ public class ParamsExportTemplateEOController extends JeroController delete(@RequestParam(name="id",required=true) String id) { boolean isSuccess = paramsExportTemplateEOService.deleteById(id); if (isSuccess) { @@ -168,7 +169,7 @@ public class ParamsExportTemplateEOController extends JeroController deleteBatch(@RequestParam(name="ids",required=true) String ids) { boolean isSuccess = paramsExportTemplateEOService.deleteByIds(Arrays.asList(ids.split(","))); if (isSuccess) { diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java index 010580e3e..8906be54b 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportDetailEOController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -64,7 +65,7 @@ public class ParamsReportDetailEOController extends JeroController>> getHeader(@RequestParam(name = "paramsManifestId") String paramsManifestId, @RequestParam(name = "flag") String flag, @RequestParam(name = "cut") String cut) { @@ -80,7 +81,7 @@ public class ParamsReportDetailEOController extends JeroController queryList(ParamsReportDetailEO paramsReportDetailEO, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="100") Integer pageSize, @@ -105,7 +106,7 @@ public class ParamsReportDetailEOController extends JeroController getConfigLableList(ParamsReportDetailVO paramsReportDetailVO) { List> configLabelList = paramsReportDetailEOService.getConfigLabelList(paramsReportDetailVO); return Result.OK(configLabelList); @@ -136,7 +137,7 @@ public class ParamsReportDetailEOController extends JeroController getConfigLableListCustom(ParamsReportDetailVO paramsReportDetailVO) { List> configLabelList = paramsReportDetailEOService.getConfigLabelList(paramsReportDetailVO); return Result.OK(configLabelList); @@ -151,7 +152,7 @@ public class ParamsReportDetailEOController extends JeroController getTemplateLabelList() { List> templateLabelList = paramsReportDetailEOService.getTemplateLabelList(); return Result.OK(templateLabelList); @@ -159,7 +160,7 @@ public class ParamsReportDetailEOController extends JeroController getById(@RequestParam(name = "id") String id) { ParamsReportConfigEO paramsReportConfigEO = paramsReportConfigEOService.getById(id); return Result.OK(paramsReportConfigEO); diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportEOController.java index 1ba513ce4..7307250e9 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/controller/ParamsReportEOController.java @@ -13,6 +13,7 @@ import com.jero.modules.system.util.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -53,7 +54,7 @@ public class ParamsReportEOController extends JeroController queryPageList(ParamsReportEO paramsReportEO, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @@ -82,7 +83,7 @@ public class ParamsReportEOController extends JeroController exportHistoryPage(ParamsReportExportHistoryEO paramsReportExportHistoryEO, @RequestParam(name="cut") String cut, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/mapper/xml/ParamsReportDetailEOMapper.xml b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/mapper/xml/ParamsReportDetailEOMapper.xml index 06d76a401..6db9c4628 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/mapper/xml/ParamsReportDetailEOMapper.xml +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/mapper/xml/ParamsReportDetailEOMapper.xml @@ -43,10 +43,16 @@ AND cert_category LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.certCategory}),'%') - AND sdt LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.sdt}),'%') + AND sdt in + + #{item} + - AND dre LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.dre}),'%') + AND dre in + + #{item} + AND params_manifest_id = #{paramsReportDetailEO.paramsManifestId} diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java index 925a271be..551b001b1 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/report/service/IParamsReportDetailEOService.java @@ -53,6 +53,7 @@ public interface IParamsReportDetailEOService extends IService allParamsInfoList = queryForExportCustom(paramsReportDetailVO); HashMap params = (HashMap) allParamsInfoList.get(0); + List> imgListAll = (List>) allParamsInfoList.get(1).get("imgListAll"); String templateUrl = ""; ParamsExportTemplateEO paramsExportTemplateEO = paramsExportTemplateEOService.getById(paramsReportDetailVO.getExportTemplateId()); @@ -820,7 +824,14 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl queryWrapper = QueryGenerator.initQueryWrapper(extRepoData, req.getParameterMap()); - Page page = new Page(pageNo, pageSize); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Page page = new Page<>(pageNo, pageSize); // 文件名称模糊查询 String fileName = req.getParameter("fileName"); if (StringUtils.isNotBlank(fileName)) { - queryWrapper.like("fileName", fileName); + queryWrapper.like(ExtRepoData::getFileName, fileName); } - - // 创建人模糊查询 + // 上传人模糊查询 String createBy = req.getParameter("createBy"); - if (StringUtils.isNotBlank(fileName)) { - queryWrapper.like("createBy", createBy); + if (StringUtils.isNotBlank(createBy)) { + queryWrapper.like(ExtRepoData::getCreateBy, createBy); } + // 更新时间查询 + String createTime = req.getParameter("time"); + if (StringUtils.isNotBlank(createTime)) { + String[] createTimeArr = createTime.split(","); + if (createTimeArr.length >= 2) { + queryWrapper.between(ExtRepoData::getCreateTime, createTimeArr[0], createTimeArr[1]); + } + } + queryWrapper.eq(ExtRepoData::getSupFolder, extRepoData.getSupFolder()); IPage pageList = extRepoDataService.page(page, queryWrapper); - log.info("查询当前页:" + pageList.getCurrent()); - log.info("查询当前页数量:" + pageList.getSize()); - log.info("查询结果数量:" + pageList.getRecords().size()); - log.info("数据总数:" + pageList.getTotal()); ExtRepoDataPage res = new ExtRepoDataPage(extRepoFolderService.haveManageAuth(extRepoData.getSupFolder()), pageList); return Result.OK(res); } @@ -105,15 +114,26 @@ public class ExtRepoDataController extends JeroController add(@Validated @RequestBody ExtRepoData extRepoData) { + public Result add(@Validated @RequestBody ExtRepoData extRepoData, + @RequestParam("cut") String cut) { if (extRepoFolderService.haveManageAuth(extRepoData.getSupFolder())) { - extRepoDataService.add(extRepoData); - return Result.OK("添加成功!"); + log.info("对外报告数据表收到文件添加请求,开始处理文件:【" + sdf.format(new Date()) + "】"); + int res = extRepoDataService.add(extRepoData); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("添加成功:" + res + "条数据!"); + } else { + return Result.OK("success:" + res + "data!"); + } } else { - return Result.error("没有权限!"); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } } } + /** * 编辑 * @@ -123,14 +143,24 @@ public class ExtRepoDataController extends JeroController edit(@Validated @RequestBody ExtRepoData extRepoData) { + public Result edit(@Validated @RequestBody ExtRepoData extRepoData, + @RequestParam("cut") String cut) { ExtRepoData erd = extRepoDataService.queryById(extRepoData.getId()); - if (extRepoFolderService.haveManageAuth(erd.getSupFolder())) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) { extRepoData.setSupFolder(erd.getSupFolder()); extRepoDataService.editById(extRepoData); - return Result.OK("编辑成功!"); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("添加成功!"); + } else { + return Result.OK("success!"); + } } else { - return Result.error("没有权限!"); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } } } @@ -143,14 +173,27 @@ public class ExtRepoDataController extends JeroController delete(@RequestParam(name = "id", required = true) String id) { + public Result delete(@RequestParam("id") String id, + @RequestParam("cut") String cut) { ExtRepoData erd = extRepoDataService.queryById(id); - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if (erd.getCreateBy().equals(sysUser.getUsername())) { - extRepoDataService.deleteById(id); - return Result.OK("删除成功!"); + if (null != erd) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + if (extRepoFolderService.isManager() || sysUser.getUsername().equals(erd.getCreateBy())) { + extRepoDataService.deleteById(id); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("删除成功!"); + } else { + return Result.OK("Delete success!"); + } + } else { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } + } } else { - return Result.error("没有权限!"); + return Result.error("Delete Error!"); } } @@ -163,17 +206,26 @@ public class ExtRepoDataController extends JeroController deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + public Result deleteBatch(@RequestParam("ids") String ids, + @RequestParam("cut") String cut) { LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); List idsList = Arrays.asList(ids.split(",")); for (String id : idsList) { ExtRepoData erd = extRepoDataService.queryById(id); - if (null != erd && !erd.getCreateBy().equals(sysUser.getUsername())) { - return Result.OK("没有权限!"); + if (null != erd && !extRepoFolderService.isManager() && !sysUser.getUsername().equals(erd.getCreateBy())) { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } } } this.extRepoDataService.deleteByIds(idsList); - return Result.OK("批量删除成功!"); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("删除成功!"); + } else { + return Result.OK("Delete success!"); + } } /** diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java index 67bc95ced..8c0caae2c 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java @@ -2,6 +2,7 @@ package com.jero.modules.extRepo.controller; import com.jero.common.api.vo.Result; import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.constant.enums.CutEnum; import com.jero.common.system.base.controller.JeroController; import com.jero.modules.extRepo.entity.ERFTreeData; import com.jero.modules.extRepo.entity.ExtRepoFolder; @@ -52,9 +53,22 @@ public class ExtRepoFolderController extends JeroController add(@Validated @RequestBody ExtRepoFolder extRepoFolder) { - extRepoFolderService.add(extRepoFolder); - return Result.OK("添加成功!"); + public Result add(@Validated @RequestBody ExtRepoFolder extRepoFolder, + @RequestParam("cut") String cut) { + if (extRepoFolderService.haveManageAuth(extRepoFolder.getSupFolder())) { + extRepoFolderService.add(extRepoFolder); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("添加成功!"); + } else { + return Result.OK("success!"); + } + } else { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } + } } /** @@ -66,9 +80,22 @@ public class ExtRepoFolderController extends JeroController edit(@Validated @RequestBody ExtRepoFolder extRepoFolder) { - extRepoFolderService.editById(extRepoFolder); - return Result.OK("编辑成功!"); + public Result edit(@Validated @RequestBody ExtRepoFolder extRepoFolder, + @RequestParam("cut") String cut) { + if (extRepoFolderService.haveManageAuth(extRepoFolder.getId())) { + extRepoFolderService.editById(extRepoFolder); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("编辑成功!"); + } else { + return Result.OK("success!"); + } + } else { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } + } } /** @@ -80,9 +107,31 @@ public class ExtRepoFolderController extends JeroController delete(@RequestParam(name = "id", required = true) String id) { - extRepoFolderService.deleteById(id); - return Result.OK("删除成功!"); + public Result delete(@RequestParam(name = "id", required = true) String id, + @RequestParam("cut") String cut) { + if (extRepoFolderService.haveManageAuth(id)) { + List resList = extRepoFolderService.getListBySupFolder(id); + if (resList.isEmpty()) { + extRepoFolderService.deleteById(id); + } else { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("请先删除子文件夹!"); + } else { + return Result.error("Please Delete Subfolder First!"); + } + } + } else { + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("没有权限!"); + } else { + return Result.error("No Permission!"); + } + } + if (CutEnum.CN.getValue().equals(cut)) { + return Result.OK("删除成功!"); + } else { + return Result.OK("success!"); + } } /** @@ -94,10 +143,15 @@ public class ExtRepoFolderController extends JeroController queryById(@RequestParam(name = "id", required = true) String id) { + public Result queryById(@RequestParam(name = "id", required = true) String id, + @RequestParam("cut") String cut) { ExtRepoFolder extRepoFolder = extRepoFolderService.queryById(id); if (extRepoFolder == null) { - return Result.error("未找到对应数据"); + if (CutEnum.CN.getValue().equals(cut)) { + return Result.error("未找到对应数据"); + } else { + return Result.error("No Data!"); + } } return Result.OK(extRepoFolder); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java index a03327422..d9d65aecd 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java @@ -46,12 +46,12 @@ public class ERFTreeData implements Comparable { /** * 查看权限人员 */ - private String authView = ""; + private String authViewIdsName = ""; /** * 管理权限人员 */ - private String authManage = ""; + private String authManageIdsName = ""; /** * 查看权限人员id @@ -135,20 +135,20 @@ public class ERFTreeData implements Comparable { this.folderName = folderName; } - public String getAuthView() { - return authView; + public String getAuthViewIdsName() { + return authViewIdsName; } - public void setAuthView(String authView) { - this.authView = authView; + public void setAuthViewIdsName(String authViewIdsName) { + this.authViewIdsName = authViewIdsName; } - public String getAuthManage() { - return authManage; + public String getAuthManageIdsName() { + return authManageIdsName; } - public void setAuthManage(String authManage) { - this.authManage = authManage; + public void setAuthManageIdsName(String authManageIdsName) { + this.authManageIdsName = authManageIdsName; } public String getAuthViewIds() { diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java index b6915fc50..972a8010d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java @@ -76,12 +76,12 @@ public class ExtRepoFolder implements Serializable { /**查看权限人员*/ @Excel(name = "查看权限人员", width = 15) @ApiModelProperty(value = "查看权限人员") - private String authView; + private String authViewIdsName; /**管理权限人员*/ @Excel(name = "管理权限人员", width = 15) @ApiModelProperty(value = "管理权限人员") - private String authManage; + private String authManageIdsName; /**查看权限人员id*/ @Excel(name = "查看权限人员id", width = 15) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/enums/ExtRepoMamagerRoleIdEnum.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/enums/ExtRepoMamagerRoleIdEnum.java new file mode 100644 index 000000000..1033458c9 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/enums/ExtRepoMamagerRoleIdEnum.java @@ -0,0 +1,72 @@ +package com.jero.modules.extRepo.enums; + +import java.util.ArrayList; +import java.util.List; + +public enum ExtRepoMamagerRoleIdEnum { + MANAGER_ID("系统管理员", "Administrator", "admin", "f6817f48af4fb3af11b9e8bf182f618b", 1), + ERMANAGER_ID("对外报告管理员", "ExternalReportsManager", "ExternalReportsManager", "1552536424587862017", 2); + + String name; + String enName; + String value; + String id; + Integer order; + + ExtRepoMamagerRoleIdEnum(String name, String enName, String value, String id, Integer order) { + this.name = name; + this.enName = enName; + this.value = value; + this.id = id; + this.order = order; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEnName() { + return enName; + } + + public void setEnName(String enName) { + this.enName = enName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getOrder() { + return order; + } + + public void setOrder(Integer order) { + this.order = order; + } + + public static List getIdList() { + List idList = new ArrayList<>(); + ExtRepoMamagerRoleIdEnum[] values = values(); + for (ExtRepoMamagerRoleIdEnum ermriEnum : values) { + idList.add(ermriEnum.getId()); + } + return idList; + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml index a742f17b9..3ff05664c 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml @@ -11,9 +11,9 @@ - - - - + + + + \ No newline at end of file diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoDataService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoDataService.java index bc9bfb91a..cb141bd4e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoDataService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoDataService.java @@ -8,55 +8,55 @@ import java.util.List; /** * @Description: 对外报告数据表 * @Author: jero-boot - * @Date: 2022-07-25 + * @Date: 2022-07-25 * @Version: V1.0 */ public interface IExtRepoDataService extends IService { - /** - * 保存 - * - * @param extRepoData - * @return - */ - void add(ExtRepoData extRepoData); + /** + * 保存 + * + * @param extRepoData + * @return + */ + int add(ExtRepoData extRepoData); - /** - * 更新 - * - * @param extRepoData - * @return - */ + /** + * 更新 + * + * @param extRepoData + * @return + */ void editById(ExtRepoData extRepoData); - /** - * 通过id删除 - * - * @param id - * @return - */ + /** + * 通过id删除 + * + * @param id + * @return + */ void deleteById(String id); - /** - * 批量删除 - * - * @param ids - * @return - */ + /** + * 批量删除 + * + * @param ids + * @return + */ void deleteByIds(List ids); - /** - * 通过id查询 - * - * @param id - * @return - */ + /** + * 通过id查询 + * + * @param id + * @return + */ ExtRepoData queryById(String id); /** - * 列表查询 - * - * @return - */ + * 列表查询 + * + * @return + */ List queryList(); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java index d9be6458b..de4d4da8f 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java @@ -68,4 +68,27 @@ public interface IExtRepoFolderService extends IService { * @return */ boolean haveManageAuth(String folderId); + + /** + * 是否有查看权限 + * + * @param folderId + * @return + */ + boolean haveViewAuth(String folderId); + + /** + * 是否管理员 + * + * @return + */ + boolean isManager(); + + /** + * 查找子文件夹 + * + * @param supFolder + * @return + */ + List getListBySupFolder(String supFolder); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java index 4f07b2182..58bbf73cb 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java @@ -1,11 +1,14 @@ package com.jero.modules.extRepo.service.impl; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.jero.common.system.vo.LoginUser; import com.jero.modules.extRepo.entity.ExtRepoData; import com.jero.modules.extRepo.mapper.ExtRepoDataMapper; import com.jero.modules.extRepo.service.IExtRepoDataService; -import org.apache.shiro.SecurityUtils; +import com.jero.modules.oss.entity.OSSFile; +import com.jero.modules.oss.service.IOSSFileService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; @@ -14,80 +17,111 @@ import java.util.List; /** * @Description: 对外报告数据表 * @Author: jero-boot - * @Date: 2022-07-25 + * @Date: 2022-07-25 * @Version: V1.0 */ @Service public class ExtRepoDataServiceImpl extends ServiceImpl implements IExtRepoDataService { - /** - * 保存 - * - * @param extRepoData - * @return - */ - @Override - public void add(ExtRepoData extRepoData) { + @Autowired + private IOSSFileService ossFileService; + + /** + * 保存 + * + * @param extRepoData + * @return + */ + @Override + public int add(ExtRepoData extRepoData) { + //返回成功数量 + int res = 0; Date now = new Date(); - extRepoData.setCreateTime(now); - extRepoData.setUpdateTime(now); - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - extRepoData.setUpdateBy(sysUser.getUsername()); - save(extRepoData); + // 根据fileKey查找文件 + String fileIds = extRepoData.getFileKey(); + if (StringUtils.isNotBlank(fileIds)) { + String[] fileIdsArr = fileIds.split(","); + for (String fid : fileIdsArr) { + OSSFile ossFile = ossFileService.getById(fid); + if (ObjectUtil.isNotEmpty(ossFile)) { + String fileName = ossFile.getFileName(); + extRepoData.setFileName(fileName); + ExtRepoData erd = extRepoDataCopy(extRepoData, fid, now); + save(erd); + res++; + } + } + } + return res; } - /** - * 更新 - * - * @param extRepoData - * @return - */ - @Override + private ExtRepoData extRepoDataCopy(ExtRepoData extRepoData, String key, Date now) { + ExtRepoData res = new ExtRepoData(); + res.setId(extRepoData.getId()); + res.setCreateBy(extRepoData.getCreateBy()); + res.setCreateTime(now); + res.setUpdateBy(extRepoData.getUpdateBy()); + res.setUpdateTime(now); + res.setSysOrgCode(extRepoData.getSysOrgCode()); + res.setFileKey(key); + res.setFileName(extRepoData.getFileName()); + res.setFileDescription(extRepoData.getFileDescription()); + res.setSupFolder(extRepoData.getSupFolder()); + return res; + } + + /** + * 更新 + * + * @param extRepoData + * @return + */ + @Override public void editById(ExtRepoData extRepoData) { - Date now = new Date(); + Date now = new Date(); extRepoData.setUpdateTime(now); - saveOrUpdate(extRepoData); + saveOrUpdate(extRepoData); } - /** - * 通过id删除 - * - * @param id - * @return - */ - @Override + /** + * 通过id删除 + * + * @param id + * @return + */ + @Override public void deleteById(String id) { removeById(id); } - /** - * 批量删除 - * - * @param ids - * @return - */ - @Override + /** + * 批量删除 + * + * @param ids + * @return + */ + @Override public void deleteByIds(List ids) { removeByIds(ids); } - /** - * 通过id查询 - * - * @param id - * @return - */ - @Override + /** + * 通过id查询 + * + * @param id + * @return + */ + @Override public ExtRepoData queryById(String id) { return getById(id); } /** - * 列表查询 - * - * @return - */ - @Override + * 列表查询 + * + * @return + */ + @Override public List queryList() { return list(); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java index 6a840e8cf..b6dffeed7 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoFolderServiceImpl.java @@ -1,5 +1,6 @@ package com.jero.modules.extRepo.service.impl; +import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.exception.JeroBootException; @@ -7,13 +8,18 @@ import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.vo.LoginUser; import com.jero.modules.extRepo.entity.ERFTreeData; import com.jero.modules.extRepo.entity.ExtRepoFolder; +import com.jero.modules.extRepo.enums.ExtRepoMamagerRoleIdEnum; import com.jero.modules.extRepo.mapper.ExtRepoFolderMapper; import com.jero.modules.extRepo.service.IExtRepoFolderService; +import com.jero.modules.system.entity.SysUserRole; +import com.jero.modules.system.service.ISysUserRoleService; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; /** * @Description: 对外报告文件夹表 @@ -23,11 +29,12 @@ import java.util.*; */ @Service public class ExtRepoFolderServiceImpl extends ServiceImpl implements IExtRepoFolderService { - + @Autowired + private ISysUserRoleService sysUserRoleService; /** * 一级文件夹的supFolder统一存root */ - private static String superFolder = "root"; + private static final String superFolder = "root"; /** * 保存 @@ -45,6 +52,11 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl getListBySupFolder(String supFolder) { + @Override + public List getListBySupFolder(String supFolder) { ExtRepoFolder erf = new ExtRepoFolder(); erf.setSupFolder(supFolder); QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(erf, new HashMap<>()); @@ -102,16 +115,16 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl authManage_orig = getAuthMap(erf_orig.getAuthManage(), erf_orig.getAuthManageIds()); - Map authManage_new = getAuthMap(erf_new.getAuthManage(), erf_new.getAuthManageIds()); + Map authManage_orig = getAuthMap(erf_orig.getAuthManageIdsName(), erf_orig.getAuthManageIds()); + Map authManage_new = getAuthMap(erf_new.getAuthManageIdsName(), erf_new.getAuthManageIds()); //增加管理权限的人 Map addManageRole = getDefMap(authManage_new, authManage_orig); //删除管理权限的人 Map delManageRole = getDefMap(authManage_orig, authManage_new); //查看权限 - Map authView_orig = getAuthMap(erf_orig.getAuthView(), erf_orig.getAuthViewIds()); - Map authView_new = getAuthMap(erf_new.getAuthView(), erf_new.getAuthViewIds()); + Map authView_orig = getAuthMap(erf_orig.getAuthViewIdsName(), erf_orig.getAuthViewIds()); + Map authView_new = getAuthMap(erf_new.getAuthViewIdsName(), erf_new.getAuthViewIds()); //增加查看权限的人 Map addViewRole = getDefMap(authView_new, authView_orig); //删除查看权限的人 @@ -122,8 +135,8 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl updateFolder = new ArrayList(); for (ExtRepoFolder erf : allSubFolder) { boolean isChange = false; - Map authManage_erf = getAuthMap(erf.getAuthManage(), erf.getAuthManageIds()); - Map authView_erf = getAuthMap(erf.getAuthView(), erf.getAuthViewIds()); + Map authManage_erf = getAuthMap(erf.getAuthManageIdsName(), erf.getAuthManageIds()); + Map authView_erf = getAuthMap(erf.getAuthViewIdsName(), erf.getAuthViewIds()); for (String add : addManageRole.keySet()) { if (!authManage_erf.keySet().contains(add)) { authManage_erf.put(add, addManageRole.get(add)); @@ -131,9 +144,12 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl resList = getListBySupFolder(id); - if (resList.isEmpty()) { - removeById(id); - } + removeById(id); } catch (Exception ex) { log.error("删除对外报告文件夹失败:" + ex.getMessage()); throw new JeroBootException("删除文件夹失败!"); @@ -262,11 +275,11 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl getStringList(String listStr) { List res = new ArrayList(); if (null != listStr) { @@ -311,4 +307,61 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl userRoles = sysUserRoleService.list(new QueryWrapper().lambda().eq(SysUserRole::getUserId, loginUser.getId())); // 查询用户所有角色 + List userRoleIds = new ArrayList<>(); // 用户管理员/对外报告管理员 + if (CollectionUtil.isNotEmpty(userRoles)) { + List roleIdList = ExtRepoMamagerRoleIdEnum.getIdList(); + List userRoleIdList = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); + userRoleIds = roleIdList.stream().filter(e -> userRoleIdList.contains(e)).collect(Collectors.toList()); + return !CollectionUtil.isEmpty(userRoleIds); + } + return false; + } + + /** + * 是否有管理权限 + * + * @param folderId + * @return + */ + @Override + public boolean haveManageAuth(String folderId) { + boolean res = false; + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + res = isManager(); + ExtRepoFolder erf = queryById(folderId); + if (null != erf) { + res = res || getStringList(erf.getAuthManageIds()).contains(sysUser.getId()); + } + return res; + } + + /** + * 是否有查看权限 + * + * @param folderId + * @return + */ + public boolean haveViewAuth(String folderId) { + boolean res = false; + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + res = isManager(); + ExtRepoFolder erf = queryById(folderId); + if (null != erf) { + res = res || getStringList(erf.getAuthManageIds()).contains(sysUser.getId()) + || getStringList(erf.getAuthViewIds()).contains(sysUser.getId()); + } + return false; + + } + } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/CellReference.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/CellReference.java new file mode 100644 index 000000000..fc67eb2d9 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/CellReference.java @@ -0,0 +1,112 @@ +/* + * Copyright 2013 Haulmont + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.jero.modules.project.util; + +import org.apache.commons.lang3.ObjectUtils; +import org.xlsx4j.sml.Cell; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class CellReference implements Comparable { + public static final Pattern CELL_COORDINATES_PATTERN = Pattern.compile("([A-z]+)([0-9]+)"); + private int column; + private int row; + private String sheet; + + public CellReference(String sheet, int row, int column) { + this.column = column; + this.row = row; + this.sheet = sheet; + } + + public CellReference(String sheet, String cellRef) { + Matcher matcher = CELL_COORDINATES_PATTERN.matcher(cellRef); + if (matcher.find()) { + column = XlsxUtils.getNumberFromColumnReference(matcher.group(1)); + row = Integer.valueOf(matcher.group(2)); + this.sheet = sheet; + } else { + throw new RuntimeException(String.format("Wrong cell %s", cellRef)); + } + } + + public CellReference(String sheet, Cell cell) { + this(sheet, cell.getR()); + } + + public CellReference shift(int downShift, int rightShift) { + row += downShift; + column += rightShift; + return this; + } + + public CellReference move(int row, int col) { + this.row = row; + this.column = col; + return this; + } + + public String toReference() { + return XlsxUtils.getColumnReferenceFromNumber(getColumn()) + getRow(); + } + + public int getColumn() { + return column; + } + + public int getRow() { + return row; + } + + public String getSheet() { + return sheet; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CellReference that = (CellReference) o; + + if (column != that.column) return false; + if (row != that.row) return false; + if (sheet != null ? !sheet.equals(that.sheet) : that.sheet != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = column; + result = 31 * result + row; + result = 31 * result + (sheet != null ? sheet.hashCode() : 0); + return result; + } + + @Override + public int compareTo(Object o) { + if (o instanceof CellReference) { + int rows = ObjectUtils.compare(row, ((CellReference) o).row); + int columns = ObjectUtils.compare(column, ((CellReference) o).column); + return rows != 0 ? rows : columns; + + } else { + throw new IllegalArgumentException("Could not compare with " + o); + } + } +} \ No newline at end of file diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/ExcelUtil.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/ExcelUtil.java index ca8984ee3..ab8fadb14 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/ExcelUtil.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/ExcelUtil.java @@ -1,50 +1,384 @@ package com.jero.modules.project.util; +import cn.hutool.core.util.ObjectUtil; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.docx4j.XmlUtils; import org.docx4j.dml.*; import org.docx4j.dml.spreadsheetdrawing.*; import org.docx4j.openpackaging.io.SaveToZipFile; +import org.docx4j.openpackaging.io3.stores.PartStore; import org.docx4j.openpackaging.packages.SpreadsheetMLPackage; import org.docx4j.openpackaging.parts.DrawingML.Drawing; +import org.docx4j.openpackaging.parts.Part; import org.docx4j.openpackaging.parts.PartName; +import org.docx4j.openpackaging.parts.Parts; import org.docx4j.openpackaging.parts.SpreadsheetML.JaxbSmlPart; +import org.docx4j.openpackaging.parts.SpreadsheetML.WorkbookPart; import org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart; import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage; +import org.docx4j.openpackaging.parts.relationships.Namespaces; +import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; import org.docx4j.relationships.Relationship; +import org.xlsx4j.sml.Cell; +import org.xlsx4j.sml.SheetData; +import org.xlsx4j.sml.Worksheet; +import javax.imageio.ImageIO; import javax.xml.bind.JAXBException; -import javax.xml.bind.util.JAXBResult; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamSource; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; -import java.io.OutputStream; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +@Slf4j public class ExcelUtil { public static void main(String[] args) throws Exception { String inputfilepath = "D:\\text\\072001自定义模板.xlsx"; SpreadsheetMLPackage pkg = SpreadsheetMLPackage.load(new File(inputfilepath)); - WorksheetPart worksheet = pkg.getWorkbookPart().getWorksheet(0); - JAXBResult result = XmlUtils.prepareJAXBResult(worksheet.getJAXBContext()); +// .createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1); + JaxbSmlPart smlPart = (JaxbSmlPart)pkg.getParts().get(new PartName("/xl/sharedStrings.xml")); // 获取所有sheet中的文本 + Parts parts = pkg.getParts(); + System.out.println("mmmmmmm"); + + /*JAXBResult result = XmlUtils.prepareJAXBResult(worksheet.getJAXBContext()); Map transformParameters = new HashMap<>(); transformParameters.put("NIO 07200103", "dfasdfas"); - -// InputStream smlPart = pkg.getParts().get(new PartName("/xl/sharedStrings.xml")); // 获取所有sheet - Source xsltSource = new StreamSource(new File("D:\\text\\sharedStrings.xml")); TransformerFactory transFact = TransformerFactory.newInstance(); Templates cachedXSLT = transFact.newTemplates(xsltSource); - - pkg.getWorkbookPart().transform(cachedXSLT,transformParameters,result); + pkg.getWorkbookPart().transform(cachedXSLT,transformParameters,result);*/ // variableReplace(); // xlsx4JAddImage(); + + WorkbookPart workbookPart = pkg.getWorkbookPart(); + WorksheetPart sheet = workbookPart.getWorksheet(0); + Worksheet ws = sheet.getContents(); + SheetData data = ws.getSheetData(); + System.out.println("mmmmmmm"); + } + + public static void replacePictureBatchPOI(Workbook workbook, SpreadsheetMLPackage pkg, List> imgListAll) throws Exception { + //获取全部sheet页中表格 + Sheet sheet=null; + int partNameNum = 0; + for (int i = 0; i < workbook.getNumberOfSheets(); i++) {//获取每个Sheet表 + sheet = workbook.getSheetAt(i); + WorksheetPart worksheetPart = (WorksheetPart) pkg.getParts().get(new PartName("/xl/worksheets/" + sheet.getSheetName().toLowerCase() + ".xml")); + partNameNum++; + + //获得数据的总行数 + int totalRowNum = sheet.getLastRowNum(); + + //获得所有数据 + for (int x = 0; x < totalRowNum; x++) { + //获得第x行对象 + Row row = sheet.getRow(x); + if (!(row == null)) { + //获得总列数 + int cellLength = row.getLastCellNum(); + //如果x行里的所有单元格 + for (int y = 0; y < cellLength; y++) { + + org.apache.poi.ss.usermodel.Cell cell = row.getCell(y); + if(ObjectUtil.isNull(cell)) { + continue; + } + String cellValue = cell.getStringCellValue(); + + for (Map imgMap : imgListAll) { + String key = (String) imgMap.get("key"); + String text = (String) imgMap.get("text"); + byte[] bytes = (byte[]) imgMap.get("bytes"); + if (("${" + key + "}").equals(cellValue)) { + putImagePOI(worksheetPart, pkg, cell, bytes, sheet.getSheetName().toLowerCase(), String.valueOf(partNameNum)); + } + } + } + } + } + + } + } + + public static void replacePictureBatch(SpreadsheetMLPackage pkg,List> imgListAll) throws Exception { + Parts parts = pkg.getParts(); + Map map = parts.getParts(); + + for (Map.Entry partMap : map.entrySet()) { + int partNameNum = 0; + if (partMap.getValue() instanceof WorksheetPart) { + String partName = String.valueOf(partMap.getKey()); + WorksheetPart worksheetPart = (WorksheetPart) partMap.getValue(); + SheetData sheetData = worksheetPart.getJaxbElement().getSheetData(); + partNameNum++; + + for (org.xlsx4j.sml.Row r : sheetData.getRow() ) { // 循环表格行 + for (Cell c : r.getC()) { // 循环表格单元格 + Object cellValue = c.getV(); // 获取单元格数内容 + + if (cellValue instanceof String) { + for (Map imgMap : imgListAll) { + String key = (String) imgMap.get("key"); + String text = (String) imgMap.get("text"); + byte[] bytes = (byte[]) imgMap.get("bytes"); + + if (("${" + key + "}").equals(cellValue)) { + c.setV(text); + putImage(worksheetPart, pkg, c, bytes, partName, String.valueOf(partNameNum)); + } + } + } + } + } + } + } + } + + private static void putImagePOI(WorksheetPart worksheetPart, SpreadsheetMLPackage pkg, org.apache.poi.ss.usermodel.Cell newCell, byte[] bytes, String sheetName, String partName) throws Exception { + ByteArrayInputStream in = new ByteArrayInputStream(bytes); + BufferedImage bufferedImage = ImageIO.read(in); + BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, worksheetPart, bytes); + String imagePartName = imagePart.getPartName().getName(); + + PartName drawingPart = new PartName(worksheetPart.getPartName().getName().replace("worksheets/" + sheetName, "drawings/drawing" + partName)); + Drawing drawing = (Drawing) pkg.getParts().get(drawingPart); + int currentId = 0; + if (drawing == null) { + drawing = new Drawing(drawingPart); + drawing.setContents(new org.docx4j.dml.spreadsheetdrawing.CTDrawing()); + Relationship relationship = worksheetPart.addTargetPart(drawing); + org.xlsx4j.sml.CTDrawing smlDrawing = new org.xlsx4j.sml.CTDrawing(); + smlDrawing.setId(relationship.getId()); + smlDrawing.setParent(worksheetPart.getContents()); + worksheetPart.getContents().setDrawing(smlDrawing); + } else { + currentId = drawing.getContents().getEGAnchor().size(); + } + + CTTwoCellAnchor anchor = new CTTwoCellAnchor(); + anchor.setFrom(new CTMarker()); + anchor.getFrom().setCol(newCell.getColumnIndex()); + anchor.getFrom().setRow(newCell.getRowIndex()); + anchor.setTo(new CTMarker()); + anchor.getTo().setCol(newCell.getColumnIndex() + 1); + anchor.getTo().setRow(newCell.getRowIndex() + 1); + + CTPicture picture = new CTPicture(); + + CTBlipFillProperties blipFillProperties = new CTBlipFillProperties(); + blipFillProperties.setStretch(new CTStretchInfoProperties()); + blipFillProperties.getStretch().setFillRect(new CTRelativeRect()); + blipFillProperties.setBlip(new CTBlip()); + blipFillProperties.getBlip().setEmbed("rId" + (currentId + 1)); + blipFillProperties.getBlip().setCstate(STBlipCompression.NONE); + + picture.setBlipFill(blipFillProperties); + + CTNonVisualDrawingProps nonVisualDrawingProps = new CTNonVisualDrawingProps(); + nonVisualDrawingProps.setId(currentId + 2); + nonVisualDrawingProps.setName(imagePartName.substring(imagePartName.lastIndexOf("/") + 1)); + nonVisualDrawingProps.setDescr(nonVisualDrawingProps.getName()); + + CTNonVisualPictureProperties nonVisualPictureProperties = new CTNonVisualPictureProperties(); + nonVisualPictureProperties.setPicLocks(new CTPictureLocking()); + nonVisualPictureProperties.getPicLocks().setNoChangeAspect(true); + CTPictureNonVisual nonVisualPicture = new CTPictureNonVisual(); + + nonVisualPicture.setCNvPr(nonVisualDrawingProps); + nonVisualPicture.setCNvPicPr(nonVisualPictureProperties); + + picture.setNvPicPr(nonVisualPicture); + + CTShapeProperties shapeProperties = new CTShapeProperties(); + CTTransform2D transform2D = new CTTransform2D(); + transform2D.setOff(new CTPoint2D()); + transform2D.setExt(new CTPositiveSize2D()); + shapeProperties.setXfrm(transform2D); + shapeProperties.setPrstGeom(new CTPresetGeometry2D()); + shapeProperties.getPrstGeom().setPrst(STShapeType.RECT); + shapeProperties.getPrstGeom().setAvLst(new CTGeomGuideList()); + CTPositiveSize2D positivesize2D = new CTPositiveSize2D(); + transform2D.setExt(positivesize2D); + positivesize2D.setCx( XlsxUtils.convertPxToEmu(bufferedImage.getWidth()) ); + positivesize2D.setCy( XlsxUtils.convertPxToEmu(bufferedImage.getHeight()) ); + + picture.setSpPr(shapeProperties); + + anchor.setPic(picture); + anchor.setClientData(new CTAnchorClientData()); + anchor.setEditAs(STEditAs.ONE_CELL); + drawing.getContents().getEGAnchor().add(anchor); + + Relationship rel = new Relationship(); + rel.setId("rId" + (currentId + 1)); + rel.setType(Namespaces.IMAGE); + rel.setTarget(imagePartName); + + drawing.getRelationshipsPart().addRelationship(rel); + RelationshipsPart relPart = drawing.getRelationshipsPart(); + pkg.getParts().remove(relPart.getPartName()); + pkg.getParts().put(relPart); + pkg.getParts().remove(drawing.getPartName()); + pkg.getParts().put(drawing); + } + + private static void putImage(WorksheetPart worksheetPart, SpreadsheetMLPackage pkg, Cell newCell, byte[] bytes, String sheetName, String partName) throws Exception { + ByteArrayInputStream in = new ByteArrayInputStream(bytes); + BufferedImage bufferedImage = ImageIO.read(in); + + BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, worksheetPart, bytes); + CTTwoCellAnchor anchor = new CTTwoCellAnchor(); + anchor.setFrom(new CTMarker()); + CellReference cellReference = new CellReference("", newCell.getR()); + anchor.getFrom().setCol(cellReference.getColumn() - 1); + anchor.getFrom().setRow(cellReference.getRow() - 1); + anchor.setTo(new CTMarker()); + anchor.getTo().setCol(cellReference.getColumn()); + anchor.getTo().setRow(cellReference.getRow()); + + PartName drawingPart = new PartName(worksheetPart.getPartName().getName().replace("worksheets/" + sheetName, "drawings/drawing" + partName)); + String imagePartName = imagePart.getPartName().getName(); + Drawing drawing = (Drawing) pkg.getParts().get(drawingPart); + int currentId = 0; + if (drawing == null) { + drawing = new Drawing(drawingPart); + drawing.setContents(new org.docx4j.dml.spreadsheetdrawing.CTDrawing()); + Relationship relationship = worksheetPart.addTargetPart(drawing); + org.xlsx4j.sml.CTDrawing smlDrawing = new org.xlsx4j.sml.CTDrawing(); + smlDrawing.setId(relationship.getId()); + smlDrawing.setParent(worksheetPart.getContents()); + worksheetPart.getContents().setDrawing(smlDrawing); + } else { + currentId = drawing.getContents().getEGAnchor().size(); + } + + CTPicture picture = new CTPicture(); + + CTBlipFillProperties blipFillProperties = new CTBlipFillProperties(); + blipFillProperties.setStretch(new CTStretchInfoProperties()); + blipFillProperties.getStretch().setFillRect(new CTRelativeRect()); + blipFillProperties.setBlip(new CTBlip()); + blipFillProperties.getBlip().setEmbed("rId" + (currentId + 1)); + blipFillProperties.getBlip().setCstate(STBlipCompression.PRINT); + + picture.setBlipFill(blipFillProperties); + + CTNonVisualDrawingProps nonVisualDrawingProps = new CTNonVisualDrawingProps(); + nonVisualDrawingProps.setId(currentId + 2); + nonVisualDrawingProps.setName(imagePartName.substring(imagePartName.lastIndexOf("/") + 1)); + nonVisualDrawingProps.setDescr(nonVisualDrawingProps.getName()); + + CTNonVisualPictureProperties nonVisualPictureProperties = new CTNonVisualPictureProperties(); + nonVisualPictureProperties.setPicLocks(new CTPictureLocking()); + nonVisualPictureProperties.getPicLocks().setNoChangeAspect(true); + CTPictureNonVisual nonVisualPicture = new CTPictureNonVisual(); + + nonVisualPicture.setCNvPr(nonVisualDrawingProps); + nonVisualPicture.setCNvPicPr(nonVisualPictureProperties); + + picture.setNvPicPr(nonVisualPicture); + + CTShapeProperties shapeProperties = new CTShapeProperties(); + CTTransform2D transform2D = new CTTransform2D(); + transform2D.setOff(new CTPoint2D()); + transform2D.setExt(new CTPositiveSize2D()); + shapeProperties.setXfrm(transform2D); + shapeProperties.setPrstGeom(new CTPresetGeometry2D()); + shapeProperties.getPrstGeom().setPrst(STShapeType.RECT); + shapeProperties.getPrstGeom().setAvLst(new CTGeomGuideList()); + CTPositiveSize2D positivesize2D = new CTPositiveSize2D(); + transform2D.setExt(positivesize2D); + positivesize2D.setCx( XlsxUtils.convertPxToEmu(bufferedImage.getWidth()) ); + positivesize2D.setCy( XlsxUtils.convertPxToEmu(bufferedImage.getHeight()) ); + + picture.setSpPr(shapeProperties); + + anchor.setPic(picture); + anchor.setClientData(new CTAnchorClientData()); + + drawing.getContents().getEGAnchor().add(anchor); + + Relationship rel = new Relationship(); + rel.setId("rId" + (currentId + 1)); + rel.setType(Namespaces.IMAGE); + rel.setTarget(imagePartName); + + drawing.getRelationshipsPart().addRelationship(rel); + RelationshipsPart relPart = drawing.getRelationshipsPart(); + pkg.getParts().remove(relPart.getPartName()); + pkg.getParts().put(relPart); + pkg.getParts().remove(drawing.getPartName()); + pkg.getParts().put(drawing); + } + + private static String getWmlTemplateString(JaxbSmlPart smlPart) { + String wmlTemplateString = null; + PartStore partStore = smlPart.getPackage().getSourcePartStore(); + String name = smlPart.getPartName().getName(); + try { + InputStream is = partStore.loadPart( + name.substring(1)); + if (is == null) { + log.warn(name + " missing from part store"); + } else { + log.info("Lazily unmarshalling " + name); +// wmlTemplateString = convertStreamToString(is); + + // This seems to be about 5% faster than the Scanner approach + wmlTemplateString = IOUtils.toString(is, "UTF-8"); + List placeholderList = new ArrayList<>(); + getAllPlaceholderElementFromObject(wmlTemplateString, 0, placeholderList); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + + } finally { + return wmlTemplateString; + } + } + + private static List getAllPlaceholderElementFromObject(String wmlTemplateString, int offset, List placeholderList) { + + int startKey = wmlTemplateString.indexOf("${", offset); + if (startKey == -1) + return null; + else { + int keyEnd = wmlTemplateString.indexOf('}', startKey); + String placeHolder = wmlTemplateString.substring(startKey, keyEnd + 1); + if (isPlaceholder(placeHolder)) { + placeholderList.add(placeHolder); + } + return getAllPlaceholderElementFromObject(wmlTemplateString, keyEnd + 1, placeholderList); + } + } + + /** + * 判断字符串是否有${}占位符 + * + * @param str 需要判断的字符串 + * @return 是否字符串是否有${}占位符 + * @author liyawei + */ + private static boolean isPlaceholder(String str) { + if (str != null && !str.isEmpty()) { + Pattern pattern = Pattern.compile("([$]\\{[A-Za-z0-9./ -]+\\})"); // 识别范围 认证模块专用 + Matcher m = pattern.matcher(str); + return m.find(); + } + return false; } public static void xlsx4JAddImage() throws Exception { @@ -88,17 +422,11 @@ public class ExcelUtil { System.out.println("\n\n done .. " + outputfilepath); } - public static void variableReplace(InputStream is, OutputStream os, HashMap mappings) throws Exception { - - SpreadsheetMLPackage opcPackagepkg = SpreadsheetMLPackage.load(is); - + public static void variableReplace(SpreadsheetMLPackage pkg, HashMap mappings) throws Exception { // Be sure to get the part which actually contains your variables! - JaxbSmlPart smlPart = (JaxbSmlPart)opcPackagepkg.getParts().get(new PartName("/xl/sharedStrings.xml")); // 获取所有sheet + JaxbSmlPart smlPart = (JaxbSmlPart)pkg.getParts().get(new PartName("/xl/sharedStrings.xml")); // 获取所有sheet //JaxbSmlPart smlPart = (JaxbSmlPart)opcPackagepkg.getParts().get(new PartName("/xl/worksheets/sheet1.xml")); smlPart.variableReplace(mappings); - - // Save it - opcPackagepkg.save(os); } /** @@ -128,14 +456,14 @@ public class ExcelUtil { CTBlip blip = dmlObjectFactory.createCTBlip(); blipfillproperties.setBlip(blip); blip.setCstate(org.docx4j.dml.STBlipCompression.NONE); - blip.setEmbed( imageRelID ); + blip.setEmbed( imageRelID ); //------- // Create object for extLst CTOfficeArtExtensionList officeartextensionlist = dmlObjectFactory.createCTOfficeArtExtensionList(); blip.setExtLst(officeartextensionlist); // Create object for ext CTOfficeArtExtension officeartextension = dmlObjectFactory.createCTOfficeArtExtension(); officeartextensionlist.getExt().add( officeartextension); - officeartextension.setUri( "{28A0092B-C50C-407E-A947-70E740481C1C}"); + officeartextension.setUri( "{28A0092B-C50C-407E-A947-70E740481C1C}"); //------ blip.setLink( ""); // Create object for stretch CTStretchInfoProperties stretchinfoproperties = dmlObjectFactory.createCTStretchInfoProperties(); @@ -143,10 +471,10 @@ public class ExcelUtil { // Create object for fillRect CTRelativeRect relativerect = dmlObjectFactory.createCTRelativeRect(); stretchinfoproperties.setFillRect(relativerect); - relativerect.setR( new Integer(0) ); - relativerect.setT( new Integer(0) ); - relativerect.setL( new Integer(0) ); - relativerect.setB( new Integer(0) ); + relativerect.setR( new Integer(0) ); //------ + relativerect.setT( new Integer(0) ); //------ + relativerect.setL( new Integer(0) ); //------ + relativerect.setB( new Integer(0) ); //------ // Create object for spPr CTShapeProperties shapeproperties = dmlObjectFactory.createCTShapeProperties(); picture.setSpPr(shapeproperties); @@ -157,13 +485,13 @@ public class ExcelUtil { // Create object for off CTPoint2D point2d = dmlObjectFactory.createCTPoint2D(); transform2d.setOff(point2d); - point2d.setY( 0 ); - point2d.setX( 0 ); + point2d.setY( 0 ); //------ + point2d.setX( 0 ); //------ // Create object for ext CTPositiveSize2D positivesize2d = dmlObjectFactory.createCTPositiveSize2D(); transform2d.setExt(positivesize2d); - positivesize2d.setCx( 714375 ); - positivesize2d.setCy( 714375 ); + positivesize2d.setCx( 714375 ); //------ + positivesize2d.setCy( 714375 ); //------ // Create object for prstGeom CTPresetGeometry2D presetgeometry2d = dmlObjectFactory.createCTPresetGeometry2D(); shapeproperties.setPrstGeom(presetgeometry2d); @@ -177,9 +505,9 @@ public class ExcelUtil { // Create object for cNvPr CTNonVisualDrawingProps nonvisualdrawingprops = dmlObjectFactory.createCTNonVisualDrawingProps(); picturenonvisual.setCNvPr(nonvisualdrawingprops); - nonvisualdrawingprops.setDescr( ""); - nonvisualdrawingprops.setName( "Picture 1"); - nonvisualdrawingprops.setId( 2 ); + nonvisualdrawingprops.setDescr( ""); //------ + nonvisualdrawingprops.setName( "Picture 1"); //------ + nonvisualdrawingprops.setId( 2 ); //------ // Create object for cNvPicPr CTNonVisualPictureProperties nonvisualpictureproperties = dmlObjectFactory.createCTNonVisualPictureProperties(); picturenonvisual.setCNvPicPr(nonvisualpictureproperties); @@ -190,18 +518,18 @@ public class ExcelUtil { // Create object for to CTMarker marker = dmlspreadsheetdrawingObjectFactory.createCTMarker(); twocellanchor.setTo(marker); - marker.setCol(1); - marker.setColOff( 104775 ); - marker.setRow(3); - marker.setRowOff( 142875 ); + marker.setCol(1); //------ + marker.setColOff( 104775 ); //------ + marker.setRow(3); //------ + marker.setRowOff( 142875 ); //------ // Create object for from CTMarker marker2 = dmlspreadsheetdrawingObjectFactory.createCTMarker(); twocellanchor.setFrom(marker2); - marker2.setCol(0); - marker2.setColOff( 0 ); - marker2.setRow(0); - marker2.setRowOff( 0 ); - twocellanchor.setEditAs(STEditAs.fromValue("name")); + marker2.setCol(0); //------ + marker2.setColOff( 0 ); //------ + marker2.setRow(0); //------ + marker2.setRowOff( 0 ); //------ + twocellanchor.setEditAs(STEditAs.ONE_CELL); // return drawingWrapped; return drawing; @@ -264,5 +592,4 @@ public class ExcelUtil { XmlUtils.unmarshalString(openXML)); } - } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/XlsxUtils.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/XlsxUtils.java new file mode 100644 index 000000000..49a72d3bf --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/project/util/XlsxUtils.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Haulmont + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.jero.modules.project.util; + +public final class XlsxUtils { + + private static final long PX_PER_INCH = 96; + private static final long EMU_PER_INCH = 914400; + + private XlsxUtils() { + } + + public static int getNumberFromColumnReference(String columnReference) { + int sum = 0; + + for (int i = 0; i < columnReference.length(); i++) { + char c = columnReference.charAt(i); + int number = ((int) c) - 64 - 1; + + int pow = columnReference.length() - i - 1; + sum += Math.pow(26, pow) * (number + 1); + } + return sum; + } + + public static String getColumnReferenceFromNumber(int number) { + int remain = 0; + StringBuilder ref = new StringBuilder(); + do { + + remain = (number - 1) % 26; + number = (number - 1) / 26; + + ref.append((char) (remain + 64 + 1)); + } while (number > 0); + + return ref.reverse().toString(); + } + + public static long convertPxToEmu(long px) { + return px * EMU_PER_INCH / PX_PER_INCH; + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/controller/LawsMonthlyReportWriteEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/controller/LawsMonthlyReportWriteEOController.java index 9f965309c..e4fb26d4e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/controller/LawsMonthlyReportWriteEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/controller/LawsMonthlyReportWriteEOController.java @@ -183,8 +183,10 @@ public class LawsMonthlyReportWriteEOController extends JeroController exportMonthlyReport(LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) throws IOException { - return lawsMonthlyReportWriteEOService.exportMonthlyReport(lawsMonthlyReportWriteEO); + public void exportMonthlyReport(HttpServletResponse response, + HttpServletRequest request, + LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) throws IOException { + lawsMonthlyReportWriteEOService.exportMonthlyReport(response,request,lawsMonthlyReportWriteEO); } @ApiOperation(value="带入标准信息--分页", notes="带入标准信息--分页") diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/ILawsMonthlyReportWriteEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/ILawsMonthlyReportWriteEOService.java index 9f4e58fec..2f653b1b2 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/ILawsMonthlyReportWriteEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/ILawsMonthlyReportWriteEOService.java @@ -3,9 +3,9 @@ package com.jero.modules.report.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.report.entity.LawsMonthlyReportWriteEO; -import org.springframework.http.ResponseEntity; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -77,7 +77,9 @@ public interface ILawsMonthlyReportWriteEOService extends IService exportMonthlyReport(LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO); + void exportMonthlyReport(HttpServletResponse response, + HttpServletRequest request, + LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO); IPage queryPageDocument(Map parameter); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/impl/LawsMonthlyReportWriteEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/impl/LawsMonthlyReportWriteEOServiceImpl.java index 1739939b6..b51b54e76 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/impl/LawsMonthlyReportWriteEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/report/service/impl/LawsMonthlyReportWriteEOServiceImpl.java @@ -1,5 +1,7 @@ package com.jero.modules.report.service.impl; +import cn.hutool.core.util.ZipUtil; +import com.aliyuncs.utils.IOUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -32,15 +34,19 @@ import com.jero.modules.system.service.impl.SysDictItemServiceImpl; import com.jero.modules.system.util.StringUtils; import org.apache.poi.xwpf.usermodel.ParagraphAlignment; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.aspectj.util.FileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -327,7 +333,9 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl exportMonthlyReport(LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) { + public void exportMonthlyReport(HttpServletResponse response, + HttpServletRequest request, + LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) { ResponseEntity result = null; //获取数据 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -353,17 +361,35 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl lawsMonthlyReportWriteEOS, List lawsMonthlyReportTitleTemplateEOS){ + //一级菜单 + List parentIdList = lawsMonthlyReportTitleTemplateEOS.stream().map(LawsMonthlyReportTitleTemplateEO::getParentId).distinct().collect(Collectors.toList()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(LawsMonthlyReportTitleTemplateEO::getId,parentIdList).orderByAsc(LawsMonthlyReportTitleTemplateEO::getSort); + List reportTitleOneList = lawsMonthlyReportTitleTemplateEOService.list(wrapper); //蔚来汽车法规月报-202004-主页面-CN //NIO Monthly Report on Automobile Regulations-202004-Main Page-EN String memoriesChapterCN = path + File.separator +"蔚来汽车法规月报" + lawsMonthlyReportWriteEOS.get(0).getMonth()+"主页面-CN.docx"; String memoriesChapterEN = path + File.separator +"NIO Monthly Report on Automobile Regulations-" + lawsMonthlyReportWriteEOS.get(0).getMonth()+"-Main Page-EN.docx"; + String titleCN = "蔚来汽车法规月报" + lawsMonthlyReportWriteEOS.get(0).getMonth(); + String titleEN = "NIO Monthly Report on Automobile Regulations-" + lawsMonthlyReportWriteEOS.get(0).getMonth(); File wordFile = new File(memoriesChapterCN); + File wordFileEn = new File(memoriesChapterEN); if(!wordFile.exists()){ try { wordFile.getParentFile().mkdirs(); wordFile.createNewFile(); } catch (IOException e) { - log.error("文件《"+memoriesChapterCN+"》创建失败"); + log.error("文件《"+titleCN+"》创建失败"); } } - try (XWPFDocument document = new XWPFDocument(); - FileOutputStream out = new FileOutputStream(wordFile)) { - WordUtil.exportWord(document, memoriesChapterCN, null, ParagraphAlignment.CENTER, 0, 12, false, true, "Microsoft YaHei UI"); - - - + try { + //主页面中文版 + XWPFDocument document = new XWPFDocument(); + FileOutputStream out = new FileOutputStream(wordFile); + word(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleCN, document,CutEnum.CN.getValue()); + document.write(out); + //主页面英文版 + XWPFDocument documentEn = new XWPFDocument(); + FileOutputStream outCn = new FileOutputStream(wordFileEn); + word(lawsMonthlyReportWriteEOS, lawsMonthlyReportTitleTemplateEOS, reportTitleOneList, titleEN, documentEn,CutEnum.EN.getValue()); + documentEn.write(outCn); } catch (IOException e) { log.error("文件创建异常,异常信息为:" + e.getMessage()); } } + private void word(List lawsMonthlyReportWriteEOS, + List lawsMonthlyReportTitleTemplateEOS, + List reportTitleOneList, + String titleCN, + XWPFDocument document, + String cut) { + String content = ""; + if(CutEnum.CN.getValue().equals(cut)){ + content = "主要内容"; + }else{ + content = "Content"; + } + WordUtil.exportWord(document, titleCN, null, ParagraphAlignment.CENTER, 0, 12, false, true, "Microsoft YaHei UI"); + WordUtil.exportWord(document, content, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Microsoft YaHei UI"); + int oneCount = 1; + + for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : reportTitleOneList) { + int twoCount = 1; + String oneNumber = intToRoman(oneCount); + //一级标题 + String oneTitle = ""; + if(CutEnum.CN.getValue().equals(cut)){ + oneTitle = lawsMonthlyReportTitleTemplateEO.getTitleCn(); + }else{ + oneTitle = lawsMonthlyReportTitleTemplateEO.getTitleEn(); + } + WordUtil.exportWord(document, oneNumber+" "+oneTitle, null, ParagraphAlignment.LEFT, 0, 12, false, true, "Microsoft YaHei UI"); + oneCount++; + List reportTitleTwoList = lawsMonthlyReportTitleTemplateEOS.stream().filter(e -> e.getParentId().equals(lawsMonthlyReportTitleTemplateEO.getId())).collect(Collectors.toList()); + + + for (LawsMonthlyReportTitleTemplateEO monthlyReportTitleTemplateEO : reportTitleTwoList) { + int reportCount = 1; + //子标题对应的月报填写的内容 + List lawsMonthlyReportWriteEOList = lawsMonthlyReportWriteEOS.stream().filter(e -> monthlyReportTitleTemplateEO.getId().equals(e.getMemoriesChapter())).collect(Collectors.toList()); + String twoNumber = intToRoman(twoCount); + twoNumber = oneNumber+"."+twoNumber; + + //二级标题 + String twoTitle = ""; + if(CutEnum.CN.getValue().equals(cut)){ + twoTitle = monthlyReportTitleTemplateEO.getTitleCn(); + }else{ + twoTitle = monthlyReportTitleTemplateEO.getTitleEn(); + } + WordUtil.exportWord(document, twoNumber+" "+twoTitle, null, ParagraphAlignment.LEFT, 2, 12, false, true, "Microsoft YaHei UI"); + twoCount++; + + for (LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO : lawsMonthlyReportWriteEOList) { + //月报内容标题 + String reportTitle = ""; + if(CutEnum.CN.getValue().equals(cut)){ + reportTitle = lawsMonthlyReportWriteEO.getTitleCn(); + }else{ + reportTitle = lawsMonthlyReportWriteEO.getTitleEn(); + } + WordUtil.exportWord(document, reportCount+". "+reportTitle, null, ParagraphAlignment.LEFT, 6, 10, false, false, "Microsoft YaHei UI"); + reportCount++; + } + } + } + } + + /** + * 数字转罗马字 + * @param num + * @return + */ + public String intToRoman(int num) { + int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; + String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; + StringBuffer ss=new StringBuffer(); + for (int i=0;i=values[i]){ + num=num-values[i]; + ss.append(symbols[i]); + } + if (num==0){ + return ss.toString(); + } + } + System.out.println(ss); + return ss.toString(); + } + @Override public IPage queryPageDocument(Map parameter) { String cut = (String) parameter.get("cut");//中英文切换标识 diff --git a/jero-web/package.json b/jero-web/package.json index da4e81b29..895530955 100644 --- a/jero-web/package.json +++ b/jero-web/package.json @@ -28,6 +28,7 @@ "jsencrypt": "^3.0.0-rc.1", "lodash.get": "^4.4.2", "lodash.pick": "^4.4.0", + "mammoth": "^1.4.21", "md5": "^2.2.1", "nprogress": "^0.2.0", "tinymce": "^5.3.2", diff --git a/jero-web/src/components/tableCollection/index.vue b/jero-web/src/components/tableCollection/index.vue index 03f462ef7..40b343d06 100644 --- a/jero-web/src/components/tableCollection/index.vue +++ b/jero-web/src/components/tableCollection/index.vue @@ -21,7 +21,8 @@ {{ text }}
- {{ item.db_field_txt }} + + {{ item.db_field_txt }} {{$t('See')}}
diff --git a/jero-web/src/views/businessSupport/regulationReport/components/RegulationMonthlyFill.vue b/jero-web/src/views/businessSupport/regulationReport/components/RegulationMonthlyFill.vue index 5a312fa44..ca1b2926e 100644 --- a/jero-web/src/views/businessSupport/regulationReport/components/RegulationMonthlyFill.vue +++ b/jero-web/src/views/businessSupport/regulationReport/components/RegulationMonthlyFill.vue @@ -94,7 +94,8 @@ //url传参严格按照当前命名 url: { deleteBatch: '/report/lawsMonthlyReportWriteEO/deleteBatch', - list:'/report/lawsMonthlyReportWriteEO/page', + list: '/report/lawsMonthlyReportWriteEO/page', + exportData: '/report/lawsMonthlyReportWriteEO/exportMonthlyReport' }, loading: false, dataSource: [], @@ -161,7 +162,7 @@ methods: { dateChange(item) { this.queryParam[item.db_field_name] = this.queryParam[item.db_field_name] ? moment(this.queryParam[item.db_field_name]).format('YYYY-MM') : '' - this.queryParam = {...this.queryParam} + this.queryParam = { ...this.queryParam } }, searchQuery() { this.pageNo = 1 @@ -170,7 +171,7 @@ searchReset() { this.queryParam = {} this.queryParam.month = moment(new Date()).format('YYYY-MM') - this.queryParam = {...this.queryParam} + this.queryParam = { ...this.queryParam } this.pageNo = 1 this.getList() }, @@ -219,7 +220,15 @@ this.$refs.fillTableRef.getData() }, monthlyIntegrationAndExportClick() { - + let selectedRowKeys = JSON.parse(JSON.stringify(this.selectedRowKeys)) + let query = { + ids: selectedRowKeys.join(','), + ...this.queryParam + } + downloadFile(this.url.exportData, this.$t('monthlyReportRegulations') + '.zip', query, this.Deselect) + }, + Deselect() { + this.selectedRowKeys = [] }, addContentClick() { this.$refs.fillAddRef.add() @@ -323,6 +332,7 @@ height: 38px; /*margin-top: 2px;*/ } + .text-operation { margin-right: 8px; } diff --git a/jero-web/src/views/documentTools/documentComparison/components/documentDataComparison.vue b/jero-web/src/views/documentTools/documentComparison/components/documentDataComparison.vue index 4b0eee9f0..73e53956b 100644 --- a/jero-web/src/views/documentTools/documentComparison/components/documentDataComparison.vue +++ b/jero-web/src/views/documentTools/documentComparison/components/documentDataComparison.vue @@ -147,6 +147,7 @@ return { formInline: {}, rules: {}, + loading: false, gData: [ { title: '0-0sdf dsfdsfdsfdsfds', @@ -175,7 +176,10 @@ }, viewTheComparisonResultsClick() { - + let newUrl = this.$router.resolve({ + path: '/comparisonResults' + }) + window.open(newUrl.href, '_blank') }, addFullTextCommentClick() { @@ -306,6 +310,7 @@ text-align: right; padding: 0 32px; box-sizing: border-box; + margin-bottom: 20px; } .detail-content-content-left { diff --git a/jero-web/src/views/documentTools/documentComparison/index.vue b/jero-web/src/views/documentTools/documentComparison/index.vue index cb3f06ed6..d83c91ba1 100644 --- a/jero-web/src/views/documentTools/documentComparison/index.vue +++ b/jero-web/src/views/documentTools/documentComparison/index.vue @@ -257,7 +257,10 @@ window.open(newUrl.href, '_blank') }, subscribe() { - + let newUrl = this.$router.resolve({ + path: '/documentDataComparison' + }) + window.open(newUrl.href, '_blank') }, edit() { diff --git a/jero-web/src/views/documentTools/documentTranslation/components/documentTranslationResults.vue b/jero-web/src/views/documentTools/documentTranslation/components/documentTranslationResults.vue index ae67c40a1..a1b5d4d06 100644 --- a/jero-web/src/views/documentTools/documentTranslation/components/documentTranslationResults.vue +++ b/jero-web/src/views/documentTools/documentTranslation/components/documentTranslationResults.vue @@ -18,18 +18,22 @@
+ {{$t('dataLoading')}}
{{$t('translatedText')}}
- +
+ {{$t('dataLoading')}}
@@ -39,6 +43,10 @@