فهرست منبع

更新邀请注册物料数据统计方式

hejq 7 سال پیش
والد
کامیت
242d8756c4

+ 10 - 7
pom.xml

@@ -223,7 +223,12 @@
 			<artifactId>jxls-core</artifactId>
 			<version>1.0.4</version>
 		</dependency>
-	</dependencies>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.9.0</version>
+        </dependency>
+    </dependencies>
 	<build>
 		<finalName>b2bManage</finalName>
 		<plugins>
@@ -240,12 +245,10 @@
 					</execution>
 				</executions>
 				<configuration>
-					<configuration>
-						<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
-						<items>
-							<item>timestamp</item>
-						</items>
-					</configuration>
+					<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
+					<items>
+						<item>timestamp</item>
+					</items>
 				</configuration>
 			</plugin>
 			<plugin>

+ 20 - 0
src/main/java/com/uas/platform/b2bManage/config/RestTemplateConfig.java

@@ -0,0 +1,20 @@
+package com.uas.platform.b2bManage.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * RestTemplate配置bean
+ * @author suntg
+ * @create 2017/2/15
+ * @version 2017年8月2日16:07:06 suntg 修改文件类名
+ */
+@Configuration
+public class RestTemplateConfig {
+
+    @Bean
+    public RestTemplate restTemplate() {
+        return new RestTemplate();
+    }
+}

+ 14 - 4
src/main/java/com/uas/platform/b2bManage/model/Invite.java

@@ -13,7 +13,7 @@ import java.util.Date;
  */
 @Entity
 @Table(name = "v_invites")
