Esempio n. 1
0
        Tb_HSPR_IncidentError log = new Tb_HSPR_IncidentError(); //写入数据库日志


        public string IncidentCRM(string incidentid, CRMZTType type)
        {
            string strreturn = "";

            #region 验证是否存在工单
            string resultIncident = IsExistenceIncident(AppGlobal.StrToStr(incidentid));
            if (resultIncident.Split('|')[0] == "false")
            {
                return(JSONHelper.FromString(false, resultIncident.Split('|')[1]));
            }
            #endregion

            switch (type.ToString())
            {
            case "受理":
                strreturn = IncidentIns(incidentid);
                break;

            case "分派":
                strreturn = IncidentState(incidentid, "2");
                break;

            //case "抢单":
            //    strreturn = IncidentState(incidentid, "2");
            //    break;
            //case "接单":
            //    strreturn = IncidentState(incidentid,"2");
            //    break;
            //case "到场":
            //    strreturn = IncidentState(incidentid, "2");
            //    break;
            case "处理":
                strreturn = IncidentState(incidentid, "3");
                break;

            case "关闭":
                strreturn = IncidentState(incidentid, "4");
                break;

            case "回访":
                strreturn = IncidentState(incidentid, "5");
                break;

            case "转派":
                strreturn = IncidentState(incidentid, "6");
                break;

            case "作废":
                strreturn = IncidentState(incidentid, "7");
                break;

            //关闭退回
            case "退回":
                strreturn = IncidentState(incidentid, "8");
                break;

            case "回访退回":
                strreturn = IncidentState(incidentid, "9");
                break;
            }


            return(strreturn);
        }
Esempio n. 2
0
        //新增工单到CRM
        public string IncidentIns(string IncidentID)
        {
            Dictionary <string, string> dir = new Dictionary <string, string>();
            string    Results = "";
            string    strSQL  = "select  * from view_HSPR_IncidentNewZT_IncidentFaceSearch_Filter where IncidentID =" + AppGlobal.StrToStr(IncidentID);
            DataTable dt2     = new DataTable();

            //   List<dynamic> list = new List<dynamic>();
            using (IDbConnection Conn = new SqlConnection(ContionString_Base))
            {
                dt2 = Conn.ExecuteReader(strSQL).ToDataSet().Tables[0];
                // list = Conn.Query<dynamic>("").ToList();
            }

            if (dt2.Rows.Count > 0)
            {
                DataRow row = dt2.Rows[0];

                dir.Add("erp_order_id", row["IncidentID"].ToString());
                dir.Add("incident_num", row["IncidentNum"].ToString());
                dir.Add("commid", row["CommID"].ToString());
                dir.Add("roomid", row["RoomID"].ToString());
                dir.Add("regional_id", row["RegionalID"].ToString());


                dir.Add("custid", row["CustID"].ToString());
                dir.Add("incident_Place", row["IncidentPlace"].ToString());
                dir.Add("incident_man", row["IncidentMan"].ToString());
                dir.Add("phone", row["Phone"].ToString());
                dir.Add("address", row["RoomName"].ToString());//报事地址
                dir.Add("incident_source", row["IncidentSource"].ToString());

                dir.Add("incident_mode", row["IncidentMode"].ToString());
                dir.Add("order_type", row["BigCorpTypeID"].ToString());     //报事类型(大分类)
                dir.Add("question_type", row["FineCorpTypeID"].ToString()); // 问题类型(小分类)
                dir.Add("resp_party", row["Duty"].ToString() == "物业类" ? "1" : "2");
                dir.Add("memo", row["IncidentContent"].ToString());
                dir.Add("answer_memo", "");//处理描述(我方处理问题的描述,咨询类工单客服直接回答业主时使用)
                dir.Add("incident_imgs", row["IncidentImgs"].ToString());
                dir.Add("emer_level", "");
                dir.Add("insert_time", row["IncidentDate"].ToString());
                dir.Add("insert_user_id", row["AdmiMan"].ToString());


                //JObject obj = (JObject)JsonConvert.DeserializeObject(new HttpHelpersZT().HttpPost("/api/addWorkOrder.idop", dir));

                JObject obj = null;

                //反写数据
                if (obj["errCode"].ToString().ToLower() == "1")
                {
                    int            rowsAffected;
                    SqlParameter[] parameters =
                    {
                        new SqlParameter("@IncidentID", SqlDbType.NVarChar, 100),
                        new SqlParameter("@CRMGuid",    SqlDbType.NVarChar, 200)
                    };
                    parameters[0].Value = Convert.ToString(obj["data"]["erp_order_id"]);
                    parameters[1].Value = Convert.ToString(obj["data"]["crm_order_id"]);
                    new DbHelperSQLP(ContionString_Base).RunProcedure("UpdateCRMIncidentAccept", parameters, out rowsAffected);
                }

                Results = obj["errCode"].ToString().ToLower() + "|" + obj["errMsg"].ToString();
            }

            return(Results);
        }
