diff --git a/Waste.Application/Test/TestAppService.cs b/Waste.Application/Test/TestAppService.cs
index 72a9538..db105b0 100644
--- a/Waste.Application/Test/TestAppService.cs
+++ b/Waste.Application/Test/TestAppService.cs
@@ -1,9 +1,12 @@
-using Furion.DynamicApiController;
+using Furion;
+using Furion.DynamicApiController;
+using MessagePack;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
@@ -14,10 +17,16 @@ namespace Waste.Application
///
public class TestAppService : IDynamicApiController
{
+ private static string ApiUrl = App.Configuration["SZDevPlatSetting:ApiUrl"];
+ private static string UserId = App.Configuration["SZDevPlatSetting:UserId"];
+ private static string ApiSecret = App.Configuration["SZDevPlatSetting:ApiSecret"];
+ private static string ApiSecretHash = App.Configuration["SZDevPlatSetting:ApiSecretHash"];
+ private readonly IHttpClientFactory _clientFactory;
private readonly ILoggerService _loggerService;
- public TestAppService(ILoggerService loggerService)
+ public TestAppService(ILoggerService loggerService, IHttpClientFactory clientFactory)
{
_loggerService = loggerService;
+ _clientFactory = clientFactory;
}
///
/// 接收测试
@@ -32,5 +41,87 @@ namespace Waste.Application
_loggerService.AddLogger(msg, 1);
return "success";
}
+ [HttpGet]
+ public async Task TestSendAsync()
+ {
+ GarbagePltC2SDto garbageC2SDto = new GarbagePltC2SDto {
+ Weight=10.1,
+ secret = "6Vxkfkg3kxqkkzgT",
+ secrethash = "51fb893bccc1395e",
+ ScanningTime= 1627917492,
+ DStatus=0,
+ deviceid = "08d954b6-df45-4de1-8fde-f5109798b855",
+ Trash = "000F000002",
+ Type = 4
+ };
+ if(garbageC2SDto.Weight == ((int)garbageC2SDto.Weight).ToDouble())
+ {
+ garbageC2SDto.Weight = garbageC2SDto.Weight.ToDouble(0);
+ }
+ var url = $"{ApiUrl}/api/garbages";
+ string[] paramlist = new string[] {
+ garbageC2SDto.Weight.ToString(),garbageC2SDto.Trash,garbageC2SDto.Type.ToString(),garbageC2SDto.ScanningTime.ToString(),garbageC2SDto.DStatus.ToString()
+ };
+ int timestamp = 1627917492;
+ int nonce = 497458578;
+ string sign = GetUserApiSign(garbageC2SDto.secret, paramlist);
+ var c2s_dto = new SuZhouPostApiBaseDto
+ {
+ Data = new GarbageC2SDto
+ {
+ DStatus = garbageC2SDto.DStatus,
+ ScanningTime = garbageC2SDto.ScanningTime,
+ Trash = garbageC2SDto.Trash,
+ Type = garbageC2SDto.Type,
+ Weight = garbageC2SDto.Weight
+ },
+ SecretHash = garbageC2SDto.secrethash,
+ Nonce = nonce,
+ Signature = sign,
+ TimeStamp = timestamp,
+ DeviceId = garbageC2SDto.deviceid
+ };
+ var request = new HttpRequestMessage(HttpMethod.Post, url);
+ var bytes = MessagePackSerializer.Serialize(c2s_dto);
+ request.Content = new ByteArrayContent(bytes);
+ request.Headers.Add("Accept", "application/x-msgpack");
+ request.Content.Headers.Add("Content-Type", "application/x-msgpack");
+ var client = _clientFactory.CreateClient();
+ var response = await client.SendAsync(request);
+ if (response.IsSuccessStatusCode)
+ {
+ //记录日志
+ _loggerService.AddLogger($"测量信息上报成功:参数:{c2s_dto.ToJson()}", 3);
+ }
+ else
+ {
+ var msg = await response.Content.ReadAsStringAsync();
+ //记录日志
+ _loggerService.AddLogger($"测量信息上报失败:参数:{c2s_dto.ToJson()}\r\n返回值:{msg}", 3);
+ }
+ }
+
+ private string GetUserApiSign(string secret, params string[] dataparams)
+ {
+ StringBuilder sb = new StringBuilder();
+ if (dataparams != null && dataparams.Length > 0)
+ {
+ foreach (var item in dataparams)
+ {
+ sb.Append(item);
+ }
+ }
+ if (!string.IsNullOrEmpty(secret))
+ {
+ sb.Append(secret);
+ }
+ else
+ {
+ sb.Append(ApiSecret);
+ }
+ string str = sb.ToString();
+ string sign = Md5.md5(str, 16).ToLower();
+ return sign;
+ }
}
}
diff --git a/Waste.Application/ThirdApiInfo/Dtos/ThirdApiInfoDto.cs b/Waste.Application/ThirdApiInfo/Dtos/ThirdApiInfoDto.cs
index f05c89d..0d85865 100644
--- a/Waste.Application/ThirdApiInfo/Dtos/ThirdApiInfoDto.cs
+++ b/Waste.Application/ThirdApiInfo/Dtos/ThirdApiInfoDto.cs
@@ -141,4 +141,22 @@ namespace Waste.Application.ThirdApiInfo
///
public Guid ResultId { get; set; }
}
+ ///
+ /// 日志上报
+ ///
+ public class BugModel
+ {
+ ///
+ /// 机器码
+ ///
+ public string ecode { get; set; }
+ ///
+ /// 位置
+ ///
+ public string ExceptionPos { get; set; }
+ ///
+ /// 错误信息
+ ///
+ public string ExceptionInfo { get; set; }
+ }
}
diff --git a/Waste.Application/ThirdApiInfo/OpenAppService.cs b/Waste.Application/ThirdApiInfo/OpenAppService.cs
index 35c1ac1..f447341 100644
--- a/Waste.Application/ThirdApiInfo/OpenAppService.cs
+++ b/Waste.Application/ThirdApiInfo/OpenAppService.cs
@@ -179,6 +179,25 @@ namespace Waste.Application.ThirdApiInfo
};
}
+ ///
+ /// BUG上报
+ ///
+ ///
+ [HttpPost]
+ [Route("api/reportbug/postbug")]
+ public object PostBug(BugModel bug)
+ {
+ var errmsg = $"机器码:{bug.ecode},位置:{bug.ExceptionPos},信息:{bug.ExceptionInfo}";
+ return new
+ {
+ status = new
+ {
+ code = 1,
+ name = "SUCCESS",
+ message = ""
+ }
+ };
+ }
///
/// 正式升级
///
@@ -253,6 +272,11 @@ namespace Waste.Application.ThirdApiInfo
code = 1,
name = "SUCCESS",
message = ""
+ },
+ data = new
+ {
+ isenable = true,
+ deadline = DateTime.Now.AddYears(2).ToString("yyyy-MM-dd")
}
};
}
diff --git a/Waste.Application/ThirdApiInfo/OpenService.cs b/Waste.Application/ThirdApiInfo/OpenService.cs
index 38f1e9a..25594b2 100644
--- a/Waste.Application/ThirdApiInfo/OpenService.cs
+++ b/Waste.Application/ThirdApiInfo/OpenService.cs
@@ -104,6 +104,11 @@ namespace Waste.Application.ThirdApiInfo
var weight = GetChsFromHex(weighthex);
returndata.type = TrashType(type);
returndata.Weight = weight.ToDouble();
+ //检查体重是否为整数如:10.0这样的情况,需要去除小数点后的数据
+ if (returndata.Weight == ((int)returndata.Weight).ToDouble())
+ {
+ returndata.Weight = returndata.Weight.ToDouble(0);
+ }
returndata.IsSuccessed = true;
string[] paramlist = new string[] {
returndata.Weight.ToString(),returndata.trash,returndata.type.ToString(),returndata.ScanningTime.ToString(),returndata.status.ToString()
@@ -143,6 +148,28 @@ namespace Waste.Application.ThirdApiInfo
tare = device.Tare,
isfrist = isfrist
});
+ var logger = App.GetService();
+ logger.AddLogger($"发送的数据:{returndata.ToJson()}", 1);
+ //上传垃圾数据
+ //if (returndata.Weight > 0)
+ //{
+ // if (devicesecret != null && !string.IsNullOrEmpty(devicesecret.Secret)
+ // && !string.IsNullOrEmpty(devicesecret.SecretHash)
+ // && !string.IsNullOrEmpty(devicesecret.DevId))
+ // {
+ // await _suZhouService.PostGarbagesAsync(new GarbagePltC2SDto
+ // {
+ // Weight = returndata.Weight,
+ // secret = devicesecret.Secret,
+ // secrethash = devicesecret.SecretHash,
+ // ScanningTime = timestamp,
+ // DStatus = 0,
+ // deviceid = devicesecret.DevId,
+ // Trash = returndata.trash,
+ // Type = returndata.type
+ // });
+ // }
+ //}
}
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
}
diff --git a/Waste.Application/Waste.Application.xml b/Waste.Application/Waste.Application.xml
index 09dd1cc..d3b4f6d 100644
--- a/Waste.Application/Waste.Application.xml
+++ b/Waste.Application/Waste.Application.xml
@@ -2100,6 +2100,26 @@
记录ID
+
+
+ 日志上报
+
+
+
+
+ 机器码
+
+
+
+
+ 位置
+
+
+
+
+ 错误信息
+
+
设备对接接口
@@ -2158,6 +2178,12 @@
+
+
+ BUG上报
+
+
+
正式升级
diff --git a/Waste.Web.Core/Startup.cs b/Waste.Web.Core/Startup.cs
index ffab21b..01b439d 100644
--- a/Waste.Web.Core/Startup.cs
+++ b/Waste.Web.Core/Startup.cs
@@ -5,10 +5,12 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
+using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Nirvana.Common;
using Serilog;
+using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Waste.Core;
diff --git a/Waste.Web.Entry/Properties/PublishProfiles/waste.ybhdmob.com.pubxml.user b/Waste.Web.Entry/Properties/PublishProfiles/waste.ybhdmob.com.pubxml.user
index aee5805..310e0ab 100644
--- a/Waste.Web.Entry/Properties/PublishProfiles/waste.ybhdmob.com.pubxml.user
+++ b/Waste.Web.Entry/Properties/PublishProfiles/waste.ybhdmob.com.pubxml.user
@@ -5,6 +5,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<_PublishTargetUrl>D:\webpublish\waste.ybhdmob.com
- True|2021-08-01T05:49:38.4071985Z;True|2021-08-01T13:36:45.5372120+08:00;True|2021-08-01T11:00:19.6165520+08:00;True|2021-08-01T10:38:51.4029710+08:00;True|2021-07-31T20:27:53.6583811+08:00;True|2021-07-31T18:35:23.4214441+08:00;True|2021-07-31T17:34:14.0712243+08:00;True|2021-07-31T14:50:43.2065556+08:00;True|2021-07-30T17:59:30.2223340+08:00;True|2021-07-30T17:57:35.9412910+08:00;True|2021-07-30T17:07:58.3305971+08:00;True|2021-07-30T17:04:10.9244859+08:00;True|2021-07-30T17:02:12.1943634+08:00;True|2021-07-30T16:16:22.2838331+08:00;True|2021-07-30T15:05:26.5664155+08:00;True|2021-07-30T14:57:59.1966108+08:00;True|2021-07-30T14:54:25.8172908+08:00;True|2021-07-30T14:52:20.9209995+08:00;True|2021-07-30T14:35:29.5239463+08:00;True|2021-07-30T09:32:38.2676032+08:00;True|2021-07-30T09:14:42.6170851+08:00;True|2021-07-29T19:06:09.1449349+08:00;True|2021-06-11T08:16:29.9542894+08:00;True|2021-06-04T14:46:02.2707457+08:00;True|2021-06-02T15:08:52.8245632+08:00;True|2021-06-02T15:05:50.3614099+08:00;True|2021-06-02T14:59:32.3690948+08:00;True|2021-06-02T14:10:25.1182836+08:00;True|2021-06-02T14:09:54.9215833+08:00;True|2021-06-01T10:41:54.9488501+08:00;True|2021-06-01T10:38:56.0283198+08:00;True|2021-05-28T13:59:02.2308877+08:00;True|2021-05-28T11:56:26.6796406+08:00;True|2021-05-28T11:28:00.4087907+08:00;True|2021-05-27T16:18:09.5993838+08:00;True|2021-05-27T16:07:31.3484951+08:00;True|2021-05-27T11:30:37.9119310+08:00;True|2021-05-27T11:28:35.5374674+08:00;True|2021-05-27T08:00:09.1625592+08:00;True|2021-05-26T20:42:17.0852150+08:00;True|2021-05-26T20:36:49.7527415+08:00;True|2021-05-25T17:57:31.8791293+08:00;True|2021-05-25T13:49:29.6488978+08:00;True|2021-05-25T13:48:24.6686105+08:00;True|2021-05-25T13:25:41.2512493+08:00;True|2021-05-24T17:55:33.3800078+08:00;True|2021-05-20T14:35:30.6957985+08:00;True|2021-05-20T13:17:22.6192995+08:00;True|2021-05-20T10:51:38.1268169+08:00;True|2021-05-19T19:50:03.7000224+08:00;True|2021-05-19T19:44:27.2518811+08:00;True|2021-05-19T19:43:26.5916681+08:00;True|2021-05-19T19:36:29.3197365+08:00;True|2021-05-19T19:30:00.3802430+08:00;True|2021-05-19T17:55:23.7939835+08:00;True|2021-05-19T11:05:17.9043392+08:00;True|2021-05-19T10:19:38.4839988+08:00;True|2021-05-19T10:17:19.7430612+08:00;True|2021-05-19T10:13:23.0031721+08:00;True|2021-05-19T10:06:03.9881599+08:00;True|2021-05-18T14:39:03.8876574+08:00;True|2021-05-18T14:23:46.9818836+08:00;True|2021-05-18T14:19:56.2382079+08:00;True|2021-05-18T11:29:53.5497590+08:00;True|2021-05-18T11:16:18.0123853+08:00;True|2021-05-17T18:59:52.4159105+08:00;True|2021-05-17T18:53:37.9438984+08:00;True|2021-05-17T18:48:14.9625161+08:00;True|2021-05-17T17:46:03.7723404+08:00;True|2021-05-17T17:14:20.2312990+08:00;True|2021-05-17T16:44:34.5837616+08:00;True|2021-05-17T16:25:20.1087804+08:00;True|2021-05-17T11:35:27.9388562+08:00;
+ True|2021-08-02T08:39:27.2332369Z;True|2021-08-02T15:07:40.7995318+08:00;True|2021-08-02T14:32:29.6885424+08:00;True|2021-08-02T14:31:18.6578543+08:00;True|2021-08-02T14:27:57.1301002+08:00;True|2021-08-02T10:55:40.3542370+08:00;True|2021-08-02T09:44:28.0994056+08:00;True|2021-08-01T13:49:38.4071985+08:00;True|2021-08-01T13:36:45.5372120+08:00;True|2021-08-01T11:00:19.6165520+08:00;True|2021-08-01T10:38:51.4029710+08:00;True|2021-07-31T20:27:53.6583811+08:00;True|2021-07-31T18:35:23.4214441+08:00;True|2021-07-31T17:34:14.0712243+08:00;True|2021-07-31T14:50:43.2065556+08:00;True|2021-07-30T17:59:30.2223340+08:00;True|2021-07-30T17:57:35.9412910+08:00;True|2021-07-30T17:07:58.3305971+08:00;True|2021-07-30T17:04:10.9244859+08:00;True|2021-07-30T17:02:12.1943634+08:00;True|2021-07-30T16:16:22.2838331+08:00;True|2021-07-30T15:05:26.5664155+08:00;True|2021-07-30T14:57:59.1966108+08:00;True|2021-07-30T14:54:25.8172908+08:00;True|2021-07-30T14:52:20.9209995+08:00;True|2021-07-30T14:35:29.5239463+08:00;True|2021-07-30T09:32:38.2676032+08:00;True|2021-07-30T09:14:42.6170851+08:00;True|2021-07-29T19:06:09.1449349+08:00;True|2021-06-11T08:16:29.9542894+08:00;True|2021-06-04T14:46:02.2707457+08:00;True|2021-06-02T15:08:52.8245632+08:00;True|2021-06-02T15:05:50.3614099+08:00;True|2021-06-02T14:59:32.3690948+08:00;True|2021-06-02T14:10:25.1182836+08:00;True|2021-06-02T14:09:54.9215833+08:00;True|2021-06-01T10:41:54.9488501+08:00;True|2021-06-01T10:38:56.0283198+08:00;True|2021-05-28T13:59:02.2308877+08:00;True|2021-05-28T11:56:26.6796406+08:00;True|2021-05-28T11:28:00.4087907+08:00;True|2021-05-27T16:18:09.5993838+08:00;True|2021-05-27T16:07:31.3484951+08:00;True|2021-05-27T11:30:37.9119310+08:00;True|2021-05-27T11:28:35.5374674+08:00;True|2021-05-27T08:00:09.1625592+08:00;True|2021-05-26T20:42:17.0852150+08:00;True|2021-05-26T20:36:49.7527415+08:00;True|2021-05-25T17:57:31.8791293+08:00;True|2021-05-25T13:49:29.6488978+08:00;True|2021-05-25T13:48:24.6686105+08:00;True|2021-05-25T13:25:41.2512493+08:00;True|2021-05-24T17:55:33.3800078+08:00;True|2021-05-20T14:35:30.6957985+08:00;True|2021-05-20T13:17:22.6192995+08:00;True|2021-05-20T10:51:38.1268169+08:00;True|2021-05-19T19:50:03.7000224+08:00;True|2021-05-19T19:44:27.2518811+08:00;True|2021-05-19T19:43:26.5916681+08:00;True|2021-05-19T19:36:29.3197365+08:00;True|2021-05-19T19:30:00.3802430+08:00;True|2021-05-19T17:55:23.7939835+08:00;True|2021-05-19T11:05:17.9043392+08:00;True|2021-05-19T10:19:38.4839988+08:00;True|2021-05-19T10:17:19.7430612+08:00;True|2021-05-19T10:13:23.0031721+08:00;True|2021-05-19T10:06:03.9881599+08:00;True|2021-05-18T14:39:03.8876574+08:00;True|2021-05-18T14:23:46.9818836+08:00;True|2021-05-18T14:19:56.2382079+08:00;True|2021-05-18T11:29:53.5497590+08:00;True|2021-05-18T11:16:18.0123853+08:00;True|2021-05-17T18:59:52.4159105+08:00;True|2021-05-17T18:53:37.9438984+08:00;True|2021-05-17T18:48:14.9625161+08:00;True|2021-05-17T17:46:03.7723404+08:00;True|2021-05-17T17:14:20.2312990+08:00;True|2021-05-17T16:44:34.5837616+08:00;True|2021-05-17T16:25:20.1087804+08:00;True|2021-05-17T11:35:27.9388562+08:00;
\ No newline at end of file