营养餐统计

This commit is contained in:
ryoeiken 2021-01-21 09:54:33 +08:00
parent dff06a9106
commit aa57a01ffa
10 changed files with 605 additions and 69 deletions

View File

@ -3,7 +3,6 @@ package com.ruoyi.system.fantang.controller;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -124,6 +123,14 @@ public class FtReportMealsDaoController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
@GetMapping("/listStatistics")
public TableDataInfo listStatistics(FtReportMealsDao ftReportMealsDao) {
startPage();
return getDataTable(iFtReportMealsDaoService.listNutrition(ftReportMealsDao));
}
@PreAuthorize("@ss.hasPermi('fantang:meals:list')") @PreAuthorize("@ss.hasPermi('fantang:meals:list')")
@GetMapping("/listMealsWithInSettle") @GetMapping("/listMealsWithInSettle")
public TableDataInfo listMealsWithInSettle(FtReportMealsDao ftReportMealsDao) { public TableDataInfo listMealsWithInSettle(FtReportMealsDao ftReportMealsDao) {

View File

@ -33,7 +33,7 @@ public class FtReportMealsDao implements Serializable {
/** /**
* $column.columnComment * id
*/ */
@TableId(value = "id") @TableId(value = "id")
private Long id; private Long id;
@ -86,18 +86,33 @@ public class FtReportMealsDao implements Serializable {
private String settlementBy; private String settlementBy;
/**
* 住院号
*/
@TableField(exist = false) @TableField(exist = false)
private String hospitalId; private String hospitalId;
/**
* 科室 id
*/
@TableField(exist = false) @TableField(exist = false)
private String departId; private String departId;
/**
* 科室名
*/
@TableField(exist = false) @TableField(exist = false)
private String departName; private String departName;
/**
* 床号
*/
@TableField(exist = false) @TableField(exist = false)
private String bedId; private String bedId;
/**
* 病人姓名
*/
@TableField(exist = false) @TableField(exist = false)
private String name; private String name;
@ -138,4 +153,31 @@ public class FtReportMealsDao implements Serializable {
private Integer total; private Integer total;
private Boolean openFlag; private Boolean openFlag;
@TableField(exist = false)
private Integer statisticsType;
/**
* 营养餐名称
*/
@TableField(exist = false)
private String nutritionName;
@TableField(exist = false)
private Integer cateringUsage;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date diningAt;
/**
* 用餐开始时间
*/
@TableField(exist = false)
private Date beginOfDay;
/**
* 用餐结束时间
*/
@TableField(exist = false)
private Date endOfDay;
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.fantang.mapper; package com.ruoyi.system.fantang.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao;
import com.ruoyi.system.fantang.entity.ReportMealsPriceEntity; import com.ruoyi.system.fantang.entity.ReportMealsPriceEntity;
@ -37,4 +38,8 @@ public interface FtReportMealsDaoMapper extends BaseMapper<FtReportMealsDao> {
*/ */
@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.create_at BETWEEN #{lastBillingDate} AND #{selectBillingDate}")
ReportMealsPriceEntity sumTotalPrice(@Param("patientId") Long patientId, @Param("lastBillingDate") Date lastBillingDate, @Param("selectBillingDate") Date selectBillingDate); ReportMealsPriceEntity sumTotalPrice(@Param("patientId") Long patientId, @Param("lastBillingDate") Date lastBillingDate, @Param("selectBillingDate") Date selectBillingDate);
List<FtReportMealsDao> listNutrition(@Param("beginOfDay") DateTime beginOfDay, @Param("endOfDay") DateTime endOfDay, FtReportMealsDao ftReportMealsDao);
List<FtReportMealsDao> listAllNutrition(FtReportMealsDao ftReportMealsDao);
} }

View File

@ -33,5 +33,9 @@ public interface IFtReportMealsDaoService extends IService<FtReportMealsDao> {
ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate); ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate);
FtReportMealsDao getLastReportMeals(Long patientId); FtReportMealsDao getLastReportMeals(Long patientId);
List<FtReportMealsDao> listNutrition(FtReportMealsDao ftReportMealsDao);
List<FtReportMealsDao> listAllNutrition(FtReportMealsDao ftReportMealsDao);
} }

View File

@ -1,5 +1,7 @@
package com.ruoyi.system.fantang.service.impl; package com.ruoyi.system.fantang.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao;
@ -85,16 +87,44 @@ public class FtReportMealsDaoServiceImpl extends ServiceImpl<FtReportMealsDaoMap
// 如果是首次结算 // 如果是首次结算
if (flag1ReportMealsDao == null) { if (flag1ReportMealsDao == null) {
// 获取最近一条报餐 // 获取第一条报餐数据
QueryWrapper<FtReportMealsDao> flag0Wrapper = new QueryWrapper<>(); QueryWrapper<FtReportMealsDao> flag0Wrapper = new QueryWrapper<>();
flag0Wrapper.eq("patient_id", patientId); flag0Wrapper.eq("patient_id", patientId);
flag0Wrapper.eq("settlement_flag", 1); flag0Wrapper.orderByAsc("dining_at");
flag0Wrapper.orderByDesc("settlement_at"); flag0Wrapper.last("limit 1");
flag0Wrapper.last("limit 0");
return this.baseMapper.selectOne(flag0Wrapper); return this.baseMapper.selectOne(flag0Wrapper);
} }
return flag1ReportMealsDao; return flag1ReportMealsDao;
} }
@Override
public List<FtReportMealsDao> listNutrition(FtReportMealsDao ftReportMealsDao) {
List<FtReportMealsDao> list;
Date today = new Date();
if (ftReportMealsDao.getStatisticsType() == null) {
list = this.baseMapper.listAllNutrition(ftReportMealsDao);
} else {
if (ftReportMealsDao.getStatisticsType() == 1) {
ftReportMealsDao.setBeginOfDay(DateUtil.beginOfDay(today));
ftReportMealsDao.setEndOfDay(DateUtil.endOfDay(today));
} else {
DateTime tomorrow = DateUtil.offsetDay(today, 1);
ftReportMealsDao.setBeginOfDay(DateUtil.beginOfDay(tomorrow));
ftReportMealsDao.setEndOfDay(DateUtil.endOfDay(tomorrow));
}
list = this.baseMapper.listAllNutrition(ftReportMealsDao);
}
return list;
}
@Override
public List<FtReportMealsDao> listAllNutrition(FtReportMealsDao ftReportMealsDao) {
return this.baseMapper.listAllNutrition(ftReportMealsDao);
}
} }

