Browse Source

增加盘点单限制

zhoudw 7 years ago
parent
commit
d2f7d372bc

+ 3 - 1
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -92,9 +92,11 @@ public enum BizExceptionCode implements BaseExceptionCode {
 
     //库存
     EMPTY_DATA(76100,"数据为空,请填写后再保存"),
+    STORAGE_POST_ERROR(76200,""),
     UNENOUGH_DETAIL_STOCK(76300, "行%s库存不足"),
     UNENOUGH_STOCK(76400, "%s :库存不足"),
-    STORAGE_POST_ERROR(76200,""),
+    UNPOSTSTOCKPROFIT_EXISTS(76500, "存在当前仓库+物料未审核的盘盈盘亏单"),
+    STOCKPROFIT_NULL(76600, "没有需要生成的盘盈盘亏单")
     ;
     private int code;
     private String message;

+ 2 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/StockTakingMapper.java

@@ -22,4 +22,6 @@ public interface StockTakingMapper extends CommonBaseMapper<StockTaking> {
     void insertFormProductWh(@Param("con") String con,@Param("companyId") Long companyId);
 
     Double getPurcpriceByProduct(Long id);
+
+    int checkUnPostStockProfit(@Param("companyId") Long companyId);
 }

+ 8 - 4
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/StocktakingServiceImpl.java

@@ -87,6 +87,11 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
         Long companyId = BaseContextHolder.getCompanyId();
         Long userId = BaseContextHolder.getUserId();
         String userName = BaseContextHolder.getUserName();
+        //检查是否有当前盘点物料+仓库未审核的盘盈盘亏单
+        int count = getMapper().checkUnPostStockProfit(companyId);
+        if (count>0) {
+            throw new BizException(BizExceptionCode.UNPOSTSTOCKPROFIT_EXISTS);
+        }
         //生成入库单
         List<StockTaking> inlist  = getMapper().selectStockTakingBycondition("st_num>0",companyId);
         if (inlist.size()>0){
@@ -98,8 +103,6 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
             prodIn.setPi_status("未审核");
             prodIn.setPi_statuscode("UNAUDITED");
             prodIn.setCompanyId(companyId);
-            prodIn.setCreateTime(new Date());
-            prodIn.setCreatorId(userId);
             prodIn.setPi_remark("盘盈单");
             prodInOutMapper.insertSelective(prodIn);
             long inid = prodIn.getId();
@@ -142,8 +145,6 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
             prodOut.setPi_status("未审核");
             prodOut.setPi_statuscode("UNAUDITED");
             prodOut.setCompanyId(companyId);
-            prodOut.setCreateTime(new Date());
-            prodOut.setCreatorId(userId);
             prodOut.setPi_remark("盘亏单");
             prodInOutMapper.insertSelective(prodOut);
             long outid = prodOut.getId();
@@ -171,6 +172,9 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
             DocBaseDTO baseDTOOUT = new DocBaseDTO(outid,piOutno,"其它出库单");
             resultMap.put("outData",baseDTOOUT);
         }
+        if (inlist.size()==0 && outlist.size()==0){
+            throw new BizException(BizExceptionCode.STOCKPROFIT_NULL);
+        }
         return resultMap;
     }
 

+ 11 - 0
applications/storage/storage-server/src/main/resources/mapper/StockTakingMapper.xml

@@ -261,5 +261,16 @@
     select pr_purcprice from product where pr_id = #{id}
   </select>
 
+  <select id="checkUnPostStockProfit" resultType="int">
+    select
+    count(*)
+    from
+    (select pd_prodid,pd_whid from prodiodetail left join prodinout on pd_piid = pi_id
+    where prodinout.companyId=#{companyId,jdbcType=INTEGER} and (pi_remark='盘盈单' or pi_remark='盘亏单')) b
+    left join
+    (select st_prodid,st_whid from stocktaking where companyId=#{companyId} ) a
+    on a.st_prodid = b.pd_prodid and a.st_whid = b.pd_whid
+  </select>
+
 
 </mapper>

+ 1 - 4
frontend/saas-web/app/view/stock/inventory/EditDataList.js

@@ -433,14 +433,11 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
                         initId: intValue
                     });
                 }
-                if(!localJson.data.outData && !localJson.data.inData){
-                    saas.util.BaseUtil.showErrorToast('没有需要生成的盘盈盘亏单');
-                }
             }
         })
         .catch(function(res) {
             console.error(res);
-            saas.util.BaseUtil.showToast('生成盘点单失败: ' + res.message);
+            saas.util.BaseUtil.showErrorToast('生成盘点单失败: ' + res.message);
         });    
     },
     onbuild:function(){