浏览代码

工资导入数据成功

西昌分支
北京泉江 1年前
父节点
当前提交
eb3923948a
共有 12 个文件被更改,包括 273 次插入38 次删除
  1. +30
    -27
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/Gz_AmountsController.cs
  2. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/Gz_Amounts/GzImport.js
  3. 二进制
      Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/GzImport.xls
  4. +2
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config
  5. +29
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsBLL.cs
  6. +6
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsEntity.cs
  7. +6
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsIBLL.cs
  8. +129
    -3
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs
  9. +26
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsBLL.cs
  10. +6
    -4
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsEntity.cs
  11. +3
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsIBLL.cs
  12. +35
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsService.cs

+ 30
- 27
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/Gz_AmountsController.cs 查看文件

@@ -1,7 +1,9 @@
using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.PersonnelManagement;
using Learun.Util;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.Mvc;

namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
@@ -17,6 +19,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
{
private Gz_AmountsIBLL gz_AmountsIBLL = new Gz_AmountsBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
private Gz_ItemsIBLL gz_ItemsIBLL = new Gz_ItemsBLL();

#region 视图功能

@@ -27,7 +30,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
[HttpGet]
public ActionResult Index()
{
return View();
return View();
}
/// <summary>
/// 表单页
@@ -36,7 +39,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
[HttpGet]
public ActionResult Form()
{
return View();
return View();
}

/// <summary>
@@ -60,7 +63,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
/// <returns></returns>
[HttpGet]
[AjaxOnly]
public ActionResult GetList( string queryJson )
public ActionResult GetList(string queryJson)
{
var data = gz_AmountsIBLL.GetList(queryJson);
return Success(data);
@@ -123,7 +126,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue,Gz_AmountsEntity entity)
public ActionResult SaveForm(string keyValue, Gz_AmountsEntity entity)
{
gz_AmountsIBLL.SaveEntity(keyValue, entity);
return Success("保存成功!");
@@ -139,34 +142,34 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ExecuteImportExcel(string fileGuid, int chunks)
public ActionResult ExecuteImportExcel(string fileGuid, int chunks, string ext)
{
string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get());
string path = annexesFileIBLL.SaveAnnexes(fileGuid, $"{fileGuid}.{ext}", chunks, LoginUserInfo.Get());
if (!string.IsNullOrEmpty(path))
{
DataTable dt = ExcelHelper.ExcelImport(path);
(DataTable failDt, int snum, int fnum) res;
//if (type == 1 || type == 2)
//{
// //必修选修
// res = stuScoreIBLL.ExecuteImportExcel(type, dt, fileGuid, queryJson);
//}
//else if (type == 3)
//{
// //补考
// res = stuScoreNotPassIBLL.ExecuteImportExcelForNotPass(dt, fileGuid, queryJson);
//}
//else
//{
// //二次补考
// res = stuScoreNotPassTwoIBLL.ExecuteImportExcelForNotPassTwo(dt, fileGuid, queryJson);
//}
var data = new
if (dt.Rows.Count > 0)
{
Success = 1,
Fail = 2
};
return Success(data);
var cols = new List<string>();
foreach (DataColumn item in dt.Columns)
{
cols.Add(item.ColumnName.Trim());
}
var ignoreCol = Config.GetValue("GzColumn").Split(',');
var useCol = cols.Except(ignoreCol).ToList();
var items = gz_ItemsIBLL.SyncColumn(useCol);


var res = gz_AmountsIBLL.ExecuteImportExcel(dt,ignoreCol,useCol,items, fileGuid);

var data = new
{
Success = res.snum,
Fail = res.failDt.Rows.Count
};
return Success(data);
}
return Fail("EXCEL表无数据");
}
else
{


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/Gz_Amounts/GzImport.js 查看文件

@@ -14,6 +14,7 @@ var bootstrap = function ($, learun) {
param['__RequestVerificationToken'] = $.lrToken;
param['fileGuid'] = fileInfo[file.id].fileGuid;
param['fileName'] = fileInfo[file.id].name;
param['ext'] = file.ext;
param['chunks'] = fileInfo[file.id].chunks;
//var queryJson = JSON.stringify(learun.frameTab.currentIframe().queryJson);



二进制
Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/GzImport.xls 查看文件


+ 2
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config 查看文件

@@ -177,5 +177,6 @@
<add key="Ports" value="192.168.50.127:8007"/>
<!--触发excel开票任务的url-->
<add key="ExcelInvoice" value="http://localhost:60037/api/PayFeeResult/SetUnInvoiceHandle"/>
<!--工资导入EXCEL列忽略项-->
<add key="GzColumn" value="年份,月份,职员代码"/>
</appSettings>

+ 29
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsBLL.cs 查看文件

@@ -23,7 +23,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
public IEnumerable<Gz_AmountsEntity> GetList( string queryJson )
public IEnumerable<Gz_AmountsEntity> GetList(string queryJson)
{
try
{
@@ -142,6 +142,34 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
}
}


#endregion

#region 自定义
/// <summary>
/// 工资导入
/// </summary>
/// <param name="dt"></param>
/// <param name="fileGuid"></param>
/// <returns></returns>
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string[] ignoreCol, List<string> cols, List<Gz_ItemsEntity> itemList, string fileGuid)
{
try
{
return gz_AmountsService.ExecuteImportExcel(dt, ignoreCol, cols, itemList, fileGuid);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion

}


+ 6
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsEntity.cs 查看文件

@@ -45,6 +45,11 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
[Column("USERNO")]
public string UserNo { get; set; }
/// <summary>
/// OriVal
/// </summary>
[Column("ORIVAL")]
public string OriVal { get; set; }
/// <summary>
/// Amount
/// </summary>
/// <returns></returns>
@@ -55,7 +60,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
/// <returns></returns>
[Column("CREATETIME")]
public DateTime? CreateTime { get; set; }
public DateTime? CreateTime { get; set; } = DateTime.Now;
#endregion

#region 扩展操作


+ 6
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsIBLL.cs 查看文件

@@ -20,7 +20,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
/// <param name="queryJson">查询参数</param>
/// <returns></returns>
IEnumerable<Gz_AmountsEntity> GetList( string queryJson );
IEnumerable<Gz_AmountsEntity> GetList(string queryJson);
/// <summary>
/// 获取列表分页数据
/// </summary>
@@ -51,5 +51,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
void SaveEntity(string keyValue, Gz_AmountsEntity entity);
#endregion

#region 自定义
(DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string[] ignoreCol, List<string> cols, List<Gz_ItemsEntity> itemList, string fileGuid);

#endregion

}
}

+ 129
- 3
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs 查看文件

@@ -1,9 +1,12 @@
using Dapper;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Learun.Application.TwoDevelopment.PersonnelManagement
@@ -17,6 +20,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
public class Gz_AmountsService : RepositoryFactory
{
#region 缓存定义
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "Learun_adms_excelError_";
#endregion
#region 构造函数和属性

private string fieldSql;
@@ -25,12 +32,13 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
public Gz_AmountsService()
{
fieldSql=@"
fieldSql = @"
t.Id,
t.Year,
t.Month,
t.ItemId,
t.UserNo,
t.OriVal,
t.Amount,
t.CreateTime
";
@@ -44,7 +52,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
/// <param name="queryJson">条件参数</param>
/// <returns></returns>
public IEnumerable<Gz_AmountsEntity> GetList( string queryJson )
public IEnumerable<Gz_AmountsEntity> GetList(string queryJson)
{
try
{
@@ -137,7 +145,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
{
try
{
this.BaseRepository("CollegeMIS").Delete<Gz_AmountsEntity>(t=>t.Id == keyValue);
this.BaseRepository("CollegeMIS").Delete<Gz_AmountsEntity>(t => t.Id == keyValue);
}
catch (Exception ex)
{
@@ -187,5 +195,123 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement

#endregion


#region 自定义

public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string[] ignoreCol, List<string> cols, List<Gz_ItemsEntity> itemList, string fileGuid)
{
//成功记录数
int snum = 0;
//总记录数
int num = 0;
//var db = this.BaseRepository("CollegeMIS");
var msg = "";
try
{

// 创建一个datatable容器用于保存导入失败的数据
DataTable failDt = new DataTable();
foreach (DataColumn dc in dt.Columns)
{
failDt.Columns.Add(dc.ColumnName, dc.DataType);
}
failDt.Columns.Add("导入错误", typeof(string));
dt.Columns.Add("导入错误", typeof(string));

var addEntity = new List<Gz_AmountsEntity>();
foreach (DataRow dr in dt.Rows)
{
try
{
num++;
var y = dr["年份"].ToString().Trim();
var m = dr["月份"].ToString().Trim();
var u = dr["职员代码"].ToString().Trim();

if (y.IsEmpty() || m.IsEmpty() || u.IsEmpty() || !int.TryParse(y, out var year) || !int.TryParse(m, out var month))
{
dr["导入错误"] = "数据异常:年份、月份、职员代码不可为空且年月为数字";
failDt.Rows.Add(dr.ItemArray);
continue;
}
else
{
var itemId = itemList.Select(x => x.Id).ToArray();
var hlist = this.BaseRepository("CollegeMIS").FindList<Gz_AmountsEntity>(x => x.Year == year && x.Month == month && x.UserNo == u && itemId.Contains(x.ItemId)).ToList();
foreach (var item in cols)
{
var val = dr[item].ToString().Trim();
if (!val.IsEmpty())
{
var itemEntity = itemList.FirstOrDefault(x => x.Name == item);
if (itemEntity != null)
{
var dbm = new Gz_AmountsEntity();
dbm.Create();
dbm.Year = year;
dbm.Month = month;
dbm.UserNo = u;
dbm.ItemId = itemEntity.Id;
dbm.OriVal = val;
if (decimal.TryParse(val, out var amount))
{
dbm.Amount = amount;
}
if(!hlist.Any(x=>x.Year==dbm.Year && x.Month==dbm.Month && x.UserNo==dbm.UserNo && x.ItemId==dbm.ItemId))
{
addEntity.Add(dbm);
}
}
else
{
throw new Exception($"工资项数据查不到 {item}");
}
}
else
{
continue;
}

}
snum++;
}
}
catch (Exception ex)
{

dr["导入错误"] = "出现异常:" + ex.Message;
failDt.Rows.Add(dr.ItemArray);
continue;
}
}
if (addEntity.Any())
{
var rs = this.BaseRepository("CollegeMIS").Insert(addEntity);
}
// 写入缓存如果有未导入的数据
if (failDt.Rows.Count > 0)
{
string errordt = failDt.ToJson();

cache.Write<string>(cacheKey + fileGuid, errordt, CacheId.excel);
}
snum = (num - failDt.Rows.Count) > 0 ? num - failDt.Rows.Count : 0;

return (failDt, snum, failDt.Rows.Count);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}

+ 26
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsBLL.cs 查看文件

@@ -142,7 +142,33 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
}
}


#endregion

#region 自定义
/// <summary>
/// 更新工资明细项
/// </summary>
/// <param name="cols"></param>
public List<Gz_ItemsEntity> SyncColumn(List<string> cols)
{
try
{
return gz_ItemsService.SyncColumn(cols);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

#endregion
}
}

+ 6
- 4
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsEntity.cs 查看文件

@@ -11,8 +11,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// 日 期:2024-01-15 12:28
/// 描 述:工资明细项
/// </summary>
public class Gz_ItemsEntity
public class Gz_ItemsEntity
{

#region 实体成员
/// <summary>
/// Id
@@ -31,19 +33,19 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
/// </summary>
/// <returns></returns>
[Column("ISSHOW")]
public bool? IsShow { get; set; }
public bool? IsShow { get; set; } = false;
/// <summary>
/// ShowOrder
/// </summary>
/// <returns></returns>
[Column("SHOWORDER")]
public int? ShowOrder { get; set; }
public int? ShowOrder { get; set; } = 100;
/// <summary>
/// CreateTime
/// </summary>
/// <returns></returns>
[Column("CREATETIME")]
public DateTime? CreateTime { get; set; }
public DateTime? CreateTime { get; set; } = DateTime.Now;
#endregion

#region 扩展操作


+ 3
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsIBLL.cs 查看文件

@@ -51,5 +51,8 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement
void SaveEntity(string keyValue, Gz_ItemsEntity entity);
#endregion

#region 自定义
List<Gz_ItemsEntity> SyncColumn(List<string> cols);
#endregion
}
}

+ 35
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Items/Gz_ItemsService.cs 查看文件

@@ -4,6 +4,7 @@ using Learun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Learun.Application.TwoDevelopment.PersonnelManagement
@@ -185,5 +186,39 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement

#endregion


#region 自定义
/// <summary>
/// 更新工资明细项
/// </summary>
/// <param name="cols"></param>
public List<Gz_ItemsEntity> SyncColumn(List<string> cols)
{
try
{
var ls = this.BaseRepository("CollegeMIS").FindList<Gz_ItemsEntity>();
var lsName = ls.Select(x => x.Name).ToList();
var exc = cols.Except(lsName);
var addLs = new List<Gz_ItemsEntity>();
if(exc.Any())
{
addLs = exc.Select(x => new Gz_ItemsEntity { Name = x, Id = Guid.NewGuid().ToString() }).ToList();
var r = this.BaseRepository("CollegeMIS").Insert<Gz_ItemsEntity>(addLs);
}
return ls.Union(addLs).ToList();
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion
}
}

正在加载...
取消
保存