😎项目管理功能实现

This commit is contained in:
bairubing 2024-09-26 00:21:59 +08:00
parent 174fb2b4f2
commit 1ba505ed19
12 changed files with 2460 additions and 89 deletions

View File

@ -27,7 +27,7 @@ public class Obj109
///
/// </summary>
[SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")]
public bool? CheckedStatus { get; set; }
public int? CheckedStatus { get; set; }
/// <summary>
///

View File

@ -178,7 +178,6 @@ public class ProductManagementBomOutput
/// <summary>
///
/// </summary>
[Required]
public long ParentObjectID { get; set; }
/// <summary>
@ -300,7 +299,6 @@ public class ProductManagementBomOutput
/// <summary>
///
/// </summary>
[Required]
public bool isAddedFromSW { get; set; }
/// <summary>
@ -321,19 +319,16 @@ public class ProductManagementBomOutput
/// <summary>
///
/// </summary>
[Required]
public bool inContext { get; set; }
/// <summary>
///
/// </summary>
[Required]
public string PrimaryFile { get; set; }
/// <summary>
///
/// </summary>
[Required]
public bool bKeepQuantityInSync { get; set; }
/// <summary>
@ -344,7 +339,6 @@ public class ProductManagementBomOutput
/// <summary>
///
/// </summary>
[Required]
public bool IsPDMReference { get; set; }
/// <summary>
@ -453,11 +447,6 @@ public class ProductManagementBomOutput
public string? fld005020 { get; set; }
}
//public class ProductManagementBomTypeOutput
//{
// public long Id { get; set; }
// public string Name { get; set; }
//}

View File

@ -1,49 +1,16 @@
using Admin.NET.Core;
using COSXML.Model.Tag;
using DocumentFormat.OpenXml.Drawing.Diagrams;
using Elastic.Clients.Elasticsearch;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NewLife.Remoting;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Http.Headers;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Vistar.Application.Const;
using Vistar.Application.Entity;
using Vistar.Application.Service.MaterialManagement.Dto;
using System.Net.Security;
using Org.BouncyCastle.Ocsp;
using System.Net.Http;
using NewLife.Configuration;
using Furion;
using Admin.NET.Core.Service;
using Vistar.Application.Util;
using Microsoft.Extensions.Options;
using Vistar.Application.SapService.Dto;
using DocumentFormat.OpenXml.ExtendedProperties;
using Vistar.Application.SapService;
using static SKIT.FlurlHttpClient.Wechat.Api.Models.ComponentTCBBatchCreateContainerServiceVersionRequest.Types;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using static COSXML.Model.Object.SelectObjectResult;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using Vistar.Application.Common;
using static Elastic.Clients.Elasticsearch.JoinField;
using OfficeOpenXml.FormulaParsing.Logging;
using Furion.Logging;
using static Org.BouncyCastle.Math.Primes;
namespace Vistar.Application.Service.MaterialManagement;
@ -66,7 +33,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
SqlSugarRepository<Configurations> configurationsRep,
SysConfigService sysConfigService,
SqlSugarRepository<ConfigurationData> configurationDataRep,
SapService.SapService sapBomService,
SapService.SapService sapService,
SqlSugarRepository<Obj118> obj118Rep,
DataValidationService dataValidationService
@ -76,7 +43,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
_configurationsRep = configurationsRep;
_sysConfigService = sysConfigService;
_configurationDataRep = configurationDataRep;
_sapService = sapBomService;
_sapService = sapService;
_obj118Rep = obj118Rep;
_dataValidationService = dataValidationService;
}
@ -99,26 +66,6 @@ public class ProductManagementService : IDynamicApiController, ITransient
.ToPagedListAsync(input.Page, input.PageSize);
return query;
}
///// <summary>
///// 获取BOM类型
///// </summary>
///// <returns></returns>
//[HttpGet]
//public async Task<List<ProductManagementBomTypeOutput>> BomType()
//{
// var BomType = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110).ToListAsync();
// var BomTypeData = new List<ProductManagementBomTypeOutput>();
// for (int i = 0; i < BomType.Count; i++)
// {
// var data = new ProductManagementBomTypeOutput()
// {
// Id = BomType[i].ConfigID,
// Name = BomType[i].ConfigLabel
// };
// BomTypeData.Add(data);
// }
// return BomTypeData;
//}
/// <summary>
/// 产品管理-同步到 SAP
@ -128,7 +75,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
[DisplayName("产品管理-同步到 SAP")]
public async Task<SapOutput> SyncToSAP(ProductManagementBaseInput input)
{
const string lengthError = "物料编码长度大于40请检查";
const string lengthError = "物料描述长度大于40请检查";
// 验证物料描述长度
if (input.fld004484.Length > 40)
@ -138,7 +85,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
{
fld004629 = DateTime.Now,
fld004312 = "N",
fld004313 = lengthError
fld004313 = lengthError,
fld004311="失败"
})
.Where(it => it.idRecord == input.idRecord)
.ExecuteCommandAsync().ConfigureAwait(false);
@ -334,7 +282,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
[DisplayName("产品管理-批量同步到SAP")]
public async Task<List<SapOutput>> BatchSyncToSAP(List<ProductManagementBaseInput> input)
{
const string lengthError = "物料编码长度大于40请检查";
const string lengthError = "物料描述长度大于40请检查";
const string synchronized = "该物料编码已同步!";
var SapOutputList = new List<SapOutput>();
var Requser = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
@ -348,7 +296,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
{
fld004629 = DateTime.Now,
fld004312 = "N",
fld004313 = lengthError
fld004313 = lengthError,
fld004311 = "失败"
})
.Where(it => it.idRecord == input[i].idRecord)
.ExecuteCommandAsync().ConfigureAwait(false);
@ -452,7 +401,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
var input = await _obj110Rep.AsQueryable()
.Where(x => x.CheckedStatus == false && x.deleted == false && x.IsLatestVersion == true && (x.fld004312 == "A" || x.fld004312 == "M"))
.ToListAsync();
const string lengthError = "物料编码长度大于40请检查";
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++)
@ -465,7 +414,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
{
fld004629 = DateTime.Now,
fld004312 = "N",
fld004313 = lengthError
fld004313 = lengthError,
fld004311 = "失败"
})
.Where(it => it.idRecord == input[i].idRecord)
.ExecuteCommandAsync().ConfigureAwait(false);

View File

@ -0,0 +1,199 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Admin.NET.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vistar.Application.Service.ProjectManagement.Dto;
public class BomProjectManagementInput : BasePageInput
{
/// <summary>
/// 子物料描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 子物料编码
/// </summary>
public string? PartNumber { get; set; }
/// <summary>
/// 父Guid
/// </summary>
public string ParentGuid { get; set; }
public string ChildGuid { get; set; }
public long ChildObjID { get; set; }
public long ConfigId { get; set; }
public int? childVersion { get; set; }
public int ParentVersion { get; set; }
public bool? isDeleted { get; set; }
public long ConfigInstanceID { get; set; }
public long? ChildConfigID { get; set; }
public long? CreatedUserID { get; set; }
public long? ModifiedUserID { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? ModifiedDate { get; set; }
public double? Quantity { get; set; }
public DateTime? EffectiveFrom { get; set; }
public DateTime? EffectiveTo { get; set; }
public string? Revision { get; set; }
public string? Marker { get; set; }
public string Type { get; set; }
public long? ConfigParent { get; set; }
public long? OrderIndex { get; set; }
public string? _conf_24_tralala { get; set; }
public string? _conf_28_hello { get; set; }
public string? _conf_28_sss { get; set; }
public string? conf_29_sss { get; set; }
public byte[]? RecordImage { get; set; }
public string? Folder { get; set; }
public int? CheckedStatus { get; set; }
public string? _TestConfigurimi_tralala { get; set; }
public string? _TestConfigurimi_asfasd { get; set; }
public long ParentObjectID { get; set; }
public string? conf_30_somefields { get; set; }
public string? conf_30_TestNBS { get; set; }
public DateTime? conf_30_testDate { get; set; }
public long? conf_30_testNumber { get; set; }
public string? conf_30_TestList { get; set; }
public long? conf_30_testListNo { get; set; }
public double? conf_30_testListdecimal { get; set; }
public string? conf_33_Comments { get; set; }
//public string? conf_33_SerialNo. { get; set; }
public string? conf_33_SerialNo { get; set; }
public long? conf_33_TestContacts2 { get; set; }
public long? conf_33_TestContacts2_Rec { get; set; }
public string? conf_6_Comments { get; set; }
public string? conf_6_SerialNumber { get; set; }
public int? ChildSwFileType { get; set; }
public int? ParentSwFileType { get; set; }
public string? conf_19_Serial { get; set; }
public string? conf_19_Comments { get; set; }
public string? conf_21_Comments { get; set; }
public string? conf_19_testList { get; set; }
public string? conf_21_BuyStage { get; set; }
public string? conf_19_testconfigfieldnbs { get; set; }
public string? conf_32_Comments { get; set; }
public bool? isSuppressed { get; set; }
public bool isAddedFromSW { get; set; }
public double? QtyManual { get; set; }
public long? SWPDMXrefId { get; set; }
public string? SwConfiguration { get; set; }
public bool inContext { get; set; }
public string PrimaryFile { get; set; }
public bool bKeepQuantityInSync { get; set; }
public string? BOMGuid { get; set; }
public bool IsPDMReference { get; set; }
public string? BOMGuidCopiedFrom { get; set; }
public int? SWPDMXRefConfigurationID { get; set; }
public string? SWPDMXRefConfigurationName { get; set; }
public string? fld004492 { get; set; }
public string? fld004670 { get; set; }
public string? fld004671 { get; set; }
public string? fld004691 { get; set; }
public string? fld004936 { get; set; }
public string? fld004937 { get; set; }
public string? fld004938 { get; set; }
public string? fld004939 { get; set; }
public string? fld004940 { get; set; }
public string? fld004941 { get; set; }
public double? fld004994 { get; set; }
public string? fld004995 { get; set; }
public string? fld004996 { get; set; }
public string? fld004997 { get; set; }
public double? fld005017 { get; set; }
public string? fld005018 { get; set; }
public string? fld005019 { get; set; }
public string? fld005020 { get; set; }
}

View File

@ -0,0 +1,446 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vistar.Application.Service.ProjectManagement.Dto;
public class ProjectManagementBomOutput
{
/// <summary>
///
/// </summary>
public string ParentGuid { get; set; }
/// <summary>
///
/// </summary>
public string ChildGuid { get; set; }
/// <summary>
///
/// </summary>
public long ChildObjID { get; set; }
/// <summary>
///
/// </summary>
public long ConfigId { get; set; }
/// <summary>
///
/// </summary>
public int? childVersion { get; set; }
/// <summary>
///
/// </summary>
public int ParentVersion { get; set; }
/// <summary>
///
/// </summary>
public bool? isDeleted { get; set; }
/// <summary>
///
/// </summary>
public long ConfigInstanceID { get; set; }
/// <summary>
///
/// </summary>
public long? ChildConfigID { get; set; }
/// <summary>
///
/// </summary>
public long? CreatedUserID { get; set; }
/// <summary>
///
/// </summary>
public long? ModifiedUserID { get; set; }
/// <summary>
///
/// </summary>
public DateTime? CreatedDate { get; set; }
/// <summary>
///
/// </summary>
public DateTime? ModifiedDate { get; set; }
/// <summary>
///
/// </summary>
public double? Quantity { get; set; }
/// <summary>
///
/// </summary>
public string? Description { get; set; }
/// <summary>
///
/// </summary>
public DateTime? EffectiveFrom { get; set; }
/// <summary>
///
/// </summary>
public DateTime? EffectiveTo { get; set; }
/// <summary>
///
/// </summary>
public string? Revision { get; set; }
/// <summary>
///
/// </summary>
public string? Marker { get; set; }
/// <summary>
///
/// </summary>
public string Type { get; set; }
/// <summary>
///
/// </summary>
public long? ConfigParent { get; set; }
/// <summary>
///
/// </summary>
public long? OrderIndex { get; set; }
/// <summary>
///
/// </summary>
public string? PartNumber { get; set; }
/// <summary>
///
/// </summary>
public string? _conf_24_tralala { get; set; }
/// <summary>
///
/// </summary>
public string? _conf_28_hello { get; set; }
/// <summary>
///
/// </summary>
public string? _conf_28_sss { get; set; }
/// <summary>
///
/// </summary>
public string? conf_29_sss { get; set; }
/// <summary>
///
/// </summary>
public byte[]? RecordImage { get; set; }
/// <summary>
///
/// </summary>
public string? Folder { get; set; }
/// <summary>
///
/// </summary>
public int? CheckedStatus { get; set; }
/// <summary>
///
/// </summary>
public string? _TestConfigurimi_tralala { get; set; }
/// <summary>
///
/// </summary>
public string? _TestConfigurimi_asfasd { get; set; }
/// <summary>
///
/// </summary>
public long ParentObjectID { get; set; }
/// <summary>
///
/// </summary>
public string? conf_30_somefields { get; set; }
/// <summary>
///
/// </summary>
public string? conf_30_TestNBS { get; set; }
/// <summary>
///
/// </summary>
public DateTime? conf_30_testDate { get; set; }
/// <summary>
///
/// </summary>
public long? conf_30_testNumber { get; set; }
/// <summary>
///
/// </summary>
public string? conf_30_TestList { get; set; }
/// <summary>
///
/// </summary>
public long? conf_30_testListNo { get; set; }
/// <summary>
///
/// </summary>
public double? conf_30_testListdecimal { get; set; }
/// <summary>
///
/// </summary>
public string? conf_33_Comments { get; set; }
/// <summary>
///
/// </summary>
//public string? conf_33_SerialNo. { get; set; }
public string? conf_33_SerialNo { get; set; }
/// <summary>
///
/// </summary>
public long? conf_33_TestContacts2 { get; set; }
/// <summary>
///
/// </summary>
public long? conf_33_TestContacts2_Rec { get; set; }
/// <summary>
///
/// </summary>
public string? conf_6_Comments { get; set; }
/// <summary>
///
/// </summary>
public string? conf_6_SerialNumber { get; set; }
/// <summary>
///
/// </summary>
public int? ChildSwFileType { get; set; }
/// <summary>
///
/// </summary>
public int? ParentSwFileType { get; set; }
/// <summary>
///
/// </summary>
public string? conf_19_Serial { get; set; }
/// <summary>
///
/// </summary>
public string? conf_19_Comments { get; set; }
/// <summary>
///
/// </summary>
public string? conf_21_Comments { get; set; }
/// <summary>
///
/// </summary>
public string? conf_19_testList { get; set; }
/// <summary>
///
/// </summary>
public string? conf_21_BuyStage { get; set; }
/// <summary>
///
/// </summary>
public string? conf_19_testconfigfieldnbs { get; set; }
/// <summary>
///
/// </summary>
public string? conf_32_Comments { get; set; }
/// <summary>
///
/// </summary>
public bool? isSuppressed { get; set; }
/// <summary>
///
/// </summary>
public bool isAddedFromSW { get; set; }
/// <summary>
///
/// </summary>
public double? QtyManual { get; set; }
/// <summary>
///
/// </summary>
public long? SWPDMXrefId { get; set; }
/// <summary>
///
/// </summary>
public string? SwConfiguration { get; set; }
/// <summary>
///
/// </summary>
public bool inContext { get; set; }
/// <summary>
///
/// </summary>
public string PrimaryFile { get; set; }
/// <summary>
///
/// </summary>
public bool bKeepQuantityInSync { get; set; }
/// <summary>
///
/// </summary>
public string? BOMGuid { get; set; }
/// <summary>
///
/// </summary>
public bool IsPDMReference { get; set; }
/// <summary>
///
/// </summary>
public string? BOMGuidCopiedFrom { get; set; }
/// <summary>
///
/// </summary>
public int? SWPDMXRefConfigurationID { get; set; }
/// <summary>
///
/// </summary>
public string? SWPDMXRefConfigurationName { get; set; }
/// <summary>
///
/// </summary>
public string? fld004492 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004670 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004671 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004691 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004936 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004937 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004938 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004939 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004940 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004941 { get; set; }
/// <summary>
///
/// </summary>
public double? fld004994 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004995 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004996 { get; set; }
/// <summary>
///
/// </summary>
public string? fld004997 { get; set; }
/// <summary>
///
/// </summary>
public double? fld005017 { get; set; }
/// <summary>
///
/// </summary>
public string? fld005018 { get; set; }
/// <summary>
///
/// </summary>
public string? fld005019 { get; set; }
/// <summary>
///
/// </summary>
public string? fld005020 { get; set; }
}

View File

@ -0,0 +1,399 @@
using Admin.NET.Core;
using DocumentFormat.OpenXml.Office2010.Word;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vistar.Application.Service.ProjectManagement.Dto;
/// <summary>
/// 项目管理基础输入参数
/// </summary>
public class ProjectManagementInput
{
public long idRecord { get; set; }
public int? CheckedStatus { get; set; }
public int? VersionIndex { get; set; }
public bool? IsLatestVersion { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? VersionCreatedDate { get; set; }
public DateTime? dateModified { get; set; }
public long? UserCreatedId { get; set; }
public long? VersionUserCreatedId { get; set; }
public long? UserModifiedId { get; set; }
public string? RecordGuid { get; set; }
public bool? isVisibilityNormal { get; set; }
public bool? deleted { get; set; }
public string? SubObjectGuid { get; set; }
public bool? PreviousStatus { get; set; }
public string? revision { get; set; }
public byte[]? Record_image160_160 { get; set; }
public byte[]? Record_Image320_240 { get; set; }
public byte[]? Record_ImageMax { get; set; }
public string? _System_objNBS { get; set; }
public string? _System_ObjDescription { get; set; }
public DateTime? _System_Effectivity_Begin { get; set; }
public DateTime? _System_Effectivity_End { get; set; }
public string? CheckedOutPc { get; set; }
public long? StageId { get; set; }
public long? ProjectManager { get; set; }
public string? ProjectManager_Rec { get; set; }
public long? GroupObjId { get; set; }
public bool? EnableNotifications { get; set; }
public bool? _CheckOutInProgress { get; set; }
public string _System_ObjNbsAuto { get; set; }
public double? WorkHoursMon { get; set; }
public double? WorkHoursTue { get; set; }
public double? WorkHoursWed { get; set; }
public double? WorkHoursThu { get; set; }
public double? WorkHoursFri { get; set; }
public double? WorkHoursSat { get; set; }
public double? WorkHoursSun { get; set; }
public string? DefaultStartTime { get; set; }
public bool? WeekStartDay { get; set; }
public bool? DurationUnits { get; set; }
public bool? MoveUnEditedTask { get; set; }
public bool? MoveEditedTask { get; set; }
public bool? UpdateProgressFromTasks { get; set; }
public bool IsAutomaticScheduling { get; set; }
public string? _System_DerivedFrom { get; set; }
public string? _System_DerivedFrom_RecordGuid { get; set; }
public string? _System_WebLink { get; set; }
public double? _System_Progress { get; set; }
public bool? isReleasedVersion { get; set; }
public bool ShowHoursInDates { get; set; }
public double TimeIncrement { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public string? fld004481 { get; set; }
/// <summary>
/// 公司缩写
/// </summary>
public string? fld004482 { get; set; }
/// <summary>
/// 项目编号(设计)
/// </summary>
public string? fld004483 { get; set; }
/// <summary>
/// 项目描述
/// </summary>
public string? fld004502 { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime? fld004503 { get; set; }
/// <summary>
/// 预计完成日期
/// </summary>
public DateTime? fld004504 { get; set; }
/// <summary>
/// 实际完成日期
/// </summary>
public DateTime? fld004505 { get; set; }
/// <summary>
/// 项目状态
/// </summary>
public string? fld004506 { get; set; }
/// <summary>
/// 物料同步信息
/// </summary>
public string? fld004507 { get; set; }
/// <summary>
/// 物料同步日期
/// </summary>
public DateTime? fld004508 { get; set; }
/// <summary>
/// 物料同步状态
/// </summary>
public string? fld004509 { get; set; }
/// <summary>
/// 物料同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004510 { get; set; }
/// <summary>
/// BOM同步状态
/// </summary>
public string? fld004511 { get; set; }
/// <summary>
/// BOM同步信息
/// </summary>
public string? fld004512 { get; set; }
/// <summary>
/// BOM同步日期
/// </summary>
public DateTime? fld004513 { get; set; }
/// <summary>
/// BOM同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004514 { get; set; }
/// <summary>
/// 工艺同步状态
/// </summary>
public string? fld004515 { get; set; }
/// <summary>
/// 工艺同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004516 { get; set; }
/// <summary>
/// 工艺同步标识
/// </summary>
public string? fld004517 { get; set; }
/// <summary>
/// 工艺同步日期
/// </summary>
public DateTime? fld004518 { get; set; }
/// <summary>
/// 物料类型
/// </summary>
public string? fld004519 { get; set; }
/// <summary>
/// 物料组
/// </summary>
public string? fld004520 { get; set; }
/// <summary>
/// 行业领域
/// </summary>
public string? fld004521 { get; set; }
/// <summary>
/// 工厂
/// </summary>
public string? fld004522 { get; set; }
/// <summary>
/// 毛重
/// </summary>
public double? fld004523 { get; set; }
/// <summary>
/// 预算总额
/// </summary>
public double? fld004524 { get; set; }
/// <summary>
/// 已花费金额
/// </summary>
public double? fld004525 { get; set; }
/// <summary>
/// 剩余预算
/// </summary>
public string? fld004526 { get; set; }
/// <summary>
/// 客户编号
/// </summary>
public long? fld004545 { get; set; }
/// <summary>
/// 客户编号ID
/// </summary>
public string? fld004545_Rec { get; set; }
/// <summary>
/// 客户名称
/// </summary>
public string? fld004546 { get; set; }
/// <summary>
/// 项目经理
/// </summary>
public string? fld004547 { get; set; }
public long? fld004682 { get; set; }
public string? fld004682_Rec { get; set; }
public DateTime? fld004683 { get; set; }
public string? fld004684 { get; set; }
public string? fld004685 { get; set; }
public string? fld004686 { get; set; }
public long? fld004687 { get; set; }
public string? fld004687_Rec { get; set; }
public DateTime? fld004688 { get; set; }
public long? fld004689 { get; set; }
public string? fld004689_Rec { get; set; }
public DateTime? fld004690 { get; set; }
public string? fld004728 { get; set; }
public long? fld004866 { get; set; }
public string? fld004866_Rec { get; set; }
public long? fld004867 { get; set; }
public string? fld004867_Rec { get; set; }
public long? fld004868 { get; set; }
public string? fld004868_Rec { get; set; }
public DateTime? fld004869 { get; set; }
public DateTime? fld004870 { get; set; }
public DateTime? fld004871 { get; set; }
public long? fld004883 { get; set; }
public string? fld004883_Rec { get; set; }
public long? fld004884 { get; set; }
public string? fld004884_Rec { get; set; }
public long? fld004885 { get; set; }
public string? fld004885_Rec { get; set; }
public long? fld004886 { get; set; }
public string? fld004886_Rec { get; set; }
public string? fld004924 { get; set; }
public string? fld004925 { get; set; }
public string? fld004926 { get; set; }
public string? fld004927 { get; set; }
public string? fld004928 { get; set; }
public string? fld004929 { get; set; }
public string? fld004930 { get; set; }
public string? fld004931 { get; set; }
public string? fld004932 { get; set; }
public double? fld004933 { get; set; }
public double? fld004934 { get; set; }
public string? fld004935 { get; set; }
public long? fld004946 { get; set; }
public long? fld004947 { get; set; }
public string? fld004947_Rec { get; set; }
public string? fld004948 { get; set; }
public DateTime? fld004949 { get; set; }
public string? fld005040 { get; set; }
}
/// <summary>
/// 产品管理分页查询输入参数
/// </summary>
public class PageProjectManagementInput : BasePageInput
{
/// <summary>
/// 项目编号
/// </summary>
public string? _System_objNBS { get; set; }
/// <summary>
/// 项目描述
/// </summary>
public string? fld004502 { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? fld004683 { get; set; }
/// <summary>
/// 创建时间范围
/// </summary>
public DateTime?[] fld004683Range { get; set; }
}

View File

@ -0,0 +1,373 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vistar.Application.Service.ProjectManagement.Dto;
/// <summary>
/// 项目管理输出参数
/// </summary>
public class ProjectManagementOutput
{
public long idRecord { get; set; }
public int? CheckedStatus { get; set; }
public int? VersionIndex { get; set; }
public bool? IsLatestVersion { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? VersionCreatedDate { get; set; }
public DateTime? dateModified { get; set; }
public long? UserCreatedId { get; set; }
public long? VersionUserCreatedId { get; set; }
public long? UserModifiedId { get; set; }
public string? RecordGuid { get; set; }
public bool? isVisibilityNormal { get; set; }
public bool? deleted { get; set; }
public string? SubObjectGuid { get; set; }
public bool? PreviousStatus { get; set; }
public string? revision { get; set; }
public byte[]? Record_image160_160 { get; set; }
public byte[]? Record_Image320_240 { get; set; }
public byte[]? Record_ImageMax { get; set; }
public string? _System_objNBS { get; set; }
public string? _System_ObjDescription { get; set; }
public DateTime? _System_Effectivity_Begin { get; set; }
public DateTime? _System_Effectivity_End { get; set; }
public string? CheckedOutPc { get; set; }
public long? StageId { get; set; }
public long? ProjectManager { get; set; }
public string? ProjectManager_Rec { get; set; }
public long? GroupObjId { get; set; }
public bool? EnableNotifications { get; set; }
public bool? _CheckOutInProgress { get; set; }
public string _System_ObjNbsAuto { get; set; }
public double? WorkHoursMon { get; set; }
public double? WorkHoursTue { get; set; }
public double? WorkHoursWed { get; set; }
public double? WorkHoursThu { get; set; }
public double? WorkHoursFri { get; set; }
public double? WorkHoursSat { get; set; }
public double? WorkHoursSun { get; set; }
public string? DefaultStartTime { get; set; }
public bool? WeekStartDay { get; set; }
public bool? DurationUnits { get; set; }
public bool? MoveUnEditedTask { get; set; }
public bool? MoveEditedTask { get; set; }
public bool? UpdateProgressFromTasks { get; set; }
public bool IsAutomaticScheduling { get; set; }
public string? _System_DerivedFrom { get; set; }
public string? _System_DerivedFrom_RecordGuid { get; set; }
public string? _System_WebLink { get; set; }
public double? _System_Progress { get; set; }
public bool? isReleasedVersion { get; set; }
public bool ShowHoursInDates { get; set; }
public double TimeIncrement { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public string? fld004481 { get; set; }
/// <summary>
/// 公司缩写
/// </summary>
public string? fld004482 { get; set; }
/// <summary>
/// 项目编号(设计)
/// </summary>
public string? fld004483 { get; set; }
/// <summary>
/// 项目描述
/// </summary>
public string? fld004502 { get; set; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime? fld004503 { get; set; }
/// <summary>
/// 预计完成日期
/// </summary>
public DateTime? fld004504 { get; set; }
/// <summary>
/// 实际完成日期
/// </summary>
public DateTime? fld004505 { get; set; }
/// <summary>
/// 项目状态
/// </summary>
public string? fld004506 { get; set; }
/// <summary>
/// 物料同步信息
/// </summary>
public string? fld004507 { get; set; }
/// <summary>
/// 物料同步日期
/// </summary>
public DateTime? fld004508 { get; set; }
/// <summary>
/// 物料同步状态
/// </summary>
public string? fld004509 { get; set; }
/// <summary>
/// 物料同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004510 { get; set; }
/// <summary>
/// BOM同步状态
/// </summary>
public string? fld004511 { get; set; }
/// <summary>
/// BOM同步信息
/// </summary>
public string? fld004512 { get; set; }
/// <summary>
/// BOM同步日期
/// </summary>
public DateTime? fld004513 { get; set; }
/// <summary>
/// BOM同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004514 { get; set; }
/// <summary>
/// 工艺同步状态
/// </summary>
public string? fld004515 { get; set; }
/// <summary>
/// 工艺同步标识 A新增 M修改 D停用 N已处理
/// </summary>
public string? fld004516 { get; set; }
/// <summary>
/// 工艺同步标识
/// </summary>
public string? fld004517 { get; set; }
/// <summary>
/// 工艺同步日期
/// </summary>
public DateTime? fld004518 { get; set; }
/// <summary>
/// 物料类型
/// </summary>
public string? fld004519 { get; set; }
/// <summary>
/// 物料组
/// </summary>
public string? fld004520 { get; set; }
/// <summary>
/// 行业领域
/// </summary>
public string? fld004521 { get; set; }
/// <summary>
/// 工厂
/// </summary>
public string? fld004522 { get; set; }
/// <summary>
/// 毛重
/// </summary>
public double? fld004523 { get; set; }
/// <summary>
/// 预算总额
/// </summary>
public double? fld004524 { get; set; }
/// <summary>
/// 已花费金额
/// </summary>
public double? fld004525 { get; set; }
/// <summary>
/// 剩余预算
/// </summary>
public string? fld004526 { get; set; }
/// <summary>
/// 客户编号
/// </summary>
public long? fld004545 { get; set; }
/// <summary>
/// 客户编号ID
/// </summary>
public string? fld004545_Rec { get; set; }
/// <summary>
/// 客户名称
/// </summary>
public string? fld004546 { get; set; }
/// <summary>
/// 项目经理
/// </summary>
public string? fld004547 { get; set; }
public long? fld004682 { get; set; }
public string? fld004682_Rec { get; set; }
public DateTime? fld004683 { get; set; }
public string? fld004684 { get; set; }
public string? fld004685 { get; set; }
public string? fld004686 { get; set; }
public long? fld004687 { get; set; }
public string? fld004687_Rec { get; set; }
public DateTime? fld004688 { get; set; }
public long? fld004689 { get; set; }
public string? fld004689_Rec { get; set; }
public DateTime? fld004690 { get; set; }
public string? fld004728 { get; set; }
public long? fld004866 { get; set; }
public string? fld004866_Rec { get; set; }
public long? fld004867 { get; set; }
public string? fld004867_Rec { get; set; }
public long? fld004868 { get; set; }
public string? fld004868_Rec { get; set; }
public DateTime? fld004869 { get; set; }
public DateTime? fld004870 { get; set; }
public DateTime? fld004871 { get; set; }
public long? fld004883 { get; set; }
public string? fld004883_Rec { get; set; }
public long? fld004884 { get; set; }
public string? fld004884_Rec { get; set; }
public long? fld004885 { get; set; }
public string? fld004885_Rec { get; set; }
public long? fld004886 { get; set; }
public string? fld004886_Rec { get; set; }
public string? fld004924 { get; set; }
public string? fld004925 { get; set; }
public string? fld004926 { get; set; }
public string? fld004927 { get; set; }
public string? fld004928 { get; set; }
public string? fld004929 { get; set; }
public string? fld004930 { get; set; }
public string? fld004931 { get; set; }
public string? fld004932 { get; set; }
public double? fld004933 { get; set; }
public double? fld004934 { get; set; }
public string? fld004935 { get; set; }
public long? fld004946 { get; set; }
public long? fld004947 { get; set; }
public string? fld004947_Rec { get; set; }
public string? fld004948 { get; set; }
public DateTime? fld004949 { get; set; }
public string? fld005040 { get; set; }
}

View File

@ -0,0 +1,624 @@
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;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vistar.Application.Common;
using Vistar.Application.Const;
using Vistar.Application.Entity;
using Vistar.Application.SapService.Dto;
using Vistar.Application.Service.ProjectManagement.Dto;
using Vistar.Application.Util;
namespace Vistar.Application.Service.ProjectManagement;
/// <summary>
/// 项目管理服务
/// </summary>
[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "ProjectManagement", Order = 100)]
public class ProjectManagementService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Obj109> _obj109Rep;
private readonly SysConfigService _sysConfigService;
public SapService.SapService _sapService;
private readonly SqlSugarRepository<Configurations> _configurationsRep;
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
public SqlSugarRepository<Obj118> _obj118Rep;
public Common.DataValidationService _dataValidationService;
public ProjectManagementService(
SqlSugarRepository<Obj109> obj109Rep,
SysConfigService sysConfigService,
SapService.SapService sapService,
SqlSugarRepository<Configurations> configurationsRep,
SqlSugarRepository<ConfigurationData> configurationDataRep,
SqlSugarRepository<Obj118> obj118Rep,
DataValidationService dataValidationService
)
{
_obj109Rep = obj109Rep;
_sysConfigService = sysConfigService;
_sapService = sapService;
_configurationsRep = configurationsRep;
_configurationDataRep = configurationDataRep;
_obj118Rep = obj118Rep;
_dataValidationService = dataValidationService;
}
/// <summary>
/// 分页查询项目管理
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "page", Description = "分页查询", Order = 1000), HttpPost]
[DisplayName("分页查询项目管理")]
public async Task<SqlSugarPagedList<ProjectManagementOutput>> Page(PageProjectManagementInput input)
{
var query = await _obj109Rep.AsQueryable()
.Where(x => (x.CheckedStatus == 0||x.CheckedStatus==1) && x.deleted == false && x.IsLatestVersion == true&&x.fld005040=="发布")
.WhereIF(!string.IsNullOrWhiteSpace(input._System_objNBS), u => u._System_objNBS.Contains(input._System_objNBS.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.fld004502), u => u.fld004502.Contains(input.fld004502.Trim()))
.WhereIF(input.fld004683Range != null && input.fld004683Range.Length == 2, u => u.fld004683 >= input.fld004683Range[0] && u.fld004683 <= input.fld004683Range[1])
.Select<ProjectManagementOutput>()
.ToPagedListAsync(input.Page, input.PageSize);
return query;
}
/// <summary>
/// 项目管理-同步到 SAP
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "syncToSAP"), HttpPost]
[DisplayName("项目管理-同步到 SAP")]
public async Task<SapOutput> SyncToSAP(ProjectManagementInput input)
{
const string lengthError = "项目描述长度大于40请检查";
// 验证物料描述长度
if (input.fld004502.Length > 40)
{
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = "N",
fld004507 = lengthError,
fld004509="失败"
})
.Where(it => it.idRecord == input.idRecord)
.ExecuteCommandAsync().ConfigureAwait(false);
return new SapOutput
{
code = "失败",
msg = lengthError,
result = lengthError
};
}
//获取时间戳精确到毫秒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._System_objNBS,
Mbrsh = input.fld004521,
Mtart = input.fld004519,
Maktx = input.fld004502,
Meins = "",//sssssssss基本计量单位
Matkl = input.fld004520,
Bismt = input.fld004684,
Groes = input.fld004685,
Normt = input.fld004924,
Ferth = input.fld004925,
Zeinr = input.fld004926,
Mstae = "",//sssssssssss跨工厂物料状态
Raube = input.fld004932,
Mhdrz = input.fld004933.ToString(),
Mhdhb = input.fld004934.ToString(),
Werks = input.fld004522,
Beskz = input.fld004929,
Sobsl = input.fld004928,
Schgt = input.fld004930,
Rgekz = input.fld004931,
Zbom = input.fld004935
};
var apiOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
var msg = apiOutput.msg;
if (apiOutput.msg == "")
{
msg = "同步成功";
}
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = codeVal,
fld004507 = "N",
fld004509 = msg
})
.Where(it => it.idRecord == input.idRecord)
.ExecuteCommandAsync();
var output = new SapOutput()
{
parameter = apiOutput.parameter,
code = codeVal,
msg = msg,
result = apiOutput.result
};
return output;
}
/// <summary>
/// 项目管理-批量同步到SAP
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "BatchSyncToSAP"), HttpPost]
[DisplayName("项目管理-批量同步到SAP")]
public async Task<List<SapOutput>> BatchSyncToSAP(List<ProjectManagementInput> input)
{
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++)
{
// 验证物料描述长度
if (input[i].fld004502.Length > 40)
{
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = "N",
fld004507 = lengthError,
fld004509 = "失败"
})
.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].fld004510 == "N")
{
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].fld004521,
Mtart = input[i].fld004519,
Maktx = input[i].fld004502,
Meins = "",//sssssssss基本计量单位
Matkl = input[i].fld004520,
Bismt = input[i].fld004684,
Groes = input[i].fld004685,
Normt = input[i].fld004924,
Ferth = input[i].fld004925,
Zeinr = input[i].fld004926,
Mstae = "",//sssssssssss跨工厂物料状态
Raube = input[i].fld004932,
Mhdrz = input[i].fld004933.ToString(),
Mhdhb = input[i].fld004934.ToString(),
Werks = input[i].fld004522,
Beskz = input[i].fld004929,
Sobsl = input[i].fld004928,
Schgt = input[i].fld004930,
Rgekz = input[i].fld004931,
Zbom = input[i].fld004935
};
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
string msg = sapOutput.msg;
if (sapOutput.msg == "")
{
msg = "同步成功";
}
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = "N",
fld004507 = lengthError,
fld004509 = "失败"
})
.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
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "GetBOM", Description = "获取BOM", Order = 1000), HttpPost]
[DisplayName("获取BOM")]
public async Task<SqlSugarPagedList<ProjectManagementBomOutput>> GetBOM(BomProjectManagementInput input)
{
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "mBOM").FirstAsync();
var parent = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).MaxAsync(x => x.VersionIndex);
var BomData = await _configurationDataRep.AsQueryable()
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent)
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
.Select<ProjectManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
return BomData;
}
/// <summary>
/// 项目管理-Bom同步到SAP
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "SyncToSAPBom"), HttpPost]
[DisplayName("项目管理-Bom同步到SAP")]
public async Task<SapOutput> SyncToSAPBom(List<BomProjectManagementInput> input)
{
var ParentData = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input[0].ParentGuid && x.deleted == false && x.VersionIndex == input[0].ParentVersion).FirstAsync();
var EcnData = await _obj118Rep.AsQueryable().Where(x => x.RecordGuid == ParentData.fld004947_Rec && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync();
var ecn = "";
if (EcnData != null)
{
ecn = EcnData._System_objNBS;
}
var itemDataList = new List<ItemData>();
for (int i = 0; i < input.Count; i++)
{
var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
if (Verification == "不存在")
{
continue;
}
int sun = i + 1;
var itemData = new ItemData()
{
POSNR = sun.ToString(),//组件序号
IDNRK = input[i].PartNumber,//组件物料号
MENGE = input[i].Quantity.ToString(),//组件数量
SORTF = input[i].fld004936,
ITISOB = input[i].fld004937,
ALPGR = input[i].fld004938,
ALPRF = input[i].fld004939,
ZDELETE = input[i].fld004940,
POSTP = input[i].fld004492,
ZYFMK = input[i].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 = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName),
Note1 = "",
Note2 = "",
Note3 = "",
Zwbid = millisecondTimestamp,
Matnr = ParentData._System_objNBS,//父物料编码
Werks = ParentData.fld004522,//工厂
Bmeng = ParentData.fld004946.ToString(),
Aennr = ecn,
Datuv = ParentData.fld004949.ToString(),
ItemList = itemDataList
};
var apiOutput = await _sapService.SapBomApi(isreq);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004513 = DateTime.Now,
fld004511 = codeVal,
fld004514 = "N",
fld004512 = apiOutput.msg
})
.Where(it => it.idRecord == ParentData.idRecord)
.ExecuteCommandAsync();
var msg = apiOutput.msg;
if (apiOutput.msg == "")
{
msg = "同步成功";
}
var output = new SapOutput()
{
parameter = apiOutput.parameter,
code = codeVal,
msg = msg,
result = apiOutput.result
};
return output;
}
/// <summary>
/// 项目管理-定时同步到SAP
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "TimingSyncToSAP"), HttpGet]
[DisplayName("项目管理-定时同步到SAP")]
[AllowAnonymous]
public async Task<List<SapOutput>> TimingSyncToSAP()
{
var input = await _obj109Rep.AsQueryable()
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布")
.ToListAsync();
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++)
{
// 验证物料描述长度
if (input[i].fld004502.Length > 40)
{
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = "N",
fld004507 = lengthError,
fld004509 = "失败"
})
.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].fld004521,
Mtart = input[i].fld004519,
Maktx = input[i].fld004502,
Meins = "",//sssssssss基本计量单位
Matkl = input[i].fld004520,
Bismt = input[i].fld004684,
Groes = input[i].fld004685,
Normt = input[i].fld004924,
Ferth = input[i].fld004925,
Zeinr = input[i].fld004926,
Mstae = "",//sssssssssss跨工厂物料状态
Raube = input[i].fld004932,
Mhdrz = input[i].fld004933.ToString(),
Mhdhb = input[i].fld004934.ToString(),
Werks = input[i].fld004522,
Beskz = input[i].fld004929,
Sobsl = input[i].fld004928,
Schgt = input[i].fld004930,
Rgekz = input[i].fld004931,
Zbom = input[i].fld004935
};
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
string msg = sapOutput.msg;
if (sapOutput.msg == "")
{
msg = "同步成功";
}
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004509 = codeVal,
fld004510 = "N",
fld004507 = 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
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "TimingSyncToSAPBom"), HttpGet]
[DisplayName("项目管理-定时同步 Bom 到 SAP")]
[AllowAnonymous]
public async Task<List<SapOutput>> TimingSyncToSAPBom()
{
var sapOutputList = new List<SapOutput>();
var sapUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SapUserName);
// 配置
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync();
var materialData = await _obj109Rep.AsQueryable()
.Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布"&& x.fld004511 == "成功" && (x.fld004514 == "A" || x.fld004514 == "M"))
.ToListAsync();
var groupedData = materialData.GroupBy(item => item.RecordGuid)
.Select(group => group.OrderByDescending(item => item.VersionIndex).First())
.ToList();
foreach (var item in groupedData)
{
// 获取版本号
var versionIndex = item.VersionIndex;
// 获取 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();
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 ecn = ecnData != null ? ecnData._System_objNBS : "";
var itemDataList = new List<ItemData>();
foreach (var bomItem in bomData)
{
var verification = await _dataValidationService.VerificationMaterial(bomItem.ChildObjID, bomItem.PartNumber, bomItem.ChildGuid);
if (verification == "不存在")
{
continue;
}
var itemData = new ItemData
{
POSNR = (bomData.IndexOf(bomItem) + 1).ToString(),
IDNRK = bomItem.PartNumber,
MENGE = bomItem.Quantity.ToString(),
SORTF = bomItem.fld004936,
ITISOB = bomItem.fld004937,
ALPGR = bomItem.fld004938,
ALPRF = bomItem.fld004939,
ZDELETE = bomItem.fld004940,
POSTP = bomItem.fld004492,
ZYFMK = bomItem.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 = item._System_objNBS,
Werks = item.fld004522,
Bmeng = item.fld004946.ToString(),
Aennr = ecn,
Datuv = item.fld004949.ToString(),
ItemList = itemDataList
};
var apiOutput = await _sapService.SapBomApi(isreq);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
await _obj109Rep.AsUpdateable()
.SetColumns(it => new Obj109
{
fld004513 = DateTime.Now,
fld004511 = codeVal,
fld004514 = "N",
fld004512 = apiOutput.msg
})
.Where(it => it.idRecord == item.idRecord)
.ExecuteCommandAsync();
var msg = apiOutput.msg;
if (string.IsNullOrEmpty(msg))
{
msg = "同步成功";
}
var output = new SapOutput
{
parameter = apiOutput.parameter,
materialCode = item._System_objNBS,
code = codeVal,
msg = msg,
result = apiOutput.result
};
sapOutputList.Add(output);
}
return sapOutputList;
}
}

