Browse Source

修改物料供应商查询分页

will.chen 7 years ago
parent
commit
11f83aa691

+ 2 - 11
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendorDTO.java

@@ -1,15 +1,14 @@
 package com.usoftchina.saas.document.dto;
 package com.usoftchina.saas.document.dto;
 
 
+import com.usoftchina.saas.base.dto.CommonBaseDTO;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 
 
 @ApiModel(value = "Vendor", description = "供应商资料")
 @ApiModel(value = "Vendor", description = "供应商资料")
-public class VendorDTO implements Serializable{
+public class VendorDTO extends CommonBaseDTO implements Serializable{
 
 
-    @ApiModelProperty(value = "ID")
-    private long ve_id;
     @ApiModelProperty(value = "供应商编号")
     @ApiModelProperty(value = "供应商编号")
     private String ve_code;
     private String ve_code;
     @ApiModelProperty(value = "供应商名称")
     @ApiModelProperty(value = "供应商名称")
@@ -19,14 +18,6 @@ public class VendorDTO implements Serializable{
     @ApiModelProperty(value = "状态")
     @ApiModelProperty(value = "状态")
     private String ve_status;
     private String ve_status;
 
 
-    public long getVe_id() {
-        return ve_id;
-    }
-
-    public void setVe_id(long ve_id) {
-        this.ve_id = ve_id;
-    }
-
     public String getVe_code() {
     public String getVe_code() {
         return ve_code;
         return ve_code;
     }
     }

+ 2 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.controller;
 package com.usoftchina.saas.document.controller;
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.Result;
 
 
 import com.usoftchina.saas.common.dto.ComboDTO;
 import com.usoftchina.saas.common.dto.ComboDTO;
@@ -22,7 +23,7 @@ public class ProductController {
 
 
     @RequestMapping("/getProductsByCondition")
     @RequestMapping("/getProductsByCondition")
     public Result<List<ProductDTO>> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO){
     public Result<List<ProductDTO>> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO){
-        List<ProductDTO> productList = productService.getProductsByCondition(page, docReqDTO);
+        PageInfo<ProductDTO> productList = productService.getProductsByCondition(page, docReqDTO);
         return Result.success(productList);
         return Result.success(productList);
     }
     }
 
 

+ 2 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.controller;
 package com.usoftchina.saas.document.controller;
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.common.dto.DocReqDTO;
 import com.usoftchina.saas.common.dto.DocReqDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
@@ -21,7 +22,7 @@ public class VendorController {
 
 
     @RequestMapping("/getVendorsByCondition")
     @RequestMapping("/getVendorsByCondition")
     public Result<List<VendorDTO>> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO){
     public Result<List<VendorDTO>> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO){
-        List<VendorDTO> vendorList = vendorService.getVendorsByCondition(page, docReqDTO);
+        PageInfo<VendorDTO> vendorList = vendorService.getVendorsByCondition(page, docReqDTO);
         return Result.success(vendorList);
         return Result.success(vendorList);
     }
     }
 }
 }

+ 2 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductMapper.java

@@ -3,13 +3,14 @@ package com.usoftchina.saas.document.mapper;
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.common.dto.ComboDTO;
 import com.usoftchina.saas.common.dto.ComboDTO;
 import com.usoftchina.saas.common.dto.DocReqDTO;
 import com.usoftchina.saas.common.dto.DocReqDTO;
