送餐员报餐 APP 后端接口,todo:批量更新报餐记录,通知营养科更新营养配餐信息

This commit is contained in:
ryoeiken 2020-12-30 16:36:44 +08:00
parent f27e2de7c1
commit 595adb7ae3
7 changed files with 201 additions and 53 deletions

View File

@ -1,10 +1,9 @@
package com.ruoyi.system.fantang.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.fantang.domain.FtOrderDao;
import com.ruoyi.system.fantang.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -12,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@ -36,6 +36,9 @@ public class ClientController extends BaseController {
@Autowired
private IFtWeekMenuDaoService weekMenuDaoService;
@Autowired
private IFtReportMealsDaoService reportMealsDaoService;
/**
* 获取用餐时间信息
* 日期2020年12月11日
@ -65,7 +68,7 @@ public class ClientController extends BaseController {
* 获取员工某一天的订单信息
* 日期2020年12月11日
* 作者陈智兴
*
* <p>
* return
*/
@GetMapping("/getOrderOfDay")
@ -89,7 +92,7 @@ public class ClientController extends BaseController {
* 获取员工停餐信息
* 日期2020年12月21日
* 作者陈智兴
*
* <p>
* param JSONObject staffId: 员工id
* return
*/
@ -103,25 +106,25 @@ public class ClientController extends BaseController {
* 推送订单信息
* 日期2020年12月11日
* 作者陈智兴
*
* <p>
* param JSONObject staffId: 员工id
* orderType订餐类型
* demandDate 订餐用餐日期
* orderType订餐类型
* demandDate 订餐用餐日期
* return
*/
@PostMapping("/PostOrder")
public AjaxResult postOrder(@RequestBody JSONObject params) {
return AjaxResult.success(orderDaoService.insertOrder(params.getLong("staffId"), params.getInteger("orderType"), params.getDate("demandDate")));
return AjaxResult.success(orderDaoService.insertOrder(params.getLong("staffId"), params.getInteger("orderType"), params.getDate("demandDate")));
}
/**
* 推送停餐信息
* 日期2020年12月21日
* 作者陈智兴
*
* <p>
* param staffId: 员工id
* type订餐类型
* demandDate 订餐用餐日期
* type订餐类型
* demandDate 订餐用餐日期
* return -1: 已报停餐信息 1 停餐成功
*/
@PostMapping("/postStopOrder")
@ -133,10 +136,10 @@ public class ClientController extends BaseController {
* 员工取消订餐信息
* 日期2020年12月21日
* 作者陈智兴
*
* <p>
* param staffId: 员工id
* type订餐类型
* demandDate 订餐用餐日期
* type订餐类型
* demandDate 订餐用餐日期
* return -1: 已报停餐信息 1 停餐成功
*/
@PostMapping("/postCancelOrder")
@ -148,10 +151,10 @@ public class ClientController extends BaseController {
* 推送取消停餐信息
* 日期2020年12月21日
* 作者陈智兴
*
* <p>
* param staffId: 员工id
* type订餐类型
* demandDate 订餐用餐日期
* type订餐类型
* demandDate 订餐用餐日期
* return -1: 已报停餐信息 1 停餐成功
*/
@PostMapping("/postCancelStopOrder")
@ -170,10 +173,10 @@ public class ClientController extends BaseController {
* 日期2020年12月10日
* 作者 陈智兴
* 修改首次创建
*
* <p>
* param { tel: 手机号码;
* password 密码
* }
* password 密码
* }
* return 返回员工信息
*/
@GetMapping("/login")
@ -252,7 +255,7 @@ public class ClientController extends BaseController {
*/
@PostMapping("/getMenuOfDay")
public AjaxResult getMenuOfDay(@RequestBody JSONObject params) {
String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
Calendar cal = Calendar.getInstance();
cal.setTime(params.getDate("date"));
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
@ -265,4 +268,36 @@ public class ClientController extends BaseController {
public AjaxResult statisGetOrderOfDate(@RequestParam Date date) {
return orderDaoService.statisGetOrderOfDate(date);
}
/**
* 获取指定日期的订单明细
* 类型日期
* 类型 = 0 所有
* type = 123
*/
@PostMapping("/getOrderDetailedByDate")
public AjaxResult getOrderDetailedByDate(@RequestBody JSONObject params) {
String createAt = params.getString("createAt");
Integer orderType = params.getInteger("orderType");
String start = createAt + " 00:00:00";
String end = createAt + " 23:59:59";
// QueryWrapper<FtOrderDao> wrapper = new QueryWrapper<>();
// if (orderType != 0) {
// wrapper.eq("order_type", orderType);
// }
// wrapper.between("create_at", start, end);
// orderDaoService.list(wrapper);
List<FtOrderDao> orderList;
if (orderType != 0) {
orderList = orderDaoService.listDetailedByDate(orderType, start, end);
}else {
orderList = orderDaoService.listAllDetailedByDate(start, end);
}
return AjaxResult.success(orderList);
}
}

View File

@ -2,20 +2,23 @@ package com.ruoyi.system.fantang.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.fantang.domain.FtFoodDao;
import com.ruoyi.system.fantang.domain.FtFoodDemandDao;
import com.ruoyi.system.fantang.domain.FtReportMealsDao;
import com.ruoyi.system.fantang.domain.FtStaffInfoDao;
import com.ruoyi.system.fantang.service.IFtDepartDaoService;
import com.ruoyi.system.fantang.service.IFtPatientDaoService;
import com.ruoyi.system.fantang.service.IFtStaffInfoDaoService;
import com.ruoyi.system.fantang.service.*;
import com.ruoyi.system.fantang.vo.FtDepartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.List;
@RestController
@ -31,6 +34,18 @@ public class ClientPatientController extends BaseController {
@Autowired
private IFtDepartDaoService iFtDepartDaoService;
@Autowired
private IFtReportMealsDaoService iFtReportMealsDaoService;
@Autowired
private IFtFoodDemandDaoService iFtFoodDemandDaoService;
@Autowired
private IFtNutritionFoodDaoService iFftNutritionFoodDaoService;
@Autowired
private IFtFoodDaoService iftFoodDaoService;
/**
* 根据病人获取今日报餐信息
*/
@ -92,10 +107,10 @@ public class ClientPatientController extends BaseController {
/**
* 更改默认报餐部门
*/
@PostMapping("/updateDepart")
public AjaxResult updateDepart(@RequestBody Map<String, Object> data) {
Long staffId = Long.parseLong(data.get("staffId").toString());
String departId = data.get("departId").toString();
@PutMapping("/updateDepart")
public AjaxResult updateDepart(@RequestBody JSONObject params) {
Long staffId = params.getLong("staffId");
String departId = params.getString("departId");
UpdateWrapper<FtStaffInfoDao> wrapper = new UpdateWrapper<>();
wrapper.eq("staff_id", staffId);
@ -104,4 +119,47 @@ public class ClientPatientController extends BaseController {
return AjaxResult.success(iFtStaffInfoDaoService.update(staffInfoDao, wrapper));
}
/**
* 批量更新报餐记录
*/
@PutMapping("/batchUpdateReportMeals")
public AjaxResult batchUpdateReportMeals(@RequestBody List<FtReportMealsDao> reportMealsDaoList) {
return AjaxResult.success(iFtReportMealsDaoService.updateBatchById(reportMealsDaoList));
}
/**
* 更新指定病患的报餐记录
*/
@PutMapping("/updateReportMeals")
public AjaxResult updateReportMeals(@RequestBody FtReportMealsDao ftReportMealsDao) {
return AjaxResult.success(iFtReportMealsDaoService.updateById(ftReportMealsDao));
}
/**
* 更新指定病患默认报餐数据
*/
@PutMapping("/updateFoodDemand")
public AjaxResult updateFoodDemand(@RequestBody FtFoodDemandDao ftFoodDemandDao) {
return AjaxResult.success(iFtFoodDemandDaoService.updateById(ftFoodDemandDao));
}
/**
* 获取营养配餐配置信息
*/
@GetMapping("getNutritionFood")
public AjaxResult getNutritionFood() {
return AjaxResult.success(iFftNutritionFoodDaoService.list());
}
/**
* 获取菜品价格
*/
@GetMapping("/getFoodPrice/{foodId}")
public AjaxResult getFoodPrice(@PathVariable("foodId") Long foodId) {
QueryWrapper<FtFoodDao> wrapper = new QueryWrapper<>();
wrapper.eq("type", 1);
wrapper.eq("food_id", foodId);
return AjaxResult.success(iftFoodDaoService.getOne(wrapper).getPrice());
}
}

View File

@ -52,6 +52,12 @@ public class FtOrderDao implements Serializable {
*/
private Long staffId;
/**
* 员工姓名
*/
@TableField(exist = false)
private String name;
/**
* 清单
*/
@ -147,4 +153,7 @@ public class FtOrderDao implements Serializable {
@TableField(exist = false)
private String departName;
@TableField(exist = false)
private Long departId;
}

View File

@ -6,7 +6,6 @@ import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
/**
@ -24,5 +23,10 @@ public interface FtOrderDaoMapper extends BaseMapper<FtOrderDao> {
" LEFT JOIN ft_staff_info b on a.staff_id = b.staff_id\n" +
" LEFT JOIN ft_depart c on b.depart_id = c.depart_id where a.order_date BETWEEN #{start} and #{end}\n" +
" GROUP BY a.order_type, c.depart_name")
List<FtOrderDao> statisGetOrderOfDate(@Param("start")String start,@Param("end") String end);
List<FtOrderDao> statisGetOrderOfDate(@Param("start") String start, @Param("end") String end);
List<FtOrderDao> listDetailedByDate(@Param("orderType") Integer orderType, @Param("start") String start, @Param("end") String end);
List<FtOrderDao> listAllDetailedByDate(String start, String end);
}

View File

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.fantang.domain.FtOrderDao;
import java.util.Date;
import java.util.List;
/**
* 订单管理Service接口
@ -31,4 +32,8 @@ public interface IFtOrderDaoService extends IService<FtOrderDao> {
AjaxResult cancelStopOrder(Long orderId);
AjaxResult statisGetOrderOfDate(Date date);
List<FtOrderDao> listDetailedByDate(Integer orderType, String start, String end);
List<FtOrderDao> listAllDetailedByDate(String start, String end);
}

View File

@ -91,7 +91,7 @@ public class FtOrderDaoServiceImpl extends ServiceImpl<FtOrderDaoMapper, FtOrder
public AjaxResult stopOrder(Long staffId, Integer orderType, Date demandDate) {
// 先删除当天的订餐记录再添加停餐记录
QueryWrapper<FtOrderDao> wrapper = new QueryWrapper<>();
wrapper.eq("staff_id", staffId);
wrapper.eq("staff_id", staffId);
wrapper.eq("order_type", orderType);
wrapper.between("order_date", DateUtil.beginOfDay(demandDate), DateUtil.endOfDay(demandDate));
this.baseMapper.delete(wrapper);
@ -129,4 +129,14 @@ public class FtOrderDaoServiceImpl extends ServiceImpl<FtOrderDaoMapper, FtOrder
public AjaxResult statisGetOrderOfDate(Date date) {
return AjaxResult.success(this.baseMapper.statisGetOrderOfDate(DateUtil.beginOfDay(date).toString(), DateUtil.endOfDay(date).toString()));
}
@Override
public List<FtOrderDao> listDetailedByDate(Integer orderType, String start, String end) {
return this.baseMapper.listDetailedByDate(orderType, start, end);
}
@Override
public List<FtOrderDao> listAllDetailedByDate(String start, String end) {
return this.baseMapper.listAllDetailedByDate(start, end);
}
}

View File

@ -1,29 +1,56 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.fantang.mapper.FtOrderDaoMapper">
<resultMap type="FtOrderDao" id="FtOrderDaoResult">
<result property="orderId" column="order_id" />
<result property="orderType" column="order_type" />
<result property="workerId" column="worker_id" />
<result property="orderList" column="order_list" />
<result property="totalPrice" column="total_price" />
<result property="discount" column="discount" />
<result property="receipts" column="receipts" />
<result property="createAt" column="create_at" />
<result property="createBy" column="create_by" />
<result property="orderSrc" column="order_src" />
<result property="currentPrice" column="current_price" />
<result property="payType" column="pay_type" />
<result property="payFlag" column="pay_flag" />
<result property="expiredFlag" column="expired_flag" />
<result property="writeOffFlag" column="write_off_flag" />
<result property="writeOffAt" column="write_off_at" />
<result property="isExpired" column="is_expired" />
<result property="deviceId" column="device_id" />
<result property="orderId" column="order_id"/>
<result property="orderType" column="order_type"/>
<result property="workerId" column="worker_id"/>
<result property="orderList" column="order_list"/>
<result property="totalPrice" column="total_price"/>
<result property="discount" column="discount"/>
<result property="receipts" column="receipts"/>
<result property="createAt" column="create_at"/>
<result property="createBy" column="create_by"/>
<result property="orderSrc" column="order_src"/>
<result property="currentPrice" column="current_price"/>
<result property="payType" column="pay_type"/>
<result property="payFlag" column="pay_flag"/>
<result property="expiredFlag" column="expired_flag"/>
<result property="writeOffFlag" column="write_off_flag"/>
<result property="writeOffAt" column="write_off_at"/>
<result property="isExpired" column="is_expired"/>
<result property="deviceId" column="device_id"/>
</resultMap>
<select id="listDetailedByDate" resultType="com.ruoyi.system.fantang.domain.FtOrderDao">
SELECT a.*,
b.staff_id,
b.`name`,
b.depart_id,
c.depart_name
FROM ft_order a
LEFT JOIN ft_staff_info b ON a.staff_id = b.staff_id
LEFT JOIN ft_depart c ON b.depart_id = c.depart_id
WHERE a.order_type = #{orderType}
AND a.create_at BETWEEN #{start}
AND #{end}
</select>
<select id="listAllDetailedByDate" resultType="com.ruoyi.system.fantang.domain.FtOrderDao">
SELECT a.*,
b.staff_id,
b.`name`,
b.depart_id,
c.depart_name
FROM ft_order a
LEFT JOIN ft_staff_info b ON a.staff_id = b.staff_id
LEFT JOIN ft_depart c ON b.depart_id = c.depart_id
AND a.create_at BETWEEN #{start}
AND #{end}
</select>
</mapper>