123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.SearchModel;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api.Controllers
- {
- /// <summary>
- /// 巡检路径巡检点
- /// </summary>
- public class TispSpotRouteController : BaseController
- {
- public ILogger<TispSpotRouteController> _logger { get; }
- private readonly ITispSpotRouteService _tispSpotRouteService;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="tispSpotRouteService"></param>
- /// <param name="logger"></param>
- public TispSpotRouteController(ITispSpotRouteService tispSpotRouteService, ILogger<TispSpotRouteController> logger)
- {
- _tispSpotRouteService = tispSpotRouteService;
- _logger = logger;
- }
- /// <summary>
- /// 分组获取巡检路径分配的巡检点列表
- /// </summary>
- /// <param name="searchViewModel"></param>
- /// <returns></returns>
- [HttpPost("GetSpotRoutesAsyncByPage")]
- public async Task<ApiResult> GetSpotRoutesAsyncByPage(TispSpotRouteSearchModel searchViewModel)
- {
- try
- {
- if (null == searchViewModel)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- var list = await _tispSpotRouteService.GetSpotRoutesAsyncByPage(searchViewModel);
- return new ApiResult<PagesModel<TispSpotsRouteViewModel>>(new PagesModel<TispSpotsRouteViewModel>(list?.ToList(), searchViewModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取路径和巡检点
- /// </summary>
- /// <param name="searchViewModel"></param>
- /// <returns></returns>
- [HttpPost("GetSpotsRouteAsyncByPage")]
- public async Task<ApiResult> GetSpotsRouteAsyncByPage(TispSpotRouteSearchModel searchViewModel)
- {
- try
- {
- if (null == searchViewModel||string.IsNullOrEmpty(searchViewModel.C_StoreCode))
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- var list = await _tispSpotRouteService.GetSpotsRouteAsyncByPage(searchViewModel);
- return new ApiResult<PagesModel<TispSpotsRouteViewModel>>(new PagesModel<TispSpotsRouteViewModel>(list?.ToList(), searchViewModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 创建或修改路径的巡检点
- /// </summary>
- /// <param name="createViewModel"></param>
- /// <returns></returns>
- [Route("CreateSpotsRoutesAsync")]
- [HttpPost]
- public async Task<ApiResult> CreateSpotsRoutesAsync(TispSpotRouteCreateViewModel createViewModel)
- {
- if (createViewModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- if (createViewModel.spotIdList == null)
- {
- throw new Exception("请选择巡检点");
- }
- if (createViewModel.routeIdList == null)
- {
- throw new Exception("请选择巡检路径");
- }
- try
- {
- await _tispSpotRouteService.CreateSpotsRoutesAsync(createViewModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- }
- }
|