username@email.com
2021-07-05 98cd7063d9b9a1570dcfbac92f5c2b35d904868b
zhengcaioa/zhengcaioa/Controllers/HR/SalaryCheckController.cs
@@ -18,12 +18,19 @@
        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)
        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()
@@ -148,19 +155,69 @@
        }
        public IActionResult Appeal(string id)
        public IActionResult Appeal(string id="",string salaryId = "")
        {
            HrSalaryAppeal dto = new HrSalaryAppeal();
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            if (!string.IsNullOrEmpty(id))
            {
                dto = _hrSalaryService.GetAppeal(id, curentuser.Id);
                if(dto==null)
            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 = id;
                }
                    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();
        }
@@ -171,14 +228,24 @@
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SaveAppeal(HrSalaryAppeal data)
        public IActionResult SaveAppeal(HrSalaryAppealDTO data)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            using (TransactionScope scope = new TransactionScope())
            {
                data.sub_user = curentuser.Id;
                resultEntity = _hrSalaryService.CheckAppea(data);
                if (data.Step == "提交")
                {
                    data.sub_user = curentuser.Id;
                    data.shenpi_status = "D";
                    data.status = "A";
                    resultEntity = _hrSalaryService.CheckAppea(data);
                }
                //发起流程相关
                resultEntity = _wfRunProcessService.WfSalaryAppeal(data.id, data.Step, data.Tongguojujue, curentuser.Id, data.Content, data.tittle, "v1");
                scope.Complete();
            }
            return new JsonResult(resultEntity);