修复ReportFlowService中工单信息更新逻辑,将其移至正确的位置以确保数据一致性 修正MmInventoryService中材料出库记录的操作符赋值错误,并补充遗漏的Operator字段
707 lines
27 KiB
C#
707 lines
27 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}");
|
||
}
|
||
if (proWorkorder.PlanNum == 0)
|
||
{
|
||
throw new Exception($"工单计划数为0,不可领料");
|
||
}
|
||
|
||
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;
|
||
string stoveCode = stove_code;
|
||
// 检查采购记录获取炉号
|
||
var purchaseInfo = Context
|
||
.Queryable<MmRecordInbound>()
|
||
.Where(it => it.BatchNo == feed_order)
|
||
.Where(it => it.TransactionType == "采购入库")
|
||
.Where(it => it.Remarks == null || it.Remarks != "已撤销")
|
||
.First();
|
||
string newFeedOrder = feed_order;
|
||
if (purchaseInfo != null)
|
||
{
|
||
stoveCode = purchaseInfo.StoveCode;
|
||
}
|
||
else
|
||
{
|
||
// 根据原料工单领料逻辑获取炉号与原材料号
|
||
if (!string.IsNullOrEmpty(workorderRaw))
|
||
{
|
||
ProWorkorder proWorkorderRawInfo = Context
|
||
.Queryable<ProWorkorder>()
|
||
.Where(it => it.Workorder == workorderRaw)
|
||
.First();
|
||
if (proWorkorderRawInfo == null)
|
||
{
|
||
throw new Exception($"原材料工单不存在,无法领料:{workorderRaw}");
|
||
}
|
||
stoveCode = proWorkorderRawInfo.StoveCode;
|
||
newFeedOrder = proWorkorderRawInfo.FeedOrder;
|
||
}
|
||
else
|
||
{
|
||
throw new Exception($"未找到原材料采购批号:{feed_order}");
|
||
}
|
||
|
||
}
|
||
Context.Ado.BeginTran();
|
||
// 工单数据调整
|
||
Context
|
||
.Updateable<ProWorkorder>()
|
||
.Where(it => it.Workorder == workorder)
|
||
.SetColumnsIF(!string.IsNullOrEmpty(stoveCode),it => it.StoveCode == stoveCode)
|
||
.SetColumnsIF(!string.IsNullOrEmpty(newFeedOrder),it => it.FeedOrder == newFeedOrder)
|
||
.ExecuteCommand();
|
||
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();
|
||
}
|
||
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();
|
||
}
|
||
//XXX 领料出库操作(上边代码先不动)
|
||
MmRecordOutbound outRecordbound = Context
|
||
.Queryable<MmRecordOutbound>()
|
||
.Where(it => it.Workorder == workorder)
|
||
.Where(it => it.TransactionType == "领料出库")
|
||
.Where(it => it.Remarks != "已撤销")
|
||
.First();
|
||
//1.检查领料是否超出限额
|
||
|
||
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 += $"[{workorder}已领料{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,
|
||
StoveCode = stoveCode,
|
||
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 = proWorkorder.FeedOrder ?? "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();
|
||
}
|
||
|
||
workorderInfo.CustomerOrder = customer_order;
|
||
|
||
// 修改采购订单出货数
|
||
|
||
orderPurchase.DeliveryQuantity += finish_num;
|
||
//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;
|
||
}
|
||
orderPurchase.UpdatedTime = DateTime.Now;
|
||
orderPurchase.UpdatedBy = Worker;
|
||
int res = Context.Updateable(orderPurchase).ExecuteCommand();
|
||
|
||
// XXX 成品库出库
|
||
// 需要保证已入库数大于等于已出货数+现在要出货的数量
|
||
workorderInfo.ShipmentNum += finish_num;
|
||
if (workorderInfo.ProductNum >= workorderInfo.ShipmentNum)
|
||
{
|
||
// 修改工单信息,绑定出货记录
|
||
Context.Updateable(workorderInfo).ExecuteCommand();
|
||
// Todo找还有库存的成品库
|
||
|
||
// 暂时默认成品入库与出库批次号都为000
|
||
OutboundReceiptDto revokeRecepitDto = new()
|
||
{
|
||
ReceiptType = 1,
|
||
MaterialCode = workorderInfo.productionCode,
|
||
BatchNo = workorderInfo.FeedOrder ?? "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("出货数超出工单成品入库数!");
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|