Commit 6bed92a5 by zxw

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

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