feat(报工): 添加报工数据导出功能
- 在IProReportworkService接口中添加导出方法定义 - 实现报工数据导出服务逻辑 - 添加导出API接口 - 为ProReportworkDto添加ExcelColumn属性用于导出映射 - 调整查询参数类型为可空类型以支持更灵活的查询
This commit is contained in:
@@ -12,13 +12,13 @@ namespace DOAN.Service.MES.product.IService
|
||||
{
|
||||
List<BaseWorkRoute> GetRoute();
|
||||
|
||||
/// <summary>
|
||||
/// 查询全部工序
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<BaseWorkProcesses> GetBaseWorkProcesses();
|
||||
/// <summary>
|
||||
/// 查询全部工序
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<BaseWorkProcesses> GetBaseWorkProcesses();
|
||||
|
||||
List<BaseWorkProcesses> GetProcessByRoute(int route_id);
|
||||
List<BaseWorkProcesses> GetProcessByRoute(int route_id);
|
||||
PagedInfo<ProReportworkDto> GetList(ProReportworkQueryDto parm);
|
||||
|
||||
ProReportwork01 GetInfo(string Id);
|
||||
@@ -27,6 +27,19 @@ namespace DOAN.Service.MES.product.IService
|
||||
ProReportwork01 AddProReportwork(ProReportwork01 parm);
|
||||
int UpdateProReportwork(ProReportwork01 parm);
|
||||
|
||||
/// <summary>
|
||||
/// 导出报工数据
|
||||
/// </summary>
|
||||
/// <param name="extportDate"></param>
|
||||
/// <returns></returns>
|
||||
List<ProReportworkDto> ReportWorkExport(DateTime extportDate);
|
||||
|
||||
/// <summary>
|
||||
/// 导出报工数据(带查询参数)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
List<ProReportworkDto> GetExportList(ProReportworkQueryDto parm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public class ProReportworkService : BaseService<ProReportwork01>, IProReportwork
|
||||
(q, w, wo) =>
|
||||
new ProReportworkDto
|
||||
{
|
||||
PlanNum = wo.PlanNum,
|
||||
ProcessName = w.Name,
|
||||
FeedOrder = wo.FeedOrder,
|
||||
ProductionName = wo.productionName,
|
||||
@@ -137,8 +138,8 @@ public class ProReportworkService : BaseService<ProReportwork01>, IProReportwork
|
||||
)
|
||||
//.AndIF(!string.IsNullOrEmpty(parm.Worker), it => it.Worker.Contains(parm.Worker))
|
||||
.AndIF(!string.IsNullOrEmpty(parm.Worker), it => it.Worker.Contains(parm.Worker))
|
||||
.AndIF(parm.RouteId > 0, it => it.RouteId == parm.RouteId)
|
||||
.AndIF(parm.ProcessId > 0, it => it.ProcessId == parm.ProcessId)
|
||||
.AndIF(parm.RouteId.HasValue && parm.RouteId > 0, it => it.RouteId == parm.RouteId)
|
||||
.AndIF(parm.ProcessId.HasValue && parm.ProcessId > 0, it => it.ProcessId == parm.ProcessId)
|
||||
.AndIF(
|
||||
parm.JobDateTime != null && parm.JobDateTime[0] > DateTime.MinValue,
|
||||
it => it.JobDateTime >= parm.JobDateTime[0]
|
||||
@@ -150,4 +151,64 @@ public class ProReportworkService : BaseService<ProReportwork01>, IProReportwork
|
||||
|
||||
return predicate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行报工数据查询
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
private List<ProReportworkDto> ExecuteExportQuery(ISugarQueryable<ProReportwork01> query)
|
||||
{
|
||||
var response = Context
|
||||
.Queryable(query)
|
||||
.LeftJoin<BaseWorkProcesses>((q, w) => q.ProcessId == w.Id)
|
||||
.LeftJoin<ProWorkorder>((q, w, wo) => q.Workorder == wo.Workorder)
|
||||
.OrderBy((q, w, wo) => new { q.Workorder, w.Id })
|
||||
.Select(
|
||||
(q, w, wo) =>
|
||||
new ProReportworkDto
|
||||
{
|
||||
PlanNum = wo.PlanNum,
|
||||
ProcessName = w.Name,
|
||||
FeedOrder = wo.FeedOrder,
|
||||
ProductionName = wo.productionName,
|
||||
ProductionCode = wo.productionCode,
|
||||
MaterialCode = wo.MaterialCode,
|
||||
MaterialName = wo.MaterialName,
|
||||
StoveCode = wo.StoveCode,
|
||||
},
|
||||
true
|
||||
)
|
||||
.ToList();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出报工数据
|
||||
/// </summary>
|
||||
/// <param name="extportDate"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProReportworkDto> ReportWorkExport(DateTime extportDate)
|
||||
{
|
||||
var startDate = extportDate.Date;
|
||||
var endDate = startDate.AddDays(1);
|
||||
|
||||
var query = Queryable()
|
||||
.Where(it => it.JobDateTime >= startDate && it.JobDateTime < endDate);
|
||||
|
||||
return ExecuteExportQuery(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出报工数据(带查询参数)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public List<ProReportworkDto> GetExportList(ProReportworkQueryDto parm)
|
||||
{
|
||||
var predicate = QueryExp(parm);
|
||||
var query = Queryable().Where(predicate.ToExpression());
|
||||
return ExecuteExportQuery(query);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user