Browse Source

公共询价匹配企业商机

liusw 7 years ago
parent
commit
1487567b11

+ 0 - 101
src/main/java/com/uas/ps/inquiry/controller/KindController.java

@@ -1,101 +0,0 @@
-package com.uas.ps.inquiry.controller;
-
-import com.uas.ps.httplog.annotation.HttpLog;
-import com.uas.ps.inquiry.domain.IPage;
-import com.uas.ps.inquiry.model.kind.KindConcern;
-import com.uas.ps.inquiry.page.PageParams;
-import com.uas.ps.inquiry.service.KindService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 类目相关接口
- * @author  dongbw
- * 18/06/13 16:02.
- */
-@RequestMapping("/kind")
-@RestController
-public class KindController {
-
-    @Autowired
-    private KindService kindService;
-
-    /**
-     * 已关注
-     */
-    private static final String HAS_CONCERN = "yes";
-
-    /**
-     * 未关注
-     */
-    private static final String NOT_CONCERN = "no";
-
-
-//    /**
-//     * 根据分页参数和关键词查询未关注类目
-//     * @param pageParams  分页参数
-//     * @param keyword  关键词
-//     * @param enUU 企业UU
-//     * @return
-//     */
-//    @RequestMapping(value = "/concern/list", method = RequestMethod.GET, params = "type=no")
-//    public IPage<KindConcern> getNotConcernKindByPage(@RequestParam PageParams pageParams, String keyword, @RequestParam Long enUU) {
-//        return kindService.getNotConcernKindByPage(pageParams, keyword, enUU);
-//    }
-//
-//    /**
-//     * 根据分页参数和关键词查询已关注类目
-//     * @param pageParams  分页参数
-//     * @param keyword  关键词
-//     * @param enUU 企业UU
-//     * @return
-//     */
-//    @RequestMapping(value = "/concern/list", method = RequestMethod.GET, params = "type=yes")
-//    public IPage<KindConcern> getConcernKindByPage(@RequestParam PageParams pageParams, String keyword, @RequestParam Long enUU) {
-//        return kindService.getConcernKindByPage(pageParams, keyword, enUU);
-//    }
-
-    /**
-     * 根据分页参数和关键词查询已关注类目
-     * @param pageParams  分页参数
-     * @param keyword  关键词
-     * @param enUU 企业UU
-     * @return
-     */
-    @HttpLog
-    @RequestMapping(value = "/concern/list", method = RequestMethod.GET)
-    public IPage<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU, String type) {
-        if (HAS_CONCERN.equals(type)) {
-            return kindService.getConcernKindByPage(pageParams, keyword, enUU);
-        } else if (NOT_CONCERN.equals(type)) {
-            return kindService.getNotConcernKindByPage(pageParams, keyword, enUU);
-        }
-        return null;
-    }
-
-    /**
-     * 设置关注接口
-     * @param kindConcern  类目关注实体
-     * @return
-     */
-    @HttpLog
-    @RequestMapping(value = "/concern", method = RequestMethod.POST, params = "type=add")
-    public ModelMap addKindConcern(KindConcern kindConcern) {
-        return kindService.addKindConcern(kindConcern);
-    }
-
-    /**
-     * 设置关注接口
-     * @param kindConcern  类目关注实体
-     * @return
-     */
-    @HttpLog
-    @RequestMapping(value = "/concern", method = RequestMethod.POST, params = "type=del")
-    public ModelMap deleteKindConcern(KindConcern kindConcern) {
-        return kindService.deleteKindConcern(kindConcern);
-    }
-}
-

+ 9 - 0
src/main/java/com/uas/ps/inquiry/dao/KindConcernDao.java

@@ -8,6 +8,7 @@ import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * 类目关注Dao
@@ -23,4 +24,12 @@ public interface KindConcernDao extends JpaRepository<KindConcern, Long>, JpaSpe
      */
     @Query("select k.nameCn from KindConcern k where k.enUU = :enUU")
     List<String> findNameByEnUU(@Param("enUU") Long enUU);
+
+    /**
+     * 根据类目名称查询企业列表
+     *
+     * @param nameCn 类目名称
+     * @return
+     */
+    Set<Long> findByNameCn(String nameCn);
 }

+ 0 - 16
src/main/java/com/uas/ps/inquiry/dao/KindDao.java

@@ -1,16 +0,0 @@
-package com.uas.ps.inquiry.dao;
-
-import com.uas.ps.inquiry.model.kind.Kind;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.stereotype.Repository;
-
-/**
- * 类目Dao
- * @author dongbw
- * @version 2018年6月13日 17:18:03
- */
-@Repository
-public interface KindDao extends JpaRepository<Kind, Long>, JpaSpecificationExecutor<Kind> {
-
-}

+ 0 - 46
src/main/java/com/uas/ps/inquiry/service/KindService.java

