订单功能逻辑修改
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.MES.base_;
|
||||
using DOAN.Model.MES.base_.Dto;
|
||||
@@ -10,11 +11,12 @@ using DOAN.Repository;
|
||||
using DOAN.Service.Mobile.IService;
|
||||
using DOAN.Service.Public.IPublicService;
|
||||
using Infrastructure.Attribute;
|
||||
using JinianNet.JNTemplate;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar.DistributedSystem.Snowflake;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DOAN.Service.Mobile;
|
||||
|
||||
@@ -28,15 +30,21 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
{
|
||||
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).ToList();
|
||||
return Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.WorkorderDate >= startDate && it.WorkorderDate <= endDate)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ProReportwork01 GetProcessReportWorkDetail(string workorder, int process)
|
||||
{
|
||||
return Context.Queryable<ProReportwork01>().Where(x => x.Workorder == workorder && x.ProcessId == process).First();
|
||||
return Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.Where(x => x.Workorder == workorder && x.ProcessId == process)
|
||||
.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,24 +57,42 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
/// <param name="feed_order"></param>
|
||||
/// <param name="Worker"></param>
|
||||
/// <returns></returns>
|
||||
public bool FeedProcessReportwork(string workorder, int processId, int finish_num, string stove_code, string feed_order, string Worker)
|
||||
public bool FeedProcessReportwork(
|
||||
string workorder,
|
||||
int processId,
|
||||
int finish_num,
|
||||
string stove_code,
|
||||
string feed_order,
|
||||
string Worker
|
||||
)
|
||||
{
|
||||
int result = 0;
|
||||
bool Exist = Context.Queryable<ProReportwork01>().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any();
|
||||
bool Exist = Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
||||
.Any();
|
||||
|
||||
string NickName = Context.Queryable<SysUser>().Where(it => it.UserName == Worker).Select(it => it.NickName).First();
|
||||
string NickName = Context
|
||||
.Queryable<SysUser>()
|
||||
.Where(it => it.UserName == Worker)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
if (Exist)
|
||||
{
|
||||
result = Context.Updateable<ProReportwork01>().Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
||||
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 == 32)
|
||||
.SetColumns(it => it.RouteId == 32)
|
||||
.SetColumns(it => it.UpdatedBy == Worker)
|
||||
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
||||
.ExecuteCommand();
|
||||
Context.Updateable<ProWorkorder>().Where(it => it.Workorder == workorder)
|
||||
Context
|
||||
.Updateable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.StoveCode == stove_code)
|
||||
.SetColumns(it => it.FeedOrder == feed_order)
|
||||
.ExecuteCommand();
|
||||
@@ -84,24 +110,40 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
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();
|
||||
|
||||
Context
|
||||
.Updateable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.StoveCode == stove_code)
|
||||
.SetColumns(it => it.FeedOrder == feed_order)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
public bool ProcessReportWork(string workorder, int process, int finish_num, int bad_num, string Worker)
|
||||
public bool ProcessReportWork(
|
||||
string workorder,
|
||||
int process,
|
||||
int finish_num,
|
||||
int bad_num,
|
||||
string Worker
|
||||
)
|
||||
{
|
||||
int result = 0;
|
||||
bool Exist = Context.Queryable<ProReportwork01>().Where(it => it.Workorder == workorder && it.ProcessId == process).Any();
|
||||
string NickName = Context.Queryable<SysUser>().Where(it => it.UserName == Worker).Select(it => it.NickName).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)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
if (Exist)
|
||||
{
|
||||
result = Context.Updateable<ProReportwork01>().Where(it => it.Workorder == workorder && it.ProcessId == process)
|
||||
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)
|
||||
@@ -110,7 +152,6 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
.SetColumns(it => it.UpdatedBy == Worker)
|
||||
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
||||
.ExecuteCommand();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -126,7 +167,6 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
proReportwork01.CreatedBy = Worker;
|
||||
proReportwork01.CreatedTime = DateTime.Now;
|
||||
result = Context.Insertable(proReportwork01).ExecuteCommand();
|
||||
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
@@ -138,158 +178,175 @@ public class ReportFlowService : BaseService<ProReportwork01>, IReportFlowServic
|
||||
/// <param name="processId"></param>
|
||||
/// <param name="finish_num"></param>
|
||||
/// <param name="bad_num"></param>
|
||||
/// <param name="feed_order"></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)
|
||||
public int ShipmentProcessReportwork(
|
||||
string workorder,
|
||||
int processId,
|
||||
int finish_num,
|
||||
int bad_num,
|
||||
string customer_order,
|
||||
string Worker
|
||||
)
|
||||
{
|
||||
//采购订单号和工单号是否匹配
|
||||
bool isexistfree_order = Context.Queryable<ProWorkorder>().Where(o=>o.FeedOrder==customer_order).Any();
|
||||
if (isexistfree_order)
|
||||
try
|
||||
{
|
||||
OrderPurchase orderPurchase= Context.Queryable<OrderPurchase>().Where(o => o.OrderNoMes == customer_order).First();
|
||||
if (orderPurchase.DeliveryQuantity + finish_num> orderPurchase.DemandQuantity)
|
||||
//TODO 20250411 采购订单号和工单号是否匹配逻辑不适配实际情况,进行修改
|
||||
|
||||
// 判断订单号是否存在
|
||||
OrderPurchase orderPurchase = Context
|
||||
.Queryable<OrderPurchase>()
|
||||
.Where(o => o.OrderNoMes == customer_order)
|
||||
.First();
|
||||
if (orderPurchase == null)
|
||||
{
|
||||
return 3;//超额
|
||||
}
|
||||
// 订单号不存在
|
||||
return 2;
|
||||
}
|
||||
string NickName = Context
|
||||
.Queryable<SysUser>()
|
||||
.Where(it => it.UserName == Worker)
|
||||
.Select(it => it.NickName)
|
||||
.First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2;//采购订单号和工单号不匹配
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
bool Exist = Context.Queryable<ProReportwork01>().Where(it => it.Workorder == workorder && it.ProcessId == processId).Any();
|
||||
string NickName = Context.Queryable<SysUser>().Where(it => it.UserName == Worker).Select(it => it.NickName).First();
|
||||
Worker = string.IsNullOrEmpty(NickName) ? Worker + "|异常人员|" : NickName;
|
||||
if (Exist)
|
||||
{
|
||||
UseTran2(() =>
|
||||
{
|
||||
result = Context.Updateable<ProReportwork01>()
|
||||
.Where(it => it.Workorder == workorder && it.ProcessId == processId)
|
||||
.SetColumns(it => it.FinishNum == finish_num)
|
||||
.SetColumns(it => it.RouteId == 32)
|
||||
.SetColumns(it => it.BadNum == bad_num)
|
||||
.SetColumns(it => it.Worker == Worker)
|
||||
.SetColumns(it => it.JobDateTime == DateTime.Now)
|
||||
.SetColumns(it => it.UpdatedBy == Worker)
|
||||
.SetColumns(it => it.UpdatedTime == DateTime.Now)
|
||||
.ExecuteCommand();
|
||||
Context.Updateable<ProWorkorder>().Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.CustomerOrder == customer_order)
|
||||
.ExecuteCommand();
|
||||
//调整工单完成数
|
||||
Context.Updateable<ProWorkorder>()
|
||||
.SetColumns(it => it.ShipmentNum == finish_num)
|
||||
.Where(it => it.Workorder == workorder).ExecuteCommand();
|
||||
//调整采购完成数
|
||||
var OrderPurchase = Context.Queryable<OrderPurchase>().Where(it => it.OrderNoMes == SqlFunc.Subqueryable<ProWorkorder>().Where(s => s.Workorder == workorder).Select(s => s.FeedOrder)).First();
|
||||
int? ShipmentNum= Context.Queryable<ProWorkorder>().Where(it => it.FeedOrder == SqlFunc.Subqueryable<ProWorkorder>().Where(s => s.Workorder == workorder).Select(s => s.FeedOrder)).Sum(it => it.ShipmentNum);
|
||||
int Orderindicator = OrderPurchase.DemandQuantity<=ShipmentNum?1:0;
|
||||
Context.Updateable<OrderPurchase>()
|
||||
.SetColumns(it => it.Orderindicator == Orderindicator)
|
||||
.SetColumns(it=>it.DeliveryQuantity == ShipmentNum)
|
||||
.Where(it => it.Id == OrderPurchase.Id).ExecuteCommand();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ProReportwork01 proReportwork01 = new ProReportwork01();
|
||||
proReportwork01.Id = XueHua;
|
||||
proReportwork01.Workorder = workorder;
|
||||
proReportwork01.ProcessId = processId;
|
||||
proReportwork01.FinishNum = finish_num;
|
||||
proReportwork01.BadNum = bad_num;
|
||||
proReportwork01.Worker = Worker;
|
||||
proReportwork01.RouteId = 32;
|
||||
proReportwork01.JobDateTime = DateTime.Now;
|
||||
proReportwork01.CreatedBy = Worker;
|
||||
proReportwork01.CreatedTime = DateTime.Now;
|
||||
UseTran2(() =>
|
||||
int result = 0;
|
||||
|
||||
// 判断报工信息是否存在
|
||||
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 = 32,
|
||||
JobDateTime = DateTime.Now,
|
||||
CreatedBy = Worker,
|
||||
CreatedTime = DateTime.Now
|
||||
};
|
||||
result = Context.Insertable(proReportwork01).ExecuteCommand();
|
||||
Context.Updateable<ProWorkorder>().Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.CustomerOrder == customer_order)
|
||||
.ExecuteCommand();
|
||||
//出货工序
|
||||
Context.Updateable<ProWorkorder>()
|
||||
.SetColumns(it => it.ShipmentNum == finish_num)
|
||||
.Where(it => it.Workorder == workorder).ExecuteCommand();
|
||||
//调整采购完成数
|
||||
var OrderPurchase = Context.Queryable<OrderPurchase>().Where(it => it.OrderNoMes == SqlFunc.Subqueryable<ProWorkorder>().Where(s => s.Workorder == workorder).Select(s => s.FeedOrder)).First();
|
||||
int? ShipmentNum = Context.Queryable<ProWorkorder>().Where(it => it.FeedOrder == SqlFunc.Subqueryable<ProWorkorder>().Where(s => s.Workorder == workorder).Select(s => s.FeedOrder)).Sum(it => it.ShipmentNum);
|
||||
int Orderindicator = OrderPurchase.DemandQuantity <= ShipmentNum ? 1 : 0;
|
||||
Context.Updateable<OrderPurchase>()
|
||||
.SetColumns(it => it.Orderindicator == Orderindicator)
|
||||
.SetColumns(it => it.DeliveryQuantity == ShipmentNum)
|
||||
.Where(it => it.Id == OrderPurchase.Id).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();
|
||||
|
||||
}
|
||||
// 修改工单信息
|
||||
Context
|
||||
.Updateable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == workorder)
|
||||
.SetColumns(it => it.ShipmentNum == finish_num)
|
||||
.SetColumns(it => it.CustomerOrder == customer_order)
|
||||
.ExecuteCommand();
|
||||
// 修改采购订单信息
|
||||
int newQuantity = Context
|
||||
.Queryable<ProWorkorder>()
|
||||
.Where(it => it.CustomerOrder == customer_order)
|
||||
.Sum(it => it.ShipmentNum) ?? 0;
|
||||
orderPurchase.DeliveryQuantity = newQuantity;
|
||||
if (orderPurchase.DeliveryQuantity > orderPurchase.DemandQuantity)
|
||||
{
|
||||
// 订单超额了
|
||||
Context.Ado.RollbackTran();
|
||||
return 3;
|
||||
}
|
||||
if (orderPurchase.DeliveryQuantity == orderPurchase.DemandQuantity)
|
||||
{
|
||||
orderPurchase.Orderindicator = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
orderPurchase.Orderindicator = 0;
|
||||
}
|
||||
int res = Context.Updateable(orderPurchase).ExecuteCommand();
|
||||
Context.Ado.CommitTran();
|
||||
return result > 0 ? 1 : 0;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
return result > 0?1:0;
|
||||
}
|
||||
|
||||
public List<ProReportWorkDetialDto> GetWorkOrderReportWorkList(string workorder)
|
||||
{
|
||||
return Context.Queryable<ProReportwork01>()
|
||||
return Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
||||
.Where((rw, wp) => rw.Workorder == workorder)
|
||||
.OrderBy(rw => rw.ProcessId)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto()
|
||||
{
|
||||
ProcessName = wp.Name,
|
||||
}, true)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto() { ProcessName = wp.Name, }, true)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PagedInfo<ProReportWorkDetialDto> GetReportInfoByName(ProReportWorkDto2 query)
|
||||
{
|
||||
|
||||
string NickName = Context.Queryable<SysUser>().Where(it => it.UserName == query.name).Select(it => it.NickName).First();
|
||||
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)
|
||||
.Where((rw, wp) => rw.Worker == query.name && rw.JobDateTime >= DateTime.Today && rw.JobDateTime < DateTime.Today.AddDays(1))
|
||||
.OrderBy(rw => rw.ProcessId)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto()
|
||||
{
|
||||
ProcessName = wp.Name,
|
||||
}, true)
|
||||
.ToPage_NO_Convert(query);
|
||||
|
||||
return Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
||||
.Where(
|
||||
(rw, wp) =>
|
||||
rw.Worker == query.name
|
||||
&& rw.JobDateTime >= DateTime.Today
|
||||
&& rw.JobDateTime < DateTime.Today.AddDays(1)
|
||||
)
|
||||
.OrderBy(rw => rw.ProcessId)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto() { ProcessName = wp.Name, }, 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>>();
|
||||
|
||||
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)
|
||||
.Where((rw, wp) => rw.ProcessId == query.processId && rw.JobDateTime >= DateTime.Today && rw.JobDateTime < DateTime.Today.AddDays(1))
|
||||
.OrderBy(rw => rw.ProcessId)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto()
|
||||
{
|
||||
ProcessName = wp.Name,
|
||||
}, true)
|
||||
.ToPage_NO_Convert(query);
|
||||
return Context
|
||||
.Queryable<ProReportwork01>()
|
||||
.LeftJoin<BaseWorkProcesses>((rw, wp) => rw.ProcessId == wp.Id)
|
||||
.Where(
|
||||
(rw, wp) =>
|
||||
rw.ProcessId == query.processId
|
||||
&& rw.JobDateTime >= DateTime.Today
|
||||
&& rw.JobDateTime < DateTime.Today.AddDays(1)
|
||||
)
|
||||
.OrderBy(rw => rw.ProcessId)
|
||||
.Select((rw, wp) => new ProReportWorkDetialDto() { ProcessName = wp.Name, }, true)
|
||||
.ToPage_NO_Convert(query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user