Browse Source

公共询价服务相关功能调整

hejq 8 years ago
parent
commit
06adbdaecd
31 changed files with 4136 additions and 302 deletions
  1. 54 0
      src/main/java/com/uas/ps/inquiry/controller/InquiryForBuyerController.java
  2. 126 0
      src/main/java/com/uas/ps/inquiry/controller/InquiryForSaleController.java
  3. 38 68
      src/main/java/com/uas/ps/inquiry/controller/PublicInquiryController.java
  4. 1 1
      src/main/java/com/uas/ps/inquiry/dao/ProductDao.java
  5. 8 0
      src/main/java/com/uas/ps/inquiry/dao/PublicInquiryDao.java
  6. 8 0
      src/main/java/com/uas/ps/inquiry/dao/PublicInquiryItemDao.java
  7. 17 0
      src/main/java/com/uas/ps/inquiry/dao/PurcInquiryItemInfoDao.java
  8. 0 142
      src/main/java/com/uas/ps/inquiry/entity/Product.java
  9. 105 0
      src/main/java/com/uas/ps/inquiry/model/Enterprise.java
  10. 277 0
      src/main/java/com/uas/ps/inquiry/model/Product.java
  11. 16 1
      src/main/java/com/uas/ps/inquiry/model/PublicInquiry.java
  12. 16 1
      src/main/java/com/uas/ps/inquiry/model/PublicInquiryItem.java
  13. 701 0
      src/main/java/com/uas/ps/inquiry/model/PublicInquiryItemInfo.java
  14. 398 0
      src/main/java/com/uas/ps/inquiry/model/PurcInquiryInfo.java
  15. 58 2
      src/main/java/com/uas/ps/inquiry/model/PurcInquiryItem.java
  16. 618 0
      src/main/java/com/uas/ps/inquiry/model/PurcInquiryItemInfo.java
  17. 447 0
      src/main/java/com/uas/ps/inquiry/page/PageInfo.java
  18. 61 0
      src/main/java/com/uas/ps/inquiry/page/PageParams.java
  19. 132 0
      src/main/java/com/uas/ps/inquiry/page/SearchFilter.java
  20. 65 0
      src/main/java/com/uas/ps/inquiry/page/criteria/CriterionExpression.java
  21. 49 0
      src/main/java/com/uas/ps/inquiry/page/criteria/LogicalExpression.java
  22. 49 0
      src/main/java/com/uas/ps/inquiry/page/criteria/PredicateFactory.java
  23. 231 0
      src/main/java/com/uas/ps/inquiry/page/criteria/PredicateUtils.java
  24. 106 0
      src/main/java/com/uas/ps/inquiry/page/criteria/SimpleExpression.java
  25. 32 0
      src/main/java/com/uas/ps/inquiry/page/exception/IllegalOperatorException.java
  26. 85 0
      src/main/java/com/uas/ps/inquiry/service/InquiryForSaleService.java
  27. 37 0
      src/main/java/com/uas/ps/inquiry/service/InquiryService.java
  28. 13 32
      src/main/java/com/uas/ps/inquiry/service/PublicInquiryService.java
  29. 210 0
      src/main/java/com/uas/ps/inquiry/service/impl/InquiryForSaleServiceImpl.java
  30. 103 0
      src/main/java/com/uas/ps/inquiry/service/impl/InquiryServiceImpl.java
  31. 75 55
      src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

+ 54 - 0
src/main/java/com/uas/ps/inquiry/controller/InquiryForBuyerController.java

