2024-11-14 10:43:15 +08:00
|
|
|
using Infrastructure;
|
2024-11-14 16:06:41 +08:00
|
|
|
using Infrastructure.Helpers;
|
2024-11-14 10:43:15 +08:00
|
|
|
using OpenAuth.App.BaseApp.Base;
|
|
|
|
|
using OpenAuth.App.Interface;
|
2024-11-14 14:41:13 +08:00
|
|
|
using OpenAuth.App.ServiceApp.Achievement.Request;
|
2024-11-14 10:43:15 +08:00
|
|
|
using OpenAuth.Repository;
|
|
|
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.App.ServiceApp.Achievement;
|
|
|
|
|
|
|
|
|
|
public class InsTifApp : SqlSugarBaseApp<InsTif, SugarDbContext>
|
|
|
|
|
{
|
|
|
|
|
public InsTifApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<InsTif> repository,
|
|
|
|
|
IAuth auth) : base(unitWork, repository, auth)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-14 14:41:13 +08:00
|
|
|
public async Task<PageInfo<List<InsTif>>> Load(InsTifQuery req)
|
2024-11-14 10:43:15 +08:00
|
|
|
{
|
|
|
|
|
RefAsync<int> total = 0;
|
|
|
|
|
var result = await Repository.AsQueryable()
|
|
|
|
|
.ToPageListAsync(req.page, req.limit, total);
|
|
|
|
|
return new PageInfo<List<InsTif>>
|
|
|
|
|
{
|
|
|
|
|
Items = result,
|
|
|
|
|
Total = total
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-11-14 16:06:41 +08:00
|
|
|
|
|
|
|
|
public async Task<InsTif> GetTif(string id)
|
|
|
|
|
{
|
|
|
|
|
return await Repository.GetByIdAsync(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Response<bool>> Update()
|
|
|
|
|
{
|
|
|
|
|
var tifDir = ConfigHelper.GetConfigRoot().GetSection("Insight:TifDir").Value;
|
2024-11-14 17:00:49 +08:00
|
|
|
var files = Directory.GetFiles(tifDir, "*.tif", SearchOption.AllDirectories);
|
2024-11-14 16:06:41 +08:00
|
|
|
foreach (var tifFile in files)
|
|
|
|
|
{
|
|
|
|
|
var tifName = Path.GetFileName(tifFile);
|
2024-11-14 17:00:49 +08:00
|
|
|
var tifDate = new DirectoryInfo(tifFile).Parent?.Name;
|
2024-11-14 16:06:41 +08:00
|
|
|
if (string.IsNullOrEmpty(tifDate))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("获取不到日期目录");
|
|
|
|
|
}
|
2024-11-15 16:26:13 +08:00
|
|
|
|
2024-11-14 16:06:41 +08:00
|
|
|
var areaName = new DirectoryInfo(tifFile).Parent?.Parent?.Name;
|
|
|
|
|
var currentTime = DateTime.Now;
|
|
|
|
|
var tifRecord = new InsTif
|
|
|
|
|
{
|
|
|
|
|
Id = Guid.NewGuid().ToString(),
|
|
|
|
|
TifName = tifName,
|
|
|
|
|
TifPath = tifFile,
|
|
|
|
|
Remark = "备注",
|
|
|
|
|
TifDate = DateTime.ParseExact(tifDate, "yyyy年MM月", null),
|
|
|
|
|
CreateTime = currentTime,
|
|
|
|
|
UpdateTime = currentTime,
|
|
|
|
|
AreaName = areaName,
|
|
|
|
|
PlotName = "地块",
|
|
|
|
|
AreaId = "areaid",
|
|
|
|
|
AreaNum = Convert.ToDecimal(0)
|
|
|
|
|
};
|
|
|
|
|
await Repository.InsertAsync(tifRecord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Response<bool>
|
|
|
|
|
{
|
|
|
|
|
Result = true
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-11-15 16:26:13 +08:00
|
|
|
|
|
|
|
|
public async Task<Response<bool>> Insert(IEnumerable<InsTifInsert> req)
|
|
|
|
|
{
|
|
|
|
|
var tifList = req.MapToList<InsTif>();
|
|
|
|
|
foreach (var tif in tifList)
|
|
|
|
|
{
|
|
|
|
|
tif.Id = Guid.NewGuid().ToString();
|
|
|
|
|
tif.CreateTime = DateTime.Now;
|
|
|
|
|
tif.UpdateTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
await Repository.InsertRangeAsync(tifList);
|
|
|
|
|
return new Response<bool>
|
|
|
|
|
{
|
|
|
|
|
Result = true
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-11-14 10:43:15 +08:00
|
|
|
}
|