413 460 513 514
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -55,6 +56,7 @@ public class InfectiousDiseaseReportDto {
|
||||
private String sex;
|
||||
|
||||
/** 出生日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/** 实足年龄 */
|
||||
|
||||
@@ -17,6 +17,9 @@ import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.workflow.domain.InventoryItem;
|
||||
import com.openhis.workflow.service.IInventoryItemService;
|
||||
import com.openhis.web.basedatamanage.dto.LocationDto;
|
||||
import com.openhis.web.common.dto.UnitDto;
|
||||
import com.openhis.web.inventorymanage.appservice.IProductTransferAppService;
|
||||
@@ -57,6 +60,9 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Autowired
|
||||
private IPractitionerService practitionerService;
|
||||
|
||||
@Autowired
|
||||
private IInventoryItemService inventoryItemService;
|
||||
|
||||
/**
|
||||
* 商品调拨页面初始化
|
||||
*
|
||||
@@ -196,6 +202,23 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Override
|
||||
public R<?> addOrEditBatchTransferReceipt(List<ProductTransferDto> productTransferDtoList, Boolean flag) {
|
||||
|
||||
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (ProductTransferDto dto : productTransferDtoList) {
|
||||
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0");
|
||||
}
|
||||
// 查询该药品在源仓库的实时库存总量
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
dto.getItemId(), dto.getLotNumber(), dto.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (dto.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + ")");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> idList = new ArrayList<>();
|
||||
if (flag) {
|
||||
// 批量保存按钮
|
||||
@@ -309,6 +332,22 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
@Override
|
||||
public R<?> addOrEditTransferReceipt(List<ProductTransferDto> productTransferDtoList) {
|
||||
|
||||
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (ProductTransferDto dto : productTransferDtoList) {
|
||||
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0");
|
||||
}
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
dto.getItemId(), dto.getLotNumber(), dto.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (dto.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + ")");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> idList = new ArrayList<>();
|
||||
|
||||
// 单据号取得
|
||||
@@ -380,6 +419,25 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
|
||||
*/
|
||||
@Override
|
||||
public R<?> submitApproval(String busNo) {
|
||||
// 提交前再次校验调拨数量(从数据库查实时库存)
|
||||
List<SupplyRequest> requestList = supplyRequestService.getSupplyByBusNo(busNo);
|
||||
if (requestList != null && !requestList.isEmpty()) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
for (SupplyRequest request : requestList) {
|
||||
if (request.getItemQuantity() == null || request.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
||||
return R.fail("调拨数量必须大于0,请检查后重新保存");
|
||||
}
|
||||
// 查询该药品在源仓库的实时库存总量
|
||||
List<InventoryItem> inventoryList = inventoryItemService.selectInventoryByItemId(
|
||||
request.getItemId(), request.getLotNumber(), request.getSourceLocationId(), tenantId);
|
||||
java.math.BigDecimal actualStock = inventoryList.stream()
|
||||
.map(InventoryItem::getQuantity)
|
||||
.reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add);
|
||||
if (request.getItemQuantity().compareTo(actualStock) > 0) {
|
||||
return R.fail("调拨数量不可超出源库存数量(当前库存:" + actualStock + "),请检查后重新保存");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 单据提交审核
|
||||
boolean result = supplyRequestService.submitApproval(busNo);
|
||||
return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, null))
|
||||
|
||||
Reference in New Issue
Block a user