+import com.usoftchina.saas.document.dto.ProductDTO;
 import com.usoftchina.saas.document.entities.Product;
 import com.usoftchina.saas.document.entities.Product;
 
 
 import java.util.List;
 import java.util.List;
 
 
 public interface ProductMapper extends CommonBaseMapper<Product> {
 public interface ProductMapper extends CommonBaseMapper<Product> {
 
 
-    List<Product> getProductsByCondition(DocReqDTO docReqDTO);
+    List<ProductDTO> getProductsByCondition(DocReqDTO docReqDTO);
     List<ComboDTO> getProdUnit();
     List<ComboDTO> getProdUnit();
     void updateLatestPurchasePrice(Long pu_id);
     void updateLatestPurchasePrice(Long pu_id);
 
 

+ 2 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorMapper.java

@@ -3,12 +3,13 @@ package com.usoftchina.saas.document.mapper;
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 
 
 import com.usoftchina.saas.common.dto.DocReqDTO;
 import com.usoftchina.saas.common.dto.DocReqDTO;
+import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.entities.Vendor;
 import com.usoftchina.saas.document.entities.Vendor;
 
 
 import java.util.List;
 import java.util.List;
 
 
 public interface VendorMapper extends CommonBaseMapper<Vendor> {
 public interface VendorMapper extends CommonBaseMapper<Vendor> {
 
 
-    List<Vendor> getVendorsByCondition(DocReqDTO docReqDTO);
+    List<VendorDTO> getVendorsByCondition(DocReqDTO docReqDTO);
 
 
 }
 }

+ 4 - 7
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/Impl/ProductServiceImpl.java

@@ -11,7 +11,6 @@ import com.usoftchina.saas.document.entities.Product;
 import com.usoftchina.saas.document.mapper.ProductMapper;
 import com.usoftchina.saas.document.mapper.ProductMapper;
 import com.usoftchina.saas.document.service.ProductService;
 import com.usoftchina.saas.document.service.ProductService;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
-import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -24,7 +23,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     private ProductMapper productMapper;
     private ProductMapper productMapper;
 
 
     @Override
     @Override
-    public List<ProductDTO> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO) {
+    public PageInfo<ProductDTO> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO) {
         //设置分页
         //设置分页
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
             page = new PageRequest();
             page = new PageRequest();
@@ -32,12 +31,10 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
             page.setSize(10);
             page.setSize(10);
         }
         }
         PageHelper.startPage(page.getNumber(), page.getSize());
         PageHelper.startPage(page.getNumber(), page.getSize());
-        List<Product> productList = productMapper.getProductsByCondition(docReqDTO);
-        //Product To ProductDTO
-        List<ProductDTO> productDTOList = BeanMapper.mapList(productList, ProductDTO.class);
+        List<ProductDTO> productList = productMapper.getProductsByCondition(docReqDTO);
         //取分页信息
         //取分页信息
-        PageInfo<ProductDTO> pageInfo = new PageInfo<ProductDTO>(productDTOList);
-        return productDTOList;
+        PageInfo<ProductDTO> pageInfo = new PageInfo<ProductDTO>(productList);
+        return pageInfo;
     }
     }
 
 
     @Override
     @Override

+ 4 - 7
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/Impl/VendorServiceImpl.java

@@ -10,7 +10,6 @@ import com.usoftchina.saas.document.mapper.VendorMapper;
 
 
 import com.usoftchina.saas.document.service.VendorService;
 import com.usoftchina.saas.document.service.VendorService;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
-import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -28,7 +27,7 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
 
 
 
 
     @Override
     @Override
-    public List<VendorDTO> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO) {
+    public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO) {
         //设置分页
         //设置分页
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
             page = new PageRequest();
             page = new PageRequest();
@@ -36,11 +35,9 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             page.setSize(10);
             page.setSize(10);
         }
         }
         PageHelper.startPage(page.getNumber(), page.getSize());
         PageHelper.startPage(page.getNumber(), page.getSize());
-        List<Vendor> vendorList = vendorMapper.getVendorsByCondition(docReqDTO);
-        //Vendor To VendorDTO
-        List<VendorDTO> vendorDTOList = BeanMapper.mapList(vendorList, VendorDTO.class);
+        List<VendorDTO> vendorList = vendorMapper.getVendorsByCondition(docReqDTO);
         //取分页信息
         //取分页信息
-        PageInfo<VendorDTO> pageInfo = new PageInfo<VendorDTO>(vendorDTOList);
-        return vendorDTOList;
+        PageInfo<VendorDTO> pageInfo = new PageInfo<VendorDTO>(vendorList);
+        return pageInfo;
     }
     }
 }
 }

+ 2 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductService.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.service;
 package com.usoftchina.saas.document.service;
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.base.service.CommonBaseService;
 
 
 import com.usoftchina.saas.common.dto.ComboDTO;
 import com.usoftchina.saas.common.dto.ComboDTO;
@@ -15,7 +16,7 @@ import java.util.List;
 public interface ProductService extends CommonBaseService<ProductMapper, Product> {
 public interface ProductService extends CommonBaseService<ProductMapper, Product> {
 
 
 
 
-    List<ProductDTO> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO);
+    PageInfo<ProductDTO> getProductsByCondition(PageRequest page, DocReqDTO docReqDTO);
 
 
     List<ComboDTO> getProdUnit();
     List<ComboDTO> getProdUnit();
 
 

+ 2 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorService.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.service;
 package com.usoftchina.saas.document.service;
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.base.service.CommonBaseService;
 
 
 import com.usoftchina.saas.common.dto.DocReqDTO;
 import com.usoftchina.saas.common.dto.DocReqDTO;
@@ -9,10 +10,9 @@ import com.usoftchina.saas.document.mapper.VendorMapper;
 
 
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
 
 
-import java.util.List;
 
 
 public interface VendorService extends CommonBaseService<VendorMapper, Vendor>{
 public interface VendorService extends CommonBaseService<VendorMapper, Vendor>{
 
 
-    List<VendorDTO> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO);
+    PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, DocReqDTO docReqDTO);
 
 
 }
 }

