违法上报

master
洁 任 2026-02-05 15:15:59 +08:00
parent 114bbf6823
commit 7680446b19
6 changed files with 310 additions and 56 deletions

View File

@ -31,49 +31,235 @@ namespace OpenAuth.App
/// <summary>
/// 分页
/// </summary>
public async Task<Response<PageInfo<List<MiViolationReport>>>> LoadAllPage(PageReq request)
public async Task<Response<PageInfo<List<dynamic>>>> LoadAllPage(MiviolationReq req)
{
//等级
var level = _auth.GetCurrentUser().Orgs.Min(a => a.Level);
//路径
var cascadeId = _auth.GetCurrentUser().Orgs.Where(a => a.Level == level).First().CascadeId;
RefAsync<int> totalCount = 0;
var list = await base.Repository.AsQueryable()
.LeftJoin<SysOrg>((r, o) => r.ReportUnit == o.Id.ToString())
//.Where((r, o) => o.CascadeId.Contains(cascadeId))
.ToPageListAsync(request.page, request.limit, totalCount);
return new Response<PageInfo<List<MiViolationReport>>>
var user = _auth.GetCurrentUser();
var users = user.User;
var level = user.Orgs?.Min(x => x.Level);
//如果不是超级管理员
if (user != null && (users.Id == -1 || level == 0))
{
Result = new PageInfo<List<MiViolationReport>>
var list = await base.Repository.AsQueryable()
.Where(p=>p.IsDelete == false)
.WhereIF(req.begindate != null && req.enddate != null, p => p.ReportTime >= req.begindate && p.ReportTime < req.enddate)
.WhereIF(req.status != null, p => p.Status == req.status)
.WhereIF(!string.IsNullOrEmpty(req.key), p => p.Title.Contains(req.key))
.WhereIF(req.viotype != null, p => p.ViolationType == req.viotype)
.LeftJoin<MiMinePoint>((p, m) => p.MinePointId == m.Id)
.LeftJoin<SysUser>((p, m, u) => p.Reporter == u.Id.ToString())
.LeftJoin<SysOrg>((p, m, u, o) => p.ReportUnit == o.Id.ToString())
.WhereIF(!string.IsNullOrEmpty(req.pointname), (p, m, u, o) => m.Name.Contains(req.pointname))
.OrderBy((p, m, u, o) => p.Status)
.OrderByDescending((p, m, u, o) => p.ReportTime)
.Select<dynamic>((p, m, u, o) => new
{
Id = p.Id.SelectAll(),
ReportUserName = u.Name,
PointName = m.Name,
OrgName = o.Name
})
.ToPageListAsync(req.page, req.limit, totalCount);
return new Response<PageInfo<List<dynamic>>>
{
Items = list,
Total = totalCount
Result = new PageInfo<List<dynamic>>
{
Items = list,
Total = totalCount
}
};
}
else
{
if (user.Orgs.Count == 0 || level == null)
{
throw new Exception("无权限查看数据");
}
};
else
{
//查询所有子部门
List<string> orgidlist = new List<string>();
var orgs = user.Orgs?.Select(r => r.Id).ToList();
using (var uow = base.UnitWork.CreateContext())
{
foreach (var item in orgs)
{
orgidlist.Add(item.ToString());
var allchilds = uow.SysOrg.AsQueryable().ToChildList(r => r.ParentId, item);
if (allchilds.Count > 0)
{
orgidlist = orgidlist.Concat(allchilds.Select(r => r.Id.ToString())).ToList();
}
}
var list = await uow.MiViolationReport.AsQueryable()
.Where(p => p.IsDelete == false)
.WhereIF(req.begindate != null && req.enddate != null, p => p.ReportTime >= req.begindate && p.ReportTime < req.enddate)
.WhereIF(req.status != null, p => p.Status == req.status)
.WhereIF(!string.IsNullOrEmpty(req.key), p => p.Title.Contains(req.key))
.WhereIF(req.viotype != null, p => p.ViolationType == req.viotype)
.Where(p => orgidlist.Contains(p.HandlingUnit))
.LeftJoin<MiMinePoint>((p, m) => p.MinePointId == m.Id)
.LeftJoin<SysUser>((p, m, u) => p.Reporter == u.Id.ToString())
.LeftJoin<SysOrg>((p, m, u, o) => p.ReportUnit == o.Id.ToString())
.WhereIF(!string.IsNullOrEmpty(req.pointname), (p, m, u, o) => m.Name.Contains(req.pointname))
.OrderBy((p, m, u, o) => p.Status)
.OrderByDescending((p, m, u, o) => p.ReportTime)
.Select<dynamic>((p, m, u, o) => new
{
Id = p.Id.SelectAll(),
ReportUserName = u.Name,
PointName = m.Name,
OrgName = o.Name
})
.ToPageListAsync(req.page, req.limit, totalCount);
return new Response<PageInfo<List<dynamic>>>
{
Result = new PageInfo<List<dynamic>>
{
Items = list,
Total = totalCount
}
};
}
}
}
}
#endregion
public async Task<ReportDetail> Get(string id)
public async Task<dynamic> Get(string id)
{
//基础信息
var model = Repository.GetByIdAsync(id).MapTo<ReportDetail>();
using (var uow = base.UnitWork.CreateContext())
{
var result = await base.Repository.AsQueryable()
.Where(p => p.Id == id)
.LeftJoin<SysOrg>((p, r) => p.ReportUnit == r.Id.ToString())
.LeftJoin<MiMinePoint>((p, r, m) => p.MinePointId == m.Id)
.LeftJoin<SysUser>((p, r, m, u) => p.Reporter == u.Id.ToString())
.LeftJoin<SysUser>((p, r, m, u, u2) => p.Handler == u2.Id.ToString())
.Select((p, r, m, u, u2) => new
{
// 提车信息
ReporterName = u.Name,
HandlerName = u2.Name,
ReportUnitName=r.Name,
model.Vehicles = new List<Vehicle>();
// 违法上报信息
p.Id,
p.Title,
ReportStatus = p.Status,
p.PartyName,
p.PartyPhone,
p.ViolationType,
p.ProblemDescription,
p.HandlingOpinion,
p.HandlingUnit,
p.Handler,
p.HandlingTime,
p.ReportTime,
p.Reporter,
p.ReportUnit,
p.Lng,
p.Lat,
model.SencePhotos = base.Repository.AsSugarClient()
.Queryable<MiScenePhoto>()
.Where(a => a.ViolationReportId == id)
.Select(a => new SencePhoto { Image = a.Image }, true).ToList();
// 盗采点信息
MinePointId = m.Id,
MinePointName = m.Name,
m.CountyName,
MinePointLng = m.Lng,
MinePointLat = m.Lat,
})
.FirstAsync();
model.Vehicles = base.Repository.AsSugarClient()
.Queryable<MiVehicle>()
.Includes(a => a.MiVehicleImages)
.Where(a => a.ViolationReportId == id)
.Select(a => new Vehicle { LicensePlate = a.LicensePlate }, true).ToList();
return model;
if (result == null)
return null;
// 查询车辆信息
var vehicles = await uow.MiVehicle.AsQueryable()
.Where(v => v.ViolationReportId == result.Id)
.ToListAsync();
// 查询车辆图片
List<MiVehicleImage> vehicleImages = new List<MiVehicleImage>();
if (vehicles.Any())
{
var vehicleIds = vehicles.Select(v => v.Id).ToList();
vehicleImages = await uow.MiVehicleImage.AsQueryable()
.Where(vi => vehicleIds.Contains(vi.VehicleId))
.ToListAsync();
}
// 查询现场照片
var scenePhotos = await uow.MiScenePhoto.AsQueryable()
.Where(sp => sp.ViolationReportId == result.Id)
.ToListAsync();
return new
{
ViolationReport = new
{
result.Id,
result.Title,
result.ReportStatus,
result.PartyName,
result.PartyPhone,
result.ViolationType,
result.ProblemDescription,
result.HandlingOpinion,
result.HandlingUnit,
result.Handler,
result.HandlingTime,
result.ReportTime,
result.Reporter,
result.ReportUnit,
result.ReportUnitName,
result.Lng,
result.Lat
},
MinePoint = string.IsNullOrEmpty(result.MinePointId) ? null : new
{
result.MinePointId,
result.MinePointName,
result.CountyName,
result.MinePointLng,
result.MinePointLat
},
Vehicles = vehicles.Select(v => new
{
v.Id,
v.LicensePlate,
v.Type,
v.Name,
v.IdCard,
v.Phone,
Images = vehicleImages
.Where(img => img.VehicleId == v.Id)
.Select(img => new
{
img.Id,
img.Image,
img.Lng,
img.Lat,
img.Angle,
img.CreateTime
})
.ToList()
}).ToList(),
ScenePhotos = scenePhotos.Select(sp => new
{
sp.Id,
sp.Image,
sp.Lng,
sp.Lat,
sp.Angle,
sp.CreateTime
}).ToList()
};
}
}
@ -97,16 +283,23 @@ namespace OpenAuth.App
/// 删除
/// </summary>
/// <param name="ids"></param>
public async Task<Response<bool>> Delete(List<MiViolationReport> models)
public async Task<Response<bool>> Delete(List<string> ids)
{
var flag = await Repository.DeleteAsync(models);
return new Response<bool>
using (var uow = base.UnitWork.CreateContext())
{
Result = flag,
Message = flag == true ? "success" : "error"
};
await uow.MiViolationReport.UpdateSetColumnsTrueAsync(a => new MiViolationReport
{
IsDelete = true
}, a => ids.Contains(a.Id));
var flag=uow.Commit();
return new Response<bool>
{
Result = flag,
Message = flag ? "success" : "error"
};
}
}
/// <summary>
@ -144,14 +337,23 @@ namespace OpenAuth.App
}
}
/// <summary>
/// 上报违法
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<Response<bool>> Report(MiViolationReportRequest request)
{
using (var uwo = UnitWork.CreateContext())
{
var user=_auth.GetCurrentUser();
//上报信息
var model = request.MapTo<MiViolationReport>();
model.Id = Guid.NewGuid().ToString();
model.Status = 0;
model.ReportTime = DateTime.Now;
model.Reporter=user.User.Id.ToString();
model.IsDelete = false;
//现场照片
var photos = request.SencePhotos.MapToList<MiScenePhoto>();
@ -159,6 +361,7 @@ namespace OpenAuth.App
{
a.Id = Guid.NewGuid().ToString();
a.ViolationReportId = model.Id;
a.CreateTime = DateTime.Now;
});
var vehicleList = new List<MiVehicle>();
@ -169,6 +372,7 @@ namespace OpenAuth.App
var vehicle = item.MapTo<MiVehicle>();
vehicle.Id = Guid.NewGuid().ToString();
vehicle.ViolationReportId = model.Id;
vehicle.CreateTime=DateTime.Now;
//车辆图片
var images = item.VehicleImages.MapToList<MiVehicleImage>();
@ -178,6 +382,7 @@ namespace OpenAuth.App
a.ViolationReportId = model.Id;
a.ParkingId = model.ParkingId;
a.VehicleId = vehicle.Id;
a.CreateTime = DateTime.Now;
vehicleImageList.Add(a);
});
@ -213,7 +418,8 @@ namespace OpenAuth.App
{
HandlingOpinion = info.HandlingOpinion,
HandlingTime = DateTime.Now,
HandlingUnit = org.Id.ToString()
HandlingUnit = org.Id.ToString(),
Status=1
}).Where(a => a.Id == info.Id).ExecuteCommandAsync();
return new Response<bool>
@ -222,8 +428,5 @@ namespace OpenAuth.App
Message = count > 0 ? "success" : "error"
};
}
}
}

