ningshuxia
2022-11-22 a5f4bf474fddbc129708f4ddb92eaaafc6ff1f73
Server/IStation.Server.SZJTKT/helper/RequestReceivedHelper.cs
文件名从 Server/IStation.DataDocking.Socket.Custom/helper/RequestReceivedHelper.cs 修改
@@ -29,11 +29,63 @@
                var bytes = packageInfo.Body;
                if (!Valid(bytes))
                {
                    SZJTKTLogHelper.Error(" bytes  Validation failed!");
                    SZJTKTLogHelper.Error(" bytes Validation failed!");
                    return;
                }
                var appParas = AppParasHelper.Get();
                if (appParas == null || appParas.RuleItems == null)
                {
                    SZJTKTLogHelper.Error(" json is null");
                    return;
                }
                var byte4 = new byte[4];
                //鏁版嵁璇诲彇鏃ユ湡
                Array.Copy(bytes, 13, byte4, 0, 4);
                var date = Bytes2Int4(byte4);
                //鏁版嵁璇诲彇鏃堕棿
                Array.Copy(bytes, 17, byte4, 0, 4);
                var time = Bytes2Int4(byte4);
                var hmsStr = time.ToString();
                if (hmsStr.Length < 6)
                    hmsStr = "0" + hmsStr;
                var hms = hmsStr.Substring(0, 2) + ":" + hmsStr.Substring(2, 2) + ":" + hmsStr.Substring(4, 2);
                var strTime = $"{date} {hms}";
                DateTime dataTime = DateTime.ParseExact(strTime.ToString(), "yyyyMMdd hh:mm:ss", System.Globalization.CultureInfo.CurrentCulture);
                var list = new List<Model.MonitorDataDockingSrcRecord>();
                foreach (var x in appParas.RuleItems)
                {
                    var record = new Model.MonitorDataDockingSrcRecord();
                    record.SignId = x.SignId;
                    record.RecordType = Model.eMonitorType.General;
                    record.SrcTime = dataTime;
                    record.SrcValue = null;
                    switch (x.Rule)
                    {
                        case eRule.Double:
                            {
                                var btValue = bytes.Skip((x.Index - 1)).Take(x.Size).ToArray();
                                record.SrcValue = Bytes2Double(btValue).ToString();
                            }
                            break;
                        case eRule.Int4:
                            {
                                var btValue = bytes.Skip((x.Index - 1)).Take(x.Size).ToArray();
                                record.SrcValue = Bytes2Int4(btValue).ToString();
                            }
                            break;
                        case eRule.Int32:
                            {
                                var btValue = bytes.Skip((x.Index - 1)).Take(x.Size).ToArray();
                                record.SrcValue = Bytes2Int32(btValue).ToString();
                            }
                            break;
                        default: break;
                    }
                    list.Add(record);
                }
            });
@@ -96,7 +148,7 @@
            //鐬椂娴侀噺锛宮3/h 
            Array.Copy(instrution_bts, 21, byte4, 0, 4);
            Array.Copy(instrution_bts, 21, byte4, 0, 4);
            list.Add(new Model.MonitorDataDockingSrcRecord()
            {
                SignId = "1590274355240243200",