pda路由

This commit is contained in:
qianhao.xu 2024-11-18 11:24:35 +08:00
parent b7e20290df
commit 989c418ecb
6 changed files with 390 additions and 101 deletions

View File

@ -77,21 +77,6 @@ public class WorkOrderProgressController : BaseController
return SUCCESS(response);
}
//TODO 获取不同状态的工单 (PDA用) (废弃)
//TODO 根据班组,日期
[HttpGet("get_workorder_status_list")]
public IActionResult GetWorkOrderStatusList(string group_code,int status, DateTime handleDate)
{
handleDate=DOANConvertDateTime.ConvertLocalDate(handleDate);
if (string.IsNullOrEmpty(group_code) || handleDate == DateTime.MinValue)
throw new CustomException("传入空值异常");
var response = workorderProgressService.GetWorkOrderStatusList(group_code, status, handleDate);
return SUCCESS(response);
}
// 获取工单详情
[HttpGet("get_workorder_detail")]

View File

@ -1,9 +1,12 @@
using DOAN.Admin.WebApi.Filters;
using DOAN.Model.MES.product;
using DOAN.Model.MES.product.Dto;
using DOAN.Service.Mobile;
using Microsoft.AspNetCore.Mvc;
using DOAN.Service.Mobile.IService;
using DOAN.Model.Mobile.Dto;
using DOAN.Service.MES.product.IService;
using Infrastructure.Converter;
namespace DOAN.Admin.Mobile.Controllers
{
@ -40,6 +43,102 @@ namespace DOAN.Admin.Mobile.Controllers
var response = padReportWorkService.NoErrorProofingAndReportingReport(workorder, reportNum);
return SUCCESS(response);
}
//TODO 获取全部工艺路线
[HttpGet("get_all_route")]
public IActionResult GetAllRoute()
{
var response = padReportWorkService.GetAllRoute();
return SUCCESS(response);
}
//TODO 获取全部组
[HttpGet("get_groups")]
public IActionResult GetGroupList()
{
var response = padReportWorkService.GetGroupList();
return SUCCESS(response);
}
//TODO 获取报工工单列表
[HttpPost("list")]
[ActionPermissionFilter(Permission = "productManagement:proreportwork:list")]
public IActionResult QueryProReportwork([FromBody] ProReportworkQueryDto parm)
{
if(parm==null&&string.IsNullOrEmpty(parm.FkWorkorder))
{
SUCCESS(null);
}
var response = padReportWorkService.GetList(parm);
return SUCCESS(response);
}
//获取工单列表PDA
//TODO 获取不同状态的工单 (PDA用)
//TODO 根据班组,日期
[HttpGet("get_workorder_status_list")]
public IActionResult GetWorkOrderStatusList(string group_code,int status, DateTime handleDate)
{
handleDate=DOANConvertDateTime.ConvertLocalDate(handleDate);
if (string.IsNullOrEmpty(group_code) || handleDate == DateTime.MinValue)
throw new CustomException("传入空值异常");
var response = padReportWorkService.GetWorkOrderStatusList(group_code, status, handleDate);
return SUCCESS(response);
}
/// <summary>
/// 更新报工表
/// </summary>
/// <returns></returns>
[HttpPut]
[Log(Title = "报工表", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateProReportwork([FromBody] ProReportworkDto parm)
{
var modal = parm.Adapt<ProReportwork>().ToUpdate(HttpContext);
var response = padReportWorkService.UpdateProReportwork(modal);
return ToResponse(response);
}
//TODO 获取工单详情
// 获取工单详情
[HttpGet("get_workorder_detail")]
public IActionResult GetWorkOrderDetail(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = padReportWorkService.GetWorkOrderDetail(workorder);
return SUCCESS(response);
}
//TODO 开始某个工单
[HttpGet("start_workorder")]
public IActionResult StartWorkOrder(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = padReportWorkService.StartWorkOrder(workorder);
return SUCCESS(response);
}
//TODO 完成某一个工单
[HttpGet("finish_workorder")]
public IActionResult FinishWorkOrder(string workorder)
{
if (string.IsNullOrEmpty(workorder)) return SUCCESS(null);
var response = padReportWorkService.FinishWorkOrder(workorder);
return SUCCESS(response);
}
// TODO 如果没有id 传入工单 手动生成报工记录 沿用之前路由 /mes/productManagement/ProReportwork/manual_generation_reportwork
}
}

View File

@ -21,8 +21,6 @@ namespace DOAN.Service.JobKanban.IService
List<ProWorkorder> GetWorkOrderList(string group_code, string line_code, DateTime handleDate);
List<ProWorkorder> GetWorkOrderStatusList(string group_code, int status, DateTime handleDate);
ProWorkorderDto4 GetWorkOrderDetail(string workorder);