View File

@ -33,7 +33,7 @@ namespace OpenAuth.App.ServiceApp.Request
/// Default:
/// Nullable:True
/// </summary>
public string ViolationType { get; set; }
public short? ViolationType { get; set; }
/// <summary>
/// Desc:问题描述

View File

@ -0,0 +1,33 @@
using OpenAuth.App.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenAuth.App.ServiceApp.MiManager.Request
{
public class MiviolationReq: PageReq
{
/// <summary>
/// 状态(0待处理1已处理2已开单提车3已审核4已提车)
/// </summary>
public short? status { get; set; }
/// <summary>
/// 盗采点名称
/// </summary>
public string pointname { get; set; }
/// <summary>
/// 违法类型
/// </summary>
public short? viotype { get; set; }
/// <summary>
/// 上报开始时间
/// </summary>
public DateTime? begindate { get; set; }
/// <summary>
/// 上报结束时间
/// </summary>
public DateTime? enddate { get; set; }
}
}

View File

@ -17,15 +17,31 @@ namespace OpenAuth.App.ServiceApp.MiManager.Request
/// 图片
/// </summary>
public string Image { get; set; }
public string Lng { get; set; }
public string Lat { get; set; }
/// <summary>
/// 角度
/// </summary>
public string Angle { get; set; }
/// Desc:经度
/// Default:
/// Nullable:True
/// </summary>
public decimal? Lng { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public string CreateTime { get; set; }
/// Desc:纬度
/// Default:
/// Nullable:True
/// </summary>
public decimal? Lat { get; set; }
/// <summary>
/// Desc:拍摄角度
/// Default:
/// Nullable:True
/// </summary>
public decimal? Angle { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:DateTime.Now
/// Nullable:True
/// </summary>
public DateTime? CreateTime { get; set; }
}
}

