Commit b851946cf0d4a7877a69c2680ae4fb7c17e2a21f

Authored by 房远帅
1 parent 33ad92f4

账期:无限担保书

Showing 15 changed files with 934 additions and 1 deletions
... ... @@ -974,3 +974,18 @@ CREATE TABLE `tbl_recapitalize` (
974 974 `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
975 975 PRIMARY KEY (`id`)
976 976 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='回笼资金表'
  977 +
  978 +
  979 +CREATE TABLE `unlimited_guarantee_letter`(
  980 + `id` varchar(32) NOT NULL COMMENT 'ID',
  981 + `ordering_unit` varchar(100) DEFAULT NULL COMMENT '订货单位ID',
  982 + `sign_date` date DEFAULT NULL COMMENT '签订日期',
  983 + `remark` text DEFAULT NULL COMMENT '备注',
  984 + `create_by_id` varchar(32) NOT NULL COMMENT '创建人ID',
  985 + `create_by` varchar(20) NOT NULL COMMENT '创建人',
  986 + `update_by_id` varchar(32) NOT NULL COMMENT '更新人ID',
  987 + `update_by` varchar(20) NOT NULL COMMENT '更新人',
  988 + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  989 + `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  990 + PRIMARY KEY (`id`)
  991 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='无限担保书明细表'
... ...
  1 +package com.lframework.xingyun.sc.bo.ledger.guarantee;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.lframework.starter.common.constants.StringPool;
  5 +import java.time.LocalDate;
  6 +
  7 +import com.lframework.starter.web.core.bo.BaseBo;
  8 +import com.lframework.starter.web.core.dto.BaseDto;
  9 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  10 +import io.swagger.annotations.ApiModelProperty;
  11 +
  12 +import lombok.Data;
  13 +
  14 +/**
  15 + * <p>
  16 + * 无限担保书明细表 GetBo
  17 + * </p>
  18 + *
  19 + */
  20 +@Data
  21 +public class GetUnlimitedGuaranteeLetterBo extends BaseBo<UnlimitedGuaranteeLetter> implements BaseDto {
  22 +
  23 + /**
  24 + * ID
  25 + */
  26 + @ApiModelProperty("ID")
  27 + private String id;
  28 +
  29 + /**
  30 + * 订货单位ID
  31 + */
  32 + @ApiModelProperty("订货单位ID")
  33 + private String orderingUnit;
  34 +
  35 + /**
  36 + * 订货单位名称
  37 + */
  38 + @ApiModelProperty("订货单位名称")
  39 + private String orderingUnitName;
  40 +
  41 + /**
  42 + * 签订日期
  43 + */
  44 + @ApiModelProperty("签订日期")
  45 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  46 + private LocalDate signDate;
  47 +
  48 + /**
  49 + * 备注
  50 + */
  51 + @ApiModelProperty("备注")
  52 + private String remark;
  53 +
  54 + public GetUnlimitedGuaranteeLetterBo() {
  55 +
  56 + }
  57 +
  58 + public GetUnlimitedGuaranteeLetterBo(UnlimitedGuaranteeLetter dto) {
  59 +
  60 + super(dto);
  61 + }
  62 +
  63 + @Override
  64 + public BaseBo<UnlimitedGuaranteeLetter> convert(UnlimitedGuaranteeLetter dto) {
  65 + return super.convert(dto);
  66 + }
  67 +
  68 + @Override
  69 + protected void afterInit(UnlimitedGuaranteeLetter dto) {
  70 +
  71 + }
  72 +}
... ...
  1 +package com.lframework.xingyun.sc.bo.ledger.guarantee;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.lframework.starter.common.constants.StringPool;
  5 +import java.time.LocalDate;
  6 +import com.lframework.starter.web.core.bo.BaseBo;
  7 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  8 +import io.swagger.annotations.ApiModelProperty;
  9 +
  10 +import lombok.Data;
  11 +
  12 +/**
  13 + * <p>
  14 + * 无限担保书明细表 QueryBo
  15 + * </p>
  16 + *
  17 + */
  18 +@Data
  19 +public class QueryUnlimitedGuaranteeLetterBo extends BaseBo<UnlimitedGuaranteeLetter> {
  20 +
  21 + /**
  22 + * ID
  23 + */
  24 + @ApiModelProperty("ID")
  25 + private String id;
  26 +
  27 + /**
  28 + * 订货单位ID
  29 + */
  30 + @ApiModelProperty("订货单位ID")
  31 + private String orderingUnit;
  32 +
  33 + /**
  34 + * 订货单位名称
  35 + */
  36 + @ApiModelProperty("订货单位名称")
  37 + private String orderingUnitName;
  38 +
  39 + /**
  40 + * 签订日期
  41 + */
  42 + @ApiModelProperty("签订日期")
  43 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  44 + private LocalDate signDate;
  45 +
  46 + /**
  47 + * 备注
  48 + */
  49 + @ApiModelProperty("备注")
  50 + private String remark;
  51 +
  52 + public QueryUnlimitedGuaranteeLetterBo() {
  53 +
  54 + }
  55 +
  56 + public QueryUnlimitedGuaranteeLetterBo(UnlimitedGuaranteeLetter dto) {
  57 +
  58 + super(dto);
  59 + }
  60 +
  61 + @Override
  62 + public BaseBo<UnlimitedGuaranteeLetter> convert(UnlimitedGuaranteeLetter dto) {
  63 + return super.convert(dto);
  64 + }
  65 +
  66 + @Override
  67 + protected void afterInit(UnlimitedGuaranteeLetter dto) {
  68 +
  69 + }
  70 +}
... ...
  1 +package com.lframework.xingyun.sc.controller.ledger;
  2 +
  3 +import com.lframework.starter.web.core.annotations.security.HasPermission;
  4 +import com.lframework.starter.web.core.components.resp.PageResult;
  5 +import com.lframework.starter.web.core.controller.DefaultBaseController;
  6 +import com.lframework.starter.web.core.utils.ExcelUtil;
  7 +import com.lframework.starter.web.core.utils.PageResultUtil;
  8 +import com.lframework.starter.web.core.components.resp.InvokeResult;
  9 +import javax.servlet.http.HttpServletResponse;
  10 +import javax.validation.constraints.NotBlank;
  11 +import com.lframework.xingyun.sc.bo.ledger.guarantee.GetUnlimitedGuaranteeLetterBo;
  12 +import com.lframework.xingyun.sc.bo.ledger.guarantee.QueryUnlimitedGuaranteeLetterBo;
  13 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  14 +import com.lframework.xingyun.sc.excel.ledger.UnlimitedGuaranteeLetterImportListener;
  15 +import com.lframework.xingyun.sc.excel.ledger.UnlimitedGuaranteeLetterImportModel;
  16 +import com.lframework.xingyun.sc.service.ledger.UnlimitedGuaranteeLetterService;
  17 +import com.lframework.xingyun.sc.vo.ledger.guarantee.CreateUnlimitedGuaranteeLetterVo;
  18 +import com.lframework.xingyun.sc.vo.ledger.guarantee.QueryUnlimitedGuaranteeLetterVo;
  19 +import com.lframework.xingyun.sc.vo.ledger.guarantee.UpdateUnlimitedGuaranteeLetterVo;
  20 +import io.swagger.annotations.ApiImplicitParam;
  21 +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
  22 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  23 +import io.swagger.annotations.ApiOperation;
  24 +import com.lframework.starter.common.utils.CollectionUtil;
  25 +import io.swagger.annotations.Api;
  26 +import org.springframework.web.bind.annotation.DeleteMapping;
  27 +import org.springframework.beans.factory.annotation.Autowired;
  28 +import org.springframework.validation.annotation.Validated;
  29 +import org.springframework.web.bind.annotation.*;
  30 +import org.springframework.web.multipart.MultipartFile;
  31 +
  32 +import javax.validation.Valid;
  33 +import javax.validation.constraints.NotNull;
  34 +import java.io.IOException;
  35 +import java.util.List;
  36 +import java.util.stream.Collectors;
  37 +
  38 +/**
  39 + * 无限担保书明细表 Controller
  40 + *
  41 + */
  42 +@Api(tags = "无限担保书明细表")
  43 +@Validated
  44 +@RestController
  45 +@RequestMapping("/unlimitedGuaranteeLetter")
  46 +public class UnlimitedGuaranteeLetterController extends DefaultBaseController {
  47 +
  48 + @Autowired
  49 + private UnlimitedGuaranteeLetterService unlimitedGuaranteeLetterService;
  50 +
  51 + /**
  52 + * 查询列表
  53 + */
  54 + @ApiOperation("查询列表")
  55 + @HasPermission({"base-data:guarantee:query"})
  56 + @GetMapping("/query")
  57 + public InvokeResult<PageResult<QueryUnlimitedGuaranteeLetterBo>> query(@Valid QueryUnlimitedGuaranteeLetterVo vo) {
  58 +
  59 + PageResult<UnlimitedGuaranteeLetter> pageResult = unlimitedGuaranteeLetterService.query(getPageIndex(vo), getPageSize(vo), vo);
  60 +
  61 + List<UnlimitedGuaranteeLetter> datas = pageResult.getDatas();
  62 + List<QueryUnlimitedGuaranteeLetterBo> results = null;
  63 +
  64 + if (!CollectionUtil.isEmpty(datas)) {
  65 + results = datas.stream().map(QueryUnlimitedGuaranteeLetterBo::new).collect(Collectors.toList());
  66 + }
  67 +
  68 + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
  69 + }
  70 +
  71 + /**
  72 + * 根据ID查询
  73 + */
  74 + @ApiOperation("根据ID查询")
  75 + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
  76 + @HasPermission({"base-data:guarantee:query"})
  77 + @GetMapping
  78 + public InvokeResult<GetUnlimitedGuaranteeLetterBo> get(@NotBlank(message = "id不能为空!") String id) {
  79 +
  80 + UnlimitedGuaranteeLetter data = unlimitedGuaranteeLetterService.findById(id);
  81 + if (data == null) {
  82 + throw new DefaultClientException("无限担保书明细表不存在!");
  83 + }
  84 +
  85 + GetUnlimitedGuaranteeLetterBo result = new GetUnlimitedGuaranteeLetterBo(data);
  86 +
  87 + return InvokeResultBuilder.success(result);
  88 + }
  89 +
  90 + /**
  91 + * 新增
  92 + */
  93 + @ApiOperation("新增")
  94 + @HasPermission({"base-data:guarantee:add"})
  95 + @PostMapping
  96 + public InvokeResult<Void> create(@Valid @RequestBody CreateUnlimitedGuaranteeLetterVo vo) {
  97 +
  98 + unlimitedGuaranteeLetterService.create(vo);
  99 +
  100 + return InvokeResultBuilder.success();
  101 + }
  102 +
  103 + /**
  104 + * 修改
  105 + */
  106 + @ApiOperation("修改")
  107 + @HasPermission({"base-data:guarantee:modify"})
  108 + @PutMapping
  109 + public InvokeResult<Void> update(@Valid @RequestBody UpdateUnlimitedGuaranteeLetterVo vo) {
  110 +
  111 + unlimitedGuaranteeLetterService.update(vo);
  112 +
  113 + return InvokeResultBuilder.success();
  114 + }
  115 +
  116 + /**
  117 + * 根据ID删除
  118 + */
  119 + @ApiOperation("根据ID删除")
  120 + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
  121 + @HasPermission({"base-data:guarantee:delete"})
  122 + @DeleteMapping
  123 + public InvokeResult<Void> deleteById(@NotBlank(message = "id不能为空!") String id) {
  124 +
  125 + unlimitedGuaranteeLetterService.deleteById(id);
  126 +
  127 + return InvokeResultBuilder.success();
  128 + }
  129 +
  130 + @ApiOperation("下载导入模板")
  131 + @HasPermission({"base-data:guarantee:import"})
  132 + @GetMapping("/import/template")
  133 + public void downloadImportTemplate(HttpServletResponse response) throws IOException {
  134 + ExcelUtil.exportXls("无限担保书导入模板", UnlimitedGuaranteeLetterImportModel.class);
  135 + }
  136 +
  137 + @ApiOperation("导入")
  138 + @HasPermission({"base-data:guarantee:import"})
  139 + @PostMapping("/import")
  140 + public InvokeResult<Void> importExcel(@NotBlank(message = "ID不能为空") String id,
  141 + @NotNull(message = "请上传文件") MultipartFile file) {
  142 +
  143 + UnlimitedGuaranteeLetterImportListener listener = new UnlimitedGuaranteeLetterImportListener();
  144 + listener.setTaskId(id);
  145 + ExcelUtil.read(file, UnlimitedGuaranteeLetterImportModel.class, listener).sheet().doRead();
  146 +
  147 + return InvokeResultBuilder.success();
  148 + }
  149 +}
... ...
  1 +package com.lframework.xingyun.sc.entity;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.TableName;
  4 +import com.lframework.starter.web.core.dto.BaseDto;
  5 +import java.time.LocalDate;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.FieldFill;
  8 +import com.lframework.starter.web.core.entity.BaseEntity;
  9 +import com.baomidou.mybatisplus.annotation.TableField;
  10 +import lombok.Data;
  11 +
  12 +/**
  13 + * <p>
  14 + * 无限担保书明细表
  15 + * </p>
  16 + *
  17 + */
  18 +@Data
  19 +@TableName("unlimited_guarantee_letter")
  20 +public class UnlimitedGuaranteeLetter extends BaseEntity implements BaseDto {
  21 +
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + public static final String CACHE_NAME = "UnlimitedGuaranteeLetter";
  25 +
  26 + /**
  27 + * ID
  28 + */
  29 + private String id;
  30 +
  31 + /**
  32 + * 订货单位ID
  33 + */
  34 + private String orderingUnit;
  35 +
  36 + /**
  37 + * 订货单位名称
  38 + */
  39 + @TableField(exist = false)
  40 + private String orderingUnitName;
  41 +
  42 + /**
  43 + * 签订日期
  44 + */
  45 + private LocalDate signDate;
  46 +
  47 + /**
  48 + * 备注
  49 + */
  50 + private String remark;
  51 +
  52 + /**
  53 + * 创建人ID
  54 + */
  55 + @TableField(fill = FieldFill.INSERT)
  56 + private String createById;
  57 +
  58 + /**
  59 + * 创建人
  60 + */
  61 + @TableField(fill = FieldFill.INSERT)
  62 + private String createBy;
  63 +
  64 + /**
  65 + * 更新人ID
  66 + */
  67 + @TableField(fill = FieldFill.INSERT_UPDATE)
  68 + private String updateById;
  69 +
  70 + /**
  71 + * 更新人
  72 + */
  73 + @TableField(fill = FieldFill.INSERT_UPDATE)
  74 + private String updateBy;
  75 +
  76 + /**
  77 + * 创建时间
  78 + */
  79 + @TableField(fill = FieldFill.INSERT)
  80 + private LocalDateTime createTime;
  81 +
  82 + /**
  83 + * 更新时间
  84 + */
  85 + @TableField(fill = FieldFill.INSERT_UPDATE)
  86 + private LocalDateTime updateTime;
  87 +
  88 +}
... ...
  1 +package com.lframework.xingyun.sc.excel.ledger;
  2 +
  3 +import com.alibaba.excel.context.AnalysisContext;
  4 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  5 +import com.lframework.starter.common.utils.StringUtil;
  6 +import com.lframework.starter.web.core.components.excel.ExcelImportListener;
  7 +import com.lframework.starter.web.core.utils.ApplicationUtil;
  8 +import com.lframework.xingyun.basedata.entity.Customer;
  9 +import com.lframework.xingyun.basedata.service.customer.CustomerService;
  10 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  11 +import com.lframework.xingyun.sc.service.ledger.UnlimitedGuaranteeLetterService;
  12 +import com.lframework.xingyun.sc.vo.ledger.guarantee.CreateUnlimitedGuaranteeLetterVo;
  13 +import com.lframework.xingyun.sc.vo.ledger.guarantee.QueryUnlimitedGuaranteeLetterVo;
  14 +import lombok.extern.slf4j.Slf4j;
  15 +import org.apache.commons.collections.CollectionUtils;
  16 +
  17 +import java.time.LocalDate;
  18 +import java.time.format.DateTimeFormatter;
  19 +import java.time.format.DateTimeParseException;
  20 +import java.util.ArrayList;
  21 +import java.util.Arrays;
  22 +import java.util.List;
  23 +
  24 +@Slf4j
  25 +public class UnlimitedGuaranteeLetterImportListener extends ExcelImportListener<UnlimitedGuaranteeLetterImportModel> {
  26 +
  27 + private List<String> checkList = new ArrayList<>();
  28 +
  29 + @Override
  30 + protected void doInvoke(UnlimitedGuaranteeLetterImportModel data, AnalysisContext context) {
  31 + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class);
  32 + if (StringUtil.isBlank(data.getOrderingUnitName())) {
  33 + throw new DefaultClientException(
  34 + "第" + context.readRowHolder().getRowIndex() + "行“订货单位名称”不能为空");
  35 + } else {
  36 + Customer customer = customerService.getByName(data.getOrderingUnitName());
  37 + if (customer == null) {
  38 + throw new DefaultClientException(
  39 + "第" + context.readRowHolder().getRowIndex() + "行“订货单位名称”不存在");
  40 + } else {
  41 + QueryUnlimitedGuaranteeLetterVo vo = new QueryUnlimitedGuaranteeLetterVo();
  42 + vo.setOrderingUnit(customer.getId());
  43 + UnlimitedGuaranteeLetterService guaranteeLetterService = ApplicationUtil.getBean(UnlimitedGuaranteeLetterService.class);
  44 + List<UnlimitedGuaranteeLetter> query = guaranteeLetterService.query(vo);
  45 + if (CollectionUtils.isNotEmpty(query) && query.size() > 0) {
  46 + throw new DefaultClientException(
  47 + "第" + context.readRowHolder().getRowIndex() + "行的“无限担保书”已存在");
  48 + }
  49 + data.setOrderingUnit(customer.getId());
  50 + }
  51 + }
  52 + if (StringUtil.isBlank(data.getSignDateStr())) {
  53 + throw new DefaultClientException(
  54 + "第" + context.readRowHolder().getRowIndex() + "行“签订日期”不能为空");
  55 + } else {
  56 + String dateStr = data.getSignDateStr().trim();
  57 + try {
  58 + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  59 + data.setSignDate(localDate);
  60 + } catch (DateTimeParseException e) {
  61 + try {
  62 + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/M/d"));
  63 + data.setSignDate(localDate);
  64 + } catch (DateTimeParseException ex) {
  65 + try {
  66 + // 支持 "2025年12月3日" 或 "2025年12月03日"
  67 + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy'年'M'月'd'日'"));
  68 + data.setSignDate(localDate);
  69 + } catch (DateTimeParseException ex2) {
  70 + throw new DefaultClientException(
  71 + "第" + context.readRowHolder().getRowIndex() + "行”签订日期“格式错误!");
  72 + }
  73 + }
  74 + }
  75 + }
  76 + if (checkList.contains(data.getOrderingUnitName())) {
  77 + throw new DefaultClientException(
  78 + "第" + context.readRowHolder().getRowIndex() + "行“订货单位名称”与第" + (checkList.indexOf(data.getOrderingUnitName()) + 1) + "行重复");
  79 + }
  80 + checkList.add(data.getOrderingUnitName());
  81 + }
  82 +
  83 + @Override
  84 + protected void afterAllAnalysed(AnalysisContext context) {
  85 + UnlimitedGuaranteeLetterService guaranteeLetterService = ApplicationUtil.getBean(UnlimitedGuaranteeLetterService.class);
  86 + List<UnlimitedGuaranteeLetterImportModel> datas = this.getDatas();
  87 + for (int i = 0; i < datas.size(); i++) {
  88 + UnlimitedGuaranteeLetterImportModel data = datas.get(i);
  89 + CreateUnlimitedGuaranteeLetterVo vo = new CreateUnlimitedGuaranteeLetterVo();
  90 + vo.setOrderingUnit(data.getOrderingUnit());
  91 + vo.setSignDate(data.getSignDate());
  92 + vo.setRemark(data.getRemark());
  93 + guaranteeLetterService.create(vo);
  94 + this.setSuccessProcess(i);
  95 + }
  96 + }
  97 +
  98 + @Override
  99 + protected void doComplete() {
  100 + }
  101 +}
