123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.Logging;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Api.Controllers;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Entities;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api
- {
- public class TmtnDevOperateRecordController : BaseController
- {
- public ILogger<TmtnDevOperateRecordController> _logger { get; }
- private readonly ITmtnDevOperateRecordService _TmtnDevOperateRecordService;
-
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="TmtnDevOperateRecordService"></param>
- /// <param name="logger"></param>
- public TmtnDevOperateRecordController(ITmtnDevOperateRecordService TmtnDevOperateRecordService, ILogger<TmtnDevOperateRecordController> logger)
- {
- _TmtnDevOperateRecordService = TmtnDevOperateRecordService;
- _logger = logger;
-
- }
- /// <summary>
- /// 取运维工单统计
- /// </summary>
- /// <param name="storeCode"></param>
- /// <returns></returns>
- [HttpGet("GetDevOpsStatisticsAsync/{storeCode}")]
- public async Task<ApiResult> GetDevOpsStatisticsAsync(string storeCode)
- {
- if (string.IsNullOrEmpty(storeCode))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- var content = await _TmtnDevOperateRecordService.GetDevOpsStatisticsAsync(storeCode);
- return new ApiResult<RepairStatistics>(content);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 维保次数统计,大屏
- /// </summary>
- /// <param name="storeCode"></param>
- /// <returns></returns>
- [HttpGet("GetDevOpsStatisticsFullScreenAsync/{storeCode}")]
- [AllowAnonymous]
- public async Task<IEnumerable<FullScreenRecordItem>> GetDevOpsStatisticsFullScreenAsync(string storeCode)
- {
- if (string.IsNullOrEmpty(storeCode))
- {
- return new FullScreenRecordItem[0];
- }
- try
- {
- var content = await _TmtnDevOperateRecordService.GetDevOpsStatisticsFullScreenAsync(storeCode);
- return content;
- }
- catch
- {
- return new FullScreenRecordItem[0];
- }
- }
- /// <summary>
- /// 通过id获取设备操作记录信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("GetDevOperateRecordAsync/{id}")]
- public async Task<ApiResult> GetDevOperateRecordAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- var content = await _TmtnDevOperateRecordService.GetConditionAsync(new TmtnDevOperateRecordSearchModel { C_ID = id });
- return new ApiResult<TmtnDevOperateRecordViewModel>(content.FirstOrDefault());
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 获取所有设备操作记录
- /// </summary>
- /// <returns></returns>
- [HttpGet("GetDevOperateRecordsAsync")]
- public async Task<ApiResult> GetDevOperateRecordsAsync()
- {
- try
- {
- var contentList = await _TmtnDevOperateRecordService.GetAllAsync();
- return new ApiResult<IEnumerable<TmtnDevOperateRecordViewModel>>(contentList);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过设备操作记录名称条件查询
- /// </summary>
- /// <param name="searchModel"></param>
- /// <returns></returns>
- [HttpPost("GetDevOperateRecordsByAsync")]
- public async Task<ApiResult> GetDevOperateRecordsByAsync(TmtnDevOperateRecordSearchModel searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- searchModel.IsPagination = false;
- try
- {
- var contentList = await _TmtnDevOperateRecordService.GetConditionAsync(searchModel);
- return new ApiResult<PagesModel<TmtnDevOperateRecordViewModel>>(new PagesModel<TmtnDevOperateRecordViewModel>(contentList, searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 创建设备操作记录
- /// </summary>
- /// <param name="content"></param>
- /// <returns></returns>
- [HttpPost("CreateDevOperateRecordAsync")]
- public async Task<ApiResult> CreateDevOperateRecordAsync(TmtnDevOperateRecordViewModel content)
- {
- if (content == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _TmtnDevOperateRecordService.CreateOneAsync(content);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 删除设备操作记录
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("DeleteDevOperateRecordAsync/{id}")]
- public async Task<ApiResult> DeleteDevOperateRecordAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TmtnDevOperateRecordService.DeleteAsync(id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 更新设备操作记录
- /// </summary>
- /// <param name="id"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("UpdateDevOperateRecordAsync/{id}")]
- public async Task<ApiResult> UpdateDevOperateRecordAsync(string id, TmtnDevOperateRecordUpdateModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TmtnDevOperateRecordService.UpdateAsync(id, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 通过维保id获取维保列表
- /// </summary>
- /// <param name="devId"></param>
- /// <param name="repairId"></param>
- /// <returns></returns>
- [HttpGet("GetDevOpsRecordItemAsync/{devId}/{repairId}")]
- public async Task<ApiResult> GetRepairOrderItemViewAsync(string devId, string repairId)
- {
- if (string.IsNullOrEmpty(devId))
- return new ApiResult(ReturnCode.GeneralError);
- if (string.IsNullOrEmpty(repairId))
- return new ApiResult(ReturnCode.GeneralError);
- try
- {
- var content = await _TmtnDevOperateRecordService.GetDevOpsRecordItemAsync(devId, repairId);
- return new ApiResult<TmtnDevOpsRecordItemDetailViewMode>(content);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- }
- }
|