-public class Invite implements Serializable {
+public class Invite extends KeyEntity implements Serializable {
 
     /**
      * 序列号
@@ -85,7 +85,7 @@ public class Invite implements Serializable {
      * 上传物料统计
      */
     @Transient
-    private Integer productCount;
+    private Long productCount;
 
     /**
      * 最近一次物料上传时间
@@ -173,11 +173,11 @@ public class Invite implements Serializable {
         this.inviteUserTel = inviteUserTel;
     }
 
-    public Integer getProductCount() {
+    public Long getProductCount() {
         return productCount;
     }
 
-    public void setProductCount(Integer productCount) {
+    public void setProductCount(Long productCount) {
         this.productCount = productCount;
     }
 
@@ -188,4 +188,14 @@ public class Invite implements Serializable {
     public void setLastProductDate(Date lastProductDate) {
         this.lastProductDate = lastProductDate;
     }
+
+    /**
+     * 主键值
+     *
+     * @return
+     */
+    @Override
+    public Object getKey() {
+        return this.uu;
+    }
 }

+ 53 - 0
src/main/java/com/uas/platform/b2bManage/model/InviteProdInfo.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2bManage.model;
+
+import java.util.Date;
+
+/**
+ * 邀请注册信息获取到的企业物料数据
+ * <pre>
+ *   关于物料信息相关查询统一移到物料服务
+ * </pre>
+ * @author hejq
+ * @date 2018-08-20 14:48
+ */
+public class InviteProdInfo {
+
+    /**
+     * 企业UU号
+     */
+    private Long enUU;
+
+    /**
+     * 企业上传物料数
+     */
+    private Long count;
+
+    /**
+     * 最近一次上传时间
+     */
+    private Date lastDate;
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getCount() {
+        return count;
+    }
+
+    public void setCount(Long count) {
+        this.count = count;
+    }
+
+    public Date getLastDate() {
+        return lastDate;
+    }
+
+    public void setLastDate(Date lastDate) {
+        this.lastDate = lastDate;
+    }
+}

+ 21 - 0
src/main/java/com/uas/platform/b2bManage/model/KeyEntity.java

@@ -0,0 +1,21 @@
+package com.uas.platform.b2bManage.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * 获取关键字
+ *
+ * @author hejq
+ * @date 2018-07-19 10:53
+ */
+public abstract class KeyEntity {
+
+    /**
+     * 主键值
+     *
+     * @return
+     */
+    @JsonIgnore
+    public abstract Object getKey();
+
+}

+ 21 - 0
src/main/java/com/uas/platform/b2bManage/service/ProductService.java

@@ -0,0 +1,21 @@
+package com.uas.platform.b2bManage.service;
+
+import com.uas.platform.b2bManage.model.InviteProdInfo;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hejq
+ * @date 2018-08-20 15:55
+ */
+public interface ProductService {
+
+    /**
+     * 通过企业UU号查询企业注册物料信息
+     *
+     * @param enUUList 企业UU
+     * @return List InviteProdInfo
+     */
+    Map<Long, InviteProdInfo> findByEnUUList(List<Long> enUUList);
+}

+ 10 - 14
src/main/java/com/uas/platform/b2bManage/service/impl/InviteServiceImpl.java

@@ -8,10 +8,8 @@ import com.uas.platform.b2bManage.dao.UserBaseInfoDao;
 import com.uas.platform.b2bManage.model.*;
 import com.uas.platform.b2bManage.page.exception.IllegalOperatorException;
 import com.uas.platform.b2bManage.service.InviteService;
-import com.uas.platform.b2bManage.support.MyException;
-import com.uas.platform.b2bManage.support.MyThread;
-import com.uas.platform.b2bManage.support.MyThreadPoolExecutor;
-import com.uas.platform.b2bManage.support.StringUtil;
+import com.uas.platform.b2bManage.service.ProductService;
+import com.uas.platform.b2bManage.support.*;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.Status;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
@@ -34,6 +32,7 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.*;
 
 
@@ -58,6 +57,9 @@ public class InviteServiceImpl extends BaseService implements InviteService {
     @Autowired
     private InvitationRecordDao recordDao;
 
+    @Autowired
+    private ProductService productService;
+
     /**
      * 通过分页信息获取邀请注册记录
      *
@@ -103,17 +105,11 @@ public class InviteServiceImpl extends BaseService implements InviteService {
                 return null;
             }
         }, info);
+        Map<Long, InviteProdInfo> map = productService.findByEnUUList(CollectionUtil.getKeyCollection(invites.getContent()));
         for (Invite invite : invites) {
-            Integer count = jdbcTemplate.queryForInt("select count(1) from products where pr_enuu = ?", invite.getUu());
-            invite.setProductCount(count);
-            if (count >= 0) {
-                Date date = jdbcTemplate.queryForObject("select max(pr_erpdate) from products where pr_enuu = " + invite.getUu(), Date.class);
-                invite.setLastProductDate(date);
-            }
-            if (null == invite.getLastProductDate()) {
-                Date date = jdbcTemplate.queryForObject("select max(pr_create_time) from products where pr_enuu = " + invite.getUu(), Date.class);
-                invite.setLastProductDate(date);
-            }
+            InviteProdInfo prodInfo = map.get(invite.getUu());
+            invite.setProductCount(prodInfo.getCount());
+            invite.setLastProductDate(prodInfo.getLastDate());
         }
         return invites;
     }

+ 57 - 0
src/main/java/com/uas/platform/b2bManage/service/impl/ProductServiceImpl.java

@@ -0,0 +1,57 @@
+package com.uas.platform.b2bManage.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.platform.b2bManage.model.InviteProdInfo;
+import com.uas.platform.b2bManage.service.ProductService;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import org.apache.commons.collections.map.HashedMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hejq
+ * @date 2018-08-20 15:56
+ */
+@Service
+public class ProductServiceImpl implements ProductService {
+
+    private final RestTemplate restTemplate;
+
+    @Autowired
+    public ProductServiceImpl(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
+    /**
+     * 公共物料访问接口
+     */
+    private final String PRODUCT_URL = "https://api-product.usoftmall.com/";
+
+    /**
+     * 通过企业UU号查询企业注册物料信息
+     *
+     * @param enUUList 企业UU
+     * @return List InviteProdInfo
+     */
+    @Override
+    public Map<Long, InviteProdInfo> findByEnUUList(List<Long> enUUList) {
+        Map<String, String> map = new HashedMap();
+        map.put("enUUList", FlexJsonUtils.toJsonDeep(enUUList));
+        try {
+            String str = restTemplate.getForObject(PRODUCT_URL + "product/get/getCountAndTime?enUUList={enUUList}", String.class, map);
+            List<InviteProdInfo> infoList = JSON.parseArray(str, InviteProdInfo.class);
+            Map<Long, InviteProdInfo> resultMap = new HashedMap();
+            for (InviteProdInfo info : infoList) {
+                resultMap.put(info.getEnUU(), info);
+            }
+            return resultMap;
+        } catch (RuntimeException e) {
+
+        }
+        return null;
+    }
+}

+ 35 - 0
src/main/java/com/uas/platform/b2bManage/support/CollectionUtil.java

@@ -0,0 +1,35 @@
+package com.uas.platform.b2bManage.support;
+
+import com.uas.platform.b2bManage.model.KeyEntity;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+
+/**
+ * 集合处理工具类
+ *
+ * @author hejq
+ * @date 2018-07-19 11:03
+ */
+public class CollectionUtil {
+
+    /**
+     * 用继承自KeyEntity的类,重写的getKey方法来取值,封装成List一次性查询数据
+     *
+     * @param paramArray
+     * @return
+     */
+    public static List<Long> getKeyCollection(Collection<? extends KeyEntity> paramArray) {
+        List<Long> idList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(paramArray)) {
+            for (KeyEntity param : paramArray) {
+                Object val = param.getKey();
+                if (val != null) {
+                    idList.add(Long.valueOf(val.toString()));
+                }
+            }
+        }
+        return idList;
+    }
+
+}