😎行政物料功能实现,物料同步、BOM同步修改

This commit is contained in:
bairubing 2024-09-27 09:34:44 +08:00
parent aa508e9cfa
commit 46ee4ea994
15 changed files with 1047 additions and 30 deletions

View File

@ -714,7 +714,7 @@ public class Obj110
///
/// </summary>
[SugarColumn(ColumnName = "fld004895", ColumnDescription = "", Length = -1)]
public long? fld004895 { get; set; }
public double? fld004895 { get; set; }//long
/// <summary>
///

View File

@ -27,7 +27,7 @@ public class Obj133
///
/// </summary>
[SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")]
public bool? CheckedStatus { get; set; }
public int? CheckedStatus { get; set; }
/// <summary>
///
@ -444,5 +444,15 @@ public class Obj133
/// </summary>
[SugarColumn(ColumnName = "fld004974", ColumnDescription = "", Length = -1)]
public string? fld004974 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005285", ColumnDescription = "", Length = -1)]
public long? fld005285 { get; set; }
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "fld005287", ColumnDescription = "", Length = -1)]
public long? fld005287 { get; set; }
}

View File

@ -0,0 +1,395 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
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.Const;
using Vistar.Application.Entity;
using Vistar.Application.SapService.Dto;
using Vistar.Application.Service.AdministrativeMaterialManagement.Dto;
using Vistar.Application.Util;
namespace Vistar.Application.Service.AdministrativeMaterialManagement;
/// <summary>
/// 行政物料管理服务
/// </summary>
[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "AdministrativeMaterialManagement", Order = 100)]
public class AdministrativeMaterialManagementService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Obj133> _obj133Rep;
private readonly SysConfigService _sysConfigService;
public SapService.SapService _sapService;
private readonly SqlSugarRepository<Configurations> _configurationsRep;
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
public AdministrativeMaterialManagementService(
SqlSugarRepository<Obj133> obj133Rep,
SysConfigService sysConfigService,
SapService.SapService sapService,
SqlSugarRepository<Configurations> configurationsRep,
SqlSugarRepository<ConfigurationData> configurationDataRep
)
{
_obj133Rep = obj133Rep;
_sysConfigService = sysConfigService;
_sapService = sapService;
_configurationsRep = configurationsRep;
_configurationDataRep = configurationDataRep;
}
/// <summary>
/// 分页查询行政物料管理
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[ApiDescriptionSettings(Name = "page", Description = "分页查询行政物料管理", Order = 1000), HttpPost]
[DisplayName("分页查询行政物料管理")]
public async Task<SqlSugarPagedList<AdministrativeMaterialManagementOutput>> Page(PageAdministrativeMaterialManagementInput input)
{
var query = await _obj133Rep.AsQueryable()
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true&&x.fld004974=="发布")
.WhereIF(!string.IsNullOrWhiteSpace(input._System_objNBS), u => u._System_objNBS.Contains(input._System_objNBS.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.fld004824), u => u.fld004824.Contains(input.fld004824.Trim()))
.WhereIF(input.fld004847Range != null && input.fld004847Range.Length == 2, u => u.fld004847 >= input.fld004847Range[0] && u.fld004847 <= input.fld004847Range[1])
.Select<AdministrativeMaterialManagementOutput>()
.ToPagedListAsync(input.Page, input.PageSize);
return query;
}
/// <summary>
/// 行政物料管理-同步到 SAP
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "syncToSAP"), HttpPost]
[DisplayName("行政物料管理-同步到 SAP")]
public async Task<SapOutput> SyncToSAP(AdministrativeMaterialManagementInput input)
{
const string lengthError = "项目描述长度大于40请检查";
// 验证物料描述长度
if (input.fld004824.Length > 40)
{
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004922 = "N",
fld004921 = lengthError,
fld004920 = "失败"
})
.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.fld004852,
Mtart = input.fld004851,
Maktx = input.fld004824,
Meins = input.fld004823,
Matkl = input.fld004850,
Bismt = input.fld004912,
Groes = input.fld004913,
Normt = input.fld004822,
Ferth = input.fld004914,
Zeinr = input.fld004915,
Mstae = input.fld004857,
Raube = input.fld004917,
Mhdrz = input.fld005285.ToString(),
Mhdhb = input.fld005287.ToString(),
Werks = input.fld004856,
Beskz = input.fld004855,
Sobsl = input.fld004854,
Schgt = input.fld004853,
Rgekz = input.fld004916,
Zbom = input.fld004858
};
var apiOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = apiOutput.code == "S" ? "成功" : "失败";
var msg = apiOutput.msg;
if (apiOutput.msg == "")
{
msg = "同步成功";
}
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004920 = codeVal,
fld004922 = "N",
fld004921 = 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<AdministrativeMaterialManagementInput> 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].fld004824.Length > 40)
{
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004922 = "N",
fld004921 = lengthError,
fld004920 = "失败"
})
.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].fld004922 != "A" && input[i].fld004922 != "M")
{
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].fld004852,
Mtart = input[i].fld004851,
Maktx = input[i].fld004824,
Meins = input[i].fld004823,
Matkl = input[i].fld004850,
Bismt = input[i].fld004912,
Groes = input[i].fld004913,
Normt = input[i].fld004822,
Ferth = input[i].fld004914,
Zeinr = input[i].fld004915,
Mstae = input[i].fld004857,
Raube = input[i].fld004917,
Mhdrz = input[i].fld005285.ToString(),
Mhdhb = input[i].fld005287.ToString(),
Werks = input[i].fld004856,
Beskz = input[i].fld004855,
Sobsl = input[i].fld004854,
Schgt = input[i].fld004853,
Rgekz = input[i].fld004916,
Zbom = input[i].fld004858
};
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
string msg = sapOutput.msg;
if (sapOutput.msg == "")
{
msg = "同步成功";
}
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004920 = codeVal,
fld004922 = "N",
fld004921 = 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>
/// 行政物料管理-定时同步到SAP
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings(Name = "TimingSyncToSAP"), HttpGet]
[DisplayName("行政物料管理-定时同步到SAP")]
[AllowAnonymous]
public async Task<List<SapOutput>> TimingSyncToSAP()
{
var input = await _obj133Rep.AsQueryable()
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true && (x.fld004922 == "A" || x.fld004922 == "M") && x.fld004974 == "发布")
.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].fld004824.Length > 40)
{
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004922 = "N",
fld004921 = lengthError,
fld004920 = "失败"
})
.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].fld004852,
Mtart = input[i].fld004851,
Maktx = input[i].fld004824,
Meins = input[i].fld004823,
Matkl = input[i].fld004850,
Bismt = input[i].fld004912,
Groes = input[i].fld004913,
Normt = input[i].fld004822,
Ferth = input[i].fld004914,
Zeinr = input[i].fld004915,
Mstae = input[i].fld004857,
Raube = input[i].fld004917,
Mhdrz = input[i].fld005285.ToString(),
Mhdhb = input[i].fld005287.ToString(),
Werks = input[i].fld004856,
Beskz = input[i].fld004855,
Sobsl = input[i].fld004854,
Schgt = input[i].fld004853,
Rgekz = input[i].fld004916,
Zbom = input[i].fld004858
};
var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput);
string codeVal = sapOutput.code == "S" ? "成功" : "失败";
string msg = sapOutput.msg;
if (sapOutput.msg == "")
{
msg = "同步成功";
}
await _obj133Rep.AsUpdateable()
.SetColumns(it => new Obj133
{
fld004923 = DateTime.Now,
fld004920 = codeVal,
fld004922 = "N",
fld004921 = 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;
}
}

