00486d53
“wangming”
更新多个.DS_Store文件,优...
|
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;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
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;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
18
19
|
using NCC.Extend.Entitys.Dto.LqLssj;
using NCC.Extend.Entitys.lq_lssj;
|
96009bc9
hexiaodong
hxd
|
20
|
using NCC.Extend.Interfaces.LqLssj;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
21
22
|
using NCC.FriendlyException;
using NCC.JsonSerialization;
|
96009bc9
hexiaodong
hxd
|
23
|
using SqlSugar;
|
96009bc9
hexiaodong
hxd
|
24
|
using Yitter.IdGenerator;
|
96009bc9
hexiaodong
hxd
|
25
26
27
28
29
30
|
namespace NCC.Extend.LqLssj
{
/// <summary>
/// 历史数据服务
/// </summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
31
|
[ApiDescriptionSettings(Tag = "Extend", Name = "LqLssj", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
32
33
34
35
36
37
38
39
40
41
|
[Route("api/Extend/[controller]")]
public class LqLssjService : ILqLssjService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqLssjEntity> _lqLssjRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
/// <summary>
/// 初始化一个<see cref="LqLssjService"/>类型的新实例
/// </summary>
|
505dccc3
“wangming”
优化代码格式,合并多行构造函数和方...
|
42
|
public LqLssjService(ISqlSugarRepository<LqLssjEntity> lqLssjRepository, IUserManager userManager)
|
96009bc9
hexiaodong
hxd
|
43
|
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
44
|
_lqLssjRepository = lqLssjRepository;
|
96009bc9
hexiaodong
hxd
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
_db = _lqLssjRepository.Context;
_userManager = userManager;
}
/// <summary>
/// 获取历史数据
/// </summary>
/// <param name="id">参数</param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
var entity = await _db.Queryable<LqLssjEntity>().FirstAsync(p => p.Id == id);
var output = entity.Adapt<LqLssjInfoOutput>();
return output;
}
/// <summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
63
64
65
66
|
/// 获取历史数据列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqLssjListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqLssjEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.syb), p => p.Syb.Contains(input.syb))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Contains(input.md))
.WhereIF(!string.IsNullOrEmpty(input.yf), p => p.Yf.Equals(input.yf))
.WhereIF(!string.IsNullOrEmpty(input.nf), p => p.Nf.Equals(input.nf))
.WhereIF(!string.IsNullOrEmpty(input.zyj), p => p.Zyj.Equals(input.zyj))
.WhereIF(!string.IsNullOrEmpty(input.zxh), p => p.Zxh.Equals(input.zxh))
.WhereIF(!string.IsNullOrEmpty(input.rts), p => p.Rts.Equals(input.rts))
.WhereIF(!string.IsNullOrEmpty(input.rcs), p => p.Rcs.Equals(input.rcs))
.WhereIF(!string.IsNullOrEmpty(input.xms), p => p.Xms.Equals(input.xms))
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
82
|
.Select(it => new LqLssjListOutput
|
96009bc9
hexiaodong
hxd
|
83
84
|
{
id = it.Id,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
syb = it.Syb,
md = it.Md,
yf = it.Yf,
nf = it.Nf,
zyj = it.Zyj,
zxh = it.Zxh,
rts = it.Rts,
rcs = it.Rcs,
xms = it.Xms,
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqLssjListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
99
100
101
102
103
104
105
106
107
108
109
110
111
|
}
/// <summary>
/// 新建历史数据
/// </summary>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPost("")]
public async Task Create([FromBody] LqLssjCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqLssjEntity>();
entity.Id = YitIdHelper.NextId().ToString();
|
505dccc3
“wangming”
优化代码格式,合并多行构造函数和方...
|
112
|
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
113
114
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1000);
|
96009bc9
hexiaodong
hxd
|
115
116
117
|
}
/// <summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
118
119
120
121
|
/// 获取历史数据无分页列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
[NonAction]
public async Task<dynamic> GetNoPagingList([FromQuery] LqLssjListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqLssjEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.syb), p => p.Syb.Contains(input.syb))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Contains(input.md))
.WhereIF(!string.IsNullOrEmpty(input.yf), p => p.Yf.Equals(input.yf))
.WhereIF(!string.IsNullOrEmpty(input.nf), p => p.Nf.Equals(input.nf))
.WhereIF(!string.IsNullOrEmpty(input.zyj), p => p.Zyj.Equals(input.zyj))
.WhereIF(!string.IsNullOrEmpty(input.zxh), p => p.Zxh.Equals(input.zxh))
.WhereIF(!string.IsNullOrEmpty(input.rts), p => p.Rts.Equals(input.rts))
.WhereIF(!string.IsNullOrEmpty(input.rcs), p => p.Rcs.Equals(input.rcs))
.WhereIF(!string.IsNullOrEmpty(input.xms), p => p.Xms.Equals(input.xms))
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
137
|
.Select(it => new LqLssjListOutput
|
96009bc9
hexiaodong
hxd
|
138
139
|
{
id = it.Id,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
syb = it.Syb,
md = it.Md,
yf = it.Yf,
nf = it.Nf,
zyj = it.Zyj,
zxh = it.Zxh,
rts = it.Rts,
rcs = it.Rcs,
xms = it.Xms,
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToListAsync();
return data;
|
96009bc9
hexiaodong
hxd
|
154
155
156
|
}
/// <summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
157
158
159
160
|
/// 导出历史数据
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
[HttpGet("Actions/Export")]
public async Task<dynamic> Export([FromQuery] LqLssjListQueryInput input)
{
var userInfo = await _userManager.GetUserInfo();
var exportData = new List<LqLssjListOutput>();
if (input.dataType == 0)
{
var data = Clay.Object(await this.GetList(input));
exportData = data.Solidify<PageResult<LqLssjListOutput>>().list;
}
else
{
exportData = await this.GetNoPagingList(input);
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
175
176
|
List<ParamsModel> paramList =
"[{\"value\":\"数据编号\",\"field\":\"id\"},{\"value\":\"事业部\",\"field\":\"syb\"},{\"value\":\"门店\",\"field\":\"md\"},{\"value\":\"月份\",\"field\":\"yf\"},{\"value\":\"年份\",\"field\":\"nf\"},{\"value\":\"总业绩\",\"field\":\"zyj\"},{\"value\":\"总消耗\",\"field\":\"zxh\"},{\"value\":\"人头数\",\"field\":\"rts\"},{\"value\":\"人次数\",\"field\":\"rcs\"},{\"value\":\"项目数\",\"field\":\"xms\"},]".ToList<ParamsModel>();
|
96009bc9
hexiaodong
hxd
|
177
178
179
180
181
182
183
184
185
186
187
188
|
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)
{
|
9e55866f
“wangming”
优化代码格式,合并多行表达式,提升...
|
189
|
excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = isExist.field, ExcelColumn = isExist.value });
|
96009bc9
hexiaodong
hxd
|
190
191
192
193
194
|
}
}
var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName;
ExcelExportHelper<LqLssjListOutput>.Export(exportData, excelconfig, addPath);
var fileName = _userManager.UserId + "|" + addPath + "|xls";
|
9e55866f
“wangming”
优化代码格式,合并多行表达式,提升...
|
195
|
var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") };
|
96009bc9
hexiaodong
hxd
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
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<LqLssjEntity>().In(it => it.Id, ids).ToListAsync();
if (entitys.Count > 0)
{
try
{
//开启事务
_db.BeginTran();
//批量删除历史数据
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
215
|
await _db.Deleteable<LqLssjEntity>().In(d => d.Id, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
//关闭事务
_db.CommitTran();
}
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] LqLssjUpInput input)
{
var entity = input.Adapt<LqLssjEntity>();
|
505dccc3
“wangming”
优化代码格式,合并多行构造函数和方...
|
238
|
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
239
240
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1001);
|
96009bc9
hexiaodong
hxd
|
241
242
243
244
245
246
247
248
249
250
251
|
}
/// <summary>
/// 删除历史数据
/// </summary>
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
var entity = await _db.Queryable<LqLssjEntity>().FirstAsync(p => p.Id == id);
_ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
|
505dccc3
“wangming”
优化代码格式,合并多行构造函数和方...
|
252
|
var isOk = await _db.Deleteable<LqLssjEntity>().Where(d => d.Id == id).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
253
254
|
if (!(isOk > 0))
throw NCCException.Oh(ErrorCode.COM1002);
|
96009bc9
hexiaodong
hxd
|
255
256
257
|
}
}
}
|