LAPTOP-FO2T5SIU\35838 hace 5 meses
padre
commit
70aef1caa3

+ 72 - 0
pro-base/src/main/java/com/idea/customerManagement/service/ContractManageService.java

@@ -29,8 +29,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class ContractManageService implements BaseService<ContractManage, ContractManageExample> {
@@ -108,12 +111,81 @@ public class ContractManageService implements BaseService<ContractManage, Contra
     public PageInfo<ContractManageDto> listByModel(Tablepar tablepar, ContractManageDto model, DateTrans dt) {
         PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
         List<ContractManageDto> list = extendMapper.listByModel(model);
+
+        // 拼接买受人名称
+        List<Buyer> buyers = buyerService.selectByExample(new BuyerExample());
+        Map<String, List<Buyer>> buyerMap = buyers.stream().sorted(Comparator.comparingInt(Buyer::getOrderNum))
+                .collect(Collectors.groupingBy(Buyer::getCustomerManagementId));
+        Map<String, String> map = sysDictService.selectDictMap("RELATIONSHIP");
+
+
+        for(ContractManageDto contract : list){
+            contract.setBuyerName(null);
+            if(buyerMap.containsKey(contract.getCustomerManagementId())){
+                StringBuilder builder = new StringBuilder();
+                List<Buyer> buyerInfo = buyerMap.get(contract.getCustomerManagementId());
+                for(Buyer buyer : buyerInfo){
+                    if (StringUtils.isEmpty(buyer.getRelationship())) {
+                        builder.append(buyer.getName()).append(",");
+                    } else {
+                        String dictLabel = "";
+                        if(map.containsKey(buyer.getRelationship())){
+                            dictLabel = map.get(buyer.getRelationship());
+                        }
+                        builder.append(buyer.getName())
+                                .append("(")
+                                .append(dictLabel)
+                                .append(")")
+                                .append(",");
+                    }
+                }
+                if(builder.length() > 0){
+                    builder.deleteCharAt(builder.length()-1);
+                }
+                contract.setBuyerName(builder.toString());
+            }
+        }
         PageInfo<ContractManageDto> pageInfo = new PageInfo<>(list);
         return pageInfo;
     }
 
     public List<ContractManageDto> listAll(ContractManageDto model){
         List<ContractManageDto> list = extendMapper.listByModel(model);
+
+        // 拼接买受人名称
+        List<Buyer> buyers = buyerService.selectByExample(new BuyerExample());
+        Map<String, List<Buyer>> buyerMap = buyers.stream().sorted(Comparator.comparingInt(Buyer::getOrderNum))
+                .collect(Collectors.groupingBy(Buyer::getCustomerManagementId));
+        Map<String, String> map = sysDictService.selectDictMap("RELATIONSHIP");
+
+
+        for(ContractManageDto contract : list){
+            contract.setBuyerName(null);
+            if(buyerMap.containsKey(contract.getCustomerManagementId())){
+                StringBuilder builder = new StringBuilder();
+                List<Buyer> buyerInfo = buyerMap.get(contract.getCustomerManagementId());
+                for(Buyer buyer : buyerInfo){
+                    if (StringUtils.isEmpty(buyer.getRelationship())) {
+                        builder.append(buyer.getName()).append(",");
+                    } else {
+                        String dictLabel = "";
+                        if(map.containsKey(buyer.getRelationship())){
+                            dictLabel = map.get(buyer.getRelationship());
+                        }
+                        builder.append(buyer.getName())
+                                .append("(")
+                                .append(dictLabel)
+                                .append(")")
+                                .append(",");
+                    }
+                }
+                if(builder.length() > 0){
+                    builder.deleteCharAt(builder.length()-1);
+                }
+                contract.setBuyerName(builder.toString());
+            }
+        }
+
         return list;
     }