|
@@ -14,6 +14,7 @@ import com.zkqy.business.service.ISaleAccountsReceivableDetailService;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
|
+import lombok.val;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -722,19 +723,24 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
@Override
|
|
|
public AjaxResult oldNoticeOutStorage(ProductInvoice productInvoice) {
|
|
|
|
|
|
- //修改通知单、发货日期、发货仓库、调拨仓库、发货员、
|
|
|
- ProductInvoice productInvoice1 = new ProductInvoice();
|
|
|
- productInvoice1.setId(productInvoice.getId());
|
|
|
- productInvoice1.setDeliveryDate(productInvoice.getDeliveryDate());
|
|
|
- productInvoice1.setDeliveryWarehouse(productInvoice.getDeliveryWarehouse());
|
|
|
- productInvoice1.setTransferWarehouse(productInvoice.getTransferWarehouse());
|
|
|
- productInvoice1.setDeliveryClerk(productInvoice.getDeliveryClerk());
|
|
|
- productInvoiceMapper.updateProductInvoice(productInvoice1);
|
|
|
int xs = 0;//箱数用于添加出库记录
|
|
|
Double zl = 0.0;//重量用于添加出库记录
|
|
|
// 减去手动输入的老库存,当前订单出库
|
|
|
+ int totalBoxNum = 0;
|
|
|
+ Double totalSuttle = 0.0;
|
|
|
+ boolean returnState = false;
|
|
|
+ String msg = "";
|
|
|
for (ProductInvoiceVO.SaleProductInfo item : productInvoice.getOldProductInvoiceList()) {
|
|
|
-
|
|
|
+ // 得到当前出库货品库存(老库存)
|
|
|
+ ProductInventory product = new ProductInventory();
|
|
|
+ product.setLotNum(item.getLotNum());
|
|
|
+ product.setProductId(item.getProductId());
|
|
|
+ product.setProductColour(item.getProductColor());
|
|
|
+ product.setInventoryType("2");
|
|
|
+ List<ProductInventory> productInventoryList = productInventoryMapper.oldselectProductInventoryByLotNumAndProductId(product);
|
|
|
+ if (productInventoryList.size() == 0) {
|
|
|
+ return AjaxResult.error("库存不足!");
|
|
|
+ }
|
|
|
// 新增老货品出库记录
|
|
|
OldProductOutboundRecord oldProductOutboundRecord = new OldProductOutboundRecord();
|
|
|
oldProductOutboundRecord.setSaleOrderNo(productInvoice.getSaleOrderNo());
|
|
@@ -749,99 +755,49 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
oldProductOutboundRecordService.insertOldProductOutboundRecord(oldProductOutboundRecord);
|
|
|
|
|
|
|
|
|
-
|
|
|
- // 得到当前出库货品库存(老库存)
|
|
|
- ProductInventory product = new ProductInventory();
|
|
|
- product.setLotNum(item.getLotNum());
|
|
|
- product.setProductId(item.getProductId());
|
|
|
- product.setProductColour(item.getProductColor());
|
|
|
- product.setInventoryType("2");
|
|
|
- List<ProductInventory> productInventoryList = productInventoryMapper.oldselectProductInventoryByLotNumAndProductId(product);
|
|
|
- if (productInventoryList.size() == 0) {
|
|
|
- return AjaxResult.error("库存不足!");
|
|
|
- }
|
|
|
-
|
|
|
- //返回变量
|
|
|
- String msg = "";
|
|
|
- boolean returnState = false;
|
|
|
- int del = 0;
|
|
|
- // 循环减当前库存
|
|
|
+ int totalBoxNums = item.getOldActualBoxNum();//记录剩余箱数
|
|
|
+ Double totalSuttles = item.getOldActualWeight();//记录剩余重量
|
|
|
+ //循环处理库存
|
|
|
for (int i = 0; i < productInventoryList.size(); i++) {
|
|
|
//当前库存对象
|
|
|
ProductInventory productInventory = productInventoryList.get(i);
|
|
|
- // 更新库存对象
|
|
|
+ // 更新库存对象类
|
|
|
ProductInventory editProductInventory = new ProductInventory();
|
|
|
editProductInventory.setId(productInventory.getId());
|
|
|
- if(productInventory.getTotalBoxNum() > xs || item.getOldActualWeight() > zl){
|
|
|
- //箱数
|
|
|
- if (productInventory.getTotalBoxNum() - 1 < 0) {
|
|
|
- // 判断当前循环是否到达最后
|
|
|
- if (i == productInventoryList.size() - 1) {
|
|
|
- returnState = true;
|
|
|
- msg = "当前库存箱数不足";
|
|
|
- } else {
|
|
|
- del++;
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- int totalBoxNum = productInventory.getTotalBoxNum() - item.getOldActualBoxNum();
|
|
|
- // 判断当前减去
|
|
|
- if (totalBoxNum <= 0) {
|
|
|
- Math.abs(totalBoxNum); // 当前出库还差多少箱数
|
|
|
- item.setOldActualBoxNum(Math.abs(totalBoxNum));
|
|
|
- editProductInventory.setTotalBoxNum(0);
|
|
|
- } else {
|
|
|
- editProductInventory.setTotalBoxNum(totalBoxNum);
|
|
|
- item.setOldActualBoxNum(0);
|
|
|
- }
|
|
|
- //获得当前减去的库存箱数
|
|
|
- xs = productInventory.getTotalBoxNum() - totalBoxNum;
|
|
|
+ //箱数
|
|
|
+ if(productInventory.getTotalBoxNum() > 0 && item.getOldActualBoxNum() > 0){
|
|
|
+ if(productInventory.getTotalBoxNum() - item.getOldActualBoxNum() > 0){
|
|
|
+ editProductInventory.setTotalBoxNum(productInventory.getTotalBoxNum() - item.getOldActualBoxNum());
|
|
|
+ xs = item.getOldActualBoxNum();
|
|
|
+ item.setOldActualBoxNum(0);
|
|
|
+ }else{
|
|
|
+ editProductInventory.setTotalBoxNum(0);
|
|
|
+ xs = item.getOldActualBoxNum() - Math.abs(productInventory.getTotalBoxNum() - item.getOldActualBoxNum());
|
|
|
+ item.setOldActualBoxNum(Math.abs(productInventory.getTotalBoxNum() - item.getOldActualBoxNum()));
|
|
|
}
|
|
|
-
|
|
|
- //净重
|
|
|
- if (productInventory.getTotalSuttle() - item.getOldActualWeight() < 0) {
|
|
|
- // 判断当前循环是否到达最后
|
|
|
- if (i == productInventoryList.size() - 1) {
|
|
|
- returnState = true;
|
|
|
- msg = "当前库存重量不足";
|
|
|
- } else {
|
|
|
- del++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- Double totalSuttle = handlingWeight(productInventory.getTotalSuttle() - item.getOldActualWeight());
|
|
|
- if (totalSuttle <= 0.0) {
|
|
|
-// Math.abs(totalSuttle);
|
|
|
- item.setOldActualWeight(Math.abs(totalSuttle));
|
|
|
- editProductInventory.setTotalSuttle(0.0);
|
|
|
- } else {
|
|
|
- editProductInventory.setTotalSuttle(totalSuttle);
|
|
|
- item.setOldActualWeight(0.0);
|
|
|
- }
|
|
|
- //获得当前减去的库存重量
|
|
|
- zl = handlingWeight(productInventory.getTotalSuttle() - totalSuttle);
|
|
|
- }
|
|
|
-
|
|
|
- // //毛重
|
|
|
- // if (productInventory.getTotalGrossWeight() - item.getOldActualWeight() < 0) {
|
|
|
- // // 判断当前循环是否到达最后
|
|
|
- // if (i == productInventoryList.size() - 1) {
|
|
|
- // returnState = true;
|
|
|
- // msg = "当前库存毛重不足";
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // Double totalGrossWeight = handlingWeight(productInventory.getTotalGrossWeight() - item.getOldActualWeight());
|
|
|
- // if (totalGrossWeight <= 0.0) {
|
|
|
- // item.setOldActualWeight(Math.abs(totalGrossWeight));
|
|
|
- // editProductInventory.setTotalSuttle(0.0);
|
|
|
- // } else {
|
|
|
- // editProductInventory.setTotalGrossWeight(totalGrossWeight);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- if (del == 2) {
|
|
|
+ }
|
|
|
+ //减库存
|
|
|
+ if(productInventory.getTotalSuttle() > 0 && item.getOldActualWeight() > 0){
|
|
|
+ if(productInventory.getTotalSuttle() - item.getOldActualWeight() > 0){
|
|
|
+ editProductInventory.setTotalSuttle(productInventory.getTotalSuttle() - item.getOldActualWeight());
|
|
|
+ zl = item.getOldActualWeight();
|
|
|
+ item.setOldActualWeight(0.0);
|
|
|
+ }else{
|
|
|
+ editProductInventory.setTotalSuttle(0.0);
|
|
|
editProductInventory.setDelFlag("2");
|
|
|
+ zl = item.getOldActualWeight() - Math.abs(productInventory.getTotalSuttle() - item.getOldActualWeight());
|
|
|
+ item.setOldActualWeight(Math.abs(productInventory.getTotalSuttle() - item.getOldActualWeight()));
|
|
|
}
|
|
|
+ }
|
|
|
+ if (i == productInventoryList.size() - 1) {
|
|
|
+ if(item.getOldActualWeight() > 0) {
|
|
|
+ returnState = true;
|
|
|
+ msg = "当前库存重量不足";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Boolean present = Optional.ofNullable(editProductInventory.getTotalBoxNum()).isPresent();
|
|
|
+ Boolean presentSuttle = Optional.ofNullable(editProductInventory.getTotalSuttle()).isPresent();
|
|
|
+ if(present || presentSuttle){
|
|
|
// 成品出库记录
|
|
|
ProductOutboundRecord productOutboundRecord = new ProductOutboundRecord();
|
|
|
productOutboundRecord.setQrCode("lkc_"+System.currentTimeMillis());//码单号
|
|
@@ -875,9 +831,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
productOutboundRecordMapper.insertProductOutboundRecord(productOutboundRecord);
|
|
|
productInventoryMapper.updateProductInventory(editProductInventory);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
if (returnState) {
|
|
|
return AjaxResult.error(msg);
|
|
|
}
|
|
@@ -885,6 +839,14 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //修改通知单、发货日期、发货仓库、调拨仓库、发货员、
|
|
|
+ ProductInvoice productInvoice1 = new ProductInvoice();
|
|
|
+ productInvoice1.setId(productInvoice.getId());
|
|
|
+ productInvoice1.setDeliveryDate(productInvoice.getDeliveryDate());
|
|
|
+ productInvoice1.setDeliveryWarehouse(productInvoice.getDeliveryWarehouse());
|
|
|
+ productInvoice1.setTransferWarehouse(productInvoice.getTransferWarehouse());
|
|
|
+ productInvoice1.setDeliveryClerk(productInvoice.getDeliveryClerk());
|
|
|
+ productInvoiceMapper.updateProductInvoice(productInvoice1);
|
|
|
//修改销售单状态为已完成
|
|
|
//查询通知单详情获取
|
|
|
ProductInvoice productInvoice2 = productInvoiceMapper.selectProductInvoiceById(productInvoice.getId());
|