diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java index a12b964d3..324f39d7c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtReportMealsDaoController.java @@ -10,8 +10,10 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.fantang.domain.FtPrepaymentDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.entity.ReportMealsDayEntity; +import com.ruoyi.system.fantang.service.IFtPrepaymentDaoService; import com.ruoyi.system.fantang.service.IFtReportMealsDaoService; import com.ruoyi.system.fantang.vo.FtReportMealVo; import lombok.RequiredArgsConstructor; @@ -23,6 +25,8 @@ import java.util.Arrays; import java.util.Date; import java.util.List; +import static com.ruoyi.common.core.domain.AjaxResult.success; + /** * 报餐管理Controller * @@ -36,31 +40,49 @@ public class FtReportMealsDaoController extends BaseController { private final IFtReportMealsDaoService iFtReportMealsDaoService; + @Autowired + private IFtPrepaymentDaoService prepaymentDaoService; + /** * 查询指定用户上一次结算的日期,并通过这个日期计算未结算的天数 */ @GetMapping("/getLastSettlementDate/{patientId}") public AjaxResult getLastSettlementDate(@PathVariable("patientId") Long patientId) { + // 初始化一个返回对象 + AjaxResult result = AjaxResult.success(); - // 获取最近一次已结算的报餐记录,如果首次结算则返回 + // 获取该病患的预付费数据 + FtPrepaymentDao prepaymentDao = prepaymentDaoService.getByPatientId(patientId); + result.put("prepayment", prepaymentDao); + + // 获取最近一次已结算的报餐记录,如果首次结算则返回第一条已用餐的记录 FtReportMealsDao reportMealsDao = iFtReportMealsDaoService.getLastReportMeals(patientId); - Date createAt = reportMealsDao.getCreateAt(); + // 获取用餐日期 + Date diningAt = reportMealsDao.getDiningAt(); + // 获取结算日期 Date settlementAt = reportMealsDao.getSettlementAt(); ReportMealsDayEntity reportMealsDayEntity = new ReportMealsDayEntity(); - if (settlementAt == null) { - long betweenDays = DateUtil.between(createAt, new Date(), DateUnit.DAY); - reportMealsDayEntity.setDays(betweenDays); - reportMealsDayEntity.setLastCreateDate(createAt); - return AjaxResult.success(reportMealsDayEntity); - } - long days = DateUtil.between(settlementAt, new Date(), DateUnit.DAY); + // 如果首次结算 + if (settlementAt == null) { + // 计算第一条已用餐的用餐时间与现在相差多少天 + long betweenDays = DateUtil.between(diningAt, new Date(), DateUnit.DAY); + reportMealsDayEntity.setDays(betweenDays); + reportMealsDayEntity.setLastCreateDate(diningAt); + result.put("reportMeals", reportMealsDayEntity); + + return result; + } + + //计算上次结算日期与现在相差多少天 + long days = DateUtil.between(settlementAt, new Date(), DateUnit.DAY); reportMealsDayEntity.setSettlementAt(settlementAt); reportMealsDayEntity.setDays(days); + result.put("reportMeals", reportMealsDayEntity); - return AjaxResult.success(reportMealsDayEntity); + return result; } @@ -161,7 +183,7 @@ public class FtReportMealsDaoController extends BaseController { */ @GetMapping("/countBillingBetween") public AjaxResult countBillingBetween(ReportMealsDayEntity dao) { - return AjaxResult.success(iFtReportMealsDaoService.countBillingBetween(dao)); + return success(iFtReportMealsDaoService.countBillingBetween(dao)); } /** @@ -170,7 +192,7 @@ public class FtReportMealsDaoController extends BaseController { @PreAuthorize("@ss.hasPermi('fantang:meals:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return AjaxResult.success(iFtReportMealsDaoService.getById(id)); + return success(iFtReportMealsDaoService.getById(id)); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java index 09da62d79..8e4c05057 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java @@ -69,8 +69,8 @@ public class FtSettleDaoController extends BaseController { // 根据病人 id ,上次结算日期,选择日期查询病人非营养餐记录 QueryWrapper reportMealsWrapper = new QueryWrapper<>(); reportMealsWrapper.eq("patient_id", patientId); -// reportMealsWrapper.eq("nutrition_food_flag", 0); - reportMealsWrapper.between("create_at", sdf.format(lastBillingDate), sdf.format(selectBillingDate)); + reportMealsWrapper.eq("dining_flag",1); + reportMealsWrapper.between("dining_at", sdf.format(lastBillingDate), sdf.format(selectBillingDate)); List reportMealsList = iFtReportMealsDaoService.list(reportMealsWrapper); ReportMealsPriceEntity reportMealsPrice = iFtReportMealsDaoService.sumTotalPrice(patientId, lastBillingDate, selectBillingDate); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java index f7a960e46..b7d6eadd2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java @@ -180,4 +180,9 @@ public class FtReportMealsDao implements Serializable { */ @TableField(exist = false) private Date endOfDay; + + /** + * 用餐标志 + */ + private Integer diningFlag; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtReportMealsDaoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtReportMealsDaoMapper.java index ec9f2882b..cc499cc6f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtReportMealsDaoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtReportMealsDaoMapper.java @@ -36,7 +36,7 @@ public interface FtReportMealsDaoMapper extends BaseMapper { * @param selectBillingDate * @return */ - @Select("SELECT a.patient_id,sum(a.price) as dinner_total_price , sum(a.nutrition_food_price ) as nutrition_total_price , sum(a.total_price) as sum_total_price FROM ft_report_meals a where a.patient_id = #{patientId} and a.create_at BETWEEN #{lastBillingDate} AND #{selectBillingDate}") + @Select("SELECT a.patient_id,sum(a.price) as dinner_total_price , sum(a.nutrition_food_price ) as nutrition_total_price , sum(a.total_price) as sum_total_price FROM ft_report_meals a where a.patient_id = #{patientId} and a.dining_at BETWEEN #{lastBillingDate} AND #{selectBillingDate}") ReportMealsPriceEntity sumTotalPrice(@Param("patientId") Long patientId, @Param("lastBillingDate") Date lastBillingDate, @Param("selectBillingDate") Date selectBillingDate); List listNutrition(@Param("beginOfDay") DateTime beginOfDay, @Param("endOfDay") DateTime endOfDay, FtReportMealsDao ftReportMealsDao); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java index a90e2c9f2..f562c49d5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtReportMealsDaoServiceImpl.java @@ -76,10 +76,11 @@ public class FtReportMealsDaoServiceImpl extends ServiceImpl flag1Wrapper = new QueryWrapper<>(); flag1Wrapper.eq("patient_id", patientId); flag1Wrapper.eq("settlement_flag", 1); + flag1Wrapper.eq("dining_flag", 1); flag1Wrapper.orderByDesc("settlement_at"); flag1Wrapper.last("limit 1"); FtReportMealsDao flag1ReportMealsDao = this.baseMapper.selectOne(flag1Wrapper); @@ -87,9 +88,10 @@ public class FtReportMealsDaoServiceImpl extends ServiceImpl flag0Wrapper = new QueryWrapper<>(); flag0Wrapper.eq("patient_id", patientId); + flag0Wrapper.eq("dining_flag", 1); flag0Wrapper.orderByAsc("dining_at"); flag0Wrapper.last("limit 1"); diff --git a/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml b/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml index ce498fb2b..10d14151c 100644 --- a/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml @@ -27,14 +27,17 @@ +