Browse Source

制造单修改

chenw 7 years ago
parent
commit
b6a0f75f68

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

@@ -49,10 +49,10 @@
         <!--productonhand-->
         <result column="pr_kind" property="pr_kind" jdbcType="VARCHAR" />
         <result column="pr_orispeccode" property="pr_orispeccode" jdbcType="VARCHAR" />
-        <result column=" pr_brand" property="pr_brand" jdbcType="VARCHAR" />
-        <result column=" pr_vendname" property="pr_vendname" jdbcType="VARCHAR" />
-        <result column=" pr_zxbzs" property="pr_zxbzs" jdbcType="VARCHAR" />
-        <result column=" pr_leadtime" property="pr_leadtime" jdbcType="INTEGER" />
+        <result column="pr_brand" property="pr_brand" jdbcType="VARCHAR" />
+        <result column="pr_vendname" property="pr_vendname" jdbcType="VARCHAR" />
+        <result column="pr_zxbzs" property="pr_zxbzs" jdbcType="VARCHAR" />
+        <result column="pr_leadtime" property="pr_leadtime" jdbcType="INTEGER" />
         <result column="pr_status" property="pr_status" jdbcType="VARCHAR" />
         <result column="pr_statuscode" property="pr_statuscode" jdbcType="VARCHAR" />
     </resultMap>

+ 11 - 0
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/MakeMaterial.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.storage.po;
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import com.usoftchina.saas.document.entities.Product;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -35,6 +36,16 @@ public class MakeMaterial extends CommonBaseEntity implements Serializable {
 
     private String mm_remark;
 
+    private Product product;
+
+    public Product getProduct() {
+        return product;
+    }
+
+    public void setProduct(Product product) {
+        this.product = product;
+    }
+
     public Long getMm_maid() {
         return mm_maid;
     }

+ 1 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/MakeMapper.java

@@ -25,4 +25,5 @@ public interface MakeMapper extends CommonBaseMapper<Make> {
 
     int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
 
+    double getOnHand(@Param("prodcode") String prodcode, @Param("whcode") String whcode, @Param("companyId") Long companyId);
 }

+ 10 - 1
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/MakeServiceImpl.java

@@ -140,12 +140,21 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         List<MakeMaterial> makeMaterialList = makeListDTO.getItems();
         if ("组装".equals(make.getMa_type())){
             //判断明细的库存是否足够
+            int i = 0;
             for(MakeMaterial makeMaterial : makeMaterialList){
+                i++;
                 double qty = makeMaterial.getMm_qty() * makeMaterial.getMm_oneuseqty();
+                double onHand = getMapper().getOnHand(makeMaterial.getMm_prodcode(),makeMaterial.getMm_whcode(), BaseContextHolder.getCompanyId());
+                if(onHand < qty){
+                    throw new BizException(79402, "行" + i + "库存不足");
+                }
             }
         }else if ("拆件".equals(make.getMa_type())){
             double qty = make.getMa_qty();
-
+            double onHand = getMapper().getOnHand(make.getMa_prodcode(),make.getMa_whcode(),BaseContextHolder.getCompanyId());
+            if(onHand < qty){
+                throw new BizException(79402, make.getMa_prodcode() + ":库存不足");
+            }
         }
     }
 

+ 4 - 0
applications/storage/storage-server/src/main/resources/mapper/MakeMapper.xml

@@ -367,4 +367,8 @@
   <select id="validateCodeWhenUpdate" resultType="int" >
     select count(*) from MAKE where MA_CODE = #{code} and MA_ID != #{id} and companyId =#{companyId}
   </select>
+
+    <select id="getOnHand" resultType="double">
+        SELECT PW_ONHAND FROM PRODUCTWH WHERE PW_PRODCODE=#{prodcode} AND PW_WHCODE=#{whcode} and COMPANYID=#{companyId}
+    </select>
 </mapper>

+ 35 - 1
applications/storage/storage-server/src/main/resources/mapper/MakematerialMapper.xml

@@ -18,6 +18,40 @@
     <result column="companyId" property="companyId" jdbcType="INTEGER" />
     <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
     <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <association property="product" jdbcType="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" />
+        <result column="pr_spec" property="pr_spec" jdbcType="VARCHAR" />
+        <result column="pr_unit" property="pr_unit" jdbcType="VARCHAR" />
+        <result column="pr_kind" property="pr_kind" jdbcType="VARCHAR" />
+        <result column="pr_orispeccode" property="pr_orispeccode" jdbcType="VARCHAR" />
+        <result column="pr_whid" property="pr_whid" jdbcType="INTEGER" />
+        <result column="pr_whcode" property="pr_whcode" jdbcType="VARCHAR" />
+        <result column="pr_whname" property="pr_whname" jdbcType="VARCHAR" />
+        <result column="pr_zxbzs" property="pr_zxbzs" jdbcType="INTEGER" />
+        <result column="pr_leadtime" property="pr_leadtime" jdbcType="INTEGER" />
+        <result column="pr_brand" property="pr_brand" jdbcType="VARCHAR" />
+        <result column="pr_standardprice" property="pr_standardprice" jdbcType="DOUBLE" />
+        <result column="pr_purcprice" property="pr_purcprice" jdbcType="DOUBLE" />
+        <result column="pr_saleprice" property="pr_saleprice" jdbcType="DOUBLE" />
+        <result column="pr_vendid" property="pr_vendid" jdbcType="INTEGER" />
+        <result column="pr_vendcode" property="pr_vendcode" jdbcType="VARCHAR" />
+        <result column="pr_vendname" property="pr_vendname" jdbcType="VARCHAR" />
+        <result column="pr_docdate" property="pr_docdate" jdbcType="TIMESTAMP" />
+        <result column="pr_recordmanid" property="pr_recordmanid" jdbcType="INTEGER" />
+        <result column="pr_recordman" property="pr_recordman" jdbcType="VARCHAR" />
+        <result column="pr_status" property="pr_status" jdbcType="VARCHAR" />
+        <result column="pr_statuscode" property="pr_statuscode" jdbcType="VARCHAR" />
+        <result column="companyId" property="companyId" jdbcType="INTEGER" />
+        <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+        <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+        <result column="pr_text1" property="pr_text1" jdbcType="VARCHAR" />
+        <result column="pr_text2" property="pr_text2" jdbcType="VARCHAR" />
+        <result column="pr_text3" property="pr_text3" jdbcType="VARCHAR" />
+        <result column="pr_text4" property="pr_text4" jdbcType="VARCHAR" />
+        <result column="pr_text5" property="pr_text5" jdbcType="VARCHAR" />
+    </association>
   </resultMap>
   <sql id="Base_Column_List" >
     mm_id, mm_maid, mm_detno, mm_prodid, mm_prodcode, mm_whid, mm_whcode, mm_price, mm_oneuseqty, 
@@ -215,7 +249,7 @@
     where mm_id = #{id}
   </update>
   <select id="selectByFK" resultMap="BaseResultMap">
-    SELECT * FROM MAKEMATERIAL WHERE MM_MAID=#{id} AND COMPANYID={companyId}
+    SELECT * FROM MAKEMATERIAL LEFT JOIN PRODUCT ON PR_ID=MA_PRODID AND MAKEMATERIAL.COMPANYID=PRODUCT.COMPANYID WHERE MM_MAID=#{id} AND MAKEMATERIAL.COMPANYID={companyId}
   </select>
   <delete id="deleteByFK">
     DELETE FROM MAKEMATERIAL WHERE MM_MAID=#{id} AND COMPANYID={companyId}