冉成楼 2026-02-04 11:20:20 +08:00
parent b60966edb4
commit 93c4486d9b
3 changed files with 88 additions and 7 deletions

View File

@ -1,9 +1,11 @@
using DocumentFormat.OpenXml.Office.CustomUI;
using Infrastructure;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.Request;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
@ -116,9 +118,60 @@ namespace OpenAuth.App
}
}
public async Task<Response<bool>> Report()
public async Task<Response<bool>> Report(MiViolationReportRequest request)
{
return null;
using (var uwo = UnitWork.CreateContext())
{
//上报信息
var model = request.MapTo<MiViolationReport>();
model.Id = Guid.NewGuid().ToString();
model.Status = "待处理";
//现场照片
var photos = request.SencePhotos.MapToList<MiScenePhoto>();
photos.ForEach(a =>
{
a.Id = Guid.NewGuid().ToString();
a.ViolationReportId = model.Id;
});
var vehicleList = new List<MiVehicle>();
var vehicleImageList = new List<MiVehicleImage>();
foreach (var item in request.Vehicles)
{
//车辆信息
var vehicle = item.MapTo<MiVehicle>();
vehicle.Id = Guid.NewGuid().ToString();
vehicle.ViolationReportId = model.Id;
//车辆图片
var images = item.VehicleImages.MapToList<MiVehicleImage>();
images.ForEach(a =>
{
a.Id = Guid.NewGuid().ToString();
a.ViolationReportId = model.Id;
a.ParkingId = model.ParkingId;
a.VehicleId = vehicle.Id;
vehicleImageList.Add(a);
});
vehicleList.Add(vehicle);
}
await uwo.MiViolationReport.InsertAsync(model);
await uwo.MiScenePhoto.InsertRangeAsync(photos);
await uwo.MiVehicle.InsertRangeAsync(vehicleList);
await uwo.MiVehicleImage.InsertRangeAsync(vehicleImageList);
var flag = uwo.Commit();
return new Response<bool>
{
Result = flag,
Message = flag == true ? "success" : "error"
};
}
}
}

View File

@ -1,4 +1,5 @@
using DocumentFormat.OpenXml.Office2010.Excel;
using OpenAuth.App.ServiceApp.MiManager.Request;
using System;
using System.Collections.Generic;
using System.Linq;
@ -40,7 +41,7 @@ namespace OpenAuth.App.ServiceApp.Request
/// <summary>
/// 图片
/// </summary>
public List<Vehicle> Vehicles { get; set; }
public List<VehicleImage> VehicleImages { get; set; }
}
}

View File

@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.EMMA;
using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.Request;
using OpenAuth.Repository.Domain;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace OpenAuth.WebApi.Controllers
{
@ -48,7 +50,7 @@ namespace OpenAuth.WebApi.Controllers
var result = new Response<MiViolationReport>();
try
{
result.Result =await _app.Get(id);
result.Result = await _app.Get(id);
}
catch (Exception ex)
{
@ -130,6 +132,31 @@ namespace OpenAuth.WebApi.Controllers
return result;
}
#endregion
#region 上报
/// <summary>
/// 上报
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<Response<bool>> Report(MiViolationReportRequest request)
{
var result = new Response<bool>();
try
{
result = await _app.Report(request);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
#endregion
#endregion
}
}