|
|
@@ -1,527 +0,0 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.IO;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using static YSAI.Unility.PlcDataParseTool._ACFA;
|
|
|
-
|
|
|
-namespace YSAI.Unility
|
|
|
-{
|
|
|
- /// <summary>
|
|
|
- /// PLC数据解析工具
|
|
|
- /// </summary>
|
|
|
- public class PlcDataParseTool
|
|
|
- {
|
|
|
- ///// <summary>
|
|
|
- ///// 获取消息
|
|
|
- ///// </summary>
|
|
|
- //public class Message
|
|
|
- //{
|
|
|
- // public Message()
|
|
|
- // {
|
|
|
- // if (messageBodies == null)
|
|
|
- // {
|
|
|
- // messageBodies = JsonTool.StringToJsonEntity<List<MessageBody>>(File.ReadAllText("config//message.json"));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // public string GetMessage(string id)
|
|
|
- // {
|
|
|
- // if (messageBodies == null)
|
|
|
- // {
|
|
|
- // messageBodies = JsonTool.StringToJsonEntity<List<MessageBody>>(File.ReadAllText("config//message.json"));
|
|
|
- // }
|
|
|
- // MessageBody messageBody = messageBodies.Find(c => c.id.Equals(id));
|
|
|
- // if (messageBody == null)
|
|
|
- // {
|
|
|
- // return string.Empty;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // return messageBody.message;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // public List<MessageBody> messageBodies;
|
|
|
- // public class MessageBody
|
|
|
- // {
|
|
|
- // public string id { get; set; }
|
|
|
- // public string message { get; set; }
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 当前报警消息
|
|
|
- /// </summary>
|
|
|
- public class _ACFA
|
|
|
- {
|
|
|
- public string 消息数量 { get; set; }
|
|
|
- public List<dataarr> 消息详情 { get; set; }
|
|
|
- public class dataarr
|
|
|
- {
|
|
|
- public string 消息编号 { get; set; }
|
|
|
- public string 文本编号 { get; set; }
|
|
|
- public string 优先级 { get; set; }
|
|
|
- public string 消息状态 { get; set; }
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 当前报警消息
|
|
|
- /// </summary>
|
|
|
- /// <param name="data">原始数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string ACFA(string data)
|
|
|
- {
|
|
|
- //实例化消息类
|
|
|
- _ACFA message = new _ACFA();
|
|
|
- //实例化集合对象
|
|
|
- if (message.消息详情 == null)
|
|
|
- {
|
|
|
- message.消息详情 = new List<_ACFA.dataarr>();
|
|
|
- }
|
|
|
- //移除两侧大括号
|
|
|
- data = data.Replace("{", "").Replace("}", "");
|
|
|
- //转换成字节数据
|
|
|
- byte[] bytes = ByteTool.StrByteToBytes(data);
|
|
|
- //获取消息条数
|
|
|
- int MessageCount = ByteTool.ByteToInt(new byte[] { bytes[70], bytes[71], bytes[72], bytes[73] });
|
|
|
- //赋值
|
|
|
- message.消息数量 = MessageCount.ToString();
|
|
|
- //掐头去尾
|
|
|
- bytes = ByteTool.BytesDispose(bytes, 74, 0);
|
|
|
- //得到所需数据(16位16位分割)
|
|
|
- List<byte[]> bytearr = ByteTool.ByteListSegmentation(bytes, 16);
|
|
|
- //循环检索
|
|
|
- foreach (byte[] b in bytearr)
|
|
|
- {
|
|
|
- //详情对象
|
|
|
- _ACFA.dataarr dataarr = new _ACFA.dataarr();
|
|
|
- //在进行4位4位分割
|
|
|
- List<byte[]> bytearr2 = ByteTool.ByteListSegmentation(b, 4);
|
|
|
- for (int i = 0; i < bytearr2.Count; i++)
|
|
|
- {
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0: //消息编号
|
|
|
- byte[] byte1 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.消息编号 = $"{ByteTool.ByteToInt(byte1[3])}.{ByteTool.ByteToInt(byte1[2])}.{ByteTool.ByteToInt(new byte[] { byte1[0], byte1[1] })}";
|
|
|
- break;
|
|
|
- case 1: //文本ID编号
|
|
|
- byte[] byte2 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.文本编号 = $"{ByteTool.ByteToInt(byte2[3])}.{ByteTool.ByteToInt(byte2[2])}.{ByteTool.ByteToInt(new byte[] { byte2[0], byte2[1] })}";
|
|
|
- break;
|
|
|
- case 2: //优先级
|
|
|
- dataarr.优先级 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 3: //消息状态
|
|
|
- dataarr.消息状态 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //添加至消息集合
|
|
|
- message.消息详情.Add(dataarr);
|
|
|
- if (message.消息详情.Count.Equals(MessageCount))
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //直接返回转换好的JSON数据
|
|
|
- return JsonTool.JsonEntityToString(message);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 当前停机消息
|
|
|
- /// </summary>
|
|
|
- public class _ACDI
|
|
|
- {
|
|
|
- public string 消息编号 { get; set; }
|
|
|
- public string 文本编号 { get; set; }
|
|
|
- public string 优先级 { get; set; }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 当前停机消息
|
|
|
- /// </summary>
|
|
|
- /// <param name="data">原始数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string ACDI(string data)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- //实例化消息类
|
|
|
- _ACDI message = new _ACDI();
|
|
|
- //移除两侧大括号
|
|
|
- data = data.Replace("{", "").Replace("}", "");
|
|
|
- //转换成字节数据
|
|
|
- byte[] bytes = ByteTool.StrByteToBytes(data);
|
|
|
- //掐头去尾
|
|
|
- bytes = ByteTool.BytesDispose(bytes, 70, 0);
|
|
|
- //得到所需数据(4位4位分割)
|
|
|
- List<byte[]> bytearr = ByteTool.ByteListSegmentation(bytes, 4);
|
|
|
- //循环检索
|
|
|
- for (int i = 0; i < bytearr.Count; i++)
|
|
|
- {
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0: //消息编号
|
|
|
- byte[] byte1 = ByteTool.BytesDispose(bytearr[i], 0, 0);
|
|
|
- message.消息编号 = $"{ByteTool.ByteToInt(byte1[3])}.{ByteTool.ByteToInt(byte1[2])}.{ByteTool.ByteToInt(new byte[] { byte1[0], byte1[1] })}";
|
|
|
- break;
|
|
|
- case 1: //文本ID编号
|
|
|
- byte[] byte2 = ByteTool.BytesDispose(bytearr[i], 0, 0);
|
|
|
- message.文本编号 = $"{ByteTool.ByteToInt(byte2[3])}.{ByteTool.ByteToInt(byte2[2])}.{ByteTool.ByteToInt(new byte[] { byte2[0], byte2[1] })}";
|
|
|
- break;
|
|
|
- case 2: //优先级
|
|
|
- message.优先级 = ByteTool.ByteToInt(bytearr[i]).ToString();
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- //直接返回转换好的JSON数据
|
|
|
- return JsonTool.JsonEntityToString(message);
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 当前停机分析
|
|
|
- /// </summary>
|
|
|
- public class _SANA
|
|
|
- {
|
|
|
- public string 消息数量 { get; set; }
|
|
|
- public List<dataarr> 消息详情 { get; set; }
|
|
|
- public class dataarr
|
|
|
- {
|
|
|
- public string 消息编号 { get; set; }
|
|
|
- public string 文本编号 { get; set; }
|
|
|
- public string 停机次数 { get; set; }
|
|
|
- public string 停机类型 { get; set; }
|
|
|
- public string 停机时长 { get; set; }
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 当前停机分析
|
|
|
- /// </summary>
|
|
|
- /// <param name="data">原始数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string SANA(string data)
|
|
|
- {
|
|
|
- //实例化消息类
|
|
|
- _SANA message = new _SANA();
|
|
|
- //实例化集合对象
|
|
|
- if (message.消息详情 == null)
|
|
|
- {
|
|
|
- message.消息详情 = new List<_SANA.dataarr>();
|
|
|
- }
|
|
|
- //移除两侧大括号
|
|
|
- data = data.Replace("{", "").Replace("}", "");
|
|
|
- //转换成字节数据
|
|
|
- byte[] bytes = ByteTool.StrByteToBytes(data);
|
|
|
- //获取消息条数
|
|
|
- int MessageCount = ByteTool.ByteToInt(new byte[] { bytes[70], bytes[71], bytes[72], bytes[73] });
|
|
|
- //赋值
|
|
|
- message.消息数量 = MessageCount.ToString();
|
|
|
- //掐头去尾
|
|
|
- bytes = ByteTool.BytesDispose(bytes, 74, 0);
|
|
|
- //得到所需数据(16位16位分割)
|
|
|
- List<byte[]> bytearr = ByteTool.ByteListSegmentation(bytes, 20);
|
|
|
- //循环检索
|
|
|
- foreach (byte[] b in bytearr)
|
|
|
- {
|
|
|
- //详情对象
|
|
|
- _SANA.dataarr dataarr = new _SANA.dataarr();
|
|
|
- //在进行4位4位分割
|
|
|
- List<byte[]> bytearr2 = ByteTool.ByteListSegmentation(b, 4);
|
|
|
- for (int i = 0; i < bytearr2.Count; i++)
|
|
|
- {
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0: //消息编号
|
|
|
- byte[] byte1 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.消息编号 = $"{ByteTool.ByteToInt(byte1[3])}.{ByteTool.ByteToInt(byte1[2])}.{ByteTool.ByteToInt(new byte[] { byte1[0], byte1[1] })}";
|
|
|
- break;
|
|
|
- case 1: //文本编号
|
|
|
- byte[] byte2 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.文本编号 = $"{ByteTool.ByteToInt(byte2[3])}.{ByteTool.ByteToInt(byte2[2])}.{ByteTool.ByteToInt(new byte[] { byte2[0], byte2[1] })}";
|
|
|
- break;
|
|
|
- case 2: //停机次数
|
|
|
- dataarr.停机次数 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 3: //停机类型
|
|
|
- dataarr.停机类型 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 4: //停机时长
|
|
|
- dataarr.停机时长 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //添加至消息集合
|
|
|
- message.消息详情.Add(dataarr);
|
|
|
- if (message.消息详情.Count.Equals(MessageCount))
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //直接返回转换好的JSON数据
|
|
|
- return JsonTool.JsonEntityToString(message);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 停机流水原因
|
|
|
- /// </summary>
|
|
|
- public class _SHIS
|
|
|
- {
|
|
|
- public string 消息数量 { get; set; }
|
|
|
- public List<dataarr> 消息详情 { get; set; }
|
|
|
- public class dataarr
|
|
|
- {
|
|
|
- public string 通过分析记录 { get; set; }
|
|
|
- public string 消息编号 { get; set; }
|
|
|
- public string 文本编号 { get; set; }
|
|
|
- public string 开始时间 { get; set; }
|
|
|
- public string 结束时间 { get; set; }
|
|
|
- public string 停机时长 { get; set; }
|
|
|
- public string 停机编号 { get; set; }
|
|
|
- public string 详情开始时间 { get; set; }
|
|
|
- public string 详情结束时间 { get; set; }
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 历史停机原因
|
|
|
- /// </summary>
|
|
|
- /// <param name="data">原始数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string SHIS(string data)
|
|
|
- {
|
|
|
- //实例化消息类
|
|
|
- _SHIS message = new _SHIS();
|
|
|
- //实例化集合对象
|
|
|
- if (message.消息详情 == null)
|
|
|
- {
|
|
|
- message.消息详情 = new List<_SHIS.dataarr>();
|
|
|
- }
|
|
|
- //移除两侧大括号
|
|
|
- data = data.Replace("{", "").Replace("}", "");
|
|
|
- //转换成字节数据
|
|
|
- byte[] bytes = ByteTool.StrByteToBytes(data);
|
|
|
- //获取消息条数
|
|
|
- int MessageCount = ByteTool.ByteToInt(new byte[] { bytes[70], bytes[71], bytes[72], bytes[73] });
|
|
|
- //赋值
|
|
|
- message.消息数量 = MessageCount.ToString();
|
|
|
- //掐头去尾
|
|
|
- bytes = ByteTool.BytesDispose(bytes, 74, 0);
|
|
|
- //得到所需数据(16位16位分割)
|
|
|
- List<byte[]> bytearr = ByteTool.ByteListSegmentation(bytes, 42);
|
|
|
- //时间
|
|
|
- DateTime dt;
|
|
|
- int ri;
|
|
|
- int yue;
|
|
|
- int nian;
|
|
|
- int shi;
|
|
|
- int fen;
|
|
|
- int miao;
|
|
|
-
|
|
|
- //循环检索
|
|
|
- foreach (byte[] b in bytearr)
|
|
|
- {
|
|
|
- //详情对象
|
|
|
- _SHIS.dataarr dataarr = new _SHIS.dataarr();
|
|
|
- //在进行4位4位分割
|
|
|
- List<byte[]> bytearr2 = ByteTool.ByteListSegmentation(b, 4);
|
|
|
- for (int i = 0; i < bytearr2.Count; i++)
|
|
|
- {
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- dataarr.通过分析记录 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 1: //消息编号
|
|
|
- byte[] byte1 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.消息编号 = $"{ByteTool.ByteToInt(byte1[3])}.{ByteTool.ByteToInt(byte1[2])}.{ByteTool.ByteToInt(new byte[] { byte1[0], byte1[1] })}";
|
|
|
- break;
|
|
|
- case 2: //文本编号
|
|
|
- byte[] byte2 = ByteTool.BytesDispose(bytearr2[i], 0, 0);
|
|
|
- dataarr.文本编号 = $"{ByteTool.ByteToInt(byte2[3])}.{ByteTool.ByteToInt(byte2[2])}.{ByteTool.ByteToInt(new byte[] { byte2[0], byte2[1] })}";
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- dt = DateTime.Parse("1970-01-01 00:00:00").AddSeconds(ByteTool.ByteToInt(bytearr2[i]));
|
|
|
- dt = dt.AddSeconds(8 * 60 * 60);
|
|
|
- dataarr.开始时间 = dt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- dt = DateTime.Parse("1970-01-01 00:00:00").AddSeconds(ByteTool.ByteToInt(bytearr2[i]));
|
|
|
- dt = dt.AddSeconds(8 * 60 * 60);
|
|
|
- dataarr.结束时间 = dt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- dataarr.停机时长 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 6:
|
|
|
- dataarr.停机编号 = ByteTool.ByteToInt(bytearr2[i]).ToString();
|
|
|
- break;
|
|
|
- case 7:
|
|
|
- ri = ByteTool.ByteToInt((byte)Int32.Parse(b[28].ToString(), System.Globalization.NumberStyles.HexNumber));
|
|
|
- yue = ByteTool.ByteToInt((byte)Int32.Parse(b[29].ToString(), System.Globalization.NumberStyles.HexNumber));
|
|
|
- nian = ByteTool.ByteToInt(new byte[] { b[30], b[31] });
|
|
|
- shi = ByteTool.ByteToInt(b[32]);
|
|
|
- fen = ByteTool.ByteToInt(b[33]);
|
|
|
- miao = ByteTool.ByteToInt(b[34]);
|
|
|
- dataarr.详情开始时间 = $"{nian}-{yue}-{ri} {shi}:{fen}:{miao}";
|
|
|
- break;
|
|
|
- case 8:
|
|
|
- ri = ByteTool.ByteToInt((byte)Int32.Parse(b[35].ToString(), System.Globalization.NumberStyles.HexNumber));
|
|
|
- yue = ByteTool.ByteToInt((byte)Int32.Parse(b[36].ToString(), System.Globalization.NumberStyles.HexNumber));
|
|
|
- nian = ByteTool.ByteToInt(new byte[] { b[37], b[38] });
|
|
|
- shi = ByteTool.ByteToInt(b[39]);
|
|
|
- fen = ByteTool.ByteToInt(b[40]);
|
|
|
- miao = ByteTool.ByteToInt(b[41]);
|
|
|
- dataarr.详情结束时间 = $"{nian}-{yue}-{ri} {shi}:{fen}:{miao}";
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //添加至消息集合
|
|
|
- message.消息详情.Add(dataarr);
|
|
|
- if (message.消息详情.Count.Equals(MessageCount))
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //直接返回转换好的JSON数据
|
|
|
- return JsonTool.JsonEntityToString(message);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 班次
|
|
|
- /// </summary>
|
|
|
- public class _SHFT
|
|
|
- {
|
|
|
- public List<dataarr> 班次 { get; set; }
|
|
|
- public class dataarr
|
|
|
- {
|
|
|
- public string 星期 { get; set; }
|
|
|
- public string 第一班时间 { get; set; }
|
|
|
- public string 第二班时间 { get; set; }
|
|
|
- public string 第三班时间 { get; set; }
|
|
|
- public string 第四班时间 { get; set; }
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 班次
|
|
|
- /// </summary>
|
|
|
- /// <param name="data">原始数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string SHFT(string data)
|
|
|
- {
|
|
|
- //实例化消息类
|
|
|
- _SHFT message = new _SHFT();
|
|
|
- //实例化集合对象
|
|
|
- if (message.班次 == null)
|
|
|
- {
|
|
|
- message.班次 = new List<_SHFT.dataarr>();
|
|
|
- }
|
|
|
- //移除两侧大括号
|
|
|
- data = data.Replace("{", "").Replace("}", "");
|
|
|
- //转换成字节数据
|
|
|
- byte[] bytes = ByteTool.StrByteToBytes(data);
|
|
|
- //掐头去尾
|
|
|
- bytes = ByteTool.BytesDispose(bytes, 297, 0);
|
|
|
- //得到所需数据(16位16位分割)
|
|
|
- List<byte[]> bytearr = ByteTool.ByteListSegmentation(bytes, 32);
|
|
|
- List<byte[]> bytearr3;
|
|
|
- int index1;
|
|
|
- int index2;
|
|
|
- string[] Day = new string[] { "7", "1", "2", "3", "4", "5", "6" };
|
|
|
- string week = Day[Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))].ToString();
|
|
|
- int xq =int.Parse(week);
|
|
|
- //循环检索
|
|
|
- foreach (byte[] b in bytearr)
|
|
|
- {
|
|
|
- //详情对象
|
|
|
- _SHFT.dataarr dataarr = new _SHFT.dataarr();
|
|
|
- //在进行4位4位分割
|
|
|
- List<byte[]> bytearr2 = ByteTool.ByteListSegmentation(b, 8);
|
|
|
- for (int i = 0; i < bytearr2.Count; i++)
|
|
|
- {
|
|
|
-
|
|
|
- switch (i)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- bytearr3 = ByteTool.ByteListSegmentation(bytearr2[i], 4);
|
|
|
- index1 = ByteTool.ByteToInt(bytearr3[0]);
|
|
|
- index2 = ByteTool.ByteToInt(bytearr3[1]);
|
|
|
- dataarr.第一班时间 = $"{SecondToHour(index1)} - {SecondToHour(index2)} 点";
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- bytearr3 = ByteTool.ByteListSegmentation(bytearr2[i], 4);
|
|
|
- index1 = ByteTool.ByteToInt(bytearr3[0]);
|
|
|
- index2 = ByteTool.ByteToInt(bytearr3[1]);
|
|
|
- dataarr.第二班时间 = $"{SecondToHour(index1)} - {SecondToHour(index2)} 点";
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- bytearr3 = ByteTool.ByteListSegmentation(bytearr2[i], 4);
|
|
|
- index1 = ByteTool.ByteToInt(bytearr3[0]);
|
|
|
- index2 = ByteTool.ByteToInt(bytearr3[1]);
|
|
|
- dataarr.第三班时间 = $"{SecondToHour(index1)} - {SecondToHour(index2)} 点";
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- bytearr3 = ByteTool.ByteListSegmentation(bytearr2[i], 4);
|
|
|
- index1 = ByteTool.ByteToInt(bytearr3[0]);
|
|
|
- index2 = ByteTool.ByteToInt(bytearr3[1]);
|
|
|
- dataarr.第四班时间 = $"{SecondToHour(index1)} - {SecondToHour(index2)} 点";
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (xq > 7)
|
|
|
- {
|
|
|
- xq = 1;
|
|
|
- }
|
|
|
- dataarr.星期 = xq++.ToString();
|
|
|
- //添加至消息集合
|
|
|
- message.班次.Add(dataarr);
|
|
|
- }
|
|
|
- //直接返回转换好的JSON数据
|
|
|
- return JsonTool.JsonEntityToString(message);
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 秒转换小时
|
|
|
- /// </summary>
|
|
|
- /// <param name="time"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private static string SecondToHour(double time)
|
|
|
- {
|
|
|
- int hour = 0;
|
|
|
- int minute = 0;
|
|
|
- int second = 0;
|
|
|
- second = Convert.ToInt32(time);
|
|
|
-
|
|
|
- if (second > 60)
|
|
|
- {
|
|
|
- minute = second / 60;
|
|
|
- second = second % 60;
|
|
|
- }
|
|
|
- if (minute > 60)
|
|
|
- {
|
|
|
- hour = minute / 60;
|
|
|
- minute = minute % 60;
|
|
|
- }
|
|
|
- return (hour % 24 ).ToString() ;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 时间戳转日期(yyyy-MM-dd)
|
|
|
- /// </summary>
|
|
|
- /// <param name="param">数据</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static string TimestampToDate(string param)
|
|
|
- {
|
|
|
- DateTime dateTime = DateTime.Parse("1970-01-01 00:00:00").AddSeconds(double.Parse(param));
|
|
|
- return dateTime.ToString("yyyy-MM-dd");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|