using LeaRun.Application.Code; using LeaRun.Application.Entity.NBManage; using LeaRun.Data; using LeaRun.Util; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LeaRun.Application.Service.NBManage { public class ReSetReportNumService { SqlHelper sqlHelper = new SqlHelper("NBDB"); public string SendCommand(string id, string addr, string IOT_Code, string retryNum) { try { //发送指令 string strParams = "{\"deviceId\": \"" + IOT_Code + "\",\"command\": {\"method\": \"SET_METER_RETRY\",\"paras\": {\"addr\": \"" + addr + "\",\"retry_num\":" + retryNum + "},\"serviceId\": \"WaterMeterX\"},\"callbackUrl\":\"https://60.205.104.179:" + NBCommon.NB_ServerPort + "/NBManage/NBSubscribeListener/CallBackRetryNum\"}"; JObject jObj = NBCommon.SendCommand(strParams); if (jObj["error_code"] != null) { return ""; } string commandId = jObj["commandId"].ToString();//命令ID string status = jObj["status"].ToString();//命令状态 string userId = OperatorProvider.Provider.Current().UserId;//命令操作者 //命令保存 string insertCommandSql = "INSERT INTO RMRS_SendCmdRecord (MeterId, CmdType, CmdID, Operator,CmdResult,SendText) VALUES(" + id + ",1012,'" + commandId + "','" + userId + "','" + status + "','"+ strParams + "')"; sqlHelper.ExecuteNoParams(insertCommandSql, CommandType.Text); string reJson = "{\"commandId\":\"" + commandId + "\",\"status\":\"" + status + "\"}"; return reJson; } catch (Exception ex) { throw ex; } } } }