😭修改排版软件报错信息
This commit is contained in:
parent
869830d6ee
commit
d705061237
@ -20,5 +20,5 @@ public class CreateLayoutInput
|
||||
public class Item
|
||||
{
|
||||
public string ChildCode { get; set; }
|
||||
public string Quantity { get; set; }
|
||||
public double Quantity { get; set; }
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using Admin.NET.Core.Service;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
@ -40,6 +41,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
public SqlSugarRepository<Obj118> _obj118Rep;
|
||||
public Common.DataValidationService _dataValidationService;
|
||||
public SqlSugarRepository<Obj122> _obj122Rep;
|
||||
public SqlSugarRepository<Obj112> _obj112Rep;
|
||||
public SqlSugarRepository<Obj121> _obj121Rep;
|
||||
public SolidWorksManageService.SolidWorksManageService _solidWorksManageService;
|
||||
|
||||
@ -52,6 +54,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
SqlSugarRepository<Obj118> obj118Rep,
|
||||
DataValidationService dataValidationService,
|
||||
SqlSugarRepository<Obj122> obj122Rep,
|
||||
SqlSugarRepository<Obj112> obj112Rep,
|
||||
SqlSugarRepository<Obj121> obj121Rep,
|
||||
SolidWorksManageService.SolidWorksManageService solidWorksManageService
|
||||
)
|
||||
@ -64,6 +67,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
_obj118Rep = obj118Rep;
|
||||
_dataValidationService = dataValidationService;
|
||||
_obj122Rep = obj122Rep;
|
||||
_obj112Rep = obj112Rep;
|
||||
_obj121Rep = obj121Rep;
|
||||
_solidWorksManageService = solidWorksManageService;
|
||||
}
|
||||
@ -234,7 +238,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
{
|
||||
POSNR = "",//组件序号 sun.ToString()
|
||||
IDNRK = input[i].PartNumber,//组件物料号
|
||||
MENGE = input[i].QtyManual.ToString(),//组件数量
|
||||
MENGE = Math.Round((decimal)input[i].QtyManual, 3).ToString(),//组件数量
|
||||
SORTF = input[i].fld005541,
|
||||
ITISOB = input[i].fld005542,
|
||||
ALPGR = input[i].fld005543,
|
||||
@ -266,7 +270,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
{
|
||||
POSNR = "",//组件序号 sun.ToString()
|
||||
IDNRK = BomData[i].PartNumber,//组件物料号
|
||||
MENGE = BomData[i].QtyManual.ToString(),//组件数量
|
||||
MENGE = Math.Round((decimal)BomData[i].QtyManual, 3).ToString(),//组件数量
|
||||
SORTF = BomData[i].fld005541,
|
||||
ITISOB = BomData[i].fld005542,
|
||||
ALPGR = BomData[i].fld005543,
|
||||
@ -626,7 +630,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
{
|
||||
POSNR = (bomData.IndexOf(bomItem) + 1).ToString(),
|
||||
IDNRK = bomItem.PartNumber,
|
||||
MENGE = bomItem.QtyManual.ToString(),
|
||||
MENGE = Math.Round((decimal)bomItem.QtyManual, 3).ToString(),
|
||||
SORTF = bomItem.fld005541,
|
||||
ITISOB = bomItem.fld005542,
|
||||
ALPGR = bomItem.fld005543,
|
||||
@ -661,7 +665,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
{
|
||||
POSNR = "",//组件序号 sun.ToString()
|
||||
IDNRK = BomData[i].PartNumber,//组件物料号
|
||||
MENGE = BomData[i].QtyManual.ToString(),//组件数量
|
||||
MENGE = Math.Round((decimal)BomData[i].QtyManual, 3).ToString(),//组件数量
|
||||
SORTF = BomData[i].fld005541,
|
||||
ITISOB = BomData[i].fld005542,
|
||||
ALPGR = BomData[i].fld005543,
|
||||
@ -1024,6 +1028,9 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)]
|
||||
[ApiDescriptionSettings(Name = "CreateLayout"), HttpPost]
|
||||
[DisplayName("创建排版软件")]
|
||||
public async Task<string> CreateLayout(CreateLayoutInput input)
|
||||
{
|
||||
string output = "";
|
||||
@ -1032,74 +1039,110 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
|
||||
return "请输入父项编码";
|
||||
}
|
||||
var parentData = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == input.ParentCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
||||
if (parentData != null)
|
||||
if (parentData == null)
|
||||
{
|
||||
return "未查询到父项编码";
|
||||
return "父项编码不存在,请检查";
|
||||
}
|
||||
int lineNumber = 0;
|
||||
if (!parentData.SWPDMStatusName.Contains("设计") && !parentData.SWPDMStatusName.Contains("工艺"))
|
||||
{
|
||||
return "不在设计或工艺阶段不允许添加";
|
||||
}
|
||||
var bom = await _configurationDataRep.AsQueryable().Where(x => x.ParentGuid == parentData.RecordGuid && x.isDeleted == false && x.ParentVersion == parentData.VersionIndex&&x.ConfigId==8).ToListAsync();
|
||||
if (bom.Count != 0)
|
||||
{
|
||||
return "编码已存在原材料不允许修改";
|
||||
}
|
||||
|
||||
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))
|
||||
var outputData = output + "子项编码" + item.ChildCode;
|
||||
if (string.IsNullOrEmpty(item.ChildCode))
|
||||
{
|
||||
outputData = outputData + "未输入必填项编码";
|
||||
output = 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)
|
||||
if (item.Quantity==0)
|
||||
{
|
||||
output = outputData + "未查询到子项编码;";
|
||||
output = outputData + "请输入数量";
|
||||
continue;
|
||||
}
|
||||
var childData = await _obj112Rep.AsQueryable().Where(x => x._System_objNBS == item.ChildCode && x.deleted == false).OrderByDescending(x => x.idRecord).ToListAsync();
|
||||
if (childData.Count == 0)
|
||||
{
|
||||
output = outputData + "不存在,请检查;";
|
||||
continue;
|
||||
}
|
||||
|
||||
var configurationData = await _configurationDataRep.AsQueryable().Where(x=> x.RecordImage!=null && x.ChildObjID ==112).FirstAsync();
|
||||
|
||||
var bomData = new ConfigurationData
|
||||
double num = item.Quantity.ToDouble();
|
||||
|
||||
// 将数值保留三位小数,再判断是否等于原数
|
||||
bool isMoreThanThreeDecimalPlaces = Math.Round(num, 3) != num;
|
||||
|
||||
if (isMoreThanThreeDecimalPlaces)
|
||||
{
|
||||
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+";";
|
||||
output = outputData + "数量格式不正确,请检查,只允许小数点后三位;";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (output == "")
|
||||
{
|
||||
int lineNumber = 0;
|
||||
foreach (var item in input.Item)
|
||||
{
|
||||
lineNumber++;
|
||||
string lineNumberStr = (lineNumber * 10).ToString("0000");
|
||||
|
||||
var childData = await _obj112Rep.AsQueryable().Where(x => x._System_objNBS == item.ChildCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
|
||||
|
||||
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();
|
||||
}
|
||||
return "成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user