设备上电自动审核逻辑修改

This commit is contained in:
mi9688
2025-01-07 17:53:10 +08:00
parent 8ac5f1c690
commit 99e3a161a8
6 changed files with 33 additions and 20 deletions

View File

@ -6,9 +6,9 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://182.40.196.154:3306/wumei2.4?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://182.40.196.154:3306/wumei2.4-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: wumei2.4 username: wumei2.4-test
password: rtB8EhbRRYSGyxHw password: JyRiZbFSZZiJBrSa
# 从库数据源 # 从库数据源
slave: slave:
enabled: false # 从数据源开关/默认关闭 enabled: false # 从数据源开关/默认关闭
@ -163,3 +163,6 @@ liteflow:
scriptTypeField: script_type scriptTypeField: script_type
scriptLanguageField: script_language scriptLanguageField: script_language
scriptEnableField: enable scriptEnableField: enable

View File

@ -6,7 +6,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://w.hanzhenyun.com:3306/wumei2.4?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://182.40.196.154:3306/wumei2.4?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: wumei2.4 username: wumei2.4
password: rtB8EhbRRYSGyxHw password: rtB8EhbRRYSGyxHw
# 从库数据源 # 从库数据源
@ -71,8 +71,8 @@ spring:
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
# mqtt 配置 # mqtt 配置
mqtt: mqtt:
username: fastbee # 账号 username: HZmqttLink # 账号
password: fastbee # 密码 password: HanZhen2025! # 密码
host-url: tcp://localhost:1883 # mqtt连接tcp地址 host-url: tcp://localhost:1883 # mqtt连接tcp地址
client-id: ${random.int} # 客户端Id不能相同采用随机数 ${random.value} client-id: ${random.int} # 客户端Id不能相同采用随机数 ${random.value}
# client-id: mqttx_22ee8d0f # 客户端Id不能相同采用随机数 ${random.value} # client-id: mqttx_22ee8d0f # 客户端Id不能相同采用随机数 ${random.value}
@ -115,6 +115,8 @@ sip:
id: 34020000002000000001 # 同上,另外增加编号,(可保持默认) id: 34020000002000000001 # 同上,另外增加编号,(可保持默认)
password: 12345678 # 监控设备接入的密码 password: 12345678 # 监控设备接入的密码
# 日志配置 # 日志配置
logging: logging:
level: level:

View File

@ -422,6 +422,7 @@ public class DeviceOtherMsgConsumer {
else if (data1.getStr("action")!=null&& "investMsg".equals(data1.getStr("action"))){ else if (data1.getStr("action")!=null&& "investMsg".equals(data1.getStr("action"))){
//获取订单号并更新订单状态 //获取订单号并更新订单状态
Long orderNum = data1.getLong("orderNum"); Long orderNum = data1.getLong("orderNum");
System.err.println("订单号"+orderNum);
boolean update = new LambdaUpdateChainWrapper<>(ngUserRechargeRecordsMapper) boolean update = new LambdaUpdateChainWrapper<>(ngUserRechargeRecordsMapper)
.set(NgUserRechargeRecords::getStatus, 3)//已充值 .set(NgUserRechargeRecords::getStatus, 3)//已充值
.eq(NgUserRechargeRecords::getId, orderNum) .eq(NgUserRechargeRecords::getId, orderNum)
@ -592,12 +593,13 @@ public class DeviceOtherMsgConsumer {
} }
} }
} }
String investBalanceStr = String.format("%.2f", investBalance);
//取最新的订单号作为合并后的订单 //取最新的订单号作为合并后的订单
dataValue.put("orderNum",orderList.get(orderList.size()-1).getId());//订单号 dataValue.put("orderNum",orderList.get(orderList.size()-1).getId());//订单号
reply.put("code",410); reply.put("code",410);
dataValue.put("cardNum",Integer.parseInt(cardId));//卡号 dataValue.put("cardNum",Integer.parseInt(cardId));//卡号
dataValue.put("areaCode",Integer.parseInt(areaCode));//区域码 dataValue.put("areaCode",Integer.parseInt(areaCode));//区域码
dataValue.put("investBalance",investBalance.doubleValue()*100);//充值金额 dataValue.put("investBalance", Double.parseDouble(investBalanceStr) *100);//充值金额
// dataValue.put("investWater",rechargecardUser.getWater()*100);//充值水量 // dataValue.put("investWater",rechargecardUser.getWater()*100);//充值水量
reply.put("data",dataValue); reply.put("data",dataValue);
pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/info/reply", JSONUtil.toJsonStr(reply)); pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/info/reply", JSONUtil.toJsonStr(reply));

View File

