Showing
11 changed files
with
771 additions
and
0 deletions
| @@ -1590,3 +1590,23 @@ CREATE TABLE `procurement_foreign_trade_credit` | @@ -1590,3 +1590,23 @@ CREATE TABLE `procurement_foreign_trade_credit` | ||
| 1590 | KEY `idx_pftc_next_review_time` (`next_review_time`), | 1590 | KEY `idx_pftc_next_review_time` (`next_review_time`), |
| 1591 | KEY `idx_pftc_create_time` (`create_time`) | 1591 | KEY `idx_pftc_create_time` (`create_time`) |
| 1592 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='采购外贸资信调查表'; | 1592 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='采购外贸资信调查表'; |
| 1593 | + | ||
| 1594 | +CREATE TABLE `base_data_breed_relationship` | ||
| 1595 | +( | ||
| 1596 | + `id` varchar(32) NOT NULL COMMENT 'ID', | ||
| 1597 | + `product_name` varchar(200) NOT NULL COMMENT '品名', | ||
| 1598 | + `code` varchar(200) NOT NULL COMMENT '代号', | ||
| 1599 | + `type` varchar(200) NOT NULL COMMENT '类型', | ||
| 1600 | + `attrition_rate` decimal(18, 10) NOT NULL COMMENT '损耗率', | ||
| 1601 | + `miscellaneous_tax_rate` decimal(18, 10) NOT NULL COMMENT '杂率', | ||
| 1602 | + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', | ||
| 1603 | + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', | ||
| 1604 | + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', | ||
| 1605 | + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人', | ||
| 1606 | + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 1607 | + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 1608 | + PRIMARY KEY (`id`), | ||
| 1609 | + UNIQUE KEY `uk_bdbr_product_name` (`product_name`), | ||
| 1610 | + KEY `idx_bdbr_code` (`code`), | ||
| 1611 | + KEY `idx_bdbr_create_time` (`create_time`) | ||
| 1612 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='品种关系表'; |
| 1 | +package com.lframework.xingyun.basedata.bo.breed; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import java.math.BigDecimal; | ||
| 5 | +import com.lframework.starter.common.constants.StringPool; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.lframework.starter.web.core.bo.BaseBo; | ||
| 8 | +import com.lframework.xingyun.basedata.entity.BreedRelationship; | ||
| 9 | +import io.swagger.annotations.ApiModelProperty; | ||
| 10 | + | ||
| 11 | +import lombok.Data; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * <p> | ||
| 15 | + * 品种关系表 QueryBo | ||
| 16 | + * </p> | ||
| 17 | + * | ||
| 18 | + */ | ||
| 19 | +@Data | ||
| 20 | +public class QueryBreedRelationshipBo extends BaseBo<BreedRelationship> { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * ID | ||
| 24 | + */ | ||
| 25 | + @ApiModelProperty("ID") | ||
| 26 | + private String id; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 品名 | ||
| 30 | + */ | ||
| 31 | + @ApiModelProperty("品名") | ||
| 32 | + private String productName; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 代号 | ||
| 36 | + */ | ||
| 37 | + @ApiModelProperty("代号") | ||
| 38 | + private String code; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 类型 | ||
| 42 | + */ | ||
| 43 | + @ApiModelProperty("类型") | ||
| 44 | + private String type; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 损耗率 | ||
| 48 | + */ | ||
| 49 | + @ApiModelProperty("损耗率") | ||
| 50 | + private BigDecimal attritionRate; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 杂率 | ||
| 54 | + */ | ||
| 55 | + @ApiModelProperty("杂率") | ||
| 56 | + private BigDecimal miscellaneousTaxRate; | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 创建人ID | ||
| 60 | + */ | ||
| 61 | + @ApiModelProperty("创建人ID") | ||
| 62 | + private String createById; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 创建人 | ||
| 66 | + */ | ||
| 67 | + @ApiModelProperty("创建人") | ||
| 68 | + private String createBy; | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 更新人ID | ||
| 72 | + */ | ||
| 73 | + @ApiModelProperty("更新人ID") | ||
| 74 | + private String updateById; | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 更新人 | ||
| 78 | + */ | ||
| 79 | + @ApiModelProperty("更新人") | ||
| 80 | + private String updateBy; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 创建时间 | ||
| 84 | + */ | ||
| 85 | + @ApiModelProperty("创建时间") | ||
| 86 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 87 | + private LocalDateTime createTime; | ||
| 88 | + | ||
| 89 | + /** | ||
| 90 | + * 更新时间 | ||
| 91 | + */ | ||
| 92 | + @ApiModelProperty("更新时间") | ||
| 93 | + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | ||
| 94 | + private LocalDateTime updateTime; | ||
| 95 | + | ||
| 96 | + public QueryBreedRelationshipBo() { | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public QueryBreedRelationshipBo(BreedRelationship dto) { | ||
| 101 | + | ||
| 102 | + super(dto); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @Override | ||
| 106 | + public BaseBo<BreedRelationship> convert(BreedRelationship dto) { | ||
| 107 | + return super.convert(dto); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + protected void afterInit(BreedRelationship dto) { | ||
| 112 | + | ||
| 113 | + } | ||
| 114 | +} |
| 1 | +package com.lframework.xingyun.basedata.controller; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.annotations.security.HasPermission; | ||
| 4 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | ||
| 5 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 6 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 7 | +import com.lframework.starter.web.core.components.resp.InvokeResult; | ||
| 8 | +import javax.validation.constraints.NotBlank; | ||
| 9 | +import com.lframework.xingyun.basedata.bo.breed.QueryBreedRelationshipBo; | ||
| 10 | +import com.lframework.xingyun.basedata.entity.BreedRelationship; | ||
| 11 | +import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; | ||
| 12 | +import com.lframework.xingyun.basedata.vo.breed.CreateBreedRelationshipVo; | ||
| 13 | +import com.lframework.xingyun.basedata.vo.breed.QueryBreedRelationshipVo; | ||
| 14 | +import com.lframework.xingyun.basedata.vo.breed.UpdateBreedRelationshipVo; | ||
| 15 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 16 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | ||
| 17 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 18 | +import io.swagger.annotations.ApiOperation; | ||
| 19 | +import com.lframework.starter.common.utils.CollectionUtil; | ||
| 20 | +import io.swagger.annotations.Api; | ||
| 21 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 23 | +import org.springframework.validation.annotation.Validated; | ||
| 24 | +import org.springframework.web.bind.annotation.*; | ||
| 25 | +import javax.validation.Valid; | ||
| 26 | +import java.util.List; | ||
| 27 | +import java.util.stream.Collectors; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * 品种关系表 Controller | ||
| 31 | + * | ||
| 32 | + */ | ||
| 33 | +@Api(tags = "品种关系表") | ||
| 34 | +@Validated | ||
| 35 | +@RestController | ||
| 36 | +@RequestMapping("/baseData/breedRelationship") | ||
| 37 | +public class BreedRelationshipController extends DefaultBaseController { | ||
| 38 | + | ||
| 39 | + @Autowired | ||
| 40 | + private BreedRelationshipService breedRelationshipService; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 查询列表 | ||
| 44 | + */ | ||
| 45 | + @ApiOperation("查询列表") | ||
| 46 | + @HasPermission({"base-data:variety:query"}) | ||
| 47 | + @GetMapping("/query") | ||
| 48 | + public InvokeResult<PageResult<QueryBreedRelationshipBo>> query(@Valid QueryBreedRelationshipVo vo) { | ||
| 49 | + | ||
| 50 | + PageResult<BreedRelationship> pageResult = breedRelationshipService.query(getPageIndex(vo), getPageSize(vo), vo); | ||
| 51 | + | ||
| 52 | + List<BreedRelationship> datas = pageResult.getDatas(); | ||
| 53 | + List<QueryBreedRelationshipBo> results = null; | ||
| 54 | + | ||
| 55 | + if (!CollectionUtil.isEmpty(datas)) { | ||
| 56 | + results = datas.stream().map(QueryBreedRelationshipBo::new).collect(Collectors.toList()); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 根据ID查询 | ||
| 64 | + */ | ||
| 65 | + @ApiOperation("根据ID查询") | ||
| 66 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 67 | + @HasPermission({"base-data:variety:query"}) | ||
| 68 | + @GetMapping | ||
| 69 | + public InvokeResult<QueryBreedRelationshipBo> get(@NotBlank(message = "id不能为空!") String id) { | ||
| 70 | + | ||
| 71 | + BreedRelationship data = breedRelationshipService.findById(id); | ||
| 72 | + if (data == null) { | ||
| 73 | + throw new DefaultClientException("品种关系表不存在!"); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + QueryBreedRelationshipBo result = new QueryBreedRelationshipBo(data); | ||
| 77 | + | ||
| 78 | + return InvokeResultBuilder.success(result); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 新增 | ||
| 83 | + */ | ||
| 84 | + @ApiOperation("新增") | ||
| 85 | + @HasPermission({"base-data:variety:add"}) | ||
| 86 | + @PostMapping | ||
| 87 | + public InvokeResult<Void> create(@RequestBody @Valid CreateBreedRelationshipVo vo) { | ||
| 88 | + | ||
| 89 | + breedRelationshipService.create(vo); | ||
| 90 | + | ||
| 91 | + return InvokeResultBuilder.success(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 修改 | ||
| 96 | + */ | ||
| 97 | + @ApiOperation("修改") | ||
| 98 | + @HasPermission({"base-data:variety:modify"}) | ||
| 99 | + @PutMapping | ||
| 100 | + public InvokeResult<Void> update(@RequestBody @Valid UpdateBreedRelationshipVo vo) { | ||
| 101 | + | ||
| 102 | + breedRelationshipService.update(vo); | ||
| 103 | + | ||
| 104 | + return InvokeResultBuilder.success(); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * 根据ID删除 | ||
| 109 | + */ | ||
| 110 | + @ApiOperation("根据ID删除") | ||
| 111 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 112 | + @HasPermission({"base-data:variety:delete"}) | ||
| 113 | + @DeleteMapping | ||
| 114 | + public InvokeResult<Void> deleteById(@NotBlank(message = "id不能为空!") String id) { | ||
| 115 | + | ||
| 116 | + breedRelationshipService.deleteById(id); | ||
| 117 | + | ||
| 118 | + return InvokeResultBuilder.success(); | ||
| 119 | + } | ||
| 120 | +} |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/entity/BreedRelationship.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.FieldFill; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import com.lframework.starter.web.core.entity.BaseEntity; | ||
| 7 | +import com.lframework.starter.web.core.dto.BaseDto; | ||
| 8 | + | ||
| 9 | +import java.math.BigDecimal; | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | +import lombok.Data; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 品种关系 | ||
| 15 | + */ | ||
| 16 | +@Data | ||
| 17 | +@TableName("base_data_breed_relationship") | ||
| 18 | +public class BreedRelationship extends BaseEntity implements BaseDto { | ||
| 19 | + | ||
| 20 | + public static final String CACHE_NAME = "BreedRelationship"; | ||
| 21 | + private static final long serialVersionUID = 1L; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * ID | ||
| 25 | + */ | ||
| 26 | + private String id; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 品名 | ||
| 30 | + */ | ||
| 31 | + private String productName; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 代号 | ||
| 35 | + */ | ||
| 36 | + private String code; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 类型 | ||
| 40 | + */ | ||
| 41 | + private String type; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 损耗率 | ||
| 45 | + */ | ||
| 46 | + private BigDecimal attritionRate; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 杂率 | ||
| 50 | + */ | ||
| 51 | + private BigDecimal miscellaneousTaxRate; | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 创建人ID 新增时赋值 | ||
| 56 | + */ | ||
| 57 | + @TableField(fill = FieldFill.INSERT) | ||
| 58 | + private String createById; | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 创建人 新增时赋值 | ||
| 62 | + */ | ||
| 63 | + @TableField(fill = FieldFill.INSERT) | ||
| 64 | + private String createBy; | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 创建时间 新增时赋值 | ||
| 68 | + */ | ||
| 69 | + @TableField(fill = FieldFill.INSERT) | ||
| 70 | + private LocalDateTime createTime; | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 修改人 新增和修改时赋值 | ||
| 74 | + */ | ||
| 75 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 76 | + private String updateBy; | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 修改人ID 新增和修改时赋值 | ||
| 80 | + */ | ||
| 81 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 82 | + private String updateById; | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * 修改时间 新增和修改时赋值 | ||
| 86 | + */ | ||
| 87 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 88 | + private LocalDateTime updateTime; | ||
| 89 | +} |
| 1 | +package com.lframework.xingyun.basedata.impl.breed; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 6 | +import com.github.pagehelper.PageInfo; | ||
| 7 | +import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | ||
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 9 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 10 | +import com.lframework.starter.web.core.utils.OpLogUtil; | ||
| 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.basedata.entity.BreedRelationship; | ||
| 20 | +import com.lframework.xingyun.basedata.mappers.BreedRelationshipMapper; | ||
| 21 | +import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; | ||
| 22 | +import com.lframework.xingyun.basedata.vo.breed.CreateBreedRelationshipVo; | ||
| 23 | +import com.lframework.xingyun.basedata.vo.breed.QueryBreedRelationshipVo; | ||
| 24 | +import com.lframework.xingyun.basedata.vo.breed.UpdateBreedRelationshipVo; | ||
| 25 | +import org.apache.commons.lang3.StringUtils; | ||
| 26 | +import org.springframework.transaction.annotation.Transactional; | ||
| 27 | +import org.springframework.stereotype.Service; | ||
| 28 | +import java.util.List; | ||
| 29 | + | ||
| 30 | +@Service | ||
| 31 | +public class BreedRelationshipServiceImpl extends BaseMpServiceImpl<BreedRelationshipMapper, BreedRelationship> implements BreedRelationshipService { | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public PageResult<BreedRelationship> query(Integer pageIndex, Integer pageSize, QueryBreedRelationshipVo vo) { | ||
| 35 | + | ||
| 36 | + Assert.greaterThanZero(pageIndex); | ||
| 37 | + Assert.greaterThanZero(pageSize); | ||
| 38 | + | ||
| 39 | + PageHelperUtil.startPage(pageIndex, pageSize); | ||
| 40 | + List<BreedRelationship> datas = this.query(vo); | ||
| 41 | + | ||
| 42 | + return PageResultUtil.convert(new PageInfo<>(datas)); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public List<BreedRelationship> query(QueryBreedRelationshipVo vo) { | ||
| 47 | + | ||
| 48 | + return getBaseMapper().query(vo); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public BreedRelationship findById(String id) { | ||
| 53 | + | ||
| 54 | + return getBaseMapper().selectById(id); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @OpLog(type = OtherOpLogType.class, name = "新增品种关系表,ID:{}", params = {"#id"}) | ||
| 58 | + @Transactional(rollbackFor = Exception.class) | ||
| 59 | + @Override | ||
| 60 | + public String create(CreateBreedRelationshipVo vo) { | ||
| 61 | + checkProductNameUnique(vo.getProductName(), null); | ||
| 62 | + | ||
| 63 | + BreedRelationship data = new BreedRelationship(); | ||
| 64 | + data.setId(IdUtil.getId()); | ||
| 65 | + data.setProductName(vo.getProductName()); | ||
| 66 | + data.setCode(vo.getCode()); | ||
| 67 | + data.setType(vo.getType()); | ||
| 68 | + data.setAttritionRate(vo.getAttritionRate()); | ||
| 69 | + data.setMiscellaneousTaxRate(vo.getMiscellaneousTaxRate()); | ||
| 70 | + | ||
| 71 | + getBaseMapper().insert(data); | ||
| 72 | + | ||
| 73 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 74 | + OpLogUtil.setExtra(vo); | ||
| 75 | + | ||
| 76 | + return data.getId(); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @OpLog(type = OtherOpLogType.class, name = "修改品种关系表,ID:{}", params = {"#id"}) | ||
| 80 | + @Transactional(rollbackFor = Exception.class) | ||
| 81 | + @Override | ||
| 82 | + public void update(UpdateBreedRelationshipVo vo) { | ||
| 83 | + | ||
| 84 | + BreedRelationship data = getBaseMapper().selectById(vo.getId()); | ||
| 85 | + if (ObjectUtil.isNull(data)) { | ||
| 86 | + throw new DefaultClientException("品种关系表不存在!"); | ||
| 87 | + } | ||
| 88 | + checkProductNameUnique(vo.getProductName(), vo.getId()); | ||
| 89 | + | ||
| 90 | + LambdaUpdateWrapper<BreedRelationship> updateWrapper = Wrappers.lambdaUpdate(BreedRelationship.class) | ||
| 91 | + .set(BreedRelationship::getProductName, vo.getProductName()) | ||
| 92 | + .set(BreedRelationship::getCode, vo.getCode()) | ||
| 93 | + .set(BreedRelationship::getType, vo.getType()) | ||
| 94 | + .set(BreedRelationship::getAttritionRate, vo.getAttritionRate()) | ||
| 95 | + .set(BreedRelationship::getMiscellaneousTaxRate, vo.getMiscellaneousTaxRate()) | ||
| 96 | + .eq(BreedRelationship::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 | + /** | ||
| 113 | + * 校验品名唯一性 | ||
| 114 | + * | ||
| 115 | + * @param productName 品名 | ||
| 116 | + * @param excludeId 排除的品名ID | ||
| 117 | + */ | ||
| 118 | + private void checkProductNameUnique(String productName, String excludeId) { | ||
| 119 | + LambdaQueryWrapper<BreedRelationship> queryWrapper = | ||
| 120 | + Wrappers.lambdaQuery(BreedRelationship.class) | ||
| 121 | + .eq(BreedRelationship::getProductName, productName); | ||
| 122 | + if (StringUtils.isNotBlank(excludeId)) { | ||
| 123 | + queryWrapper.ne(BreedRelationship::getId, excludeId); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + Integer count = getBaseMapper().selectCount(queryWrapper); | ||
| 127 | + if (count != null && count > 0) { | ||
| 128 | + throw new DefaultClientException("品名已存在,请重新输入!"); | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + @Override | ||
| 133 | + public void cleanCacheByKey(Serializable key) { | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | +} |
xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/mappers/BreedRelationshipMapper.java
0 → 100644
| 1 | +package com.lframework.xingyun.basedata.mappers; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.mapper.BaseMapper; | ||
| 4 | +import com.lframework.xingyun.basedata.entity.BreedRelationship; | ||
| 5 | +import com.lframework.xingyun.basedata.vo.breed.QueryBreedRelationshipVo; | ||
| 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 BreedRelationshipMapper extends BaseMapper<BreedRelationship> { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 查询列表 | ||
| 20 | + * @param vo | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + List<BreedRelationship> query(@Param("vo") QueryBreedRelationshipVo vo); | ||
| 24 | +} |
| 1 | +package com.lframework.xingyun.basedata.service.breed; | ||
| 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.basedata.entity.BreedRelationship; | ||
| 6 | +import com.lframework.xingyun.basedata.vo.breed.CreateBreedRelationshipVo; | ||
| 7 | +import com.lframework.xingyun.basedata.vo.breed.QueryBreedRelationshipVo; | ||
| 8 | +import com.lframework.xingyun.basedata.vo.breed.UpdateBreedRelationshipVo; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 品种关系表 Service | ||
| 13 | + */ | ||
| 14 | +public interface BreedRelationshipService extends BaseMpService<BreedRelationship> { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 查询列表 | ||
| 18 | + * @return | ||
| 19 | + */ | ||
| 20 | + PageResult<BreedRelationship> query(Integer pageIndex, Integer pageSize, QueryBreedRelationshipVo vo); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询列表 | ||
| 24 | + * @param vo | ||
| 25 | + * @return | ||
| 26 | + */ | ||
| 27 | + List<BreedRelationship> query(QueryBreedRelationshipVo vo); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 根据ID查询 | ||
| 31 | + * @param id | ||
| 32 | + * @return | ||
| 33 | + */ | ||
| 34 | + BreedRelationship findById(String id); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 创建 | ||
| 38 | + * @param vo | ||
| 39 | + * @return | ||
| 40 | + */ | ||
| 41 | + String create(CreateBreedRelationshipVo vo); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 修改 | ||
| 45 | + * @param vo | ||
| 46 | + */ | ||
| 47 | + void update(UpdateBreedRelationshipVo vo); | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 根据ID删除 | ||
| 51 | + * @param id | ||
| 52 | + * @return | ||
| 53 | + */ | ||
| 54 | + void deleteById(String id); | ||
| 55 | +} |
| 1 | +package com.lframework.xingyun.basedata.vo.breed; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.components.validation.IsNumberPrecision; | ||
| 4 | +import java.math.BigDecimal; | ||
| 5 | +import javax.validation.constraints.NotBlank; | ||
| 6 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | +import io.swagger.annotations.ApiModelProperty; | ||
| 9 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 10 | +import org.hibernate.validator.constraints.Length; | ||
| 11 | +import java.io.Serializable; | ||
| 12 | +import lombok.Data; | ||
| 13 | + | ||
| 14 | +@Data | ||
| 15 | +public class CreateBreedRelationshipVo implements BaseVo, Serializable { | ||
| 16 | + | ||
| 17 | + private static final long serialVersionUID = 1L; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 品名 | ||
| 21 | + */ | ||
| 22 | + @ApiModelProperty(value = "品名", required = true) | ||
| 23 | + @NotBlank(message = "请输入品名!") | ||
| 24 | + @Length(message = "品名最多允许200个字符!") | ||
| 25 | + private String productName; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 代号 | ||
| 29 | + */ | ||
| 30 | + @ApiModelProperty(value = "代号", required = true) | ||
| 31 | + @NotBlank(message = "请输入代号!") | ||
| 32 | + @Length(message = "代号最多允许200个字符!") | ||
| 33 | + private String code; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 类型 | ||
| 37 | + */ | ||
| 38 | + @ApiModelProperty(value = "类型", required = true) | ||
| 39 | + @NotBlank(message = "请输入类型!") | ||
| 40 | + @Length(message = "类型最多允许200个字符!") | ||
| 41 | + private String type; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 损耗率 | ||
| 45 | + */ | ||
| 46 | + @ApiModelProperty(value = "损耗率", required = true) | ||
| 47 | + @NotNull(message = "请输入损耗率!") | ||
| 48 | + @TypeMismatch(message = "损耗率格式有误!") | ||
| 49 | + @IsNumberPrecision(message = "损耗率最多允许10位小数!", value = 10) | ||
| 50 | + private BigDecimal attritionRate; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 杂率 | ||
| 54 | + */ | ||
| 55 | + @ApiModelProperty(value = "杂率", required = true) | ||
| 56 | + @NotNull(message = "请输入杂率!") | ||
| 57 | + @TypeMismatch(message = "杂率格式有误!") | ||
| 58 | + @IsNumberPrecision(message = "杂率最多允许10位小数!", value = 10) | ||
| 59 | + private BigDecimal miscellaneousTaxRate; | ||
| 60 | + | ||
| 61 | +} |
| 1 | +package com.lframework.xingyun.basedata.vo.breed; | ||
| 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 QueryBreedRelationshipVo extends PageVo implements BaseVo, Serializable { | ||
| 11 | + | ||
| 12 | + private static final long serialVersionUID = 1L; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 品名 | ||
| 16 | + */ | ||
| 17 | + @ApiModelProperty("品名") | ||
| 18 | + private String productName; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 代号 | ||
| 22 | + */ | ||
| 23 | + @ApiModelProperty("代号") | ||
| 24 | + private String code; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 类型 | ||
| 28 | + */ | ||
| 29 | + @ApiModelProperty("类型") | ||
| 30 | + private String type; | ||
| 31 | + | ||
| 32 | +} |
| 1 | +package com.lframework.xingyun.basedata.vo.breed; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | +import com.lframework.starter.web.core.components.validation.IsNumberPrecision; | ||
| 5 | +import java.math.BigDecimal; | ||
| 6 | +import javax.validation.constraints.NotBlank; | ||
| 7 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | +import com.lframework.starter.web.core.components.validation.TypeMismatch; | ||
| 10 | +import io.swagger.annotations.ApiModelProperty; | ||
| 11 | +import org.hibernate.validator.constraints.Length; | ||
| 12 | +import java.io.Serializable; | ||
| 13 | + | ||
| 14 | +@Data | ||
| 15 | +public class UpdateBreedRelationshipVo implements BaseVo, Serializable { | ||
| 16 | + | ||
| 17 | + private static final long serialVersionUID = 1L; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * ID | ||
| 21 | + */ | ||
| 22 | + @ApiModelProperty(value = "ID", required = true) | ||
| 23 | + @NotBlank(message = "id不能为空!") | ||
| 24 | + private String id; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 品名 | ||
| 28 | + */ | ||
| 29 | + @ApiModelProperty(value = "品名", required = true) | ||
| 30 | + @NotBlank(message = "请输入品名!") | ||
| 31 | + @Length(message = "品名最多允许200个字符!") | ||
| 32 | + private String productName; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 代号 | ||
| 36 | + */ | ||
| 37 | + @ApiModelProperty(value = "代号", required = true) | ||
| 38 | + @NotBlank(message = "请输入代号!") | ||
| 39 | + @Length(message = "代号最多允许200个字符!") | ||
| 40 | + private String code; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 类型 | ||
| 44 | + */ | ||
| 45 | + @ApiModelProperty(value = "类型", required = true) | ||
| 46 | + @NotBlank(message = "请输入类型!") | ||
| 47 | + @Length(message = "类型最多允许200个字符!") | ||
| 48 | + private String type; | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 损耗率 | ||
| 52 | + */ | ||
| 53 | + @ApiModelProperty(value = "损耗率", required = true) | ||
| 54 | + @TypeMismatch(message = "损耗率格式有误!") | ||
| 55 | + @NotNull(message = "请输入损耗率!") | ||
| 56 | + @IsNumberPrecision(message = "损耗率最多允许10位小数!", value = 10) | ||
| 57 | + private BigDecimal attritionRate; | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 杂率 | ||
| 61 | + */ | ||
| 62 | + @ApiModelProperty(value = "杂率", required = true) | ||
| 63 | + @TypeMismatch(message = "杂率格式有误!") | ||
| 64 | + @NotNull(message = "请输入杂率!") | ||
| 65 | + @IsNumberPrecision(message = "杂率最多允许10位小数!", value = 10) | ||
| 66 | + private BigDecimal miscellaneousTaxRate; | ||
| 67 | + | ||
| 68 | +} |
| 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.basedata.mappers.BreedRelationshipMapper"> | ||
| 4 | + | ||
| 5 | + <resultMap id="BreedRelationship" type="com.lframework.xingyun.basedata.entity.BreedRelationship"> | ||
| 6 | + <id column="id" property="id"/> | ||
| 7 | + <result column="product_name" property="productName"/> | ||
| 8 | + <result column="code" property="code"/> | ||
| 9 | + <result column="type" property="type"/> | ||
| 10 | + <result column="attrition_rate" property="attritionRate"/> | ||
| 11 | + <result column="miscellaneous_tax_rate" property="miscellaneousTaxRate"/> | ||
| 12 | + <result column="create_by_id" property="createById"/> | ||
| 13 | + <result column="create_by" property="createBy"/> | ||
| 14 | + <result column="update_by_id" property="updateById"/> | ||
| 15 | + <result column="update_by" property="updateBy"/> | ||
| 16 | + <result column="create_time" property="createTime"/> | ||
| 17 | + <result column="update_time" property="updateTime"/> | ||
| 18 | + </resultMap> | ||
| 19 | + | ||
| 20 | + <sql id="BreedRelationship_sql"> | ||
| 21 | + SELECT | ||
| 22 | + tb.id, | ||
| 23 | + tb.product_name, | ||
| 24 | + tb.code, | ||
| 25 | + tb.type, | ||
| 26 | + tb.attrition_rate, | ||
| 27 | + tb.miscellaneous_tax_rate, | ||
| 28 | + tb.create_by_id, | ||
| 29 | + tb.create_by, | ||
| 30 | + tb.update_by_id, | ||
| 31 | + tb.update_by, | ||
| 32 | + tb.create_time, | ||
| 33 | + tb.update_time | ||
| 34 | + FROM base_data_breed_relationship AS tb | ||
| 35 | + </sql> | ||
| 36 | + | ||
| 37 | + <select id="query" resultMap="BreedRelationship"> | ||
| 38 | + <include refid="BreedRelationship_sql"/> | ||
| 39 | + <where> | ||
| 40 | + <if test="vo.productName != null and vo.productName != ''"> | ||
| 41 | + AND tb.product_name LIKE CONCAT('%', #{vo.productName},'%') | ||
| 42 | + </if> | ||
| 43 | + <if test="vo.code != null and vo.code != ''"> | ||
| 44 | + AND tb.code LIKE CONCAT('%', #{vo.code},'%') | ||
| 45 | + </if> | ||
| 46 | + <if test="vo.type != null and vo.type != ''"> | ||
| 47 | + AND tb.type LIKE CONCAT('%', #{vo.type},'%') | ||
| 48 | + </if> | ||
| 49 | + </where> | ||
| 50 | + ORDER BY tb.create_time DESC | ||
| 51 | + </select> | ||
| 52 | +</mapper> |