前台页面整体保存功能完善和后台读取社区列表和读取幢列表的功能开发
This commit is contained in:
@@ -27,6 +27,7 @@ using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.HPSF;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Vote.Services.Dto;
|
||||
using Vote.Services.Entities;
|
||||
|
||||
@@ -65,23 +66,132 @@ namespace Vote.Services.ApiController
|
||||
rep_SysFile = _rep_SysFile;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("query/{id}")]
|
||||
public async Task<dynamic> Query(string id)
|
||||
/// 导出Excel
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
[Route("export_excel")]
|
||||
public async Task<dynamic> ExportExcel(NbzcGetListInput args)
|
||||
{
|
||||
var entity = await repoutside_wall.AsQueryable().FirstAsync(a => a.communityId == id);
|
||||
if (entity != null)
|
||||
//var list = await repoutside_wall.AsQueryable().Where(a => !a.IsDeleted).OrderByDescending(a => a.CreatedTime).ToListAsync();
|
||||
//var filepath = Tools.ExcelHelper.WriteExcelNingBoZhiChun(list);
|
||||
//return new FileStreamResult(new FileStream(filepath, FileMode.Open), "application/octet-stream") { FileDownloadName = filepath };
|
||||
return 1;
|
||||
}
|
||||
[HttpPost("querybuildings")]
|
||||
public async Task<dynamic> QueryBuildings(OutsideWallQueryInput args)
|
||||
{
|
||||
var entity = await repoutside_wall_building.AsQueryable().LeftJoin<outside_wall>((a, b) => a.outsidewallId == b.Id)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.communityId), (a, b) => b.communityId == args.communityId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.submitCode), (a, b) => b.submitCode == args.submitCode)
|
||||
.Select((a, b) => new OutsideWallBuildingsOutput
|
||||
{
|
||||
communityId = b.Id,
|
||||
createtime = b.createtime,
|
||||
communityName = b.communityName,
|
||||
submitCode = b.submitCode,
|
||||
Address = a.Address,
|
||||
BuildingId = a.BuildingId,
|
||||
BuildingName = a.BuildingName,
|
||||
BuildingUnit = a.BuildingUnit,
|
||||
ConstructionUnit = a.ConstructionUnit,
|
||||
curwallproblemother = a.curwallproblemother,
|
||||
curwallproblems = a.curwallproblems,
|
||||
DesingerUnit = a.DesingerUnit,
|
||||
diaoluowu = a.diaoluowu,
|
||||
firstproblemdate = a.firstproblemdate,
|
||||
MonitorUnit = a.MonitorUnit,
|
||||
Households = a.Households,
|
||||
Id = a.Id,
|
||||
LevelCount = a.LevelCount,
|
||||
outsidewallId = a.outsidewallId,
|
||||
problemfanwei = a.problemfanwei,
|
||||
problemfrequency = a.problemfanwei,
|
||||
problemheight = a.problemheight,
|
||||
problemseason = a.problemseason,
|
||||
wallproblemsfirst = a.wallproblemsfirst,
|
||||
wallproblemtoward = a.wallproblemtoward,
|
||||
WuYeUnit = a.WuYeUnit
|
||||
})
|
||||
.WithCache(60 * 60).ToListAsync();
|
||||
var ids = entity.Select(a => a.Id).ToArray();
|
||||
var photos = await repoutside_wall_building_photo.AsQueryable()
|
||||
.Where(a => ids.Contains(a.outsidewallBuildingId)).WithCache(60 * 60).ToListAsync();
|
||||
foreach (var building in entity)
|
||||
{
|
||||
var outside_wall_photos = await repoutside_wall_photo.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
entity.outside_wall_photos = outside_wall_photos;
|
||||
var outside_wall_buildings = await repoutside_wall_building.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
entity.outside_wall_buildings = outside_wall_buildings;
|
||||
return entity;
|
||||
var _ps = photos.Where(a => a.outsidewallBuildingId == building.Id).OrderBy(a => a.toward).ToList();
|
||||
var _ps2 = new List<outside_wall_building_photo>();
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "东"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "西"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "南"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "北"));
|
||||
building.outside_wall_building_photos = _ps2;
|
||||
}
|
||||
return null;
|
||||
//var result = entity.Adapt<List<OutsideWallResultOutput>>();
|
||||
//if (entity != null)
|
||||
//{
|
||||
// var outside_wall_photos = await repoutside_wall_photo.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_photos = outside_wall_photos;
|
||||
// var outside_wall_buildings = await repoutside_wall_building.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_buildings = outside_wall_buildings;
|
||||
// return entity;
|
||||
//}
|
||||
return entity;
|
||||
}
|
||||
[HttpPost("query")]
|
||||
public async Task<dynamic> Query(OutsideWallQueryInput args)
|
||||
{
|
||||
//repoutside_wall.Ado.SqlQuery<OutsideWallResultOutput>("")
|
||||
var entity = await repoutside_wall.AsQueryable()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.communityId), a => a.communityId == args.communityId)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(args.submitCode), a => a.submitCode == args.submitCode)
|
||||
.WithCache(60 * 60).ToListAsync();
|
||||
var ids = entity.Select(a => a.Id).ToArray();
|
||||
var photos = await repoutside_wall_photo.AsQueryable()
|
||||
.Where(a => ids.Contains(a.outsidewallId)).WithCache(60 * 60).ToListAsync();
|
||||
foreach (var wall in entity)
|
||||
{
|
||||
wall.outside_wall_photos = photos.Where(a => a.outsidewallId == wall.Id).ToList();
|
||||
}
|
||||
|
||||
//var result = entity.Adapt<List<OutsideWallResultOutput>>();
|
||||
//if (entity != null)
|
||||
//{
|
||||
// var outside_wall_photos = await repoutside_wall_photo.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_photos = outside_wall_photos;
|
||||
// var outside_wall_buildings = await repoutside_wall_building.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_buildings = outside_wall_buildings;
|
||||
// return entity;
|
||||
//}
|
||||
return entity;
|
||||
}
|
||||
[HttpPost("querybuilding")]
|
||||
public async Task<dynamic> QueryBuilding(OutsideWallQueryBuildingInput args)
|
||||
{
|
||||
var entity = await repoutside_wall_building.AsQueryable().Where(a => a.outsidewallId == args.wallId).WithCache(60 * 60).ToListAsync();
|
||||
var ids = entity.Select(a => a.Id).ToArray();
|
||||
var photos = await repoutside_wall_building_photo.AsQueryable().Where(a => ids.Contains(a.outsidewallBuildingId)).WithCache(60 * 60).ToListAsync();
|
||||
foreach (var building in entity)
|
||||
{
|
||||
var _ps = photos.Where(a => a.outsidewallBuildingId == building.Id).OrderBy(a => a.toward).ToList();
|
||||
var _ps2 = new List<outside_wall_building_photo>();
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "东"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "西"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "南"));
|
||||
_ps2.AddRange(_ps.Where(a => a.toward == "北"));
|
||||
building.outside_wall_building_photos = _ps2;
|
||||
}
|
||||
//var result = entity.Adapt<List<OutsideWallResultOutput>>();
|
||||
//if (entity != null)
|
||||
//{
|
||||
// var outside_wall_photos = await repoutside_wall_photo.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_photos = outside_wall_photos;
|
||||
// var outside_wall_buildings = await repoutside_wall_building.AsQueryable().Where(a => a.outsidewallId == entity.Id).ToListAsync();
|
||||
// entity.outside_wall_buildings = outside_wall_buildings;
|
||||
// return entity;
|
||||
//}
|
||||
return entity;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取三居系统中的社区
|
||||
@@ -234,6 +344,28 @@ namespace Vote.Services.ApiController
|
||||
|
||||
return fileId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成随机字母与数字
|
||||
/// </summary>
|
||||
/// <param name="Length">生成长度</param>
|
||||
/// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
|
||||
public string GetCode(int Length, bool Sleep)
|
||||
{
|
||||
if (Sleep) System.Threading.Thread.Sleep(3);
|
||||
char[] Pattern = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
|
||||
string result = "";
|
||||
int n = Pattern.Length;
|
||||
System.Random random = new Random(~unchecked((int)DateTime.Now.Ticks));
|
||||
for (int i = 0; i < Length; i++)
|
||||
{
|
||||
int rnd = random.Next(0, n);
|
||||
result += Pattern[rnd];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交
|
||||
/// </summary>
|
||||
@@ -245,8 +377,10 @@ namespace Vote.Services.ApiController
|
||||
{
|
||||
try
|
||||
{
|
||||
string code = GetCode(6, true);
|
||||
repoutside_wall.Ado.BeginTran();
|
||||
var wall = args.Adapt<outside_wall>();
|
||||
wall.submitCode = code;
|
||||
wall.Id = Guid.NewGuid().ToString();
|
||||
wall.createtime = DateTime.Now;
|
||||
wall.isdeleted = 0;
|
||||
@@ -264,6 +398,8 @@ namespace Vote.Services.ApiController
|
||||
}
|
||||
foreach (var item in args.buildings)
|
||||
{
|
||||
if (!item.curwallproblems.Any())
|
||||
continue;
|
||||
var build = item.Adapt<outside_wall_building>();
|
||||
build.Id = Guid.NewGuid().ToString();
|
||||
build.outsidewallId = wall.Id;
|
||||
@@ -284,7 +420,7 @@ namespace Vote.Services.ApiController
|
||||
}
|
||||
}
|
||||
repoutside_wall.Ado.CommitTran();
|
||||
return "提交成功";
|
||||
return code;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user