Browse Source

休息日管理,工作时间管理

zhengbingbing 5 years ago
parent
commit
9be2799a60

+ 12 - 0
代码/System.IRepositories/ISys_WorkOffDaysRepository.cs

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.Model;
5
+using System.Text;
6
+
7
+namespace System.IRepositories
8
+{
9
+    public interface ISys_WorkOffDaysRepository : IRepository<T_Sys_WorkOffDays>
10
+    {
11
+    }
12
+}

+ 12 - 0
代码/System.IRepositories/ISys_WorkTimesRepository.cs

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using System.Common;
5
+using System.Model;
6
+
7
+namespace System.IRepositories
8
+{
9
+    public interface ISys_WorkTimesRepository : IRepository<T_Sys_WorkTimes>
10
+    {
11
+    }
12
+}

+ 55 - 0
代码/System.Model/T_Sys_WorkOffDays.cs

@@ -0,0 +1,55 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace System.Model
6
+{
7
+    [Serializable]
8
+    public partial class T_Sys_WorkOffDays
9
+    {
10
+        /// <summary>
11
+        /// 自增id
12
+        /// </summary>
13
+        public int F_Id { get; set; }
14
+        /// <summary>
15
+		/// 休息日日期
16
+		/// </summary>
17
+		public string F_Date { get; set; }
18
+        /// <summary>
19
+        /// 备注
20
+        /// </summary>
21
+        public string F_Remark { get; set; }
22
+        /// <summary>
23
+        /// 坐席组编号
24
+        /// </summary>
25
+        public string F_GroupCode { get; set; }
26
+        /// <summary>
27
+        /// 状态
28
+        /// </summary>
29
+        public int? F_State { get; set; }
30
+        /// <summary>
31
+        /// 添加时间
32
+        /// </summary>
33
+        public DateTime? F_CreateOn { get; set; }
34
+        /// <summary>
35
+        /// 添加工号
36
+        /// </summary>
37
+        public string F_CreateBy { get; set; }
38
+        /// <summary>
39
+        /// 最后一次修改时间
40
+        /// </summary>
41
+        public DateTime? F_LastModifyOn { get; set; }
42
+        /// <summary>
43
+        /// 最后一次修改工号
44
+        /// </summary>
45
+        public string F_LastModifyBy { get; set; }
46
+        /// <summary>
47
+        /// 删除时间
48
+        /// </summary>
49
+        public DateTime? F_DeleteOn { get; set; }
50
+        /// <summary>
51
+        /// 删除工号
52
+        /// </summary>
53
+        public string F_DeleteBy { get; set; }
54
+    }
55
+}

+ 63 - 0
代码/System.Model/T_Sys_WorkTimes.cs

@@ -0,0 +1,63 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace System.Model
6
+{
7
+    [Serializable]
8
+    public partial class T_Sys_WorkTimes
9
+    {
10
+        /// <summary>
11
+        /// 自增id
12
+        /// </summary>
13
+        public int F_Id { get; set; }
14
+        /// <summary>
15
+        /// 工作开始时间
16
+        /// </summary>
17
+        public string F_StartDate { get; set; }
18
+        /// <summary>
19
+        /// 工作结束时间
20
+        /// </summary>
21
+        public string F_EndDate { get; set; }
22
+        /// <summary>
23
+		/// 时间段名称
24
+		/// </summary>
25
+		public string F_Name { get; set; }
26
+        /// <summary>
27
+        /// 备注
28
+        /// </summary>
29
+        public string F_Remark { get; set; }
30
+        /// <summary>
31
+        /// 坐席组编号
32
+        /// </summary>
33
+        public string F_GroupCode { get; set; }
34
+        /// <summary>
35
+        /// 状态
36
+        /// </summary>
37
+        public int? F_State { get; set; }
38
+        /// <summary>
39
+        /// 添加时间
40
+        /// </summary>
41
+        public DateTime? F_CreateOn { get; set; }
42
+        /// <summary>
43
+        /// 添加工号
44
+        /// </summary>
45
+        public string F_CreateBy { get; set; }
46
+        /// <summary>
47
+        /// 最后一次修改时间
48
+        /// </summary>
49
+        public DateTime? F_LastModifyOn { get; set; }
50
+        /// <summary>
51
+        /// 最后一次修改工号
52
+        /// </summary>
53
+        public string F_LastModifyBy { get; set; }
54
+        /// <summary>
55
+        /// 删除时间
56
+        /// </summary>
57
+        public DateTime? F_DeleteOn { get; set; }
58
+        /// <summary>
59
+        /// 删除工号
60
+        /// </summary>
61
+        public string F_DeleteBy { get; set; }
62
+    }
63
+}

