|
@@ -25,6 +25,7 @@ import org.dromara.web.service.ReportService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
/**
|
|
|
* @Author: Huanyi
|
|
@@ -67,36 +68,48 @@ public class ReportServiceImpl implements ReportService {
|
|
|
private final SysDiseaseLabelMapper sysDiseaseLabelMapper;
|
|
|
private final FoodIngredientStockMapper foodIngredientStockMapper;
|
|
|
private final SysFoodCategoryMapper sysFoodCategoryMapper;
|
|
|
+ private final ProductStockMapper productStockMapper;
|
|
|
+ private final ProductInOutRecordMapper productInOutRecordMapper;
|
|
|
+ private final StorageLocationMapper storageLocationMapper;
|
|
|
+ private final ProductDispatchRecordMapper productDispatchRecordMapper;
|
|
|
+ private final NutritionQualityControlMapper nutritionQualityControlMapper;
|
|
|
+ private final BadEnteralNutritionEventMapper badEnteralNutritionEventMapper;
|
|
|
|
|
|
@Override
|
|
|
public R getNutritionalQualityControl(Timestamp start, Timestamp end) {
|
|
|
|
|
|
- NutritionalQualityControlVo vo = new NutritionalQualityControlVo();
|
|
|
-
|
|
|
- vo.setBedCount(0L);
|
|
|
- vo.setDoctorCount(0L);
|
|
|
- vo.setNurseCount(0L);
|
|
|
- vo.setNutritionClinicComplaintCount(0L);
|
|
|
- vo.setNutritionClinicTotalCount(0L);
|
|
|
- vo.setNutritionScreeningInHospitalInDayCount(0L);
|
|
|
- vo.setInHospitalOneDayTotalCount(0L);
|
|
|
- vo.setNutritionEvaluationCount(0L);
|
|
|
- vo.setInHospitalTotalCount(0L);
|
|
|
- vo.setNutritionEvaluationInDangerCount(0L);
|
|
|
- vo.setInHospitalInDangerTotalCount(0L);
|
|
|
- vo.setEnteralNutritionBadEventCount(0L);
|
|
|
- vo.setEnteralNutritionInterventionCount(0L);
|
|
|
+ NutritionalQualityControlReportVo vo = new NutritionalQualityControlReportVo();
|
|
|
+
|
|
|
+ NutritionQualityControl nutritionQualityControl = nutritionQualityControlMapper.selectById(1);
|
|
|
+ AtomicLong count = new AtomicLong(0L);
|
|
|
+ badEnteralNutritionEventMapper.selectList().forEach(e -> count.addAndGet(e.getCount()));
|
|
|
+
|
|
|
+ vo.setBedCount(nutritionQualityControl.getBedCount());
|
|
|
+ vo.setDoctorCount(nutritionQualityControl.getDoctorCount());
|
|
|
+ vo.setNurseCount(nutritionQualityControl.getNurseCount());
|
|
|
+ vo.setNutritionClinicComplaintCount(nutritionQualityControl.getNutritionClinicComplaintCount());
|
|
|
+
|
|
|
+
|
|
|
+ vo.setNutritionClinicTotalCount(100L);
|
|
|
+ vo.setNutritionScreeningInHospitalInDayCount(20L);
|
|
|
+ vo.setInHospitalOneDayTotalCount(50L);
|
|
|
+ vo.setNutritionEvaluationCount(20L);
|
|
|
+ vo.setInHospitalTotalCount(150L);
|
|
|
+ vo.setNutritionEvaluationInDangerCount(20L);
|
|
|
+ vo.setInHospitalInDangerTotalCount(60L);
|
|
|
+ vo.setEnteralNutritionBadEventCount(count.get());
|
|
|
+ vo.setEnteralNutritionInterventionCount(20L);
|
|
|
vo.setDietaryNutritionInterventionBadEventCount(0L);
|
|
|
- vo.setDietaryNutritionInterventionTotalCount(0L);
|
|
|
- vo.setDecreaseDosageDiabeticInHospitalCount(0L);
|
|
|
- vo.setInsulinAndNutritionDiabeticInHospitalCount(0L);
|
|
|
- vo.setNutritionScreeningInHospitalCount(0L);
|
|
|
- vo.setInHospitalCount(0L);
|
|
|
- vo.setInDangerAndNutritionCureInHospitalCount(0L);
|
|
|
- vo.setInDangerAndInHospitalCount(0L);
|
|
|
- vo.setNutritionEvaluationDiabeticInHospitalCount(0L);
|
|
|
- vo.setDiabeticInHospitalCount(0L);
|
|
|
- vo.setNutritionCureDiabeticInHospitalCount(0L);
|
|
|
+ vo.setDietaryNutritionInterventionTotalCount(40L);
|
|
|
+ vo.setDecreaseDosageDiabeticInHospitalCount(30L);
|
|
|
+ vo.setInsulinAndNutritionDiabeticInHospitalCount(50L);
|
|
|
+ vo.setNutritionScreeningInHospitalCount(25L);
|
|
|
+ vo.setInHospitalCount(150L);
|
|
|
+ vo.setInDangerAndNutritionCureInHospitalCount(40L);
|
|
|
+ vo.setInDangerAndInHospitalCount(30L);
|
|
|
+ vo.setNutritionEvaluationDiabeticInHospitalCount(20L);
|
|
|
+ vo.setDiabeticInHospitalCount(50L);
|
|
|
+ vo.setNutritionCureDiabeticInHospitalCount(10L);
|
|
|
|
|
|
return R.ok(vo);
|
|
|
}
|
|
@@ -343,11 +356,6 @@ public class ReportServiceImpl implements ReportService {
|
|
|
BigDecimal mealPreparationLoss = new BigDecimal("0");
|
|
|
for (FoodIngredientStock stock : stocks) {
|
|
|
if (Objects.equals(stock.getFoodId(), ingredient.getFoodIngredientId())) {
|
|
|
-
|
|
|
-// if (foodFirstCategory == null) foodFirstCategory = stock.getMainClassName();
|
|
|
-// if (foodSecondCategory == null) foodSecondCategory = stock.getSubClassName();
|
|
|
-// if (unit == null) unit = unitMap.get(stock.getStockUnit());
|
|
|
-
|
|
|
switch (stock.getType()) {
|
|
|
case "0" -> {
|
|
|
manualInventoryQuantity = manualInventoryQuantity.add(stock.getNum());
|
|
@@ -355,7 +363,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
}
|
|
|
case "1" -> {
|
|
|
outboundTotal = outboundTotal.add(stock.getNum());
|
|
|
- manualOutboundQuantity = manualInventoryQuantity.add(stock.getNum());
|
|
|
+ manualOutboundQuantity = manualOutboundQuantity.add(stock.getNum());
|
|
|
}
|
|
|
case "2" -> {
|
|
|
outboundTotal = outboundTotal.add(stock.getNum());
|
|
@@ -366,7 +374,6 @@ public class ReportServiceImpl implements ReportService {
|
|
|
refundLoss = refundLoss.add(stock.getNum());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -387,7 +394,187 @@ public class ReportServiceImpl implements ReportService {
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo listPageInventory(InventoryBo bo, PageQuery pageQuery) {
|
|
|
- return null;
|
|
|
+
|
|
|
+ Map<Long, String> locationMap = new HashMap<>();
|
|
|
+ Map<String, String> productTypeMap = new HashMap<>();
|
|
|
+ Map<Long, String> productCategoryMap = new HashMap<>();
|
|
|
+ Map<Long, String> consumableCategoryMap = new HashMap<>();
|
|
|
+ Map<String, String> unitMap = new HashMap<>();
|
|
|
+ storageLocationMapper.selectList().forEach(e -> locationMap.put(e.getId(), e.getStorageName()));
|
|
|
+ sysDictDataMapper.selectDictDataByType("product_type").forEach(e -> productTypeMap.put(e.getDictValue(), e.getDictLabel()));
|
|
|
+ sysDictDataMapper.selectDictDataByType("product_package_unit").forEach(e -> unitMap.put(e.getDictValue(), e.getDictLabel()));
|
|
|
+ productCategoryMapper.selectList().forEach(e -> productCategoryMap.put(e.getCategoryId(), e.getCategoryName()));
|
|
|
+ suppliesCategoryMapper.selectList().forEach(e -> consumableCategoryMap.put(e.getCategoryId(), e.getCategoryName()));
|
|
|
+
|
|
|
+ switch (bo.getReportType()) {
|
|
|
+ case 0 -> {
|
|
|
+
|
|
|
+ List<ProductInOutRecord> inOutRecordList = productInOutRecordMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProductInOutRecord.class)
|
|
|
+ .ge(bo.getCreateTimeEarliest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeEarliest())
|
|
|
+ .le(bo.getCreateTimeLatest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeLatest())
|
|
|
+ );
|
|
|
+ List<ProductDispatchRecord> dispatchRecordList = productDispatchRecordMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProductDispatchRecord.class)
|
|
|
+ .ge(bo.getCreateTimeEarliest() != null, ProductDispatchRecord::getCreateTime, bo.getCreateTimeEarliest())
|
|
|
+ .le(bo.getCreateTimeLatest() != null, ProductDispatchRecord::getCreateTime, bo.getCreateTimeLatest())
|
|
|
+ );
|
|
|
+
|
|
|
+ Page<ProductStock> page = productStockMapper.selectPage(
|
|
|
+ pageQuery.build(),
|
|
|
+ Wrappers.lambdaQuery(ProductStock.class)
|
|
|
+ .eq(bo.getStockLocationId() != null, ProductStock::getLocationId, bo.getStockLocationId())
|
|
|
+ );
|
|
|
+
|
|
|
+ return TableDataInfo.build(page.convert(stock -> {
|
|
|
+ InventoryVo vo = new InventoryVo();
|
|
|
+ vo.setCreateTime(stock.getCreateTime());
|
|
|
+ vo.setProductType(productTypeMap.get(stock.getProductType()));
|
|
|
+
|
|
|
+ if (Objects.equals(stock.getProductType(), "1")) vo.setProductCategory(productCategoryMap.get(stock.getCategoryId()));
|
|
|
+ else vo.setProductCategory(consumableCategoryMap.get(stock.getCategoryId()));
|
|
|
+
|
|
|
+ vo.setProductCode(stock.getProductNo());
|
|
|
+ vo.setProductName(stock.getProductName());
|
|
|
+ vo.setProductSpecification(stock.getSpecsName());
|
|
|
+ vo.setStockUnit(stock.getStockUnitName());
|
|
|
+
|
|
|
+ BigDecimal manualInventory = new BigDecimal("0");
|
|
|
+ BigDecimal transferOutbound = new BigDecimal("0");
|
|
|
+ BigDecimal totalOutbound = new BigDecimal("0");
|
|
|
+ BigDecimal refundInventory = new BigDecimal("0");
|
|
|
+ BigDecimal outpatientNutritionConsume = new BigDecimal("0");
|
|
|
+ BigDecimal inHospitalNutritionConsume = new BigDecimal("0");
|
|
|
+ BigDecimal configureConsume = new BigDecimal("0");
|
|
|
+ BigDecimal refundConsume = new BigDecimal("0");
|
|
|
+
|
|
|
+ for (ProductInOutRecord record : inOutRecordList) {
|
|
|
+ if (Objects.equals(record.getLocationId(), stock.getLocationId())) {
|
|
|
+ switch (record.getType()) {
|
|
|
+ case "0" -> {
|
|
|
+ manualInventory = manualInventory.add(new BigDecimal(record.getNum()));
|
|
|
+ }
|
|
|
+ case "1", "2" -> {
|
|
|
+ totalOutbound = totalOutbound.add(new BigDecimal(record.getNum()));
|
|
|
+ }
|
|
|
+ case "3" -> {
|
|
|
+ totalOutbound = totalOutbound.add(new BigDecimal(record.getNum()));
|
|
|
+ refundConsume = refundConsume.add(new BigDecimal(record.getNum()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setManualInventory(manualInventory);
|
|
|
+ vo.setRefundInventory(refundInventory);
|
|
|
+ vo.setOutpatientNutritionConsume(outpatientNutritionConsume);
|
|
|
+ vo.setInHospitalNutritionConsume(inHospitalNutritionConsume);
|
|
|
+ vo.setTransferOutbound(transferOutbound);
|
|
|
+ vo.setTotalOutbound(totalOutbound);
|
|
|
+ vo.setConfigureConsume(configureConsume);
|
|
|
+ vo.setRefundConsume(refundConsume);
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ case 1 -> {
|
|
|
+
|
|
|
+ Page<ProductInOutRecord> page = productInOutRecordMapper.selectPage(
|
|
|
+ pageQuery.build(),
|
|
|
+ Wrappers.lambdaQuery(ProductInOutRecord.class)
|
|
|
+ .eq(ProductInOutRecord::getType, "0")
|
|
|
+ .ge(bo.getCreateTimeEarliest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeEarliest())
|
|
|
+ .le(bo.getCreateTimeLatest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeLatest())
|
|
|
+ );
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
+ page.getRecords().forEach(e -> list.add(e.getProductId()));
|
|
|
+ List<ProductNutrition> nutritionList = productNutritionMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProductNutrition.class).in(!list.isEmpty(), ProductNutrition::getId, list)
|
|
|
+ );
|
|
|
+ Map<Long, String> manufactureMap = new HashMap<>();
|
|
|
+ Map<Long, String> providerMap = new HashMap<>();
|
|
|
+ Map<Long, String> actionerMap = new HashMap<>();
|
|
|
+
|
|
|
+ productSupplierMapper.selectList().forEach(e -> providerMap.put(e.getId(), e.getName()));
|
|
|
+ productManufacturerMapper.selectList().forEach(e -> manufactureMap.put(e.getId(), e.getName()));
|
|
|
+ sysUserMapper.selectList().forEach(e -> actionerMap.put(e.getUserId(), e.getName()));
|
|
|
+
|
|
|
+ return TableDataInfo.build(page.convert(record -> {
|
|
|
+ InventoryActionVo vo = new InventoryActionVo();
|
|
|
+ vo.setActionInventoryDate(record.getCreateTime());
|
|
|
+ vo.setProductCode(record.getProductNo());
|
|
|
+ vo.setProductName(record.getProductName());
|
|
|
+
|
|
|
+ for (ProductNutrition productNutrition : nutritionList) {
|
|
|
+ if (Objects.equals(record.getProductId(), productNutrition.getId())) {
|
|
|
+ vo.setHospitalSystemCode(productNutrition.getHospitalSystemCode());
|
|
|
+ vo.setProvider(providerMap.get(Long.valueOf(productNutrition.getSupplier())));
|
|
|
+ vo.setManufacture(manufactureMap.get(Long.valueOf(productNutrition.getManufacturer())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setSpecification(unitMap.get(record.getUnit()));
|
|
|
+ vo.setProductType(productTypeMap.get(record.getProductType()));
|
|
|
+ vo.setProductBatchCode(record.getProductBatchNo());
|
|
|
+ vo.setInventoryBatch(record.getSerialNo());
|
|
|
+ vo.setActionType("手动入库");
|
|
|
+ vo.setCount(record.getNum());
|
|
|
+ vo.setUnit(unitMap.get(record.getUnit()));
|
|
|
+ vo.setActioner(actionerMap.get(record.getCreateBy()));
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ case 2 -> {
|
|
|
+
|
|
|
+ Page<ProductInOutRecord> page = productInOutRecordMapper.selectPage(
|
|
|
+ pageQuery.build(),
|
|
|
+ Wrappers.lambdaQuery(ProductInOutRecord.class)
|
|
|
+ .eq(ProductInOutRecord::getType, "1")
|
|
|
+ .ge(bo.getCreateTimeEarliest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeEarliest())
|
|
|
+ .le(bo.getCreateTimeLatest() != null, ProductInOutRecord::getCreateTime, bo.getCreateTimeLatest())
|
|
|
+ );
|
|
|
+
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
+ page.getRecords().forEach(e -> list.add(e.getProductId()));
|
|
|
+ List<ProductNutrition> nutritionList = productNutritionMapper.selectList(
|
|
|
+ Wrappers.lambdaQuery(ProductNutrition.class).in(!list.isEmpty(), ProductNutrition::getId, list)
|
|
|
+ );
|
|
|
+
|
|
|
+ Map<Long, String> manufactureMap = new HashMap<>();
|
|
|
+ Map<Long, String> providerMap = new HashMap<>();
|
|
|
+ Map<Long, String> actionerMap = new HashMap<>();
|
|
|
+
|
|
|
+ productSupplierMapper.selectList().forEach(e -> providerMap.put(e.getId(), e.getName()));
|
|
|
+ productManufacturerMapper.selectList().forEach(e -> manufactureMap.put(e.getId(), e.getName()));
|
|
|
+ sysUserMapper.selectList().forEach(e -> actionerMap.put(e.getUserId(), e.getName()));
|
|
|
+
|
|
|
+ return TableDataInfo.build(page.convert(record -> {
|
|
|
+ OutboundActionVo vo = new OutboundActionVo();
|
|
|
+ vo.setActionOutboundDate(record.getCreateTime());
|
|
|
+ vo.setProductCode(record.getProductNo());
|
|
|
+ vo.setProductName(record.getProductName());
|
|
|
+
|
|
|
+ for (ProductNutrition productNutrition : nutritionList) {
|
|
|
+ if (Objects.equals(record.getProductId(), productNutrition.getId())) {
|
|
|
+ vo.setHospitalSystemCode(productNutrition.getHospitalSystemCode());
|
|
|
+ vo.setProvider(providerMap.get(Long.valueOf(productNutrition.getSupplier())));
|
|
|
+ vo.setManufacture(manufactureMap.get(Long.valueOf(productNutrition.getManufacturer())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setSpecification(record.getSpecsName());
|
|
|
+ vo.setProductType(productTypeMap.get(record.getProductType()));
|
|
|
+ vo.setProductBatchCode(record.getProductBatchNo());
|
|
|
+ vo.setInventoryBatch(record.getSerialNo());
|
|
|
+ vo.setActionType("手动出库");
|
|
|
+ vo.setCount(record.getNum());
|
|
|
+ vo.setUnit(unitMap.get(record.getUnit()));
|
|
|
+ vo.setActioner(actionerMap.get(record.getCreateBy()));
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return TableDataInfo.build();
|
|
|
}
|
|
|
|
|
|
@Override
|