Files
sunwang b6c3ef8b2c feature:
成品入库页面分配库存弹窗字段完善
2026-11-05 08:38:53 +08:00

80 lines
3.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HHWMS.Web.Models;
using Quartz;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Support.Quartz;
namespace HHWMS.Web
{
/// <summary>
/// ERP 平库材料出库单上报补传(AddRdRecord11)
/// 同一出库单号(BillCode)的多条流水合并为一单上报,失败置 0 下一轮重试
/// </summary>
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class AddRdRecord11Job : WtmJob
{
public override async Task Execute(IJobExecutionContext context)
{
try
{
var unitWork = new UnitWork(Wtm);
var first = unitWork.Find<InventoryTransaction>(x =>
x.Type == InventoryTranType.出库
&& x.BillType == InventoryTransaction.ErpRdRecord11BillType
&& x.UploadErpFlag != 1
&& x.UploadErpFlag != null)
.OrderBy(x => x.ID)
.FirstOrDefault();
if (first != null)
{
// 按出库单号取出同组待传明细;无单号时只上报当前一条
List<InventoryTransaction> group;
if (string.IsNullOrWhiteSpace(first.BillCode))
{
group = new List<InventoryTransaction> { first };
}
else
{
group = unitWork.Find<InventoryTransaction>(x =>
x.Type == InventoryTranType.出库
&& x.BillType == InventoryTransaction.ErpRdRecord11BillType
&& x.BillCode == first.BillCode
&& x.UploadErpFlag != 1
&& x.UploadErpFlag != null)
.OrderBy(x => x.ID)
.ToList();
}
var vm = Wtm.CreateVM<InventoryVM>();
await vm.ProcessErpRdRecord11(group);
}
var job = unitWork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name);
if (job != null)
{
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(
context.FireTimeUtc.DateTime,
TimeZoneInfo.Local);
if (context.NextFireTimeUtc != null)
{
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(
context.NextFireTimeUtc.Value.DateTime,
TimeZoneInfo.Local);
}
unitWork.Update(job);
}
}
catch (Exception ex)
{
Wtm.DoLog("ERP平库出库上报失败", ActionLogTypesEnum.Job,
"AddRdRecord11Job", request: "error", result: ex.Message);
}
}
}
}