username@email.com
2021-06-07 c218f7fadbef75a948e94ac3fd3635a31294cbdd
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
using IServices;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zhengcaioa.Models;
using Newtonsoft.Json;
using DTO;
using Microsoft.AspNetCore.Http;
using zhengcaioa.IService;
 
namespace zhengcaioa.Controllers.AdmManagement
{
    public class DailyManagementController : Controller
    {
        private readonly ILogger<DailyManagementController> _logger;
        private readonly IDailyManagementService _DailyManageService;
        private readonly ILiaotianService _liaotianService;
        private readonly IUserService _userService;
        private readonly IHrDeptService _hrDeptService;
 
        [CheckLogin]
        public DailyManagementController(ILogger<DailyManagementController> logger, IDailyManagementService DailyManageService, 
                 ILiaotianService liaotianService, IUserService userService, IHrDeptService hrDeptService)
        {
            _logger = logger;
            _DailyManageService = DailyManageService;
            _liaotianService = liaotianService;
            _userService =  userService;
            _hrDeptService = hrDeptService;
        }
 
        #region 通话管理
        [CheckLogin]
        public IActionResult HoldPhone()
        {
            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 = "Add";
            actionEntity1.PageIco = "fa fa-plus";
            actionEntity1.ActionName = "新增";
            actionlist.Add(actionEntity1);            
            ViewData["ActionInfo"] = actionlist;
            ViewBag.LineType =    _liaotianService.GetSYScode("ADM_HoldPhone", "LineType").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Intention = _liaotianService.GetSYScode("ADM_HoldPhone", "Intention").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            return View();
        }
 
        [CheckLogin]
        public string GetList(AdmHoldPhoneDTOSearch search)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            return JsonConvert.SerializeObject(_DailyManageService.GetHoldPhoneList(search));
        }
 
        [CheckLogin]
        public IActionResult EditHoldPhone(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
 
            ViewData["users"]  = _userService.GetList();
            ViewData["LineType"] = _liaotianService.GetSYScode("ADM_HoldPhone", "LineType").ToList();
            ViewData["Intention"] = _liaotianService.GetSYScode("ADM_HoldPhone", "Intention").ToList();
            AdmHoldPhoneDTO admHoldPhoneDTO = _DailyManageService.GetHoldPhone(id);
            if (admHoldPhoneDTO.InTime.Equals(DateTime.MinValue))
            {
                admHoldPhoneDTO.InTime = DateTime.Now;
            }
            if (string.IsNullOrEmpty(admHoldPhoneDTO.UserId) )
            {
                admHoldPhoneDTO.UserId = curentuser.Id;
            }
 
            if (string.IsNullOrEmpty(admHoldPhoneDTO.LineType))
            {
                admHoldPhoneDTO.LineType = "1";
            }
            if (string.IsNullOrEmpty(admHoldPhoneDTO.Intention))
            {
                admHoldPhoneDTO.Intention = "3";
            }
 
            ViewData.Model = admHoldPhoneDTO;
            return View();
        }
 
        [CheckLogin]
        [HttpPost]
        public string SaveAskLeave(AdmHoldPhoneDTO admHoldPhone)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            admHoldPhone.RecStatus = "A";
            if (String.IsNullOrEmpty(admHoldPhone.Id))
            {
                admHoldPhone.Creater = curentuser.Id;
                admHoldPhone.Createtime = DateTime.Now;
            }
            else
            {
                admHoldPhone.Modifier = curentuser.Id;
                admHoldPhone.Modifytime = DateTime.Now;
            }            
            ResultEntity resultEntity = _DailyManageService.SaveHoldPhone(admHoldPhone);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
        [CheckLogin]
        public string ModifyStatus(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ResultEntity resultEntity = _DailyManageService.ModifyStatus(id, curentuser.Id);
            return JsonConvert.SerializeObject(resultEntity); 
        }
        #endregion
 
        #region 工作提醒
        /// <summary>
        /// 工作提醒
        /// </summary>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult MemoBook()
        {
            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 = "Add";
            actionEntity1.PageIco = "fa fa-plus";
            actionEntity1.ActionName = "提醒同事";
            actionlist.Add(actionEntity1);
 
            //ActionEntity actionEntity2 = new ActionEntity();
            //actionEntity2.OpenType = 0;
            //actionEntity2.ActionUrl = "";
            //actionEntity2.ActionFun = "Memo";
            //actionEntity2.PageIco = "fa fa-plus";
            //actionEntity2.ActionName = "我的备忘录";
            //actionlist.Add(actionEntity2);
            ViewData["ActionInfo"] = actionlist;          
            return View();
        }
 
