Ver Fonte

增加采购转单限制

zhoudw há 7 anos atrás
pai
commit
c8c0420fc6

+ 4 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdInOutMapper.java

@@ -24,4 +24,8 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
     Integer validateCodeWhenUpdate(@Param("pi_inoutno") String pi_inoutno, @Param("id") Long id,@Param("companyId") Long companyId);
 
     String selectCodeById(Long id);
+
+    int checkQtyFromPurchase(String pu_code);
+
+    int checkQtyFromProdIn(String pu_code);
 }

+ 24 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -192,6 +192,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if (updateDetails.size()>0) {
             prodIODetailMapper.batchUpdate(updateDetails);
         }
+
+        //检查更新后数据是否
+        String pu_code = prodInOut.getPi_pucode();
+        if (!StringUtils.isEmpty(pu_code)){
+            checkUpdateQty(pu_code,pi_class);
+        }
+
         baseDTO = getBaseDTOById(pi_id,pi_class,pi_inoutno);
         //计算金额,未税单价,未税金额等
         calcProdInout(pi_id,pi_class);
@@ -202,6 +209,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
+
     @Override
     @Transactional
     public void delete(Long id) {
@@ -358,6 +366,22 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         }
     }
 
+    private void checkUpdateQty(String pu_code, String pi_class) {
+        int count = 0;
+        if ("采购验收单".equals(pi_class)) {
+            count = getMapper().checkQtyFromPurchase(pu_code);
+            if (count>0){
+                throw new BizException(500, "明细行数量超过来源采购单明细行数量");
+            }
+        } else if ("采购验退单".equals(pi_class)) {
+            count = getMapper().checkQtyFromProdIn(pu_code);
+            if (count>0){
+                throw new BizException(500, "明细行数量超过来源采购验收单明细行数量");
+            }
+        }
+
+    }
+
 
 
     public void updateYqty(ProdInOut prodInOut) {

+ 10 - 2
applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -435,8 +435,16 @@
     select pi_inoutno from prodinout where pi_id=#{id}
   </select>
 
+  <select id="checkQtyFromPurchase" resultType="int" parameterType="string">
+  select count(1) from(
+  select sum(pd_inqty) nowqty,(select pd_qty from purchasedetail where pd_id = pd_orderid) totalqty   from prodiodetail   where pd_ordercode=#{pu_code}
+  GROUP BY pd_orderid) t  where t.nowqty>t.totalqty
+  </select>
 
-
-
+  <select id="checkQtyFromProdIn" resultType="int" parameterType="string">
+  select count(1) from(
+  select sum(b.pd_outqty) nowqty,(select a.pd_inqty from prodiodetail a where a.pd_id = b.pd_ioid and a.pd_piclass='采购验收单') totalqty from prodiodetail b where b.pd_ordercode=#{pu_code} and b.pd_piclass='采购验退单'
+  GROUP BY b.pd_ioid) t where t.nowqty>t.totalqty
+  </select>
 
 </mapper>