| | |
| | | using Newtonsoft.Json; |
| | | using DLL; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.IO; |
| | | using System.Threading.Tasks; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 设备工艺参数明细行分页查询 |
| | | [Route("Sb_EquipStopBill/getSb_EquipStopBillListPage")] |
| | | [HttpGet] |
| | | public object Sb_EquipBeginBillListPage(string sWhere, string user, int page, int size) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("ModRightNameList", 3, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCn.RunProcReturn("exec h_p_Sb_EquipStopBillMainListPage " + page + "," + size + ",''", "h_p_Sb_EquipStopBillMainListPage"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCn.RunProcReturn("exec h_p_Sb_EquipStopBillMainListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipStopBillMainListPage"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.list = columnNameList; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 设备工艺参数订单点检表删除 |
| | | /// <summary> |
| | |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据号:"+ oBill.omodel.HBillNo+ " 审核成功!"; |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //关闭单据 |
| | | if (!oBill.CloseBill(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) |
| | | |
| | | string sql = ""; |
| | | //关闭前控制===============================================Begin=================================================================== |
| | | sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; |
| | | ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl"); |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.Message = "关闭失败!原因:关闭前前判断失败,无返回信息,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //关闭前控制===============================================End=================================================================== |
| | | |
| | | //关闭提交 |
| | | if (oBill.CloseBill(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "关闭成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 关闭成功!"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //反关闭单据 |
| | | if (!oBill.CancelClose(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) |
| | | |
| | | string sql = ""; |
| | | //反关闭前控制===============================================Begin=================================================================== |
| | | sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; |
| | | ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl"); |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.Message = "反关闭失败!原因:反关闭前前判断失败,无返回信息,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //反关闭前控制===============================================End=================================================================== |
| | | |
| | | //反关闭提交 |
| | | if (oBill.CancelClose(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterUnCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反关闭成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反关闭成功!"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | |
| | | if (bResult) |
| | | { |
| | | |
| | | //自动审核设置 |
| | | if (OperationType == "1") |
| | | { |
| | | objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID |
| | | //系统参数 自动审核 |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.SB_EquipICMOTechParamBill_Check == "Y") //系统参数 自动审核 |
| | | { |
| | | objJsonResult.Verify = "Y"; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | # region 手工点检表出现NG发送信息 |
| | | [Route("SB_EquipICMOTechParamBillController/HSendDDMeg")] |
| | | [HttpGet] |
| | | |
| | | public async Task<object> HSendDDMeg(string HInterID) |
| | | { |
| | | try |
| | | { |
| | | //查询子表是否有NG值 |
| | | ds = oCn.RunProcReturn("select * from SB_EquipICMOTechParamBillMain a inner join SB_EquipICMOTechParamBillSub b on a.HInterID=b.HInterID where b.HResult='NG' and a.HInterID=" + HInterID, "SB_EquipICMOTechParamBillMain"); |
| | | if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count != 0) |
| | | { |
| | | //查询并合并异常工艺参数值 |
| | | string sql = @"SELECT 生产车间, STUFF((SELECT ', ' + CAST(hsubid AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable WHERE InnerTable.生产车间 = OuterTable.生产车间 AND InnerTable.检测结果 = 'NG' AND InnerTable.hmainid ='"+HInterID+"' FOR XML PATH('')), 1, 2, '') AS hsubid,STUFF(( SELECT '; ' + 设备编码 + ' - ' + 工艺参数 + ' - 工艺参数值: ' + CAST(工艺参数值 AS VARCHAR(10)) + ' - 标准值: ' + CAST(标准值 AS VARCHAR(10)) + ' - 上限: ' + CAST(上限 AS VARCHAR(10)) + ' - 下限: ' + CAST(下限 AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable WHERE InnerTable.生产车间 = OuterTable.生产车间 AND InnerTable.检测结果 = 'NG' FOR XML PATH('') ), 1, 2, '') AS 内容 FROM h_v_SB_EquipICMOTechParamBillList_Detail AS OuterTable where OuterTable.hmainid = '" + HInterID + "' GROUP BY 生产车间"; |
| | | ds = oCn.RunProcReturn(sql, "h_v_SB_EquipICMOTechParamBillList_Detail"); |
| | | var HDeptName = ds.Tables[0].Rows[0]["生产车间"].ToString(); |
| | | var HDescription = ds.Tables[0].Rows[0]["内容"].ToString(); |
| | | var HSubID = ds.Tables[0].Rows[0]["hsubid"].ToString(); |
| | | //查询接收人 |
| | | string newSql1 = @"select a.HDingDingUserID 钉钉id,a.Czymc 接收人 from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId |
| | | left join System_UserGroup c on b.GroupId = c.GroupID where c.GroupName = '" + HDeptName + "工艺异常预警接收人'"; |
| | | DataSet dt = oCn.RunProcReturn(newSql1, "Gy_Czygl"); |
| | | if (dt.Tables[0].Rows.Count > 0) |
| | | { |
| | | |
| | | string appKey = ""; |
| | | string appSecret = ""; |
| | | string sReturn = ""; |
| | | string agentIds = ""; |
| | | Cls_DDMsg msg = new Cls_DDMsg(); |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | //系统参数是否 N为本地,Y为斯莫尔 |
| | | if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "N") |
| | | { |
| | | appKey = "dingrsrzhdyn3mlaof95"; |
| | | appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq"; |
| | | agentIds = "3118119317"; |
| | | } |
| | | else if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "Y") |
| | | { |
| | | appKey = "dingkdddbhdcssk7jduw"; |
| | | appSecret = "iv07c-GLfJPnzfJaNAAOfJDl3Z-eODvDAhlInMZCZhGorkle5Evbaxx3ImylvdjQ"; |
| | | agentIds = "3151454458"; |
| | | } |
| | | |
| | | } |
| | | |
| | | //获取企业的access_token的值 |
| | | string response = msg.GetAccessToken(appKey, appSecret); |
| | | JObject responseJson = JObject.Parse(response); |
| | | // 获取access_token的值 |
| | | string accessToken = responseJson["accessToken"].ToString(); |
| | | |
| | | |
| | | string HName = ""; // 用于存储拼接后的钉钉ID |
| | | List<string> dingDingIds = new List<string>(); // 用来存储钉钉ID的集合 |
| | | |
| | | // 拼接钉钉ID |
| | | for (int i = 0; i < dt.Tables[0].Rows.Count; i++) |
| | | { |
| | | dingDingIds.Add(dt.Tables[0].Rows[i]["钉钉id"].ToString()); // 将每个钉钉ID添加到列表中 |
| | | } |
| | | |
| | | // 使用逗号将钉钉ID拼接成一个字符串 |
| | | HName = string.Join(",", dingDingIds); |
| | | //更新为NG的子表字段 未 已发送 1 |
| | | oCn.RunProc("update SB_EquipICMOTechParamBillSub set HSendFlag =1 where HInterID='" + HInterID + "' and HEntryID in(" + HSubID + ")"); |
| | | response = await msg.SendTextMessage(accessToken, agentIds, HName, "0", "false", HDescription); |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "无NG工艺参数!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "发送失败!" + e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |