Showing
12 changed files
with
679 additions
and
5 deletions
| ... | ... | @@ -1828,3 +1828,32 @@ CREATE TABLE `procurement_supplier_quotation_project_quote` |
| 1828 | 1828 | KEY `idx_psqpjq_quote_time` (`quote_time`), |
| 1829 | 1829 | KEY `idx_psqpjq_create_time` (`create_time`) |
| 1830 | 1830 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='供应商报价项目报价'; |
| 1831 | + | |
| 1832 | +CREATE TABLE `procurement_supplier_quotation_deal` | |
| 1833 | +( | |
| 1834 | + `id` varchar(32) NOT NULL COMMENT 'ID', | |
| 1835 | + `project_id` varchar(32) NOT NULL COMMENT '报价项目ID', | |
| 1836 | + `project_code` varchar(20) NOT NULL COMMENT '项目编号', | |
| 1837 | + `project_name` varchar(200) NOT NULL COMMENT '项目名称', | |
| 1838 | + `quote_time` datetime NOT NULL COMMENT '报价开始时间', | |
| 1839 | + `supplier_id` varchar(32) NOT NULL COMMENT '供应商ID', | |
| 1840 | + `supplier_name` varchar(200) NOT NULL COMMENT '供应商名称', | |
| 1841 | + `product_id` varchar(32) NOT NULL COMMENT '品种ID', | |
| 1842 | + `quantity` decimal(18, 5) NOT NULL COMMENT '数量', | |
| 1843 | + `price` decimal(18, 10) NOT NULL COMMENT '价格', | |
| 1844 | + `purchase_department` varchar(32) DEFAULT NULL COMMENT '采购处', | |
| 1845 | + `principal_id` varchar(32) DEFAULT NULL COMMENT '负责人ID', | |
| 1846 | + `principal_name` varchar(64) DEFAULT NULL COMMENT '负责人', | |
| 1847 | + `assign_time` datetime DEFAULT NULL COMMENT '分配时间', | |
| 1848 | + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', | |
| 1849 | + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', | |
| 1850 | + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', | |
| 1851 | + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人', | |
| 1852 | + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 1853 | + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 1854 | + PRIMARY KEY (`id`), | |
| 1855 | + UNIQUE KEY `uk_psqd_project_supplier` (`project_id`, `supplier_id`), | |
| 1856 | + KEY `idx_psqd_purchase_department` (`purchase_department`), | |
| 1857 | + KEY `idx_psqd_principal_id` (`principal_id`), | |
| 1858 | + KEY `idx_psqd_create_time` (`create_time`) | |
| 1859 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='供应商报价成交表'; | ... | ... |
| ... | ... | @@ -130,7 +130,7 @@ public class SalesmanQuotationController extends DefaultBaseController { |
| 130 | 130 | /** |
| 131 | 131 | * 成交/终止 |
| 132 | 132 | */ |
| 133 | - @ApiOperation("成交/终止") | |
| 133 | + @ApiOperation("完成/终止") | |
| 134 | 134 | @PostMapping("/updateStatus") |
| 135 | 135 | public InvokeResult<Void> updateStatus(@NotBlank(message = "id不能为空!") String id, |
| 136 | 136 | @NotBlank(message = "状态不能为空!") String status) { | ... | ... |
| 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.starter.web.inner.bo.system.user.QuerySysUserBo; | |
| 10 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationDeal; | |
| 11 | +import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationDealService; | |
| 12 | +import com.lframework.xingyun.sc.procurement.vo.quotation.AssignSupplierQuotationDealVo; | |
| 13 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationDealVo; | |
| 14 | +import io.swagger.annotations.Api; | |
| 15 | +import io.swagger.annotations.ApiImplicitParam; | |
| 16 | +import io.swagger.annotations.ApiOperation; | |
| 17 | +import java.util.List; | |
| 18 | +import javax.annotation.Resource; | |
| 19 | +import javax.validation.Valid; | |
| 20 | +import javax.validation.constraints.NotBlank; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 23 | +import org.springframework.web.bind.annotation.PutMapping; | |
| 24 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 25 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 26 | +import org.springframework.web.bind.annotation.RestController; | |
| 27 | + | |
| 28 | +@Api(tags = "供应商报价成交表") | |
| 29 | +@Validated | |
| 30 | +@RestController | |
| 31 | +@RequestMapping("/procurement/supplierQuotationDeal") | |
| 32 | +public class SupplierQuotationDealController extends DefaultBaseController { | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private SupplierQuotationDealService supplierQuotationDealService; | |
| 36 | + | |
| 37 | + @ApiOperation("分页查询") | |
| 38 | + @HasPermission({"procure-manage:quote-manage:query"}) | |
| 39 | + @GetMapping("/query") | |
| 40 | + public InvokeResult<PageResult<SupplierQuotationDeal>> query(@Valid QuerySupplierQuotationDealVo vo) { | |
| 41 | + return InvokeResultBuilder.success( | |
| 42 | + supplierQuotationDealService.query(getPageIndex(vo), getPageSize(vo), vo)); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @ApiOperation("详情") | |
| 46 | + @HasPermission({"procure-manage:quote-manage:query"}) | |
| 47 | + @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true) | |
| 48 | + @GetMapping("") | |
| 49 | + public InvokeResult<SupplierQuotationDeal> get(@NotBlank(message = "id不能为空!") String id) { | |
| 50 | + SupplierQuotationDeal data = supplierQuotationDealService.findById(id); | |
| 51 | + if (data == null) { | |
| 52 | + throw new DefaultClientException("成交数据不存在!"); | |
| 53 | + } | |
| 54 | + return InvokeResultBuilder.success(data); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @ApiOperation("分配负责人") | |
| 58 | + @HasPermission({"procure-manage:quote-manage:assign"}) | |
| 59 | + @PutMapping("/assign") | |
| 60 | + public InvokeResult<Void> assign(@Valid @RequestBody AssignSupplierQuotationDealVo vo) { | |
| 61 | + supplierQuotationDealService.assign(vo); | |
| 62 | + return InvokeResultBuilder.success(); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @ApiOperation("获取当前采购处可分配人员") | |
| 66 | + @GetMapping("/assignUsers") | |
| 67 | + public InvokeResult<List<QuerySysUserBo>> getCurrentPurchaseDeptUsers(@NotBlank(message = "采购处不能为空!") String purchaseDepartment) { | |
| 68 | + return InvokeResultBuilder.success(supplierQuotationDealService.getDeptUsersWithChildren(purchaseDepartment)); | |
| 69 | + } | |
| 70 | +} | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/procurement/entity/SupplierQuotationDeal.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_deal") | |
| 14 | +public class SupplierQuotationDeal extends BaseEntity implements BaseDto { | |
| 15 | + | |
| 16 | + private static final long serialVersionUID = 1L; | |
| 17 | + | |
| 18 | + public static final String CACHE_NAME = "SupplierQuotationDeal"; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * ID | |
| 22 | + */ | |
| 23 | + private String id; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 报价项目ID | |
| 27 | + */ | |
| 28 | + private String projectId; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 项目编号 | |
| 32 | + */ | |
| 33 | + private String projectCode; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 项目名称 | |
| 37 | + */ | |
| 38 | + private String projectName; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 报价开始时间 | |
| 42 | + */ | |
| 43 | + private LocalDateTime quoteTime; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 供应商ID | |
| 47 | + */ | |
| 48 | + private String supplierId; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 供应商名称 | |
| 52 | + */ | |
| 53 | + private String supplierName; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 品种ID | |
| 57 | + */ | |
| 58 | + private String productId; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 品种名称 | |
| 62 | + */ | |
| 63 | + @TableField(exist = false) | |
| 64 | + private String productName; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 品种代号 | |
| 68 | + */ | |
| 69 | + @TableField(exist = false) | |
| 70 | + private String productCode; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 数量 | |
| 74 | + */ | |
| 75 | + private BigDecimal quantity; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 价格 | |
| 79 | + */ | |
| 80 | + private BigDecimal price; | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 采购处 | |
| 84 | + */ | |
| 85 | + private String purchaseDepartment; | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * 采购处名称 | |
| 89 | + */ | |
| 90 | + @TableField(exist = false) | |
| 91 | + private String purchaseDepartmentName; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * 负责人ID | |
| 95 | + */ | |
| 96 | + private String principalId; | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * 负责人 | |
| 100 | + */ | |
| 101 | + private String principalName; | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * 分配时间 | |
| 105 | + */ | |
| 106 | + private LocalDateTime assignTime; | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * 创建人ID | |
| 110 | + */ | |
| 111 | + @TableField(fill = FieldFill.INSERT) | |
| 112 | + private String createById; | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * 创建人 | |
| 116 | + */ | |
| 117 | + @TableField(fill = FieldFill.INSERT) | |
| 118 | + private String createBy; | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * 更新人ID | |
| 122 | + */ | |
| 123 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 124 | + private String updateById; | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 更新人 | |
| 128 | + */ | |
| 129 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 130 | + private String updateBy; | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * 创建时间 | |
| 134 | + */ | |
| 135 | + @TableField(fill = FieldFill.INSERT) | |
| 136 | + private LocalDateTime createTime; | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * 更新时间 | |
| 140 | + */ | |
| 141 | + @TableField(fill = FieldFill.INSERT_UPDATE) | |
| 142 | + private LocalDateTime updateTime; | |
| 143 | +} | |
| 144 | + | ... | ... |
| 1 | +package com.lframework.xingyun.sc.procurement.impl.quotation; | |
| 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.CollectionUtil; | |
| 8 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | |
| 9 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 10 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | |
| 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.bo.system.user.QuerySysUserBo; | |
| 17 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | |
| 18 | +import com.lframework.starter.web.inner.entity.SysDept; | |
| 19 | +import com.lframework.starter.web.inner.entity.SysUser; | |
| 20 | +import com.lframework.starter.web.inner.entity.SysUserDept; | |
| 21 | +import com.lframework.starter.web.inner.service.system.SysDeptService; | |
| 22 | +import com.lframework.starter.web.inner.service.system.SysUserDeptService; | |
| 23 | +import com.lframework.starter.web.inner.service.system.SysUserService; | |
| 24 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationDeal; | |
| 25 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; | |
| 26 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProjectQuote; | |
| 27 | +import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationDealMapper; | |
| 28 | +import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectMapper; | |
| 29 | +import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectQuoteMapper; | |
| 30 | +import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationDealService; | |
| 31 | +import com.lframework.xingyun.sc.procurement.vo.quotation.AssignSupplierQuotationDealVo; | |
| 32 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationDealVo; | |
| 33 | +import java.io.Serializable; | |
| 34 | +import java.time.LocalDateTime; | |
| 35 | +import java.util.ArrayList; | |
| 36 | +import java.util.Collections; | |
| 37 | +import java.util.List; | |
| 38 | +import java.util.Map; | |
| 39 | +import java.util.Set; | |
| 40 | +import java.util.stream.Collectors; | |
| 41 | +import java.util.stream.Stream; | |
| 42 | +import javax.annotation.Resource; | |
| 43 | +import org.apache.commons.lang3.StringUtils; | |
| 44 | +import org.springframework.stereotype.Service; | |
| 45 | +import org.springframework.transaction.annotation.Transactional; | |
| 46 | + | |
| 47 | +@Service | |
| 48 | +public class SupplierQuotationDealServiceImpl | |
| 49 | + extends BaseMpServiceImpl<SupplierQuotationDealMapper, SupplierQuotationDeal> | |
| 50 | + implements SupplierQuotationDealService { | |
| 51 | + @Resource | |
| 52 | + private SupplierQuotationProjectMapper supplierQuotationProjectMapper; | |
| 53 | + @Resource | |
| 54 | + private SupplierQuotationProjectQuoteMapper supplierQuotationProjectQuoteMapper; | |
| 55 | + @Resource | |
| 56 | + private SysDeptService sysDeptService; | |
| 57 | + @Resource | |
| 58 | + private SysUserDeptService sysUserDeptService; | |
| 59 | + @Resource | |
| 60 | + private SysUserService sysUserService; | |
| 61 | + | |
| 62 | + @Transactional(rollbackFor = Exception.class) | |
| 63 | + @Override | |
| 64 | + public void syncDealByBidStatus(String projectId, String supplierId) { | |
| 65 | + if (StringUtils.isBlank(projectId) || StringUtils.isBlank(supplierId)) { | |
| 66 | + return; | |
| 67 | + } | |
| 68 | + SupplierQuotationProject project = supplierQuotationProjectMapper.selectById(projectId); | |
| 69 | + SupplierQuotationProjectQuote quote = supplierQuotationProjectQuoteMapper.findByProjectAndSupplier(projectId, supplierId); | |
| 70 | + if (project == null || quote == null) { | |
| 71 | + throw new DefaultClientException("成交数据同步失败,报价项目或报价记录不存在!"); | |
| 72 | + } | |
| 73 | + | |
| 74 | + List<SysDept> purchaseDept = sysDeptService.getPurchaseDept(quote.getSupplierId()); | |
| 75 | + String purchaseDepartment = CollectionUtil.isNotEmpty(purchaseDept) ? purchaseDept.get(0).getId() : null; | |
| 76 | + SupplierQuotationDeal exist = getBaseMapper().findByProjectAndSupplier(projectId, supplierId); | |
| 77 | + if (exist == null) { | |
| 78 | + SupplierQuotationDeal data = new SupplierQuotationDeal(); | |
| 79 | + data.setId(IdUtil.getId()); | |
| 80 | + data.setProjectId(project.getId()); | |
| 81 | + data.setProjectCode(project.getCode()); | |
| 82 | + data.setProjectName(project.getName()); | |
| 83 | + data.setQuoteTime(project.getStartTime()); | |
| 84 | + data.setSupplierId(quote.getSupplierId()); | |
| 85 | + data.setSupplierName(quote.getSupplierName()); | |
| 86 | + data.setProductId(project.getProductId()); | |
| 87 | + data.setQuantity(quote.getQuantity()); | |
| 88 | + data.setPrice(quote.getPrice()); | |
| 89 | + data.setPurchaseDepartment(purchaseDepartment); | |
| 90 | + getBaseMapper().insert(data); | |
| 91 | + } else { | |
| 92 | + LambdaUpdateWrapper<SupplierQuotationDeal> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationDeal.class) | |
| 93 | + .set(SupplierQuotationDeal::getProjectCode, project.getCode()) | |
| 94 | + .set(SupplierQuotationDeal::getProjectName, project.getName()) | |
| 95 | + .set(SupplierQuotationDeal::getQuoteTime, project.getStartTime()) | |
| 96 | + .set(SupplierQuotationDeal::getSupplierName, quote.getSupplierName()) | |
| 97 | + .set(SupplierQuotationDeal::getProductId, project.getProductId()) | |
| 98 | + .set(SupplierQuotationDeal::getQuantity, quote.getQuantity()) | |
| 99 | + .set(SupplierQuotationDeal::getPrice, quote.getPrice()) | |
| 100 | + .set(SupplierQuotationDeal::getPurchaseDepartment, purchaseDepartment) | |
| 101 | + .eq(SupplierQuotationDeal::getId, exist.getId()); | |
| 102 | + getBaseMapper().update(updateWrapper); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + | |
| 106 | + @Override | |
| 107 | + public PageResult<SupplierQuotationDeal> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationDealVo vo) { | |
| 108 | + PageHelperUtil.startPage(pageIndex, pageSize); | |
| 109 | + List<SupplierQuotationDeal> datas = query(vo); | |
| 110 | + return PageResultUtil.convert(new PageInfo<>(datas)); | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + public SupplierQuotationDeal findById(String id) { | |
| 115 | + SupplierQuotationDeal data = getBaseMapper().findById(id); | |
| 116 | + if (data == null) { | |
| 117 | + return null; | |
| 118 | + } | |
| 119 | + return data; | |
| 120 | + } | |
| 121 | + | |
| 122 | + @OpLog(type = OtherOpLogType.class, name = "分配供应商报价成交数据,ID:{}", params = {"#vo.id"}) | |
| 123 | + @Transactional(rollbackFor = Exception.class) | |
| 124 | + @Override | |
| 125 | + public void assign(AssignSupplierQuotationDealVo vo) { | |
| 126 | + SupplierQuotationDeal data = getBaseMapper().findById(vo.getId()); | |
| 127 | + if (data == null) { | |
| 128 | + throw new DefaultClientException("成交数据不存在!"); | |
| 129 | + } | |
| 130 | + validateCurrentUserCanManage(data); | |
| 131 | + | |
| 132 | + SysUser principal = sysUserService.findById(vo.getPrincipalId()); | |
| 133 | + if (principal == null) { | |
| 134 | + throw new DefaultClientException("负责人不存在!"); | |
| 135 | + } | |
| 136 | + | |
| 137 | + LambdaUpdateWrapper<SupplierQuotationDeal> updateWrapper = Wrappers.lambdaUpdate(SupplierQuotationDeal.class) | |
| 138 | + .set(SupplierQuotationDeal::getPrincipalId, principal.getId()) | |
| 139 | + .set(SupplierQuotationDeal::getPrincipalName, principal.getName()) | |
| 140 | + .set(SupplierQuotationDeal::getAssignTime, LocalDateTime.now()) | |
| 141 | + .eq(SupplierQuotationDeal::getId, data.getId()); | |
| 142 | + getBaseMapper().update(updateWrapper); | |
| 143 | + | |
| 144 | + OpLogUtil.setExtra(vo); | |
| 145 | + } | |
| 146 | + | |
| 147 | + @Override | |
| 148 | + public List<QuerySysUserBo> getDeptUsersWithChildren(String purchaseDepartment) { | |
| 149 | + if (StringUtils.isBlank(purchaseDepartment)) { | |
| 150 | + return Collections.emptyList(); | |
| 151 | + } | |
| 152 | + | |
| 153 | + Map<String, List<String>> deptChildIdMap = sysDeptService.getDeptChildIdMap(Collections.singletonList(purchaseDepartment)); | |
| 154 | + List<String> deptIdList = deptChildIdMap.get(purchaseDepartment); | |
| 155 | + if (CollectionUtil.isEmpty(deptIdList)) { | |
| 156 | + deptIdList = new ArrayList<>(); | |
| 157 | + deptIdList.add(purchaseDepartment); | |
| 158 | + } else if (!deptIdList.contains(purchaseDepartment)) { | |
| 159 | + deptIdList = new ArrayList<>(deptIdList); | |
| 160 | + deptIdList.add(purchaseDepartment); | |
| 161 | + } | |
| 162 | + | |
| 163 | + Set<String> userIdSet = deptIdList.stream() | |
| 164 | + .flatMap(deptId -> { | |
| 165 | + List<SysUserDept> userDeptList = sysUserDeptService.getByDeptId(deptId); | |
| 166 | + if (CollectionUtil.isEmpty(userDeptList)) { | |
| 167 | + return Stream.empty(); | |
| 168 | + } | |
| 169 | + return userDeptList.stream(); | |
| 170 | + }) | |
| 171 | + .map(SysUserDept::getUserId) | |
| 172 | + .filter(StringUtils::isNotBlank) | |
| 173 | + .collect(Collectors.toSet()); | |
| 174 | + if (userIdSet.isEmpty()) { | |
| 175 | + return Collections.emptyList(); | |
| 176 | + } | |
| 177 | + | |
| 178 | + List<SysUser> userList = sysUserService.listByIds(new ArrayList<>(userIdSet)); | |
| 179 | + if (CollectionUtil.isEmpty(userList)) { | |
| 180 | + return Collections.emptyList(); | |
| 181 | + } | |
| 182 | + return userList.stream() | |
| 183 | + .map(QuerySysUserBo::new) | |
| 184 | + .collect(Collectors.toList()); | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + @Override | |
| 189 | + public void cleanCacheByKey(Serializable key) { | |
| 190 | + } | |
| 191 | + | |
| 192 | + private List<SupplierQuotationDeal> query(QuerySupplierQuotationDealVo vo) { | |
| 193 | + String currentUserId = SecurityUtil.getCurrentUser().getId(); | |
| 194 | + List<String> purchaseDepartmentList = resolveUserPurchaseDepartments(currentUserId); | |
| 195 | + return getBaseMapper().query(vo, purchaseDepartmentList, currentUserId); | |
| 196 | + } | |
| 197 | + | |
| 198 | + private void validateCurrentUserCanManage(SupplierQuotationDeal data) { | |
| 199 | + List<String> purchaseDepartmentList = resolveUserPurchaseDepartments(SecurityUtil.getCurrentUser().getId()); | |
| 200 | + if (CollectionUtil.isEmpty(purchaseDepartmentList) || !purchaseDepartmentList.contains(data.getPurchaseDepartment())) { | |
| 201 | + throw new DefaultClientException("当前用户无权分配该成交数据!"); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + private List<String> resolveUserPurchaseDepartments(String userId) { | |
| 206 | + List<SysUserDept> userDeptList = sysUserDeptService.getByUserId(userId); | |
| 207 | + if (CollectionUtil.isEmpty(userDeptList)) { | |
| 208 | + return Collections.emptyList(); | |
| 209 | + } | |
| 210 | + return userDeptList.stream() | |
| 211 | + .map(SysUserDept::getDeptId) | |
| 212 | + .filter(StringUtils::isNotBlank) | |
| 213 | + .distinct() | |
| 214 | + .collect(Collectors.toList()); | |
| 215 | + } | |
| 216 | +} | ... | ... |
| ... | ... | @@ -24,6 +24,7 @@ import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject; |
| 24 | 24 | import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProjectQuote; |
| 25 | 25 | import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectMapper; |
| 26 | 26 | import com.lframework.xingyun.sc.procurement.mappers.quotation.SupplierQuotationProjectQuoteMapper; |
| 27 | +import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationDealService; | |
| 27 | 28 | import com.lframework.xingyun.sc.procurement.service.quotation.SupplierQuotationProjectQuoteService; |
| 28 | 29 | import com.lframework.xingyun.sc.procurement.vo.quotation.SupplierQuotationProjectQuoteVo; |
| 29 | 30 | import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectQuoteBidStatusVo; |
| ... | ... | @@ -44,9 +45,9 @@ public class SupplierQuotationProjectQuoteServiceImpl |
| 44 | 45 | extends BaseMpServiceImpl<SupplierQuotationProjectQuoteMapper, SupplierQuotationProjectQuote> |
| 45 | 46 | implements SupplierQuotationProjectQuoteService { |
| 46 | 47 | |
| 47 | - private static final String BID_STATUS_WIN = "中标"; | |
| 48 | - private static final String BID_STATUS_LOSE = "未中标"; | |
| 49 | - private static final String BID_STATUS_ABORT = "废标"; | |
| 48 | + private static final String BID_STATUS_WIN = "WIN"; | |
| 49 | + private static final String BID_STATUS_LOSE = "LOSE"; | |
| 50 | + private static final String BID_STATUS_ABORT = "ABORT"; | |
| 50 | 51 | |
| 51 | 52 | private static final String PROJECT_STATUS_COMPLETED = "COMPLETED"; |
| 52 | 53 | private static final String PROJECT_STATUS_ABORTED = "ABORTED"; |
| ... | ... | @@ -71,6 +72,8 @@ public class SupplierQuotationProjectQuoteServiceImpl |
| 71 | 72 | private BreedRelationshipService breedRelationshipService; |
| 72 | 73 | @Resource |
| 73 | 74 | private ApplicationEventPublisher applicationEventPublisher; |
| 75 | + @Resource | |
| 76 | + private SupplierQuotationDealService supplierQuotationDealService; | |
| 74 | 77 | |
| 75 | 78 | @OpLog(type = OtherOpLogType.class, name = "供应商报价项目报价,项目ID:{}", params = {"#vo.projectId"}) |
| 76 | 79 | @Transactional(rollbackFor = Exception.class) |
| ... | ... | @@ -185,6 +188,9 @@ public class SupplierQuotationProjectQuoteServiceImpl |
| 185 | 188 | .set(SupplierQuotationProjectQuote::getBidStatus, bidStatus) |
| 186 | 189 | .eq(SupplierQuotationProjectQuote::getId, exist.getId()); |
| 187 | 190 | getBaseMapper().update(updateWrapper); |
| 191 | + if (BID_STATUS_WIN.equals(bidStatus)) { | |
| 192 | + supplierQuotationDealService.syncDealByBidStatus(vo.getProjectId(), vo.getSupplierId()); | |
| 193 | + } | |
| 188 | 194 | publishChangedEvent(vo.getProjectId(), "BID_STATUS_UPDATE"); |
| 189 | 195 | |
| 190 | 196 | OpLogUtil.setExtra(vo); | ... | ... |
| 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.SupplierQuotationDeal; | |
| 5 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationDealVo; | |
| 6 | +import java.time.LocalDate; | |
| 7 | +import java.util.List; | |
| 8 | +import org.apache.ibatis.annotations.Param; | |
| 9 | + | |
| 10 | +public interface SupplierQuotationDealMapper extends BaseMapper<SupplierQuotationDeal> { | |
| 11 | + | |
| 12 | + SupplierQuotationDeal findById(@Param("id") String id); | |
| 13 | + | |
| 14 | + SupplierQuotationDeal findByProjectAndSupplier(@Param("projectId") String projectId, | |
| 15 | + @Param("supplierId") String supplierId); | |
| 16 | + | |
| 17 | + List<SupplierQuotationDeal> query(@Param("vo") QuerySupplierQuotationDealVo vo, | |
| 18 | + @Param("purchaseDepartmentList") List<String> purchaseDepartmentList, | |
| 19 | + @Param("userId") String userId); | |
| 20 | +} | |
| 21 | + | ... | ... |
| 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.starter.web.inner.bo.system.user.QuerySysUserBo; | |
| 6 | +import com.lframework.xingyun.sc.procurement.entity.SupplierQuotationDeal; | |
| 7 | +import com.lframework.xingyun.sc.procurement.vo.quotation.AssignSupplierQuotationDealVo; | |
| 8 | +import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationDealVo; | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +public interface SupplierQuotationDealService extends BaseMpService<SupplierQuotationDeal> { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 成交数据 | |
| 15 | + * | |
| 16 | + * @param projectId 项目主键 | |
| 17 | + * @param supplierId 供应商主键 | |
| 18 | + */ | |
| 19 | + void syncDealByBidStatus(String projectId, String supplierId); | |
| 20 | + | |
| 21 | + PageResult<SupplierQuotationDeal> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationDealVo vo); | |
| 22 | + | |
| 23 | + SupplierQuotationDeal findById(String id); | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 分配人员 | |
| 27 | + * | |
| 28 | + * @param vo 数据 | |
| 29 | + */ | |
| 30 | + void assign(AssignSupplierQuotationDealVo vo); | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 获取当前部门及其子部门下人员 | |
| 34 | + * | |
| 35 | + * @param purchaseDepartment 部门主键 | |
| 36 | + */ | |
| 37 | + List<QuerySysUserBo> getDeptUsersWithChildren(String purchaseDepartment); | |
| 38 | +} | ... | ... |
| 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 javax.validation.constraints.NotBlank; | |
| 7 | +import lombok.Data; | |
| 8 | + | |
| 9 | +@Data | |
| 10 | +public class AssignSupplierQuotationDealVo implements BaseVo, Serializable { | |
| 11 | + | |
| 12 | + private static final long serialVersionUID = 1L; | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "成交表ID", required = true) | |
| 15 | + @NotBlank(message = "成交表ID不能为空!") | |
| 16 | + private String id; | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "负责人ID", required = true) | |
| 19 | + @NotBlank(message = "负责人ID不能为空!") | |
| 20 | + private String principalId; | |
| 21 | +} | |
| 22 | + | ... | ... |
| 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 lombok.Data; | |
| 8 | + | |
| 9 | +@Data | |
| 10 | +public class QuerySupplierQuotationDealVo extends PageVo implements BaseVo, Serializable { | |
| 11 | + | |
| 12 | + private static final long serialVersionUID = 1L; | |
| 13 | + | |
| 14 | + @ApiModelProperty("项目名称") | |
| 15 | + private String projectName; | |
| 16 | + | |
| 17 | + @ApiModelProperty("项目编号") | |
| 18 | + private String projectCode; | |
| 19 | + | |
| 20 | + @ApiModelProperty("供应商名称") | |
| 21 | + private String supplierName; | |
| 22 | + | |
| 23 | + @ApiModelProperty("负责人ID") | |
| 24 | + private String principalId; | |
| 25 | +} | |
| 26 | + | ... | ... |
xingyun-sc/src/main/resources/mappers/procurement/quotation/SupplierQuotationDealMapper.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.SupplierQuotationDealMapper"> | |
| 4 | + | |
| 5 | + <resultMap id="SupplierQuotationDeal" type="com.lframework.xingyun.sc.procurement.entity.SupplierQuotationDeal"> | |
| 6 | + <id column="id" property="id"/> | |
| 7 | + <result column="project_id" property="projectId"/> | |
| 8 | + <result column="project_code" property="projectCode"/> | |
| 9 | + <result column="project_name" property="projectName"/> | |
| 10 | + <result column="quote_time" property="quoteTime"/> | |
| 11 | + <result column="supplier_id" property="supplierId"/> | |
| 12 | + <result column="supplier_name" property="supplierName"/> | |
| 13 | + <result column="product_id" property="productId"/> | |
| 14 | + <result column="product_name" property="productName"/> | |
| 15 | + <result column="product_code" property="productCode"/> | |
| 16 | + <result column="quantity" property="quantity"/> | |
| 17 | + <result column="price" property="price"/> | |
| 18 | + <result column="purchase_department" property="purchaseDepartment"/> | |
| 19 | + <result column="purchase_department_name" property="purchaseDepartmentName"/> | |
| 20 | + <result column="principal_id" property="principalId"/> | |
| 21 | + <result column="principal_name" property="principalName"/> | |
| 22 | + <result column="assign_time" property="assignTime"/> | |
| 23 | + <result column="create_by_id" property="createById"/> | |
| 24 | + <result column="create_by" property="createBy"/> | |
| 25 | + <result column="update_by_id" property="updateById"/> | |
| 26 | + <result column="update_by" property="updateBy"/> | |
| 27 | + <result column="create_time" property="createTime"/> | |
| 28 | + <result column="update_time" property="updateTime"/> | |
| 29 | + </resultMap> | |
| 30 | + | |
| 31 | + <sql id="SupplierQuotationDealSql"> | |
| 32 | + SELECT | |
| 33 | + tb.id, | |
| 34 | + tb.project_id, | |
| 35 | + tb.project_code, | |
| 36 | + tb.project_name, | |
| 37 | + tb.quote_time, | |
| 38 | + tb.supplier_id, | |
| 39 | + tb.supplier_name, | |
| 40 | + tb.product_id, | |
| 41 | + br.product_name, | |
| 42 | + br.code AS product_code, | |
| 43 | + tb.quantity, | |
| 44 | + tb.price, | |
| 45 | + tb.purchase_department, | |
| 46 | + sd.name AS purchase_department_name, | |
| 47 | + tb.principal_id, | |
| 48 | + tb.principal_name, | |
| 49 | + tb.assign_time, | |
| 50 | + tb.create_by_id, | |
| 51 | + tb.create_by, | |
| 52 | + tb.update_by_id, | |
| 53 | + tb.update_by, | |
| 54 | + tb.create_time, | |
| 55 | + tb.update_time | |
| 56 | + FROM procurement_supplier_quotation_deal tb | |
| 57 | + LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id | |
| 58 | + LEFT JOIN sys_dept sd ON sd.id = tb.purchase_department | |
| 59 | + </sql> | |
| 60 | + | |
| 61 | + <select id="findById" resultMap="SupplierQuotationDeal"> | |
| 62 | + <include refid="SupplierQuotationDealSql"/> | |
| 63 | + WHERE tb.id = #{id} | |
| 64 | + </select> | |
| 65 | + | |
| 66 | + <select id="findByProjectAndSupplier" resultMap="SupplierQuotationDeal"> | |
| 67 | + <include refid="SupplierQuotationDealSql"/> | |
| 68 | + WHERE tb.project_id = #{projectId} | |
| 69 | + AND tb.supplier_id = #{supplierId} | |
| 70 | + </select> | |
| 71 | + | |
| 72 | + <select id="query" resultMap="SupplierQuotationDeal"> | |
| 73 | + <include refid="SupplierQuotationDealSql"/> | |
| 74 | + <where> | |
| 75 | + <if test="vo.projectName != null and vo.projectName != ''"> | |
| 76 | + AND tb.project_name LIKE CONCAT('%', #{vo.projectName}, '%') | |
| 77 | + </if> | |
| 78 | + <if test="vo.projectCode != null and vo.projectCode != ''"> | |
| 79 | + AND tb.project_code LIKE CONCAT('%', #{vo.projectCode}, '%') | |
| 80 | + </if> | |
| 81 | + <if test="vo.supplierName != null and vo.supplierName != ''"> | |
| 82 | + AND tb.supplier_name LIKE CONCAT('%', #{vo.supplierName}, '%') | |
| 83 | + </if> | |
| 84 | + <if test="vo.principalId != null and vo.principalId != ''"> | |
| 85 | + AND tb.principal_id = #{vo.principalId} | |
| 86 | + </if> | |
| 87 | + <choose> | |
| 88 | + <when test="purchaseDepartmentList != null and purchaseDepartmentList.size() > 0"> | |
| 89 | + AND tb.purchase_department IN | |
| 90 | + <foreach collection="purchaseDepartmentList" item="item" open="(" separator="," close=")"> | |
| 91 | + #{item} | |
| 92 | + </foreach> | |
| 93 | + </when> | |
| 94 | + <otherwise> | |
| 95 | + AND tb.principal_id = #{userId} | |
| 96 | + </otherwise> | |
| 97 | + </choose> | |
| 98 | + </where> | |
| 99 | + ORDER BY tb.create_time DESC, tb.id DESC | |
| 100 | + </select> | |
| 101 | +</mapper> | |
| 102 | + | ... | ... |