예제 #1
0
        public JsonResult SentBF()
        {
            try
            {
                var arr    = groupMemberService.GetGroupMembersByType(Entity.GroupTypeEnum.BriefReport).Select(s => s.UserId).ToArray();
                var touser = string.Join("|", arr);
                var brief  = orderService.LoadBriefing(0);
                LogHelper.Info("总金额:" + brief.TomorrowDeliverTotal + "XMS金额:" + brief.TomorrowDeliverTotalXms.ToString() + "BDS金额:" + brief.TomorrowDeliverTotalBds.ToString());
                var cnt = "当日预申请审批通过数量:" + brief.TodayApprove + "(0元-" + brief.TodayApproveZero + "; 非0元-" + brief.TodayApproveNotZero + ")"
                          + "\r\n明日配送订单量: " + brief.TomorrowDeliver + "(XMS-" + brief.TomorrowDeliverXms + ";\t BDS-" + brief.TomorrowDeliverBds + ")"
                          + "\r\n明日配送订单金额: RMB" + brief.TomorrowDeliverTotal.ToString("n") + "(XMS- RMB" + brief.TomorrowDeliverTotalXms.ToString("n") + ";\t BDS- RMB" + brief.TomorrowDeliverTotalBds.ToString("n") + ")"
                          + "\r\n明日配送订单,参会人数>=60人: " + brief.TomorrowAttendCount60
                          + "\r\n明日配送订单,预定金额>=1500元: " + brief.TomorrowExceed2000
                          + "\r\n当日确认收餐数量:" + brief.TodayConfirmOrder
                          + "\r\n当日上传文件审批通过数量:" + brief.TodayUpLoadThroughCount;
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var rtnVal = WxMessageClientChannelFactory.GetChannel().SendText(touser, cnt);
                        LogHelper.Info("manual send BriefReport Content:【" + JsonConvert.SerializeObject(brief) + "】, | toUser: 【" + touser + "】,| result:" + rtnVal);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error("manual send BriefReport  ERR", ex);
                        throw ex;
                    }
                });

                return(Json(new { state = 1 }));
            }
            catch (Exception ex)
            {
                LogHelper.Error("P/Group/SentBF(0)  manual send BriefReport  ERR", ex);
                return(Json(new { state = 1, txt = ex.Message }));
            }
        }
예제 #2
0
        public void SendOrderRejectMessageToUser(string Comments, P_PREUPLOADORDER order)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendOrderRejectMessageToUser(Comments, order);
        }
예제 #3
0
        public void SendPreApprovalRejectMessageToUser(string Comments, P_PreApproval preApproval)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendPreApprovalRejectMessageToUser(Comments, preApproval);
        }
예제 #4
0
        //文件上传操作部分
        public void SendOrderStateChangeMessageToUser(P_PREUPLOADORDER order)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendOrderStateChangeMessageToUser(order);
        }
예제 #5
0
        public void SendPreApprovalStateChangeMessageToUser(P_PreApproval preApproval)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendPreApprovalStateChangeMessageToUser(preApproval);
        }
예제 #6
0
        public void SendApproveStepErrorMessageToGroup(P_PreApproval preApproval)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendApproveStepErrorMessageToGroup(preApproval);
        }
예제 #7
0
        /// <summary>
        /// 发出订单状态消息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="order"></param>
        public void SendMessageToUser(string userid, P_ORDER order)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendWxMessageByOrder(order.ID);
        }
예제 #8
0
        /// <summary>
        /// 发出订单金额修改消息
        /// </summary>
        /// <param name="xmsOrderid"></param>
        public void SendNonHTMessageToUserForChangeFee(string xmsOrderid)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendMessageToUserForChangeFee(xmsOrderid);
        }
예제 #9
0
        public void SendCoverChangeToUser(string HospitalCode, string HospitalName, string Address, string Touser, int Type, string ResId, string ResName)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendCoverChangeToUser(HospitalCode, HospitalName, Address, Touser, Type, ResId, ResName);
        }
예제 #10
0
        public void SendOrderErrorMsgToUser(Guid id, string HTCode, string Touser, string remark, int type)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendOrderErrorMsgToUser(id, HTCode, Touser, remark, type);
        }
예제 #11
0
        public void SendOrderErrorToUser(string HTCode, string Touser)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendOrderErrorToUser(HTCode, Touser);
        }
