无需防错就报工

This commit is contained in:
qianhao.xu 2024-11-18 10:39:51 +08:00
parent 3db1c38761
commit b7e20290df
6 changed files with 176 additions and 63 deletions

View File

@ -183,21 +183,6 @@ public class WorkOrderProgressController : BaseController
return SUCCESS(response);
}
//TODO 无需防错就报工
/// <summary>
/// 无需防错就报工
/// </summary>
/// <param name="wokorder">工单</param>
/// <param name="reportNum">报工数</param>
/// <returns></returns>
[HttpGet("no_errorProofingAndReportingReport")]
public IActionResult NoErrorProofingAndReportingReport(string workorder,int reportNum)
{
if (string.IsNullOrEmpty(workorder) || reportNum<=0)
throw new CustomException("workorder或者报工数为0");
var response = workorderProgressService.NoErrorProofingAndReportingReport(workorder, reportNum);
return SUCCESS(response);
}
/// <summary>
/// TODO 完成 工单

View File

@ -17,11 +17,28 @@ namespace DOAN.Admin.Mobile.Controllers
/// <summary>
/// 报工表接口
/// </summary>
private readonly IProReportworkService _ProReportworkService;
private readonly IPADReportWorkService padReportWorkService;
public PADReportWorkController(IProReportworkService _ProReportworkService)
public PADReportWorkController(IPADReportWorkService padReportWorkService)
{
this._ProReportworkService = _ProReportworkService;
this.padReportWorkService = padReportWorkService;
}
//TODO 无需防错就报工
/// <summary>
/// 无需防错就报工
/// </summary>
/// <param name="wokorder">工单</param>
/// <param name="reportNum">报工数</param>
/// <returns></returns>
[HttpGet("no_errorProofingAndReportingReport")]
public IActionResult NoErrorProofingAndReportingReport(string workorder,int reportNum)
{
if (string.IsNullOrEmpty(workorder) || reportNum<=0)
throw new CustomException("workorder或者报工数为0");
var response = padReportWorkService.NoErrorProofingAndReportingReport(workorder, reportNum);
return SUCCESS(response);
}
}
}

View File

@ -37,7 +37,6 @@ namespace DOAN.Service.JobKanban.IService
int ErrorProofingAndReportingWork(string workorder, string labelContext);
int NoErrorProofingAndReportingReport(string wokorder, int reportNum);
int FinishWorkorder(string workorder, int finish_num);

View File