@@ -1,46 +0,0 @@
-package com.uas.ps.inquiry.service;
-
-import com.uas.ps.inquiry.domain.IPage;
-import com.uas.ps.inquiry.model.kind.KindConcern;
-import com.uas.ps.inquiry.page.PageParams;
-import org.springframework.ui.ModelMap;
-
-/**
- * 类目接口
- * @author dongbw
- */
-public interface KindService {
-
-
-    /**
-     * 添加关注
-     * @param kindConcern 实体
-     * @return 处理结果
-     */
-    ModelMap addKindConcern(KindConcern kindConcern);
-
-    /**
-     * 取消关注
-     * @param kindConcern 实体
-     * @return 处理结果
-     */
-    ModelMap deleteKindConcern(KindConcern kindConcern);
-
-    /**
-     * 获取未关注类目列表
-     * @param pageParams  分页参数
-     * @param keyword  关键词
-     * @param enUU 企业UU
-     * @return 类目收藏分页
-     */
-    IPage<KindConcern> getNotConcernKindByPage(PageParams pageParams, String keyword, Long enUU);
-
-    /**
-     * 获取已关注类目列表
-     * @param pageParams  分页参数
-     * @param keyword  关键词
-     * @param enUU 企业UU
-     * @return 类目收藏分页
-     */
-    IPage<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU);
-}

+ 0 - 195
src/main/java/com/uas/ps/inquiry/service/impl/KindServiceImpl.java

@@ -1,195 +0,0 @@
-package com.uas.ps.inquiry.service.impl;
-
-import com.uas.ps.inquiry.dao.KindConcernDao;
-import com.uas.ps.inquiry.dao.KindDao;
-import com.uas.ps.inquiry.domain.IPage;
-import com.uas.ps.inquiry.entity.Constant;
-import com.uas.ps.inquiry.model.kind.Kind;
-import com.uas.ps.inquiry.model.kind.KindConcern;
-import com.uas.ps.inquiry.page.PageInfo;
-import com.uas.ps.inquiry.page.PageParams;
-import com.uas.ps.inquiry.page.criteria.PredicateUtils;
-import com.uas.ps.inquiry.service.KindService;
-import com.uas.ps.inquiry.util.IPageUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.stereotype.Service;
-import org.springframework.ui.ModelMap;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 类目接口实现
- *
- * @author dongbw
- * @version 2018年6月13日 16:11:21
- */
-@Service
-public class KindServiceImpl implements KindService {
-
-    @Autowired
-    private KindConcernDao kindConcernDao;
-
-    @Autowired
-    private KindDao kindDao;
-
-
-    /**
-     * 添加关注
-     *
-     * @param kindConcern 实体
-     * @return 处理结果
-     */
-    @Override
-    public ModelMap addKindConcern(KindConcern kindConcern) {
-        ModelMap map = new ModelMap();
-        try {
-            if (null == kindConcern) {
-               map.put("success", false);
-               map.put("message", "传入参数为空");
-               return map;
-            }
-            if (null == kindConcern.getEnUU()) {
-                map.put("success", false);
-                map.put("message", "传入企业为空");
-                return map;
-            }
-            if (StringUtils.isEmpty(kindConcern.getNameCn())) {
-                map.put("success", false);
-                map.put("message", "传入类目名称为空");
-                return map;
-            }
-            kindConcern.setDate(new Date());
-            kindConcern.setStatus(Constant.YES);
-            kindConcernDao.save(kindConcern);
-            map.put("success", true);
-            return map;
-        } catch (Exception e) {
-            e.printStackTrace();
-            map.put("success", false);
-            map.put("message", e.getMessage());
-            return map;
-        }
-    }
-
-    /**
-     * 取消关注
-     *
-     * @param kindConcern 实体
-     * @return 处理结果
-     */
-    @Override
-    public ModelMap deleteKindConcern(KindConcern kindConcern) {
-        ModelMap map = new ModelMap();
-        try {
-            if (null == kindConcern) {
-                map.put("success", false);
-                map.put("message", "传入参数为空");
-                return map;
-            }
-            if (null == kindConcern.getId()) {
-                map.put("success", false);
-                map.put("message", "传入id为空");
-                return map;
-            }
-            if (null == kindConcern.getEnUU()) {
-                map.put("success", false);
-                map.put("message", "传入企业为空");
-                return map;
-            }
-            if (StringUtils.isEmpty(kindConcern.getNameCn())) {
-                map.put("success", false);
-                map.put("message", "传入类目名称为空");
-                return map;
-            }
-            KindConcern concern = kindConcernDao.findOne(kindConcern.getId());
-            concern.setStatus(Constant.NO);
-            concern.setDate(new Date());
-            kindConcernDao.save(concern);
-            map.put("success", true);
-            return map;
-        } catch (Exception e) {
-            e.printStackTrace();
-            map.put("success", false);
-            map.put("message", e.getMessage());
-            return map;
-        }
-    }
-
-    /**
-     * 获取未关注类目列表
-     *
-     * @param pageParams 分页参数
-     * @param keyword    关键词
-     * @param enUU 企业UU
-     * @return 类目收藏分页
-     */
-    @Override
-    public IPage<KindConcern> getNotConcernKindByPage(PageParams pageParams, String keyword, Long enUU) {
-        final PageInfo pageInfo = new PageInfo(pageParams);
-        if (!StringUtils.isEmpty(keyword)) {
-            pageInfo.expression(PredicateUtils.like("nameCn", keyword, false));
-        }
-        pageInfo.expression(PredicateUtils.eq("isLeaf", Constant.YES, false));
-        List<String> kindConcernNameList = kindConcernDao.findNameByEnUU(enUU);
-        if (!CollectionUtils.isEmpty(kindConcernNameList)) {
-            pageInfo.expression(PredicateUtils.notIn("nameCn", kindConcernNameList, false));
-        }
-        Page<Kind> kindPage = kindDao.findAll(new Specification<Kind>() {
-            @Override
-            public Predicate toPredicate(Root<Kind> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
-                query.where(pageInfo.getPredicates(root, query, cb));
-                return null;
-            }
-        }, pageInfo);
-        List<KindConcern> kindConcerns = new ArrayList<>();
-        for (Kind kind : kindPage) {
-            KindConcern kindConcern = new KindConcern(kind);
-            kindConcern.setEnUU(enUU);
-            kindConcerns.add(kindConcern);
-        }
-        IPage<KindConcern> page = new IPage<>();
-        page.setContent(kindConcerns);
-        page.setFirst(kindPage.isFirst());
-        page.setLast(kindPage.isLast());
-        page.setNumber(kindPage.getNumber());
-        page.setSize(kindPage.getSize());
-        page.setTotalElements(kindPage.getTotalElements());
-        page.setNumberOfElements(kindPage.getNumberOfElements());
-        return page;
-    }
-
-    /**
-     * 获取已关注类目列表
-     *
-     * @param pageParams 分页参数
-     * @param keyword    关键词
-     * @param enUU 企业UU
-     * @return 类目收藏分页
-     */
-    @Override
-    public IPage<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU) {
-        final PageInfo pageInfo = new PageInfo(pageParams);
-        if (!StringUtils.isEmpty(keyword)) {
-            pageInfo.expression(PredicateUtils.like("nameCn", keyword, false));
-        }
-        pageInfo.expression(PredicateUtils.eq("enUU", enUU, false));
-        Page<KindConcern> kindConcernPage = kindConcernDao.findAll(new Specification<KindConcern>() {
-            @Override
-            public Predicate toPredicate(Root<KindConcern> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
-                query.where(pageInfo.getPredicates(root, query, cb));
-                return null;
-            }
-        }, pageInfo);
-        return IPageUtils.covert(kindConcernPage);
-    }
-}

