@@ -1,7 +1,9 @@ | |||||
using Learun.Application.Base.SystemModule; | using Learun.Application.Base.SystemModule; | ||||
using Learun.Application.TwoDevelopment.PersonnelManagement; | using Learun.Application.TwoDevelopment.PersonnelManagement; | ||||
using Learun.Util; | using Learun.Util; | ||||
using System.Collections.Generic; | |||||
using System.Data; | using System.Data; | ||||
using System.Linq; | |||||
using System.Web.Mvc; | using System.Web.Mvc; | ||||
namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | 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 Gz_AmountsIBLL gz_AmountsIBLL = new Gz_AmountsBLL(); | ||||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | ||||
private Gz_ItemsIBLL gz_ItemsIBLL = new Gz_ItemsBLL(); | |||||
#region 视图功能 | #region 视图功能 | ||||
@@ -27,7 +30,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||||
[HttpGet] | [HttpGet] | ||||
public ActionResult Index() | public ActionResult Index() | ||||
{ | { | ||||
return View(); | |||||
return View(); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 表单页 | /// 表单页 | ||||
@@ -36,7 +39,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||||
[HttpGet] | [HttpGet] | ||||
public ActionResult Form() | public ActionResult Form() | ||||
{ | { | ||||
return View(); | |||||
return View(); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -60,7 +63,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult GetList( string queryJson ) | |||||
public ActionResult GetList(string queryJson) | |||||
{ | { | ||||
var data = gz_AmountsIBLL.GetList(queryJson); | var data = gz_AmountsIBLL.GetList(queryJson); | ||||
return Success(data); | return Success(data); | ||||
@@ -123,7 +126,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||||
[HttpPost] | [HttpPost] | ||||
[ValidateAntiForgeryToken] | [ValidateAntiForgeryToken] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult SaveForm(string keyValue,Gz_AmountsEntity entity) | |||||
public ActionResult SaveForm(string keyValue, Gz_AmountsEntity entity) | |||||
{ | { | ||||
gz_AmountsIBLL.SaveEntity(keyValue, entity); | gz_AmountsIBLL.SaveEntity(keyValue, entity); | ||||
return Success("保存成功!"); | return Success("保存成功!"); | ||||
@@ -139,34 +142,34 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost] | [HttpPost] | ||||
[ValidateAntiForgeryToken] | [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)) | if (!string.IsNullOrEmpty(path)) | ||||
{ | { | ||||
DataTable dt = ExcelHelper.ExcelImport(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 | else | ||||
{ | { | ||||
@@ -14,6 +14,7 @@ var bootstrap = function ($, learun) { | |||||
param['__RequestVerificationToken'] = $.lrToken; | param['__RequestVerificationToken'] = $.lrToken; | ||||
param['fileGuid'] = fileInfo[file.id].fileGuid; | param['fileGuid'] = fileInfo[file.id].fileGuid; | ||||
param['fileName'] = fileInfo[file.id].name; | param['fileName'] = fileInfo[file.id].name; | ||||
param['ext'] = file.ext; | |||||
param['chunks'] = fileInfo[file.id].chunks; | param['chunks'] = fileInfo[file.id].chunks; | ||||
//var queryJson = JSON.stringify(learun.frameTab.currentIframe().queryJson); | //var queryJson = JSON.stringify(learun.frameTab.currentIframe().queryJson); | ||||
@@ -177,5 +177,6 @@ | |||||
<add key="Ports" value="192.168.50.127:8007"/> | <add key="Ports" value="192.168.50.127:8007"/> | ||||
<!--触发excel开票任务的url--> | <!--触发excel开票任务的url--> | ||||
<add key="ExcelInvoice" value="http://localhost:60037/api/PayFeeResult/SetUnInvoiceHandle"/> | <add key="ExcelInvoice" value="http://localhost:60037/api/PayFeeResult/SetUnInvoiceHandle"/> | ||||
<!--工资导入EXCEL列忽略项--> | |||||
<add key="GzColumn" value="年份,月份,职员代码"/> | |||||
</appSettings> | </appSettings> |
@@ -23,7 +23,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
/// <param name="queryJson">查询参数</param> | /// <param name="queryJson">查询参数</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public IEnumerable<Gz_AmountsEntity> GetList( string queryJson ) | |||||
public IEnumerable<Gz_AmountsEntity> GetList(string queryJson) | |||||
{ | { | ||||
try | 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 | #endregion | ||||
} | } | ||||
@@ -45,6 +45,11 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
[Column("USERNO")] | [Column("USERNO")] | ||||
public string UserNo { get; set; } | public string UserNo { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// OriVal | |||||
/// </summary> | |||||
[Column("ORIVAL")] | |||||
public string OriVal { get; set; } | |||||
/// <summary> | |||||
/// Amount | /// Amount | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
@@ -55,7 +60,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[Column("CREATETIME")] | [Column("CREATETIME")] | ||||
public DateTime? CreateTime { get; set; } | |||||
public DateTime? CreateTime { get; set; } = DateTime.Now; | |||||
#endregion | #endregion | ||||
#region 扩展操作 | #region 扩展操作 | ||||
@@ -20,7 +20,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
/// <param name="queryJson">查询参数</param> | /// <param name="queryJson">查询参数</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
IEnumerable<Gz_AmountsEntity> GetList( string queryJson ); | |||||
IEnumerable<Gz_AmountsEntity> GetList(string queryJson); | |||||
/// <summary> | /// <summary> | ||||
/// 获取列表分页数据 | /// 获取列表分页数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -51,5 +51,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
void SaveEntity(string keyValue, Gz_AmountsEntity entity); | void SaveEntity(string keyValue, Gz_AmountsEntity entity); | ||||
#endregion | #endregion | ||||
#region 自定义 | |||||
(DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string[] ignoreCol, List<string> cols, List<Gz_ItemsEntity> itemList, string fileGuid); | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -1,9 +1,12 @@ | |||||
using Dapper; | using Dapper; | ||||
using Learun.Cache.Base; | |||||
using Learun.Cache.Factory; | |||||
using Learun.DataBase.Repository; | using Learun.DataBase.Repository; | ||||
using Learun.Util; | using Learun.Util; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Data; | using System.Data; | ||||
using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
namespace Learun.Application.TwoDevelopment.PersonnelManagement | namespace Learun.Application.TwoDevelopment.PersonnelManagement | ||||
@@ -17,6 +20,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
public class Gz_AmountsService : RepositoryFactory | public class Gz_AmountsService : RepositoryFactory | ||||
{ | { | ||||
#region 缓存定义 | |||||
private ICache cache = CacheFactory.CaChe(); | |||||
private string cacheKey = "Learun_adms_excelError_"; | |||||
#endregion | |||||
#region 构造函数和属性 | #region 构造函数和属性 | ||||
private string fieldSql; | private string fieldSql; | ||||
@@ -25,12 +32,13 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
public Gz_AmountsService() | public Gz_AmountsService() | ||||
{ | { | ||||
fieldSql=@" | |||||
fieldSql = @" | |||||
t.Id, | t.Id, | ||||
t.Year, | t.Year, | ||||
t.Month, | t.Month, | ||||
t.ItemId, | t.ItemId, | ||||
t.UserNo, | t.UserNo, | ||||
t.OriVal, | |||||
t.Amount, | t.Amount, | ||||
t.CreateTime | t.CreateTime | ||||
"; | "; | ||||
@@ -44,7 +52,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
/// <param name="queryJson">条件参数</param> | /// <param name="queryJson">条件参数</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public IEnumerable<Gz_AmountsEntity> GetList( string queryJson ) | |||||
public IEnumerable<Gz_AmountsEntity> GetList(string queryJson) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -137,7 +145,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
this.BaseRepository("CollegeMIS").Delete<Gz_AmountsEntity>(t=>t.Id == keyValue); | |||||
this.BaseRepository("CollegeMIS").Delete<Gz_AmountsEntity>(t => t.Id == keyValue); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -187,5 +195,123 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
#endregion | #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 | |||||
} | } | ||||
} | } |
@@ -142,7 +142,33 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
} | } | ||||
} | } | ||||
#endregion | #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 | |||||
} | } | ||||
} | } |
@@ -11,8 +11,10 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// 日 期:2024-01-15 12:28 | /// 日 期:2024-01-15 12:28 | ||||
/// 描 述:工资明细项 | /// 描 述:工资明细项 | ||||
/// </summary> | /// </summary> | ||||
public class Gz_ItemsEntity | |||||
public class Gz_ItemsEntity | |||||
{ | { | ||||
#region 实体成员 | #region 实体成员 | ||||
/// <summary> | /// <summary> | ||||
/// Id | /// Id | ||||
@@ -31,19 +33,19 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[Column("ISSHOW")] | [Column("ISSHOW")] | ||||
public bool? IsShow { get; set; } | |||||
public bool? IsShow { get; set; } = false; | |||||
/// <summary> | /// <summary> | ||||
/// ShowOrder | /// ShowOrder | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[Column("SHOWORDER")] | [Column("SHOWORDER")] | ||||
public int? ShowOrder { get; set; } | |||||
public int? ShowOrder { get; set; } = 100; | |||||
/// <summary> | /// <summary> | ||||
/// CreateTime | /// CreateTime | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
[Column("CREATETIME")] | [Column("CREATETIME")] | ||||
public DateTime? CreateTime { get; set; } | |||||
public DateTime? CreateTime { get; set; } = DateTime.Now; | |||||
#endregion | #endregion | ||||
#region 扩展操作 | #region 扩展操作 | ||||
@@ -51,5 +51,8 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
void SaveEntity(string keyValue, Gz_ItemsEntity entity); | void SaveEntity(string keyValue, Gz_ItemsEntity entity); | ||||
#endregion | #endregion | ||||
#region 自定义 | |||||
List<Gz_ItemsEntity> SyncColumn(List<string> cols); | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -4,6 +4,7 @@ using Learun.Util; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Data; | using System.Data; | ||||
using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
namespace Learun.Application.TwoDevelopment.PersonnelManagement | namespace Learun.Application.TwoDevelopment.PersonnelManagement | ||||
@@ -185,5 +186,39 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
#endregion | #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 | |||||
} | } | ||||
} | } |