View File

@ -1,7 +1,6 @@
import request from '/@/utils/request';
enum Api {
PageProductManagement = '/api/productManagement/page',
BomTypeProductManagement = '/api/productManagement/bomType',
SyncToSAPProductManagement = '/api/productManagement/SyncToSAP',
GetetBOMProductManagement = '/api/productManagement/getBOM',
SyncToSAPBomProductManagement = '/api/productManagement/syncToSAPBom',
@ -16,13 +15,6 @@ export const PageProductManagement = (params?: any) =>
data: params,
});
// BOM类型
export const BomTypeProductManagement = () =>
request({
url: Api.BomTypeProductManagement,
method: 'get',
data: {},
});
// 同步到SAP
export const SyncToSAPProductManagement = (params?: any) =>
request({

View File

@ -0,0 +1,46 @@
import request from '/@/utils/request';
enum Api {
PageProjectManagement = '/api/projectManagement/page',
SyncToSAPProjectManagement = '/api/projectManagement/SyncToSAP',
GetBOMProjectManagement = '/api/projectManagement/getBOM',
SyncToSAPBomProjectManagement = '/api/projectManagement/syncToSAPBom',
BatchSyncToSAPProjectManagement = '/api/projectManagement/batchSyncToSAP'
}
// 分页查询产品管理
export const PageProjectManagement = (params?: any) =>
request({
url: Api.PageProjectManagement,
method: 'post',
data: params,
});
// 同步到SAP
export const SyncToSAPProjectManagement = (params?: any) =>
request({
url: Api.SyncToSAPProjectManagement,
method: 'post',
data: params,
});
// 分页查询产品管理BOM
export const GetBOMProjectManagement = (params?: any) =>
request({
url: Api.GetBOMProjectManagement,
method: 'post',
data: params,
});
// BOM同步到sap
export const SyncToSAPBomProjectManagement = (params?: any) =>
request({
url: Api.SyncToSAPBomProjectManagement,
method: 'post',
data: params,
});
// 批量同步到SAP
export const BatchSyncToSAPProjectManagement = (params?: any) =>
request({
url: Api.BatchSyncToSAPProjectManagement,
method: 'post',
data: params,
});

View File

@ -37,7 +37,7 @@
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_tools>
<el-button style="position: absolute; left: 0" icon="ele-Promotion" size="small" text=""
type="success" @click="batchSyncToSAP" v-auth="'productManagement/syncToSAP'"> 批量同步到SAP
type="success" @click="batchSyncToSAP" v-auth="'productManagement/batchSyncToSAP'"> 批量同步到SAP
</el-button>
</template>
<!-- <template #empty>
@ -47,13 +47,13 @@
<ModifyRecord :data="row" />
</template> -->
<template #row_buttons="{ row }">
<el-tooltip content="查看BOM" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary"
@click="showBomDrawer(row)" v-if="row.fld004316=='A'||row.fld004316=='M'">
查看BOM </el-button>
<el-tooltip content="同步BOM" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click="examineBom(row)"
v-auth="'productManagement/getBOM'" v-if="row.fld004316=='A'||row.fld004316=='M'">
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click="showBomDrawer"
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click=""
v-if="row.fld004320 != 'N'">
工艺路线 </el-button>
</el-tooltip>
@ -100,7 +100,7 @@ import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { formatDate } from '/@/utils/formatTime';
import { PageProductManagement, BomTypeProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement } from '/@/api/materialManagement/productManagement';
import { PageProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement } from '/@/api/materialManagement/productManagement';
import { disable } from 'ol/rotationconstraint';
//
@ -258,7 +258,7 @@ const syncToSAP = async (row: any) => {
//Guid
const bomxGrid = ref<VxeGridInstance>();
// BOM
const showBomDrawer = async (row: any) => {
const examineBom = async (row: any) => {
stateBom.queryParams.ParentGuid = row.recordGuid;
showBom.value = true;
await handleQueryBom();

View File

@ -0,0 +1,353 @@
<template>
<div class="projectManagement-container">
<el-card shadow="hover"
:body-style="{ padding: '20px 20px 16px 10px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true"
label-width="auto" style="flex: 1 1 0%" @submit.prevent="handleQuery">
<el-row :gutter="10">
<el-col :xs="24" :sm="12" :md="8" :lg="5" :xl="6" class="mb5">
<el-form-item label="项目编号" prop="_System_objNBS">
<el-input v-model="state.queryParams._System_objNBS" placeholder="项目编号" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8" :lg="5" :xl="6" class="mb5">
<el-form-item label="项目描述" prop="fld004502">
<el-input v-model="state.queryParams.fld004502" placeholder="项目描述" clearable
@keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8" :lg="5" :xl="6" class="mb5">
<el-form-item label="创建时间" prop="fld004683">
<el-date-picker type="daterange" v-model="state.queryParams.fld004683Range"
value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="开始日期" end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" unlink-panels />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb5">
<el-button type="primary" icon="ele-Search" @click="handleQuery"
v-auth="'projectManagement/page'" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_tools>
<el-button style="position: absolute; left: 0" icon="ele-Promotion" size="small" text=""
type="success" @click="batchSyncToSAP" v-auth="'projectManagement/batchSyncToSAP'"> 批量同步到SAP
</el-button>
</template>
<template #row_buttons="{ row }">
<el-tooltip content="同步BOM" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click="getBOM(row)"
v-auth="'projectManagement/getBOM'" v-if="row.fld004514=='A'||row.fld004514=='M'">
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">
<el-button icon="ele-MessageBox" size="small" text="" type="primary" @click=""
v-if="row.fld004320 != 'N'">
工艺路线 </el-button>
</el-tooltip>
<el-tooltip content="同步到ERP" placement="top">
<el-button icon="ele-Promotion" size="small" text="" type="success" @click="syncToSAP(row)"
v-auth="'projectManagement/syncToSAP'" v-if="row.fld004510=='A'||row.fld004510=='M'"> 同步到SAP </el-button>
</el-tooltip>
</template>
</vxe-grid>
</el-card>
<!-- 添加 drawer 抽屉 -->
<el-drawer v-model="showBom" title="BOM 详情" :direction="'rtl'" :visible.sync="false" size="50%">
<!-- 这里可以放置 BOM 的具体内容 -->
<el-card class="full-table" shadow="hover" style="margin-top: 5px;height: 100%;">
<el-form :model="stateBom.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true"
label-width="auto" style="flex: 1 1 0%" @submit.prevent="handleQueryBom">
<el-input v-model="stateBom.queryParams.ParentGuid" placeholder="父GUID" @click="handleQueryBom" />
</el-form>
<vxe-grid ref="bomxGrid" v-bind="bomOptions" v-on="gridEvents">
<template #toolbar_tools>
<el-button style="position: absolute; left: 0" icon="ele-Promotion" size="small" text=""
type="success" @click="syncToSAPBom" v-auth="'projectManagement/syncToSAPBom'"> BOM同步到SAP
</el-button>
</template>
</vxe-grid>
</el-card>
</el-drawer>
</div>
</template>
<script lang="ts" setup name="projectManagement">
import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElMessage } from "element-plus";
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { formatDate } from '/@/utils/formatTime';
import { PageProjectManagement, SyncToSAPProjectManagement, GetBOMProjectManagement, BatchSyncToSAPProjectManagement, SyncToSAPBomProjectManagement } from '/@/api/materialManagement/projectManagement';
import { disable } from 'ol/rotationconstraint';
//
const xGrid = ref<VxeGridInstance>();
const editDialogRef = ref();
let bomTypeList: any;
//
const state = reactive({
showAdvanceQueryUI: false,
queryParams: {
searchKey: undefined,
_System_objNBS: undefined,
fld004502: undefined,
fld004683: undefined,
fld004683Range: undefined,
},
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' },
},
visible: false,
title: '',
});
//
const resetQuery = async () => {
state.queryParams.searchKey = undefined,
state.queryParams._System_objNBS = undefined,
state.queryParams.fld004502 = undefined,
state.queryParams.fld004683 = undefined,
await xGrid.value?.commitProxy('reload');
};
//
const gridEvents: VxeGridListeners = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
//
const localPageParamKey = 'localPageParam:projectManagement';
//
const options = useVxeTable(
{
id: 'projectManagement',
name: '产品管理',
columns: [
{ type: 'checkbox', title: '', width: 60},
{ type: 'seq', title: '序号', width: 60 },
{ field: '_System_objNBS', title: '项目编号', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: '_System_ObjDescription', title: '项目名称', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004683', title: '创建时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004509', title: '物料同步状态', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004508', title: '物料同步时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004510', title: '物料同步标识', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004507', title: '物料同步信息', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004511', title: 'BOM同步状态', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004513', title: 'BOM同步时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004514', title: 'BOM同步标识', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004512', title: 'BOM同步信息', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004515', title: '工艺同步状态', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004518', title: '工艺同步时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004517', title: '工艺同步标识', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004516', title: '工艺同步信息', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ title: '操作', fixed: 'right', width: 300, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKey)?.defaultSort || state.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKey)?.pageSize || state.localPageParam.pageSize },
//
toolbarConfig: { export: false },
//
// rowConfig: { height: 80 },
}
);
//
onMounted(() => {
});
// api
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(state.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' });
var data = PageProjectManagement(params)
return data;
};
//
const handleQuery = async (reset = false) => {
options.loading = true;
await xGrid.value?.commitProxy('query');
options.loading = false;
};
// SAP
const syncToSAP = async (row: any) => {
options.loading = true;
ElMessageBox.confirm(`确定要同步物料吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var data = await SyncToSAPProjectManagement(row);
await handleQuery();
if (data.data.result.code == "成功") {
ElMessage.success("同步成功");
} else {
ElMessage.error("同步失败");
}
})
.catch(() => { });
options.loading = false;
};
//SAP
const batchSyncToSAP = async () => {
options.loading = true;
var data = xGrid.value?.getCheckboxRecords();
ElMessageBox.confirm(`确定要批量同步物料吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var output = await BatchSyncToSAPProjectManagement(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;
}
//
const stateBom = reactive({
showAdvanceQueryUI: false,
queryParams: {
PartNumber: undefined,
Description: undefined,
ParentGuid: undefined
},
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' },
},
visible: false,
title: '',
});
const showBom = ref(false);
// BOM
const getBOM = async (row: any) => {
stateBom.queryParams.ParentGuid = row.recordGuid;
showBom.value = true;
await handleQueryBom();
};
//
const localPageParamKeyBom = 'localPageParam:productManagementBom';
//
const bomOptions = useVxeTable(
{
id: 'productManagementBom',
name: '产品管理',
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'partNumber', title: '物料编码', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'description', title: '物料描述', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'quantity', title: '数量', minWidth: 100, showOverflow: 'tooltip', sortable: false },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleBOMQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKeyBom)?.defaultSort || stateBom.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKeyBom)?.pageSize || stateBom.localPageParam.pageSize },
//
toolbarConfig: { export: false },
//
// rowConfig: { height: 80 },
}
);
// BOM API
const handleBOMQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(stateBom.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' });
var data = GetBOMProjectManagement(params);
return data;
};
const bomxGrid = ref<VxeGridInstance>();
const handleQueryBom = async (reset = false) => {
bomOptions.loading = true;
await bomxGrid.value?.commitProxy('query');
bomOptions.loading = false;
};
//Bomsap
const syncToSAPBom = async () => {
options.loading = true;
var data = bomxGrid.value?.getTableData().fullData;
ElMessageBox.confirm(`确定要同步BOM吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var output = await SyncToSAPBomProjectManagement(data);
await handleQuery();
if (output.data.result.code == "成功") {
ElMessage.success("同步成功");
} else {
ElMessage.error("同步失败");
}
})
.catch(() => { });
options.loading = false;
}
</script>