Compare commits

6 Commits
master ... dev

Author SHA1 Message Date
zc
67d3a30584 消费改造-人员同步筛选 2026-06-05 17:22:41 +08:00
zc
2d77fb02f7 消费改造-人员同步筛选 2026-02-09 15:32:06 +08:00
zc
1d8f613999 消费改造-餐盘监测设备 2026-02-09 11:01:08 +08:00
zc
67d29ca51c 消费改造-餐盘监测设备 2026-02-09 10:41:35 +08:00
zc
0e1a3404dc 消费改造-餐盘监测设备 2026-02-06 15:46:59 +08:00
zc
8a51bd9ed7 优化 2026-02-06 15:20:25 +08:00
12 changed files with 1064 additions and 592 deletions

View File

@@ -1,5 +1,8 @@
package io.renren.controller; package io.renren.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayApiException;
@@ -18,13 +21,11 @@ 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;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.MessageDigest; import java.security.MessageDigest;
@@ -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;
@@ -93,6 +98,30 @@ public class CardController {
equipmentService.updateSysEquipment(e); equipmentService.updateSysEquipment(e);
} }
} }
Object queryperson = redisUtils.get("queryperson:" + json.getString("dev_id"));
if (ObjectUtil.isNotEmpty(queryperson)) {
String emp_id = queryperson.toString();
api.put("api","queryperson");
Long time = new Date().getTime() / 1000;
api.put("time", time);
String noncestr = UUID.randomUUID().toString();
api.put("noncestr",noncestr);
api.put("interval","10000");
String sign = EncodeByMD5(time + noncestr + "FFFFFFFFFFFF");
api.put("sign",sign);
api.put("transaction_id",json.getString("transaction_id"));
api.put("query_mode","1");//1根据工号查人
api.put("account_id","");
api.put("emp_id",emp_id);
api.put("photo","");
api.put("rec_id","");
redisUtils.delete("queryperson:" + json.getString("dev_id"));
return api;
}
//获取设备的参数,只获取一次,当设备更新时再获取一次 //获取设备的参数,只获取一次,当设备更新时再获取一次
if ("0".equals(equipment.getConsumeFlag())){ if ("0".equals(equipment.getConsumeFlag())){
CardEntity card=new CardEntity(); CardEntity card=new CardEntity();
@@ -178,7 +207,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 +323,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{
@@ -401,8 +430,9 @@ public class CardController {
people.setDelFlag(0L); people.setDelFlag(0L);
people.setEquipmentId(equipment.getId()+""); people.setEquipmentId(equipment.getId()+"");
people.setPageNo(20); people.setPageNo(20);
people.setConsumeStats(1);
List<SysPeople> sysPeopleList = peopleService.selectSysPeopleList(people); List<SysPeople> sysPeopleList = peopleService.selectSysPeopleList(people);
if(sysPeopleList!=null&&sysPeopleList.size()>0){ if (CollUtil.isNotEmpty(sysPeopleList)) {
card.setApi("addperson"); card.setApi("addperson");
JSONArray whitelist = new JSONArray(); JSONArray whitelist = new JSONArray();
for (SysPeople p : sysPeopleList) { for (SysPeople p : sysPeopleList) {
@@ -433,6 +463,7 @@ public class CardController {
card.setWhitelist(whitelist); card.setWhitelist(whitelist);
String cards = gson.toJson(card); String cards = gson.toJson(card);
api = JSONObject.parseObject(cards); api = JSONObject.parseObject(cards);
log.info("增加人员白名单{}", api.toJSONString());
return api; return api;
} }
//删除名单 //删除名单
@@ -460,6 +491,7 @@ public class CardController {
card.setWhitelist(whitelist); card.setWhitelist(whitelist);
String cards = gson.toJson(card); String cards = gson.toJson(card);
api = JSONObject.parseObject(cards); api = JSONObject.parseObject(cards);
log.info("删除人员白名单{}", api.toJSONString());
return api; return api;
} }
//发布菜品 //发布菜品
@@ -472,6 +504,7 @@ public class CardController {
@RequestMapping(value = "addperson",method = RequestMethod.POST) @RequestMapping(value = "addperson",method = RequestMethod.POST)
@ApiOperation("设备收到增加名单处理结果接口") @ApiOperation("设备收到增加名单处理结果接口")
public void addperson(@RequestBody JSONObject json){ public void addperson(@RequestBody JSONObject json){
log.info("增加名单处理结果接口{}", json.toJSONString());
//如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF //如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF
JSONArray whitelist= JSONArray.parseArray(JSONArray.toJSONString(json.get("whitelist"))); JSONArray whitelist= JSONArray.parseArray(JSONArray.toJSONString(json.get("whitelist")));
for(Object o:whitelist){ for(Object o:whitelist){
@@ -602,7 +635,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,10 +648,10 @@ 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();
Gson gson = new Gson(); log.info("实时接口========={}", json.toJSONString());
System.out.println("实时接口========="+json);
//如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF //如果有记录时则要处理记录后再应答保存后的id回传给设备方便设备对记录作标志 cardpwd FFFFFFFFFFFF
String api=json.get("api")+""; String api = json.getString("api");
//判断是否是人员查询接口
if ("infoquery".equals(api)) { if ("infoquery".equals(api)) {
//判断人员查询是否成功 //判断人员查询是否成功
JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params")));
@@ -701,10 +734,11 @@ public class CardController {
result.put("msg", msg); result.put("msg", msg);
return result; return result;
} }
//判断是否是无点餐接口
if ("posonline".equals(api)) { if ("posonline".equals(api)) {
//无点餐时上传 //无点餐时上传
JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params"))); JSONObject params = JSONObject.parseObject(JSONObject.toJSONString(json.get("params")));
String devId=json.get("dev_id")+""; String devId = json.getString("dev_id");
SysPeople people = new SysPeople(); SysPeople people = new SysPeople();
//总金额 //总金额
Long amount = Long.parseLong(params.get("amount") + "");//交易金额 Long amount = Long.parseLong(params.get("amount") + "");//交易金额
@@ -765,6 +799,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){
@@ -786,7 +847,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)) {
@@ -824,6 +885,7 @@ public class CardController {
paramMap.put("recordDateTime", sdf1.format(startDate)); paramMap.put("recordDateTime", sdf1.format(startDate));
paramMap.put("code", people.getId());//认证人员员工号 paramMap.put("code", people.getId());//认证人员员工号
paramMap.put("consumeInterval", timeType); paramMap.put("consumeInterval", timeType);
paramMap.put("dev_id", devId);
//请求当天的消费信息 //请求当天的消费信息
JSONObject jsons1 = queryPeopleDay(paramMap); JSONObject jsons1 = queryPeopleDay(paramMap);
if (!"0".equals(jsons1.get("code") + "")) { if (!"0".equals(jsons1.get("code") + "")) {
@@ -837,7 +899,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());
@@ -952,8 +1014,7 @@ public class CardController {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
} } else {
else{
result.put("tts", "余次不足"); result.put("tts", "余次不足");
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("line", "余次不足"); obj.put("line", "余次不足");
@@ -996,7 +1057,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应答
@@ -1125,7 +1186,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应答
@@ -1246,20 +1307,19 @@ public class CardController {
consumePeopleDay.setAccountId(paramMap.get("code") + ""); consumePeopleDay.setAccountId(paramMap.get("code") + "");
consumePeopleDay.setConsumeInterval(paramMap.get("consumeInterval") + ""); consumePeopleDay.setConsumeInterval(paramMap.get("consumeInterval") + "");
List<ConsumePeopleDay> list = peopleDayService.selectConsumePeopleDayList(consumePeopleDay); List<ConsumePeopleDay> list = peopleDayService.selectConsumePeopleDayList(consumePeopleDay);
if(list.size()>0){ if (CollUtil.isNotEmpty(list)) {
ConsumePeopleDay consumePeople = list.get(0); ConsumePeopleDay consumePeople = list.get(0);
if ("1".equals(consumePeople.getIsConsume())) { if ("1".equals(consumePeople.getIsConsume())) {
obj.put("code", "2"); obj.put("code", "2");
obj.put("msg", consumePeople.getAccountName() + "重复就餐"); obj.put("msg", consumePeople.getAccountName() + "重复就餐");
return obj;
} else { } else {
obj.put("code", "0"); obj.put("code", "0");
obj.put("msg", consumePeople.getAccountName() + "核验通过"); obj.put("msg", consumePeople.getAccountName() + "核验通过");
consumePeople.setIsConsume("1"); consumePeople.setIsConsume("1");
consumePeople.setUpdateTime(new Date()); consumePeople.setUpdateTime(new Date());
peopleDayService.updateConsumePeopleDay(consumePeople); peopleDayService.updateConsumePeopleDay(consumePeople);
return obj;
} }
return obj;
} else { } else {
obj.put("code", "1"); obj.put("code", "1");
obj.put("msg", "未报餐"); obj.put("msg", "未报餐");
@@ -1349,7 +1409,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");
@@ -1362,7 +1422,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));
@@ -1380,7 +1440,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());
@@ -1391,15 +1451,15 @@ 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.get("pay_code")+""; String account_id = params.getString("pay_code");
String devId=json.get("dev_id")+""; String devId = json.getString("dev_id");
SysPeople people = peopleService.selectSysPeopleById(Long.parseLong(account_id)); SysPeople people = peopleService.selectSysPeopleById(Long.parseLong(account_id));
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
Date startDate=new Date(Long.parseLong(params.get("sign_time")+"")); Date startDate = new Date(params.getLong("sign_time"));
String timeType = ""; String timeType = "";
Long timeId = 0L; Long timeId = 0L;
try { try {
@@ -1422,6 +1482,7 @@ public class CardController {
paramMap.put("recordDateTime", sdf1.format(startDate)); paramMap.put("recordDateTime", sdf1.format(startDate));
paramMap.put("code", people.getId());//认证人员员工号 paramMap.put("code", people.getId());//认证人员员工号
paramMap.put("consumeInterval", timeType); paramMap.put("consumeInterval", timeType);
paramMap.put("dev_id", devId);
//请求当天的消费信息 //请求当天的消费信息
JSONObject jsons1 = queryPeopleDay(paramMap); JSONObject jsons1 = queryPeopleDay(paramMap);
if (!"0".equals(jsons1.get("code") + "")) { if (!"0".equals(jsons1.get("code") + "")) {
@@ -1557,9 +1618,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("调用失败");
} }
} }
@@ -1589,7 +1650,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<>();
@@ -1677,6 +1738,23 @@ public class CardController {
@RequestMapping(value = "webQueryperson",method = RequestMethod.POST)
@ApiOperation("主动查询消费机人员信息")
public void webQueryperson(@RequestBody JSONObject json){
String dev_id = json.getString("dev_id");
String emp_id = json.getString("emp_id");
redisUtils.set("queryperson:" + dev_id, emp_id, 8);
}
@RequestMapping(value = "queryperson",method = RequestMethod.POST)
@ApiOperation("设备上传查询人员信息")
public void queryperson(@RequestBody JSONObject json){
log.info("设备上传查询人员信息{}", json.toJSONString());
}
/** /**
* 对字符串进行32位MD5加密 * 对字符串进行32位MD5加密

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

@@ -100,6 +100,15 @@ public class SysPeople extends BaseEntity {
private String isConsume; private String isConsume;
private Integer consumeStats;
public Integer getConsumeStats() {
return consumeStats;
}
public void setConsumeStats(Integer consumeStats) {
this.consumeStats = consumeStats;
}
public String getOpenid() { public String getOpenid() {
return openid; return openid;

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

@@ -2,15 +2,9 @@ spring:
datasource: datasource:
druid: druid:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
#url: jdbc:mysql://127.0.0.1:3306/fk_cloud?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true url: jdbc:mysql://127.0.0.1:3306/xa_cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
#username: root
#password: 111111
url: jdbc:mysql://192.168.124.185:3306/taihe_cloud?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root username: root
password: SQLsql123 password: root
#url: jdbc:mysql://127.0.0.1:8123/chungu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
#username: root
#password: 3dxz2023
initial-size: 10 initial-size: 10
max-active: 100 max-active: 100
min-idle: 10 min-idle: 10
@@ -37,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

@@ -31,3 +31,15 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
redis:
database: 0
host: 127.0.0.1
port: 6379
password: # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒)
jedis:
pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接

View File

@@ -25,6 +25,7 @@ spring:
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles:
active: prod active: prod
# active: dev
messages: messages:
encoding: UTF-8 encoding: UTF-8
basename: i18n/messages basename: i18n/messages
@@ -40,18 +41,18 @@ 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 # port: 6379
password: # 密码(默认为空) # password: # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒) # timeout: 6000ms # 连接超时时长(毫秒)
jedis: # jedis:
pool: # pool:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) # max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) # max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接 # max-idle: 10 # 连接池中的最大空闲连接
min-idle: 5 # 连接池中的最小空闲连接 # min-idle: 5 # 连接池中的最小空闲连接
renren: renren:
redis: redis:

View File

@@ -1,21 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration scan="true" scanPeriod="60 seconds" debug="false">
<include resource="org/springframework/boot/logging/logback/base.xml" /> <!-- 日志存放路径 -->
<logger name="org.springframework.web" level="INFO"/> <property name="log.path" value="logs/thxf" />
<logger name="org.springboot.sample" level="TRACE" /> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 开发、测试环境 --> <!-- 控制台输出 -->
<springProfile name="dev,test"> <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<logger name="org.springframework.web" level="INFO"/> <encoder>
<logger name="org.springboot.sample" level="INFO" /> <pattern>${log.pattern}</pattern>
<logger name="io.renren" level="DEBUG" /> </encoder>
</springProfile> </appender>
<!-- 生产环境 --> <!-- 系统日志输出 -->
<springProfile name="prod"> <appender name="file_all" class="ch.qos.logback.core.rolling.RollingFileAppender">
<logger name="org.springframework.web" level="ERROR"/> <file>${log.path}/xf.log</file>
<logger name="org.springboot.sample" level="ERROR" /> <!-- 循环政策:基于时间创建日志文件 -->
<logger name="io.renren" level="ERROR" /> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
</springProfile> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/xf.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="io.renren" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_all" />
</root>
</configuration> </configuration>

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>

View File

@@ -69,6 +69,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="branchId != null "> <if test="branchId != null ">
AND (p.branch_id = #{branchId} OR p.branch_id IN ( SELECT t.id FROM sys_branch t WHERE find_in_set(#{branchId}, ancestors) )) AND (p.branch_id = #{branchId} OR p.branch_id IN ( SELECT t.id FROM sys_branch t WHERE find_in_set(#{branchId}, ancestors) ))
</if> </if>
<if test="consumeStats != null ">
AND (p.avatar is not null or p.door_no is not null)
</if>
<if test="delFlag != null"> <if test="delFlag != null">
<if test="delFlag == 0"> <if test="delFlag == 0">
<if test="equipmentId != null and equipmentId != ''"> and spe.equipment_id is null </if> <if test="equipmentId != null and equipmentId != ''"> and spe.equipment_id is null </if>