归档管理

new
JilingLee 1 year ago
parent 64b183bd1e
commit 7f119924f4

@ -24,6 +24,7 @@
<!-- 示例项目 -->
<!-- <module>yudao-example</module>-->
<module>yudao-module-bs</module>
<module>yudao-module-archives</module>
</modules>
<name>${project.artifactId}</name>

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>yudao-module-archives-api</module>
<module>yudao-module-archives-biz</module>
</modules>
<artifactId>yudao-module-archives</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
报销系统业务模块
</description>
<dependencies>
<dependency>
<groupId>com.baidu.aip</groupId>
<artifactId>java-sdk</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.80</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-archives</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-archives-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
archives 模块 API暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

@ -0,0 +1,7 @@
package cn.iocoder.yudao.module.archives.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
public interface ErrorCodeConstants {
ErrorCode RECORD_NOT_EXISTS = new ErrorCode(200100, "归档不存在");
ErrorCode CODE_RULE_NOT_EXISTS = new ErrorCode(300100, "编码不存在");
}

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-archives</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-archives-biz</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
archives 模块,主要实现商品相关功能
例如品牌、商品分类、spu、sku等功能。
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-archives-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-api</artifactId>
<version>1.7.3-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>1.7.3-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

@ -0,0 +1,99 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
import cn.iocoder.yudao.module.archives.convert.coderule.CodeRuleConvert;
import cn.iocoder.yudao.module.archives.service.coderule.CodeRuleService;
/**
*
*/
@Tag(name = "管理后台 - 档案编码规则")
@RestController
@RequestMapping("/archives/code-rule")
@Validated
public class CodeRuleController {
@Resource
private CodeRuleService codeRuleService;
@PostMapping("/create")
@Operation(summary = "创建档案编码规则")
public CommonResult<String> createCodeRule(@Valid @RequestBody CodeRuleCreateReqVO createReqVO) {
return success(codeRuleService.createCodeRule(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新档案编码规则")
public CommonResult<Boolean> updateCodeRule(@Valid @RequestBody CodeRuleUpdateReqVO updateReqVO) {
codeRuleService.updateCodeRule(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除档案编码规则")
@Parameter(name = "id", description = "编号", required = true)
public CommonResult<Boolean> deleteCodeRule(@RequestParam("id") Long id) {
codeRuleService.deleteCodeRule(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得档案编码规则")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<CodeRuleRespVO> getCodeRule(@RequestParam("id") Long id) {
CodeRuleDO codeRule = codeRuleService.getCodeRule(id);
return success(CodeRuleConvert.INSTANCE.convert(codeRule));
}
@GetMapping("/list")
@Operation(summary = "获得档案编码规则列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
public CommonResult<List<CodeRuleRespVO>> getCodeRuleList(@RequestParam("ids") Collection<Long> ids) {
List<CodeRuleDO> list = codeRuleService.getCodeRuleList(ids);
return success(CodeRuleConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得档案编码规则分页")
public CommonResult<PageResult<CodeRuleRespVO>> getCodeRulePage(@Valid CodeRulePageReqVO pageVO) {
PageResult<CodeRuleDO> pageResult = codeRuleService.getCodeRulePage(pageVO);
return success(CodeRuleConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出档案编码规则 Excel")
@OperateLog(type = EXPORT)
public void exportCodeRuleExcel(@Valid CodeRuleExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CodeRuleDO> list = codeRuleService.getCodeRuleList(exportReqVO);
// 导出 Excel
List<CodeRuleExcelVO> datas = CodeRuleConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "档案编码规则.xls", "数据", CodeRuleExcelVO.class, datas);
}
}

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class CodeRuleBaseVO {
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
}

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 档案编码规则创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CodeRuleCreateReqVO extends CodeRuleBaseVO {
}

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author gys123456
*/
@Data
public class CodeRuleExcelVO {
@ExcelProperty("id")
private Long id;
@ExcelProperty("全宗号")
private String caseNum;
@ExcelProperty("目录号")
private String catalogNum;
@ExcelProperty("案卷号")
private String filesNum;
}

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 档案编码规则 Excel 导出 Request VO参数和 CodeRulePageReqVO 是一致的")
@Data
public class CodeRuleExportReqVO {
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
}

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 档案编码规则分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CodeRulePageReqVO extends PageParam {
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
}

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Schema(description = "管理后台 - 档案编码规则 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CodeRuleRespVO extends CodeRuleBaseVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21349")
private Long id;
}

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.archives.controller.admin.coderule.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 档案编码规则更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CodeRuleUpdateReqVO extends CodeRuleBaseVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21349")
@NotNull(message = "id不能为空")
private Long id;
}

@ -0,0 +1,103 @@
package cn.iocoder.yudao.module.archives.controller.admin.record;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.module.archives.convert.record.RecordConvert;
import cn.iocoder.yudao.module.archives.service.record.RecordService;
@Tag(name = "管理后台 - 归档")
@RestController
@RequestMapping("/archives/record")
@Validated
public class RecordController {
@Resource
private RecordService recordService;
@PostMapping("/create")
@Operation(summary = "创建归档")
@PreAuthorize("@ss.hasPermission('archives:record:create')")
public CommonResult<Long> createRecord(@Valid @RequestBody RecordCreateReqVO createReqVO) {
return success(recordService.createRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新归档")
@PreAuthorize("@ss.hasPermission('archives:record:update')")
public CommonResult<Boolean> updateRecord(@Valid @RequestBody RecordUpdateReqVO updateReqVO) {
recordService.updateRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除归档")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('archives:record:delete')")
public CommonResult<Boolean> deleteRecord(@RequestParam("id") Long id) {
recordService.deleteRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得归档")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('archives:record:query')")
public CommonResult<RecordRespVO> getRecord(@RequestParam("id") Long id) {
RecordDO record = recordService.getRecord(id);
return success(RecordConvert.INSTANCE.convert(record));
}
@GetMapping("/list")
@Operation(summary = "获得归档列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('archives:record:query')")
public CommonResult<List<RecordRespVO>> getRecordList(@RequestParam("ids") Collection<Long> ids) {
List<RecordDO> list = recordService.getRecordList(ids);
return success(RecordConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得归档分页")
@PreAuthorize("@ss.hasPermission('archives:record:query')")
@DataPermission
public CommonResult<PageResult<RecordRespVO>> getRecordPage(@Valid RecordPageReqVO pageVO) {
PageResult<RecordDO> pageResult = recordService.getRecordPage(pageVO);
return success(RecordConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出归档 Excel")
@PreAuthorize("@ss.hasPermission('archives:record:export')")
@OperateLog(type = EXPORT)
public void exportRecordExcel(@Valid RecordExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<RecordDO> list = recordService.getRecordList(exportReqVO);
// 导出 Excel
List<RecordExcelVO> datas = RecordConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "归档.xls", "数据", RecordExcelVO.class, datas);
}
}

@ -0,0 +1,98 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class RecordBaseVO {
@Schema(description = "业务实体id", example = "1895")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "归档频次")
private String frequency;
@Schema(description = "档案类型", example = "1")
private String fileType;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "起止凭证号")
private String vouNum;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "档案位置")
private String site;
@Schema(description = "关联号", example = "18131")
private Long flowId;
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "归档详情")
private String note;
@Schema(description = "归档状态", example = "1")
private String fileStatus;
@Schema(description = "借阅状态", example = "2")
private String borrowStatus;
@Schema(description = "鉴定状态", example = "1")
private String identifyStatus;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "归档时间")
private String recordTime;
@Schema(description = "所属部门id", example = "12651")
private Long deptId;
@Schema(description = "所属部门", example = "王五")
private String deptName;
@Schema(description = "预留字段1")
private String attr1;
@Schema(description = "预留字段2")
private String attr2;
@Schema(description = "预留字段3")
private Integer attr3;
@Schema(description = "预留字段4")
private Integer attr4;
@Schema(description = "用户id", example = "19801")
private Long userId;
@Schema(description = "制单人", example = "王五")
private String createBy;
}

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 归档创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RecordCreateReqVO extends RecordBaseVO {
}

@ -0,0 +1,106 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author
*/
@Data
public class RecordExcelVO {
@ExcelProperty("主键")
private Long id;
@ExcelProperty("业务实体id")
private Long companyId;
@ExcelProperty("业务实体")
private String company;
@ExcelProperty("归档频次")
private String frequency;
@ExcelProperty("档案类型")
private String fileType;
@ExcelProperty("会计年份")
private String year;
@ExcelProperty("会计月份")
private String period;
@ExcelProperty("起止凭证号")
private String vouNum;
@ExcelProperty("全宗号")
private String caseNum;
@ExcelProperty("目录号")
private String catalogNum;
@ExcelProperty("案卷号")
private String filesNum;
@ExcelProperty("档案位置")
private String site;
@ExcelProperty("关联号")
private Long flowId;
@ExcelProperty("创建日期")
private LocalDateTime createTime;
@ExcelProperty("状态")
private String status;
@ExcelProperty("归档详情")
private String note;
@ExcelProperty("归档状态")
private String fileStatus;
@ExcelProperty("借阅状态")
private String borrowStatus;
@ExcelProperty("鉴定状态")
private String identifyStatus;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("归档时间")
private String recordTime;
@ExcelProperty("所属部门id")
private Long deptId;
@ExcelProperty("所属部门")
private String deptName;
@ExcelProperty("预留字段1")
private String attr1;
@ExcelProperty("预留字段2")
private String attr2;
@ExcelProperty("预留字段3")
private Integer attr3;
@ExcelProperty("预留字段4")
private Integer attr4;
@ExcelProperty("用户id")
private Long userId;
@ExcelProperty("制单人")
private String createBy;
}

@ -0,0 +1,101 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 归档 Excel 导出 Request VO参数和 RecordPageReqVO 是一致的")
@Data
public class RecordExportReqVO {
@Schema(description = "业务实体id", example = "1895")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "归档频次")
private String frequency;
@Schema(description = "档案类型", example = "1")
private String fileType;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "起止凭证号")
private String vouNum;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "档案位置")
private String site;
@Schema(description = "关联号", example = "18131")
private Long flowId;
@Schema(description = "创建日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "归档详情")
private String note;
@Schema(description = "归档状态", example = "1")
private String fileStatus;
@Schema(description = "借阅状态", example = "2")
private String borrowStatus;
@Schema(description = "鉴定状态", example = "1")
private String identifyStatus;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "归档时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] recordTime;
@Schema(description = "所属部门id", example = "12651")
private Long deptId;
@Schema(description = "所属部门", example = "王五")
private String deptName;
@Schema(description = "预留字段1")
private String attr1;
@Schema(description = "预留字段2")
private String attr2;
@Schema(description = "预留字段3")
private Integer attr3;
@Schema(description = "预留字段4")
private Integer attr4;
@Schema(description = "用户id", example = "19801")
private Long userId;
@Schema(description = "制单人")
private String createBy;
}

@ -0,0 +1,104 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 归档分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RecordPageReqVO extends PageParam {
@Schema(description = "业务实体id", example = "1895")
private Long companyId;
@Schema(description = "业务实体")
private String company;
@Schema(description = "归档频次")
private String frequency;
@Schema(description = "档案类型", example = "1")
private String fileType;
@Schema(description = "会计年份")
private String year;
@Schema(description = "会计月份")
private String period;
@Schema(description = "起止凭证号")
private String vouNum;
@Schema(description = "全宗号")
private String caseNum;
@Schema(description = "目录号")
private String catalogNum;
@Schema(description = "案卷号")
private String filesNum;
@Schema(description = "档案位置")
private String site;
@Schema(description = "关联号", example = "18131")
private Long flowId;
@Schema(description = "创建日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "归档详情")
private String note;
@Schema(description = "归档状态", example = "1")
private String fileStatus;
@Schema(description = "借阅状态", example = "2")
private String borrowStatus;
@Schema(description = "鉴定状态", example = "1")
private String identifyStatus;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "归档时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] recordTime;
@Schema(description = "所属部门id", example = "12651")
private Long deptId;
@Schema(description = "所属部门", example = "王五")
private String deptName;
@Schema(description = "预留字段1")
private String attr1;
@Schema(description = "预留字段2")
private String attr2;
@Schema(description = "预留字段3")
private Integer attr3;
@Schema(description = "预留字段4")
private Integer attr4;
@Schema(description = "用户id", example = "19801")
private Long userId;
@Schema(description = "制单人")
private String createBy;
}

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 归档 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RecordRespVO extends RecordBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4837")
private Long id;
@Schema(description = "创建日期")
private LocalDateTime createTime;
}

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.archives.controller.admin.record.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 归档更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RecordUpdateReqVO extends RecordBaseVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4837")
@NotNull(message = "主键不能为空")
private Long id;
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.archives.convert.coderule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
/**
* Convert
*
* @author gys123456
*/
@Mapper
public interface CodeRuleConvert {
CodeRuleConvert INSTANCE = Mappers.getMapper(CodeRuleConvert.class);
CodeRuleDO convert(CodeRuleCreateReqVO bean);
CodeRuleDO convert(CodeRuleUpdateReqVO bean);
CodeRuleRespVO convert(CodeRuleDO bean);
List<CodeRuleRespVO> convertList(List<CodeRuleDO> list);
PageResult<CodeRuleRespVO> convertPage(PageResult<CodeRuleDO> page);
List<CodeRuleExcelVO> convertList02(List<CodeRuleDO> list);
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.archives.convert.record;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
/**
* Convert
*
* @author
*/
@Mapper
public interface RecordConvert {
RecordConvert INSTANCE = Mappers.getMapper(RecordConvert.class);
RecordDO convert(RecordCreateReqVO bean);
RecordDO convert(RecordUpdateReqVO bean);
RecordRespVO convert(RecordDO bean);
List<RecordRespVO> convertList(List<RecordDO> list);
PageResult<RecordRespVO> convertPage(PageResult<RecordDO> page);
List<RecordExcelVO> convertList02(List<RecordDO> list);
}

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.archives.dal.dataobject.coderule;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author gys123456
*/
@TableName("archives_code_rule")
@KeySequence("archives_code_rule_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CodeRuleDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private String caseNum;
/**
*
*/
private String catalogNum;
/**
*
*/
private String filesNum;
}

@ -0,0 +1,140 @@
package cn.iocoder.yudao.module.archives.dal.dataobject.record;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("archives_record")
@KeySequence("archives_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RecordDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* id
*/
private Long companyId;
/**
*
*/
private String company;
/**
*
*/
private String frequency;
/**
*
*/
private String fileType;
/**
*
*/
private String year;
/**
*
*/
private String period;
/**
*
*/
private String vouNum;
/**
*
*/
private String caseNum;
/**
*
*/
private String catalogNum;
/**
*
*/
private String filesNum;
/**
*
*/
private String site;
/**
*
*/
private Long flowId;
/**
*
*/
private String status;
/**
*
*/
private String note;
/**
*
*/
private String fileStatus;
/**
*
*/
private String borrowStatus;
/**
*
*/
private String identifyStatus;
/**
*
*/
private String remark;
/**
*
*/
private String recordTime;
/**
* id
*/
private Long deptId;
/**
*
*/
private String deptName;
/**
* 1
*/
private String attr1;
/**
* 2
*/
private String attr2;
/**
* 3
*/
private Integer attr3;
/**
* 4
*/
private Integer attr4;
/**
* id
*/
private Long userId;
/**
*
*/
private String createBy;
}

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.archives.dal.mysql.coderule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
/**
* Mapper
*
* @author gys123456
*/
@Mapper
public interface CodeRuleMapper extends BaseMapperX<CodeRuleDO> {
default PageResult<CodeRuleDO> selectPage(CodeRulePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CodeRuleDO>()
.eqIfPresent(CodeRuleDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(CodeRuleDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(CodeRuleDO::getFilesNum, reqVO.getFilesNum())
.orderByDesc(CodeRuleDO::getId));
}
default List<CodeRuleDO> selectList(CodeRuleExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CodeRuleDO>()
.eqIfPresent(CodeRuleDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(CodeRuleDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(CodeRuleDO::getFilesNum, reqVO.getFilesNum())
.orderByDesc(CodeRuleDO::getId));
}
}

@ -0,0 +1,88 @@
package cn.iocoder.yudao.module.archives.dal.mysql.record;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.*;
/**
* Mapper
*
* @author
*/
@Mapper
public interface RecordMapper extends BaseMapperX<RecordDO> {
default PageResult<RecordDO> selectPage(RecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<RecordDO>()
.eqIfPresent(RecordDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(RecordDO::getCompany, reqVO.getCompany())
.eqIfPresent(RecordDO::getFrequency, reqVO.getFrequency())
.eqIfPresent(RecordDO::getFileType, reqVO.getFileType())
.eqIfPresent(RecordDO::getYear, reqVO.getYear())
.eqIfPresent(RecordDO::getPeriod, reqVO.getPeriod())
.eqIfPresent(RecordDO::getVouNum, reqVO.getVouNum())
.eqIfPresent(RecordDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(RecordDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(RecordDO::getFilesNum, reqVO.getFilesNum())
.eqIfPresent(RecordDO::getSite, reqVO.getSite())
.eqIfPresent(RecordDO::getFlowId, reqVO.getFlowId())
.betweenIfPresent(RecordDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(RecordDO::getStatus, reqVO.getStatus())
.eqIfPresent(RecordDO::getNote, reqVO.getNote())
.eqIfPresent(RecordDO::getFileStatus, reqVO.getFileStatus())
.eqIfPresent(RecordDO::getBorrowStatus, reqVO.getBorrowStatus())
.eqIfPresent(RecordDO::getIdentifyStatus, reqVO.getIdentifyStatus())
.eqIfPresent(RecordDO::getRemark, reqVO.getRemark())
.betweenIfPresent(RecordDO::getRecordTime, reqVO.getRecordTime())
.eqIfPresent(RecordDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(RecordDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(RecordDO::getAttr1, reqVO.getAttr1())
.eqIfPresent(RecordDO::getAttr2, reqVO.getAttr2())
.eqIfPresent(RecordDO::getAttr3, reqVO.getAttr3())
.eqIfPresent(RecordDO::getAttr4, reqVO.getAttr4())
.eqIfPresent(RecordDO::getUserId, reqVO.getUserId())
.eqIfPresent(RecordDO::getCreateBy, reqVO.getCreateBy())
.orderByDesc(RecordDO::getId));
}
default List<RecordDO> selectList(RecordExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<RecordDO>()
.eqIfPresent(RecordDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(RecordDO::getCompany, reqVO.getCompany())
.eqIfPresent(RecordDO::getFrequency, reqVO.getFrequency())
.eqIfPresent(RecordDO::getFileType, reqVO.getFileType())
.eqIfPresent(RecordDO::getYear, reqVO.getYear())
.eqIfPresent(RecordDO::getPeriod, reqVO.getPeriod())
.eqIfPresent(RecordDO::getVouNum, reqVO.getVouNum())
.eqIfPresent(RecordDO::getCaseNum, reqVO.getCaseNum())
.eqIfPresent(RecordDO::getCatalogNum, reqVO.getCatalogNum())
.eqIfPresent(RecordDO::getFilesNum, reqVO.getFilesNum())
.eqIfPresent(RecordDO::getSite, reqVO.getSite())
.eqIfPresent(RecordDO::getFlowId, reqVO.getFlowId())
.betweenIfPresent(RecordDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(RecordDO::getStatus, reqVO.getStatus())
.eqIfPresent(RecordDO::getNote, reqVO.getNote())
.eqIfPresent(RecordDO::getFileStatus, reqVO.getFileStatus())
.eqIfPresent(RecordDO::getBorrowStatus, reqVO.getBorrowStatus())
.eqIfPresent(RecordDO::getIdentifyStatus, reqVO.getIdentifyStatus())
.eqIfPresent(RecordDO::getRemark, reqVO.getRemark())
.betweenIfPresent(RecordDO::getRecordTime, reqVO.getRecordTime())
.eqIfPresent(RecordDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(RecordDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(RecordDO::getAttr1, reqVO.getAttr1())
.eqIfPresent(RecordDO::getAttr2, reqVO.getAttr2())
.eqIfPresent(RecordDO::getAttr3, reqVO.getAttr3())
.eqIfPresent(RecordDO::getAttr4, reqVO.getAttr4())
.eqIfPresent(RecordDO::getUserId, reqVO.getUserId())
.eqIfPresent(RecordDO::getCreateBy, reqVO.getCreateBy())
.orderByDesc(RecordDO::getId));
}
}

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.archives.framework.datapermission.config;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* archives Configuration
*
* @author
*/
@Configuration(proxyBeanMethods = false)
public class DataPermissionConfigurationRecord {
@Bean
public DeptDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizerRecord() {
return rule -> {
// dept
rule.addDeptColumn(RecordDO.class);
rule.addDeptColumn(DeptDO.class, "id");
// user
rule.addUserColumn(RecordDO.class);
rule.addUserColumn(AdminUserDO.class,"id");
};
}
}

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.archives.service.coderule;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* Service
*
* @author gys123456
*/
public interface CodeRuleService {
/**
*
*
* @param createReqVO
* @return
*/
String createCodeRule(@Valid CodeRuleCreateReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateCodeRule(@Valid CodeRuleUpdateReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteCodeRule(Long id);
/**
*
*
* @param id
* @return
*/
CodeRuleDO getCodeRule(Long id);
/**
*
*
* @param ids
* @return
*/
List<CodeRuleDO> getCodeRuleList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<CodeRuleDO> getCodeRulePage(CodeRulePageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<CodeRuleDO> getCodeRuleList(CodeRuleExportReqVO exportReqVO);
}

@ -0,0 +1,129 @@
package cn.iocoder.yudao.module.archives.service.coderule;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.checkerframework.checker.units.qual.C;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.text.SimpleDateFormat;
import java.util.*;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.archives.convert.coderule.CodeRuleConvert;
import cn.iocoder.yudao.module.archives.dal.mysql.coderule.CodeRuleMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author gys123456
*/
@Service
@Validated
public class CodeRuleServiceImpl implements CodeRuleService {
@Resource
private CodeRuleMapper codeRuleMapper;
@Override
public String createCodeRule(CodeRuleCreateReqVO createReqVO) {
// 插入
//格式说明 CODE20201111xxx CODE+当前年月日+编号(具体长度看需求)
String front = "CODE";
// 前缀//当前时间编码
Date date = new Date();
String bidDate = new SimpleDateFormat("yyyyMMdd").format(date);
List<CodeRuleDO> codeRuleDOList = codeRuleMapper.selectList(Wrappers.<CodeRuleDO>lambdaQuery()
.eq(CodeRuleDO::getCaseNum, createReqVO.getCaseNum())
.eq(CodeRuleDO::getCatalogNum, createReqVO.getCatalogNum())
.orderByDesc(CodeRuleDO::getCreateTime)
.last("LIMIT 1")
);
String code ="";
//修改为自己的业务代码
if (codeRuleDOList.size()>0) {
// 在数据表中查到了,说明现在这个订单不是今天的第一单
String bid = codeRuleDOList.get(0).getFilesNum();
//取出ID也就是业务号
bid = bid.substring(12, 15);
// 取出后三位数,也就是自动生成的三位数 001
int num = Integer.valueOf(bid);
num++;
// 加1
if (num < 10) {
String bidNum = String.format("%03d", num);
//%03d 只是三位不足补0
code = front + bidDate + bidNum;
} else if (num < 100) {
String bidNum = String.format("%03d", num);
//num<100,说明是两位数前面要补一个0
code = front + bidDate + bidNum;
} else {
String bidNum = String.valueOf(num);
code = front + bidDate + bidNum;
}
} else {
int number = 1;
String bidNum = "00" + number;
code = front + bidDate + bidNum;
}
CodeRuleDO codeRule = CodeRuleConvert.INSTANCE.convert(createReqVO);
codeRule.setFilesNum(code);
codeRule.setDeleted(false);
codeRuleMapper.insert(codeRule);
// 返回
return codeRule.getFilesNum();
}
@Override
public void updateCodeRule(CodeRuleUpdateReqVO updateReqVO) {
// 校验存在
validateCodeRuleExists(updateReqVO.getId());
// 更新
CodeRuleDO updateObj = CodeRuleConvert.INSTANCE.convert(updateReqVO);
codeRuleMapper.updateById(updateObj);
}
@Override
public void deleteCodeRule(Long id) {
// 校验存在
validateCodeRuleExists(id);
// 删除
codeRuleMapper.deleteById(id);
}
private void validateCodeRuleExists(Long id) {
if (codeRuleMapper.selectById(id) == null) {
throw exception(CODE_RULE_NOT_EXISTS);
}
}
@Override
public CodeRuleDO getCodeRule(Long id) {
return codeRuleMapper.selectById(id);
}
@Override
public List<CodeRuleDO> getCodeRuleList(Collection<Long> ids) {
return codeRuleMapper.selectBatchIds(ids);
}
@Override
public PageResult<CodeRuleDO> getCodeRulePage(CodeRulePageReqVO pageReqVO) {
return codeRuleMapper.selectPage(pageReqVO);
}
@Override
public List<CodeRuleDO> getCodeRuleList(CodeRuleExportReqVO exportReqVO) {
return codeRuleMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.archives.service.record;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* Service
*
* @author
*/
public interface RecordService {
/**
*
*
* @param createReqVO
* @return
*/
Long createRecord(@Valid RecordCreateReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateRecord(@Valid RecordUpdateReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteRecord(Long id);
/**
*
*
* @param id
* @return
*/
RecordDO getRecord(Long id);
/**
*
*
* @param ids
* @return
*/
List<RecordDO> getRecordList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<RecordDO> getRecordPage(RecordPageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<RecordDO> getRecordList(RecordExportReqVO exportReqVO);
}

@ -0,0 +1,111 @@
package cn.iocoder.yudao.module.archives.service.record;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.archives.convert.record.RecordConvert;
import cn.iocoder.yudao.module.archives.dal.mysql.record.RecordMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author
*/
@Service
@Validated
public class RecordServiceImpl implements RecordService {
@Resource
private RecordMapper recordMapper;
@Resource
private AdminUserMapper userMapper;
@Resource
private DeptMapper deptMapper;
@Override
public Long createRecord(RecordCreateReqVO createReqVO) {
// 插入
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
RecordDO record = RecordConvert.INSTANCE.convert(createReqVO);
record.setDeleted(false);
//添加数据userid
record.setUserId(loginUser.getId());
AdminUserDO adminUserDO = userMapper.selectById(loginUser.getId());
//添加数据部门id后续DataPermissionConfigurationRecord配置类中过滤数据
record.setDeptId(adminUserDO.getDeptId());
//业务实体
if (record.getCompanyId() != null){
LambdaQueryWrapperX<DeptDO> eq = new LambdaQueryWrapperX<DeptDO>().eq(DeptDO::getId, adminUserDO.getDeptId());
DeptDO deptDO = deptMapper.selectOne(eq);
record.setCompany(deptDO.getName());
}
record.setCreateBy(adminUserDO.getNickname());
recordMapper.insert(record);
// 返回
return record.getId();
}
@Override
public void updateRecord(RecordUpdateReqVO updateReqVO) {
// 校验存在
validateRecordExists(updateReqVO.getId());
// 更新
RecordDO updateObj = RecordConvert.INSTANCE.convert(updateReqVO);
recordMapper.updateById(updateObj);
}
@Override
public void deleteRecord(Long id) {
// 校验存在
validateRecordExists(id);
// 删除
recordMapper.deleteById(id);
}
private void validateRecordExists(Long id) {
if (recordMapper.selectById(id) == null) {
throw exception(RECORD_NOT_EXISTS);
}
}
@Override
public RecordDO getRecord(Long id) {
return recordMapper.selectById(id);
}
@Override
public List<RecordDO> getRecordList(Collection<Long> ids) {
return recordMapper.selectBatchIds(ids);
}
@Override
public PageResult<RecordDO> getRecordPage(RecordPageReqVO pageReqVO) {
return recordMapper.selectPage(pageReqVO);
}
@Override
public List<RecordDO> getRecordList(RecordExportReqVO exportReqVO) {
return recordMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.archives.dal.mysql.coderule.CodeRuleMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.archives.dal.mysql.record.RecordMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,167 @@
package cn.iocoder.yudao.module.archives.service.coderule;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.archives.controller.admin.coderule.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.coderule.CodeRuleDO;
import cn.iocoder.yudao.module.archives.dal.mysql.coderule.CodeRuleMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link CodeRuleServiceImpl}
*
* @author gys123456
*/
@Import(CodeRuleServiceImpl.class)
public class CodeRuleServiceImplTest extends BaseDbUnitTest {
@Resource
private CodeRuleServiceImpl codeRuleService;
@Resource
private CodeRuleMapper codeRuleMapper;
@Test
public void testCreateCodeRule_success() {
// 准备参数
CodeRuleCreateReqVO reqVO = randomPojo(CodeRuleCreateReqVO.class);
// 调用
String codeRuleId = codeRuleService.createCodeRule(reqVO);
// 断言
assertNotNull(codeRuleId);
// 校验记录的属性是否正确
CodeRuleDO codeRule = codeRuleMapper.selectById(codeRuleId);
assertPojoEquals(reqVO, codeRule);
}
@Test
public void testUpdateCodeRule_success() {
// mock 数据
CodeRuleDO dbCodeRule = randomPojo(CodeRuleDO.class);
codeRuleMapper.insert(dbCodeRule);// @Sql: 先插入出一条存在的数据
// 准备参数
CodeRuleUpdateReqVO reqVO = randomPojo(CodeRuleUpdateReqVO.class, o -> {
o.setId(dbCodeRule.getId()); // 设置更新的 ID
});
// 调用
codeRuleService.updateCodeRule(reqVO);
// 校验是否更新正确
CodeRuleDO codeRule = codeRuleMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, codeRule);
}
@Test
public void testUpdateCodeRule_notExists() {
// 准备参数
CodeRuleUpdateReqVO reqVO = randomPojo(CodeRuleUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> codeRuleService.updateCodeRule(reqVO), CODE_RULE_NOT_EXISTS);
}
@Test
public void testDeleteCodeRule_success() {
// mock 数据
CodeRuleDO dbCodeRule = randomPojo(CodeRuleDO.class);
codeRuleMapper.insert(dbCodeRule);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbCodeRule.getId();
// 调用
codeRuleService.deleteCodeRule(id);
// 校验数据不存在了
assertNull(codeRuleMapper.selectById(id));
}
@Test
public void testDeleteCodeRule_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> codeRuleService.deleteCodeRule(id), CODE_RULE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetCodeRulePage() {
// mock 数据
CodeRuleDO dbCodeRule = randomPojo(CodeRuleDO.class, o -> { // 等会查询到
o.setCaseNum(null);
o.setCatalogNum(null);
o.setFilesNum(null);
});
codeRuleMapper.insert(dbCodeRule);
// 测试 caseNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setCaseNum(null)));
// 测试 catalogNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setCatalogNum(null)));
// 测试 filesNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setFilesNum(null)));
// 准备参数
CodeRulePageReqVO reqVO = new CodeRulePageReqVO();
reqVO.setCaseNum(null);
reqVO.setCatalogNum(null);
reqVO.setFilesNum(null);
// 调用
PageResult<CodeRuleDO> pageResult = codeRuleService.getCodeRulePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbCodeRule, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetCodeRuleList() {
// mock 数据
CodeRuleDO dbCodeRule = randomPojo(CodeRuleDO.class, o -> { // 等会查询到
o.setCaseNum(null);
o.setCatalogNum(null);
o.setFilesNum(null);
});
codeRuleMapper.insert(dbCodeRule);
// 测试 caseNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setCaseNum(null)));
// 测试 catalogNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setCatalogNum(null)));
// 测试 filesNum 不匹配
codeRuleMapper.insert(cloneIgnoreId(dbCodeRule, o -> o.setFilesNum(null)));
// 准备参数
CodeRuleExportReqVO reqVO = new CodeRuleExportReqVO();
reqVO.setCaseNum(null);
reqVO.setCatalogNum(null);
reqVO.setFilesNum(null);
// 调用
List<CodeRuleDO> list = codeRuleService.getCodeRuleList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbCodeRule, list.get(0));
}
}

@ -27,6 +27,11 @@
<artifactId>yudao-module-bs-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-archives-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-biz</artifactId>

Loading…
Cancel
Save