        /// <summary>
        /// 工作提醒列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        [CheckLogin]
        public string GetMomeBookList(AdmMemoBookDTOSearch search)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
           // search.Creater = curentuser.Id;
            return JsonConvert.SerializeObject(_DailyManageService.GetMemoBookList(search));
        }
 
 
        [CheckLogin]
        public IActionResult EditMemoBook(string Rtype="1" , string id = "0") 
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["users"] = _userService.GetList().Where(x=>x.Id != curentuser.Id).ToList();
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(id);
            if (!admMemoBookDTO.Time.HasValue)
            {
                admMemoBookDTO.TimeName = "";
                Rtype = string.IsNullOrEmpty(admMemoBookDTO.Rtype)? Rtype : admMemoBookDTO.Rtype;
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
                Rtype = string.IsNullOrEmpty(admMemoBookDTO.Rtype) ? Rtype : admMemoBookDTO.Rtype;
            }
            ViewData.Model = admMemoBookDTO;
            ViewBag.Rtype = Rtype;
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
 
        [CheckLogin]
        public string ModifyMemoBookStatus(string id,bool isReaded = false)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO =  _DailyManageService.GetMemoBook(id);
            if (admMemoBookDTO.HaveRead == 1)
            {
                resultEntity.Result = false;
                resultEntity.Message = "已经完成得提醒不能删除";
                return JsonConvert.SerializeObject(resultEntity);
            }
            resultEntity = _DailyManageService.ModifyMemoBookStatus(id, curentuser.Id, isReaded);
            return JsonConvert.SerializeObject(resultEntity);
        }
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveMemoBook(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            memoBook.RecStatus = "A";
            if (String.IsNullOrEmpty(memoBook.Id))
            {
                memoBook.Creater = curentuser.Id;
                memoBook.Createtime = DateTime.Now;
            }
            else
            {
                memoBook.Modifier = curentuser.Id;
                memoBook.Modifytime = DateTime.Now;
            }
            ResultEntity resultEntity = _DailyManageService.SaveMemoBook(memoBook);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
        public IActionResult ShowRemind()
        {
           var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;             
            return View();
        }
 
        public int CountRemindRecord()
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
             return _DailyManageService.GetRemind(curentuser.Id);
        }
        #endregion
 
 
 
 
 
 
        #region 工作安排
        /// <summary>
        /// 工作提醒
        /// </summary>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult MemoWorkAnPai()
        {
            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 = "Add";
            actionEntity1.PageIco = "fa fa-plus";
            actionEntity1.ActionName = "工作安排";
            actionlist.Add(actionEntity1);
 
            //ActionEntity actionEntity2 = new ActionEntity();
            //actionEntity2.OpenType = 0;
            //actionEntity2.ActionUrl = "";
            //actionEntity2.ActionFun = "Memo";
            //actionEntity2.PageIco = "fa fa-plus";
            //actionEntity2.ActionName = "我的备忘录";
            //actionlist.Add(actionEntity2);
            ViewBag.Dept = _hrDeptService.GetList().Select(x => new { code = x.Id, label = x.DeptName }).ToList();
            ViewBag.User = _userService.GetList().Select(x => new { code = x.Id, label = x.UserName }).ToList();
 
            ViewBag.Wancheng = _liaotianService.GetSYScode("ADM_MemoBook", "HaveRead").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewData["ActionInfo"] = actionlist;
            return View();
        }
 
        /// <summary>
        /// 工作提醒列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        [CheckLogin]
        public string GetWorkAnPaiList(AdmMemoBookDTOSearch search)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            // search.Creater = curentuser.Id;
            return JsonConvert.SerializeObject(_DailyManageService.GetMemoBookList(search));
        }
 
 
 
        [CheckLogin]
        public IActionResult EditWorkAnPai( string id = "")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ViewData["users"] = _userService.GetList().Where(x => x.Id != curentuser.Id).ToList();
            AdmMemoBookDTO admMemoBookDTO = new AdmMemoBookDTO();
            if (!string.IsNullOrEmpty(id))
            {
                admMemoBookDTO = _DailyManageService.GetMemoBook(id);
                admMemoBookDTO.WorkDept = _userService.GetPltUserEntity(admMemoBookDTO.ToUserId).DeptId;
            }
            
            if (!admMemoBookDTO.Time.HasValue)
            {
                //admMemoBookDTO.Time = DateTime.Now;
                admMemoBookDTO.TimeName = "";
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ViewData.Model = admMemoBookDTO;
            ViewData["Dept"] = _hrDeptService.GetList();
 
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
        [CheckLogin]
        public string ModifyWorkAnPaiStatus(string id, bool isReaded = false)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(id);
            if (admMemoBookDTO.HaveRead == 1)
            {
                resultEntity.Result = false;
                resultEntity.Message = "已经完成得工作不能删除";
                return JsonConvert.SerializeObject(resultEntity);
            }
            resultEntity = _DailyManageService.ModifyMemoBookStatus(id, curentuser.Id, isReaded);
            return JsonConvert.SerializeObject(resultEntity);
        }
 
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveWorkAnPai(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            memoBook.RecStatus = "A";
            if (String.IsNullOrEmpty(memoBook.Id))
            {
                memoBook.Creater = curentuser.Id;
                memoBook.Createtime = DateTime.Now;
            }
            else
            {
                memoBook.Modifier = curentuser.Id;
                memoBook.Modifytime = DateTime.Now;
            }
 
            ResultEntity resultEntity = _DailyManageService.SaveMemoBook(memoBook);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
        [CheckLogin]
        public IActionResult EditWorkKaoHe(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            AdmMemoBookDTO admMemoBookDTO = new AdmMemoBookDTO();
            if (!string.IsNullOrEmpty(id))
            {
                admMemoBookDTO = _DailyManageService.GetMemoBook(id);
                admMemoBookDTO.WorkDept = _userService.GetPltUserEntity(admMemoBookDTO.ToUserId).DeptId;
            }
 
            if (!admMemoBookDTO.Time.HasValue)
            {
                //admMemoBookDTO.Time = DateTime.Now;
                admMemoBookDTO.TimeName = "";
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ViewData.Model = admMemoBookDTO;
            ViewBag.KaoHe = _liaotianService.GetSYScode("ADM_MemoBook", "KaoHe");
 
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveWorkKaoHe(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(memoBook.Id);
            if (string.IsNullOrEmpty(admMemoBookDTO.Id))
            {
                resultEntity.Result = false;
                resultEntity.Message = "未找到工作安排";
                return JsonConvert.SerializeObject(resultEntity);
            }
            if (admMemoBookDTO.HaveRead!=1)
            {
                resultEntity.Result = false;
                resultEntity.Message = "未完成的工作不能考核";
                return JsonConvert.SerializeObject(resultEntity);
            }
            admMemoBookDTO.KaoHe = memoBook.KaoHe;
            admMemoBookDTO.ZhuiZe = memoBook.ZhuiZe;
            admMemoBookDTO.Modifier = curentuser.Id;
            admMemoBookDTO.Modifytime = DateTime.Now;
 
 
              resultEntity = _DailyManageService.SaveMemoBookKaohe(admMemoBookDTO);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
        #endregion
 
 
 
 
        #region 我的工作
        /// <summary>
        /// 工作提醒
        /// </summary>
        /// <returns></returns>
        [CheckLogin]
        public IActionResult MemoWorkmy()
        {
            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 = "Add";
            actionEntity1.PageIco = "fa fa-plus";
            actionEntity1.ActionName = "我的备忘录";
            actionlist.Add(actionEntity1);
 
            //ActionEntity actionEntity2 = new ActionEntity();
            //actionEntity2.OpenType = 0;
            //actionEntity2.ActionUrl = "";
            //actionEntity2.ActionFun = "Memo";
            //actionEntity2.PageIco = "fa fa-plus";
            //actionEntity2.ActionName = "我的备忘录";
            //actionlist.Add(actionEntity2);
          
 
            ViewBag.Wancheng = _liaotianService.GetSYScode("ADM_MemoBook", "HaveRead").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.Rtype = _liaotianService.GetSYScode("ADM_MemoBook", "Rtype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewBag.KaoHe = _liaotianService.GetSYScode("ADM_MemoBook", "KaoHe").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
            ViewData["ActionInfo"] = actionlist;
            return View();
        }
 
        /// <summary>
        /// 工作提醒列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        [CheckLogin]
        public string GetWorkmyList(AdmMemoBookDTOSearch search)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            // search.Creater = curentuser.Id;
            return JsonConvert.SerializeObject(_DailyManageService.GetMemoBookList(search));
        }
 
 
        [CheckLogin]
        public IActionResult EditWorkmy(string id = "")
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
           
            AdmMemoBookDTO admMemoBookDTO = new AdmMemoBookDTO();
            if (!string.IsNullOrEmpty(id))
            {
                admMemoBookDTO = _DailyManageService.GetMemoBook(id);
            }
 
            if (!admMemoBookDTO.Time.HasValue)
            {
                //admMemoBookDTO.Time = DateTime.Now;
                admMemoBookDTO.TimeName = "";
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ViewData.Model = admMemoBookDTO;
            ViewBag.Rtype = _liaotianService.GetSYScode("ADM_MemoBook", "Rtype").Where(x=>x.CodeSn=="2" || x.CodeSn == "4").ToList();
 
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
        [CheckLogin]
        public string ModifyWorkmyStatus(string id, bool isReaded = false)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ViewData["curentuser"] = curentuser;
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(id);
            if (admMemoBookDTO.HaveRead == 1)
            {
                resultEntity.Result = false;
                resultEntity.Message = "已经完成得工作不能删除";
                return JsonConvert.SerializeObject(resultEntity);
            }
            resultEntity = _DailyManageService.ModifyMemoBookStatus(id, curentuser.Id, isReaded);
            return JsonConvert.SerializeObject(resultEntity);
        }
 
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveWorkmy(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            memoBook.RecStatus = "A";
            memoBook.ToUserId = curentuser.Id;
            if (String.IsNullOrEmpty(memoBook.Id))
            {
                memoBook.Creater = curentuser.Id;
                memoBook.Createtime = DateTime.Now;
            }
            else
            {
                memoBook.Modifier = curentuser.Id;
                memoBook.Modifytime = DateTime.Now;
            }
 
            ResultEntity resultEntity = _DailyManageService.SaveMemoBook(memoBook);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
        [CheckLogin]
        public IActionResult EditWorkBanLi(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            AdmMemoBookDTO admMemoBookDTO = new AdmMemoBookDTO();
            if (!string.IsNullOrEmpty(id))
            {
                admMemoBookDTO = _DailyManageService.GetMemoBook(id);
                admMemoBookDTO.WorkDept = _userService.GetPltUserEntity(admMemoBookDTO.ToUserId).DeptId;
            }
 
            if (!admMemoBookDTO.Time.HasValue)
            {
                //admMemoBookDTO.Time = DateTime.Now;
                admMemoBookDTO.TimeName = "";
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ViewData.Model = admMemoBookDTO;
           
 
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveWorkBanLi(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(memoBook.Id);
            if (string.IsNullOrEmpty(admMemoBookDTO.Id))
            {
                resultEntity.Result = false;
                resultEntity.Message = "未找到我的工作";
                return JsonConvert.SerializeObject(resultEntity);
            }
             
            admMemoBookDTO.BanLi = memoBook.BanLi;
            admMemoBookDTO.HaveRead = 1;
            admMemoBookDTO.Modifier = curentuser.Id;
            admMemoBookDTO.Modifytime = DateTime.Now;
            admMemoBookDTO.WanchengTime = admMemoBookDTO.Modifytime;
 
 
            resultEntity = _DailyManageService.SaveMemoBook(admMemoBookDTO);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
 
 
        [CheckLogin]
        public IActionResult EditWorkShenSu(string id)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            AdmMemoBookDTO admMemoBookDTO = new AdmMemoBookDTO();
            if (!string.IsNullOrEmpty(id))
            {
                admMemoBookDTO = _DailyManageService.GetMemoBook(id);
                admMemoBookDTO.WorkDept = _userService.GetPltUserEntity(admMemoBookDTO.ToUserId).DeptId;
            }
 
            if (!admMemoBookDTO.Time.HasValue)
            {
                //admMemoBookDTO.Time = DateTime.Now;
                admMemoBookDTO.TimeName = "";
            }
            else
            {
                admMemoBookDTO.TimeName = admMemoBookDTO.Time.Value.ToString("yyyy-MM-dd HH:mm");
            }
            ViewData.Model = admMemoBookDTO;
 
 
            ViewBag.curUserId = curentuser.Id;
            return View();
        }
 
 
        [CheckLogin]
        [HttpPost]
        public string SaveWorkShenSu(AdmMemoBookDTO memoBook)
        {
            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
            ResultEntity resultEntity = new ResultEntity();
            resultEntity.Result = false;
            AdmMemoBookDTO admMemoBookDTO = _DailyManageService.GetMemoBook(memoBook.Id);
            if (string.IsNullOrEmpty(admMemoBookDTO.Id))
            {
                resultEntity.Result = false;
                resultEntity.Message = "未找到我的工作";
                return JsonConvert.SerializeObject(resultEntity);
            }
 
            admMemoBookDTO.ShenSu = memoBook.ShenSu;
            admMemoBookDTO.Modifier = curentuser.Id;
            admMemoBookDTO.Modifytime = DateTime.Now;
            admMemoBookDTO.ShenSuTime = admMemoBookDTO.Modifytime;
 
 
            resultEntity = _DailyManageService.SaveMemoBookKaohe(admMemoBookDTO);
            return JsonConvert.SerializeObject(resultEntity);
 
        }
 
        #endregion
    }
}