123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- using AutoMapper;
- using Ropin.Inspection.Common.Accessor.Interface;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Entities;
- using Ropin.Inspection.Model.SearchModel.LGS;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Model.ViewModel.LGS;
- using Ropin.Inspection.Repository.LGS.Interface;
- using Ropin.Inspection.Service.LGS.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Service.LGS
- {
- public class LGSLargeScreenService : ILGSLargeScreenService
- {
- private readonly ILGSLargeScreenRepository _repository;
- private readonly IMapper _mapper;
- private readonly IClaimsAccessor _claims;
- private readonly InspectionDbContext _sqlDBContext;
- public LGSLargeScreenService(IClaimsAccessor claims, InspectionDbContext sqlDBContext, ILGSLargeScreenRepository repository, IMapper mapper)
- {
- _repository = repository;
- _mapper = mapper;
- _claims = claims;
- _sqlDBContext = sqlDBContext;
- }
- public async Task<IEnumerable<LargeScreenViewModel>> GetConditionAsync(LargeScreenSearch searchModel)
- {
- var list = await _repository.GetConditionAsync(searchModel);
- return list;
- }
- public async Task CreateOneAsync(LargeScreenViewModel viewModel)
- {
- var content = _mapper.Map<TLGS_LargeScreen>(viewModel);
- content.C_ID = Guid.NewGuid().ToString();
- content.C_CreateBy = _claims.ApiUserId.ToString();
- content.C_Creator = _claims.ApiUserName;
- content.D_CreateOn = DateTime.Now;
- content.C_Status = "1";
- _repository.Create(content);
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("创建失败");
- }
- }
- public async Task DeleteAsync(string id)
- {
- var content = await _repository.GetByIdAsync(id);
- if (content == null)
- {
- throw new Exception("数据库中没有此数据");
- }
- content.C_LastUpdatedBy = _claims.ApiUserId.ToString();
- content.D_LastUpdatedOn = DateTime.Now;
- content.C_Modifier = _claims.ApiUserName;
- content.C_Status = "0";
- _repository.Update(content);
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("删除失败");
- }
- }
- public async Task<LargeScreenViewModel> GetByIdAsync(string id)
- {
- LargeScreenSearch searchModel = new LargeScreenSearch();
- searchModel.IsPagination = false;
- searchModel.C_ID = id;
- var list = await _repository.GetConditionAsync(searchModel);
- return list?.FirstOrDefault();
- }
- public async Task UpdateAsync(LargeScreenViewModel viewModel, string Id)
- {
- var content = await _repository.GetByIdAsync(Id);
- if (content == null)
- {
- throw new Exception("没有此数据");
- }
- _mapper.Map(viewModel, content, typeof(LargeScreenViewModel), typeof(TLGS_LargeScreen));
- content.C_LastUpdatedBy = _claims.Linsence == null ? _claims.ApiUserId.ToString() : "6e864cbc-5252-11ec-8681-fa163e02b3e4";
- content.D_LastUpdatedOn = DateTime.Now;
- content.C_Modifier = _claims.ApiUserName;
- _repository.Update(content);
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("更新失败");
- }
- }
- public async Task<bool> UpdateImageAsync(string FilePath, string Id)
- {
- var content = await _repository.GetByIdAsync(Id);
- if (content == null)
- {
- throw new Exception("没有此数据");
- }
- content.C_ImageURL = FilePath;
- content.D_LastUpdatedOn = DateTime.Now;
- content.C_Modifier = _claims.ApiUserName;
- _repository.Update(content);
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("更新失败");
- }
- return result;
- }
- #region 大屏数据接口
- /// <summary>
- /// 设备维修、维保、点检 30天统计
- /// </summary>
- /// <param name="DevStoreCode"></param>
- /// <returns></returns>
- public async Task<IEnumerable<DevOpsRepairISPDaysStatistics>> DevOpsRepairISP30DaysStatistics(string DevStoreCode)
- {
- return await _repository.DevOpsRepairISP30DaysStatistics(DevStoreCode);
- }
- /// <summary>
- /// 设备维修、维保、点检 7天统计
- /// </summary>
- /// <param name="DevStoreCode"></param>
- /// <returns></returns>
- public async Task<IEnumerable<DevOpsRepairISPDaysStatistics>> DevOpsRepairISP7DaysStatistics(string DevStoreCode)
- {
- return await _repository.DevOpsRepairISP7DaysStatistics(DevStoreCode);
- }
- /// <summary>
- /// 设备维保-天状态统计
- /// </summary>
- /// <param name="DevStoreCode"></param>
- /// <param name="days"></param>
- /// <returns></returns>
- public async Task<IEnumerable<DaysStatusStatistics>> DevOpsDaysStatistics(string DevStoreCode, int days)
- {
- return await _repository.DevOpsDaysStatistics(DevStoreCode,days);
- }
- /// <summary>
- /// 设备维修-天状态统计
- /// </summary>
- /// <returns></returns>
- public async Task<IEnumerable<DaysStatusStatistics>> RepairOrderDaysStatistics(string DevStoreCode, int days)
- {
- return await _repository.RepairOrderDaysStatistics(DevStoreCode, days);
- }
- /// <summary>
- /// 设备点检-天状态统计
- /// </summary>
- /// <returns></returns>
- public async Task<IEnumerable<DaysStatusStatistics>> ISPDaysStatistics(string DevStoreCode, int days)
- {
- return await _repository.ISPDaysStatistics(DevStoreCode, days);
- }
- /// <summary>
- /// 维保饼图状态统计
- /// </summary>
- /// <returns></returns>
- public async Task<RepairStatistics> GeDevOpsStatisticsMonthPieAsync(string DevStoreCode, int months)
- {
- return await _repository.GeDevOpsStatisticsMonthPieAsync(DevStoreCode, months);
- }
- /// <summary>
- /// 维修饼图状态统计
- /// </summary>
- /// <returns></returns>
- public async Task<RepairStatistics> GeRepairOrderStatisticsMonthPieAsync(string DevStoreCode, int months)
- {
- return await _repository.GeRepairOrderStatisticsMonthPieAsync(DevStoreCode, months);
- }
- #endregion
- public Task<bool> IsExistAsync(string id)
- {
- throw new NotImplementedException();
- }
- public Task<int> UpdateOneAsync(LargeScreenViewModel viewModel, params string[] fields)
- {
- throw new NotImplementedException();
- }
- }
- }
|