yuansh 3 месяцев назад
Родитель
Сommit
0a1bc34e29

+ 202 - 176
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StoreCheckServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.storeCode.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.storeCode.entity.*;
 import org.jeecg.modules.storeCode.entity.StoreCheck;
 import org.jeecg.modules.storeCode.mapper.StoreCheckDetailsMapper;
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.ArrayList;
@@ -23,226 +25,250 @@ import java.util.Collection;
 /**
  * @Description: 盘盈盘亏(inventory check)
  * @Author: jeecg-boot
- * @Date:   2024-12-11
+ * @Date: 2024-12-11
  * @Version: V1.0
  */
 @Service
 public class StoreCheckServiceImpl extends ServiceImpl<StoreCheckMapper, StoreCheck> implements IStoreCheckService {
 
-	@Autowired
-	private StoreCheckMapper storeCheckMapper;
-	@Autowired
-	private StoreCheckDetailsMapper storeCheckDetailsMapper;
-
-	@Autowired
-	private IStoreOnhandService storeOnhandService;
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void saveMain(StoreCheck storeCheck, List<StoreCheckDetails> storeCheckDetailsList) {
-		storeCheckMapper.insert(storeCheck);
-		if(storeCheckDetailsList!=null && storeCheckDetailsList.size()>0) {
-			for(StoreCheckDetails entity:storeCheckDetailsList) {
-				//外键设置
-				entity.setId(null);
-				entity.setHeadId(storeCheck.getId());
-				storeCheckDetailsMapper.insert(entity);
-			}
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void updateMain(StoreCheck storeCheck,List<StoreCheckDetails> storeCheckDetailsList) {
-		storeCheckMapper.updateById(storeCheck);
-		
-		//1.先删除子表数据
-		storeCheckDetailsMapper.deleteByMainId(storeCheck.getId());
-		
-		//2.子表数据重新插入
-		if(storeCheckDetailsList!=null && storeCheckDetailsList.size()>0) {
-			for(StoreCheckDetails entity:storeCheckDetailsList) {
-				//外键设置
-				entity.setId(null);
-				entity.setHeadId(storeCheck.getId());
-				storeCheckDetailsMapper.insert(entity);
-			}
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void delMain(String id) {
-		storeCheckDetailsMapper.deleteByMainId(id);
-		storeCheckMapper.deleteById(id);
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void delBatchMain(Collection<? extends Serializable> idList) {
-		for(Serializable id:idList) {
-			storeCheckDetailsMapper.deleteByMainId(id.toString());
-			storeCheckMapper.deleteById(id);
-		}
-	}
-
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public Result<String> submitBatch(String ids) {
-
-		QueryWrapper<StoreCheck> queryWrapper = new QueryWrapper<>();
-		queryWrapper.in("id", Arrays.asList(ids.split(",")));
-
-		List<StoreCheck> list = this.list(queryWrapper);
-		if (list.size() == 0) {
-			return Result.error("数据为空!");
-		}
+    @Autowired
+    private StoreCheckMapper storeCheckMapper;
+    @Autowired
+    private StoreCheckDetailsMapper storeCheckDetailsMapper;
+
+    @Autowired
+    private IStoreOnhandService storeOnhandService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveMain(StoreCheck storeCheck, List<StoreCheckDetails> storeCheckDetailsList) {
+        storeCheckMapper.insert(storeCheck);
+        if (storeCheckDetailsList != null && storeCheckDetailsList.size() > 0) {
+            for (StoreCheckDetails entity : storeCheckDetailsList) {
+                //外键设置
+                entity.setId(null);
+                entity.setHeadId(storeCheck.getId());
+                storeCheckDetailsMapper.insert(entity);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateMain(StoreCheck storeCheck, List<StoreCheckDetails> storeCheckDetailsList) {
+        storeCheckMapper.updateById(storeCheck);
+
+        //1.先删除子表数据
+        storeCheckDetailsMapper.deleteByMainId(storeCheck.getId());
+
+        //2.子表数据重新插入
+        if (storeCheckDetailsList != null && storeCheckDetailsList.size() > 0) {
+            for (StoreCheckDetails entity : storeCheckDetailsList) {
+                //外键设置
+                entity.setId(null);
+                entity.setHeadId(storeCheck.getId());
+                storeCheckDetailsMapper.insert(entity);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delMain(String id) {
+        storeCheckDetailsMapper.deleteByMainId(id);
+        storeCheckMapper.deleteById(id);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delBatchMain(Collection<? extends Serializable> idList) {
+        for (Serializable id : idList) {
+            storeCheckDetailsMapper.deleteByMainId(id.toString());
+            storeCheckMapper.deleteById(id);
+        }
+    }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result<String> submitBatch(String ids) {
+
+        QueryWrapper<StoreCheck> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("id", Arrays.asList(ids.split(",")));
+
+        List<StoreCheck> list = this.list(queryWrapper);
+        if (list.size() == 0) {
+            return Result.error("数据为空!");
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for (StoreCheck o : list) {
+            // 1-已提交,0-未提交
+            String submit = o.getSubmit();
+            String code = o.getBillCode();
+
+            if (submit != null && submit != "" && submit.equals("1")) {
+                sb.append("单据编码" + code).append("已提交,请勿再次提交;");
+                continue;
+            }
+        }
+
+        if (StringUtils.isNotBlank(sb.toString())) {
+
+            return Result.error(sb.toString());
+        }
+        try {
+
+            //执行出入库操作
+            String result = actionIn(list, true);
+
+            if ("true".equals(result)) {
+
+                StoreCheck ent = new StoreCheck();
+                ent.setSubmit("1");
+                this.update(ent, queryWrapper);
+            } else {
+
+                return Result.error(result);
+            }
+        }catch (Exception e){
+
+            return Result.error(e.getMessage());
+        }
+
+        return Result.OK("提交成功!");
 
-		StringBuffer sb = new StringBuffer();
-		for (StoreCheck o : list) {
-			// 1-已提交,0-未提交
-			String submit = o.getSubmit();
-			String code = o.getBillCode();
-
-			if (submit != null && submit != "" && submit.equals("1")) {
-				sb.append("单据编码" + code).append("已提交,请勿再次提交;");
-				continue;
-			}
-		}
+    }
 
-		if (StringUtils.isNotBlank(sb.toString())) {
 
-			return Result.error(sb.toString());
-		}
-
-		//执行出入库操作
-		String result = actionIn(list,true);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result<String> returnSubmitBatch(String ids) {
 
-		if ("true".equals(result)) {
+        QueryWrapper<StoreCheck> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("id", Arrays.asList(ids.split(",")));
 
-			StoreCheck ent = new StoreCheck();
-			ent.setSubmit("1");
-			this.update(ent, queryWrapper);
-		} else {
+        List<StoreCheck> list = this.list(queryWrapper);
+        if (list.size() == 0) {
+            return Result.error("数据为空!");
+        }
 
-			return Result.error(result);
-		}
+        StringBuffer sb = new StringBuffer();
+        List<String> idList = new ArrayList<>();
 
-		return Result.OK("提交成功!");
+        for (StoreCheck o : list) {
 
-	}
+            //提交(1-是 ,0-否)
+            String submit = o.getSubmit();
+            String code = o.getBillCode();
+            idList.add(code);
 
+            if (submit == null || submit == "" || submit.equals("0")) {
+                sb.append("单号" + code).append("已取消提交,请勿再次取消提交;");
+                continue;
+            }
+        }
 
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public Result<String> returnSubmitBatch(String ids) {
+        if (StringUtils.isNotBlank(sb.toString())) {
 
-		QueryWrapper<StoreCheck> queryWrapper = new QueryWrapper<>();
-		queryWrapper.in("id", Arrays.asList(ids.split(",")));
+            return Result.error(sb.toString());
+        }
 
-		List<StoreCheck> list = this.list(queryWrapper);
-		if (list.size() == 0) {
-			return Result.error("数据为空!");
-		}
+        try {
 
-		StringBuffer sb = new StringBuffer();
-		List<String> idList = new ArrayList<>();
+            //执行出入库操作
+            String result = actionIn(list, false);
 
-		for (StoreCheck o : list) {
+            if ("true".equals(result)) {
 
-			//提交(1-是 ,0-否)
-			String submit = o.getSubmit();
-			String code = o.getBillCode();
-			idList.add(code);
+                StoreCheck ent = new StoreCheck();
+                ent.setSubmit("0");
+                this.update(ent, queryWrapper);
+            } else {
 
-			if (submit == null || submit == "" || submit.equals("0")) {
-				sb.append("单号" + code).append("已取消提交,请勿再次取消提交;");
-				continue;
-			}
-		}
+                return Result.error(result);
+            }
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
 
-		if (StringUtils.isNotBlank(sb.toString())) {
+        return Result.OK("取消提交成功!");
+    }
 
-			return Result.error(sb.toString());
-		}
 
-		//执行出入库操作
-		String result = actionIn(list,false);
+    //执行出库操作
+    //type true 提交盘盈盘亏 false 取消提交盘盈盘亏
+    @Transactional(rollbackFor = Exception.class)
+    public String actionIn(List<StoreCheck> list, boolean type) {
 
-		if ("true".equals(result)) {
+        try {
 
-			StoreCheck ent = new StoreCheck();
-			ent.setSubmit("0");
-			this.update(ent, queryWrapper);
-		} else {
+            for (StoreCheck o : list) {
 
-			return Result.error(result);
-		}
+                String id = o.getId();
+                String code = o.getBillCode();
+                List<StoreCheckDetails> entList = storeCheckDetailsMapper.selectByMainId(id);
 
-		return Result.OK("取消提交成功!");
-	}
+                for (StoreCheckDetails ent : entList) {
 
+                    //库存id
+                    String sourceId = ent.getSourceId();
+                    //库存数量
+                    BigDecimal inventoryQuantity = ent.getInventoryQuantity();
+                    //盘点数量
+                    BigDecimal countedQuantity = ent.getCountedQuantity();
 
-	//执行出库操作
-	//type true 提交盘盈盘亏 false 取消提交盘盈盘亏
-	@Transactional(rollbackFor = Exception.class)
-	public String actionIn(List<StoreCheck> list,boolean type) {
+                    BigDecimal inventory = countedQuantity.subtract(inventoryQuantity);
 
-		try {
 
-			for (StoreCheck o : list) {
+                    String productCode = ent.getProductCode();
 
-				String id = o.getId();
-				String code = o.getBillCode();
-				List<StoreCheckDetails> entList = storeCheckDetailsMapper.selectByMainId(id);
+                    if (StringUtils.isBlank(sourceId)) {
+                        throw new JeecgBootException(code + "产品:" + productCode + "库存选择不能为空!");
+                    }
+                    if (inventoryQuantity == null || inventoryQuantity.equals(BigDecimal.ZERO)) {
+                        throw new JeecgBootException(code + "产品:" + productCode + "库存数量不能为空或为0!");
+                    }
+                    if (countedQuantity == null || countedQuantity.equals(BigDecimal.ZERO)) {
+                        throw new JeecgBootException(code + "产品:" + productCode + "盘点数量不能为空或为0!");
+                    }
 
-				for (StoreCheckDetails ent : entList) {
 
-					//库存id
-					String sourceId = ent.getSourceId();
-					//库存数量
-					BigDecimal inventoryQuantity = ent.getInventoryQuantity();
-					//盘点数量
-					BigDecimal countedQuantity = ent.getCountedQuantity();
+                    //提交
+                    if (type) {
 
-					BigDecimal inventory = countedQuantity.subtract(inventoryQuantity);
+                        if (inventory.compareTo(BigDecimal.ZERO) > 0) {
 
-					//提交
-					if (type) {
+                            //增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
+                            storeOnhandService.addStoreById(inventory, sourceId, "盘盈盘亏(正数提交)", code);
+                        } else if (inventory.compareTo(BigDecimal.ZERO) < 0) {
 
-						if(inventory.compareTo(BigDecimal.ZERO) > 0){
+                            //减少库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
+                            storeOnhandService.deleteStoreById(inventory.abs(), sourceId, "盘盈盘亏(负数提交)", code);
+                        }
 
-							//增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
-							storeOnhandService.addStoreById(inventory, sourceId, "盘盈盘亏(正数提交)", code);
-						}else if(inventory.compareTo(BigDecimal.ZERO) < 0){
+                        //取消提交
+                    } else {
 
-							//减少库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
-							storeOnhandService.deleteStoreById(inventory.abs(), sourceId, "盘盈盘亏(负数提交)", code);
-						}
+                        if (inventory.compareTo(BigDecimal.ZERO) > 0) {
 
-						//取消提交
-					} else {
+                            //减少库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
+                            storeOnhandService.deleteStoreById(inventory, sourceId, "盘盈盘亏(正数取消提交)", code);
+                        } else if (inventory.compareTo(BigDecimal.ZERO) < 0) {
 
-						if(inventory.compareTo(BigDecimal.ZERO) > 0){
+                            //增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
+                            storeOnhandService.addStoreById(inventory.abs(), sourceId, "盘盈盘亏(负数取消提交)", code);
+                        }
 
-							//减少库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
-							storeOnhandService.deleteStoreById(inventory, sourceId, "盘盈盘亏(正数取消提交)", code);
-						}else if(inventory.compareTo(BigDecimal.ZERO) < 0){
+                    }
+                }
+            }
 
-							//增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
-							storeOnhandService.addStoreById(inventory.abs(), sourceId, "盘盈盘亏(负数取消提交)", code);
-						}
+        } catch (Exception e) {
+            return e.getMessage();
+        }
 
-					}
-				}
-			}
+        return "true";
+    }
 
-		} catch (Exception e) {
-			return e.getMessage();
-		}
-		
-		return "true";
-	}
-	
 }

+ 26 - 2
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StoreOnhandServiceImpl.java

@@ -33,14 +33,26 @@ public class StoreOnhandServiceImpl extends ServiceImpl<StoreOnhandMapper, Store
     private StoreOnhandMapper storeOnhandMapper;
     @Autowired
     private ISerialPatternService serialPatternService;
-
     @Resource
     private ISysDataLogService sysDataLogService;
 
+    public boolean isNullOrEmpty(BigDecimal quantity) {
+        if(quantity == null || quantity.compareTo(BigDecimal.ZERO) == 0){
+            return true;
+        }else{
+            return false;
+        }
+    }
+
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String addStoreById(BigDecimal quantity, String id, String sourceType, String sourceCode) {
 
+        if(isNullOrEmpty(quantity)){
+            throw new JeecgBootException(sourceType +sourceCode+ "产品:" + id + "数量为空,无法执行!");
+        }
+
         try {
 
             StoreOnhand storeOnhand = this.getById(id);
@@ -68,6 +80,9 @@ public class StoreOnhandServiceImpl extends ServiceImpl<StoreOnhandMapper, Store
     @Transactional(rollbackFor = Exception.class)
     public String deleteStoreById(BigDecimal quantity, String id, String sourceType, String sourceCode) {
 
+        if(isNullOrEmpty(quantity)){
+            throw new JeecgBootException(sourceType +sourceCode+ "产品:" + id + "数量为空,无法执行!");
+        }
         try {
 
             StoreOnhand storeOnhand = this.getById(id);
@@ -82,7 +97,7 @@ public class StoreOnhandServiceImpl extends ServiceImpl<StoreOnhandMapper, Store
             }
             sysDataLogService.addDataLog(sourceType + "减少库存", sourceCode+":"+id, quantity.toString());
 
-            BigDecimal newQuantity = quantityOld.add(quantity);
+            BigDecimal newQuantity = quantityOld.subtract(quantity);
 
             storeOnhand.setQuantity(newQuantity);
             this.updateById(storeOnhand);
@@ -105,6 +120,11 @@ public class StoreOnhandServiceImpl extends ServiceImpl<StoreOnhandMapper, Store
 
         try {
 
+            BigDecimal quantity1 = storeOnhand.getQuantity();
+            if(isNullOrEmpty(quantity1)){
+                throw new JeecgBootException(sourceType + "产品:" + productCode + "数量为空,无法执行!");
+            }
+
             QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper();
             queryWrapper.eq("project", storeOnhand.getProject());
             queryWrapper.eq("product_id", storeOnhand.getProductId());
@@ -154,6 +174,10 @@ public class StoreOnhandServiceImpl extends ServiceImpl<StoreOnhandMapper, Store
         String getSourceId = storeOnhand.getSourceId();
         String productCode = storeOnhand.getProductCode();
 
+        BigDecimal quantity1 = storeOnhand.getQuantity();
+        if(isNullOrEmpty(quantity1)){
+            throw new JeecgBootException(sourceType + "产品:" + productCode + "数量为空,无法执行!");
+        }
         try {
 
             QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper();

+ 36 - 16
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StoreOtherOutServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.storeCode.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.storeCode.entity.StoreOtherOut;
 import org.jeecg.modules.storeCode.entity.StoreOtherOutDetails;
 import org.jeecg.modules.storeCode.entity.StoreSaleOut;
@@ -116,17 +117,23 @@ public class StoreOtherOutServiceImpl extends ServiceImpl<StoreOtherOutMapper, S
 			return Result.error(sb.toString());
 		}
 
-		//执行出库操作
-		String result = actionIn(list,false);
+		try {
+
+			//执行出库操作
+			String result = actionIn(list,false);
 
-		if ("true".equals(result)) {
+			if ("true".equals(result)) {
 
-			StoreOtherOut ent = new StoreOtherOut();
-			ent.setSubmit("1");
-			this.update(ent, queryWrapper);
-		} else {
+				StoreOtherOut ent = new StoreOtherOut();
+				ent.setSubmit("1");
+				this.update(ent, queryWrapper);
+			} else {
 
-			return Result.error(result);
+				return Result.error(result);
+			}
+		}catch (JeecgBootException e){
+
+			return Result.error(e.getMessage());
 		}
 
 		return Result.OK("提交成功!");
@@ -167,17 +174,22 @@ public class StoreOtherOutServiceImpl extends ServiceImpl<StoreOtherOutMapper, S
 			return Result.error(sb.toString());
 		}
 
-		//执行出库操作
-		String result = actionIn(list,true);
+ 		try {
+
+			//执行出库操作
+			String result = actionIn(list,true);
 
-		if ("true".equals(result)) {
+			if ("true".equals(result)) {
 
-			StoreOtherOut ent = new StoreOtherOut();
-			ent.setSubmit("0");
-			this.update(ent, queryWrapper);
-		} else {
+				StoreOtherOut ent = new StoreOtherOut();
+				ent.setSubmit("0");
+				this.update(ent, queryWrapper);
+			} else {
 
-			return Result.error(result);
+				return Result.error(result);
+			}
+		}catch (JeecgBootException e){
+			return Result.error(e.getMessage());
 		}
 
 		return Result.OK("取消提交成功!");
@@ -202,9 +214,17 @@ public class StoreOtherOutServiceImpl extends ServiceImpl<StoreOtherOutMapper, S
 
 					//库存id
 					String sourceId = ent.getBatchId();
+					String productCode = ent.getProductCode();
 					//出库数量
 					BigDecimal stockOutQuantity = ent.getStockOutQuantity();
 
+					if(StringUtils.isBlank(sourceId)){
+						throw new JeecgBootException(code+ "产品:" + productCode + "库存选择为空!");
+					}
+					if(stockOutQuantity == null || stockOutQuantity.equals(BigDecimal.ZERO)){
+						throw new JeecgBootException(code+ "产品:" + productCode + "出库数量不能为空或为0!");
+					}
+
 					if (type) {
 						//增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
 						storeOnhandService.addStoreById(stockOutQuantity, sourceId, "其他出库(取消提交)", code);

+ 35 - 28
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StorePurchaseInServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.storeCode.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.storeCode.entity.*;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseInShipMapper;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseInDetailsMapper;
@@ -227,18 +228,6 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
                 continue;
             }
 
-//            //1已处理 0未处理
-//            String hasDeal = o.getHasDeal();
-//            //1采购入库 2异常采购入库
-//            String type = o.getType();
-//
-//            if(StringUtils.isNotBlank(type) && type.equals("2")){
-//
-//                if (hasDeal == null || hasDeal == "" || hasDeal.equals("0")) {
-//                    sb.append("单据编码" + code).append("为异常入库,请先至采购入库异常处理;");
-//                    continue;
-//                }
-//            }
             if (submit != null && submit != "" && submit.equals("1")) {
                 sb.append("单据编码" + code).append("已提交,请勿再次提交;");
                 continue;
@@ -250,17 +239,23 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
             return Result.error(sb.toString());
         }
 
-        //执行入库操作
-        String result = actionIn(list, true);
+        try {
+
+            //执行入库操作
+            String result = actionIn(list, true);
+
+            if ("true".equals(result)) {
 
-        if ("true".equals(result)) {
+                StorePurchaseIn ent = new StorePurchaseIn();
+                ent.setSubmit("1");
+                this.update(ent, queryWrapper);
+            } else {
 
-            StorePurchaseIn ent = new StorePurchaseIn();
-            ent.setSubmit("1");
-            this.update(ent, queryWrapper);
-        } else {
+                return Result.error(result);
+            }
+        }catch (Exception e){
 
-            return Result.error(result);
+            return Result.error(e.getMessage());
         }
 
         return Result.OK("提交入库成功!");
@@ -284,6 +279,12 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
                         continue;
                     }
 
+                    BigDecimal stockInQuantity = ent.getStockInQuantity();
+
+                    if(stockInQuantity == null || stockInQuantity.equals(BigDecimal.ZERO)){
+                        throw new JeecgBootException(o.getBillCode()+ "产品:" + ent.getProductCode() + "入库数量不能为空或为0!");
+                    }
+
                     StoreOnhand storeOnhand = new StoreOnhand();
 
                     storeOnhand.setWarehouse(o.getWarehouse());//仓库
@@ -367,17 +368,23 @@ public class StorePurchaseInServiceImpl extends ServiceImpl<StorePurchaseInMappe
             return Result.error(sb.toString());
         }
 
-        //执行入库操作
-        String result = actionIn(list, false);
+        try {
+
+            //执行入库操作
+            String result = actionIn(list, false);
 
-        if ("true".equals(result)) {
+            if ("true".equals(result)) {
 
-            StorePurchaseIn ent = new StorePurchaseIn();
-            ent.setSubmit("0");
-            this.update(ent, queryWrapper);
-        } else {
+                StorePurchaseIn ent = new StorePurchaseIn();
+                ent.setSubmit("0");
+                this.update(ent, queryWrapper);
+            } else {
+
+                return Result.error(result);
+            }
+        }catch (Exception e){
 
-            return Result.error(result);
+            return Result.error(e.getMessage());
         }
 
 

+ 35 - 16
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StorePurchaseOtherServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.storeCode.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.storeCode.entity.*;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseOtherShipMapper;
 import org.jeecg.modules.storeCode.mapper.StorePurchaseOtherDetailsMapper;
@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -148,17 +150,22 @@ public class StorePurchaseOtherServiceImpl extends ServiceImpl<StorePurchaseOthe
             return Result.error(sb.toString());
         }
 
-        //执行入库操作
-        String result = actionIn(list,true);
+        try {
+            //执行入库操作
+            String result = actionIn(list,true);
+
+            if ("true".equals(result)) {
 
-        if ("true".equals(result)) {
+                StorePurchaseOther ent = new StorePurchaseOther();
+                ent.setSubmit("1");
+                this.update(ent, queryWrapper);
+            } else {
 
-            StorePurchaseOther ent = new StorePurchaseOther();
-            ent.setSubmit("1");
-            this.update(ent, queryWrapper);
-        } else {
+                return Result.error(result);
+            }
 
-            return Result.error(result);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
         }
 
 
@@ -180,6 +187,12 @@ public class StorePurchaseOtherServiceImpl extends ServiceImpl<StorePurchaseOthe
 
                 for (StorePurchaseOtherDetails ent : entList) {
 
+                    BigDecimal stockInQuantity = ent.getStockInQuantity();
+
+                    if(stockInQuantity == null || stockInQuantity.equals(BigDecimal.ZERO)){
+                        throw new JeecgBootException(o.getBillCode()+ "产品:" + ent.getProductCode() + "入库数量不能为空或为0!");
+                    }
+
                     StoreOnhand storeOnhand = new StoreOnhand();
 
                     storeOnhand.setWarehouse(o.getWarehouse());//仓库
@@ -258,17 +271,23 @@ public class StorePurchaseOtherServiceImpl extends ServiceImpl<StorePurchaseOthe
             return Result.error(sb.toString());
         }
 
-        //执行入库操作
-        String result = actionIn(list,false);
+        try {
+
+            //执行入库操作
+            String result = actionIn(list,false);
 
-        if ("true".equals(result)) {
+            if ("true".equals(result)) {
 
-            StorePurchaseOther ent = new StorePurchaseOther();
-            ent.setSubmit("0");
-            this.update(ent, queryWrapper);
-        } else {
+                StorePurchaseOther ent = new StorePurchaseOther();
+                ent.setSubmit("0");
+                this.update(ent, queryWrapper);
+            } else {
+
+                return Result.error(result);
+            }
 
-            return Result.error(result);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
         }
 
         return Result.OK("取消提交成功!");

+ 33 - 16
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StoreSaleOutServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.storeCode.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.storeCode.entity.StoreSaleOut;
 import org.jeecg.modules.storeCode.entity.StoreSaleOutShip;
 import org.jeecg.modules.storeCode.entity.StoreSaleOutDetails;
@@ -167,18 +168,22 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
 
             return Result.error(sb.toString());
         }
+        try {
 
-        //执行出库操作
-        String result = actionIn(list, false);
+            //执行出库操作
+            String result = actionIn(list, false);
 
-        if ("true".equals(result)) {
+            if ("true".equals(result)) {
 
-            StoreSaleOut ent = new StoreSaleOut();
-            ent.setSubmit("1");
-            this.update(ent, queryWrapper);
-        } else {
+                StoreSaleOut ent = new StoreSaleOut();
+                ent.setSubmit("1");
+                this.update(ent, queryWrapper);
+            } else {
 
-            return Result.error(result);
+                return Result.error(result);
+            }
+        }catch (Exception e){
+            return Result.error(e.getMessage());
         }
 
         return Result.OK("提交成功!");
@@ -217,17 +222,21 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
             return Result.error(sb.toString());
         }
 
-        //执行出库操作
-        String result = actionIn(list, true);
+        try {
+            //执行出库操作
+            String result = actionIn(list, true);
 
-        if ("true".equals(result)) {
+            if ("true".equals(result)) {
 
-            StoreSaleOut ent = new StoreSaleOut();
-            ent.setSubmit("0");
-            this.update(ent, queryWrapper);
-        } else {
+                StoreSaleOut ent = new StoreSaleOut();
+                ent.setSubmit("0");
+                this.update(ent, queryWrapper);
+            } else {
 
-            return Result.error(result);
+                return Result.error(result);
+            }
+        }catch (Exception e){
+            return Result.error(e.getMessage());
         }
 
         return Result.OK("取消提交成功!");
@@ -251,9 +260,17 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
 
                     //库存id
                     String sourceId = ent.getBatchId();
+                    String productCode = ent.getProductCode();
                     //出库数量
                     BigDecimal stockOutQuantity = ent.getStockOutQuantity();
 
+                    if(StringUtils.isBlank(sourceId)){
+                        throw new JeecgBootException(code+ "产品:" + productCode + "库存选择为空!");
+                    }
+                    if(stockOutQuantity == null || stockOutQuantity.equals(BigDecimal.ZERO)){
+                        throw new JeecgBootException(code+ "产品:" + productCode + "出库数量不能为空或为0!");
+                    }
+
                     if (type) {
                         //增加库存 BigDecimal quantity,String id,  String sourceType, String sourceCode
                         storeOnhandService.addStoreById(stockOutQuantity, sourceId, "销售出库(取消提交)", code);