|
@@ -1,9 +1,11 @@
|
|
|
package com.fjhx.sale.service.contract.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.entity.contract.po.ContractTemplate;
|
|
|
import com.fjhx.common.enums.FlowStatusEnum;
|
|
|
import com.fjhx.common.service.contract.ContractTemplateService;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
@@ -19,6 +21,7 @@ import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractProductVo;
|
|
|
import com.fjhx.sale.mapper.contract.ContractProductMapper;
|
|
|
+import com.fjhx.sale.service.claim.ClaimContractService;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
@@ -67,6 +70,8 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
|
|
|
@Autowired
|
|
|
private FlowExampleService flowExampleService;
|
|
|
+ @Autowired
|
|
|
+ private ClaimContractService claimContractService;
|
|
|
|
|
|
/**
|
|
|
* 分页
|
|
@@ -83,6 +88,24 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
wrapper.keyword(dto.getKeyword(), new SqlField("t2.`code`"), new SqlField("t2.`user_name`"));
|
|
|
}
|
|
|
+ //所属公司id过滤
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getCorporationId())) {
|
|
|
+ List<Long> ctIds = contractTemplateService.listObject(ContractTemplate::getId,
|
|
|
+ q -> q.eq(ContractTemplate::getCorporationId, dto.getCorporationId()));
|
|
|
+ if (ObjectUtil.isEmpty(ctIds)) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ wrapper.in("t2.contract_template_id", ctIds);
|
|
|
+ }
|
|
|
+ //是否到账过滤
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getIsReceived())) {
|
|
|
+ if (1 == dto.getIsReceived()) {
|
|
|
+ wrapper.isNotNull("co.id");
|
|
|
+ } else {
|
|
|
+ wrapper.isNull("co.id");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wrapper.groupBy("t1.id");
|
|
|
Page<ContractProductVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<ContractProductVo> list = page.getRecords();
|
|
|
|
|
@@ -126,11 +149,12 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
|
|
|
/**
|
|
|
* 根据合同ID和客户ID查询未包装的产品
|
|
|
+ *
|
|
|
* @param customerId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ContractProductVo> getNoPackContractProductById(String customerId,String contractIds) {
|
|
|
+ public List<ContractProductVo> getNoPackContractProductById(String customerId, String contractIds) {
|
|
|
List<ContractProductVo> list = baseMapper.getNoPackContractProductById(customerId, Arrays.asList(contractIds.split(",")));
|
|
|
// 赋值产品属性
|
|
|
productInfoService.attributeAssign(list, ContractProductVo::getProductId, (item, product) -> {
|
|
@@ -150,6 +174,7 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
|
|
|
/**
|
|
|
* 交接单
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -157,15 +182,15 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
public Page<ContractProductVo> getEHSDPage(ContractProductSelectDto dto) {
|
|
|
IWrapper<ContractProduct> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("t1.ct");
|
|
|
- if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.keyword(dto.getKeyword(),new SqlField("t1.`contractCode`"),new SqlField("t1.`userName`"));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t1.`contractCode`"), new SqlField("t1.`userName`"));
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getIds())){
|
|
|
- wrapper.in("t1.id",Arrays.asList(dto.getIds().split(",")));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getIds())) {
|
|
|
+ wrapper.in("t1.id", Arrays.asList(dto.getIds().split(",")));
|
|
|
}
|
|
|
Page<ContractProductVo> page = this.baseMapper.getEHSDPage(dto.getPage(), wrapper);
|
|
|
List<ContractProductVo> list = page.getRecords();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
// 赋值产品属性
|
|
|
productInfoService.attributeAssign(list, ContractProductVo::getProductId, (item, product) -> {
|
|
|
item.setProductCode(product.getCode());
|
|
@@ -185,6 +210,7 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
|
|
|
/**
|
|
|
* 待质检分页
|
|
|
+ *
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
@@ -192,17 +218,17 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
public Page<ContractProductVo> getEHSDQualityPage(ContractProductSelectDto dto) {
|
|
|
IWrapper<ContractProduct> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("t1.ct");
|
|
|
- if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.keyword(dto.getKeyword(),new SqlField("t1.`contractCode`"),new SqlField("t1.`userName`"));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t1.`contractCode`"), new SqlField("t1.`userName`"));
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getOrderType())){
|
|
|
- wrapper.eq("t1.orderType",dto.getOrderType());
|
|
|
+ if (StringUtils.isNotEmpty(dto.getOrderType())) {
|
|
|
+ wrapper.eq("t1.orderType", dto.getOrderType());
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getQualityStatus())){
|
|
|
- wrapper.eq("t1.qualityStatus",dto.getQualityStatus());
|
|
|
+ if (StringUtils.isNotEmpty(dto.getQualityStatus())) {
|
|
|
+ wrapper.eq("t1.qualityStatus", dto.getQualityStatus());
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(dto.getSummary())){
|
|
|
- wrapper.eq("t1.summary",dto.getSummary());
|
|
|
+ if (StringUtils.isNotEmpty(dto.getSummary())) {
|
|
|
+ wrapper.eq("t1.summary", dto.getSummary());
|
|
|
}
|
|
|
Page<ContractProductVo> page = this.baseMapper.getEHSDPage(dto.getPage(), wrapper);
|
|
|
List<ContractProductVo> list = page.getRecords();
|
|
@@ -210,7 +236,7 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
// List<Long> contractProductIds = list.stream().map(ContractProductVo::getId).collect(Collectors.toList());
|
|
|
// List<EhsdQuality> qualityList = ehsdQualityService.list(Wrappers.<EhsdQuality>query().lambda().in(EhsdQuality::getBusinessId,contractProductIds));
|
|
|
// Map<Long,Integer> qualityMap = qualityList.stream().distinct().collect(Collectors.toMap(EhsdQuality::getBusinessId,EhsdQuality::getStatus));
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
// 赋值产品属性
|
|
|
productInfoService.attributeAssign(list, ContractProductVo::getProductId, (item, product) -> {
|
|
|
item.setProductCode(product.getCode());
|
|
@@ -247,17 +273,17 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
public Page<ContractProductVo> contractHandoverPage(ContractProductSelectDto dto) {
|
|
|
IWrapper<ContractProduct> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("t1.create_time");
|
|
|
- if(StringUtils.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.keyword(dto.getKeyword(),new SqlField("t1.`contractCode`"),new SqlField("t1.`userName`"));
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.keyword(dto.getKeyword(), new SqlField("t1.`contractCode`"), new SqlField("t1.`userName`"));
|
|
|
}
|
|
|
- wrapper.ge("t2.`status`",30);
|
|
|
- wrapper.lt("t2.`status`",88);
|
|
|
- wrapper.gt("t1.expend_quantity",0);
|
|
|
+ wrapper.ge("t2.`status`", 30);
|
|
|
+ wrapper.lt("t2.`status`", 88);
|
|
|
+ wrapper.gt("t1.expend_quantity", 0);
|
|
|
//查询合同交接单的数据(只查询有添加交接单的数据)
|
|
|
Page<ContractProductVo> page = this.baseMapper.contractHandoverPage(dto.getPage(), wrapper);
|
|
|
|
|
|
List<ContractProductVo> list = page.getRecords();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
// 赋值产品属性
|
|
|
productInfoService.attributeAssign(list, ContractProductVo::getProductId, (item, product) -> {
|
|
|
item.setProductCode(product.getCode());
|
|
@@ -277,23 +303,24 @@ public class ContractProductServiceImpl extends ServiceImpl<ContractProductMappe
|
|
|
|
|
|
/**
|
|
|
* 根据合同产品IDS查询合同产品
|
|
|
+ *
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public List<ContractProductVo> getListDetail(List<Long> ids) {
|
|
|
- if(CollectionUtils.isEmpty(ids)){
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
throw new ServiceException("参数异常");
|
|
|
}
|
|
|
IWrapper<ContractProduct> wrapper = getWrapper();
|
|
|
- wrapper.in("t1",ContractProduct::getId,ids);
|
|
|
+ wrapper.in("t1", ContractProduct::getId, ids);
|
|
|
List<ContractProductVo> list = baseMapper.getListByIds(wrapper);
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
List<PurchaseDetailVo> vo = purchaseDetailService.getSumCountInDataResourceIds(ids);
|
|
|
- Map<Long,BigDecimal> voMap = vo.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId,PurchaseDetailVo::getSumCount));
|
|
|
- for(ContractProductVo c:list){
|
|
|
- if(MapUtils.isNotEmpty(voMap)){
|
|
|
- c.setSumPurchaseCount(voMap.getOrDefault(c.getId(),BigDecimal.ZERO));
|
|
|
+ Map<Long, BigDecimal> voMap = vo.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId, PurchaseDetailVo::getSumCount));
|
|
|
+ for (ContractProductVo c : list) {
|
|
|
+ if (MapUtils.isNotEmpty(voMap)) {
|
|
|
+ c.setSumPurchaseCount(voMap.getOrDefault(c.getId(), BigDecimal.ZERO));
|
|
|
}
|
|
|
}
|
|
|
|