Esempio n. 1
0
        public ActionResult ApplyBorrow(string recordIdString, string borrowOnly)
        {
            var recordIdList   = recordIdString.Split(',').ToList();
            var failBorrowList = new List <string>();

            for (var i = recordIdList.Count - 1; i >= 0; i--)
            {
                var record = recordService.GetRecord(recordIdList[i]);
                if (record.RecordStatus != 2)
                {
                    failBorrowList.Add(recordIdList[i]);
                    recordIdList.RemoveAt(i);
                }
                else
                {
                    if (string.IsNullOrEmpty(borrowOnly) && record.RecordManager != Operator.UserName)
                    {
                        failBorrowList.Add(recordIdList[i]);
                        recordIdList.RemoveAt(i);
                    }
                }
            }

            var timeNow = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            var apply   = new ApplyBorrowTable()
            {
                BorrowID   = timeNow,
                ApplyTime  = DateTime.Now,
                ApplyUser  = Operator.UserName,
                ApplyState = 1
            };

            var message = new StringBuilder();

            if (failBorrowList.Any())
            {
                message.Append($"  {string.Join(",", recordIdList)}申请借阅失败,失败原因:档案不在库或者不归属您所在的支行!");
            }

            if (recordIdList.Any())
            {
                message.Append($"{string.Join(",", recordIdList)}申请借阅成功");

                var result = ApplyBorrowService.ApplyBorrow(timeNow, apply, recordIdList, Operator.RealName);
                if (result)
                {
                    foreach (var item in recordIdList)
                    {
                        var operate = new OperateLog()
                        {
                            RecordId      = item,
                            OperatePeople = Operator.RealName,
                            OperateType   = "申请借阅",
                            OperateTime   = DateTime.Now,
                            OperateInfo   = $"申请借阅 借阅号:{timeNow},档案编号:{item}"
                        };
                        OperateLogService.CreateModel(operate);
                    }
                    return(Json(SuccessTip($"{message.ToString()},请等待审核!")));
                }
                else
                {
                    return(Json(ErrorTip("申请借阅失败,请重试!")));
                }
            }
            else
            {
                return(Json(ErrorTip("申请借阅失败!")));
            }
        }