@ -6,6 +6,7 @@
using Admin.NET.Core ;
using Admin.NET.Core.Service ;
using DocumentFormat.OpenXml.Wordprocessing ;
using Furion.DependencyInjection ;
using Furion.DynamicApiController ;
using Microsoft.AspNetCore.Authorization ;
@ -21,6 +22,7 @@ using Vistar.Application.Const;
using Vistar.Application.Entity ;
using Vistar.Application.SapService.Dto ;
using Vistar.Application.Service.ProductDesignLibrary.Dto ;
using Vistar.Application.SolidWorksManageService.Dto ;
using Vistar.Application.Util ;
namespace Vistar.Application.Service.ProductDesignLibrary ;
@ -39,6 +41,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
public Common . DataValidationService _dataValidationService ;
public SqlSugarRepository < Obj122 > _obj122Rep ;
public SqlSugarRepository < Obj121 > _obj121Rep ;
public SolidWorksManageService . SolidWorksManageService _solidWorksManageService ;
public ProductDesignLibraryService (
SqlSugarRepository < Obj137 > obj137Rep ,
@ -49,7 +52,8 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
SqlSugarRepository < Obj118 > obj118Rep ,
DataValidationService dataValidationService ,
SqlSugarRepository < Obj122 > obj122Rep ,
SqlSugarRepository < Obj121 > obj121Rep
SqlSugarRepository < Obj121 > obj121Rep ,
SolidWorksManageService . SolidWorksManageService solidWorksManageService
)
{
_obj137Rep = obj137Rep ;
@ -61,6 +65,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
_dataValidationService = dataValidationService ;
_obj122Rep = obj122Rep ;
_obj121Rep = obj121Rep ;
_solidWorksManageService = solidWorksManageService ;
}
/// <summary>
@ -192,7 +197,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
. Where ( x = > x . RecordGuid = = input . ParentGuid & & x . deleted = = false & & x . _system_objConfigurationName = = "默认" & & ! x . SWPDMFileName . Contains ( "SLDDRW" ) )
. 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 & & ( x . fld005577 ! = "不包含" | | x . fld005577 = = null ) & & x . isSuppressed = = false & & x . inContext = = false )
. Where ( x = > x . ConfigId = = configid . ConfigID & & x . ParentGuid = = input . ParentGuid & & x . isDeleted = = false & & x . ParentVersion = = parent & & ( x . fld005577 ! = "不包含" | | x . fld005577 = = null ) & & x . isSuppressed = = false & & x . inContext = = false )
. 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 < ProductDesignLibraryBomOutput > ( ) . ToPagedListAsync ( input . Page , input . PageSize ) ;
@ -314,7 +319,8 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
. Where ( it = > it . idRecord = = ParentData . idRecord )
. ExecuteCommandAsync ( ) ;
}
else {
else
{
await _obj137Rep . AsUpdateable ( )
. SetColumns ( it = > new Obj137
{
@ -326,7 +332,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
. Where ( it = > it . idRecord = = ParentData . idRecord )
. ExecuteCommandAsync ( ) ;
}
var msg = apiOutput . msg ;
if ( apiOutput . msg = = "" )
{
@ -379,7 +385,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
} ) ;
continue ;
}
if ( input [ i ] . fld005530 = = "N" | | input [ i ] . fld005530 = = "D" | | input [ i ] . fld005530 = = null )
if ( input [ i ] . fld005530 = = "N" | | input [ i ] . fld005530 = = "D" | | input [ i ] . fld005530 = = null )
{
SapOutputList . Add ( new SapOutput ( )
{
@ -500,7 +506,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
continue ;
}
}
//获取时间戳精确到毫秒, sap要求每次调用生成不重复guid
string millisecondTimestamp = DateTimeOffset . UtcNow . ToUnixTimeMilliseconds ( ) . ToString ( ) ;
@ -638,7 +644,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
if ( ! string . IsNullOrEmpty ( ParentData . fld005686 ) )
{
var configidold = await _configurationsRep . AsQueryable ( ) . Where ( x = > x . ObjectId = = 137 & & x . ConfigSystemName = = "SolidWorks" ) . FirstAsync ( ) ;
var BomData = await _configurationDataRep . AsQueryable ( ) . Where ( x = > x . ConfigId = = configidold . ConfigID & & x . ParentGuid = = bomData [ 0 ] . ParentGuid & & x . isDeleted = = false & & x . ParentVersion = = Convert . ToInt32 ( ParentData . fld005686 ) & & ( x . fld005577 ! = "不包含" | | x . fld005577 = = null ) & & x . isSuppressed = = false & & x . inContext = = false ) . ToListAsync ( ) ;
var BomData = await _configurationDataRep . AsQueryable ( ) . Where ( x = > x . ConfigId = = configidold . ConfigID & & x . ParentGuid = = bomData [ 0 ] . ParentGuid & & x . isDeleted = = false & & x . ParentVersion = = Convert . ToInt32 ( ParentData . fld005686 ) & & ( x . fld005577 ! = "不包含" | | x . fld005577 = = null ) & & x . isSuppressed = = false & & x . inContext = = false ) . ToListAsync ( ) ;
for ( int i = 0 ; i < BomData . Count ; i + + )
{
@ -786,10 +792,10 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
public async Task < SapOutput > SyncToSAPProcessRoute ( List < BomPageProductDesignLibraryInput > input )
{
var ParentData = await _obj137Rep . AsQueryable ( )
. Where ( x = >
x . RecordGuid = = input [ 0 ] . ParentGuid
& & x . deleted = = false
& & x . VersionIndex = = input [ 0 ] . ParentVersion
. Where ( x = >
x . RecordGuid = = input [ 0 ] . ParentGuid
& & x . deleted = = false
& & x . VersionIndex = = input [ 0 ] . ParentVersion
& & x . _system_objConfigurationName = = "默认"
& & ! x . SWPDMFileName . Contains ( "SLDDRW" )
& & x . CheckedStatus = = 0
@ -900,10 +906,10 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
//查询需要同步的产品
var materialData = await _obj137Rep . AsQueryable ( )
. Where ( x = >
x . CheckedStatus = = 0
& & x . deleted = = false
& & x . IsLatestVersion = = true
. Where ( x = >
x . CheckedStatus = = 0
& & x . deleted = = false
& & x . IsLatestVersion = = true
& & x . _system_objConfigurationName = = "默认"
& & ! x . SWPDMFileName . Contains ( "SLDDRW" )
& & ( x . _SWPDM_1202_SW_____ ! = "不展开" | | x . _SWPDM_1202_SW_____ = = null )
@ -1013,4 +1019,87 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
return sapOutputList ;
}
/// <summary>
/// 创建排版软件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task < string > CreateLayout ( CreateLayoutInput input )
{
string output = "" ;
if ( string . IsNullOrEmpty ( input . ParentCode ) )
{
return "请输入父项编码" ;
}
var parentData = await _obj137Rep . AsQueryable ( ) . Where ( x = > x . _System_objNBS = = input . ParentCode & & x . deleted = = false ) . OrderByDescending ( x = > x . idRecord ) . FirstAsync ( ) ;
if ( parentData ! = null )
{
return "未查询到父项编码" ;
}
int lineNumber = 0 ;
foreach ( var item in input . Item )
{
lineNumber + + ;
string lineNumberStr = ( lineNumber * 10 ) . ToString ( "0000" ) ;
var outputData = output + "子项编码" + item . ChildCode ;
if ( string . IsNullOrEmpty ( item . ChildCode ) | | string . IsNullOrEmpty ( item . Quantity ) )
{
outputData = outputData + "未输入必填项编码" ;
continue ;
}
var childData = await _obj122Rep . AsQueryable ( ) . Where ( x = > x . _System_objNBS = = item . ChildCode & & x . deleted = = false ) . OrderByDescending ( x = > x . idRecord ) . FirstAsync ( ) ;
if ( childData ! = null )
{
output = outputData + "未查询到子项编码;" ;
continue ;
}
var configurationData = await _configurationDataRep . AsQueryable ( ) . Where ( x = > x . RecordImage ! = null & & x . ChildObjID = = 112 ) . FirstAsync ( ) ;
var bomData = new ConfigurationData
{
ParentGuid = parentData . RecordGuid ,
ChildGuid = childData . RecordGuid ,
ChildObjID = 112 ,
ConfigId = 8 ,
childVersion = childData . VersionIndex ,
ParentVersion = ( int ) parentData . VersionIndex ,
isDeleted = false ,
ChildConfigID = 0 ,
CreatedUserID = 2 ,
ModifiedUserID = 2 ,
CreatedDate = DateTime . Now ,
ModifiedDate = DateTime . Now ,
Quantity = item . Quantity . ToDouble ( ) ,
Description = parentData . _System_ObjDescription ,
EffectiveFrom = DateTime . Now ,
EffectiveTo = DateTime . Now . AddYears ( 100 ) ,
Revision = "" ,
Marker = lineNumberStr ,
Type = "正常" ,
OrderIndex = lineNumber ,
PartNumber = childData . _System_objNBS ,
RecordImage = configurationData . RecordImage ,
Folder = configurationData . Folder ,
ParentObjectID = 137 ,
ChildSwFileType = 0 ,
ParentSwFileType = 1 ,
isSuppressed = false ,
isAddedFromSW = true ,
QtyManual = item . Quantity . ToDouble ( ) ,
SwConfiguration = "" ,
inContext = false ,
PrimaryFile = "" ,
bKeepQuantityInSync = true ,
BOMGuid = await _dataValidationService . GetGuid ( ) ,
IsPDMReference = false
} ;
var addChildBomBom = await _configurationDataRep . AsInsertable ( bomData ) . InsertColumns ( x = > new { x . ParentGuid , x . ChildGuid , x . ChildObjID , x . ConfigId , x . childVersion , x . ParentVersion , x . isDeleted , x . ChildConfigID , x . CreatedUserID , x . ModifiedUserID , x . CreatedDate , x . ModifiedDate , x . Quantity , x . Description , x . EffectiveFrom , x . EffectiveTo , x . Revision , x . Marker , x . Type , x . OrderIndex , x . PartNumber , x . RecordImage , x . Folder , x . ParentObjectID , x . ChildSwFileType , x . ParentSwFileType , x . isSuppressed , x . isAddedFromSW , x . QtyManual , x . SwConfiguration , x . inContext , x . PrimaryFile , x . bKeepQuantityInSync , x . BOMGuid , x . IsPDMReference } ) . ExecuteReturnEntityAsync ( ) ;
//var message = AddItemsInBomOutput.Message;
//output = outputData + message+"; ";
}
return output ;
}
}