订单查询,出货撤销与,工单查询功能修改

This commit is contained in:
2026-02-07 18:16:21 +08:00
parent a9b59678de
commit bfc0f27b18
6 changed files with 150 additions and 77 deletions

View File

@@ -400,7 +400,6 @@ namespace DOAN.Service.BZFM
Context.Insertable(newRecord).ExecuteCommand();
Context.Ado.CommitTran();
return "ok";
}
else
{
@@ -477,10 +476,7 @@ namespace DOAN.Service.BZFM
Context.Insertable(newRecord).ExecuteCommand();
Context.Ado.CommitTran();
return "ok";
}
}
catch (Exception ex)
{
@@ -891,10 +887,11 @@ namespace DOAN.Service.BZFM
{
int _type = parm.Type;
int _id = parm.Id;
if (_type < -1 && _id < -1)
if (_type < -1 || _id < -1)
{
return $"传入参数有误,请检查:type-{_type},id-{_id}";
}
// type == 1 入库单
if (_type == 1)
{
@@ -953,6 +950,7 @@ namespace DOAN.Service.BZFM
{
return $"此记录已撤销过,不可重复撤销";
}
//做出库红单
OutboundReceiptDto revokeRecepitDto = new()
{
@@ -970,20 +968,73 @@ namespace DOAN.Service.BZFM
Remarks = $"撤销操作,出库单号:{recordOutbound.OutboundNo}",
};
string result = CreateOutboundReceipt(revokeRecepitDto);
if (result == "ok")
{
recordOutbound.Remarks = "已撤销";
Context.Updateable(recordOutbound).ExecuteCommand();
return result;
}
else
if(result != "ok")
{
return result;
}
// 如果是出货则还要减少出货单库存
Context.Ado.BeginTran();
if (recordOutbound.TransactionType == "出货出库")
{
var workorderInfo = Context
.Queryable<ProWorkorder>()
.Where(it => it.Workorder == recordOutbound.Workorder)
.First();
if (workorderInfo == null)
{
Context.Ado.RollbackTran();
return "工单不存在";
}
// 判断订单号是否存在
var orderPurchase = Context
.Queryable<OrderPurchase>()
.Where(o => o.OrderNoMes == workorderInfo.CustomerOrder)
.First();
if (orderPurchase == null)
{
Context.Ado.RollbackTran();
return "订单号不存在";
}
Context
.Updateable<ProWorkorder>()
.Where(it => it.Workorder == recordOutbound.Workorder)
.SetColumns(it => it.ShipmentNum == 0)
.SetColumns(it => it.CustomerOrder == string.Empty)
.ExecuteCommand();
// 修改采购订单是否完成
int newQuantity =
Context
.Queryable<ProWorkorder>()
.Where(it => it.CustomerOrder == orderPurchase.OrderNoMes)
.Sum(it => it.ShipmentNum)
?? 0;
orderPurchase.DeliveryQuantity = newQuantity;
if (orderPurchase.DeliveryQuantity > orderPurchase.DemandQuantity)
{
// 订单超额了
Context.Ado.RollbackTran();
return "订单超额了";
}
if (orderPurchase.DeliveryQuantity == orderPurchase.DemandQuantity)
{
orderPurchase.Orderindicator = 1;
}
else
{
orderPurchase.Orderindicator = -1;
}
int res = Context.Updateable(orderPurchase).ExecuteCommand();
}
recordOutbound.Remarks = "已撤销";
Context.Updateable(recordOutbound).ExecuteCommand();
Context.Ado.CommitTran();
return result;
}
}
catch (Exception e)
{
Context.Ado.RollbackTran();
return e.Message;
}
}
@@ -1191,7 +1242,7 @@ namespace DOAN.Service.BZFM
}
else
{
orderPurchase.Orderindicator = 0;
orderPurchase.Orderindicator = -1;
}
Context.Updateable(orderPurchase).ExecuteCommand();
}

View File

