😎研发采购申请服务,增加项目描述字段

This commit is contained in:
bairubing 2025-01-15 15:09:54 +08:00
parent 534b9b8aec
commit 12c38a51c7
2 changed files with 21 additions and 9 deletions

View File

@ -461,5 +461,6 @@ public class Obj119
/// </summary>
[SugarColumn(ColumnName = "fld006416", ColumnDescription = "", Length = -1)]
public string? fld006416 { get; set; }
public string? fld007052 { get; set; }
}

View File

@ -9,7 +9,10 @@ using Admin.NET.Core.Service;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NewLife.Xml;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@ -41,6 +44,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
public SqlSugarRepository<Obj122> _obj122Rep;
public SqlSugarRepository<Obj121> _obj121Rep;
public SqlSugarRepository<Obj81> _obj81Rep;
private readonly IServiceScopeFactory _scopeFactory;
public PurchasingRequisitionService(
SqlSugarRepository<Obj119> obj119Rep,
@ -53,7 +57,8 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
SqlSugarRepository<Obj122> obj122Rep,
SqlSugarRepository<Obj121> obj121Rep,
SqlSugarRepository<Obj109> obj109Rep,
SqlSugarRepository<Obj81> obj81Rep
SqlSugarRepository<Obj81> obj81Rep,
IServiceScopeFactory scopeFactory
)
{
@ -68,6 +73,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
_obj121Rep = obj121Rep;
_obj109Rep = obj109Rep;
_obj81Rep = obj81Rep;
_scopeFactory = scopeFactory;
}
/// <summary>
/// 创建研发采购申请
@ -75,6 +81,9 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
/// <returns></returns>
public async Task<List<SapOutput>> TimingSyncToSAPPurchasingRequisition()
{
using var serviceScope = _scopeFactory.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
var sapOutputList = new List<SapOutput>();
//获取Sap用户名
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
@ -83,7 +92,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
var configid = 10;
// 获取符合条件的采购申请单
var PurchasingRequisitionList = await _obj119Rep.AsQueryable().Where(x => x.fld006416 == "A" && x.deleted == false && x.CheckedStatus == false && x._System_CurrentStage == "结束").ToListAsync();
var PurchasingRequisitionList = await db.CopyNew().Queryable<Obj119>().Where(x => x.fld006416 == "A" && x.deleted == false && x.CheckedStatus == false && x._System_CurrentStage == "结束").ToListAsync();
foreach (var item in PurchasingRequisitionList)
{
@ -110,8 +119,8 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
};
//查询BOM
var bomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configid && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == item.VersionIndex).ToListAsync();
var project = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == item.fld004639_Rec && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
var bomData = await db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == configid && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == item.VersionIndex).ToListAsync();
var project = await db.CopyNew().Queryable<Obj119>().Where(x => x.RecordGuid == item.fld004639_Rec && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
foreach (var bomItem in bomData)
{
var unit = await _dataValidationService.GetUnit(bomItem.ChildObjID, bomItem.ChildGuid);
@ -133,7 +142,9 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
Ekorg = bomItem.fld006147,
Zzpspnr = project._System_objNBS,
Afnam = item.fld006125,
Loekz = bomItem.fld006141
Loekz = bomItem.fld006141,
Ztext = item.fld007052
};
itemList.Add(Item);
}
@ -148,7 +159,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
}
if (item.fld006139 == "I")
{
await _obj119Rep.AsUpdateable()
db.CopyNew().Updateable<Obj119>()
.SetColumns(it => new Obj119
{
fld005934 = DateTime.Now,//同步日期
@ -158,11 +169,11 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
fld006138 = sapOutput.banfn//采购申请编号
})
.Where(it => it.idRecord == item.idRecord)
.ExecuteCommandAsync();
.ExecuteCommand();
}
if (item.fld006139 == "U")
{
await _obj119Rep.AsUpdateable()
db.CopyNew().Updateable<Obj119>()
.SetColumns(it => new Obj119
{
fld005934 = DateTime.Now,//同步日期
@ -171,7 +182,7 @@ public class PurchasingRequisitionService : IDynamicApiController, ITransient
fld005935 = msg//同步信息
})
.Where(it => it.idRecord == item.idRecord)
.ExecuteCommandAsync();
.ExecuteCommand();
}
var output = new SapOutput()
{