80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
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);
|
||
}
|
||
}
|
||
}
|
||
}
|