Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/uas/ps/inquiry/service/impl/InquiryServiceImpl.java
scr 7 years ago
parent
commit
10cf943cb6

+ 28 - 0
src/main/java/com/uas/ps/inquiry/AccessConfiguration.java

@@ -29,6 +29,34 @@ public class AccessConfiguration {
     @Value("${mall.url}")
     private String mallUrl;
 
+    /**
+     * 短信推送人UU
+     */
+    @Value("${message.senderuu}")
+    private Long senderuu;
+
+    /**
+     * 短信推送人企业uU
+     */
+    @Value("${message.senderEnuu}")
+    private Long senderEnuu;
+
+    public Long getSenderuu() {
+        return senderuu;
+    }
+
+    public void setSenderuu(Long senderuu) {
+        this.senderuu = senderuu;
+    }
+
+    public Long getSenderEnuu() {
+        return senderEnuu;
+    }
+
+    public void setSenderEnuu(Long senderEnuu) {
+        this.senderEnuu = senderEnuu;
+    }
+
     public String getMallUrl() {
         return mallUrl;
     }

+ 48 - 31
src/main/java/com/uas/ps/inquiry/controller/PublicInquiryController.java

@@ -21,11 +21,13 @@ import com.uas.ps.inquiry.service.AttachService;
 import com.uas.ps.inquiry.service.InquiryForSaleService;
 import com.uas.ps.inquiry.service.PublicInquiryService;
 import com.uas.ps.inquiry.support.InquiryBufferedLogger;
+
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.rmi.AccessException;
 import java.util.List;
 import java.util.Map;
+
 import javassist.NotFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -40,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 公共询价接口路径
- *
+ * <p>
  * Created by hejq on 2018-01-13.
  */
 @RestController
@@ -61,8 +63,8 @@ public class PublicInquiryController {
     /**
      * 将买家ERP的公共询价写到公共询价服务中心
      *
-     * @param data 封装的data
-     * @param enuu 询价企业UU
+     * @param data    封装的data
+     * @param enuu    询价企业UU
      * @param address 询价企业地址信息
      * @return
      * @throws UnsupportedEncodingException
@@ -96,9 +98,9 @@ public class PublicInquiryController {
     /**
      * (针对客户)获取公共询价服务中心供应商的报价信息
      *
+     * @param enuu 询价企业UU
      * @author hejq
      * @date 2018-01-14 15:20
-     * @param enuu 询价企业UU
      */
     @HttpLog
     @RequestMapping(value = "/quotation", method = RequestMethod.GET)
@@ -172,12 +174,12 @@ public class PublicInquiryController {
     /**
      * 将客户的公共询价列表中一条数据转成询价报价单数据
      *
-     * @author hejq
-     * @date 2018-01-14 15:20
-     * @param id 公共询价明细id
-     * @param enuu 报价企业UU
+     * @param id     公共询价明细id
+     * @param enuu   报价企业UU
      * @param useruu 报价个人UU
      * @return
+     * @author hejq
+     * @date 2018-01-14 15:20
      */
     @HttpLog
     @RequestMapping(value = "/turntoInquiry", method = RequestMethod.POST)
@@ -188,11 +190,11 @@ public class PublicInquiryController {
     /**
      * 通过分页参数和过滤条件查询公共询价列表信息
      *
-     * @author hejq
-     * @date 2018-01-17 10:27
-     * @param pageInfo 分页参数
+     * @param pageInfo     分页参数
      * @param searchFilter 过滤条件
      * @return
+     * @author hejq
+     * @date 2018-01-17 10:27
      */
     @HttpLog
     @RequestMapping(method = RequestMethod.GET)
@@ -213,7 +215,7 @@ public class PublicInquiryController {
     /**
      * 针对商城,查询已发布的公共询价信息
      *
-     * @param pageInfo 分页信息
+     * @param pageInfo     分页信息
      * @param searchFilter 过滤条件
      * @return
      */
@@ -238,20 +240,20 @@ public class PublicInquiryController {
     /**
      * 移动端查询公共询价列表信息
      *
-     * @param page 页码
-     * @param size 每页大小
-     * @param en_uu 企业UU
-     * @param _state 过滤状态
-     * @param keyword 搜索词
+     * @param page     页码
+     * @param size     每页大小
+     * @param en_uu    企业UU
+     * @param _state   过滤状态
+     * @param keyword  搜索词
      * @param user_tel 电话
      * @param fromDate 开始日期
-     * @param endDate 截止日期
+     * @param endDate  截止日期
      * @return
      */
     @HttpLog
     @RequestMapping(value = "/mobile", method = RequestMethod.GET)
     public ModelMap publincInquiry(Integer page, Integer size, Long en_uu, String _state,
-                                                    String keyword, String user_tel, Long fromDate, Long endDate) {
+                                   String keyword, String user_tel, Long fromDate, Long endDate) {
         ModelMap map = new ModelMap();
         PageInfo pageInfo = new PageInfo();
         if (page == null || page == 0) {
@@ -301,20 +303,20 @@ public class PublicInquiryController {
     /**
      * 移动端查询公共询价列表信息
      *
-     * @param page 页码
-     * @param size 每页大小
-     * @param en_uu 企业UU
-     * @param _state 过滤状态
-     * @param keyword 搜索词
+     * @param page     页码
+     * @param size     每页大小
+     * @param en_uu    企业UU
+     * @param _state   过滤状态
+     * @param keyword  搜索词
      * @param user_tel 电话
      * @param fromDate 开始日期
-     * @param endDate 截止日期
+     * @param endDate  截止日期
      * @return
      */
     @HttpLog
     @RequestMapping(value = "/mobile/v2", method = RequestMethod.GET)
     public ModelMap publicInquiry(Integer page, Integer size, Long en_uu, String _state,
-                                   String keyword, String user_tel, Long fromDate, Long endDate) {
+                                  String keyword, String user_tel, Long fromDate, Long endDate) {
         ModelMap map = new ModelMap();
         PageInfo pageInfo = new PageInfo();
         if (page == null || page == 0) {
@@ -363,12 +365,12 @@ public class PublicInquiryController {
 
     /**
      * 通过分页信息和过滤条件查询已转报价的信息
-     * 
-     * @author hejq
-     * @date 2018-01-18 15:36
+     *
      * @param pageInfo 分页参数
-     * @param filter 过滤条件
+     * @param filter   过滤条件
      * @return
+     * @author hejq
+     * @date 2018-01-18 15:36
      */
     @HttpLog
     @RequestMapping(value = "/quotation/list", method = RequestMethod.GET)
@@ -395,6 +397,7 @@ public class PublicInquiryController {
 
     /**
      * 通过id查询单个已转报价的信息
+     *
      * @param id
      * @return
      */
@@ -409,6 +412,7 @@ public class PublicInquiryController {
 
     /**
      * 商城获取采纳列表
+     *
      * @param pageInfo
      * @param filter
      * @param _state
@@ -470,6 +474,7 @@ public class PublicInquiryController {
 
     /**
      * 商城-采购排行榜
+     *
      * @return
      */
     @HttpLog
@@ -482,7 +487,7 @@ public class PublicInquiryController {
      * 通过明细id查询该条询价的详情
      *
      * @param itemId 明细id
-     * @param enuu enuu
+     * @param enuu   enuu
      * @return
      */
     @HttpLog
@@ -494,10 +499,22 @@ public class PublicInquiryController {
 
     /**
      * 公共询价单明细总数
+     *
      * @return
      */
     @RequestMapping(value = "/getPurcInquiryItemCount", method = RequestMethod.GET)
     public ModelMap getPurcInquiryItemCount() {
         return publicInquiryService.getPurcInquiryItemCount();
     }
+
+    /**
+     * 公共询价单明细某年某月总数
+     *
+     * @param month
+     * @return
+     */
+    @RequestMapping(value = "/getPurcInquiryItemCountByMonth", method = RequestMethod.GET)
+    public ModelMap getPurcInquiryItemCountByMonth(Integer year, Integer month) {
+        return publicInquiryService.countByMonth(year, month);
+    }
 }

+ 38 - 1
src/main/java/com/uas/ps/inquiry/dao/InquiryRemindDao.java

@@ -9,6 +9,7 @@ import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 import javax.transaction.Transactional;
+import java.math.BigInteger;
 import java.util.List;
 
 /**
@@ -44,7 +45,43 @@ public interface InquiryRemindDao extends JpaRepository<InquiryRemind, Long>, Jp
      * @param vendUserUU 推荐的企业UU
      * @param vendUU 个人UU
      * @param itemId 来源id
-     * @return
      */
     List<InquiryRemind> findByVendUserUUAndVendUUAndItemId(Long vendUserUU, Long vendUU, Long itemId);
+
+    /**
+     * 查出昨晚17点到今早九点的询价信息
+     * @param venduseruu
+     * @param venduu
+     */
+    @Query(value = "select * from purc$inquiry$remind where ir_date > date_add(now(),interval -16 HOUR) and ir_date < now() and ir_venduseruu =?1 and ir_venduu = ?2 and ir_enuu != ir_venduu",nativeQuery = true)
+    List<InquiryRemind> findInquiryRemind(BigInteger venduseruu,BigInteger venduu);
+
+    /**
+     * 查出今早9点到14点的询价信息
+     * @param venduseruu
+     * @param venduu
+     */
+    @Query(value = "select * from purc$inquiry$remind where ir_date > date_add(now(),interval -5 hour) and ir_date < now() and ir_venduseruu =?1 and ir_venduu = ?2  and ir_enuu != ir_venduu ",nativeQuery = true)
+    List<InquiryRemind> findInquiryRemind1(BigInteger venduseruu,BigInteger venduu);
+
+    /**
+     * 查出14点到17点的询价信息
+     * @param venduseruu
+     * @param venduu
+     */
+    @Query(value = "select * from purc$inquiry$remind where ir_date > date_add(now(),interval -3 hour) and ir_date < now() and ir_venduseruu =?1 and ir_venduu = ?2 and ir_enuu != ir_venduu",nativeQuery = true)
+    List<InquiryRemind> findInquiryRemind2(BigInteger venduseruu,BigInteger venduu);
+
+    /**
+     * 找到询价推荐表中所有的用户
+     */
+    @Query(value = "select ir_venduseruu from purc$inquiry$remind group by ir_venduseruu",nativeQuery = true)
+    List<BigInteger> findvenduseruu();
+
+    /**
+     * 找到询价推荐表中的所有公司
+     */
+    @Query(value = "select ir_venduu from purc$inquiry$remind group by ir_venduu",nativeQuery = true)
+    List<BigInteger> findvenduu();
+
 }

+ 11 - 1
src/main/java/com/uas/ps/inquiry/dao/PurcInquiryItemInfoDao.java

@@ -3,15 +3,25 @@ package com.uas.ps.inquiry.dao;
 import com.uas.ps.inquiry.model.PurcInquiryItemInfo;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 
 /**
  * 询价明细数据库操作
- *  <pre>
+ * <pre>
  *      明细带出主表信息,列表查询使用
  *  </pre>
  * Created by hejq on 2018-01-17.
  */
 @Repository
 public interface PurcInquiryItemInfoDao extends JpaSpecificationExecutor<PurcInquiryItemInfo>, JpaRepository<PurcInquiryItemInfo, Long> {
+
+    /**
+     * 查询某年某月的询价明细总数
+     *
+     * @param month
+     * @return
+     */
+    @Query(value = "select count(*) from purc$puinquiryitems where year(id_date)=?1 and month(id_date) = ?2", nativeQuery = true)
+    Long countByMonth(Integer year, Integer month);
 }

+ 46 - 31
src/main/java/com/uas/ps/inquiry/service/PublicInquiryService.java

@@ -5,15 +5,17 @@ import com.uas.ps.inquiry.entity.*;
 import com.uas.ps.inquiry.model.*;
 import com.uas.ps.inquiry.page.PageInfo;
 import com.uas.ps.inquiry.page.SearchFilter;
+
 import java.util.List;
 import java.util.Map;
+
 import javassist.NotFoundException;
 import org.springframework.data.domain.Page;
 import org.springframework.ui.ModelMap;
 
 /**
  * 公共询价接口
- *
+ * <p>
  * Created by hejq on 2018-01-13.
  */
 public interface PublicInquiryService {
@@ -21,32 +23,32 @@ public interface PublicInquiryService {
     /**
      * 保存公共询价信息
      *
+     * @param inquiries erp传入公共询价的信息
+     * @param enuu      询价企业UU号
+     * @param address   询价企业地址
      * @author hejq
      * @date 2018-01-14 11:45
-     * @param inquiries erp传入公共询价的信息
-     * @param enuu 询价企业UU号
-     * @param address 询价企业地址
      */
     void save(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException;
 
     /**
      * 将ERP传入的inquiry信息转成公共询价服务中心需要的信息
      *
-     * @author hejq
-     * @date 2018-01-14 11:45
      * @param inquiries 将ERP传入的inquiry信息
-     * @param enuu 询价企业UU号
+     * @param enuu      询价企业UU号
      * @return
+     * @author hejq
+     * @date 2018-01-14 11:45
      */
     List<PurcInquiry> covert(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException;
 
     /**
      * erp提交审核时,公共询价服务中心单据禁用报价功能
      *
+     * @param inquiries erp询价信息
+     * @param enuu      询价企业UU号
      * @author hejq
      * @date 2018-01-14 11:45
-     * @param inquiries erp询价信息
-     * @param enuu 询价企业UU号
      */
     void updateStatus(List<BatchInquiry> inquiries, Long enuu);
 
@@ -54,9 +56,9 @@ public interface PublicInquiryService {
      * 查询供应商的报价信息
      *
      * @param enuu 企业uu
+     * @return
      * @author hejq
      * @date 2018-01-14 11:45
-     * @return
      */
     List<InquiryDetail> findNotUploadReply(Long enuu);
 
@@ -64,9 +66,9 @@ public interface PublicInquiryService {
      * 将平台的公共询价转成ERP的对应的字段
      *
      * @param notUploadReply 未下载的供应商报价信息
+     * @return
      * @author hejq
      * @date 2018-01-14 11:51
-     * @return
      */
     List<InquiryDetail> convertPublicInquiryReply(List<PublicInquiryItem> notUploadReply);
 
@@ -82,65 +84,66 @@ public interface PublicInquiryService {
     /**
      * ERP提交公共询价单之后,更新平台状态,让公共询价服务中心询价单不能进行报价操作
      *
+     * @param inquiries 询价信息
      * @author hejq
      * @date 2018-01-14 12:20
-     * @param inquiries 询价信息
      */
     void updateInquiryStatus(List<InquiryDetail> inquiries, Long enuu);
 
     /**
      * ERP对报价信息的采纳状态上传到公共询价服务中心
      *
+     * @param decides 采纳信息
      * @author hejq
      * @date 2018-01-14 12:24
-     * @param decides 采纳信息
      */
     void onReplyDecide(List<InquiryDecide> decides, Long enuu);
 
     /**
      * 将ERP的报价采纳信息转为公共询价服务中心需要的信息
-     * 
+     *
+     * @param decides erp报价采纳信息
      * @author hejq
      * @date 2018-01-14 12:26
-     * @param decides erp报价采纳信息
      */
     List<PublicInquiryItem> convertInquiryDecide(List<InquiryDecide> decides);
 
     /**
      * 买家ERP作废询价单后,修改公共询价服务中心里面的状态
      *
+     * @param inquiries 询价信息
+     * @param enuu      企业UU
      * @author hejq
      * @date 2018-01-14 12:28
-     * @param inquiries 询价信息
-     * @param enuu 企业UU
      */
     void onReplyInvalid(List<Inquiry> inquiries, Long enuu);
 
     /**
      * 将公共询价列表转成需要报价的询价单,类型是公共询价
      *
-     * @author hejq
-     * @date 2018-01-14 14:46
-     * @param id 询价明细id
-     * @param enuu 报价企业UU
+     * @param id     询价明细id
+     * @param enuu   报价企业UU
      * @param useruu 报价人uu
      * @return
+     * @author hejq
+     * @date 2018-01-14 14:46
      */
     ModelMap transtoInquiry(Long id, Long enuu, Long useruu);
 
     /**
      * 通过分页参数和过滤条件查询报价信息
      *
-     * @author hejq
-     * @date 2018-01-17 10:30
-     * @param info 分页参数
+     * @param info   分页参数
      * @param filter 过滤条件
      * @return
+     * @author hejq
+     * @date 2018-01-17 10:30
      */
     IPage<PublicInquiryItemInfo> findByPageInfo(PageInfo info, SearchFilter filter);
 
     /**
      * 通过id查询单个已转报价的信息
+     *
      * @param id
      * @return
      */
@@ -148,6 +151,7 @@ public interface PublicInquiryService {
 
     /**
      * 商城获取采纳列表
+     *
      * @param info
      * @param filter
      * @return
@@ -156,11 +160,12 @@ public interface PublicInquiryService {
 
     /**
      * 通过分页参数和过滤条件查询公共询价价信息
-     * @author hejq
-     * @date 2018-01-18 15:32
+     *
      * @param info
      * @param filter
      * @return
+     * @author hejq
+     * @date 2018-01-18 15:32
      */
     IPage<PurcInquiryItemInfo> findTodoByPageInfo(PageInfo info, SearchFilter filter);
 
@@ -168,7 +173,7 @@ public interface PublicInquiryService {
      * 根据传入条件封装查询条件
      *
      * @param pageInfo 分页参数
-     * @param state 过滤条件
+     * @param state    过滤条件
      * @return
      */
     PageInfo covert(PageInfo pageInfo, String state, Short overdue);
@@ -186,7 +191,7 @@ public interface PublicInquiryService {
      * 消息推送
      *
      * @param inquiryItems 询价明细
-     * @param sourceApp 应用来源
+     * @param sourceApp    应用来源
      * @throws Exception
      */
     void notifyMessage(List<PurcInquiryItem> inquiryItems, String sourceApp) throws Exception;
@@ -194,7 +199,7 @@ public interface PublicInquiryService {
     /**
      * 针对供应商,客户对报价采纳结果进行消息通知
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 来源
      */
     void notifyDecide(PublicInquiryItem item, String sourceApp);
@@ -209,6 +214,7 @@ public interface PublicInquiryService {
 
     /**
      * 商城-采购排行榜
+     *
      * @return
      */
     List<Map<String, Object>> findCodeRankingList();
@@ -232,7 +238,7 @@ public interface PublicInquiryService {
     /**
      * 消息推送
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 应用来源
      * @return
      */
@@ -241,7 +247,7 @@ public interface PublicInquiryService {
     /**
      * 消息推送
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 应用来源
      * @return
      */
@@ -258,8 +264,17 @@ public interface PublicInquiryService {
 
     /**
      * 公共询价单明细总数
+     *
      * @return
      */
     ModelMap getPurcInquiryItemCount();
+
+    /**
+     * 查询某年某月的询价明细总数
+     *
+     * @param month
+     * @return
+     */
+    ModelMap countByMonth(Integer year, Integer month);
 }
 

+ 147 - 22
src/main/java/com/uas/ps/inquiry/service/impl/InquiryServiceImpl.java

@@ -5,7 +5,6 @@ import com.uas.ps.core.logging.BufferedLoggerManager;
 import com.uas.ps.core.util.CollectionUtils;
 import com.uas.ps.core.util.ContextUtils;
 import com.uas.ps.entity.Product;
-import com.uas.ps.entity.ProductUsers;
 import com.uas.ps.entity.Status;
 import com.uas.ps.inquiry.AccessConfiguration;
 import com.uas.ps.inquiry.dao.*;
@@ -21,6 +20,7 @@ import com.uas.ps.inquiry.page.exception.IllegalOperatorException;
 import com.uas.ps.inquiry.service.InquiryService;
 import com.uas.ps.inquiry.service.PublicInquiryService;
 
+import java.math.BigInteger;
 import java.util.*;
 import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
@@ -35,6 +35,7 @@ import javassist.NotFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.jpa.domain.Specification;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -49,15 +50,71 @@ import org.springframework.util.StringUtils;
 public class InquiryServiceImpl implements InquiryService {
 
     /**
-     * 公共物料访问地址
+     * 消息类型 (在B2B消息中拼接跳转单据详情url请求时需要)
      */
-    private final String PS_PRODUCT_URL = ContextUtils.getBean(AccessConfiguration.class).getPsProductUrl();
+    private final String INQUIRY_TYPE = "公共询价";
+
+    /**
+     * 应用来源
+     */
+    private final String SOURCERAPP = "MALL";
+
+    /**
+     * 消息类型,公共询价的采纳结果
+     */
+    private final String INQUIRY_DECIDE_TYPE = "公共询价采纳结果";
+
+    /**
+     * 询价种类
+     */
+    private final String INQUIRYKIND = "publicInquiry";
+
+
+    /**
+     * 消息推送短信模板id
+     */
+    private final String SMS_TEMP_ID = "e6320a3c-89ac-4c77-a75f-62a727bce654";
+
+    /**
+     * 消息推送方式:邮件、短信、im
+     */
+    private final String SMS_TYPE = "MAIL_AND_SM_AND_IM";
 
     /**
      * 来源应用,ERP
      */
     private final String PRODUCERAPP = "ERP";
 
+    /**
+     * 消费类型: 多个,MULTI
+     */
+    private final String CUST_TYPE = "MULTI";
+
+    /**
+     * 接收应用
+     */
+    private final String CONSUMERAPP = "HIDE";
+
+    /**
+     * 消息类型 (在MALL消息中拼接求购询价待报价)
+     */
+    private final String INQUIRY_TYPE_SELLER_MALL = "MALL跳转卖家待报价页面";
+
+    /**
+     * 公共消息访问地址
+     */
+    private final String PS_MESSAGE_URL = ContextUtils.getBean(AccessConfiguration.class).getPsMessageUrl();
+
+    /**
+     * 询价统计通知发送人UU
+     */
+    private final Long MESSAGE_SENDERUU = ContextUtils.getBean(AccessConfiguration.class).getSenderuu();
+
+    /**
+     * 询价统计通知发送企业UU
+     */
+     private final Long MESSAGE_SENDERENUU = ContextUtils.getBean(AccessConfiguration.class).getSenderEnuu();
+
     @Autowired
     private PublicInquiryItemDao itemDao;
 
@@ -88,6 +145,10 @@ public class InquiryServiceImpl implements InquiryService {
     @Autowired
     private EnterpriseDao enterpriseDao;
 
+    @Autowired
+    private PublicInquiryServiceImpl service;
+
+
     /**
      * 公共物料访问地址
      */
@@ -98,11 +159,6 @@ public class InquiryServiceImpl implements InquiryService {
      */
     private final static InquiryBufferedLogger logger = BufferedLoggerManager.getLogger(InquiryBufferedLogger.class);
 
-    /**
-     * 日志
-     */
-    private final static InquiryBufferedLogger logger = BufferedLoggerManager.getLogger(InquiryBufferedLogger.class);
-
     /**
      * 查询公共询价列表信息
      *
@@ -222,7 +278,7 @@ public class InquiryServiceImpl implements InquiryService {
                 }
                 //保存询价单明细表
                 items = purcInquiryItemDao.save(items);
-                // 询价单转报价
+
                 final List<PurcInquiryItem> purcInquiryItems = items;
                 final String sourceapp = inquiry.getSourceapp();
                 final Long enuu = inquiry.getEnUU();
@@ -231,6 +287,7 @@ public class InquiryServiceImpl implements InquiryService {
                         @Override
                         public void run() {
                             try {
+                                //生成推荐询价表
                                 inquiryService.notifyMessage(purcInquiryItems, sourceapp);
                                 if (!StringUtils.isEmpty(enuu)) {
                                     saveProduct(purcInquiryItems, sourceapp);
@@ -251,36 +308,103 @@ public class InquiryServiceImpl implements InquiryService {
      */
     @Scheduled(cron = "0 0 9 * * ?" )
     private void sendMessage() throws Exception {
-        //找到所有还未短信通知的询价单
-        List<PurcInquiry> inquiries = purcInquiryDao.findByHassend(0);
-        //询价明细
-        List<PurcInquiryItem> items = new ArrayList<PurcInquiryItem>();
-
-        for(PurcInquiry currentInquiry : inquiries) {
-            final String sourceapp = currentInquiry.getSourceapp();
-            //获取某条询价单的询价明细
-            if (!CollectionUtils.isEmpty(currentInquiry.getInquiryItems())) {
-                for (PurcInquiryItem item : currentInquiry.getInquiryItems()) {
-                    items.add(item);
-                    inquiryService.notifyMessage(items,sourceapp);
+
+            List<BigInteger> list1 = inquiryRemindDao.findvenduseruu();
+            //找到询价推荐表中的所有公司
+            List<BigInteger> list2 = inquiryRemindDao.findvenduu();
+            for(BigInteger vendUserUU : list1){
+                for(BigInteger enuu : list2){
+                    //查出昨晚17点到今早九点的询价信息
+                    List<InquiryRemind> reminds = inquiryRemindDao.findInquiryRemind(vendUserUU,enuu);
+                    if(!CollectionUtils.isEmpty(reminds)){
+                            sendMessage(reminds.size(),reminds);
+                    }
                 }
             }
-        }
+    }
+
+
+    /**
+     * 发送消息推送
+     *
+     */
+    private void sendMessage(final Integer count, final List<InquiryRemind> reminds) {
+        ThreadUtils.task(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    List<MessageModel> models = new ArrayList<>();
+                    MessageModel model = new MessageModel();
+                    model.setType(INQUIRY_TYPE);
+                    model.setType(INQUIRY_TYPE_SELLER_MALL);
+                    model.setProducerApp("MALl");
+                    model.setConsumerType(CUST_TYPE);
+                    model.setConsumerApp(CONSUMERAPP);
+                    model.setRemark(String.valueOf(count));
+                    for(InquiryRemind remind : reminds){
+                        model.setReceiverEnuu(remind.getVendUU());
+                        model.setReceiverUu(remind.getVendUserUU());
+                        model.setSenderEnuu(MESSAGE_SENDERENUU);
+                        model.setSenderUu(MESSAGE_SENDERUU);
+                    }
+                    String company = "";
+                    Enterprise enterprise = enterpriseDao.findOne(reminds.get(0).getVendUU());
+                    if(null != enterprise){
+                        company = enterprise.getEnName();
+                    }
+                    String content = company + "新增了"+ count +"张公共询价单,快登录优软商城查看详情吧!https://www.usoftmall.com/vendor#/seekPurchase";
+                    model.setContent(content);
+                    model.setSmsType(SMS_TYPE);
+                    model.setSmTemplate(SMS_TEMP_ID);
+                    models.add(model);
+                    String res = HttpUtil.doPost(PS_MESSAGE_URL + "/messages", FlexJsonUtils.toJsonDeep(models));
+                    System.out.println(res);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }).run();
     }
 
 
     /**
      *  每天下午2点发送询价通知短信
      */
+    @Scheduled(cron = "0 0 14 * * ?" )
     private void sendMessage2(){
 
+        List<BigInteger> list1 = inquiryRemindDao.findvenduseruu();
+        //找到询价推荐表中的所有公司
+        List<BigInteger> list2 = inquiryRemindDao.findvenduu();
+        for(BigInteger vendUserUU : list1){
+            for(BigInteger enuu : list2){
+                //查出昨晚17点到今早九点的询价信息
+                List<InquiryRemind> reminds = inquiryRemindDao.findInquiryRemind1(vendUserUU,enuu);
+                if(!CollectionUtils.isEmpty(reminds)){
+                    sendMessage(reminds.size(),reminds);
+                }
+            }
+        }
     }
 
     /**
      * 每天下午5点发送询价通知短信
      */
+    @Scheduled(cron = "0 0 17 * * ?" )
     private void sendMessage3(){
 
+        List<BigInteger> list1 = inquiryRemindDao.findvenduseruu();
+        //找到询价推荐表中的所有公司
+        List<BigInteger> list2 = inquiryRemindDao.findvenduu();
+        for(BigInteger vendUserUU : list1){
+            for(BigInteger enuu : list2){
+                //查出昨晚17点到今早九点的询价信息
+                List<InquiryRemind> reminds = inquiryRemindDao.findInquiryRemind2(vendUserUU,enuu);
+                if(!CollectionUtils.isEmpty(reminds)){
+                    sendMessage(reminds.size(),reminds);
+                }
+            }
+        }
     }
 
     /**
@@ -627,6 +751,7 @@ public class InquiryServiceImpl implements InquiryService {
         PurcInquiryItemInfo itemInfo = inquiryItemDao.findOne(id);
         List<PublicInquiryItem> itemList = itemDao.findBySourceId(itemInfo.getId());
         itemInfo.setQutations(itemList);
+
         itemInfo.setAgreed(Constant.NO);
         if (!CollectionUtils.isEmpty(itemList)) {
             for (PublicInquiryItem i : itemList) {

+ 104 - 74
src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

@@ -38,7 +38,7 @@ import java.util.*;
 
 /**
  * 公共询价接口实现
- *
+ * <p>
  * Created by hejq on 2018-01-13.
  */
 @Service
@@ -175,8 +175,8 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * 保存公共询价信息
      *
      * @param inquiries erp传入公共询价的信息
-     * @param enuu 询价企业UU号
-     * @param address 询价企业地址
+     * @param enuu      询价企业UU号
+     * @param address   询价企业地址
      */
     @Override
     public void save(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException {
@@ -219,19 +219,19 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * 消息推送
      *
      * @param inquiryItems 询价明细
-     * @param sourceApp 消息来源应用
+     * @param sourceApp    消息来源应用
      */
     @Override
     public void notifyMessage(List<PurcInquiryItem> inquiryItems, String sourceApp) throws Exception {
-        final String CONSUMERAPP ="MALL,B2B";
+        final String CONSUMERAPP = "MALL,B2B";
         for (PurcInquiryItem item : inquiryItems) {
-           String cmpCode = null;
-           if (item.getCmpCode() != null) {
-               cmpCode = item.getCmpCode();
-           } else if (null != item.getProductId()) {
-               Product product = productDao.findOne(item.getProductId());
-               cmpCode = product.getCmpCode();
-           }
+            String cmpCode = null;
+            if (item.getCmpCode() != null) {
+                cmpCode = item.getCmpCode();
+            } else if (null != item.getProductId()) {
+                Product product = productDao.findOne(item.getProductId());
+                cmpCode = product.getCmpCode();
+            }
             if (null != cmpCode) {
                 String url = PS_PRODUCT_URL + "/productuser/getProductUsersByEnUUAndCmpCode";
                 JSONObject formData = new JSONObject();
@@ -325,13 +325,13 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
             public Predicate toPredicate(Root<ProductReplace> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                 final PredicateFactory<ProductReplace> factory = new PredicateFactory<>();
                 factory.add(PredicateUtils.ne("userUU", userUU, false));
-                factory.add(PredicateUtils.and (PredicateUtils.isNotNull("ptrCmpcode"), PredicateUtils.eq("ptrCmpcode", cmpCode, false)));
+                factory.add(PredicateUtils.and(PredicateUtils.isNotNull("ptrCmpcode"), PredicateUtils.eq("ptrCmpcode", cmpCode, false)));
                 query.where(factory.toPredicate(root, query, cb));
                 return null;
             }
         });
         if (!CollectionUtils.isEmpty(productReplacesList)) {
-            for (ProductReplace productReplace:productReplacesList) {
+            for (ProductReplace productReplace : productReplacesList) {
                 ProductUsers user = new ProductUsers();
                 user.setEnuu(productReplace.getEnuu());
                 user.setUseruu(productReplace.getUserUU());
@@ -354,7 +354,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     /**
      * 通过查询的个人物料相关联的信息,自动生成推荐的报价的数据
      *
-     * @param item 报价明细
+     * @param item  报价明细
      * @param users 用户信息
      */
     private void remindInquiry(final PurcInquiryItem item, final List<ProductUsers> users) {
@@ -450,13 +450,13 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * 将ERP传入的inquiry信息转成公共询价服务中心需要的信息
      *
      * @param inquiries 将ERP传入的inquiry信息
-     * @param enuu 询价企业UU号
-     * @param address 询价企业地址
+     * @param enuu      询价企业UU号
+     * @param address   询价企业地址
      * @return
      */
     @Override
     public List<PurcInquiry> covert(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException {
-        List<PurcInquiry>  purcInquiries = new ArrayList<PurcInquiry>();
+        List<PurcInquiry> purcInquiries = new ArrayList<PurcInquiry>();
         if (!CollectionUtils.isEmpty(inquiries)) {
             for (BatchInquiry inquiry : inquiries) {
                 PurcInquiry old = purcInquiryDao.findByCodeAndEnUU(inquiry.getBi_code(), enuu);
@@ -528,7 +528,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * erp提交审核时,公共询价服务中心单据禁用报价功能
      *
      * @param inquiries erp询价信息
-     * @param enuu 询价企业UU号
+     * @param enuu      询价企业UU号
      */
     @Override
     public void updateStatus(List<BatchInquiry> inquiries, Long enuu) {
@@ -547,7 +547,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      */
     @Override
     public List<InquiryDetail> findNotUploadReply(Long enuu) {
-        List<PublicInquiryItem> items =  publicInquiryItemDao.findByEnUUAndBackStatus(enuu, (short) Status.NOT_UPLOAD.value());
+        List<PublicInquiryItem> items = publicInquiryItemDao.findByEnUUAndBackStatus(enuu, (short) Status.NOT_UPLOAD.value());
         if (!CollectionUtils.isEmpty(items)) {
             // 防止下载过程中进行操作,这里设置一个下载中的状态
             Set<Long> ids = new HashSet<>();
@@ -640,7 +640,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     /**
      * 针对供应商,客户对报价结果发送消息通知
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 应用来源
      */
     @Override
@@ -716,7 +716,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
      * 买家ERP作废询价单后,修改公共询价服务中心里面的状态
      *
      * @param inquiries 询价信息
-     * @param enuu 企业UU
+     * @param enuu      企业UU
      * @author hejq
      * @date 2018-01-14 12:28
      */
@@ -885,7 +885,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                         }
                         item = publicInquiryItemDao.findOne(idid);
                         //回复清单更新
-                        if(replies.size() > 0) {
+                        if (replies.size() > 0) {
                             for (PublicInquiryReply reply1 : replies) {
                                 jdbcTemplate.update("update public$inquiryreply set ir_idid = " + idid + "where ir_id = " + reply1.getId());
                             }
@@ -980,7 +980,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     /**
      * 查询公共询价列表信息
      *
-     * @param info 分页参数
+     * @param info   分页参数
      * @param filter 过滤条件
      * @return
      */
@@ -1113,7 +1113,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
         }
         String sql = "select * from (select p.id_id id, p.id_prodtitle prodTitle, p.id_date as date, i.in_enuu enuu from purc$puinquiryitems p left join purc$puinquiry i on i.in_id = p.id_inid where 1=1";
         if (enuu != null) {
-            sql = sql + " and i.in_enuu <> " + enuu ;
+            sql = sql + " and i.in_enuu <> " + enuu;
         }
         sql = sql + " and COALESCE(p.id_overdue, 0) <> 1 order by p.id_id desc) i limit " + size;
         List<PurcInquiryItem> items = jdbcTemplate.query(sql, new BeanPropertyRowMapper<PurcInquiryItem>(PurcInquiryItem.class));
@@ -1154,6 +1154,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
 
     /**
      * 商城-采购排行榜
+     *
      * @return
      */
     @Override
@@ -1172,7 +1173,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     @Override
     public PurcInquiryItemInfo findItemByItemId(Long itemId, Long enuu) {
         PurcInquiryItemInfo itemInfo = inquiryItemInfoDao.findOne(itemId);
-         PublicInquiryItem item = publicInquiryItemDao.findByVendUUAndSourceId(enuu, itemInfo.getId());
+        PublicInquiryItem item = publicInquiryItemDao.findByVendUUAndSourceId(enuu, itemInfo.getId());
         itemInfo.setQuoted(Constant.NO);
         if (null != item) {
             itemInfo.setAgreed(item.getAgreed());
@@ -1192,6 +1193,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
 
     /**
      * 通过id查询单个已转报价的信息
+     *
      * @param id
      * @return
      */
@@ -1230,13 +1232,13 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                         itemInfo.setAgreed(Constant.YES);
                     }
                     itemInfo.setQuoted(Constant.NO);
-                   if (remind.getStatus().equals(Status.SUBMITTED.value())) {
-                       itemInfo.setQuoted(Constant.YES);
-                       itemInfo.setQuteId(remind.getNewId());
-                   }
-                   if (itemInfo.getRemainingTime() <= 0) {
-                       itemInfo.setOverdue(Constant.YES);
-                   }
+                    if (remind.getStatus().equals(Status.SUBMITTED.value())) {
+                        itemInfo.setQuoted(Constant.YES);
+                        itemInfo.setQuteId(remind.getNewId());
+                    }
+                    if (itemInfo.getRemainingTime() <= 0) {
+                        itemInfo.setOverdue(Constant.YES);
+                    }
                     infoList.add(itemInfo);
                 }
             }
@@ -1247,62 +1249,63 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     /**
      * 针对供应商,客户将拒绝理由发送信息给供应商
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 应用来源
      * @throws Exception
      */
     @Override
     public Page<MessageModel> refuseMessage(PublicInquiryItem item, String sourceApp) {
-        if (null != item.getVendUU() && null != item.getVendUserUU() ) {
-                final String SMS_TYPE = "SM"; //发送信息
-                final String CONSUMERAPP ="MALL";
-                List<MessageModel> models = new ArrayList<MessageModel>();
-                String Buyer=item.getInquiry().getEnName() == null ? item.getInquiry().getRecorder():item.getInquiry().getEnName();
-                String cmpCode = item.getCmpCode();
-                String cmp = cmpCode.length() > 10 ? cmpCode.substring(0, 10).concat("...") : cmpCode;
-                String content= "因"+item.getRefusereason() + "," + Buyer + "【未采纳】您关于“型号:" + cmp + "”的报价。期待与您的下次合作!" ;
-                MessageModel model = new MessageModel();
-                model.setType(INQUIRY_DECIDE_TYPE_MALL);
-                model.setProducerApp(sourceApp);
-                model.setConsumerType(CUST_TYPE);
-                model.setConsumerApp(CONSUMERAPP);
-                model.setContent(content);
-                model.setRemark(String.valueOf(item.getInquiry().getId()));
-                model.setSourceId(item.getId());
-                model.setReceiverEnuu(item.getVendUU());
-                model.setReceiverUu(item.getVendUserUU());
-                model.setSenderEnuu(item.getInquiry().getEnUU());
-                if (null != item.getUserUU() || null != item.getInquiry().getRecorderUU()) {
-                    model.setSenderUu(item.getUserUU() != null ? item.getUserUU() : item.getInquiry().getRecorderUU());
-                } else {
-                    Enterprise enterprise = enterpriseDao.findOne(item.getInquiry().getEnUU());
-                    model.setSenderUu(null != enterprise ? enterprise.getAdminUU() : 0L);
-                }
-                model.setSmsType(SMS_TYPE);
-                models.add(model);
-                if (!CollectionUtils.isEmpty(models)) {
-                    sendMessage(models);
-                }
+        if (null != item.getVendUU() && null != item.getVendUserUU()) {
+            final String SMS_TYPE = "SM"; //发送信息
+            final String CONSUMERAPP = "MALL";
+            List<MessageModel> models = new ArrayList<MessageModel>();
+            String Buyer = item.getInquiry().getEnName() == null ? item.getInquiry().getRecorder() : item.getInquiry().getEnName();
+            String cmpCode = item.getCmpCode();
+            String cmp = cmpCode.length() > 10 ? cmpCode.substring(0, 10).concat("...") : cmpCode;
+            String content = "因" + item.getRefusereason() + "," + Buyer + "【未采纳】您关于“型号:" + cmp + "”的报价。期待与您的下次合作!";
+            MessageModel model = new MessageModel();
+            model.setType(INQUIRY_DECIDE_TYPE_MALL);
+            model.setProducerApp(sourceApp);
+            model.setConsumerType(CUST_TYPE);
+            model.setConsumerApp(CONSUMERAPP);
+            model.setContent(content);
+            model.setRemark(String.valueOf(item.getInquiry().getId()));
+            model.setSourceId(item.getId());
+            model.setReceiverEnuu(item.getVendUU());
+            model.setReceiverUu(item.getVendUserUU());
+            model.setSenderEnuu(item.getInquiry().getEnUU());
+            if (null != item.getUserUU() || null != item.getInquiry().getRecorderUU()) {
+                model.setSenderUu(item.getUserUU() != null ? item.getUserUU() : item.getInquiry().getRecorderUU());
+            } else {
+                Enterprise enterprise = enterpriseDao.findOne(item.getInquiry().getEnUU());
+                model.setSenderUu(null != enterprise ? enterprise.getAdminUU() : 0L);
             }
+            model.setSmsType(SMS_TYPE);
+            models.add(model);
+            if (!CollectionUtils.isEmpty(models)) {
+                sendMessage(models);
+            }
+        }
         return null;
 
     }
+
     /**
      * 针对供应商,把客户采纳报价的消息发送给供应商
      *
-     * @param item 询价明细
+     * @param item      询价明细
      * @param sourceApp 应用来源
      * @throws Exception
      */
     @Override
     public Page<MessageModel> adoptMessage(PublicInquiryItem item, String sourceApp) {
-        if (null != item.getVendUU() && null != item.getVendUserUU() ) {
+        if (null != item.getVendUU() && null != item.getVendUserUU()) {
             final String SMS_TYPE = "SM"; //发送信息
-            final String CONSUMERAPP ="MALL";
+            final String CONSUMERAPP = "MALL";
             List<MessageModel> models = new ArrayList<MessageModel>();
             String cmpCode = item.getCmpCode();
             String cmp = cmpCode.length() > 10 ? cmpCode.substring(0, 10).concat("...") : cmpCode;
-            String content= item.getInquiry().getEnName()+"【已采纳】您关于'型号:'" + cmp + "的报价,期待与您的合作!" ;
+            String content = item.getInquiry().getEnName() + "【已采纳】您关于'型号:'" + cmp + "的报价,期待与您的合作!";
             MessageModel model = new MessageModel();
             model.setType(INQUIRY_DECIDE_TYPE_MALL);
             model.setProducerApp(sourceApp);
@@ -1332,13 +1335,13 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
 
     @Override
     public Page<MessageModel> ReceiveMessage(PublicInquiryItem item, String sourceApp) {
-        if (null != item.getVendUU() && null != item.getVendUserUU() ) {
+        if (null != item.getVendUU() && null != item.getVendUserUU()) {
             final String SMS_TYPE = "SM"; //发送信息
-            final String CONSUMERAPP ="MALL";
+            final String CONSUMERAPP = "MALL";
             List<MessageModel> models = new ArrayList<MessageModel>();
             String cmpCode = item.getCmpCode();
             String cmp = cmpCode.length() > 10 ? cmpCode.substring(0, 10).concat("...") : cmpCode;
-            String content= "您收到了"+item.getVendName()+"关于“型号:"+ cmp +"“的报价,马上去看一看吧!";
+            String content = "您收到了" + item.getVendName() + "关于“型号:" + cmp + "“的报价,马上去看一看吧!";
 
             MessageModel model = new MessageModel();
             model.setType(INQUIRY_TYPE_MALL);
@@ -1370,9 +1373,36 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
 
     @Override
     public ModelMap getPurcInquiryItemCount() {
-        ModelMap result = new ModelMap();
-        Long count = inquiryItemInfoDao.count();
-        result.put("count", count);
+        ModelMap result = null;
+        try {
+            result = new ModelMap();
+            Long count = inquiryItemInfoDao.count();
+            result.put("count", count);
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+        return result;
+    }
+
+    /**
+     * 查询某年某月的询价明细总数
+     *
+     * @param month
+     * @return
+     */
+    public ModelMap countByMonth(Integer year, Integer month) {
+        ModelMap result = null;
+        try {
+            result = new ModelMap();
+            Long count = inquiryItemInfoDao.countByMonth(year, month);
+            result.put("count", count);
+            result.put("success", "true");
+        } catch (Exception e) {
+            result.put("message", e.getMessage());
+            result.put("success", false);
+            e.printStackTrace();
+        }
         return result;
     }
 }

+ 4 - 0
src/main/resources/config/application-cloud.properties

@@ -22,3 +22,7 @@ datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMill
 ps.product.url=https://api-product.usoftmall.com/
 ps.message.url=http://api-message.ubtob.com/
 mall.url = https://www.usoftmall.com/
+
+#message
+message.senderuu=2000002849
+message.senderEnuu=20000682

+ 5 - 1
src/main/resources/config/application-dev.properties

@@ -25,4 +25,8 @@ ps.product.url=http://192.168.253.102:8080/
 ps.message.url=http://192.168.253.12:24000/message/
 # wang localhost
 #ps.message.url=http://192.168.253.131:20000/
-mall.url = http://192.168.253.12:23400/
+mall.url = http://192.168.253.12:23400/
+
+#message
+message.senderuu=2000002849
+message.senderEnuu=20000682

+ 5 - 1
src/main/resources/config/application-test.properties

@@ -21,4 +21,8 @@ datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMill
 # Access path
 ps.product.url=http://218.17.158.219:24000/
 ps.message.url=http://218.17.158.219:24000/message/
-mall.url = http://192.168.253.12:23400/
+mall.url = http://192.168.253.12:23400/
+
+#message
+message.senderuu=2000002849
+message.senderEnuu=20000682