@ -259,50 +259,6 @@ public class WorkorderProgressService : BaseService<ProWorkorder>, IWorkorderPro
}
public int NoErrorProofingAndReportingReport(string wokorder, int reportNum)
{
int result = 0;
var selected_workorder = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == wokorder)
.First();
if (selected_workorder != null)
{
//修改
result = Context.Updateable<ProReportwork>().Where(it => it.FkWorkorder == wokorder)
.SetColumns(it => it.FinishedNum == reportNum)
.SetColumns(it => it.UpdatedTime == DateTime.Now)
.SetColumns(it => it.UpdatedBy == "PDA")
.ExecuteCommand();
}
else
{
//新增
var reportWork = new ProReportwork();
reportWork.Id = XueHua;
reportWork.FkWorkorder = wokorder;
reportWork.DispatchNum = selected_workorder.DeliveryNum;
reportWork.FinishedNum = reportNum;
reportWork.GroupCode = selected_workorder.GroupCode;
reportWork.LineCode = selected_workorder.LineCode;
reportWork.CreatedTime = DateTime.Now;
reportWork.CreatedBy = "kanban";
reportWork.UpdatedBy = "kanban";
reportWork.UpdatedTime = DateTime.Now;
result = Context.Insertable(reportWork).ExecuteCommand();
}
#region 线
linesideInventoryDeductions(wokorder, reportNum);
#endregion
return result;
}
public int FinishWorkorder(string workorder, int finish_num)
{
var result = 0;

View File

@ -0,0 +1,6 @@
namespace DOAN.Service.Mobile.IService;
public interface IPADReportWorkService
{
int NoErrorProofingAndReportingReport(string wokorder, int reportNum);
}

View File

@ -0,0 +1,150 @@
using DOAN.Model.MES.base_;
using DOAN.Model.MES.mm;
using DOAN.Model.MES.product;
using DOAN.Service.Mobile.IService;
using Infrastructure.Attribute;
namespace DOAN.Service.Mobile
{
[AppService(ServiceType = typeof(IPADReportWorkService), ServiceLifetime = LifeTime.Transient)]
public class PADReportWorkService : BaseService<ProReportwork>, IPADReportWorkService
{
/// <summary>
/// 不防错直接报工
/// </summary>
/// <param name="wokorder"></param>
/// <param name="reportNum"></param>
/// <returns></returns>
public int NoErrorProofingAndReportingReport(string wokorder, int reportNum)
{
int result = 0;
var selected_workorder = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == wokorder)
.First();
if (selected_workorder != null)
{
//修改
result = Context.Updateable<ProReportwork>().Where(it => it.FkWorkorder == wokorder)
.SetColumns(it => it.FinishedNum == reportNum)
.SetColumns(it => it.UpdatedTime == DateTime.Now)
.SetColumns(it => it.UpdatedBy == "PDA")
.ExecuteCommand();
}
else
{
//新增
var reportWork = new ProReportwork();
reportWork.Id = XueHua;
reportWork.FkWorkorder = wokorder;
reportWork.DispatchNum = selected_workorder.DeliveryNum;
reportWork.FinishedNum = reportNum;
reportWork.GroupCode = selected_workorder.GroupCode;
reportWork.LineCode = selected_workorder.LineCode;
reportWork.CreatedTime = DateTime.Now;
reportWork.CreatedBy = "kanban";
reportWork.UpdatedBy = "kanban";
reportWork.UpdatedTime = DateTime.Now;
result = Context.Insertable(reportWork).ExecuteCommand();
}
#region 线
linesideInventoryDeductions(wokorder, reportNum);
#endregion
return result;
}
/// <summary>
/// 线边库 库存扣除
/// </summary>
/// <param name="workorder"></param>
private void linesideInventoryDeductions(string workorder, int reportNum)
{
var selected_workorder = Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder).First();
if (selected_workorder == null)
{
return;
}
//TODO 获取实际报工数量 作为线边库库存 出库
// 查询这个工单的BOM
List<BaseMaterialBom> SubMaterialList = Context.Queryable<BaseMaterialBom>()
.Where(it => it.InvCode == selected_workorder.ProductionCode)
.ToList();
if (SubMaterialList.Count > 0)
{
List<MmLinesidebarInventoryOutboundAndInbound> InsertedSubMaterialOutboundAndInboundList =
new List<MmLinesidebarInventoryOutboundAndInbound>();
List<MmLinesidebarInventory> needReduceLinesidebarInventories = new List<MmLinesidebarInventory>();
// 添加出库记录
// 扣除库存记录
string[] SubMaterialArray = SubMaterialList.Select(it => it.InvCode).ToArray();
//线边库存
List<MmLinesidebarInventory> SideInventoryList = Context.Queryable<MmLinesidebarInventory>()
.Where(it => it.LineCode == selected_workorder.LineCode)
.Where(it => SubMaterialArray.Contains(it.MaterialCode)).ToList();
foreach (var subMaterial in SubMaterialList)
{
//物料在线边库存
if (SideInventoryList.Where(it => it.MaterialCode == subMaterial.SubInvCode).Any())
{
// 记录需要扣除的线边库存
MmLinesidebarInventory sideInventory = new MmLinesidebarInventory();
sideInventory.LineCode = selected_workorder.LineCode;
sideInventory.MaterialCode = subMaterial.SubInvCode;
var seleced = SideInventoryList.Where(it => it.MaterialCode == subMaterial.SubInvCode).First();
sideInventory.LogicQuantity =
seleced.LogicQuantity -
reportNum * Convert.ToDecimal(subMaterial.Iusequantity); //库存------需要扣减的数量
needReduceLinesidebarInventories.Add(sideInventory);
MmLinesidebarInventoryOutboundAndInbound outbound =
new MmLinesidebarInventoryOutboundAndInbound();
outbound.Id = XueHua;
outbound.LineCode = selected_workorder.LineCode;
outbound.MaterialCode = subMaterial.SubInvCode;
outbound.MaterialName = subMaterial.SubInvName;
outbound.Action = 1;
outbound.Quantity = reportNum * Convert.ToDecimal(subMaterial.Iusequantity);
outbound.Remark = $"(正常)触摸屏报工,工单号为{workorder}";
outbound.CreatedBy = "kanban";
outbound.CreatedTime = DateTime.Now;
InsertedSubMaterialOutboundAndInboundList.Add(outbound);
}
else
{
MmLinesidebarInventoryOutboundAndInbound outbound =
new MmLinesidebarInventoryOutboundAndInbound();
outbound.Id = XueHua;
outbound.LineCode = selected_workorder.LineCode;
outbound.MaterialCode = subMaterial.SubInvCode;
outbound.MaterialName = subMaterial.SubInvName;
outbound.Action = 1;
outbound.Quantity = reportNum * Convert.ToDecimal(subMaterial.Iusequantity);
outbound.Remark = $"(异常)触摸屏报工,工单号为{workorder},物料不在这个线边库";
outbound.CreatedBy = "kanban";
outbound.CreatedTime = DateTime.Now;
InsertedSubMaterialOutboundAndInboundList.Add(outbound);
}
}
UseTran2(() =>
{
Context.Updateable(needReduceLinesidebarInventories).UpdateColumns(it => new { it.LogicQuantity })
.WhereColumns(it => new { it.LineCode, it.MaterialCode }).ExecuteCommand();
Context.Insertable(InsertedSubMaterialOutboundAndInboundList).ExecuteCommand();
});
}
}
}
}