using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using System.Transactions;
|
using zhengcaioa.Models;
|
|
namespace zhengcaioa.Controllers.HR
|
{
|
public class SalaryCheckController : Controller
|
{
|
private readonly IHrDeptService _hrDeptService;
|
private readonly ILogger<SalaryCheckController> _logger;
|
private readonly IHrSalaryService _hrSalaryService;
|
private readonly IWfRunProcessService _wfRunProcessService;
|
private readonly IWfHistoryService _wfHistoryService;
|
private readonly IWfNeeddeelService _wfNeeddeelService;
|
|
public SalaryCheckController(ILogger<SalaryCheckController> logger, IHrSalaryService hrSalaryService, IHrDeptService hrDeptService, IWfRunProcessService wfRunProcessService
|
, IWfHistoryService wfHistoryService, IWfNeeddeelService wfNeeddeelService)
|
{
|
_logger = logger;
|
_hrDeptService = hrDeptService;
|
_hrSalaryService = hrSalaryService;
|
_wfRunProcessService = wfRunProcessService;
|
_wfHistoryService = wfHistoryService;
|
_wfNeeddeelService = wfNeeddeelService;
|
}
|
|
public IActionResult Index()
|
{
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
|
ActionEntity actionEntity1 = new ActionEntity();
|
actionEntity1.OpenType = 0;
|
actionEntity1.ActionUrl = "";
|
actionEntity1.ActionFun = "Edit";
|
actionEntity1.PageIco = "fa fa-plus";
|
actionEntity1.ActionName = "核准";
|
actionlist.Add(actionEntity1);
|
|
ViewBag.editBtn = false;
|
|
ViewData["ActionInfo"] = actionlist;
|
|
ViewBag.dept = _hrDeptService.GetList().Select(x => new { code = x.Id, label = x.DeptName }).ToList();
|
|
return View();
|
}
|
|
|
/// <summary>
|
/// 列表内容
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public IActionResult GetList(HrSalaryDTOSearch search)
|
{
|
//_hrSalaryService.AutoCheck();
|
|
return new JsonResult(_hrSalaryService.SearchSalaryByPaging(search));
|
}
|
|
/// <summary>
|
/// 编辑页
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public IActionResult Edit(string id)
|
{
|
HrSalaryDTO dto = new HrSalaryDTO();
|
if (!string.IsNullOrEmpty(id))
|
{
|
dto = _hrSalaryService.Get(id);
|
}
|
if(!dto.Jiangjin.HasValue)
|
{
|
dto.Jiangjin = 0;
|
}
|
if (!dto.Bufagongzi.HasValue)
|
{
|
dto.Bufagongzi = 0;
|
}
|
if (!dto.Peichang.HasValue)
|
{
|
dto.Peichang = 0;
|
}
|
if (!dto.Jiucuo.HasValue)
|
{
|
dto.Jiucuo = 0;
|
}
|
ViewData.Model = dto;
|
return View();
|
}
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult SaveCheck(HrSalaryUpDTO data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ResultEntity resultEntity = new ResultEntity();
|
using (TransactionScope scope = new TransactionScope())
|
{
|
data.Modifier = curentuser.Id;
|
resultEntity = _hrSalaryService.SaveCheckSalary(data);
|
scope.Complete();
|
}
|
return new JsonResult(resultEntity);
|
}
|
|
#region 工资核对
|
|
public IActionResult Employee()
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewBag.Employee = curentuser;
|
return View();
|
}
|
|
public JsonResult EmployeeSalary(string month)
|
{
|
ResultDataEntity<HrSalaryDTO> data = new ResultDataEntity<HrSalaryDTO>();
|
HrSalaryDTOSearch searchEntity = new HrSalaryDTOSearch();
|
searchEntity.page = 0;
|
searchEntity.rows = 10;
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
if (!string.IsNullOrEmpty(month))
|
{
|
var dtime = DateTime.Parse(month);
|
var md = _hrSalaryService.GetSalary(curentuser.Id, dtime.Year,dtime.Month);
|
if (searchEntity.totalrows == 0)
|
searchEntity.totalrows =1;
|
data.LoadData(searchEntity, md );
|
}
|
|
return Json(data);
|
}
|
|
[HttpPost]
|
public JsonResult SalaryCheckOk(string id)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ResultEntity resultEntity = new ResultEntity();
|
if(!string.IsNullOrEmpty(id))
|
{
|
using (TransactionScope scope = new TransactionScope())
|
{
|
resultEntity = _hrSalaryService.CheckOk(id, curentuser.Id);
|
scope.Complete();
|
}
|
}
|
|
return Json(resultEntity);
|
}
|
|
|
public IActionResult Appeal(string id="",string salaryId = "")
|
{
|
HrSalaryAppeal dto = new HrSalaryAppeal();
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
dto = _hrSalaryService.GetAppeal(id, curentuser.Id, salaryId);
|
|
//流程相关
|
string shifoubiaoji = "A";
|
string sifoudangqian = "A";
|
string dangqianbuzhou = "提交";
|
var lishiyijian = new List<WfHistoryDTO>();
|
|
if (dto==null)
|
{
|
var salaryDTO = _hrSalaryService.Get(salaryId);
|
dto = new HrSalaryAppeal();
|
dto.salary_id = salaryId;
|
dto.year = salaryDTO.Year;
|
dto.month = salaryDTO.Month;
|
dto.createrName = curentuser.UserName;
|
dto.tittle = "工资申诉(" + curentuser.UserName + ")";
|
}
|
else if (dto != null)
|
{
|
var wfRunProcessDTO = _wfRunProcessService.GetList(dto.id, "03").FirstOrDefault();
|
if (wfRunProcessDTO == null)
|
{
|
shifoubiaoji = "D";
|
sifoudangqian = "D";
|
}
|
else
|
{
|
dangqianbuzhou = wfRunProcessDTO.Step;
|
//查询审批进度
|
lishiyijian = _wfHistoryService.GetListshenpi(wfRunProcessDTO.Id);
|
if (wfRunProcessDTO.Step != "提交")
|
{
|
shifoubiaoji = "D";
|
}
|
|
//查询待办
|
var chaxundaiban = _wfNeeddeelService.GetListTracking(wfRunProcessDTO.Id, wfRunProcessDTO.Step).Where(x => x.DeelUserId == curentuser.Id).ToList();
|
if (chaxundaiban != null && chaxundaiban.Count > 0)
|
{
|
sifoudangqian = "A";
|
}
|
else
|
{
|
sifoudangqian = "D";
|
}
|
|
}
|
|
|
|
|
}
|
|
ViewBag.shifoubiaoji = shifoubiaoji;
|
ViewBag.sifoudangqian = sifoudangqian;
|
ViewBag.lishiyijian = lishiyijian;
|
ViewBag.dangqianbuzhou = dangqianbuzhou;
|
|
ViewData.Model = dto;
|
return View();
|
}
|
|
/// <summary>
|
/// 保存申诉
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult SaveAppeal(HrSalaryAppealDTO data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ResultEntity resultEntity = new ResultEntity();
|
using (TransactionScope scope = new TransactionScope())
|
{
|
if (data.Step == "提交")
|
{
|
data.sub_user = curentuser.Id;
|
data.shenpi_status = "D";
|
data.status = "A";
|
resultEntity = _hrSalaryService.CheckAppea(data);
|
if (!resultEntity.Result)
|
{
|
return new JsonResult(resultEntity);
|
}
|
}
|
|
|
//发起流程相关
|
|
resultEntity = _wfRunProcessService.WfSalaryAppeal(data.id, data.Step, data.Tongguojujue, curentuser.Id, data.Content, data.tittle, "v1");
|
if (!resultEntity.Result)
|
{
|
return new JsonResult(resultEntity);
|
}
|
scope.Complete();
|
}
|
return new JsonResult(resultEntity);
|
}
|
|
#endregion
|
|
#region 工资查询
|
|
public IActionResult SearchIndex()
|
{
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
ViewData["ActionInfo"] = actionlist;
|
|
ViewBag.dept = _hrDeptService.GetList().Select(x => new { code = x.Id, label = x.DeptName }).ToList();
|
ViewBag.stime = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM-dd");
|
ViewBag.etime = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
|
|
return View();
|
}
|
|
/// <summary>
|
/// 列表内容
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public IActionResult GetSearchList(HrSalaryDTOSearch search)
|
{
|
//自动确认
|
//_hrSalaryService.AutoCheck();
|
|
return new JsonResult(_hrSalaryService.SearchByPagingFinish(search));
|
}
|
|
#endregion
|
}
|
}
|