Exemplo n.º 1
0
        private void SaveData(HttpContext context, string btn)
        {
            if (btn != "btnSave")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            string ID                 = RequestHelper.GetString("ID");
            string IntentionId        = RequestHelper.GetString("IntentionId");
            string AssignmentCode     = RequestHelper.GetString("AssignmentCode");
            string AssignmentDate     = RequestHelper.GetString("AssignmentDate");
            string ExpectStartDate    = RequestHelper.GetString("ExpectStartDate");
            string ExpectCompleteDate = RequestHelper.GetString("ExpectCompleteDate");
            string MainRepair         = RequestHelper.GetString("MainRepair").Trim();
            string AssistRepair       = RequestHelper.GetString("AssistRepair").Trim();
            string detailStr          = RequestHelper.GetString("detailStr");
            string procedureList_prev = RequestHelper.GetString("procedureList_prev");
            string WorkContent        = RequestHelper.GetString("WorkContent").Trim();

            Model.System.sys_LoginUser          loginUserModel = BaseWeb.GetLoginInfo();
            SCZM.Model.Repair.Repair_Assignment model          = new SCZM.Model.Repair.Repair_Assignment();
            SCZM.BLL.Repair.Repair_Assignment   bll            = new SCZM.BLL.Repair.Repair_Assignment();
            model.ID          = Utils.StrToInt(ID, 0);
            model.IntentionId = Utils.StrToInt(IntentionId, 0);
            if (AssignmentCode == "")
            {
                AssignmentCode = "PG" + DateTime.Now.ToString("yyyyMMdd") + bll.GetMaxId();
            }
            model.AssignmentCode = AssignmentCode;
            if (AssignmentDate != "")
            {
                model.AssignmentDate = Utils.StrToDateTime(AssignmentDate);
            }
            if (ExpectStartDate != "")
            {
                model.ExpectStartDate = Utils.StrToDateTime(ExpectStartDate);
            }
            if (ExpectCompleteDate != "")
            {
                model.ExpectCompleteDate = Utils.StrToDateTime(ExpectCompleteDate);
            }
            model.MainRepair   = Utils.StrToInt(MainRepair, 0);
            model.AssistRepair = AssistRepair;
            model.WorkContent  = WorkContent;
            List <Model.Repair.Repair_Assignment_Procedure> modelList = new List <Model.Repair.Repair_Assignment_Procedure>();

            if (detailStr != "")
            {
                string[] detailArray = detailStr.Split('≮');
                for (int i = 0; i < detailArray.Length; i++)
                {
                    string[] detailMXArray = detailArray[i].Split('⊥');
                    Model.Repair.Repair_Assignment_Procedure model_Procedure = new Model.Repair.Repair_Assignment_Procedure();
                    model_Procedure.ProcedureId = Utils.StrToInt(detailMXArray[0], 0);
                    model_Procedure.Num         = Utils.StrToDecimal(detailMXArray[1], 0);
                    model_Procedure.WorkContent = Utils.Filter(detailMXArray[2]);
                    model_Procedure.AllNat      = Utils.StrToDecimal(detailMXArray[3], 0);
                    modelList.Add(model_Procedure);
                }
            }
            model.Repair_Assignment_Procedure = modelList;
            model.OperaDepId = loginUserModel.DepId;
            model.OperaId    = loginUserModel.ID;
            model.OperaName  = loginUserModel.PerName;
            model.OperaTime  = DateTime.Now;

            string operaMessage = "";
            string status       = "0";
            string operaAction  = "";
            string operaMemo    = "";

            try
            {
                if (ID == "")
                {
                    model.ID = bll.Add(model, out operaMessage);
                    if (model.ID > 0)
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Add.ToString();
                        operaMemo   = "新增维修派工:" + model.ID;
                    }
                }
                else
                {
                    if (bll.Update(model, procedureList_prev, out operaMessage))
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Edit.ToString();
                        operaMemo   = "修改维修派工:" + model.ID;
                    }
                }
                if (status == "1")
                {
                    //写入操作日志
                    BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo);
                }
                if (status == "1")
                {
                    string userIdList = "";
                    if (MainRepair != "")
                    {
                        userIdList += MainRepair;
                        if (model.AssistRepair != "")
                        {
                            userIdList += "," + AssistRepair;
                        }
                    }
                    if (userIdList != "")
                    {
                        try
                        {
                            BLL.WX.WX_GetLoginInfo bll_Wx = new BLL.WX.WX_GetLoginInfo();
                            DataSet wx_AccountDs          = bll_Wx.getWxAccount_Id(userIdList);
                            if (wx_AccountDs != null && wx_AccountDs.Tables[0].Rows.Count > 0)
                            {
                                string touser = "", touser_ds = "";
                                for (int i = 0; i < wx_AccountDs.Tables[0].Rows.Count; i++)
                                {
                                    touser_ds = wx_AccountDs.Tables[0].Rows[i][0].ToString();
                                    if (touser_ds != "")
                                    {
                                        touser += touser_ds + "|";
                                    }
                                }
                                if (touser.Length > 0)
                                {
                                    touser = touser.Remove(touser.Length - 1);
                                    DataRow dr = bll.GetDetail(model.ID).Tables[0].Rows[0];
                                    //string message = "有新的派工,请及时查看";context.Request.Url.Authority + "/SCZM/Pages/WeiXin/WX_Schedule_List_procedure.html?AssignmentId="+model.ID
                                    WX.WX_GetLoginInfo.GetMessageCard(touser, "", "有新的派工,请及时查看。", " 派工单:" + dr["AssignmentCode"] + "\n 客户:" + dr["CustName"] + "\n 机型:" + dr["MachineModel"] + "\n 机号:" + dr["MachineCode"] + "\n 维修担当:" + dr["MainRepairName"] + "\n 计划维修日期:\n " + DateTime.Parse(dr["ExpectStartDate"].ToString()).ToLongDateString() + "-" + DateTime.Parse(dr["ExpectCompleteDate"].ToString()).ToLongDateString(), "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + new BLL.System.sys_Config().loadConfig().WxCorpid + "&redirect_uri=" + context.Request.Url.Authority + ConfigurationManager.AppSettings["appName"] + "Pages/WeiXin/WX_Schedule_List_new.html&response_type=code&scope=snsapi_userinfo&agentid=" + WX.WX_GetLoginInfo.GetAgentid("Schedule") + "#wechat_redirect", "查看", "Schedule");
                                    //WX.WX_GetLoginInfo.GetMessage(touser,"", message);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            operaMessage += "微信推送失败(" + e.Message + "),请及时联系系统管理员";
                        }
                    }
                }
                context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}");
                return;
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }
Exemplo n.º 2
0
        private void SaveData(Model.Repair.repair_Schedule model, HttpContext context)
        {
            Model.System.sys_LoginUser      loginUserModel = BaseWeb.GetLoginInfo();
            SCZM.BLL.Repair.repair_Schedule bll            = new SCZM.BLL.Repair.repair_Schedule();
            string operaMessage = "";
            string status       = "0";
            string operaAction  = "";
            string operaMemo    = "";

            try
            {
                if (model.ID == -1)
                {
                    model.ID = bll.Add(model, out operaMessage);
                    if (model.ID > 0)
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Add.ToString();
                        operaMemo   = "新增进度反馈:" + model.ID;
                    }
                }
                else
                {
                    if (bll.Update(model, out operaMessage))
                    {
                        status      = "1";
                        operaAction = Enums.ActionEnum.Edit.ToString();
                        operaMemo   = "修改进度反馈:" + model.ID;
                    }
                }
                if (status == "1")
                {
                    //写入操作日志
                    BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo);
                }
                //if (status == "1") {
                //    BLL.WX.WX_GetLoginInfo bll_Wx = new BLL.WX.WX_GetLoginInfo();
                //    bll_Wx.getWxAccount_Procedure
                //}
                if (status == "1" && model.PauseReason == 5)
                {
                    //-----------------------------------------------------------
                    string PartDepId = "23";
                    BLL.WX.WX_GetLoginInfo bll_Wx = new BLL.WX.WX_GetLoginInfo();
                    DataSet wx_AccountDs          = bll_Wx.getWxAccount_Dep(PartDepId);
                    if (wx_AccountDs != null && wx_AccountDs.Tables[0].Rows.Count > 0)
                    {
                        string touser = "", touser_ds = "";
                        for (int i = 0; i < wx_AccountDs.Tables[0].Rows.Count; i++)
                        {
                            touser_ds = wx_AccountDs.Tables[0].Rows[i][0].ToString();
                            if (touser_ds != "")
                            {
                                touser += touser_ds + "|";
                            }
                        }
                        if (touser.Length > 0)
                        {
                            touser = touser.Remove(touser.Length - 1);

                            SCZM.BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                            DataTable dt_CustMessage = bll_Assignment.GetComboList(" and a.ID=" + model.AssignmentId + " ").Tables[0];
                            SCZM.BLL.Base.base_Procedure bll_Procedure = new BLL.Base.base_Procedure();
                            DataTable dt_Procedure = bll_Procedure.GetComboList(" and a.ID=" + model.ProcedureId + " ").Tables[0];
                            WX_GetLoginInfo.GetMessage(touser, "", "客户:" + dt_CustMessage.Rows[0]["CustName"] + "\n机型:" + dt_CustMessage.Rows[0]["MachineModel"] + " \n机号:" + dt_CustMessage.Rows[0]["MachineCode"] + "\n工序:" + dt_Procedure.Rows[0]["ProcedureName"] + "\n维修担当:" + dt_CustMessage.Rows[0]["PerName"] + "\n因等件原因:" + model.Memo + "\n暂停维修,请及时沟通。", "Schedule");
                        }
                    }
                    //-----------------------------------------------------------
                }
                else if (status == "1" && model.ScheduleType == 3)
                {
                    BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                    //model.AssignmentId; 派工ID
                    //model.AssignmentProcedureId 派工工序ID
                    //---------------------2018/6/26---取消审核(系统内默认审核同意,需手动审核时删掉此段+Wx_GetLoginInfo.ashx也有同样的设置,需同步修改)-----------------------------
                    Model.Repair.Repair_Assignment_Procedure model_AssignmentProcedure = null;
                    BLL.Repair.repair_Report bll_Report = new BLL.Repair.repair_Report();
                    DataTable dt = bll_Assignment.GetAssignmentProcedureList(" and a.ID=" + model.AssignmentProcedureId + " ").Tables[0];


                    DataRow[] dr = dt.Select("ID=" + model.AssignmentProcedureId);
                    if (dr.Length == 1)
                    {
                        model_AssignmentProcedure = new Model.Repair.Repair_Assignment_Procedure();
                        if (dr[0]["AllNat"].ToString() != "")
                        {
                            model_AssignmentProcedure.AllNat_Audit = Utils.StrToDecimal(dr[0]["AllNat"].ToString(), 0);
                        }
                        else
                        {
                            DataTable dt_Detail = bll_Report.GetRepairerRewardDetail(" and d.ID=" + model.AssignmentProcedureId + " ").Tables[0];
                            if (dt_Detail.Rows[0]["AllNat"].ToString() != "")
                            {
                                model_AssignmentProcedure.AllNat_Audit = Utils.StrToDecimal(dt_Detail.Rows[0]["AllNat"].ToString(), 0) * Utils.StrToDecimal(dr[0]["Num"].ToString(), 0);
                            }
                        }
                        model_AssignmentProcedure.AuditDate    = DateTime.Now;
                        model_AssignmentProcedure.AuditOpinion = "";
                        model_AssignmentProcedure.AuditState   = 1;
                        model_AssignmentProcedure.AuditorId    = loginUserModel.ID;
                        model_AssignmentProcedure.ID           = model.AssignmentProcedureId;
                        bll_Report.SaveRepairReward_Audit(model_AssignmentProcedure);
                    }

                    //----------------------------zhx----------------上箭头-------------------------------------------------------------------

                    BLL.WX.WX_GetLoginInfo bll_Wx = new BLL.WX.WX_GetLoginInfo();
                    DataSet wx_AccountDs          = bll_Wx.getWxAccount_Procedure(model.AssignmentProcedureId);
                    if (wx_AccountDs != null && wx_AccountDs.Tables[0].Rows.Count > 0)
                    {
                        string touser = "", touser_ds = "";
                        for (int i = 0; i < wx_AccountDs.Tables[0].Rows.Count; i++)
                        {
                            touser_ds = wx_AccountDs.Tables[0].Rows[i]["WXNo"].ToString();
                            if (touser_ds != "")
                            {
                                touser += touser_ds + "|";
                            }
                        }
                        if (touser.Length > 0)
                        {
                            touser = touser.Remove(touser.Length - 1);

                            //SCZM.BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                            DataTable dt_CustMessage = bll_Assignment.GetComboList(" and a.ID=" + model.AssignmentId + " ").Tables[0];
                            SCZM.BLL.Base.base_Procedure bll_Procedure = new BLL.Base.base_Procedure();
                            DataTable dt_Procedure = bll_Procedure.GetComboList(" and a.ID=" + model.ProcedureId + " ").Tables[0];
                            WX_GetLoginInfo.GetMessage(touser, "", "客户:" + dt_CustMessage.Rows[0]["CustName"] + "\n机型:" + dt_CustMessage.Rows[0]["MachineModel"] + " \n机号:" + dt_CustMessage.Rows[0]["MachineCode"] + "\n维修担当:" + dt_CustMessage.Rows[0]["PerName"] + "\n工序:" + dt_Procedure.Rows[0]["ProcedureName"] + "\n维修已完成。" + model.Memo + "\n", "Schedule");
                        }
                    }
                    //---------------------------------------------
                }
                else if (status == "1" && (model.ScheduleType == 1 || model.ScheduleType == 2))
                {
                    BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                    BLL.WX.WX_GetLoginInfo       bll_Wx         = new BLL.WX.WX_GetLoginInfo();
                    DataSet wx_AccountDs = bll_Wx.getWxAccount_Procedure_onlyGroup(model.AssignmentProcedureId);
                    if (wx_AccountDs != null && wx_AccountDs.Tables[0].Rows.Count > 0)
                    {
                        string touser = "", touser_ds = "";
                        for (int i = 0; i < wx_AccountDs.Tables[0].Rows.Count; i++)
                        {
                            touser_ds = wx_AccountDs.Tables[0].Rows[i]["WXNo"].ToString();
                            if (touser_ds != "")
                            {
                                touser += touser_ds + "|";
                            }
                        }
                        if (touser.Length > 0)
                        {
                            touser = touser.Remove(touser.Length - 1);

                            //SCZM.BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                            DataTable dt_CustMessage = bll_Assignment.GetComboList(" and a.ID=" + model.AssignmentId + " ").Tables[0];
                            SCZM.BLL.Base.base_Procedure bll_Procedure = new BLL.Base.base_Procedure();
                            DataTable dt_Procedure = bll_Procedure.GetComboList(" and a.ID=" + model.ProcedureId + " ").Tables[0];
                            WX_GetLoginInfo.GetMessage(touser, "", "客户:" + dt_CustMessage.Rows[0]["CustName"] + "\n机型:" + dt_CustMessage.Rows[0]["MachineModel"] + " \n机号:" + dt_CustMessage.Rows[0]["MachineCode"] + "\n维修担当:" + dt_CustMessage.Rows[0]["PerName"] + "\n工序:" + dt_Procedure.Rows[0]["ProcedureName"] + "\n维修" + (model.ScheduleType == 1?"已开始":"已暂停") + "。" + model.Memo + "\n", "Schedule");
                        }
                    }
                }
                if (status == "1")
                {
                    if (bll.GetScheduleType(model.AssignmentProcedureId) == 3)
                    {
                        BLL.WX.WX_GetLoginInfo       bll_Wx         = new BLL.WX.WX_GetLoginInfo();
                        BLL.Repair.Repair_Assignment bll_Assignment = new BLL.Repair.Repair_Assignment();
                        DataTable dt_repairSecond        = bll.GetRepairSceond(model.AssignmentProcedureId).Tables[0];
                        DataSet   wx_AccountDs_onlyGroup = bll_Wx.getWxAccount_Procedure_onlyGroup(model.AssignmentProcedureId);
                        if (wx_AccountDs_onlyGroup != null && wx_AccountDs_onlyGroup.Tables[0].Rows.Count > 0)
                        {
                            string touser = "", touser_ds = "";
                            for (int i = 0; i < wx_AccountDs_onlyGroup.Tables[0].Rows.Count; i++)
                            {
                                touser_ds = wx_AccountDs_onlyGroup.Tables[0].Rows[i]["WXNo"].ToString();
                                if (touser_ds != "")
                                {
                                    touser += touser_ds + "|";
                                }
                            }
                            if (touser.Length > 0)
                            {
                                touser = touser.Remove(touser.Length - 1);
                                int AllSecond    = Convert.IsDBNull(dt_repairSecond.Rows[0]["AllSecond"]) == true ? 0 : Convert.ToInt32(dt_repairSecond.Rows[0]["AllSecond"]);
                                int RepairSecond = Convert.IsDBNull(dt_repairSecond.Rows[0]["RepairSecond"]) == true ? 0 : Convert.ToInt32(dt_repairSecond.Rows[0]["RepairSecond"]);
                                int PauseSecond  = Convert.IsDBNull(dt_repairSecond.Rows[0]["PauseSecond"]) == true ? 0 : Convert.ToInt32(dt_repairSecond.Rows[0]["PauseSecond"]);
                                WX_GetLoginInfo.GetMessage(touser, "", "本次派工工序总用时:" + WX_GetLoginInfo.GetDateTime(0, 0, 0, AllSecond) + "\n维修用时:" + WX_GetLoginInfo.GetDateTime(0, 0, 0, RepairSecond) + "\n暂停用时:" + WX_GetLoginInfo.GetDateTime(0, 0, 0, PauseSecond) + "", "Schedule");
                                bll_Assignment.UpdateRepairSecond(model.AssignmentProcedureId, AllSecond, RepairSecond, PauseSecond);
                            }
                        }
                    }
                }
                context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}");
                return;
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }