Kaynağa Gözat

Merge remote-tracking branch 'origin/dev' into dev

24282 2 yıl önce
ebeveyn
işleme
9adcd366df

+ 10 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/po/Purchase.java

@@ -120,4 +120,14 @@ public class Purchase extends BasePo {
      * 采购单个数
      */
     private Integer count;
+
+    /***
+     * 业务来源 0自建  1外销合同采购 2:样品单
+     */
+    private Integer dataResource;
+
+    /**
+     * 业务来源ID (外销合同id)
+     */
+    private Long dataResourceId;
 }

+ 20 - 11
hx-sale/src/main/java/com/fjhx/sale/controller/contract/ContractController.java

@@ -76,7 +76,7 @@ public class ContractController {
      * 根据客户ID查询未包装的订单
      */
     @GetMapping("/getNoPackContractByCustomerId")
-    public List<ContractVo> getNoPackContractByCustomerId(@RequestParam("customerId")String customerId) {
+    public List<ContractVo> getNoPackContractByCustomerId(@RequestParam("customerId") String customerId) {
         return contractService.getNoPackContractByCustomerId(customerId);
     }
 
@@ -98,10 +98,11 @@ public class ContractController {
 
     /**
      * 销售趋势(数据看板-产品分析页面)
+     *
      * @param productInfoDto
      */
     @PostMapping("/saleTrend")
-    public  List<Map<String, Object>> saleTrend(@RequestBody ProductInfoSelectDto productInfoDto) {
+    public List<Map<String, Object>> saleTrend(@RequestBody ProductInfoSelectDto productInfoDto) {
         return contractService.saleTrend(productInfoDto);
     }
 
@@ -109,7 +110,7 @@ public class ContractController {
      * 销售统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/salesStatistics")
-    public  Map<String, Object>  salesStatistics(@RequestBody ContractDto dto) {
+    public Map<String, Object> salesStatistics(@RequestBody ContractDto dto) {
         return contractService.salesStatistics(dto);
     }
 
@@ -118,7 +119,7 @@ public class ContractController {
      * 国家销售统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/countrySalesStatistics")
-    public  List<ContractDto>  countrySalesStatistics(@RequestBody ContractDto dto) {
+    public List<ContractDto> countrySalesStatistics(@RequestBody ContractDto dto) {
         return contractService.countrySalesStatistics(dto);
     }
 
@@ -126,7 +127,7 @@ public class ContractController {
      * 客户销售统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/customSalesStatistics")
-    public  List<ContractDto>  customSalesStatistics(@RequestBody ContractDto dto) {
+    public List<ContractDto> customSalesStatistics(@RequestBody ContractDto dto) {
         return contractService.customSalesStatistics(dto);
     }
 
@@ -134,7 +135,7 @@ public class ContractController {
      * 业务员销售统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/salesmanSalesStatistics")
-    public  List<ContractDto>  salesmanSalesStatistics(@RequestBody ContractDto dto) {
+    public List<ContractDto> salesmanSalesStatistics(@RequestBody ContractDto dto) {
         return contractService.salesmanSalesStatistics(dto);
     }
 
@@ -142,7 +143,7 @@ public class ContractController {
      * 产品销售额统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/productSalesStatistics")
-    public  List<ContractDto>  productSalesStatistics(@RequestBody ContractDto dto) {
+    public List<ContractDto> productSalesStatistics(@RequestBody ContractDto dto) {
         return contractService.productSalesStatistics(dto);
     }
 
@@ -150,7 +151,7 @@ public class ContractController {
      * 产品销售量统计(数据看板-销售分析页面开发)
      */
     @PostMapping("/salesVolumeStatistics")
-    public  List<ContractDto>  salesVolumeStatistics(@RequestBody ContractDto dto) {
+    public List<ContractDto> salesVolumeStatistics(@RequestBody ContractDto dto) {
         return contractService.salesVolumeStatistics(dto);
     }
 
@@ -166,15 +167,15 @@ public class ContractController {
      * 合同销售统计(合同列表)
      */
     @PostMapping("/covenantStatistics")
-    public  Map<String,Object> covenantStatistics(@RequestBody ContractDto dto){
-        return  contractService.covenantStatistics(dto);
+    public Map<String, Object> covenantStatistics(@RequestBody ContractDto dto) {
+        return contractService.covenantStatistics(dto);
     }
 
     /**
      * 利润预算
      */
     @PostMapping("/getProfitBudgetPage")
-    public  Page<ContractBudgetVo> getProfitBudgetPage(@RequestBody ContractSelectDto dto){
+    public Page<ContractBudgetVo> getProfitBudgetPage(@RequestBody ContractSelectDto dto) {
         return contractService.getProfitBudgetPage(dto);
     }
 
@@ -210,4 +211,12 @@ public class ContractController {
         return contractService.payDecisionAid(dto);
     }
 
+    /**
+     * 获取合同历史联系方式
+     */
+    @PostMapping("/contactList")
+    List<Contract> contactList(@RequestBody ContractDto dto) {
+        return contractService.contactList(dto);
+    }
+
 }

+ 6 - 1
hx-sale/src/main/java/com/fjhx/sale/entity/documents/vo/DocumentsVo.java

@@ -42,7 +42,7 @@ public class DocumentsVo extends Documents {
     private String code;
 
     /**
-     *承运方
+     * 承运方
      */
     private String acceptCarriage;
 
@@ -50,4 +50,9 @@ public class DocumentsVo extends Documents {
      * 货运单号
      */
     private String acceptCode;
+
+    /**
+     * 流程id
+     */
+    private Long flowId;
 }

+ 22 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlow.java

@@ -19,9 +19,12 @@ import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
 import com.fjhx.purchase.entity.purchase.po.PurchaseOtherFee;
 import com.fjhx.purchase.entity.purchase.vo.PurchaseVo;
+import com.fjhx.purchase.entity.subscribe.enums.SubscribeDetailStatusEnum;
+import com.fjhx.purchase.entity.subscribe.po.SubscribeDetail;
 import com.fjhx.purchase.service.purchase.PurchaseDetailService;
 import com.fjhx.purchase.service.purchase.PurchaseOtherFeeService;
 import com.fjhx.purchase.service.purchase.PurchaseService;
+import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
 import com.fjhx.sale.entity.contract.po.ContractProduct;
 import com.fjhx.sale.entity.sample.po.SampleProduct;
 import com.fjhx.sale.service.contract.ContractProductService;
@@ -63,6 +66,8 @@ public class PurchaseFlow extends FlowDelegate {
 
     @Autowired
     private PurchaseOtherFeeService purchaseOtherFeeService;
+    @Autowired
+    private SubscribeDetailService subscribeDetailService;
 
     @Override
     public String getFlowKey() {
@@ -91,6 +96,23 @@ public class PurchaseFlow extends FlowDelegate {
                 s.setPurchaseId(purchase.getId());
             }
             purchaseDetailService.saveBatch(purchaseDetailList);
+            //修改申购明细的采购状态
+            for (PurchaseDetail purchaseDetail : purchaseDetailList) {
+                //计算已经采购的数量
+                List<PurchaseDetail> purchaseDetails = purchaseDetailService.list(q -> q
+                        .eq(PurchaseDetail::getSubscribeDetailId, purchaseDetail.getSubscribeDetailId())
+                );
+                BigDecimal pdCount = purchaseDetails.stream().map(PurchaseDetail::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
+                SubscribeDetail subscribeDetail = subscribeDetailService.getById(purchaseDetail.getSubscribeDetailId());
+                if (pdCount.compareTo(subscribeDetail.getCount()) >= 0) {
+                    //修改为已采购
+                    subscribeDetail.setStatus(SubscribeDetailStatusEnum.PURCHASED.getKey());
+                } else {
+                    //修改为部分采购
+                    subscribeDetail.setStatus(SubscribeDetailStatusEnum.LITT_PAID_AMOUNT.getKey());
+                }
+                subscribeDetailService.updateById(subscribeDetail);
+            }
         }
         //保存其他费用信息
         List<PurchaseOtherFee> otherFeeList = purchase.getOtherFeeList();

+ 4 - 3
hx-sale/src/main/java/com/fjhx/sale/mapper/contract/ContractMapper.java

@@ -1,12 +1,11 @@
 package com.fjhx.sale.mapper.contract;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.customer.entity.customer.dto.CustomerDto;
 import com.fjhx.sale.entity.contract.dto.ContractDto;
 import com.fjhx.sale.entity.contract.po.Contract;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.sale.entity.contract.po.ContractBudget;
 import com.fjhx.sale.entity.contract.vo.ContractBudgetVo;
 import com.fjhx.sale.entity.contract.vo.ContractVo;
 import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
@@ -90,4 +89,6 @@ public interface ContractMapper extends BaseMapper<Contract> {
     List<ContractDto> productSalesStatistics(@Param("ew") QueryWrapper<Object> query);
 
     List<ContractDto> salesVolumeStatistics(@Param("ew") QueryWrapper<Object> query);
+
+    List<Contract> contactList(@Param("ew") IWrapper<Contract> wrapper);
 }

+ 4 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/ContractService.java

@@ -160,4 +160,8 @@ public interface ContractService extends BaseService<Contract> {
      */
     PayDecisionAidVo payDecisionAid(PayDecisionAidDto dto);
 
+    /**
+     * 获取合同历史联系方式
+     */
+    List<Contract> contactList(ContractDto dto);
 }

+ 115 - 94
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -236,6 +236,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 利润预算
+     *
      * @param dto
      * @return
      */
@@ -244,18 +245,18 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         IWrapper<Contract> wrapper = getWrapper();
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         wrapper.between("t1", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
-        if(StringUtils.isNotEmpty(dto.getCustomerId())){
-            wrapper.eq("t1",Contract::getBuyCorporationId,dto.getCustomerId());
+        if (StringUtils.isNotEmpty(dto.getCustomerId())) {
+            wrapper.eq("t1", Contract::getBuyCorporationId, dto.getCustomerId());
         }
-        if(StringUtils.isNotEmpty(dto.getUserId())){
-            wrapper.eq("t1",Contract::getCreateUser,dto.getUserId());
+        if (StringUtils.isNotEmpty(dto.getUserId())) {
+            wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
         }
-        if(StringUtils.isNotEmpty(dto.getKeyword())){
-            wrapper.keyword(dto.getKeyword(),new SqlField("t1.code"));
+        if (StringUtils.isNotEmpty(dto.getKeyword())) {
+            wrapper.keyword(dto.getKeyword(), new SqlField("t1.code"));
         }
         Page<ContractBudgetVo> page = this.baseMapper.getProfitBudgetPage(dto.getPage(), wrapper);
         List<ContractBudgetVo> list = page.getRecords();
-        if(CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             // 赋值客户名称
             customerService.attributeAssign(list, Contract::getBuyCorporationId, (item, customer) -> {
                 item.setCustomerName(customer.getName());
@@ -264,65 +265,65 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             List<Long> contractIds = list.stream().map(ContractBudgetVo::getContractId).collect(Collectors.toList());
             List<EhsdPurchaseProductVo> ehsdAmountList = ehsdPurchaseProductService.getGroupSumAmount(contractIds);
             //取出采购所有金额和货币-通过合同ID分组
-            Map<Long,String> ehsdAmountMap = ehsdAmountList.stream().collect(Collectors.toMap(EhsdPurchaseProductVo::getContractId,EhsdPurchaseProductVo::getCurrencyAmount));
+            Map<Long, String> ehsdAmountMap = ehsdAmountList.stream().collect(Collectors.toMap(EhsdPurchaseProductVo::getContractId, EhsdPurchaseProductVo::getCurrencyAmount));
             List<PurchaseDetailVo> otherAmountList = purchaseDetailService.getSumCountInDataResourceIds(contractIds);
-            Map<Long,String> otherAmountMap = otherAmountList.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId,PurchaseDetailVo::getSumAmountCurrency));
+            Map<Long, String> otherAmountMap = otherAmountList.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId, PurchaseDetailVo::getSumAmountCurrency));
             //取出默认汇率
             List<CurrencyRate> currencyRateList = currencyRateService.getList();
-            Map<String,BigDecimal> currencyRateMap = currencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType,CurrencyRate::getRate));
-            for(ContractBudgetVo v : list){
-                if(StringUtils.isNotEmpty(v.getCurrencyRateJson())){//如果此条合同有汇率了
+            Map<String, BigDecimal> currencyRateMap = currencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
+            for (ContractBudgetVo v : list) {
+                if (StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
                     List<ContractCurrencyRate> contractCurrencyRates = JSON.parseArray(v.getCurrencyRateJson(), ContractCurrencyRate.class);
-                    Map<String,BigDecimal> map = contractCurrencyRates.stream().collect(Collectors.toMap(ContractCurrencyRate::getType,ContractCurrencyRate::getRate));
+                    Map<String, BigDecimal> map = contractCurrencyRates.stream().collect(Collectors.toMap(ContractCurrencyRate::getType, ContractCurrencyRate::getRate));
                     v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
-                    if(MapUtils.isNotEmpty(ehsdAmountMap)){    //计算EHSD租户应付货款
-                        String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(),null);
-                        if(StringUtils.isNotEmpty(concatAmountCurrency)){
+                    if (MapUtils.isNotEmpty(ehsdAmountMap)) {    //计算EHSD租户应付货款
+                        String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(), null);
+                        if (StringUtils.isNotEmpty(concatAmountCurrency)) {
                             BigDecimal amount = new BigDecimal(concatAmountCurrency.split("-")[0]);
                             String currency = concatAmountCurrency.split("-")[1];
-                            BigDecimal rate = map.getOrDefault(currency,BigDecimal.ONE);
+                            BigDecimal rate = map.getOrDefault(currency, BigDecimal.ONE);
                             v.setEhsdSumAmount(amount.multiply(rate));
-                        }else{
+                        } else {
                             v.setEhsdSumAmount(BigDecimal.ZERO);
                         }
                     }
                     //计算收入总计=合同金额(转人民币)+应退税金额(转人民币)
                     v.setIncomeAmount(v.getAmount().multiply(new BigDecimal(map.getOrDefault(v.getCurrency(), BigDecimal.ONE).toString())).add(v.getRefundableAmount()));
                     //计算支出总计 除合同金额(转人民币)+应退税金额(转人民币) 其他金额相加
-                    v.setExpenditureAmount(v.getTrailerFee()==null?BigDecimal.ZERO:v.getTrailerFee().multiply(new BigDecimal(map.getOrDefault(v.getTrailerFeeCurrency(),BigDecimal.ONE).toString())).add
-                            (v.getCustomsFee()==null?BigDecimal.ZERO:v.getCustomsFee().multiply(new BigDecimal(map.getOrDefault(v.getCustomsFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getAgencyFee()==null?BigDecimal.ZERO:v.getAgencyFee().multiply(new BigDecimal(map.getOrDefault(v.getAgencyFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getPortMixedFee()==null?BigDecimal.ZERO:v.getPortMixedFee().multiply(new BigDecimal(map.getOrDefault(v.getPortMixedFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getInspectionRedPack()==null?BigDecimal.ZERO:v.getInspectionRedPack().multiply(new BigDecimal(map.getOrDefault(v.getInspectionRedPackCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getCommission()==null?BigDecimal.ZERO:v.getCommission().multiply(new BigDecimal(map.getOrDefault(v.getCommissionCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getOther()==null?BigDecimal.ZERO:v.getOther().multiply(new BigDecimal(map.getOrDefault(v.getOtherCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getEhsdSumAmount()==null?BigDecimal.ZERO:v.getEhsdSumAmount()).add
-                            (v.getOtherSumAmount()==null?BigDecimal.ZERO:v.getOtherSumAmount()));
-                }else{//没有汇率取默认汇率
+                    v.setExpenditureAmount(v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(new BigDecimal(map.getOrDefault(v.getTrailerFeeCurrency(), BigDecimal.ONE).toString())).add
+                            (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(new BigDecimal(map.getOrDefault(v.getCustomsFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee().multiply(new BigDecimal(map.getOrDefault(v.getAgencyFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee().multiply(new BigDecimal(map.getOrDefault(v.getPortMixedFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(new BigDecimal(map.getOrDefault(v.getInspectionRedPackCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(new BigDecimal(map.getOrDefault(v.getCommissionCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(new BigDecimal(map.getOrDefault(v.getOtherCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
+                            (v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
+                } else {//没有汇率取默认汇率
                     v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
-                    if(MapUtils.isNotEmpty(ehsdAmountMap)){    //计算EHSD租户应付货款
-                        String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(),null);
-                        if(StringUtils.isNotEmpty(concatAmountCurrency)){
+                    if (MapUtils.isNotEmpty(ehsdAmountMap)) {    //计算EHSD租户应付货款
+                        String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(), null);
+                        if (StringUtils.isNotEmpty(concatAmountCurrency)) {
                             BigDecimal amount = new BigDecimal(concatAmountCurrency.split("-")[0]);
                             String currency = concatAmountCurrency.split("-")[1];
-                            BigDecimal rate = currencyRateMap.getOrDefault(currency,BigDecimal.ONE);
+                            BigDecimal rate = currencyRateMap.getOrDefault(currency, BigDecimal.ONE);
                             v.setEhsdSumAmount(amount.multiply(rate));
-                        }else{
+                        } else {
                             v.setEhsdSumAmount(BigDecimal.ZERO);
                         }
                     }
                     //计算收入总计=合同金额(转人民币)+应退税金额(转人民币)
-                    v.setIncomeAmount(v.getAmount().multiply(currencyRateMap.getOrDefault(v.getContractId(),new BigDecimal("1"))).add(v.getRefundableAmount()));
+                    v.setIncomeAmount(v.getAmount().multiply(currencyRateMap.getOrDefault(v.getContractId(), new BigDecimal("1"))).add(v.getRefundableAmount()));
                     //计算支出总计 除合同金额(转人民币)+应退税金额(转人民币) 其他金额相加
-                    v.setExpenditureAmount(v.getTrailerFee()==null?BigDecimal.ZERO:v.getTrailerFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getTrailerFeeCurrency(),BigDecimal.ONE).toString())).add
-                            (v.getCustomsFee()==null?BigDecimal.ZERO:v.getCustomsFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCustomsFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getAgencyFee()==null?BigDecimal.ZERO:v.getAgencyFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getAgencyFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getPortMixedFee()==null?BigDecimal.ZERO:v.getPortMixedFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getPortMixedFeeCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getInspectionRedPack()==null?BigDecimal.ZERO:v.getInspectionRedPack().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getInspectionRedPackCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getCommission()==null?BigDecimal.ZERO:v.getCommission().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCommissionCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getOther()==null?BigDecimal.ZERO:v.getOther().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getOtherCurrency(),BigDecimal.ONE).toString()))).add
-                            (v.getEhsdSumAmount()==null?BigDecimal.ZERO:v.getEhsdSumAmount()).add
-                            (v.getOtherSumAmount()==null?BigDecimal.ZERO:v.getOtherSumAmount()));
+                    v.setExpenditureAmount(v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getTrailerFeeCurrency(), BigDecimal.ONE).toString())).add
+                            (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCustomsFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getAgencyFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getPortMixedFeeCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getInspectionRedPackCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCommissionCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getOtherCurrency(), BigDecimal.ONE).toString()))).add
+                            (v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
+                            (v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
                 }
                 //计算毛利 收入-支出
                 v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
@@ -335,6 +336,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 利润结算表分页
+     *
      * @param dto
      * @return
      */
@@ -343,21 +345,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         IWrapper<Contract> wrapper = getWrapper();
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         wrapper.between("t1", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
-        if(StringUtils.isNotEmpty(dto.getCustomerId())){
-            wrapper.eq("t1",Contract::getBuyCorporationId,dto.getCustomerId());
+        if (StringUtils.isNotEmpty(dto.getCustomerId())) {
+            wrapper.eq("t1", Contract::getBuyCorporationId, dto.getCustomerId());
         }
-        if(StringUtils.isNotEmpty(dto.getUserId())){
-            wrapper.eq("t1",Contract::getCreateUser,dto.getUserId());
+        if (StringUtils.isNotEmpty(dto.getUserId())) {
+            wrapper.eq("t1", Contract::getCreateUser, dto.getUserId());
         }
-        if(StringUtils.isNotEmpty(dto.getKeyword())){
-            wrapper.keyword(dto.getKeyword(),new SqlField("t1.code"));
+        if (StringUtils.isNotEmpty(dto.getKeyword())) {
+            wrapper.keyword(dto.getKeyword(), new SqlField("t1.code"));
         }
         Page<ContractBudgetVo> page = this.baseMapper.getProfitClearingPage(dto.getPage(), wrapper);
         List<ContractBudgetVo> list = page.getRecords();
         //取出默认汇率
         List<CurrencyRate> defaultCurrencyRateList = currencyRateService.getList();
-        Map<String,BigDecimal> defaultCurrencyRateMap = defaultCurrencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType,CurrencyRate::getRate));
-        for(ContractBudgetVo v : list){
+        Map<String, BigDecimal> defaultCurrencyRateMap = defaultCurrencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
+        for (ContractBudgetVo v : list) {
             v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
             v.setOtherIncomeAmount(BigDecimal.ZERO);//暂时先设置其他收入为0
             v.setAccountPaid(BigDecimal.ZERO);//暂时先设置已付货款为0
@@ -365,28 +367,28 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             customerService.attributeAssign(list, Contract::getBuyCorporationId, (item, customer) -> {
                 item.setCustomerName(customer.getName());
             });
-            if(StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
+            if (StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
                 //取出汇率
                 List<CurrencyRate> assignCurrencyRatesList = JSON.parseArray(v.getCurrencyRateJson(), CurrencyRate.class);
-                Map<String,BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType,CurrencyRate::getRate));
-                v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
+                Map<String, BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
+                v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));//计算汇算人民币
                 //到账金额
-                v.setSumClaimMoney(this.getSumClaimMoney(v,assignCurrencyRatesMap));
+                v.setSumClaimMoney(this.getSumClaimMoney(v, assignCurrencyRatesMap));
                 //采购合同总金额
-                v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v,assignCurrencyRatesMap));
+                v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, assignCurrencyRatesMap));
                 //支出费用
-                this.getGroupTypeMoney(v,assignCurrencyRatesMap);
-            }else{//没有取默认的汇率
-                v.setRmbContractAmount(v.getAmount().multiply(defaultCurrencyRateMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
+                this.getGroupTypeMoney(v, assignCurrencyRatesMap);
+            } else {//没有取默认的汇率
+                v.setRmbContractAmount(v.getAmount().multiply(defaultCurrencyRateMap.getOrDefault(v.getCurrency(), BigDecimal.ONE)));//计算汇算人民币
                 //到账金额
-                v.setSumClaimMoney(this.getSumClaimMoney(v,defaultCurrencyRateMap));
+                v.setSumClaimMoney(this.getSumClaimMoney(v, defaultCurrencyRateMap));
                 //采购合同总金额
-                v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v,defaultCurrencyRateMap));
+                v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v, defaultCurrencyRateMap));
                 //支出费用
-                this.getGroupTypeMoney(v,defaultCurrencyRateMap);
+                this.getGroupTypeMoney(v, defaultCurrencyRateMap);
             }
             //计算收入总计=合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币)
-            v.setIncomeAmount(v.getRmbContractAmount()==null?BigDecimal.ZERO:v.getRmbContractAmount().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
+            v.setIncomeAmount(v.getRmbContractAmount() == null ? BigDecimal.ZERO : v.getRmbContractAmount().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
             //计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
             v.setExpenditureAmount(v.getTrailerFee().add
                     (v.getCustomsFee()).add
@@ -691,8 +693,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      */
     @Override
     public void contractHandover(ContractDto dto) {
-        ObsFileUtil.editFile(dto.getFileList(),dto.getId(),1);
-        ObsFileUtil.editFile(dto.getPackageFileList(),dto.getId(),2);
+        ObsFileUtil.editFile(dto.getFileList(), dto.getId(), 1);
+        ObsFileUtil.editFile(dto.getPackageFileList(), dto.getId(), 2);
     }
 
     /**
@@ -705,15 +707,15 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         QueryWrapper<Contract> query = Wrappers.query();
         query.select("count(*) count,ifnull(sum(amount),0) amount,sell_corporation_id sellCorporationId");
         query.groupBy("sell_corporation_id");
-        query.eq("status",30);
+        query.eq("status", 30);
         List<Contract> contractList = baseMapper.selectList(query);
 
         //计算合计数量
         Integer countAmount = contractList.stream().map(Contract::getCount).reduce(Integer::sum).orElse(0);
         //计算合计金额
         BigDecimal amount = contractList.stream().map(Contract::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-        map.put("countAmount",countAmount);
-        map.put("amount",amount);
+        map.put("countAmount", countAmount);
+        map.put("amount", amount);
 
         //赋值归属公司名称
         DynamicDataSourceContextHolder.push(SourceConstant.COMMON);
@@ -1261,49 +1263,52 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 统计到账认领总金额
+     *
      * @param v
      * @param currencyRatesMap 汇率JSON
      * @return
      */
-    private BigDecimal getSumClaimMoney(ContractBudgetVo v,Map<String,BigDecimal> currencyRatesMap){
-        List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().eq(ClaimContract::getContractId,v.getContractId()));
+    private BigDecimal getSumClaimMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
+        List<ClaimContract> claimContractList = claimContractService.list(Wrappers.<ClaimContract>query().lambda().eq(ClaimContract::getContractId, v.getContractId()));
         BigDecimal sumClaimMOney = BigDecimal.ZERO;
-        if(CollectionUtils.isNotEmpty(claimContractList)){
-            for(ClaimContract c:claimContractList){
-                sumClaimMOney = sumClaimMOney.add(c.getMoney().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+        if (CollectionUtils.isNotEmpty(claimContractList)) {
+            for (ClaimContract c : claimContractList) {
+                sumClaimMOney = sumClaimMOney.add(c.getMoney().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
             }
             return sumClaimMOney;
-        }else{
+        } else {
             return BigDecimal.ZERO;
         }
     }
 
     /**
      * 统采购合同总金额
+     *
      * @param v
      * @param currencyRatesMap 汇率JSON
      * @return
      */
-    private BigDecimal getSumPurchaseContractMoney(ContractBudgetVo v,Map<String,BigDecimal> currencyRatesMap){
+    private BigDecimal getSumPurchaseContractMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
         List<EhsdPurchaseProductVo> list = ehsdPurchaseProductService.getListByContractId(v.getContractId());
         BigDecimal sumPurchaseContractMoney = BigDecimal.ZERO;
-        if(CollectionUtils.isNotEmpty(list)){
-            for(EhsdPurchaseProductVo c:list){
-                sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+        if (CollectionUtils.isNotEmpty(list)) {
+            for (EhsdPurchaseProductVo c : list) {
+                sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
             }
             return sumPurchaseContractMoney;
-        }else{
+        } else {
             return BigDecimal.ZERO;
         }
     }
 
     /**
      * 统计支出各种费用
+     *
      * @param v
      * @param currencyRatesMap 汇率JSON
      * @return
      */
-    private void getGroupTypeMoney(ContractBudgetVo v,Map<String,BigDecimal> currencyRatesMap){
+    private void getGroupTypeMoney(ContractBudgetVo v, Map<String, BigDecimal> currencyRatesMap) {
         List<AccountRequestFundsDetailVo> list = accountRequestFundsDetailService.getListByContractId(v.getContractId());
         /**
          * 拖车费
@@ -1353,40 +1358,40 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         /**
          * 其他费用
          */
-        BigDecimal other  = BigDecimal.ZERO;
+        BigDecimal other = BigDecimal.ZERO;
 
-        if(CollectionUtils.isNotEmpty(list)){
-            for(AccountRequestFundsDetailVo c:list){
-                switch (c.getCostType()){
+        if (CollectionUtils.isNotEmpty(list)) {
+            for (AccountRequestFundsDetailVo c : list) {
+                switch (c.getCostType()) {
                     case "1"://拖车费
-                        trailerFee = trailerFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        trailerFee = trailerFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "2"://报关费
-                        customsFee = customsFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        customsFee = customsFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "3"://港杂费
-                        portMixedFee = portMixedFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        portMixedFee = portMixedFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "4"://验收红包
-                        inspectionRedPack = inspectionRedPack.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        inspectionRedPack = inspectionRedPack.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "5"://佣金
-                        commission = commission.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        commission = commission.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "6"://检测费
-                        checkout = checkout.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        checkout = checkout.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "7"://验货费
-                        inspectionCharge = inspectionCharge.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        inspectionCharge = inspectionCharge.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "8"://运费
-                        freight = freight.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        freight = freight.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     case "9"://产地证费
-                        certificateOfOrigin = certificateOfOrigin.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        certificateOfOrigin = certificateOfOrigin.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                     default:
-                        other = other.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
+                        other = other.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(), BigDecimal.ONE)));
                         break;
                 }
             }
@@ -1402,4 +1407,20 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         v.setCertificateOfOrigin(certificateOfOrigin);
         v.setOther(other);
     }
+
+    /**
+     * 获取合同历史联系方式
+     */
+    @Override
+    public List<Contract> contactList(ContractDto dto) {
+        IWrapper<Contract> wrapper = IWrapper.getWrapper();
+        //根据卖方联系人名称/联系方式过滤
+        wrapper.or().like(Contract::getSellContactName, dto.getSellContactName());
+        wrapper.or().like(Contract::getSellContactNumber, dto.getSellContactNumber());
+        //根据买方联系人名称/联系方式过滤
+        wrapper.or().like(Contract::getBuyContactName, dto.getBuyContactName());
+        wrapper.or().like(Contract::getBuyContactNumber, dto.getBuyContactNumber());
+        List<Contract> list = baseMapper.contactList(wrapper);
+        return list;
+    }
 }

+ 42 - 33
hx-sale/src/main/java/com/fjhx/sale/service/documents/impl/DocumentsServiceImpl.java

@@ -15,6 +15,7 @@ import com.fjhx.common.entity.corporation.po.Corporation;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.customer.entity.customer.po.Customer;
 import com.fjhx.customer.service.customer.CustomerService;
+import com.fjhx.flow.service.flow.FlowExampleService;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.po.ContractProject;
@@ -93,6 +94,9 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
     @Autowired
     private ContractProjectService contractProjectService;
 
+    @Autowired
+    private FlowExampleService flowExampleService;
+
     private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy", Locale.ENGLISH);
 
     /**
@@ -110,13 +114,13 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
         DynamicDataSourceContextHolder.poll();
 
         List<DocumentsVo> records = page.getRecords();
-        if (ObjectUtil.isEmpty(records)){
+        if (ObjectUtil.isEmpty(records)) {
             return page;
         }
         for (DocumentsVo record : records) {
             //赋值归属公司名称
             List<Corporation> corporationList2 = corporationMap.get(record.getSellCorporationId());
-            if (ObjectUtil.isNotEmpty(corporationList2)){
+            if (ObjectUtil.isNotEmpty(corporationList2)) {
                 record.setSellCorporationName(corporationList2.get(0).getName());
             }
 
@@ -125,6 +129,8 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
         customerService.attributeAssign(records, DocumentsVo::getBuyCorporationId, (item, customer) -> {
             item.setBuyCorporationName(customer.getName());
         });
+        //  赋值流程id
+        flowExampleService.setFlowId(records, DocumentsVo::getContractId, DocumentsVo::setFlowId);
         return page;
     }
 
@@ -162,41 +168,42 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
         //删除单证表的数据
         this.removeById(id);
         //删除单证-产品表的数据
-        documentsProductService.remove(Wrappers.<DocumentsProduct>lambdaQuery().eq(DocumentsProduct::getDocumentsId,id));
+        documentsProductService.remove(Wrappers.<DocumentsProduct>lambdaQuery().eq(DocumentsProduct::getDocumentsId, id));
 
         //删除单证-货运表的数据
-        documentsTransportService.remove(Wrappers.<DocumentsTransport>lambdaQuery().eq(DocumentsTransport::getDocumentsId,id));
+        documentsTransportService.remove(Wrappers.<DocumentsTransport>lambdaQuery().eq(DocumentsTransport::getDocumentsId, id));
     }
 
     /**
      * 生成PDF---商业发票、装箱单
+     *
      * @return
      */
     @Override
     public Map<String, Object> generateInvoiceAPackPdf(Long id) {
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
         //查询单证
         Documents documents = this.getById(id);
-        if(ObjectUtil.isEmpty(documents)){
+        if (ObjectUtil.isEmpty(documents)) {
             throw new ServiceException("单证不存在");
         }
         setDocumentArea(documents);
         //查询合同
         Contract contract = contractService.getById(documents.getContractId());
-        if(ObjectUtil.isEmpty(contract)){
+        if (ObjectUtil.isEmpty(contract)) {
             throw new ServiceException("该单证合同不存在");
         }
         //查询合同
         ContractVo contractVo = BeanUtil.toBean(contract, ContractVo.class);
         setContractArea(contractVo);
         //查询收费项目
-        List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().eq(ContractProject::getContractId,contractVo.getId()));
+        List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().eq(ContractProject::getContractId, contractVo.getId()));
         //查询买方
         Customer customer = customerService.getById(contractVo.getBuyCorporationId());
         //查询卖方
         Corporation corporation = corporationService.getById(contractVo.getSellCorporationId());
         //查询单证货物
-        List<DocumentsProduct> documentsProducts = documentsProductService.list(Wrappers.<DocumentsProduct>query().lambda().eq(DocumentsProduct::getDocumentsId,documents.getId()));
+        List<DocumentsProduct> documentsProducts = documentsProductService.list(Wrappers.<DocumentsProduct>query().lambda().eq(DocumentsProduct::getDocumentsId, documents.getId()));
         // 赋值产品属性
         productInfoService.attributeAssign(documentsProducts, DocumentsProduct::getBusinessId, (item, product) -> {
             item.setProductCode(product.getCode());
@@ -218,31 +225,31 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
         BigDecimal sumPackQuantity = BigDecimal.ZERO;
         //装箱商品明细
         List<PackDetailGoods> packDetailGoodsList = new ArrayList<>();
-        if(ObjectUtil.isNotEmpty(packShipment)){//查询装箱单
+        if (ObjectUtil.isNotEmpty(packShipment)) {//查询装箱单
             packDetailList = packDetailService.list(Wrappers.<PackDetail>query().lambda().in(PackDetail::getId, Arrays.asList(packShipment.getPackDetailIds())));
             List<Long> packDetailIds = packDetailList.stream().map(PackDetail::getId).collect(Collectors.toList());
-            packDetailGoodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().in(PackDetailGoods::getPackDetailId,packDetailIds));
-            Map<Long,List<PackDetailGoods>> packGoodMap = packDetailGoodsList.stream().collect(Collectors.groupingBy(PackDetailGoods::getPackDetailId));
-            for(PackDetail p:packDetailList){
-                p.setPackDetailGoodsList(packGoodMap.getOrDefault(p.getId(),null));
+            packDetailGoodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().in(PackDetailGoods::getPackDetailId, packDetailIds));
+            Map<Long, List<PackDetailGoods>> packGoodMap = packDetailGoodsList.stream().collect(Collectors.groupingBy(PackDetailGoods::getPackDetailId));
+            for (PackDetail p : packDetailList) {
+                p.setPackDetailGoodsList(packGoodMap.getOrDefault(p.getId(), null));
             }
-            sumPackQuantity = packDetailList.stream().map(PackDetail::getPackQuantity).reduce(BigDecimal.ZERO,BigDecimal::add);
-            sumRoughWeight = packDetailList.stream().map(PackDetail::getRoughWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
-            sumNetWeight = packDetailList.stream().map(PackDetail::getNetWeight).reduce(BigDecimal.ZERO,BigDecimal::add);
-            sumBomVolume = packDetailList.stream().map(PackDetail::getBomVolume).reduce(BigDecimal.ZERO,BigDecimal::add);
+            sumPackQuantity = packDetailList.stream().map(PackDetail::getPackQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+            sumRoughWeight = packDetailList.stream().map(PackDetail::getRoughWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
+            sumNetWeight = packDetailList.stream().map(PackDetail::getNetWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
+            sumBomVolume = packDetailList.stream().map(PackDetail::getBomVolume).reduce(BigDecimal.ZERO, BigDecimal::add);
         }
-        map.put("contract",contractVo);//合同信息
-        map.put("date",sdf.format(contractVo.getCreateTime()));//日期
-        map.put("documents",documents);//单证信息
-        map.put("documentsProducts",documentsProducts);//单证信息货物
-        map.put("packDetailList",packDetailList);//单证信息货物
-        map.put("sumRoughWeight",sumRoughWeight);//总毛重
-        map.put("sumNetWeight",sumNetWeight);//总净重
-        map.put("sumBomVolume",sumBomVolume);//总体积
-        map.put("sumPackQuantity",sumPackQuantity);//总箱数
-        map.put("customer",customer);//买方信息
-        map.put("corporation",corporation);//卖方信息
-        map.put("contractProjectList",contractProjectList);//卖方信息
+        map.put("contract", contractVo);//合同信息
+        map.put("date", sdf.format(contractVo.getCreateTime()));//日期
+        map.put("documents", documents);//单证信息
+        map.put("documentsProducts", documentsProducts);//单证信息货物
+        map.put("packDetailList", packDetailList);//单证信息货物
+        map.put("sumRoughWeight", sumRoughWeight);//总毛重
+        map.put("sumNetWeight", sumNetWeight);//总净重
+        map.put("sumBomVolume", sumBomVolume);//总体积
+        map.put("sumPackQuantity", sumPackQuantity);//总箱数
+        map.put("customer", customer);//买方信息
+        map.put("corporation", corporation);//卖方信息
+        map.put("contractProjectList", contractProjectList);//卖方信息
 
 //        map.put("packDetailGoodsList",packDetailGoodsList);//装箱商品明细
         return map;
@@ -250,6 +257,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
 
     /**
      * 生成pdf----报关单
+     *
      * @param id
      * @return
      */
@@ -257,7 +265,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
     public DocumentsPdf generateClearanceePdf(Long id) {
         //获取单证PDF数据
         DocumentsPdf pdfData = documentsPdfService.getOne(Wrappers.<DocumentsPdf>query().lambda()
-                .eq(DocumentsPdf::getDocumentId,id).eq(DocumentsPdf::getDataType,0));
+                .eq(DocumentsPdf::getDocumentId, id).eq(DocumentsPdf::getDataType, 0));
         if (ObjectUtil.isEmpty(pdfData)) {
             JSONObject data = new JSONObject();
             List<JSONObject> productData = new ArrayList<>();
@@ -284,7 +292,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
             //发件公司清关负责人
             data.put("contacts", contract.getSellContactName());
             //发件公司清关负责人联系电话/手机
-            data.put("contactsMobile",contract.getSellContactNumber());
+            data.put("contactsMobile", contract.getSellContactNumber());
             //联系人邮箱
             data.put("contactsEmail", "");
             //境内发货人名称(填写发货公司中文名称)
@@ -393,7 +401,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
             pdfData.setDocumentId(documents.getId());
             pdfData.setContractCode(contract.getCode());
             pdfData.setDataType(0);//报关单
-            pdfData.setContent(JSONObject.toJSONString(data,JSONWriter.Feature.WriteLongAsString));
+            pdfData.setContent(JSONObject.toJSONString(data, JSONWriter.Feature.WriteLongAsString));
         }
         return pdfData;
     }
@@ -419,6 +427,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
         contractVo.setSellProvinceName(areaMap.get(contractVo.getSellProvinceId()));
         contractVo.setSellCityName(areaMap.get(contractVo.getSellCityId()));
     }
+
     /**
      * 赋值单证目的国家名称
      */

+ 4 - 3
hx-sale/src/main/java/com/fjhx/sale/service/pack/impl/PackShipmentServiceImpl.java

@@ -40,6 +40,7 @@ public class PackShipmentServiceImpl extends ServiceImpl<PackShipmentMapper, Pac
 
     @Autowired
     private PackDetailProductService packDetailProductService;
+
     @Autowired
     private DocumentsService documentsService;
 
@@ -81,11 +82,11 @@ public class PackShipmentServiceImpl extends ServiceImpl<PackShipmentMapper, Pac
      */
     @Override
     public List<PackShipmentVo> getList(PackShipmentSelectDto dto) {
-        List<Long> documentsIds = documentsService.listObject(Documents::getContractId, q -> q.orderByAsc(Documents::getContractId));
+        List<Long> packShipmentIds = documentsService.listObject(Documents::getPackShipmentId, q -> q.orderByAsc(Documents::getContractId));
         //查询出货绑定主合同列表详情
         List<PackShipmentVo> packShipments = baseMapper.getList(Wrappers.query()
-                .like(ObjectUtil.isNotEmpty(dto.getKeyword()), " c.code", dto.getKeyword())
-                .notIn("ps.contract_id", documentsIds)
+                .like(ObjectUtil.isNotEmpty(dto.getKeyword()), "c.code", dto.getKeyword())
+                .notIn(ObjectUtil.isNotEmpty(packShipmentIds), "ps.id", packShipmentIds)
         );
         return packShipments;
     }

+ 11 - 6
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -145,14 +145,19 @@
     </select>
     <select id="salesVolumeStatistics" resultType="com.fjhx.sale.entity.contract.dto.ContractDto">
 
-        SELECT
-            SUM(cp.quantity) quantity,
-            pi.name productName
-        FROM
-            contract_product cp
-                LEFT JOIN bytesailing_item.product_info pi ON cp.product_id = pi.id
+        SELECT SUM(cp.quantity) quantity,
+               pi.name          productName
+        FROM contract_product cp
+                 LEFT JOIN bytesailing_item.product_info pi ON cp.product_id = pi.id
             ${ew.customSqlSegment}
     </select>
+    <select id="contactList" resultType="com.fjhx.sale.entity.contract.po.Contract">
+        SELECT c.sell_contact_name,
+               c.sell_contact_number,
+               c.buy_contact_name,
+               c.buy_contact_number
+        FROM contract c
+    </select>
 
 
 </mapper>

+ 0 - 45
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/purchase/impl/PurchaseBackServiceImpl.java

@@ -131,51 +131,6 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
     @Override
     @DSTransactional
     public void backOut(StockWaitDetailsDto stockWaitDetailsDto) {
-//        //修改待出入库状态
-//        stockWaitDetailsService.changeStockWaitStatus(stockWaitDetailsDto);
-//        StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
-//        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
-//        //创建出入库记录
-//        StockJournal stockJournal = new StockJournal();
-//        stockJournal.setOpType(byId.getType());
-//        //退货出库
-//        stockJournal.setType(JournalType.BACK_OUT.getDetailType());
-//
-//        DynamicDataSourceContextHolder.push(SourceConstant.WMS);
-//        stockJournal.setCode(CodeEnum.SOUT_CODE.getCode());
-//        DynamicDataSourceContextHolder.poll();
-//
-//        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
-//        stockJournal.setBusinessId(byId.getId());
-//        //保存出入库记录
-//        stockJournalService.save(stockJournal);
-//        //操作库存
-//        Stock stock = new Stock();
-//        stock.setQuantity(stockWaitDetailsDto.getQuantity());
-//        stock.setProductId(stockWaitDetails.getProductId());
-//        //退货出库出次品库存
-//        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), 4, Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
-//        //保存出入库明细
-//        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
-//
-//        //创建物流数据
-//        LogisticsInfos logisticsInfos = new LogisticsInfos();
-//        logisticsInfos.setBusinessId(byId.getId());
-//        logisticsInfos.setBusinessCode(byId.getBusinessCode());
-//        logisticsInfos.setBusinessType(5);//采购退货
-//        logisticsInfos.setLogisticsCompanyCode(stockWaitDetailsDto.getLogisticsCompanyCode());
-//        logisticsInfos.setCode(stockWaitDetailsDto.getLogisticsCode());
-//        logisticsInfos.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
-//        logisticsInfos.setIsKd100(0);
-//        logisticsInfosService.save(logisticsInfos);
-//
-//        LogisticsDetails logisticsDetails = new LogisticsDetails();
-//        logisticsDetails.setLogisticsInfoId(logisticsInfos.getId());
-//        logisticsDetails.setLogisticsInfoCode(logisticsInfos.getCode());
-//        logisticsDetails.setBusinessDetailsId(stockWaitDetailsDto.getId());
-//        logisticsDetails.setReceiptQuantity(stockWaitDetailsDto.getQuantity());
-//        logisticsDetailsService.save(logisticsDetails);
-
         //优化
         StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
         Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");

+ 1 - 57
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitDetailsServiceImpl.java

@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fjhx.common.utils.Assert;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
@@ -15,7 +14,6 @@ import com.fjhx.wms.entity.stock.po.StockWait;
 import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.mapper.stock.StockWaitDetailsMapper;
-import com.fjhx.wms.service.MyPurchaseService;
 import com.fjhx.wms.service.stock.StockWaitDetailsService;
 import com.fjhx.wms.service.stock.StockWaitService;
 import com.ruoyi.common.exception.ServiceException;
@@ -24,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -44,8 +41,6 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
     private ProductInfoService productInfoService;
     @Autowired
     private StockWaitService stockWaitService;
-    @Autowired
-    private MyPurchaseService myPurchaseService;
 
     @Override
     public Page<StockWaitDetailsVo> getPage(StockWaitDetailsSelectDto dto) {
@@ -105,58 +100,7 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
     @Override
     @DSTransactional
     public void add(StockWaitDetailsDto stockWaitDetailsDto) {
-//        //修改待出库状态
-//        changeStockWaitStatus(stockWaitDetailsDto);
-//        StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
-//        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
-//        Integer businessType = byId.getBusinessType();
-//
-//        if (StockWaitType.SALE_ORDER_OUT.getDetailType().equals(businessType)) {
-//            //销售订单出库
-//            wmsService.outbound(stockWaitDetailsDto);
-//        }
-//        if (StockWaitType.PRODUCTION_TASK_OUT.getDetailType().equals(businessType)) {
-//            //生产任务待出库
-//            //减少冻结库存
-//            StockFrozen stockFrozen = stockFrozenService.getOne(q -> q.eq(StockFrozen::getProductId, stockWaitDetails.getProductId()));
-//            BigDecimal subtract = stockFrozen.getFrozenQuantity().subtract(stockWaitDetailsDto.getQuantity());
-//            stockFrozen.setFrozenQuantity(subtract);
-//            stockFrozenService.updateById(stockFrozen);
-//        }
-//
-//        //创建出入库记录
-//        StockJournal stockJournal = new StockJournal();
-//        stockJournal.setOpType(byId.getType());
-//        //根据待入库业务类型创建待出入库记录
-//        stockJournal.setType(stockWaitService.getStockJournalType(businessType));
-//        stockJournal.setCode(byId.getType() == 1 ? CodeEnum.SIN_CODE.getCode() : CodeEnum.SOUT_CODE.getCode());
-//        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
-//        stockJournal.setBusinessId(byId.getId());
-//        //保存出入库记录
-//        stockJournalService.save(stockJournal);
-//        //操作库存
-//        Stock stock = new Stock();
-//        stock.setQuantity(stockWaitDetailsDto.getQuantity());
-//        stock.setProductId(stockWaitDetails.getProductId());
-//        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), byId.getType(), Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
-//        //保存出入库明细
-//        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
-
-        //优化
-        StockWaitDetails stockWaitDetails = this.getById(stockWaitDetailsDto.getId());
-        Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");
-        StockWaitDto stockWaitDto = BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDto.class);
-        stockWaitDto.setId(stockWaitDetails.getStockWaitId());
-        stockWaitDto.setStockWaitDetailsList(Collections.singletonList(BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDetails.class)));
-        stockWaitService.addByWdly(stockWaitDto);
-
-        //如果是采购退货 修改采购退货状态
-        StockWait stockWait = stockWaitService.getById(stockWaitDto.getId());
-        Assert.notEmpty(stockWait, "查询不到待出库信息");
-        if (stockWait.getBusinessType() == 4) {
-            Integer status = stockWait.getStatus();
-            myPurchaseService.updateSalesReturnStatus(stockWaitDetails.getBusinessDetailsId(), status);
-        }
+        stockWaitService.add(stockWaitDetailsDto);
     }
 
 

+ 26 - 8
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

@@ -24,6 +24,7 @@ import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.entity.stock.vo.StockWaitVo;
 import com.fjhx.wms.entity.warehouse.po.Warehouse;
 import com.fjhx.wms.mapper.stock.StockWaitMapper;
+import com.fjhx.wms.service.MyPurchaseService;
 import com.fjhx.wms.service.WmsService;
 import com.fjhx.wms.service.arrival.ArrivalStockRecordsDetailsService;
 import com.fjhx.wms.service.arrival.ArrivalStockRecordsService;
@@ -38,6 +39,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -75,6 +77,8 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
     private WmsService wmsService;
     @Autowired
     private StockFrozenService stockFrozenService;
+    @Autowired
+    private MyPurchaseService myPurchaseService;
 
     @Override
     public Page<StockWaitVo> getPage(StockWaitSelectDto dto) {
@@ -118,7 +122,7 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         //赋值操作人
         UserUtil.assignmentNickName(records, StockWaitVo::getCreateUser, StockWaitVo::setOperatorName);
         //赋值仓库名称和id
-        List<Long> wids = new ArrayList<>();
+        List<Long> warehouseIds = new ArrayList<>();
         for (StockWaitVo stockWaitVo : records) {
             String victoriatouristJson = stockWaitVo.getVictoriatouristJson();
             if (ObjectUtil.isEmpty(victoriatouristJson)) {
@@ -128,12 +132,12 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
             if (!json.containsKey("receiptWarehouseId")) {
                 continue;
             }
-            wids.add(json.getLong("receiptWarehouseId"));
+            warehouseIds.add(json.getLong("receiptWarehouseId"));
         }
-        if (ObjectUtil.isEmpty(wids)) {
+        if (ObjectUtil.isEmpty(warehouseIds)) {
             return page;
         }
-        List<Warehouse> warehouses = warehouseService.listByIds(wids);
+        List<Warehouse> warehouses = warehouseService.listByIds(warehouseIds);
         Map<Long, String> warehousesMap = warehouses.stream().collect(Collectors.toMap(Warehouse::getId, Warehouse::getName));
         for (StockWaitVo stockWaitVo : records) {
             String victoriatouristJson = stockWaitVo.getVictoriatouristJson();
@@ -181,9 +185,9 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
 
 
         //赋值物品信息和采购信息
-        List<Long> pids = stockWaitDetailsVos.stream().map(StockWaitDetails::getProductId).collect(Collectors.toList());
-        if (ObjectUtil.isNotEmpty(pids)) {
-            List<ProductInfo> productInfos = productInfoService.listByIds(pids);
+        List<Long> productIds = stockWaitDetailsVos.stream().map(StockWaitDetails::getProductId).collect(Collectors.toList());
+        if (ObjectUtil.isNotEmpty(productIds)) {
+            List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
             Map<Long, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.toMap(ProductInfo::getId, Function.identity()));
             for (StockWaitDetailsVo stockWaitDetails : stockWaitDetailsVos) {
                 ProductInfo productInfo = productInfoMap.get(stockWaitDetails.getProductId());
@@ -202,7 +206,21 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
     @DSTransactional
     @Override
     public void add(StockWaitDetailsDto stockWaitDetailsDto) {
-        stockWaitDetailsService.add(stockWaitDetailsDto);
+        //优化
+        StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
+        Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");
+        StockWaitDto stockWaitDto = BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDto.class);
+        stockWaitDto.setId(stockWaitDetails.getStockWaitId());
+        stockWaitDto.setStockWaitDetailsList(Collections.singletonList(BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDetails.class)));
+        this.addByWdly(stockWaitDto);
+
+        //如果是采购退货 修改采购退货状态
+        StockWait stockWait = this.getById(stockWaitDto.getId());
+        Assert.notEmpty(stockWait, "查询不到待出库信息");
+        if (stockWait.getBusinessType() == 4) {
+            Integer status = stockWait.getStatus();
+            myPurchaseService.updateSalesReturnStatus(stockWaitDetails.getBusinessDetailsId(), status);
+        }
     }
 
     @DSTransactional