From 7026d78c34912259f7b2da131d070c365c785ced Mon Sep 17 00:00:00 2001 From: czx <28353131@qq.com> Date: Mon, 18 Jan 2021 16:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=97=85=E6=82=A3=E8=90=A5?= =?UTF-8?q?=E5=85=BB=E9=85=8D=E9=A4=90=E2=80=9C=E6=8B=B7=E8=B4=9D=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E2=80=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FtCateringDaoController.java | 26 ++- .../service/IFtCateringDaoService.java | 2 +- .../impl/FtCateringDaoServiceImpl.java | 57 +++--- ruoyi-ui/src/api/fantang/catering.js | 8 + ruoyi-ui/src/views/fantang/catering/index.vue | 167 +++++++++--------- 5 files changed, 136 insertions(+), 124 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java index 9fe329e9e..600931795 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtCateringDaoController.java @@ -1,5 +1,7 @@ package com.ruoyi.system.fantang.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.annotation.Log; @@ -152,18 +154,28 @@ public class FtCateringDaoController extends BaseController { return AjaxResult.success(iFtCateringDaoService.getOne(wrapper)); } + /** + * 根据病人 id 查找营养配餐数据 + */ + @GetMapping("/getAllByPatient/{patientId}") + public AjaxResult getAllByPatient(@PathVariable Long patientId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("patient_id", patientId); + return AjaxResult.success(iFtCateringDaoService.list(wrapper)); + } + + /** * 拷贝并新增 */ @PostMapping("/copyAndAdd") - public AjaxResult copyAndAdd(@RequestBody FtCateringDao ftCateringDao) { + public AjaxResult copyAndAdd(@RequestBody JSONObject params) { + List patientIds = params.getJSONArray("patientIds").toJavaList(Long.class); + List data = params.getJSONArray("data").toJavaList(FtCateringDao.class); + for (Long patientId : patientIds) { + Integer ftCateringDaoList = iFtCateringDaoService.copyAndAdd(patientId, data); + } - System.out.println(ftCateringDao); - - - List patientIds = iFtCateringDaoService.notInTable(ftCateringDao); - - List ftCateringDaoList = iFtCateringDaoService.copyAndAdd(patientIds, ftCateringDao); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java index f29ff1d56..5a5f9d68f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtCateringDaoService.java @@ -25,5 +25,5 @@ public interface IFtCateringDaoService extends IService { List notInTable(FtCateringDao ftCateringDao); - List copyAndAdd(List patientIds, FtCateringDao ftCateringDao); + Integer copyAndAdd(Long patientId, List ftCateringDao); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java index 5971efbe2..2addd0b9c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtCateringDaoServiceImpl.java @@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.fantang.domain.FtCateringDao; +import com.ruoyi.system.fantang.domain.FtFoodDemandDao; import com.ruoyi.system.fantang.mapper.FtCateringDaoMapper; +import com.ruoyi.system.fantang.mapper.FtFoodDemandDaoMapper; import com.ruoyi.system.fantang.service.IFtCateringDaoService; +import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -21,6 +25,9 @@ import java.util.List; @Service public class FtCateringDaoServiceImpl extends ServiceImpl implements IFtCateringDaoService { + @Autowired + IFtFoodDemandDaoService foodDemandDaoService; + @Override public List listNewFormatter(FtCateringDao ftCateringDao) { return this.baseMapper.listNewFormatter(ftCateringDao); @@ -116,37 +123,31 @@ public class FtCateringDaoServiceImpl extends ServiceImpl copyAndAdd(List patientIds, FtCateringDao ftCateringDao) { + public Integer copyAndAdd(Long patientId, List ftCateringDao) { - List list = new ArrayList<>(); + // 为指定病患id批量插入营养配餐配置记录 + for (FtCateringDao cateringDao : ftCateringDao) { + cateringDao.setId(null); + cateringDao.setPatientId(patientId); + this.baseMapper.insert(cateringDao); - List types = ftCateringDao.getTypes(); - - for (Long patientId : patientIds) { - for (int i = 1; i < 5; i++) { - FtCateringDao cateringDao = new FtCateringDao(); - cateringDao.setPatientId(patientId); - cateringDao.setNumber(ftCateringDao.getNumber()); - cateringDao.setFrequency(ftCateringDao.getFrequency()); - cateringDao.setCateringUsage(ftCateringDao.getCateringUsage()); - cateringDao.setCreateAt(new Date()); - cateringDao.setType(i); - - for (Integer type : types) { - if (i == type) { - cateringDao.setFlag(true); - break; - } else { - cateringDao.setFlag(false); - } - } - - this.baseMapper.insert(cateringDao); - list.add(cateringDao); - } + // 更新该病患默认配餐信息 + FtFoodDemandDao foodDemandDao = new FtFoodDemandDao(); + foodDemandDao.setNutritionFoodId(cateringDao.getNumber()); + foodDemandDao.setNutritionFoodFlag(true); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("patient_id",patientId); + wrapper.eq("type",cateringDao.getType()); + foodDemandDaoService.update(foodDemandDao, wrapper); } - - return list; + return 1; } } diff --git a/ruoyi-ui/src/api/fantang/catering.js b/ruoyi-ui/src/api/fantang/catering.js index 814d68700..744607088 100644 --- a/ruoyi-ui/src/api/fantang/catering.js +++ b/ruoyi-ui/src/api/fantang/catering.js @@ -76,3 +76,11 @@ export function getByPatient(id) { method: 'get' }) } + +// 根据病人 id 查找全部四条营养配餐记录 +export function getAllByPatient(id) { + return request({ + url: '/fantang/catering/getAllByPatient/' + id, + method: 'get' + }) +} diff --git a/ruoyi-ui/src/views/fantang/catering/index.vue b/ruoyi-ui/src/views/fantang/catering/index.vue index d1430ccbf..5a02db7db 100644 --- a/ruoyi-ui/src/views/fantang/catering/index.vue +++ b/ruoyi-ui/src/views/fantang/catering/index.vue @@ -411,11 +411,12 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -517,7 +513,7 @@ import { import {listDepart} from "../../../api/fantang/depart"; import {getBedIdById, selectNoCateringByDepartId} from "../../../api/fantang/patient"; import {listNutritionFood} from "../../../api/fantang/nutritionFood"; -import {cancelCatering, copyAndAdd, getByPatient} from "../../../api/fantang/catering"; +import {cancelCatering, copyAndAdd, getByPatient, getAllByPatient} from "../../../api/fantang/catering"; export default { name: "Catering", @@ -600,24 +596,9 @@ export default { copyItemForm: {}, // 拷贝并新增表单校验 copyItemFormRules: { - departId: [ - {required: true, message: "部门不能为空", trigger: "blur"} - ], patientIds: [ {required: true, message: "病人不能为空", trigger: "blur"} ], - types: [ - {required: true, message: "正餐类型不能为空", trigger: "blur"} - ], - cateringUsage: [ - {required: true, message: "用法不能为空", trigger: "blur"} - ], - frequency: [ - {required: true, message: "频次不能为空", trigger: "blur"} - ], - number: [ - {required: true, message: "配餐号不能为空", trigger: "blur"} - ], }, // 表单校验 rules: { @@ -678,7 +659,7 @@ export default { return "禁用"; } }, - // 控制合并列 + // 控制数据合并列 objectSpanMethod({rowIndex, columnIndex}) { if (columnIndex === 1) { if (rowIndex % 4 === 0) { @@ -744,6 +725,25 @@ export default { } }, + // 控制弹出层“拷贝和新增”数据合并列 + objectSpanMethodForCopyAndCreate({rowIndex, columnIndex}) { + if (columnIndex === 0) { + if (rowIndex % 4 === 0) { + return { + rowspan: 4, + colspan: 1 + }; + } else { + return { + rowspan: 0, + colspan: 0 + }; + } + } + }, + + + // 响应营养配餐用餐安排多选列表 changeDinnerType(value) { if (value.length === 1) { @@ -824,17 +824,8 @@ export default { this.copyItemForm = { id: null, + data: null, patientId: null, - type: null, - number: null, - frequency: null, - cateringUsage: null, - isReplace: null, - flag: null, - updateAt: null, - updateBy: null, - createAt: null, - createBy: null, cateringDescribe: null }; this.resetForm("copyItemForm"); @@ -880,12 +871,12 @@ export default { if (this.ids.length > 1) { this.msgError("只能选择一条记录进行拷贝并新增") } else { - getByPatient(id).then(response => { - console.log(response.data) - this.copyItemForm.cateringUsage = response.data.cateringUsage; - this.copyItemForm.frequency = response.data.frequency; - this.copyItemForm.number = response.data.number; - this.copyItem = true; + this.copyItem = true; + getAllByPatient(id).then(response => { + this.copyItemForm.data = response.data; + this.copyItemForm.departId =null; + this.copyItemForm.patientIds = []; + console.log('cateringList-->', this.copyItemForm); }) } },