会计账簿
parent
e5b1df08da
commit
fb74d22a6e
@ -0,0 +1,162 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||||
|
import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClient;
|
||||||
|
import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.accounting.convert.accountingbook.AccountingBookConvert;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.service.accountingbook.AccountingBookService;
|
||||||
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
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 java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
|
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 org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 会计账簿")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/archives/accounting-book")
|
||||||
|
@Validated
|
||||||
|
public class AccountingBookController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountingBookService accountingBookService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建会计账簿")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:create')")
|
||||||
|
public CommonResult<AccountingBookDO> createAccountingBook(AccountingBookCreateReqVO createReqVO) {
|
||||||
|
return success(accountingBookService.createAccountingBook(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账簿上传
|
||||||
|
*/
|
||||||
|
@PostMapping("/upload")
|
||||||
|
@Operation(summary = "上传会计账簿")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:create')")
|
||||||
|
public String uploadAccountingBook(@RequestPart("file") MultipartFile multipartFile,@RequestParam("type") String type) {
|
||||||
|
try {
|
||||||
|
//TODO minio配置 后续修改
|
||||||
|
S3FileClientConfig config = new S3FileClientConfig();
|
||||||
|
// 配置成你自己的
|
||||||
|
config.setAccessKey("minioadmin");
|
||||||
|
config.setAccessSecret("minioadmin");
|
||||||
|
config.setBucket("ktg-mes");
|
||||||
|
config.setDomain(null);
|
||||||
|
// 默认 9000 endpoint
|
||||||
|
config.setEndpoint("https://www.lyrfp.com");
|
||||||
|
|
||||||
|
// 执行上传
|
||||||
|
String uri = testExecuteUpload(config, multipartFile);
|
||||||
|
// String uri = fileService.createFile(multipartFile.getOriginalFilename(), multipartFile.getOriginalFilename(), multipartFile.getBytes());
|
||||||
|
//加入redis缓存
|
||||||
|
redisTemplate.boundValueOps("fileUrlKey").set(uri);
|
||||||
|
redisTemplate.boundValueOps("fileKeyName").set(multipartFile.getOriginalFilename());
|
||||||
|
redisTemplate.boundValueOps("fileKeyType").set(type);
|
||||||
|
return uri;
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "vo";
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO minio上传函数 后续封装为公用方法
|
||||||
|
private String testExecuteUpload(S3FileClientConfig config,MultipartFile file) throws Exception {
|
||||||
|
// 校验配置
|
||||||
|
ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config);
|
||||||
|
// 创建 Client
|
||||||
|
S3FileClient client = new S3FileClient(0L, config);
|
||||||
|
client.init();
|
||||||
|
// 上传文件
|
||||||
|
String path = file.getOriginalFilename();
|
||||||
|
// byte[] content = ResourceUtil.readBytes(file);
|
||||||
|
return client.upload(file.getBytes(), path, "xls/xlsx");
|
||||||
|
}
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新会计账簿")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:update')")
|
||||||
|
public CommonResult<Boolean> updateAccountingBook(@Valid @RequestBody AccountingBookUpdateReqVO updateReqVO) {
|
||||||
|
accountingBookService.updateAccountingBook(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除会计账簿")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:delete')")
|
||||||
|
public CommonResult<Boolean> deleteAccountingBook(@RequestParam("id") Long id) {
|
||||||
|
accountingBookService.deleteAccountingBook(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得会计账簿")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:query')")
|
||||||
|
public CommonResult<AccountingBookRespVO> getAccountingBook(@RequestParam("id") Long id) {
|
||||||
|
AccountingBookDO accountingBook = accountingBookService.getAccountingBook(id);
|
||||||
|
return success(AccountingBookConvert.INSTANCE.convert(accountingBook));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "获得会计账簿列表")
|
||||||
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:query')")
|
||||||
|
public CommonResult<List<AccountingBookRespVO>> getAccountingBookList(@RequestParam("ids") Collection<Long> ids) {
|
||||||
|
List<AccountingBookDO> list = accountingBookService.getAccountingBookList(ids);
|
||||||
|
return success(AccountingBookConvert.INSTANCE.convertList(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得会计账簿分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:query')")
|
||||||
|
public CommonResult<PageResult<AccountingBookRespVO>> getAccountingBookPage(@Valid AccountingBookPageReqVO pageVO) {
|
||||||
|
PageResult<AccountingBookDO> pageResult = accountingBookService.getAccountingBookPage(pageVO);
|
||||||
|
return success(AccountingBookConvert.INSTANCE.convertPage(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出会计账簿 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('archives:accounting-book:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportAccountingBookExcel(@Valid AccountingBookExportReqVO exportReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
List<AccountingBookDO> list = accountingBookService.getAccountingBookList(exportReqVO);
|
||||||
|
// 导出 Excel
|
||||||
|
List<AccountingBookExcelVO> datas = AccountingBookConvert.INSTANCE.convertList02(list);
|
||||||
|
ExcelUtils.write(response, "会计账簿.xls", "数据", AccountingBookExcelVO.class, datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookCreateReqVO extends AccountingBookBaseVO {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计账簿 Excel VO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AccountingBookExcelVO {
|
||||||
|
|
||||||
|
@ExcelProperty("账簿id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ExcelProperty("业务实体名称")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@ExcelProperty("业务实体")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@ExcelProperty("细分类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ExcelProperty("会计年度")
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
@ExcelProperty("会计期间")
|
||||||
|
private String period;
|
||||||
|
|
||||||
|
@ExcelProperty("账簿来源")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@ExcelProperty("摘要")
|
||||||
|
private String digest;
|
||||||
|
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ExcelProperty("加密")
|
||||||
|
private String encrypt;
|
||||||
|
|
||||||
|
@ExcelProperty("归档id")
|
||||||
|
private Long archiveId;
|
||||||
|
|
||||||
|
@ExcelProperty("归档状态")
|
||||||
|
private String archiveState;
|
||||||
|
|
||||||
|
@ExcelProperty("部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@ExcelProperty("所属部门")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "业务实体名称", example = "4767")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Schema(description = "业务实体")
|
||||||
|
private String company;
|
||||||
|
|
||||||
|
@Schema(description = "账簿文件url")
|
||||||
|
private String uri;
|
||||||
|
|
||||||
|
@Schema(description = "账簿文件名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "细分类型", example = "2")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Schema(description = "会计年度")
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
@Schema(description = "会计期间")
|
||||||
|
private String period;
|
||||||
|
|
||||||
|
@Schema(description = "账簿来源")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@Schema(description = "摘要")
|
||||||
|
private String digest;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "加密")
|
||||||
|
private String encrypt;
|
||||||
|
|
||||||
|
@Schema(description = "归档id", example = "26310")
|
||||||
|
private Long archiveId;
|
||||||
|
|
||||||
|
@Schema(description = "归档状态")
|
||||||
|
private String archiveState;
|
||||||
|
|
||||||
|
@Schema(description = "部门id", example = "15870")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "所属部门", example = "张三")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookRespVO extends AccountingBookBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "账簿id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26750")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "账簿文件uri")
|
||||||
|
private String uri;
|
||||||
|
|
||||||
|
@Schema(description = "账簿文件名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookUpdateReqVO extends AccountingBookBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "账簿id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26750")
|
||||||
|
@NotNull(message = "账簿id不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.convert.accountingbook;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExcelVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookRespVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计账簿 Convert
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AccountingBookConvert {
|
||||||
|
|
||||||
|
AccountingBookConvert INSTANCE = Mappers.getMapper(AccountingBookConvert.class);
|
||||||
|
|
||||||
|
AccountingBookDO convert(AccountingBookCreateReqVO bean);
|
||||||
|
|
||||||
|
AccountingBookDO convert(AccountingBookUpdateReqVO bean);
|
||||||
|
|
||||||
|
AccountingBookRespVO convert(AccountingBookDO bean);
|
||||||
|
|
||||||
|
List<AccountingBookRespVO> convertList(List<AccountingBookDO> list);
|
||||||
|
|
||||||
|
PageResult<AccountingBookRespVO> convertPage(PageResult<AccountingBookDO> page);
|
||||||
|
|
||||||
|
List<AccountingBookExcelVO> convertList02(List<AccountingBookDO> list);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
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_accounting_book")
|
||||||
|
@KeySequence("archives_accounting_book_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AccountingBookDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账簿id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账簿文件uri
|
||||||
|
*/
|
||||||
|
private String uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账簿文件uri
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务实体名称
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
/**
|
||||||
|
* 业务实体
|
||||||
|
*/
|
||||||
|
private String company;
|
||||||
|
/**
|
||||||
|
* 细分类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 会计年度
|
||||||
|
*/
|
||||||
|
private String year;
|
||||||
|
/**
|
||||||
|
* 会计期间
|
||||||
|
*/
|
||||||
|
private String period;
|
||||||
|
/**
|
||||||
|
* 账簿来源
|
||||||
|
*/
|
||||||
|
private String source;
|
||||||
|
/**
|
||||||
|
* 摘要
|
||||||
|
*/
|
||||||
|
private String digest;
|
||||||
|
/**
|
||||||
|
* 加密
|
||||||
|
*/
|
||||||
|
private String encrypt;
|
||||||
|
/**
|
||||||
|
* 归档id
|
||||||
|
*/
|
||||||
|
private Long archiveId;
|
||||||
|
/**
|
||||||
|
* 归档状态
|
||||||
|
*/
|
||||||
|
private String archiveState;
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.dal.mysql.accountingbook;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计账簿 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AccountingBookMapper extends BaseMapperX<AccountingBookDO> {
|
||||||
|
|
||||||
|
default PageResult<AccountingBookDO> selectPage(AccountingBookPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<AccountingBookDO>()
|
||||||
|
.eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(AccountingBookDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(AccountingBookDO::getUri, reqVO.getUri())
|
||||||
|
.eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(AccountingBookDO::getCompany, reqVO.getCompany())
|
||||||
|
.eqIfPresent(AccountingBookDO::getType, reqVO.getType())
|
||||||
|
.eqIfPresent(AccountingBookDO::getYear, reqVO.getYear())
|
||||||
|
.eqIfPresent(AccountingBookDO::getPeriod, reqVO.getPeriod())
|
||||||
|
.eqIfPresent(AccountingBookDO::getSource, reqVO.getSource())
|
||||||
|
.eqIfPresent(AccountingBookDO::getDigest, reqVO.getDigest())
|
||||||
|
.betweenIfPresent(AccountingBookDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(AccountingBookDO::getEncrypt, reqVO.getEncrypt())
|
||||||
|
.eqIfPresent(AccountingBookDO::getArchiveId, reqVO.getArchiveId())
|
||||||
|
.eqIfPresent(AccountingBookDO::getArchiveState, reqVO.getArchiveState())
|
||||||
|
.eqIfPresent(AccountingBookDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.likeIfPresent(AccountingBookDO::getName,reqVO.getName())
|
||||||
|
.likeIfPresent(AccountingBookDO::getDeptName, reqVO.getDeptName())
|
||||||
|
.orderByDesc(AccountingBookDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<AccountingBookDO> selectList(AccountingBookExportReqVO reqVO) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<AccountingBookDO>()
|
||||||
|
.eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(AccountingBookDO::getCompany, reqVO.getCompany())
|
||||||
|
.eqIfPresent(AccountingBookDO::getType, reqVO.getType())
|
||||||
|
.eqIfPresent(AccountingBookDO::getYear, reqVO.getYear())
|
||||||
|
.eqIfPresent(AccountingBookDO::getPeriod, reqVO.getPeriod())
|
||||||
|
.eqIfPresent(AccountingBookDO::getSource, reqVO.getSource())
|
||||||
|
.eqIfPresent(AccountingBookDO::getDigest, reqVO.getDigest())
|
||||||
|
.betweenIfPresent(AccountingBookDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(AccountingBookDO::getEncrypt, reqVO.getEncrypt())
|
||||||
|
.eqIfPresent(AccountingBookDO::getArchiveId, reqVO.getArchiveId())
|
||||||
|
.eqIfPresent(AccountingBookDO::getArchiveState, reqVO.getArchiveState())
|
||||||
|
.eqIfPresent(AccountingBookDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.likeIfPresent(AccountingBookDO::getDeptName, reqVO.getDeptName())
|
||||||
|
.orderByDesc(AccountingBookDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.service.accountingbook;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计账簿 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface AccountingBookService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建会计账簿
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
AccountingBookDO createAccountingBook(@Valid AccountingBookCreateReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新会计账簿
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateAccountingBook(@Valid AccountingBookUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会计账簿
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteAccountingBook(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计账簿
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 会计账簿
|
||||||
|
*/
|
||||||
|
AccountingBookDO getAccountingBook(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计账簿列表
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
* @return 会计账簿列表
|
||||||
|
*/
|
||||||
|
List<AccountingBookDO> getAccountingBookList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计账簿分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 会计账簿分页
|
||||||
|
*/
|
||||||
|
PageResult<AccountingBookDO> getAccountingBookPage(AccountingBookPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得会计账簿列表, 用于 Excel 导出
|
||||||
|
*
|
||||||
|
* @param exportReqVO 查询条件
|
||||||
|
* @return 会计账簿列表
|
||||||
|
*/
|
||||||
|
List<AccountingBookDO> getAccountingBookList(AccountingBookExportReqVO exportReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
package cn.iocoder.yudao.module.accounting.service.accountingbook;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.convert.accountingbook.AccountingBookConvert;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
||||||
|
import cn.iocoder.yudao.module.accounting.dal.mysql.accountingbook.AccountingBookMapper;
|
||||||
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.ACCOUNTING_BOOK_NOT_EXISTS;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会计账簿 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class AccountingBookServiceImpl implements AccountingBookService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountingBookMapper accountingBookMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccountingBookDO createAccountingBook(AccountingBookCreateReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
AccountingBookDO accountingBook = AccountingBookConvert.INSTANCE.convert(createReqVO);
|
||||||
|
// if (ObjectUtil.isNotNull(accountingBook)){
|
||||||
|
// redisTemplate.boundValueOps("Company").set(createReqVO.getCompany());
|
||||||
|
// redisTemplate.boundValueOps("Year").set(createReqVO.getYear());
|
||||||
|
// redisTemplate.boundValueOps("Period").set(createReqVO.getPeriod());
|
||||||
|
// }
|
||||||
|
// accountingBook.setCompany((String) redisTemplate.boundValueOps("Company").get());
|
||||||
|
// accountingBook.setYear((String) redisTemplate.boundValueOps("Year").get());
|
||||||
|
// accountingBook.setPeriod((String) redisTemplate.boundValueOps("Period").get());
|
||||||
|
//如果要优化可以改成redis存储一个包含 uri name type字段的对象 也可以查询 infra_file 表获得 uri地址和文件名称 redis只缓存type字段
|
||||||
|
String uri =(String) redisTemplate.boundValueOps("fileUrlKey").get();
|
||||||
|
String name =(String) redisTemplate.boundValueOps("fileKeyName").get();
|
||||||
|
String type =(String) redisTemplate.boundValueOps("fileKeyType").get();
|
||||||
|
if (ObjectUtil.isNotNull(uri) && ObjectUtil.isNotNull(name) && ObjectUtil.isNotNull(type)){
|
||||||
|
accountingBook.setUri(uri);
|
||||||
|
accountingBook.setName(name);
|
||||||
|
accountingBook.setType(type);
|
||||||
|
|
||||||
|
}
|
||||||
|
accountingBookMapper.insert(accountingBook);
|
||||||
|
// 返回
|
||||||
|
return accountingBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAccountingBook(AccountingBookUpdateReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateAccountingBookExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
AccountingBookDO updateObj = AccountingBookConvert.INSTANCE.convert(updateReqVO);
|
||||||
|
accountingBookMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAccountingBook(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateAccountingBookExists(id);
|
||||||
|
// 删除
|
||||||
|
accountingBookMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateAccountingBookExists(Long id) {
|
||||||
|
if (accountingBookMapper.selectById(id) == null) {
|
||||||
|
throw exception(ACCOUNTING_BOOK_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccountingBookDO getAccountingBook(Long id) {
|
||||||
|
return accountingBookMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AccountingBookDO> getAccountingBookList(Collection<Long> ids) {
|
||||||
|
return accountingBookMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<AccountingBookDO> getAccountingBookPage(AccountingBookPageReqVO pageReqVO) {
|
||||||
|
return accountingBookMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AccountingBookDO> getAccountingBookList(AccountingBookExportReqVO exportReqVO) {
|
||||||
|
return accountingBookMapper.selectList(exportReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue