username@email.com
2022-08-27 6e2b929cf381e2320ba6e7dec56c0371124d2b51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
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;
        private readonly IPltPageService _pltPageService;
 
        public SalaryCheckController(ILogger<SalaryCheckController> logger, IHrSalaryService hrSalaryService, IHrDeptService hrDeptService, IWfRunProcessService wfRunProcessService
            , IWfHistoryService wfHistoryService, IWfNeeddeelService wfNeeddeelService
              , IPltPageService pltPageService)
        {
            _logger = logger;            
            _hrDeptService = hrDeptService;
            _hrSalaryService = hrSalaryService;
            _wfRunProcessService = wfRunProcessService;
            _wfHistoryService = wfHistoryService;
            _wfNeeddeelService = wfNeeddeelService;
            _pltPageService = pltPageService;
        }
 
        public IActionResult Index()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            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);
            var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/SalaryCheck/Index");
            var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
            foreach (var pageEntity in pageEntities1)
            {
                ActionEntity actionEntity1 = new ActionEntity();
                actionEntity1.OpenType = pageEntity.OpenType;
                actionEntity1.ActionUrl = "";
                actionEntity1.ActionFun = pageEntity.PageShortcut;
                actionEntity1.PageIco = pageEntity.PageIco;
                actionEntity1.ActionName = pageEntity.PageName;
                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();
            if (!string.IsNullOrEmpty(search.YearMonth222))
            {
                search.YearMonth = search.YearMonth222;
            }
 
            return new JsonResult(_hrSalaryService.SearchSalaryByPaging(search));
        }
 
        /// <summary>
        /// 编辑页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Edit(string id)
        {
 
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/SalaryCheck/Index");
            var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
            ViewData["ActionInfo2"] = pageEntities2;
            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.Value == 0)
            {
                dto.Jiucuo = 0;
            }
            //if (!dto.Yufagongziheji.HasValue)
            //{
            //    dto.Yufagongziheji = 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.AddMonths(-1).AddDays(1 - DateTime.Now.Day).Date.ToString("yyyy-MM");
            ViewBag.etime = DateTime.Now.AddMonths(-1).AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM"); 
 
            return View();
        }
 
        /// <summary>
        /// 列表内容
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IActionResult GetSearchList(HrSalaryDTOSearch search)
        {
            //自动确认
            //_hrSalaryService.AutoCheck();
            if (!string.IsNullOrEmpty(search.searchDatestart222))
            {
                search.searchDatestart = search.searchDatestart222;
            }
            if (!string.IsNullOrEmpty(search.searchDateend222))
            {
                search.searchDateend = search.searchDateend222;
            }
 
            return new JsonResult(_hrSalaryService.SearchByPagingFinish(search));
        }
 
        #endregion
 
 
 
        #region 工资查询
 
        public IActionResult SearchIndexRenshi(string UserId)
        {
            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.AddMonths(-1).ToString("yyyy-MM");
            ViewBag.etime = DateTime.Now.AddMonths(-1).AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM");
 
            ViewBag.UserId = UserId;
 
            return View();
        }
 
        /// <summary>
        /// 列表内容
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IActionResult GetSearchListRenshi(HrSalaryDTOSearch search)
        {
            if (!string.IsNullOrEmpty(search.searchDatestart222))
            {
                search.searchDatestart = search.searchDatestart222;
            }
            if (!string.IsNullOrEmpty(search.searchDateend222))
            {
                search.searchDateend = search.searchDateend222;
            }
 
            //自动确认
            //_hrSalaryService.AutoCheck();
 
            if (!string.IsNullOrEmpty(search.searchDatestart))
            {
                search.searchDatestart = DateTime.Now.ToString("yyyy-MM");
            }
            if (!string.IsNullOrEmpty(search.searchDateend))
            {
                search.searchDate = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM");
            }
 
            return new JsonResult(_hrSalaryService.SearchByPagingFinish(search));
        }
 
        #endregion
    }
}