|
@@ -9,6 +9,8 @@ import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
|
|
+import com.sd.business.entity.in.dto.CorrectionDto;
|
|
|
|
+import com.sd.business.entity.in.po.InOutStorageBom;
|
|
import com.sd.business.entity.in.po.InOutStorageDetails;
|
|
import com.sd.business.entity.in.po.InOutStorageDetails;
|
|
import com.sd.business.entity.inventory.bo.InOutFun;
|
|
import com.sd.business.entity.inventory.bo.InOutFun;
|
|
import com.sd.business.entity.inventory.dto.GetQuantityDto;
|
|
import com.sd.business.entity.inventory.dto.GetQuantityDto;
|
|
@@ -27,6 +29,7 @@ import com.sd.framework.util.excel.util.ExcelUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -246,6 +249,71 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public void correction(CorrectionDto dto) {
|
|
|
|
+ List<InOutStorageBom> inOutStorageBomList = dto.getInOutStorageBomList();
|
|
|
|
+ List<Long> bomSpecIdList = inOutStorageBomList.stream().map(InOutStorageBom::getBomSpecId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<Inventory> addInventoryList = new ArrayList<>();
|
|
|
|
+ List<Inventory> updateInventoryList;
|
|
|
|
+ List<InOutStorageDetails> addInOutStorageDetailsList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ synchronized (this) {
|
|
|
|
+
|
|
|
|
+ updateInventoryList = getInventoryList(dto.getDepartmentId(), dto.getWarehouseId(), bomSpecIdList);
|
|
|
|
+ Map<Long, Inventory> map = updateInventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ for (InOutStorageBom inOutStorageBom : inOutStorageBomList) {
|
|
|
|
+ Long bomSpecId = inOutStorageBom.getBomSpecId();
|
|
|
|
+ BigDecimal quantity = inOutStorageBom.getQuantity();
|
|
|
|
+ Inventory inventory = map.get(bomSpecId);
|
|
|
|
+
|
|
|
|
+ InOutStorageDetails inOutStorageDetails = new InOutStorageDetails();
|
|
|
|
+ inOutStorageDetails.setWarehouseId(dto.getWarehouseId());
|
|
|
|
+ inOutStorageDetails.setDepartmentId(dto.getDepartmentId());
|
|
|
|
+ inOutStorageDetails.setBomSpecId(bomSpecId);
|
|
|
|
+ inOutStorageDetails.setQuantity(quantity);
|
|
|
|
+
|
|
|
|
+ if (inventory == null) {
|
|
|
|
+ Inventory addInventory = new Inventory();
|
|
|
|
+ addInventory.setWarehouseId(dto.getWarehouseId());
|
|
|
|
+ addInventory.setDepartmentId(dto.getDepartmentId());
|
|
|
|
+ addInventory.setBomSpecId(bomSpecId);
|
|
|
|
+ addInventory.setQuantity(quantity);
|
|
|
|
+ addInventory.setBalanceUnitPrice(BigDecimal.ZERO);
|
|
|
|
+ addInventoryList.add(addInventory);
|
|
|
|
+
|
|
|
|
+ inOutStorageDetails.setInUnitPrice(BigDecimal.ZERO);
|
|
|
|
+ } else {
|
|
|
|
+ inventory.setQuantity(quantity);
|
|
|
|
+
|
|
|
|
+ inOutStorageDetails.setInUnitPrice(inventory.getBalanceUnitPrice());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addInOutStorageDetailsList.add(inOutStorageDetails);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ inOutStorageDetailsService.remove(q -> q
|
|
|
|
+ .eq(InOutStorageDetails::getWarehouseId, dto.getWarehouseId())
|
|
|
|
+ .eq(InOutStorageDetails::getDepartmentId, dto.getDepartmentId())
|
|
|
|
+ .in(InOutStorageDetails::getBomSpecId, bomSpecIdList)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ inOutStorageDetailsService.saveBatch(addInOutStorageDetailsList);
|
|
|
|
+
|
|
|
|
+ if (addInventoryList.size() > 0) {
|
|
|
|
+ saveBatch(addInventoryList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (updateInventoryList.size() > 0) {
|
|
|
|
+ updateBatchById(updateInventoryList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 通过事业部id和出库id获取bom规格库存
|
|
* 通过事业部id和出库id获取bom规格库存
|
|
*/
|
|
*/
|