@@ -0,0 +1,54 @@
+package com.uas.ps.inquiry.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.ps.inquiry.model.PublicInquiryItem;
+import com.uas.ps.inquiry.model.PurcInquiry;
+import com.uas.ps.inquiry.service.InquiryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 针对买家,对询价的操作
+ *
+ * Created by hejq on 2018-01-17.
+ */
+@RequestMapping("/inquiry/buyer")
+@RestController
+public class InquiryForBuyerController {
+
+    @Autowired
+    private InquiryService inquiryService;
+
+    /**
+     * 作为买家,保存更新公共询价单
+     *
+     * @param inquiry 询价信息
+     * @return
+     */
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    public String saveInquiry(@RequestBody PurcInquiry inquiry) throws Exception {
+        inquiry = inquiryService.saveInquiry(inquiry);
+        if (null != inquiry.getId()) {
+            return JSONObject.toJSONString(inquiry);
+        } else {
+            throw new Exception("保存失败");
+        }
+    }
+
+    /**
+     * 通过明细id对供应商报价进行审核操作
+     *
+     * @param id 报价明细id
+     * @param status 状态
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/decide", method = RequestMethod.POST)
+    public void decideQuote(Long id, Short status) throws Exception {
+        inquiryService.decideQuote(id, status);
+    }
+}

+ 126 - 0
src/main/java/com/uas/ps/inquiry/controller/InquiryForSaleController.java

@@ -0,0 +1,126 @@
+package com.uas.ps.inquiry.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.ps.inquiry.model.Attach;
+import com.uas.ps.inquiry.model.PublicInquiryItem;
+import com.uas.ps.inquiry.service.InquiryForSaleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * 针对供应商,对询价的相关操作
+ *
+ * Created by hejq on 2018-01-18.
+ */
+@RequestMapping("/inquiry/sale")
+@RestController
+public class InquiryForSaleController {
+
+    @Autowired
+    private InquiryForSaleService saleService;
+
+    /**
+     * 通过ID查询报价详情
+     *
+     * @param id 已转报价的明细id
+     * @return
+     */
+    @RequestMapping(value = "/inquiry/detail", method = RequestMethod.GET)
+    public PublicInquiryItem findById(Long id) {
+        return saleService.findById(id);
+    }
+
+    /**
+     * 通过id查询公共询价详情
+     *
+     * @param id 询价明细id
+     * @param enuu 企业UU号
+     * @return
+     */
+    @RequestMapping(value = "/publicInquiry/detail", method = RequestMethod.GET)
+    public ModelMap findInquiryById(Long id, Long enuu) {
+        return saleService.findByIdAndEnuu(id, enuu);
+    }
+
+    /**
+     * 卖家报价时上传附件信息
+     *
+     * @param attach 附件信息
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/attach", method = RequestMethod.POST)
+    public String addAttachs(@RequestBody Attach attach) throws Exception {
+        attach = saleService.addAttachs(attach);
+        if (null != attach.getId()) {
+            return JSONObject.toJSONString(attach);
+        } else {
+            throw new Exception("保存失败");
+        }
+    }
+
+    /**
+     * 作为卖家,新增报价
+     *
+     * @param item 前台数据
+     * @return
+     */
+    @RequestMapping(value = "/item/add", method = RequestMethod.POST)
+    public String saveInquiryItem(@RequestBody PublicInquiryItem item) throws Exception {
+        item = saleService.add(item);
+        if (null != item.getId()) {
+            return JSONObject.toJSONString(item);
+        } else {
+            throw new Exception("保存失败");
+        }
+    }
+
+    /**
+     * 作为卖家,保存更新公共询价单
+     *
+     * @param item 前台数据
+     * @return
+     */
+    @RequestMapping(value = "/item/save", method = RequestMethod.POST)
+    public String saveInquiryItems(@RequestBody PublicInquiryItem item) throws Exception {
+        item = saleService.saveItem(item);
+        if (null != item) {
+            return JSON.toJSONString(item.getInquiry());
+        } else {
+            throw new Exception("保存失败");
+        }
+    }
+
+    /**
+     * 保存询价信息
+     *
+     * @author hejq
+     * @date 2018-01-16 15:49
+     * @param inquiryItem 供应商报价信息
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/renew", method = RequestMethod.POST)
+    public String saveItem(@RequestBody PublicInquiryItem inquiryItem) throws Exception {
+        inquiryItem = saleService.save(inquiryItem);
+        return JSONObject.toJSONString(inquiryItem);
+    }
+
+    /**
+     * 根据公共询价明细id查询报价信息,判断是否已报价
+     *
+     * @param id
+     * @param enuu
+     * @return
+     */
+    @RequestMapping(value = "/quote", method = RequestMethod.GET)
+    public PublicInquiryItem findBySourceId(Long id, Long enuu) {
+        return saleService.findBySourceIdAndEnuu(id, enuu);
+    }
+}

+ 38 - 68
src/main/java/com/uas/ps/inquiry/controller/PublicInquiryController.java

@@ -1,22 +1,21 @@
 package com.uas.ps.inquiry.controller;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.ps.inquiry.entity.BatchInquiry;
 import com.uas.ps.inquiry.entity.Inquiry;
 import com.uas.ps.inquiry.entity.InquiryDecide;
 import com.uas.ps.inquiry.entity.InquiryDetail;
-import com.uas.ps.inquiry.model.Attach;
-import com.uas.ps.inquiry.model.FileUpload;
 import com.uas.ps.inquiry.model.PublicInquiryItem;
-import com.uas.ps.inquiry.model.PurcInquiry;
+import com.uas.ps.inquiry.model.PublicInquiryItemInfo;
+import com.uas.ps.inquiry.model.PurcInquiryItemInfo;
+import com.uas.ps.inquiry.page.PageInfo;
+import com.uas.ps.inquiry.page.SearchFilter;
+import com.uas.ps.inquiry.page.exception.IllegalOperatorException;
 import com.uas.ps.inquiry.service.PublicInquiryService;
 import javassist.NotFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.data.domain.Page;
 import org.springframework.ui.ModelMap;
-import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.UnsupportedEncodingException;
@@ -29,7 +28,7 @@ import java.util.List;
  * Created by hejq on 2018-01-13.
  */
 @RestController
-@RequestMapping("/public/Inquiry")
+@RequestMapping("/inquiry/public")
 public class PublicInquiryController {
 
     @Autowired
@@ -148,82 +147,53 @@ public class PublicInquiryController {
     }
 
     /**
-     * 作为卖家,新增报价
+     * 通过分页参数和过滤条件查询公共询价列表信息
      *
-     * @param item 前台数据
+     * @author hejq
+     * @date 2018-01-17 10:27
+     * @param info 分页参数
+     * @param filter 过滤条件
      * @return
      */
-    @RequestMapping(value = "/item/add", method = RequestMethod.POST)
-    public String saveInquiryItem(@RequestBody PublicInquiryItem item) throws Exception {
-        item = publicInquiryService.add(item);
-        if (null != item.getId()) {
-            return JSONObject.toJSONString(item);
-        } else {
-            throw new Exception("保存失败");
-        }
+    @RequestMapping(method = RequestMethod.GET)
+    public Page<PurcInquiryItemInfo> getInquiry(PageInfo info, SearchFilter filter) {
+        return publicInquiryService.findTodoByPageInfo(info, filter);
     }
 
     /**
-     * 作为卖家,保存更新公共询价单
+     * 移动端查询公共询价列表
      *
-     * @param items 前台数据
+     * @param pageSize 分页大小
+     * @param pageNumber 页码
+     * @param enuu enuu
      * @return
      */
-    @RequestMapping(value = "/items/save", method = RequestMethod.POST)
-    public String saveInquiryItems(@RequestBody List<PublicInquiryItem> items) throws Exception {
-        items = publicInquiryService.save(items);
-        if (!CollectionUtils.isEmpty(items)) {
-            return JSON.toJSONString(items.get(0).getInquiry());
-        } else {
-            throw new Exception("保存失败");
-        }
+    @RequestMapping(value = "/mobile", method = RequestMethod.GET)
+    public Page<PurcInquiryItemInfo> publincInquiry(Integer pageSize, Integer pageNumber, Long enuu) {
+        PageInfo pageInfo = new PageInfo();
+        pageInfo.setPageNumber(pageNumber);
+        pageInfo.setPageSize(pageSize);
+        return publicInquiryService.findTodoByPageInfo(pageInfo, null);
     }
 
     /**
-     * 作为买家,保存更新公共询价单
-     *
-     * @param inquiry 询价信息
-     * @return
-     */
-    @RequestMapping(value = "/save", method = RequestMethod.POST)
-    public String saveInquiry(@RequestBody PurcInquiry inquiry) throws Exception {
-        inquiry = publicInquiryService.saveInquiry(inquiry);
-        if (null != inquiry.getId()) {
-            return JSONObject.toJSONString(inquiry);
-        } else {
-            throw new Exception("保存失败");
-        }
-    }
-
-    /**
-     * 保存询价信息(供应商、客户可能都会调用这条数据)
-     *
+     * 通过分页信息和过滤条件查询已转报价的信息
+     * 
      * @author hejq
-     * @date 2018-01-16 15:49
-     * @param inquiryItem 供应商报价信息
-     * @return
-     * @throws Exception
-     */
-    @RequestMapping(value = "/check", method = RequestMethod.POST)
-    public String saveItem(@RequestBody PublicInquiryItem inquiryItem) throws Exception {
-        inquiryItem = publicInquiryService.save(inquiryItem);
-        return JSONObject.toJSONString(inquiryItem);
-    }
-
-    /**
-     * 卖家报价时上传附件信息
-     *
-     * @param attach 附件信息
+     * @date 2018-01-18 15:36
+     * @param pageInfo 分页参数
+     * @param searchFilter 过滤条件
      * @return
-     * @throws Exception
      */
-    @RequestMapping(value = "/attach", method = RequestMethod.POST)
-    public String addAttachs(@RequestBody Attach attach) throws Exception {
-        attach = publicInquiryService.addAttachs(attach);
-        if (null != attach.getId()) {
-            return JSONObject.toJSONString(attach);
+    @RequestMapping(value = "/quotation/list", method = RequestMethod.GET)
+    public Page<PublicInquiryItem> getQuotation(PageInfo pageInfo, SearchFilter searchFilter) {
+        if (null != searchFilter.getVendUU()) {
+            pageInfo.filter("vendUU", searchFilter.getVendUU());
+        } else if (null != searchFilter.getEnUU()) {
+            pageInfo.filter("inquiry.enUU", searchFilter.getVendUU());
         } else {
-            throw new Exception("保存失败");
+            throw new IllegalOperatorException("参数格式不对");
         }
+        return publicInquiryService.findByPageInfo(pageInfo, searchFilter);
     }
 }

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

@@ -1,6 +1,6 @@
 package com.uas.ps.inquiry.dao;
 
-import com.uas.ps.inquiry.entity.Product;
+import com.uas.ps.inquiry.model.Product;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.stereotype.Repository;

+ 8 - 0
src/main/java/com/uas/ps/inquiry/dao/PublicInquiryDao.java

@@ -36,4 +36,12 @@ public interface PublicInquiryDao extends JpaSpecificationExecutor<PublicInquiry
      * @return
      */
     PublicInquiry findBySourceIdAndSourceApp(Long id, String sourcerapp);
+
+    /**
+     * 通过来源id查询报价单主表信息
+     *
+     * @param id 来源id
+     * @return
+     */
+    PublicInquiry findBySourceId(Long id);
 }

+ 8 - 0
src/main/java/com/uas/ps/inquiry/dao/PublicInquiryItemDao.java

@@ -67,4 +67,12 @@ public interface PublicInquiryItemDao extends JpaRepository<PublicInquiryItem, L
      * @return
      */
     PublicInquiryItem findByVendUUAndSourceId(Long enuu, Long id);
+
+    /**
+     * 通过主表id查询序号
+     *
+     * @param id 询价主表id
+     * @return
+     */
+    Integer countByInquiryId(Long id);
 }

+ 17 - 0
src/main/java/com/uas/ps/inquiry/dao/PurcInquiryItemInfoDao.java

@@ -0,0 +1,17 @@
+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.stereotype.Repository;
+
+/**
+ * 询价明细数据库操作
+ *  <pre>
+ *      明细带出主表信息,列表查询使用
+ *  </pre>
+ * Created by hejq on 2018-01-17.
+ */
+@Repository
+public interface PurcInquiryItemInfoDao extends JpaSpecificationExecutor<PurcInquiryItemInfo>, JpaRepository<PurcInquiryItemInfo, Long> {
+}

+ 0 - 142
src/main/java/com/uas/ps/inquiry/entity/Product.java

@@ -1,142 +0,0 @@
-package com.uas.ps.inquiry.entity;
-
-import javax.persistence.*;
-import java.io.Serializable;
-
-/**
- * 询价所需的简单的物料信息
- *
- * @author hejq
- * @date 2018-01-14 16:25
- */
-@Entity
-@Table(name = "products")
-public class Product implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    @Column(name = "pr_id")
-    private Long id;
-
-    /**
-     * 商品信息标题
-     */
-    @Column(name = "pr_title")
-    private String title;
-
-    /**
-     * TODO unknown?
-     */
-    @Column(name = "pr_detail")
-    private String detail;
-
-    /**
-     * 产品编号
-     */
-    @Column(name = "pr_code")
-    private String code;
-
-    /**
-     * 产品规格
-     */
-    @Column(name = "pr_spec")
-    private String spec;
-
-    /**
-     * 单位
-     */
-    @Column(name = "pr_unit")
-    private String unit;
-
-    /**
-     * 所属企业UU
-     */
-    @Column(name = "pr_enuu")
-    private Long enUU;
-
-    /**
-     * 个人UU 上传人的UU
-     */
-    @Column(name = "pr_useruu")
-    private Long userUU;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String getDetail() {
-        return detail;
-    }
-
-    public void setDetail(String detail) {
-        this.detail = detail;
-    }
-
-    public String getCode() {
-        return code;
-    }
-
-    public void setCode(String code) {
-        this.code = code;
-    }
-
-    public String getSpec() {
-        return spec;
-    }
-
-    public void setSpec(String spec) {
-        this.spec = spec;
-    }
-
-    public String getUnit() {
-        return unit;
-    }
-
-    public void setUnit(String unit) {
-        this.unit = unit;
-    }
-
-    public Long getEnUU() {
-        return enUU;
-    }
-
-    public void setEnUU(Long enUU) {
-        this.enUU = enUU;
-    }
-
-    public Long getUserUU() {
-        return userUU;
-    }
-
-    public void setUserUU(Long userUU) {
-        this.userUU = userUU;
-    }
-
-    @Override
-    public String toString() {
-        return "Product{" +
-                "id=" + id +
-                ", title='" + title + '\'' +
-                ", detail='" + detail + '\'' +
-                ", code='" + code + '\'' +
-                ", spec='" + spec + '\'' +
-                ", unit='" + unit + '\'' +
-                ", enUU=" + enUU +
-                ", userUU=" + userUU +
-                '}';
-    }
-}

+ 105 - 0
src/main/java/com/uas/ps/inquiry/model/Enterprise.java

@@ -0,0 +1,105 @@
+package com.uas.ps.inquiry.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 企业信息,询价所有信息存在公共服务,这里需要关联企业信息
+ *
+ * Created by hejq on 2018-01-18.
+ */
+@Entity
+@Table(name = "sec$enterprises")
+public class Enterprise implements Serializable {
+
+    /**
+     * 序列号
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * uu号
+     */
+    @Id
+    @Column(name = "en_uu")
+    private Long uu;
+
+    /**
+     * 公司名称
+     */
+    @Column(name = "en_name")
+    private String enName;
+
+    /**
+     * 公司电话
+     */
+    @Column(name = "en_tel")
+    private String enTel;
+
+    /**
+     * 注册地址
+     */
+    @Column(name = "en_address")
+    private String enAddress;
+
+    /**
+     * 营业执照号
+     */
+    @Column(name = "en_businesscode")
+    private  String businesscode;
+
+    public Long getUu() {
+        return uu;
+    }
+
+    public void setUu(Long uu) {
+        this.uu = uu;
+    }
+
+    public String getEnName() {
+        return enName;
+    }
+
+    public void setEnName(String enName) {
+        this.enName = enName;
+    }
+
+    public String getEnTel() {
+        return enTel;
+    }
+
+    public void setEnTel(String enTel) {
+        this.enTel = enTel;
+    }
+
+    public String getEnAddress() {
+        return enAddress;
+    }
+
+    public void setEnAddress(String enAddress) {
+        this.enAddress = enAddress;
+    }
+
+    public String getBusinesscode() {
+        return businesscode;
+    }
+
+    public void setBusinesscode(String businesscode) {
+        this.businesscode = businesscode;
+    }
+
+    @Override
+    public String toString() {
+        return "Enterprise{" +
+                "uu=" + uu +
+                ", enName='" + enName + '\'' +
+                ", enTel='" + enTel + '\'' +
+                ", enAddress='" + enAddress + '\'' +
+                ", businesscode='" + businesscode + '\'' +
+                '}';
+    }
+}

+ 277 - 0
src/main/java/com/uas/ps/inquiry/model/Product.java

@@ -0,0 +1,277 @@
+package com.uas.ps.inquiry.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * 简单物料信息,询价搜索
+ *
+ * @author hejq
+ * @date 2018-01-17 11:19
+ */
+@Entity
+@Table(name = "products")
+public class Product implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "pr_id")
+    private Long id;
+
+    /**
+     * 商品信息标题
+     */
+    @Column(name = "pr_title")
+    private String title;
+
+    /**
+     * TODO unknown?
+     */
+    @Column(name = "pr_detail")
+    private String detail;
+
+    /**
+     * 产品编号
+     */
+    @Column(name = "pr_code")
+    private String code;
+
+    /**
+     * 产品规格
+     */
+    @Column(name = "pr_spec")
+    private String spec;
+
+    /**
+     * 单位
+     */
+    @Column(name = "pr_unit")
+    private String unit;
+
+    /**
+     * 所属企业UU
+     */
+    @Column(name = "pr_enuu")
+    private Long enUU;
+
+    /**
+     * 个人UU 上传人的UU
+     */
+    @Column(name = "pr_useruu")
+    private Long userUU;
+
+    /**
+     * 品牌(ERP) 上传时的品牌
+     */
+    @Column(name = "pr_brand")
+    private String brand;
+
+    /**
+     * 原厂型号(erp) 用户上传的型号
+     */
+    @Column(name = "pr_cmpcode")
+    private String cmpCode;
+
+    /**
+     * UUID 标准料号
+     */
+    @Column(name = "pr_cmpuuid")
+    private String cmpUuid;
+
+    /**
+     * 类目(平台)(中文)
+     */
+    @Column(name = "pr_kind")
+    private String kind;
+
+    /**
+     * 类目(平台)(英文)
+     */
+    @Column(name = "pr_kinden")
+    private String kindEn;
+
+    /**
+     * 品牌(平台)(中文)
+     */
+    @Column(name = "pr_pbrand")
+    private String pBrand;
+
+    /**
+     * 品牌(平台)(英文)
+     */
+    @Column(name = "pr_pbranden")
+    private String pBrandEn;
+
+    /**
+     * 品牌(平台)(uuid)
+     */
+    @Column(name = "pr_pbranduuid")
+    private String pBrandUuid;
+
+    /**
+     * 型号(平台)
+     */
+    @Column(name = "pr_pcmpcode")
+    private String pCmpCode;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDetail() {
+        return detail;
+    }
+
+    public void setDetail(String detail) {
+        this.detail = detail;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getSpec() {
+        return spec;
+    }
+
+    public void setSpec(String spec) {
+        this.spec = spec;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getCmpCode() {
+        return cmpCode;
+    }
+
+    public void setCmpCode(String cmpCode) {
+        this.cmpCode = cmpCode;
+    }
+
+    public String getCmpUuid() {
+        return cmpUuid;
+    }
+
+    public void setCmpUuid(String cmpUuid) {
+        this.cmpUuid = cmpUuid;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getKindEn() {
+        return kindEn;
+    }
+
+    public void setKindEn(String kindEn) {
+        this.kindEn = kindEn;
+    }
+
+    public String getpBrand() {
+        return pBrand;
+    }
+
+    public void setpBrand(String pBrand) {
+        this.pBrand = pBrand;
+    }
+
+    public String getpBrandEn() {
+        return pBrandEn;
+    }
+
+    public void setpBrandEn(String pBrandEn) {
+        this.pBrandEn = pBrandEn;
+    }
+
+    public String getpBrandUuid() {
+        return pBrandUuid;
+    }
+
+    public void setpBrandUuid(String pBrandUuid) {
+        this.pBrandUuid = pBrandUuid;
+    }
+
+    public String getpCmpCode() {
+        return pCmpCode;
+    }
+
+    public void setpCmpCode(String pCmpCode) {
+        this.pCmpCode = pCmpCode;
+    }
+
+    @Override
+    public String toString() {
+        return "Product{" +
+                "id=" + id +
+                ", title='" + title + '\'' +
+                ", detail='" + detail + '\'' +
+                ", code='" + code + '\'' +
+                ", spec='" + spec + '\'' +
+                ", unit='" + unit + '\'' +
+                ", enUU=" + enUU +
+                ", userUU=" + userUU +
+                ", brand='" + brand + '\'' +
+                ", cmpCode='" + cmpCode + '\'' +
+                ", cmpUuid='" + cmpUuid + '\'' +
+                ", kind='" + kind + '\'' +
+                ", kindEn='" + kindEn + '\'' +
+                ", pBrand='" + pBrand + '\'' +
+                ", pBrandEn='" + pBrandEn + '\'' +
+                ", pBrandUuid='" + pBrandUuid + '\'' +
+                ", pCmpCode='" + pCmpCode + '\'' +
+                '}';
+    }
+}

+ 16 - 1
src/main/java/com/uas/ps/inquiry/model/PublicInquiry.java

@@ -38,6 +38,13 @@ public class PublicInquiry implements Serializable {
 	@Column(name = "in_enuu")
 	private Long enUU;
 
+	/**
+	 * 询价企业信息
+	 */
+	@OneToOne(cascade = { CascadeType.MERGE, CascadeType.REFRESH })
+	@JoinColumn(name = "in_enuu", insertable = false, updatable = false)
+	private Enterprise enterprise;
+
 	/**
 	 * 询价单所属用户UU
 	 */
@@ -237,7 +244,15 @@ public class PublicInquiry implements Serializable {
 		this.enUU = enUU;
 	}
 
-	public Long getRecorderUU() {
+    public Enterprise getEnterprise() {
+        return enterprise;
+    }
+
+    public void setEnterprise(Enterprise enterprise) {
+        this.enterprise = enterprise;
+    }
+
+    public Long getRecorderUU() {
 		return recorderUU;
 	}
 

+ 16 - 1
src/main/java/com/uas/ps/inquiry/model/PublicInquiryItem.java

@@ -64,6 +64,13 @@ public class PublicInquiryItem implements Serializable {
 	@Column(name = "id_prid")
 	private Long productId;
 
+	/**
+	 * 产品
+	 */
+	@OneToOne(cascade = {CascadeType.ALL})
+	@JoinColumn(name = "id_prid", insertable = false, updatable = false)
+	private Product product;
+
     /**
      * 物料编号,物料表加载不出来,这里用code去处理
      */
@@ -339,7 +346,15 @@ public class PublicInquiryItem implements Serializable {
 		this.productId = productId;
 	}
 
-    public String getPrcode() {
+	public Product getProduct() {
+		return product;
+	}
+
+	public void setProduct(Product product) {
+		this.product = product;
+	}
+
+	public String getPrcode() {
         return prcode;
     }
 

+ 701 - 0
src/main/java/com/uas/ps/inquiry/model/PublicInquiryItemInfo.java

@@ -0,0 +1,701 @@
+package com.uas.ps.inquiry.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.uas.ps.entity.Status;
+import com.uas.ps.inquiry.entity.Constant;
+import com.uas.ps.inquiry.util.DateUtils;
+import org.springframework.util.CollectionUtils;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * 公共询价单转报价后的询价单明细(查询方法,用明细带出主表信息)
+ *
+ * @author hejq 2018-01-06
+ */
+@Table(name = "public$inquiryitems")
+@Entity
+public class PublicInquiryItemInfo implements Serializable {
+
+    /**
+     * default serialVersionUID
+     */
+    private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id_id")
+	private Long id;
+
+	/**
+	 * 来源(买家ERP采购询价明细)的ID
+	 */
+	@Column(name = "id_sourceid", updatable = false)
+	private Long sourceId;
+
+	/**
+	 * 序号
+	 */
+	@Column(name = "id_number")
+	private Short number;
+
+	/**
+	 * 询价单
+	 */
+	@ManyToOne(cascade = CascadeType.ALL, optional = true)
+	@JoinColumn(name = "id_inid", nullable = false)
+	private PublicInquiry inquiry;
+
+	/**
+	 * 买家采购员UU
+	 */
+	@Column(name = "id_useruu")
+	private Long userUU;
+
+    /**
+     * 产品id
+     */
+	@Column(name = "id_prid")
+	private Long productId;
+
+	/**
+	 * 产品
+	 */
+	@OneToOne(cascade = {CascadeType.ALL})
+	@JoinColumn(name = "id_prid", insertable = false, updatable = false)
+	private Product product;
+
+    /**
+     * 物料编号,物料表加载不出来,这里用code去处理
+     */
+    @Column(name = "id_prcode")
+    private String prcode;
+
+	/**
+	 * 币种
+	 */
+	@Column(name = "id_currency")
+	private String currency;
+
+	/**
+	 * 税率
+	 */
+	@Column(name = "id_taxrate")
+	private Float taxrate;
+
+	/**
+	 * 备注
+	 */
+	@Column(name = "id_remark")
+	private String remark;
+
+	/**
+	 * 供应商UU
+	 */
+	@Column(name = "id_venduu")
+	private Long vendUU;
+
+	/**
+	 * 供应商联系人UU
+	 */
+	@Column(name = "id_venduseruu")
+	private Long vendUserUU;
+
+	/**
+	 * (买家预先提供的)有效期始
+	 */
+	@Column(name = "id_fromdate")
+	private Date fromDate;
+
+	/**
+	 * (买家预先提供的)有效期止
+	 */
+	@Column(name = "id_todate")
+	private Date toDate;
+
+	/**
+	 * (卖家报的)有效期始
+	 */
+	@Column(name = "id_vendfromdate")
+	private Date vendFromDate;
+
+	/**
+	 * (卖家报的)有效期止
+	 */
+	@Column(name = "id_vendtodate")
+	private Date vendToDate;
+
+	/**
+	 * (卖家报的)最小订购量
+	 */
+	@Column(name = "id_minorderqty")
+	private Double minOrderQty;
+
+	/**
+	 * (卖家报的)最小包装量
+	 */
+	@Column(name = "id_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * (卖家报的)物料品牌
+	 */
+	@Column(name = "id_brand")
+	private String brand;
+
+	/**
+	 * (卖家报的)供应商物料编号
+	 */
+	@Column(name = "id_vendorprodcode")
+	private String vendorprodcode;
+
+	/**
+	 * (卖家报的)交货周期(天数)
+	 */
+	@Column(name = "id_leadtime")
+	private Long leadtime;
+
+	/**
+	 * 分段报价明细
+	 */
+	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+	@JoinColumn(name = "ir_idid")
+	@OrderBy("lapQty")
+	private List<PublicInquiryReply> replies;
+
+	/**
+	 * {未回复、已回复}
+	 */
+	@Column(name = "id_status")
+	private Short status;
+
+	/**
+	 * (针对卖家的)询价传输状态{待上传、已下载}
+	 */
+	@Column(name = "id_sendstatus")
+	private Short sendStatus;
+
+	/**
+	 * (针对买家的)报价信息传输状态{待上传、已下载}
+	 */
+	@Column(name = "id_backstatus")
+	private Short backStatus;
+
+	/**
+	 * (针对卖家的)报价信息传输状态{待上传、已下载}
+	 */
+	@Column(name = "id_replysendstatus")
+	private Short replySendStatus;
+
+	/**
+	 * 是否采纳
+	 */
+	@Column(name = "id_agreed")
+	private Short agreed;
+
+	/**
+	 * (针对卖家的)是否采纳信息传输状态{待上传、已下载}
+	 */
+	@Column(name = "id_decidestatus")
+	private Short decideStatus;
+
+	/**
+	 * (针对卖家的)作废信息传输状态{待上传、已下载}
+	 */
+	@Column(name = "id_invalidstatus")
+	private Short invalidStatus;
+
+	/**
+	 * 是否买家已设置分段数
+	 */
+	@Column(name = "id_custlap")
+	private Short custLap;
+
+	/**
+	 * 保存erp传入数据的时间
+	 * 
+	 * @return
+	 */
+	@Column(name = "id_erpdate")
+	private Date erpDate;
+
+	/**
+	 * 录入时间(取主表日期字段)
+	 *
+	 * @return
+	 */
+	@Column(name = "id_date", insertable = false, updatable = false)
+	private Date date;
+
+	/**
+	 * search项目进行单据是否已过期时实际根据主表中enddate与当前时间的比较获取,但是数据库无字段会报“标识符无效”的错误
+	 * 所以建立此字段,但是此字段不会赋值。
+	 *   在建立索引时,overdue的值加入到了invalid(已失效)的判断条件中,所以此字段的值无实际意义,
+	 *   UAS询价单提交或反提交时,更新此字段,来使询价单明细更新触发器生效,更新询价单明细索引,
+	 *   才能使未过期未报价已提交单据进入失效列表,未过期未报价反提交单据从已失效列表回到待报价列表。
+	 *
+	 *   (1为已提交, 0为被反提交, null为未提交)
+	 */
+	@Column(name = "id_overdue", insertable = false, updatable = false)
+	private Short overdue;
+
+	/**
+	 * 报价是否已过期  根据vendToDate与当前时间的比较获取,但是数据库无字段会报“标识符无效”的错误
+	 * 所以建立此字段,此字段在视图中赋值。
+	 *
+	 */
+	@Column(name = "id_invalid", insertable = false, updatable = false)
+	private Short invalid;
+
+	/**
+	 * 应用来源ERP、B2B
+	 */
+	@Column(name = "id_sourceapp")
+	private String sourceApp;
+
+	/**
+	 * 报价附件
+	 */
+	@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
+	@JoinTable(name = "public$inquiryitems$attach", joinColumns = @JoinColumn(name = "id_id", referencedColumnName = "id_id"), inverseJoinColumns = @JoinColumn(name="at_id", referencedColumnName = "at_id"))
+	private Set<Attach> attaches;
+
+	/**
+	 * 需求数量
+	 */
+	@Column(name = "id_needquantity")
+	private Double needquantity;
+
+    /**
+     * erp传输状态
+     *
+     * <pre>erp发出数据传输请求时,赋给状态,完成后更新状态</pre>
+     *
+     * 1、 传输完成<br>
+     * 0、 正在传输
+     *
+     */
+	@Column(name = "id_erpstatus")
+    private Short erpstatus;
+
+	/**
+	 * 询价种类
+	 */
+	@Column(name = "id_kind")
+	private String kind;
+
+	/*这下面是供应商报价时存的相关信息;
+	* 因为存在非客户报价,而且公共服务里面没有企业信息,现存入相关字段,后续处理*/
+	/**
+	 * 供应商名称
+	 */
+	@Column(name = "id_vend_name")
+	private String vendName;
+
+	/**
+	 * 供应商营业执照
+	 */
+	@Column(name = "id_vend_businesscode")
+	private String businessCode;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	@JsonIgnore
+	@JSONField(serialize = false)
+	public Long getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(Long sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public Short getNumber() {
+		return number;
+	}
+
+	public void setNumber(Short number) {
+		this.number = number;
+	}
+
+	public PublicInquiry getInquiry() {
+		return inquiry;
+	}
+
+	public void setInquiry(PublicInquiry inquiry) {
+		this.inquiry = inquiry;
+	}
+
+	public Long getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Long productId) {
+		this.productId = productId;
+	}
+
+	public Product getProduct() {
+		return product;
+	}
+
+	public void setProduct(Product product) {
+		this.product = product;
+	}
+
+	public String getPrcode() {
+        return prcode;
+    }
+
+    public void setPrcode(String prcode) {
+        this.prcode = prcode;
+    }
+
+    public String getCurrency() {
+		return currency;
+	}
+
+	public void setCurrency(String currency) {
+		this.currency = currency;
+	}
+
+	public Float getTaxrate() {
+		return taxrate;
+	}
+
+	public void setTaxrate(Float taxrate) {
+		this.taxrate = taxrate;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Date getFromDate() {
+		return fromDate;
+	}
+
+	public void setFromDate(Date fromDate) {
+		this.fromDate = fromDate;
+	}
+
+	public Date getToDate() {
+		return toDate;
+	}
+
+	public void setToDate(Date toDate) {
+		this.toDate = toDate;
+	}
+
+	public Date getVendFromDate() {
+		return vendFromDate;
+	}
+
+	public void setVendFromDate(Date vendFromDate) {
+		this.vendFromDate = vendFromDate;
+	}
+
+	public Date getVendToDate() {
+		return vendToDate;
+	}
+
+	public void setVendToDate(Date vendToDate) {
+		this.vendToDate = vendToDate;
+	}
+
+	public Long getVendUU() {
+		return vendUU;
+	}
+
+	public void setVendUU(Long vendUU) {
+		this.vendUU = vendUU;
+	}
+
+	public List<PublicInquiryReply> getReplies() {
+		return replies;
+	}
+
+	public void setReplies(List<PublicInquiryReply> replies) {
+		this.replies = replies;
+	}
+
+	public Long getVendUserUU() {
+		return vendUserUU;
+	}
+
+	public void setVendUserUU(Long vendUserUU) {
+		this.vendUserUU = vendUserUU;
+	}
+
+	public Short getAgreed() {
+		return agreed;
+	}
+
+	public void setAgreed(Short agreed) {
+		this.agreed = agreed;
+	}
+
+	public Short getStatus() {
+		return status;
+	}
+
+	public void setStatus(Short status) {
+		this.status = status;
+	}
+
+	public Short getSendStatus() {
+		return sendStatus;
+	}
+
+	public void setSendStatus(Short sendStatus) {
+		this.sendStatus = sendStatus;
+	}
+
+	public Double getMinOrderQty() {
+		return minOrderQty;
+	}
+
+	public void setMinOrderQty(Double minOrderQty) {
+		this.minOrderQty = minOrderQty;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public Short getBackStatus() {
+		return backStatus;
+	}
+
+	public void setBackStatus(Short backStatus) {
+		this.backStatus = backStatus;
+	}
+
+	public Short getReplySendStatus() {
+		return replySendStatus;
+	}
+
+	public void setReplySendStatus(Short replySendStatus) {
+		this.replySendStatus = replySendStatus;
+	}
+
+	public Short getDecideStatus() {
+		return decideStatus;
+	}
+
+	public void setDecideStatus(Short decideStatus) {
+		this.decideStatus = decideStatus;
+	}
+
+	public Short getCustLap() {
+		return custLap;
+	}
+
+	public void setCustLap(Short custLap) {
+		this.custLap = custLap;
+	}
+
+	public Long getUserUU() {
+		return userUU;
+	}
+
+	public void setUserUU(Long userUU) {
+		this.userUU = userUU;
+	}
+
+	public String getBrand() {
+		return brand;
+	}
+
+	public void setBrand(String brand) {
+		this.brand = brand;
+	}
+
+	public String getVendorprodcode() {
+		return vendorprodcode;
+	}
+
+	public void setVendorprodcode(String vendorprodcode) {
+		this.vendorprodcode = vendorprodcode;
+	}
+
+	public Long getLeadtime() {
+		return leadtime;
+	}
+
+	public void setLeadtime(Long leadtime) {
+		this.leadtime = leadtime;
+	}
+
+	public Date getErpDate() {
+		return erpDate;
+	}
+
+	public void setErpDate(Date erpDate) {
+		this.erpDate = erpDate;
+	}
+
+	public Date getDate() {
+		return date;
+	}
+
+	public void setDate(Date date) {
+		this.date = date;
+	}
+
+	public String getSourceApp() {
+		return sourceApp;
+	}
+
+	public void setSourceApp(String sourceApp) {
+		this.sourceApp = sourceApp;
+	}
+
+	public Short getInvalidStatus() {
+		return invalidStatus;
+	}
+
+	public void setInvalidStatus(Short invalidStatus) {
+		this.invalidStatus = invalidStatus;
+	}
+
+	public Set<Attach> getAttaches() {
+		return attaches;
+	}
+
+	public void setAttaches(Set<Attach> attaches) {
+		this.attaches = attaches;
+	}
+
+	public Double getNeedquantity() {
+		return needquantity;
+	}
+
+	public void setNeedquantity(Double needquantity) {
+		this.needquantity = needquantity;
+	}
+
+	public Short getOverdue() {
+		return overdue;
+	}
+
+	public void setOverdue(Short overdue) {
+		this.overdue = overdue;
+	}
+
+	public Short getInvalid() {
+		return invalid;
+	}
+
+	public void setInvalid(Short invalid) {
+		this.invalid = invalid;
+	}
+
+    public Short getErpstatus() {
+        return erpstatus;
+    }
+
+    public void setErpstatus(Short erpstatus) {
+
+	    this.erpstatus = erpstatus ;
+    }
+
+	public String getKind() {
+		return kind;
+	}
+
+	public void setKind(String kind) {
+		this.kind = kind;
+	}
+
+	public String getVendName() {
+		return vendName;
+	}
+
+	public void setVendName(String vendName) {
+		this.vendName = vendName;
+	}
+
+	public String getBusinessCode() {
+		return businessCode;
+	}
+
+	public void setBusinessCode(String businessCode) {
+		this.businessCode = businessCode;
+	}
+
+	/**
+	 * 回复记录的描述
+	 * 
+	 * @return
+	 */
+	public String replyDescription() {
+		if (!CollectionUtils.isEmpty(this.replies)) {
+			StringBuffer sb = new StringBuffer();
+			for (PublicInquiryReply reply : this.replies)
+				sb.append("分段数:").append(reply.getLapQty()).append(",").append("价格:").append(reply.getPrice())
+						.append(";");
+			return sb.toString();
+		}
+		return null;
+	}
+
+	/**
+	 * 是否可报价
+	 * <p>
+	 * 1.未报价,未截止报价
+	 * </p>
+	 * <p>
+	 * 2.已报价,未截止报价,客户未提交
+	 * </p>
+	 * 
+	 * @return
+	 */
+	public boolean isReplyable() {
+	    if(this.erpstatus == null) {
+	        this.erpstatus = Constant.YES;
+        }
+		if (this.inquiry.getEndDate() != null) {
+			return DateUtils
+					.compare(this.inquiry.getEndDate(), new Date(),
+							DateUtils.COMPARE_DAY) >= 0
+					&& (this.status == Status.NOT_REPLY.value() || (this.status == Status.REPLIED.value()
+							&& (this.inquiry.getCheck() == null || this.inquiry.getCheck() != Constant.YES)
+							&& this.agreed == null) && this.erpstatus != Constant.NO);
+		}
+		return this.status == Status.NOT_REPLY.value() || (this.status == Status.REPLIED.value()
+				&& (this.inquiry.getCheck() == null || this.inquiry.getCheck() != Constant.YES)
+				&& this.agreed == null) && this.erpstatus != Constant.NO;
+	}
+
+    public static List<PublicInquiry> distinct(List<PublicInquiryItemInfo> purcitems) {
+		List<PublicInquiry> inquiries = new ArrayList<>();
+		Set<Long> keys = new HashSet<>();
+		for (PublicInquiryItemInfo item : purcitems) {
+			if (!keys.contains(item.getInquiry().getId())) {
+				inquiries.add(item.getInquiry());
+				keys.add(item.getInquiry().getId());
+			}
+		}
+		return inquiries;
+    }
+}

+ 398 - 0
src/main/java/com/uas/ps/inquiry/model/PurcInquiryInfo.java

@@ -0,0 +1,398 @@
+package com.uas.ps.inquiry.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * 公共库新增的询价信息表中间表(查询信息)
+ *
+ * @author hejq
+ * @date 2018-01-17 15:46
+ */
+@Entity
+@Table(name = "purc$puinquiry")
+public class PurcInquiryInfo implements Serializable {
+
+    /**
+     * default serialVersionUID
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "in_id")
+    private Long id;
+
+    /**
+     * 询价单所属企业UU
+     */
+    @Column(name = "in_enuu")
+    private Long enUU;
+
+    /**
+     * 询价企业
+     */
+    @OneToOne(cascade = { CascadeType.MERGE, CascadeType.REFRESH })
+    @JoinColumn(name = "in_enuu", insertable = false, updatable = false)
+    private Enterprise enterprise;
+
+    /**
+     * 询价单所属用户UU
+     */
+    @Column(name = "in_recorderuu")
+    private Long recorderUU;
+
+    /**
+     * 流水号
+     */
+    @Column(name = "in_code")
+    private String code;
+
+    /**
+     * 单据归属日期
+     */
+    @Column(name = "in_date")
+    private Date date;
+
+    /**
+     * 录入人
+     */
+    @Column(name = "in_recorder")
+    private String recorder;
+
+    /**
+     * 审核人
+     */
+    @Column(name = "in_auditor")
+    private String auditor;
+
+    /**
+     * 报价截止日期
+     */
+    @Column(name = "in_enddate")
+    private Date endDate;
+
+    /**
+     * 备注
+     */
+    @Column(name = "in_remark")
+    private String remark;
+
+    /**
+     * 环保要求
+     */
+    @Column(name = "in_environment")
+    private String environment;
+
+    /**
+     * 价格类型
+     */
+    @Column(name = "in_pricetype")
+    private String priceType;
+
+    /**
+     * 询价明细
+     */
+    @OneToMany(mappedBy = "inquiry", cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
+    @OrderBy("number")
+    private Set<PurcInquiryItemInfo> inquiryItems;
+
+    /**
+     * 附件
+     */
+    @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
+    @JoinTable(name = "purc$puinquiryattach", joinColumns = @JoinColumn(name = "in_id", referencedColumnName = "in_id") , inverseJoinColumns = @JoinColumn(name = "at_id", referencedColumnName = "at_id") )
+    private Set<Attach> attachs;
+
+    /**
+     * 采纳结果
+     */
+    @Column(name = "in_checked")
+    private Short check;
+
+    /**
+     * 单据状态(已提交、在录入)
+     */
+    @Column(name = "in_enterystatus")
+    private Integer enteryStatus;
+
+    /**
+     * 是否过期
+     */
+    @Column(name = "in_overdue", insertable = false, updatable = false)
+    private Short overdue;
+
+    /**
+     * 是否公开
+     */
+    @Column(name = "in_isopen")
+    private Short isOpen;
+
+    /**
+     * 收货地址
+     */
+    @Column(name = "in_ship")
+    private String ship;
+
+    /**
+     * 是否开票<br>
+     * 1. 是<br>
+     * 0. 否
+     */
+    @Column(name = "in_invoice")
+    private Short invoice;
+
+    /**
+     * 是否含税
+     */
+    @Column(name = "in_iftax")
+    private Short ifTax;
+
+    /**
+     * 币别
+     */
+    @Column(name = "in_currency")
+    private String currency;
+
+    /**
+     * 询价类型
+     */
+    @Column(name = "in_inquirytype")
+    private String inquirytype;
+
+    /**
+     * 应用来源
+     */
+    @Column(name = "in_sourceapp")
+    private String sourceapp;
+
+    /**
+     * 如果从erp传过来的,记录id
+     */
+    @Column(name = "in_erpid")
+    private Long erpid;
+
+    /**
+     * erp传过来的记录时间
+     */
+    @Column(name = "in_erpdate")
+    private  Date erpdate;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Enterprise getEnterprise() {
+        return enterprise;
+    }
+
+    public void setEnterprise(Enterprise enterprise) {
+        this.enterprise = enterprise;
+    }
+
+    public Long getRecorderUU() {
+        return recorderUU;
+    }
+
+    public void setRecorderUU(Long recorderUU) {
+        this.recorderUU = recorderUU;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public String getRecorder() {
+        return recorder;
+    }
+
+    public void setRecorder(String recorder) {
+        this.recorder = recorder;
+    }
+
+    public String getAuditor() {
+        return auditor;
+    }
+
+    public void setAuditor(String auditor) {
+        this.auditor = auditor;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getEnvironment() {
+        return environment;
+    }
+
+    public void setEnvironment(String environment) {
+        this.environment = environment;
+    }
+
+    public String getPriceType() {
+        return priceType;
+    }
+
+    public void setPriceType(String priceType) {
+        this.priceType = priceType;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Set<PurcInquiryItemInfo> getInquiryItems() {
+        return inquiryItems;
+    }
+
+    public void setInquiryItems(Set<PurcInquiryItemInfo> inquiryItems) {
+        this.inquiryItems = inquiryItems;
+    }
+
+    public Set<Attach> getAttachs() {
+        return attachs;
+    }
+
+    public void setAttachs(Set<Attach> attachs) {
+        this.attachs = attachs;
+    }
+
+    public Short getCheck() {
+        return check;
+    }
+
+    public void setCheck(Short check) {
+        this.check = check;
+    }
+
+    public Integer getEnteryStatus() {
+        return enteryStatus;
+    }
+
+    public void setEnteryStatus(Integer enteryStatus) {
+        this.enteryStatus = enteryStatus;
+    }
+
+    public Short getOverdue() {
+        return overdue;
+    }
+
+    public void setOverdue(Short overdue) {
+        this.overdue = overdue;
+    }
+
+    public Short getIsOpen() {
+        return isOpen;
+    }
+
+    public void setIsOpen(Short isOpen) {
+        this.isOpen = isOpen;
+    }
+
+    public String getShip() {
+        return ship;
+    }
+
+    public void setShip(String ship) {
+        this.ship = ship;
+    }
+
+    public Short getInvoice() {
+        return invoice;
+    }
+
+    public void setInvoice(Short invoice) {
+        this.invoice = invoice;
+    }
+
+    public Short getIfTax() {
+        return ifTax;
+    }
+
+    public void setIfTax(Short ifTax) {
+        this.ifTax = ifTax;
+    }
+
+    public String getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+
+    public String getInquirytype() {
+        return inquirytype;
+    }
+
+    public void setInquirytype(String inquirytype) {
+        this.inquirytype = inquirytype;
+    }
+
+    public String getSourceapp() {
+        return sourceapp;
+    }
+
+    public void setSourceapp(String sourceapp) {
+        this.sourceapp = sourceapp;
+    }
+
+    public Long getErpid() {
+        return erpid;
+    }
+
+    public void setErpid(Long erpid) {
+        this.erpid = erpid;
+    }
+
+    public Date getErpdate() {
+        return erpdate;
+    }
+
+    public void setErpdate(Date erpdate) {
+        this.erpdate = erpdate;
+    }
+}

+ 58 - 2
src/main/java/com/uas/ps/inquiry/model/PurcInquiryItem.java

@@ -2,7 +2,6 @@ package com.uas.ps.inquiry.model;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.uas.ps.entity.Product;
 
 import javax.persistence.*;
 import java.util.*;
@@ -47,6 +46,12 @@ public class PurcInquiryItem {
 	@Column(name = "id_prid")
 	private Long productId;
 
+	/**
+	 * 产品
+	 */
+	@OneToOne(cascade = {CascadeType.ALL})
+	@JoinColumn(name = "id_prid", insertable = false, updatable = false)
+	private Product product;
 
 	/**
 	 * ************* 上传的物料信息,因为可能是手动输入的,物料款不存在,需要先进行保存物料 *************
@@ -287,7 +292,15 @@ public class PurcInquiryItem {
 		this.productId = productId;
 	}
 
-	public String getCurrency() {
+    public Product getProduct() {
+        return product;
+    }
+
+    public void setProduct(Product product) {
+        this.product = product;
+    }
+
+    public String getCurrency() {
 		return currency;
 	}
 
@@ -546,4 +559,47 @@ public class PurcInquiryItem {
 		}
 		return inquiries;
     }
+
+	@Override
+	public String toString() {
+		return "PurcInquiryItem{" +
+				"id=" + id +
+				", number=" + number +
+				", inquiry=" + inquiry +
+				", userUU=" + userUU +
+				", productId=" + productId +
+				", product=" + product +
+				", prodCode='" + prodCode + '\'' +
+				", prodTitle='" + prodTitle + '\'' +
+				", spec='" + spec + '\'' +
+				", unit='" + unit + '\'' +
+				", cmpCode='" + cmpCode + '\'' +
+				", inbrand='" + inbrand + '\'' +
+				", currency='" + currency + '\'' +
+				", taxrate=" + taxrate +
+				", remark='" + remark + '\'' +
+				", vendUU=" + vendUU +
+				", vendUserUU=" + vendUserUU +
+				", fromDate=" + fromDate +
+				", toDate=" + toDate +
+				", vendFromDate=" + vendFromDate +
+				", vendToDate=" + vendToDate +
+				", minOrderQty=" + minOrderQty +
+				", minPackQty=" + minPackQty +
+				", brand='" + brand + '\'' +
+				", vendorprodcode='" + vendorprodcode + '\'' +
+				", leadtime=" + leadtime +
+				", replies=" + replies +
+				", status=" + status +
+				", agreed=" + agreed +
+				", custLap=" + custLap +
+				", overdue=" + overdue +
+				", source='" + source + '\'' +
+				", isOpen=" + isOpen +
+				", needquantity=" + needquantity +
+				", sourceid=" + sourceid +
+				", date=" + date +
+				", enuu=" + enuu +
+				'}';
+	}
 }

+ 618 - 0
src/main/java/com/uas/ps/inquiry/model/PurcInquiryItemInfo.java

@@ -0,0 +1,618 @@
+package com.uas.ps.inquiry.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import java.util.*;
+
+/**
+ * 平台新增询价单明细(查询,用明细带出主表信息)
+ *
+ * @author hejq
+ * @date 2018-01-17 15:46
+ */
+@Entity
+@Table(name = "purc$puinquiryitems")
+public class PurcInquiryItemInfo {
+
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	@Column(name = "id_id")
+	private Long id;
+
+	/**
+	 * 序号
+	 */
+	@Column(name = "id_number")
+	private Short number;
+
+	/**
+	 * 询价单
+	 */
+	@ManyToOne(cascade = CascadeType.ALL, optional = true)
+	@JoinColumn(name = "id_inid", nullable = false)
+	private PurcInquiryInfo inquiry;
+
+	/**
+	 * 买家采购员UU
+	 */
+	@Column(name = "id_useruu")
+	private Long userUU;
+
+	/**
+	 * 产品id
+	 */
+	@Column(name = "id_prid")
+	private Long productId;
+
+	/**
+	 * 产品
+	 */
+	@OneToOne(cascade = {CascadeType.ALL})
+	@JoinColumn(name = "id_prid", insertable = false, updatable = false)
+	private Product product;
+
+	/**
+	 * ************* 上传的物料信息,因为可能是手动输入的,物料款不存在,需要先进行保存物料 *************
+	 */
+	/**
+	 * 物料编号
+	 */
+	@Column(name = "id_prodcode")
+	private String prodCode;
+
+	/**
+	 * 名称
+	 */
+	@Column(name = "id_prodtitle")
+	private String prodTitle;
+
+	/**
+	 * 规格
+	 */
+	@Column(name = "id_prodspec")
+	private String spec;
+
+	/**
+	 * 单位
+	 */
+	@Column(name = "id_unit")
+	private String unit;
+
+	/**
+	 * 型号
+	 */
+	@Column(name = "id_cmpcode")
+	private String cmpCode;
+
+	/**
+	 * 品牌
+	 */
+	@Column(name = "id_inbrand")
+	private String inbrand;
+	/**
+	 * ******end*******
+	 */
+
+	/**
+	 * 币种
+	 */
+	@Column(name = "id_currency")
+	private String currency;
+
+	/**
+	 * 税率
+	 */
+	@Column(name = "id_taxrate")
+	private Float taxrate;
+
+	/**
+	 * 备注
+	 */
+	@Column(name = "id_remark")
+	private String remark;
+
+	/**
+	 * 供应商UU
+	 */
+	@Column(name = "id_venduu")
+	private Long vendUU;
+
+    /**
+     * 报价企业信息
+     */
+    @OneToOne(cascade = { CascadeType.MERGE, CascadeType.REFRESH })
+    @JoinColumn(name = "id_venduu", insertable = false, updatable = false)
+    private Enterprise enterprise;
+
+	/**
+	 * 供应商联系人UU
+	 */
+	@Column(name = "id_venduseruu")
+	private Long vendUserUU;
+
+	/**
+	 * (买家预先提供的)有效期始
+	 */
+	@Column(name = "id_fromdate")
+	private Date fromDate;
+
+	/**
+	 * (买家预先提供的)有效期止
+	 */
+	@Column(name = "id_todate")
+	private Date toDate;
+
+	/**
+	 * (卖家报的)有效期始
+	 */
+	@Column(name = "id_vendfromdate")
+	private Date vendFromDate;
+
+	/**
+	 * (卖家报的)有效期止
+	 */
+	@Column(name = "id_vendtodate")
+	private Date vendToDate;
+
+	/**
+	 * (卖家报的)最小订购量
+	 */
+	@Column(name = "id_minorderqty")
+	private Double minOrderQty;
+
+	/**
+	 * (卖家报的)最小包装量
+	 */
+	@Column(name = "id_minpackqty")
+	private Double minPackQty;
+
+	/**
+	 * (卖家报的)物料品牌
+	 */
+	@Column(name = "id_brand")
+	private String brand;
+
+	/**
+	 * (卖家报的)供应商物料编号
+	 */
+	@Column(name = "id_vendorprodcode")
+	private String vendorprodcode;
+
+	/**
+	 * (卖家报的)交货周期(天数)
+	 */
+	@Column(name = "id_leadtime")
+	private Long leadtime;
+
+	/**
+	 * 分段报价明细
+	 */
+	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+	@JoinColumn(name = "ir_idid")
+	@OrderBy("lapQty")
+	private List<PurchaseInquiryReply> replies;
+
+	/**
+	 * {未回复、已回复}
+	 */
+	@Column(name = "id_status")
+	private Short status;
+
+	/**
+	 * 是否采纳
+	 */
+	@Column(name = "id_agreed")
+	private Short agreed;
+
+	/**
+	 * 是否买家已设置分段数
+	 */
+	@Column(name = "id_custlap")
+	private Short custLap;
+
+	/**
+	 * search项目进行是否已过期时实际根据主表中enddate与当前时间的比较获取,但是数据库无字段会报“标识符无效”的错误
+	 * 所以建立此字段,但是此字段不会赋值。
+	 * 
+	 * @return
+	 */
+	@Column(name = "id_overdue")
+	private Short overdue;
+
+	/**
+	 * 来源ERP或B2B
+	 */
+	@Column(name = "id_source")
+	private String source;
+
+	/**
+	 * 是否公开
+	 */
+	@Column(name = "id_isopen")
+	private Short isOpen;
+
+	/**
+	 * 需求数量
+	 */
+	@Column(name = "id_needquantity")
+	private Double needquantity;
+
+	/**
+	 * 来源id,可能是ERP同步过来的单据
+	 */
+	@Column(name = "id_sourceid")
+	private Long sourceid;
+
+    /**
+     * 单据日期,索引过滤需要
+     */
+	@Column(name = "id_date")
+    private Date date;
+
+	/**
+	 * 企业uu,公共询价需要这个字段做标识
+	 */
+	@Transient
+	private Long enuu;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Short getNumber() {
+		return number;
+	}
+
+	public void setNumber(Short number) {
+		this.number = number;
+	}
+
+	public PurcInquiryInfo getInquiry() {
+		return inquiry;
+	}
+
+	public void setInquiry(PurcInquiryInfo inquiry) {
+		this.inquiry = inquiry;
+	}
+
+	public Long getUserUU() {
+		return userUU;
+	}
+
+	public void setUserUU(Long userUU) {
+		this.userUU = userUU;
+	}
+
+	public Long getProductId() {
+		return productId;
+	}
+
+	public void setProductId(Long productId) {
+		this.productId = productId;
+	}
+
+    public Product getProduct() {
+        return product;
+    }
+
+    public void setProduct(Product product) {
+        this.product = product;
+    }
+
+    public String getCurrency() {
+		return currency;
+	}
+
+	public void setCurrency(String currency) {
+		this.currency = currency;
+	}
+
+	public Float getTaxrate() {
+		return taxrate;
+	}
+
+	public void setTaxrate(Float taxrate) {
+		this.taxrate = taxrate;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Long getVendUU() {
+		return vendUU;
+	}
+
+	public void setVendUU(Long vendUU) {
+		this.vendUU = vendUU;
+	}
+
+    public Enterprise getEnterprise() {
+        return enterprise;
+    }
+
+    public void setEnterprise(Enterprise enterprise) {
+        this.enterprise = enterprise;
+    }
+
+    public Long getVendUserUU() {
+		return vendUserUU;
+	}
+
+	public void setVendUserUU(Long vendUserUU) {
+		this.vendUserUU = vendUserUU;
+	}
+
+	public Date getFromDate() {
+		return fromDate;
+	}
+
+	public void setFromDate(Date fromDate) {
+		this.fromDate = fromDate;
+	}
+
+	public Date getToDate() {
+		return toDate;
+	}
+
+	public void setToDate(Date toDate) {
+		this.toDate = toDate;
+	}
+
+	public Date getVendFromDate() {
+		return vendFromDate;
+	}
+
+	public void setVendFromDate(Date vendFromDate) {
+		this.vendFromDate = vendFromDate;
+	}
+
+	public Date getVendToDate() {
+		return vendToDate;
+	}
+
+	public void setVendToDate(Date vendToDate) {
+		this.vendToDate = vendToDate;
+	}
+
+	public Double getMinOrderQty() {
+		return minOrderQty;
+	}
+
+	public void setMinOrderQty(Double minOrderQty) {
+		this.minOrderQty = minOrderQty;
+	}
+
+	public Double getMinPackQty() {
+		return minPackQty;
+	}
+
+	public void setMinPackQty(Double minPackQty) {
+		this.minPackQty = minPackQty;
+	}
+
+	public String getBrand() {
+		return brand;
+	}
+
+	public void setBrand(String brand) {
+		this.brand = brand;
+	}
+
+	public String getVendorprodcode() {
+		return vendorprodcode;
+	}
+
+	public void setVendorprodcode(String vendorprodcode) {
+		this.vendorprodcode = vendorprodcode;
+	}
+
+	public Long getLeadtime() {
+		return leadtime;
+	}
+
+	public void setLeadtime(Long leadtime) {
+		this.leadtime = leadtime;
+	}
+
+	public List<PurchaseInquiryReply> getReplies() {
+		return replies;
+	}
+
+	public void setReplies(List<PurchaseInquiryReply> replies) {
+		this.replies = replies;
+	}
+
+	public Short getStatus() {
+		return status;
+	}
+
+	public void setStatus(Short status) {
+		this.status = status;
+	}
+
+	public Short getAgreed() {
+		return agreed;
+	}
+
+	public void setAgreed(Short agreed) {
+		this.agreed = agreed;
+	}
+
+	public Short getCustLap() {
+		return custLap;
+	}
+
+	public void setCustLap(Short custLap) {
+		this.custLap = custLap;
+	}
+
+	public Short getOverdue() {
+		return overdue;
+	}
+
+	public void setOverdue(Short overdue) {
+		this.overdue = overdue;
+	}
+
+	public String getSource() {
+		return source;
+	}
+
+	public void setSource(String source) {
+		this.source = source;
+	}
+
+	public Short getIsOpen() {
+		return isOpen;
+	}
+
+	public void setIsOpen(Short isOpen) {
+		this.isOpen = isOpen;
+	}
+
+	public String getProdCode() {
+		return prodCode;
+	}
+
+	public void setProdCode(String prodCode) {
+		this.prodCode = prodCode;
+	}
+
+	public String getProdTitle() {
+		return prodTitle;
+	}
+
+	public void setProdTitle(String prodTitle) {
+		this.prodTitle = prodTitle;
+	}
+
+	public String getSpec() {
+		return spec;
+	}
+
+	public void setSpec(String spec) {
+		this.spec = spec;
+	}
+
+	public String getUnit() {
+		return unit;
+	}
+
+	public void setUnit(String unit) {
+		this.unit = unit;
+	}
+
+	public String getCmpCode() {
+		return cmpCode;
+	}
+
+	public void setCmpCode(String cmpCode) {
+		this.cmpCode = cmpCode;
+	}
+
+	public String getInbrand() {
+		return inbrand;
+	}
+
+	public void setInbrand(String inbrand) {
+		this.inbrand = inbrand;
+	}
+
+	public Double getNeedquantity() {
+		return needquantity;
+	}
+
+	public void setNeedquantity(Double needquantity) {
+		this.needquantity = needquantity;
+	}
+
+	public Long getSourceid() {
+		return sourceid;
+	}
+
+	public void setSourceid(Long sourceid) {
+		this.sourceid = sourceid;
+	}
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public static List<PurcInquiryInfo> distinct(List<PurcInquiryItemInfo> inquiryItems) {
+		List<PurcInquiryInfo> inquiries = new ArrayList<>();
+		Set<Long> keys = new HashSet<>();
+		for (PurcInquiryItemInfo item : inquiryItems) {
+			if (!keys.contains(item.getInquiry().getId())) {
+				inquiries.add(item.getInquiry());
+				keys.add(item.getInquiry().getId());
+			}
+		}
+		return inquiries;
+    }
+
+	@Override
+	public String toString() {
+		return "PurcInquiryItem{" +
+				"id=" + id +
+				", number=" + number +
+				", inquiry=" + inquiry +
+				", userUU=" + userUU +
+				", productId=" + productId +
+				", product=" + product +
+				", prodCode='" + prodCode + '\'' +
+				", prodTitle='" + prodTitle + '\'' +
+				", spec='" + spec + '\'' +
+				", unit='" + unit + '\'' +
+				", cmpCode='" + cmpCode + '\'' +
+				", inbrand='" + inbrand + '\'' +
+				", currency='" + currency + '\'' +
+				", taxrate=" + taxrate +
+				", remark='" + remark + '\'' +
+				", vendUU=" + vendUU +
+				", vendUserUU=" + vendUserUU +
+				", fromDate=" + fromDate +
+				", toDate=" + toDate +
+				", vendFromDate=" + vendFromDate +
+				", vendToDate=" + vendToDate +
+				", minOrderQty=" + minOrderQty +
+				", minPackQty=" + minPackQty +
+				", brand='" + brand + '\'' +
+				", vendorprodcode='" + vendorprodcode + '\'' +
+				", leadtime=" + leadtime +
+				", replies=" + replies +
+				", status=" + status +
+				", agreed=" + agreed +
+				", custLap=" + custLap +
+				", overdue=" + overdue +
+				", source='" + source + '\'' +
+				", isOpen=" + isOpen +
+				", needquantity=" + needquantity +
+				", sourceid=" + sourceid +
+				", date=" + date +
+				", enuu=" + enuu +
+				'}';
+	}
+}

+ 447 - 0
src/main/java/com/uas/ps/inquiry/page/PageInfo.java

@@ -0,0 +1,447 @@
+package com.uas.ps.inquiry.page;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.ps.inquiry.page.criteria.CriterionExpression;
+import com.uas.ps.inquiry.page.criteria.PredicateUtils;
+import com.uas.ps.inquiry.page.exception.IllegalOperatorException;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+
+import javax.persistence.criteria.*;
+import java.util.*;
+
+/**
+ * 分页信息
+ * 
+ * @author yingp
+ * 
+ */
+public class PageInfo implements Pageable {
+
+	public PageInfo() {
+	}
+
+	/**
+	 * 分页信息
+	 * 
+	 * @param jsonPageParams
+	 */
+	public PageInfo(String jsonPageParams) {
+		PageParams params = JSONObject.parseObject(jsonPageParams,
+				PageParams.class);
+		getPageInfo(params);
+	}
+
+	public PageInfo(PageParams params) {
+		getPageInfo(params);
+	}
+
+	private void getPageInfo(PageParams params) {
+		this.pageSize = params.getCount();
+		if (this.pageSize == 0) {// 不传入页面大小,默认页面大小为5
+			this.pageSize = 5;
+		}
+		if (this.pageSize > 1000) {// 页面大小最大不可超过1000,防止服务器崩溃
+			throw new IllegalOperatorException("页面大小不可超过1000");
+		}
+		this.pageNumber = params.getPage();
+		if (this.pageNumber == 0) {
+			this.pageNumber = 1;// 不传入页码,默认为第一页
+		}
+		this.offset = this.pageSize * (this.pageNumber - 1);
+		if (params.getFilter() != null)
+			this.filters = JSONObject.parseObject(params.getFilter());
+		if (params.getSorting() != null) {
+			JSONObject sorting = JSONObject.parseObject(params.getSorting());
+			LinkedList<Sort.Order> orders = new LinkedList<Sort.Order>();
+			for (Object property : sorting.keySet()) {
+				orders.add(new Sort.Order(Direction.fromString(sorting.get(
+						property).toString()), property.toString()));
+			}
+			sort = new Sort(orders);
+		}
+	}
+
+	/**
+	 * 分页信息
+	 * 
+	 * @param pageNumber
+	 *            页码
+	 * @param pageSize
+	 *            单页条数
+	 */
+	public PageInfo(int pageNumber, int pageSize) {
+		this.pageNumber = pageNumber;
+		this.pageSize = pageSize;
+		this.offset = this.pageSize * (this.pageNumber - 1);
+	}
+
+	/**
+	 * 分页信息
+	 * 
+	 * @param pageNumber
+	 *            页码
+	 * @param pageSize
+	 *            单页条数
+	 */
+	public PageInfo(int pageNumber, int pageSize, int offset) {
+		this.pageNumber = pageNumber;
+		this.pageSize = pageSize;
+		this.offset = offset;
+	}
+
+	public void filter(String key, Object value) {
+		if (filters == null)
+			filters = new HashMap<String, Object>();
+		filters.put(key, value);
+	}
+
+	public void filter(String key, Object value, Boolean ignoreCase) {
+		if (filters == null)
+			filters = new HashMap<String, Object>();
+		filters.put(key, value);
+		if (ignoreCaseMap == null) {
+			ignoreCaseMap = new HashMap<String, Boolean>();
+		}
+		if (ignoreCase) {
+			ignoreCaseMap.put(key, ignoreCase);
+		}
+	}
+
+	public void filterAll(Map<String, Object> filters) {
+		if (this.filters == null)
+			this.filters = new HashMap<String, Object>();
+		this.filters.putAll(filters);
+	}
+
+	/**
+	 * 表达式
+	 * 
+	 * @param expression
+	 */
+	public void expression(CriterionExpression expression) {
+		if (expression != null) {
+			if (expressions == null)
+				expressions = new HashSet<CriterionExpression>();
+			expressions.add(expression);
+		}
+	}
+
+	/**
+	 * 添加orExpression
+	 * 
+	 * @param expression
+	 */
+	public void orExpression(CriterionExpression expression) {
+		if (expression != null) {
+			if (orExpressions == null)
+				orExpressions = new HashSet<CriterionExpression>();
+			orExpressions.add(expression);
+		}
+	}
+
+	/**
+	 * 排序
+	 * 
+	 * @param property
+	 *            需要排序的字段
+	 * @param direction
+	 *            方向
+	 */
+	public void sorting(String property, Direction direction) {
+		sort = new Sort(direction, property);
+	}
+
+	/**
+	 * 排序
+	 * 
+	 * @param direction
+	 *            方向
+	 * @param properties
+	 *            需要排序的字段
+	 */
+	public void sorting(Direction direction, String... properties) {
+		sort = new Sort(direction, properties);
+	}
+
+	private int pageNumber;
+
+	private int pageSize;
+
+	private int offset;
+
+	private Sort sort;
+
+	private Map<String, Object> filters;
+
+	private Set<CriterionExpression> expressions; // 这个里面的条件,全部都用and连接
+
+	private Set<CriterionExpression> orExpressions; // 这个里面的条件,全部都用or连接
+
+	private Map<String, Boolean> ignoreCaseMap; // 是否对这个字段 进行忽略大小写的查询
+
+	public Set<CriterionExpression> getOrExpressions() {
+		return orExpressions;
+	}
+
+	public void setOrExpressions(Set<CriterionExpression> orExpressions) {
+		this.orExpressions = orExpressions;
+	}
+
+	public int getPageNumber() {
+		return pageNumber;
+	}
+
+	public int getPageSize() {
+		return pageSize;
+	}
+
+	public int getOffset() {
+		return offset;
+	}
+
+	public Sort getSort() {
+		return sort;
+	}
+
+	public void setPageNumber(int pageNumber) {
+		this.pageNumber = pageNumber;
+	}
+
+	public void setPageSize(int pageSize) {
+		this.pageSize = pageSize;
+	}
+
+	public void setOffset(int offset) {
+		this.offset = offset;
+	}
+
+	public void setSort(Sort sort) {
+		this.sort = sort;
+	}
+
+	public Map<String, Object> getFilters() {
+		return filters;
+	}
+
+	public void setFilters(Map<String, Object> filters) {
+		this.filters = filters;
+	}
+
+	public Set<CriterionExpression> getExpressions() {
+		return expressions;
+	}
+
+	public void setExpressions(Set<CriterionExpression> expressions) {
+		this.expressions = expressions;
+	}
+
+	@SuppressWarnings("unchecked")
+	public Predicate[] getPredicates(Root<?> root, CriteriaQuery<?> query,
+			CriteriaBuilder builder) {
+		Predicate[] predicates = new Predicate[] {};
+		int i = 0;
+		if (filters != null && filters.size() > 0) {
+			Set<String> keys = filters.keySet();
+			predicates = new Predicate[keys.size()];
+			Object value = null;
+			for (String key : keys) {
+				value = filters.get(key);
+				if (value instanceof Number) {
+					Path<Number> param = PredicateUtils.getPath(root, key,
+							Number.class);
+					predicates[i++] = builder.equal(param, value);
+				} else if (value instanceof Map) {
+					predicates[i++] = getPredicate(root, query, builder, key,
+							(Map<String, Object>) value);
+				} else {
+					Path<String> param = PredicateUtils.getPath(root, key,
+							String.class);
+					if ((ignoreCaseMap == null)
+							|| (ignoreCaseMap.get(key) == null)
+							|| (!ignoreCaseMap.get(key))) {
+						predicates[i++] = builder.like(param,
+								"%" + value.toString() + "%");
+					} else { // 对数据的大小写忽略
+						predicates[i++] = builder.like(builder.upper(param),
+								"%" + value.toString().toUpperCase() + "%");
+					}
+				}
+			}
+		}
+		if (expressions != null && expressions.size() > 0) {
+			predicates = Arrays.copyOf(predicates, predicates.length
+					+ expressions.size());
+			for (CriterionExpression expression : expressions) {
+				predicates[i++] = expression.toPredicate(root, query, builder);
+			}
+		}
+
+		if (orExpressions != null && orExpressions.size() > 0) {
+			predicates = Arrays.copyOf(predicates, predicates.length + 1);
+			Predicate[] orPredicates = new Predicate[] {};
+			orPredicates = new Predicate[orExpressions.size()];
+			int j = 0;
+			for (CriterionExpression expression : orExpressions) {
+				orPredicates[j++] = expression
+						.toPredicate(root, query, builder);
+			}
+			if (orPredicates.length == 1) {
+				predicates[i++] = orPredicates[0];
+			} else {
+				predicates[i++] = builder.or(orPredicates);
+			}
+		}
+		return predicates;
+	}
+
+	/**
+	 * 传入单个字段的多个过滤条件<br>
+	 * 
+	 * @example {"filters":{"status":
+	 *          200,"date":{"gted":1441269176697,"lted":1441269176698}}}
+	 * 
+	 * @param root
+	 * @param query
+	 * @param builder
+	 * @param field
+	 *            字段名
+	 * @param valueMap
+	 *            条件map
+	 * @return
+	 */
+	private Predicate getPredicate(Root<?> root, CriteriaQuery<?> query,
+                                   CriteriaBuilder builder, String field, Map<String, Object> valueMap) {
+		Set<String> keys = valueMap.keySet();
+		Object val = null;
+		Predicate[] predicates = new Predicate[keys.size()];
+		int i = 0;
+		for (String valKey : keys) {
+			val = valueMap.get(valKey);
+			if (valKey.equals("ne")) {// 不等于 {"ne": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				if (val != null)
+					predicates[i++] = builder.notEqual(path,
+							String.valueOf(val));
+				else
+					predicates[i++] = builder.isNotNull(path);
+			} else if (valKey.equals("eq")) {// 等于 {"eq": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				if (val != null)
+					predicates[i++] = builder.equal(path, String.valueOf(val));
+				else
+					predicates[i++] = builder.isNull(path);
+			} else if (valKey.equals("gt")) {// 大于 {"gt": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				predicates[i++] = builder
+						.greaterThan(path, String.valueOf(val));
+			} else if (valKey.equals("lt")) {// 小于 {"lt": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				predicates[i++] = builder.lessThan(path, String.valueOf(val));
+			} else if (valKey.equals("gte")) {// 大于等于 {"gte": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				predicates[i++] = builder.greaterThanOrEqualTo(path,
+						String.valueOf(val));
+			} else if (valKey.equals("lte")) {// 小于等于 {"lte": "something"}
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				predicates[i++] = builder.lessThanOrEqualTo(path,
+						String.valueOf(val));
+			} else if (valKey.equals("gtd")) {// 日期大于 {"gtd": 1441269176697}
+				Path<Date> path = PredicateUtils.getPath(root, field,
+						Date.class);
+				predicates[i++] = builder.greaterThan(path,
+						new Date(Long.parseLong(String.valueOf(val))));
+			} else if (valKey.equals("ltd")) {// 日期小于 {"ltd": 1441269176697}
+				Path<Date> path = PredicateUtils.getPath(root, field,
+						Date.class);
+				predicates[i++] = builder.lessThan(path,
+						new Date(Long.parseLong(String.valueOf(val))));
+			} else if (valKey.equals("gted")) {// 日期大于等于 {"gted": 1441269176697}
+				Path<Date> path = PredicateUtils.getPath(root, field,
+						Date.class);
+				predicates[i++] = builder.greaterThanOrEqualTo(path, new Date(
+						Long.parseLong(String.valueOf(val))));
+			} else if (valKey.equals("lted")) {// 日期小于等于 {"lted": 1441269176697}
+				Path<Date> path = PredicateUtils.getPath(root, field,
+						Date.class);
+				predicates[i++] = builder.lessThanOrEqualTo(path,
+						new Date(Long.parseLong(String.valueOf(val))));
+			} else {
+				Path<String> path = PredicateUtils.getPath(root, field,
+						String.class);
+				predicates[i++] = builder.equal(path, String.valueOf(val));
+			}
+		}
+		return builder.and(predicates);
+	}
+
+	public Pageable next() {
+		return null;
+	}
+
+	public Pageable previousOrFirst() {
+		return null;
+	}
+
+	public Pageable first() {
+		return null;
+	}
+
+	public boolean hasPrevious() {
+		return false;
+	}
+
+	public Pageable getPageable() {
+		final Pageable scope = this;
+		return new Pageable() {
+
+			@Override
+			public Pageable previousOrFirst() {
+				return scope.previousOrFirst();
+			}
+
+			@Override
+			public Pageable next() {
+				return scope.next();
+			}
+
+			@Override
+			public boolean hasPrevious() {
+				return scope.hasPrevious();
+			}
+
+			@Override
+			public Sort getSort() {
+				return scope.getSort();
+			}
+
+			@Override
+			public int getPageSize() {
+				return scope.getPageSize();
+			}
+
+			@Override
+			public int getPageNumber() {
+				return scope.getPageNumber();
+			}
+
+			@Override
+			public int getOffset() {
+				return scope.getOffset();
+			}
+
+			@Override
+			public Pageable first() {
+				return scope.first();
+			}
+		};
+	}
+
+}

+ 61 - 0
src/main/java/com/uas/ps/inquiry/page/PageParams.java

@@ -0,0 +1,61 @@
+package com.uas.ps.inquiry.page;
+
+import java.io.Serializable;
+
+public class PageParams implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	private int count;
+	private int page;
+	private String filter;
+	private String sorting;
+
+	public int getCount() {
+		return count;
+	}
+
+	public void setCount(int count) {
+		this.count = count;
+	}
+
+	public int getPage() {
+		return page;
+	}
+
+	public void setPage(int page) {
+		this.page = page;
+	}
+
+	public String getFilter() {
+		return filter;
+	}
+
+	public void setFilter(String filter) {
+		this.filter = filter;
+	}
+
+	public String getSorting() {
+		return sorting;
+	}
+
+	public void setSorting(String sorting) {
+		this.sorting = sorting;
+	}
+
+	public PageParams(int count, int page, String filter, String sorting) {
+		super();
+		this.count = count;
+		this.page = page;
+		this.filter = filter;
+		this.sorting = sorting;
+	}
+
+	public PageParams() {
+		super();
+	}
+
+
+}

+ 132 - 0
src/main/java/com/uas/ps/inquiry/page/SearchFilter.java

@@ -0,0 +1,132 @@
+package com.uas.ps.inquiry.page;
+
+import java.util.Collection;
+
+/**
+ * 单据查询搜索条件
+ * @author suntg
+ * @since 2015年8月20日下午2:37:22
+ */
+public class SearchFilter {
+
+	/**
+	 * 关键词
+	 */
+	private String keyword;
+	/**
+	 * 开始日期
+	 */
+	private Long fromDate;
+	/**
+	 * 结束日期
+	 */
+	private Long endDate;
+	/**
+	 * 开始交货日期
+	 */
+	private Long fromDelivery;
+	/**
+	 * 结束交货日期
+	 */
+	private Long endDelivery;
+	/**
+	 * 开始价格
+	 */
+	private Double fromPrice;
+	/**
+	 * 结束价格
+	 */
+	private Double endPrice;
+	/**
+	 * 客户分配条件
+	 */
+	private Collection<?> distribute;
+
+	/**
+	 * 供应商UU
+	 */
+	private Long vendUU;
+
+	/**
+	 * 客户UU
+	 */
+	private Long enUU;
+
+	/**
+	 * 用户UU
+	 */
+	private Long userUU;
+
+	public String getKeyword() {
+		return keyword;
+	}
+	public void setKeyword(String keyword) {
+		this.keyword = keyword;
+	}
+	public Long getFromDate() {
+		return fromDate;
+	}
+	public void setFromDate(Long fromDate) {
+		this.fromDate = fromDate;
+	}
+	public Long getEndDate() {
+		return endDate;
+	}
+	public void setEndDate(Long endDate) {
+		this.endDate = endDate;
+	}
+	public Long getFromDelivery() {
+		return fromDelivery;
+	}
+	public void setFromDelivery(Long fromDelivery) {
+		this.fromDelivery = fromDelivery;
+	}
+	public Long getEndDelivery() {
+		return endDelivery;
+	}
+	public void setEndDelivery(Long endDelivery) {
+		this.endDelivery = endDelivery;
+	}
+	public Double getFromPrice() {
+		return fromPrice;
+	}
+	public void setFromPrice(Double fromPrice) {
+		this.fromPrice = fromPrice;
+	}
+	public Double getEndPrice() {
+		return endPrice;
+	}
+	public void setEndPrice(Double endPrice) {
+		this.endPrice = endPrice;
+	}
+	public Collection<?> getDistribute() {
+		return distribute;
+	}
+	public void setDistribute(Collection<?> distribute) {
+		this.distribute = distribute;
+	}
+
+	public Long getVendUU() {
+		return vendUU;
+	}
+
+	public void setVendUU(Long vendUU) {
+		this.vendUU = vendUU;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Long getUserUU() {
+		return userUU;
+	}
+
+	public void setUserUU(Long userUU) {
+		this.userUU = userUU;
+	}
+}

+ 65 - 0
src/main/java/com/uas/ps/inquiry/page/criteria/CriterionExpression.java

@@ -0,0 +1,65 @@
+package com.uas.ps.inquiry.page.criteria;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+/**
+ * 条件表达式接口
+ * 
+ * @author yingp
+ * 
+ */
+public interface CriterionExpression {
+
+	public enum Operator {
+		/**
+		 * 等于
+		 */
+		EQ,
+		/**
+		 * 不等于
+		 */
+		NE,
+		/**
+		 * like
+		 */
+		LIKE,
+		/**
+		 * 大于
+		 */
+		GT,
+		/**
+		 * 小于
+		 */
+		LT,
+		/**
+		 * 大于等于
+		 */
+		GTE,
+		/**
+		 * 小于等于
+		 */
+		LTE,
+		/**
+		 * and
+		 */
+		AND,
+		/**
+		 * or
+		 */
+		OR,
+		/**
+		 * is null
+		 */
+		IS_NULL,
+		/**
+		 * is not null
+		 */
+		IS_NOT_NULL
+	}
+
+	public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder);
+
+}

+ 49 - 0
src/main/java/com/uas/ps/inquiry/page/criteria/LogicalExpression.java

@@ -0,0 +1,49 @@
+package com.uas.ps.inquiry.page.criteria;
+
+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.List;
+
+/**
+ * 逻辑条件表达式 用于复杂条件时使用
+ * 
+ * @author yingp
+ * 
+ */
+public class LogicalExpression implements CriterionExpression {
+
+	/**
+	 * 逻辑表达式中包含的表达式
+	 */
+	private CriterionExpression[] expressions;
+
+	/**
+	 * 运算符
+	 */
+	private Operator operator;
+
+	public LogicalExpression(CriterionExpression[] expressions, Operator operator) {
+		this.expressions = expressions;
+		this.operator = operator;
+	}
+
+	public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+		List<Predicate> predicates = new ArrayList<Predicate>();
+		for (int i = 0, len = this.expressions.length; i < len; i++) {
+			predicates.add(this.expressions[i].toPredicate(root, query, builder));
+		}
+		switch (operator) {
+		case OR:
+			return builder.or(predicates.toArray(new Predicate[predicates.size()]));
+		case AND:
+			return builder.and(predicates.toArray(new Predicate[predicates.size()]));
+		default:
+			return null;
+		}
+
+	}
+
+}

+ 49 - 0
src/main/java/com/uas/ps/inquiry/page/criteria/PredicateFactory.java

@@ -0,0 +1,49 @@
+package com.uas.ps.inquiry.page.criteria;
+
+import org.springframework.data.jpa.domain.Specification;
+
+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.List;
+
+/**
+ * 特殊查询条件的容器
+ * 
+ * @author yingp
+ * 
+ * @param <T>
+ */
+public class PredicateFactory<T> implements Specification<T> {
+
+	private List<CriterionExpression> expressions = new ArrayList<CriterionExpression>();
+
+	public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
+			CriteriaBuilder builder) {
+		if (!expressions.isEmpty()) {
+			List<Predicate> predicates = new ArrayList<Predicate>();
+			for (CriterionExpression c : expressions) {
+				predicates.add(c.toPredicate(root, query, builder));
+			}
+			// 将所有条件用 and 联合起来
+			if (predicates.size() > 0) {
+				return builder.and(predicates.toArray(new Predicate[predicates.size()]));
+			}
+		}
+		return builder.conjunction();
+	}
+
+	/**
+	 * 增加简单条件表达式
+	 * 
+	 */
+	public PredicateFactory<T> add(CriterionExpression expression) {
+		if (expression != null) {
+			expressions.add(expression);
+		}
+		return this;
+	}
+
+}

+ 231 - 0
src/main/java/com/uas/ps/inquiry/page/criteria/PredicateUtils.java

@@ -0,0 +1,231 @@
+package com.uas.ps.inquiry.page.criteria;
+
+import org.hibernate.criterion.MatchMode;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.Path;
+import java.util.Collection;
+
+/**
+ * 条件构造器 用于创建条件表达式
+ * 
+ */
+public class PredicateUtils {
+
+	/**
+	 * 等于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression eq(String param, Object value, boolean ignoreNull) {
+		if (StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.EQ);
+	}
+
+	/**
+	 * 不等于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression ne(String param, Object value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.NE);
+	}
+
+	/**
+	 * 模糊匹配
+	 * 
+	 * @param param
+	 * @param value
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression like(String param, String value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.LIKE);
+	}
+	
+	/**
+	 * 模糊匹配
+	 * 
+	 * @param param
+	 * @param value
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression like(String param, String value, boolean ignoreNull, boolean ignoreCase) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.LIKE, ignoreCase);
+	}
+
+	/**
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param matchMode
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression like(String param, String value, MatchMode matchMode, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.LIKE);
+	}
+
+	/**
+	 * 大于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression gt(String param, Object value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.GT);
+	}
+
+	/**
+	 * 小于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression lt(String param, Object value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.LT);
+	}
+
+	/**
+	 * 大于等于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression gte(String param, Object value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.GTE);
+	}
+
+	/**
+	 * 小于等于
+	 * 
+	 * @param param
+	 * @param value 注意和modul对应字段的数据类型对应
+	 * @param ignoreNull
+	 * @return
+	 */
+	public static SimpleExpression lte(String param, Object value, boolean ignoreNull) {
+		if (ignoreNull && StringUtils.isEmpty(value))
+			return null;
+		return new SimpleExpression(param, value, CriterionExpression.Operator.LTE);
+	}
+
+	/**
+	 * 为空
+	 * 
+	 * @param param
+	 * @return
+	 */
+	public static SimpleExpression isNull(String param) {
+		return new SimpleExpression(param, CriterionExpression.Operator.IS_NULL);
+	}
+
+	/**
+	 * 不为空
+	 * 
+	 * @param param
+	 * @return
+	 */
+	public static SimpleExpression isNotNull(String param) {
+		return new SimpleExpression(param, CriterionExpression.Operator.IS_NOT_NULL);
+	}
+
+	/**
+	 * 并且
+	 * 
+	 * @param expressions
+	 * @return
+	 */
+	public static LogicalExpression and(CriterionExpression... expressions) {
+		return new LogicalExpression(expressions, CriterionExpression.Operator.AND);
+	}
+
+	/**
+	 * 或者
+	 * 
+	 * @param expressions
+	 * @return
+	 */
+	public static LogicalExpression or(CriterionExpression... expressions) {
+		return new LogicalExpression(expressions, CriterionExpression.Operator.OR);
+	}
+
+	/**
+	 * 包含于
+	 * 
+	 * @param param
+	 * @param value
+	 * @return
+	 */
+	@SuppressWarnings("rawtypes")
+	public static LogicalExpression in(String param, Collection value, boolean ignoreNull) {
+		if (ignoreNull && (value == null || value.isEmpty())) {
+			return null;
+		}
+		SimpleExpression[] ses = new SimpleExpression[value.size()];
+		int i = 0;
+		for (Object obj : value) {
+			ses[i] = new SimpleExpression(param, obj, CriterionExpression.Operator.EQ);
+			i++;
+		}
+		return new LogicalExpression(ses, CriterionExpression.Operator.OR);
+	}
+
+	/**
+	 * 包含于
+	 * 
+	 * @param param
+	 * @param values
+	 * @return
+	 */
+	public static LogicalExpression in(String param, Object[] values, boolean ignoreNull) {
+		if (ignoreNull && (values == null || values.length == 0)) {
+			return null;
+		}
+		SimpleExpression[] ses = new SimpleExpression[values.length];
+		int i = 0;
+		for (Object obj : values) {
+			ses[i] = new SimpleExpression(param, obj, CriterionExpression.Operator.EQ);
+			i++;
+		}
+		return new LogicalExpression(ses, CriterionExpression.Operator.OR);
+	}
+
+	@SuppressWarnings("unchecked")
+	public static <T, R> Path<R> getPath(Path<T> root, String path, Class<R> resultType) {
+		String[] pathElements = path.split("\\.");
+		Path<?> retVal = root;
+		for (String pathEl : pathElements) {
+			retVal = (Path<R>) retVal.get(pathEl);
+		}
+		return (Path<R>) retVal;
+	}
+}

+ 106 - 0
src/main/java/com/uas/ps/inquiry/page/criteria/SimpleExpression.java

@@ -0,0 +1,106 @@
+package com.uas.ps.inquiry.page.criteria;
+
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.*;
+
+/**
+ * 条件表达式
+ * 
+ * @author yingp
+ * 
+ */
+public class SimpleExpression implements CriterionExpression {
+
+	/**
+	 * 属性
+	 */
+	private String param;
+	/**
+	 * 值
+	 */
+	private Object value;
+	
+	/*
+	 * 是否忽略大小写
+	 */
+	private boolean ignoreCase;
+	/**
+	 * 运算符
+	 */
+	private Operator operator;
+	
+	public SimpleExpression(String param, Object value, Operator operator) {
+		this.param = param;
+		this.value = value;
+		this.operator = operator;
+		this.ignoreCase = false;
+	}
+
+	public SimpleExpression(String param, Object value, Operator operator, boolean ignoreCase) {
+		this.param = param;
+		this.value = value;
+		this.operator = operator;
+		this.ignoreCase = ignoreCase;
+	}
+
+	protected SimpleExpression(String param, Operator operator) {
+		this.param = param;
+		this.operator = operator;
+	}
+
+	public String getParam() {
+		return param;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public Operator getOperator() {
+		return operator;
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+		Path expression = null;
+		if (param.contains(".")) {
+			String[] names = StringUtils.split(param, ".");
+			expression = root.get(names[0]);
+			for (int i = 1; i < names.length; i++) {
+				expression = expression.get(names[i]);
+			}
+		} else {
+			expression = root.get(param);
+		}
+
+		switch (operator) {
+		case EQ:
+			return builder.equal(expression, value);
+		case NE:
+			return builder.notEqual(expression, value);
+		case LIKE:
+				if(ignoreCase) {
+					return builder.like(builder.upper((Expression<String>) expression), "%" + value.toString().toUpperCase() + "%");
+				}else {
+					return builder.like((Expression<String>) expression, "%" + value + "%");
+				}
+			
+		case LT:
+			return builder.lessThan(expression, (Comparable) value);
+		case GT:
+			return builder.greaterThan(expression, (Comparable) value);
+		case LTE:
+			return builder.lessThanOrEqualTo(expression, (Comparable) value);
+		case GTE:
+			return builder.greaterThanOrEqualTo(expression, (Comparable) value);
+		case IS_NULL:
+			return builder.isNull(expression);
+		case IS_NOT_NULL:
+			return builder.isNotNull(expression);
+		default:
+			return null;
+		}
+	}
+
+}

+ 32 - 0
src/main/java/com/uas/ps/inquiry/page/exception/IllegalOperatorException.java

@@ -0,0 +1,32 @@
+package com.uas.ps.inquiry.page.exception;
+
+/**
+ * 非法操作
+ * 
+ * @author yingp
+ * 
+ */
+public class IllegalOperatorException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3958657497510022539L;
+
+	public IllegalOperatorException() {
+		super("非法操作");
+	}
+
+	public IllegalOperatorException(String paramString) {
+		super(paramString);
+	}
+
+	public IllegalOperatorException(String paramString, Throwable paramThrowable) {
+		super(paramString, paramThrowable);
+	}
+
+	public IllegalOperatorException(Throwable paramThrowable) {
+		super(paramThrowable);
+	}
+
+}

+ 85 - 0
src/main/java/com/uas/ps/inquiry/service/InquiryForSaleService.java

@@ -0,0 +1,85 @@
+package com.uas.ps.inquiry.service;
+
+import com.uas.ps.inquiry.model.Attach;
+import com.uas.ps.inquiry.model.PublicInquiryItem;
+import org.springframework.ui.ModelMap;
+
+import java.util.List;
+
+/**
+ * 针对卖家,对询价的操作接口
+ *
+ * Created by hejq on 2018-01-18.
+ */
+public interface InquiryForSaleService {
+
+    /**
+     * 通过明细查询询价详情
+     *
+     * @param id 报价明细id
+     * @return
+     */
+    PublicInquiryItem findById(Long id);
+
+    /**
+     * 供应商报价时上传附件信息
+     *
+     * @param attach
+     * @return
+     */
+    Attach addAttachs(Attach attach);
+
+    /**
+     * 供应商保存报价信息
+     *
+     * @author hejq
+     * @date 2018-01-14 16:43
+     * @param item 报价信息
+     * @return
+     */
+    PublicInquiryItem add(PublicInquiryItem item);
+
+    /**
+     * 保存询价信息
+     *
+     * @author hejq
+     * @date 2018-01-15 9:16
+     * @param items 询价信息
+     * @return
+     */
+    List<PublicInquiryItem> saveItems(List<PublicInquiryItem> items);
+
+    /**
+     * 保存询价信息
+     *
+     * @param inquiryItem 报价信息
+     * @return
+     */
+    PublicInquiryItem save(PublicInquiryItem inquiryItem);
+
+    /**
+     * 通过公共询价明细id查询报价信息
+     *
+     * @param id 公共询价明细id
+     * @param enuu 供应商UU
+     * @return
+     */
+    PublicInquiryItem findBySourceIdAndEnuu(Long id, Long enuu);
+
+    /**
+     * 转成报价询价单
+     *
+     * @param item 询价明细
+     * @return
+     */
+    PublicInquiryItem saveItem(PublicInquiryItem item) throws Exception;
+
+    /**
+     * 通过id查询公共询价详情
+     *
+     * @param id 主键id
+     * @param enuu 企业uu
+     * @return
+     */
+    ModelMap findByIdAndEnuu(Long id, Long enuu);
+}

+ 37 - 0
src/main/java/com/uas/ps/inquiry/service/InquiryService.java

@@ -0,0 +1,37 @@
+package com.uas.ps.inquiry.service;
+
+import com.uas.ps.inquiry.model.*;
+import com.uas.ps.inquiry.page.PageInfo;
+import com.uas.ps.inquiry.page.SearchFilter;
+import org.springframework.data.domain.Page;
+
+/**
+ * 转询价报价后的数据查询
+ *
+ * Created by hejq on 2018-01-17.
+ */
+public interface InquiryService {
+
+    /**
+     * 查询公共询价列表信息
+     * @param info
+     * @param filter
+     * @return
+     */
+    Page<PurcInquiryItemInfo> findTodoByPageInfo(PageInfo info, SearchFilter filter);
+
+    /**
+     * 保存公共询价
+     *
+     * @param inquiry 询价信息
+     */
+    PurcInquiry saveInquiry(PurcInquiry inquiry);
+
+    /**
+     * 通过报价明细id对供应商报价进行相关审核操作
+     *
+     * @param id 报价明细id
+     * @param status 状态
+     */
+    void decideQuote(Long id, Short status);
+}

+ 13 - 32
src/main/java/com/uas/ps/inquiry/service/PublicInquiryService.java

@@ -5,7 +5,10 @@ import com.uas.ps.inquiry.entity.Inquiry;
 import com.uas.ps.inquiry.entity.InquiryDecide;
 import com.uas.ps.inquiry.entity.InquiryDetail;
 import com.uas.ps.inquiry.model.*;
+import com.uas.ps.inquiry.page.PageInfo;
+import com.uas.ps.inquiry.page.SearchFilter;
 import javassist.NotFoundException;
+import org.springframework.data.domain.Page;
 import org.springframework.ui.ModelMap;
 
 import java.util.List;
@@ -28,13 +31,6 @@ public interface PublicInquiryService {
      */
     void save(List<BatchInquiry> inquiries, Long enuu, String address) throws NotFoundException;
 
-    /**
-     * 保存公共询价
-     *
-     * @param inquiry
-     */
-    PurcInquiry saveInquiry(PurcInquiry inquiry);
-
     /**
      * 将ERP传入的inquiry信息转成公共询价服务中心需要的信息
      *
@@ -135,39 +131,24 @@ public interface PublicInquiryService {
     ModelMap transtoInquiry(Long id, Long enuu, Long useruu);
 
     /**
-     * 供应商保存报价信息
+     * 通过分页参数和过滤条件查询报价信息
      *
      * @author hejq
-     * @date 2018-01-14 16:43
-     * @param item 报价信息
+     * @date 2018-01-17 10:30
+     * @param info 分页参数
+     * @param filter 过滤条件
      * @return
      */
-    PublicInquiryItem add(PublicInquiryItem item);
+    Page<PublicInquiryItem> findByPageInfo(PageInfo info, SearchFilter filter);
 
     /**
-     * 保存询价信息
-     * 
+     * 通过分页参数和过滤条件查询公共询价价信息
      * @author hejq
-     * @date 2018-01-15 9:16
-     * @param items 询价信息
-     * @return
-     */
-    List<PublicInquiryItem> save(List<PublicInquiryItem> items);
-
-    /**
-     * 保存询价信息(供应商、客户可能都会调用这条数据)
-     *
-     * @param inquiryItem 报价信息
-     * @return
-     */
-    PublicInquiryItem save(PublicInquiryItem inquiryItem);
-
-    /**
-     * 供应商报价时上传附件信息
-     *
-     * @param attach
+     * @date 2018-01-18 15:32
+     * @param info
+     * @param filter
      * @return
      */
-    Attach addAttachs(Attach attach);
+    Page<PurcInquiryItemInfo> findTodoByPageInfo(PageInfo info, SearchFilter filter);
 }
 

+ 210 - 0
src/main/java/com/uas/ps/inquiry/service/impl/InquiryForSaleServiceImpl.java

@@ -0,0 +1,210 @@
+package com.uas.ps.inquiry.service.impl;
+
+import com.uas.ps.entity.Status;
+import com.uas.ps.inquiry.dao.*;
+import com.uas.ps.inquiry.entity.Constant;
+import com.uas.ps.inquiry.model.*;
+import com.uas.ps.inquiry.service.InquiryForSaleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+
+/**
+ * 针对卖家,对询价的相关操作
+ *
+ * Created by hejq on 2018-01-18.
+ */
+@Service
+public class InquiryForSaleServiceImpl implements InquiryForSaleService {
+
+    @Autowired
+    private PublicInquiryItemDao infoDao;
+
+    @Autowired
+    private AttachDao attachDao;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private PublicInquiryDao inquiryDao;
+
+    @Autowired
+    private PurcInquiryItemInfoDao inquiryItemInfoDao;
+
+    /**
+     * 通过明细查询询价详情
+     *
+     * @param id 报价明细id
+     * @return
+     */
+    @Override
+    public PublicInquiryItem findById(Long id) {
+        return infoDao.findOne(id);
+    }
+
+    /**
+     * 供应商报价时上传附件信息
+     *
+     * @param attach
+     * @return
+     */
+    @Override
+    public Attach addAttachs(Attach attach) {
+        return attachDao.save(attach);
+    }
+
+    /**
+     * 供应商保存报价信息
+     *
+     * @param item 报价信息
+     * @return
+     * @author hejq
+     * @date 2018-01-14 16:43
+     */
+    @Override
+    public PublicInquiryItem add(PublicInquiryItem item) {
+        jdbcTemplate.update("insert into public$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
+                        + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+                item.getId(), item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
+                item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
+                item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
+                item.getSourceId(), item.getInquiry().getId(), item.getInquiry().getKind());
+        //回复清单更新
+        if(item.getReplies().size() > 0) {
+            for (PublicInquiryReply reply1 : item.getReplies()) {
+                jdbcTemplate.update("update public$inquiryreply set ir_idid = " + item.getId() + "where ir_id = " + reply1.getId());
+            }
+        }
+        return infoDao.findOne(item.getId());
+    }
+
+    /**
+     * 保存询价信息
+     *
+     * @param items 询价信息
+     * @return
+     * @author hejq
+     * @date 2018-01-15 9:16
+     */
+    @Override
+    public List<PublicInquiryItem> saveItems(List<PublicInquiryItem> items) {
+        return infoDao.save(items);
+    }
+
+    /**
+     * 保存询价信息
+     *
+     * @param inquiryItem 报价信息
+     * @return
+     */
+    @Override
+    public PublicInquiryItem save(PublicInquiryItem inquiryItem) {
+        return infoDao.save(inquiryItem);
+    }
+
+    /**
+     * 通过公共询价明细id查询报价信息
+     *
+     * @param id   公共询价明细id
+     * @param enuu 供应商UU
+     * @return
+     */
+    @Override
+    public PublicInquiryItem findBySourceIdAndEnuu(Long id, Long enuu) {
+        return infoDao.findByVendUUAndSourceId(enuu, id);
+    }
+
+    /**
+     * 转成报价询价单
+     *
+     * @param inquiryItem 询价明细
+     * @return
+     */
+    @Override
+    public PublicInquiryItem saveItem(PublicInquiryItem inquiryItem) throws Exception {
+        PublicInquiry inquiry = inquiryItem.getInquiry();
+        if (null != inquiry) {
+            // 先判断客户询价单是否存在这张单据
+            List<PublicInquiry> saleInquiries = inquiryDao.findByEnUUAndCode(inquiry.getEnUU(), inquiry.getCode());
+            if (CollectionUtils.isEmpty(saleInquiries)) {// 新增
+                inquiry.setSourceId(inquiry.getId());
+                inquiry.setId(null);
+                if (!CollectionUtils.isEmpty(inquiry.getAttachs())) {
+                    Set<Attach> attachs = new HashSet<Attach>();
+                    for (com.uas.ps.inquiry.model.Attach attach : inquiry.getAttachs()) {
+                        com.uas.ps.inquiry.model.Attach newAttach = new com.uas.ps.inquiry.model.Attach();
+                        newAttach.setDate(new Date());
+                        newAttach.setDescription(attach.getDescription());
+                        newAttach.setName(attach.getName());
+                        newAttach.setPath(attach.getPath());
+                        newAttach.setRelatedKey(attach.getRelatedKey());
+                        newAttach.setSize(attach.getSize());
+                        newAttach.setRelatedKey(attach.getRelatedKey());
+                        attachs.add(newAttach);
+                    }
+                    inquiry.setAttachs(attachs);
+
+                }
+                Set<PublicInquiryItem> items = new HashSet<PublicInquiryItem>();
+                Short i = 0;
+                if (null != inquiryItem) {
+                    inquiryItem.setInquiry(inquiry);
+                    inquiryItem.setNumber(i);
+                    inquiryItem.setCustLap(Constant.NO);
+                    inquiryItem.setSendStatus((short) Status.NOT_UPLOAD.value());
+                    inquiryItem.setSourceId(inquiryItem.getId());
+                    inquiryItem.setId(null);
+                    List<PublicInquiryReply> replies = new ArrayList<PublicInquiryReply>();
+                    PublicInquiryReply reply = new PublicInquiryReply();
+                    reply.setLapQty((double) 0);
+                    replies.add(reply);
+                    inquiryItem.setReplies(replies);
+                    items.add(inquiryItem);
+                    i++;
+                }
+                List<PublicInquiryItem> purcitems = infoDao.save(items);
+                if (purcitems.get(0).getId() != null) {
+                    return purcitems.get(0);
+                } else {
+                   throw new Exception("转询价报价单失败");
+                }
+            } else {// 插入
+                PublicInquiryItem purcItem = infoDao.findByVendUUAndSourceId(inquiryItem.getVendUU(), inquiryItem.getSourceId());
+                if (purcItem != null) {
+                    throw new Exception("询价单已存在,不允许再次报价");
+                } else {
+                    int number = infoDao.countByInquiryId(inquiryItem.getInquiry().getId()) + 1;
+                    inquiryItem.setNumber((short) number);
+                    return add(inquiryItem);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 通过id查询公共询价详情
+     *
+     * @param id   主键id
+     * @param enuu 企业uu
+     * @return
+     */
+    @Override
+    public ModelMap findByIdAndEnuu(Long id, Long enuu) {
+        ModelMap map = new ModelMap();
+        PurcInquiryItemInfo inquiryItem = inquiryItemInfoDao.findOne(id);
+        if (null != inquiryItem) {
+            map.put("inquiryItem", inquiryItem);
+        }
+        PublicInquiryItem item = infoDao.findByVendUUAndSourceId(enuu, id);
+        if (null != item) {
+            map.put("idid", item.getId());
+        }
+        return map;
+    }
+}

+ 103 - 0
src/main/java/com/uas/ps/inquiry/service/impl/InquiryServiceImpl.java

@@ -0,0 +1,103 @@
+package com.uas.ps.inquiry.service.impl;
+
+import com.uas.ps.inquiry.dao.PublicInquiryItemDao;
+import com.uas.ps.inquiry.dao.PurcInquiryDao;
+import com.uas.ps.inquiry.dao.PurcInquiryItemDao;
+import com.uas.ps.inquiry.dao.PurcInquiryItemInfoDao;
+import com.uas.ps.inquiry.model.*;
+import com.uas.ps.inquiry.page.PageInfo;
+import com.uas.ps.inquiry.page.SearchFilter;
+import com.uas.ps.inquiry.page.criteria.CriterionExpression;
+import com.uas.ps.inquiry.page.criteria.LogicalExpression;
+import com.uas.ps.inquiry.page.criteria.PredicateUtils;
+import com.uas.ps.inquiry.page.criteria.SimpleExpression;
+import com.uas.ps.inquiry.service.InquiryService;
+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.StringUtils;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.Date;
+
+/**
+ * 针对转询价报价单的数据查询操作
+ *
+ * Created by hejq on 2018-01-17.
+ */
+@Service
+public class InquiryServiceImpl implements InquiryService {
+
+    @Autowired
+    private PublicInquiryItemDao itemDao;
+
+    @Autowired
+    private PurcInquiryItemInfoDao inquiryItemDao;
+
+    @Autowired
+    private PurcInquiryDao purcInquiryDao;
+
+    /**
+     * 查询公共询价列表信息
+     *
+     * @param info
+     * @param filter
+     * @return
+     */
+    @Override
+    public Page<PurcInquiryItemInfo> findTodoByPageInfo(final PageInfo info, SearchFilter filter) {
+        if (null != filter) {
+            int k = 1;
+            SimpleExpression[] simpArrs = new SimpleExpression[5];
+            simpArrs[0] = new SimpleExpression("inquiry.enUU", filter.getEnUU(), CriterionExpression.Operator.NE, true);
+            if (StringUtils.hasText(filter.getKeyword())) {
+                simpArrs[k] = new SimpleExpression("product.title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 1] = new SimpleExpression("product.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 2] = new SimpleExpression("product.spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 3] = new SimpleExpression("product.brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                LogicalExpression logical = new LogicalExpression(simpArrs, CriterionExpression.Operator.OR);
+                info.expression(logical);
+            }
+            if (filter.getFromDate() != null) {
+                info.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
+            }
+            if (filter.getEndDate() != null) {
+                info.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
+            }
+        }
+        return inquiryItemDao.findAll(new Specification<PurcInquiryItemInfo>() {
+            public Predicate toPredicate(Root<PurcInquiryItemInfo> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                query.where(info.getPredicates(root, query, builder));
+                return null;
+            }
+        }, info);
+    }
+
+    /**
+     * 保存公共询价
+     *
+     * @param inquiry 询价信息
+     */
+    @Override
+    public PurcInquiry saveInquiry(PurcInquiry inquiry) {
+        return purcInquiryDao.save(inquiry);
+    }
+
+    /**
+     * 通过报价明细id对供应商报价进行相关审核操作
+     *
+     * @param id 报价明细id
+     * @param status 状态
+     */
+    @Override
+    public void decideQuote(Long id, Short status) {
+        PublicInquiryItem item = itemDao.findOne(id);
+        item.setAgreed(status);
+        itemDao.save(item);
+    }
+}

+ 75 - 55
src/main/java/com/uas/ps/inquiry/service/impl/PublicInquiryServiceImpl.java

@@ -5,17 +5,30 @@ import com.uas.ps.inquiry.dao.*;
 import com.uas.ps.inquiry.entity.*;
 import com.uas.ps.inquiry.model.*;
 import com.uas.ps.inquiry.model.Attach;
+import com.uas.ps.inquiry.page.PageInfo;
+import com.uas.ps.inquiry.page.SearchFilter;
+import com.uas.ps.inquiry.page.criteria.CriterionExpression;
+import com.uas.ps.inquiry.page.criteria.LogicalExpression;
+import com.uas.ps.inquiry.page.criteria.PredicateUtils;
+import com.uas.ps.inquiry.page.criteria.SimpleExpression;
 import com.uas.ps.inquiry.service.PublicInquiryService;
 import com.uas.ps.inquiry.util.IRunnable;
 import com.uas.ps.inquiry.util.ThreadUtils;
 import javassist.NotFoundException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataAccessException;
+import org.springframework.data.domain.Page;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.jdbc.core.JdbcTemplate;
 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.*;
 
 /**
@@ -48,7 +61,7 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     private PublicInquiryReplyDao publicInquiryReplyDao;
 
     @Autowired
-    private AttachDao attachDao;
+    private PurcInquiryItemInfoDao inquiryItemInfoDao;
 
     /**
      * 应用来源
@@ -92,16 +105,6 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
         }
     }
 
-    /**
-     * 保存公共询价
-     *
-     * @param inquiry
-     */
-    @Override
-    public PurcInquiry saveInquiry(PurcInquiry inquiry) {
-        return purcInquiryDao.save(inquiry);
-    }
-
     /**
      * 将ERP传入的inquiry信息转成公共询价服务中心需要的信息
      *
@@ -492,63 +495,80 @@ public class PublicInquiryServiceImpl implements PublicInquiryService {
     }
 
     /**
-     * 供应商保存报价信息
+     * 通过分页参数和过滤条件查询报价信息
      *
-     * @param item 报价信息
+     * @param info   分页参数
+     * @param filter 过滤条件
      * @return
      * @author hejq
-     * @date 2018-01-14 16:43
+     * @date 2018-01-17 10:30
      */
     @Override
-    public PublicInquiryItem add(PublicInquiryItem item) {
-        jdbcTemplate.update("insert into public$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
-                        + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
-                item.getId(), item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
-                item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
-                item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
-                item.getSourceId(), item.getInquiry().getId(), item.getInquiry().getKind());
-        //回复清单更新
-        if(item.getReplies().size() > 0) {
-            for (PublicInquiryReply reply1 : item.getReplies()) {
-                jdbcTemplate.update("update public$inquiryreply set ir_idid = " + item.getId() + "where ir_id = " + reply1.getId());
+    public Page<PublicInquiryItem> findByPageInfo(final PageInfo info, final SearchFilter filter) {
+        if (null != filter) {
+            int k = 1;
+            SimpleExpression[] simpArrs = new SimpleExpression[5];
+            if (null != filter.getEnUU()) {
+                simpArrs[0] = new SimpleExpression("inquiry.enUU", filter.getEnUU(), CriterionExpression.Operator.EQ, true);
+            } else if (null != filter.getVendUU()) {
+                simpArrs[0] = new SimpleExpression("vendUU", filter.getEnUU(), CriterionExpression.Operator.EQ, true);
+            }
+            if (StringUtils.hasText(filter.getKeyword())) {
+                simpArrs[k] = new SimpleExpression("product.title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 1] = new SimpleExpression("product.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 2] = new SimpleExpression("product.spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 3] = new SimpleExpression("product.brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                LogicalExpression logical = new LogicalExpression(simpArrs, CriterionExpression.Operator.OR);
+                info.expression(logical);
+            }
+            if (filter.getFromDate() != null) {
+                info.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
+            }
+            if (filter.getEndDate() != null) {
+                info.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
             }
         }
-        return publicInquiryItemDao.findOne(item.getId());
-    }
-
-    /**
-     * 保存询价信息
-     *
-     * @param items 询价信息
-     * @return
-     * @author hejq
-     * @date 2018-01-15 9:16
-     */
-    @Override
-    public List<PublicInquiryItem> save(List<PublicInquiryItem> items) {
-        return publicInquiryItemDao.save(items);
-    }
-
-    /**
-     * 保存询价信息(供应商、客户可能都会调用这条数据)
-     *
-     * @param inquiryItem 报价信息
-     * @return
-     */
-    @Override
-    public PublicInquiryItem save(PublicInquiryItem inquiryItem) {
-        return publicInquiryItemDao.save(inquiryItem);
+        return publicInquiryItemDao.findAll(new Specification<PublicInquiryItem>() {
+            public Predicate toPredicate(Root<PublicInquiryItem> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                query.where(info.getPredicates(root, query, builder));
+                return null;
+            }
+        }, info);
     }
 
     /**
-     * 供应商报价时上传附件信息
+     * 查询公共询价列表信息
      *
-     * @param attach
+     * @param info 分页参数
+     * @param filter 过滤条件
      * @return
      */
     @Override
-    public Attach addAttachs(Attach attach) {
-        return attachDao.save(attach);
+    public Page<PurcInquiryItemInfo> findTodoByPageInfo(final PageInfo info, SearchFilter filter) {
+        if (null != filter) {
+            int k = 1;
+            SimpleExpression[] simpArrs = new SimpleExpression[5];
+            simpArrs[0] = new SimpleExpression("inquiry.enUU", filter.getEnUU(), CriterionExpression.Operator.NE, true);
+            if (StringUtils.hasText(filter.getKeyword())) {
+                simpArrs[k] = new SimpleExpression("product.title", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 1] = new SimpleExpression("product.code", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 2] = new SimpleExpression("product.spec", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                simpArrs[k + 3] = new SimpleExpression("product.brand", filter.getKeyword(), CriterionExpression.Operator.LIKE, true);
+                LogicalExpression logical = new LogicalExpression(simpArrs, CriterionExpression.Operator.OR);
+                info.expression(logical);
+            }
+            if (filter.getFromDate() != null) {
+                info.expression(PredicateUtils.gte("date", new Date(filter.getFromDate()), false));
+            }
+            if (filter.getEndDate() != null) {
+                info.expression(PredicateUtils.lte("date", new Date(filter.getEndDate()), false));
+            }
+        }
+        return inquiryItemInfoDao.findAll(new Specification<PurcInquiryItemInfo>() {
+            public Predicate toPredicate(Root<PurcInquiryItemInfo> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+                query.where(info.getPredicates(root, query, builder));
+                return null;
+            }
+        }, info);
     }
-
 }