View File

@ -0,0 +1,191 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Admin.NET.Core;
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.AdministrativeMaterialManagement.Dto;
/// <summary>
/// 行政物料管理输入参数
/// </summary>
public class AdministrativeMaterialManagementInput
{
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? GroupObjId { get; set; }
public bool? _CheckOutInProgress { get; set; }
public bool? EnableNotifications { get; set; }
public string? _system_objConfigurationName { get; set; }
public bool? _system_objConfigurationType { get; set; }
public string? _system_objConfigurationGuid { get; set; }
public string ShowBomFromConfiguration { get; set; }
public string _System_ObjNbsAuto { get; set; }
public string? _System_DerivedFrom { get; set; }
public string? _System_DerivedFrom_RecordGuid { get; set; }
public bool? _system_objLinkedCompare { get; set; }
public bool? isReleasedVersion { get; set; }
public string? _System_WebLink { get; set; }
public bool? LinkDrw { get; set; }
public string? ParentRecordGuid { get; set; }
public string? fld004822 { get; set; }
public string? fld004823 { get; set; }
public string? fld004824 { get; set; }
public string? fld004825 { get; set; }
public long? fld004846 { get; set; }
public string? fld004846_Rec { get; set; }
public DateTime? fld004847 { get; set; }
public long? fld004848 { get; set; }
public string? fld004848_Rec { get; set; }
public DateTime? fld004849 { get; set; }
public string? fld004850 { get; set; }
public string? fld004851 { get; set; }
public string? fld004852 { get; set; }
public string? fld004853 { get; set; }
public string? fld004854 { get; set; }
public string? fld004855 { get; set; }
public string? fld004856 { get; set; }
public string? fld004857 { get; set; }
public string? fld004858 { get; set; }
public string? fld004912 { get; set; }
public string? fld004913 { get; set; }
public string? fld004914 { get; set; }
public string? fld004915 { get; set; }
public string? fld004916 { get; set; }
public string? fld004917 { get; set; }
public string? fld004918 { get; set; }
public string? fld004919 { get; set; }
public string? fld004920 { get; set; }
public string? fld004921 { get; set; }
public string? fld004922 { get; set; }
public DateTime? fld004923 { get; set; }
public string? fld004974 { get; set; }
public long? fld005285 { get; set; }
public long? fld005287 { get; set; }
}
/// <summary>
/// 行政物料管理查询输入参数
/// </summary>
public class PageAdministrativeMaterialManagementInput : BasePageInput
{
/// <summary>
/// 物料编码
/// </summary>
public string? _System_objNBS { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string? fld004824 { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? fld004847 { get; set; }
/// <summary>
/// 创建时间范围
/// </summary>
public DateTime?[] fld004847Range { get; set; }
}

View File

@ -0,0 +1,163 @@
// 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.AdministrativeMaterialManagement.Dto;
/// <summary>
/// 行政物料管理输出参数
/// </summary>
public class AdministrativeMaterialManagementOutput
{
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? GroupObjId { get; set; }
public bool? _CheckOutInProgress { get; set; }
public bool? EnableNotifications { get; set; }
public string? _system_objConfigurationName { get; set; }
public bool? _system_objConfigurationType { get; set; }
public string? _system_objConfigurationGuid { get; set; }
public string ShowBomFromConfiguration { get; set; }
public string _System_ObjNbsAuto { get; set; }
public string? _System_DerivedFrom { get; set; }
public string? _System_DerivedFrom_RecordGuid { get; set; }
public bool? _system_objLinkedCompare { get; set; }
public bool? isReleasedVersion { get; set; }
public string? _System_WebLink { get; set; }
public bool? LinkDrw { get; set; }
public string? ParentRecordGuid { get; set; }
public string? fld004822 { get; set; }
public string? fld004823 { get; set; }
public string? fld004824 { get; set; }
public string? fld004825 { get; set; }
public long? fld004846 { get; set; }
public string? fld004846_Rec { get; set; }
public DateTime? fld004847 { get; set; }
public long? fld004848 { get; set; }
public string? fld004848_Rec { get; set; }
public DateTime? fld004849 { get; set; }
public string? fld004850 { get; set; }
public string? fld004851 { get; set; }
public string? fld004852 { get; set; }
public string? fld004853 { get; set; }
public string? fld004854 { get; set; }
public string? fld004855 { get; set; }
public string? fld004856 { get; set; }
public string? fld004857 { get; set; }
public string? fld004858 { get; set; }
public string? fld004912 { get; set; }
public string? fld004913 { get; set; }
public string? fld004914 { get; set; }
public string? fld004915 { get; set; }
public string? fld004916 { get; set; }
public string? fld004917 { get; set; }
public string? fld004918 { get; set; }
public string? fld004919 { get; set; }
public string? fld004920 { get; set; }
public string? fld004921 { get; set; }
public string? fld004922 { get; set; }
public DateTime? fld004923 { get; set; }
public string? fld004974 { get; set; }
public long? fld005285 { get; set; }
public long? fld005287 { get; set; }
}

View File

@ -480,7 +480,7 @@ public class ProductManagementBaseInput
/// <summary>
///
/// </summary>
public string? fld004895 { get; set; }
public double? fld004895 { get; set; }
/// <summary>
///

View File

@ -242,7 +242,7 @@ public class ProductManagementOutput
public string? fld004887 { get; set; }
public long? fld004895 { get; set; }
public double? fld004895 { get; set; }
public float? fld004942 { get; set; }

View File

@ -128,7 +128,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
Mstae = input.fld004699,
Raube = input.fld004877,
Mhdrz = input.fld004876,
Mhdhb = input.fld004895,
Mhdhb = input.fld004895.ToString(),
Werks = input.fld004325,
Beskz = input.fld004490,
Sobsl = input.fld004491,
@ -311,7 +311,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
});
continue;
}
if (input[i].fld004312 != "A" || input[i].fld004312 != "M")
if (input[i].fld004312 != "A" && input[i].fld004312 != "M")
{
SapOutputList.Add(new SapOutput()
{
@ -350,7 +350,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
Mstae = input[i].fld004699,
Raube = input[i].fld004877,
Mhdrz = input[i].fld004876,
Mhdhb = input[i].fld004895,
Mhdhb = input[i].fld004895.ToString(),
Werks = input[i].fld004325,
Beskz = input[i].fld004490,
Sobsl = input[i].fld004491,

View File

@ -59,7 +59,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
public async Task<SqlSugarPagedList<ProductionMaterialsManagementOutput>> Page(PageProductionMaterialsManagementInput input)
{
var query = await _obj112Rep.AsQueryable()
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true)
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true && x.fld004973=="发布")
.WhereIF(!string.IsNullOrWhiteSpace(input._System_objNBS), u => u._System_objNBS.Contains(input._System_objNBS.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.fld004598), u => u.fld004598.Contains(input.fld004598.Trim()))
.WhereIF(input.fld004609Range != null && input.fld004609Range.Length == 2, u => u.fld004609 >= input.fld004609Range[0] && u.fld004609 <= input.fld004609Range[1])
@ -204,7 +204,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
});
continue;
}
if (input[i].fld004607 != "A"|| input[i].fld004607 != "M")
if (input[i].fld004607 != "A"&& input[i].fld004607 != "M")
{
SapOutputList.Add(new SapOutput()
{
@ -292,7 +292,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran
public async Task<List<SapOutput>> TimingSyncToSAP()
{
var input = await _obj112Rep.AsQueryable()
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true&&(x.fld004607=="A"||x.fld004607 == "M"))
.Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true&&(x.fld004607=="A"||x.fld004607 == "M") && x.fld004973 == "发布")
.ToListAsync();
const string lengthError = "物料描述长度大于40请检查";
var SapOutputList = new List<SapOutput>();

View File

@ -122,7 +122,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Maktx = input.fld004502,
Meins = input.fld005281,
Matkl = input.fld004520,
Bismt = input.fld004684,
Bismt = input.fld004686,
Groes = input.fld004685,
Normt = input.fld004924,
Ferth = input.fld004925,
@ -132,8 +132,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Mhdrz = input.fld004933.ToString(),
Mhdhb = input.fld004934.ToString(),
Werks = input.fld004522,
Beskz = input.fld004929,
Sobsl = input.fld004928,
Beskz = input.fld004928,
Sobsl = input.fld004929,
Schgt = input.fld004930,
Rgekz = input.fld004931,
Zbom = input.fld004935
@ -151,9 +151,9 @@ public class ProjectManagementService : IDynamicApiController, ITransient
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = codeVal,
fld004507 = "N",
fld004509 = msg
fld004507=msg,
fld004509=codeVal,
fld004510 = "N"
})
.Where(it => it.idRecord == input.idRecord)
.ExecuteCommandAsync();
@ -205,7 +205,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
});
continue;
}
if (input[i].fld004510 != "A" || input[i].fld004510 != "M")
if (input[i].fld004510 != "A" && input[i].fld004510 != "M")
{
SapOutputList.Add(new SapOutput()
{
@ -236,7 +236,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Maktx = input[i].fld004502,
Meins = input[i].fld005281,
Matkl = input[i].fld004520,
Bismt = input[i].fld004684,
Bismt = input[i].fld004686,
Groes = input[i].fld004685,
Normt = input[i].fld004924,
Ferth = input[i].fld004925,
@ -246,8 +246,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Mhdrz = input[i].fld004933.ToString(),
Mhdhb = input[i].fld004934.ToString(),
Werks = input[i].fld004522,
Beskz = input[i].fld004929,
Sobsl = input[i].fld004928,
Beskz = input[i].fld004928,
Sobsl = input[i].fld004929,
Schgt = input[i].fld004930,
Rgekz = input[i].fld004931,
Zbom = input[i].fld004935
@ -264,9 +264,9 @@ public class ProjectManagementService : IDynamicApiController, ITransient
.SetColumns(it => new Obj109
{
fld004508 = DateTime.Now,
fld004510 = "N",
fld004507 = lengthError,
fld004509 = "失败"
fld004507 = msg,
fld004509 = codeVal,
fld004510 = "N"
})
.Where(it => it.idRecord == input[i].idRecord)
.ExecuteCommandAsync();
@ -456,7 +456,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Maktx = input[i].fld004502,
Meins = input[i].fld005281,
Matkl = input[i].fld004520,
Bismt = input[i].fld004684,
Bismt = input[i].fld004686,
Groes = input[i].fld004685,
Normt = input[i].fld004924,
Ferth = input[i].fld004925,
@ -466,8 +466,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient
Mhdrz = input[i].fld004933.ToString(),
Mhdhb = input[i].fld004934.ToString(),
Werks = input[i].fld004522,
Beskz = input[i].fld004929,
Sobsl = input[i].fld004928,
Beskz = input[i].fld004928,
Sobsl = input[i].fld004929,
Schgt = input[i].fld004930,
Rgekz = input[i].fld004931,
Zbom = input[i].fld004935

View File

@ -0,0 +1,32 @@
import request from '/@/utils/request';
enum Api {
PageAdministrativeMaterialManagement = '/api/administrativeMaterialManagement/page',
SyncToSAPAdministrativeMaterialManagement = '/api/administrativeMaterialManagement/SyncToSAP',
BatchSyncToSAPAdministrativeMaterialManagement = '/api/administrativeMaterialManagement/batchSyncToSAP'
}
// 分页查询产品管理
export const PageAdministrativeMaterialManagement = (params?: any) =>
request({
url: Api.PageAdministrativeMaterialManagement,
method: 'post',
data: params,
});
// 同步到SAP
export const SyncToSAPAdministrativeMaterialManagement = (params?: any) =>
request({
url: Api.SyncToSAPAdministrativeMaterialManagement,
method: 'post',
data: params,
});
// 批量同步到SAP
export const BatchSyncToSAPAdministrativeMaterialManagement = (params?: any) =>
request({
url: Api.BatchSyncToSAPAdministrativeMaterialManagement,
method: 'post',
data: params,
});

View File

@ -5,7 +5,7 @@ import { Local, Session } from '/@/utils/storage';
// 配置新建一个 axios 实例
export const service = axios.create({
baseURL: window.__env__.VITE_API_URL as any,
timeout: 50000,
timeout: 60000,//50000
headers: { 'Content-Type': 'application/json' },
});

View File

@ -0,0 +1,226 @@
<template>
<div class="administrativeMaterialManagement-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="fld004824">
<el-input v-model="state.queryParams.fld004824" 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="fld004847">
<el-date-picker type="daterange" v-model="state.queryParams.fld004847Range"
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="'administrativeMaterialManagement/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="同步到ERP" placement="top">
<el-button icon="ele-Promotion" size="small" text="" type="success" @click="syncToSAP(row)"
v-auth="'administrativeMaterialManagement/syncToSAP'" v-if="row.fld004922=='A'||row.fld004922=='M'"> 同步到SAP </el-button>
</el-tooltip>
</template>
</vxe-grid>
</el-card>
</div>
</template>
<script lang="ts" setup name="administrativeMaterialManagement">
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 { PageAdministrativeMaterialManagement, SyncToSAPAdministrativeMaterialManagement, BatchSyncToSAPAdministrativeMaterialManagement } from '/@/api/materialManagement/administrativeMaterialManagement';
import { disable } from 'ol/rotationconstraint';
//
const state = reactive({
showAdvanceQueryUI: false,
queryParams: {
searchKey: undefined,
_System_objNBS: undefined,
fld004824: undefined,
fld004847: undefined,
fld004847Range: undefined,
},
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' },
},
visible: false,
title: '',
});
const xGrid = ref<VxeGridInstance>();
//
const resetQuery = async () => {
state.queryParams.searchKey = undefined,
state.queryParams._System_objNBS = undefined,
state.queryParams.fld004824 = undefined,
state.queryParams.fld004847 = undefined,
await xGrid.value?.commitProxy('reload');
};
// 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 = PageAdministrativeMaterialManagement(params)
return data;
};
//
const handleQuery = async (reset = false) => {
options.loading = true;
await xGrid.value?.commitProxy('query');
options.loading = false;
};
//
const localPageParamKey = 'localPageParam:projectManagement';
//
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 options = useVxeTable(
{
id: 'administrativeMaterialManagement',
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: 'fld004847', title: '创建时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004920', title: '物料同步状态', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004923', title: '物料同步时间', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004922', title: '物料同步标识', minWidth: 100, showOverflow: 'tooltip', sortable: false },
{ field: 'fld004921', 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(() => {
});
// SAP
const syncToSAP = async (row: any) => {
options.loading = true;
ElMessageBox.confirm(`确定要同步物料吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
var data = await SyncToSAPAdministrativeMaterialManagement(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 BatchSyncToSAPAdministrativeMaterialManagement(data);
await handleQuery();
var succeed = 0;
var error = 0;
for (let i = 0; i < output.data.result.length; i++) {
var code = output.data.result[i].code
if (code == "成功") {
succeed++
} else {
error++
}
}
ElMessageBox.alert("同步成功:" + succeed + "" + "同步失败:" + error, '批量同步结果', {
//
// autofocus: false,
confirmButtonText: 'OK'
})
})
.catch(() => { });
options.loading = false;
}
</script>

View File

@ -49,7 +49,7 @@
<template #row_buttons="{ row }">
<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'">
v-auth="'productManagement/getBOM'" v-if="(row.fld004316=='A'||row.fld004316=='M')&&row.fld004311=='成功'">
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">

View File

@ -42,7 +42,7 @@
<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'">
v-auth="'projectManagement/getBOM'" v-if="(row.fld004514=='A'||row.fld004514=='M')&&row.fld004509=='成功'">
同步BOM </el-button>
</el-tooltip>
<el-tooltip content="工艺路线" placement="top">