添加病人报餐

This commit is contained in:
ryoeiken 2020-11-26 16:32:01 +08:00
parent 000f94049b
commit 7ab0d24e50
9 changed files with 660 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.ruoyi.quartz.task;
import com.ruoyi.system.fantang.service.impl.FtFoodDemandDaoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 定时任务调度测试
*
* @author ruoyi
*/
@Component("OrderingTask")
public class FtGenerateOrderTask {
@Autowired
private FtFoodDemandDaoServiceImpl foodDemandDaoService;
public void GenerateOrderTask() {
System.out.println("执行生成一条病患默认订餐配置记录");
foodDemandDaoService.GenerateOrderByPatientId(4L);
}
}

View File

@ -0,0 +1,116 @@
package com.ruoyi.system.fantang.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.List;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 病人报餐Controller
*
* @author ft
* @date 2020-11-26
*/
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/fantang/foodDemand" )
public class FtFoodDemandDaoController extends BaseController {
private final IFtFoodDemandDaoService iFtFoodDemandDaoService;
/**
* 查询病人报餐列表
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:list')")
@GetMapping("/list")
public TableDataInfo list(FtFoodDemandDao ftFoodDemandDao)
{
startPage();
LambdaQueryWrapper<FtFoodDemandDao> lqw = Wrappers.lambdaQuery(ftFoodDemandDao);
if (ftFoodDemandDao.getType() != null){
lqw.eq(FtFoodDemandDao::getType ,ftFoodDemandDao.getType());
}
if (ftFoodDemandDao.getUpdateAt() != null){
lqw.eq(FtFoodDemandDao::getUpdateAt ,ftFoodDemandDao.getUpdateAt());
}
if (ftFoodDemandDao.getUpdateFrom() != null){
lqw.eq(FtFoodDemandDao::getUpdateFrom ,ftFoodDemandDao.getUpdateFrom());
}
List<FtFoodDemandDao> list = iFtFoodDemandDaoService.list(lqw);
return getDataTable(list);
}
/**
* 导出病人报餐列表
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:export')" )
@Log(title = "病人报餐" , businessType = BusinessType.EXPORT)
@GetMapping("/export" )
public AjaxResult export(FtFoodDemandDao ftFoodDemandDao) {
LambdaQueryWrapper<FtFoodDemandDao> lqw = new LambdaQueryWrapper<FtFoodDemandDao>(ftFoodDemandDao);
List<FtFoodDemandDao> list = iFtFoodDemandDaoService.list(lqw);
ExcelUtil<FtFoodDemandDao> util = new ExcelUtil<FtFoodDemandDao>(FtFoodDemandDao. class);
return util.exportExcel(list, "foodDemand" );
}
/**
* 获取病人报餐详细信息
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:query')" )
@GetMapping(value = "/{id}" )
public AjaxResult getInfo(@PathVariable("id" ) Long id) {
return AjaxResult.success(iFtFoodDemandDaoService.getById(id));
}
/**
* 新增病人报餐
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:add')" )
@Log(title = "病人报餐" , businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody FtFoodDemandDao ftFoodDemandDao) {
return toAjax(iFtFoodDemandDaoService.save(ftFoodDemandDao) ? 1 : 0);
}
/**
* 修改病人报餐
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:edit')" )
@Log(title = "病人报餐" , businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody FtFoodDemandDao ftFoodDemandDao) {
return toAjax(iFtFoodDemandDaoService.updateById(ftFoodDemandDao) ? 1 : 0);
}
/**
* 删除病人报餐
*/
@PreAuthorize("@ss.hasPermi('fantang:foodDemand:remove')" )
@Log(title = "病人报餐" , businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}" )
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(iFtFoodDemandDaoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
}
}

View File