Esempio n. 3
0
        //状态更新
        public string IncidentState(string IncidentID, string type)
        {
            Dictionary <string, string> dir = new Dictionary <string, string>();
            string    Results = "";
            string    strSQL  = "select  * from view_HSPR_IncidentNewZT_IncidentFaceSearch_Filter where IncidentID =" + AppGlobal.StrToStr(IncidentID);
            DataTable dt2     = new DataTable();

            //   List<dynamic> list = new List<dynamic>();
            using (IDbConnection Conn = new SqlConnection(ContionString_Base))
            {
                dt2 = Conn.ExecuteReader(strSQL).ToDataSet().Tables[0];
                // list = Conn.Query<dynamic>("").ToList();
            }

            if (dt2.Rows.Count > 0)
            {
                DataRow row = dt2.Rows[0];
                dir.Add("erp_order_id", row["IncidentID"].ToString());
                dir.Add("crm_order_id", row["CRMGuid"].ToString());
                dir.Add("deal_type", type);

                //根据不同类别生成相应json
                Dictionary <string, string> dir2 = new Dictionary <string, string>();

                switch (type)
                {
                //分派
                case "2":

                    dir2.Add("disp_user_id", row["DispUserCode"].ToString());
                    dir2.Add("disp_user_name", row["DispMan"].ToString());

                    dir2.Add("corp_type_id", row["BigCorpTypeID"].ToString());
                    dir2.Add("corp_type_name", row["BigCorpTypeName"].ToString());

                    dir2.Add("deal_memo", row["DispRemarks"].ToString());
                    dir2.Add("deal_user_id", row["DealManCode"].ToString());
                    dir2.Add("deal_user_name", row["DealMan"].ToString());
                    dir2.Add("deal_time", row["DispDate"].ToString());

                    break;

                //处理完成
                case "3":



                    dir2.Add("deal_memo", row["DealSituation"].ToString());
                    dir2.Add("over_due_reason", row["OverdueReason"].ToString());
                    dir2.Add("deal_img", GetImgsUrl(row["IncidentID"].ToString(), "处理图片"));
                    dir2.Add("fine_type_id", row["FineCorpTypeID"].ToString());
                    dir2.Add("fine_type_name", row["FineTypeName"].ToString());

                    dir2.Add("deal_user_id", row["FinishUserCode"].ToString());
                    dir2.Add("deal_user_name", row["FinishUser"].ToString());
                    dir2.Add("deal_time", row["MainEndDate"].ToString());

                    break;

                //报事关闭
                case "4":

                    dir2.Add("deal_memo", row["CloseSituation"].ToString());
                    dir2.Add("close_type", row["CloseType"].ToString());
                    dir2.Add("no_normal_reason", row["NoNormalCloseReasons"].ToString());
                    dir2.Add("deal_img", GetImgsUrl(row["IncidentID"].ToString(), "关闭图片"));

                    dir2.Add("deal_user_id", row["CloseUserCode"].ToString());
                    dir2.Add("deal_user_name", row["CloseUser"].ToString());
                    dir2.Add("deal_time", row["CloseTime"].ToString());

                    break;

                //报事回访
                case "5":

                    dir2.Add("reply_type", row["ReplyResult"].ToString());

                    dir2.Add("reply_user_id", "0");    //受访人
                    dir2.Add("reply_user_name", row["CustName"].ToString());

                    dir2.Add("deal_memo", row["ReplyContent"].ToString());
                    dir2.Add("deal_img", "");
                    dir2.Add("service_quality", row["ServiceQuality"].ToString());
                    dir2.Add("reply_result", row["ReplyResult"].ToString());
                    dir2.Add("reply_way", row["ReplyWay"].ToString());
                    dir2.Add("reply_situation", row["ReplyContent"].ToString());
                    dir2.Add("deal_user_id", row["ReplyManUserCode"].ToString());
                    dir2.Add("deal_user_name", row["ReplyMan"].ToString());
                    dir2.Add("deal_time", row["ReplyDate"].ToString());

                    break;

                case "6":
                    // 转派责任方



                    dir2.Add("disp_user_id", row["DealManCode"].ToString());
                    dir2.Add("disp_user_name", row["DealMan"].ToString());
                    dir2.Add("corp_type_id", row["BigCorpTypeID"].ToString());
                    dir2.Add("corp_type_name", row["BigCorpTypeName"].ToString());


                    using (IDbConnection Conn = new SqlConnection(ContionString_Base))
                    {
                        DataTable dt3 = Conn.ExecuteReader($@" 
                            select   b.UserName,a.* ,b.HeadImg from Tb_HSPR_IncidentTransmit a
                            left join tb_sys_user b
                            on a.TransmitUserCode=b.UserCode
                            where isnull(b.IsDelete,0)=0 and IncidentID={IncidentID}").ToDataSet().Tables[0];
                        if (dt3.Rows.Count > 0)
                        {
                            dir2.Add("deal_memo", dt3.Rows[0]["TransmitReasons"].ToString());
                            dir2.Add("deal_img", dt3.Rows[0]["HeadImg"].ToString());
                            dir2.Add("deal_user_id", dt3.Rows[0]["TransmitUserCode"].ToString());
                            dir2.Add("deal_user_name", dt3.Rows[0]["UserName"].ToString());
                            dir2.Add("deal_time", dt3.Rows[0]["TransmitDateTime"].ToString());
                        }
                        Conn.Close();
                    }

                    break;

                case "7":
                    //报事废弃
                    if (row["IsDelete"].ToString() == "1")
                    {
                        dir2.Add("deal_memo", row["DeleteReasons"].ToString());
                        dir2.Add("deal_img", "");
                        dir2.Add("deal_user_id", row["DeleteManCode"].ToString());
                        dir2.Add("deal_user_name", row["DeleteMan"].ToString());
                        dir2.Add("deal_time", row["DeleteDate"].ToString());
                    }

                    break;

                case "8":
                    //关闭回退
                    using (IDbConnection Conn = new SqlConnection(ContionString_Base))
                    {
                        DataTable dt3 = Conn.ExecuteReader($@" 
                            select   * from Tb_HSPR_IncidentCloseGoBack  
                            where  IncidentID={IncidentID}").ToDataSet().Tables[0];
                        if (dt3.Rows.Count > 0)
                        {
                            dir2.Add("fallback_type", "关闭回退");
                            dir2.Add("deal_memo", dt3.Rows[0]["CloseGoBackReasons"].ToString());
                            dir2.Add("deal_img", "");
                            dir2.Add("deal_user_id", dt3.Rows[0]["CloseGoBackUserCode"].ToString());
                            dir2.Add("deal_user_name", dt3.Rows[0]["CloseGoBackUser"].ToString());
                            dir2.Add("deal_time", dt3.Rows[0]["CloseGoBackTime"].ToString());
                        }
                        Conn.Close();
                    }
                    break;

                case "9":
                    //回访回退

                    using (IDbConnection Conn = new SqlConnection(ContionString_Base))
                    {
                        DataTable dt3 = Conn.ExecuteReader($@" 
                            select   * from Tb_HSPR_IncidentReplyGoBack  
                            where  IncidentID={IncidentID}").ToDataSet().Tables[0];
                        if (dt3.Rows.Count > 0)
                        {
                            dir2.Add("fallback_type", "回访回退");
                            dir2.Add("deal_memo", dt3.Rows[0]["LastCloseSituation"].ToString());
                            dir2.Add("deal_img", "");
                            dir2.Add("deal_user_id", dt3.Rows[0]["ReplyGoBackUserCode"].ToString());
                            dir2.Add("deal_user_name", dt3.Rows[0]["ReplyGoBackUser"].ToString());
                            dir2.Add("deal_time", dt3.Rows[0]["ReplyGoBackTime"].ToString());
                        }
                        Conn.Close();
                    }
                    break;
                }

                dir.Add("deal_info", JsonConvert.SerializeObject(dir2));

                //JObject obj = (JObject)JsonConvert.DeserializeObject(new HttpHelpersZT().HttpPost("/api/workOrderOper.idop", dir));

                JObject obj = null;



                ////反写数据
                //if (obj["errCode"].ToString().ToLower() == "1")
                //{
                //    int rowsAffected;
                //    SqlParameter[] parameters = {
                //                                new SqlParameter("@IncidentID", SqlDbType.NVarChar,100),
                //                                new SqlParameter("@CRMGuid", SqlDbType.NVarChar,200)
                //        };
                //    parameters[0].Value = Convert.ToString(obj["data"]["erp_order_id"]);
                //    parameters[1].Value = Convert.ToString(obj["data"]["crm_order_id"]);
                //    new DbHelperSQLP(ContionString_Base).RunProcedure("UpdateMtIncidentAccept", parameters, out rowsAffected);
                //}

                Results = obj["errCode"].ToString().ToLower() + "|" + obj["errMsg"].ToString();
            }

            return(Results);
        }
Esempio n. 4
0
        /// <summary>
        ///添加外出登记
        /// </summary>
        private string GetAddGoOutRegister(DataRow row)
        {
            #region 参数校验
            if (!row.Table.Columns.Contains("UserCode") || string.IsNullOrEmpty(row["UserCode"].AsString()))
            {
                return(new ApiResult(false, "缺少参数UserCode").toJson());
            }
            if (!row.Table.Columns.Contains("RecordDate") || string.IsNullOrEmpty(row["RecordDate"].AsString()))
            {
                return(new ApiResult(false, "缺少参数RecordDate").toJson());
            }
            if (!row.Table.Columns.Contains("LeaveManList") || string.IsNullOrEmpty(row["LeaveManList"].AsString()))
            {
                return(new ApiResult(false, "缺少参数LeaveManList").toJson());
            }
            if (!row.Table.Columns.Contains("OutDate") || string.IsNullOrEmpty(row["OutDate"].AsString()))
            {
                return(new ApiResult(false, "缺少参数OutDate").toJson());
            }
            if (!row.Table.Columns.Contains("PlanRetDate") || string.IsNullOrEmpty(row["PlanRetDate"].AsString()))
            {
                return(new ApiResult(false, "缺少参数PlanRetDate").toJson());
            }
            if (!row.Table.Columns.Contains("OutWhere") || string.IsNullOrEmpty(row["OutWhere"].AsString()))
            {
                return(new ApiResult(false, "缺少参数OutWhere").toJson());
            }
            if (!row.Table.Columns.Contains("OutThing") || string.IsNullOrEmpty(row["OutThing"].AsString()))
            {
                return(new ApiResult(false, "缺少参数OutThing").toJson());
            }
            if (!row.Table.Columns.Contains("IsReturn") || string.IsNullOrEmpty(row["IsReturn"].AsString()))
            {
                return(new ApiResult(false, "缺少参数IsReturn").toJson());
            }
            #endregion 参数校验

            var userCode     = row["UserCode"].ToString();
            var recordDate   = row["RecordDate"].ToString();
            var leaveManList = row["LeaveManList"].ToString();
            var outDate      = row["OutDate"].ToString();
            var planRetDate  = row["PlanRetDate"].ToString();
            var outWhere     = row["OutWhere"].ToString();
            var outThing     = row["OutThing"].ToString();
            var outResult    = "";
            if (row.Table.Columns.Contains("OutResult") || !string.IsNullOrEmpty(row["OutResult"].AsString()))
            {
                outResult = AppGlobal.StrToStr(row["OutResult"].ToString());
            }
            var isReturn = row["IsReturn"].ToString();
            using (var conn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                var sql = @"INSERT  INTO Tb_OAPublicWork_PeopleOutWork    
                                     (UserCode,RecordDate,OutDate,PlanRetDate,RealRetDate,OutWhere,OutThing,OutResult,IsReturn,LeaveManList)
		                            VALUES
		                            (@UserCode,@RecordDate,@OutDate,@PlanRetDate,@RealRetDate,@OutWhere,@OutThing,@OutResult,@IsReturn,
                                    @LeaveManList)";

                var data = conn.Execute(sql, new
                {
                    UserCode     = userCode,
                    RecordDate   = recordDate,
                    OutDate      = outDate,
                    PlanRetDate  = planRetDate,
                    RealRetDate  = "",
                    OutWhere     = outWhere,
                    OutThing     = outThing,
                    OutResult    = outResult,
                    IsReturn     = isReturn,
                    LeaveManList = leaveManList
                });
                return(new ApiResult(true, "保存成功").toJson());
            }
        }