@ -58,16 +58,17 @@ public class DeviceReportSSEController extends BaseController {
* 与客户端建立http长链接 * 与客户端建立http长链接
*/ */
@PostMapping(value = "/device/init",produces = MediaType.TEXT_EVENT_STREAM_VALUE) @PostMapping(value = "/device/init",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter getReport() throws IOException { public SseEmitter getReport(@RequestBody String timeStamp) throws IOException {
SseEmitter emitter= new SseEmitter(0L); SseEmitter emitter= new SseEmitter(0L);
emitters.put("device-init",emitter); String emittersKey="sse-connection-"+timeStamp;
emitters.put(emittersKey,emitter);
log.info("{}连接成功!",emittersKey);
emitter.send(JSONUtil.toJsonStr(Message.builder().event(1).content("连接成功!").build())); emitter.send(JSONUtil.toJsonStr(Message.builder().event(1).content("连接成功!").build()));
return emitter; return emitter;
} }
@PostMapping("/device/init/new") @PostMapping("/device/init/new")
public AjaxResultPro sendMsg(@RequestBody DevicePowerDTO reportInfo) { public AjaxResultPro sendMsg(@RequestBody DevicePowerDTO reportInfo) {
// checkDeviceReportInfo(reportInfo);
if(StringUtils.isBlank(reportInfo.getImei())){ if(StringUtils.isBlank(reportInfo.getImei())){
return AjaxResultPro.success(1102,"imei不能为空",null); return AjaxResultPro.success(1102,"imei不能为空",null);
} }
@ -105,7 +106,7 @@ public class DeviceReportSSEController extends BaseController {
if(StringUtils.isBlank(reportInfo.getTestRecord())){ if(StringUtils.isBlank(reportInfo.getTestRecord())){
return AjaxResultPro.success(111,"testRecord不能为空!",null); return AjaxResultPro.success(111,"testRecord不能为空!",null);
} }
SseEmitter emitter = emitters.get("device-init");
// String deviceNumber = generateDeviceNumber(); // String deviceNumber = generateDeviceNumber();
//映射字段 //映射字段
@ -123,7 +124,7 @@ public class DeviceReportSSEController extends BaseController {
deviceReportInfo.setReplaceManufacturer(Long.valueOf(reportInfo.getFacType())); deviceReportInfo.setReplaceManufacturer(Long.valueOf(reportInfo.getFacType()));
deviceReportInfo.setTestRecord(reportInfo.getTestRecord()); deviceReportInfo.setTestRecord(reportInfo.getTestRecord());
//设置状态为未审核 //设置状态为未审核
deviceReportInfo.setStatus(1); deviceReportInfo.setStatus(0);
//设备编码查重 //设备编码查重
List<DeviceReportInfo> list = new LambdaQueryChainWrapper<>(deviceReportInfoMapper) List<DeviceReportInfo> list = new LambdaQueryChainWrapper<>(deviceReportInfoMapper)
.select(DeviceReportInfo::getSerialNumber,DeviceReportInfo::getImei,DeviceReportInfo::getStatus) .select(DeviceReportInfo::getSerialNumber,DeviceReportInfo::getImei,DeviceReportInfo::getStatus)
@ -179,6 +180,7 @@ public class DeviceReportSSEController extends BaseController {
} }
} }
deviceReportInfo.setSerialNumber(genDeviceNumber); deviceReportInfo.setSerialNumber(genDeviceNumber);
reportInfo.setSerialNumber(genDeviceNumber);
deviceReportInfo.setName(genDeviceNumber); deviceReportInfo.setName(genDeviceNumber);
deviceReportInfo.setType(1); deviceReportInfo.setType(1);
int inserted = deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo); int inserted = deviceReportInfoMapper.insertDeviceReportInfo(deviceReportInfo);
@ -202,14 +204,15 @@ public class DeviceReportSSEController extends BaseController {
if(inserted1<1){ if(inserted1<1){
throw new ServiceException("插入设备信息失败!"); throw new ServiceException("插入设备信息失败!");
} }
//当开启自动审核,也就是打开自动审核页面的时候需要推送到前端
if(emitter!=null){
emitters.forEach((k,v)->{
try { try {
emitter.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build())); v.send(JSONUtil.toJsonStr(Message.builder().event(2).content("新的消息").data(reportInfo).build()));
} catch (IOException e) { } catch (Exception e) {
return AjaxResultPro.success(1104,"推送上电基本信息失败!",null); log.error("推送上电基本信息失败!",e);
} }
} });
Map<String,Object> map=new HashMap<>(); Map<String,Object> map=new HashMap<>();
map.put("regSn",deviceReportInfo.getSerialNumber()); map.put("regSn",deviceReportInfo.getSerialNumber());

View File

@ -17,4 +17,7 @@ public class DevicePowerDTO {
private String framType; private String framType;
private String facType; private String facType;
private String testRecord; private String testRecord;
//---------------------------------
String serialNumber;
} }

View File

@ -58,9 +58,9 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
// public static String platformCertificatePath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/damogang_platformCertificate.pem"; // public static String platformCertificatePath="fastbee-common/src/main/java/com/fastbee/common/utils/pay/damogang_platformCertificate.pem";
//支付结果回调地址 //支付结果回调地址
public static String notify_url="https://1f647120.r3.cpolar.cn/pay/getresult";//https://1f647120.r3.cpolar.cn // public static String notify_url="https://1f647120.r3.cpolar.cn/pay/getresult";//https://1f647120.r3.cpolar.cn
//TODO 生产环境支付结果异步通知地址 //TODO 生产环境支付结果异步通知地址
//public static String notify_url="https://farmh5.hze2.com/prod-api/pay/getresult"; public static String notify_url="https://farmh5.hze2.com/prod-api/pay/getresult";
//https://5f655ed0.r3.cpolar.cn //https://5f655ed0.r3.cpolar.cn
//微信小程序appid //微信小程序appid
public static String appId="wx308612d2a8423311"; public static String appId="wx308612d2a8423311";