View File

@ -57,7 +57,7 @@ namespace OpenAuth.Repository.Domain
/// Default:
/// Nullable:True
/// </summary>
public string ViolationType { get; set; }
public short? ViolationType { get; set; }
/// <summary>
/// Desc:问题描述
@ -140,5 +140,7 @@ namespace OpenAuth.Repository.Domain
/// </summary>
public string ReportUnit { get; set; }
public bool? IsDelete { get; set; }
}
}

View File

@ -35,7 +35,7 @@ namespace OpenAuth.WebApi.Controllers
/// 分页
/// </summary>
[HttpGet]
public async Task<Response<PageInfo<List<MiViolationReport>>>> LoadAllPage([FromQuery] PageReq request)
public async Task<Response<PageInfo<List<dynamic>>>> LoadAllPage([FromQuery] MiviolationReq request)
{
return await _app.LoadAllPage(request);
}
@ -47,9 +47,9 @@ namespace OpenAuth.WebApi.Controllers
/// 上报详情
/// </summary>
[HttpGet]
public async Task<Response<ReportDetail>> Get(string id)
public async Task<Response<dynamic>> Get(string id)
{
var result = new Response<ReportDetail>();
var result = new Response<dynamic>();
try
{
result.Result = await _app.Get(id);
@ -117,7 +117,7 @@ namespace OpenAuth.WebApi.Controllers
/// 删除
/// </summary>
[HttpPost]
public async Task<Response<bool>> Delete([FromBody] List<MiViolationReport> models)
public async Task<Response<bool>> Delete([FromBody] List<string> models)
{
var result = new Response<bool>();
try