... ...
  1 +package com.lframework.xingyun.sc.excel.ledger;
  2 +
  3 +import com.alibaba.excel.annotation.ExcelIgnore;
  4 +import com.alibaba.excel.annotation.ExcelProperty;
  5 +import com.lframework.starter.web.core.annotations.excel.ExcelRequired;
  6 +import com.lframework.starter.web.core.components.excel.ExcelModel;
  7 +import lombok.Data;
  8 +
  9 +import java.time.LocalDate;
  10 +
  11 +
  12 +@Data
  13 +public class UnlimitedGuaranteeLetterImportModel implements ExcelModel {
  14 +
  15 + @ExcelIgnore
  16 + private String id;
  17 +
  18 + /**
  19 + * 序号
  20 + */
  21 + @ExcelProperty("序号")
  22 + private String sort;
  23 +
  24 + /**
  25 + * 订货单位名称
  26 + */
  27 + @ExcelRequired
  28 + @ExcelProperty("订货单位名称")
  29 + private String orderingUnitName;
  30 +
  31 + /**
  32 + * 订货单位ID
  33 + */
  34 + @ExcelIgnore
  35 + private String orderingUnit;
  36 +
  37 + /**
  38 + * 签订日期
  39 + */
  40 + @ExcelRequired
  41 + @ExcelProperty("签订日期")
  42 + private String signDateStr;
  43 +
  44 + /**
  45 + * 签订日期
  46 + */
  47 + @ExcelIgnore
  48 + private LocalDate signDate;
  49 +
  50 + /**
  51 + * 备注
  52 + */
  53 + @ExcelProperty("备注")
  54 + private String remark;
  55 +
  56 +}
