Commit e6cfd6fd authored by fangxinjiang's avatar fangxinjiang

项目规则配置-fxj

parent 9c715fd7
...@@ -29,7 +29,6 @@ import lombok.EqualsAndHashCode; ...@@ -29,7 +29,6 @@ import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.Date;
/** /**
* 字典项 * 字典项
...@@ -130,13 +129,13 @@ public class SysAutoDictItem extends BaseEntity { ...@@ -130,13 +129,13 @@ public class SysAutoDictItem extends BaseEntity {
@Schema(description = "客户端标识") @Schema(description = "客户端标识")
private String clientId; private String clientId;
/** /**
* 是否禁用: 0 启用 1 * 是否禁用: 0 启用 1
*/ */
@ExcelAttribute(name = "是否禁用: 0 启用 1 急用", isNotEmpty = true, errorInfo = "是否禁用: 0 启用 1 急用不能为空", maxLength = 1) @ExcelAttribute(name = "是否禁用: 0 启用 1 禁用", isNotEmpty = true, errorInfo = "是否禁用: 0 启用 1 禁用不能为空", maxLength = 1)
@NotBlank(message = "是否禁用: 0 启用 1 用不能为空") @NotBlank(message = "是否禁用: 0 启用 1 用不能为空")
@Length(max = 1, message = "是否禁用: 0 启用 1 用不能超过1个字符") @Length(max = 1, message = "是否禁用: 0 启用 1 用不能超过1个字符")
@ExcelProperty("是否禁用: 0 启用 1 用") @ExcelProperty("是否禁用: 0 启用 1 用")
@Schema(description = "是否禁用: 0 启用 1 用") @Schema(description = "是否禁用: 0 启用 1 用")
private String disable; private String disable;
/** /**
* 项目编码,标识此字典项为那个项目所有 * 项目编码,标识此字典项为那个项目所有
......
...@@ -53,20 +53,20 @@ public class TAutoEmpRuleInfo extends BaseEntity { ...@@ -53,20 +53,20 @@ public class TAutoEmpRuleInfo extends BaseEntity {
/** /**
* 是否启用自动化:0是 1否 * 是否启用自动化:0是 1否
*/ */
@ExcelAttribute(name = "是否启用自动化:0是 1否", isNotEmpty = true, errorInfo = "是否启用自动化:0是 1否不能为空", maxLength = 1) @ExcelAttribute(name = "是否启用自动化:0是 1否", isNotEmpty = true, errorInfo = "是否启用自动化不能为空", maxLength = 1)
@NotBlank(message = "是否启用自动化:0是 1否不能为空") @NotBlank(message = "是否启用自动化:0是 1否不能为空")
@Length(max = 1, message = "是否启用自动化:0是 1否不能超过1个字符") @Length(max = 1, message = "是否启用自动化:0是 1否不能超过1个字符")
@ExcelProperty("是否启用自动化:0是 1否") @ExcelProperty("是否启用自动化:0是 1否")
@Schema(description = "是否启用自动化:0是 1否") @Schema(description = "是否启用自动化:0是 1否")
private String autoFlag; private String autoFlag;
/** /**
* 收集方:0自动1 手动 * 收集方:0自动1 手动
*/ */
@ExcelAttribute(name = "收集方案:0自动1 手动", isNotEmpty = true, errorInfo = "收集方案:0自动1 手动不能为空", maxLength = 1) @ExcelAttribute(name = "收集方式:0自动1 手动", isNotEmpty = true, errorInfo = "收集方式不能为空", maxLength = 1)
@NotBlank(message = "收集方:0自动1 手动不能为空") @NotBlank(message = "收集方:0自动1 手动不能为空")
@Length(max = 1, message = "收集方:0自动1 手动不能超过1个字符") @Length(max = 1, message = "收集方:0自动1 手动不能超过1个字符")
@ExcelProperty("收集方:0自动1 手动") @ExcelProperty("收集方:0自动1 手动")
@Schema(description = "收集方:0自动1 手动") @Schema(description = "收集方:0自动1 手动")
private String collectType; private String collectType;
/** /**
* 推送时间 * 推送时间
...@@ -119,7 +119,7 @@ public class TAutoEmpRuleInfo extends BaseEntity { ...@@ -119,7 +119,7 @@ public class TAutoEmpRuleInfo extends BaseEntity {
/** /**
* 业务细分(同合的业务细分) * 业务细分(同合的业务细分)
*/ */
@ExcelAttribute(name = "业务细分(同合的业务细分)", isNotEmpty = true, errorInfo = "业务细分(同合的业务细分)不能为空", maxLength = 32) @ExcelAttribute(name = "业务细分(同合的业务细分)", isNotEmpty = true, errorInfo = "业务细分不能为空", maxLength = 32)
@NotBlank(message = "业务细分(同合的业务细分)不能为空") @NotBlank(message = "业务细分(同合的业务细分)不能为空")
@Length(max = 32, message = "业务细分(同合的业务细分)不能超过32个字符") @Length(max = 32, message = "业务细分(同合的业务细分)不能超过32个字符")
@ExcelProperty("业务细分(同合的业务细分)") @ExcelProperty("业务细分(同合的业务细分)")
...@@ -137,7 +137,7 @@ public class TAutoEmpRuleInfo extends BaseEntity { ...@@ -137,7 +137,7 @@ public class TAutoEmpRuleInfo extends BaseEntity {
/** /**
* 项目编码 * 项目编码
*/ */
@ExcelAttribute(name = "项目编码", isNotEmpty = true, errorInfo = "项目编码不能为空", maxLength = 50) @ExcelAttribute(name = "项目编码")
@NotBlank(message = "项目编码不能为空") @NotBlank(message = "项目编码不能为空")
@Length(max = 50, message = "项目编码不能超过50个字符") @Length(max = 50, message = "项目编码不能超过50个字符")
@ExcelProperty("项目编码") @ExcelProperty("项目编码")
...@@ -146,8 +146,7 @@ public class TAutoEmpRuleInfo extends BaseEntity { ...@@ -146,8 +146,7 @@ public class TAutoEmpRuleInfo extends BaseEntity {
/** /**
* 项目ID * 项目ID
*/ */
@ExcelAttribute(name = "项目ID", isNotEmpty = true, errorInfo = "项目ID不能为空", maxLength = 32) @ExcelAttribute(name = "项目ID")
@NotBlank(message = "项目ID不能为空")
@Length(max = 32, message = "项目ID不能超过32个字符") @Length(max = 32, message = "项目ID不能超过32个字符")
@ExcelProperty("项目ID") @ExcelProperty("项目ID")
@Schema(description = "项目ID") @Schema(description = "项目ID")
...@@ -155,8 +154,7 @@ public class TAutoEmpRuleInfo extends BaseEntity { ...@@ -155,8 +154,7 @@ public class TAutoEmpRuleInfo extends BaseEntity {
/** /**
* 项目配置主表ID * 项目配置主表ID
*/ */
@ExcelAttribute(name = "项目配置主表ID", isNotEmpty = true, errorInfo = "项目配置主表ID不能为空", maxLength = 32) @ExcelAttribute(name = "项目配置主表ID")
@NotBlank(message = "项目配置主表ID不能为空")
@Length(max = 32, message = "项目配置主表ID不能超过32个字符") @Length(max = 32, message = "项目配置主表ID不能超过32个字符")
@ExcelProperty("项目配置主表ID") @ExcelProperty("项目配置主表ID")
@Schema(description = "项目配置主表ID") @Schema(description = "项目配置主表ID")
......
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.SysAutoDictItem;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoEmpRuleInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 项目配置表主表--详情
*
* @author fxj
* @date 2025-03-13 15:15:26
*/
@Data
public class TAutoMainRelAddVo implements Serializable {
//项目配置主表
private TAutoMainRel autoMainRel;
//档案管理规则配置表
private TAutoEmpRuleInfo autoEmpRuleInfo;
//岗位信息表
private List<SysAutoDictItem> autoDictItems;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yifu.cloud.plus.v1.yifu.archives.entity.SysAutoDictItem;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoEmpRuleInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 项目配置表主表--详情
*
* @author fxj
* @date 2025-03-13 15:15:26
*/
@Data
public class TAutoMainRelDetailVo implements Serializable {
//项目配置主表
private TAutoMainRel autoMainRel;
//档案管理规则配置表
private TAutoEmpRuleInfo autoEmpRuleInfo;
//项目配置日志表
private List<TAutoRuleLog> autoRuleLogs;
//岗位信息表
private List<SysAutoDictItem> autoDictItems;
//项目信息表
private TSettleDomainSelectVo settleDomainVo;
}
...@@ -21,8 +21,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -21,8 +21,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel; import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService; import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelAddVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelDetailVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelSearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
...@@ -84,41 +87,50 @@ public class TAutoMainRelController { ...@@ -84,41 +87,50 @@ public class TAutoMainRelController {
} }
/** /**
* 通过id查询项目配置表主表 * 通过id查询项目配置表主表及相关信息
* @param id id * @param id id
* @return R * @return R
*/ */
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tautomainrel_get')") @Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}" ) @GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tautomainrel_get')" ) public R<TAutoMainRelDetailVo> getById(@PathVariable("id" ) String id) {
public R<TAutoMainRel> getById(@PathVariable("id" ) String id) { return tAutoMainRelService.getByIdAsso(id);
return R.ok(tAutoMainRelService.getById(id));
} }
/**
* 通过id查询项目配置表主表及相关信息
* @param deptId deptNo
* @return R
*/
@Operation(summary = "通过项目信息查询项目配置", description = "通过项目信息查询项目配置")
@GetMapping("/getProjectRule" )
public R<TAutoMainRelDetailVo> getProjectRule(@RequestParam(required = false) String deptId,
@RequestParam(required = false) String deptNo) {
return tAutoMainRelService.getProjectRule(deptId,deptNo);
}
/** /**
* 新增项目配置表主表 * 新增项目配置表主表
* @param tAutoMainRel 项目配置表主表 * @param entity 项目配置表主表
* @return R * @return R
*/ */
@Operation(summary = "新增项目配置表主表", description = "新增项目配置表主表:hasPermission('demo_tautomainrel_add')") @Operation(summary = "新增项目配置表", description = "新增项目配置表")
@SysLog("新增项目配置表主表" ) @SysLog("新增项目配置表" )
@PostMapping @PostMapping("/save")
@PreAuthorize("@pms.hasPermission('demo_tautomainrel_add')" ) public R<Boolean> save(@RequestBody TAutoMainRelAddVo entity) {
public R<Boolean> save(@RequestBody TAutoMainRel tAutoMainRel) { return tAutoMainRelService.saveAsso(entity);
return R.ok(tAutoMainRelService.save(tAutoMainRel));
} }
/** /**
* 修改项目配置表主表 * 修改项目配置表主表
* @param tAutoMainRel 项目配置表主表 * @param entity 项目配置表修改
* @return R * @return R
*/ */
@Operation(summary = "修改项目配置表主表", description = "修改项目配置表主表:hasPermission('demo_tautomainrel_edit')") @Operation(summary = "修改项目配置表主表", description = "修改项目配置表")
@SysLog("修改项目配置表主表" ) @SysLog("修改项目配置表" )
@PutMapping @PutMapping("/updateById")
@PreAuthorize("@pms.hasPermission('demo_tautomainrel_edit')" ) public R<Boolean> updateById(@RequestBody TAutoMainRelAddVo entity) {
public R<Boolean> updateById(@RequestBody TAutoMainRel tAutoMainRel) { return tAutoMainRelService.updateAsso(entity);
return R.ok(tAutoMainRelService.updateById(tAutoMainRel));
} }
/** /**
......
...@@ -63,93 +63,5 @@ public class TAutoRuleLogController { ...@@ -63,93 +63,5 @@ public class TAutoRuleLogController {
public R<IPage<TAutoRuleLog>> getTAutoRuleLogPage(Page<TAutoRuleLog> page, TAutoRuleLogSearchVo tAutoRuleLog) { public R<IPage<TAutoRuleLog>> getTAutoRuleLogPage(Page<TAutoRuleLog> page, TAutoRuleLogSearchVo tAutoRuleLog) {
return new R<>(tAutoRuleLogService.getTAutoRuleLogPage(page,tAutoRuleLog)); return new R<>(tAutoRuleLogService.getTAutoRuleLogPage(page,tAutoRuleLog));
} }
/**
* 不分页查询
* @param tAutoRuleLog 规则变更日志表
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@PostMapping("/noPage" )
//@PreAuthorize("@pms.hasPermission('demo_tautorulelog_get')" )
public R<List<TAutoRuleLog>> getTAutoRuleLogNoPage(@RequestBody TAutoRuleLogSearchVo tAutoRuleLog) {
return R.ok(tAutoRuleLogService.noPageDiy(tAutoRuleLog));
}
/**
* 通过id查询规则变更日志表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('demo_tautorulelog_get')")
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tautorulelog_get')" )
public R<TAutoRuleLog> getById(@PathVariable("id" ) String id) {
return R.ok(tAutoRuleLogService.getById(id));
}
/**
* 新增规则变更日志表
* @param tAutoRuleLog 规则变更日志表
* @return R
*/
@Operation(summary = "新增规则变更日志表", description = "新增规则变更日志表:hasPermission('demo_tautorulelog_add')")
@SysLog("新增规则变更日志表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('demo_tautorulelog_add')" )
public R<Boolean> save(@RequestBody TAutoRuleLog tAutoRuleLog) {
return R.ok(tAutoRuleLogService.save(tAutoRuleLog));
}
/**
* 修改规则变更日志表
* @param tAutoRuleLog 规则变更日志表
* @return R
*/
@Operation(summary = "修改规则变更日志表", description = "修改规则变更日志表:hasPermission('demo_tautorulelog_edit')")
@SysLog("修改规则变更日志表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('demo_tautorulelog_edit')" )
public R<Boolean> updateById(@RequestBody TAutoRuleLog tAutoRuleLog) {
return R.ok(tAutoRuleLogService.updateById(tAutoRuleLog));
}
/**
* 通过id删除规则变更日志表
* @param id id
* @return R
*/
@Operation(summary = "通过id删除规则变更日志表", description = "通过id删除规则变更日志表:hasPermission('demo_tautorulelog_del')")
@SysLog("通过id删除规则变更日志表" )
@DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('demo_tautorulelog_del')" )
public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tAutoRuleLogService.removeById(id));
}
/**
* 规则变更日志表 批量导入
*
* @author fxj
* @date 2025-03-13 15:15:26
**/
@SneakyThrows
@Operation(description = "批量新增规则变更日志表 hasPermission('demo_tautorulelog-batch-import')")
@SysLog("批量新增规则变更日志表")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('demo_tautorulelog-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){
return tAutoRuleLogService.importDiy(file.getInputStream());
}
/**
* 规则变更日志表 批量导出
* @author fxj
* @date 2025-03-13 15:15:26
**/
@Operation(description = "导出规则变更日志表 hasPermission('demo_tautorulelog-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('demo_tautorulelog-export')")
public void export(HttpServletResponse response, @RequestBody TAutoRuleLogSearchVo searchVo) {
tAutoRuleLogService.listExport(response,searchVo);
}
} }
...@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel; import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelAddVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelDetailVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelSearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
...@@ -49,4 +51,12 @@ public interface TAutoMainRelService extends IService<TAutoMainRel> { ...@@ -49,4 +51,12 @@ public interface TAutoMainRelService extends IService<TAutoMainRel> {
void listExport(HttpServletResponse response, TAutoMainRelSearchVo searchVo); void listExport(HttpServletResponse response, TAutoMainRelSearchVo searchVo);
List<TAutoMainRelExportVo> noPageDiy(TAutoMainRelSearchVo searchVo); List<TAutoMainRelExportVo> noPageDiy(TAutoMainRelSearchVo searchVo);
R<TAutoMainRelDetailVo> getByIdAsso(String id);
R<Boolean> saveAsso(TAutoMainRelAddVo entity);
R<Boolean> updateAsso(TAutoMainRelAddVo entity);
R<TAutoMainRelDetailVo> getProjectRule(String deptId, String deptNo);
} }
...@@ -22,12 +22,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -22,12 +22,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog; import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoRuleLogSearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoRuleLogSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/** /**
* 规则变更日志表 * 规则变更日志表
...@@ -36,16 +30,8 @@ import java.util.List; ...@@ -36,16 +30,8 @@ import java.util.List;
* @date 2025-03-13 15:15:26 * @date 2025-03-13 15:15:26
*/ */
public interface TAutoRuleLogService extends IService<TAutoRuleLog> { public interface TAutoRuleLogService extends IService<TAutoRuleLog> {
/**
* 规则变更日志表简单分页查询
* @param tAutoRuleLog 规则变更日志表
* @return
*/
IPage<TAutoRuleLog> getTAutoRuleLogPage(Page<TAutoRuleLog> page, TAutoRuleLogSearchVo tAutoRuleLog);
R<List<ErrorMessage>> importDiy(InputStream inputStream);
void listExport(HttpServletResponse response, TAutoRuleLogSearchVo searchVo); IPage<TAutoRuleLog> getTAutoRuleLogPage(Page<TAutoRuleLog> page, TAutoRuleLogSearchVo tAutoRuleLog);
List<TAutoRuleLog> noPageDiy(TAutoRuleLogSearchVo searchVo); <T> TAutoRuleLog saveModificationRecord(Integer type, String mainId, T oldInfo, T newInfo);
} }
...@@ -20,26 +20,27 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -20,26 +20,27 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoMainRel; import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAutoMainRelMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.*;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService; import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoMainRelService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelExportVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoMainRelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.core.util.equator.HrEquator;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
...@@ -47,8 +48,12 @@ import javax.servlet.http.HttpServletResponse; ...@@ -47,8 +48,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.time.LocalDateTime;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.serializer.SerializerFeature.*;
/** /**
* 项目配置表主表 * 项目配置表主表
* *
...@@ -58,6 +63,24 @@ import java.util.List; ...@@ -58,6 +63,24 @@ import java.util.List;
@Log4j2 @Log4j2
@Service @Service
public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAutoMainRel> implements TAutoMainRelService { public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAutoMainRel> implements TAutoMainRelService {
@Autowired
private TAutoEmpRuleInfoMapper autoEmpRuleInfoMapper;
@Autowired
private TAutoRuleLogMapper autoRuleLogMapper;
@Autowired
private SysAutoDictItemMapper autoDictItemMapper;
@Autowired
private ArchivesDaprUtil archivesDaprUtil;
@Autowired
private SysAutoDictMapper autoDictMapper;
public static final String itemsLabel = "label,description,disable";
/** /**
* 项目配置表主表简单分页查询 * 项目配置表主表简单分页查询
* @param tAutoMainRel 项目配置表主表 * @param tAutoMainRel 项目配置表主表
...@@ -139,7 +162,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu ...@@ -139,7 +162,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
return baseMapper.noPageDiy(searchVo); return baseMapper.noPageDiy(searchVo);
} }
private Long noPageCountDiy(TAutoMainRelSearchVo searchVo) { private Long noPageCountDiy(TAutoMainRelSearchVo searchVo) {
return baseMapper.noPageCountDiy(searchVo); return baseMapper.noPageCountDiy(searchVo);
} }
...@@ -158,58 +181,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu ...@@ -158,58 +181,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
@Override @Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) { public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); return R.ok();
ExcelUtil<TAutoMainRelVo> util1 = new ExcelUtil<>(TAutoMainRelVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TAutoMainRelVo.class, new ReadListener<TAutoMainRelVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TAutoMainRelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TAutoMainRelVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTAutoMainRel(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
private void importTAutoMainRel(List<TAutoMainRelVo> excelVOList, List<ErrorMessage> errorMessageList) { private void importTAutoMainRel(List<TAutoMainRelVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑 // 个性化校验逻辑
...@@ -232,4 +204,270 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu ...@@ -232,4 +204,270 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
BeanUtil.copyProperties(excel, insert); BeanUtil.copyProperties(excel, insert);
this.save(insert); this.save(insert);
} }
@Override
public R<TAutoMainRelDetailVo> getByIdAsso(String id) {
TAutoMainRelDetailVo detailVo = new TAutoMainRelDetailVo();
//项目配置主表
TAutoMainRel mainRel = baseMapper.selectById(id);
if (Common.isEmpty(mainRel)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
detailVo.setAutoMainRel(mainRel);
//档案管理规则配置表
detailVo.setAutoEmpRuleInfo(autoEmpRuleInfoMapper.selectOne(Wrappers.<TAutoEmpRuleInfo>query().lambda()
.eq(TAutoEmpRuleInfo::getMainId,id).last(CommonConstants.LAST_ONE_SQL)));
//项目配置日志表
detailVo.setAutoRuleLogs(autoRuleLogMapper.selectList(Wrappers.<TAutoRuleLog>query().lambda()
.eq(TAutoRuleLog::getMainId,id)));
//岗位信息表
detailVo.setAutoDictItems(autoDictItemMapper.selectList(Wrappers.<SysAutoDictItem>query().lambda()
.eq(SysAutoDictItem::getDeptNo,mainRel.getDeptNo())));
//项目信息表
detailVo.setSettleDomainVo(archivesDaprUtil.selectDeptByNo(mainRel.getDeptNo()));
return R.ok(detailVo);
}
/**
* @Author fxj
* @Description 规则保存
* @Date 10:24 2025/3/14
**/
@Override
public R<Boolean> saveAsso(TAutoMainRelAddVo entity) {
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(user)){
return R.failed(CommonConstants.USER_FAIL);
}
if (Common.isEmpty(entity)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel autoMainRel = entity.getAutoMainRel();
if (Common.isEmpty(autoMainRel)
|| Common.isEmpty(autoMainRel.getDeptId())
|| Common.isEmpty(autoMainRel.getDeptNo())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysAutoDict autoDict = autoDictMapper.selectOne(Wrappers.<SysAutoDict>query().lambda()
.eq(SysAutoDict::getType,CommonConstants.POST_TYPE).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(autoDict)){
return R.failed(CommonConstants.INIT_DATA_GET_FAIL);
}
TAutoEmpRuleInfo autoEmpRuleInfo = entity.getAutoEmpRuleInfo();
if (Common.isNotNull(autoEmpRuleInfo)){
ExcelUtil<TAutoEmpRuleInfo> excelUtil = new ExcelUtil<>(TAutoEmpRuleInfo.class);
ErrorMessage errorMessage = excelUtil.checkEntity(autoEmpRuleInfo,0);
if (Common.isNotNull(errorMessage)){
return R.failed(errorMessage.getMessage());
}
}
//新增主表
autoMainRel.setRuleUpdatePerson(user.getNickname());
autoMainRel.setRuleUpdateTime(DateUtil.getCurrentDateTime());
int res = baseMapper.insert(autoMainRel);
if (res <= CommonConstants.ZERO_INT){
return R.failed(CommonConstants.SAVE_FAILED);
}
//新增岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
if (Common.isNotNull(autoDictItems)) {
autoDictItems.forEach(sysAutoDictItem -> {
//初始化字典信息
initDictItem(sysAutoDictItem, user, autoDict, autoMainRel);
sysAutoDictItem.setCreateTime(LocalDateTime.now());
sysAutoDictItem.setCreateBy(user.getId());
sysAutoDictItem.setCreateName(user.getNickname());
autoDictItemMapper.insert(sysAutoDictItem);
});
}
//新增档案规则
if (Common.isNotNull(autoEmpRuleInfo)){
autoEmpRuleInfo.setDeptNo(autoMainRel.getDeptNo());
autoEmpRuleInfo.setDeptId(autoMainRel.getDeptId());
autoEmpRuleInfo.setMainId(autoMainRel.getId());
autoEmpRuleInfoMapper.insert(autoEmpRuleInfo);
}
return R.ok();
}
/**
* @Author fxj
* @Description 规则修改
* @Date 10:24 2025/3/14
**/
@Override
public R<Boolean> updateAsso(TAutoMainRelAddVo entity) {
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(user)){
return R.failed(CommonConstants.USER_FAIL);
}
if (Common.isEmpty(entity)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel autoMainRel = entity.getAutoMainRel();
if (Common.isEmpty(autoMainRel) || Common.isEmpty(autoMainRel.getId())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysAutoDict autoDict = autoDictMapper.selectOne(Wrappers.<SysAutoDict>query().lambda()
.eq(SysAutoDict::getType,CommonConstants.POST_TYPE).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(autoDict)){
return R.failed(CommonConstants.INIT_DATA_GET_FAIL);
}
TAutoEmpRuleInfo autoEmpRuleNew = entity.getAutoEmpRuleInfo();
TAutoEmpRuleInfo autoEmpRuleOld = null;
if (Common.isNotNull(autoEmpRuleNew)){
if (!Common.isNotNull(autoEmpRuleNew.getId())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
autoEmpRuleOld = autoEmpRuleInfoMapper.selectById(autoEmpRuleNew.getId());
ExcelUtil<TAutoEmpRuleInfo> excelUtil = new ExcelUtil<>(TAutoEmpRuleInfo.class);
ErrorMessage errorMessage = excelUtil.checkEntity(autoEmpRuleNew,0);
if (Common.isNotNull(errorMessage)){
return R.failed(errorMessage.getMessage());
}
}
//更新主表
autoMainRel.setRuleUpdatePerson(user.getNickname());
autoMainRel.setRuleUpdateTime(DateUtil.getCurrentDateTime());
baseMapper.updateById(autoMainRel);
Map<String,String> diffKeyMap = new HashMap<>();
Map<String,Object> oldMap = new HashMap<>();
Map<String,Object> newMap = new HashMap<>();
//更新岗位字典
List<SysAutoDictItem> autoDictItems = entity.getAutoDictItems();
//处理岗位字典数据
dictItemHandle(user, autoMainRel, autoDict, diffKeyMap, autoDictItems);
//更新档案管理规则
if (Common.isNotNull(autoEmpRuleNew)){
oldMap.put("oldEmpRule",autoEmpRuleOld);
newMap.put("newEmpRule",autoEmpRuleNew);
String differenceKey = HrEquator.comparisonValue(autoEmpRuleOld, autoEmpRuleNew);
if (!Common.isEmpty(differenceKey)){
diffKeyMap.put("empRule",differenceKey);
}
autoEmpRuleNew.setDeptNo(autoMainRel.getDeptNo());
autoEmpRuleNew.setDeptId(autoMainRel.getDeptId());
autoEmpRuleNew.setMainId(autoMainRel.getId());
autoEmpRuleInfoMapper.updateById(autoEmpRuleNew);
}
//插入变更日志
insertLog(autoMainRel, diffKeyMap, oldMap, newMap);
return R.ok(true,CommonConstants.UPDATE_SUCCESS);
}
private void dictItemHandle(YifuUser user, TAutoMainRel autoMainRel, SysAutoDict autoDict, Map<String, String> diffKeyMap, List<SysAutoDictItem> autoDictItems) {
//更新岗位字典
List<SysAutoDictItem> oldAutoDictItems = autoDictItemMapper.selectList(Wrappers.<SysAutoDictItem>query()
.lambda().eq(SysAutoDictItem::getDeptNo,autoMainRel.getDeptNo())
.eq(SysAutoDictItem::getDisable,CommonConstants.ZERO_STRING));
if (Common.isNotNull(autoDictItems)){
Map<Long, SysAutoDictItem> oldItemMap = null;
if (Common.isNotNull(oldAutoDictItems)){
oldItemMap = oldAutoDictItems.stream().collect(Collectors.toMap(SysAutoDictItem::getId, v->v));
}
SysAutoDictItem oldItem;
String diffKey;
StringBuilder difkeys = new StringBuilder("");
for(SysAutoDictItem sysAutoDictItem : autoDictItems){
initDictItem(sysAutoDictItem, user, autoDict, autoMainRel);
if (Common.isNotNull(sysAutoDictItem.getId())){
oldItem = null==oldItemMap?null:oldItemMap.get(sysAutoDictItem.getId());
if (Common.isNotNull(oldItem)){
diffKey = HrEquator.comparisonValue(oldItem, sysAutoDictItem);
if (Common.isNotNull(diffKey)){
if (Common.isEmpty(difkeys.toString())){
difkeys.append(difkeys);
}else {
difkeys.append(CommonConstants.COMMA_STRING);
difkeys.append(difkeys);
}
}
}
autoDictItemMapper.updateById(sysAutoDictItem);
}else {
if (Common.isEmpty(difkeys.toString())){
difkeys.append(itemsLabel);
}else {
difkeys.append(CommonConstants.COMMA_STRING);
difkeys.append(itemsLabel);
}
sysAutoDictItem.setCreateTime(LocalDateTime.now());
sysAutoDictItem.setCreateBy(user.getId());
sysAutoDictItem.setCreateName(user.getNickname());
autoDictItemMapper.insert(sysAutoDictItem);
}
}
if (!Common.isEmpty(difkeys.toString())){
String[] keys = difkeys.toString().split(CommonConstants.COMMA_STRING);
String keysStr = Arrays.stream(keys).distinct().collect(Collectors.joining(CommonConstants.COMMA_STRING));
diffKeyMap.put("postType",keysStr);
}
}
}
/**
* @Author fxj
* @Description 插入变更日志
* @Date 15:43 2025/3/14
**/
private void insertLog(TAutoMainRel autoMainRel, Map<String, String> diffKeyMap, Map<String, Object> oldMap, Map<String, Object> newMap) {
try{
//比较记录不影响业务逻辑,用try套住
//如果有差异保存差异
if(!Common.isEmpty(diffKeyMap)){
TAutoRuleLog log = new TAutoRuleLog();
log.setType(0);
log.setMainId(autoMainRel.getId());
log.setCreateTime(LocalDateTime.now());
log.setOldInfo(JSON.toJSONString(oldMap,features));
log.setNewInfo(JSON.toJSONString(newMap,features));
log.setDifferenceInfo(JSON.toJSONString(diffKeyMap,features));
autoRuleLogMapper.insert(log);
}
}catch (Exception e){
log.error(JSON.toJSON(oldMap)+"插入修改记录报错>>>",e);
}
}
/**
* @Author fxj
* @Description 初始化字典项信息公共方法
* @Date 15:43 2025/3/14
**/
private void initDictItem(SysAutoDictItem sysAutoDictItem, YifuUser user, SysAutoDict autoDict, TAutoMainRel autoMainRel) {
sysAutoDictItem.setUpdateTime(LocalDateTime.now());
sysAutoDictItem.setUpdateBy(user.getId());
sysAutoDictItem.setDelFlag(CommonConstants.ZERO_STRING);
sysAutoDictItem.setClientId(ServiceNameConstants.SERVICE_CLIENT_ID_MVP);
sysAutoDictItem.setDictId(autoDict.getId());
sysAutoDictItem.setType(CommonConstants.POST_TYPE);
sysAutoDictItem.setDisable(CommonConstants.ZERO_STRING);
sysAutoDictItem.setDeptNo(autoMainRel.getDeptNo());
}
private SerializerFeature[] features = new SerializerFeature[] {
WriteMapNullValue, WriteNullNumberAsZero, WriteNullListAsEmpty,
WriteNullStringAsEmpty,WriteDateUseDateFormat
};
@Override
public R<TAutoMainRelDetailVo> getProjectRule(String deptId, String deptNo) {
if (Common.isEmpty(deptId) && Common.isEmpty(deptNo)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
LambdaQueryWrapper<TAutoMainRel> wrapper = buildQueryWrapper(deptId,deptNo);
TAutoMainRel rel = baseMapper.selectOne(wrapper);
if (Common.isNotNull(rel) && Common.isNotNull(rel.getId())){
return this.getByIdAsso(rel.getId());
}
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
private LambdaQueryWrapper buildQueryWrapper(String deptId, String deptNo){
LambdaQueryWrapper<TAutoMainRel> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(deptId)) {
wrapper.ge(TAutoMainRel::getDeptId, deptId);
}
if (Common.isNotNull(deptNo)){
wrapper.eq(TAutoMainRel::getDeptNo,deptNo);
}
return wrapper;
}
} }
...@@ -16,38 +16,24 @@ ...@@ -16,38 +16,24 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.archives.service.impl; package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON;
import cn.hutool.core.util.ArrayUtil; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog; import com.yifu.cloud.plus.v1.yifu.archives.entity.TAutoRuleLog;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAutoRuleLogMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAutoRuleLogMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoRuleLogService; import com.yifu.cloud.plus.v1.yifu.archives.service.TAutoRuleLogService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoRuleLogSearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoRuleLogSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TAutoRuleLogVo; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.util.equator.HrEquator;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream; import java.time.LocalDateTime;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import static com.alibaba.fastjson.serializer.SerializerFeature.*;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/** /**
* 规则变更日志表 * 规则变更日志表
* *
...@@ -67,181 +53,31 @@ public class TAutoRuleLogServiceImpl extends ServiceImpl<TAutoRuleLogMapper, TAu ...@@ -67,181 +53,31 @@ public class TAutoRuleLogServiceImpl extends ServiceImpl<TAutoRuleLogMapper, TAu
return baseMapper.getTAutoRuleLogPage(page,tAutoRuleLog); return baseMapper.getTAutoRuleLogPage(page,tAutoRuleLog);
} }
/** @Override
* 规则变更日志表批量导出 public <T> TAutoRuleLog saveModificationRecord(Integer type, String mainId, T oldInfo, T newInfo) {
* @param searchVo 规则变更日志表 try{
* @return //比较记录不影响业务逻辑,用try套住
*/ //比较差异
@Override String differenceKey = HrEquator.comparisonValue(oldInfo, newInfo);
public void listExport(HttpServletResponse response, TAutoRuleLogSearchVo searchVo){ //如果有差异保存差异
String fileName = "规则变更日志表批量导出" + DateUtil.getThisTime() + ".xlsx"; if(!Common.isEmpty(differenceKey)){
//获取要导出的列表 TAutoRuleLog log = new TAutoRuleLog();
List<TAutoRuleLog> list = new ArrayList<>(); log.setType(type);
long count = noPageCountDiy(searchVo); log.setMainId(mainId);
ServletOutputStream out = null; log.setCreateTime(LocalDateTime.now());
try { log.setOldInfo(JSON.toJSONString(oldInfo,features));
out = response.getOutputStream(); log.setNewInfo(JSON.toJSONString(newInfo,features));
response.setContentType(CommonConstants.MULTIPART_FORM_DATA); log.setDifferenceInfo(differenceKey);
response.setCharacterEncoding("utf-8"); baseMapper.insert(log);
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , CommonConstants.UTF8)); return log;
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 }
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list); }catch (Exception e){
ExcelWriter excelWriter = EasyExcel.write(out, TAutoRuleLog.class).build(); log.error(JSON.toJSON(oldInfo)+"插入修改记录报错>>>",e);
int index = 0; }
if (count > CommonConstants.ZERO_INT){ return null;
for (int i = 0; i <= count; ) { }
// 获取实际记录 private SerializerFeature[] features = new SerializerFeature[] {
searchVo.setLimitStart(i); WriteMapNullValue, WriteNullNumberAsZero, WriteNullListAsEmpty,
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT); WriteNullStringAsEmpty,WriteDateUseDateFormat
list = noPageDiy(searchVo); };
if (Common.isNotNull(list)){
ExcelUtil<TAutoRuleLog> util = new ExcelUtil<>(TAutoRuleLog.class);
for (TAutoRuleLog vo:list){
util.convertEntity(vo,null,null,null);
}
}
if (Common.isNotNull(list)){
WriteSheet writeSheet = EasyExcel.writerSheet("规则变更日志表"+index).build();
excelWriter.write(list,writeSheet);
index++;
}
i = i + CommonConstants.EXCEL_EXPORT_LIMIT;
if (Common.isNotNull(list)){
list.clear();
}
}
}else {
WriteSheet writeSheet = EasyExcel.writerSheet("规则变更日志表"+index).build();
excelWriter.write(list,writeSheet);
}
if (Common.isNotNull(list)){
list.clear();
}
out.flush();
excelWriter.finish();
}catch (Exception e){
log.error("执行异常" ,e);
}finally {
try {
if (null != out) {
out.close();
}
} catch (IOException e) {
log.error("执行异常", e);
}
}
}
@Override
public List<TAutoRuleLog> noPageDiy(TAutoRuleLogSearchVo searchVo) {
LambdaQueryWrapper<TAutoRuleLog> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TAutoRuleLog::getId,idList);
}
if (searchVo.getLimitStart() >= 0 && searchVo.getLimitEnd() > 0){
wrapper.last(" limit "+ searchVo.getLimitStart() +","+ searchVo.getLimitEnd());
}
wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectList(wrapper);
}
private Long noPageCountDiy(TAutoRuleLogSearchVo searchVo) {
LambdaQueryWrapper<TAutoRuleLog> wrapper = buildQueryWrapper(searchVo);
List<String> idList = Common.getList(searchVo.getIds());
if (Common.isNotNull(idList)){
wrapper.in(TAutoRuleLog::getId,idList);
}
return baseMapper.selectCount(wrapper);
}
private LambdaQueryWrapper buildQueryWrapper(TAutoRuleLogSearchVo entity){
LambdaQueryWrapper<TAutoRuleLog> wrapper = Wrappers.lambdaQuery();
if (ArrayUtil.isNotEmpty(entity.getCreateTimes())) {
wrapper.ge(TAutoRuleLog::getCreateTime, entity.getCreateTimes()[0])
.le(TAutoRuleLog::getCreateTime,
entity.getCreateTimes()[1]);
}
if (Common.isNotNull(entity.getCreateName())){
wrapper.eq(TAutoRuleLog::getCreateName,entity.getCreateName());
}
return wrapper;
}
@Override
public R<List<ErrorMessage>> importDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<TAutoRuleLogVo> util1 = new ExcelUtil<>(TAutoRuleLogVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, TAutoRuleLogVo.class, new ReadListener<TAutoRuleLogVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<TAutoRuleLogVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(TAutoRuleLogVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTAutoRuleLog(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private void importTAutoRuleLog(List<TAutoRuleLogVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
TAutoRuleLogVo excel = excelVOList.get(i);
// 数据合法情况 TODO
// 插入
insertExcel(excel);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.SAVE_SUCCESS));
}
}
/**
* 插入excel bad record
*/
private void insertExcel(TAutoRuleLogVo excel) {
TAutoRuleLog insert = new TAutoRuleLog();
BeanUtil.copyProperties(excel, insert);
this.save(insert);
}
} }
...@@ -347,6 +347,8 @@ public interface CommonConstants { ...@@ -347,6 +347,8 @@ public interface CommonConstants {
String PLEASE_LOG_IN = "请登录!"; String PLEASE_LOG_IN = "请登录!";
String INIT_DATA_GET_FAIL = "初试化数据失败,请检查传参!";
String SEX_MAN = "1"; String SEX_MAN = "1";
String SEX_WONMAN = "2"; String SEX_WONMAN = "2";
String SALARY_ISFLAG = "已结算"; String SALARY_ISFLAG = "已结算";
...@@ -660,4 +662,5 @@ public interface CommonConstants { ...@@ -660,4 +662,5 @@ public interface CommonConstants {
public static final String DELETE_FLAG = "1"; public static final String DELETE_FLAG = "1";
//单条数据检索SQL //单条数据检索SQL
public static final String SQL_LIMIT_ONE = " limit 1 "; public static final String SQL_LIMIT_ONE = " limit 1 ";
String POST_TYPE = "post_type";
} }
...@@ -52,4 +52,6 @@ public interface ServiceNameConstants { ...@@ -52,4 +52,6 @@ public interface ServiceNameConstants {
String CLIENT_ID_HR_B = "hrCustomer"; String CLIENT_ID_HR_B = "hrCustomer";
String SERVICE_NAME_MVP = "mvp"; String SERVICE_NAME_MVP = "mvp";
String SERVICE_CLIENT_ID_MVP = "yifu-mvp";
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment