namespace IStation.Application
|
{
|
/// <summary>
|
/// Map
|
/// </summary>
|
[Route("SZJT/Map/Mobile")]
|
[ApiDescriptionSettings("SZJT", Name = "地图(手机)", Order = 1600)]
|
public class Map_MobileController : IDynamicApiController
|
{
|
|
/// <summary>
|
/// 获取泵站列表
|
/// </summary>
|
[Route("GetStationList@V1.0")]
|
[HttpGet]
|
public List<StationMapMobileDto> GetStationList()
|
{
|
var keyContent = $"SZJT_Map_Mobile_GetStationList";
|
var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
|
|
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
|
{
|
var allList = new Yw.Service.LogicSite().GetAll();
|
Yw.Service.LogicSite.PublishCache(cacheKey);
|
if (allList == null || allList.Count < 1)
|
{
|
return default;
|
}
|
|
var serviceMap = new Yw.Service.MapInfo();
|
var vmList = new List<StationMapMobileDto>();
|
foreach (var station in allList)
|
{
|
var vm = new StationMapMobileDto(station);
|
vmList.Add(vm);
|
var map = serviceMap.Get(IStation.DataType.LogicSite, station.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (map != null)
|
{
|
var position = Yw.Model.Map.Marker.ToModel(map.Position);
|
vm.Position = position;
|
}
|
}
|
return vmList;
|
|
}, Yw.Service.ConfigHelper.CacheLevel3);
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 StationID 获取监测Kpi信息
|
/// </summary>
|
[Route("GetMonitorKpiInfoByStationID@V1.0")]
|
[HttpGet]
|
public StationMapMonitorKpiInfoMobileDto GetMonitorKpiInfoByStationID([FromQuery][Required] StationIDInput input)
|
{
|
var station = new Yw.Service.LogicSite().GetByID(input.StationID);
|
if (station == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"StationID:{input.StationID} 数据不存在");
|
}
|
var vm = new StationMapMonitorKpiInfoMobileDto(station);
|
|
var allMonitorList = new Yw.Service.MonitorPoint().GetExSignalWithSignalTypeByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID);
|
allMonitorList = allMonitorList?.Where(x => x.UseStatus == Yw.Model.eUseStatus.Enable).ToList();
|
allMonitorList = allMonitorList?.Where(x => x.CronType == Yw.Monitor.eCronType.Real).ToList();
|
if (allMonitorList != null && allMonitorList.Count > 0)
|
{
|
allMonitorList = allMonitorList.Where(x => x.Flags.Contains(Flags.KPI)).OrderByDescending(X => X.Importance).ToList();
|
if (allMonitorList.Count > 0)
|
{
|
var service_monitor_record = new Yw.Service.MonitorRealRecord();
|
allMonitorList = allMonitorList.Take(4).ToList();
|
foreach (var monitor in allMonitorList)
|
{
|
var monitorRecord = service_monitor_record.GetLastRecord(monitor.SignalList.First().ID);
|
vm.LastRecordList.Add(new StationMapMonitorKpiLastRecordMobileDto(monitor, monitorRecord));
|
}
|
}
|
}
|
|
var allEquipmentList = new Yw.Service.Equipment().GetByBelongTypeAndBelongID(IStation.DataType.LogicSite, station.ID);
|
allEquipmentList = allEquipmentList?.Where(x => x.ParentIds.Count < 1).ToList();
|
if (allEquipmentList != null && allEquipmentList.Count > 0)
|
{
|
var service_run_record = new Yw.Service.RunRealRecord();
|
foreach (var equipment in allEquipmentList)
|
{
|
var runRecord = service_run_record.GetLastRecord(Yw.Assets.DataType.Equipment, equipment.ID);
|
vm.LastStatusList.Add(new StationMapMonitorKpiLastStatusMobileDto(equipment, runRecord));
|
}
|
}
|
|
return vm;
|
}
|
|
/// <summary>
|
/// 获取流量计列表
|
/// </summary>
|
[Route("GetFlowMeterList@V1.0")]
|
[HttpGet]
|
public List<FlowMeterMapMobileDto> GetFlowMeterList()
|
{
|
var keyContent = $"SZJT_Map_Mobile_GetFlowMeterList";
|
var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
|
|
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
|
{
|
var catalogList = new Yw.Service.SysCatalog().GetChildAndSelfByCode(IStation.Catalog.FlowMeter);
|
Yw.Service.SysCatalog.PublishCache(cacheKey);
|
if (catalogList == null || catalogList.Count < 1)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, "流量计分类编码验证失败");
|
}
|
var catalogIds = catalogList.Select(x => x.ID).Distinct().ToList();
|
|
var allMeterList = new Yw.Service.Equipment().GetByBelongTypeAndBelongID(IStation.DataType.LogicDma, 1);
|
Yw.Service.Equipment.PublishCache(cacheKey);
|
allMeterList = allMeterList?.Where(x => catalogIds.Contains(x.CatalogID)).ToList();
|
if (allMeterList == null || allMeterList.Count < 1)
|
{
|
return default;
|
}
|
|
var service_map = new Lazy<Yw.Service.MapInfo>(() => new Yw.Service.MapInfo());
|
|
var vmList = new List<FlowMeterMapMobileDto>();
|
foreach (var meter in allMeterList)
|
{
|
var vm = new FlowMeterMapMobileDto(meter);
|
vmList.Add(vm);
|
|
var mapInfo = service_map.Value.Get(Yw.Assets.DataType.Equipment, meter.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (mapInfo != null)
|
{
|
vm.Position = Yw.Model.Map.Marker.ToModel(mapInfo.Position);
|
}
|
|
}
|
|
return vmList;
|
|
}, Yw.Service.ConfigHelper.CacheLevel3);
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 FlowMeterID 获取监测Kpi信息
|
/// </summary>
|
[Route("GetMonitorKpiInfoByFlowMeterID@V1.0")]
|
[HttpGet]
|
public FlowMeterMapMonitorKpiInfoMobileDto GetMonitorKpiInfoByFlowMeterID([FromQuery][Required] FlowMeterIDInput input)
|
{
|
var equipment = new Yw.Service.Equipment().GetByID(input.FlowMeterID);
|
if (equipment == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"FlowMeterID:{input.FlowMeterID} 数据不存在");
|
}
|
var catalogList = new Yw.Service.SysCatalog().GetChildAndSelfByCode(IStation.Catalog.FlowMeter);
|
if (catalogList == null || catalogList.Count < 1)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, "流量计分类编码验证失败");
|
}
|
var catalogIds = catalogList.Select(x => x.ID).Distinct().ToList();
|
if (!catalogIds.Contains(equipment.CatalogID))
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"FlowMeterID:{input.FlowMeterID} 请输入正确流量计id");
|
}
|
|
var vm = new FlowMeterMapMonitorKpiInfoMobileDto();
|
vm.FlowMeterID = input.FlowMeterID;
|
vm.Name = equipment.Name;
|
vm.LastRecordList = new List<FlowMeterMapMonitorKpiLastRecordMobileDto>();
|
|
var service_monitor_mapping = new Yw.Service.EquipmentMonitorMapping();
|
var mappingList = new Yw.Service.EquipmentMonitorMapping().GetByEquipmentID(input.FlowMeterID);
|
if (mappingList != null && mappingList.Count > 0)
|
{
|
var monitorIds = mappingList.Select(x => x.MonitorPointID).Distinct().ToList();
|
var monitorList = new Yw.Service.MonitorPoint().GetExSignalWithSignalTypeByIds(monitorIds);
|
monitorList = monitorList?.Where(x => x.UseStatus == Yw.Model.eUseStatus.Enable).ToList();
|
monitorList = monitorList?.Where(x => x.CronType == Yw.Monitor.eCronType.Real).ToList();
|
if (monitorList != null && monitorList.Count > 0)
|
{
|
var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
|
var monitorQ = monitorList.Find(x => x.Flags.Contains(IStation.Flags.默认) && x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.瞬时流量));
|
if (monitorQ == null)
|
{
|
monitorQ = monitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.瞬时流量));
|
}
|
if (monitorQ != null)
|
{
|
var signalQ = monitorQ.SignalList.First();
|
var last_record = service_monitor_record.Value.GetLastRecord(signalQ.ID);
|
if (last_record != null)
|
{
|
vm.LastRecordList.Add(new FlowMeterMapMonitorKpiLastRecordMobileDto(monitorQ, last_record));
|
}
|
}
|
|
var monitorQl = monitorList.Find(x => x.Flags.Contains(IStation.Flags.默认) && x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.累积流量));
|
if (monitorQl == null)
|
{
|
monitorQl = monitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.累积流量));
|
}
|
if (monitorQl != null)
|
{
|
var signalQl = monitorQl.SignalList.First();
|
var last_record = service_monitor_record.Value.GetLastRecord(signalQl.ID);
|
if (last_record != null)
|
{
|
vm.LastRecordList.Add(new FlowMeterMapMonitorKpiLastRecordMobileDto(monitorQl, last_record));
|
}
|
}
|
|
}
|
}
|
|
return vm;
|
|
}
|
|
/// <summary>
|
/// 获取压力计列表
|
/// </summary>
|
[Route("GetPressMeterList@V1.0")]
|
[HttpGet]
|
public List<FlowMeterMapMobileDto> GetPressMeterList()
|
{
|
var keyContent = $"SZJT_Map_Mobile_GetPressMeterList";
|
var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
|
|
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
|
{
|
var catalogList = new Yw.Service.SysCatalog().GetChildAndSelfByCode(IStation.Catalog.PressMeter);
|
Yw.Service.SysCatalog.PublishCache(cacheKey);
|
if (catalogList == null || catalogList.Count < 1)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, "压力计分类编码验证失败");
|
}
|
var catalogIds = catalogList.Select(x => x.ID).Distinct().ToList();
|
|
var allMeterList = new Yw.Service.Equipment().GetByBelongTypeAndBelongID(IStation.DataType.LogicDma, 1);
|
Yw.Service.Equipment.PublishCache(cacheKey);
|
allMeterList = allMeterList?.Where(x => catalogIds.Contains(x.CatalogID)).ToList();
|
if (allMeterList == null || allMeterList.Count < 1)
|
{
|
return default;
|
}
|
|
var service_map = new Lazy<Yw.Service.MapInfo>(() => new Yw.Service.MapInfo());
|
|
var vmList = new List<FlowMeterMapMobileDto>();
|
foreach (var meter in allMeterList)
|
{
|
var vm = new FlowMeterMapMobileDto(meter);
|
vmList.Add(vm);
|
|
var mapInfo = service_map.Value.Get(Yw.Assets.DataType.Equipment, meter.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (mapInfo != null)
|
{
|
vm.Position = Yw.Model.Map.Marker.ToModel(mapInfo.Position);
|
}
|
|
}
|
|
return vmList;
|
|
}, Yw.Service.ConfigHelper.CacheLevel3);
|
return vm_list;
|
}
|
|
/// <summary>
|
/// 通过 PressMeterID 获取监测Kpi信息
|
/// </summary>
|
[Route("GetMonitorKpiInfoByPressMeterID@V1.0")]
|
[HttpGet]
|
public PressMeterMapMonitorKpiInfoMobileDto GetMonitorKpiInfoByPressMeterID([FromQuery][Required] PressMeterIDInput input)
|
{
|
var equipment = new Yw.Service.Equipment().GetByID(input.PressMeterID);
|
if (equipment == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"PressMeterID:{input.PressMeterID} 数据不存在");
|
}
|
var catalogList = new Yw.Service.SysCatalog().GetChildAndSelfByCode(IStation.Catalog.PressMeter);
|
if (catalogList == null || catalogList.Count < 1)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, "压力计分类编码验证失败");
|
}
|
var catalogIds = catalogList.Select(x => x.ID).Distinct().ToList();
|
if (!catalogIds.Contains(equipment.CatalogID))
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"PressMeterID:{input.PressMeterID} 请输入正确压力计id");
|
}
|
|
var vm = new PressMeterMapMonitorKpiInfoMobileDto();
|
vm.PressMeterID = input.PressMeterID;
|
vm.Name = equipment.Name;
|
vm.LastRecordList = new List<PressMeterMapMonitorKpiLastRecordMobileDto>();
|
|
var service_monitor_mapping = new Yw.Service.EquipmentMonitorMapping();
|
var mappingList = new Yw.Service.EquipmentMonitorMapping().GetByEquipmentID(input.PressMeterID);
|
if (mappingList != null && mappingList.Count > 0)
|
{
|
var monitorIds = mappingList.Select(x => x.MonitorPointID).Distinct().ToList();
|
var monitorList = new Yw.Service.MonitorPoint().GetExSignalWithSignalTypeByIds(monitorIds);
|
monitorList = monitorList?.Where(x => x.UseStatus == Yw.Model.eUseStatus.Enable).ToList();
|
monitorList = monitorList?.Where(x => x.CronType == Yw.Monitor.eCronType.Real).ToList();
|
if (monitorList != null && monitorList.Count > 0)
|
{
|
var service_monitor_record = new Lazy<Yw.Service.MonitorRealRecord>(() => new Yw.Service.MonitorRealRecord());
|
var monitorPr = monitorList.Find(x => x.Flags.Contains(IStation.Flags.默认) && x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.压力));
|
if (monitorPr == null)
|
{
|
monitorPr = monitorList.Find(x => x.SignalList.Exists(t => t.SignalType.Code == Yw.Monitor.SignalType.压力));
|
}
|
if (monitorPr != null)
|
{
|
var signalPr = monitorPr.SignalList.First();
|
var last_record = service_monitor_record.Value.GetLastRecord(signalPr.ID);
|
if (last_record != null)
|
{
|
vm.LastRecordList.Add(new PressMeterMapMonitorKpiLastRecordMobileDto(monitorPr, last_record));
|
}
|
}
|
|
}
|
}
|
|
return vm;
|
|
}
|
|
/// <summary>
|
/// 获取工单列表
|
/// </summary>
|
[Route("GetRepairList@V1.0")]
|
[HttpGet]
|
public List<RepairMapMobileDto> GetRepairList()
|
{
|
var vmList = new List<RepairMapMobileDto>();
|
var requestList = new Yw.Service.RepairRequestForm().GetPendingList();
|
if (requestList != null && requestList.Count > 0)
|
{
|
foreach (var request in requestList)
|
{
|
var vmRequest = new RepairMapMobileDto(request, Yw.Map.Kind.Gaodei);
|
vmList.Add(vmRequest);
|
}
|
}
|
var taskList = new Yw.Service.RepairTaskForm().GetUnCheckedList();
|
if (taskList != null && taskList.Count > 0)
|
{
|
foreach (var task in taskList)
|
{
|
var vmTask = new RepairMapMobileDto(task, Yw.Map.Kind.Gaodei);
|
vmList.Add(vmTask);
|
}
|
}
|
return vmList;
|
}
|
|
/// <summary>
|
/// 获取工单状态信息
|
/// </summary>
|
[Route("GetRepairStatusInfo@V1.0")]
|
[HttpGet]
|
public RepairMapStatusMobileDto GetRepairStatusInfo
|
(
|
[Required]
|
string FormType,
|
[Required]
|
long FormID
|
)
|
{
|
if (FormType == Yw.Repair.DataType.RepairRequestForm)
|
{
|
var request = new Yw.Service.RepairRequestForm().GetByID(FormID);
|
if (request == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"FormID:{FormID} 数据不存在");
|
}
|
return new RepairMapStatusMobileDto(request);
|
}
|
else if (FormType == Yw.Repair.DataType.RepairTaskForm)
|
{
|
var task = new Yw.Service.RepairTaskForm().GetByID(FormID);
|
if (task == null)
|
{
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.D001, $"FormID:{FormID} 数据不存在");
|
}
|
return new RepairMapStatusMobileDto(task);
|
}
|
|
throw YOops.Oh(eResultCode.Alert, InternalErrorCodes.V001, $"FormType 参数错误");
|
|
}
|
|
/// <summary>
|
/// 获取Dma分区列表
|
/// </summary>
|
[Route("GetDmaAreaList@V1.0")]
|
[HttpGet]
|
public List<DmaAreaMapMobileDto> GetDmaAreaList()
|
{
|
var keyContent = $"SZJT_Map_Mobile_GetDmaAreaList";
|
var cacheKey = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.WebApiLevel, MemoryCacheKey.Module, keyContent);
|
|
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
|
{
|
var allAreaList = new Yw.Service.DmaArea().GetByBelongTypeAndBelongID(IStation.DataType.LogicDma, 1);
|
Yw.Service.DmaArea.PublishCache(cacheKey);
|
if (allAreaList == null || allAreaList.Count < 1)
|
{
|
return default;
|
}
|
|
var serviceMapInfo = new Yw.Service.MapInfo();
|
|
var vm_list = new List<DmaAreaMapMobileDto>();
|
foreach (var area in allAreaList)
|
{
|
var vm = new DmaAreaMapMobileDto(area);
|
vm_list.Add(vm);
|
|
var area_map_info = serviceMapInfo.Get(Yw.DMA.DataType.DmaArea, area.ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
|
if (area_map_info != null)
|
{
|
vm.Position = Yw.Model.Map.Polygon.ToModel(area_map_info.Position);
|
}
|
}
|
|
return vm_list;
|
}, Yw.Service.ConfigHelper.CacheLevel3);
|
return vm_list;
|
}
|
|
|
}
|
}
|