@@ -1,4 +1,9 @@
using DOAN.Model.MES.order;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DOAN.Model.MES.order;
using DOAN.Model.MES.order.Dto;
using DOAN.Model.MES.Order.Dto;
using DOAN.Model.MES.product;
@@ -6,15 +11,13 @@ using DOAN.Service.MES.order.IService;
using DOAN.Service.MES.Order.IService;
using Infrastructure.Attribute;
using Infrastructure.Converter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DOAN.Service.MES.Order
{
[AppService(ServiceType = typeof(IDeliveryScheduleService), ServiceLifetime = LifeTime.Transient)]
[AppService(
ServiceType = typeof(IDeliveryScheduleService),
ServiceLifetime = LifeTime.Transient
)]
public class DeliveryScheduleService : BaseService<OrderPurchase>, IDeliveryScheduleService
{
/// <summary>
@@ -37,68 +40,86 @@ namespace DOAN.Service.MES.Order
}
}
var predicate = QueryExp(parm);
var queryResult = Context.Queryable<OrderPurchase>()
var queryResult = Context
.Queryable<OrderPurchase>()
.LeftJoin<ProWorkorder>((o, w) => o.OrderNoMes == w.CustomerOrder)
.Where(predicate.ToExpression())
.Where((o, w) => !SqlFunc.IsNullOrEmpty(o.OrderNoMes))
.OrderBy((o, w) => o.OrderNoMes)
.Select((o, w) => new OrderScheduleDto
{
Id = o.Id,
ImportDate = o.ImportDate,
OrderNoMes = o.OrderNoMes,
PurchaseOrderErp = o.PurchaseOrderErp,
Poitem = o.Poitem,
Variety = o.Variety,
Specordindicator = o.Specordindicator,
KdType = o.KdType,
DocumentDate = o.DocumentDate,
Seller = o.Seller,
SalesArea = o.SalesArea,
MaterialName = o.MaterialName,
MaterialCode = o.MaterialCode,
DemandQuantity = o.DemandQuantity,
DeliveryQuantity= o.DeliveryQuantity,
DeliveryDate = o.DeliveryDate,
//DeliveryQuantity = SqlFunc.Subqueryable<ProWorkorder>()
//.Where(w => w.FeedOrder == o.OrderNoMes).Sum(it=>it.ShipmentNum),
.Select(
(o, w) =>
new OrderScheduleDto
{
Id = o.Id,
ImportDate = o.ImportDate,
OrderNoMes = o.OrderNoMes,
PurchaseOrderErp = o.PurchaseOrderErp,
Poitem = o.Poitem,
Variety = o.Variety,
Specordindicator = o.Specordindicator,
KdType = o.KdType,
DocumentDate = o.DocumentDate,
Seller = o.Seller,
SalesArea = o.SalesArea,
MaterialName = o.MaterialName,
MaterialCode = o.MaterialCode,
DemandQuantity = o.DemandQuantity,
DeliveryQuantity = o.DeliveryQuantity,
DeliveryDate = o.DeliveryDate,
//DeliveryQuantity = SqlFunc.Subqueryable<ProWorkorder>()
//.Where(w => w.FeedOrder == o.OrderNoMes).Sum(it=>it.ShipmentNum),
StartDate = o.StartDate,
EndDate = o.EndDate,
Orderindicator = o.Orderindicator,
RouteCode = o.RouteCode,
Status = o.Status,
Remark = o.Remark,
CreatedBy = o.CreatedBy,
CreatedTime = o.CreatedTime,
UpdatedBy = o.UpdatedBy,
UpdatedTime = o.UpdatedTime,
Children = SqlFunc.Subqueryable<ProWorkorder>()
.Where(w => w.CustomerOrder == o.OrderNoMes) // 子查询,获取对应的工单数据
.ToList()
})
StartDate = o.StartDate,
EndDate = o.EndDate,
Orderindicator = o.Orderindicator,
RouteCode = o.RouteCode,
Status = o.Status,
Remark = o.Remark,
CreatedBy = o.CreatedBy,
CreatedTime = o.CreatedTime,
UpdatedBy = o.UpdatedBy,
UpdatedTime = o.UpdatedTime,
Children = SqlFunc
.Subqueryable<ProWorkorder>()
.Where(w => w.CustomerOrder == o.OrderNoMes) // 子查询,获取对应的工单数据
.ToList(),
}
)
.Distinct()
.ToList();
return queryResult;
}
private static Expressionable<OrderPurchase, ProWorkorder> QueryExp(OrderPurchaseQueryDto parm)
private static Expressionable<OrderPurchase, ProWorkorder> QueryExp(
OrderPurchaseQueryDto parm
)
{
var predicate = Expressionable.Create<OrderPurchase, ProWorkorder>()
.AndIF(!string.IsNullOrEmpty(parm.OrderNoMes), (o, w) => o.OrderNoMes.Contains(parm.OrderNoMes))
.AndIF(!string.IsNullOrEmpty(parm.PurchaseOrderErp), (o, w) => o.PurchaseOrderErp.Contains(parm.PurchaseOrderErp))
.AndIF(!string.IsNullOrEmpty(parm.MaterialCode), (o, w) => o.MaterialCode.Contains(parm.MaterialCode))
.AndIF(parm.ImportDate != null && parm.ImportDate[0] > DateTime.MinValue, (o, w) => o.ImportDate >= parm.ImportDate[0])
.AndIF(parm.ImportDate != null && parm.ImportDate[1] > DateTime.MinValue, (o, w) => o.ImportDate <= parm.ImportDate[1])
.AndIF(parm.Orderindicator>-2,(o,w)=>o.Orderindicator==parm.Orderindicator)
;
var predicate = Expressionable
.Create<OrderPurchase, ProWorkorder>()
.AndIF(
!string.IsNullOrEmpty(parm.OrderNoMes),
(o, w) => o.OrderNoMes.Contains(parm.OrderNoMes)
)
.AndIF(
!string.IsNullOrEmpty(parm.PurchaseOrderErp),
(o, w) => o.PurchaseOrderErp.Contains(parm.PurchaseOrderErp)
)
.AndIF(
!string.IsNullOrEmpty(parm.MaterialCode),
(o, w) => o.MaterialCode.Contains(parm.MaterialCode)
)
.AndIF(
parm.ImportDate != null && parm.ImportDate[0] > DateTime.MinValue,
(o, w) => o.ImportDate >= parm.ImportDate[0]
)
.AndIF(
parm.ImportDate != null && parm.ImportDate[1] > DateTime.MinValue,
(o, w) => o.ImportDate <= parm.ImportDate[1]
)
.AndIF(parm.Orderindicator > -2, (o, w) => o.Orderindicator == parm.Orderindicator);
return predicate;
}
}
}

