| | |
| | | //è·åç³»ç»åæ° |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | |
| | | |
| | | |
| | | #region 设å¤åå¸ è®¾å¤ç»å®ççäº§èµæºä¸æ£å¨ç产çå·¥å |
| | | |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 设å¤è¿è¡åçï¼è·åé¨é¨-è®¾å¤ æ ç¶å¾ |
| | | private class HEquipTreeList_DAQ_Node |
| | | { |
| | | public int id { get; set; } |
| | | public string title { get; set; } |
| | | public List<HEquipTreeList_DAQ_Node> children { get; set; } |
| | | } |
| | | |
| | | |
| | | [Route("DAQ_EquipRunningSlice/GetHEquipTreeList_DAQ")] |
| | | [HttpGet] |
| | | public object Sc_HEquipStateDistribution_Souce(string sWhere) |
| | | { |
| | | try |
| | | { |
| | | List<HEquipTreeList_DAQ_Node> treeArr = new List<HEquipTreeList_DAQ_Node>(); |
| | | // è®°å½é¨é¨æ¯å¦å·²ç»å å
¥treeArr(ä¸å¯éå¤å å
¥) |
| | | HashSet<String> HDeptSet = new HashSet<String>(); |
| | | |
| | | ds = oCN.RunProcReturn($@"select hmainid HEquipID, 设å¤åç§° HEquipName, HDeptID HDeptID, 使ç¨é¨é¨ HDeptName from h_v_Gy_EquipFileMainList |
| | | {sWhere} |
| | | order by HEquipName asc", "h_v_Gy_EquipFileMainList"); |
| | | |
| | | foreach(DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | int HDeptID = int.Parse(row["HDeptID"].ToString()); |
| | | string HDeptName = row["HDeptName"] as string; |
| | | int HEquipID = int.Parse(row["HEquipID"].ToString()); |
| | | string HEquipName = row["HEquipName"] as string; |
| | | |
| | | if (!HDeptSet.Contains(row["HDeptID"].ToString())) |
| | | { |
| | | // 没æé¨é¨å¯¹åºçä¸çº§èç¹ï¼åæ·»å ä¸çº§èç¹ |
| | | treeArr.Add(new HEquipTreeList_DAQ_Node |
| | | { |
| | | id = int.Parse(row["HDeptID"].ToString()), |
| | | title = row["HDeptName"].ToString(), |
| | | children = new List<HEquipTreeList_DAQ_Node>() |
| | | }); |
| | | |
| | | // é¨é¨IDæ·»å å°Setï¼ç¡®ä¿å¯ä¸æ§ |
| | | HDeptSet.Add(row["HDeptID"].ToString()); |
| | | } |
| | | |
| | | // é¨é¨å¯¹å°çä¸çº§èç¹å·²ç»è®¾ç½®å¥½ï¼è®¾ç½®äºçº§èç¹ |
| | | HEquipTreeList_DAQ_Node Node = treeArr.First(item => item.id == HDeptID); |
| | | Node.children.Add(new HEquipTreeList_DAQ_Node |
| | | { |
| | | id = HEquipID, |
| | | title = HEquipName, |
| | | children = new List<HEquipTreeList_DAQ_Node>() |
| | | }); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ¥è¯¢æå"; |
| | | objJsonResult.data = JArray.FromObject(treeArr); |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.Message.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 设å¤è¿è¡åç è¿å设å¤ç¶æ å¾è¡¨æ°æ® (饼å¾) |
| | | [Route("DAQ_EquipRunningSlice/GetHEquipStatusReportList_DAQ")] |
| | | [HttpGet] |
| | | public object GetHEquipStatusReportList_DAQ(string HEquipID, string HDeptID, string HBeginDate, string HEndDate, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | string sql = "select * from h_v_Sb_EquipRunningStatusReport where 1 = 1"; |
| | | if(!string.IsNullOrWhiteSpace(HEquipID) && HEquipID != "0") |
| | | { |
| | | sql += $" and HEquipID = {HEquipID}"; |
| | | } |
| | | if(!string.IsNullOrWhiteSpace(HDeptID) && HDeptID != "0") |
| | | { |
| | | sql += $" and HDeptID = {HDeptID}"; |
| | | } |
| | | if(!string.IsNullOrWhiteSpace(HBeginDate) && !string.IsNullOrWhiteSpace(HEndDate)) |
| | | { |
| | | sql += $"and (æå±æ¥æ between CONVERT(DATETIME, '{HBeginDate} 00:00:00', 120) AND CONVERT(DATETIME, '{HEndDate} 23:59:59', 120))"; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipRunningStatusReport"); |
| | | |
| | | //æ·»å åå |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//è·åå°DataColumnå对象çåå |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥è¯¢æ°æ®å¼å¸¸ï¼è¯·ä¸ç®¡çåèç³»ï¼" + ex.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 设å¤è¿è¡åç è¿å设å¤ç¶æ å¾è¡¨æ°æ® (æ¶åºå¾) |
| | | [Route("DAQ_EquipRunningSlice/GetHEquipStatusReportList2_DAQ")] |
| | | [HttpGet] |
| | | public object GetHEquipStatusReportList2_DAQ(string HEquipID, string HDeptID, string HBeginDate, string HEndDate, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | ds = oCN.RunProcReturn($@"exec h_p_DAQ_EquipTimeLineReport {HEquipID}, {HDeptID}, N'{HBeginDate}', N'{HEndDate}'", "h_p_DAQ_EquipTimeLineReport"); |
| | | |
| | | |
| | | // åå§åç»æ JObject |
| | | JObject result = new JObject(); |
| | | // ææ¶é´å¯¹è¡¨æ¥è¯¢åºæ¥çæ°æ®è¿è¡åç» |
| | | DataTable table = ds.Tables[0]; |
| | | var groupedData = table.Rows.Cast<DataRow>() |
| | | .GroupBy(row => |
| | | { |
| | | // ååºæ¶é´åæ®µå¹¶è½¬ä¸ºæ¥æï¼èªå¨å¿½ç¥æ¶åç§ï¼ |
| | | DateTime time = Convert.ToDateTime(row["æ¶é´"]); |
| | | return time.ToString("yyyy-MM-dd"); // åç» Key |
| | | }); |
| | | |
| | | foreach (var group in groupedData) |
| | | { |
| | | string dateKey = group.Key; |
| | | JArray dataArray = new JArray(); |
| | | |
| | | foreach (DataRow row in group) |
| | | { |
| | | JObject rowObj = new JObject(); |
| | | |
| | | // æè¿ä¸è¡çææåé½è½¬æ EChartså¯ä»¥è¯»åçdata对象 |
| | | foreach (DataColumn col in table.Columns) |
| | | { |
| | | |
| | | rowObj[col.ColumnName] = row[col] != DBNull.Value |
| | | ? JToken.FromObject(row[col]) |
| | | : null; |
| | | } |
| | | |
| | | dataArray.Add(rowObj); |
| | | } |
| | | |
| | | // å å
¥æç»ç»æ |
| | | result[dateKey] = dataArray; |
| | | } |
| | | |
| | | //æ·»å åå |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//è·åå°DataColumnå对象çåå |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = result; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥è¯¢æ°æ®å¼å¸¸ï¼è¯·ä¸ç®¡çåèç³»ï¼" + ex.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 设å¤é©¾é©¶è± æ ¹æ®é¨é¨æ¥è¯¢å¯¹åºçè®¾å¤ |
| | | |
| | | [Route("Sc_HEquipStateDistribution/Get_HEquipStateList")] |
| | | [HttpGet] |
| | | public object Get_HEquipStateList(string HDeptID, string user, int OrganizationID) |
| | | { |
| | | try |
| | | { |
| | | string sql1 = string.Format("exec h_p_sc_HDeptEquipList {0},{1}", HDeptID, OrganizationID); |
| | | |
| | | ds = oCN.RunProcReturn(sql1, "h_p_sc_HDeptEquipList"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |