Beispiel #1
0
        /// <summary>
        /// 处理作业单流程
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public ActionResult <bool> FlowResult(OpreateBillFlowResult flow)
        {
            try
            {
                if (flow == null)
                {
                    throw new Exception("参数有误");
                }
                if ((int)flow.FlowResult == 0)
                {
                    throw new Exception("处理结果数据有误");
                }
                var oflow = _work.Repository <Basic_OpreationFlow>().GetModel(q => q.ID == flow.OpreationFlowID);
                if (oflow == null)
                {
                    throw new Exception("作业流程节点不存在");
                }
                var opreationflow = _work.Repository <Basic_Opreation>().GetModel(oflow.OpreationID);
                if (opreationflow == null)
                {
                    throw new Exception("作业流程不存在");
                }

                if (flow.FlowResult == PublicEnum.OpreateFlowResult.reback && !opreationflow.IsBackReturn)
                {
                    throw new Exception("作业流和不支持回退");
                }
                var checkflow = rpsBillFlow.Any(q => q.FlowResult == (int)flow.FlowResult && q.OpreationFlowID == flow.OpreationFlowID && q.BillID == flow.BillID);
                if (checkflow)
                {
                    throw new Exception("该作业单已经提交了该节点的处理结果");
                }
                var billmodel = rpsOpreateBill.GetModel(flow.BillID);
                if (billmodel == null)
                {
                    throw new Exception("业务单据不存在");
                }
                if (billmodel.State != (int)PublicEnum.BillFlowState.audited)
                {
                    throw new Exception("作业单状态不允许");
                }

                //所有节点集合,
                IEnumerable <Basic_OpreationFlow> points = JsonConvert.DeserializeObject <IEnumerable <Basic_OpreationFlow> >(billmodel.FlowsJson);

                bool writbill = false;

                switch (flow.FlowResult)
                {
                case PublicEnum.OpreateFlowResult.stop:     //终止
                    billmodel.State = (int)PublicEnum.BillFlowState.stop;
                    writbill        = true;
                    break;

                case PublicEnum.OpreateFlowResult.over:     //完成,如果是最后一步则修改单据状态
                    var lastpointid = points.OrderByDescending(o => o.PointIndex).FirstOrDefault().ID;
                    if (flow.OpreationFlowID == lastpointid)
                    {
                        billmodel.State = (int)PublicEnum.BillFlowState.Over;
                        writbill        = true;
                    }
                    //如果不是最后一步就给下一步推送信息
                    /******************************发送管处理人信息**************************************/
                    var nextpoint = points.OrderBy(o => o.PointIndex).FirstOrDefault(p => p.PointIndex > oflow.PointIndex);

                    var empsIds    = _work.Repository <Basic_PostEmployees>().Queryable(p => p.PostID == nextpoint.PostID).Select(s => s.EmployeeID);
                    var ctrp       = _work.Repository <Basic_Employee>().Queryable(p => empsIds.Contains(p.ID)).Select(s => s.Login);
                    var msgToUsers = _work.Repository <Auth_User>().Queryable(p => ctrp.Contains(p.Login));

                    foreach (var item in msgToUsers)
                    {
                        //判断是否绑定微信
                        if (string.IsNullOrEmpty(item.openID))
                        {
                            continue;
                        }
                        var sendData = new Dictionary <string, MessageDataBase>();
                        sendData.Add("first", new MessageDataBase {
                            value = "请尽快完成当前节点的类容"
                        });
                        sendData.Add("keyword1", new MessageDataBase {
                            value = billmodel.BillName
                        });
                        sendData.Add("keyword2", new MessageDataBase {
                            value = "作业流程"
                        });
                        sendData.Add("keyword3", new MessageDataBase {
                            value = nextpoint.PointName
                        });
                        sendData.Add("keyword4", new MessageDataBase {
                            value = billmodel.CreateDate.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        sendData.Add("keyword5", new MessageDataBase {
                            value = billmodel.EndTime.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        sendData.Add("remark", new MessageDataBase {
                            value = "ESF微服为安全护航。"
                        });
                        var Msg = new TemplateMessagePara
                        {
                            template_id = "6HzNyomBRZiKo5u-JgJFbr2ygqdQ-n7wq3c5obqQpY0",
                            touser      = item.openID,
                            data        = sendData,
                            url         = "http://weixin.bjjtza.com/MyWork/Doingwork"
                        };
                        WxService.SendTemplateMessage(Msg);
                    }
                    /************************************************************************/

                    break;

                case PublicEnum.OpreateFlowResult.reback:    //退回到最后一步时则退回完成
                    var relastpointid = points.OrderBy(o => o.PointIndex).FirstOrDefault().ID;
                    if (flow.OpreationFlowID == relastpointid)
                    {
                        billmodel.State = (int)PublicEnum.BillFlowState.Reback;
                        writbill        = true;
                    }
                    //如果不是最后一步就给上一步推送信息
                    /******************************发送管处理人信息**************************************/
                    var lastpoint   = points.OrderByDescending(o => o.PointIndex).FirstOrDefault(p => p.PointIndex < oflow.PointIndex);
                    var empsIds1    = _work.Repository <Basic_PostEmployees>().Queryable(p => p.PostID == lastpoint.PostID).Select(s => s.EmployeeID);
                    var ctrp1       = _work.Repository <Basic_Employee>().Queryable(p => empsIds1.Contains(p.ID)).Select(s => s.Login);
                    var msgToUsers1 = _work.Repository <Auth_User>().Queryable(p => ctrp1.Contains(p.Login));

                    foreach (var item in msgToUsers1)
                    {
                        //判断是否绑定微信
                        if (string.IsNullOrEmpty(item.openID))
                        {
                            continue;
                        }

                        var sendData = new Dictionary <string, MessageDataBase>();
                        sendData.Add("first", new MessageDataBase {
                            value = "请尽快完成当前节点的类容"
                        });
                        sendData.Add("keyword1", new MessageDataBase {
                            value = billmodel.BillName
                        });
                        sendData.Add("keyword2", new MessageDataBase {
                            value = "作业流程"
                        });
                        sendData.Add("keyword3", new MessageDataBase {
                            value = lastpoint.PointName
                        });
                        sendData.Add("keyword4", new MessageDataBase {
                            value = billmodel.CreateDate.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        sendData.Add("keyword5", new MessageDataBase {
                            value = billmodel.EndTime.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        sendData.Add("remark", new MessageDataBase {
                            value = "ESF微服为安全护航。"
                        });
                        var Msg = new TemplateMessagePara
                        {
                            template_id = "6HzNyomBRZiKo5u-JgJFbr2ygqdQ-n7wq3c5obqQpY0",
                            touser      = item.openID,
                            data        = sendData,
                            url         = "http://weixin.bjjtza.com/MyWork/Doingwork"
                        };
                        WxService.SendTemplateMessage(Msg);
                    }
                    /************************************************************************/

                    break;

                default:
                    break;
                }

                var dbflow = flow.MAPTO <Bll_OpreateionBillFlow>();
                dbflow.BillID         = billmodel.ID;
                dbflow.FlowEmployeeID = AppUser.EmployeeInfo.ID;
                dbflow.FlowTime       = DateTime.Now;
                dbflow.ID             = Guid.NewGuid();

                rpsBillFlow.Add(dbflow);
                if (writbill)
                {
                    rpsOpreateBill.Update(billmodel);
                }
                _work.Commit();

                return(new ActionResult <bool>(true));
            }
            catch (Exception ex)
            {
                return(new ActionResult <bool>(ex));
            }
        }
Beispiel #2
0
 public ActionResult <bool> FlowResult(OpreateBillFlowResult flow)
 {
     LogContent = "处理了作业节点,参数源:" + JsonConvert.SerializeObject(flow);
     return(opreatebll.FlowResult(flow));
 }