zhoudw 7 лет назад
Родитель
Сommit
027f3e0b7b

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

@@ -25,7 +25,7 @@ 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);
+    Double getOnHand(@Param("prodid") Long prodid, @Param("whid") Integer whid, @Param("companyId") Long companyId);
 
     String selectMakeInOutCode(@Param("code") String code, @Param("companyId") Long companyId, @Param("type") String type);
 

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

@@ -161,9 +161,13 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
             for(MakeMaterial makeMaterial : makeMaterialList){
                 i++;
                 double qty = makeMaterial.getMm_qty()==null?0:makeMaterial.getMm_qty();
-                Double onHand = getMapper().getOnHand(makeMaterial.getMm_prodcode(),makeMaterial.getMm_whcode(), BaseContextHolder.getCompanyId());
-                if (onHand==null){
-                    onHand=0d;
+                double onHand = 0;
+                try {
+                    onHand = getMapper().getOnHand(make.getMa_prodid(),make.getMa_whid(), BaseContextHolder.getCompanyId());
+                }catch (Exception e){
+                    String msg = BizExceptionCode.UNENOUGH_DETAIL_STOCK.getMessage();
+                    int code = BizExceptionCode.SALE_ORDER_HASAUDIT.getCode();
+                    throw new BizException(code, String.format(msg, i));
                 }
                 if(onHand < qty){
                     String msg = BizExceptionCode.UNENOUGH_DETAIL_STOCK.getMessage();
@@ -175,7 +179,8 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
             double qty = make.getMa_qty();
             double onHand = 0;
             try {
-                onHand = getMapper().getOnHand(make.getMa_prodcode(), make.getMa_whcode(), BaseContextHolder.getCompanyId());
+                onHand = getMapper().getOnHand(make.getMa_prodid(), make.getMa_whid(), BaseContextHolder.getCompanyId());
+
             }catch (Exception e){
                 String msg = BizExceptionCode.UNENOUGH_STOCK.getMessage();
                 int code = BizExceptionCode.UNENOUGH_STOCK.getCode();

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

@@ -410,7 +410,7 @@
   </select>
 
     <select id="getOnHand" resultType="double">
-        SELECT IFNULL(PW_ONHAND,0) FROM PRODUCTWH WHERE PW_PRODCODE=#{prodcode} AND PW_WHCODE=#{whcode} and COMPANYID=#{companyId}
+        SELECT IFNULL(PW_ONHAND,0) FROM PRODUCTWH WHERE PW_PRODID=#{prodid} AND PW_WHID=#{whid} and COMPANYID=#{companyId}
     </select>
 
     <select id="selectMakeInOutCode" resultType="string">