消费改造-餐盘监测设备

This commit is contained in:
zc
2026-02-09 10:41:35 +08:00
parent 0e1a3404dc
commit 67d29ca51c
8 changed files with 417 additions and 47 deletions

View File

@@ -21,6 +21,7 @@ import io.renren.util.HttpUtil;
import io.renren.util.WXPayUtil; import io.renren.util.WXPayUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -36,6 +37,7 @@ import java.util.*;
@RestController @RestController
@RequestMapping("/request") @RequestMapping("/request")
@Api(tags="消费机接口") @Api(tags="消费机接口")
@Slf4j
public class CardController { public class CardController {
@Autowired @Autowired
@@ -59,6 +61,9 @@ public class CardController {
@Autowired @Autowired
private IConsumeTimeIntervalService consumeTimeIntervalService; private IConsumeTimeIntervalService consumeTimeIntervalService;
@Autowired
private ISysConfigService configService;
@Autowired @Autowired
private IConsumePeopleDayService peopleDayService; private IConsumePeopleDayService peopleDayService;
@@ -178,7 +183,7 @@ public class CardController {
} }
String cards=gson.toJson(card); String cards=gson.toJson(card);
api=JSONObject.parseObject(cards); api=JSONObject.parseObject(cards);
System.out.println("设备主动请求获取参数==="+api); log.info("设备主动请求获取参数==={}", api.toJSONString());
return api; return api;
} }
//设备版本升级后进行软件推送 //设备版本升级后进行软件推送
@@ -294,7 +299,7 @@ public class CardController {
if(consumeRecords!=null){ if(consumeRecords!=null){
break; break;
}*/ }*/
System.out.println("获取信息===="+consumeRecord.getOutTradeId()); log.info("获取信息===={}", consumeRecord.getOutTradeId());
if(StringUtils.isEmpty(consumeRecord.getOutTradeId())){ if(StringUtils.isEmpty(consumeRecord.getOutTradeId())){
}else{ }else{
@@ -602,7 +607,7 @@ public class CardController {
@RequestMapping(value = "adddish",method = RequestMethod.POST) @RequestMapping(value = "adddish",method = RequestMethod.POST)
@ApiOperation("设备上传发布菜品结果") @ApiOperation("设备上传发布菜品结果")
public void adddish(@RequestBody JSONObject json){ public void adddish(@RequestBody JSONObject json){
System.out.println("设备上传发布菜品结果========="+json); log.info("设备上传发布菜品结果========={}", json.toJSONString());
//如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF //如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF
@@ -615,7 +620,7 @@ public class CardController {
@ApiOperation("实时接口") @ApiOperation("实时接口")
public JSONObject real(@RequestBody JSONObject json) { public JSONObject real(@RequestBody JSONObject json) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
System.out.println("实时接口=========" + json); log.info("实时接口========={}", json.toJSONString());
//如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF //如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF
String api = json.getString("api"); String api = json.getString("api");
//判断是否是人员查询接口 //判断是否是人员查询接口
@@ -766,6 +771,33 @@ public class CardController {
result.put("result", results); result.put("result", results);
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
JSONArray msg = new JSONArray(); 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")+""); ConsumeRecord consumeRecords=consumeRecordService.selectConsumeRecordByOutTradeId(params.get("trade_id")+"");
if(consumeRecords!=null){ if(consumeRecords!=null){
@@ -787,7 +819,7 @@ public class CardController {
msg.add(obj); msg.add(obj);
result.put("msg", msg); result.put("msg", msg);
result.put("result_code", "1"); result.put("result_code", "1");
System.out.println("请求当天的消费信息1==="+result); log.info("请求当天的消费信息1==="+result);
return result; return result;
} }
if (twoConsume(people)) { 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 consumeRecord = new ConsumeRecord();
consumeRecord.setEmpId(people.getGh()); consumeRecord.setEmpId(people.getGh());
@@ -997,7 +1029,7 @@ public class CardController {
consumeRecordService.insertConsumeRecord(consumeRecord); consumeRecordService.insertConsumeRecord(consumeRecord);
} }
result.put("msg", msg); result.put("msg", msg);
System.out.println("系统发送数据====" + result); log.info("系统发送数据===={}", result.toJSONString());
return result; return result;
} }
if ("recordquery".equals(api)) {//查询记录recordquery应答 if ("recordquery".equals(api)) {//查询记录recordquery应答
@@ -1126,7 +1158,7 @@ public class CardController {
msg.add(obj); msg.add(obj);
} }
result.put("msg", msg); result.put("msg", msg);
System.out.println("发送的json====" + result); log.info("发送的json===={}", result.toJSONString());
return result; return result;
} }
if ("sumonline".equals(api)) {//汇总sumonline应答 if ("sumonline".equals(api)) {//汇总sumonline应答
@@ -1236,21 +1268,6 @@ public class CardController {
public JSONObject queryPeopleDay(Map<String, Object> paramMap) { public JSONObject queryPeopleDay(Map<String, Object> paramMap) {
JSONObject obj = new JSONObject(); 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(); ConsumePeopleDay consumePeopleDay = new ConsumePeopleDay();
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try { try {
@@ -1364,7 +1381,7 @@ public class CardController {
@RequestMapping(value = "selfserver/queryRecord",method = RequestMethod.POST) @RequestMapping(value = "selfserver/queryRecord",method = RequestMethod.POST)
@ApiOperation("自助机自助查询界面") @ApiOperation("自助机自助查询界面")
public JSONObject queryRecord(@RequestBody JSONObject json){ public JSONObject queryRecord(@RequestBody JSONObject json){
System.out.println("查询人员的消费充值记录========="+json); log.info("查询人员的消费充值记录========={}", json.toJSONString());
JSONObject result=new JSONObject(); JSONObject result=new JSONObject();
String id=json.get("account_id")+""; String id=json.get("account_id")+"";
result.put("state","0"); result.put("state","0");
@@ -1377,7 +1394,7 @@ public class CardController {
@RequestMapping(value = "selfserver/queryRechargeRecord",method = RequestMethod.POST) @RequestMapping(value = "selfserver/queryRechargeRecord",method = RequestMethod.POST)
@ApiOperation("自助机查询待退款订单记录") @ApiOperation("自助机查询待退款订单记录")
public JSONObject queryRechargeRecord(@RequestBody JSONObject json){ 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"} //{"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")+""; String id=json.get("account_id")+"";
SysPeople people=peopleService.selectSysPeopleById(Long.parseLong(id)); SysPeople people=peopleService.selectSysPeopleById(Long.parseLong(id));
@@ -1395,7 +1412,7 @@ public class CardController {
@RequestMapping(value = "selfserver/rechargeRefund",method = RequestMethod.POST) @RequestMapping(value = "selfserver/rechargeRefund",method = RequestMethod.POST)
@ApiOperation("自助机退款") @ApiOperation("自助机退款")
public void rechargeRefund(@RequestBody JSONObject json){ 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) @RequestMapping(value = "realpass", method = RequestMethod.POST)
@ApiOperation("人脸设备实时控制") @ApiOperation("人脸设备实时控制")
public JSONObject realpass(@RequestBody JSONObject json) { public JSONObject realpass(@RequestBody JSONObject json) {
System.out.println("人脸设备实时控制=========" + json); log.info("人脸设备实时控制========={}", json.toJSONString());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params")));
String account_id = params.getString("pay_code"); String account_id = params.getString("pay_code");
@@ -1573,9 +1590,9 @@ public class CardController {
request.setBizContent(bizContent.toString()); request.setBizContent(bizContent.toString());
AlipayTradePayResponse response = alipayClient.execute(request); AlipayTradePayResponse response = alipayClient.execute(request);
if(response.isSuccess()){ if(response.isSuccess()){
System.out.println("调用成功"); log.info("调用成功");
} else { } else {
System.out.println("调用失败"); log.info("调用失败");
} }
} }
@@ -1605,7 +1622,7 @@ public class CardController {
public JSONObject takephoto(@RequestBody JSONObject json){ public JSONObject takephoto(@RequestBody JSONObject json){
JSONObject result=new JSONObject(); JSONObject result=new JSONObject();
//如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF //如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF
System.out.println("设备上传自助拍照结果========="+json); log.info("设备上传自助拍照结果========={}", json.toJSONString());
String account_id=json.get("account_id")+""; String account_id=json.get("account_id")+"";
String photo=json.get("photo")+""; String photo=json.get("photo")+"";
Map<String, Object> paramMap=new HashMap<>(); Map<String, Object> paramMap=new HashMap<>();

View File

@@ -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<SysConfig> selectConfigList(SysConfig config);
}

View File

@@ -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();
}
}

View File

@@ -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<SysConfig> selectConfigList(SysConfig config);
}

View File

@@ -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<SysConfig> selectConfigList(SysConfig config)
{
return configMapper.selectConfigList(config);
}
/**
* 设置cache key
*
* @param configKey 参数键
* @return 缓存键key
*/
private String getCacheKey(String configKey)
{
return "sys_config:" + configKey;
}
}

View File

@@ -31,3 +31,16 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true 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 # 连接池中的最小空闲连接

View File

@@ -24,8 +24,8 @@ knife4j:
spring: spring:
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles:
active: prod # active: prod
# active: dev active: dev
messages: messages:
encoding: UTF-8 encoding: UTF-8
basename: i18n/messages basename: i18n/messages
@@ -41,22 +41,22 @@ spring:
max-file-size: 100MB max-file-size: 100MB
max-request-size: 100MB max-request-size: 100MB
enabled: true enabled: true
redis: # redis:
database: 0 # database: 0
host: 127.0.0.1 # host: 127.0.0.1
port: 6379
password: # 密码(默认为空)
# host: 192.168.2.30
# password: redis2025
# database: 5
# port: 6379 # port: 6379
timeout: 6000ms # 连接超时时长(毫秒 # password: # 密码(默认为空
jedis: ## host: 192.168.2.30
pool: ## password: redis2025
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) ## database: 5
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) ## port: 6379
max-idle: 10 # 连接池中的最大空闲连接 # timeout: 6000ms # 连接超时时长(毫秒)
min-idle: 5 # 连接池中的最小空闲连接 # jedis:
# pool:
# max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
# max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# max-idle: 10 # 连接池中的最大空闲连接
# min-idle: 5 # 连接池中的最小空闲连接
renren: renren:
redis: redis:

View File

@@ -0,0 +1,67 @@
<?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">
<mapper namespace="io.renren.dao.SysConfigMapper">
<resultMap type="SysConfig" id="SysConfigResult">
<id property="configId" column="config_id" />
<result property="configName" column="config_name" />
<result property="configKey" column="config_key" />
<result property="configValue" column="config_value" />
<result property="configType" column="config_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config
</sql>
<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
<if test="configId !=null">
and config_id = #{configId}
</if>
<if test="configKey !=null and configKey != ''">
and config_key = #{configKey}
</if>
</where>
</sql>
<select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<where>
<if test="configName != null and configName != ''">
AND config_name like concat('%', #{configName}, '%')
</if>
<if test="configType != null and configType != ''">
AND config_type = #{configType}
</if>
<if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_id = #{configId}
</select>
</mapper>