1
This commit is contained in:
@@ -12,24 +12,43 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ExtensionMethods;
|
||||
using Kingdee.BOS.Log;
|
||||
|
||||
namespace MonthlyProductionSchedule
|
||||
{
|
||||
[Description("生产计划表-定时任务"), HotUpdate]
|
||||
[Description("生产计划表-库存记录-定时任务"), HotUpdate]
|
||||
public class AutoRecordsInventoryPlugIn : IScheduleService
|
||||
{
|
||||
public void Run(Context ctx, Schedule schedule)
|
||||
{
|
||||
var executeDay = schedule.Parameters.IsEmpty() ? 20 : schedule.Parameters.Long2Int();
|
||||
var newDate = DateTime.Now;
|
||||
//var year = filter.FilterParameter.CustomFilter["DataHoldYear"].Long2Int();
|
||||
//var month = filter.FilterParameter.CustomFilter["DataHoldMonth"].Long2Int();
|
||||
//var date = new DateTime(year, month, 1);
|
||||
var tableName = "TMP" + Guid.NewGuid().ToString("N").ToUpper();
|
||||
var startDate = newDate.AddDays(1 - newDate.Day);
|
||||
var endDate = startDate.AddMonths(1).AddDays(-1);
|
||||
var year = newDate.Year;
|
||||
var month = newDate.Month;
|
||||
DBServiceHelper.Execute(ctx, $"/*dialect*/ EXEC PROC_PPL_AutoSaveCurrentData {tableName} , {newDate.ToLongFormat()} ,{startDate.ToShortFormat()} ,{endDate.ToShortFormat()} ,{year} ,{month}");
|
||||
if (newDate.Day == executeDay)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Info(schedule.Name, "记录物料即时库存start...");
|
||||
|
||||
////如果这个日期下已保存有数据,先删除
|
||||
//var delSql = $"DELETE FROM T_MATERIAL_INVENTORY_MONTH_RECORD WHERE RECORDDAY = {newDate.Day} AND RECORDMONTH = {newDate.Month} AND RECORDYEAR = {newDate.Year} ";
|
||||
//var delNum = DBServiceHelper.Execute(ctx, $"/*dialect*/{delSql}");
|
||||
//Logger.Info(schedule.Name, $"删除物料即时库存数据成功!(本次删除{delNum}条)");
|
||||
|
||||
var intoSql = $@" PROC_SAVE_MATERIAL_INVENTORY {ctx.UserLocale.LCID} ,{newDate.Year} ,{newDate.Month} ,{newDate.Day} ";
|
||||
var intoNum = DBServiceHelper.Execute(ctx, $"/*dialect*/{intoSql}");
|
||||
Logger.Info(schedule.Name, $"记录物料即时库存成功!(本次记录{intoNum}条)");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(schedule.Name, ex.Message, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Logger.Info(schedule.Name, "记录物料即时库存end...");
|
||||
}
|
||||
}
|
||||
|
||||
//DBServiceHelper.Execute(ctx, $"/*dialect*/ EXEC PROC_PPL_AutoSaveCurrentData {tableName} , {newDate.ToLongFormat()} ,{startDate.ToShortFormat()} ,{endDate.ToShortFormat()} ,{year} ,{month}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user