Showing
10 changed files
with
783 additions
and
0 deletions
| @@ -1775,3 +1775,31 @@ CREATE TABLE `procurement_salesman_quotation_peer` | @@ -1775,3 +1775,31 @@ CREATE TABLE `procurement_salesman_quotation_peer` | ||
| 1775 | KEY `idx_psqp_peer_product_id` (`peer_product_id`), | 1775 | KEY `idx_psqp_peer_product_id` (`peer_product_id`), |
| 1776 | KEY `idx_psqp_create_time` (`create_time`) | 1776 | KEY `idx_psqp_create_time` (`create_time`) |
| 1777 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='同行报价信息'; | 1777 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='同行报价信息'; |
| 1778 | + | ||
| 1779 | +CREATE TABLE `procurement_supplier_quotation_project` | ||
| 1780 | +( | ||
| 1781 | + `id` varchar(32) NOT NULL COMMENT 'ID', | ||
| 1782 | + `code` varchar(20) NOT NULL COMMENT '项目编号', | ||
| 1783 | + `name` varchar(200) NOT NULL COMMENT '项目名称', | ||
| 1784 | + `product_id` varchar(32) NOT NULL COMMENT '品种ID', | ||
| 1785 | + `quantity` decimal(18, 5) NOT NULL COMMENT '数量', | ||
| 1786 | + `start_time` datetime NOT NULL COMMENT '开始时间', | ||
| 1787 | + `end_time` datetime NOT NULL COMMENT '截止时间', | ||
| 1788 | + `project_type` varchar(50) NOT NULL COMMENT '项目类型', | ||
| 1789 | + `bid_time` datetime DEFAULT NULL COMMENT '开标时间', | ||
| 1790 | + `purchase_rule` varchar(2000) DEFAULT NULL COMMENT '采购规则', | ||
| 1791 | + `status` varchar(50) DEFAULT NULL COMMENT '状态', | ||
| 1792 | + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', | ||
| 1793 | + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', | ||
| 1794 | + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', | ||
| 1795 | + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人', | ||
| 1796 | + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 1797 | + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 1798 | + PRIMARY KEY (`id`), | ||
| 1799 | + UNIQUE KEY `uk_psqpj_code` (`code`), | ||
| 1800 | + KEY `idx_psqpj_product_id` (`product_id`), | ||
| 1801 | + KEY `idx_psqpj_start_time` (`start_time`), | ||
| 1802 | + KEY `idx_psqpj_end_time` (`end_time`), | ||
| 1803 | + KEY `idx_psqpj_bid_time` (`bid_time`), | ||
| 1804 | + KEY `idx_psqpj_create_time` (`create_time`) | ||
| 1805 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='供应商报价项目'; |
| 1 | +package com.lframework.xingyun.sc.procurement.controller.quotation; | ||
| 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.InvokeResult; | ||
| 6 | +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | ||
| 7 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 8 | +import com.lframework.starter.web.core.controller.DefaultBaseController; | ||
| 9 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; | ||
| 10 | +import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectService; | ||
| 11 | +import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotationProjectVo; | ||
| 12 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo; | ||
| 13 | +import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo; | ||
| 14 | +import io.swagger.annotations.Api; | ||
| 15 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 16 | +import io.swagger.annotations.ApiOperation; | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import javax.validation.Valid; | ||
| 19 | +import javax.validation.constraints.NotBlank; | ||
| 20 | +import org.springframework.validation.annotation.Validated; | ||
| 21 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 24 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 25 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 26 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 27 | +import org.springframework.web.bind.annotation.RestController; | ||
| 28 | + | ||
| 29 | +@Api(tags = "供应商报价项目") | ||
| 30 | +@Validated | ||
| 31 | +@RestController | ||
| 32 | +@RequestMapping("/procurement/supplierQuotationProject") | ||
| 33 | +public class SupplierQuotationProjectController extends DefaultBaseController { | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private SupplierQuotationProjectService supplierQuotationProjectService; | ||
| 37 | + | ||
| 38 | + @ApiOperation("新增") | ||
| 39 | + @HasPermission({"procure-manage:supplier-quote-project:add"}) | ||
| 40 | + @PostMapping | ||
| 41 | + public InvokeResult<Void> create(@Valid @RequestBody CreateSupplierQuotationProjectVo vo) { | ||
| 42 | + supplierQuotationProjectService.create(vo); | ||
| 43 | + return InvokeResultBuilder.success(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @ApiOperation("分页查询") | ||
| 47 | + @HasPermission({"procure-manage:supplier-quote-project:query"}) | ||
| 48 | + @GetMapping("/query") | ||
| 49 | + public InvokeResult<PageResult<SupplierQuotationProject>> query(@Valid QuerySupplierQuotationProjectVo vo) { | ||
| 50 | + return InvokeResultBuilder.success( | ||
| 51 | + supplierQuotationProjectService.query(getPageIndex(vo), getPageSize(vo), vo)); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @ApiOperation("详情") | ||
| 55 | + @HasPermission({"procure-manage:supplier-quote-project:query"}) | ||
| 56 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | ||
| 57 | + @GetMapping("") | ||
| 58 | + public InvokeResult<SupplierQuotationProject> get(@NotBlank(message = "id不能为空!") String id) { | ||
| 59 | + SupplierQuotationProject data = supplierQuotationProjectService.findById(id); | ||
| 60 | + if (data == null) { | ||
| 61 | + throw new DefaultClientException("供应商报价项目不存在!"); | ||
| 62 | + } | ||
| 63 | + return InvokeResultBuilder.success(data); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @ApiOperation("修改") | ||
| 67 | + @HasPermission({"procure-manage:supplier-quote-project:modify"}) | ||
| 68 | + @PutMapping | ||
| 69 | + public InvokeResult<Void> update(@Valid @RequestBody UpdateSupplierQuotationProjectVo vo) { | ||
| 70 | + supplierQuotationProjectService.update(vo); | ||
| 71 | + return InvokeResultBuilder.success(); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @ApiOperation("更新项目状态") | ||
| 75 | + @HasPermission({"procure-manage:supplier-quote-project:modify"}) | ||
| 76 | + @GetMapping("/updateStatus") | ||
| 77 | + public InvokeResult<Void> updateStatus(@NotBlank(message = "id不能为空!") String id, @NotBlank(message = "status不能为空!") String status) { | ||
| 78 | + supplierQuotationProjectService.updateStatus(id, status); | ||
| 79 | + return InvokeResultBuilder.success(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @ApiOperation("删除") | ||
| 83 | + @HasPermission({"procure-manage:supplier-quote-project:delete"}) | ||
| 84 | + @DeleteMapping("") | ||
| 85 | + public InvokeResult<Void> delete(@NotBlank(message = "id不能为空!") String id) { | ||
| 86 | + supplierQuotationProjectService.delete(id); | ||
| 87 | + return InvokeResultBuilder.success(); | ||
| 88 | + } | ||
| 89 | +} | ||
| 90 | + |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/procurement/entity/SupplierQuotationProject.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.procurement.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.dto.BaseDto; | ||
| 7 | +import com.lframework.starter.web.core.entity.BaseEntity; | ||
| 8 | +import java.math.BigDecimal; | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | +import lombok.Data; | ||
| 11 | + | ||
| 12 | +@Data | ||
| 13 | +@TableName("procurement_supplier_quotation_project") | ||
| 14 | +public class SupplierQuotationProject extends BaseEntity implements BaseDto { | ||
| 15 | + | ||
| 16 | + private static final long serialVersionUID = 1L; | ||
| 17 | + | ||
| 18 | + public static final String CACHE_NAME = "SupplierQuotationProject"; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * ID | ||
| 22 | + */ | ||
| 23 | + private String id; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 项目编号 | ||
| 27 | + */ | ||
| 28 | + private String code; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 项目名称 | ||
| 32 | + */ | ||
| 33 | + private String name; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 品种ID | ||
| 37 | + */ | ||
| 38 | + private String productId; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 品种名称 | ||
| 42 | + */ | ||
| 43 | + @TableField(exist = false) | ||
| 44 | + private String productName; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 品种代号 | ||
| 48 | + */ | ||
| 49 | + @TableField(exist = false) | ||
| 50 | + private String productCode; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 数量 | ||
| 54 | + */ | ||
| 55 | + private BigDecimal quantity; | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 开始时间 | ||
| 59 | + */ | ||
| 60 | + private LocalDateTime startTime; | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 截止时间 | ||
| 64 | + */ | ||
| 65 | + private LocalDateTime endTime; | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 项目类型 | ||
| 69 | + */ | ||
| 70 | + private String projectType; | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 开标时间 | ||
| 74 | + */ | ||
| 75 | + private LocalDateTime bidTime; | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 采购规则 | ||
| 79 | + */ | ||
| 80 | + private String purchaseRule; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 状态 | ||
| 84 | + */ | ||
| 85 | + private String status; | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 创建人ID | ||
| 89 | + */ | ||
| 90 | + @TableField(fill = FieldFill.INSERT) | ||
| 91 | + private String createById; | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 创建人 | ||
| 95 | + */ | ||
| 96 | + @TableField(fill = FieldFill.INSERT) | ||
| 97 | + private String createBy; | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * 更新人ID | ||
| 101 | + */ | ||
| 102 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 103 | + private String updateById; | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 更新人 | ||
| 107 | + */ | ||
| 108 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 109 | + private String updateBy; | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * 创建时间 | ||
| 113 | + */ | ||
| 114 | + @TableField(fill = FieldFill.INSERT) | ||
| 115 | + private LocalDateTime createTime; | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * 更新时间 | ||
| 119 | + */ | ||
| 120 | + @TableField(fill = FieldFill.INSERT_UPDATE) | ||
| 121 | + private LocalDateTime updateTime; | ||
| 122 | +} | ||
| 123 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.impl.quotation; | ||
| 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.common.exceptions.impl.DefaultClientException; | ||
| 8 | +import com.lframework.starter.common.utils.Assert; | ||
| 9 | +import com.lframework.starter.common.utils.ObjectUtil; | ||
| 10 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | ||
| 11 | +import com.lframework.starter.web.core.components.resp.PageResult; | ||
| 12 | +import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | ||
| 13 | +import com.lframework.starter.web.core.utils.IdUtil; | ||
| 14 | +import com.lframework.starter.web.core.utils.OpLogUtil; | ||
| 15 | +import com.lframework.starter.web.core.utils.PageHelperUtil; | ||
| 16 | +import com.lframework.starter.web.core.utils.PageResultUtil; | ||
| 17 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | ||
| 18 | +import com.lframework.xingyun.basedata.entity.BreedRelationship; | ||
| 19 | +import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; | ||
| 20 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; | ||
| 21 | +import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectMapper; | ||
| 22 | +import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectService; | ||
| 23 | +import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotationProjectVo; | ||
| 24 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo; | ||
| 25 | +import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo; | ||
| 26 | +import java.io.Serializable; | ||
| 27 | +import java.time.LocalDate; | ||
| 28 | +import java.time.LocalDateTime; | ||
| 29 | +import java.time.format.DateTimeFormatter; | ||
| 30 | +import java.util.List; | ||
| 31 | +import javax.annotation.Resource; | ||
| 32 | +import org.apache.commons.lang3.StringUtils; | ||
| 33 | +import org.springframework.stereotype.Service; | ||
| 34 | +import org.springframework.transaction.annotation.Transactional; | ||
| 35 | + | ||
| 36 | +@Service | ||
| 37 | +public class SupplierQuotationProjectServiceImpl | ||
| 38 | + extends BaseMpServiceImpl<SupplierQuotationProjectMapper, SupplierQuotationProject> | ||
| 39 | + implements SupplierQuotationProjectService { | ||
| 40 | + | ||
| 41 | + private static final DateTimeFormatter CODE_DAY_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd"); | ||
| 42 | + private static final String CODE_PREFIX = "G"; | ||
| 43 | + //未发布 | ||
| 44 | + private static final String STATUS_UNPUBLISHED_CN = "UNPUBLISHED"; | ||
| 45 | + //未开始 | ||
| 46 | + private static final String STATUS_NOT_STARTED_CN = "NOT_STARTED"; | ||
| 47 | + //报价中 | ||
| 48 | + private static final String STATUS_QUOTING_CN = "QUOTING"; | ||
| 49 | + //已截止 | ||
| 50 | + private static final String STATUS_EXPIRED_CN = "EXPIRED"; | ||
| 51 | + //已完成 | ||
| 52 | + private static final String STATUS_COMPLETED_CN = "COMPLETED"; | ||
| 53 | + //已中止 | ||
| 54 | + private static final String STATUS_ABORTED_CN = "ABORTED"; | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + @Resource | ||
| 59 | + private BreedRelationshipService breedRelationshipService; | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public PageResult<SupplierQuotationProject> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationProjectVo vo) { | ||
| 63 | + Assert.greaterThanZero(pageIndex); | ||
| 64 | + Assert.greaterThanZero(pageSize); | ||
| 65 | + | ||
| 66 | + PageHelperUtil.startPage(pageIndex, pageSize); | ||
| 67 | + List<SupplierQuotationProject> datas = this.query(vo); | ||
| 68 | + fillComputedStatus(datas); | ||
| 69 | + return PageResultUtil.convert(new PageInfo<>(datas)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public List<SupplierQuotationProject> query(QuerySupplierQuotationProjectVo vo) { | ||
| 74 | + List<SupplierQuotationProject> datas = getBaseMapper().query(vo); | ||
| 75 | + fillComputedStatus(datas); | ||
| 76 | + return datas; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 80 | + public SupplierQuotationProject findById(String id) { | ||
| 81 | + SupplierQuotationProject data = getBaseMapper().findById(id); | ||
| 82 | + if (data != null) { | ||
| 83 | + data.setStatus(computeStatus(data)); | ||
| 84 | + } | ||
| 85 | + return data; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @OpLog(type = OtherOpLogType.class, name = "新增供应商报价项目,ID:{}", params = {"#id"}) | ||
| 89 | + @Transactional(rollbackFor = Exception.class) | ||
| 90 | + @Override | ||
| 91 | + public String create(CreateSupplierQuotationProjectVo vo) { | ||
| 92 | + validateProduct(vo.getProductId()); | ||
| 93 | + validateTimes(vo.getProjectType(), vo.getStartTime(), vo.getEndTime(), vo.getBidTime()); | ||
| 94 | + | ||
| 95 | + SupplierQuotationProject data = new SupplierQuotationProject(); | ||
| 96 | + data.setId(IdUtil.getId()); | ||
| 97 | + data.setCode(generateCode()); | ||
| 98 | + data.setName(StringUtils.trimToEmpty(vo.getName())); | ||
| 99 | + data.setProductId(StringUtils.trimToEmpty(vo.getProductId())); | ||
| 100 | + data.setQuantity(vo.getQuantity()); | ||
| 101 | + data.setStartTime(vo.getStartTime()); | ||
| 102 | + data.setEndTime(vo.getEndTime()); | ||
| 103 | + data.setProjectType(StringUtils.trimToEmpty(vo.getProjectType())); | ||
| 104 | + data.setBidTime(vo.getBidTime()); | ||
| 105 | + data.setPurchaseRule(StringUtils.defaultIfBlank(vo.getPurchaseRule(), null)); | ||
| 106 | + data.setStatus(null); | ||
| 107 | + | ||
| 108 | + getBaseMapper().insert(data); | ||
| 109 | + | ||
| 110 | + OpLogUtil.setVariable("id", data.getId()); | ||
| 111 | + OpLogUtil.setExtra(vo); | ||
| 112 | + return data.getId(); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @OpLog(type = OtherOpLogType.class, name = "修改供应商报价项目,ID:{}", params = {"#vo.id"}) | ||
| 116 | + @Transactional(rollbackFor = Exception.class) | ||
| 117 | + @Override | ||
| 118 | + public void update(UpdateSupplierQuotationProjectVo vo) { | ||
| 119 | + SupplierQuotationProject data = getBaseMapper().selectById(vo.getId()); | ||
| 120 | + if (ObjectUtil.isNull(data)) { | ||
| 121 | + throw new DefaultClientException("供应商报价项目不存在!"); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + validateProduct(vo.getProductId()); | ||
| 125 | + validateTimes(vo.getProjectType(), vo.getStartTime(), vo.getEndTime(), vo.getBidTime()); | ||
| 126 | + | ||
| 127 | + LambdaUpdateWrapper<SupplierQuotationProject> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationProject.class) | ||
| 128 | + .set(SupplierQuotationProject::getName, StringUtils.trimToEmpty(vo.getName())) | ||
| 129 | + .set(SupplierQuotationProject::getProductId, StringUtils.trimToEmpty(vo.getProductId())) | ||
| 130 | + .set(SupplierQuotationProject::getQuantity, vo.getQuantity()) | ||
| 131 | + .set(SupplierQuotationProject::getStartTime, vo.getStartTime()) | ||
| 132 | + .set(SupplierQuotationProject::getEndTime, vo.getEndTime()) | ||
| 133 | + .set(SupplierQuotationProject::getProjectType, StringUtils.trimToEmpty(vo.getProjectType())) | ||
| 134 | + .set(SupplierQuotationProject::getBidTime, vo.getBidTime()) | ||
| 135 | + .set(SupplierQuotationProject::getPurchaseRule, StringUtils.defaultIfBlank(vo.getPurchaseRule(), null)) | ||
| 136 | + .eq(SupplierQuotationProject::getId, vo.getId()); | ||
| 137 | + | ||
| 138 | + getBaseMapper().update(updateWrapper); | ||
| 139 | + | ||
| 140 | + OpLogUtil.setVariable("id", vo.getId()); | ||
| 141 | + OpLogUtil.setExtra(vo); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + @OpLog(type = OtherOpLogType.class, name = "删除供应商报价项目,ID:{}", params = {"#id"}) | ||
| 145 | + @Transactional(rollbackFor = Exception.class) | ||
| 146 | + @Override | ||
| 147 | + public void delete(String id) { | ||
| 148 | + getBaseMapper().deleteById(id); | ||
| 149 | + | ||
| 150 | + OpLogUtil.setVariable("id", id); | ||
| 151 | + OpLogUtil.setExtra(id); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + @OpLog(type = OtherOpLogType.class, name = "修改供应商报价项目状态,ID:{}", params = {"#id"}) | ||
| 155 | + @Transactional(rollbackFor = Exception.class) | ||
| 156 | + @Override | ||
| 157 | + public void updateStatus(String id, String status) { | ||
| 158 | + SupplierQuotationProject data = getBaseMapper().selectById(id); | ||
| 159 | + if (ObjectUtil.isNull(data)) { | ||
| 160 | + throw new DefaultClientException("供应商报价项目不存在!"); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + LambdaUpdateWrapper<SupplierQuotationProject> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationProject.class) | ||
| 164 | + .set(SupplierQuotationProject::getStatus, status) | ||
| 165 | + .eq(SupplierQuotationProject::getId, id); | ||
| 166 | + | ||
| 167 | + getBaseMapper().update(updateWrapper); | ||
| 168 | + | ||
| 169 | + OpLogUtil.setVariable("id", id); | ||
| 170 | + OpLogUtil.setExtra(status); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + @Override | ||
| 174 | + public void cleanCacheByKey(Serializable key) { | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + private void validateProduct(String productId) { | ||
| 178 | + BreedRelationship breedRelationship = breedRelationshipService.findById(productId); | ||
| 179 | + if (breedRelationship == null) { | ||
| 180 | + throw new DefaultClientException("品种不存在,请重新选择!"); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + private void validateTimes(String projectType, LocalDateTime startTime, LocalDateTime endTime, LocalDateTime bidTime) { | ||
| 185 | + if (startTime != null && endTime != null && endTime.isBefore(startTime)) { | ||
| 186 | + throw new DefaultClientException("截止时间不能早于开始时间!"); | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + if (isCentralBid(projectType) && bidTime == null) { | ||
| 190 | + throw new DefaultClientException("项目类型为集中开标时,开标时间不能为空!"); | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + private boolean isCentralBid(String projectType) { | ||
| 195 | + return "集中开标".equals(projectType) || "CENTRAL_BID".equalsIgnoreCase(projectType); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + private String generateCode() { | ||
| 199 | + LocalDate today = LocalDate.now(); | ||
| 200 | + String dayPrefix = CODE_PREFIX + today.format(CODE_DAY_FORMATTER); | ||
| 201 | + String maxCode = getBaseMapper().getMaxCodeByDay(dayPrefix); | ||
| 202 | + | ||
| 203 | + int nextSeq = 1; | ||
| 204 | + if (StringUtils.isNotBlank(maxCode) && maxCode.length() >= dayPrefix.length() + 2) { | ||
| 205 | + String seqStr = StringUtils.right(maxCode, 2); | ||
| 206 | + if (StringUtils.isNumeric(seqStr)) { | ||
| 207 | + nextSeq = Integer.parseInt(seqStr) + 1; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + String code = dayPrefix + String.format("%02d", nextSeq); | ||
| 212 | + checkCodeUnique(code); | ||
| 213 | + return code; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + private void checkCodeUnique(String code) { | ||
| 217 | + LambdaQueryWrapper<SupplierQuotationProject> wrapper = Wrappers.lambdaQuery(SupplierQuotationProject.class) | ||
| 218 | + .eq(SupplierQuotationProject::getCode, code); | ||
| 219 | + if (getBaseMapper().selectCount(wrapper) > 0) { | ||
| 220 | + throw new DefaultClientException("项目编号已存在,请重新生成!"); | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + private void fillComputedStatus(List<SupplierQuotationProject> datas) { | ||
| 225 | + if (datas == null || datas.isEmpty()) { | ||
| 226 | + return; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + datas.forEach(d -> d.setStatus(computeStatus(d))); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + private String computeStatus(SupplierQuotationProject data) { | ||
| 233 | + //未发布 | ||
| 234 | + if (StringUtils.isBlank(data.getStatus())) { | ||
| 235 | + return STATUS_UNPUBLISHED_CN; | ||
| 236 | + } | ||
| 237 | + LocalDateTime now = LocalDateTime.now(); | ||
| 238 | + if (STATUS_COMPLETED_CN.equals(data.getStatus()) || STATUS_ABORTED_CN.equals(data.getStatus())) { | ||
| 239 | + return data.getStatus(); | ||
| 240 | + } | ||
| 241 | + //未开始 | ||
| 242 | + if (data.getStartTime() != null && now.isBefore(data.getStartTime())) { | ||
| 243 | + return STATUS_NOT_STARTED_CN; | ||
| 244 | + } | ||
| 245 | + //已截止 | ||
| 246 | + if (data.getEndTime() != null && now.isAfter(data.getEndTime())) { | ||
| 247 | + return STATUS_EXPIRED_CN; | ||
| 248 | + } | ||
| 249 | + //报价中 | ||
| 250 | + if (data.getStartTime() != null && now.isAfter(data.getStartTime()) | ||
| 251 | + && data.getEndTime() != null && now.isBefore(data.getEndTime())) { | ||
| 252 | + return STATUS_QUOTING_CN; | ||
| 253 | + } | ||
| 254 | + return data.getStatus(); | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | +} | ||
| 258 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.mappers.quotation; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.mapper.BaseMapper; | ||
| 4 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; | ||
| 5 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo; | ||
| 6 | +import java.util.List; | ||
| 7 | +import org.apache.ibatis.annotations.Param; | ||
| 8 | + | ||
| 9 | +public interface SupplierQuotationProjectMapper extends BaseMapper<SupplierQuotationProject> { | ||
| 10 | + | ||
| 11 | + List<SupplierQuotationProject> query(@Param("vo") QuerySupplierQuotationProjectVo vo); | ||
| 12 | + | ||
| 13 | + SupplierQuotationProject findById(@Param("id") String id); | ||
| 14 | + | ||
| 15 | + String getMaxCodeByDay(@Param("dayPrefix") String dayPrefix); | ||
| 16 | +} | ||
| 17 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.service.quotation; | ||
| 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.procurement.entity.SupplierQuotationProject; | ||
| 6 | +import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotationProjectVo; | ||
| 7 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo; | ||
| 8 | +import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +public interface SupplierQuotationProjectService extends BaseMpService<SupplierQuotationProject> { | ||
| 12 | + | ||
| 13 | + PageResult<SupplierQuotationProject> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationProjectVo vo); | ||
| 14 | + | ||
| 15 | + List<SupplierQuotationProject> query(QuerySupplierQuotationProjectVo vo); | ||
| 16 | + | ||
| 17 | + SupplierQuotationProject findById(String id); | ||
| 18 | + | ||
| 19 | + String create(CreateSupplierQuotationProjectVo vo); | ||
| 20 | + | ||
| 21 | + void update(UpdateSupplierQuotationProjectVo vo); | ||
| 22 | + | ||
| 23 | + void delete(String id); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新项目状态 | ||
| 27 | + * | ||
| 28 | + * @param id 主键 | ||
| 29 | + * @param status 状态 | ||
| 30 | + */ | ||
| 31 | + void updateStatus(String id, String status); | ||
| 32 | +} | ||
| 33 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.vo.quotation; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import java.io.Serializable; | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import javax.validation.constraints.NotBlank; | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import lombok.Data; | ||
| 11 | +import org.hibernate.validator.constraints.Length; | ||
| 12 | + | ||
| 13 | +@Data | ||
| 14 | +public class CreateSupplierQuotationProjectVo implements BaseVo, Serializable { | ||
| 15 | + | ||
| 16 | + private static final long serialVersionUID = 1L; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "项目名称", required = true) | ||
| 19 | + @NotBlank(message = "项目名称不能为空!") | ||
| 20 | + @Length(max = 200, message = "项目名称最多允许200个字符!") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "品种ID", required = true) | ||
| 24 | + @NotBlank(message = "品种不能为空!") | ||
| 25 | + private String productId; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "数量", required = true) | ||
| 28 | + @NotNull(message = "数量不能为空!") | ||
| 29 | + private BigDecimal quantity; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "开始时间", required = true) | ||
| 32 | + @NotNull(message = "开始时间不能为空!") | ||
| 33 | + private LocalDateTime startTime; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "截止时间", required = true) | ||
| 36 | + @NotNull(message = "截止时间不能为空!") | ||
| 37 | + private LocalDateTime endTime; | ||
| 38 | + | ||
| 39 | + @ApiModelProperty(value = "项目类型", required = true) | ||
| 40 | + @NotBlank(message = "项目类型不能为空!") | ||
| 41 | + private String projectType; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty("开标时间") | ||
| 44 | + private LocalDateTime bidTime; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty("采购规则") | ||
| 47 | + @Length(max = 2000, message = "采购规则最多允许2000个字符!") | ||
| 48 | + private String purchaseRule; | ||
| 49 | +} | ||
| 50 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.vo.quotation; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 4 | +import com.lframework.starter.web.core.vo.PageVo; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import java.io.Serializable; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import lombok.Data; | ||
| 9 | + | ||
| 10 | +@Data | ||
| 11 | +public class QuerySupplierQuotationProjectVo extends PageVo implements BaseVo, Serializable { | ||
| 12 | + | ||
| 13 | + private static final long serialVersionUID = 1L; | ||
| 14 | + | ||
| 15 | + @ApiModelProperty("项目名称") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty("开始时间开始") | ||
| 19 | + private LocalDateTime startTimeStart; | ||
| 20 | + | ||
| 21 | + @ApiModelProperty("开始时间结束") | ||
| 22 | + private LocalDateTime startTimeEnd; | ||
| 23 | + | ||
| 24 | + @ApiModelProperty("截止时间开始") | ||
| 25 | + private LocalDateTime endTimeStart; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty("截止时间结束") | ||
| 28 | + private LocalDateTime endTimeEnd; | ||
| 29 | + | ||
| 30 | + @ApiModelProperty("开标时间开始") | ||
| 31 | + private LocalDateTime bidTimeStart; | ||
| 32 | + | ||
| 33 | + @ApiModelProperty("开标时间结束") | ||
| 34 | + private LocalDateTime bidTimeEnd; | ||
| 35 | +} | ||
| 36 | + |
| 1 | +package com.lframework.xingyun.sc.procurement.vo.quotation; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.web.core.vo.BaseVo; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import java.io.Serializable; | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import javax.validation.constraints.NotBlank; | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import lombok.Data; | ||
| 11 | +import org.hibernate.validator.constraints.Length; | ||
| 12 | + | ||
| 13 | +@Data | ||
| 14 | +public class UpdateSupplierQuotationProjectVo implements BaseVo, Serializable { | ||
| 15 | + | ||
| 16 | + private static final long serialVersionUID = 1L; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "ID", required = true) | ||
| 19 | + @NotBlank(message = "ID不能为空!") | ||
| 20 | + private String id; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "项目名称", required = true) | ||
| 23 | + @NotBlank(message = "项目名称不能为空!") | ||
| 24 | + @Length(max = 200, message = "项目名称最多允许200个字符!") | ||
| 25 | + private String name; | ||
| 26 | + | ||
| 27 | + @ApiModelProperty(value = "品种ID", required = true) | ||
| 28 | + @NotBlank(message = "品种不能为空!") | ||
| 29 | + private String productId; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "数量", required = true) | ||
| 32 | + @NotNull(message = "数量不能为空!") | ||
| 33 | + private BigDecimal quantity; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "开始时间", required = true) | ||
| 36 | + @NotNull(message = "开始时间不能为空!") | ||
| 37 | + private LocalDateTime startTime; | ||
| 38 | + | ||
| 39 | + @ApiModelProperty(value = "截止时间", required = true) | ||
| 40 | + @NotNull(message = "截止时间不能为空!") | ||
| 41 | + private LocalDateTime endTime; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty(value = "项目类型", required = true) | ||
| 44 | + @NotBlank(message = "项目类型不能为空!") | ||
| 45 | + private String projectType; | ||
| 46 | + | ||
| 47 | + @ApiModelProperty("开标时间") | ||
| 48 | + private LocalDateTime bidTime; | ||
| 49 | + | ||
| 50 | + @ApiModelProperty("采购规则") | ||
| 51 | + @Length(max = 2000, message = "采购规则最多允许2000个字符!") | ||
| 52 | + private String purchaseRule; | ||
| 53 | + | ||
| 54 | +} | ||
| 55 | + |
xingyun-sc/src/main/resources/mappers/procurement/quotation/SupplierQuotationProjectMapper.xml
0 → 100644
| 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.procurement.mappers.quotation.SupplierQuotationProjectMapper"> | ||
| 4 | + | ||
| 5 | + <resultMap id="SupplierQuotationProject" type="com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject"> | ||
| 6 | + <id column="id" property="id"/> | ||
| 7 | + <result column="code" property="code"/> | ||
| 8 | + <result column="name" property="name"/> | ||
| 9 | + <result column="product_id" property="productId"/> | ||
| 10 | + <result column="product_name" property="productName"/> | ||
| 11 | + <result column="product_code" property="productCode"/> | ||
| 12 | + <result column="quantity" property="quantity"/> | ||
| 13 | + <result column="start_time" property="startTime"/> | ||
| 14 | + <result column="end_time" property="endTime"/> | ||
| 15 | + <result column="project_type" property="projectType"/> | ||
| 16 | + <result column="bid_time" property="bidTime"/> | ||
| 17 | + <result column="purchase_rule" property="purchaseRule"/> | ||
| 18 | + <result column="status" property="status"/> | ||
| 19 | + <result column="create_by_id" property="createById"/> | ||
| 20 | + <result column="create_by" property="createBy"/> | ||
| 21 | + <result column="update_by_id" property="updateById"/> | ||
| 22 | + <result column="update_by" property="updateBy"/> | ||
| 23 | + <result column="create_time" property="createTime"/> | ||
| 24 | + <result column="update_time" property="updateTime"/> | ||
| 25 | + </resultMap> | ||
| 26 | + | ||
| 27 | + <sql id="SupplierQuotationProjectSql"> | ||
| 28 | + SELECT | ||
| 29 | + tb.id, | ||
| 30 | + tb.code, | ||
| 31 | + tb.name, | ||
| 32 | + tb.product_id, | ||
| 33 | + br.product_name, | ||
| 34 | + br.code AS product_code, | ||
| 35 | + tb.quantity, | ||
| 36 | + tb.start_time, | ||
| 37 | + tb.end_time, | ||
| 38 | + tb.project_type, | ||
| 39 | + tb.bid_time, | ||
| 40 | + tb.purchase_rule, | ||
| 41 | + tb.status, | ||
| 42 | + tb.create_by_id, | ||
| 43 | + tb.create_by, | ||
| 44 | + tb.update_by_id, | ||
| 45 | + tb.update_by, | ||
| 46 | + tb.create_time, | ||
| 47 | + tb.update_time | ||
| 48 | + FROM procurement_supplier_quotation_project tb | ||
| 49 | + LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id | ||
| 50 | + </sql> | ||
| 51 | + | ||
| 52 | + <select id="query" resultMap="SupplierQuotationProject"> | ||
| 53 | + <include refid="SupplierQuotationProjectSql"/> | ||
| 54 | + <where> | ||
| 55 | + <if test="vo.name != null and vo.name != ''"> | ||
| 56 | + AND tb.name LIKE CONCAT('%', #{vo.name}, '%') | ||
| 57 | + </if> | ||
| 58 | + <if test="vo.startTimeStart != null"> | ||
| 59 | + AND tb.start_time <![CDATA[ >= ]]> #{vo.startTimeStart} | ||
| 60 | + </if> | ||
| 61 | + <if test="vo.startTimeEnd != null"> | ||
| 62 | + AND tb.start_time <![CDATA[ <= ]]> #{vo.startTimeEnd} | ||
| 63 | + </if> | ||
| 64 | + <if test="vo.endTimeStart != null"> | ||
| 65 | + AND tb.end_time <![CDATA[ >= ]]> #{vo.endTimeStart} | ||
| 66 | + </if> | ||
| 67 | + <if test="vo.endTimeEnd != null"> | ||
| 68 | + AND tb.end_time <![CDATA[ <= ]]> #{vo.endTimeEnd} | ||
| 69 | + </if> | ||
| 70 | + <if test="vo.bidTimeStart != null"> | ||
| 71 | + AND tb.bid_time <![CDATA[ >= ]]> #{vo.bidTimeStart} | ||
| 72 | + </if> | ||
| 73 | + <if test="vo.bidTimeEnd != null"> | ||
| 74 | + AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd} | ||
| 75 | + </if> | ||
| 76 | + </where> | ||
| 77 | + ORDER BY tb.create_time DESC, tb.id DESC | ||
| 78 | + </select> | ||
| 79 | + | ||
| 80 | + <select id="findById" resultMap="SupplierQuotationProject"> | ||
| 81 | + <include refid="SupplierQuotationProjectSql"/> | ||
| 82 | + WHERE tb.id = #{id} | ||
| 83 | + </select> | ||
| 84 | + | ||
| 85 | + <select id="getMaxCodeByDay" resultType="java.lang.String"> | ||
| 86 | + SELECT tb.code | ||
| 87 | + FROM procurement_supplier_quotation_project tb | ||
| 88 | + WHERE tb.code LIKE CONCAT(#{dayPrefix}, '%') | ||
| 89 | + ORDER BY CAST(RIGHT(tb.code, 2) AS UNSIGNED) DESC | ||
| 90 | + LIMIT 1 | ||
| 91 | + </select> | ||
| 92 | +</mapper> | ||
| 93 | + |