From d0191ba05d77214054c4cfa75d55263b8eccdcc3 Mon Sep 17 00:00:00 2001 From: ryoeiken <754264374@qq.com> Date: Wed, 13 Jan 2021 15:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=BA=E8=84=B8=E8=AF=86=E5=88=AB=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=8C=E5=AE=8C=E5=96=84=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E6=A0=B8=E9=94=80=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fantang/controller/ClientController.java | 57 ++++-------------- .../controller/FtConfigDaoController.java | 20 ++++++- .../fantang/service/IFtConfigDaoService.java | 6 +- .../service/impl/FtConfigDaoServiceImpl.java | 33 +++++++++- ruoyi-ui/src/api/fantang/fantangConfig.js | 8 +++ .../src/views/fantang/fantangConfig/index.vue | 60 +++++++++++++++---- 6 files changed, 121 insertions(+), 63 deletions(-) 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 821046d77..522e6fe65 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 @@ -559,20 +559,7 @@ public class ClientController extends BaseController { System.out.println("face device heartbeat....."); System.out.println(request); return "ok"; -// StringBuffer data = new StringBuffer(); -// String line = null; -// BufferedReader reader = null; -// try { -// reader = request.getReader(); -// while (null != (line = reader.readLine())) { -// data.append(line); -// } -// JSONObject jsonObject = JSONObject.parseObject(data.toString()); -// System.out.println(jsonObject); -// } catch (IOException e) { -// } finally { -// } -// return data.toString(); + } @@ -592,6 +579,13 @@ public class ClientController extends BaseController { Integer personId = info.getInteger("PersonID"); Long deviceId = info.getLong("DeviceID"); + // 判断该设备是否有效 + Boolean isEffective = iFtConfigDaoService.isDeviceEffective(deviceId); + if (!isEffective) { + log.info("设备有效性 : {} ", "该人脸识别设备已失效"); + return "该人脸识别设备已失效"; + } + // 是否有该员工 FtStaffInfoDao staffInfoDao = staffInfoDaoService.inStaff(personId); @@ -616,48 +610,17 @@ public class ClientController extends BaseController { default: throw new IllegalStateException("Unexpected value: " + dinnerType); } - log.info("人脸核销结果: {}", message); + log.info("人脸核销结果 : {}", message); return message; } else { // 如果该人脸id没有对应的员工,则记录找日志中 - + log.info("员工查询 : {}", "没有找到该员工"); return "没有找到该员工"; } - - // 跟进人脸id信息,查找该id对应的员工id的当餐订单 - -// StringBuffer data = new StringBuffer(); -// -// try { -// // 从请求头中获取数据 -// BufferedReader reader = request.getReader(); -// String line = null; -// while (null != (line = reader.readLine())) -// data.append(line); -// JSONObject jsonObject = JSONObject.parseObject(data.toString()); -// System.out.println(jsonObject); -// -// HashMap map = new HashMap<>(); -// map.put("flag", 0); -// List dao = faceEventService.selectByMap(map); -// if (dao.size() == 0) -// { -// JSONObject infoObject = JSONObject.parseObject(jsonObject.getString("info")); -// FtFaceEventDao eventDao = new FtFaceEventDao(); -// -// eventDao.setDeviceId(infoObject.getString("DeviceID")); -// eventDao.setPersonId(infoObject.getString("PersonID")); -//// faceEventService.insert(eventDao); -// } -// else { -// } -// } catch (IOException e) { -// } finally { -// } } /** 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 41cc43e1a..f9ad20eb0 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 @@ -155,7 +155,23 @@ public class FtConfigDaoController extends BaseController { ftConfigDao.setConfigValue(configValue.toString()); iFtConfigDaoService.update(ftConfigDao, wrapper); - System.out.println(params); - return null; + return AjaxResult.success("已修改"); + } + + /** + * 修改人脸识别设备信息 + */ + @PostMapping("/updateFaceDevice") + public AjaxResult updateFaceDevice(@RequestBody JSONObject params) { + + String deviceId = params.getString("deviceId"); + Long deviceConfigId = params.getLong("deviceConfigId"); + iFtConfigDaoService.updateConfigValue(deviceConfigId, deviceId); + + String deviceFlag = params.getString("deviceFlag"); + Long flagConfigId = params.getLong("flagConfigId"); + iFtConfigDaoService.updateConfigValue(flagConfigId, deviceFlag); + + return AjaxResult.success("已修改"); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtConfigDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtConfigDaoService.java index 9a5ee18db..6e2f1f255 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtConfigDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtConfigDaoService.java @@ -1,7 +1,7 @@ package com.ruoyi.system.fantang.service; -import com.ruoyi.system.fantang.domain.FtConfigDao; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.fantang.domain.FtConfigDao; import java.util.Map; @@ -14,4 +14,8 @@ import java.util.Map; public interface IFtConfigDaoService extends IService { Map getDinnerTimeSetting(); + + void updateConfigValue(Long id, String value); + + Boolean isDeviceEffective(Long deviceId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtConfigDaoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtConfigDaoServiceImpl.java index 125a74c81..a7efa32fb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtConfigDaoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/impl/FtConfigDaoServiceImpl.java @@ -1,14 +1,13 @@ package com.ruoyi.system.fantang.service.impl; 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.FtConfigDao; import com.ruoyi.system.fantang.mapper.FtConfigDaoMapper; import com.ruoyi.system.fantang.service.IFtConfigDaoService; import org.springframework.stereotype.Service; -import java.lang.reflect.Array; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -38,4 +37,34 @@ public class FtConfigDaoServiceImpl extends ServiceImpl wrapper = new UpdateWrapper<>(); + wrapper.eq("id", id); + FtConfigDao ftConfigDao = new FtConfigDao(); + ftConfigDao.setConfigValue(value); + this.baseMapper.update(ftConfigDao, wrapper); + } + + @Override + public Boolean isDeviceEffective(Long deviceId) { + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("config_key", "device_id"); + wrapper.eq("config_value", deviceId.toString()); + FtConfigDao ftConfigDao = this.baseMapper.selectOne(wrapper); + + if (ftConfigDao == null) { + return false; + + } else { + QueryWrapper flagWrapper = new QueryWrapper<>(); + flagWrapper.eq("config_key", "device_flag"); + FtConfigDao flagDao = this.baseMapper.selectOne(flagWrapper); + + return !"0".equals(flagDao.getConfigValue()); + } + } } diff --git a/ruoyi-ui/src/api/fantang/fantangConfig.js b/ruoyi-ui/src/api/fantang/fantangConfig.js index f08aa4d77..68abb457c 100644 --- a/ruoyi-ui/src/api/fantang/fantangConfig.js +++ b/ruoyi-ui/src/api/fantang/fantangConfig.js @@ -34,6 +34,14 @@ export function updateDinnerTime(data) { }) } +export function updateFaceDevice(data) { + return request({ + url: '/fantang/fantangConfig/updateFaceDevice', + method: 'post', + data: data + }) +} + // 修改饭堂参数 export function updateFantangConfig(data) { return request({ diff --git a/ruoyi-ui/src/views/fantang/fantangConfig/index.vue b/ruoyi-ui/src/views/fantang/fantangConfig/index.vue index dc73bace2..547cbdc13 100644 --- a/ruoyi-ui/src/views/fantang/fantangConfig/index.vue +++ b/ruoyi-ui/src/views/fantang/fantangConfig/index.vue @@ -11,7 +11,7 @@ - + - + - + + 提交 - - 提交 - + + + + + + + + + + + + 提交 @@ -71,23 +85,37 @@ import { updateDinnerTime, updateFantangConfig } from "@/api/fantang/fantangConfig"; +import {updateFaceDevice} from "../../../api/fantang/fantangConfig"; export default { name: "FantangConfig", components: {}, data() { return { + deviceFlagOptions: [{ + value: '1', + label: '开启' + }, { + value: '0', + label: '关闭' + }], timeArr: [], formInline: { configValue: null, id: null, }, dinnerForm: { - breakfast: [new Date('2016-9-10 8:41'), new Date(2016, 9, 10, 9, 40)], + breakfast: [], lunch: [], dinner: [], id: 7, }, + faceDeviceForm: { + deviceId: null, + deviceConfigId: 11, + deviceFlag: null, + flagConfigId: 12, + }, }; }, @@ -101,12 +129,12 @@ export default { 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 = [new Date(2016, 9, 1, this.timeArr[0].split(':')[0], this.timeArr[0].split(':')[1]), new Date(2016, 9, 1, this.timeArr[1].split(':')[0], this.timeArr[1].split(':')[1])]; this.dinnerForm.lunch = [new Date(2016, 9, 1, this.timeArr[2].split(':')[0], this.timeArr[2].split(':')[1]), new Date(2016, 9, 1, this.timeArr[3].split(':')[0], this.timeArr[3].split(':')[1])]; this.dinnerForm.dinner = [new Date(2016, 9, 1, this.timeArr[4].split(':')[0], this.timeArr[4].split(':')[1]), new Date(2016, 9, 1, this.timeArr[5].split(':')[0], this.timeArr[5].split(':')[1])]; + this.faceDeviceForm.deviceId = response.rows[10].configValue; + this.faceDeviceForm.deviceFlag = response.rows[11].configValue; }); }, // 取消按钮 @@ -158,9 +186,20 @@ export default { }); }, + // 人脸识别设备 + submitFaceDeviceForm() { + if (this.faceDeviceForm.deviceId != null && this.faceDeviceForm.deviceId !== '' + && this.faceDeviceForm.deviceFlag != null && this.faceDeviceForm.deviceFlag !== '') { + console.log(this.faceDeviceForm) + updateFaceDevice(this.faceDeviceForm).then(response => { + this.msgSuccess("修改成功") + }) + + } + }, + // 用餐时间提交 submitDinnerForm() { - console.log(this.dinnerForm) updateDinnerTime(this.dinnerForm).then(response => { this.msgSuccess("修改成功") }) @@ -168,7 +207,6 @@ export default { // 补贴金额 onSubmit() { - console.log(this.formInline) if (this.formInline.configValue != null || this.formInline.configValue !== '') updateFantangConfig(this.formInline).then(response => { this.msgSuccess("修改成功")