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