|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.system.domain.SysDept;
|
|
import org.dromara.system.domain.SysDept;
|
|
@@ -64,6 +65,8 @@ public class ReportServiceImpl implements ReportService {
|
|
private final NutritionEducationMapper nutritionEducationMapper;
|
|
private final NutritionEducationMapper nutritionEducationMapper;
|
|
private final SysScreeningAssessmentConfigMapper sysScreeningAssessmentConfigMapper;
|
|
private final SysScreeningAssessmentConfigMapper sysScreeningAssessmentConfigMapper;
|
|
private final SysDiseaseLabelMapper sysDiseaseLabelMapper;
|
|
private final SysDiseaseLabelMapper sysDiseaseLabelMapper;
|
|
|
|
+ private final FoodIngredientStockMapper foodIngredientStockMapper;
|
|
|
|
+ private final SysFoodCategoryMapper sysFoodCategoryMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public R getNutritionalQualityControl(Timestamp start, Timestamp end) {
|
|
public R getNutritionalQualityControl(Timestamp start, Timestamp end) {
|
|
@@ -304,7 +307,82 @@ public class ReportServiceImpl implements ReportService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public TableDataInfo listPageDietaryInventory(DietaryInventoryBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo listPageDietaryInventory(DietaryInventoryBo bo, PageQuery pageQuery) {
|
|
- return null;
|
|
|
|
|
|
+
|
|
|
|
+ Map<String, String> unitMap = new HashMap<>();
|
|
|
|
+ Map<Long, String> categoryMap = new HashMap<>();
|
|
|
|
+ sysDictDataMapper.selectDictDataByType("product_package_unit").forEach(e -> unitMap.put(e.getDictValue(), e.getDictLabel()));
|
|
|
|
+ sysFoodCategoryMapper.selectList().forEach(e -> categoryMap.put(e.getFoodCategoryId(), e.getName()));
|
|
|
|
+
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ Page<SysFoodIngredient> page = sysFoodIngredientMapper.selectPage(
|
|
|
|
+ pageQuery.build(),
|
|
|
|
+ Wrappers.lambdaQuery(SysFoodIngredient.class)
|
|
|
|
+ .like(StringUtils.isNotEmpty(bo.getFoodName()), SysFoodIngredient::getName, bo.getFoodName())
|
|
|
|
+ );
|
|
|
|
+ page.getRecords().forEach(e -> ids.add(e.getFoodIngredientId()));
|
|
|
|
+
|
|
|
|
+ List<FoodIngredientStock> stocks = foodIngredientStockMapper.selectList(
|
|
|
|
+ Wrappers.lambdaQuery(FoodIngredientStock.class)
|
|
|
|
+ .in(!ids.isEmpty(), FoodIngredientStock::getFoodId, ids)
|
|
|
|
+ .ge(bo.getStatisticalDateEarliest() != null, FoodIngredientStock::getCreateTime, bo.getStatisticalDateEarliest())
|
|
|
|
+ .le(bo.getStatisticalDateLatest() != null, FoodIngredientStock::getCreateTime, bo.getStatisticalDateEarliest())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ return TableDataInfo.build(page.convert(ingredient -> {
|
|
|
|
+ DietaryInventoryVo vo = new DietaryInventoryVo();
|
|
|
|
+ vo.setStatisticalDate(new Date());
|
|
|
|
+ vo.setFoodName(ingredient.getName());
|
|
|
|
+
|
|
|
|
+ BigDecimal manualInventoryQuantity = new BigDecimal("0");
|
|
|
|
+ BigDecimal inventoryTotal = new BigDecimal("0");
|
|
|
|
+ BigDecimal outboundTotal = new BigDecimal("0");
|
|
|
|
+ BigDecimal manualOutboundQuantity = new BigDecimal("0");
|
|
|
|
+ BigDecimal nutritionOutboundQuantity = new BigDecimal("0");
|
|
|
|
+ BigDecimal refundLoss = new BigDecimal("0");
|
|
|
|
+ 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());
|
|
|
|
+ inventoryTotal = inventoryTotal.add(stock.getNum());
|
|
|
|
+ }
|
|
|
|
+ case "1" -> {
|
|
|
|
+ outboundTotal = outboundTotal.add(stock.getNum());
|
|
|
|
+ manualOutboundQuantity = manualInventoryQuantity.add(stock.getNum());
|
|
|
|
+ }
|
|
|
|
+ case "2" -> {
|
|
|
|
+ outboundTotal = outboundTotal.add(stock.getNum());
|
|
|
|
+ nutritionOutboundQuantity = nutritionOutboundQuantity.add(stock.getNum());
|
|
|
|
+ mealPreparationLoss = mealPreparationLoss.add(stock.getNum());
|
|
|
|
+ }
|
|
|
|
+ case "3" -> {
|
|
|
|
+ refundLoss = refundLoss.add(stock.getNum());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String[] categoryIds = ingredient.getFoodCategoryId().split(",");
|
|
|
|
+ vo.setFoodFirstCategory(categoryMap.get(Long.valueOf(categoryIds[0])));
|
|
|
|
+ vo.setFoodSecondCategory(categoryMap.get(Long.valueOf(categoryIds[1])));
|
|
|
|
+ vo.setInventoryUnit(unitMap.get(ingredient.getUnit()));
|
|
|
|
+ vo.setManualInventoryQuantity(manualInventoryQuantity);
|
|
|
|
+ vo.setInventoryTotal(inventoryTotal);
|
|
|
|
+ vo.setManualOutboundQuantity(manualOutboundQuantity);
|
|
|
|
+ vo.setNutritionOutboundQuantity(nutritionOutboundQuantity);
|
|
|
|
+ vo.setOutboundTotal(outboundTotal);
|
|
|
|
+ vo.setMealPreparationLoss(new BigDecimal("5").multiply(mealPreparationLoss));
|
|
|
|
+ vo.setRefundLoss(refundLoss);
|
|
|
|
+ return vo;
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|