diff --git a/OpenAuth.App/ServiceApp/DroneSsnydManage/DroneSsnyApp.cs b/OpenAuth.App/ServiceApp/DroneSsnydManage/DroneSsnyApp.cs index e801720..66aab4b 100644 --- a/OpenAuth.App/ServiceApp/DroneSsnydManage/DroneSsnyApp.cs +++ b/OpenAuth.App/ServiceApp/DroneSsnydManage/DroneSsnyApp.cs @@ -419,8 +419,61 @@ namespace OpenAuth.App.ServiceApp.DroneSsnydManage Id = project.Id, xiangmu_no = newXiangmuNo }; - // todo 空字段是否会影响 - await Repository.UpdateAsync(newProject); + await Repository.AsUpdateable(newProject).IgnoreNullColumns().ExecuteCommandAsync(); } + + public async Task MaintainXianmuName(string id, string newXiangmuName) + { + var project = await Repository.AsQueryable().SingleAsync(a => a.Id == id && a.handle_status_id != 99); + if (project == null) + { + throw new Exception("项目不存在或停止生产"); + } + + var newProject = new DroneSsnyd() + { + Id = project.Id, + xiangmu_name = newXiangmuName + }; + await Repository.AsUpdateable(newProject).IgnoreNullColumns().ExecuteCommandAsync(); + } + + public async Task ProjectRenewal(string id, DateTime newEndTime) + { + var project = await Repository.AsQueryable().SingleAsync(a => a.Id == id && a.handle_status_id != 99); + if (project == null) + { + throw new Exception("项目不存在或停止生产"); + } + + if (newEndTime < project.end_time) + { + throw new Exception("新的结束时间不能早于原结束时间"); + } + + var newProject = new DroneSsnyd() + { + Id = project.Id, + end_time = newEndTime + }; + await Repository.AsUpdateable(newProject).IgnoreNullColumns().ExecuteCommandAsync(); + } + + public async Task CloseProject(string id) + { + var project = await Repository.AsQueryable().SingleAsync(a => a.Id == id && a.handle_status_id != 99); + if (project == null) + { + throw new Exception("项目不存在或停止生产"); + } + + var newProject = new DroneSsnyd() + { + Id = project.Id, + handle_status_id = 99, + handle_status_name = "项目终止", + }; + await Repository.AsUpdateable(newProject).IgnoreNullColumns().ExecuteCommandAsync(); + } } } \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneSsnyController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneSsnyController.cs index 776f32b..c508f44 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/DroneSsnyController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/DroneSsnyController.cs @@ -120,7 +120,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers return response; } - // todo 编号维护 名称维护 项目续期 项目详情 停止生产 项目称交 + // todo 项目详情 停止生产 项目称交 /// /// 编号维护 /// @@ -133,7 +133,78 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers var response = new Response(); try { - await droneSsnyApp.MaintainNumber(id, newXiangmuNo); + await droneSsnyApp.MaintainNumber(id, newXiangmuNo); + response.Result = true; + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.InnerException?.Message ?? ex.Message; + } + + return response; + } + + /// + /// 名称维护 + /// + /// + /// + /// + [HttpPost] + public async Task> MaintainXianmuName(string id, string newXiangmuName) + { + var response = new Response(); + try + { + await droneSsnyApp.MaintainXianmuName(id, newXiangmuName); + response.Result = true; + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.InnerException?.Message ?? ex.Message; + } + + return response; + } + + /// + /// 项目续期 + /// + /// + /// + /// + [HttpPost] + public async Task> ProjectRenewal(string id, DateTime newEndTime) + { + var response = new Response(); + try + { + await droneSsnyApp.ProjectRenewal(id, newEndTime); + response.Result = true; + } + catch (Exception ex) + { + response.Code = 500; + response.Message = ex.InnerException?.Message ?? ex.Message; + } + + return response; + } + + /// + /// 停止生产 + /// + /// + /// + [HttpPost] + public async Task> CloseProject(string id) + { + var response = new Response(); + try + { + await droneSsnyApp.CloseProject(id); response.Result = true; } catch (Exception ex)