From 67d29ca51c4e26f3fe84511f2a596177df022360 Mon Sep 17 00:00:00 2001 From: zc Date: Mon, 9 Feb 2026 10:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E6=94=B9=E9=80=A0-=E9=A4=90?= =?UTF-8?q?=E7=9B=98=E7=9B=91=E6=B5=8B=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/renren/controller/CardController.java | 77 ++++++++----- .../java/io/renren/dao/SysConfigMapper.java | 41 +++++++ .../main/java/io/renren/entity/SysConfig.java | 104 ++++++++++++++++++ .../io/renren/service/ISysConfigService.java | 38 +++++++ .../service/impl/SysConfigServiceImpl.java | 90 +++++++++++++++ .../src/main/resources/application-dev.yml | 13 +++ renren-api/src/main/resources/application.yml | 34 +++--- .../main/resources/mapper/SysConfigMapper.xml | 67 +++++++++++ 8 files changed, 417 insertions(+), 47 deletions(-) create mode 100644 renren-api/src/main/java/io/renren/dao/SysConfigMapper.java create mode 100644 renren-api/src/main/java/io/renren/entity/SysConfig.java create mode 100644 renren-api/src/main/java/io/renren/service/ISysConfigService.java create mode 100644 renren-api/src/main/java/io/renren/service/impl/SysConfigServiceImpl.java create mode 100644 renren-api/src/main/resources/mapper/SysConfigMapper.xml diff --git a/renren-api/src/main/java/io/renren/controller/CardController.java b/renren-api/src/main/java/io/renren/controller/CardController.java index 3b24ba5..cbff308 100644 --- a/renren-api/src/main/java/io/renren/controller/CardController.java +++ b/renren-api/src/main/java/io/renren/controller/CardController.java @@ -21,6 +21,7 @@ import io.renren.util.HttpUtil; import io.renren.util.WXPayUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -36,6 +37,7 @@ import java.util.*; @RestController @RequestMapping("/request") @Api(tags="消费机接口") +@Slf4j public class CardController { @Autowired @@ -59,6 +61,9 @@ public class CardController { @Autowired private IConsumeTimeIntervalService consumeTimeIntervalService; + @Autowired + private ISysConfigService configService; + @Autowired private IConsumePeopleDayService peopleDayService; @@ -178,7 +183,7 @@ public class CardController { } String cards=gson.toJson(card); api=JSONObject.parseObject(cards); - System.out.println("设备主动请求获取参数==="+api); + log.info("设备主动请求获取参数==={}", api.toJSONString()); return api; } //设备版本升级后进行软件推送 @@ -294,7 +299,7 @@ public class CardController { if(consumeRecords!=null){ break; }*/ - System.out.println("获取信息===="+consumeRecord.getOutTradeId()); + log.info("获取信息===={}", consumeRecord.getOutTradeId()); if(StringUtils.isEmpty(consumeRecord.getOutTradeId())){ }else{ @@ -602,7 +607,7 @@ public class CardController { @RequestMapping(value = "adddish",method = RequestMethod.POST) @ApiOperation("设备上传发布菜品结果") public void adddish(@RequestBody JSONObject json){ - System.out.println("设备上传发布菜品结果========="+json); + log.info("设备上传发布菜品结果========={}", json.toJSONString()); //如果有记录时则要处理记录后再应答,保存后的id回传给设备,方便设备对记录作标志 cardpwd FFFFFFFFFFFF @@ -615,7 +620,7 @@ public class CardController { @ApiOperation("实时接口") public JSONObject real(@RequestBody JSONObject json) { JSONObject result = new JSONObject(); - System.out.println("实时接口=========" + json); + log.info("实时接口========={}", json.toJSONString()); //如果有记录时则要处理记录后再应答,保存后的id回传给设备,方便设备对记录作标志 cardpwd FFFFFFFFFFFF String api = json.getString("api"); //判断是否是人员查询接口 @@ -766,6 +771,33 @@ public class CardController { result.put("result", results); DecimalFormat df = new DecimalFormat("0.00"); JSONArray msg = new JSONArray(); + //查询 + String cloud = configService.selectConfigByKey("sys.xfcpj.enable"); + if (StrUtil.equals("true", cloud) && (StrUtil.equals("8", devId) || StrUtil.equals("9", devId))) { + Object data = redisUtils.get("xf:heartbeat:" + devId); + log.info("出盘机查询缓存信息:{}", data); + if (ObjectUtil.isNull(data)) { + result.put("tts", "网络异常"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "网络异常"); + msg.add(obj1); + result.put("msg", msg); + result.put("result_code", "1"); + log.info("餐盘机未查询到缓存信息:{}",result.toJSONString()); + return result; + } + if (StrUtil.equals("0000", data.toString())) { + result.put("tts", "请添加餐盘"); + JSONObject obj1 = new JSONObject(); + obj1.put("line", "请添加餐盘"); + msg.add(obj1); + result.put("msg", msg); + result.put("result_code", "1"); + log.info("餐盘机监测到无餐盘:{}",result.toJSONString()); + return result; + } + } + /* //判断是否是同一订单,若是同一订单就不扣钱 ConsumeRecord consumeRecords=consumeRecordService.selectConsumeRecordByOutTradeId(params.get("trade_id")+""); if(consumeRecords!=null){ @@ -787,7 +819,7 @@ public class CardController { msg.add(obj); result.put("msg", msg); result.put("result_code", "1"); - System.out.println("请求当天的消费信息1==="+result); + log.info("请求当天的消费信息1==="+result); return result; } if (twoConsume(people)) { @@ -839,7 +871,7 @@ public class CardController { } } } - System.out.println("result1===" + result); + log.info("result1==={}", result.toJSONString()); //保存消费记录 ConsumeRecord consumeRecord = new ConsumeRecord(); consumeRecord.setEmpId(people.getGh()); @@ -997,7 +1029,7 @@ public class CardController { consumeRecordService.insertConsumeRecord(consumeRecord); } result.put("msg", msg); - System.out.println("系统发送数据====" + result); + log.info("系统发送数据===={}", result.toJSONString()); return result; } if ("recordquery".equals(api)) {//查询记录recordquery应答 @@ -1126,7 +1158,7 @@ public class CardController { msg.add(obj); } result.put("msg", msg); - System.out.println("发送的json====" + result); + log.info("发送的json===={}", result.toJSONString()); return result; } if ("sumonline".equals(api)) {//汇总sumonline应答 @@ -1236,21 +1268,6 @@ public class CardController { public JSONObject queryPeopleDay(Map paramMap) { JSONObject obj = new JSONObject(); - String devId = (String) paramMap.get("dev_id"); - if (StrUtil.equals("8", devId) || StrUtil.equals("9", devId)) { - Object data = redisUtils.get("xf:heartbeat:" + paramMap.get("dev_id")); - if (ObjectUtil.isNull(data)) { - obj.put("code", "1"); - obj.put("msg", "网络异常"); - return obj; - } - if (StrUtil.equals("0000", data.toString())) { - obj.put("code", "1"); - obj.put("msg", "请添加餐盘"); - return obj; - } - } - ConsumePeopleDay consumePeopleDay = new ConsumePeopleDay(); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { @@ -1364,7 +1381,7 @@ public class CardController { @RequestMapping(value = "selfserver/queryRecord",method = RequestMethod.POST) @ApiOperation("自助机自助查询界面") public JSONObject queryRecord(@RequestBody JSONObject json){ - System.out.println("查询人员的消费充值记录========="+json); + log.info("查询人员的消费充值记录========={}", json.toJSONString()); JSONObject result=new JSONObject(); String id=json.get("account_id")+""; result.put("state","0"); @@ -1377,7 +1394,7 @@ public class CardController { @RequestMapping(value = "selfserver/queryRechargeRecord",method = RequestMethod.POST) @ApiOperation("自助机查询待退款订单记录") public JSONObject queryRechargeRecord(@RequestBody JSONObject json){ - System.out.println("查询待退款订单记录, 只能查询微信或支付宝的充值记录========="+json); + log.info("查询待退款订单记录, 只能查询微信或支付宝的充值记录========={}", json.toJSONString()); //{"transaction_id":"100","fireware":"XF108-Y-SV1.020240822","ip":"192.168.124.52","build_time":"2024-09-20 15-19-58","sign":"feddcdb6fcb522110ff748930160a550","version":"V1.0.3","mac":"E8519E98F18D","noncestr":"359ff14bd3ad4f78be564dee92a3d622","dev_id":"1","serialno":"99032CFCBDFFEF1A","account_id":"578173","total_amount":0,"refund_amount":0,"return_money":0,"model":"17","pay_type":0,"time":"1727166839717","customer":"385946"} String id=json.get("account_id")+""; SysPeople people=peopleService.selectSysPeopleById(Long.parseLong(id)); @@ -1395,7 +1412,7 @@ public class CardController { @RequestMapping(value = "selfserver/rechargeRefund",method = RequestMethod.POST) @ApiOperation("自助机退款") public void rechargeRefund(@RequestBody JSONObject json){ - System.out.println("退款========="+json); + log.info("退款========={}", json.toJSONString()); @@ -1406,7 +1423,7 @@ public class CardController { @RequestMapping(value = "realpass", method = RequestMethod.POST) @ApiOperation("人脸设备实时控制") public JSONObject realpass(@RequestBody JSONObject json) { - System.out.println("人脸设备实时控制=========" + json); + log.info("人脸设备实时控制========={}", json.toJSONString()); JSONObject result = new JSONObject(); JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); String account_id = params.getString("pay_code"); @@ -1573,9 +1590,9 @@ public class CardController { request.setBizContent(bizContent.toString()); AlipayTradePayResponse response = alipayClient.execute(request); if(response.isSuccess()){ - System.out.println("调用成功"); + log.info("调用成功"); } else { - System.out.println("调用失败"); + log.info("调用失败"); } } @@ -1605,7 +1622,7 @@ public class CardController { public JSONObject takephoto(@RequestBody JSONObject json){ JSONObject result=new JSONObject(); //如果有记录时则要处理记录后再应答,保存后的id回传给设备,方便设备对记录作标志 cardpwd FFFFFFFFFFFF - System.out.println("设备上传自助拍照结果========="+json); + log.info("设备上传自助拍照结果========={}", json.toJSONString()); String account_id=json.get("account_id")+""; String photo=json.get("photo")+""; Map paramMap=new HashMap<>(); diff --git a/renren-api/src/main/java/io/renren/dao/SysConfigMapper.java b/renren-api/src/main/java/io/renren/dao/SysConfigMapper.java new file mode 100644 index 0000000..ed5490e --- /dev/null +++ b/renren-api/src/main/java/io/renren/dao/SysConfigMapper.java @@ -0,0 +1,41 @@ +package io.renren.dao; + + +import io.renren.entity.SysConfig; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 参数配置 数据层 + * + * @author dcsoft + */ +@Mapper +public interface SysConfigMapper +{ + /** + * 查询参数配置信息 + * + * @param config 参数配置信息 + * @return 参数配置信息 + */ + public SysConfig selectConfig(SysConfig config); + + /** + * 通过ID查询配置 + * + * @param configId 参数ID + * @return 参数配置信息 + */ + public SysConfig selectConfigById(Long configId); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + +} diff --git a/renren-api/src/main/java/io/renren/entity/SysConfig.java b/renren-api/src/main/java/io/renren/entity/SysConfig.java new file mode 100644 index 0000000..c9cfdf3 --- /dev/null +++ b/renren-api/src/main/java/io/renren/entity/SysConfig.java @@ -0,0 +1,104 @@ +package io.renren.entity; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 参数配置表 sys_config + * + * @author dcsoft + */ +public class SysConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 参数主键 */ + private Long configId; + + /** 参数名称 */ + private String configName; + + /** 参数键名 */ + private String configKey; + + /** 参数键值 */ + private String configValue; + + /** 系统内置(Y是 N否) */ + private String configType; + + public Long getConfigId() + { + return configId; + } + + public void setConfigId(Long configId) + { + this.configId = configId; + } + + @NotBlank(message = "参数名称不能为空") + @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") + public String getConfigName() + { + return configName; + } + + public void setConfigName(String configName) + { + this.configName = configName; + } + + @NotBlank(message = "参数键名长度不能为空") + @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") + public String getConfigKey() + { + return configKey; + } + + public void setConfigKey(String configKey) + { + this.configKey = configKey; + } + + @NotBlank(message = "参数键值不能为空") + @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") + public String getConfigValue() + { + return configValue; + } + + public void setConfigValue(String configValue) + { + this.configValue = configValue; + } + + public String getConfigType() + { + return configType; + } + + public void setConfigType(String configType) + { + this.configType = configType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/renren-api/src/main/java/io/renren/service/ISysConfigService.java b/renren-api/src/main/java/io/renren/service/ISysConfigService.java new file mode 100644 index 0000000..3c17781 --- /dev/null +++ b/renren-api/src/main/java/io/renren/service/ISysConfigService.java @@ -0,0 +1,38 @@ +package io.renren.service; + +import io.renren.entity.SysConfig; + +import java.util.List; + +/** + * 参数配置 服务层 + * + * @author dcsoft + */ +public interface ISysConfigService { + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + public SysConfig selectConfigById(Long configId); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数键值 + */ + public String selectConfigByKey(String configKey); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + +} diff --git a/renren-api/src/main/java/io/renren/service/impl/SysConfigServiceImpl.java b/renren-api/src/main/java/io/renren/service/impl/SysConfigServiceImpl.java new file mode 100644 index 0000000..ac54e85 --- /dev/null +++ b/renren-api/src/main/java/io/renren/service/impl/SysConfigServiceImpl.java @@ -0,0 +1,90 @@ +package io.renren.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import io.renren.common.redis.RedisUtils; +import io.renren.dao.SysConfigMapper; +import io.renren.entity.SysConfig; +import io.renren.service.ISysConfigService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 参数配置 服务层实现 + * + * @author dcsoft + */ +@Service +public class SysConfigServiceImpl implements ISysConfigService +{ + @Autowired + private SysConfigMapper configMapper; + + @Autowired + private RedisUtils redisService; + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + @Override + public SysConfig selectConfigById(Long configId) + { + SysConfig config = new SysConfig(); + config.setConfigId(configId); + return configMapper.selectConfig(config); + } + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数key + * @return 参数键值 + */ + @Override + public String selectConfigByKey(String configKey) { + Object configValue = redisService.get(getCacheKey(configKey)); + if (ObjectUtil.isNotNull(configValue) && StrUtil.isNotEmpty(configValue.toString())) { + + return configValue.toString(); + } + SysConfig config = new SysConfig(); + config.setConfigKey(configKey); + SysConfig retConfig = configMapper.selectConfig(config); + if (ObjectUtil.isNotNull(retConfig)) { + redisService.set(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StringUtils.EMPTY; + } + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + @Override + public List selectConfigList(SysConfig config) + { + return configMapper.selectConfigList(config); + } + + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + private String getCacheKey(String configKey) + { + return "sys_config:" + configKey; + } + +} diff --git a/renren-api/src/main/resources/application-dev.yml b/renren-api/src/main/resources/application-dev.yml index 68b145e..7737177 100644 --- a/renren-api/src/main/resources/application-dev.yml +++ b/renren-api/src/main/resources/application-dev.yml @@ -31,3 +31,16 @@ spring: wall: config: multi-statement-allow: true + + redis: + host: 192.168.2.30 + password: redis2025 + database: 5 + port: 6379 + timeout: 6000ms # 连接超时时长(毫秒) + jedis: + pool: + max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) + max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-idle: 10 # 连接池中的最大空闲连接 + min-idle: 5 # 连接池中的最小空闲连接 \ No newline at end of file diff --git a/renren-api/src/main/resources/application.yml b/renren-api/src/main/resources/application.yml index d6f2e0a..686e8f5 100644 --- a/renren-api/src/main/resources/application.yml +++ b/renren-api/src/main/resources/application.yml @@ -24,8 +24,8 @@ knife4j: spring: # 环境 dev|test|prod profiles: - active: prod -# active: dev +# active: prod + active: dev messages: encoding: UTF-8 basename: i18n/messages @@ -41,22 +41,22 @@ spring: max-file-size: 100MB max-request-size: 100MB enabled: true - redis: - database: 0 - host: 127.0.0.1 - port: 6379 - password: # 密码(默认为空) -# host: 192.168.2.30 -# password: redis2025 -# database: 5 +# redis: +# database: 0 +# host: 127.0.0.1 # port: 6379 - timeout: 6000ms # 连接超时时长(毫秒) - jedis: - pool: - max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) - max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) - max-idle: 10 # 连接池中的最大空闲连接 - min-idle: 5 # 连接池中的最小空闲连接 +# password: # 密码(默认为空) +## host: 192.168.2.30 +## password: redis2025 +## database: 5 +## port: 6379 +# timeout: 6000ms # 连接超时时长(毫秒) +# jedis: +# pool: +# max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) +# max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) +# max-idle: 10 # 连接池中的最大空闲连接 +# min-idle: 5 # 连接池中的最小空闲连接 renren: redis: diff --git a/renren-api/src/main/resources/mapper/SysConfigMapper.xml b/renren-api/src/main/resources/mapper/SysConfigMapper.xml new file mode 100644 index 0000000..398a869 --- /dev/null +++ b/renren-api/src/main/resources/mapper/SysConfigMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark + from sys_config + + + + + + + and config_id = #{configId} + + + and config_key = #{configKey} + + + + + + + + + + +