设备在线状态逻辑调整,支付下发指令参数调整等
This commit is contained in:
parent
6ed87aa6e6
commit
250530570a
@ -137,6 +137,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/common/upload").permitAll()
|
||||
.antMatchers("/pay/getresult").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.antMatchers("/device/operation/**").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
|
||||
// // oauth
|
||||
|
@ -2,8 +2,11 @@ package com.fastbee.mq.redischannel.consumer;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.fastbee.common.constant.FastBeeConstant;
|
||||
import com.fastbee.common.core.mq.DeviceReportBo;
|
||||
import com.fastbee.iot.domain.DeviceReportInfo;
|
||||
import com.fastbee.iot.mapper.DeviceReportInfoMapper;
|
||||
import com.fastbee.mq.redischannel.producer.IssueInstructionsProducer;
|
||||
import com.fastbee.mq.service.impl.DeviceOtherMsgHandler;
|
||||
import com.fastbee.mqttclient.PubMqttClient;
|
||||
@ -36,6 +39,9 @@ public class DeviceOtherMsgConsumer {
|
||||
@Autowired
|
||||
private IssueInstructionsProducer issueInstructionsProducer;
|
||||
|
||||
@Autowired
|
||||
private DeviceReportInfoMapper deviceReportInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private NgWaterPumpUsageRecordsMapper ngWaterPumpUsageRecordsMapper;
|
||||
|
||||
@ -63,6 +69,9 @@ public class DeviceOtherMsgConsumer {
|
||||
//设备上报数据消息---------------------------------------------------------------------------------
|
||||
if(topic.endsWith("/info/up")){
|
||||
deviceDataReportHandler(new String(data));
|
||||
//更新设备在线状态
|
||||
updateDeviceOnlineStatus( productId,serialNumber);
|
||||
// updateDeviceOnlineStatusDb(serialNumber);
|
||||
//保存使用记录
|
||||
NgWaterPumpUsageRecords pumpUsageRecords=new NgWaterPumpUsageRecords();
|
||||
pumpUsageRecords.setDeviceNumber(serialNumber);
|
||||
@ -73,8 +82,7 @@ public class DeviceOtherMsgConsumer {
|
||||
String data1 = jsonObject.getStr("data");
|
||||
//收到定时报文
|
||||
if(JSONUtil.parseObj(data1).get("action").equals("timeMsg")){
|
||||
//更新设备在线状态
|
||||
updateDeviceOnlineStatus( productId,serialNumber);
|
||||
|
||||
pumpUsageRecords.setMessageContent(JSONUtil.toJsonStr(jsonObject));
|
||||
int i = ngWaterPumpUsageRecordsMapper.insertNgWaterPumpUsageRecords(pumpUsageRecords);
|
||||
if(i<1){
|
||||
@ -83,6 +91,11 @@ public class DeviceOtherMsgConsumer {
|
||||
}else if(JSONUtil.parseObj(data1).get("action").equals("safeMsg")){
|
||||
//续费在线状态
|
||||
updateDeviceOnlineStatus( productId,serialNumber);
|
||||
//保存数据
|
||||
int i = ngWaterPumpUsageRecordsMapper.insertNgWaterPumpUsageRecords(pumpUsageRecords);
|
||||
if(i<1){
|
||||
System.err.println("--------------------------保存使用记录失败!---------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,6 +108,8 @@ public class DeviceOtherMsgConsumer {
|
||||
//打印设备
|
||||
else if ( topic.endsWith("/info/reply")) {
|
||||
platformDataReportAckHandler(new String(data));
|
||||
updateDeviceOnlineStatus( productId,serialNumber);
|
||||
// updateDeviceOnlineStatusDb(serialNumber);
|
||||
}
|
||||
else if (topic.endsWith("/cmd/down")) {
|
||||
platformCmdHandler(new String(data));
|
||||
@ -102,6 +117,8 @@ public class DeviceOtherMsgConsumer {
|
||||
|
||||
} else if (topic.endsWith("/cmd/reply")) {
|
||||
deviceCmdAckHandler(new String(data));
|
||||
updateDeviceOnlineStatus( productId,serialNumber);
|
||||
// updateDeviceOnlineStatusDb(serialNumber);
|
||||
}
|
||||
otherMsgHandler.messageHandler(bo);
|
||||
}catch (Exception e){
|
||||
@ -111,7 +128,7 @@ public class DeviceOtherMsgConsumer {
|
||||
|
||||
|
||||
/**
|
||||
* 更新设备在线状态
|
||||
* 缓存更新设备在线状态
|
||||
*/
|
||||
private void updateDeviceOnlineStatus(Long productId,String serialNumber){
|
||||
try {
|
||||
@ -123,9 +140,24 @@ public class DeviceOtherMsgConsumer {
|
||||
}
|
||||
stringRedisTemplate.opsForValue().set("neixiang_device_online_status:"+productId+":"+serialNumber,"1",360, TimeUnit.SECONDS);
|
||||
}catch (Exception e){
|
||||
log.error("=>更新设备在线状态出错",e);
|
||||
log.error("=>更新缓存设备在线状态出错",e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 数据库更新设备在线状态
|
||||
*/
|
||||
private void updateDeviceOnlineStatusDb(String serialNumber){
|
||||
try {
|
||||
boolean update = new LambdaUpdateChainWrapper<>(deviceReportInfoMapper)
|
||||
.set(DeviceReportInfo::getOnLine, 1)
|
||||
.eq(DeviceReportInfo::getSerialNumber, serialNumber)
|
||||
.update();
|
||||
if(!update){
|
||||
throw new RuntimeException("=>数据库更新设备在线状态失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("=>更新数据库设备在线状态出错",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,11 +3,14 @@ package com.fastbee.data.controller;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -51,10 +54,9 @@ public class DeviceReportInfoController extends BaseController
|
||||
public TableDataInfo list(DeviceReportInfo deviceReportInfo)
|
||||
{
|
||||
startPage();
|
||||
|
||||
List<DeviceReportInfo> list = deviceReportInfoService.selectDeviceReportInfoList(deviceReportInfo);
|
||||
|
||||
|
||||
System.err.println("查询条件:"+deviceReportInfo.getOnLine());
|
||||
System.err.println("设备总长度:"+list.size());
|
||||
//查询设备在线状态
|
||||
list.forEach(d->{
|
||||
if(d.getType()==1){
|
||||
@ -68,9 +70,14 @@ public class DeviceReportInfoController extends BaseController
|
||||
//展连流量计设备在线状态判断
|
||||
d.setType(0);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// //处理在线/离线筛选
|
||||
// if(deviceReportInfo.getOnLine()!=null){
|
||||
// //根据online状态的值过滤集合
|
||||
// list= list.stream().filter(d -> Objects.equals(d.getOnLine(), deviceReportInfo.getOnLine()))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
System.err.println("过滤后总长度:"+list.size());
|
||||
return getDataTable(list);
|
||||
}
|
||||
//统计是设备相关信息
|
||||
|
@ -217,6 +217,8 @@ public class WeChatPayController extends BaseController {
|
||||
}
|
||||
if (isVerified) {
|
||||
System.out.println("签名验证成功");
|
||||
|
||||
|
||||
} else {
|
||||
System.out.println("签名验证失败");
|
||||
responseBody.put("code", "FAIL");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fastbee.iot.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -155,15 +156,19 @@ public class DeviceReportInfo extends BaseEntity
|
||||
@ApiModelProperty("纬度")
|
||||
private String latitude;
|
||||
|
||||
//----------------------------------------------------------业务字段-----------------------------------------------------------
|
||||
/** 是否自动审核 */
|
||||
private Boolean autoReview ;
|
||||
|
||||
/** 设备类型:1.水电双计 2.流量计 */
|
||||
@Excel(name = "设备类型:1.水电双计 2.流量计")
|
||||
@ApiModelProperty("设备类型:1.水电双计 2.流量计")
|
||||
private Integer type;
|
||||
|
||||
//----------------------------------------------------------业务字段-----------------------------------------------------------
|
||||
/** 是否自动审核 */
|
||||
@TableField(exist = false)
|
||||
private Boolean autoReview ;
|
||||
|
||||
/** 设备类型:1.水电双计 2.流量计 */
|
||||
private String searchValue;
|
||||
|
||||
// @TableField(exist = false)
|
||||
private Integer onLine;//0离线,1在线
|
||||
|
||||
|
||||
|
@ -32,16 +32,17 @@
|
||||
<result property="type" column="type" />
|
||||
<result property="longitude" column="longitude" />
|
||||
<result property="latitude" column="latitude" />
|
||||
<result property="onLine" column="on_line" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeviceReportInfoVo">
|
||||
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number, serial_number, qr_code, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status, powers_time, type, longitude, latitude from iot_device_report_info
|
||||
select id, imei, iccid, mcu_id, bsp_type, lte_type, mcu_type, mcu_fw, lte_fw, lcd_manufacturer, voice_manufacturer, fram_model, replace_manufacturer, test_record, batch_number, serial_number, qr_code, name, lcd_manufacturer_name, voice_manufacturer_name, replace_manufacturer_name, device_id, status, powers_time, type, longitude, latitude,on_line from iot_device_report_info
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceReportInfoList" parameterType="DeviceReportInfo" resultMap="DeviceReportInfoResult">
|
||||
<include refid="selectDeviceReportInfoVo"/>
|
||||
<where>
|
||||
<if test="imei != null and imei != ''"> and imei = #{imei}</if>
|
||||
<if test="imei != null and imei != ''"> and imei like concat('%', #{imei}, '%')</if>
|
||||
<if test="iccid != null and iccid != ''"> and iccid = #{iccid}</if>
|
||||
<if test="mcuId != null and mcuId != ''"> and mcu_id = #{mcuId}</if>
|
||||
<if test="bspType != null and bspType != ''"> and bsp_type = #{bspType}</if>
|
||||
@ -55,7 +56,7 @@
|
||||
<if test="replaceManufacturer != null "> and replace_manufacturer = #{replaceManufacturer}</if>
|
||||
<if test="testRecord != null and testRecord != ''"> and test_record = #{testRecord}</if>
|
||||
<if test="batchNumber != null and batchNumber != ''"> and batch_number = #{batchNumber}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number like concat('%', #{serialNumber}, '%') </if>
|
||||
<if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="lcdManufacturerName != null and lcdManufacturerName != ''"> and lcd_manufacturer_name like concat('%', #{lcdManufacturerName}, '%')</if>
|
||||
@ -67,6 +68,7 @@
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
<if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
|
||||
<if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
|
||||
<if test="onLine != null "> and on_line = #{onLine}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
@ -62,7 +62,7 @@ private static final long serialVersionUID = 1L;
|
||||
/** 微信支付公钥id */
|
||||
@Excel(name = "微信支付公钥id")
|
||||
@ApiModelProperty("微信支付公钥id")
|
||||
private Long wechatPublicKeyId;
|
||||
private String wechatPublicKeyId;
|
||||
|
||||
/** 平台证书序列号 */
|
||||
@Excel(name = "平台证书序列号")
|
||||
|
@ -25,7 +25,7 @@ public class NgMerchantsDto {
|
||||
|
||||
private String deptName;
|
||||
|
||||
private Long wechatPublicKeyId;
|
||||
private String wechatPublicKeyId;
|
||||
|
||||
private String platformCertificateSerialNumber;
|
||||
}
|
||||
|
@ -155,7 +155,9 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
|
||||
userConsumptionDetails.setPaymentStatus(2);//账单状态更改为已支付*/
|
||||
|
||||
String areaCode=ngUserRechargeRecords.getAreaCode();
|
||||
|
||||
if(ngUserRechargeRecords.getSerialNumber()==null){
|
||||
throw new ServiceException("充值机编码为空!!!");
|
||||
}
|
||||
//构建主题
|
||||
String topic ="hzlink/147/"+ngUserRechargeRecords.getSerialNumber()+"/cmd/down";
|
||||
//构建消息
|
||||
@ -163,18 +165,18 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
|
||||
//远程阀控
|
||||
param.put("cmd",1000);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("orderNum", rechargeCode);//订单号
|
||||
data.put("cardNum",cardNumber);//卡号
|
||||
data.put("areaCode",areaCode);//区域号
|
||||
data.put("investBalance",balance);//充值的金额
|
||||
data.put("investWater",100);//充值的水量
|
||||
data.put("orderNum", ngUserRechargeRecords.getId());//订单号
|
||||
data.put("cardNum",Integer.parseInt(cardNumber));//卡号
|
||||
data.put("areaCode",Integer.parseInt(areaCode));//区域号
|
||||
data.put("investBalance",balance.doubleValue()*100);//充值的金额
|
||||
data.put("investWater",100*100);//充值的水量
|
||||
|
||||
param.put("data",data);
|
||||
try{
|
||||
pubMqttClient.publish(1,true,topic, JSONUtil.toJsonStr(param));
|
||||
}catch (Exception e)
|
||||
{
|
||||
throw new Exception("消息发布失败");
|
||||
throw new ServiceException("消息发布失败");
|
||||
}
|
||||
|
||||
// int i = userRechargeCardsMapper.updateUserRechargeCards(info);
|
||||
|
@ -63,9 +63,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 notify_url="https://3ffb1c5f.r3.cpolar.cn/pay/getresult";//https://3ffb1c5f.r3.cpolar.cn
|
||||
// public static String notify_url="https://3ffb1c5f.r3.cpolar.cn/pay/getresult";//https://3ffb1c5f.r3.cpolar.cn
|
||||
//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
|
||||
@Override
|
||||
/**
|
||||
|
@ -161,7 +161,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
@Cacheable(value = "role", key = "#root.methodName + '_' + #userId", unless = "#result == null or #result.size() == 0")
|
||||
// @Cacheable(value = "role", key = "#root.methodName + '_' + #userId", unless = "#result == null or #result.size() == 0")
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user