[BackendWorkerService]修改Niagara撈回的資料有科學記號時,型別會轉換錯誤的問題

This commit is contained in:
張家睿 2024-02-07 15:52:11 +08:00
parent 5ab5319116
commit 8efb19af68

View File

@ -1,6 +1,7 @@
using Backend.Models; using Backend.Models;
using BackendWorkerService.Services.Implement; using BackendWorkerService.Services.Implement;
using Dapper; using Dapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -1725,15 +1726,15 @@ namespace BackendWorkerService.Quartz.Jobs
switch (name) switch (name)
{ {
case "min": case "min":
var min = Convert.ToDecimal(real["@val"].ToString()); var min = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@min_rawdata", min); arrangeRawData.Add("@min_rawdata", min);
break; break;
case "max": case "max":
var max = Convert.ToDecimal(real["@val"].ToString()); var max = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@max_rawdata", max); arrangeRawData.Add("@max_rawdata", max);
break; break;
case "avg": case "avg":
var avg = Convert.ToDecimal(real["@val"].ToString()); var avg = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":
@ -1793,15 +1794,15 @@ namespace BackendWorkerService.Quartz.Jobs
switch (name) switch (name)
{ {
case "min": case "min":
var min = Convert.ToDecimal(real["@val"].ToString()); var min = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@min_rawdata", min); arrangeRawData.Add("@min_rawdata", min);
break; break;
case "max": case "max":
var max = Convert.ToDecimal(real["@val"].ToString()); var max = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@max_rawdata", max); arrangeRawData.Add("@max_rawdata", max);
break; break;
case "avg": case "avg":
var avg = Convert.ToDecimal(real["@val"].ToString()); var avg = Decimal.Parse(real["@val"].ToString(), System.Globalization.NumberStyles.Float);
arrangeRawData.Add("@avg_rawdata", avg); arrangeRawData.Add("@avg_rawdata", avg);
break; break;
case "sum": case "sum":