123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Model.ViewModel.LGS;
- using Ropin.Inspection.Service.MTN.Interface;
- using System.Threading.Tasks;
- using System;
- using Ropin.Inspection.Model.ViewModel.MTN;
- using Microsoft.AspNetCore.Authorization;
- using Ropin.Inspection.Model;
- using Minio.DataModel.Args;
- using Minio;
- using System.Collections.Generic;
- using System.Linq;
- using Ropin.Inspection.Model.ViewModel;
- namespace Ropin.Inspection.Api.Controllers.MTN
- {
- public class DevOpsPlanController : BaseController
- {
- private readonly IDevOpsPlanService _devOpsPlanService;
- public DevOpsPlanController(IDevOpsPlanService devOpsPlanService)
- {
- _devOpsPlanService = devOpsPlanService;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="devOpsPlanModel"></param>
- /// <returns></returns>
- [HttpPost("Add")]
- public async Task<ApiResult> AddAsync(DevOpsPlanModel devOpsPlanModel)
- {
- try
- {
- await _devOpsPlanService.CreateOneAsync(devOpsPlanModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 分页列表
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("Page")]
- public async Task<ApiResult> PageAsync(DevOpsPlanInput input)
- {
- try
- {
- var libraryModels = await _devOpsPlanService.PageAsync(input);
- PagesModel<DevOpsPlanModel> pages = new PagesModel<DevOpsPlanModel>(libraryModels, input);
- return new ApiResult<PagesModel<DevOpsPlanModel>>(pages);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- [HttpGet("Detail/{id}")]
- public async Task<ApiResult> DeatilAsync(string id)
- {
- var result = await _devOpsPlanService.GetByIdAsync(id);
- return new ApiResult<DevOpsPlanModel>(result);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("Delete/{id}")]
- public async Task<ApiResult> DeleteReportAsync(string id)
- {
- try
- {
- await _devOpsPlanService.DeleteAsync(id);
- return new ApiResult(ReturnCode.Success);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="devOpsPlanModel"></param>
- /// <returns></returns>
- [HttpPost("Update")]
- public async Task<ApiResult> UpdateAsync(DevOpsPlanModel devOpsPlanModel)
- {
- var result = await _devOpsPlanService.UpdateOneAsync(devOpsPlanModel);
- return new ApiResult<bool>(result >= 1);
- }
- /// <summary>
- /// 添加运维计划设备
- /// </summary>
- /// <param name="devOpsPlanDeviceModel"></param>
- /// <returns></returns>
- [HttpPost("AddDevice")]
- public async Task<ApiResult> AddDevice(DevOpsPlanDeviceModel devOpsPlanDeviceModel)
- {
- try
- {
- await _devOpsPlanService.AddDeviceAsync(devOpsPlanDeviceModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 设备列表
- /// </summary>
- /// <param name="imageLibraryModel"></param>
- /// <returns></returns>
- [HttpGet("DeviceList/{id}")]
- public async Task<ApiResult> DeviceListAsync(string id)
- {
- try
- {
- var libraryModels = await _devOpsPlanService.DeviceListAsync(id);
- //var result = libraryModels
- // .GroupBy(x => new
- // {
- // x.CDevStoreCode,
- // x.DevStoreName,
- // x.Url,
- // x.CNumberCode,
- // })
- // .Select(x => new DevOpsPlanDeviceGroupModel
- // {
- // CDevStoreCode = x.Key.CDevStoreCode,
- // DevStoreName = x.Key.DevStoreName,
- // Url = x.Key.Url,
- // CNumberCode = x.Key.CNumberCode,
- // })
- // .ToList();
- //result.ForEach(x =>
- //{
- // x.Spots = libraryModels.Where(y => y.CDevStoreCode == x.CDevStoreCode).Select(y=>new SpotGroupModel { CName=y.SpotName,CSpotCode=y.CSpotCode}).ToList();
- //});
- return new ApiResult<List<DevOpsPlanDeviceModel>>(libraryModels);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 删除设备
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("DeleteDeveice/{id}")]
- public async Task<ApiResult> DeleteDeviceAsync(string id)
- {
- try
- {
- await _devOpsPlanService.DeleteDeviceAsync(id);
- return new ApiResult(ReturnCode.Success);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 删除运维点
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("DeleteDeviceSpot/{planId}/{spotId}")]
- public async Task<ApiResult> DeleteDeviceSpotAsync(string planId, string spotId)
- {
- try
- {
- await _devOpsPlanService.DeleteDeviceSpotAsync(planId, spotId);
- return new ApiResult(ReturnCode.Success);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 添加运维计划设备内容
- /// </summary>
- /// <param name="devOpsPlanContentModel"></param>
- /// <returns></returns>
- [HttpPost("AddDeviceContent")]
- public async Task<ApiResult> AddDeviceContentAsync(DevOpsPlanContentModel devOpsPlanContentModel)
- {
- try
- {
- await _devOpsPlanService.AddDeviceContentAsync(devOpsPlanContentModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 设备内容列表
- /// </summary>
- /// <param name="imageLibraryModel"></param>
- /// <returns></returns>
- [HttpGet("DeviceContentList/{deviceId}/{id}")]
- public async Task<ApiResult> DeviceContentListAsync(string deviceId ,string id)
- {
- try
- {
- var result = await _devOpsPlanService.DeviceContentListAsync(deviceId,id);
- return new ApiResult<List<string>>(result);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 添加运维计划人员
- /// </summary>
- /// <param name="devOpsPlanPersonModel"></param>
- /// <returns></returns>
- [HttpPost("AddPlanPerson")]
- public async Task<ApiResult> AddPlanPersonAsync(DevOpsPlanPersonModel devOpsPlanPersonModel)
- {
- try
- {
- await _devOpsPlanService.AddPlanPersonAsync(devOpsPlanPersonModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 计划人员列表
- /// </summary>
- /// <param name="imageLibraryModel"></param>
- /// <returns></returns>
- [HttpGet("PlanPersonList/{id}")]
- public async Task<ApiResult> PlanPersonListAsync(string id)
- {
- try
- {
- var result = await _devOpsPlanService.PlanPersonListAsync(id);
- return new ApiResult<List<string>>(result);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 取消计划
- /// </summary>
- /// <returns></returns>
- [HttpPost("CancelPlan/{id}")]
- public async Task<ApiResult> CancelPlan(string id)
- {
- var result = await _devOpsPlanService.CancelPlan(id);
- return new ApiResult<bool>(result);
- }
- /// <summary>
- /// 确认计划
- /// </summary>
- /// <returns></returns>
- [HttpPost("ConfirmPlan/{id}")]
- public async Task<ApiResult> ConfirmPlan(string id)
- {
- var result = await _devOpsPlanService.ConfirmPlan(id);
- return new ApiResult<bool>(result);
- }
- /// <summary>
- /// 生成工单
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPost("GenerateWorkOrder/{id}")]
- public async Task<ApiResult> GenerateWorkOrder(string id)
- {
- try
- {
- var result = await _devOpsPlanService.GenerateWorkOrder(id);
- return new ApiResult<bool>(result);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 查看工单
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPost("GetDevOps/{id}")]
- public async Task<ApiResult> GetDevOps(string id, BaseSearchModel searchModel)
- {
- List<TmtnDevOpsDetailViewModel> result = await _devOpsPlanService.GetDevOps(id, searchModel);
- return new ApiResult<PagesModel<TmtnDevOpsDetailViewModel>>(new PagesModel<TmtnDevOpsDetailViewModel>(result, searchModel));
- }
- [HttpPost("SetOpsTime")]
- public async Task<ApiResult> SetOpsTime(SetOpsModel model)
- {
- var result = await _devOpsPlanService.SetOpsTime(model);
- return new ApiResult<bool>(result);
- }
- /// <summary>
- /// 通过工单id获取巡检点内容.
- /// </summary>
- [HttpPost("GetSpotContent")]
- public async Task<ApiResult> GetSpotContent(GetOpsSpotContentModel model)
- {
- try
- {
- if (string.IsNullOrEmpty(model.QrCode) || string.IsNullOrEmpty(model.StoreCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- var spot = await _devOpsPlanService.GetSpotContent(model);
- return new ApiResult<TispSpotViewModel>(spot);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 设置点检工单状态
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- [HttpPost("SetWorkOrderStatus")]
- public async Task<ApiResult> SetWorkOrderStatus(GetOpsSpotContentModel model)
- {
- try
- {
- await _devOpsPlanService.SetWorkOrderStatus(model);
- return new ApiResult<bool>(true);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- }
- }
|