😎实现变更通知ECN批量同步、定时同步功能
This commit is contained in:
parent
8c197178d6
commit
4b1d0fb58d
@ -8,6 +8,7 @@ using Admin.NET.Core;
|
||||
using Admin.NET.Core.Service;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -120,5 +121,136 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变更通知ECN-批量同步到SAP
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[ApiDescriptionSettings(Name = "BatchSyncToSAP"), HttpPost]
|
||||
[DisplayName("变更通知ECN-批量同步到SAP")]
|
||||
public async Task<List<SapOutput>> BatchSyncToSAP(List<ChangeNoticeEcnInput> input)
|
||||
{
|
||||
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
{
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
|
||||
var sapEcnInput = new SapEcnInput()
|
||||
{
|
||||
Reqkeyid = "",
|
||||
Businessid = "",
|
||||
Messageid = "",
|
||||
Sndprn = "PLM",
|
||||
Rcvprn = "SAP",
|
||||
Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
|
||||
Note1 = "",
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
|
||||
Aennr = input[i]._System_objNBS,
|
||||
Aetxt = input[i]._System_ObjDescription,
|
||||
Datuv = input[i].fld004693.ToDateTime().ToString("yyyy-MM-dd"),
|
||||
Lvorm = input[i].fld004694,
|
||||
Matnr = await _dataValidationService.ChangeModuleMaterial(input[i].fld004638.ToLong(), input[i].fld004638_Rec)
|
||||
};
|
||||
var apiOutput = await _sapService.SapEcnApi(sapEcnInput);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
var msg = apiOutput.msg;
|
||||
if (apiOutput.msg == "")
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj118Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj118
|
||||
{
|
||||
fld005293 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
fld005294 = codeVal,
|
||||
fld005292 = "N",
|
||||
fld005295 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
{
|
||||
parameter = apiOutput.parameter,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = apiOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
|
||||
return SapOutputList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变更通知ECN-定时同步到SAP
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[ApiDescriptionSettings(Name = "TimingSyncToSAP"), HttpGet]
|
||||
[DisplayName("变更通知ECN-定时同步到SAP")]
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAP()
|
||||
{
|
||||
var input = await _obj118Rep.AsQueryable()
|
||||
.Where(x => (x.CheckedStatus == 1 || x.CheckedStatus == 0) && x.deleted == false && x.IsLatestVersion == true && (x.fld005292 == "A" || x.fld005292 == "M"))
|
||||
.ToListAsync();
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
{
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
|
||||
var sapEcnInput = new SapEcnInput()
|
||||
{
|
||||
Reqkeyid = "",
|
||||
Businessid = "",
|
||||
Messageid = "",
|
||||
Sndprn = "PLM",
|
||||
Rcvprn = "SAP",
|
||||
Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
|
||||
Note1 = "",
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
|
||||
Aennr = input[i]._System_objNBS,
|
||||
Aetxt = input[i]._System_ObjDescription,
|
||||
Datuv = input[i].fld004693.ToDateTime().ToString("yyyy-MM-dd"),
|
||||
Lvorm = input[i].fld004694,
|
||||
Matnr = await _dataValidationService.ChangeModuleMaterial(input[i].fld004638.ToLong(), input[i].fld004638_Rec)
|
||||
};
|
||||
var apiOutput = await _sapService.SapEcnApi(sapEcnInput);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
var msg = apiOutput.msg;
|
||||
if (apiOutput.msg == "")
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj118Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj118
|
||||
{
|
||||
fld005293 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
fld005294 = codeVal,
|
||||
fld005292 = "N",
|
||||
fld005295 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
{
|
||||
parameter = apiOutput.parameter,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = apiOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
|
||||
return SapOutputList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -181,4 +181,37 @@ const syncToSAP = async (row: any) => {
|
||||
|
||||
};
|
||||
|
||||
//ECN批量同步到SAP
|
||||
const batchSyncToSAP = async () => {
|
||||
options.loading = true;
|
||||
var data = xGrid.value?.getCheckboxRecords();
|
||||
|
||||
ElMessageBox.confirm(`确定要批量同步ECN吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
var output = await BatchSyncToSAPChangeNoticeEcn(data);
|
||||
await handleQuery();
|
||||
var succeed = 0;
|
||||
var error = 0;
|
||||
for (let i = 0; i < output.data.result.length; i++) {
|
||||
var code = output.data.result[i].code
|
||||
if (code == "成功") {
|
||||
succeed++
|
||||
} else {
|
||||
error++
|
||||
}
|
||||
}
|
||||
ElMessageBox.alert("同步成功:" + succeed + ";" + "同步失败:" + error, '批量同步结果', {
|
||||
// 如果你想禁用它的自动对焦
|
||||
// autofocus: false,
|
||||
confirmButtonText: 'OK'
|
||||
})
|
||||
})
|
||||
.catch(() => { });
|
||||
options.loading = false;
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user