... ...
  1 +package com.lframework.xingyun.sc.impl.ledger;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5 +import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
  7 +import com.lframework.starter.web.core.utils.PageResultUtil;
  8 +import com.lframework.starter.web.core.components.resp.PageResult;
  9 +import com.lframework.starter.web.core.utils.OpLogUtil;
  10 +import com.lframework.starter.common.utils.StringUtil;
  11 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  12 +import java.io.Serializable;
  13 +import com.lframework.starter.web.core.utils.IdUtil;
  14 +import com.lframework.starter.common.utils.ObjectUtil;
  15 +import com.lframework.starter.web.core.annotations.oplog.OpLog;
  16 +import com.lframework.starter.web.core.utils.PageHelperUtil;
  17 +import com.lframework.starter.common.utils.Assert;
  18 +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  19 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  20 +import com.lframework.xingyun.sc.mappers.UnlimitedGuaranteeLetterMapper;
  21 +import com.lframework.xingyun.sc.service.ledger.UnlimitedGuaranteeLetterService;
  22 +import com.lframework.xingyun.sc.vo.ledger.guarantee.CreateUnlimitedGuaranteeLetterVo;
  23 +import com.lframework.xingyun.sc.vo.ledger.guarantee.QueryUnlimitedGuaranteeLetterVo;
  24 +import com.lframework.xingyun.sc.vo.ledger.guarantee.UpdateUnlimitedGuaranteeLetterVo;
  25 +import org.springframework.transaction.annotation.Transactional;
  26 +import org.springframework.stereotype.Service;
  27 +
  28 +import java.util.List;
  29 +
  30 +@Service
  31 +public class UnlimitedGuaranteeLetterServiceImpl extends BaseMpServiceImpl<UnlimitedGuaranteeLetterMapper, UnlimitedGuaranteeLetter> implements UnlimitedGuaranteeLetterService {
  32 +
  33 + @Override
  34 + public PageResult<UnlimitedGuaranteeLetter> query(Integer pageIndex, Integer pageSize, QueryUnlimitedGuaranteeLetterVo vo) {
  35 +
  36 + Assert.greaterThanZero(pageIndex);
  37 + Assert.greaterThanZero(pageSize);
  38 +
  39 + PageHelperUtil.startPage(pageIndex, pageSize);
  40 + List<UnlimitedGuaranteeLetter> datas = this.query(vo);
  41 +
  42 + return PageResultUtil.convert(new PageInfo<>(datas));
  43 + }
  44 +
  45 + @Override
  46 + public List<UnlimitedGuaranteeLetter> query(QueryUnlimitedGuaranteeLetterVo vo) {
  47 +
  48 + return getBaseMapper().query(vo);
  49 + }
  50 +
  51 + @Override
  52 + public UnlimitedGuaranteeLetter findById(String id) {
  53 +
  54 + return getBaseMapper().findById(id);
  55 + }
  56 +
  57 + @OpLog(type = OtherOpLogType.class, name = "新增无限担保书明细表,ID:{}", params = {"#id"})
  58 + @Transactional(rollbackFor = Exception.class)
  59 + @Override
  60 + public String create(CreateUnlimitedGuaranteeLetterVo vo) {
  61 +
  62 + UnlimitedGuaranteeLetter data = new UnlimitedGuaranteeLetter();
  63 + data.setId(IdUtil.getId());
  64 + if (!StringUtil.isBlank(vo.getOrderingUnit())) {
  65 + data.setOrderingUnit(vo.getOrderingUnit());
  66 + }
  67 + if (vo.getSignDate() != null) {
  68 + data.setSignDate(vo.getSignDate());
  69 + }
  70 + if (!StringUtil.isBlank(vo.getRemark())) {
  71 + data.setRemark(vo.getRemark());
  72 + }
  73 +
  74 + getBaseMapper().insert(data);
  75 +
  76 + OpLogUtil.setVariable("id", data.getId());
  77 + OpLogUtil.setExtra(vo);
  78 +
  79 + return data.getId();
  80 + }
  81 +
  82 + @OpLog(type = OtherOpLogType.class, name = "修改无限担保书明细表,ID:{}", params = {"#id"})
  83 + @Transactional(rollbackFor = Exception.class)
  84 + @Override
  85 + public void update(UpdateUnlimitedGuaranteeLetterVo vo) {
  86 +
  87 + UnlimitedGuaranteeLetter data = getBaseMapper().selectById(vo.getId());
  88 + if (ObjectUtil.isNull(data)) {
  89 + throw new DefaultClientException("无限担保书明细表不存在!");
  90 + }
  91 +
  92 + LambdaUpdateWrapper<UnlimitedGuaranteeLetter> updateWrapper = Wrappers.lambdaUpdate(UnlimitedGuaranteeLetter.class)
  93 + .set(UnlimitedGuaranteeLetter::getOrderingUnit, StringUtil.isBlank(vo.getOrderingUnit()) ? null : vo.getOrderingUnit())
  94 + .set(UnlimitedGuaranteeLetter::getSignDate, vo.getSignDate() == null ? null : vo.getSignDate())
  95 + .set(UnlimitedGuaranteeLetter::getRemark, StringUtil.isBlank(vo.getRemark()) ? null : vo.getRemark())
  96 + .eq(UnlimitedGuaranteeLetter::getId, vo.getId());
  97 +
  98 + getBaseMapper().update(updateWrapper);
  99 +
  100 + OpLogUtil.setVariable("id", data.getId());
  101 + OpLogUtil.setExtra(vo);
  102 + }
  103 +
  104 + @OpLog(type = OtherOpLogType.class, name = "删除无限担保书明细表,ID:{}", params = {"#id"})
  105 + @Transactional(rollbackFor = Exception.class)
  106 + @Override
  107 + public void deleteById(String id) {
  108 +
  109 + getBaseMapper().deleteById(id);
  110 + }
  111 +
  112 + @Override
  113 + public void cleanCacheByKey(Serializable key) {
  114 +
  115 + }
  116 +}