예제 #12
0
        public void SendSpecialMessageToUser(P_AddressApproval addressApproval)
        {
            var channel = WxMessageClientChannelFactory.GetChannel();

            channel.SendSpecialMessageToUser(addressApproval);
        }
        //[AdminSessionFilter(Order = 1)]
        //[PermissionFilter(Order = 2, Permission = "00000000-0000-0000-5000-000000000001")]
        public JsonResult SyncQyUser()
        {
            LogHelper.Info("SyncQyUser Start!");
            string        account = System.Configuration.ConfigurationManager.AppSettings["SFTPAccount"];
            string        pass    = System.Configuration.ConfigurationManager.AppSettings["SFTPPass"];
            SFTPOperation sftp    = new SFTPOperation("esft-cn.gsk.com", "22", account, pass);
            //读取人员数据
            var                 employeeFile = sftp.ReadFile("shared/UserList/EXP_EMPLOYEE_USER_LIST_WX_DD.CSV");
            String              csvSplitBy = "(?<=^|,)(\"(?:[^\"]|\"\")*\"|[^,]*)";
            StreamReader        sr = new StreamReader(employeeFile, System.Text.UTF8Encoding.UTF8);
            List <SyncUserInfo> syncUserInfo = new List <SyncUserInfo>();
            DataTable           dt = new DataTable();
            int                 i = 0, m = 0;

            sr.Peek();
            while (sr.Peek() > 0)
            {
                m = m + 1;
                string strd = sr.ReadLine();
                if (m >= 0 + 1)
                {
                    if (m == 0 + 1) //如果是字段行,则自动加入字段。
                    {
                        MatchCollection mcs = Regex.Matches(strd, csvSplitBy);
                        foreach (Match mc in mcs)
                        {
                            dt.Columns.Add(mc.Value); //增加列标题
                        }
                    }
                    else
                    {
                        MatchCollection mcs = Regex.Matches(strd, "(?<=^|,)(\"(?:[^\"]|\"\")*\"|[^,]*)");
                        i = 0;
                        System.Data.DataRow dr = dt.NewRow();
                        foreach (Match mc in mcs)
                        {
                            dr[i] = mc.Value;
                            i++;
                        }
                        dt.Rows.Add(dr);  //DataTable 增加一行
                    }
                }
            }
            foreach (DataRow item in dt.Rows)
            {
                SyncUserInfo syncUser = new SyncUserInfo();
                syncUser.ID          = Guid.NewGuid();
                syncUser.UserId      = item[0].ToString().Replace("\"", "").Trim();
                syncUser.UserName    = item[1].ToString().Replace("\"", "");
                syncUser.UserNo      = item[3].ToString().Replace("\"", "");
                syncUser.Email       = item[4].ToString().Replace("\"", "");
                syncUser.LineManager = item[8].ToString().Replace("\"", "");
                syncUser.IsCurrent   = item[9].ToString().Replace("\"", "") == "YES" ? 1 : 0;
                syncUser.Department  = item[5].ToString().Replace("\"", "");
                syncUser.Title       = item[11].ToString().Replace("\"", "").Replace("?", "").Replace("?", "").Replace("�", "").Replace("㡰", "");
                syncUserInfo.Add(syncUser);
            }
            //List<SyncUserInfo> syncUserInfo = new List<SyncUserInfo>();
            //SyncUserInfo syncUser = new SyncUserInfo();
            //syncUser.ID = Guid.NewGuid();
            //syncUser.UserId = "yw960402";
            //syncUser.UserName = "******";
            //syncUser.UserNo = "";
            //syncUser.Email = "";
            //syncUser.LineManager = "jjz63156";
            //syncUser.IsCurrent = 1;
            //syncUser.Department = "";
            //syncUser.Title = "";
            //syncUserInfo.Add(syncUser);


            //SyncUserInfo syncUser1 = new SyncUserInfo();
            //syncUser1.ID = Guid.NewGuid();
            //syncUser1.UserId = "jjz63156";
            //syncUser1.UserName = "******";
            //syncUser1.UserNo = "";
            //syncUser1.Email = "";
            //syncUser1.LineManager = "jfh21155";
            //syncUser1.IsCurrent = 1;
            //syncUser1.Department = "";
            //syncUser1.Title = "";
            //syncUserInfo.Add(syncUser1);
            List <WP_QYUSER> qyUserList      = new List <WP_QYUSER>();
            List <WP_QYUSER> qyUserListLine2 = new List <WP_QYUSER>();
            Guid             weChatId        = Guid.NewGuid();

            foreach (var item in syncUserInfo.ToList())
            {
                WP_QYUSER qyUser = new WP_QYUSER();
                qyUser.ID         = item.ID;
                qyUser.WechatID   = weChatId;
                qyUser.Name       = item.UserName;
                qyUser.UserId     = item.UserId;
                qyUser.Email      = item.Email;
                qyUser.CreateDate = DateTime.Now;
                qyUser.Creator    = Guid.Empty;
                qyUser.ModifyDate = qyUser.CreateDate;
                qyUser.Modifier   = qyUser.Creator;
                var lineManager = syncUserInfo.FirstOrDefault(p => p.UserId == item.LineManager);
                if (lineManager != null)
                {
                    qyUser.LineManager   = lineManager.UserId + "," + lineManager.UserName;
                    qyUser.LineManagerID = lineManager.ID;
                }
                qyUser.State     = item.IsCurrent == 1 ? 1 : 4;
                qyUser.DeptNames = item.Department;
                qyUser.Position  = item.Title;
                qyUser.Gender    = 0;
                qyUserList.Add(qyUser);
            }

            var LineManagerList = userInfoService.FindUserManagerInfo();

            foreach (var item in syncUserInfo.ToList())
            {
                WP_QYUSER qyUser = new WP_QYUSER();
                qyUser.ID         = item.ID;
                qyUser.WechatID   = weChatId;
                qyUser.Name       = item.UserName;
                qyUser.UserId     = item.UserId;
                qyUser.Email      = item.Email;
                qyUser.CreateDate = DateTime.Now;
                qyUser.Creator    = Guid.Empty;
                qyUser.ModifyDate = qyUser.CreateDate;
                qyUser.Modifier   = qyUser.Creator;
                var LineManager1 = LineManagerList.Where(x => x.UserId == item.UserId).FirstOrDefault();
                if (LineManager1 != null && LineManager1.LineManagerId != null)
                {
                    qyUser.LineManager = LineManager1.LineManagerId;
                }
                else
                {
                    qyUser.LineManager = "";
                }
                qyUser.State     = item.IsCurrent == 1 ? 1 : 4;
                qyUser.DeptNames = item.Department;
                qyUser.Position  = item.Title;
                qyUser.Gender    = 0;
                qyUserListLine2.Add(qyUser);
            }

            if (qyUserList.Count > 0)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        userInfoService.SyncWorkDayUserInfo(qyUserList);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error("SysUserError:Start");
                        LogHelper.Error(ex.Message);
                        LogHelper.Error("SysUserError:End");
                        throw ex;
                    }
                });

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        LogHelper.Info("SyncQyUser Start!");
                        SyncPreChange(qyUserList, qyUserListLine2);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                });
                //对结果进行遍历
                foreach (var item in qyUserList)
                {
                    //查询用户是否有未完成的上传文件审批
                    var uploadOrderList = uploadOrderService.GetUploadOrderByUserId(item.UserId);
                    foreach (var uploadOrder in uploadOrderList)
                    {
                        if (item.State != 4)
                        {
                            //判断未完成的订单是否审批人发生了变化
                            LogHelper.Info("SyncQyUser:UserID" + item.UserId);
                            if (item.LineManager == null || item.LineManager == "")
                            {
                                continue;
                            }
                            var uploadInfoDMDelegate = userInfoService.isAgent(item.LineManager.Split(',')[0]);
                            if (uploadInfoDMDelegate != null && uploadOrder.BUHeadMUDID.Equals(uploadInfoDMDelegate) && uploadOrder.IsReAssign == false)
                            {
                                continue;
                            }
                            if ((!uploadOrder.BUHeadMUDID.Equals(item.LineManager.Split(',')[0]) && uploadOrder.IsReAssign == false) || (uploadOrder.IsReAssign == true && !uploadOrder.ReAssignBUHeadMUDID.Equals(item.LineManager.Split(',')[0])))
                            {
                                LogHelper.Info("SyncQyUser:LineManager" + item.LineManager);
                                //将待审批上传文件转交给新的审批人
                                PreApprovalService.UpdatePuoReAssign(uploadOrder.ID.ToString(), "系统自动", "系统自动", item.LineManager.Split(',')[0], item.LineManager.Split(',')[1]);
                                //发消息
                                var messageBase = "该订单已上传会议支持文件";
                                switch (uploadOrder.FileType)
                                {
                                case 1:
                                    messageBase = "该订单已提交退单原因";
                                    break;

                                case 2:
                                    messageBase = "该订单已提交会议支持文件丢失原因";
                                    break;

                                case 3:
                                    messageBase = "该订单已提交未送达,会议未正常召开原因";
                                    break;
                                }
                                LogHelper.Info("SyncQyUser:HTCode" + uploadOrder.HTCode);
                                var approverMsg = $"{uploadOrder.HTCode},{messageBase},请<a href='{ConfigurationManager.AppSettings["MealH5SiteUrl"]}/P/Upload/Approval?id={uploadOrder.ID}&from=0'>点击这里</a>进行审批。";
                                var rtnVal      = WxMessageClientChannelFactory.GetChannel().SendText(item.LineManager.Split(',')[0], approverMsg);
                            }
                        }
                    }
                }
            }
            LogHelper.Info("SyncQyUser Success!");
            //new TaskPlanController().AutoTransfer();
            return(Json(new { state = 1 }));
        }
        /// <summary>
        /// 保存重新分配审批人
        /// </summary>
        /// <param name="UploadID"></param>
        /// <param name="userId"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public JsonResult UploadApprover(string UploadID, string htcode, string userId, string userName)
        {
            UploadID = UploadID.Replace(",", "','");
            var res        = PreApprovalService.LoadByID(UploadID);
            var preList    = new List <string>();
            var upoList    = new List <string>();
            var preHTcodes = new List <string>();
            var upoHTcodes = new List <string>();

            foreach (var item in res)
            {
                if (item.c4 == "预申请")
                {
                    preList.Add(item.c0.ToString());
                    preHTcodes.Add(item.c1.ToString());
                    //var cont = "重新分配审批人-预申请:" + item.c1;
                    //var num = operationAuditService.AddAudit("3", cont);
                }
                else
                {
                    upoList.Add(item.c0.ToString());
                    upoHTcodes.Add(item.c1.ToString());
                    //var cont = "重新分配审批人-上传文件:" + item.c1;
                    //var num = operationAuditService.AddAudit("3", cont);
                }
            }

            if (preList.Count > 0)
            {
                var preIds = string.Join("','", preList);
                var preHTs = string.Join(",", preHTcodes);
                PreApprovalService.UpdatePreReAssign(preIds, CurrentAdminUser.Email, CurrentAdminUser.Name, userId, userName);
                var cont = "重新分配审批人-预申请:" + preHTs;
                var num  = operationAuditService.AddAudit("3", cont);
                //发消息
                foreach (var preId in preList)
                {
                    var preApproval = PreApprovalService.GetPreApprovalByID(preId).FirstOrDefault();
                    if (preApproval != null)
                    {
                        string applicantMsg = preApproval.ModifyDate == preApproval.CreateDate ? $"{preApproval.HTCode},您有需要审批的预申请。请<a href='{ConfigurationManager.AppSettings["MealH5SiteUrl"]}/P/PreApproval/Approval?id={preId}&from=0'>点击这里</a>进行审批。" : $"{preApproval.HTCode},您有需要审批的预申请修改。请<a href='{ConfigurationManager.AppSettings["MealH5SiteUrl"]}/P/PreApproval/Approval?id={preId}&from=0'>点击这里</a>进行审批。";
                        var    rtnVal       = WxMessageClientChannelFactory.GetChannel().SendText(userId, applicantMsg);
                    }
                }
            }

            if (upoList.Count > 0)
            {
                var upoIds = string.Join("','", upoList);
                var upoHTs = string.Join(",", upoHTcodes);
                PreApprovalService.UpdatePuoReAssign(upoIds, CurrentAdminUser.Email, CurrentAdminUser.Name, userId, userName);
                var cont = "重新分配审批人-上传文件:" + upoHTs;
                var num  = operationAuditService.AddAudit("3", cont);
                //发消息
                foreach (var uplId in upoList)
                {
                    var uploadFile = UploadFileQueryService.FindPreUploadFile(uplId);
                    if (uploadFile != null)
                    {
                        var messageBase = "该订单已上传会议支持文件";
                        switch (uploadFile.FileType)
                        {
                        case 1:
                            messageBase = "该订单已提交退单原因";
                            break;

                        case 2:
                            messageBase = "该订单已提交会议支持文件丢失原因";
                            break;

                        case 3:
                            messageBase = "该订单已提交未送达,会议未正常召开原因";
                            break;
                        }
                        var approverMsg = $"{uploadFile.HTCode},{messageBase},请<a href='{ConfigurationManager.AppSettings["MealH5SiteUrl"]}/P/Upload/Approval?id={uplId}&from=0'>点击这里</a>进行审批。";
                        var rtnVal      = WxMessageClientChannelFactory.GetChannel().SendText(userId, approverMsg);
                    }
                }
            }
            return(Json(new { state = 1 }));
        }
        public ActionResult SendBriefReport()
        {
            var      _thisTime = DateTime.Now;
            var      _time     = GetTSTime(TaskScheduler.SendBriefReport);
            var      conf      = bizConfigService.GetConfig();
            TimeSpan timeSpan  = _thisTime - _time;

            LogHelper.Info("debug SendBriefReport | GetLastSendBriefTime():" + _time.ToString("yyyy-MM-dd HH:mm:ss")
                           + " | DateTime.Now : " + _thisTime.ToString("yyyy-MM-dd HH:mm:ss")
                           + " | timeSpan.TotalHours:" + timeSpan.TotalHours
                           + " | DateTime.Now.Hour:" + _thisTime.Hour
                           + " | conf._8_SendBriefReportHour:" + conf._8_SendBriefReportHour);
            if (_thisTime.Hour != conf._8_SendBriefReportHour)
            {
                return(Content("【briefReport】 is not send, not send hour: " + conf._8_SendBriefReportHour + " | currentTime:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            else if (timeSpan.TotalHours < 2d)
            {
                return(Content("【briefReport】 is not send, it has been sent at:" + _time.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            else
            {
                var arr    = groupMemberService.GetGroupMembersByType(Entity.GroupTypeEnum.BriefReport).Select(s => s.UserId).ToArray();
                var touser = string.Join("|", arr);
                var brief  = orderService.LoadBriefing(0);
                var cnt    = "当日预申请审批通过数量:" + brief.TodayApprove + "(0元-" + brief.TodayApproveZero + "; 非0元-" + brief.TodayApproveNotZero + ")"
                             + "\r\n明日配送订单量: " + brief.TomorrowDeliver + "(XMS-" + brief.TomorrowDeliverXms + ";\t BDS-" + brief.TomorrowDeliverBds + ")"
                             + "\r\n明日配送订单金额: RMB" + brief.TomorrowDeliverTotal.ToString("n") + "(XMS- RMB" + brief.TomorrowDeliverTotalXms.ToString("n") + ";\t BDS- RMB" + brief.TomorrowDeliverTotalBds.ToString("n") + ")"
                             + "\r\n明日配送订单,参会人数>=60人: " + brief.TomorrowAttendCount60
                             + "\r\n明日配送订单,预定金额>=1500元: " + brief.TomorrowExceed2000
                             + "\r\n当日上传文件审批通过数量:" + brief.TodayUpLoadThroughCount
                             + "\r\n当日确认收餐数量:" + brief.TodayUpLoadThroughCount;
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var rtnVal = WxMessageClientChannelFactory.GetChannel().SendText(touser, cnt);
                        LogHelper.Info("auto send BriefReport Content:【" + JsonConvert.SerializeObject(brief) + "】, | toUser: 【" + touser + "】,| result:" + rtnVal);
                        SetTSTime(TaskScheduler.SendBriefReport, _thisTime);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error("auto send BriefReport  ERR", ex);
                        throw ex;
                    }
                });


                var _brief = orderService.LoadBriefing(1);
                var _cnt   = "当日预申请审批通过数量:" + brief.TodayApprove + "(0元-" + brief.TodayApproveZero + "; 非0元-" + brief.TodayApproveNotZero + ")"
                             + "\r\n明日配送订单量: " + brief.TomorrowDeliver + "(MXS-" + brief.TomorrowDeliverXms + ";\t BDS-" + brief.TomorrowDeliverBds + ")"
                             + "\r\n明日配送订单金额: RMB" + brief.TomorrowDeliverTotal.ToString("n") + "(XMS- RMB" + brief.TomorrowDeliverTotalXms.ToString("n") + ";\t BDS- RMB" + brief.TomorrowDeliverTotalBds.ToString("n") + ")"
                             + "\r\n明日配送订单,参会人数>=60人: " + brief.TomorrowAttendCount60
                             + "\r\n明日配送订单,预定金额>=1500元: " + brief.TomorrowExceed2000
                             + "\r\n当日上传文件审批通过数量:" + brief.TodayUpLoadThroughCount
                             + "\r\n当日确认收餐数量:" + brief.TodayUpLoadThroughCount;
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var rtnVal = WMessageClientChannelFactory.GetChannel().SendText(touser, _cnt);
                        LogHelper.Info("auto send BriefReport Content:【" + JsonConvert.SerializeObject(brief) + "】, | toUser: 【" + touser + "】,| result:" + rtnVal);
                        SetTSTime(TaskScheduler.SendBriefReport, _thisTime);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error("auto send BriefReport  ERR", ex);
                        throw ex;
                    }
                });

                return(Content("【briefReport】 success!the next exec time: " + _thisTime.AddDays(1d).ToString("yyyy-MM-dd HH:mm:ss")));
            }
        }