+ 13 - 0
代码/System.Repositories/Sys_WorkOffDaysRepository.cs

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using System.IRepositories;
5
+using System.Model;
6
+using System.Common;
7
+
8
+namespace System.Repositories
9
+{
10
+    public class Sys_WorkOffDaysRepository : BaseRepository<T_Sys_WorkOffDays>, ISys_WorkOffDaysRepository
11
+    {
12
+    }
13
+}

+ 13 - 0
代码/System.Repositories/Sys_WorkTimesRepository.cs

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.IRepositories;
5
+using System.Model;
6
+using System.Text;
7
+
8
+namespace System.Repositories
9
+{
10
+    public class Sys_WorkTimesRepository : BaseRepository<T_Sys_WorkTimes>, ISys_WorkTimesRepository
11
+    {
12
+    }
13
+}

+ 105 - 0
代码/TVShoppingCallCenter_ZLJ/Controllers/Traffic/SetWorkOffDayController.cs

@@ -0,0 +1,105 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.IRepositories;
5
+using System.Linq;
6
+using System.Model;
7
+using System.Security.Claims;
8
+using System.Threading.Tasks;
9
+using Microsoft.AspNetCore.Authorization;
10
+using Microsoft.AspNetCore.Mvc;
11
+using SqlSugar;
12
+using TVShoppingCallCenter_ZLJ.Models.Inputs;
13
+
14
+namespace TVShoppingCallCenter_ZLJ.Controllers.Traffic
15
+{
16
+    [Authorize]
17
+    [Produces("application/json")]
18
+    [Route("api/[controller]")]
19
+    public class SetWorkOffDayController : BaseController
20
+    {
21
+        private readonly ISys_WorkOffDaysRepository _sys_workoffdaysRepository;
22
+        public SetWorkOffDayController(ISys_WorkOffDaysRepository sys_workoffdaysRepository)
23
+        {
24
+            _sys_workoffdaysRepository = sys_workoffdaysRepository;
25
+        }
26
+
27
+        [Authorize]
28
+        [HttpGet("getlist")]
29
+        public async Task<IActionResult> GetListAsync(string strdate,string groupcode)
30
+        {
31
+            List<IConditionalModel> conModels = new List<IConditionalModel>();
32
+            #region 条件筛选
33
+            conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
34
+
35
+            if (!string.IsNullOrWhiteSpace(strdate))
36
+            {
37
+                DateTime dt2 = new DateTime();
38
+                if (DateTime.TryParse(strdate.Trim(), out dt2))
39
+                    conModels.Add(new ConditionalModel() { FieldName = "F_Date", ConditionalType = ConditionalType.Equal, FieldValue = strdate });
40
+            }
41
+            if(!string.IsNullOrWhiteSpace(groupcode))
42
+                conModels.Add(new ConditionalModel() { FieldName = "F_GroupCode", ConditionalType = ConditionalType.Equal, FieldValue = groupcode });
43
+
44
+            #endregion
45
+
46
+            var list = await _sys_workoffdaysRepository.GetListALL(conModels, "F_Date desc");
47
+
48
+            return Success("根据条件获取数据成功", list);
49
+        }
50
+
51
+        //设置(非)工作日
52
+        [Authorize]
53
+        [HttpPost("setofforon")]
54
+        public async Task<IActionResult> setOfforOn(string offdate, string groupcode, string remark, int type = 0, int id = 0)
55
+        {
56
+            var res = Error("");
57
+            if (string.IsNullOrWhiteSpace(offdate))
58
+                return Error("获取参数失败");
59
+            DateTime dt = new DateTime();
60
+            if (!DateTime.TryParse(offdate.Trim(), out dt))
61
+                return Error("日期格式不正确");
62
+
63
+            var nmodel = new T_Sys_WorkOffDays();
64
+
65
+            if (type == 0)
66
+            {//设为休息日
67
+                nmodel.F_Date = offdate;
68
+                nmodel.F_GroupCode = groupcode;
69
+                nmodel.F_Remark = remark;
70
+
71
+                nmodel.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value; //"8000";
72
+                nmodel.F_CreateOn = DateTime.Now;
73
+                nmodel.F_State = (int)EnumDelState.Enabled;
74
+                var n = await _sys_workoffdaysRepository.Add(nmodel);
75
+                if (n > 0)
76
+                {
77
+                    return Success("设为休息日成功");
78
+                }
79
+                else
80
+                {
81
+                    return Error("设为休息日失败");
82
+                }
83
+            }
84
+            else
85
+            {//取消休息日
86
+                if (id <= 0)
87
+                    return Error("获取参数失败");
88
+
89
+                nmodel = await _sys_workoffdaysRepository.GetSingle(x => x.F_Id == id && x.F_State == (int)EnumDelState.Enabled);
90
+                if (nmodel == null)
91
+                    return Error("获取信息失败");
92
+                nmodel.F_State = (int)EnumDelState.UnEnabled;
93
+                nmodel.F_LastModifyBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value; //"8000";
94
+                nmodel.F_LastModifyOn = DateTime.Now;
95
+                if (await _sys_workoffdaysRepository.Update(nmodel))
96
+                {
97
+                    return Success("取消休息日成功");
98
+                }
99
+                else
100
+                    return Success("取消休息日失败");
101
+            }
102
+
103
+        }
104
+    }
105
+}

+ 226 - 0
代码/TVShoppingCallCenter_ZLJ/Controllers/Traffic/SetWorkTimeController.cs

@@ -0,0 +1,226 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Common;
4
+using System.IRepositories;
5
+using System.Linq;
6
+using System.Linq.Expressions;
7
+using System.Model;
8
+using System.Security.Claims;
9
+using System.Threading.Tasks;
10
+using Microsoft.AspNetCore.Authorization;
11
+using Microsoft.AspNetCore.Mvc;
12
+using SqlSugar;
13
+using TVShoppingCallCenter_ZLJ.Models.Inputs;
14
+
15
+namespace TVShoppingCallCenter_ZLJ.Controllers.Traffic
16
+{
17
+    [Authorize]
18
+    [Produces("application/json")]
19
+    [Route("api/[controller]")]
20
+    public class SetWorkTimeController : BaseController
21
+    {
22
+        private readonly ISys_WorkTimesRepository _sys_worktimeRepository;
23
+        public SetWorkTimeController(ISys_WorkTimesRepository sys_worktimeRepository)
24
+        {
25
+            _sys_worktimeRepository = sys_worktimeRepository;
26
+        }
27
+
28
+        /// <summary>
29
+        /// 获取工作时间列表
30
+        /// </summary>
31
+        /// <param name="filter"></param>
32
+        /// <returns></returns>
33
+        [HttpGet("getlistbypage")]
34
+        public async Task<IActionResult> GetListsByPage(string key,string groupcode, int pageindex = 1, int pagesize = 20)
35
+        {
36
+            List<IConditionalModel> conModels = new List<IConditionalModel>();
37
+            #region 条件筛选
38
+            conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
39
+            if(!string.IsNullOrWhiteSpace(groupcode))
40
+                conModels.Add(new ConditionalModel() { FieldName = "F_GroupCode", ConditionalType = ConditionalType.Equal, FieldValue = groupcode });
41
+            if (!string.IsNullOrEmpty(key))
42
+            {
43
+                conModels.Add(new ConditionalCollections()
44
+                {
45
+                    ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
46
+                    {
47
+                        new  KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel() { FieldName = "F_Name", ConditionalType = ConditionalType.Like, FieldValue = key }),
48
+                        new  KeyValuePair<WhereType, ConditionalModel>( WhereType.Or , new ConditionalModel() { FieldName = "F_GroupCode", ConditionalType = ConditionalType.Like, FieldValue = key }),
49
+                        new  KeyValuePair<WhereType, ConditionalModel>( WhereType.Or, new ConditionalModel() { FieldName = "F_Remark", ConditionalType = ConditionalType.Like, FieldValue = key })
50
+                    }
51
+                });
52
+            }
53
+            #endregion
54
+            int recordCount = 0;
55
+            var list = await _sys_worktimeRepository.GetListByPage(conModels, new MyPageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount }, "F_CreateOn desc");
56
+
57
+            return Success("成功", list);
58
+        }
59
+
60
+        /// <summary>
61
+        /// 获取实体
62
+        /// </summary>
63
+        [HttpGet("getdetails")]
64
+        public async Task<IActionResult> GetDetails(int id)
65
+        {
66
+            if (id > 0)
67
+            {
68
+                var dModel = await _sys_worktimeRepository.GetSingle(x => x.F_Id == id && x.F_State == (int)EnumDelState.Enabled);
69
+
70
+                if (dModel != null)
71
+                {
72
+                    return Success("获取工作时间成功", dModel);
73
+                }
74
+                else
75
+                {
76
+                    return Error("获取工作时间失败");
77
+                }
78
+            }
79
+            else
80
+            {
81
+                return Error("获取参数失败");
82
+            }
83
+        }
84
+
85
+        /// <summary>
86
+        /// 添加工作时间
87
+        /// </summary>
88
+        [HttpPost("add")]
89
+        public async Task<IActionResult> Add(WorkTimeInput input)
90
+        {
91
+            #region 验证
92
+            if (string.IsNullOrWhiteSpace(input.startdate))
93
+            {
94
+                return Error("开始时间不能为空");
95
+            }
96
+            if (string.IsNullOrWhiteSpace(input.enddate))
97
+            {
98
+                return Error("结束时间不能为空");
99
+            }
100
+            DateTime st = new DateTime(), et = new DateTime();
101
+            if (!DateTime.TryParse(input.startdate, out st))
102
+                return Error("开始时间格式不正确");
103
+            if (!DateTime.TryParse(input.enddate, out et))
104
+                return Error("结束时间格式不正确");
105
+            if (await GetExistAsync(input.startdate, input.enddate, input.groupcode, input.id))
106
+                return Error("已存在此时段的记录,请重新输入!");
107
+            #endregion
108
+            T_Sys_WorkTimes clmodel = new T_Sys_WorkTimes();
109
+            clmodel.F_StartDate = input.startdate.Trim();
110
+            clmodel.F_EndDate = input.enddate.Trim();
111
+            clmodel.F_GroupCode = input.groupcode;
112
+            clmodel.F_Name = input.name;
113
+            clmodel.F_Remark = input.remark;
114
+
115
+            clmodel.F_CreateBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value; //"8000";
116
+            clmodel.F_CreateOn = DateTime.Now;
117
+            clmodel.F_State = (int)EnumDelState.Enabled;
118
+
119
+            var res = await _sys_worktimeRepository.Add(clmodel);
120
+            if (res > 0)
121
+                return Success("保存成功");
122
+            else
123
+            {
124
+                return Error("保存失败");
125
+            }
126
+        }
127
+
128
+        /// <summary>
129
+        /// 修改工作时间
130
+        /// </summary>
131
+        [HttpPost("update")]
132
+        public async Task<IActionResult> Edit(WorkTimeInput input)
133
+        {
134
+            #region
135
+            if (input.id <= 0)
136
+                return Error("请选择要编辑的数据");
137
+            if (string.IsNullOrWhiteSpace(input.startdate))
138
+            {
139
+                return Error("开始时间不能为空");
140
+            }
141
+            if (string.IsNullOrWhiteSpace(input.enddate))
142
+            {
143
+                return Error("结束时间不能为空");
144
+            }
145
+            DateTime st = new DateTime(), et = new DateTime();
146
+            if (!DateTime.TryParse(input.startdate, out st))
147
+                return Error("开始时间格式不正确");
148
+            if (!DateTime.TryParse(input.enddate, out et))
149
+                return Error("结束时间格式不正确");
150
+            if (await GetExistAsync(input.startdate,input.enddate,input.groupcode, input.id))
151
+                return Error("已存在此时段的记录,请重新输入!");
152
+            #endregion
153
+
154
+            var clmodel = await _sys_worktimeRepository.GetSingle(x => x.F_Id == input.id && x.F_State == (int)EnumDelState.Enabled);
155
+            if (clmodel == null)
156
+                return Error("信息获取失败");
157
+            clmodel.F_StartDate = input.startdate.Trim();
158
+            clmodel.F_EndDate = input.enddate.Trim();
159
+            clmodel.F_GroupCode = input.groupcode.Trim();
160
+            clmodel.F_Name = input.name.Trim();
161
+            clmodel.F_Remark = input.remark.Trim();
162
+
163
+            clmodel.F_LastModifyBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
164
+            clmodel.F_LastModifyOn = DateTime.Now;
165
+
166
+            var res = await _sys_worktimeRepository.Update(clmodel);
167
+
168
+            if (res)
169
+                return Success("工作时间保存成功");
170
+            else
171
+            {
172
+                return Error("工作时间保存失败");
173
+            }
174
+        }
175
+
176
+        [HttpPost("delete")]
177
+        public async Task<IActionResult> Remove(int[] ids)
178
+        {
179
+            //使用逻辑删除
180
+            //物理删除的数据无法恢复
181
+            var res = 0;
182
+            if (ids != null && ids.Length > 0)
183
+            {
184
+                foreach (var item in ids)
185
+                {
186
+                    var ml = await _sys_worktimeRepository.GetSingle(x => x.F_Id == item);
187
+                    ml.F_State = (int)EnumDelState.Delete;
188
+                    ml.F_DeleteBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
189
+                    ml.F_DeleteOn = DateTime.Now;
190
+                    if (await _sys_worktimeRepository.Update(ml))
191
+                        res += 1;
192
+                }
193
+                if (res == ids.Length)
194
+                    return Success("删除成功");
195
+                else if (res > 0 && res < ids.Length)
196
+                    return Error("部分删除失败,请查看后重新操作");
197
+                else
198
+                    return Error("删除失败,请查看后重新操作");
199
+            }
200
+            else
201
+                return Error("请选择要删除的记录");
202
+        }
203
+
204
+        #region 私有方法
205
+        /// <summary>
206
+        /// 根据基础数据编号查询是否存在此基础数据编号
207
+        /// </summary>
208
+        /// <param name="code"></param>
209
+        /// <returns></returns>
210
+        private async Task<bool> GetExistAsync(string startdate,string enddate,string groupcode, int id)
211
+        {
212
+
213
+            Expression<Func<T_Sys_WorkTimes, bool>> eq = a => a.F_State == (int)EnumDelState.Enabled;
214
+            eq = eq.And(b => b.F_StartDate == startdate);
215
+            eq = eq.And(b => b.F_EndDate == enddate);
216
+            if (!string.IsNullOrWhiteSpace(groupcode))
217
+                eq = eq.And(b => b.F_GroupCode == groupcode);
218
+            if(id>0)
219
+                eq = eq.And(b => b.F_Id != id);
220
+            long c = await _sys_worktimeRepository.GetCount(eq);
221
+
222
+            return c > 0;
223
+        }
224
+        #endregion
225
+    }
226
+}