... ...
  1 +package com.lframework.xingyun.sc.mappers;
  2 +
  3 +import com.lframework.starter.web.core.mapper.BaseMapper;
  4 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  5 +import com.lframework.xingyun.sc.vo.ledger.guarantee.QueryUnlimitedGuaranteeLetterVo;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * <p>
  12 + * 无限担保书明细表 Mapper 接口
  13 + * </p>
  14 + *
  15 + */
  16 +public interface UnlimitedGuaranteeLetterMapper extends BaseMapper<UnlimitedGuaranteeLetter> {
  17 +
  18 + /**
  19 + * 查询列表
  20 + * @param vo
  21 + * @return
  22 + */
  23 + List<UnlimitedGuaranteeLetter> query(@Param("vo") QueryUnlimitedGuaranteeLetterVo vo);
  24 +
  25 + UnlimitedGuaranteeLetter findById(@Param("id") String id);
  26 +}
... ...
  1 +package com.lframework.xingyun.sc.service.ledger;
  2 +
  3 +import com.lframework.starter.web.core.service.BaseMpService;
  4 +import com.lframework.starter.web.core.components.resp.PageResult;
  5 +import com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter;
  6 +import com.lframework.xingyun.sc.vo.ledger.guarantee.CreateUnlimitedGuaranteeLetterVo;
  7 +import com.lframework.xingyun.sc.vo.ledger.guarantee.QueryUnlimitedGuaranteeLetterVo;
  8 +import com.lframework.xingyun.sc.vo.ledger.guarantee.UpdateUnlimitedGuaranteeLetterVo;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * 无限担保书明细表 Service
  13 + */
  14 +public interface UnlimitedGuaranteeLetterService extends BaseMpService<UnlimitedGuaranteeLetter> {
  15 +
  16 + /**
  17 + * 查询列表
  18 + * @return
  19 + */
  20 + PageResult<UnlimitedGuaranteeLetter> query(Integer pageIndex, Integer pageSize, QueryUnlimitedGuaranteeLetterVo vo);
  21 +
  22 + /**
  23 + * 查询列表
  24 + * @param vo
  25 + * @return
  26 + */
  27 + List<UnlimitedGuaranteeLetter> query(QueryUnlimitedGuaranteeLetterVo vo);
  28 +
  29 + /**
  30 + * 根据ID查询
  31 + * @param id
  32 + * @return
  33 + */
  34 + UnlimitedGuaranteeLetter findById(String id);
  35 +
  36 + /**
  37 + * 创建
  38 + * @param vo
  39 + * @return
  40 + */
  41 + String create(CreateUnlimitedGuaranteeLetterVo vo);
  42 +
  43 + /**
  44 + * 修改
  45 + * @param vo
  46 + */
  47 + void update(UpdateUnlimitedGuaranteeLetterVo vo);
  48 +
  49 + /**
  50 + * 根据ID删除
  51 + * @param id
  52 + * @return
  53 + */
  54 + void deleteById(String id);
  55 +}
... ...
  1 +package com.lframework.xingyun.sc.vo.ledger.guarantee;
  2 +
  3 +import java.time.LocalDate;
  4 +import com.lframework.starter.web.core.vo.BaseVo;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import com.lframework.starter.web.core.components.validation.TypeMismatch;
  7 +import org.hibernate.validator.constraints.Length;
  8 +import java.io.Serializable;
  9 +import lombok.Data;
  10 +
  11 +@Data
  12 +public class CreateUnlimitedGuaranteeLetterVo implements BaseVo, Serializable {
  13 +
  14 + private static final long serialVersionUID = 1L;
  15 +
  16 + /**
  17 + * 订货单位ID
  18 + */
  19 + @ApiModelProperty("订货单位ID")
  20 + @Length(message = "订货单位ID最多允许100个字符!")
  21 + private String orderingUnit;
  22 +
  23 + /**
  24 + * 签订日期
  25 + */
  26 + @ApiModelProperty("签订日期")
  27 + @TypeMismatch(message = "签订日期格式有误!")
  28 + private LocalDate signDate;
  29 +
  30 + /**
  31 + * 备注
  32 + */
  33 + @ApiModelProperty("备注")
  34 + @Length(message = "备注最多允许65,535个字符!")
  35 + private String remark;
  36 +
  37 +}
... ...
  1 +package com.lframework.xingyun.sc.vo.ledger.guarantee;
  2 +
  3 +import lombok.Data;
  4 +import com.lframework.starter.web.core.vo.PageVo;
  5 +import com.lframework.starter.web.core.vo.BaseVo;
  6 +import io.swagger.annotations.ApiModelProperty;
  7 +import java.io.Serializable;
  8 +
  9 +@Data
  10 +public class QueryUnlimitedGuaranteeLetterVo extends PageVo implements BaseVo, Serializable {
  11 +
  12 + private static final long serialVersionUID = 1L;
  13 +
  14 + /**
  15 + * 订货单位ID
  16 + */
  17 + @ApiModelProperty("订货单位ID")
  18 + private String orderingUnit;
  19 +
  20 + /**
  21 + * 订货单位名称
  22 + */
  23 + @ApiModelProperty("订货单位名称")
  24 + private String orderingUnitName;
  25 +
  26 + /**
  27 + * 签订日期开始
  28 + */
  29 + @ApiModelProperty("签订日期开始")
  30 + private String signDateStart;
  31 +
  32 + /**
  33 + * 签订日期结束
  34 + */
  35 + @ApiModelProperty("签订日期结束")
  36 + private String signDateEnd;
  37 +
  38 +}
