fix 网格排班推送到sap

This commit is contained in:
2025-07-16 14:36:50 +08:00
parent c5d6166e9f
commit 5057bbd855

View File

@@ -142,41 +142,41 @@ public class WorkGridScheduleService : IWorkGridScheduleService
await _dbContext.InsertAsync(toInserts); await _dbContext.InsertAsync(toInserts);
await _operateLog.LogAsync(OperateLogType.WorkGrid, $"新增网格({workGrid.Name}){request.Date.ToString("yyyy-M-d")}的{request.PeriodType.GetDescription()}人员:{request.UserCodes.Join(",")}"); await _operateLog.LogAsync(OperateLogType.WorkGrid, $"新增网格({workGrid.Name}){request.Date.ToString("yyyy-M-d")}的{request.PeriodType.GetDescription()}人员:{request.UserCodes.Join(",")}");
// //推送到SAP //推送到SAP
// var items = toInserts.Select(x => new SyncWorkShiftDayItem var items = toInserts.Select(x => new SyncWorkShiftDayItem
// { {
// UserCode = x.UserCode, UserCode = x.UserCode,
// Begin = x.Date.ToString("yyyyMMdd"), Begin = x.Date.ToString("yyyyMMdd"),
// End = x.Date.ToString("yyyyMMdd"), End = x.Date.ToString("yyyyMMdd"),
// Plan = request.PeriodType == WorkGridTimePeriodEnumType.Day ? "JK03" : "JK04", Plan = request.PeriodType == WorkGridTimePeriodEnumType.Day ? "JK03" : "JK04",
// Operate = "INS" Operate = "INS"
// }).ToList(); }).ToList();
//
// var response = await _jinkoJipApi.SyncWorkShiftAsync(new SyncWorkShiftRequest { Items = items }); var response = await _jinkoJipApi.SyncWorkShiftAsync(new SyncWorkShiftRequest { Items = items });
// response.Message.IsPresent().ThrowIfTrue("JIP接口返回错误:" + response.Message); response.Message.IsPresent().ThrowIfTrue("JIP接口返回错误:" + response.Message);
// if (response == null || response.Items == null || response.Items.Count == 0) if (response == null || response.Items == null || response.Items.Count == 0)
// { {
// throw new UserFriendlyException("JIP接口返回数据异常,请联系管理员"); throw new UserFriendlyException("JIP接口返回数据异常,请联系管理员");
// } }
//
// if (response.Items.Any(x => x.Result != "S")) if (response.Items.Any(x => x.Result != "S"))
// { {
// var errorMessages = response.Items.Where(x => x.Result != "S") var errorMessages = response.Items.Where(x => x.Result != "S")
// .Select(x => $"{x.UserCode}排班新增失败:{x.Message}").Join("\r\n"); .Select(x => $"{x.UserCode}排班新增失败:{x.Message}").Join("\r\n");
// throw new UserFriendlyException(errorMessages); throw new UserFriendlyException(errorMessages);
// } }
//
// foreach (var workGridSchedule in toInserts) foreach (var workGridSchedule in toInserts)
// { {
// var msg = response.Items.FirstOrDefault(x => x.UserCode == workGridSchedule.UserCode)?.Message; var msg = response.Items.FirstOrDefault(x => x.UserCode == workGridSchedule.UserCode)?.Message;
// await _dbContext.Updateable<WorkGridScheduleEntity>() await _dbContext.Updateable<WorkGridScheduleEntity>()
// .SetColumns(x => x.SyncResult == msg) .SetColumns(x => x.SyncResult == msg)
// .Where(x => x.WorkGridCode == workGrid.Code) .Where(x => x.WorkGridCode == workGrid.Code)
// .Where(x => x.UserCode == workGridSchedule.UserCode) .Where(x => x.UserCode == workGridSchedule.UserCode)
// .Where(x => x.Date == workGridSchedule.Date) .Where(x => x.Date == workGridSchedule.Date)
// .Where(x => x.PeriodType == workGridSchedule.PeriodType) .Where(x => x.PeriodType == workGridSchedule.PeriodType)
// .ExecuteCommandAsync(); .ExecuteCommandAsync();
// } }
//todo sub pub //todo sub pub
//推送排班通知 //推送排班通知
@@ -243,34 +243,34 @@ public class WorkGridScheduleService : IWorkGridScheduleService
if (data.Any()) if (data.Any())
{ {
// //推送到SAP //推送到SAP
// var items = data.Select(x => new SyncWorkShiftDayItem var items = data.Select(x => new SyncWorkShiftDayItem
// { {
// UserCode = x.UserCode, UserCode = x.UserCode,
// Begin = x.Date.ToString("yyyyMMdd"), Begin = x.Date.ToString("yyyyMMdd"),
// End = x.Date.ToString("yyyyMMdd"), End = x.Date.ToString("yyyyMMdd"),
// Plan = request.PeriodType == WorkGridTimePeriodEnumType.Day ? "JK03" : "JK04", Plan = request.PeriodType == WorkGridTimePeriodEnumType.Day ? "JK03" : "JK04",
// Operate = "DEL" Operate = "DEL"
// }).ToList(); }).ToList();
//
// var response = await _jinkoJipApi.SyncWorkShiftAsync(new SyncWorkShiftRequest { Items = items }); var response = await _jinkoJipApi.SyncWorkShiftAsync(new SyncWorkShiftRequest { Items = items });
// response.Message.IsPresent().ThrowIfTrue("JIP接口返回错误:" + response.Message); response.Message.IsPresent().ThrowIfTrue("JIP接口返回错误:" + response.Message);
// if (response == null || response.Items == null || response.Items.Count == 0) if (response == null || response.Items == null || response.Items.Count == 0)
// { {
// throw new UserFriendlyException("JIP接口返回数据异常,请联系管理员"); throw new UserFriendlyException("JIP接口返回数据异常,请联系管理员");
// } }
//
// if (response.Items.Any(x => x.Result != "S")) if (response.Items.Any(x => x.Result != "S"))
// { {
// var errorMessages = response.Items.Where(x => x.Result != "S") var errorMessages = response.Items.Where(x => x.Result != "S")
// .Select(x => $"{x.UserCode}排班删除失败:{x.Message}").Join("\r\n"); .Select(x => $"{x.UserCode}排班删除失败:{x.Message}").Join("\r\n");
// throw new UserFriendlyException(errorMessages); throw new UserFriendlyException(errorMessages);
// } }
//
// foreach (var workGridSchedule in data) foreach (var workGridSchedule in data)
// { {
// workGridSchedule.SyncResult = response.Items.FirstOrDefault(x => x.UserCode == workGridSchedule.UserCode)?.Message; workGridSchedule.SyncResult = response.Items.FirstOrDefault(x => x.UserCode == workGridSchedule.UserCode)?.Message;
// } }
await _dbContext.UpdateAsync(data); await _dbContext.UpdateAsync(data);
await _dbContext.DeleteAsync(data); await _dbContext.DeleteAsync(data);