/// 工单处理 /// <summary> /// 工单处理 /// </summary> /// <param name="flag"></param> /// <param name="msg"></param> /// <returns></returns> private string SaveProcess(ref bool flag, ref string msg) { try { WOrderProcessJsonData jsondata = WOrderProcessJsonData.GetWOrderProcessJsonData(JsonData); if (jsondata == null) { flag = false; msg = "参数错误!"; return(""); } WOrderInfoInfo worderinfo = null; WOrderOperTypeEnum oper = WOrderOperTypeEnum.None; WOrderProcessRightJsonData right = WOrderProcessRightJsonData.GetWOrderProcessRightJsonData(RightData); flag = BLL.WOrderProcess.Instance.ValidateWOrderProcessRight(OrderID, ref msg, ref oper, out worderinfo, right); if (flag == false) { return(""); } int loginuserid = BLL.Util.GetLoginUserID(); SysRightUserInfo sysinfo = BLL.EmployeeSuper.Instance.GetSysRightUserInfo(loginuserid); if (sysinfo == null) { flag = false; msg = "获取不到当前登录人信息!"; return(""); } //处理工单 BLL.WOrderProcess.Instance.WOrderProcessMain(jsondata, sysinfo, oper, worderinfo); flag = true; msg = ""; return(BLL.Util.GetEnumOptText(typeof(WOrderOperTypeEnum), (int)oper)); } catch (Exception ex) { WOrderInfo.ErrorToLog4("工单处理", ex); flag = false; msg = ex.Message; return(""); } }
/// 接口调用 /// <summary> /// 接口调用 /// </summary> /// <param name="jsondata"></param> /// <param name="loginuserid"></param> public void InterfaceCall(WOrderJsonData jsondata, SysRightUserInfo sysinfo) { try { //同步CRM if (jsondata.WOrderInfo.IsSysCRM_Out == 1 && !string.IsNullOrEmpty(jsondata.CRMCustID_Out)) { //jsondata.Common.CRMCustID_Out crm的custid //jsondata.WOrderInfo.VisitType_Out 访问类型id //sysinfo 登录人信息,部门,姓名,id,员工编号等 InserCRMVisitInfo(jsondata, sysinfo); LogForWebForCall("CRM添加访问记录"); } //同步IM接口 //1—会话,2—留言 int imType = jsondata.Common.CallSource_Out == CallSourceEnum.C03_IM对话 ? 1 : 2; int csid = (int)jsondata.Common.RelatedCSID; string orderid = jsondata.WOrderID; if (jsondata.Common.ModuleSource_Out == ModuleSourceEnum.M05_IM个人) { BitAuto.ISDC.CC2012.WebService.IM.IMUtilsServiceHelper server = new WebService.IM.IMUtilsServiceHelper(); server.UpdateCCWorkOrderToIM(imType, csid, orderid); LogForWebForCall("M05_IM个人 回调接口"); } else if (jsondata.Common.ModuleSource_Out == ModuleSourceEnum.M06_IM经销商_新车) { BitAuto.ISDC.CC2012.WebService.IM.IMepUtilsServiceHelper server = new WebService.IM.IMepUtilsServiceHelper(); server.UpdateCCWorkOrderToIM(imType, csid, orderid); LogForWebForCall("M06_IM经销商_新车 回调接口"); } else if (jsondata.Common.ModuleSource_Out == ModuleSourceEnum.M07_IM经销商_二手车) { BitAuto.ISDC.CC2012.WebService.IM.IMtcUtilsServiceHelper server = new WebService.IM.IMtcUtilsServiceHelper(); server.UpdateCCWorkOrderToIM(imType, csid, orderid); LogForWebForCall("M07_IM经销商_二手车 回调接口"); } } catch (Exception ex) { WOrderInfo.ErrorToLog4("接口调用", ex); } }
/// <summary> /// 堆垛机PLC连接的处理逻辑 /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> private static void V_LoopWrite(object Sender, EArgOnHandle_Process e) { string plcID = ((PLCProcesser)Sender).Name; string currentSRMNo = ""; try { var arry_sts = Dic_SRM_STSClass.Where(item => item.Value.address.PLC == plcID).ToList(); var arry_pc = Dic_SRM_PS.Where(item => item.Value.address.PLC == plcID).ToList(); bool f = false; int r = 0; int c = 0; foreach (var pc in arry_pc) { f = pc.Value.LoadFromPLC(e.PLCConn, 4); } int s_finish = 0; int s_fault = 1; int s_runMaintenance = 1; int s_run = 1; int s_FrGrid = 0; int s_FrTier = 0; int s_pattern = 0; int s_FrStand = 0;//站 int s_FrLine = 0; int s_FrGrids = 0; int s_FrTiers = 0; int s_ToStand = 0;//站 int s_ToLine = 0; int s_ToGrid = 0; int s_ToTier = 0; string str; var arry_res = Dic_SRM_Res.Where(item => item.Value.address.PLC == plcID).ToList(); foreach (var res in arry_res) { res.Value.LoadFromPLC(e.PLCConn); //完成信号 s_finish = res.Value.s_finish; //故障 s_fault = res.Value.s_fault; //运行维护 s_runMaintenance = res.Value.s_runMaintenance; //运行信号 s_run = res.Value.s_run; //格 s_FrGrid = res.Value.s_FrGrid; //层 s_FrTier = res.Value.s_FrTier; } #region 当前指令 var arry_dd = Dic_SRM_Request.Where(item => item.Value.address.PLC == plcID).ToList(); foreach (var s in arry_dd) { s.Value.LoadFromPLC(e.PLCConn); int s_serial = s.Value.s_serial; s_pattern = s.Value.s_pattern; //模式 s_FrStand = s.Value.s_FrStand; //站 s_FrLine = s.Value.s_FrLine; s_FrGrids = s.Value.s_FrGrid; s_FrTiers = s.Value.s_FrTier; s_ToStand = s.Value.s_ToStand;//站 s_ToLine = s.Value.s_ToLine; s_ToGrid = s.Value.s_ToGrid; s_ToTier = s.Value.s_ToTier; } #endregion var arry_req = Dic_SRM_Request.Where(item => item.Value.address.PLC == plcID).ToList(); WOrderInfo w = new WOrderInfo(); foreach (var s in arry_req) { //currentSRMNo = s.Key; //s.Value.LoadFromPLC(e.PLCConn); r = s.Value.s_FrStand; c = s.Value.s_ToStand; #region 写入数据 if (s_finish == 1 && s_fault == 0 && s_runMaintenance == 0) { //判断当前指令是否有值 str = w.OrderInfo(s_pattern); //更新数据库 if (str == "出库") { w.OutAccount(s_FrLine, s_FrGrids, s_FrTiers, s_ToStand); } else if (str == "入库") { w.InAccount(s_FrStand, s_ToLine, s_ToGrid, s_ToTier); } //判断指令排队序列 string strs = w.Write(); if (strs == "S") { w.ClearAccount(); //写入数据成功后 完成信号改为0 if (s.Value.WirteToPLC(e.PLCConn)) { foreach (var h in PLCSystem_SRM.Dic_SRM_Res) { h.Value.s_finish = 0; h.Value.WirteToPLC(e.PLCConn); int aaa = h.Value.s_finish; } //系统过账 w.Account(); } } if (strs == "N") { #region 清除数据 s.Value.s_serial = 0; s.Value.s_pattern = 0; s.Value.s_FrStand = 0; s.Value.s_FrLine = 0; s.Value.s_FrGrid = 0; s.Value.s_FrTier = 0; s.Value.s_ToStand = 0; s.Value.s_ToLine = 0; s.Value.s_ToGrid = 0; s.Value.s_ToTier = 0; s.Value.WirteToPLC(e.PLCConn); w.ClearAccount(); #endregion } #region 判断当前指令 格 层是否有值 //if (str == "写入") //{ // //执行order_info 中排队指令 // w.Write(); // //写入数据成功后 完成信号改为0 // if (s.Value.WirteToPLC(e.PLCConn)) // { // foreach (var h in PLCSystem_SRM.Dic_SRM_Res) // { // h.Value.s_finish = 0; // h.Value.WirteToPLC(e.PLCConn); // int aaa = h.Value.s_finish; // } // #region 清除数据 // //s.Value.s_serial = 0; // //s.Value.s_pattern = 0; // //s.Value.s_FrStand = 0; // //s.Value.s_FrLine = 0; // //s.Value.s_FrGrid = 0; // //s.Value.s_FrTier = 0; // //s.Value.s_ToStand = 0; // //s.Value.s_ToLine = 0; // //s.Value.s_ToGrid = 0; // //s.Value.s_ToTier = 0; // //s.Value.WirteToPLC(e.PLCConn); // #endregion // //系统过账 // w.Account(); // } //} //if (str == "过账") //{ // s.Value.s_serial = 0; // s.Value.s_pattern = 0; // s.Value.s_FrStand = 0; // s.Value.s_FrLine = 0; // s.Value.s_FrGrid = 0; // s.Value.s_FrTier = 0; // s.Value.s_ToStand = 0; // s.Value.s_ToLine = 0; // s.Value.s_ToGrid = 0; // s.Value.s_ToTier = 0; // if (s.Value.WirteToPLC(e.PLCConn)) // { // foreach (var h in PLCSystem_SRM.Dic_SRM_Res) // { // h.Value.s_finish = 0; // h.Value.WirteToPLC(e.PLCConn); // int aaa = h.Value.s_finish; // } // #region 完成后指令过账 // w.ClearAccount(); // #endregion // } //} #region 清除数据 //if (of1!=1) //{ // s.Value.s_serial = 0; // s.Value.s_pattern = 0; // s.Value.s_FrStand = 0; // s.Value.s_FrLine = 0; // s.Value.s_FrGrid = 0; // s.Value.s_FrTier = 0; // s.Value.s_ToStand = 0; // s.Value.s_ToLine = 0; // s.Value.s_ToGrid = 0; // s.Value.s_ToTier = 0; // if (s.Value.WirteToPLC(e.PLCConn)) // { // foreach (var h in PLCSystem_SRM.Dic_SRM_Res) // { // h.Value.s_finish = 0; // h.Value.WirteToPLC(e.PLCConn); // int aaa = h.Value.s_finish; // } // #region 完成后指令过账 // w.ClearAccount(); // #endregion // } //} #endregion #endregion } #endregion #region 清除指令 //if (s_finish == 0) //{ // s.Value.s_serial = 0; // s.Value.s_pattern = 0; // s.Value.s_FrStand = 0; // s.Value.s_FrLine = 0; // s.Value.s_FrGrid = 0; // s.Value.s_FrTier = 0; // s.Value.s_ToStand = 0; // s.Value.s_ToLine = 0; // s.Value.s_ToGrid = 0; // s.Value.s_ToTier = 0; // if (s.Value.WirteToPLC(e.PLCConn)) // { // foreach (var h in PLCSystem_SRM.Dic_SRM_Res) // { // h.Value.s_finish = 0; // h.Value.WirteToPLC(e.PLCConn); // int aaa = h.Value.s_finish; // } // #region 完成后指令过账 // w.ClearAccount(); // #endregion // } //} #endregion } if (s_fault == 1) //故障 { w.Fault(); foreach (var s in PLCSystem_SRM.Dic_SRM_Request) { s.Value.s_serial = 0; s.Value.s_pattern = 0; s.Value.s_FrStand = 0; s.Value.s_FrLine = 0; s.Value.s_FrGrid = 0; s.Value.s_FrTier = 0; s.Value.s_ToStand = 0; s.Value.s_ToLine = 0; s.Value.s_ToGrid = 0; s.Value.s_ToTier = 0; s.Value.WirteToPLC(e.PLCConn); } } e.result = true; } catch (Exception ex) { Program.Log_Agent_SRM.WriteLog(Enum_LogType.LogType_Error, Enum_LogGrade.LogGrade_Nin, Enum_LogMessageType.LogMsgType_Exception, string.Format("V_LoopWrite-[{0}]-[{1}]", plcID, currentSRMNo), ex.Message, ex.StackTrace); e.result = false; } }