Showing
11 changed files
with
856 additions
and
1 deletions
| @@ -56,4 +56,23 @@ create table if not exists base_data_product_variety ( | @@ -56,4 +56,23 @@ create table if not exists base_data_product_variety ( | ||
| 56 | update_by varchar(20) not null comment '更新人', | 56 | update_by varchar(20) not null comment '更新人', |
| 57 | create_time datetime default now() comment '创建时间', | 57 | create_time datetime default now() comment '创建时间', |
| 58 | update_time datetime default now() comment '更新时间' | 58 | update_time datetime default now() comment '更新时间' |
| 59 | -); | ||
| 59 | +); | ||
| 60 | + | ||
| 61 | + | ||
| 62 | +-- 合同框架 | ||
| 63 | +create table if not exists `tbl_contract_framework` ( | ||
| 64 | + `id` varchar(32) primary key comment 'ID', | ||
| 65 | + `code` varchar(20) not null comment '编号', | ||
| 66 | + `customer_id` varchar(32) not null comment '客户id', | ||
| 67 | + `company` varchar(50) not null comment '所属单位', | ||
| 68 | + `has_framework_agreement` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否签订框架合同', | ||
| 69 | + `material_type_id` varchar(32) NOT NULL COMMENT '品种id', | ||
| 70 | + `validity_time` datetime comment '期限', | ||
| 71 | + `create_by_id` varchar(32) not null comment '创建人ID', | ||
| 72 | + `create_by` varchar(20) not null comment '创建人', | ||
| 73 | + `update_by_id` varchar(32) not null comment '更新人ID', | ||
| 74 | + `update_by` varchar(20) not null comment '更新人', | ||
| 75 | + `create_time` datetime default now() comment '创建时间', | ||
| 76 | + `update_time` datetime default now() comment '更新时间' | ||
| 77 | + ); | ||
| 78 | + |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/contract/QueryContractFrameworkBo.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.bo.contract; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import com.lframework.starter.common.constants.StringPool; | ||
| 5 | +import com.lframework.starter.web.core.bo.BaseBo; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 10 | +import com.lframework.xingyun.sc.entity.ContractFramework; | ||
| 11 | +import io.swagger.annotations.ApiModelProperty; | ||
| 12 | + | ||
| 13 | +import lombok.Data; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * <p> | ||
| 17 | + * 合同框架 QueryBo | ||
| 18 | + * </p> | ||
| 19 | + */ | ||
| 20 | +@Data | ||
| 21 | +public class QueryContractFrameworkBo extends BaseBo<ContractFramework> { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * ID | ||
| 25 | + */ | ||
| 26 | + @ApiModelProperty("ID") | ||
| 27 | + private String id; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 编号 | ||
| 31 | + */ | ||
| 32 | + @ApiModelProperty("编号") | ||
| 33 | + private String code; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 客户id | ||
| 37 | + */ | ||
| 38 | + @ApiModelProperty("客户id") | ||
| 39 | + private String customerId; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 客户名称 | ||
| 43 | + */ | ||
| 44 | + @ApiModelProperty("客户名称") | ||
| 45 | + private String customerName; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 所属单位 | ||
| 49 | + */ | ||
| 50 | + @ApiModelProperty("所属单位") | ||
| 51 | + private String company; | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 品种id | ||
| 55 | + */ | ||
| 56 | + @ApiModelProperty("品种") | ||
| 57 | + private String materialTypeId; | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 品种名称 | ||
| 61 | + */ | ||
| 62 | + @ApiModelProperty("品种名称") | ||
| 63 | + private String materialTypeName; | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 期限 | ||
| 67 | + */ | ||
| 68 | + @ApiModelProperty("期限") | ||
| 69 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 70 | + private LocalDateTime validityTime; | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 是否签订框架合同 | ||
| 74 | + */ | ||
| 75 | + @ApiModelProperty("是否签订框架合同") | ||
| 76 | + private Boolean hasFrameworkAgreement; | ||
| 77 | + | ||
| 78 | + public QueryContractFrameworkBo() { | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public QueryContractFrameworkBo(ContractFramework dto) { | ||
| 83 | + | ||
| 84 | + super(dto); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + public BaseBo<ContractFramework> convert(ContractFramework dto) { | ||
| 89 | + return super.convert(dto); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + protected void afterInit(ContractFramework dto) { | ||
| 94 | + | ||
| 95 | + } | ||
| 96 | +} |
| 1 | +package com.lframework.xingyun.sc.controller.contract; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 4 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | ||
| 5 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | ||
| 6 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | ||
| 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.components.resp.InvokeResult; | ||
| 10 | +import com.lframework.xingyun.basedata.entity.Customer; | ||
| 11 | +import com.lframework.xingyun.basedata.entity.ProductVariety; | ||
| 12 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | ||
| 13 | +import com.lframework.xingyun.basedata.service.product.ProductVarietyService; | ||
| 14 | +import com.lframework.xingyun.sc.bo.contract.QueryContractFrameworkBo; | ||
| 15 | +import com.lframework.xingyun.sc.entity.ContractFramework; | ||
| 16 | +import com.lframework.xingyun.sc.service.contract.ContractFrameworkService; | ||
| 17 | +import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractFrameworkVo; | ||
| 18 | +import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; | ||
| 19 | +import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractFrameworkVo; | ||
| 20 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 21 | +import io.swagger.annotations.ApiOperation; | ||
| 22 | +import com.lframework.starter.common.utils.CollectionUtil; | ||
| 23 | +import io.swagger.annotations.Api; | ||
| 24 | +import org.apache.commons.collections4.CollectionUtils; | ||
| 25 | +import org.apache.commons.lang3.StringUtils; | ||
| 26 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 27 | +import org.springframework.validation.annotation.Validated; | ||
| 28 | +import org.springframework.web.bind.annotation.*; | ||
| 29 | + | ||
| 30 | +import javax.validation.Valid; | ||
| 31 | +import javax.validation.constraints.NotBlank; | ||
| 32 | +import java.util.HashMap; | ||
| 33 | +import java.util.List; | ||
| 34 | +import java.util.Map; | ||
| 35 | +import java.util.function.Function; | ||
| 36 | +import java.util.stream.Collectors; | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * 合同框架 Controller | ||
| 40 | + */ | ||
| 41 | +@Api(tags = "合同框架") | ||
| 42 | +@Validated | ||
| 43 | +@RestController | ||
| 44 | +@RequestMapping("/contract/contractFramework") | ||
| 45 | +public class ContractFrameworkController extends DefaultBaseController { | ||
| 46 | + | ||
| 47 | + @Autowired | ||
| 48 | + private ContractFrameworkService contractFrameworkService; | ||
| 49 | + @Autowired | ||
| 50 | + private ProductVarietyService productVarietyService; | ||
| 51 | + @Autowired | ||
| 52 | + private CustomerService customerService; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 查询列表 | ||
| 56 | + */ | ||
| 57 | + @ApiOperation("查询列表") | ||
| 58 | + @HasPermission({"contractFramework:contractFramework:query"}) | ||
| 59 | + @GetMapping("/query") | ||
| 60 | + public InvokeResult<PageResult<QueryContractFrameworkBo>> query(@Valid QueryContractFrameworkVo vo) { | ||
| 61 | + | ||
| 62 | + PageResult<ContractFramework> pageResult = contractFrameworkService.query(getPageIndex(vo), getPageSize(vo), vo); | ||
| 63 | + | ||
| 64 | + List<ContractFramework> datas = pageResult.getDatas(); | ||
| 65 | + List<QueryContractFrameworkBo> results = null; | ||
| 66 | + | ||
| 67 | + if (!CollectionUtil.isEmpty(datas)) { | ||
| 68 | + results = datas.stream().map(QueryContractFrameworkBo::new).collect(Collectors.toList()); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + PageResult<QueryContractFrameworkBo> boPageResult = PageResultUtil.rebuild(pageResult, results); | ||
| 72 | + if (CollectionUtils.isEmpty(boPageResult.getDatas())) { | ||
| 73 | + return InvokeResultBuilder.success(boPageResult); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + results = boPageResult.getDatas(); | ||
| 77 | + List<String> materialTypeIdList = results.stream().map(QueryContractFrameworkBo::getMaterialTypeId).collect(Collectors.toList()); | ||
| 78 | + Map<String, ProductVariety> productVarietyMap = new HashMap<>(materialTypeIdList.size()); | ||
| 79 | + if (CollectionUtils.isNotEmpty(materialTypeIdList)) { | ||
| 80 | + List<ProductVariety> productVarietyList = productVarietyService.listByIds(materialTypeIdList); | ||
| 81 | + productVarietyMap.putAll(CollectionUtils.emptyIfNull(productVarietyList) | ||
| 82 | + .stream() | ||
| 83 | + .collect(Collectors.toMap(ProductVariety::getId, Function.identity()))); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + List<String> customerIdList = results.stream().map(QueryContractFrameworkBo::getCustomerId).collect(Collectors.toList()); | ||
| 87 | + Map<String, Customer> customerMap = new HashMap<>(customerIdList.size()); | ||
| 88 | + if (CollectionUtils.isNotEmpty(customerIdList)) { | ||
| 89 | + List<Customer> customerList = customerService.listByIds(customerIdList); | ||
| 90 | + customerMap.putAll(CollectionUtils.emptyIfNull(customerList) | ||
| 91 | + .stream() | ||
| 92 | + .collect(Collectors.toMap(Customer::getId, Function.identity()))); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + results.forEach(bo -> { | ||
| 96 | + if (bo == null) return; | ||
| 97 | + | ||
| 98 | + if (StringUtils.isNotBlank(bo.getMaterialTypeId())) { | ||
| 99 | + ProductVariety productVariety = productVarietyMap.get(bo.getMaterialTypeId()); | ||
| 100 | + bo.setMaterialTypeName(productVariety != null ? productVariety.getName() : ""); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + if (StringUtils.isNotBlank(bo.getCustomerId())) { | ||
| 104 | + Customer customer = customerMap.get(bo.getCustomerId()); | ||
| 105 | + bo.setCustomerName(customer != null ? customer.getName() : ""); | ||
| 106 | + } | ||
| 107 | + }); | ||
| 108 | + | ||
| 109 | + boPageResult.setDatas(results); | ||
| 110 | + return InvokeResultBuilder.success(boPageResult); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * 新增 | ||
| 115 | + */ | ||
| 116 | + @ApiOperation("新增") | ||
| 117 | + @HasPermission({"contractFramework:contractFramework:add"}) | ||
| 118 | + @PostMapping | ||
| 119 | + public InvokeResult<String> create(@Valid CreateContractFrameworkVo vo) { | ||
| 120 | + return InvokeResultBuilder.success(contractFrameworkService.create(vo)); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 根据ID查询 | ||
| 125 | + */ | ||
| 126 | + @ApiOperation("根据ID查询") | ||
| 127 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 128 | + @HasPermission({"contractFramework:contractFramework:query"}) | ||
| 129 | + @GetMapping | ||
| 130 | + public InvokeResult<QueryContractFrameworkBo> get(@NotBlank(message = "id不能为空!") String id) { | ||
| 131 | + | ||
| 132 | + ContractFramework data = contractFrameworkService.findById(id); | ||
| 133 | + if (data == null) { | ||
| 134 | + throw new DefaultClientException("合同框架不存在!"); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + QueryContractFrameworkBo result = new QueryContractFrameworkBo(data); | ||
| 138 | + String materialTypeId = result.getMaterialTypeId(); | ||
| 139 | + ProductVariety productVariety = productVarietyService.findById(materialTypeId); | ||
| 140 | + String customerId = result.getCustomerId(); | ||
| 141 | + Customer customer = customerService.findById(customerId); | ||
| 142 | + result.setMaterialTypeName(productVariety != null ? productVariety.getName() : ""); | ||
| 143 | + result.setCustomerName(customer != null ? customer.getName() : ""); | ||
| 144 | + | ||
| 145 | + return InvokeResultBuilder.success(result); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * 修改 | ||
| 151 | + */ | ||
| 152 | + @ApiOperation("修改") | ||
| 153 | + @HasPermission({"contractFramework:contractFramework:modify"}) | ||
| 154 | + @PutMapping | ||
| 155 | + public InvokeResult<Void> update(@Valid UpdateContractFrameworkVo vo) { | ||
| 156 | + | ||
| 157 | + contractFrameworkService.update(vo); | ||
| 158 | + | ||
| 159 | + contractFrameworkService.cleanCacheByKey(vo.getId()); | ||
| 160 | + | ||
| 161 | + return InvokeResultBuilder.success(); | ||
| 162 | + } | ||
| 163 | +} |
| 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 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +import com.baomidou.mybatisplus.annotation.FieldFill; | ||
| 9 | +import com.lframework.starter.web.core.entity.BaseEntity; | ||
| 10 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 11 | +import lombok.Data; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * <p> | ||
| 15 | + * 合同框架 | ||
| 16 | + * </p> | ||
| 17 | + */ | ||
| 18 | +@Data | ||
| 19 | +@TableName("tbl_contract_framework") | ||
| 20 | +public class ContractFramework extends BaseEntity implements BaseDto { | ||
| 21 | + | ||
| 22 | + private static final long serialVersionUID = 1L; | ||
| 23 | + | ||
| 24 | + public static final String CACHE_NAME = "TblContractFramework"; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * ID | ||
| 28 | + */ | ||
| 29 | + private String id; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 编号 | ||
| 33 | + */ | ||
| 34 | + private String code; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 客户id | ||
| 38 | + */ | ||
| 39 | + private String customerId; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 所属单位 | ||
| 43 | + */ | ||
| 44 | + private String company; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 是否签订框架合同 | ||
| 48 | + */ | ||
| 49 | + private Boolean hasFrameworkAgreement; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 品种 | ||
| 53 | + */ | ||
| 54 | + private String materialTypeId; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 期限 | ||
| 58 | + */ | ||
| 59 | + private LocalDateTime validityTime; | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 创建人ID | ||
| 63 | + */ | ||
| 64 | + @TableField(fill = FieldFill.INSERT) | ||
| 65 | + private String createById; | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 创建人 | ||
| 69 | + */ | ||
| 70 | + @TableField(fill = FieldFill.INSERT) | ||
| 71 | + private String createBy; | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 更新人ID | ||
| 75 | + */ | ||
| 76 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 77 | + private String updateById; | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 更新人 | ||
| 81 | + */ | ||
| 82 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 83 | + private String updateBy; | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 创建时间 | ||
| 87 | + */ | ||
| 88 | + @TableField(fill = FieldFill.INSERT) | ||
| 89 | + private LocalDateTime createTime; | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 更新时间 | ||
| 93 | + */ | ||
| 94 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 95 | + private LocalDateTime updateTime; | ||
| 96 | + | ||
| 97 | +} |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/contract/ContractFrameworkServiceImpl.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.impl.contract; | ||
| 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.common.exceptions.impl.DefaultClientException; | ||
| 7 | +import com.lframework.starter.common.utils.Assert; | ||
| 8 | +import com.lframework.starter.common.utils.ObjectUtil; | ||
| 9 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | ||
| 10 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 11 | +import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | ||
| 12 | +import com.lframework.starter.web.core.utils.IdUtil; | ||
| 13 | +import com.lframework.starter.web.core.utils.OpLogUtil; | ||
| 14 | +import com.lframework.starter.web.core.utils.PageHelperUtil; | ||
| 15 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 16 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | ||
| 17 | +import com.lframework.xingyun.sc.entity.ContractFramework; | ||
| 18 | +import com.lframework.xingyun.sc.mappers.ContractFrameworkMapper; | ||
| 19 | +import com.lframework.xingyun.sc.service.contract.ContractFrameworkService; | ||
| 20 | +import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractFrameworkVo; | ||
| 21 | +import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; | ||
| 22 | +import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractFrameworkVo; | ||
| 23 | +import org.springframework.cache.annotation.CacheEvict; | ||
| 24 | +import org.springframework.cache.annotation.Cacheable; | ||
| 25 | +import org.springframework.stereotype.Service; | ||
| 26 | +import org.springframework.transaction.annotation.Transactional; | ||
| 27 | + | ||
| 28 | +import java.io.Serializable; | ||
| 29 | +import java.util.List; | ||
| 30 | + | ||
| 31 | +@Service | ||
| 32 | +public class ContractFrameworkServiceImpl extends BaseMpServiceImpl<ContractFrameworkMapper, ContractFramework> implements ContractFrameworkService { | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public PageResult<ContractFramework> query(Integer pageIndex, Integer pageSize, QueryContractFrameworkVo vo) { | ||
| 36 | + | ||
| 37 | + Assert.greaterThanZero(pageIndex); | ||
| 38 | + Assert.greaterThanZero(pageSize); | ||
| 39 | + | ||
| 40 | + PageHelperUtil.startPage(pageIndex, pageSize); | ||
| 41 | + List<ContractFramework> datas = this.query(vo); | ||
| 42 | + | ||
| 43 | + return PageResultUtil.convert(new PageInfo<>(datas)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public List<ContractFramework> query(QueryContractFrameworkVo vo) { | ||
| 48 | + | ||
| 49 | + return getBaseMapper().query(vo); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Cacheable(value = ContractFramework.CACHE_NAME, key = "@cacheVariables.tenantId() + #id", unless = "#result == null") | ||
| 53 | + @Override | ||
| 54 | + public ContractFramework findById(String id) { | ||
| 55 | + | ||
| 56 | + return getBaseMapper().selectById(id); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @OpLog(type = OtherOpLogType.class, name = "更新合同框架,ID:{}", params = {"#id"}) | ||
| 60 | + @Transactional(rollbackFor = Exception.class) | ||
| 61 | + @Override | ||
| 62 | + public void update(UpdateContractFrameworkVo vo) { | ||
| 63 | + ContractFramework data = getBaseMapper().selectById(vo.getId()); | ||
| 64 | + if (ObjectUtil.isNull(data)) { | ||
| 65 | + throw new DefaultClientException("合同框架不存在!"); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + LambdaUpdateWrapper<ContractFramework> updateWrapper = Wrappers.lambdaUpdate(ContractFramework.class) | ||
| 69 | + .set(ContractFramework::getCode, vo.getCode()) | ||
| 70 | + .set(ContractFramework::getCustomerId, vo.getCustomerId()) | ||
| 71 | + .set(ContractFramework::getCompany, vo.getCompany()) | ||
| 72 | + .set(ContractFramework::getHasFrameworkAgreement, vo.getHasFrameworkAgreement()) | ||
| 73 | + .set(ContractFramework::getValidityTime, vo.getValidityTime()) | ||
| 74 | + .set(ContractFramework::getMaterialTypeId, vo.getMaterialTypeId()) | ||
| 75 | + .eq(ContractFramework::getId, vo.getId()); | ||
| 76 | + | ||
| 77 | + getBaseMapper().update(updateWrapper); | ||
| 78 | + | ||
| 79 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 80 | + OpLogUtil.setExtra(vo); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @OpLog(type = OtherOpLogType.class, name = "新增合同框架,ID:{}", params = {"#id"}) | ||
| 84 | + @Transactional(rollbackFor = Exception.class) | ||
| 85 | + @Override | ||
| 86 | + public String create(CreateContractFrameworkVo vo) { | ||
| 87 | + | ||
| 88 | + ContractFramework data = new ContractFramework(); | ||
| 89 | + data.setId(IdUtil.getId()); | ||
| 90 | + data.setCode(vo.getCode()); | ||
| 91 | + data.setCustomerId(vo.getCustomerId()); | ||
| 92 | + data.setCompany(vo.getCompany()); | ||
| 93 | + data.setHasFrameworkAgreement(vo.getHasFrameworkAgreement()); | ||
| 94 | + data.setValidityTime(vo.getValidityTime()); | ||
| 95 | + data.setMaterialTypeId(vo.getMaterialTypeId()); | ||
| 96 | + | ||
| 97 | + getBaseMapper().insert(data); | ||
| 98 | + | ||
| 99 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 100 | + OpLogUtil.setExtra(vo); | ||
| 101 | + | ||
| 102 | + return data.getId(); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @CacheEvict(value = ContractFramework.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") | ||
| 106 | + @Override | ||
| 107 | + public void cleanCacheByKey(Serializable key) { | ||
| 108 | + | ||
| 109 | + } | ||
| 110 | +} |
| 1 | +package com.lframework.xingyun.sc.mappers; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import com.lframework.starter.web.core.mapper.BaseMapper; | ||
| 6 | +import com.lframework.xingyun.sc.entity.ContractFramework; | ||
| 7 | +import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; | ||
| 8 | +import org.apache.ibatis.annotations.Param; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * <p> | ||
| 12 | + * 合同框架 Mapper 接口 | ||
| 13 | + * </p> | ||
| 14 | + */ | ||
| 15 | +public interface ContractFrameworkMapper extends BaseMapper<ContractFramework> { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 查询列表 | ||
| 19 | + * | ||
| 20 | + * @param vo | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + List<ContractFramework> query(@Param("vo") QueryContractFrameworkVo vo); | ||
| 24 | +} |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/service/contract/ContractFrameworkService.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.service.contract; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 4 | +import com.lframework.starter.web.core.service.BaseMpService; | ||
| 5 | +import com.lframework.xingyun.sc.entity.ContractFramework; | ||
| 6 | +import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractFrameworkVo; | ||
| 7 | +import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; | ||
| 8 | +import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractFrameworkVo; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 合同框架 Service | ||
| 14 | + */ | ||
| 15 | +public interface ContractFrameworkService extends BaseMpService<ContractFramework> { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 查询列表 | ||
| 19 | + * | ||
| 20 | + * @return | ||
| 21 | + */ | ||
| 22 | + PageResult<ContractFramework> query(Integer pageIndex, Integer pageSize, QueryContractFrameworkVo vo); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 查询列表 | ||
| 26 | + * | ||
| 27 | + * @param vo | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + List<ContractFramework> query(QueryContractFrameworkVo vo); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 根据ID查询 | ||
| 34 | + * | ||
| 35 | + * @param id | ||
| 36 | + * @return | ||
| 37 | + */ | ||
| 38 | + ContractFramework findById(String id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 修改 | ||
| 42 | + * @param vo | ||
| 43 | + */ | ||
| 44 | + void update(UpdateContractFrameworkVo vo); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 创建 | ||
| 48 | + * @param vo | ||
| 49 | + * @return | ||
| 50 | + */ | ||
| 51 | + String create(CreateContractFrameworkVo vo); | ||
| 52 | + | ||
| 53 | +} |
| 1 | +package com.lframework.xingyun.sc.vo.contract.createVo; | ||
| 2 | + | ||
| 3 | +import javax.validation.constraints.NotBlank; | ||
| 4 | + | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | + | ||
| 7 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | + | ||
| 11 | +import io.swagger.annotations.ApiModelProperty; | ||
| 12 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 13 | +import org.hibernate.validator.constraints.Length; | ||
| 14 | + | ||
| 15 | +import java.io.Serializable; | ||
| 16 | + | ||
| 17 | +import lombok.Data; | ||
| 18 | + | ||
| 19 | +@Data | ||
| 20 | +public class CreateContractFrameworkVo implements BaseVo, Serializable { | ||
| 21 | + | ||
| 22 | + private static final long serialVersionUID = 1L; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 编号 | ||
| 26 | + */ | ||
| 27 | + @ApiModelProperty(value = "编号", required = true) | ||
| 28 | + @NotBlank(message = "请输入编号!") | ||
| 29 | + @Length(message = "编号最多允许20个字符!") | ||
| 30 | + private String code; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 客户id | ||
| 34 | + */ | ||
| 35 | + @ApiModelProperty(value = "客户id", required = true) | ||
| 36 | + @NotBlank(message = "请输入客户id!") | ||
| 37 | + @Length(message = "客户id最多允许32个字符!") | ||
| 38 | + private String customerId; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 所属单位 | ||
| 42 | + */ | ||
| 43 | + @ApiModelProperty(value = "所属单位", required = true) | ||
| 44 | + @NotBlank(message = "请输入所属单位!") | ||
| 45 | + @Length(message = "所属单位最多允许50个字符!") | ||
| 46 | + private String company; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 是否签订框架合同 | ||
| 50 | + */ | ||
| 51 | + @ApiModelProperty(value = "是否签订框架合同", required = true) | ||
| 52 | + @NotNull(message = "请输入是否签订框架合同!") | ||
| 53 | + @TypeMismatch(message = "是否签订框架合同格式有误!") | ||
| 54 | + private Boolean hasFrameworkAgreement; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 期限 | ||
| 58 | + */ | ||
| 59 | + @ApiModelProperty(value = "期限", required = true) | ||
| 60 | + @NotNull(message = "请输入期限!") | ||
| 61 | + @TypeMismatch(message = "期限格式有误!") | ||
| 62 | + private LocalDateTime validityTime; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 品种id | ||
| 66 | + */ | ||
| 67 | + @ApiModelProperty(value = "品种id", required = true) | ||
| 68 | + @NotBlank(message = "请输入品种id!") | ||
| 69 | + @Length(message = "品种id最多允许32个字符!") | ||
| 70 | + private String materialTypeId; | ||
| 71 | + | ||
| 72 | +} | ||
| 73 | + |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/contract/queryVo/QueryContractFrameworkVo.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.vo.contract.queryVo; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import com.lframework.starter.common.constants.StringPool; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import com.lframework.starter.web.core.vo.PageVo; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 11 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 12 | +import io.swagger.annotations.ApiModelProperty; | ||
| 13 | + | ||
| 14 | +import java.io.Serializable; | ||
| 15 | + | ||
| 16 | +@Data | ||
| 17 | +public class QueryContractFrameworkVo extends PageVo implements BaseVo, Serializable { | ||
| 18 | + | ||
| 19 | + private static final long serialVersionUID = 1L; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 编号 | ||
| 23 | + */ | ||
| 24 | + @ApiModelProperty("编号") | ||
| 25 | + private String code; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 客户id | ||
| 29 | + */ | ||
| 30 | + @ApiModelProperty("客户id") | ||
| 31 | + private String customerId; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 所属单位 | ||
| 35 | + */ | ||
| 36 | + @ApiModelProperty("所属单位") | ||
| 37 | + private String company; | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 是否签订框架合同 | ||
| 41 | + */ | ||
| 42 | + @ApiModelProperty("是否签订框架合同") | ||
| 43 | + @TypeMismatch(message = "是否签订框架合同格式有误!") | ||
| 44 | + private Boolean hasFrameworkAgreement; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 品种 | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty("品种") | ||
| 50 | + private String materialTypeId; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 品种名称 | ||
| 54 | + */ | ||
| 55 | + @ApiModelProperty("品种名称") | ||
| 56 | + private String materialTypeName; | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 期限 | ||
| 60 | + */ | ||
| 61 | + @ApiModelProperty("期限") | ||
| 62 | + @TypeMismatch(message = "期限格式有误!") | ||
| 63 | + private LocalDateTime validityTime; | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 期限(查询) | ||
| 67 | + */ | ||
| 68 | + @ApiModelProperty("期限查询开始时间") | ||
| 69 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 70 | + private LocalDateTime validityTimeStart; | ||
| 71 | + | ||
| 72 | + @ApiModelProperty("期限查询结束时间") | ||
| 73 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 74 | + private LocalDateTime validityTimeEnd; | ||
| 75 | +} |
| 1 | +package com.lframework.xingyun.sc.vo.contract.updateVo; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +import javax.validation.constraints.NotBlank; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 9 | + | ||
| 10 | +import javax.validation.constraints.NotNull; | ||
| 11 | + | ||
| 12 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 13 | +import io.swagger.annotations.ApiModelProperty; | ||
| 14 | +import org.hibernate.validator.constraints.Length; | ||
| 15 | + | ||
| 16 | +import java.io.Serializable; | ||
| 17 | + | ||
| 18 | +@Data | ||
| 19 | +public class UpdateContractFrameworkVo implements BaseVo, Serializable { | ||
| 20 | + | ||
| 21 | + private static final long serialVersionUID = 1L; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * ID | ||
| 25 | + */ | ||
| 26 | + @ApiModelProperty(value = "ID", required = true) | ||
| 27 | + @NotBlank(message = "id不能为空!") | ||
| 28 | + private String id; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 编号 | ||
| 32 | + */ | ||
| 33 | + @ApiModelProperty(value = "编号", required = true) | ||
| 34 | + @NotBlank(message = "请输入编号!") | ||
| 35 | + @Length(message = "编号最多允许20个字符!") | ||
| 36 | + private String code; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 客户id | ||
| 40 | + */ | ||
| 41 | + @ApiModelProperty(value = "客户id", required = true) | ||
| 42 | + @NotBlank(message = "请输入客户id!") | ||
| 43 | + @Length(message = "客户id最多允许32个字符!") | ||
| 44 | + private String customerId; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 所属单位 | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty(value = "所属单位", required = true) | ||
| 50 | + @NotBlank(message = "请输入所属单位!") | ||
| 51 | + @Length(message = "所属单位最多允许50个字符!") | ||
| 52 | + private String company; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 是否签订框架合同 | ||
| 56 | + */ | ||
| 57 | + @ApiModelProperty(value = "是否签订框架合同", required = true) | ||
| 58 | + @NotNull(message = "请输入是否签订框架合同!") | ||
| 59 | + private Boolean hasFrameworkAgreement; | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 期限 | ||
| 63 | + */ | ||
| 64 | + @ApiModelProperty(value = "期限", required = true) | ||
| 65 | + @TypeMismatch(message = "期限格式有误!") | ||
| 66 | + @NotNull(message = "请输入期限!") | ||
| 67 | + private LocalDateTime validityTime; | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 品种id | ||
| 71 | + */ | ||
| 72 | + @ApiModelProperty(value = "品种id", required = true) | ||
| 73 | + @NotBlank(message = "请输入品种id!") | ||
| 74 | + @Length(message = "品种id最多允许32个字符!") | ||
| 75 | + private String materialTypeId; | ||
| 76 | + | ||
| 77 | +} |
| 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.ContractFrameworkMapper"> | ||
| 4 | + | ||
| 5 | + <resultMap id="ContractFramework" type="com.lframework.xingyun.sc.entity.ContractFramework"> | ||
| 6 | + <id column="id" property="id"/> | ||
| 7 | + <result column="code" property="code"/> | ||
| 8 | + <result column="customer_id" property="customerId"/> | ||
| 9 | + <result column="company" property="company"/> | ||
| 10 | + <result column="has_framework_agreement" property="hasFrameworkAgreement"/> | ||
| 11 | + <result column="material_type_id" property="materialTypeId"/> | ||
| 12 | + <result column="validity_time" property="validityTime"/> | ||
| 13 | + <result column="create_by_id" property="createById"/> | ||
| 14 | + <result column="create_by" property="createBy"/> | ||
| 15 | + <result column="update_by_id" property="updateById"/> | ||
| 16 | + <result column="update_by" property="updateBy"/> | ||
| 17 | + <result column="create_time" property="createTime"/> | ||
| 18 | + <result column="update_time" property="updateTime"/> | ||
| 19 | + </resultMap> | ||
| 20 | + | ||
| 21 | + <sql id="ContractFramework_sql"> | ||
| 22 | + SELECT | ||
| 23 | + tb.id, | ||
| 24 | + tb.code, | ||
| 25 | + tb.customer_id, | ||
| 26 | + tb.company, | ||
| 27 | + tb.has_framework_agreement, | ||
| 28 | + tb.material_type_id, | ||
| 29 | + tb.validity_time, | ||
| 30 | + tb.create_by_id, | ||
| 31 | + tb.create_by, | ||
| 32 | + tb.update_by_id, | ||
| 33 | + tb.update_by, | ||
| 34 | + tb.create_time, | ||
| 35 | + tb.update_time | ||
| 36 | + FROM tbl_contract_framework AS tb | ||
| 37 | + </sql> | ||
| 38 | + | ||
| 39 | + <select id="query" resultMap="ContractFramework"> | ||
| 40 | + <include refid="ContractFramework_sql"/> | ||
| 41 | + <where> | ||
| 42 | + <if test="vo.code != null and vo.code != ''"> | ||
| 43 | + AND tb.code like CONCAT('%', #{vo.code}, '%') | ||
| 44 | + </if> | ||
| 45 | + <if test="vo.customerId != null and vo.customerId != ''"> | ||
| 46 | + AND tb.customer_id = #{vo.customerId} | ||
| 47 | + </if> | ||
| 48 | + <if test="vo.company != null and vo.company != ''"> | ||
| 49 | + AND tb.company = #{vo.company} | ||
| 50 | + </if> | ||
| 51 | + <if test="vo.hasFrameworkAgreement != null"> | ||
| 52 | + AND tb.has_framework_agreement = #{vo.hasFrameworkAgreement} | ||
| 53 | + </if> | ||
| 54 | + <if test="vo.materialTypeId != null and vo.materialTypeId != ''"> | ||
| 55 | + AND tb.material_type_id = #{materialTypeId} | ||
| 56 | + </if> | ||
| 57 | + <if test="vo.validityTime != null"> | ||
| 58 | + AND tb.validity_time = #{vo.validityTime} | ||
| 59 | + </if> | ||
| 60 | + <if test="vo.validityTimeStart != null"> | ||
| 61 | + AND tb.validity_time >= #{vo.validityTimeStart} | ||
| 62 | + </if> | ||
| 63 | + <if test="vo.validityTimeEnd != null"> | ||
| 64 | + AND tb.validity_time <= #{vo.validityTimeEnd} | ||
| 65 | + </if> | ||
| 66 | + </where> | ||
| 67 | + </select> | ||
| 68 | +</mapper> |