+ 16 - 3
src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

@@ -87,6 +87,9 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     @Autowired
     private InquiryEnRemindDao inquiryEnRemindDao;
 
+    @Autowired
+    private KindConcernDao kindConcernDao;
+
     private static final Logger log = Logger.getLogger(Logger.class);
 
     /**
@@ -407,7 +410,12 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                         }
                     }
 
-
+                    // 查询已关注类目中是否有当前类目
+                    String kind = item.getProdTitle();
+                    Set<Long> enuuSet = new HashSet<>();
+                    if (!StringUtils.isEmpty(kind)) {
+                        enuuSet = kindConcernDao.findByNameCn(kind);
+                    }
                     String url = PS_PRODUCT_URL + "/product/businessOpportunity";
                     JSONObject formData = new JSONObject();
                     formData.put("enUU", item.getInquiry().getEnUU());
@@ -418,7 +426,9 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                         if (!StringUtils.isEmpty(result.get("enUUs"))) {
                             List<Long> enuus = (List<Long>) result.get("enUUs");
                             if (!CollectionUtils.isEmpty(enuus)) {
-                                for (Long enuu : enuus) {
+                                List<InquiryEnRemind> inquiryEnReminds = new ArrayList<>();
+                                enuuSet.addAll(enuus);
+                                for (Long enuu : enuuSet) {
                                     Enterprise enterprise = enterpriseDao.findOne(item.getInquiry().getEnUU());
                                     InquiryEnRemind remind = new InquiryEnRemind();
                                     remind.setEnName(enterprise.getEnName());
@@ -450,7 +460,10 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
                                     }
                                     remind.setDate(new Date(System.currentTimeMillis()));
                                     remind.setStatus(Status.INPUTTING.value());
-                                    inquiryEnRemindDao.save(remind);
+                                    inquiryEnReminds.add(remind);
+                                }
+                                if (!CollectionUtils.isEmpty(inquiryEnReminds)) {
+                                    inquiryEnRemindDao.save(inquiryEnReminds);
                                 }
                             }
                         }