+ 27 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/Traffic/WorkOffDaysInput.cs

@@ -0,0 +1,27 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace TVShoppingCallCenter_ZLJ.Models.Inputs
7
+{
8
+    public class WorkOffDaysInput
9
+    {
10
+        /// <summary>
11
+        /// 自增id
12
+        /// </summary>
13
+        public int id { get; set; }
14
+        /// <summary>
15
+		/// 休息日日期
16
+		/// </summary>
17
+		public string dates { get; set; }
18
+        /// <summary>
19
+        /// 备注
20
+        /// </summary>
21
+        public string remark { get; set; }
22
+        /// <summary>
23
+        /// 坐席组编号
24
+        /// </summary>
25
+        public string groupcode { get; set; }
26
+    }
27
+}

+ 35 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/Traffic/WorkTimeInput.cs

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace TVShoppingCallCenter_ZLJ.Models.Inputs
7
+{
8
+    public class WorkTimeInput
9
+    {
10
+        /// <summary>
11
+        /// 自增id
12
+        /// </summary>
13
+        public int id { get; set; }
14
+        /// <summary>
15
+        /// 工作开始时间
16
+        /// </summary>
17
+        public string startdate { get; set; }
18
+        /// <summary>
19
+        /// 工作结束时间
20
+        /// </summary>
21
+        public string enddate { get; set; }
22
+        /// <summary>
23
+		/// 时间段名称
24
+		/// </summary>
25
+		public string name { get; set; }
26
+        /// <summary>
27
+        /// 备注
28
+        /// </summary>
29
+        public string remark { get; set; }
30
+        /// <summary>
31
+        /// 坐席组编号
32
+        /// </summary>
33
+        public string groupcode { get; set; }
34
+    }
35
+}

+ 4 - 1
代码/TVShoppingCallCenter_ZLJ/Startup.cs

@@ -114,7 +114,10 @@ namespace TVShoppingCallCenter_ZLJ
114 114
             services.AddTransient<ISys_RoleFunctionRepository, Sys_RoleFunctionRepository>();
115 115
             services.AddTransient<ISys_SeatPermissionConfigRepository, Sys_SeatPermissionConfigRepository>();
116 116
             services.AddTransient<ISys_SystemConfigRepository, Sys_SystemConfigRepository>();
117
-            services.AddTransient<ISys_MobileDataRepository, Sys_MobileDataRepository>(); 
117
+            services.AddTransient<ISys_MobileDataRepository, Sys_MobileDataRepository>();
118
+            services.AddTransient<ISys_WorkOffDaysRepository, Sys_WorkOffDaysRepository>();
119
+            services.AddTransient<ISys_WorkTimesRepository, Sys_WorkTimesRepository>();
120
+            
118 121
 
119 122
             services.AddTransient<IBus_ProductClassRepository, Bus_ProductClassRepository>();
120 123
             services.AddTransient<IBus_ProductRepository, Bus_ProductRepository>();