营养配餐暂停,恢复,复制,粘贴

This commit is contained in:
ryoeiken 2021-01-19 14:33:04 +08:00
parent 5273d1d669
commit e940708d52
7 changed files with 234 additions and 71 deletions

View File

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://120.77.157.122:3306/fantang_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: fantang_test
password: FcK2GcNhK54bLGM6
url: jdbc:mysql://192.168.3.95:3306/fantang_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
username: root
password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@ -1,6 +1,5 @@
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;
@ -20,9 +19,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* 配餐功能Controller
@ -134,12 +131,9 @@ public class FtCateringDaoController extends BaseController {
public AjaxResult cancel(@PathVariable Long[] ids) {
System.out.println(Arrays.toString(ids));
// 根据病人 id 修改营养配餐启用标志
// 根据病人 id 修改 营养配餐 启用标志
iFtCateringDaoService.cancelByPatientId(ids);
// 根据病人 id 修改报餐配置表营养餐启用标志
iFtFoodDemandDaoService.cancelNutritionByPatientId(ids);
return AjaxResult.success("已暂停");
}
@ -153,12 +147,9 @@ public class FtCateringDaoController extends BaseController {
System.out.println(Arrays.toString(ids));
// 根据病人 id 修改营养配餐启用标志
iFtCateringDaoService.cancelByPatientId(ids);
iFtCateringDaoService.restoreByPatientId(ids);
// 根据病人 id 修改报餐配置表营养餐启用标志
iFtFoodDemandDaoService.cancelNutritionByPatientId(ids);
return AjaxResult.success("已暂停");
return AjaxResult.success("已恢复");
}
/**
@ -195,4 +186,23 @@ public class FtCateringDaoController extends BaseController {
}
return AjaxResult.success();
}
@PutMapping("/paste")
public AjaxResult paste(@RequestBody JSONObject params) {
System.out.println(params);
List<Long> ids = params.getJSONArray("ids").toJavaList(Long.class);
List<FtCateringDao> ftCateringDaoList = params.getJSONArray("copyItem").toJavaList(FtCateringDao.class);
for (Long id : ids) {
iFtCateringDaoService.paste(id,ftCateringDaoList);
}
return AjaxResult.success("已修改");
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.fantang.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.fantang.domain.FtCateringDao;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -26,4 +27,8 @@ public interface IFtCateringDaoService extends IService<FtCateringDao> {
List<Long> notInTable(FtCateringDao ftCateringDao);
Integer copyAndAdd(Long patientId, List<FtCateringDao> ftCateringDao);
Integer restoreByPatientId(Long[] ids);
void paste(Long id, List<FtCateringDao> ftCateringDaoList);
}

View File

@ -6,7 +6,6 @@ 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;
@ -45,28 +44,28 @@ public class FtCateringDaoServiceImpl extends ServiceImpl<FtCateringDaoMapper, F
List<Integer> types = ftCateringDao.getTypes();
for (int i = 1; i < 5; i++) {
FtCateringDao cateringDao = new FtCateringDao();
cateringDao.setPatientId(ftCateringDao.getPatientId());
cateringDao.setNumber(ftCateringDao.getNumber());
cateringDao.setFrequency(ftCateringDao.getFrequency());
cateringDao.setCateringUsage(ftCateringDao.getCateringUsage());
cateringDao.setCreateAt(new Date());
cateringDao.setType(i);
for (int i = 1; i < 5; i++) {
FtCateringDao cateringDao = new FtCateringDao();
cateringDao.setPatientId(ftCateringDao.getPatientId());
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);
}
for (Integer type : types) {
if (i == type) {
cateringDao.setFlag(true);
break;
} else {
cateringDao.setFlag(false);
}
this.baseMapper.insert(cateringDao);
list.add(cateringDao);
}
this.baseMapper.insert(cateringDao);
list.add(cateringDao);
}
return list;
}
@ -94,16 +93,18 @@ public class FtCateringDaoServiceImpl extends ServiceImpl<FtCateringDaoMapper, F
ftCateringDao.setUpdateAt(new Date());
ftCateringDao.setSuspendFlag(false);
FtFoodDemandDao foodDemandDao = new FtFoodDemandDao();
foodDemandDao.setNutritionFoodFlag(false);
for (Long id : ids) {
UpdateWrapper<FtCateringDao> wrapper = new UpdateWrapper<>();
wrapper.eq("patient_id", id);
rows += this.baseMapper.update(ftCateringDao, wrapper);
// 更新该病患的报餐配置记录
FtFoodDemandDao foodDemandDao = new FtFoodDemandDao();
foodDemandDao.setNutritionFoodFlag(false);
QueryWrapper<FtFoodDemandDao> wrapper1 = new QueryWrapper<>();
foodDemandDaoService.update(foodDemandDao, wrapper1);
UpdateWrapper<FtFoodDemandDao> foodDemandWrapper = new UpdateWrapper<>();
foodDemandWrapper.eq("patient_id", id);
foodDemandDaoService.update(foodDemandDao, foodDemandWrapper);
}
return rows;
@ -132,10 +133,11 @@ public class FtCateringDaoServiceImpl extends ServiceImpl<FtCateringDaoMapper, F
/**
* 拷贝粘贴新增指定病患的营养配餐记录并更新该病患默认报餐配置信息
* @author 陈智兴
*
* @param patientId
* @param ftCateringDao
* @return
* @author 陈智兴
*/
@Override
public Integer copyAndAdd(Long patientId, List<FtCateringDao> ftCateringDao) {
@ -151,10 +153,61 @@ public class FtCateringDaoServiceImpl extends ServiceImpl<FtCateringDaoMapper, F
foodDemandDao.setNutritionFoodId(cateringDao.getNumber());
foodDemandDao.setNutritionFoodFlag(true);
QueryWrapper<FtFoodDemandDao> wrapper = new QueryWrapper<>();
wrapper.eq("patient_id",patientId);
wrapper.eq("type",cateringDao.getType());
wrapper.eq("patient_id", patientId);
wrapper.eq("type", cateringDao.getType());
foodDemandDaoService.update(foodDemandDao, wrapper);
}
return 1;
}
@Override
public Integer restoreByPatientId(Long[] ids) {
int rows = 0;
FtCateringDao ftCateringDao = new FtCateringDao();
ftCateringDao.setUpdateAt(new Date());
ftCateringDao.setSuspendFlag(true);
for (Long id : ids) {
UpdateWrapper<FtCateringDao> wrapper = new UpdateWrapper<>();
wrapper.eq("patient_id", id);
rows += this.baseMapper.update(ftCateringDao, wrapper);
}
return rows;
}
@Override
public void paste(Long id, List<FtCateringDao> ftCateringDaoList) {
for (int i = 0; i < 4; i++) {
FtCateringDao ftCateringDao = ftCateringDaoList.get(i);
FtCateringDao cateringDao = new FtCateringDao();
cateringDao.setCateringUsage(ftCateringDao.getCateringUsage());
cateringDao.setFlag(ftCateringDao.getFlag());
cateringDao.setFrequency(ftCateringDao.getFrequency());
cateringDao.setNumber(ftCateringDao.getNumber());
cateringDao.setSuspendFlag(ftCateringDao.getSuspendFlag());
cateringDao.setUpdateAt(new Date());
// 更新该病患营养配餐信息
UpdateWrapper<FtCateringDao> wrapper = new UpdateWrapper<>();
wrapper.eq("patient_id", id);
wrapper.eq("type", i + 1);
this.baseMapper.update(cateringDao, wrapper);
// 更新该病患默认配餐信息
FtFoodDemandDao foodDemandDao = new FtFoodDemandDao();
foodDemandDao.setNutritionFoodId(ftCateringDao.getNumber());
foodDemandDao.setNutritionFoodFlag(ftCateringDao.getFlag());
QueryWrapper<FtFoodDemandDao> foodDemandWrapper = new QueryWrapper<>();
foodDemandWrapper.eq("patient_id", id);
foodDemandWrapper.eq("type", i + 1);
foodDemandDaoService.update(foodDemandDao, foodDemandWrapper);
}
}
}

