Commit 1c42c4b4ad6988ef296eaaec06c804803ca644e8
1 parent
d2891442
feat: 添加获取部门管理的门店列表接口和修改开单文件接口
- 新增接口:GetManagedStores,根据年月、组织类型、部门ID查询管理的门店列表 - 新增接口:UpdateFile,根据开单ID修改scwj和F_FIleUrl字段 - 支持的组织类型:事业部、科技部、教育部、大项目部 - 包含完整的参数验证和错误处理
Showing
5 changed files
with
312 additions
and
22 deletions
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/LqKdKdjlbUpdateFileInput.cs
0 → 100644
| 1 | +using System.Collections.Generic; | |
| 2 | +using System.ComponentModel.DataAnnotations; | |
| 3 | +using NCC.Common.Model; | |
| 4 | + | |
| 5 | +namespace NCC.Extend.Entitys.Dto.LqKdKdjlb | |
| 6 | +{ | |
| 7 | + /// <summary> | |
| 8 | + /// 修改开单文件输入 | |
| 9 | + /// </summary> | |
| 10 | + public class LqKdKdjlbUpdateFileInput | |
| 11 | + { | |
| 12 | + /// <summary> | |
| 13 | + /// 开单记录ID | |
| 14 | + /// </summary> | |
| 15 | + [Required(ErrorMessage = "开单记录ID不能为空")] | |
| 16 | + public string Id { get; set; } | |
| 17 | + | |
| 18 | + /// <summary> | |
| 19 | + /// 上传文件 | |
| 20 | + /// </summary> | |
| 21 | + public List<FileControlsModel> scwj { get; set; } | |
| 22 | + | |
| 23 | + /// <summary> | |
| 24 | + /// 方案其他 | |
| 25 | + /// </summary> | |
| 26 | + public string F_FIleUrl { get; set; } | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/Dto/LqMdTarget/GetManagedStoresInput.cs
0 → 100644
| 1 | +using System.ComponentModel.DataAnnotations; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Dto.LqMdTarget | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 获取部门管理的门店列表输入 | |
| 7 | + /// </summary> | |
| 8 | + public class GetManagedStoresInput | |
| 9 | + { | |
| 10 | + /// <summary> | |
| 11 | + /// 年月(YYYYMM格式,如:202511) | |
| 12 | + /// </summary> | |
| 13 | + [Required(ErrorMessage = "年月不能为空")] | |
| 14 | + public string Month { get; set; } | |
| 15 | + | |
| 16 | + /// <summary> | |
| 17 | + /// 组织类型(事业部、科技部、教育部、大项目部) | |
| 18 | + /// </summary> | |
| 19 | + [Required(ErrorMessage = "组织类型不能为空")] | |
| 20 | + public string OrganizationType { get; set; } | |
| 21 | + | |
| 22 | + /// <summary> | |
| 23 | + /// 部门ID | |
| 24 | + /// </summary> | |
| 25 | + [Required(ErrorMessage = "部门ID不能为空")] | |
| 26 | + public string DepartmentId { get; set; } | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/Dto/LqMdTarget/ManagedStoreOutput.cs
0 → 100644
| 1 | +namespace NCC.Extend.Entitys.Dto.LqMdTarget | |
| 2 | +{ | |
| 3 | + /// <summary> | |
| 4 | + /// 管理的门店输出 | |
| 5 | + /// </summary> | |
| 6 | + public class ManagedStoreOutput | |
| 7 | + { | |
| 8 | + /// <summary> | |
| 9 | + /// 门店ID | |
| 10 | + /// </summary> | |
| 11 | + public string StoreId { get; set; } | |
| 12 | + | |
| 13 | + /// <summary> | |
| 14 | + /// 门店名称 | |
| 15 | + /// </summary> | |
| 16 | + public string StoreName { get; set; } | |
| 17 | + } | |
| 18 | +} | |
| 19 | + | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
| ... | ... | @@ -4261,6 +4261,121 @@ namespace NCC.Extend.LqKdKdjlb |
| 4261 | 4261 | throw NCCException.Oh($"清空欠款失败: {ex.Message}"); |
| 4262 | 4262 | } |
| 4263 | 4263 | } |
| 4264 | + | |
| 4265 | + /// <summary> | |
| 4266 | + /// 修改开单文件 | |
| 4267 | + /// </summary> | |
| 4268 | + /// <remarks> | |
| 4269 | + /// 根据开单记录ID修改上传文件(scwj)和方案其他(F_FIleUrl)字段 | |
| 4270 | + /// | |
| 4271 | + /// 示例请求: | |
| 4272 | + /// ```json | |
| 4273 | + /// { | |
| 4274 | + /// "id": "开单记录ID", | |
| 4275 | + /// "scwj": [ | |
| 4276 | + /// { | |
| 4277 | + /// "name": "文件名", | |
| 4278 | + /// "url": "文件URL" | |
| 4279 | + /// } | |
| 4280 | + /// ], | |
| 4281 | + /// "F_FIleUrl": "方案其他文件URL" | |
| 4282 | + /// } | |
| 4283 | + /// ``` | |
| 4284 | + /// | |
| 4285 | + /// 参数说明: | |
| 4286 | + /// - id: 开单记录ID(必填) | |
| 4287 | + /// - scwj: 上传文件列表(可选,不传则不更新) | |
| 4288 | + /// - F_FIleUrl: 方案其他文件URL(可选,不传则不更新) | |
| 4289 | + /// </remarks> | |
| 4290 | + /// <param name="input">更新文件输入参数</param> | |
| 4291 | + /// <returns>更新结果</returns> | |
| 4292 | + /// <response code="200">更新成功</response> | |
| 4293 | + /// <response code="400">参数错误或开单记录不存在</response> | |
| 4294 | + /// <response code="500">服务器错误</response> | |
| 4295 | + [HttpPut("UpdateFile")] | |
| 4296 | + public async Task<dynamic> UpdateFile([FromBody] LqKdKdjlbUpdateFileInput input) | |
| 4297 | + { | |
| 4298 | + try | |
| 4299 | + { | |
| 4300 | + // 验证输入参数 | |
| 4301 | + if (input == null || string.IsNullOrEmpty(input.Id)) | |
| 4302 | + { | |
| 4303 | + throw NCCException.Oh("开单记录ID不能为空"); | |
| 4304 | + } | |
| 4305 | + | |
| 4306 | + // 检查开单记录是否存在且有效 | |
| 4307 | + var billingEntity = await _db.Queryable<LqKdKdjlbEntity>() | |
| 4308 | + .Where(w => w.Id == input.Id && w.IsEffective == StatusEnum.有效.GetHashCode()) | |
| 4309 | + .FirstAsync(); | |
| 4310 | + | |
| 4311 | + if (billingEntity == null) | |
| 4312 | + { | |
| 4313 | + throw NCCException.Oh("开单记录不存在或已作废"); | |
| 4314 | + } | |
| 4315 | + | |
| 4316 | + // 构建更新字段列表 | |
| 4317 | + var updatedFields = new List<string>(); | |
| 4318 | + | |
| 4319 | + // 构建更新表达式(只更新提供的字段) | |
| 4320 | + var updateBuilder = _db.Updateable<LqKdKdjlbEntity>() | |
| 4321 | + .SetColumns(it => new LqKdKdjlbEntity | |
| 4322 | + { | |
| 4323 | + UpdateTime = DateTime.Now | |
| 4324 | + }); | |
| 4325 | + | |
| 4326 | + // 如果提供了scwj,则更新上传文件 | |
| 4327 | + if (input.scwj != null) | |
| 4328 | + { | |
| 4329 | + updateBuilder = updateBuilder.SetColumns(it => new LqKdKdjlbEntity | |
| 4330 | + { | |
| 4331 | + Scwj = input.scwj.ToJson() | |
| 4332 | + }); | |
| 4333 | + updatedFields.Add("scwj"); | |
| 4334 | + } | |
| 4335 | + | |
| 4336 | + // 如果提供了F_FIleUrl,则更新方案其他 | |
| 4337 | + if (input.F_FIleUrl != null) | |
| 4338 | + { | |
| 4339 | + updateBuilder = updateBuilder.SetColumns(it => new LqKdKdjlbEntity | |
| 4340 | + { | |
| 4341 | + F_FIleUrl = input.F_FIleUrl | |
| 4342 | + }); | |
| 4343 | + updatedFields.Add("F_FIleUrl"); | |
| 4344 | + } | |
| 4345 | + | |
| 4346 | + // 如果没有提供任何字段,则返回错误 | |
| 4347 | + if (!updatedFields.Any()) | |
| 4348 | + { | |
| 4349 | + throw NCCException.Oh("至少需要提供一个要更新的字段(scwj或F_FIleUrl)"); | |
| 4350 | + } | |
| 4351 | + | |
| 4352 | + // 执行更新 | |
| 4353 | + var updateResult = await updateBuilder | |
| 4354 | + .Where(w => w.Id == input.Id) | |
| 4355 | + .ExecuteCommandAsync(); | |
| 4356 | + | |
| 4357 | + if (updateResult <= 0) | |
| 4358 | + { | |
| 4359 | + throw NCCException.Oh("更新开单文件失败"); | |
| 4360 | + } | |
| 4361 | + | |
| 4362 | + return new | |
| 4363 | + { | |
| 4364 | + code = 200, | |
| 4365 | + msg = "更新成功", | |
| 4366 | + data = new | |
| 4367 | + { | |
| 4368 | + id = input.Id, | |
| 4369 | + updatedFields = updatedFields | |
| 4370 | + } | |
| 4371 | + }; | |
| 4372 | + } | |
| 4373 | + catch (Exception ex) | |
| 4374 | + { | |
| 4375 | + _logger.LogError(ex, $"修改开单文件失败 - 开单ID: {input?.Id}"); | |
| 4376 | + throw NCCException.Oh($"修改开单文件失败: {ex.Message}"); | |
| 4377 | + } | |
| 4378 | + } | |
| 4264 | 4379 | #endregion |
| 4265 | 4380 | } |
| 4266 | 4381 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqMdTargetService.cs
| ... | ... | @@ -181,28 +181,28 @@ namespace NCC.Extend.LqMdTarget |
| 181 | 181 | continue; |
| 182 | 182 | |
| 183 | 183 | entities.Add(new LqMdTargetEntity |
| 184 | - { | |
| 185 | - Id = YitIdHelper.NextId().ToString(), | |
| 186 | - StoreId = storeId, | |
| 187 | - Month = month, | |
| 188 | - BusinessUnit = "", | |
| 189 | - TechDepartment = "", | |
| 190 | - EducationDepartment = "", | |
| 191 | - MajorProjectDepartment = "", | |
| 192 | - BusinessUnitTarget = 0, | |
| 193 | - TechDepartmentTarget = 0, | |
| 194 | - EducationDepartmentTarget = 0, | |
| 195 | - BusinessUnitGeneralManager = "", | |
| 196 | - BusinessUnitManager = "", | |
| 197 | - StoreTarget = 0, | |
| 198 | - StoreLifeline = 0, | |
| 199 | - StoreConsumeTarget = 0, | |
| 200 | - StoreProjectTarget = 0, | |
| 201 | - StoreHeadcountTarget = 0, | |
| 202 | - AssistantHeadcountTargetStage1 = 0, | |
| 203 | - AssistantHeadcountTargetStage2 = 0, | |
| 204 | - CreateTime = DateTime.Now, | |
| 205 | - CreateUser = userInfo.userId, | |
| 184 | + { | |
| 185 | + Id = YitIdHelper.NextId().ToString(), | |
| 186 | + StoreId = storeId, | |
| 187 | + Month = month, | |
| 188 | + BusinessUnit = "", | |
| 189 | + TechDepartment = "", | |
| 190 | + EducationDepartment = "", | |
| 191 | + MajorProjectDepartment = "", | |
| 192 | + BusinessUnitTarget = 0, | |
| 193 | + TechDepartmentTarget = 0, | |
| 194 | + EducationDepartmentTarget = 0, | |
| 195 | + BusinessUnitGeneralManager = "", | |
| 196 | + BusinessUnitManager = "", | |
| 197 | + StoreTarget = 0, | |
| 198 | + StoreLifeline = 0, | |
| 199 | + StoreConsumeTarget = 0, | |
| 200 | + StoreProjectTarget = 0, | |
| 201 | + StoreHeadcountTarget = 0, | |
| 202 | + AssistantHeadcountTargetStage1 = 0, | |
| 203 | + AssistantHeadcountTargetStage2 = 0, | |
| 204 | + CreateTime = DateTime.Now, | |
| 205 | + CreateUser = userInfo.userId, | |
| 206 | 206 | }); |
| 207 | 207 | } |
| 208 | 208 | |
| ... | ... | @@ -379,6 +379,104 @@ namespace NCC.Extend.LqMdTarget |
| 379 | 379 | }; |
| 380 | 380 | } |
| 381 | 381 | #endregion |
| 382 | + | |
| 383 | + #region 获取部门管理的门店列表 | |
| 384 | + /// <summary> | |
| 385 | + /// 获取部门管理的门店列表 | |
| 386 | + /// </summary> | |
| 387 | + /// <remarks> | |
| 388 | + /// 根据年月、组织类型、部门ID查询该部门在该月份管理的门店列表 | |
| 389 | + /// | |
| 390 | + /// 示例请求: | |
| 391 | + /// ```json | |
| 392 | + /// { | |
| 393 | + /// "month": "202511", | |
| 394 | + /// "organizationType": "事业部", | |
| 395 | + /// "departmentId": "部门ID" | |
| 396 | + /// } | |
| 397 | + /// ``` | |
| 398 | + /// | |
| 399 | + /// 参数说明: | |
| 400 | + /// - month: 年月,格式为YYYYMM(如:202511表示2025年11月) | |
| 401 | + /// - organizationType: 组织类型,可选值:事业部、科技部、教育部、大项目部 | |
| 402 | + /// - departmentId: 部门ID | |
| 403 | + /// </remarks> | |
| 404 | + /// <param name="input">查询参数</param> | |
| 405 | + /// <returns>门店列表(包含门店ID和门店名称)</returns> | |
| 406 | + /// <response code="200">成功返回门店列表</response> | |
| 407 | + /// <response code="400">参数错误</response> | |
| 408 | + [HttpPost("GetManagedStores")] | |
| 409 | + public async Task<dynamic> GetManagedStores([FromBody] GetManagedStoresInput input) | |
| 410 | + { | |
| 411 | + try | |
| 412 | + { | |
| 413 | + // 验证参数 | |
| 414 | + if (input == null) | |
| 415 | + { | |
| 416 | + throw NCCException.Oh("参数不能为空"); | |
| 417 | + } | |
| 418 | + | |
| 419 | + if (string.IsNullOrEmpty(input.Month)) | |
| 420 | + { | |
| 421 | + throw NCCException.Oh("年月不能为空"); | |
| 422 | + } | |
| 423 | + | |
| 424 | + if (input.Month.Length != 6 || !Regex.IsMatch(input.Month, @"^\d{6}$")) | |
| 425 | + { | |
| 426 | + throw NCCException.Oh("年月格式必须为YYYYMM(如:202511)"); | |
| 427 | + } | |
| 428 | + | |
| 429 | + if (string.IsNullOrEmpty(input.OrganizationType)) | |
| 430 | + { | |
| 431 | + throw NCCException.Oh("组织类型不能为空"); | |
| 432 | + } | |
| 433 | + | |
| 434 | + if (string.IsNullOrEmpty(input.DepartmentId)) | |
| 435 | + { | |
| 436 | + throw NCCException.Oh("部门ID不能为空"); | |
| 437 | + } | |
| 438 | + | |
| 439 | + // 构建查询条件(使用多表关联方式) | |
| 440 | + var query = _db.Queryable<LqMdTargetEntity, LqMdxxEntity>( | |
| 441 | + (t, s) => t.StoreId == s.Id) | |
| 442 | + .Where((t, s) => t.Month == input.Month); | |
| 443 | + | |
| 444 | + // 根据组织类型添加部门过滤条件 | |
| 445 | + switch (input.OrganizationType) | |
| 446 | + { | |
| 447 | + case "事业部": | |
| 448 | + query = query.Where((t, s) => t.BusinessUnit == input.DepartmentId); | |
| 449 | + break; | |
| 450 | + case "科技部": | |
| 451 | + query = query.Where((t, s) => t.TechDepartment == input.DepartmentId); | |
| 452 | + break; | |
| 453 | + case "教育部": | |
| 454 | + query = query.Where((t, s) => t.EducationDepartment == input.DepartmentId); | |
| 455 | + break; | |
| 456 | + case "大项目部": | |
| 457 | + query = query.Where((t, s) => t.MajorProjectDepartment == input.DepartmentId); | |
| 458 | + break; | |
| 459 | + default: | |
| 460 | + throw NCCException.Oh($"不支持的组织类型:{input.OrganizationType},支持的类型:事业部、科技部、教育部、大项目部"); | |
| 461 | + } | |
| 462 | + | |
| 463 | + // 关联门店表获取门店名称 | |
| 464 | + var result = await query | |
| 465 | + .Select((t, s) => new ManagedStoreOutput | |
| 466 | + { | |
| 467 | + StoreId = t.StoreId, | |
| 468 | + StoreName = s.Dm ?? "未知门店" | |
| 469 | + }) | |
| 470 | + .ToListAsync(); | |
| 471 | + | |
| 472 | + return result; | |
| 473 | + } | |
| 474 | + catch (Exception ex) | |
| 475 | + { | |
| 476 | + throw NCCException.Oh($"查询失败:{ex.Message}"); | |
| 477 | + } | |
| 478 | + } | |
| 479 | + #endregion | |
| 382 | 480 | } |
| 383 | 481 | } |
| 384 | 482 | ... | ... |