+ 10 - 1
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -35,8 +35,17 @@
         <result column="pr_text4" property="pr_text4" jdbcType="VARCHAR" />
         <result column="pr_text4" property="pr_text4" jdbcType="VARCHAR" />
         <result column="pr_text5" property="pr_text5" jdbcType="VARCHAR" />
         <result column="pr_text5" property="pr_text5" jdbcType="VARCHAR" />
     </resultMap>
     </resultMap>
+    <resultMap id="ProductDTOResultMapper" type="com.usoftchina.saas.document.dto.ProductDTO">
+        <id column="pr_id" property="id" jdbcType="INTEGER" />
+        <result column="pr_code" property="pr_code" jdbcType="VARCHAR" />
+        <result column="pr_detail" property="pr_detail" jdbcType="VARCHAR" />
+        <result column="pr_spec" property="pr_spec" jdbcType="VARCHAR" />
+        <result column="pr_unit" property="pr_unit" jdbcType="VARCHAR" />
+        <result column="pr_orispeccode" property="pr_orispeccode" jdbcType="VARCHAR" />
+        <result column="pr_brand" property="pr_brand" jdbcType="VARCHAR" />
+    </resultMap>
     <!--查询所有物料信息-->
     <!--查询所有物料信息-->
-    <select id="getProductsByCondition" resultMap="ProductResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
+    <select id="getProductsByCondition" resultMap="ProductDTOResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
         SELECT * FROM PRODUCT
         SELECT * FROM PRODUCT
         <where>
         <where>
             <if test="condition!=null">
             <if test="condition!=null">

+ 9 - 1
applications/document/document-server/src/main/resources/mapper/VendorMapper.xml

@@ -29,7 +29,15 @@
         <result column="ve_text4" property="ve_text4" jdbcType="VARCHAR" />
         <result column="ve_text4" property="ve_text4" jdbcType="VARCHAR" />
         <result column="ve_text5" property="ve_text5" jdbcType="VARCHAR" />
         <result column="ve_text5" property="ve_text5" jdbcType="VARCHAR" />
     </resultMap>
     </resultMap>
-    <select id="getVendorsByCondition" resultMap="VendorResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
+    <resultMap id="VendorDTOResultMapper" type="com.usoftchina.saas.document.dto.VendorDTO">
+        <id column="ve_id" property="id" jdbcType="INTEGER" />
+        <result column="ve_code" property="ve_code" jdbcType="VARCHAR" />
+        <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
+        <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
+        <result column="ve_status" property="ve_status" jdbcType="VARCHAR" />
+    </resultMap>
+
+    <select id="getVendorsByCondition" resultMap="VendorDTOResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
         SELECT * FROM VENDOR
         SELECT * FROM VENDOR
         <where>
         <where>
             <if test="condition!=null">
             <if test="condition!=null">

+ 6 - 5
applications/document/document-server/src/test/java/com/usoftchina/saas/document/service/VendorTest.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.document.service;
 package com.usoftchina.saas.document.service;
 
 
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.document.DocumentApplication;
 import com.usoftchina.saas.document.DocumentApplication;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import org.junit.Test;
 import org.junit.Test;
@@ -22,10 +23,10 @@ public class VendorTest {
 
 
     @Test
     @Test
     public void testSelectAll(){
     public void testSelectAll(){
-        List<VendorDTO> vendorList = vendorService.getVendorsByCondition(null, null);
-        System.out.println("vendCode: " + vendorList.get(0).getVe_code());
-        System.out.println("vendName: " + vendorList.get(0).getVe_name());
-        System.out.println("vendType: " + vendorList.get(0).getVe_type());
-        System.out.println("vendBeginDate: " + vendorList.get(0).getVe_status());
+        PageInfo<VendorDTO> vendorList = vendorService.getVendorsByCondition(null, null);
+        System.out.println("vendCode: " + vendorList.getList().get(0).getVe_code());
+        System.out.println("vendName: " + vendorList.getList().get(0).getVe_name());
+        System.out.println("vendType: " + vendorList.getList().get(0).getVe_type());
+        System.out.println("vendBeginDate: " + vendorList.getList().get(0).getVe_status());
     }
     }
 }
 }