😎生产物料服务、变更通知ECN服务、产品管理服务、项目管理服务更改同步逻辑
This commit is contained in:
parent
12c38a51c7
commit
ef71855c8b
@ -13,7 +13,10 @@ using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using RazorEngine;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -46,6 +49,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
private readonly SysConfigService _sysConfigService;
|
||||
public Common.DataValidationService _dataValidationService;
|
||||
public SapService.SapService _sapService;
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ChangeNoticeEcnService(
|
||||
SqlSugarRepository<Obj118> obj118Rep,
|
||||
@ -55,7 +59,8 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
SqlSugarRepository<ProcessesRequestItems> processesRequestItemsRep,
|
||||
SysConfigService sysConfigService,
|
||||
DataValidationService dataValidationService,
|
||||
SapService.SapService sapService
|
||||
SapService.SapService sapService,
|
||||
IServiceScopeFactory scopeFactory
|
||||
|
||||
)
|
||||
{
|
||||
@ -67,6 +72,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
_sysConfigService = sysConfigService;
|
||||
_dataValidationService = dataValidationService;
|
||||
_sapService = sapService;
|
||||
_scopeFactory = scopeFactory;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@ -218,7 +224,10 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAP()
|
||||
{
|
||||
var input = await _obj118Rep.AsQueryable()
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var input = await db.CopyNew().Queryable<Obj118>()
|
||||
.Where(x => x.CheckedStatus == 1 && x._System_CurrentStage == "标准化审核" && x.deleted == false && x.IsLatestVersion == true && x.fld005292 == "A")
|
||||
.ToListAsync();
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
@ -253,7 +262,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj118Rep.AsUpdateable()
|
||||
await db.Updateable<Obj118>()
|
||||
.SetColumns(it => new Obj118
|
||||
{
|
||||
fld005293 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
@ -280,11 +289,15 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
/// 生成ECN差异清单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[ApiDescriptionSettings(Name = "EcnVarianceList"), HttpGet]
|
||||
[DisplayName("生成ECN差异清单")]
|
||||
public async Task<string> EcnVarianceList()
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
//获取符合条件的变更通知Ecn数据
|
||||
var list = await _obj118Rep.AsQueryable()
|
||||
var list = await db.CopyNew().Queryable<Obj118>()
|
||||
.Where(x => x.CheckedStatus == 1 && x.deleted == false && x.fld006576 == "A" && x._System_CurrentStage == "差异清单对比中" && x.IsLatestVersion == true)
|
||||
.ToListAsync();
|
||||
|
||||
@ -307,7 +320,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
//最新版本
|
||||
var ecnVersionIndex = ecnListItem.VersionIndex;
|
||||
//获取条目记录
|
||||
var listOfDrawing = await _processesRequestItemsRep.AsQueryable()
|
||||
var listOfDrawing = await db.CopyNew().Queryable<ProcessesRequestItems>()
|
||||
.Where(x => x.ProcObjId == 118 && x.fld006573 == "A" && x.ProcRecGuid == ecnRecordGuid)
|
||||
.ToListAsync();
|
||||
foreach (var listOfDrawingItem in listOfDrawing)
|
||||
@ -316,8 +329,8 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
var listOfDrawingRequestItemsId = listOfDrawingItem.RequestItemsId;
|
||||
|
||||
//获取137表记录
|
||||
var recordData = await _obj137Rep.AsQueryable()
|
||||
.Where(x => x.RecordGuid == listOfDrawingRecordGuid && x.SWPDMConfigurationName == "默认" && x.deleted == false && !string.IsNullOrEmpty(x.fld005686)).OrderByDescending(x => x.idRecord)
|
||||
var recordData = await db.CopyNew().Queryable<Obj137>()
|
||||
.Where(x => x.RecordGuid == listOfDrawingRecordGuid && x.SWPDMConfigurationName == "默认" && x.deleted == false && !string.IsNullOrEmpty(x.fld005686)).OrderByDescending(x => x.idRecord)
|
||||
.FirstAsync();
|
||||
if (recordData == null)
|
||||
{
|
||||
@ -352,22 +365,22 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
EffectiveTo = DateTime.Now.AddYears(100),
|
||||
ChildSwFileType = 1,//记录属于137PDM库的默认1 属性112原材料库默认 0
|
||||
ParentSwFileType = -1,
|
||||
ParentObjectID=118,
|
||||
CreatedUserID=2,
|
||||
ModifiedUserID=2,
|
||||
ChildConfigID=8,
|
||||
isAddedFromSW=true
|
||||
ParentObjectID = 118,
|
||||
CreatedUserID = 2,
|
||||
ModifiedUserID = 2,
|
||||
ChildConfigID = 8,
|
||||
isAddedFromSW = true
|
||||
};
|
||||
|
||||
var addParentBom = await _configurationDataRep.AsInsertable(parentBom)
|
||||
.InsertColumns(x=> new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.fld006567, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType,x.ParentObjectID, x.CreatedUserID ,x.ModifiedUserID,x.ChildConfigID,x.isAddedFromSW })
|
||||
.ExecuteReturnEntityAsync();
|
||||
var addParentBom = db.CopyNew().Insertable(parentBom)
|
||||
.InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.fld006567, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.isAddedFromSW })
|
||||
.ExecuteReturnEntity();
|
||||
|
||||
//当前版本BOM
|
||||
var bomList = await _configurationDataRep.AsQueryable().Where(x => x.ParentGuid == recordRecordGuid && x.ParentVersion == recordVersionIndex && x.isDeleted == false && x.ConfigId == 8 && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false).ToListAsync();
|
||||
var bomList = await db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ParentGuid == recordRecordGuid && x.ParentVersion == recordVersionIndex && x.isDeleted == false && x.ConfigId == 8 && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false && (!(x.ParentSwFileType == 1 && x.isAddedFromSW == false))).ToListAsync();
|
||||
|
||||
//旧版本BOM
|
||||
var historyBomList = await _configurationDataRep.AsQueryable().Where(x => x.ParentGuid == recordRecordGuid && x.ParentVersion == Convert.ToInt32(fld005686) && x.isDeleted == false && x.ConfigId == 8 && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false).ToListAsync();
|
||||
var historyBomList = await db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ParentGuid == recordRecordGuid && x.ParentVersion == Convert.ToInt32(fld005686) && x.isDeleted == false && x.ConfigId == 8 && (x.fld005577 != "不包含" || x.fld005577 == null) && x.isSuppressed == false && x.inContext == false && (!(x.ParentSwFileType == 1 && x.isAddedFromSW == false))).ToListAsync();
|
||||
//遍历新BOM
|
||||
foreach (var bomListItem in bomList)
|
||||
{
|
||||
@ -393,7 +406,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
var versionChange = "";
|
||||
if (bomListItem.childVersion != bomChange[i].childVersion)
|
||||
{
|
||||
var contrastResult = await _dataValidationService.ComparativeVersion(bomChange[i].ChildObjID, bomListChildGuid, (int)bomListItem.childVersion,(int)bomChange[i].childVersion);
|
||||
var contrastResult = await _dataValidationService.ComparativeVersion(bomChange[i].ChildObjID, bomListChildGuid, (int)bomListItem.childVersion, (int)bomChange[i].childVersion);
|
||||
versionChange = contrastResult;
|
||||
}
|
||||
//创建子项
|
||||
@ -423,20 +436,20 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
CreatedUserID = 2,
|
||||
ModifiedUserID = 2,
|
||||
ChildConfigID = ChildConfigID,
|
||||
isAddedFromSW=true,
|
||||
fld006586= versionChange,
|
||||
isAddedFromSW = true,
|
||||
fld006586 = versionChange,
|
||||
|
||||
fld006567 = "子项",
|
||||
fld006581 = recordData._System_objNBS,
|
||||
fld006565 = "修改",
|
||||
fld006564 = bomChange[i].QtyManual.ToString(),
|
||||
fld006566 = bomListQuantity.ToString()
|
||||
};
|
||||
};
|
||||
|
||||
var addChildBomBom = await _configurationDataRep.AsInsertable(childBom).InsertColumns(x => new{ x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566,x.isAddedFromSW,x.fld006586 }).ExecuteReturnEntityAsync();
|
||||
var addChildBomBom = db.CopyNew().Insertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566, x.isAddedFromSW, x.fld006586 }).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
var bomChangeVersion = historyBomList.Where(x => x.ChildGuid == bomListChildGuid && x.QtyManual == bomListQuantity && x.childVersion!= bomListItem.childVersion).ToList();
|
||||
var bomChangeVersion = historyBomList.Where(x => x.ChildGuid == bomListChildGuid && x.QtyManual == bomListQuantity && x.childVersion != bomListItem.childVersion).ToList();
|
||||
for (var i = 0; i < bomChangeVersion.Count; i++)
|
||||
{
|
||||
var versionChange = await _dataValidationService.ComparativeVersion(bomChangeVersion[i].ChildObjID, bomListChildGuid, (int)bomListItem.childVersion, (int)bomChangeVersion[i].childVersion);
|
||||
@ -481,11 +494,11 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
fld006566 = bomListQuantity.ToString()
|
||||
};
|
||||
|
||||
var addChildBomBom = await _configurationDataRep.AsInsertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566, x.isAddedFromSW ,x.fld006586 }).ExecuteReturnEntityAsync();
|
||||
var addChildBomBom = db.CopyNew().Insertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566, x.isAddedFromSW, x.fld006586 }).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
//BOM对比-新增
|
||||
var bomAdd = historyBomList.Where(x => x.ChildGuid == bomListChildGuid).ToList();
|
||||
//BOM对比-新增
|
||||
var bomAdd = historyBomList.Where(x => x.ChildGuid == bomListChildGuid).ToList();
|
||||
if (bomAdd.Count == 0)
|
||||
{
|
||||
//创建子项
|
||||
@ -524,7 +537,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
fld006566 = bomListQuantity.ToString()
|
||||
};
|
||||
|
||||
var addChildBomBom = await _configurationDataRep.AsInsertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566 ,x.isAddedFromSW }).ExecuteReturnEntityAsync();
|
||||
var addChildBomBom = db.CopyNew().Insertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566, x.isAddedFromSW }).ExecuteReturnEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +568,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
ParentGuid = ecnRecordGuid,
|
||||
ChildGuid = historyBomChildGuid,
|
||||
ChildObjID = historyBomChildObjID,
|
||||
ConfigId =14,
|
||||
ConfigId = 14,
|
||||
childVersion = historyBomListItem.childVersion,
|
||||
ParentVersion = (int)ecnVersionIndex,
|
||||
isDeleted = false,
|
||||
@ -576,7 +589,7 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
CreatedUserID = 2,
|
||||
ModifiedUserID = 2,
|
||||
ChildConfigID = ChildConfigID,
|
||||
isAddedFromSW=true,
|
||||
isAddedFromSW = true,
|
||||
|
||||
fld006567 = "子项",
|
||||
fld006581 = recordData._System_objNBS,
|
||||
@ -584,32 +597,32 @@ public class ChangeNoticeEcnService : IDynamicApiController, ITransient
|
||||
fld006564 = historyBomQuantity.ToString(),
|
||||
fld006566 = "0"
|
||||
};
|
||||
var addChildBomBom = await _configurationDataRep.AsInsertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566,x.isAddedFromSW }).ExecuteReturnEntityAsync();
|
||||
var addChildBomBom = db.CopyNew().Insertable(childBom).InsertColumns(x => new { x.ParentGuid, x.ChildGuid, x.ChildObjID, x.ConfigId, x.childVersion, x.ParentVersion, x.isDeleted, x.Quantity, x.Description, x.OrderIndex, x.PartNumber, x.BOMGuid, x.CreatedDate, x.ModifiedDate, x.EffectiveFrom, x.EffectiveTo, x.ChildSwFileType, x.ParentSwFileType, x.ParentObjectID, x.CreatedUserID, x.ModifiedUserID, x.ChildConfigID, x.fld006567, x.fld006581, x.fld006565, x.fld006564, x.fld006566, x.isAddedFromSW }).ExecuteReturnEntity();
|
||||
}
|
||||
}
|
||||
|
||||
await _processesRequestItemsRep.AsUpdateable()
|
||||
.SetColumns(it => new ProcessesRequestItems
|
||||
{
|
||||
fld006574 = itemComparisonResult,
|
||||
fld006575 = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
|
||||
fld006573 = "N"
|
||||
})
|
||||
.Where(it => it.RequestItemsId == listOfDrawingRequestItemsId)
|
||||
.ExecuteCommandAsync();
|
||||
db.CopyNew().Updateable<ProcessesRequestItems>()
|
||||
.SetColumns(it => new ProcessesRequestItems
|
||||
{
|
||||
fld006574 = itemComparisonResult,
|
||||
fld006575 = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
|
||||
fld006573 = "N"
|
||||
})
|
||||
.Where(it => it.RequestItemsId == listOfDrawingRequestItemsId)
|
||||
.ExecuteCommand();
|
||||
|
||||
ecnComparisonResult = ecnComparisonResult + itemComparisonResult;
|
||||
}
|
||||
|
||||
await _obj118Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj118
|
||||
{
|
||||
fld006577 = ecnComparisonResult,
|
||||
fld006578 = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
|
||||
fld006576 = "N"
|
||||
})
|
||||
db.CopyNew().Updateable<Obj118>()
|
||||
.SetColumns(it => new Obj118
|
||||
{
|
||||
fld006577 = ecnComparisonResult,
|
||||
fld006578 = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
|
||||
fld006576 = "N"
|
||||
})
|
||||
.Where(it => it.idRecord == ecnListItem.idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
}
|
||||
return "对比完成,请到前端查看结果";
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ public class ProductManagementBaseInput
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string? fld004876 { get; set; }
|
||||
public double? fld004876 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -14,6 +14,8 @@ using Vistar.Application.Common;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
||||
using static Elastic.Clients.Elasticsearch.JoinField;
|
||||
using Qiniu.CDN;
|
||||
using SqlSugar;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Vistar.Application.Service.MaterialManagement;
|
||||
|
||||
@ -32,6 +34,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
public Common.DataValidationService _dataValidationService;
|
||||
public SqlSugarRepository<Obj122> _obj122Rep;
|
||||
public SqlSugarRepository<Obj121> _obj121Rep;
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ProductManagementService(
|
||||
SqlSugarRepository<Obj110> obj110Rep,
|
||||
@ -42,7 +45,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
SqlSugarRepository<Obj118> obj118Rep,
|
||||
DataValidationService dataValidationService,
|
||||
SqlSugarRepository<Obj122> obj122Rep,
|
||||
SqlSugarRepository<Obj121> obj121Rep
|
||||
SqlSugarRepository<Obj121> obj121Rep,
|
||||
IServiceScopeFactory scopeFactory
|
||||
|
||||
)
|
||||
{
|
||||
@ -55,6 +59,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
_dataValidationService = dataValidationService;
|
||||
_obj122Rep = obj122Rep;
|
||||
_obj121Rep = obj121Rep;
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询产品管理
|
||||
@ -136,7 +141,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
Zeinr = input.fld004881,
|
||||
Mstae = input.fld004699,
|
||||
Raube = input.fld004877,
|
||||
Mhdrz = input.fld004876,
|
||||
Mhdrz = input.fld004876.ToString(),
|
||||
Mhdhb = input.fld004895.ToString(),
|
||||
Werks = input.fld004325,
|
||||
Beskz = input.fld004490,
|
||||
@ -344,16 +349,20 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
[DisplayName("产品管理-批量同步到SAP")]
|
||||
public async Task<List<SapOutput>> BatchSyncToSAP(List<ProductManagementBaseInput> input)
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
const string lengthError = "物料描述长度大于40,请检查!";
|
||||
const string synchronized = "该物料编码已同步或已停用!";
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
|
||||
var tasks = input.Select(async item =>
|
||||
{
|
||||
// 验证物料描述长度
|
||||
if (input[i].fld004484.Length > 40)
|
||||
if (item.fld004484.Length > 40)
|
||||
{
|
||||
await _obj110Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
@ -361,29 +370,29 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
fld004313 = lengthError,
|
||||
fld004311 = "失败"
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync().ConfigureAwait(false);
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = lengthError,
|
||||
result = lengthError
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
if (input[i].fld004312 == "N" || input[i].fld004312 == "D" || input[i].fld004312 == null)
|
||||
|
||||
if (item.fld004312 == "N" || item.fld004312 == "D" || item.fld004312 == null)
|
||||
{
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = synchronized,
|
||||
result = synchronized
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
var sapMaterialInput = new SapMaterialInput()
|
||||
@ -398,27 +407,27 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = input[i]._System_objNBS,
|
||||
Mbrsh = input[i].fld004323,
|
||||
Mtart = input[i].fld004324,
|
||||
Maktx = input[i].fld004484,
|
||||
Meins = input[i].fld004861,
|
||||
Matkl = input[i].fld004485,
|
||||
Bismt = input[i]._System_ObjDescription,
|
||||
Groes = input[i]._System_objNBS,
|
||||
Normt = input[i].fld004887,
|
||||
Ferth = input[i].fld004882,
|
||||
Zeinr = input[i].fld004881,
|
||||
Mstae = input[i].fld004699,
|
||||
Raube = input[i].fld004877,
|
||||
Mhdrz = input[i].fld004876,
|
||||
Mhdhb = input[i].fld004895.ToString(),
|
||||
Werks = input[i].fld004325,
|
||||
Beskz = input[i].fld004490,
|
||||
Sobsl = input[i].fld004491,
|
||||
Schgt = input[i].fld004873,
|
||||
Rgekz = input[i].fld004872,
|
||||
Zbom = input[i].fld004698
|
||||
Matnr = item._System_objNBS,
|
||||
Mbrsh = item.fld004323,
|
||||
Mtart = item.fld004324,
|
||||
Maktx = item.fld004484,
|
||||
Meins = item.fld004861,
|
||||
Matkl = item.fld004485,
|
||||
Bismt = item._System_ObjDescription,
|
||||
Groes = item._System_objNBS,
|
||||
Normt = item.fld004887,
|
||||
Ferth = item.fld004882,
|
||||
Zeinr = item.fld004881,
|
||||
Mstae = item.fld004699,
|
||||
Raube = item.fld004877,
|
||||
Mhdrz = item.fld004876.ToString(),
|
||||
Mhdhb = item.fld004895.ToString(),
|
||||
Werks = item.fld004325,
|
||||
Beskz = item.fld004490,
|
||||
Sobsl = item.fld004491,
|
||||
Schgt = item.fld004873,
|
||||
Rgekz = item.fld004872,
|
||||
Zbom = item.fld004698
|
||||
};
|
||||
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
@ -428,28 +437,133 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
|
||||
await _obj110Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
fld004311 = codeVal,
|
||||
fld004312 = "N",
|
||||
fld004313 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
fld004311 = codeVal,
|
||||
fld004312 = "N",
|
||||
fld004313 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
return new SapOutput
|
||||
{
|
||||
parameter = sapOutput.parameter,
|
||||
materialCode = input[0]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = sapOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
|
||||
return SapOutputList;
|
||||
});
|
||||
|
||||
var materialOutput = await Task.WhenAll(tasks);
|
||||
return materialOutput.ToList();
|
||||
|
||||
//for (int i = 0; i < input.Count; i++)
|
||||
//{
|
||||
// // 验证物料描述长度
|
||||
// if (input[i].fld004484.Length > 40)
|
||||
// {
|
||||
// await _obj110Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj110
|
||||
// {
|
||||
// fld004629 = DateTime.Now,
|
||||
// fld004312 = "N",
|
||||
// fld004313 = lengthError,
|
||||
// fld004311 = "失败"
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync().ConfigureAwait(false);
|
||||
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = lengthError,
|
||||
// result = lengthError
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
// if (input[i].fld004312 == "N" || input[i].fld004312 == "D" || input[i].fld004312 == null)
|
||||
// {
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = synchronized,
|
||||
// result = synchronized
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
// //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
// string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
// var sapMaterialInput = new SapMaterialInput()
|
||||
// {
|
||||
// Reqkeyid = "",
|
||||
// Businessid = "",
|
||||
// Messageid = "",
|
||||
// Sndprn = "PLM",
|
||||
// Rcvprn = "SAP",
|
||||
// Requser = Requser,
|
||||
// Note1 = "",
|
||||
// Note2 = "",
|
||||
// Note3 = "",
|
||||
// Zwbid = millisecondTimestamp,
|
||||
// Matnr = input[i]._System_objNBS,
|
||||
// Mbrsh = input[i].fld004323,
|
||||
// Mtart = input[i].fld004324,
|
||||
// Maktx = input[i].fld004484,
|
||||
// Meins = input[i].fld004861,
|
||||
// Matkl = input[i].fld004485,
|
||||
// Bismt = input[i]._System_ObjDescription,
|
||||
// Groes = input[i]._System_objNBS,
|
||||
// Normt = input[i].fld004887,
|
||||
// Ferth = input[i].fld004882,
|
||||
// Zeinr = input[i].fld004881,
|
||||
// Mstae = input[i].fld004699,
|
||||
// Raube = input[i].fld004877,
|
||||
// Mhdrz = input[i].fld004876,
|
||||
// Mhdhb = input[i].fld004895.ToString(),
|
||||
// Werks = input[i].fld004325,
|
||||
// Beskz = input[i].fld004490,
|
||||
// Sobsl = input[i].fld004491,
|
||||
// Schgt = input[i].fld004873,
|
||||
// Rgekz = input[i].fld004872,
|
||||
// Zbom = input[i].fld004698
|
||||
// };
|
||||
// var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
// string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
// string msg = sapOutput.msg;
|
||||
|
||||
// if (sapOutput.msg == "")
|
||||
// {
|
||||
// msg = "同步成功";
|
||||
// }
|
||||
// db.CopyNew().Updateable<Obj110>()
|
||||
// .SetColumns(it => new Obj110
|
||||
// {
|
||||
// fld004629 = DateTime.Now,
|
||||
// fld004311 = codeVal,
|
||||
// fld004312 = "N",
|
||||
// fld004313 = msg
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommand();
|
||||
// var output = new SapOutput()
|
||||
// {
|
||||
// parameter = sapOutput.parameter,
|
||||
// materialCode = input[0]._System_objNBS,
|
||||
// code = codeVal,
|
||||
// msg = msg,
|
||||
// result = sapOutput.result
|
||||
// };
|
||||
// SapOutputList.Add(output);
|
||||
//}
|
||||
|
||||
//return SapOutputList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 产品管理-定时同步到SAP
|
||||
@ -460,22 +574,22 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAP()
|
||||
{
|
||||
var input = await _obj110Rep.AsQueryable()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1)
|
||||
&& x.fld005324 == "发布"
|
||||
&& x.deleted == false
|
||||
&& x.IsLatestVersion == true
|
||||
&& (x.fld004312 == "A" || x.fld004312 == "M"))
|
||||
.ToListAsync();
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var input = db.Queryable<Obj110>()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.fld005324 == "发布" && x.deleted == false && x.IsLatestVersion == true && (x.fld004312 == "A" || x.fld004312 == "M"))
|
||||
.ToList();
|
||||
const string lengthError = "物料描述长度大于40,请检查!";
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
|
||||
var tasks = input.Select(async item =>
|
||||
{
|
||||
// 验证物料描述长度
|
||||
if (input[i].fld004484.Length > 40)
|
||||
if (item.fld004484.Length > 40)
|
||||
{
|
||||
await _obj110Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
@ -483,17 +597,16 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
fld004313 = lengthError,
|
||||
fld004311 = "失败"
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync().ConfigureAwait(false);
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = lengthError,
|
||||
result = lengthError
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
@ -510,27 +623,27 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = input[i]._System_objNBS,
|
||||
Mbrsh = input[i].fld004323,
|
||||
Mtart = input[i].fld004324,
|
||||
Maktx = input[i].fld004484,
|
||||
Meins = input[i].fld004861,
|
||||
Matkl = input[i].fld004485,
|
||||
Bismt = input[i]._System_ObjDescription,
|
||||
Groes = input[i]._System_objNBS,
|
||||
Normt = input[i].fld004887,
|
||||
Ferth = input[i].fld004882,
|
||||
Zeinr = input[i].fld004881,
|
||||
Mstae = input[i].fld004699,
|
||||
Raube = input[i].fld004877,
|
||||
Mhdrz = input[i].fld004876.ToString(),
|
||||
Mhdhb = input[i].fld004895.ToString(),
|
||||
Werks = input[i].fld004325,
|
||||
Beskz = input[i].fld004490,
|
||||
Sobsl = input[i].fld004491,
|
||||
Schgt = input[i].fld004873,
|
||||
Rgekz = input[i].fld004872,
|
||||
Zbom = input[i].fld004698
|
||||
Matnr = item._System_objNBS,
|
||||
Mbrsh = item.fld004323,
|
||||
Mtart = item.fld004324,
|
||||
Maktx = item.fld004484,
|
||||
Meins = item.fld004861,
|
||||
Matkl = item.fld004485,
|
||||
Bismt = item._System_ObjDescription,
|
||||
Groes = item._System_objNBS,
|
||||
Normt = item.fld004887,
|
||||
Ferth = item.fld004882,
|
||||
Zeinr = item.fld004881,
|
||||
Mstae = item.fld004699,
|
||||
Raube = item.fld004877,
|
||||
Mhdrz = item.fld004876.ToString(),
|
||||
Mhdhb = item.fld004895.ToString(),
|
||||
Werks = item.fld004325,
|
||||
Beskz = item.fld004490,
|
||||
Sobsl = item.fld004491,
|
||||
Schgt = item.fld004873,
|
||||
Rgekz = item.fld004872,
|
||||
Zbom = item.fld004698
|
||||
};
|
||||
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
@ -540,28 +653,124 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj110Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
fld004311 = codeVal,
|
||||
fld004312 = "N",
|
||||
fld004313 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004629 = DateTime.Now,
|
||||
fld004311 = codeVal,
|
||||
fld004312 = "N",
|
||||
fld004313 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
return new SapOutput
|
||||
{
|
||||
parameter = sapOutput.parameter,
|
||||
materialCode = input[0]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = sapOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
|
||||
return SapOutputList;
|
||||
});
|
||||
|
||||
var materialOutput = await Task.WhenAll(tasks);
|
||||
return materialOutput.ToList();
|
||||
|
||||
|
||||
//for (int i = 0; i < input.Count; i++)
|
||||
//{
|
||||
// // 验证物料描述长度
|
||||
// if (input[i].fld004484.Length > 40)
|
||||
// {
|
||||
// await _obj110Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj110
|
||||
// {
|
||||
// fld004629 = DateTime.Now,
|
||||
// fld004312 = "N",
|
||||
// fld004313 = lengthError,
|
||||
// fld004311 = "失败"
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync().ConfigureAwait(false);
|
||||
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = lengthError,
|
||||
// result = lengthError
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
// string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
// var sapMaterialInput = new SapMaterialInput()
|
||||
// {
|
||||
// Reqkeyid = "",
|
||||
// Businessid = "",
|
||||
// Messageid = "",
|
||||
// Sndprn = "PLM",
|
||||
// Rcvprn = "SAP",
|
||||
// Requser = Requser,
|
||||
// Note1 = "",
|
||||
// Note2 = "",
|
||||
// Note3 = "",
|
||||
// Zwbid = millisecondTimestamp,
|
||||
// Matnr = input[i]._System_objNBS,
|
||||
// Mbrsh = input[i].fld004323,
|
||||
// Mtart = input[i].fld004324,
|
||||
// Maktx = input[i].fld004484,
|
||||
// Meins = input[i].fld004861,
|
||||
// Matkl = input[i].fld004485,
|
||||
// Bismt = input[i]._System_ObjDescription,
|
||||
// Groes = input[i]._System_objNBS,
|
||||
// Normt = input[i].fld004887,
|
||||
// Ferth = input[i].fld004882,
|
||||
// Zeinr = input[i].fld004881,
|
||||
// Mstae = input[i].fld004699,
|
||||
// Raube = input[i].fld004877,
|
||||
// Mhdrz = input[i].fld004876.ToString(),
|
||||
// Mhdhb = input[i].fld004895.ToString(),
|
||||
// Werks = input[i].fld004325,
|
||||
// Beskz = input[i].fld004490,
|
||||
// Sobsl = input[i].fld004491,
|
||||
// Schgt = input[i].fld004873,
|
||||
// Rgekz = input[i].fld004872,
|
||||
// Zbom = input[i].fld004698
|
||||
// };
|
||||
// var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
// string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
// string msg = sapOutput.msg;
|
||||
|
||||
// if (sapOutput.msg == "")
|
||||
// {
|
||||
// msg = "同步成功";
|
||||
// }
|
||||
// await _obj110Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj110
|
||||
// {
|
||||
// fld004629 = DateTime.Now,
|
||||
// fld004311 = codeVal,
|
||||
// fld004312 = "N",
|
||||
// fld004313 = msg
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync();
|
||||
// var output = new SapOutput()
|
||||
// {
|
||||
// parameter = sapOutput.parameter,
|
||||
// materialCode = input[0]._System_objNBS,
|
||||
// code = codeVal,
|
||||
// msg = msg,
|
||||
// result = sapOutput.result
|
||||
// };
|
||||
// SapOutputList.Add(output);
|
||||
//}
|
||||
|
||||
//return SapOutputList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 产品管理-定时同步 BOM 到 SAP
|
||||
@ -575,7 +784,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
var sapOutputList = new List<SapOutput>();
|
||||
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
// 配置
|
||||
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync();
|
||||
var configid = 1;
|
||||
|
||||
var materialData = await _obj110Rep.AsQueryable()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.fld005324 == "发布" && x.deleted == false && x.IsLatestVersion == true && x.fld004311 == "成功" && x.fld004312 == "N" && (x.fld004316 == "A" || x.fld004316 == "M"))
|
||||
@ -586,14 +795,13 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
|
||||
foreach (var item in groupedData)
|
||||
{
|
||||
|
||||
// 获取版本号
|
||||
var versionIndex = item.VersionIndex;
|
||||
// 获取 ECN guid
|
||||
var ecnGuid = item.fld004944_Rec;
|
||||
// 查询 BOM
|
||||
var bomData = await _configurationDataRep.AsQueryable()
|
||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex && (x.fld005586 != "不包含" || x.fld005586 == null)).ToListAsync();
|
||||
.Where(x => x.ConfigId == configid && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex && (x.fld005586 != "不包含" || x.fld005586 == null)).ToListAsync();
|
||||
if (bomData.Count == 0)
|
||||
{
|
||||
continue;
|
||||
@ -738,6 +946,144 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
}
|
||||
return sapOutputList;
|
||||
}
|
||||
/// <summary>
|
||||
///产品管理同步Bom到SAP
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SapOutput> SyncBomToSap(SyncBomData data)
|
||||
{
|
||||
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
var ecn = db.CopyNew().Queryable<Obj118>().Where(x => x.RecordGuid == data.ecnGuid).OrderByDescending(x => x.idRecord).First();
|
||||
if (ecn != null)
|
||||
{
|
||||
data.Ecn = ecn._System_objNBS;
|
||||
}
|
||||
var itemDataList = new List<ItemData>();
|
||||
foreach (var item in data.Bom)
|
||||
{
|
||||
var verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||
if (verification == "不存在")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var itemData = new ItemData
|
||||
{
|
||||
POSNR = (data.Bom.IndexOf(item) + 1).ToString(),
|
||||
IDNRK = item.PartNumber,
|
||||
MENGE = item.Quantity.ToString(),
|
||||
SORTF = item.SORTF,
|
||||
ITISOB = item.ITISOB,
|
||||
ALPGR = item.ALPGR,
|
||||
ALPRF = item.ALPRF,
|
||||
ZDELETE = item.ZDELETE,
|
||||
POSTP = item.POSTP,
|
||||
ZYFMK = item.ZYFMK
|
||||
};
|
||||
itemDataList.Add(itemData);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(data.SyncVersion))
|
||||
{
|
||||
var BomData = db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == 1 && x.ParentGuid == data.RecordGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(data.SyncVersion) && (x.fld005586 != "不包含" || x.fld005586 == null)).ToList();
|
||||
foreach (var item in BomData)
|
||||
{
|
||||
var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList();
|
||||
if (itemList.Count == 0)
|
||||
{
|
||||
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||
if (Verification == "不存在")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var itemData = new ItemData()
|
||||
{
|
||||
POSNR = "",//组件序号 sun.ToString()
|
||||
IDNRK = item.PartNumber,//组件物料号
|
||||
MENGE = item.Quantity.ToString(),//组件数量
|
||||
SORTF = item.fld004936,
|
||||
ITISOB = item.fld004937,
|
||||
ALPGR = item.fld004938,
|
||||
ALPRF = item.fld004939,
|
||||
ZDELETE = "X",
|
||||
POSTP = item.fld004492,
|
||||
ZYFMK = item.fld004941
|
||||
};
|
||||
itemDataList.Add(itemData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取时间戳精确到毫秒,sap 要求每次调用生成不重复 guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
var isreq = new IS_REQ
|
||||
{
|
||||
ReqKeyId = "",
|
||||
BusinessId = "",
|
||||
MessageId = "",
|
||||
SndPrn = "PLM",
|
||||
RcvPrn = "SAP",
|
||||
ReqUser = sapUserName,
|
||||
Note1 = "",
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = data.MaterialCode,
|
||||
Werks = data.Werks,
|
||||
Bmeng = data.Bmeng.ToString(),
|
||||
Aennr = data.Ecn,
|
||||
Datuv = data.Datuv.ToString(),
|
||||
ItemList = itemDataList
|
||||
};
|
||||
var apiOutput = await _sapService.SapBomApi(isreq);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
|
||||
if (codeVal == "成功")
|
||||
{
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004631 = DateTime.Now,
|
||||
fld004315 = codeVal,
|
||||
fld004316 = "N",
|
||||
fld004317 = apiOutput.msg,
|
||||
fld005288 = data.VersionIndex.ToString()
|
||||
})
|
||||
.Where(it => it.idRecord == data.Id)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004631 = DateTime.Now,
|
||||
fld004315 = codeVal,
|
||||
fld004316 = "N",
|
||||
fld004317 = apiOutput.msg
|
||||
})
|
||||
.Where(it => it.idRecord == data.Id)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
var msg = apiOutput.msg;
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
|
||||
var output = new SapOutput
|
||||
{
|
||||
parameter = apiOutput.parameter,
|
||||
materialCode = data.MaterialCode,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = apiOutput.result
|
||||
};
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产品管理-获取工艺路线
|
||||
@ -972,4 +1318,102 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
return sapOutputList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 产品管理同步工艺路线到sap
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SapOutput> SyncProcessRouteToSap(SyncProcessRouteData data)
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var itemDataList = new List<SapProcessRouteItemData>();
|
||||
foreach (var item in data.ProcessRouteList)
|
||||
{
|
||||
var verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||
if (verification == "不存在")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//获取工序描述
|
||||
var procedureDescription = db.CopyNew().Queryable<Obj122>().Where(x => x.RecordGuid == item.ChildGuid).First(); ;
|
||||
|
||||
//获取工作中心
|
||||
var workCenter = db.CopyNew().Queryable<Obj121>().Where(x => x.RecordGuid == procedureDescription.fld005059_Rec).First();
|
||||
|
||||
var itemData = new SapProcessRouteItemData()
|
||||
{
|
||||
VORNR = item.VORNR,
|
||||
LTXA1 = procedureDescription._System_ObjDescription,
|
||||
ARBPL = workCenter._System_objNBS,
|
||||
VGW01 = item.VGW01.ToString(),
|
||||
VGE01 = item.VGE01,
|
||||
STEUS = item.STEUS,
|
||||
BMSCH = item.BMSCH.ToString()
|
||||
|
||||
};
|
||||
itemDataList.Add(itemData);
|
||||
}
|
||||
|
||||
var Datuv = data.Datuv.ToString();
|
||||
|
||||
if (!string.IsNullOrEmpty(Datuv))
|
||||
{
|
||||
Datuv = data.Datuv.ToDateTime().ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
|
||||
var isreq = new SapProcessRouteIS_REQ()
|
||||
{
|
||||
ReqKeyId = "",
|
||||
BusinessId = "",
|
||||
MessageId = "",
|
||||
SndPrn = "PLM",
|
||||
RcvPrn = "SAP",
|
||||
ReqUser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
|
||||
Note1 = "",
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = data._System_objNBS,
|
||||
Werks = data.Werks,
|
||||
Datuv = Datuv,
|
||||
Plnal = "",
|
||||
|
||||
ItemList = itemDataList
|
||||
};
|
||||
|
||||
var apiOutput = await _sapService.SapProcessRouteApi(isreq);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
|
||||
db.CopyNew().Updateable<Obj110>()
|
||||
.SetColumns(it => new Obj110
|
||||
{
|
||||
fld004632 = DateTime.Now,
|
||||
fld004319 = codeVal,
|
||||
fld004320 = "N",
|
||||
fld004321 = apiOutput.msg
|
||||
})
|
||||
.Where(it => it.idRecord == data.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
var msg = apiOutput.msg;
|
||||
if (apiOutput.msg == "")
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
var output = new SapOutput()
|
||||
{
|
||||
parameter = apiOutput.parameter,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = apiOutput.result
|
||||
};
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -34,13 +36,15 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
public SapService.SapService _sapService;
|
||||
private readonly SqlSugarRepository<Configurations> _configurationsRep;
|
||||
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ProductionMaterialsManagementService(
|
||||
SqlSugarRepository<Obj112> obj112Rep,
|
||||
SysConfigService sysConfigService,
|
||||
SapService.SapService sapService,
|
||||
SqlSugarRepository<Configurations> configurationsRep,
|
||||
SqlSugarRepository<ConfigurationData> configurationDataRep
|
||||
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
||||
IServiceScopeFactory scopeFactory
|
||||
)
|
||||
{
|
||||
_obj112Rep = obj112Rep;
|
||||
@ -48,6 +52,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
_sapService = sapService;
|
||||
_configurationsRep = configurationsRep;
|
||||
_configurationDataRep = configurationDataRep;
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询生产物料管理
|
||||
@ -175,16 +180,20 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
[DisplayName("生产物料管理-批量同步到SAP")]
|
||||
public async Task<List<SapOutput>> BatchSyncToSAP(List<ProductionMaterialsManagementInput> input)
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
const string lengthError = "物料描述长度大于40,请检查!";
|
||||
const string synchronized = "该项目编号已同步或已停用!";
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
|
||||
var tasks = input.Select(async item =>
|
||||
{
|
||||
// 验证物料描述长度
|
||||
if (input[i].fld004598.Length > 40)
|
||||
if (item.fld004598.Length > 40)
|
||||
{
|
||||
await _obj112Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj112>()
|
||||
.SetColumns(it => new Obj112
|
||||
{
|
||||
fld004606 = DateTime.Now,
|
||||
@ -192,29 +201,29 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
fld004605 = lengthError,
|
||||
fld004604 = "失败"
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync().ConfigureAwait(false);
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = lengthError,
|
||||
result = lengthError
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
if (input[i].fld004607 == "N" || input[i].fld004607 == "D" || input[i].fld004607 == null)
|
||||
|
||||
if (item.fld004607 == "N" || item.fld004607 == "D" || item.fld004607 == null)
|
||||
{
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = synchronized,
|
||||
result = synchronized
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
var sapMaterialInput = new SapMaterialInput()
|
||||
@ -229,27 +238,27 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = input[i]._System_objNBS,
|
||||
Mbrsh = input[i].fld004595,
|
||||
Mtart = input[i].fld004596,
|
||||
Maktx = input[i].fld004598,
|
||||
Meins = input[i].fld004594,
|
||||
Matkl = input[i].fld004599,
|
||||
Bismt = input[i]._System_ObjDescription,
|
||||
Groes = input[i].fld005323,
|
||||
Normt = input[i].fld004592,
|
||||
Ferth = input[i].fld004593,
|
||||
Zeinr = input[i].fld004903,
|
||||
Mstae = input[i].fld004696,
|
||||
Raube = input[i].fld004904,
|
||||
Mhdrz = input[i].fld004905.ToString(),
|
||||
Mhdhb = input[i].fld004907.ToString(),
|
||||
Werks = input[i].fld004597,
|
||||
Beskz = input[i].fld004600,
|
||||
Sobsl = input[i].fld004601,
|
||||
Schgt = input[i].fld004602,
|
||||
Rgekz = input[i].fld004603,
|
||||
Zbom = input[i].fld004695
|
||||
Matnr = item._System_objNBS,
|
||||
Mbrsh = item.fld004595,
|
||||
Mtart = item.fld004596,
|
||||
Maktx = item.fld004598,
|
||||
Meins = item.fld004594,
|
||||
Matkl = item.fld004599,
|
||||
Bismt = item._System_ObjDescription,
|
||||
Groes = item.fld005323,
|
||||
Normt = item.fld004592,
|
||||
Ferth = item.fld004593,
|
||||
Zeinr = item.fld004903,
|
||||
Mstae = item.fld004696,
|
||||
Raube = item.fld004904,
|
||||
Mhdrz = item.fld004905.ToString(),
|
||||
Mhdhb = item.fld004907.ToString(),
|
||||
Werks = item.fld004597,
|
||||
Beskz = item.fld004600,
|
||||
Sobsl = item.fld004601,
|
||||
Schgt = item.fld004602,
|
||||
Rgekz = item.fld004603,
|
||||
Zbom = item.fld004695
|
||||
};
|
||||
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
@ -259,27 +268,130 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj112Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj112>()
|
||||
.SetColumns(it => new Obj112
|
||||
{
|
||||
fld004606 = DateTime.Now,
|
||||
fld004604 = codeVal,
|
||||
fld004607 = "N",
|
||||
fld004605 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
{
|
||||
fld004606 = DateTime.Now,
|
||||
fld004604 = codeVal,
|
||||
fld004607 = "N",
|
||||
fld004605 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
return new SapOutput()
|
||||
{
|
||||
parameter = sapOutput.parameter,
|
||||
materialCode = input[0]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = sapOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
return SapOutputList;
|
||||
|
||||
});
|
||||
var materialOutput = await Task.WhenAll(tasks);
|
||||
return materialOutput.ToList();
|
||||
//for (int i = 0; i < input.Count; i++)
|
||||
//{
|
||||
// // 验证物料描述长度
|
||||
// if (input[i].fld004598.Length > 40)
|
||||
// {
|
||||
// await _obj112Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj112
|
||||
// {
|
||||
// fld004606 = DateTime.Now,
|
||||
// fld004607 = "N",
|
||||
// fld004605 = lengthError,
|
||||
// fld004604 = "失败"
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync().ConfigureAwait(false);
|
||||
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = lengthError,
|
||||
// result = lengthError
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
// if (input[i].fld004607 == "N" || input[i].fld004607 == "D" || input[i].fld004607 == null)
|
||||
// {
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = synchronized,
|
||||
// result = synchronized
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
// //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
// string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
// var sapMaterialInput = new SapMaterialInput()
|
||||
// {
|
||||
// Reqkeyid = "",
|
||||
// Businessid = "",
|
||||
// Messageid = "",
|
||||
// Sndprn = "PLM",
|
||||
// Rcvprn = "SAP",
|
||||
// Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
|
||||
// Note1 = "",
|
||||
// Note2 = "",
|
||||
// Note3 = "",
|
||||
// Zwbid = millisecondTimestamp,
|
||||
// Matnr = input[i]._System_objNBS,
|
||||
// Mbrsh = input[i].fld004595,
|
||||
// Mtart = input[i].fld004596,
|
||||
// Maktx = input[i].fld004598,
|
||||
// Meins = input[i].fld004594,
|
||||
// Matkl = input[i].fld004599,
|
||||
// Bismt = input[i]._System_ObjDescription,
|
||||
// Groes = input[i].fld005323,
|
||||
// Normt = input[i].fld004592,
|
||||
// Ferth = input[i].fld004593,
|
||||
// Zeinr = input[i].fld004903,
|
||||
// Mstae = input[i].fld004696,
|
||||
// Raube = input[i].fld004904,
|
||||
// Mhdrz = input[i].fld004905.ToString(),
|
||||
// Mhdhb = input[i].fld004907.ToString(),
|
||||
// Werks = input[i].fld004597,
|
||||
// Beskz = input[i].fld004600,
|
||||
// Sobsl = input[i].fld004601,
|
||||
// Schgt = input[i].fld004602,
|
||||
// Rgekz = input[i].fld004603,
|
||||
// Zbom = input[i].fld004695
|
||||
// };
|
||||
// var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
// string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
// string msg = sapOutput.msg;
|
||||
|
||||
// if (sapOutput.msg == "")
|
||||
// {
|
||||
// msg = "同步成功";
|
||||
// }
|
||||
// await _obj112Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj112
|
||||
// {
|
||||
// fld004606 = DateTime.Now,
|
||||
// fld004604 = codeVal,
|
||||
// fld004607 = "N",
|
||||
// fld004605 = msg
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync();
|
||||
// var output = new SapOutput()
|
||||
// {
|
||||
// parameter = sapOutput.parameter,
|
||||
// materialCode = input[0]._System_objNBS,
|
||||
// code = codeVal,
|
||||
// msg = msg,
|
||||
// result = sapOutput.result
|
||||
// };
|
||||
// SapOutputList.Add(output);
|
||||
//}
|
||||
//return SapOutputList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -291,18 +403,22 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAP()
|
||||
{
|
||||
var input = await _obj112Rep.AsQueryable()
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var input = db.Queryable<Obj112>()
|
||||
.Where(x => (x.CheckedStatus == 7 || x.CheckedStatus == 8) && x.deleted == false && x.IsLatestVersion == true && (x.fld004607 == "A" || x.fld004607 == "M") && x.fld004973 == "发布")
|
||||
.ToListAsync();
|
||||
.ToList();
|
||||
const string lengthError = "物料描述长度大于40,请检查!";
|
||||
var SapOutputList = new List<SapOutput>();
|
||||
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
|
||||
var tasks = input.Select(async item =>
|
||||
{
|
||||
// 验证物料描述长度
|
||||
if (input[i].fld004598.Length > 40)
|
||||
if (item.fld004598.Length > 40)
|
||||
{
|
||||
await _obj112Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj112>()
|
||||
.SetColumns(it => new Obj112
|
||||
{
|
||||
fld004606 = DateTime.Now,
|
||||
@ -310,17 +426,16 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
fld004605 = lengthError,
|
||||
fld004604 = "失败"
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync().ConfigureAwait(false);
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
SapOutputList.Add(new SapOutput()
|
||||
return new SapOutput
|
||||
{
|
||||
materialCode = input[i]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = "失败",
|
||||
msg = lengthError,
|
||||
result = lengthError
|
||||
});
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
//获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
@ -337,27 +452,27 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
Note2 = "",
|
||||
Note3 = "",
|
||||
Zwbid = millisecondTimestamp,
|
||||
Matnr = input[i]._System_objNBS,
|
||||
Mbrsh = input[i].fld004595,
|
||||
Mtart = input[i].fld004596,
|
||||
Maktx = input[i].fld004598,
|
||||
Meins = input[i].fld004594,
|
||||
Matkl = input[i].fld004599,
|
||||
Bismt = input[i]._System_ObjDescription,
|
||||
Groes = input[i].fld005323,
|
||||
Normt = input[i].fld004592,
|
||||
Ferth = input[i].fld004593,
|
||||
Zeinr = input[i].fld004903,
|
||||
Mstae = input[i].fld004696,
|
||||
Raube = input[i].fld004904,
|
||||
Mhdrz = input[i].fld004905.ToString(),
|
||||
Mhdhb = input[i].fld004907.ToString(),
|
||||
Werks = input[i].fld004597,
|
||||
Beskz = input[i].fld004600,
|
||||
Sobsl = input[i].fld004601,
|
||||
Schgt = input[i].fld004602,
|
||||
Rgekz = input[i].fld004603,
|
||||
Zbom = input[i].fld004695
|
||||
Matnr = item._System_objNBS,
|
||||
Mbrsh = item.fld004595,
|
||||
Mtart = item.fld004596,
|
||||
Maktx = item.fld004598,
|
||||
Meins = item.fld004594,
|
||||
Matkl = item.fld004599,
|
||||
Bismt = item._System_ObjDescription,
|
||||
Groes = item.fld005323,
|
||||
Normt = item.fld004592,
|
||||
Ferth = item.fld004593,
|
||||
Zeinr = item.fld004903,
|
||||
Mstae = item.fld004696,
|
||||
Raube = item.fld004904,
|
||||
Mhdrz = item.fld004905.ToString(),
|
||||
Mhdhb = item.fld004907.ToString(),
|
||||
Werks = item.fld004597,
|
||||
Beskz = item.fld004600,
|
||||
Sobsl = item.fld004601,
|
||||
Schgt = item.fld004602,
|
||||
Rgekz = item.fld004603,
|
||||
Zbom = item.fld004695
|
||||
};
|
||||
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
@ -367,7 +482,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj112Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj112>()
|
||||
.SetColumns(it => new Obj112
|
||||
{
|
||||
fld004606 = DateTime.Now,
|
||||
@ -375,20 +490,114 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
|
||||
fld004607 = "N",
|
||||
fld004605 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
var output = new SapOutput()
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommand();
|
||||
|
||||
return new SapOutput()
|
||||
{
|
||||
parameter = sapOutput.parameter,
|
||||
materialCode = input[0]._System_objNBS,
|
||||
materialCode = item._System_objNBS,
|
||||
code = codeVal,
|
||||
msg = msg,
|
||||
result = sapOutput.result
|
||||
};
|
||||
SapOutputList.Add(output);
|
||||
}
|
||||
|
||||
return SapOutputList;
|
||||
});
|
||||
var materialOutput = await Task.WhenAll(tasks);
|
||||
return materialOutput.ToList();
|
||||
|
||||
//for (int i = 0; i < input.Count; i++)
|
||||
//{
|
||||
// // 验证物料描述长度
|
||||
// if (input[i].fld004598.Length > 40)
|
||||
// {
|
||||
// await _obj112Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj112
|
||||
// {
|
||||
// fld004606 = DateTime.Now,
|
||||
// fld004607 = "N",
|
||||
// fld004605 = lengthError,
|
||||
// fld004604 = "失败"
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync().ConfigureAwait(false);
|
||||
|
||||
// SapOutputList.Add(new SapOutput()
|
||||
// {
|
||||
// materialCode = input[i]._System_objNBS,
|
||||
// code = "失败",
|
||||
// msg = lengthError,
|
||||
// result = lengthError
|
||||
// });
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid
|
||||
// string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
|
||||
// var sapMaterialInput = new SapMaterialInput()
|
||||
// {
|
||||
// Reqkeyid = "",
|
||||
// Businessid = "",
|
||||
// Messageid = "",
|
||||
// Sndprn = "PLM",
|
||||
// Rcvprn = "SAP",
|
||||
// Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
|
||||
// Note1 = "",
|
||||
// Note2 = "",
|
||||
// Note3 = "",
|
||||
// Zwbid = millisecondTimestamp,
|
||||
// Matnr = input[i]._System_objNBS,
|
||||
// Mbrsh = input[i].fld004595,
|
||||
// Mtart = input[i].fld004596,
|
||||
// Maktx = input[i].fld004598,
|
||||
// Meins = input[i].fld004594,
|
||||
// Matkl = input[i].fld004599,
|
||||
// Bismt = input[i]._System_ObjDescription,
|
||||
// Groes = input[i].fld005323,
|
||||
// Normt = input[i].fld004592,
|
||||
// Ferth = input[i].fld004593,
|
||||
// Zeinr = input[i].fld004903,
|
||||
// Mstae = input[i].fld004696,
|
||||
// Raube = input[i].fld004904,
|
||||
// Mhdrz = input[i].fld004905.ToString(),
|
||||
// Mhdhb = input[i].fld004907.ToString(),
|
||||
// Werks = input[i].fld004597,
|
||||
// Beskz = input[i].fld004600,
|
||||
// Sobsl = input[i].fld004601,
|
||||
// Schgt = input[i].fld004602,
|
||||
// Rgekz = input[i].fld004603,
|
||||
// Zbom = input[i].fld004695
|
||||
// };
|
||||
// var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
|
||||
// string codeVal = sapOutput.code == "S" ? "成功" : "失败";
|
||||
// string msg = sapOutput.msg;
|
||||
|
||||
// if (sapOutput.msg == "")
|
||||
// {
|
||||
// msg = "同步成功";
|
||||
// }
|
||||
// await _obj112Rep.AsUpdateable()
|
||||
// .SetColumns(it => new Obj112
|
||||
// {
|
||||
// fld004606 = DateTime.Now,
|
||||
// fld004604 = codeVal,
|
||||
// fld004607 = "N",
|
||||
// fld004605 = msg
|
||||
// })
|
||||
// .Where(it => it.idRecord == input[i].idRecord)
|
||||
// .ExecuteCommandAsync();
|
||||
// var output = new SapOutput()
|
||||
// {
|
||||
// parameter = sapOutput.parameter,
|
||||
// materialCode = input[0]._System_objNBS,
|
||||
// code = codeVal,
|
||||
// msg = msg,
|
||||
// result = sapOutput.result
|
||||
// };
|
||||
// SapOutputList.Add(output);
|
||||
//}
|
||||
|
||||
//return SapOutputList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
||||
using RazorEngine;
|
||||
@ -423,10 +424,12 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
[ApiDescriptionSettings(Name = "TimingSyncToSAP"), HttpGet]
|
||||
[DisplayName("项目管理-定时同步到SAP")]
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAP()
|
||||
{
|
||||
var input = await _obj109Rep.AsQueryable()
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var input = await db.CopyNew().Queryable<Obj109>()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && (x.fld004510 == "A" || x.fld004510 == "M"))
|
||||
.ToListAsync();
|
||||
const string lengthError = "物料描述长度大于40,请检查!";
|
||||
@ -437,7 +440,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
// 验证物料描述长度
|
||||
if (input[i].fld004502.Length > 40)
|
||||
{
|
||||
await _obj109Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld004508 = DateTime.Now,
|
||||
@ -446,7 +449,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld004509 = "失败"
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync().ConfigureAwait(false);
|
||||
.ExecuteCommand();
|
||||
|
||||
SapOutputList.Add(new SapOutput()
|
||||
{
|
||||
@ -502,7 +505,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
{
|
||||
msg = "同步成功";
|
||||
}
|
||||
await _obj109Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld004508 = DateTime.Now,
|
||||
@ -511,7 +514,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld004507 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == input[i].idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
var output = new SapOutput()
|
||||
{
|
||||
parameter = sapOutput.parameter,
|
||||
@ -535,12 +538,13 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAPBom()
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var sapOutputList = new List<SapOutput>();
|
||||
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
// 配置
|
||||
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "mBOM").FirstAsync();
|
||||
|
||||
var materialData = await _obj109Rep.AsQueryable()
|
||||
var materialData = await db.CopyNew().Queryable<Obj109>()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && x.fld004510 == "N" && x.fld004509 == "成功" && (x.fld004514 == "A" || x.fld004514 == "M"))
|
||||
.ToListAsync();
|
||||
var groupedData = materialData.GroupBy(item => item.RecordGuid)
|
||||
@ -554,14 +558,14 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
// 获取 ECN guid
|
||||
var ecnGuid = item.fld004947_Rec;
|
||||
// 查询 BOM
|
||||
var bomData = await _configurationDataRep.AsQueryable()
|
||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync();
|
||||
var bomData = await db.CopyNew().Queryable<ConfigurationData>()
|
||||
.Where(x => x.ConfigId == 2 && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync();
|
||||
if (bomData.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 查询 ECN 编码
|
||||
var ecnData = await _obj118Rep.AsQueryable().Where(x => x.RecordGuid == ecnGuid && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
||||
var ecnData = await db.CopyNew().Queryable<Obj118>().Where(x => x.RecordGuid == ecnGuid && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
|
||||
var ecn = ecnData != null ? ecnData._System_objNBS : "";
|
||||
|
||||
var itemDataList = new List<ItemData>();
|
||||
@ -613,7 +617,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
|
||||
var apiOutput = await _sapService.SapBomApi(isreq);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
await _obj109Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld004513 = DateTime.Now,
|
||||
@ -622,7 +626,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld004512 = apiOutput.msg
|
||||
})
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
|
||||
var msg = apiOutput.msg;
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
@ -761,16 +765,17 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
/// <returns></returns>
|
||||
[ApiDescriptionSettings(Name = "TimingSyncToSAPProcessRoute"), HttpGet]
|
||||
[DisplayName("项目管理-定时同步工艺路线到SAP")]
|
||||
[AllowAnonymous]
|
||||
public async Task<List<SapOutput>> TimingSyncToSAPProcessRoute()
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
var sapOutputList = new List<SapOutput>();
|
||||
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
|
||||
// 配置
|
||||
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "pBOM").FirstAsync();
|
||||
|
||||
//查询需要同步的产品
|
||||
var materialData = await _obj109Rep.AsQueryable()
|
||||
var materialData = await db.CopyNew().Queryable<Obj109>()
|
||||
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && x.fld004510 == "N" && x.fld004509 == "成功" && (x.fld004514 == "A" || x.fld004514 == "M"))
|
||||
.ToListAsync();
|
||||
//分组查询最大版本的物料
|
||||
@ -783,8 +788,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
// 获取版本号
|
||||
var versionIndex = item.VersionIndex;
|
||||
// 查询 BOM
|
||||
var processRouteData = await _configurationDataRep.AsQueryable()
|
||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync();
|
||||
var processRouteData = await db.CopyNew().Queryable<ConfigurationData>()
|
||||
.Where(x => x.ConfigId == 5 && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync();
|
||||
if (processRouteData.Count == 0)
|
||||
{
|
||||
continue;
|
||||
@ -799,9 +804,9 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
continue;
|
||||
}
|
||||
//获取工序描述
|
||||
var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == processRouteItem.ChildGuid).ToListAsync();
|
||||
var procedureDescription = await db.CopyNew().Queryable<Obj122>().Where(x => x.RecordGuid == processRouteItem.ChildGuid).ToListAsync();
|
||||
//获取工作中心
|
||||
var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync();
|
||||
var workCenter = await db.CopyNew().Queryable<Obj121>().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync();
|
||||
var itemData = new SapProcessRouteItemData()
|
||||
{
|
||||
VORNR = processRouteItem.Marker,
|
||||
@ -846,7 +851,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
|
||||
var apiOutput = await _sapService.SapProcessRouteApi(isreq);
|
||||
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
|
||||
await _obj109Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld004518 = DateTime.Now,
|
||||
@ -855,7 +860,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld004516 = apiOutput.msg
|
||||
})
|
||||
.Where(it => it.idRecord == item.idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
var msg = apiOutput.msg;
|
||||
if (apiOutput.msg == "")
|
||||
{
|
||||
@ -881,9 +886,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
public async Task<List<SapOutput>> WbsInSapCreate()
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
var syncData = db.Queryable<Obj109>()
|
||||
var syncData = await db.CopyNew().Queryable<Obj109>()
|
||||
.InnerJoin<CasesStagesMain>((x, y) => x.RecordGuid == y.RecordGuid)
|
||||
.InnerJoin<Obj126>((x, y, z) => y.ChildRecordGuid == z.RecordGuid)
|
||||
.Where((x, y) => x.deleted == false && x.fld006774 == "A" && (x.fld006993 == "" || x.fld006993 == null) && (x.CheckedStatus == 0 || x.CheckedStatus == 1) && y.indentLevel < 4)
|
||||
@ -908,7 +912,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
System_objNBS109 = x._System_objNBS
|
||||
|
||||
})
|
||||
.ToList();
|
||||
.ToListAsync();
|
||||
var syncList = syncData.GroupBy(record => record.RecordGuid)
|
||||
.Select(group => new
|
||||
{
|
||||
@ -1157,9 +1161,13 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
}
|
||||
private async Task UpdateObj109(long idRecord, string msg, string creationState)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
if (creationState == "创建成功")
|
||||
{
|
||||
await _obj109Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld006775 = DateTime.Now,
|
||||
@ -1168,28 +1176,32 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld006993 = "成功"
|
||||
})
|
||||
.Where(it => it.idRecord == idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
}
|
||||
if (creationState == "修改成功" || creationState == "创建失败" || creationState == "修改失败")
|
||||
{
|
||||
await _obj109Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj109
|
||||
db.CopyNew().Updateable<Obj109>()
|
||||
.SetColumns(it => new Obj109
|
||||
{
|
||||
fld006775 = DateTime.Now,
|
||||
fld006774 = "N",
|
||||
fld006776 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task UpdateObj126(long idRecord, string msg, string creationState)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
|
||||
if (creationState == "创建成功")
|
||||
{
|
||||
await _obj126Rep.AsUpdateable()
|
||||
db.CopyNew().Updateable<Obj126>()
|
||||
.SetColumns(it => new Obj126
|
||||
{
|
||||
fld006772 = DateTime.Now,
|
||||
@ -1198,19 +1210,19 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld006990 = creationState
|
||||
})
|
||||
.Where(it => it.idRecord == idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
}
|
||||
if (creationState == "创建失败" || creationState == "修改成功"|| creationState == "修改失败")
|
||||
{
|
||||
await _obj126Rep.AsUpdateable()
|
||||
.SetColumns(it => new Obj126
|
||||
db.CopyNew().Updateable<Obj126>()
|
||||
.SetColumns(it => new Obj126
|
||||
{
|
||||
fld006772 = DateTime.Now,
|
||||
fld006771 = "N",
|
||||
fld006773 = msg
|
||||
})
|
||||
.Where(it => it.idRecord == idRecord)
|
||||
.ExecuteCommandAsync();
|
||||
.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1221,9 +1233,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
public async Task<List<SapOutput>> WbsInSapUpdate()
|
||||
{
|
||||
using var serviceScope = _scopeFactory.CreateScope();
|
||||
var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||
var syncData = db.Queryable<Obj109>()
|
||||
var syncData = await db.CopyNew().Queryable<Obj109>()
|
||||
.InnerJoin<CasesStagesMain>((x, y) => x.RecordGuid == y.RecordGuid)
|
||||
.InnerJoin<Obj126>((x, y, z) => y.ChildRecordGuid == z.RecordGuid)
|
||||
.Where((x, y) => x.deleted == false && x.fld006774 == "A" && (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.fld006993 == "成功" && y.indentLevel < 4) //&& (x.fld006776 == "" || x.fld006776 == null)
|
||||
@ -1251,7 +1262,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
|
||||
fld006771=z.fld006771
|
||||
|
||||
})
|
||||
.ToList();
|
||||
.ToListAsync();
|
||||
var syncList = syncData.GroupBy(record => record.RecordGuid)
|
||||
.Select(group => new
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user