0ef47194
“wangming”
Refactor LqHytkHy...
|
1
2
3
4
5
6
7
8
9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using NCC.ClayObject;
using NCC.Common.Configuration;
using NCC.Common.Core.Manager;
|
96009bc9
hexiaodong
hxd
|
10
11
12
|
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
13
14
15
|
using NCC.Common.Helper;
using NCC.Common.Model.NPOI;
using NCC.DataEncryption;
|
96009bc9
hexiaodong
hxd
|
16
17
|
using NCC.Dependency;
using NCC.DynamicApiController;
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
18
19
|
using NCC.Extend.Entitys.Dto.LqJlmxb;
using NCC.Extend.Entitys.lq_jlmxb;
|
96009bc9
hexiaodong
hxd
|
20
|
using NCC.Extend.Interfaces.LqJlmxb;
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
21
22
|
using NCC.FriendlyException;
using NCC.JsonSerialization;
|
96009bc9
hexiaodong
hxd
|
23
|
using SqlSugar;
|
96009bc9
hexiaodong
hxd
|
24
|
using Yitter.IdGenerator;
|
e1dcb3a0
“wangming”
1
|
25
26
27
|
using Microsoft.Extensions.Logging;
using NCC.Extend.Helpers;
using NCC.Extend.Interfaces.BusinessOperationLog;
|
96009bc9
hexiaodong
hxd
|
28
29
30
31
32
33
|
namespace NCC.Extend.LqJlmxb
{
/// <summary>
/// 奖励统计表服务
/// </summary>
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
34
|
[ApiDescriptionSettings(Tag = "Extend", Name = "LqJlmxb", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
35
36
37
|
[Route("api/Extend/[controller]")]
public class LqJlmxbService : ILqJlmxbService, IDynamicApiController, ITransient
{
|
e1dcb3a0
“wangming”
1
|
38
39
40
41
|
private const string BizLogModule = "工资管理";
private const string BizLogEntity = "奖励明细";
private const string BizType = "lq_jlmxb";
|
96009bc9
hexiaodong
hxd
|
42
43
44
45
|
private readonly ISqlSugarRepository<LqJlmxbEntity> _lqJlmxbRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
|
e1dcb3a0
“wangming”
1
|
46
47
48
|
private readonly IBusinessOperationLogService _businessOperationLogService;
private readonly ILogger<LqJlmxbService> _logger;
|
96009bc9
hexiaodong
hxd
|
49
50
51
|
/// <summary>
/// 初始化一个<see cref="LqJlmxbService"/>类型的新实例
/// </summary>
|
e1dcb3a0
“wangming”
1
|
52
53
54
|
public LqJlmxbService(ISqlSugarRepository<LqJlmxbEntity> lqJlmxbRepository, IUserManager userManager,
IBusinessOperationLogService businessOperationLogService,
ILogger<LqJlmxbService> logger)
|
96009bc9
hexiaodong
hxd
|
55
|
{
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
56
|
_lqJlmxbRepository = lqJlmxbRepository;
|
96009bc9
hexiaodong
hxd
|
57
58
|
_db = _lqJlmxbRepository.Context;
_userManager = userManager;
|
e1dcb3a0
“wangming”
1
|
59
60
|
_businessOperationLogService = businessOperationLogService;
_logger = logger;
|
96009bc9
hexiaodong
hxd
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
}
/// <summary>
/// 获取奖励统计表
/// </summary>
/// <param name="id">参数</param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
var entity = await _db.Queryable<LqJlmxbEntity>().FirstAsync(p => p.Id == id);
var output = entity.Adapt<LqJlmxbInfoOutput>();
return output;
}
/// <summary>
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
77
78
79
80
|
/// 获取奖励统计表列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqJlmxbListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqJlmxbEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.gw), p => p.Gw.Contains(input.gw))
.WhereIF(!string.IsNullOrEmpty(input.jks), p => p.Jks.Contains(input.jks))
.WhereIF(!string.IsNullOrEmpty(input.ymmsk), p => p.Ymmsk.Contains(input.ymmsk))
.WhereIF(!string.IsNullOrEmpty(input.kjbmsk), p => p.Kjbmsk.Contains(input.kjbmsk))
.WhereIF(!string.IsNullOrEmpty(input.cjj), p => p.Cjj.Contains(input.cjj))
.WhereIF(!string.IsNullOrEmpty(input.pk), p => p.Pk.Contains(input.pk))
.WhereIF(!string.IsNullOrEmpty(input.ty), p => p.Ty.Contains(input.ty))
.WhereIF(!string.IsNullOrEmpty(input.db), p => p.Db.Contains(input.db))
.WhereIF(!string.IsNullOrEmpty(input.cs), p => p.Cs.Contains(input.cs))
.WhereIF(!string.IsNullOrEmpty(input.jb), p => p.Jb.Contains(input.jb))
.WhereIF(!string.IsNullOrEmpty(input.hj), p => p.Hj.Contains(input.hj))
.WhereIF(!string.IsNullOrEmpty(input.kcmx), p => p.Kcmx.Contains(input.kcmx))
.WhereIF(!string.IsNullOrEmpty(input.bhjb), p => p.Bhjb.Contains(input.bhjb))
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
102
|
.Select(it => new LqJlmxbListOutput
|
96009bc9
hexiaodong
hxd
|
103
104
|
{
id = it.Id,
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
mdbh = it.Mdbh,
mdmc = it.Mdmc,
gw = it.Gw,
jks = it.Jks,
ymmsk = it.Ymmsk,
kjbmsk = it.Kjbmsk,
cjj = it.Cjj,
pk = it.Pk,
ty = it.Ty,
db = it.Db,
cs = it.Cs,
jb = it.Jb,
hj = it.Hj,
kcmx = it.Kcmx,
bhjb = it.Bhjb,
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqJlmxbListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
}
/// <summary>
/// 新建奖励统计表
/// </summary>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPost("")]
public async Task Create([FromBody] LqJlmxbCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqJlmxbEntity>();
entity.Id = YitIdHelper.NextId().ToString();
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
139
140
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1000);
|
e1dcb3a0
“wangming”
1
|
141
142
143
|
await BusinessOperationLogHelper.LogCreateAsync(
_businessOperationLogService, _logger, BizLogModule, BizLogEntity, BizType, entity.Id,
new { entity.Id });
|
96009bc9
hexiaodong
hxd
|
144
145
146
|
}
/// <summary>
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
147
148
149
150
|
/// 获取奖励统计表无分页列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
[NonAction]
public async Task<dynamic> GetNoPagingList([FromQuery] LqJlmxbListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqJlmxbEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.gw), p => p.Gw.Contains(input.gw))
.WhereIF(!string.IsNullOrEmpty(input.jks), p => p.Jks.Contains(input.jks))
.WhereIF(!string.IsNullOrEmpty(input.ymmsk), p => p.Ymmsk.Contains(input.ymmsk))
.WhereIF(!string.IsNullOrEmpty(input.kjbmsk), p => p.Kjbmsk.Contains(input.kjbmsk))
.WhereIF(!string.IsNullOrEmpty(input.cjj), p => p.Cjj.Contains(input.cjj))
.WhereIF(!string.IsNullOrEmpty(input.pk), p => p.Pk.Contains(input.pk))
.WhereIF(!string.IsNullOrEmpty(input.ty), p => p.Ty.Contains(input.ty))
.WhereIF(!string.IsNullOrEmpty(input.db), p => p.Db.Contains(input.db))
.WhereIF(!string.IsNullOrEmpty(input.cs), p => p.Cs.Contains(input.cs))
.WhereIF(!string.IsNullOrEmpty(input.jb), p => p.Jb.Contains(input.jb))
.WhereIF(!string.IsNullOrEmpty(input.hj), p => p.Hj.Contains(input.hj))
.WhereIF(!string.IsNullOrEmpty(input.kcmx), p => p.Kcmx.Contains(input.kcmx))
.WhereIF(!string.IsNullOrEmpty(input.bhjb), p => p.Bhjb.Contains(input.bhjb))
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
172
|
.Select(it => new LqJlmxbListOutput
|
96009bc9
hexiaodong
hxd
|
173
174
|
{
id = it.Id,
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
175
176
177
178
179
180
181
182
183
184
185
186
|
mdbh = it.Mdbh,
mdmc = it.Mdmc,
gw = it.Gw,
jks = it.Jks,
ymmsk = it.Ymmsk,
kjbmsk = it.Kjbmsk,
cjj = it.Cjj,
pk = it.Pk,
ty = it.Ty,
db = it.Db,
cs = it.Cs,
jb = it.Jb,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
187
|
hj = it.Hj,
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
188
189
190
191
192
193
194
|
kcmx = it.Kcmx,
bhjb = it.Bhjb,
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToListAsync();
return data;
|
96009bc9
hexiaodong
hxd
|
195
196
197
|
}
/// <summary>
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
198
199
200
201
|
/// 导出奖励统计表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
[HttpGet("Actions/Export")]
public async Task<dynamic> Export([FromQuery] LqJlmxbListQueryInput input)
{
var userInfo = await _userManager.GetUserInfo();
var exportData = new List<LqJlmxbListOutput>();
if (input.dataType == 0)
{
var data = Clay.Object(await this.GetList(input));
exportData = data.Solidify<PageResult<LqJlmxbListOutput>>().list;
}
else
{
exportData = await this.GetNoPagingList(input);
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
216
217
|
List<ParamsModel> paramList =
"[{\"value\":\"奖励编号\",\"field\":\"id\"},{\"value\":\"门店编号\",\"field\":\"mdbh\"},{\"value\":\"门店名称\",\"field\":\"mdmc\"},{\"value\":\"岗位\",\"field\":\"gw\"},{\"value\":\"健康师\",\"field\":\"jks\"},{\"value\":\"医美秒杀卡\",\"field\":\"ymmsk\"},{\"value\":\"科技部秒杀卡\",\"field\":\"kjbmsk\"},{\"value\":\"成交奖\",\"field\":\"cjj\"},{\"value\":\"PK\",\"field\":\"pk\"},{\"value\":\"体验\",\"field\":\"ty\"},{\"value\":\"打版\",\"field\":\"db\"},{\"value\":\"沉睡\",\"field\":\"cs\"},{\"value\":\"嘉宾\",\"field\":\"jb\"},{\"value\":\"合计\",\"field\":\"hj\"},{\"value\":\"扣除明细\",\"field\":\"kcmx\"},{\"value\":\"不含嘉宾\",\"field\":\"bhjb\"},]".ToList<ParamsModel>();
|
96009bc9
hexiaodong
hxd
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "奖励统计表.xls";
excelconfig.HeadFont = "微软雅黑";
excelconfig.HeadPoint = 10;
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnModel = new List<ExcelColumnModel>();
List<string> selectKeyList = input.selectKey.Split(',').ToList();
foreach (var item in selectKeyList)
{
var isExist = paramList.Find(p => p.field == item);
if (isExist != null)
{
excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = isExist.field, ExcelColumn = isExist.value });
}
}
var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName;
ExcelExportHelper<LqJlmxbListOutput>.Export(exportData, excelconfig, addPath);
|
e1dcb3a0
“wangming”
1
|
235
236
237
|
await BusinessOperationLogHelper.LogExportAsync(
_businessOperationLogService, _logger, BizLogModule, BizLogEntity, BizType,
exportData.Count, excelconfig.FileName, new { input.dataType });
|
96009bc9
hexiaodong
hxd
|
238
|
var fileName = _userManager.UserId + "|" + addPath + "|xls";
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
239
|
var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") };
|
96009bc9
hexiaodong
hxd
|
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
return output;
}
/// <summary>
/// 批量删除奖励统计表
/// </summary>
/// <param name="ids">主键数组</param>
/// <returns></returns>
[HttpPost("batchRemove")]
public async Task BatchRemove([FromBody] List<string> ids)
{
var entitys = await _db.Queryable<LqJlmxbEntity>().In(it => it.Id, ids).ToListAsync();
if (entitys.Count > 0)
{
try
{
//开启事务
_db.BeginTran();
//批量删除奖励统计表
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
259
|
await _db.Deleteable<LqJlmxbEntity>().In(d => d.Id, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
260
261
|
//关闭事务
_db.CommitTran();
|
e1dcb3a0
“wangming”
1
|
262
263
|
await BusinessOperationLogHelper.LogBatchDeleteAsync(
_businessOperationLogService, _logger, BizLogModule, BizLogEntity, BizType, ids);
|
96009bc9
hexiaodong
hxd
|
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
}
}
/// <summary>
/// 更新奖励统计表
/// </summary>
/// <param name="id">主键</param>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqJlmxbUpInput input)
{
|
e1dcb3a0
“wangming”
1
|
283
284
|
var before = await _db.Queryable<LqJlmxbEntity>().FirstAsync(p => p.Id == id);
_ = before ?? throw NCCException.Oh(ErrorCode.COM1005);
|
96009bc9
hexiaodong
hxd
|
285
286
|
var entity = input.Adapt<LqJlmxbEntity>();
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
287
288
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1001);
|
e1dcb3a0
“wangming”
1
|
289
290
291
|
await BusinessOperationLogHelper.LogUpdateAsync(
_businessOperationLogService, _logger, BizLogModule, BizLogEntity, BizType, id,
new { before.Id }, new { entity.Id });
|
96009bc9
hexiaodong
hxd
|
292
293
294
295
296
297
298
299
300
301
302
303
|
}
/// <summary>
/// 删除奖励统计表
/// </summary>
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
var entity = await _db.Queryable<LqJlmxbEntity>().FirstAsync(p => p.Id == id);
_ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
var isOk = await _db.Deleteable<LqJlmxbEntity>().Where(d => d.Id == id).ExecuteCommandAsync();
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
304
305
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1002);
|
e1dcb3a0
“wangming”
1
|
306
307
308
|
await BusinessOperationLogHelper.LogDeleteAsync(
_businessOperationLogService, _logger, BizLogModule, BizLogEntity, BizType, id,
new { entity.Id });
|
96009bc9
hexiaodong
hxd
|
309
310
311
|
}
}
}
|