... ...
  1 +package com.lframework.xingyun.sc.vo.ledger.guarantee;
  2 +
  3 +import lombok.Data;
  4 +import javax.validation.constraints.NotBlank;
  5 +import java.time.LocalDate;
  6 +import com.lframework.starter.web.core.vo.BaseVo;
  7 +import com.lframework.starter.web.core.components.validation.TypeMismatch;
  8 +import io.swagger.annotations.ApiModelProperty;
  9 +import org.hibernate.validator.constraints.Length;
  10 +import java.io.Serializable;
  11 +
  12 +@Data
  13 +public class UpdateUnlimitedGuaranteeLetterVo implements BaseVo, Serializable {
  14 +
  15 + private static final long serialVersionUID = 1L;
  16 +
  17 + /**
  18 + * ID
  19 + */
  20 + @ApiModelProperty(value = "ID", required = true)
  21 + @NotBlank(message = "id不能为空!")
  22 + private String id;
  23 +
  24 + /**
  25 + * 订货单位ID
  26 + */
  27 + @ApiModelProperty("订货单位ID")
  28 + @Length(message = "订货单位ID最多允许100个字符!")
  29 + private String orderingUnit;
  30 +
  31 + /**
  32 + * 签订日期
  33 + */
  34 + @ApiModelProperty("签订日期")
  35 + @TypeMismatch(message = "签订日期格式有误!")
  36 + private LocalDate signDate;
  37 +
  38 + /**
  39 + * 备注
  40 + */
  41 + @ApiModelProperty("备注")
  42 + @Length(message = "备注最多允许65,535个字符!")
  43 + private String remark;
  44 +
  45 +}