View File

@ -26,6 +26,7 @@
<result property="rice" column="rice"/> <result property="rice" column="rice"/>
<result property="egg" column="egg"/> <result property="egg" column="egg"/>
<result property="openFlag" column="open_flag"/> <result property="openFlag" column="open_flag"/>
<result property="diningAt" column="dining_at"/>
</resultMap> </resultMap>
<select id="listMealsWithInSettle" resultType="com.ruoyi.system.fantang.domain.FtReportMealsDao"> <select id="listMealsWithInSettle" resultType="com.ruoyi.system.fantang.domain.FtReportMealsDao">
@ -42,4 +43,76 @@
GROUP BY a.patient_id GROUP BY a.patient_id
</select> </select>
<select id="listNutrition" resultType="com.ruoyi.system.fantang.domain.FtReportMealsDao">
SELECT
a.patient_id,
a.type,
a.foods,
a.nutrition_food_price,
a.nutrition_food_id,
d.`name` AS nutrition_name,
a.nutrition_food_flag,
a.is_replace_food,
b.`name`,
b.depart_id,
b.hospital_id,
b.bed_id,
c.depart_name,
f.catering_usage
FROM
ft_report_meals a
LEFT JOIN ft_patient b ON a.patient_id = b.patient_id
LEFT JOIN ft_depart c ON b.depart_id = c.depart_id
LEFT JOIN ft_nutrition_food d ON a.nutrition_food_id = d.id
LEFT JOIN ft_catering f ON a.patient_id = f.patient_id
AND a.type = f.type
<where>
a.open_flag = 1
AND a.dining_at BETWEEN #{beginOfDay}
AND #{endOfDay}
<if test="cateringUsage != null">and f.catering_usage = #{cateringUsage}</if>
<if test="departId != null">and b.depart_id = #{departId}</if>
<if test="name != null">and b.`name` = #{name}</if>
<if test="nutritionFoodId != null">and a.nutrition_food_id = #{nutritionFoodId}</if>
<if test="type != null">and a.type = #{type}</if>
</where>
</select>
<select id="listAllNutrition" resultType="com.ruoyi.system.fantang.domain.FtReportMealsDao">
SELECT
a.patient_id,
a.type,
a.foods,
a.dining_at,
a.nutrition_food_price,
a.nutrition_food_id,
d.`name` AS nutrition_name,
a.nutrition_food_flag,
a.is_replace_food,
b.`name`,
b.depart_id,
b.hospital_id,
b.bed_id,
c.depart_name,
f.catering_usage
FROM
ft_report_meals a
LEFT JOIN ft_patient b ON a.patient_id = b.patient_id
LEFT JOIN ft_depart c ON b.depart_id = c.depart_id
LEFT JOIN ft_nutrition_food d ON a.nutrition_food_id = d.id
LEFT JOIN ft_catering f ON a.patient_id = f.patient_id
AND a.type = f.type
<where>
a.open_flag = 1
<if test="beginOfDay != null">AND a.dining_at BETWEEN #{beginOfDay}</if>
<if test="endOfDay != null">AND #{endOfDay}</if>
<if test="cateringUsage != null">and f.catering_usage = #{cateringUsage}</if>
<if test="cateringUsage != null">and f.catering_usage = #{cateringUsage}</if>
<if test="departId != null">and b.depart_id = #{departId}</if>
<if test="name != null">and b.`name` = #{name}</if>
<if test="nutritionFoodId != null">and a.nutrition_food_id = #{nutritionFoodId}</if>
<if test="type != null">and a.type = #{type}</if>
</where>
</select>
</mapper> </mapper>

