diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/FtGenerateOrderTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/FtGenerateOrderTask.java index c6d33c094..ad1db65bf 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/FtGenerateOrderTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/FtGenerateOrderTask.java @@ -2,6 +2,7 @@ package com.ruoyi.quartz.task; import com.ruoyi.system.fantang.mapper.FtReportMealVoMapper; import com.ruoyi.system.fantang.service.impl.FtFoodDemandDaoServiceImpl; +import com.ruoyi.system.fantang.service.impl.FtOrderDaoServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -19,6 +20,9 @@ public class FtGenerateOrderTask { @Autowired private FtReportMealVoMapper ftReportMealVoMapper; + @Autowired + private FtOrderDaoServiceImpl orderDaoService; + public void GenerateOrderTask() { System.out.println("执行生成一条病患默认订餐配置记录"); foodDemandDaoService.GenerateOrderForNewPatient(); @@ -28,4 +32,10 @@ public class FtGenerateOrderTask { System.out.println("生成次日病患报餐记录"); ftReportMealVoMapper.insertTomorrowReportMeal(); } + + // 生成次日员工订餐记录 + public void GenerateStaffTomorrowOrder() { + System.out.println("生成次日员工订餐记录"); + orderDaoService.GenerateStaffTomorrowOrder(); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/ClientController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/ClientController.java index 44dae9d24..77534c14b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/ClientController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/ClientController.java @@ -1,12 +1,18 @@ package com.ruoyi.system.fantang.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.fantang.service.IFtConfigDaoService; +import com.ruoyi.system.fantang.service.IFtOrderDaoService; +import com.ruoyi.system.fantang.service.IFtStaffDemandDaoService; +import com.ruoyi.system.fantang.service.IFtStaffInfoDaoService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; + @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/client_api/staff") @@ -17,18 +23,27 @@ public class ClientController extends BaseController { @Autowired private IFtConfigDaoService iFtConfigDaoService; + @Autowired + private IFtStaffInfoDaoService staffInfoDaoService; + + @Autowired + private IFtStaffDemandDaoService staffDemandDaoService; + + @Autowired + private IFtOrderDaoService orderDaoService; + @GetMapping("/getDinnerTimeSetting") public AjaxResult getDinnerTimeSetting() { return AjaxResult.success(iFtConfigDaoService.getDinnerTimeSetting()); } @GetMapping("/getOrderOfToday/{staffId}") - public AjaxResult getOrderOfToday(@PathVariable("staffId") Integer staffId) { - return AjaxResult.success("调用成功"); + public AjaxResult getOrderOfToday(@PathVariable("staffId") Long staffId) { + return AjaxResult.success(orderDaoService.getOrderOfToday(staffId)); } @GetMapping("/getWeekMenu") - public AjaxResult getWeekMenu(){ + public AjaxResult getWeekMenu() { return AjaxResult.success("调用每周菜谱成功"); } @@ -37,28 +52,60 @@ public class ClientController extends BaseController { return AjaxResult.success("调用有效订单成功"); } + /** + * 推送订单信息 + * 日期:2020年12月11日 + * 作者:陈智兴 + * @param JSONArray + * staffId: 员工id + * type:订餐类型 + * demandDate: 订餐用餐日期 + * @return + */ @PostMapping("/PostOrder") - public AjaxResult postOrder() { + public AjaxResult postOrder(JSONArray params) { +// for(int i : params.size()) { +// +// } +// Long staffId = params.getLong("staffId"); +// Integer type = params.getInteger("type"); +// Date demandDate = params.getDate("demandDate"); +// orderDaoService.postOrder(); + return AjaxResult.success("调用提交订单成功"); } + // 获取配置信息 @GetMapping("/getConfiguration/{staffId}") - public AjaxResult getConfiguration(@PathVariable("staffId") Integer staffId) { - return AjaxResult.success("调用个人配置"); + public AjaxResult getConfiguration(@PathVariable("staffId") Long staffId) { + return AjaxResult.success(staffDemandDaoService.getConfiguration(staffId)); } - @PostMapping("/postConfiguration") - public AjaxResult postConfiguration() { + // 获取配置信息 + @PostMapping("/postConfiguration/{staffId}") + public AjaxResult postConfiguration(@PathVariable("staffId") Long staffId) { + return AjaxResult.success("推送个人配置"); } - - @PostMapping("/login") - public AjaxResult login() { - return AjaxResult.success("登录成功"); + /** + * 设置订餐模式 + * 日期:2020年12月10日 + * 作者: 陈智兴 + * 修改:首次创建 + * @param { + * tel: 手机号码; + * password: 密码 + * } + * @return 返回员工信息 + */ + @GetMapping("/login") + public AjaxResult login(String tel, String password) { + return staffInfoDaoService.login(tel, password); } - @PostMapping("/logout") - public AjaxResult logout() { - return AjaxResult.success("登录成功"); + + @PostMapping("/logout/{staffId}") + public AjaxResult logout(@PathVariable("staffId") Long staffId) { + return AjaxResult.success(staffInfoDaoService.logout(staffId)); } @GetMapping("/getWorkday") @@ -75,20 +122,42 @@ public class ClientController extends BaseController { public AjaxResult getOtherProduct() { return null; } - @GetMapping("/postProductOrder") + + @PostMapping("/postProductOrder") public AjaxResult postProductOrder() { return null; } - @GetMapping("/postCurrentOrder") + + @PostMapping("/postCurrentOrder") public AjaxResult postCurrentOrder() { return null; } - @GetMapping("/postStopOrder") + + @PostMapping("/postStopOrder") public AjaxResult postStopOrder() { return null; } - @GetMapping("/postRestoreOrder") + + @PostMapping("/postRestoreOrder") public AjaxResult postRestoreOrder() { return null; } + + /** + * 设置订餐模式 + * 日期:2020年12月11日 + * 作者: 陈智兴 + * 修改:首次创建 + * @param { + * config_id: id; + * demandMode: true:自动模式;false:手动模式 + * } + * @return + */ + @PostMapping("/setDemandMode") + public AjaxResult setDemandMode(@RequestBody JSONObject params) { + Long id = params.getLong("id"); + Boolean demandMode = params.getBoolean("demandModeFlag"); + return staffDemandDaoService.setDemandMode(id, demandMode); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtOrderDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtOrderDao.java index 92e271f00..71a4d0309 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtOrderDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtOrderDao.java @@ -46,7 +46,7 @@ public class FtOrderDao implements Serializable { /** * 员工 id */ - private Long workerId; + private Long staffId; /** * 清单 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffDemandDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffDemandDao.java index 7e137d050..f97266f59 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffDemandDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffDemandDao.java @@ -38,7 +38,7 @@ private static final long serialVersionUID=1L; /** 员工 id */ @Excel(name = "员工 id") - private Long staffId; + private Integer staffId; /** 正餐清单 */ @Excel(name = "正餐清单") @@ -74,7 +74,7 @@ private static final long serialVersionUID=1L; /** 报餐模式 */ @Excel(name = "报餐模式") - private Integer demandMode; + private Boolean demandMode; /** 停用标志 */ @Excel(name = "停用标志") diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffInfoDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffInfoDao.java index 7a648ce02..4dd1fd3cb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffInfoDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtStaffInfoDao.java @@ -123,4 +123,10 @@ public class FtStaffInfoDao { * 手机号码 */ private String tel; + + private String token; + + private Boolean loginFlag; + + private String expired; } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtOrderDaoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtOrderDaoMapper.java index d927dee87..486929230 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtOrderDaoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtOrderDaoMapper.java @@ -2,6 +2,9 @@ package com.ruoyi.system.fantang.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.fantang.domain.FtOrderDao; +import org.apache.ibatis.annotations.Insert; + +import java.util.List; /** * 订单管理Mapper接口 @@ -11,4 +14,9 @@ import com.ruoyi.system.fantang.domain.FtOrderDao; */ public interface FtOrderDaoMapper extends BaseMapper { + @Insert("insert into ft_order (order_type, staff_id, order_src, create_at, order_date, order_list, total_price) select type as order_type, staff_id, 1 as order_src, now() as create_at, date_add(now(), interval 1 day) as order_date, foods, (select sum(price) from ft_food f where FIND_IN_SET(f.food_id,d.foods)) as price from ft_staff_demand d where d.demand_mode = 1") + void GenerateStaffTomorrowOrder(); + + + List getOrderOfToday(Long staffId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtStaffInfoDaoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtStaffInfoDaoMapper.java index c14f2cb70..f80cf3230 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtStaffInfoDaoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtStaffInfoDaoMapper.java @@ -3,6 +3,7 @@ package com.ruoyi.system.fantang.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.fantang.domain.FtStaffInfoDao; import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -16,4 +17,7 @@ public interface FtStaffInfoDaoMapper extends BaseMapper { @Select("SELECT a.*, b.depart_name from ft_staff_info a LEFT JOIN ft_depart b on a.depart_id = b.depart_id where staff_type = 1") List selectStaffInfoWithDepart(); + + @Update("update ft_staff_info set token=#{token}, login_flag=1 where staff_id=#{staff_id}") + void updateLoginStatus(FtStaffInfoDao dao); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtOrderDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtOrderDaoService.java index d11f742d4..b3b11bb07 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtOrderDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtOrderDaoService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.fantang.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.fantang.domain.FtOrderDao; /** @@ -11,4 +12,5 @@ import com.ruoyi.system.fantang.domain.FtOrderDao; */ public interface IFtOrderDaoService extends IService { + AjaxResult getOrderOfToday(Long staffId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffDemandDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffDemandDaoService.java index 3e4fa3ddc..9e46b453f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffDemandDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffDemandDaoService.java @@ -1,14 +1,18 @@ package com.ruoyi.system.fantang.service; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.fantang.domain.FtStaffDemandDao; import com.baomidou.mybatisplus.extension.service.IService; /** * 员工报餐Service接口 * - * @author ft + * @author 陈智兴 * @date 2020-12-07 */ public interface IFtStaffDemandDaoService extends IService { + AjaxResult getConfiguration(Long staffId); + + AjaxResult setDemandMode(Long id, Boolean demandModeFlag); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffInfoDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffInfoDaoService.java index f2b47f49a..2720880d5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffInfoDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtStaffInfoDaoService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.fantang.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.fantang.domain.FtStaffInfoDao; import java.util.List; @@ -15,4 +16,7 @@ public interface IFtStaffInfoDaoService extends IService { List selectStaffInfoWithDepart(); + AjaxResult login(String tel, String password); + + AjaxResult logout(Long staffId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtOrderDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtOrderDaoServiceImpl.java index b1159e872..32b5df66f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtOrderDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtOrderDaoServiceImpl.java @@ -1,11 +1,17 @@ package com.ruoyi.system.fantang.service.impl; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.fantang.domain.FtOrderDao; import com.ruoyi.system.fantang.mapper.FtOrderDaoMapper; import com.ruoyi.system.fantang.service.IFtOrderDaoService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; + /** * 订单管理Service业务层处理 * @@ -15,4 +21,17 @@ import org.springframework.stereotype.Service; @Service public class FtOrderDaoServiceImpl extends ServiceImpl implements IFtOrderDaoService { + public void GenerateStaffTomorrowOrder() { + this.baseMapper.GenerateStaffTomorrowOrder(); + + } + + @Override + public AjaxResult getOrderOfToday(Long staffId) { + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("staff_id", staffId); + wrapper.between("order_date", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date())); + return AjaxResult.success(this.baseMapper.selectList(wrapper)); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffDemandDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffDemandDaoServiceImpl.java index 8162df1ce..22140d422 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffDemandDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffDemandDaoServiceImpl.java @@ -1,5 +1,7 @@ package com.ruoyi.system.fantang.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.core.domain.AjaxResult; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.fantang.mapper.FtStaffDemandDaoMapper; @@ -15,4 +17,25 @@ import com.ruoyi.system.fantang.service.IFtStaffDemandDaoService; @Service public class FtStaffDemandDaoServiceImpl extends ServiceImpl implements IFtStaffDemandDaoService { + @Override + public AjaxResult getConfiguration(Long staffId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("staff_id", staffId); + FtStaffDemandDao dao = this.baseMapper.selectOne(wrapper); + if (dao == null) + return AjaxResult.error("获取个人配置信息错误"); + return AjaxResult.success(dao); + } + + @Override + public AjaxResult setDemandMode(Long id, Boolean demandMode) { + FtStaffDemandDao dao = new FtStaffDemandDao(); + dao.setId(id); + dao.setDemandMode(demandMode); + int ret = this.baseMapper.updateById(dao); + if (ret == 0) + return AjaxResult.error("更新订餐状态失败"); + return AjaxResult.success(); + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffInfoDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffInfoDaoServiceImpl.java index a86bd22f4..6a4f782a4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffInfoDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtStaffInfoDaoServiceImpl.java @@ -1,6 +1,9 @@ package com.ruoyi.system.fantang.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.fantang.domain.FtStaffInfoDao; import com.ruoyi.system.fantang.mapper.FtStaffInfoDaoMapper; import com.ruoyi.system.fantang.service.IFtStaffInfoDaoService; @@ -22,4 +25,30 @@ public class FtStaffInfoDaoServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("tel", tel); + queryWrapper.eq("password", password); + FtStaffInfoDao dao = this.baseMapper.selectOne(queryWrapper); + if (dao == null) + return AjaxResult.error(-1, "查无记录"); + dao.setLoginFlag(true); + dao.setToken(IdUtils.fastUUID()); + this.baseMapper.updateById(dao); + return AjaxResult.success(dao); + } + + @Override + public AjaxResult logout(Long staffId) { + FtStaffInfoDao dao = new FtStaffInfoDao(); + dao.setStaffId(staffId); + dao.setLoginFlag(false); + dao.setToken(""); + int ret = this.baseMapper.updateById(dao); + if (ret == 0) + return AjaxResult.error("更新退出状态失败"); + return AjaxResult.success(dao); + } } diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index cb10a631e..f89e8e5b8 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,8 +1,8 @@ { "name": "ruoyi", "version": "3.3.0", - "description": "若依管理系统", - "author": "若依", + "description": "食堂管理系统", + "author": "食堂", "license": "MIT", "scripts": { "dev": "vue-cli-service serve",