@ -0,0 +1,73 @@
package com.ruoyi.system.fantang.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.ruoyi.common.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 病人报餐对象 ft_food_demand
*
* @author ft
* @date 2020-11-26
*/
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
@TableName("ft_food_demand")
public class FtFoodDemandDao implements Serializable {
private static final long serialVersionUID=1L;
/** id */
@TableId(value = "id")
private Long id;
/** 病人id */
private Long patientId;
/** 订单详情 */
private String foods;
/** 用餐类型 */
@Excel(name = "用餐类型")
private Long type;
/** 创建时间 */
private Date createAt;
/** 创建人 */
private Long createBy;
/** 总价 */
@Excel(name = "总价")
private BigDecimal price;
/** 有效期 */
private Long term;
/** 更新日期 */
@Excel(name = "更新日期" , width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateAt;
/** 更新操作人 id */
private Long updateBy;
/** 更新来源 */
@Excel(name = "更新来源")
private Integer updateFrom;
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.system.fantang.mapper;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
/**
* 病人报餐Mapper接口
*
* @author ft
* @date 2020-11-26
*/
public interface FtFoodDemandDaoMapper extends BaseMapper<FtFoodDemandDao> {
@Insert("insert into ft_food_demand (patient_id, foods, type) select #{patient_id}, food_list, type FROM ft_food_default")
public Integer GenerateOrderByPatientId(@Param("patient_id") Long patientId) ;
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.system.fantang.service;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 病人报餐Service接口
*
* @author ft
* @date 2020-11-26
*/
public interface IFtFoodDemandDaoService extends IService<FtFoodDemandDao> {
public Integer GenerateOrderByPatientId(Long patientId);
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.system.fantang.service.impl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.fantang.mapper.FtFoodDemandDaoMapper;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService;
/**
* 病人报餐Service业务层处理
*
* @author ft
* @date 2020-11-26
*/
@Service
public class FtFoodDemandDaoServiceImpl extends ServiceImpl<FtFoodDemandDaoMapper, FtFoodDemandDao> implements IFtFoodDemandDaoService {
@Override
public Integer GenerateOrderByPatientId(Long patientId) {
return this.baseMapper.GenerateOrderByPatientId(patientId);
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.fantang.mapper.FtFoodDemandDaoMapper">
<resultMap type="FtFoodDemandDao" id="FtFoodDemandDaoResult">
<result property="id" column="id" />
<result property="patientId" column="patient_id" />
<result property="foods" column="foods" />
<result property="type" column="type" />
<result property="createAt" column="create_at" />
<result property="createBy" column="create_by" />
<result property="price" column="price" />
<result property="term" column="term" />
<result property="updateAt" column="update_at" />
<result property="updateBy" column="update_by" />
<result property="updateFrom" column="update_from" />
</resultMap>
</mapper>

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询病人报餐列表
export function listFoodDemand(query) {
return request({
url: '/fantang/foodDemand/list',
method: 'get',
params: query
})
}
// 查询病人报餐详细
export function getFoodDemand(id) {
return request({
url: '/fantang/foodDemand/' + id,
method: 'get'
})
}
// 新增病人报餐
export function addFoodDemand(data) {
return request({
url: '/fantang/foodDemand',
method: 'post',
data: data
})
}
// 修改病人报餐
export function updateFoodDemand(data) {
return request({
url: '/fantang/foodDemand',
method: 'put',
data: data
})
}
// 删除病人报餐
export function delFoodDemand(id) {
return request({
url: '/fantang/foodDemand/' + id,
method: 'delete'
})
}
// 导出病人报餐
export function exportFoodDemand(query) {
return request({
url: '/fantang/foodDemand/export',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,320 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="用餐类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择用餐类型" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item label="更新日期" prop="updateAt">
<el-date-picker clearable size="small" style="width: 200px"
v-model="queryParams.updateAt"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择更新日期">
</el-date-picker>
</el-form-item>
<el-form-item label="更新来源" prop="updateFrom">
<el-select v-model="queryParams.updateFrom" placeholder="请选择更新来源" clearable size="small">
<el-option
v-for="dict in updateFromOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</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="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['fantang:foodDemand:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['fantang:foodDemand:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['fantang:foodDemand:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['fantang:foodDemand:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="foodDemandList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" v-if="false"/>
<el-table-column label="用餐类型" align="center" prop="type" :formatter="typeFormat" />
<el-table-column label="总价" align="center" prop="price" />
<el-table-column label="更新日期" align="center" prop="updateAt" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="更新来源" align="center" prop="updateFrom" :formatter="updateFromFormat" />
<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:foodDemand:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['fantang:foodDemand: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="type">
<el-select v-model="form.type" placeholder="请选择用餐类型">
<el-option
v-for="dict in typeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
></el-option>
</el-select>
</el-form-item>
</el-form>
<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 { listFoodDemand, getFoodDemand, delFoodDemand, addFoodDemand, updateFoodDemand, exportFoodDemand } from "@/api/fantang/foodDemand";
export default {
name: "FoodDemand",
components: {
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
foodDemandList: [],
//
title: "",
//
open: false,
//
typeOptions: [],
//
updateFromOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
type: null,
updateAt: null,
updateFrom: null
},
//
form: {},
//
rules: {
type: [
{ required: true, message: "用餐类型不能为空", trigger: "change" }
],
}
};
},
created() {
this.getList();
this.getDicts("ft_book_type").then(response => {
this.typeOptions = response.data;
});
this.getDicts("ft_update_from").then(response => {
this.updateFromOptions = response.data;
});
},
methods: {
/** 查询病人报餐列表 */
getList() {
this.loading = true;
listFoodDemand(this.queryParams).then(response => {
this.foodDemandList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
//
updateFromFormat(row, column) {
return this.selectDictLabel(this.updateFromOptions, row.updateFrom);
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
patientId: null,
foods: null,
type: null,
createAt: null,
createBy: null,
price: null,
term: null,
updateAt: null,
updateBy: null,
updateFrom: 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
getFoodDemand(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) {
updateFoodDemand(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addFoodDemand(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 delFoodDemand(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有病人报餐数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportFoodDemand(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};
</script>