View File

@@ -264,7 +264,7 @@ namespace DOAN.Service.MES.order
}
else if (!string.IsNullOrEmpty(Orderindicator) && Orderindicator == "否")
{
model.Orderindicator = 0;
model.Orderindicator = -1;
}
else
{

View File

@@ -31,10 +31,10 @@ namespace DOAN.Service.MES.product
parm.WorkorderDate[0] = parm.WorkorderDate[0].Date;
parm.WorkorderDate[1] = parm.WorkorderDate[1].Date;
}
bool hasWorkorder = !string.IsNullOrEmpty(parm.Workorder);
var predicate = Expressionable
.Create<ProWorkorder>()
.And(it => it.PlanNum > 0)
.AndIF(hasWorkorder, it => it.Workorder.Contains(parm.Workorder))
.AndIF(
!string.IsNullOrEmpty(parm.productionName),
it => it.productionName.Contains(parm.productionName)
@@ -60,7 +60,7 @@ namespace DOAN.Service.MES.product
.AndIF(!string.IsNullOrEmpty(parm.RouteCode), it => it.RouteCode == parm.RouteCode)
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
.AndIF(
parm.WorkorderDate != null && parm.WorkorderDate.Length > 0,
(parm.WorkorderDate != null && parm.WorkorderDate.Length > 0) && !hasWorkorder,
it =>
it.WorkorderDate >= parm.WorkorderDate[0]
&& it.WorkorderDate <= parm.WorkorderDate[1]
@@ -91,7 +91,7 @@ namespace DOAN.Service.MES.product
parm.WorkorderDate[0] = parm.WorkorderDate[0].Date;
parm.WorkorderDate[1] = parm.WorkorderDate[1].Date;
}
bool hasWorkorder = !string.IsNullOrEmpty(parm.Workorder);
var predicate = Expressionable
.Create<ProWorkorder>()
.AndIF(
@@ -119,11 +119,12 @@ namespace DOAN.Service.MES.product
.AndIF(!string.IsNullOrEmpty(parm.RouteCode), it => it.RouteCode == parm.RouteCode)
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), it => it.GroupCode == parm.GroupCode)
.AndIF(
parm.WorkorderDate != null && parm.WorkorderDate.Length > 0,
(parm.WorkorderDate != null && parm.WorkorderDate.Length > 0) && !hasWorkorder,
it =>
it.WorkorderDate >= parm.WorkorderDate[0]
&& it.WorkorderDate <= parm.WorkorderDate[1]
)
.AndIF(hasWorkorder, it => it.Workorder.Contains(parm.Workorder))
.And(it => it.PlanNum > 0)
.ToExpression();

View File

@@ -571,7 +571,7 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
}
else
{
orderPurchase.Orderindicator = 0;
orderPurchase.Orderindicator = -1;
}
int res = Context.Updateable(orderPurchase).ExecuteCommand();
Context.Ado.CommitTran();