View File

@ -9,6 +9,15 @@ export function listAll(query) {
}) })
} }
// 查询所有统计报餐
export function listStatistics(query) {
return request({
url: '/fantang/meals/listStatistics',
method: 'get',
params: query
})
}
// 查询未结算报餐记录 // 查询未结算报餐记录
export function listNoPay(query) { export function listNoPay(query) {
return request({ return request({

View File

@ -0,0 +1,360 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="统计日期" prop="statisticsType">
<el-select v-model="queryParams.statisticsType" placeholder="请选择统计日期" clearable size="small">
<el-option
v-for="item in statisticsTypeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="病人姓名" prop="name">
<el-input v-model="queryParams.name" size="small"></el-input>
</el-form-item>
<el-form-item label="营养餐" prop="nutritionFoodId">
<el-select v-model="queryParams.nutritionFoodId" placeholder="请选择营养餐" clearable size="small">
<el-option
v-for="item in nutritionFoodOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="科室" prop="departId">
<el-select v-model="queryParams.departId" placeholder="请选择科室" clearable size="small">
<el-option
v-for="item in departOptions"
:key="item.departId"
:label="item.departName"
:value="item.departId">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="用法" prop="cateringUsage">
<el-select v-model="queryParams.cateringUsage" placeholder="请选择用法" clearable size="small">
<el-option
v-for="item in cateringUsageOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="正餐类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择用法" clearable size="small">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['fantang:meals:export']"
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="mealsList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="科室" align="center" prop="departName"/>
<el-table-column label="姓名" align="center" prop="name"/>
<el-table-column label="床号" align="center" prop="bedId"/>
<el-table-column label="正餐类型" align="center" prop="type"/>
<el-table-column label="营养餐" align="center" prop="nutritionName"/>
<el-table-column label="用法" align="center" prop="cateringUsage"/>
<el-table-column label="用餐日期" align="center" prop="diningAt">
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['fantang:meals:edit']"-->
<!-- >修改-->
<!-- </el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['fantang:meals:remove']"-->
<!-- >删除-->
<!-- </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改报餐管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="报餐日期" prop="createAt">
<el-date-picker clearable size="small" style="width: 200px"
v-model="form.createAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择报餐日期">
</el-date-picker>
</el-form-item>
<el-form-item label="报餐类型" prop="type">
<el-select v-model="form.type" placeholder="请选择报餐类型">
<el-option label="请选择字典生成" value=""/>
</el-select>
</el-form-item>
<el-form-item label="订单列表" prop="foods">
<el-input v-model="form.foods" placeholder="请输入订单列表"/>
</el-form-item>
<el-form-item label="正餐总价" prop="price">
<el-input v-model="form.price" placeholder="请输入总价"/>
</el-form-item>
</el-form>
<el-form-item>
</el-form-item>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {addMeals, delMeals, exportMeals, getMeals, updateMeals} from "@/api/fantang/meals";
import {listStatistics} from "../../../api/fantang/meals";
import {listNutritionFood} from "../../../api/fantang/nutritionFood";
import {listDepart} from "../../../api/fantang/depart";
export default {
name: "Meals",
components: {},
data() {
return {
typeOptions: [{
value: 1,
label: '早餐'
}, {
value: 2,
label: '午餐'
}, {
value: 3,
label: '晚餐'
}, {
value: 4,
label: '加餐'
}],
cateringUsageOptions: [{
value: 1,
label: '鼻饲'
}, {
value: 2,
label: '口服'
}],
departOptions: [],
nutritionFoodOptions: [],
statisticsTypeOptions: [{
value: 1,
label: '今日'
}, {
value: 2,
label: '明日'
}],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
mealsList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
statisticsType: null,
name: null,
nutritionFoodId: null,
departId: null,
},
//
form: {},
//
rules: {
createAt: [
{required: true, message: "报餐日期不能为空", trigger: "blur"}
],
type: [
{required: true, message: "报餐类型不能为空", trigger: "change"}
],
createBy: [
{required: true, message: "报餐人不能为空", trigger: "blur"}
],
foods: [
{required: true, message: "订单列表不能为空", trigger: "blur"}
],
price: [
{required: true, message: "总价不能为空", trigger: "blur"}
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询报餐管理列表 */
getList() {
this.loading = true;
listStatistics(this.queryParams).then(response => {
this.mealsList = response.rows;
this.total = response.total;
this.loading = false;
});
listNutritionFood().then(response => {
this.nutritionFoodOptions = response.rows;
})
listDepart().then(response => {
this.departOptions = response.rows;
})
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
createAt: null,
type: null,
patientId: null,
createBy: null,
foods: null,
price: null,
settlementFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加报餐管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getMeals(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改报餐管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateMeals(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addMeals(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除报餐管理编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return delMeals(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有报餐管理数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return exportMeals(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};
</script>

View File

@ -159,7 +159,9 @@ export default {
}; };
}, },
created() { created() {
this.getList(); // this.getList();
this.total = 0;
this.loading = false;
this.getDicts("ft_book_type").then(response => { this.getDicts("ft_book_type").then(response => {
this.typeOptions = response.data; this.typeOptions = response.data;
}); });

View File

@ -495,6 +495,10 @@ export default {
// console.log("selectBillingDate", this.formAddNewSettlement.selectBillingDate) // console.log("selectBillingDate", this.formAddNewSettlement.selectBillingDate)
dateSpan = sDate2 - sDate1; dateSpan = sDate2 - sDate1;
console.log("sdate2-------", sDate2);
console.log("sdate1-------", sDate1);
if (dateSpan < 0) { if (dateSpan < 0) {
this.msgError("你现在的结算日期小于上一次上次结算 / 用餐日期"); this.msgError("你现在的结算日期小于上一次上次结算 / 用餐日期");
} else { } else {