浏览代码

合同头部统计过滤条件

caozj 1 年之前
父节点
当前提交
8e57b93a1f
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

+ 14 - 1
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -1709,7 +1709,17 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             wrapper.in("t1.refundStatusNew", Arrays.asList(dto.getRefundStatusNew().split(",")));
         }
         if (StringUtils.isNotEmpty(dto.getKeyword())) {
-            wrapper.keyword(dto.getKeyword(), new SqlField("t1", Contract::getCode));
+            //归属公司
+            List<Long> corporationIds = corporationService.listObject(Corporation::getId, q -> q.like(Corporation::getName, dto.getKeyword()));
+            List<Long> customerIds = customerService.listObject(Customer::getId, q -> q.like(Customer::getName, dto.getKeyword()));
+            wrapper.and(q -> q
+                    .like("t1", Contract::getCode, dto.getKeyword())
+                    .or().in("t1", Contract::getSellCorporationId, corporationIds)
+                    .or().in("t1", Contract::getBuyCorporationId, customerIds)
+            );
+        }
+        if (StringUtils.isNotEmpty(dto.getUserId())) {
+            wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
         }
         //根据客户id关联
         wrapper.eq(ContractVo::getBuyCorporationId, dto.getCustomerId());
@@ -1746,6 +1756,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         }
         contract.setCreateTimeEn(sdf.format(contract.getCreateTime()));
         map.put("contract",contract);
+        QueryWrapper<Contract> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("IFNULL(SUM( amount ),0) AS amount").in("id",contractIds);
+        contract.setAmount(contractService.getOne(queryWrapper).getAmount());
         //查询合同产品
         List<ContractProduct> contractProductList = contractProductService.list(Wrappers.<ContractProduct>query().lambda().in(ContractProduct::getContractId,contractIds));
         //查询合同产品