Răsfoiți Sursa

订单合同新增接口

chenxiaofei 2 luni în urmă
părinte
comite
d6788693b4

+ 6 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/res/QueryListResVo.java

@@ -115,6 +115,12 @@ public class QueryListResVo implements Serializable {
     @Schema(description = "已履约量")
     private BigDecimal performedAmount;
 
+    /**
+     * 已履约金额
+     */
+    @Schema(description = "已履约金额")
+    private BigDecimal performedAmountMoney;
+
     /**
      * 主合同id
      */

+ 31 - 5
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractTradeService.java

@@ -45,16 +45,19 @@ import com.sckw.stream.model.UserInfo;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.model.dto.res.*;
+import com.sckw.transport.api.dubbo.TransportRemoteService;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.xml.crypto.dsig.TransformService;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.function.Function;
@@ -104,6 +107,8 @@ public class KwcContractTradeService {
 
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private TradeOrderInfoService tradeOrderInfoService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private TransportRemoteService transportRemoteService;
 
     /**销售合同*/
     @Value(value = "${jumpUrl.saleSendContract}")
@@ -176,7 +181,17 @@ public class KwcContractTradeService {
             return PageHelperUtil.getPageResult(new PageInfo<>());
         }
 
-        List<QueryListResVo> list = getQueryListResVos(queryListResDtos);
+        //获取贸易合同id
+        Set<Long> tradeContractIds =
+                queryListResDtos.stream().map(QueryListResDto::getId).collect(Collectors.toSet());
+        //查询贸易合同关联商品
+        List<KwcContractTradeGoods> tradeContractGoods = kwcContractTradeGoodsRepository.queryByContractIds(tradeContractIds);
+        Map<Long, List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap = Maps.newHashMap();
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tradeContractGoods)){
+            contractIdGoodsIdKeyAndGoodsMap =
+                    tradeContractGoods.stream().collect(Collectors.groupingBy(KwcContractTradeGoods::getContractId));
+        }
+        List<QueryListResVo> list = getQueryListResVos(queryListResDtos, contractIdGoodsIdKeyAndGoodsMap);
         return PageHelperUtil.getPageResult(new PageInfo<>(list), queryListResDtos, reqVo.getPageSize());
     }
 
@@ -188,7 +203,7 @@ public class KwcContractTradeService {
      * @author: czh
      * @date: 2023/7/18
      */
-    private List<QueryListResVo> getQueryListResVos(List<QueryListResDto> queryListResDtos) {
+    private List<QueryListResVo> getQueryListResVos(List<QueryListResDto> queryListResDtos,Map<Long, List<KwcContractTradeGoods>> contractIdGoodsIdKeyAndGoodsMap ) {
         Map<Long, UserCacheResDto> longUserCacheResDtoMap = new HashMap<>(8);
         List<Long> initiateByList = queryListResDtos.stream().map(QueryListResDto::getInitiateBy).toList();
         if (CollectionUtils.isNotEmpty(initiateByList)) {
@@ -225,7 +240,18 @@ public class KwcContractTradeService {
                     String.valueOf(queryListResDto.getUnloadWay())));
             queryListResVo.setAmount(queryListResDto.getAmount());
             queryListResVo.setPerformedAmount(queryListResDto.getPerformedAmount());
-
+            BigDecimal performedAmountMoney = BigDecimal.ZERO;
+            if(MapUtils.isNotEmpty(contractIdGoodsIdKeyAndGoodsMap)) {
+                List<KwcContractTradeGoods> contractTradeGoods = contractIdGoodsIdKeyAndGoodsMap.get(queryListResDto.getId());
+                if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(contractTradeGoods)){
+                    for (KwcContractTradeGoods goods : contractTradeGoods) {
+                        BigDecimal performedAmount = goods.getPerformedAmount() != null ? goods.getPerformedAmount() : BigDecimal.ZERO;
+                        BigDecimal price = goods.getPrice() != null ? goods.getPrice() : BigDecimal.ZERO;
+                        performedAmountMoney = performedAmountMoney.add(performedAmount.multiply(price));
+                    }
+                }
+            }
+            queryListResVo.setPerformedAmountMoney( performedAmountMoney);
             if(Objects.nonNull(queryListResVo.getEndTime())) {
                 queryListResVo.setEndTime(DateUtils.getStartOfDay(queryListResVo.getEndTime()));
             }
@@ -860,7 +886,7 @@ public class KwcContractTradeService {
             throw new SystemException(HttpStatus.SUCCESS_CODE, "暂无数据,请确认!");
         }
 
-        List<QueryListResVo> list = getQueryListResVos(queryListResDtos);
+        List<QueryListResVo> list = getQueryListResVos(queryListResDtos,null);
         List<TradeListExport> dataList = BeanUtils.copyToList(list, TradeListExport.class);
         ExcelUtil.downData(response, TradeListExport.class, dataList);
     }
@@ -881,7 +907,7 @@ public class KwcContractTradeService {
         if (CollectionUtils.isEmpty(queryListResDtos)) {
             return Collections.emptyList();
         }
-        return getQueryListResVos(queryListResDtos);
+        return getQueryListResVos(queryListResDtos,null);
     }