|
@@ -4,6 +4,7 @@ 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.StoreOnhand;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreSaleOut;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreSaleOutShip;
|
|
|
import org.jeecg.modules.storeCode.entity.StoreSaleOutDetails;
|
|
@@ -54,8 +55,40 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
storeSaleOutShipMapper.insert(entity);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ String project = storeSaleOut.getProject();
|
|
|
+ String warehouse = storeSaleOut.getWarehouse();
|
|
|
+ String goodsAllocation = storeSaleOut.getGoodsAllocation();
|
|
|
+
|
|
|
if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
|
|
|
for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
|
|
|
+
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity();
|
|
|
+
|
|
|
+ if (stockOutQuantity == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String productId = entity.getProductId();
|
|
|
+ // 项目、仓库、货位、产品编码
|
|
|
+
|
|
|
+ QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("project", project);
|
|
|
+ queryWrapper.eq("warehouse", warehouse);
|
|
|
+ queryWrapper.eq("goods_allocation", goodsAllocation);
|
|
|
+ queryWrapper.eq("product_id", productId);
|
|
|
+ queryWrapper.eq("del_flag", 0);
|
|
|
+
|
|
|
+ List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
|
|
|
+
|
|
|
+ if (list.size() > 0) {
|
|
|
+
|
|
|
+ BigDecimal quantity = list.get(0).getQuantity();
|
|
|
+ if (quantity.compareTo(stockOutQuantity) >= 0) {
|
|
|
+ entity.setInventorySelection(list.get(0).getBatchCode());
|
|
|
+ entity.setBatchId(list.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//外键设置
|
|
|
entity.setId(null);
|
|
|
entity.setHeadId(storeSaleOut.getId());
|
|
@@ -69,6 +102,10 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
public void updateMain(StoreSaleOut storeSaleOut, List<StoreSaleOutShip> storeSaleOutShipList, List<StoreSaleOutDetails> storeSaleOutDetailsList) {
|
|
|
storeSaleOutMapper.updateById(storeSaleOut);
|
|
|
|
|
|
+ String project = storeSaleOut.getProject();
|
|
|
+ String warehouse = storeSaleOut.getWarehouse();
|
|
|
+ String goodsAllocation = storeSaleOut.getGoodsAllocation();
|
|
|
+
|
|
|
//1.先删除子表数据
|
|
|
storeSaleOutShipMapper.deleteByMainId(storeSaleOut.getId());
|
|
|
storeSaleOutDetailsMapper.deleteByMainId(storeSaleOut.getId());
|
|
@@ -84,6 +121,35 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
}
|
|
|
if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
|
|
|
for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
|
|
|
+
|
|
|
+ BigDecimal stockOutQuantity = entity.getStockOutQuantity();
|
|
|
+
|
|
|
+ if (stockOutQuantity == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String productId = entity.getProductId();
|
|
|
+ // 项目、仓库、货位、产品编码
|
|
|
+
|
|
|
+ QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("project", project);
|
|
|
+ queryWrapper.eq("warehouse", warehouse);
|
|
|
+ queryWrapper.eq("goods_allocation", goodsAllocation);
|
|
|
+ queryWrapper.eq("product_id", productId);
|
|
|
+ queryWrapper.eq("del_flag", 0);
|
|
|
+
|
|
|
+ List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
|
|
|
+
|
|
|
+ if (list.size() > 0) {
|
|
|
+
|
|
|
+ BigDecimal quantity = list.get(0).getQuantity();
|
|
|
+ if (quantity.compareTo(stockOutQuantity) >= 0) {
|
|
|
+ entity.setInventorySelection(list.get(0).getBatchCode());
|
|
|
+ entity.setBatchId(list.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//外键设置
|
|
|
entity.setId(null);
|
|
|
entity.setHeadId(storeSaleOut.getId());
|
|
@@ -183,7 +249,7 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
throw new JeecgBootException(result);
|
|
|
// return Result.error(result);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
throw new JeecgBootException(e.getMessage());
|
|
|
// return Result.error(e.getMessage());
|
|
|
}
|
|
@@ -237,7 +303,7 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
throw new JeecgBootException(result);
|
|
|
// return Result.error(result);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
throw new JeecgBootException(e.getMessage());
|
|
|
// return Result.error(e.getMessage());
|
|
|
}
|
|
@@ -267,11 +333,11 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
//出库数量
|
|
|
BigDecimal stockOutQuantity = ent.getStockOutQuantity();
|
|
|
|
|
|
- if(StringUtils.isBlank(sourceId)){
|
|
|
- throw new JeecgBootException(code+ "产品:" + productCode + "库存选择为空!");
|
|
|
+ if (StringUtils.isBlank(sourceId)) {
|
|
|
+ throw new JeecgBootException(code + "产品:" + productCode + "库存选择为空!");
|
|
|
}
|
|
|
- if(isNullOrEmpty(stockOutQuantity)){
|
|
|
- throw new JeecgBootException(code+ "产品:" + productCode + "出库数量不能为空或为0!");
|
|
|
+ if (isNullOrEmpty(stockOutQuantity)) {
|
|
|
+ throw new JeecgBootException(code + "产品:" + productCode + "出库数量不能为空或为0!");
|
|
|
}
|
|
|
|
|
|
if (type) {
|
|
@@ -295,9 +361,9 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
|
|
|
|
|
|
|
|
|
public boolean isNullOrEmpty(BigDecimal quantity) {
|
|
|
- if(quantity == null || quantity.compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ if (quantity == null || quantity.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
return true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|