提交
This commit is contained in:
@@ -10,26 +10,32 @@ using ThreadContext = UFSoft.U8.Framework.ContextSrv.ThreadContext;
|
||||
using VBLogin = U8Login.clsLogin;
|
||||
// ReSharper disable IdentifierTypo
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable CommentTypo
|
||||
// ReSharper disable FieldCanBeMadeReadOnly.Local
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
|
||||
public class BaseLogin
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
|
||||
private NetLogin _netLogin { get; set; }
|
||||
public VBLogin _vbLogin { get; set; }
|
||||
static ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
public ProductContext _productContext { get; set; }
|
||||
|
||||
public Connection Connection { get; set; }
|
||||
public NetLogin _netLogin;
|
||||
|
||||
public VBLogin _vbLogin;
|
||||
|
||||
public ProductContext _productContext;
|
||||
|
||||
public Connection Connection;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化生产制造上下文
|
||||
/// </summary>
|
||||
/// <param name="paramter">登录参数</param>
|
||||
/// <param name="bMon"></param>
|
||||
/// <param name="traceTimes"></param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public void Init(LoginParamter paramter,bool bMon=true, int traceTimes=0)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
public interface IBaseBF
|
||||
{
|
||||
BaseResult<string> Save(string cCardNum, Dictionary<string, object> input);
|
||||
|
||||
BaseResult<string> Save(string cCardNum, List<Dictionary<string, object>> inputs);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ using UFSoft.U8.U8M.DOSchema.MO;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产订单
|
||||
/// </summary>
|
||||
public class MOrder
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Reflection;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
using UFSoft.U8.Framework.BizBase;
|
||||
using UFSoft.U8.Framework.ContextSrv;
|
||||
using UFSoft.U8.U8M.BFDispatcher;
|
||||
using UFSoft.U8.U8M.Common;
|
||||
@@ -22,15 +23,19 @@ using UFSoft.U8.U8M.Exceptions;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
|
||||
public class MoRoutingBill
|
||||
/// <summary>
|
||||
/// 报工单
|
||||
/// </summary>
|
||||
public class MoRoutingBill: IBaseBF
|
||||
{
|
||||
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
private IContextContainer callar { get; set; }
|
||||
|
||||
private MoRoutingBillDs GetEmptyDs(string cCardNum)
|
||||
{
|
||||
var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, new DefaultContextContainer());
|
||||
var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, callar);
|
||||
|
||||
#region 清除数据集里的数据
|
||||
|
||||
@@ -63,7 +68,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
|
||||
ds.MoRoutingBill.AddMoRoutingBillRow(head);
|
||||
|
||||
var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, docNoParam.Paramaters, false, new DefaultContextContainer());
|
||||
var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, docNoParam.Paramaters, false, callar);
|
||||
|
||||
var be = new UFSoft.U8.SF.BE.MoRoutingBill(ds);
|
||||
|
||||
@@ -98,14 +103,17 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BaseResult<string> Save(string cCardNum, Dictionary<string, object> input)
|
||||
{
|
||||
try
|
||||
{
|
||||
callar = new DefaultContextContainer();
|
||||
|
||||
var docNoParam = new AutoDocNoGenerateParam(EnumAutoDocNoType.HandAuto, cCardNum)
|
||||
{
|
||||
IsCurrentDocNoByHand = false
|
||||
};
|
||||
{
|
||||
IsCurrentDocNoByHand = false
|
||||
};
|
||||
|
||||
var ds = GetVoucherDs(cCardNum, docNoParam, input);
|
||||
|
||||
@@ -119,7 +127,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
|
||||
logInfo.Debug($"单据编码:{cCardNum},开始保存");
|
||||
|
||||
var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds, docNoParam, new DefaultContextContainer());
|
||||
var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds, docNoParam, callar);
|
||||
|
||||
|
||||
logInfo.Debug($"单据编码:{cCardNum},保存完成,id:{id}");
|
||||
@@ -139,8 +147,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
logInfo.Error(ex.InnerException.Message, ex.InnerException);
|
||||
|
||||
return new BaseResult<string>
|
||||
{ bSuccess = false, message = "新增失败", result = ex.InnerException.Message };
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.InnerException.Message };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Common;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Json;
|
||||
using UFIDA.U8.Framework.Api.ControlObject.Models;
|
||||
using UFSoft.U8.Framework.BizBase;
|
||||
using UFSoft.U8.Framework.ContextSrv;
|
||||
using UFSoft.U8.U8M.BFDispatcher;
|
||||
using UFSoft.U8.U8M.Common;
|
||||
using UFSoft.U8.U8M.DOSchema.BO;
|
||||
using UFSoft.U8.U8M.DOSchema.SF;
|
||||
using UFSoft.U8.U8M.Exceptions;
|
||||
using UFSoft.U8.U8MCommon.GSetup;
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
||||
{
|
||||
/// <summary>
|
||||
/// 标准BOM
|
||||
/// </summary>
|
||||
public class StandardBom
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
private IContextContainer callar { get; set; }
|
||||
|
||||
public StandardBom()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private StandardBomDs GetEmptyDs()
|
||||
{
|
||||
var standardBomDs = new StandardBomDs();
|
||||
var standardBomRow = standardBomDs.StandardBom.NewStandardBomRow();
|
||||
standardBomRow.BomType = 1;
|
||||
standardBomRow.VersionEffDate = MParameters.Instance.DefaultVersionDate;
|
||||
standardBomRow.Status = (byte)MParameters.Instance.Options.BomDefaultStatus;
|
||||
standardBomDs.StandardBom.AddStandardBomRow(standardBomRow);
|
||||
var bomParentRow = standardBomDs.BomParent.NewBomParentRow();
|
||||
bomParentRow.BomId = standardBomRow.BomId;
|
||||
bomParentRow.AutoId = $"{Guid.NewGuid()}";
|
||||
standardBomDs.BomParent.AddBomParentRow(bomParentRow);
|
||||
return standardBomDs;
|
||||
}
|
||||
|
||||
private StandardBomDs GetVoucherDs(Dictionary<string, object> input)
|
||||
{
|
||||
var ds = GetEmptyDs();
|
||||
|
||||
var be = new UFSoft.U8.BO.BE.BomEntity(ds);
|
||||
|
||||
be.BomType = EnumBOMCatalogType.StandardBom;
|
||||
|
||||
var beHead = new BEHelper(be.Bom);
|
||||
|
||||
beHead.SetValue(input);
|
||||
|
||||
beHead.SetPartId();
|
||||
|
||||
var bodys = input["body"] as List<Dictionary<string, object>> ?? $"{input["body"]}".ToObject<List<Dictionary<string, object>>>();
|
||||
|
||||
for (var i = 0; i < bodys.Count; i++)
|
||||
{
|
||||
var body = bodys[i];
|
||||
var detail = be.Bom.Components[i];
|
||||
|
||||
var beBody = new BEHelper(detail);
|
||||
|
||||
beBody.SetValue(body);
|
||||
|
||||
beBody.SetPartId();
|
||||
}
|
||||
|
||||
return (StandardBomDs)be.InstanceBom.DataObject;
|
||||
}
|
||||
|
||||
public BaseResult<string> Save(Dictionary<string, object> input)
|
||||
{
|
||||
try
|
||||
{
|
||||
callar = new DefaultContextContainer();
|
||||
|
||||
var ds = GetVoucherDs(input);
|
||||
|
||||
if (ds == null)
|
||||
{
|
||||
throw new Exception("未能构建数据集");
|
||||
}
|
||||
|
||||
//var context = new DefaultContextContainer();
|
||||
//context.context["taskid"] = taskId;
|
||||
|
||||
logInfo.Debug("单据编码:BO11,开始保存");
|
||||
|
||||
var id = BOMExecutor.BFStandardBom_Save(ds, callar);
|
||||
|
||||
|
||||
logInfo.Debug($"单据编码:BO11,保存完成,id:{id}");
|
||||
|
||||
return new BaseResult<string> { bSuccess = true, message = "新增成功", result = $"{id}" };
|
||||
|
||||
}
|
||||
catch (U8MReferenceBENotExistException ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
if (ex.InnerException is U8MReferenceBENotExistException)
|
||||
{
|
||||
logInfo.Error(ex.InnerException.Message, ex.InnerException);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.InnerException.Message };
|
||||
}
|
||||
else
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user