合并分支 'dev_third_stage' 到 'master'

Dev third stage

查看合并请求 laws-nio/laws-weilai!115
This commit is contained in:
李雪涛
2022-07-31 10:42:50 +08:00
37 changed files with 1396 additions and 333 deletions
@@ -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;
@@ -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;
@@ -676,6 +676,7 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
map.put("db_field_name", paramsConfigEO.getId());
map.put("db_field_txt", paramsConfigEO.getConfigName());
map.put("type", true); //配置列 标识
map.put("isLock", paramsConfigEO.getIsLock()); //配置列 冻结标识
listConfig.add(map);
}
@@ -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.*;
@@ -51,7 +52,7 @@ public class ParamsExportTemplateEOController extends JeroController<ParamsExpor
@AutoLog(value = "参数导出模板表-分页列表查询")
@ApiOperation(value="参数导出模板表-分页列表查询", notes="参数导出模板表-分页列表查询")
@GetMapping(value = "/page")
// @RequiresPermissions("report:exportTemplate:page")
@RequiresPermissions("report:exportTemplate:page")
public Result<?> 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<ParamsExpor
@AutoLog(value = "参数导出模板表-添加")
@ApiOperation(value="参数导出模板表-添加", notes="参数导出模板表-添加")
@PostMapping(value = "/add")
// @RequiresPermissions("report:exportTemplate:add")
@RequiresPermissions("report:exportTemplate:add")
public Result<?> add(@Validated @RequestBody ParamsExportTemplateEO paramsExportTemplateEO) {
boolean isSuccess = paramsExportTemplateEOService.add(paramsExportTemplateEO);
if (isSuccess) {
@@ -130,7 +131,7 @@ public class ParamsExportTemplateEOController extends JeroController<ParamsExpor
@AutoLog(value = "参数导出模板表-编辑")
@ApiOperation(value="参数导出模板表-编辑", notes="参数导出模板表-编辑")
@PostMapping(value = "/edit")
// @RequiresPermissions("report:exportTemplate:edit")
@RequiresPermissions("report:exportTemplate:edit")
public Result<?> edit(@Validated @RequestBody ParamsExportTemplateEO paramsExportTemplateEO) {
boolean isSuccess = paramsExportTemplateEOService.editById(paramsExportTemplateEO);
if (isSuccess) {
@@ -149,7 +150,7 @@ public class ParamsExportTemplateEOController extends JeroController<ParamsExpor
@AutoLog(value = "参数导出模板表-通过id删除")
@ApiOperation(value="参数导出模板表-通过id删除", notes="参数导出模板表-通过id删除")
@GetMapping(value = "/delete")
// @RequiresPermissions("report:exportTemplate:delete")
@RequiresPermissions("report:exportTemplate:delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
boolean isSuccess = paramsExportTemplateEOService.deleteById(id);
if (isSuccess) {
@@ -168,7 +169,7 @@ public class ParamsExportTemplateEOController extends JeroController<ParamsExpor
@AutoLog(value = "参数导出模板表-批量删除")
@ApiOperation(value="参数导出模板表-批量删除", notes="参数导出模板表-批量删除")
@PostMapping(value = "/deleteBatch")
// @RequiresPermissions("report:exportTemplate:deleteBatch")
@RequiresPermissions("report:exportTemplate:deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
boolean isSuccess = paramsExportTemplateEOService.deleteByIds(Arrays.asList(ids.split(",")));
if (isSuccess) {
@@ -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<ParamsReportD
@AutoLog(value = "上报库参数项-表头中英文切换")
@ApiOperation(value="上报库参数项-表头中英文切换", notes="上报库参数项-表头中英文切换")
@GetMapping(value = "/getHeader")
// @RequiresPermissions("report:detail:list")
@RequiresPermissions("report:detail:list")
public Result<List<Map<String, Object>>> 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<ParamsReportD
@AutoLog(value = "上报库参数项-列表查询")
@ApiOperation(value="上报库参数项-列表查询", notes="上报库参数项-列表查询")
@GetMapping(value = "/list")
// @RequiresPermissions("report:detail:list")
@RequiresPermissions("report:detail:list")
public Result<?> 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<ParamsReportD
@ApiOperation(value = "上报库参数项-常规导出")
@GetMapping(value = "/exportNormal")
// @RequiresPermissions("report:detail:export:normal")
@RequiresPermissions("report:detail:export:normal")
public void exportNormal(ParamsReportDetailVO paramsReportDetailVO,
HttpServletResponse response,
HttpServletRequest request) {
@@ -121,7 +122,7 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@AutoLog(value = "上报库参数项-配置下拉选项(常规导出)")
@ApiOperation(value="上报库参数项-配置下拉选项(常规导出)", notes="上报库参数项-配置下拉选项(常规导出)")
@GetMapping(value = "/getConfigLabelList")
// @RequiresPermissions("report:detail:export:normal")
@RequiresPermissions("report:detail:export:normal")
public Result<?> getConfigLableList(ParamsReportDetailVO paramsReportDetailVO) {
List<Map<String, String>> configLabelList = paramsReportDetailEOService.getConfigLabelList(paramsReportDetailVO);
return Result.OK(configLabelList);
@@ -136,7 +137,7 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@AutoLog(value = "上报库参数项-配置下拉选项(自定义导出)")
@ApiOperation(value="上报库参数项-配置下拉选项(自定义导出)", notes="上报库参数项-配置下拉选项(自定义导出)")
@GetMapping(value = "/getConfigLabelListCustom")
// @RequiresPermissions("report:detail:export:custom")
@RequiresPermissions("report:detail:export:custom")
public Result<?> getConfigLableListCustom(ParamsReportDetailVO paramsReportDetailVO) {
List<Map<String, String>> configLabelList = paramsReportDetailEOService.getConfigLabelList(paramsReportDetailVO);
return Result.OK(configLabelList);
@@ -151,7 +152,7 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@AutoLog(value = "上报库参数项-导出模板下拉选项")
@ApiOperation(value="上报库参数项-导出模板下拉选项", notes="上报库参数项-导出模板下拉选项")
@GetMapping(value = "/getTemplateLabelList")
// @RequiresPermissions("report:detail:export:custom")
@RequiresPermissions("report:detail:export:custom")
public Result<?> getTemplateLabelList() {
List<Map<String, String>> templateLabelList = paramsReportDetailEOService.getTemplateLabelList();
return Result.OK(templateLabelList);
@@ -159,7 +160,7 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@ApiOperation(value = "上报库参数项-自定义导出")
@GetMapping(value = "/exportCustom")
// @RequiresPermissions("report:detail:export:custom")
@RequiresPermissions("report:detail:export:custom")
public void exportCustom(ParamsReportDetailVO paramsReportDetailVO,
HttpServletResponse response,
HttpServletRequest request) {
@@ -190,7 +191,7 @@ public class ParamsReportDetailEOController extends JeroController<ParamsReportD
@AutoLog(value = "上报库参数配置-查看单个详情")
@ApiOperation(value="上报库参数配置-查看单个详情", notes="上报库参数配置-查看单个详情")
@GetMapping(value = "/getConfig")
// @RequiresPermissions("report:detail:list")
@RequiresPermissions("report:detail:list")
public Result<ParamsReportConfigEO> getById(@RequestParam(name = "id") String id) {
ParamsReportConfigEO paramsReportConfigEO = paramsReportConfigEOService.getById(id);
return Result.OK(paramsReportConfigEO);
@@ -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<ParamsReportEO, IPa
@AutoLog(value = "上报库-分页列表查询")
@ApiOperation(value="上报库-分页列表查询", notes="上报库-分页列表查询")
@GetMapping(value = "/page")
// @RequiresPermissions("params:report:page")
@RequiresPermissions("params:report:page")
public Result<?> 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<ParamsReportEO, IPa
@AutoLog(value = "上报库-导出历史分页查询")
@ApiOperation(value="上报库-导出历史分页查询", notes="上报库-导出历史分页查询")
@GetMapping(value = "/exportHistoryPage")
// @RequiresPermissions("params:report:history")
@RequiresPermissions("params:report:history")
public Result<?> exportHistoryPage(ParamsReportExportHistoryEO paramsReportExportHistoryEO,
@RequestParam(name="cut") String cut,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@@ -43,10 +43,16 @@
AND cert_category LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.certCategory}),'%')
</if>
<if test="paramsReportDetailEO.sdt !=null and paramsReportDetailEO.sdt !=''">
AND sdt LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.sdt}),'%')
AND sdt in
<foreach collection="paramsReportDetailEO.sdt.split(',')" index="" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="paramsReportDetailEO.dre !=null and paramsReportDetailEO.dre !=''">
AND dre LIKE CONCAT(CONCAT('%',#{paramsReportDetailEO.dre}),'%')
AND dre in
<foreach collection="paramsReportDetailEO.dre.split(',')" index="" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="paramsReportDetailEO.paramsManifestId !=null and paramsReportDetailEO.paramsManifestId !=''">
AND params_manifest_id = #{paramsReportDetailEO.paramsManifestId}
@@ -53,6 +53,7 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
// 自定义导出-word模板
void exportCustomWord(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request);
// 自定义导出-excel模板
void exportCustomExcel(ParamsReportDetailVO paramsReportDetailVO, HttpServletResponse response, HttpServletRequest request);
}
@@ -36,11 +36,14 @@ import com.jero.modules.system.service.ISysDictItemService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.*;
import org.aspectj.util.FileUtil;
import org.docx4j.Docx4J;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.SpreadsheetMLPackage;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -795,6 +798,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
// 查询导出数据
List<Map> allParamsInfoList = queryForExportCustom(paramsReportDetailVO);
HashMap<String, String> params = (HashMap<String, String>) allParamsInfoList.get(0);
List<Map<String, Object>> imgListAll = (List<Map<String, Object>>) allParamsInfoList.get(1).get("imgListAll");
String templateUrl = "";
ParamsExportTemplateEO paramsExportTemplateEO = paramsExportTemplateEOService.getById(paramsReportDetailVO.getExportTemplateId());
@@ -820,7 +824,14 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
InputStream wordTemplate = CosBootUtil.download(templateUrl);
// com.qcloud.cos.utils.IOUtils.copy(wordTemplate, wordOS);
ExcelUtil.variableReplace(wordTemplate, wordOS, params);
// 替换占位符内容
// docx4j方式
InputStream excelTemplate = CosBootUtil.download(templateUrl);
SpreadsheetMLPackage pkg = SpreadsheetMLPackage.load(wordTemplate);
Workbook workbook = WorkbookFactory.create(excelTemplate);
ExcelUtil.replacePictureBatchPOI(workbook, pkg, imgListAll);
ExcelUtil.variableReplace(pkg, params);
pkg.save(wordOS);
}
@@ -1285,7 +1296,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
if (Date.class.equals(field.getType())) {
Date date = (Date) o;
String pattern = "";
if ("deadline".equals(varName)) {
if ("syncTime".equals(varName)) {
pattern = "yyyy-MM-dd";
} else {
pattern = "yyyy-MM-dd HH:mm:ss";
@@ -1,12 +1,12 @@
package com.jero.modules.extRepo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.common.system.query.QueryGenerator;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.extRepo.entity.ExtRepoData;
import com.jero.modules.extRepo.entity.ExtRepoDataPage;
@@ -24,7 +24,9 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -45,6 +47,9 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@Autowired
private IExtRepoFolderService extRepoFolderService;
private final SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
/**
* 分页列表查询
*
@@ -61,24 +66,28 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ExtRepoData> queryWrapper = QueryGenerator.initQueryWrapper(extRepoData, req.getParameterMap());
Page<ExtRepoData> page = new Page<ExtRepoData>(pageNo, pageSize);
LambdaQueryWrapper<ExtRepoData> queryWrapper = new LambdaQueryWrapper<>();
Page<ExtRepoData> 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<ExtRepoData> 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<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-添加")
@ApiOperation(value = "对外报告数据表-添加", notes = "对外报告数据表-添加")
@PostMapping(value = "/add")
public Result<?> 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<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-编辑")
@ApiOperation(value = "对外报告数据表-编辑", notes = "对外报告数据表-编辑")
@PutMapping(value = "/edit")
public Result<?> 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<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-通过id删除")
@ApiOperation(value = "对外报告数据表-通过id删除", notes = "对外报告数据表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> 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<ExtRepoData, IExtRepoD
@AutoLog(value = "对外报告数据表-批量删除")
@ApiOperation(value = "对外报告数据表-批量删除", notes = "对外报告数据表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> 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<String> 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!");
}
}
/**
@@ -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<ExtRepoFolder, IExtR
@AutoLog(value = "对外报告文件夹表-添加")
@ApiOperation(value = "对外报告文件夹表-添加", notes = "对外报告文件夹表-添加")
@PostMapping(value = "/add")
public Result<?> 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<ExtRepoFolder, IExtR
@AutoLog(value = "对外报告文件夹表-编辑")
@ApiOperation(value = "对外报告文件夹表-编辑", notes = "对外报告文件夹表-编辑")
@PutMapping(value = "/edit")
public Result<?> 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<ExtRepoFolder, IExtR
@AutoLog(value = "对外报告文件夹表-通过id删除")
@ApiOperation(value = "对外报告文件夹表-通过id删除", notes = "对外报告文件夹表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> 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<ExtRepoFolder> 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<ExtRepoFolder, IExtR
@AutoLog(value = "对外报告文件夹表-通过id查询")
@ApiOperation(value = "对外报告文件夹表-通过id查询", notes = "对外报告文件夹表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> 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);
}
@@ -46,12 +46,12 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
/**
* 查看权限人员
*/
private String authView = "";
private String authViewIdsName = "";
/**
* 管理权限人员
*/
private String authManage = "";
private String authManageIdsName = "";
/**
* 查看权限人员id
@@ -135,20 +135,20 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
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() {
@@ -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)
@@ -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<String> getIdList() {
List<String> idList = new ArrayList<>();
ExtRepoMamagerRoleIdEnum[] values = values();
for (ExtRepoMamagerRoleIdEnum ermriEnum : values) {
idList.add(ermriEnum.getId());
}
return idList;
}
}
@@ -11,9 +11,9 @@
<result column="folder_name" property="folderName" />
<result column="order_id" property="orderId" />
<result column="sup_folder" property="supFolder" />
<result column="auth_view" property="authView" />
<result column="auth_manage" property="authManage" />
<result column="auth_view_ids" property="authViewIds" />
<result column="auth_manage_ids" property="authManageIds" />
<result column="auth_view_ids_name" property="authViewIdsName" />
<result column="auth_manage_ids_name" property="authManageIdsName" />
<result column="auth_view_ids" property="authViewIdsName" />
<result column="auth_manage_ids" property="authManageIdsName" />
</resultMap>
</mapper>
@@ -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<ExtRepoData> {
/**
* 保存
*
* @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<String> ids);
/**
* 通过id查询
*
* @param id
* @return
*/
/**
* 通过id查询
*
* @param id
* @return
*/
ExtRepoData queryById(String id);
/**
* 列表查询
*
* @return
*/
* 列表查询
*
* @return
*/
List<ExtRepoData> queryList();
}
@@ -68,4 +68,27 @@ public interface IExtRepoFolderService extends IService<ExtRepoFolder> {
* @return
*/
boolean haveManageAuth(String folderId);
/**
* 是否有查看权限
*
* @param folderId
* @return
*/
boolean haveViewAuth(String folderId);
/**
* 是否管理员
*
* @return
*/
boolean isManager();
/**
* 查找子文件夹
*
* @param supFolder
* @return
*/
List<ExtRepoFolder> getListBySupFolder(String supFolder);
}
@@ -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<ExtRepoDataMapper, ExtRepoData> 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<String> 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<ExtRepoData> queryList() {
return list();
}
@@ -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<ExtRepoFolderMapper, ExtRepoFolder> 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<ExtRepoFolderMapper, E
Date now = new Date();
extRepoFolder.setCreateTime(now);
extRepoFolder.setUpdateTime(now);
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// extRepoFolder.setAuthManageName(extRepoFolder.getAuthManageName() + "," + sysUser.getUsername());
// extRepoFolder.setAuthManageIds(extRepoFolder.getAuthManageIds() + "," + sysUser.getId());
extRepoFolder.setAuthManageIdsName(extRepoFolder.getAuthManageIdsName());
extRepoFolder.setAuthManageIds(extRepoFolder.getAuthManageIds());
save(extRepoFolder);
editOrderId(extRepoFolder);
} catch (Exception ex) {
@@ -68,7 +80,8 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
}
}
private List<ExtRepoFolder> getListBySupFolder(String supFolder) {
@Override
public List<ExtRepoFolder> getListBySupFolder(String supFolder) {
ExtRepoFolder erf = new ExtRepoFolder();
erf.setSupFolder(supFolder);
QueryWrapper<ExtRepoFolder> queryWrapper = QueryGenerator.initQueryWrapper(erf, new HashMap<>());
@@ -102,16 +115,16 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
*/
private void editAuth(ExtRepoFolder erf_orig, ExtRepoFolder erf_new) throws Exception {
//管理权限
Map<String, String> authManage_orig = getAuthMap(erf_orig.getAuthManage(), erf_orig.getAuthManageIds());
Map<String, String> authManage_new = getAuthMap(erf_new.getAuthManage(), erf_new.getAuthManageIds());
Map<String, String> authManage_orig = getAuthMap(erf_orig.getAuthManageIdsName(), erf_orig.getAuthManageIds());
Map<String, String> authManage_new = getAuthMap(erf_new.getAuthManageIdsName(), erf_new.getAuthManageIds());
//增加管理权限的人
Map<String, String> addManageRole = getDefMap(authManage_new, authManage_orig);
//删除管理权限的人
Map<String, String> delManageRole = getDefMap(authManage_orig, authManage_new);
//查看权限
Map<String, String> authView_orig = getAuthMap(erf_orig.getAuthView(), erf_orig.getAuthViewIds());
Map<String, String> authView_new = getAuthMap(erf_new.getAuthView(), erf_new.getAuthViewIds());
Map<String, String> authView_orig = getAuthMap(erf_orig.getAuthViewIdsName(), erf_orig.getAuthViewIds());
Map<String, String> authView_new = getAuthMap(erf_new.getAuthViewIdsName(), erf_new.getAuthViewIds());
//增加查看权限的人
Map<String, String> addViewRole = getDefMap(authView_new, authView_orig);
//删除查看权限的人
@@ -122,8 +135,8 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
List<ExtRepoFolder> updateFolder = new ArrayList<ExtRepoFolder>();
for (ExtRepoFolder erf : allSubFolder) {
boolean isChange = false;
Map<String, String> authManage_erf = getAuthMap(erf.getAuthManage(), erf.getAuthManageIds());
Map<String, String> authView_erf = getAuthMap(erf.getAuthView(), erf.getAuthViewIds());
Map<String, String> authManage_erf = getAuthMap(erf.getAuthManageIdsName(), erf.getAuthManageIds());
Map<String, String> 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<ExtRepoFolderMapper, E
}
}
for (String del : delManageRole.keySet()) {
//如果是创建人 不能删除管理权限
if (authManage_erf.keySet().contains(del)) {
authManage_erf.remove(del);
isChange = true;
if (!del.equals(erf_orig.getCreateBy())) {
authManage_erf.remove(del);
isChange = true;
}
}
}
for (String add : addViewRole.keySet()) {
@@ -148,9 +164,9 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
isChange = true;
}
}
erf.setAuthManage(StringUtils.join(authManage_erf.keySet(), ","));
erf.setAuthManageIdsName(StringUtils.join(authManage_erf.keySet(), ","));
erf.setAuthManageIds(StringUtils.join(authManage_erf.values(), ","));
erf.setAuthView(StringUtils.join(authView_erf.keySet(), ","));
erf.setAuthViewIdsName(StringUtils.join(authView_erf.keySet(), ","));
erf.setAuthViewIds(StringUtils.join(authView_erf.values(), ","));
if (isChange) {
updateFolder.add(erf);
@@ -197,10 +213,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
@Override
public void deleteById(String id) {
try {
List<ExtRepoFolder> 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<ExtRepoFolderMapper, E
if (supId.equals(erf.getSupFolder())) {
ERFTreeData date = new ERFTreeData(erf.getFolderName(), erf.getId(), level, erf.getOrderId());
//检查有没有权限查看
date.setDisplay(erf.getCreateBy().equals(sysUser.getUsername()) || getStringList(erf.getAuthManage()).contains(sysUser.getUsername()) || getStringList(erf.getAuthView()).contains(sysUser.getUsername()));
date.setDisplay(haveViewAuth(erf.getSupFolder()));
int childLevel = date.getLevel() + 1;
date.setAuthManage(erf.getAuthManage());
date.setAuthManageIdsName(erf.getAuthManageIdsName());
date.setAuthManageIds(erf.getAuthManageIds());
date.setAuthView(erf.getAuthManage());
date.setAuthViewIdsName(erf.getAuthViewIdsName());
date.setAuthViewIds(erf.getAuthViewIds());
date.setChildren(getSubFolder(erf.getId(), list, childLevel));
date.sortChildren();
@@ -276,23 +289,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
return resList;
}
/**
* 是否有管理权限
*
* @param folderId
* @return
*/
@Override
public boolean haveManageAuth(String folderId) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
ExtRepoFolder erf = queryById(folderId);
//如果是创建人 则默认有权限
if (null != erf) {
return getStringList(erf.getAuthManage()).contains(sysUser.getUsername()) || erf.getCreateBy().equals(sysUser.getUsername());
}
return false;
}
private List<String> getStringList(String listStr) {
List<String> res = new ArrayList<String>();
if (null != listStr) {
@@ -311,4 +307,61 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
return resMap;
}
/**
* 判断是否是文件夹管理员角色
*
* @return
*/
@Override
public boolean isManager() {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录用户
// 查询当前登录用户角色
List<SysUserRole> userRoles = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, loginUser.getId())); // 查询用户所有角色
List<String> userRoleIds = new ArrayList<>(); // 用户管理员/对外报告管理员
if (CollectionUtil.isNotEmpty(userRoles)) {
List<String> roleIdList = ExtRepoMamagerRoleIdEnum.getIdList();
List<String> 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;
}
}
@@ -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);
}
}
}
@@ -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<String, Object> 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<Map<String, Object>> 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<String, Object> 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<Map<String, Object>> imgListAll) throws Exception {
Parts parts = pkg.getParts();
Map<PartName, Part> map = parts.getParts();
for (Map.Entry<PartName, Part> 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<String, Object> 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<String> placeholderList = new ArrayList<>();
getAllPlaceholderElementFromObject(wmlTemplateString, 0, placeholderList);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
return wmlTemplateString;
}
}
private static List<String> getAllPlaceholderElementFromObject(String wmlTemplateString, int offset, List<String> 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<String, String> mappings) throws Exception {
SpreadsheetMLPackage opcPackagepkg = SpreadsheetMLPackage.load(is);
public static void variableReplace(SpreadsheetMLPackage pkg, HashMap<String, String> 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));
}
}
@@ -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;
}
}
@@ -183,8 +183,10 @@ public class LawsMonthlyReportWriteEOController extends JeroController<LawsMonth
@AutoLog(value = "月报整合导出zip")
@ApiOperation(value = "月报整合导出zip", notes = "月报整合导出zip")
@RequestMapping(value = "/exportMonthlyReport", method = RequestMethod.GET)
public ResponseEntity<byte[]> 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="带入标准信息--分页")
@@ -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<LawsMonthlyRe
Integer pageSize,
HttpServletRequest req);
ResponseEntity<byte[]> exportMonthlyReport(LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO);
void exportMonthlyReport(HttpServletResponse response,
HttpServletRequest request,
LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO);
IPage queryPageDocument(Map<String, Object> parameter);
}
@@ -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<LawsMonthly
}
@Override
public ResponseEntity<byte[]> exportMonthlyReport(LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) {
public void exportMonthlyReport(HttpServletResponse response,
HttpServletRequest request,
LawsMonthlyReportWriteEO lawsMonthlyReportWriteEO) {
ResponseEntity<byte[]> result = null;
//获取数据
LambdaQueryWrapper<LawsMonthlyReportWriteEO> wrapper = new LambdaQueryWrapper<>();
@@ -353,17 +361,35 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
fileTemp.delete();
}
fileTemp.mkdirs();
createWord(path,lawsMonthlyReportWriteEOS,lawsMonthlyReportTitleTemplateEOS);
OutputStream os = null;
try {
createWord(path,lawsMonthlyReportWriteEOS,lawsMonthlyReportTitleTemplateEOS);
ZipUtil.zip(path, path + ".zip");
//文件
os = response.getOutputStream();
FileInputStream fis = new FileInputStream(path + ".zip");
os = response.getOutputStream();
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
} catch (Exception e) {
}finally {
IOUtils.closeQuietly(os);
File file = new File(uploadpath + "/tempZip");
FileUtil.deleteContents(file);
File fileTem = new File(uploadpath + "/tempZip.zip");
FileUtil.deleteContents(fileTem);
}
return null;
}
/**
*
*创建word文件
* @param path
* @param lawsMonthlyReportWriteEOS 列表数据
* @param lawsMonthlyReportTitleTemplateEOS 章节目录
@@ -371,32 +397,130 @@ public class LawsMonthlyReportWriteEOServiceImpl extends ServiceImpl<LawsMonthly
private void createWord(String path,
List<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS){
//一级菜单
List<String> parentIdList = lawsMonthlyReportTitleTemplateEOS.stream().map(LawsMonthlyReportTitleTemplateEO::getParentId).distinct().collect(Collectors.toList());
LambdaQueryWrapper<LawsMonthlyReportTitleTemplateEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(LawsMonthlyReportTitleTemplateEO::getId,parentIdList).orderByAsc(LawsMonthlyReportTitleTemplateEO::getSort);
List<LawsMonthlyReportTitleTemplateEO> 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<LawsMonthlyReportWriteEO> lawsMonthlyReportWriteEOS,
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS,
List<LawsMonthlyReportTitleTemplateEO> 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<LawsMonthlyReportTitleTemplateEO> reportTitleTwoList = lawsMonthlyReportTitleTemplateEOS.stream().filter(e -> e.getParentId().equals(lawsMonthlyReportTitleTemplateEO.getId())).collect(Collectors.toList());
for (LawsMonthlyReportTitleTemplateEO monthlyReportTitleTemplateEO : reportTitleTwoList) {
int reportCount = 1;
//子标题对应的月报填写的内容
List<LawsMonthlyReportWriteEO> 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.length;i++){
while (num>=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<String, Object> parameter) {
String cut = (String) parameter.get("cut");//中英文切换标识