View File

@ -18,6 +18,7 @@
<result property="createAt" column="create_at"/>
<result property="createBy" column="create_by"/>
<result property="cateringDescribe" column="catering_describe"/>
<result property="suspendFlag" column="suspend_flag"/>
</resultMap>
<select id="listNewFormatter" resultType="com.ruoyi.system.fantang.domain.FtCateringDao">
@ -39,7 +40,7 @@
<if test="bedId != null">and b.bed_id = #{bedId}</if>
<if test="departId != null">and b.depart_id = #{departId}</if>
<if test="hospitalId != null">and b.hospital_id = #{hospitalId}</if>
<if test="flag != null">and a.flag = #{flag}</if>
<if test="suspendFlag != null">and a.suspend_flag = #{suspendFlag}</if>
ORDER BY
b.patient_id,
`type` ASC

View File

@ -35,6 +35,15 @@ export function copyAndAdd(data) {
})
}
// 粘贴
export function paste(data) {
return request({
url: '/fantang/catering/paste',
method: 'put',
data: data
})
}
// 修改配餐功能
export function updateCatering(data) {
return request({

View File

@ -42,11 +42,11 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否启用" prop="flag">
<el-select v-model="queryParams.flag"
<el-form-item label="是否暂停" prop="suspendFlag">
<el-select v-model="queryParams.suspendFlag"
size="small"
@keyup.enter.native="handleQuery"
placeholder="请选是否启用">
placeholder="请选是否暂停">
<el-option
v-for="item in flagOptions"
:key="item.value"
@ -84,20 +84,31 @@
>修改
</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:catering:remove']"-->
<!-- >删除-->
<!-- </el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="danger"
type="success"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
@click="handleRecovery"
v-hasPermi="['fantang:catering:remove']"
>删除
>恢复
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@ -145,7 +156,7 @@
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click=""
@click="handleCopy"
v-hasPermi="['fantang:catering:remove']"
>拷贝
</el-button>
@ -156,7 +167,7 @@
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click=""
@click="handlePaste"
v-hasPermi="['fantang:catering:remove']"
>粘贴
</el-button>
@ -182,11 +193,7 @@
@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="suspendFlag" width="80px">
<template slot-scope="scope">
<el-checkbox v-model="scope.row.suspendFlag" @change="changeSuspend(scope.row, $event)">暂停</el-checkbox>
</template>
</el-table-column>
<el-table-column label="是否暂停" align="center" prop="suspendFlag" width="80px" :formatter="suspendFlagFormat"/>
<el-table-column label="科室" align="center" prop="departName"/>
<el-table-column label="姓名" align="center" prop="name"/>
<el-table-column label="床号" align="center" prop="bedId"/>
@ -210,6 +217,7 @@
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['fantang:catering:edit']"
v-if="scope.row.suspendFlag"
>修改
</el-button>
</template>
@ -431,8 +439,8 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="病人" prop="patientIds" >
<el-select v-model="copyItemForm.patientIds" placeholder="请选择病人" multiple style="width:450px">
<el-form-item label="病人" prop="patientIds">
<el-select v-model="copyItemForm.patientIds" placeholder="请选择病人" multiple style="width:450px">
<el-option
v-for="item in patientOptions"
:key="item.name"
@ -463,7 +471,7 @@
<el-table-column label="正餐类型" align="center" prop="type" :formatter="typeFormat" width="120px"/>
<el-table-column label="营养配餐" align="center" prop="foodName" width="200px">
<template slot-scope="scope">
<el-select v-model="scope.row.number">
<el-select v-model="scope.row.number">
<el-option
v-for="item in numberOptions"
:key="item.id"
@ -473,7 +481,8 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="用法" align="center" prop="cateringUsage" :formatter="cateringUsageFormat" width="120px">
<el-table-column label="用法" align="center" prop="cateringUsage" :formatter="cateringUsageFormat"
width="120px">
<template slot-scope="scope">
<el-select v-model="scope.row.cateringUsage" placeholder="请选择用法">
<el-option
@ -509,16 +518,20 @@
<script>
import {
addCatering,
cancelCatering,
copyAndAdd,
delCatering,
exportCatering,
getAllByPatient,
getCatering,
listCatering,
paste,
restoreCatering,
updateCatering
} from "../../../api/fantang/catering";
import {listDepart} from "../../../api/fantang/depart";
import {getBedIdById, selectNoCateringByDepartId} from "../../../api/fantang/patient";
import {listNutritionFood} from "../../../api/fantang/nutritionFood";
import {cancelCatering, copyAndAdd, getByPatient, getAllByPatient} from "../../../api/fantang/catering";
export default {
name: "Catering",
@ -551,10 +564,10 @@ export default {
//
flagOptions: [{
value: 1,
label: ''
label: '启用'
}, {
value: 0,
label: ''
label: '暂停'
}],
//
departOptions: [],
@ -590,6 +603,7 @@ export default {
pageNum: 1,
pageSize: 12,
flag: null,
suspendFlag: null,
hospitalId: null,
name: null,
departId: null,
@ -599,6 +613,8 @@ export default {
form: {},
//
copyItemForm: {},
//
copyForm: [],
//
copyItemFormRules: {
patientIds: [
@ -761,7 +777,6 @@ export default {
},
//
changeDinnerType(value) {
if (value.length === 1) {
@ -814,6 +829,15 @@ export default {
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
suspendFlagFormat(row) {
if (row.suspendFlag === true) {
return "启用"
} else if (row.suspendFlag === false) {
return "暂停"
} else {
return " ";
}
},
//
cancel() {
this.open = false;
@ -836,7 +860,8 @@ export default {
updateBy: null,
createAt: null,
createBy: null,
cateringDescribe: null
cateringDescribe: null,
suspendFlag: null,
};
this.resetForm("form");
@ -891,13 +916,59 @@ export default {
} else {
this.copyItem = true;
getAllByPatient(id).then(response => {
this.copyItemForm.data = response.data;
this.copyItemForm.departId =null;
this.copyItemForm.data = response.data;
this.copyItemForm.departId = null;
this.copyItemForm.patientIds = [];
console.log('cateringList-->', this.copyItemForm);
})
}
},
//
handleCopy(row) {
this.reset();
const id = row.id || this.ids;
if (this.ids.length > 1) {
this.msgError("只能选择一条记录进行拷贝")
} else {
console.log(id);
getAllByPatient(id).then(response => {
console.log("该病人 4 条数据------", response.data)
this.copyForm = response.data;
console.log("暂存中的 4 条数据", this.copyForm);
})
}
},
//
handlePaste(row) {
const id = row.id || this.ids;
console.log("要粘贴的病人 id ----------------", id)
// if (Object.keys(this.copyForm).length ===0) {
// this.msgError("")
// } else {
// console.log("------", this.copyForm)
// paste( this.copyForm).then(response => {
// console.log("")
// })
// }
if (this.copyForm.length < 4) {
this.msgError("请先进行复制操作")
} else {
console.log("即将粘贴的数据------", this.copyForm)
let data = {
copyItem: this.copyForm,
ids: id,
}
console.log("传的对象-----", data);
paste(data).then(response => {
console.log("修改成功")
this.getList();
})
}
},
/** 拷贝并新增提交按钮 */
submitCopyForm() {
this.$refs["copyItemForm"].validate(valid => {
@ -950,7 +1021,7 @@ export default {
//
changeSuspend(row, e) {
if (e){
if (e) {
this.$confirm('是否暂停 “' + row.name + '” 的营养配餐数据?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@ -980,7 +1051,7 @@ export default {
handleCancel(row) {
const ids = row.patientId || this.ids;
console.log("ids-----", row);
this.$confirm('是否作废 “' + this.names + '” 的营养配餐数据?', "警告", {
this.$confirm('是否暂停 “' + this.names + '” 的营养配餐数据?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
@ -988,7 +1059,21 @@ export default {
return cancelCatering(ids);
}).then(() => {
this.getList();
this.msgSuccess("已作废");
this.msgSuccess("已暂停");
})
},
handleRecovery(row) {
const ids = row.patientId || this.ids;
console.log("ids-----", row);
this.$confirm('是否恢复 “' + this.names + '” 的营养配餐数据?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
return restoreCatering(ids);
}).then(() => {
this.getList();
this.msgSuccess("已恢复");
})
},
/** 导出按钮操作 */