|
@@ -11,7 +11,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
|
+import com.fjhx.item.service.product.ProductClassifyService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
|
|
@@ -41,7 +43,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -70,8 +71,8 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
private CorporationService corporationService;
|
|
|
@Autowired
|
|
|
private ISysDeptService deptService;
|
|
|
-// @Autowired
|
|
|
-// private SubscribeService subscribeService;
|
|
|
+ @Autowired
|
|
|
+ private ProductClassifyService productClassifyService;
|
|
|
|
|
|
/**
|
|
|
* 分页
|
|
@@ -83,26 +84,36 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
public Page<SubscribeDetailVo> getPage(SubscribeDetailSelectDto dto) {
|
|
|
IWrapper<SubscribeDetail> wrapper = getWrapper();
|
|
|
// 申购单号
|
|
|
- wrapper.like("t2.subscribeCode", dto.getCode());
|
|
|
+ wrapper.eq("t2.subscribeCode", dto.getCode());
|
|
|
// 申购时间
|
|
|
wrapper.between("t2", Subscribe::getCreateTime, dto.getBeginTime(), dto.getEndTime());
|
|
|
// 申购状态
|
|
|
wrapper.ge("t2", Subscribe::getSubcribeStatus, dto.getSubscribeStatus());
|
|
|
// 关键字
|
|
|
- wrapper.like("t2.subscribeCode", dto.getKeyword());
|
|
|
+ String keyword = dto.getKeyword();
|
|
|
+ if (ObjectUtil.isNotEmpty(keyword)) {
|
|
|
+ List<Long> pIds = productInfoService.listObject(ProductInfo::getId, q -> q
|
|
|
+ .like(ProductInfo::getName, keyword)
|
|
|
+ .or().like(ProductInfo::getCustomCode, keyword)
|
|
|
+ );
|
|
|
+ wrapper.and(q -> q
|
|
|
+ .like("t2.subscribeCode", dto.getKeyword())
|
|
|
+ .or().in("t2", SubscribeDetail::getProductId, pIds)
|
|
|
+ );
|
|
|
+ }
|
|
|
// 状态
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatus())) {
|
|
|
wrapper.in("t2", SubscribeDetail::getStatus, Arrays.asList(dto.getStatus().split(",")));
|
|
|
}
|
|
|
|
|
|
- // 如果类型存在带入类型查询
|
|
|
- List<ProductInfoVo> productList = productInfoService.getListByProductType(
|
|
|
- dto.getProductType(), dto.getDefinition(), dto.getProductName(), dto.getProductCode());
|
|
|
- if (ObjectUtil.isEmpty(productList)) {
|
|
|
- return new Page<>();
|
|
|
- }
|
|
|
- List<Long> productIds = productList.stream().map(ProductInfoVo::getId).collect(Collectors.toList());
|
|
|
- wrapper.in("t2", SubscribeDetail::getProductId, productIds);
|
|
|
+// // 如果类型存在带入类型查询
|
|
|
+// List<ProductInfoVo> productList = productInfoService.getListByProductType(
|
|
|
+// dto.getProductType(), dto.getDefinition(), dto.getProductName(), dto.getProductCode());
|
|
|
+// if (ObjectUtil.isEmpty(productList)) {
|
|
|
+// return new Page<>();
|
|
|
+// }
|
|
|
+// List<Long> productIds = productList.stream().map(ProductInfoVo::getId).collect(Collectors.toList());
|
|
|
+// wrapper.in("t2", SubscribeDetail::getProductId, productIds);
|
|
|
|
|
|
// 待采购过滤掉指定状态 例如不要 88 作废
|
|
|
if (StrUtil.isNotBlank(dto.getNeStatus())) {
|
|
@@ -124,7 +135,7 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
//如果是待采购页面
|
|
|
if (ObjectUtil.equals(dto.getIsWaitPurchase(), 1)) {
|
|
|
//过滤要入库的数据 or 来自合同的数据
|
|
|
- wrapper.eq("t2", Subscribe::getIsInStock, 1).or().ne("t2", SubscribeDetail::getDataType, 0);
|
|
|
+ wrapper.and(q -> q.eq("t2", Subscribe::getIsInStock, 1).or().ne("t2", SubscribeDetail::getDataType, 0));
|
|
|
}
|
|
|
|
|
|
Page<SubscribeDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
@@ -152,23 +163,27 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
|
|
|
Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
|
|
|
|
// 赋值产品信息
|
|
|
- for (SubscribeDetailVo record : records) {
|
|
|
- Map<Long, ProductInfoVo> productMap = productList.stream().collect(Collectors.toMap(ProductInfoVo::getId, Function.identity()));
|
|
|
- ProductInfoVo productInfo = productMap.get(record.getProductId());
|
|
|
- record.setProductCode(productInfo.getCustomCode());
|
|
|
- record.setProductName(productInfo.getName());
|
|
|
- record.setProductType(productInfo.getType());
|
|
|
- record.setProductCategory(productInfo.getClassifyName());
|
|
|
- record.setProductUnit(productInfo.getUnit());
|
|
|
- record.setProductDefinition(productInfo.getDefinition());
|
|
|
- record.setProductCustomCode(productInfo.getCustomCode());
|
|
|
- record.setProductSpec(productInfo.getSpec());
|
|
|
-
|
|
|
- record.setProductLength(productInfo.getLength());
|
|
|
- record.setProductWidth(productInfo.getWidth());
|
|
|
- record.setProductHeight(productInfo.getHeight());
|
|
|
+ productInfoService.attributeAssign(records, SubscribeDetailVo::getProductId, (item, productInfo) -> {
|
|
|
+ item.setProductCode(productInfo.getCustomCode());
|
|
|
+ item.setProductName(productInfo.getName());
|
|
|
+ item.setProductType(productInfo.getType());
|
|
|
+ item.setProductCategoryId(productInfo.getProductClassifyId());
|
|
|
+ item.setProductUnit(productInfo.getUnit());
|
|
|
+ item.setProductDefinition(productInfo.getDefinition());
|
|
|
+ item.setProductCustomCode(productInfo.getCustomCode());
|
|
|
+ item.setProductSpec(productInfo.getSpec());
|
|
|
+
|
|
|
+ item.setProductLength(productInfo.getLength());
|
|
|
+ item.setProductWidth(productInfo.getWidth());
|
|
|
+ item.setProductHeight(productInfo.getHeight());
|
|
|
+ });
|
|
|
|
|
|
+ //赋值产品分类
|
|
|
+ productClassifyService.attributeAssign(records, SubscribeDetailVo::getProductCategoryId, (item, productClassify) -> {
|
|
|
+ item.setProductCategory(productClassify.getName());
|
|
|
+ });
|
|
|
|
|
|
+ for (SubscribeDetailVo record : records) {
|
|
|
//赋值生产公司名称
|
|
|
record.setCompanyName(companyNameMap.get(record.getCompanyId()));
|
|
|
|