|
|
@@ -27,6 +27,7 @@ import org.dromara.external.api.domain.ExternalProductDto;
|
|
|
import org.dromara.external.api.service.RemoteExternalItemService;
|
|
|
import org.dromara.external.api.service.RemoteExternalProductService;
|
|
|
import org.dromara.product.domain.*;
|
|
|
+import org.dromara.product.domain.bo.PoolAuditBo;
|
|
|
import org.dromara.product.domain.bo.ProductBaseBo;
|
|
|
import org.dromara.product.domain.bo.ProductPoolAuditBatchBo;
|
|
|
import org.dromara.product.domain.vo.ProductBaseVo;
|
|
|
@@ -75,6 +76,8 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
private final ProductEsMapper productEsMapper;
|
|
|
//商品
|
|
|
private final ProductBaseMapper productBaseMapper;
|
|
|
+ //采购项目产品关联
|
|
|
+ private final ProcurementProgramProductMapper procurementProgramProductMapper;
|
|
|
|
|
|
@DubboReference
|
|
|
private RemoteCustomerService remoteCustomerService;
|
|
|
@@ -159,6 +162,43 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
item.setAuditByName(AuditByName);
|
|
|
}
|
|
|
}
|
|
|
+ String name = null;
|
|
|
+ if(Objects.equals(item.getType(),"0")){
|
|
|
+ name = "自营产品池";
|
|
|
+ }else if(Objects.equals(item.getType(),"1")){
|
|
|
+ name = "标准产品池";
|
|
|
+ }else if(Objects.equals(item.getType(),"2")){
|
|
|
+ //先获取协议信息
|
|
|
+ ProtocolInfo protocolInfo= protocolInfoMapper.selectById(item.getProtocolId());
|
|
|
+ if (ObjectUtil.isNotEmpty(protocolInfo)){
|
|
|
+ //获取客户信息
|
|
|
+ CustomerInfoDTO customerInfoDTO = remoteCustomerService.selectCustomerInfoById(protocolInfo.getCustomerId());
|
|
|
+ if(customerInfoDTO != null){
|
|
|
+ name = customerInfoDTO.getCustomerName();
|
|
|
+ }else{
|
|
|
+ name = "未知协议产品池";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ name = "未知协议产品池";
|
|
|
+ }
|
|
|
+ }else if(Objects.equals(item.getType(),"3")){
|
|
|
+ //获取项目信息
|
|
|
+ ExternalItemDto itemInfo = remoteExternalItemService.getItemInfo(item.getItemId());
|
|
|
+ if(itemInfo != null){
|
|
|
+ name = itemInfo.getItemName();
|
|
|
+ }else{
|
|
|
+ name = "未知项目产品池";
|
|
|
+ }
|
|
|
+ }else if(Objects.equals(item.getType(),"4")){
|
|
|
+ //获取营销信息
|
|
|
+ ProductPool productPool = productPoolMapper.selectById(item.getPoolId());
|
|
|
+ if(productPool != null){
|
|
|
+ name = productPool.getName();
|
|
|
+ }else{
|
|
|
+ name = "未知营销产品池";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setPoolName(name);
|
|
|
});
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
@@ -185,9 +225,30 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getType()), ProductPoolAudit::getType, bo.getType());
|
|
|
lqw.eq(bo.getProtocolId() != null, ProductPoolAudit::getProtocolId, bo.getProtocolId());
|
|
|
lqw.eq(bo.getCustomerId() != null, ProductPoolAudit::getCustomerId, bo.getCustomerId());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getProductReviewStatus()), ProductPoolAudit::getProductReviewStatus, bo.getProductReviewStatus());
|
|
|
+ if(ObjectUtil.isNotEmpty(bo.getProductReviewStatus())){
|
|
|
+ lqw.in( ProductPoolAudit::getProductReviewStatus, bo.getProductReviewStatus().split(","));
|
|
|
+ }
|
|
|
+
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getReviewReason()), ProductPoolAudit::getReviewReason, bo.getReviewReason());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), ProductPoolAudit::getPlatformCode, bo.getPlatformCode());
|
|
|
+ // 申请时间筛选
|
|
|
+ Object beginCreateTime = params.get("beginCreateTime");
|
|
|
+ Object endCreateTime = params.get("endCreateTime");
|
|
|
+ if (beginCreateTime != null) {
|
|
|
+ lqw.ge(ProductPoolAudit::getCreateTime, beginCreateTime);
|
|
|
+ }
|
|
|
+ if (endCreateTime != null) {
|
|
|
+ lqw.le(ProductPoolAudit::getCreateTime, endCreateTime);
|
|
|
+ }
|
|
|
+ // 审核时间筛选
|
|
|
+ Object beginAuditTime = params.get("beginAuditTime");
|
|
|
+ Object endAuditTime = params.get("endAuditTime");
|
|
|
+ if (beginAuditTime != null) {
|
|
|
+ lqw.ge(ProductPoolAudit::getAuditTime, beginAuditTime);
|
|
|
+ }
|
|
|
+ if (endAuditTime != null) {
|
|
|
+ lqw.le(ProductPoolAudit::getAuditTime, endAuditTime);
|
|
|
+ }
|
|
|
return lqw;
|
|
|
}
|
|
|
|
|
|
@@ -201,10 +262,16 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(ProductPoolAuditBo bo) {
|
|
|
ProductPoolAudit add = MapstructUtils.convert(bo, ProductPoolAudit.class);
|
|
|
+
|
|
|
+ // 生成6位数的审核编号
|
|
|
+ String poolAuditNo = generatePoolAuditNo();
|
|
|
+ add.setPoolAuditNo(poolAuditNo);
|
|
|
+
|
|
|
validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setId(add.getId());
|
|
|
+ bo.setPoolAuditNo(poolAuditNo);
|
|
|
// 保存产品池和产品关联审核数据
|
|
|
if (ObjectUtil.isNotEmpty(bo.getProducts())) {
|
|
|
savePoolLinkAudits(bo);
|
|
|
@@ -246,6 +313,36 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成6位数的产品池审核编号
|
|
|
+ *
|
|
|
+ * @return 6位数审核编号
|
|
|
+ */
|
|
|
+ private String generatePoolAuditNo() {
|
|
|
+ // 查询当前最大的审核编号
|
|
|
+ ProductPoolAudit maxAudit = baseMapper.selectOne(
|
|
|
+ Wrappers.lambdaQuery(ProductPoolAudit.class)
|
|
|
+ .orderByDesc(ProductPoolAudit::getPoolAuditNo)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ String nextNo;
|
|
|
+ if (maxAudit != null && StringUtils.isNotBlank(maxAudit.getPoolAuditNo())) {
|
|
|
+ // 如果存在最大编号,则 +1
|
|
|
+ nextNo = org.dromara.common.core.utils.NumberGeneratorUtil.generateNumber(maxAudit.getPoolAuditNo());
|
|
|
+ } else {
|
|
|
+ // 如果不存在,从 000001 开始
|
|
|
+ nextNo = "000001";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保是6位数,不足补零
|
|
|
+ if (nextNo.length() < 6) {
|
|
|
+ nextNo = String.format("%06d", Long.parseLong(nextNo));
|
|
|
+ }
|
|
|
+
|
|
|
+ return nextNo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存产品池和产品关联审核数据
|
|
|
*
|
|
|
@@ -293,7 +390,7 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
public TableDataInfo<ProductBaseVo> getPoolAuditProductPage(ProductBaseBo bo, PageQuery pageQuery) {
|
|
|
List<ProductPoolLinkAuditVo> productPoolLinkAuditVos = productPoolLinkAuditMapper.selectVoList(Wrappers.lambdaQuery(ProductPoolLinkAudit.class)
|
|
|
.eq(ProductPoolLinkAudit::getPoolAuditId, bo.getPoolAuditId())
|
|
|
- .eq(ObjectUtil.isNotEmpty(bo.getAuditStatus()),ProductPoolLinkAudit::getProductReviewStatus, bo.getAuditStatus())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(bo.getProductReviewStatus()),ProductPoolLinkAudit::getProductReviewStatus, bo.getProductReviewStatus())
|
|
|
);
|
|
|
if (CollUtil.isEmpty(productPoolLinkAuditVos)) {
|
|
|
return TableDataInfo.build();
|
|
|
@@ -310,7 +407,6 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getUnitId()), ProductBaseVo::getUnitId, bo.getUnitId())
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()), ProductBaseVo::getProductStatus, bo.getProductStatus())
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getIsSelf()), ProductBaseVo::getIsSelf, bo.getIsSelf())
|
|
|
- .eq(ObjectUtil.isNotEmpty(bo.getProductReviewStatus()), ProductBaseVo::getProductReviewStatus, bo.getProductReviewStatus())
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getDataSource()), ProductBaseVo::getDataSource, bo.getDataSource())
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getProductCategory()), ProductBaseVo::getProductCategory, bo.getProductCategory())
|
|
|
.orderByDesc(ProductBaseVo::getCreateTime)
|
|
|
@@ -735,5 +831,108 @@ public class ProductPoolAuditServiceImpl extends ServiceImpl<ProductPoolAuditMa
|
|
|
// 改变审核商品表状态
|
|
|
changeProductStatus(linkAudits, bo.getAuditStatus(), bo.getReason(), currentUserId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取审核池出池的商品列表
|
|
|
+ *
|
|
|
+ * @param bo 筛选条件
|
|
|
+ * @param pageQuery
|
|
|
+ * @return 审核池商品列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<ProductBaseVo> getPoolAuditProducts(PoolAuditBo bo, PageQuery pageQuery) {
|
|
|
+ // 构建查询条件
|
|
|
+ LambdaEsQueryWrapper<ProductBaseVo> esQueryWrapper = new LambdaEsQueryWrapper<>();
|
|
|
+
|
|
|
+ // 添加基本筛选条件:编号和名称
|
|
|
+ if (StringUtils.isNotBlank(bo.getProductNo())) {
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getProductNo, bo.getProductNo());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(bo.getProductName())) {
|
|
|
+ esQueryWrapper.like(ProductBaseVo::getItemName, bo.getProductName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据不同的池类型和申请类型获取不同的商品列表
|
|
|
+ String type = bo.getType();
|
|
|
+ Long poolId = bo.getPoolId();
|
|
|
+ Long itemId = bo.getItemId();
|
|
|
+ Long protocolId = bo.getProtocolId();
|
|
|
+
|
|
|
+ // 根据不同的池类型进行过滤,只查询池中已存在的商品
|
|
|
+ if ("0".equals(type)) {
|
|
|
+ // 自营产品池:只查询自营商品
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getIsSelf, 1);
|
|
|
+ } else if ("1".equals(type)) {
|
|
|
+ // 精选产品池:只查询精选商品
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getProductCategory, 2);
|
|
|
+ } else if ("2".equals(type)) {
|
|
|
+ // 协议产品池:查询协议中已存在的商品
|
|
|
+ if (ObjectUtil.isNotEmpty(protocolId)) {
|
|
|
+ List<ProtocolProducts> existingProducts = protocolProductsMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProtocolProducts.class)
|
|
|
+ .eq(ProtocolProducts::getProtocolId, protocolId)
|
|
|
+ );
|
|
|
+ if (CollUtil.isNotEmpty(existingProducts)) {
|
|
|
+ List<Long> existingProductIds = existingProducts.stream()
|
|
|
+ .map(ProtocolProducts::getProductId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ esQueryWrapper.in(ProductBaseVo::getId, existingProductIds);
|
|
|
+ } else {
|
|
|
+ // 如果协议中没有商品,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有指定协议ID,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ } else if ("3".equals(type)) {
|
|
|
+ // 项目产品池:查询项目中已存在的商品
|
|
|
+ if (ObjectUtil.isNotEmpty(itemId)) {
|
|
|
+ // 查询项目中已存在的商品ID
|
|
|
+ List<ExternalProductDto> externalProductList = remoteExternalProductService.getExternalProductList(itemId);
|
|
|
+ if (CollUtil.isNotEmpty(externalProductList)) {
|
|
|
+ List<Long> existingProductIds = externalProductList.stream()
|
|
|
+ .map(ExternalProductDto::getProductId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ esQueryWrapper.in(ProductBaseVo::getId, existingProductIds);
|
|
|
+ } else {
|
|
|
+ // 如果项目中没有商品,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有指定项目ID,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ } else if ("4".equals(type)) {
|
|
|
+ // 营销产品池:查询池中已存在的商品
|
|
|
+ if (ObjectUtil.isNotEmpty(poolId)) {
|
|
|
+ List<ProductPoolLink> existingLinks = productPoolLinkMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProductPoolLink.class)
|
|
|
+ .eq(ProductPoolLink::getPoolId, poolId)
|
|
|
+ );
|
|
|
+ if (CollUtil.isNotEmpty(existingLinks)) {
|
|
|
+ List<Long> existingProductIds = existingLinks.stream()
|
|
|
+ .map(ProductPoolLink::getProductId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ esQueryWrapper.in(ProductBaseVo::getId, existingProductIds);
|
|
|
+ } else {
|
|
|
+ // 如果池中没有商品,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有指定池ID,返回空结果
|
|
|
+ esQueryWrapper.eq(ProductBaseVo::getId, -1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按创建时间倒序排列
|
|
|
+ esQueryWrapper.orderByDesc(ProductBaseVo::getCreateTime);
|
|
|
+
|
|
|
+ // 执行分页查询
|
|
|
+ EsPageInfo<ProductBaseVo> esPageInfo = productEsMapper.pageQuery(esQueryWrapper, pageQuery.getPageNum(), pageQuery.getPageSize());
|
|
|
+ TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build(esPageInfo.getList());
|
|
|
+ tableDataInfo.setTotal(esPageInfo.getTotal());
|
|
|
+ return tableDataInfo;
|
|
|
+ }
|
|
|
}
|
|
|
|