新增,修改营养配餐时一同新增,修改病人配餐设置

This commit is contained in:
ryoeiken 2021-01-04 10:10:20 +08:00
parent 873bf7203a
commit b96b7bbf41
3 changed files with 65 additions and 21 deletions

View File

@ -1,6 +1,7 @@
package com.ruoyi.system.fantang.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -8,7 +9,9 @@ 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.FtCateringDao;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.service.IFtCateringDaoService;
import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -31,6 +34,8 @@ public class FtCateringDaoController extends BaseController {
private final IFtCateringDaoService iFtCateringDaoService;
private final IFtFoodDemandDaoService iFtFoodDemandDaoService;
/**
* 查询配餐功能列表
*/
@ -74,8 +79,9 @@ public class FtCateringDaoController extends BaseController {
public AjaxResult add(@RequestBody FtCateringDao ftCateringDao) {
List<Integer> types = ftCateringDao.getTypes();
for (Integer type : types) {
Long patientId = ftCateringDao.getPatientId();
FtCateringDao ftCatering = new FtCateringDao();
ftCatering.setPatientId(ftCateringDao.getPatientId());
ftCatering.setPatientId(patientId);
ftCatering.setNumber(ftCateringDao.getNumber());
ftCatering.setFrequency(ftCateringDao.getFrequency());
ftCatering.setCateringUsage(ftCateringDao.getCateringUsage());
@ -83,6 +89,26 @@ public class FtCateringDaoController extends BaseController {
ftCatering.setCreateAt(new Date());
ftCatering.setType(type);
iFtCateringDaoService.save(ftCatering);
// 如果属于加餐新增一条病患配餐记录否则修改
if (type == 4) {
FtFoodDemandDao foodDemandDao = new FtFoodDemandDao();
foodDemandDao.setPatientId(patientId);
foodDemandDao.setType(type);
foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber());
foodDemandDao.setNutritionFoodFlag(1);
foodDemandDao.setCreateAt(new Date());
iFtFoodDemandDaoService.save(foodDemandDao);
} else {
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId);
wrapper.eq("type", type);
FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper);
foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber());
foodDemandDao.setNutritionFoodFlag(1);
foodDemandDao.setUpdateAt(new Date());
iFtFoodDemandDaoService.updateById(foodDemandDao);
}
}
return AjaxResult.success("新增成功");
@ -95,6 +121,20 @@ public class FtCateringDaoController extends BaseController {
@Log(title = "配餐功能", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody FtCateringDao ftCateringDao) {
Long patientId = ftCateringDao.getPatientId();
Integer type = ftCateringDao.getType();
Long number = ftCateringDao.getNumber();
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id", patientId);
wrapper.eq("type", type);
FtFoodDemandDao foodDemandDao = iFtFoodDemandDaoService.getOne(wrapper);
foodDemandDao.setNutritionFoodId(number);
foodDemandDao.setNutritionFoodFlag(1);
foodDemandDao.setUpdateAt(new Date());
iFtFoodDemandDaoService.updateById(foodDemandDao);
return toAjax(iFtCateringDaoService.updateById(ftCateringDao) ? 1 : 0);
}

View File

@ -52,7 +52,7 @@ public class FtFoodDemandDao extends BasePatient implements Serializable {
* 正餐类型
*/
@Excel(name = "正餐类型")
private Long type;
private Integer type;
/**
* 创建时间

View File

@ -274,23 +274,25 @@ export default {
//
formatFoods(row) {
const _this = this;
let arr = row.foods.split(",").map(Number);
let ret = arr.map(item => {
let obj = _this.foodList.find((value => {
return value.foodId === item;
}));
return obj.name;
});
let str = ret.toString();
if (row.vegetables > 0)
str += ",加菜";
if (row.rice > 0)
str += ",加饭"
if (row.meat > 0)
str += ",加肉"
if (row.egg > 0)
str += ",加蛋" + row.egg;
return str;
if (row.foods!=null){
let arr = row.foods.split(",").map(Number);
let ret = arr.map(item => {
let obj = _this.foodList.find((value => {
return value.foodId === item;
}));
return obj.name;
});
let str = ret.toString();
if (row.vegetables > 0)
str += ",加菜";
if (row.rice > 0)
str += ",加饭"
if (row.meat > 0)
str += ",加肉"
if (row.egg > 0)
str += ",加蛋" + row.egg;
return str;
}
},
formatVegetables(row) {
if (row.vegetables)
@ -319,8 +321,8 @@ export default {
listFoodDemand(this.queryParams).then(response => {
this.foodDemandList = response.rows;
this.total = response.total;
this.loading = false;
console.log(response.rows)
});
},
//
@ -385,7 +387,9 @@ export default {
const id = row.id || this.ids
getFoodDemand(id).then(response => {
this.form = response.data;
this.form.foods = this.form.foods.split(",").map(Number);
if (this.form.foods!=null){
this.form.foods = this.form.foods.split(",").map(Number);
}
this.form.type = this.selectDictLabel(this.typeOptions, row.type);
this.open = true;
this.title = "修改病人报餐";