修改充值查询报文处理,以及充值机充值逻辑
This commit is contained in:
@ -252,6 +252,7 @@ public class DeviceOtherMsgConsumer {
|
||||
if("startPump".equals(JSONUtil.parseObj(data1).get("action")))
|
||||
{
|
||||
System.err.println("开阀");
|
||||
log.info("设备{}开阀",serialNumber);
|
||||
//开阀-添加灌溉记录
|
||||
UserIrrigationRecord userIrrigationRecord=new UserIrrigationRecord();
|
||||
userIrrigationRecord.setDeviceNumber(serialNumber);//设备编码
|
||||
@ -319,8 +320,9 @@ public class DeviceOtherMsgConsumer {
|
||||
System.err.println("充值卡金额同步失败");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}else if("stopPump".equals(JSONUtil.parseObj(data1).get("action"))){
|
||||
System.err.println("关阀");
|
||||
log.info("设备{}关",serialNumber);
|
||||
//关阀-修改灌溉记录,修改结束时间、灌溉用水量(做差 关阀-开阀用户总累计流量。)查卡号最新一条记录
|
||||
String cardNumber=dataJson.getStr("cardId");//解析cardId
|
||||
//根据设备编码和卡号获取当前状态为灌溉中的灌溉记录
|
||||
@ -378,7 +380,7 @@ public class DeviceOtherMsgConsumer {
|
||||
}
|
||||
//如果是设备刷卡上报的查询报文
|
||||
if(data1.getStr("action")!=null&& "askMsg".equals(data1.getStr("action"))){
|
||||
cardReportHandler(productId,serialNumber,data1);
|
||||
cardReportHandler(productId,serialNumber,jsonObject);
|
||||
}
|
||||
|
||||
}
|
||||
@ -501,37 +503,57 @@ public class DeviceOtherMsgConsumer {
|
||||
* 处理刷卡上报查询报文
|
||||
*/
|
||||
private void cardReportHandler(Long productId,String serialNumber,JSONObject dataObj){
|
||||
JSONObject data = dataObj.getJSONObject("data");
|
||||
//解析消息
|
||||
String cardId=dataObj.getStr("cardId");//卡号
|
||||
String areaCode=dataObj.getStr("areaCode");//区域码
|
||||
//查询是否有未下发的指令
|
||||
String cardId=data.getStr("cardId");//卡号
|
||||
String areaCode=data.getStr("areaCode");//区域码
|
||||
//先回应代表平台收到了来自设备的查询报文
|
||||
Map<String,Object> reply=new HashMap<>();
|
||||
reply.put("pakSn",dataObj.getInt("pakSn"));
|
||||
//默认没有充值的订单
|
||||
reply.put("cmd",400);
|
||||
Map<String,Object> dataValue=new HashMap<>();
|
||||
// dataValue.put("cmd",1000);
|
||||
// data.put("orderNum",item.getId());//订单号
|
||||
// dataValue.put("cardId",cardId);//卡号
|
||||
// dataValue.put("areaCode",areaCode);//区域码
|
||||
// data.put("investBalance",item.getAmount().doubleValue()*100);
|
||||
// data.put("investWater",rechargecardUser.getWater()*100);
|
||||
|
||||
reply.put("msg","");
|
||||
|
||||
|
||||
//查询是否待充值的订单
|
||||
List<NgUserRechargeRecords> list = new LambdaQueryChainWrapper<>(ngUserRechargeRecordsMapper)
|
||||
.select(NgUserRechargeRecords::getId, NgUserRechargeRecords::getStatus,NgUserRechargeRecords::getAmount)
|
||||
.eq(NgUserRechargeRecords::getCardNumber,cardId)
|
||||
.eq(NgUserRechargeRecords::getStatus,1)
|
||||
.list();
|
||||
//如果有待充值的订单
|
||||
if(!list.isEmpty()){
|
||||
reply.put("cmd",410);
|
||||
dataValue.put("orderNum",list.get(0).getId());//订单号
|
||||
reply.put("data",dataValue);
|
||||
pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/info/reply", JSONUtil.toJsonStr(reply));
|
||||
}
|
||||
|
||||
//如果订单已经支付但并未下发
|
||||
list.forEach(item->{
|
||||
//下发指令
|
||||
//构建回应
|
||||
Map<String,Object> reply=new HashMap<>();
|
||||
reply.put("cmd",5300);
|
||||
Map<String,Object> data=new HashMap<>();
|
||||
data.put("cmd",1000);
|
||||
// 构建回应
|
||||
Map<String,Object> recharge=new HashMap<>();
|
||||
recharge.put("cmd",1000);
|
||||
Map<String,Object> data1=new HashMap<>();
|
||||
data.put("orderNum",item.getId());//订单号
|
||||
data.put("cardId",cardId);//卡号
|
||||
data.put("cardNum",cardId);//卡号
|
||||
data.put("areaCode",areaCode);//区域码
|
||||
data.put("investBalance",item.getAmount().doubleValue()*100);
|
||||
// data.put("investWater",rechargecardUser.getWater()*100);
|
||||
data.put("investWater",1*100);
|
||||
reply.put("data",data);
|
||||
//发送回应
|
||||
issueInstructionsProducer.receiveDataReportResponse(productId.toString(),serialNumber,JSONUtil.toJsonStr(reply));
|
||||
pubMqttClient.publish(1,true,"hzlink/"+productId+"/"+serialNumber+"/cmd/down", JSONUtil.toJsonStr(recharge));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
Reference in New Issue
Block a user