View File

@ -34,13 +34,6 @@ public class WorkorderProgressService : BaseService<ProWorkorder>, IWorkorderPro
.ToList();
}
public List<ProWorkorder> GetWorkOrderStatusList(string group_code, int status, DateTime handleDate)
{
return Context.Queryable<ProWorkorder>().Where(it => it.GroupCode == group_code)
.Where(it => it.Status == status)
.Where(it => it.WorkorderDate == handleDate)
.ToList();
}
public List<ProReportwork> GetReportWorkRecord(string group_code, string line_code, DateTime handleDate)
{

View File

@ -1,6 +1,26 @@
using DOAN.Model;
using DOAN.Model.MES.base_;
using DOAN.Model.MES.product;
using DOAN.Model.MES.product.Dto;
namespace DOAN.Service.Mobile.IService;
public interface IPADReportWorkService
{
int NoErrorProofingAndReportingReport(string wokorder, int reportNum);
List<BaseWorkRoute> GetAllRoute();
List<BaseGroup> GetGroupList();
PagedInfo<ProReportworkDto> GetList(ProReportworkQueryDto parm);
ProWorkorderDto4 GetWorkOrderDetail(string workorder);
List<ProWorkorder> GetWorkOrderStatusList(string group_code, int status, DateTime handleDate);
int UpdateProReportwork(ProReportwork parm);
int StartWorkOrder(string workorder);
int FinishWorkOrder(string workorder);
}

View File

@ -1,12 +1,13 @@
using DOAN.Model;
using DOAN.Model.MES.base_;
using DOAN.Model.MES.mm;
using DOAN.Model.MES.product;
using DOAN.Model.MES.product.Dto;
using DOAN.Repository;
using DOAN.Service.Mobile.IService;
using Infrastructure.Attribute;
namespace DOAN.Service.Mobile
{
[AppService(ServiceType = typeof(IPADReportWorkService), ServiceLifetime = LifeTime.Transient)]
@ -61,90 +62,283 @@ namespace DOAN.Service.Mobile
return result;
}
public List<BaseWorkRoute> GetAllRoute()
{
return Context.Queryable<BaseWorkRoute>().ToList();
}
public List<BaseGroup> GetGroupList()
{
return Context.Queryable<BaseGroup>().Where(it => it.Status == 1).ToList();
}
/// <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)
/// 查询报工表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<ProReportworkDto> GetList(ProReportworkQueryDto parm)
{
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 (parm.TimeRange != null && parm.TimeRange.Length == 2)
{
//物料在线边库存
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);
}
parm.TimeRange[0] = parm.TimeRange[0].Date;
// parm.TimeRange[1] = parm.TimeRange[1].Date.AddDays(1);
parm.TimeRange[1] = parm.TimeRange[1].Date;
}
var predicate = Expressionable.Create<ProWorkorder, ProReportwork>()
.AndIF(!string.IsNullOrEmpty(parm.FkWorkorder), (w, r) => w.Workorder.Contains(parm.FkWorkorder))
.AndIF(!string.IsNullOrEmpty(parm.GroupCode), (w, r) => w.GroupCode == parm.GroupCode)
.AndIF(!string.IsNullOrEmpty(parm.LineCode), (w, r) => w.LineCode == parm.LineCode)
.AndIF(parm.WarehouseconfirmationNum > 0, (w, r) => r.QualifiedNumber > 0)
.AndIF(
parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[0] > DateTime.MinValue,
(w, r) => w.WorkorderDate >= parm.TimeRange[0])
.AndIF(
parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[1] > DateTime.MinValue,
(w, r) => w.WorkorderDate <= parm.TimeRange[1])
.AndIF(parm.Status > 0, (w, r) => w.Status == parm.Status)
;
var response = Context.Queryable<ProWorkorder>()
.LeftJoin<ProReportwork>((w, r) => w.Workorder == r.FkWorkorder)
.Where(predicate.ToExpression())
.Select((w, r) => new ProReportworkDto
{
Id = r.Id,
ProductionCode = w.ProductionCode,
ProductionName = w.ProductionName,
Specification = w.Specification,
QualifiedNumber = r.QualifiedNumber,
UnqualifiedNumber = r.UnqualifiedNumber,
ReworkNumber = r.ReworkNumber,
ScrapNumber = r.ScrapNumber,
Remark = r.Remark,
Difference = r.QualifiedNumber - r.FinishedNum ?? 0,
FkWorkorder = w.Workorder,
GroupCode = w.GroupCode,
LineCode = w.LineCode,
DispatchNum = w.DeliveryNum ?? 0,
Priority = w.Priority,
Status = w.Status,
Beat = w.Beat
}, true).ToPage_NO_Convert<ProReportworkDto>(parm);
return response;
}
public ProWorkorderDto4 GetWorkOrderDetail(string workorder)
{
var query = Context.Queryable<ProWorkorder>()
.Where(it => it.Workorder == workorder);
return Context.Queryable(query)
.LeftJoin<ProReportwork>((q, r) => q.Workorder == r.FkWorkorder)
.Select((q, r) => new ProWorkorderDto4
{
FinishNum = r.FinishedNum
}, true).First();
}
public List<ProWorkorder> GetWorkOrderStatusList(string group_code, int status, DateTime handleDate)
{
return Context.Queryable<ProWorkorder>().Where(it => it.GroupCode == group_code)
.Where(it => it.Status == status)
.Where(it => it.WorkorderDate == handleDate)
.ToList();
}
/// <summary>
/// 修改报工表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateProReportwork(ProReportwork model)
{
// 更新线边库
if (model.FinishedNum != null&&string.IsNullOrEmpty(model.FkWorkorder))
{
linesideInventoryRecovery(model.FkWorkorder, model.CreatedBy);
linesideInventoryDeductions(model.FkWorkorder, model.FinishedNum??0);
}
//var response = Update(w => w.Id == model.Id, it => new ProReportwork()
//{
// FkWorkorder = model.FkWorkorder,
// DispatchNum = model.DispatchNum,
// FinishedNum = model.FinishedNum,
// GroupCode = model.GroupCode,
// LineCode = model.LineCode,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
public int StartWorkOrder(string workorder)
{
var result = 0;
// 获取同一天 同一组 同一线 的所有工单 把状态2 设为init 1
var handleWorkorder =
Context.Queryable<ProWorkorder>().Where(it => it.Workorder == workorder).First();
UseTran2(() =>
{
Context.Updateable(needReduceLinesidebarInventories).UpdateColumns(it => new { it.LogicQuantity })
.WhereColumns(it => new { it.LineCode, it.MaterialCode }).ExecuteCommand();
Context.Insertable(InsertedSubMaterialOutboundAndInboundList).ExecuteCommand();
Context.Updateable<ProWorkorder>().SetColumns(it => it.Status == 1)
.Where(it => it.Status == 2)
.Where(it => it.WorkorderDate == handleWorkorder.WorkorderDate)
.Where(it => it.GroupCode == handleWorkorder.GroupCode)
.Where(it => it.LineCode == handleWorkorder.LineCode)
.ExecuteCommand();
result = Context.Updateable<ProWorkorder>().SetColumns(it => it.Status == 2)
.SetColumns(it => it.StartTime == DateTime.Now)
.Where(it => it.Workorder == workorder).ExecuteCommand();
});
return result;
}
public int FinishWorkOrder(string workorder)
{
return Context.Updateable<ProWorkorder>()
.SetColumns(it => it.Status == 3)
.SetColumns(it => it.EndTime == DateTime.Now)
.Where(it => it.Workorder == workorder).ExecuteCommand();
}
/// <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();
});
}
}
/// <summary>
/// 取消出库
/// </summary>
/// <param name="workorder"></param>
/// <param name="CreatedBy"></param>
private void linesideInventoryRecovery(string workorder, string CreatedBy)
{
// 取消报工 出库
var cancal = Context.Queryable<MmLinesidebarInventoryOutboundAndInbound>()
.Where(it => it.WorkOrder == workorder).OrderByDescending(it => it.CreatedTime).First();
// 取消 报工库存日志
MmLinesidebarInventoryOutboundAndInbound log = new MmLinesidebarInventoryOutboundAndInbound();
log.Id = XueHua;
log.LineCode = cancal.LineCode;
log.MaterialCode = cancal.MaterialCode;
log.MaterialName = cancal.MaterialName;
log.Action = 2;
log.Quantity = cancal.Quantity;
log.Remark = $"取消这个工单{cancal.WorkOrder}的报工消耗,恢复库存;{cancal.Remark}";
log.CreatedBy = CreatedBy;
log.CreatedTime = DateTime.Now;
UseTran2(() =>
{
// 增加库存
Context.Updateable<MmLinesidebarInventory>()
.Where(it => it.LineCode == cancal.LineCode)
.Where(it => it.MaterialCode == cancal.MaterialCode)
.SetColumns(it => it.LogicQuantity == it.LogicQuantity + cancal.Quantity);
Context.Insertable(log).ExecuteCommand();
});
}
}
}
}