From 6cb636ca402ddf3bf6dbc717ad85aa9518bb6c16 Mon Sep 17 00:00:00 2001 From: ryoeiken <754264374@qq.com> Date: Thu, 31 Dec 2020 14:14:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FtConfigDaoController.java | 132 ++++++++++++------ ruoyi-ui/src/api/fantang/fantangConfig.js | 10 +- .../src/views/fantang/fantangConfig/index.vue | 66 +++++++-- 3 files changed, 150 insertions(+), 58 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtConfigDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtConfigDaoController.java index 2d8d92417..41cc43e1a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtConfigDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtConfigDaoController.java @@ -1,41 +1,38 @@ 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 java.util.List; -import java.util.Arrays; - +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ruoyi.common.utils.StringUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.fantang.domain.FtConfigDao; import com.ruoyi.system.fantang.service.IFtConfigDaoService; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.common.core.page.TableDataInfo; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; /** * 饭堂参数Controller - * + * * @author ft * @date 2020-12-07 */ @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController -@RequestMapping("/fantang/fantangConfig" ) +@RequestMapping("/fantang/fantangConfig") public class FtConfigDaoController extends BaseController { private final IFtConfigDaoService iFtConfigDaoService; @@ -45,21 +42,20 @@ public class FtConfigDaoController extends BaseController { */ @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:list')") @GetMapping("/list") - public TableDataInfo list(FtConfigDao ftConfigDao) - { + public TableDataInfo list(FtConfigDao ftConfigDao) { startPage(); LambdaQueryWrapper lqw = Wrappers.lambdaQuery(ftConfigDao); - if (ftConfigDao.getCorpId() != null){ - lqw.eq(FtConfigDao::getCorpId ,ftConfigDao.getCorpId()); + if (ftConfigDao.getCorpId() != null) { + lqw.eq(FtConfigDao::getCorpId, ftConfigDao.getCorpId()); } - if (StringUtils.isNotBlank(ftConfigDao.getConfigKey())){ - lqw.eq(FtConfigDao::getConfigKey ,ftConfigDao.getConfigKey()); + if (StringUtils.isNotBlank(ftConfigDao.getConfigKey())) { + lqw.eq(FtConfigDao::getConfigKey, ftConfigDao.getConfigKey()); } - if (StringUtils.isNotBlank(ftConfigDao.getConfigValue())){ - lqw.eq(FtConfigDao::getConfigValue ,ftConfigDao.getConfigValue()); + if (StringUtils.isNotBlank(ftConfigDao.getConfigValue())) { + lqw.eq(FtConfigDao::getConfigValue, ftConfigDao.getConfigValue()); } - if (ftConfigDao.getFlag() != null){ - lqw.eq(FtConfigDao::getFlag ,ftConfigDao.getFlag()); + if (ftConfigDao.getFlag() != null) { + lqw.eq(FtConfigDao::getFlag, ftConfigDao.getFlag()); } List list = iFtConfigDaoService.list(lqw); return getDataTable(list); @@ -68,30 +64,30 @@ public class FtConfigDaoController extends BaseController { /** * 导出饭堂参数列表 */ - @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:export')" ) - @Log(title = "饭堂参数" , businessType = BusinessType.EXPORT) - @GetMapping("/export" ) + @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:export')") + @Log(title = "饭堂参数", businessType = BusinessType.EXPORT) + @GetMapping("/export") public AjaxResult export(FtConfigDao ftConfigDao) { LambdaQueryWrapper lqw = new LambdaQueryWrapper(ftConfigDao); List list = iFtConfigDaoService.list(lqw); - ExcelUtil util = new ExcelUtil(FtConfigDao. class); - return util.exportExcel(list, "fantangConfig" ); + ExcelUtil util = new ExcelUtil(FtConfigDao.class); + return util.exportExcel(list, "fantangConfig"); } /** * 获取饭堂参数详细信息 */ - @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:query')" ) - @GetMapping(value = "/{id}" ) - public AjaxResult getInfo(@PathVariable("id" ) Long id) { + @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(iFtConfigDaoService.getById(id)); } /** * 新增饭堂参数 */ - @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:add')" ) - @Log(title = "饭堂参数" , businessType = BusinessType.INSERT) + @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:add')") + @Log(title = "饭堂参数", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody FtConfigDao ftConfigDao) { return toAjax(iFtConfigDaoService.save(ftConfigDao) ? 1 : 0); @@ -100,8 +96,8 @@ public class FtConfigDaoController extends BaseController { /** * 修改饭堂参数 */ - @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:edit')" ) - @Log(title = "饭堂参数" , businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:edit')") + @Log(title = "饭堂参数", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody FtConfigDao ftConfigDao) { return toAjax(iFtConfigDaoService.updateById(ftConfigDao) ? 1 : 0); @@ -110,10 +106,56 @@ public class FtConfigDaoController extends BaseController { /** * 删除饭堂参数 */ - @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:remove')" ) - @Log(title = "饭堂参数" , businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}" ) + @PreAuthorize("@ss.hasPermi('fantang:fantangConfig:remove')") + @Log(title = "饭堂参数", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(iFtConfigDaoService.removeByIds(Arrays.asList(ids)) ? 1 : 0); } + + @PostMapping("/updateDinnerTime") + public AjaxResult updateDinnerTime(@RequestBody JSONObject params) { + + + StringBuilder configValue = new StringBuilder(); + + + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); + JSONArray breakfastJson = params.getJSONArray("breakfast"); + JSONArray lunchJson = params.getJSONArray("lunch"); + JSONArray dinnerJson = params.getJSONArray("dinner"); + + List breakfastTime = breakfastJson.toJavaList(Date.class); + for (Date date : breakfastTime) { + String time = sdf.format(date); + System.out.println(time); + configValue.append(time).append(","); + } + + List lunchTime = lunchJson.toJavaList(Date.class); + for (Date date : lunchTime) { + String time = sdf.format(date); + System.out.println(time); + configValue.append(time).append(","); + } + + List dinnerTime = dinnerJson.toJavaList(Date.class); + + for (int i = 0; i < dinnerTime.size(); i++) { + String time = sdf.format(dinnerTime.get(i)); + configValue.append(time); + if (i != dinnerTime.size() - 1) { + configValue.append(","); + } + } + + UpdateWrapper wrapper = new UpdateWrapper<>(); + wrapper.eq("id", params.getLong("id")); + FtConfigDao ftConfigDao = new FtConfigDao(); + ftConfigDao.setConfigValue(configValue.toString()); + + iFtConfigDaoService.update(ftConfigDao, wrapper); + System.out.println(params); + return null; + } } diff --git a/ruoyi-ui/src/api/fantang/fantangConfig.js b/ruoyi-ui/src/api/fantang/fantangConfig.js index bc1158e62..f08aa4d77 100644 --- a/ruoyi-ui/src/api/fantang/fantangConfig.js +++ b/ruoyi-ui/src/api/fantang/fantangConfig.js @@ -26,6 +26,14 @@ export function addFantangConfig(data) { }) } +export function updateDinnerTime(data) { + return request({ + url: '/fantang/fantangConfig/updateDinnerTime', + method: 'post', + data: data + }) +} + // 修改饭堂参数 export function updateFantangConfig(data) { return request({ @@ -50,4 +58,4 @@ export function exportFantangConfig(query) { method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/views/fantang/fantangConfig/index.vue b/ruoyi-ui/src/views/fantang/fantangConfig/index.vue index 8bc7f5abf..52d82241f 100644 --- a/ruoyi-ui/src/views/fantang/fantangConfig/index.vue +++ b/ruoyi-ui/src/views/fantang/fantangConfig/index.vue @@ -2,7 +2,7 @@
- + 提交 @@ -15,6 +15,8 @@ { - this.fantangConfigList = response.rows; - this.total = response.total; - this.loading = false; + listFantangConfig().then(response => { + this.formInline.configValue = response.rows[7].configValue + this.formInline.id = response.rows[7].id + console.log("数据库获取--------", response.rows[6].configValue.split(',')) + + this.timeArr = response.rows[6].configValue.split(',') + this.dinnerForm.breakfast[0] = new Date(2016, 9, 1, this.timeArr[0].split(':')[0], this.timeArr[0].split(':')[1]) + this.dinnerForm.breakfast[1] = new Date(2016, 9, 1, this.timeArr[1].split(':')[0], this.timeArr[1].split(':')[1]) + this.dinnerForm.lunch[0] = new Date(2016, 9, 1, this.timeArr[2].split(':')[0], this.timeArr[2].split(':')[1]) + this.dinnerForm.lunch[1] = new Date(2016, 9, 1, this.timeArr[3].split(':')[0], this.timeArr[3].split(':')[1]) + this.dinnerForm.dinner[0] = new Date(2016, 9, 1, this.timeArr[4].split(':')[0], this.timeArr[4].split(':')[1]) + this.dinnerForm.dinner[1] = new Date(2016, 9, 1, this.timeArr[5].split(':')[0], this.timeArr[5].split(':')[1]) }); }, // 取消按钮 @@ -148,14 +184,20 @@ export default { }, // 用餐时间提交 - submitDinnerForm(){ + submitDinnerForm() { console.log(this.dinnerForm) - + updateDinnerTime(this.dinnerForm).then(response => { + this.msgSuccess("修改成功") + }) }, // 补贴金额 - onSubmit(){ + onSubmit() { console.log(this.formInline) + if (this.formInline.configValue != null || this.formInline.configValue !== '') + updateFantangConfig(this.formInline).then(response => { + this.msgSuccess("修改成功") + }) }, /** 提交按钮 */