Просмотр исходного кода

Merge remote-tracking branch 'origin/release-201844-wangcz' into release-201844-wangcz

shenjunjie 7 лет назад
Родитель
Сommit
4cf1db64f7

+ 36 - 7
src/main/java/com/uas/platform/b2b/model/Vendor.java

@@ -24,6 +24,7 @@ import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 import java.io.*;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
@@ -194,13 +195,25 @@ public class Vendor implements Serializable {
      * (针对买家、客户)采购联系人
      */
 	@Transient
-    private Set<String> purchaseContacts = new HashSet<>();
+    private Set<VendorContactMan> buyerContacts = new HashSet<>();
+
+    /**
+     * (针对买家、客户)采购联系人
+     */
+    @Transient
+    private List<String> purchaseContacts = new ArrayList<>();
 
     /**
      * (针对卖家、供应商) 业务对接人
      */
-	@Transient
-    private Set<String> saleContacts = new HashSet<>();
+    @Transient
+    private Set<VendorContactMan> sellerContacts = new HashSet<>();
+
+    /**
+     * (针对卖家、供应商) 业务对接人
+     */
+    @Transient
+    private List<String> saleContacts = new ArrayList<>();
 
     /**
      * 本月应收(前端传入指定月份)
@@ -395,19 +408,35 @@ public class Vendor implements Serializable {
         this.uncheckedCount = uncheckedCount;
     }
 
-    public Set<String> getPurchaseContacts() {
+    public Set<VendorContactMan> getBuyerContacts() {
+        return buyerContacts;
+    }
+
+    public void setBuyerContacts(Set<VendorContactMan> buyerContacts) {
+        this.buyerContacts = buyerContacts;
+    }
+
+    public List<String> getPurchaseContacts() {
         return purchaseContacts;
     }
 
-    public void setPurchaseContacts(Set<String> purchaseContacts) {
+    public void setPurchaseContacts(List<String> purchaseContacts) {
         this.purchaseContacts = purchaseContacts;
     }
 
-    public Set<String> getSaleContacts() {
+    public Set<VendorContactMan> getSellerContacts() {
+        return sellerContacts;
+    }
+
+    public void setSellerContacts(Set<VendorContactMan> sellerContacts) {
+        this.sellerContacts = sellerContacts;
+    }
+
+    public List<String> getSaleContacts() {
         return saleContacts;
     }
 
-    public void setSaleContacts(Set<String> saleContacts) {
+    public void setSaleContacts(List<String> saleContacts) {
         this.saleContacts = saleContacts;
     }
 

+ 77 - 0
src/main/java/com/uas/platform/b2b/model/VendorContactMan.java

@@ -0,0 +1,77 @@
+package com.uas.platform.b2b.model;
+
+/**
+ * 业务联系人
+ *
+ * @author hejq
+ * @date 2018-12-14 15:07
+ */
+public class VendorContactMan {
+
+    /**
+     * 用户UU
+     */
+    private Long userUU;
+
+    /**
+     * 用户姓名
+     */
+    private String name;
+
+    /**
+     * 无参构造
+     */
+    public VendorContactMan() {
+    }
+
+    /**
+     * 通过UU和姓名生成联系人
+     *
+     * @param userUU 用户UU
+     * @param userName 姓名
+     */
+    public VendorContactMan(Long userUU, String userName) {
+        this.userUU = userUU;
+        this.name = userName;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        VendorContactMan that = (VendorContactMan) o;
+
+        if (userUU != null ? !userUU.equals(that.userUU) : that.userUU != null) {
+            return false;
+        }
+        return name != null ? name.equals(that.name) : that.name == null;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = userUU != null ? userUU.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        return result;
+    }
+}

+ 10 - 7
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -21,6 +21,7 @@ import com.uas.platform.b2b.model.User;
 import com.uas.platform.b2b.model.UserBaseInfo;
 import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.model.VendorContact;
+import com.uas.platform.b2b.model.VendorContactMan;
 import com.uas.platform.b2b.model.VendorDistribute;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.service.UserService;
@@ -31,7 +32,6 @@ import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
-import com.uas.ps.core.page.exception.IllegalOperatorException;
 import com.uas.search.b2b.model.MultiValue;
 import com.uas.search.b2b.model.SPage;
 import com.uas.search.b2b.model.Sort;
@@ -54,6 +54,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * 供应商
@@ -448,17 +449,18 @@ public class VendorsServiceImpl implements VendorService {
         distributeListCopy.addAll(distributeList);
         if (!CollectionUtil.isEmpty(vendorList)) {
             vendorList.forEach(vendor -> {
-                Set<String> contacts = new HashSet<>();
+                Set<VendorContactMan> contacts = new HashSet<>();
                 // 使用后移除,减少后面循环次数
                 Iterator<Distribute> iterator = distributeListCopy.iterator();
                 while (iterator.hasNext()) {
                     Distribute distribute = iterator.next();
                     if (Objects.equals(vendor.getId(), distribute.getVendorId())) {
-                        contacts.add(distribute.getUser().getUserName());
+                        contacts.add(new VendorContactMan(distribute.getUserUU(), distribute.getUser().getUserName()));
                         iterator.remove();
                     }
                 }
-                vendor.setPurchaseContacts(contacts);
+                List<String> contactMans = contacts.stream().map(VendorContactMan::getName).collect(Collectors.toList());
+                vendor.setPurchaseContacts(contactMans);
             });
         }
     }
@@ -499,7 +501,7 @@ public class VendorsServiceImpl implements VendorService {
         distributeListCopy.addAll(distributeList);
         if (!CollectionUtil.isEmpty(vendorList)) {
             vendorList.forEach(vendor -> {
-                Set<String> contacts = new HashSet<>();
+                Set<VendorContactMan> contacts = new HashSet<>();
                 // 使用后移除,减少后面循环次数
                 Iterator<VendorDistribute> iterator = distributeListCopy.iterator();
                 while (iterator.hasNext()) {
@@ -507,11 +509,12 @@ public class VendorsServiceImpl implements VendorService {
                     boolean existContacts = Objects.equals(vendor.getId(), distribute.getVendorId())
                         && (1 == distribute.getIsTransfer() || 1 == distribute.getDistribute());
                     if (existContacts) {
-                        contacts.add(distribute.getUser().getUserName());
+                        contacts.add(new VendorContactMan(distribute.getUserUU(), distribute.getUser().getUserName()));
                         iterator.remove();
                     }
                 }
-                vendor.setSaleContacts(contacts);
+                List<String> contactMans = contacts.stream().map(VendorContactMan::getName).collect(Collectors.toList());
+                vendor.setSaleContacts(contactMans);
             });
         }
     }