将工单数量字段从可空类型改为非可空类型并添加默认值 添加成品入库数量字段并完善相关业务逻辑 修复出货失败时的错误响应 完善撤销入库/出库操作时的工单数量调整 增加出货数量与成品入库数量的校验
664 lines
26 KiB
C#
664 lines
26 KiB
C#
using DOAN.Model.BZFM;
|
|
using DOAN.Model.BZFM.Dto;
|
|
using DOAN.Model.MES.base_;
|
|
using DOAN.Model.MES.base_.Dto;
|
|
using DOAN.Model.MES.order;
|
|
using DOAN.Model.MES.product;
|
|
using DOAN.Model.Mobile.ReportFlow.Dto;
|
|
using DOAN.Model.System;
|
|
using DOAN.Repository;
|
|
using DOAN.Service.BZFM;
|
|
using DOAN.Service.Mobile.IService;
|
|
using Infrastructure.Attribute;
|
|
using Mapster;
|
|
|
|
namespace DOAN.Service.Mobile;
|
|
|
|
/// <summary>
|
|
/// 广告管理Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IReportFlowService), ServiceLifetime = LifeTime.Transient)]
|
|
public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowService
|
|
{
|
|
public ProWorkorder GetWorkOrderDetail(string workorder)
|
|
{
|
|
return Context.Queryable<ProWorkorder>().Where(x => x.Workorder == workorder).First();
|
|
}
|
|
|
|
public List<ProWorkorder> GetWorkOrdersByDate(DateTime startDate, DateTime endDate)
|
|
{
|
|
return Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.WorkorderDate >= startDate && it.WorkorderDate <= endDate)
|
|
.Where(it => it.PlanNum > 0)
|
|
.ToList();
|
|
}
|
|
|
|
public ProReportwork01 GetProcessReportWorkDetail(string workorder, int process)
|
|
{
|
|
return Context
|
|
.Queryable<ProReportwork01>()
|
|
.Where(x => x.Workorder == workorder && x.ProcessId == process)
|
|
.First();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 首工序报工(领料报工)
|
|
/// </summary>
|
|
/// <param name="workorder"></param>
|
|
/// <param name="processId"></param>
|
|
/// <param name="finish_num"></param>
|
|
/// <param name="stove_code"></param>
|
|
/// <param name="feed_order"></param>
|
|
/// <param name="Worker"></param>
|
|
/// <param name="workorderRaw">原材料工单号</param>
|
|
/// <param name="inventoryId">领料库存id</param>
|
|
/// <returns></returns>
|
|
public bool FeedProcessReportwork(
|
|
string workorder,
|
|
int processId,
|
|
int finish_num,
|
|
string stove_code,
|
|
string feed_order,
|
|
string Worker,
|
|
string workorderRaw = "",
|
|
int inventoryId = -1
|
|
)
|
|
{
|
|
try
|
|
{
|
|
int result = 0;
|
|
|
|
ProWorkorder proWorkorder = Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.First();
|
|
if (proWorkorder == null)
|
|
{
|
|
throw new Exception($"工单不存在,原材料无法出库:{workorder}");
|
|
}
|
|
|
|
int routeId = Context
|
|
.Queryable<BaseWorkRoute>()
|
|
.Where(it => it.Code == proWorkorder.RouteCode)
|
|
.Select(it => it.Id)
|
|
.First();
|
|
|
|
// 是否首次提交
|
|
bool Exist = Context
|
|
.Queryable<ProReportwork01>()
|
|
.Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
|
.Any();
|
|
|
|
string NickName = Context
|
|
.Queryable<SysUser>()
|
|
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
|
.Select(it => it.NickName)
|
|
.First();
|
|
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
|
|
|
Context.Ado.BeginTran();
|
|
if (Exist)
|
|
{
|
|
result = Context
|
|
.Updateable<ProReportwork01>()
|
|
.Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
|
.SetColumns(it => it.FinishNum == finish_num)
|
|
.SetColumns(it => it.Worker == Worker)
|
|
.SetColumns(it => it.JobDateTime == DateTime.Now)
|
|
.SetColumns(it => it.RouteId == routeId)
|
|
.SetColumns(it => it.UpdatedBy == Worker)
|
|
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
|
.ExecuteCommand();
|
|
Context
|
|
.Updateable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.SetColumns(it => it.StoveCode == stove_code)
|
|
.SetColumns(it => it.FeedOrder == feed_order)
|
|
.ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
ProReportwork01 proReportwork01 = new ProReportwork01();
|
|
proReportwork01.Id = XueHua;
|
|
proReportwork01.Workorder = workorder;
|
|
proReportwork01.ProcessId = processId;
|
|
proReportwork01.FinishNum = finish_num;
|
|
proReportwork01.RouteId = routeId;
|
|
proReportwork01.Worker = Worker;
|
|
proReportwork01.JobDateTime = DateTime.Now;
|
|
proReportwork01.CreatedBy = Worker;
|
|
proReportwork01.CreatedTime = DateTime.Now;
|
|
result = Context.Insertable(proReportwork01).ExecuteCommand();
|
|
Context
|
|
.Updateable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.SetColumns(it => it.StoveCode == stove_code)
|
|
.SetColumns(it => it.FeedOrder == feed_order)
|
|
.ExecuteCommand();
|
|
}
|
|
//XXX 领料出库操作(上边代码先不动)
|
|
MmRecordOutbound outRecordbound = Context
|
|
.Queryable<MmRecordOutbound>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.Where(it => it.TransactionType == "领料出库")
|
|
.Where(it => it.Remarks != "已撤销")
|
|
.First();
|
|
|
|
if (outRecordbound == null || proWorkorder.RouteCode == "10")
|
|
{
|
|
// 根据原材料工单领料的
|
|
if (!string.IsNullOrEmpty(workorderRaw))
|
|
{
|
|
// 需要实现累计领料,超出数量需要提示用户
|
|
ProWorkorder proWorkorderRawInfo = Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorderRaw)
|
|
.First();
|
|
if (proWorkorderRawInfo == null)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception($"原材料工单不存在,无法出库:{workorderRaw}");
|
|
}
|
|
MmRecordInbound inboundRecord = Context
|
|
.Queryable<MmRecordInbound>()
|
|
.Where(it => it.Workorder == workorderRaw)
|
|
.Where(it => it.TransactionType == "生产入库")
|
|
.Where(it => it.Remarks != "已撤销")
|
|
.First();
|
|
if (inboundRecord == null)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception($"原材料工单无成品入库记录:{workorderRaw}");
|
|
}
|
|
int newShipmentNum = (proWorkorderRawInfo.ShipmentNum) + finish_num;
|
|
if (newShipmentNum > inboundRecord.Quantity)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(
|
|
$"领料数量超出原始工单成品入库数量,请检查:{workorderRaw}"
|
|
);
|
|
}
|
|
Context
|
|
.Updateable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorderRaw)
|
|
.SetColumns(it => it.ShipmentNum == newShipmentNum)
|
|
.ExecuteCommand();
|
|
inboundRecord.Remarks += $"[已领料{finish_num}]";
|
|
Context.Updateable(inboundRecord).ExecuteCommand();
|
|
}
|
|
string supplierCode = string.Empty;
|
|
if (inventoryId != -1)
|
|
{
|
|
supplierCode =
|
|
Context
|
|
.Queryable<MmInventory>()
|
|
.Where(it => it.Id == inventoryId)
|
|
.Select(it => it.SupplierCode)
|
|
.First()
|
|
?? string.Empty;
|
|
if (string.IsNullOrEmpty(supplierCode))
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception($"库存信息获取异常,请检查库存是否存在:{inventoryId}");
|
|
}
|
|
}
|
|
|
|
OutboundReceiptDto revokeRecepitDto = new()
|
|
{
|
|
ReceiptType = 1,
|
|
InventoryId = inventoryId,
|
|
MaterialCode = proWorkorder.MaterialCode,
|
|
SupplierCode = supplierCode,
|
|
BatchNo = feed_order,
|
|
LocationCode = "YCL001",
|
|
WarehouseCode = "WH003",
|
|
OrderNo = proWorkorder.CustomerOrder,
|
|
Workorder = workorder,
|
|
WorkorderRaw = workorderRaw,
|
|
Operator = Worker,
|
|
Quantity = finish_num,
|
|
TransactionType = "领料出库",
|
|
Remarks = $"生产领料,领取工单号:{workorder},原材料工单号{workorderRaw}",
|
|
};
|
|
MmInventoryService mmInventoryService = new();
|
|
string createReceiptresult = mmInventoryService.CreateOutboundReceipt(
|
|
revokeRecepitDto
|
|
);
|
|
if (createReceiptresult != "ok")
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(createReceiptresult);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (outRecordbound.Quantity != finish_num)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception("修改领料数量前请先撤销已有领料出库记录!");
|
|
}
|
|
if (outRecordbound.BatchNo != feed_order)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception("修改领料号前请先撤销已有领料出库记录!");
|
|
}
|
|
}
|
|
Context.Ado.CommitTran();
|
|
return result > 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 普通工序报工
|
|
/// </summary>
|
|
/// <param name="workorder"></param>
|
|
/// <param name="process"></param>
|
|
/// <param name="finish_num"></param>
|
|
/// <param name="bad_num"></param>
|
|
/// <param name="Worker"></param>
|
|
/// <returns></returns>
|
|
public bool ProcessReportWork(
|
|
string workorder,
|
|
int process,
|
|
int finish_num,
|
|
int bad_num,
|
|
string Worker
|
|
)
|
|
{
|
|
try
|
|
{
|
|
int result = 0;
|
|
|
|
ProWorkorder proWorkorder = Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.First();
|
|
if (proWorkorder == null)
|
|
{
|
|
throw new Exception($"工单不存在,原材料无法出库:{workorder}");
|
|
}
|
|
|
|
int routeId = Context
|
|
.Queryable<BaseWorkRoute>()
|
|
.Where(it => it.Code == proWorkorder.RouteCode)
|
|
.Select(it => it.Id)
|
|
.First();
|
|
|
|
bool Exist = Context
|
|
.Queryable<ProReportwork01>()
|
|
.Where(it => it.Workorder == workorder && it.ProcessId == process)
|
|
.Any();
|
|
string NickName = Context
|
|
.Queryable<SysUser>()
|
|
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
|
.Select(it => it.NickName)
|
|
.First();
|
|
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
|
|
|
Context.Ado.BeginTran();
|
|
if (Exist)
|
|
{
|
|
result = Context
|
|
.Updateable<ProReportwork01>()
|
|
.Where(it => it.Workorder == workorder && it.ProcessId == process)
|
|
.SetColumns(it => it.FinishNum == finish_num)
|
|
.SetColumns(it => it.BadNum == bad_num)
|
|
.SetColumns(it => it.Worker == Worker)
|
|
.SetColumns(it => it.RouteId == routeId)
|
|
.SetColumns(it => it.JobDateTime == DateTime.Now)
|
|
.SetColumns(it => it.UpdatedBy == Worker)
|
|
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
|
.ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
ProReportwork01 proReportwork01 = new ProReportwork01();
|
|
proReportwork01.Id = XueHua;
|
|
proReportwork01.Workorder = workorder;
|
|
proReportwork01.ProcessId = process;
|
|
proReportwork01.FinishNum = finish_num;
|
|
proReportwork01.BadNum = bad_num;
|
|
proReportwork01.Worker = Worker;
|
|
proReportwork01.RouteId = routeId;
|
|
proReportwork01.JobDateTime = DateTime.Now;
|
|
proReportwork01.CreatedBy = Worker;
|
|
proReportwork01.CreatedTime = DateTime.Now;
|
|
result = Context.Insertable(proReportwork01).ExecuteCommand();
|
|
}
|
|
|
|
// XXX TODO 成品入库(临时使用)
|
|
string workorder_raw = workorder;
|
|
if (proWorkorder.RouteCode == "10")
|
|
{
|
|
//TODO 绑定原有工单
|
|
workorder_raw = "";
|
|
}
|
|
if (process == 70)
|
|
{
|
|
MmMaterial mmMaterial = Context
|
|
.Queryable<MmMaterial>()
|
|
.Where(it => it.MaterialCode == proWorkorder.productionCode)
|
|
.First();
|
|
if (mmMaterial == null)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(
|
|
$"物料档案不存在,无法成品入库:{proWorkorder.productionCode}"
|
|
);
|
|
}
|
|
|
|
proWorkorder.ProductNum += finish_num;
|
|
if (proWorkorder.PlanNum >= proWorkorder.ProductNum)
|
|
{
|
|
//做生产入库单
|
|
// 暂时默认成品入库与出库批次号都为000
|
|
InboundReceiptDto revokeRecepitDto = new()
|
|
{
|
|
ReceiptType = 1,
|
|
MaterialCode = proWorkorder.productionCode,
|
|
BatchNo = "000",
|
|
LocationCode = "CP001",
|
|
WarehouseCode = "WH001",
|
|
SupplierCode = mmMaterial.SupplierCode,
|
|
StoveCode = proWorkorder.StoveCode,
|
|
Workorder = workorder,
|
|
WorkorderRaw = workorder_raw,
|
|
Operator = Worker,
|
|
Quantity = finish_num,
|
|
TransactionType = "生产入库",
|
|
Remarks = $"成品入库,工单号:{workorder}",
|
|
};
|
|
MmInventoryService mmInventoryService = new();
|
|
string createReceiptresult = mmInventoryService.CreateInboundReceipt(
|
|
revokeRecepitDto
|
|
);
|
|
if (createReceiptresult != "ok")
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(createReceiptresult);
|
|
}
|
|
Context.Updateable(proWorkorder).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception("成品入库数超出计划数!");
|
|
}
|
|
}
|
|
Context.Ado.CommitTran();
|
|
return result > 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 出货工序报工
|
|
/// </summary>
|
|
/// <param name="workorder"></param>
|
|
/// <param name="processId"></param>
|
|
/// <param name="finish_num"></param>
|
|
/// <param name="bad_num"></param>
|
|
/// <param name="customer_order">客户订单号</param>
|
|
/// <param name="Worker"></param>
|
|
/// <returns></returns>
|
|
public int ShipmentProcessReportwork(
|
|
string workorder,
|
|
int processId,
|
|
int finish_num,
|
|
int bad_num,
|
|
string customer_order,
|
|
string Worker
|
|
)
|
|
{
|
|
try
|
|
{
|
|
//TODO 20250411 采购订单号和工单号是否匹配逻辑不适配实际情况,进行修改
|
|
|
|
// 判断订单号是否存在
|
|
OrderPurchase orderPurchase = Context
|
|
.Queryable<OrderPurchase>()
|
|
.Where(o => o.OrderNoMes == customer_order)
|
|
.First();
|
|
if (orderPurchase == null)
|
|
{
|
|
// 订单号不存在
|
|
return 2;
|
|
}
|
|
// 判断工单是否存在
|
|
ProWorkorder workorderInfo = Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.Workorder == workorder)
|
|
.First();
|
|
if (workorderInfo == null)
|
|
{
|
|
// 工单不存在
|
|
return 4;
|
|
}
|
|
// 判断工单主体型号和订单物料号是否匹配
|
|
if (workorderInfo.productionCode != orderPurchase.MaterialCode)
|
|
{
|
|
return 5;
|
|
}
|
|
|
|
string NickName = Context
|
|
.Queryable<SysUser>()
|
|
.Where(it => it.UserName == Worker || it.NickName == Worker)
|
|
.Select(it => it.NickName)
|
|
.First();
|
|
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
|
|
|
int result = 0;
|
|
int routeId = Context
|
|
.Queryable<BaseWorkRoute>()
|
|
.Where(it => it.Code == workorderInfo.RouteCode)
|
|
.Select(it => it.Id)
|
|
.First();
|
|
// 判断报工信息是否存在
|
|
Context.Ado.BeginTran();
|
|
// 更新报工信息
|
|
ProReportwork01 ReportWorkOrderDetail = Context
|
|
.Queryable<ProReportwork01>()
|
|
.Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
|
.First();
|
|
if (ReportWorkOrderDetail == null)
|
|
{
|
|
// 新增
|
|
ProReportwork01 proReportwork01 = new()
|
|
{
|
|
Id = XueHua,
|
|
Workorder = workorder,
|
|
ProcessId = processId,
|
|
FinishNum = finish_num,
|
|
BadNum = bad_num,
|
|
Worker = Worker,
|
|
RouteId = routeId,
|
|
JobDateTime = DateTime.Now,
|
|
CreatedBy = Worker,
|
|
CreatedTime = DateTime.Now,
|
|
};
|
|
result = Context.Insertable(proReportwork01).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
// 修改
|
|
ReportWorkOrderDetail.FinishNum = finish_num;
|
|
ReportWorkOrderDetail.BadNum = bad_num;
|
|
ReportWorkOrderDetail.Worker = Worker;
|
|
ReportWorkOrderDetail.UpdatedBy = Worker;
|
|
ReportWorkOrderDetail.UpdatedTime = DateTime.Now;
|
|
result = Context.Updateable(ReportWorkOrderDetail).ExecuteCommand();
|
|
}
|
|
|
|
// XXX 成品库出库
|
|
// 需要保证已入库数大于等于已出货数+现在要出货的数量
|
|
workorderInfo.ShipmentNum += finish_num;
|
|
if (workorderInfo.ProductNum >= workorderInfo.ShipmentNum)
|
|
{
|
|
// Todo找还有库存的成品库
|
|
|
|
// 暂时默认成品入库与出库批次号都为000
|
|
OutboundReceiptDto revokeRecepitDto = new()
|
|
{
|
|
ReceiptType = 1,
|
|
MaterialCode = workorderInfo.productionCode,
|
|
BatchNo = "000",
|
|
LocationCode = "CP001",
|
|
WarehouseCode = "WH001",
|
|
OrderNo = customer_order,
|
|
Workorder = workorder,
|
|
Operator = Worker,
|
|
Quantity = finish_num,
|
|
TransactionType = "出货出库",
|
|
Remarks = $"出货出库,工单号:{workorder},订单号{customer_order}",
|
|
};
|
|
MmInventoryService mmInventoryService = new();
|
|
string createReceiptresult = mmInventoryService.CreateOutboundReceipt(
|
|
revokeRecepitDto
|
|
);
|
|
if (createReceiptresult != "ok")
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(createReceiptresult);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception("出货数超出工单成品入库数!");
|
|
}
|
|
workorderInfo.CustomerOrder = customer_order;
|
|
// 修改工单信息
|
|
Context.Updateable(workorderInfo).ExecuteCommand();
|
|
// 修改采购订单是否完成
|
|
int newQuantity = Context
|
|
.Queryable<ProWorkorder>()
|
|
.Where(it => it.CustomerOrder == customer_order)
|
|
.Sum(it => it.ShipmentNum);
|
|
orderPurchase.DeliveryQuantity = newQuantity;
|
|
if (orderPurchase.DeliveryQuantity > orderPurchase.DemandQuantity)
|
|
{
|
|
// 订单超额了
|
|
Context.Ado.RollbackTran();
|
|
return 3;
|
|
}
|
|
if (orderPurchase.DeliveryQuantity == orderPurchase.DemandQuantity)
|
|
{
|
|
orderPurchase.Orderindicator = 1;
|
|
}
|
|
else
|
|
{
|
|
orderPurchase.Orderindicator = -1;
|
|
}
|
|
int res = Context.Updateable(orderPurchase).ExecuteCommand();
|
|
Context.Ado.CommitTran();
|
|
return result > 0 ? 1 : 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Context.Ado.RollbackTran();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
public List<ProReportWorkDetialDto> GetWorkOrderReportWorkList(string workorder)
|
|
{
|
|
return Context
|
|
.Queryable<ProReportwork01>()
|
|
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
|
.LeftJoin<ProWorkorder>((rw, wp, wo) => rw.Workorder == wo.Workorder)
|
|
.Where((rw, wp) => rw.Workorder == workorder)
|
|
.OrderBy(rw => rw.ProcessId)
|
|
.Select(
|
|
(rw, wp, wo) =>
|
|
new ProReportWorkDetialDto()
|
|
{
|
|
ProcessName = wp.Name,
|
|
StoveCode = wo.StoveCode,
|
|
FeedOrder = wo.FeedOrder,
|
|
},
|
|
true
|
|
)
|
|
.ToList();
|
|
}
|
|
|
|
public PagedInfo<ProReportWorkDetialDto> GetReportInfoByName(ProReportWorkDto2 query)
|
|
{
|
|
string NickName = Context
|
|
.Queryable<SysUser>()
|
|
.Where(it => it.UserName == query.name)
|
|
.Select(it => it.NickName)
|
|
.First();
|
|
query.name = string.IsNullOrEmpty(NickName) ? query.name + "|异常人员|" : NickName;
|
|
|
|
return Context
|
|
.Queryable<ProReportwork01>()
|
|
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
|
.LeftJoin<ProWorkorder>((rw, wp, wo) => rw.Workorder == wo.Workorder)
|
|
.Where(
|
|
(rw, wp) =>
|
|
rw.Worker == query.name
|
|
&& rw.JobDateTime >= DateTime.Today
|
|
&& rw.JobDateTime < DateTime.Today.AddDays(1)
|
|
)
|
|
.OrderBy(rw => rw.ProcessId)
|
|
.Select(
|
|
(rw, wp, wo) =>
|
|
new ProReportWorkDetialDto()
|
|
{
|
|
ProcessName = wp.Name,
|
|
StoveCode = wo.StoveCode,
|
|
FeedOrder = wo.FeedOrder,
|
|
},
|
|
true
|
|
)
|
|
.ToPage_NO_Convert(query);
|
|
}
|
|
|
|
public List<BaseWorkProcessesDto> GetProcessByRoute(int route_id)
|
|
{
|
|
return Context
|
|
.Queryable<BaseRelWorkRouteProcesses>()
|
|
.LeftJoin<BaseWorkProcesses>((rel, pro) => rel.FkWorkProcesses == pro.Id)
|
|
.Where((rel, pro) => rel.FkWorkRoute == route_id)
|
|
.Select((rel, pro) => pro)
|
|
.ToList()
|
|
.Adapt<List<BaseWorkProcesses>, List<BaseWorkProcessesDto>>();
|
|
}
|
|
|
|
public PagedInfo<ProReportWorkDetialDto> GetReportByProcessId(ProReportWorkDto3 query)
|
|
{
|
|
return Context
|
|
.Queryable<ProReportwork01>()
|
|
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
|
.LeftJoin<ProWorkorder>((rw, wp, wo) => rw.Workorder == wo.Workorder)
|
|
.Where(
|
|
(rw, wp, wo) =>
|
|
rw.ProcessId == query.processId
|
|
&& rw.JobDateTime >= DateTime.Today
|
|
&& rw.JobDateTime < DateTime.Today.AddDays(1)
|
|
)
|
|
.OrderBy(rw => rw.ProcessId)
|
|
.Select(
|
|
(rw, wp, wo) =>
|
|
new ProReportWorkDetialDto()
|
|
{
|
|
ProcessName = wp.Name,
|
|
StoveCode = wo.StoveCode,
|
|
FeedOrder = wo.FeedOrder,
|
|
},
|
|
true
|
|
)
|
|
.ToPage_NO_Convert(query);
|
|
}
|
|
}
|