... ...
... ... @@ -46,7 +46,7 @@
46 46 <if test="vo.recapitalizeDateStart != null and vo.recapitalizeDateStart != ''">
47 47 AND tb.recapitalize_date >= #{vo.recapitalizeDateStart}
48 48 </if>
49   - <if test="vo.recapitalizeDateEnd != null and vo.recapitalizeDateStart != ''">
  49 + <if test="vo.recapitalizeDateEnd != null and vo.recapitalizeDateEnd != ''">
50 50 <![CDATA[
51 51 AND tb.recapitalize_date <= #{vo.recapitalizeDateEnd}
52 52 ]]>
... ...
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.lframework.xingyun.sc.mappers.UnlimitedGuaranteeLetterMapper">
  4 +
  5 + <resultMap id="UnlimitedGuaranteeLetter" type="com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter">
  6 + <id column="id" property="id"/>
  7 + <result column="ordering_unit" property="orderingUnit"/>
  8 + <result column="ordering_unit_name" property="orderingUnitName"/>
  9 + <result column="sign_date" property="signDate"/>
  10 + <result column="remark" property="remark"/>
  11 + <result column="create_by_id" property="createById"/>
  12 + <result column="create_by" property="createBy"/>
  13 + <result column="update_by_id" property="updateById"/>
  14 + <result column="update_by" property="updateBy"/>
  15 + <result column="create_time" property="createTime"/>
  16 + <result column="update_time" property="updateTime"/>
  17 + </resultMap>
  18 +
  19 + <sql id="UnlimitedGuaranteeLetter_sql">
  20 + SELECT
  21 + tb.id,
  22 + tb.ordering_unit,
  23 + cu.name AS ordering_unit_name,
  24 + tb.sign_date,
  25 + tb.remark,
  26 + tb.create_by_id,
  27 + tb.create_by,
  28 + tb.update_by_id,
  29 + tb.update_by,
  30 + tb.create_time,
  31 + tb.update_time
  32 + FROM unlimited_guarantee_letter AS tb
  33 + left join base_data_customer as cu on cu.id = tb.ordering_unit
  34 + </sql>
  35 +
  36 + <select id="query" resultMap="UnlimitedGuaranteeLetter">
  37 + <include refid="UnlimitedGuaranteeLetter_sql"/>
  38 + <where>
  39 + <if test="vo.orderingUnit != null and vo.orderingUnit != ''">
  40 + AND tb.ordering_unit = #{vo.orderingUnit}
  41 + </if>
  42 + <if test="vo.orderingUnitName != null and vo.orderingUnitName != ''">
  43 + AND cu.name LIKE CONCAT('%', #{vo.orderingUnitName}, '%')
  44 + </if>
  45 + <if test="vo.signDateStart != null and vo.signDateStart != ''">
  46 + AND tb.sign_date >= #{vo.signDateStart}
  47 + </if>
  48 + <if test="vo.signDateEnd != null and vo.signDateEnd != ''">
  49 + <![CDATA[
  50 + AND tb.sign_date <= #{vo.signDateEnd}
  51 + ]]>
  52 + </if>
  53 + </where>
  54 + ORDER BY tb.create_time DESC
  55 + </select>
  56 +
  57 + <select id="findById" resultType="com.lframework.xingyun.sc.entity.UnlimitedGuaranteeLetter">
  58 + <include refid="UnlimitedGuaranteeLetter_sql"/>
  59 + <where>
  60 + <if test="id != null and id != ''">
  61 + AND tb.id = #{id}
  62 + </if>
  63 + </where>
  64 + </select>
  65 +</mapper>
... ...