Commit 6bed92a5 by zxw

GetAllStates 查询条件新增createTime,移除分页

parent 9cde2969
...@@ -37,7 +37,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -37,7 +37,7 @@ namespace JunmpPoliceStation.Controllers
where c.ParentId == id where c.ParentId == id
select c; select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetClassID(t.Id))).ToList(); return query.ToList().Concat(query.ToList().SelectMany(t => GetClassID(t.Id))).ToList();
} }
// 生成树 // 生成树
private List<Node> CreateTreeNodes(List<Node> nodes, string id) private List<Node> CreateTreeNodes(List<Node> nodes, string id)
{ {
...@@ -212,10 +212,10 @@ namespace JunmpPoliceStation.Controllers ...@@ -212,10 +212,10 @@ namespace JunmpPoliceStation.Controllers
isCurrentLevel = "false"; isCurrentLevel = "false";
} }
string orgId = entity?.orgId ?? ""; string orgId = entity?.orgId ?? "";
string currentState= entity?.currentState ?? ""; string currentState = entity?.currentState ?? "";
Expression<Func<ViewEquipmentDetail, bool>> expression = t => t.Id!=null; Expression<Func<ViewEquipmentDetail, bool>> expression = t => t.Id != null;
var param = new string[] { var param = new string[] {
}; };
var stateParam = new string[] { var stateParam = new string[] {
"Eqiupment", "Eqiupment",
...@@ -242,7 +242,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -242,7 +242,7 @@ namespace JunmpPoliceStation.Controllers
dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgId))).ToList(); dataList = dataList.ToList().Concat(ListEq.Where(c => c.Id.Equals(orgId))).ToList();
var orgNewList = _unitOfWork.OrganizationRepository.GetList(expressionOrg).Select(p => p.Id); var orgNewList = _unitOfWork.OrganizationRepository.GetList(expressionOrg).Select(p => p.Id);
expression = LambdaExtensions.AndAlso(expression, t => dataList.Select(c => c.Id).Contains(t.OrgId) ); expression = LambdaExtensions.AndAlso(expression, t => dataList.Select(c => c.Id).Contains(t.OrgId));
} }
if (!string.IsNullOrEmpty(currentState)) if (!string.IsNullOrEmpty(currentState))
{ {
...@@ -258,41 +258,43 @@ namespace JunmpPoliceStation.Controllers ...@@ -258,41 +258,43 @@ namespace JunmpPoliceStation.Controllers
expression = expression.AndAlso(t => t.UpdateTime >= DateTime.Parse(updateTime)); expression = expression.AndAlso(t => t.UpdateTime >= DateTime.Parse(updateTime));
} }
var allState = _unitOfWork.EquipmentStateRepository.GetList(p => !string.IsNullOrEmpty(p.TransferId) && !string.IsNullOrEmpty(p.Eqiupment.Epc),null,false, stateParam).ToList(); var allState = _unitOfWork.EquipmentStateRepository.GetList(p => !string.IsNullOrEmpty(p.TransferId) && !string.IsNullOrEmpty(p.Eqiupment.Epc), null, false, stateParam).ToList();
var equipments = _unitOfWork.ViewEquipmentDetailRepository.GetPageAsync(expression, "-CreateTime", page, size, false, param).Result; var equipments = _unitOfWork.ViewEquipmentDetailRepository.GetPageAsync(expression, "-CreateTime", page, size, false, param).Result;
var data = equipments?.content.Select(t => new var data = equipments?.content.Select(t => new
{ {
t.Id, t.Id,
t.OrgId, t.OrgId,
t.OrgName, t.OrgName,
targetWarehouseId = t.CurrentState == 1 ? allState.Where(p => p.EqiupmentId.Equals(t.Id)).OrderByDescending(p => p.CreateTime).First().Transfer?.Reality?.ReceiveWarehouse.Id : "", targetWarehouseId = t.CurrentState == 1 ? allState.Where(p => p.EqiupmentId.Equals(t.Id)).OrderByDescending(p => p.CreateTime).First().Transfer?.Reality?.ReceiveWarehouse.Id : "",
targetWarehouseName = t.CurrentState == 1 ? allState.Where(p => p.EqiupmentId.Equals(t.Id)).OrderByDescending(p => p.CreateTime).First().Transfer?.Reality?.ReceiveWarehouse?.Name : "", targetWarehouseName = t.CurrentState == 1 ? allState.Where(p => p.EqiupmentId.Equals(t.Id)).OrderByDescending(p => p.CreateTime).First().Transfer?.Reality?.ReceiveWarehouse?.Name : "",
scrpTime=t.CurrentState==6? allState.Where(p => p.EqiupmentId.Equals(t.Id)).FirstOrDefault()?.CreateTime.ToString() : "", scrpTime = t.CurrentState == 6 ? allState.Where(p => p.EqiupmentId.Equals(t.Id)).FirstOrDefault()?.CreateTime.ToString() : "",
t.WarehouseId, t.WarehouseId,
t.WarehouseName, t.WarehouseName,
t.CurrentState, t.CurrentState,
t.Epc, t.Epc,
t.EquipmentName, t.EquipmentName,
t.EquipmentCode, t.EquipmentCode,
t.SizeName, t.SizeName,
t.EquipmentSizecode, t.EquipmentSizecode,
t.SupplierName, t.SupplierName,
location=string.IsNullOrEmpty(t.ShelfName)?"": t.ShelfName+(t.ShelfRow==null?"":t.ShelfRow + "行")+ (t.ShelfColumn == null ? "" : t.ShelfColumn + "列") + (t.ShelfRange == null ? "" : t.ShelfRange + "排"), location = string.IsNullOrEmpty(t.ShelfName) ? "" : t.ShelfName + (t.ShelfRow == null ? "" : t.ShelfRow + "行") + (t.ShelfColumn == null ? "" : t.ShelfColumn + "列") + (t.ShelfRange == null ? "" : t.ShelfRange + "排"),
t.SafeLevel, t.SafeLevel,
fixCount=t.FixCount==null?0:t.FixCount, fixCount = t.FixCount == null ? 0 : t.FixCount,
useCount = t.UseCount == null ? 0 : t.UseCount, useCount = t.UseCount == null ? 0 : t.UseCount,
t.WarrantyCycle, t.WarrantyCycle,
t.RepairCycle, t.RepairCycle,
t.Price, t.Price,
t.ProductTime, t.ProductTime,
t.FindCode, t.FindCode,
t.AreaName, t.AreaName,
DetailName= t.Name, DetailName = t.Name,
typeOne= t.ParentName, typeOne = t.ParentName,
typeTwo= t.TypeName, typeTwo = t.TypeName,
typeThree= t.Name, typeThree = t.Name,
createTime = t.CreateTime,
updateTime = t.UpdateTime
}); });
var content = new var content = new
{ {
...@@ -327,8 +329,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -327,8 +329,7 @@ namespace JunmpPoliceStation.Controllers
/// { /// {
/// "orgId":"组织机构ID", /// "orgId":"组织机构ID",
/// "isCurrentLevel":"true"本级,"false"本级及下级 /// "isCurrentLevel":"true"本级,"false"本级及下级
/// "page":"页数", /// "createTime":"创建时间"
/// "size":"当页数量",
/// } /// }
/// ///
/// </remarks> /// </remarks>
...@@ -345,12 +346,13 @@ namespace JunmpPoliceStation.Controllers ...@@ -345,12 +346,13 @@ namespace JunmpPoliceStation.Controllers
if (jdata != null) if (jdata != null)
{ {
var entity = JsonManager.GetJsonEntity(jdata); var entity = JsonManager.GetJsonEntity(jdata);
int.TryParse(entity.page, out int page); //int.TryParse(entity.page, out int page);
int.TryParse(entity.size, out int size); //int.TryParse(entity.size, out int size);
if (size == 0) //if (size == 0)
{ //{
size = 10; // size = 10;
} //}
bool bCreateTime = DateTime.TryParse(entity.createTime, out DateTime createTime);
string isCurrentLevel = entity.isCurrentLevel; string isCurrentLevel = entity.isCurrentLevel;
if (string.IsNullOrEmpty(isCurrentLevel)) if (string.IsNullOrEmpty(isCurrentLevel))
{ {
...@@ -364,7 +366,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -364,7 +366,7 @@ namespace JunmpPoliceStation.Controllers
Expression<Func<BaseJpOrganization, bool>> expressionOrg = t => t.State == 1; Expression<Func<BaseJpOrganization, bool>> expressionOrg = t => t.State == 1;
ListEq = _unitOfWork.OrganizationRepository.GetList(expressionOrg, t => t.Code).ToList(); ListEq = _unitOfWork.OrganizationRepository.GetList(expressionOrg, t => t.Code).ToList();
if (isCurrentLevel.Equals("true")) if (isCurrentLevel.Equals("true"))
{ {
expression = LambdaExtensions.AndAlso(expression, t => t.OrgId.Equals(orgId)); expression = LambdaExtensions.AndAlso(expression, t => t.OrgId.Equals(orgId));
...@@ -379,9 +381,20 @@ namespace JunmpPoliceStation.Controllers ...@@ -379,9 +381,20 @@ namespace JunmpPoliceStation.Controllers
var orgNewList = _unitOfWork.OrganizationRepository.GetList(expressionOrg).Select(p => p.Id); var orgNewList = _unitOfWork.OrganizationRepository.GetList(expressionOrg).Select(p => p.Id);
expression = LambdaExtensions.AndAlso(expression, t => dataList.Select(c => c.Id).Contains(t.OrgId)); expression = LambdaExtensions.AndAlso(expression, t => dataList.Select(c => c.Id).Contains(t.OrgId));
} }
var equipments = _unitOfWork.ViewStateRepository.GetPageAsync(expression, "-CreateTime", page, size, false, param).Result;
var data = equipments?.content.Select(t => new if (bCreateTime)
{
expression = LambdaExtensions.AndAlso(expression, t => t.CreateTime >= createTime);
}
else
{
//不传默认返回7天内数据
expression = LambdaExtensions.AndAlso(expression, t => t.CreateTime >= DateTime.Now.AddDays(-7));
}
var equipments = _unitOfWork.ViewStateRepository.GetList(expression, x => x.CreateTime, false, param).ToList();
var data = equipments?.Select(t => new
{ {
t.OutInState, t.OutInState,
...@@ -395,7 +408,7 @@ namespace JunmpPoliceStation.Controllers ...@@ -395,7 +408,7 @@ namespace JunmpPoliceStation.Controllers
}); });
var content = new var content = new
{ {
equipments?.totalElements, equipments.Count,
content = data content = data
}; };
return JsonManager.ReturnSuccessResponse(content, true); return JsonManager.ReturnSuccessResponse(content, true);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论