Browse Source

导出功能添加记录ID列

DuGuYang 3 năm trước cách đây
mục cha
commit
67b2075849

+ 98 - 1
Areas/Admin/Controllers/MainServer/StoreHouseAmountRecordController.cs

@@ -553,7 +553,7 @@ namespace MySystem.Areas.Admin.Controllers
                 condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
             }
 
-            Dictionary<string, object> obj = new AdminContent(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,UseAmount", false);
+            Dictionary<string, object> obj = new AdminContent(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreHouseAmountRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,UserId,UseAmount", false);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
             foreach (Dictionary<string, object> dic in diclist)
             {
@@ -564,6 +564,10 @@ namespace MySystem.Areas.Admin.Controllers
                 dic["UserIdMakerCode"] = userid_Users.MakerCode;
                 dic.Remove("UserId");
 
+                //记录Id
+                int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
+                dic["Id"] = Id;
+
             }
 
             Dictionary<string, object> result = new Dictionary<string, object>();
@@ -571,6 +575,7 @@ namespace MySystem.Areas.Admin.Controllers
             result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
             result.Add("Obj", diclist);
             Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
+            ReturnFields.Add("Id", "记录ID");
             ReturnFields.Add("UserIdRealName", "创客真实姓名");
             ReturnFields.Add("UserIdMakerCode", "创客编号");
             ReturnFields.Add("UseAmount", "申请提现临额");
@@ -606,5 +611,97 @@ namespace MySystem.Areas.Admin.Controllers
 
         #endregion
 
+
+        #region 银行卡临额提现记录结果导入Excel
+        /// <summary>
+        /// 银行卡临额提现记录结果导入Excel
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string Imports(string ExcelData)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            string error = "";
+            List<string> IdList = new List<string>();
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+                string itemJson = dr.ToJson();
+                string Id = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                if (IdList.Contains(Id))
+                {
+                    error += "以下操作失败" + Id + ',' + "该机具号重复" + '\n';
+                }
+                else
+                {
+                    IdList.Add(Id);
+                }
+            }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
+            else
+            {
+                
+            }
+            AddSysLog("0", "StoreHouseCardAmountRecord", "Import");
+            return "success";
+        }
+        #endregion
+
+
+        #region 导入数据
+
+        public IActionResult Import(string right, string ExcelKind)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+            ViewBag.ExcelKind = ExcelKind;
+            return View();
+        }
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        [HttpPost]
+        public string ImportPost(string ExcelPath, int Kind = 0)
+        {
+            string key = function.MD5_16(Guid.NewGuid().ToString());
+            RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key + "#cut#" + SysUserName);
+            return "success|" + key;
+        }
+        public Dictionary<string, object> CheckImportV2(string key)
+        {
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            string result = RedisDbconn.Instance.Get<string>("CheckImport:" + key);
+            if (!string.IsNullOrEmpty(result))
+            {
+                string[] datalist = result.Split('|');
+                if (datalist[0] == "success")
+                {
+                    List<string> errList = RedisDbconn.Instance.GetList<string>("ErrList" + key);
+                    if (errList.Count > 0)
+                    {
+                        Obj.Add("status", 2);
+                        Obj.Add("errList", errList);
+                    }
+                    else
+                    {
+                        Obj.Add("status", 1);
+                        Obj.Add("data", result);
+                    }
+                    return Obj;
+                }
+                Obj.Add("status", 0);
+                Obj.Add("data", datalist[0]);
+                return Obj;
+            }
+            Obj.Add("status", -1);
+            Obj.Add("data", "执行中...");
+            return Obj;
+        }
+        #endregion
+
     }
 }