using Learun.Application.Base.SystemModule; using Learun.Application.TwoDevelopment.PersonnelManagement; using Learun.Util; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web.Mvc; namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers { /// /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 /// 创 建:超级管理员 /// 日 期:2024-01-15 14:07 /// 描 述:工资明细信息 /// public class Gz_AmountsController : MvcControllerBase { private Gz_AmountsIBLL gz_AmountsIBLL = new Gz_AmountsBLL(); private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); private Gz_ItemsIBLL gz_ItemsIBLL = new Gz_ItemsBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { return View(); } /// /// 导入工资 /// /// [HttpGet] public ActionResult GzImport() { return View(); } /// /// 我的工资 /// /// [HttpGet] public ActionResult MyAmount() { return View(); } #endregion #region 获取数据 /// /// 获取列表数据 /// /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetList(string queryJson) { var data = gz_AmountsIBLL.GetList(queryJson); return Success(data); } /// /// 获取列表分页数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = gz_AmountsIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取列表分页数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageListCol(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = gz_AmountsIBLL.GetPageListCol(paginationobj, queryJson, out decimal totalSend); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, totalSend }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetPageListMyCol(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var user = LoginUserInfo.Get(); var data = gz_AmountsIBLL.GetPageListCol(paginationobj, queryJson, user.account); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetPageListMyCurrCol(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var user = LoginUserInfo.Get(); var data = gz_AmountsIBLL.GetPageListCol(user.account,out var year,out var month); var jsonData = new { year, month, rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取表单数据 /// /// 主键 /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { var data = gz_AmountsIBLL.GetEntity(keyValue); return Success(data); } [HttpGet] [AjaxOnly] public ActionResult GetDetail(string userNo, int year, int month, string cs) { var data = gz_AmountsIBLL.GetAmountsDetail(userNo, year, month, cs, 0); return Success(data); } #endregion #region 提交数据 /// /// 删除实体数据 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm() { var userNo = Request.Params["userNo"].ToString().Split(','); var year = Request.Params["year"].ToString().Split(',').Select(x=>int.Parse(x)).ToArray(); var month = Request.Params["month"].ToString().Split(',').Select(x => int.Parse(x)).ToArray(); var sendCount = Request.Params["sendCount"].ToString().Split(','); gz_AmountsIBLL.DeleteEntity(userNo, year, month, sendCount); return Success("删除成功!"); } /// /// 保存实体数据(新增、修改) /// /// 主键 /// 实体 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, Gz_AmountsEntity entity) { gz_AmountsIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion #region 导入 /// /// 导入 /// /// /// /// [HttpPost] [ValidateAntiForgeryToken] public ActionResult ExecuteImportExcel(string fileGuid, int chunks, string ext) { string path = annexesFileIBLL.SaveAnnexes(fileGuid, $"{fileGuid}.{ext}", chunks, LoginUserInfo.Get()); if (!string.IsNullOrEmpty(path)) { DataTable dt = ExcelHelper.ExcelImport(path); if (dt.Rows.Count > 0) { var cols = new List(); 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 { return Fail("导入数据失败!"); } } #endregion #region 导出 [HttpPost, ValidateInput(false)] public ActionResult ExportCol(string queryJson) { var paginationobj = new Pagination { page = 1, rows = 10000, sidx = string.Empty, sord = "DESC" }; var data = gz_AmountsIBLL.GetPageListCol(paginationobj, queryJson, out decimal totalSend).ToList(); var result = new List>(); if(data.Any()) { foreach (var item in data) { var dic = new Dictionary(); dic.Add("DeptCode", item.DeptCode); dic.Add("DeptName", item.DeptName); dic.Add("PersonTypeCode", item.PersonTypeCode); dic.Add("PersonType", item.PersonType); dic.Add("UserNo", item.UserNo); dic.Add("RealName", item.RealName); dic.Add("SendDate", item.SendDate); dic.Add("SendCount", item.SendCount); dic.Add("Year", item.Year.ToString()); dic.Add("Month", item.Month.ToString()); dic.Add("TotalPay", item.TotalPay); dic.Add("TotalDeduction", item.TotalDeduction); dic.Add("TotalSend", item.TotalSend); dic.Add("Remark", item.Remark); result.Add(dic); } var str = JsonConvert.SerializeObject(result); var dt = str.ToTable(); //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = " 工资数据列表"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 20; excelconfig.FileName = " 工资数据导出.xls"; excelconfig.IsAllSizeColumn = true; //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出 excelconfig.ColumnEntity = new List(); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "DeptCode", ExcelColumn = "部门代码" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "DeptName", ExcelColumn = "部门名称" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "PersonTypeCode", ExcelColumn = "职员类型代码" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "PersonType", ExcelColumn = "职员类型" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "UserNo", ExcelColumn = "职员代码" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "RealName", ExcelColumn = "职员姓名" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "SendDate", ExcelColumn = "发放时间" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "SendCount", ExcelColumn = "发放次数" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Year", ExcelColumn = "发放年份" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Month", ExcelColumn = "发放月份" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalPay", ExcelColumn = "应发合计" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalDeduction", ExcelColumn = "扣款合计" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TotalSend", ExcelColumn = "实发合计" }); excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "Remark", ExcelColumn = "备注" }); //调用导出方法 ExcelHelper.ExcelDownload(dt, excelconfig); return Success("导出成功!"); } else { return Success("无可导出数据!"); } } #endregion } }