Browse Source

采购单明显关联物料

guq 7 years ago
parent
commit
c6209c6560

+ 9 - 7
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/ProductDTO.java

@@ -4,21 +4,23 @@ import java.io.Serializable;
 
 public class ProductDTO implements Serializable {
 
-    private long pr_id;
+    private long id;
     private String pr_code;
     private String pr_detail;
     private String pr_spec;
     private String pr_orispeccode;
-    private String pr_brand;
 
-    public long getPr_id() {
-        return pr_id;
+    public long getId() {
+        return id;
     }
 
-    public void setPr_id(long pr_id) {
-        this.pr_id = pr_id;
+    public void setId(long id) {
+        this.id = id;
     }
 
+    private String pr_brand;
+
+
     public String getPr_code() {
         return pr_code;
     }
@@ -62,7 +64,7 @@ public class ProductDTO implements Serializable {
     @Override
     public String toString() {
         return "ProductDTO{" +
-                "pr_id='" + pr_id + '\'' +
+                "pr_id='" + id + '\'' +
                 ", pr_code='" + pr_code + '\'' +
                 ", pr_detail='" + pr_detail + '\'' +
                 ", pr_spec='" + pr_spec + '\'' +

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java

@@ -5,6 +5,7 @@ import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.common.dto.ComboDTO;
 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.service.ProductService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,5 +39,9 @@ public class ProductController {
         productService.updateLatestPurchasePrice(pu_id);
     };
 
+    @RequestMapping("/getProductsByPK")
+    public Product getProductsByPK(@RequestParam(value = "pr_id") Long id) {
+        return productService.getProductsByPK(id);
+    };
 
 }

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

@@ -49,4 +49,12 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     public void updateLatestPurchasePrice(Long pu_id) {
         productMapper.updateLatestPurchasePrice(pu_id);
     }
+
+    @Override
+    public Product getProductsByPK(Long id) {
+        if (null == id) {
+            return productMapper.selectByPrimaryKey(id);
+        }
+        return null;
+    }
 }

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

@@ -20,4 +20,6 @@ public interface ProductService extends CommonBaseService<ProductMapper, Product
     List<ComboDTO> getProdUnit();
 
     void updateLatestPurchasePrice(Long pu_id);
+
+    Product getProductsByPK(Long id);
 }

+ 7 - 3
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.document.mapper.ProductMapper">
-    <resultMap id="ProductResultMapper" type="com.usoftchina.saas.document.po.Product">
+    <resultMap id="ProductResultMapper" type="com.usoftchina.saas.document.entities.Product">
         <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" />
@@ -36,7 +36,7 @@
         <result column="pr_text5" property="pr_text5" jdbcType="VARCHAR" />
     </resultMap>
     <!--查询所有物料信息-->
-    <select id="getProductsByCondition" resultMap="ProductResultMapper" parameterType="dto.DocReqDTO">
+    <select id="getProductsByCondition" resultMap="ProductResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
         SELECT * FROM PRODUCT
         <where>
             <if test="condition!=null">
@@ -45,7 +45,11 @@
         </where>
     </select>
 
-    <select id="getProdUnit" resultType="dto.ComboDTO">
+    <select id="selectByPrimaryKey" resultMap="ProductResultMapper" parameterType="long">
+        SELECT * FROM PRODUCT where pr_id = #{pr_id}
+    </select>
+
+    <select id="getProdUnit" resultType="com.usoftchina.saas.common.dto.ComboDTO">
         SELECT PR_UNIT as display, pr_unit as value FROM PRODUCT
     </select>
     <update id="updateLatestPurchasePrice" parameterType="long">

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

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.document.mapper.VendorMapper">
-    <resultMap id="VendorResultMapper" type="com.usoftchina.saas.document.po.Vendor">
+    <resultMap id="VendorResultMapper" type="com.usoftchina.saas.document.entities.Vendor">
         <id column="ve_id" property="id" jdbcType="INTEGER" />
         <result column="ve_code" property="ve_code" jdbcType="VARCHAR" />
         <result column="ve_uu" property="ve_uu" jdbcType="VARCHAR" />
@@ -29,7 +29,7 @@
         <result column="ve_text4" property="ve_text4" jdbcType="VARCHAR" />
         <result column="ve_text5" property="ve_text5" jdbcType="VARCHAR" />
     </resultMap>
-    <select id="getVendorsByCondition" resultMap="VendorResultMapper" parameterType="dto.DocReqDTO">
+    <select id="getVendorsByCondition" resultMap="VendorResultMapper" parameterType="com.usoftchina.saas.common.dto.DocReqDTO">
         SELECT * FROM VENDOR
         <where>
             <if test="condition!=null">

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

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.document.mapper.WarehouseMapper">
-    <resultMap id="WarehouseResultMapper" type="com.usoftchina.saas.document.po.Warehouse">
+    <resultMap id="WarehouseResultMapper" type="com.usoftchina.saas.document.entities.Warehouse">
         <id column="wh_id" property="id" jdbcType="INTEGER" />
         <result column="wh_code" property="wh_code" jdbcType="VARCHAR" />
         <result column="wh_type" property="wh_type" jdbcType="VARCHAR" />

+ 5 - 0
applications/purchase/purchase-dto/pom.xml

@@ -26,5 +26,10 @@
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>document-dto</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>

+ 3 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseItemDTO.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.purchase.dto;
 
+import com.usoftchina.saas.document.entities.Product;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -69,4 +70,6 @@ public class PurchaseItemDTO implements Serializable{
 
     private Double pd_yqty;
 
+    private Product product;
+
 }

+ 4 - 2
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/PurchaseItem.java

@@ -1,6 +1,8 @@
 package com.usoftchina.saas.purchase.po;
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import com.usoftchina.saas.document.entities.Product;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -14,7 +16,7 @@ public class PurchaseItem extends CommonBaseEntity implements Serializable {
 
     private Integer pd_detno;
 
-    private Integer pd_prodid;
+    private Long pd_prodid;
 
     private String pd_prodcode;
 
@@ -50,5 +52,5 @@ public class PurchaseItem extends CommonBaseEntity implements Serializable {
 
     private Double pd_yqty;
 
-    //private Product product;
+    private Product product;
 }

+ 4 - 7
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java

@@ -19,6 +19,7 @@ import com.usoftchina.saas.purchase.service.PurchaseService;
 import com.usoftchina.saas.utils.BeanMapper;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -64,15 +65,11 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         PurchaseFormDTO purchaseFormDTO = new PurchaseFormDTO();
         //查询主表信息
         Purchase purchase = getMapper().selectByPrimaryKey(id);
-        //查询从表
-        List<PurchaseItem> purchaseItems = purchasedetailMapper.selectByFK(id);
         //将purchase实体对象转化成传输对象
         PurchaseDTO main = BeanMapper.map(purchase, PurchaseDTO.class);
-        List<PurchaseItemDTO> items = new ArrayList<>();
-        //添加从表传输对象
-        for (PurchaseItem detail : purchaseItems) {
-            items.add(BeanMapper.map(detail, PurchaseItemDTO.class));
-        }
+        //查询从表
+        List<PurchaseItem> purchaseItems = purchasedetailMapper.selectByFK(id);
+        List<PurchaseItemDTO> items = BeanMapper.mapList(purchaseItems, PurchaseItemDTO.class);
         purchaseFormDTO.setMain(main);
         purchaseFormDTO.setItems(items);
         return  purchaseFormDTO;

+ 1 - 1
applications/purchase/purchase-server/src/main/resources/mapper/PurchaseMapper.xml

@@ -391,7 +391,7 @@
       pu_text5 = #{pu_text5,jdbcType=VARCHAR}
     where pu_id = #{id,jdbcType=INTEGER}
   </update>
-  <select id="validateAudit" parameterType="dto.DocBaseDTO" resultType="java.lang.String">
+  <select id="validateAudit" parameterType="com.usoftchina.saas.common.dto.DocBaseDTO" resultType="java.lang.String">
     select GROUP_CONCAT(pu_code) from purchase where pu_statuscode='AUDITED' and pu_id in
     <foreach collection="list" item="item" open="(" close=")" separator=",">
       #{item.id}

+ 32 - 1
applications/purchase/purchase-server/src/main/resources/mapper/PurchasedetailMapper.xml

@@ -27,6 +27,36 @@
     <result column="pd_text4" property="pd_text4" jdbcType="VARCHAR" />
     <result column="pd_text5" property="pd_text5" jdbcType="VARCHAR" />
     <result column="pd_yqty" property="pd_yqty" jdbcType="DOUBLE" />
+    <association property="product" javaType="com.usoftchina.saas.document.entities.Product">
+      <id column="pr_id" property="id"/>
+      <result column="pr_code" property="pr_code"/>
+      <result column="pr_detail" property="pr_detail"/>
+      <result column="pr_spec" property="pr_spec"/>
+      <result column="pr_unit" property="pr_unit"/>
+      <result column="pr_kind" property="pr_kind"/>
+      <result column="pr_orispeccode" property="pr_orispeccode"/>
+      <result column="pr_whid" property="pr_whid"/>
+      <result column="pr_whcode" property="pr_whcode"/>
+      <result column="pr_whname" property="pr_whname"/>
+      <result column="pr_zxbzs" property="pr_zxbzs"/>
+      <result column="pr_leadtime" property="pr_leadtime"/>
+      <result column="pr_brand" property="pr_brand"/>
+      <result column="pr_standardprice" property="pr_standardprice"/>
+      <result column="pr_purcprice" property="pr_purcprice"/>
+      <result column="pr_saleprice" property="pr_saleprice"/>
+      <result column="pr_vendid" property="pr_vendid"/>
+      <result column="pr_vendname" property="pr_vendname"/>
+      <result column="pr_vendcode" property="pr_vendcode"/>
+      <result column="pr_docdate" property="pr_docdate"/>
+      <result column="pr_recordmanid" property="pr_recordmanid"/>
+      <result column="pr_recordman" property="pr_recordman"/>
+      <result column="pr_status" property="pr_status"/>
+      <result column="pr_statuscode" property="pr_statuscode"/>
+      <result column="pr_text1" property="pr_text1"/>
+      <result column="pr_text2" property="pr_text2"/>
+      <result column="pr_text3" property="pr_text3"/>
+      <result column="pr_text4" property="pr_text4"/>
+    </association>
   </resultMap>
   <sql id="Base_Column_List" >
     PD_ID, PD_PUID, PD_CODE, PD_DETNO, PD_PRODID, PD_PRODCODE, PD_UNIT, PD_QTY, PD_PRICE,
@@ -381,6 +411,7 @@
     delete from purchasedetail where pd_puid=#{id}
   </delete>
   <select id="selectByFK" parameterType="long" resultMap="BaseResultMap">
-    select * from purchasedetail where pd_puid=#{pu_id}
+    select * from purchasedetail a left join product b on pr_id=pd_prodid and a.companyid = b.companyid
+      where pd_puid=#{pu_id}
   </select>
 </mapper>