128 lines
3.9 KiB
C#
128 lines
3.9 KiB
C#
using log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
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.Framework.DBConnection;
|
|
using UFSoft.U8.Framework.LoginContext;
|
|
using UFSoft.U8.U8M.BFDispatcher;
|
|
using UFSoft.U8.U8M.Common;
|
|
using UFSoft.U8.U8M.DOSchema.SF;
|
|
using ThreadContext = UFSoft.U8.Framework.ContextSrv.ThreadContext;
|
|
// ReSharper disable IdentifierTypo
|
|
// ReSharper disable InconsistentNaming
|
|
// ReSharper disable StringLiteralTypo
|
|
|
|
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
|
|
{
|
|
public class MoRoutingBill
|
|
{
|
|
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
|
|
|
private MoRoutingBillDs GetEmptyDs(string cCardNum)
|
|
{
|
|
var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, new DefaultContextContainer());
|
|
|
|
#region 清除数据集里的数据
|
|
|
|
if (ds.Tables.Contains("fc_MoRoutingBilldetail_ExtraDefine"))
|
|
{
|
|
ds.Tables["fc_MoRoutingBilldetail_ExtraDefine"].Clear();
|
|
}
|
|
if (ds.Tables.Contains("fc_MoRoutingBill_ExtraDefine"))
|
|
{
|
|
ds.Tables["fc_MoRoutingBill_ExtraDefine"].Clear();
|
|
}
|
|
|
|
ds.MoRoutingBillRes.Clear();
|
|
ds.MoRoutingBillDetail.Clear();
|
|
ds.MoRoutingBill.Clear();
|
|
|
|
#endregion
|
|
|
|
return ds;
|
|
}
|
|
|
|
|
|
private MoRoutingBillDs GetVoucherDs(string cCardNum, AutoDocNoGenerateParam docNoParam, Dictionary<string, object> input)
|
|
{
|
|
|
|
var ds = GetEmptyDs(cCardNum);
|
|
|
|
var head = ds.MoRoutingBill.NewMoRoutingBillRow();
|
|
|
|
ds.MoRoutingBill.AddMoRoutingBillRow(head);
|
|
|
|
var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, docNoParam.Paramaters, false, new DefaultContextContainer());
|
|
|
|
var be = new UFSoft.U8.SF.BE.MoRoutingBill(ds);
|
|
|
|
be.cVouchType = cCardNum;
|
|
be.cVouchCode = "";
|
|
|
|
var beHead = new BEHelper(be);
|
|
|
|
beHead.SetValue(input);
|
|
|
|
if (string.IsNullOrWhiteSpace(be.cVouchCode))
|
|
{
|
|
be.cVouchCode = docNo;
|
|
}
|
|
|
|
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.MoRoutingBillDetails[i];
|
|
|
|
var beBody = new BEHelper(detail);
|
|
|
|
beBody.SetValue(body);
|
|
}
|
|
|
|
|
|
return (MoRoutingBillDs)be.DataObject;
|
|
}
|
|
|
|
|
|
public BaseResult<dynamic> Save(string cCardNum, Dictionary<string, object> input)
|
|
{
|
|
try
|
|
{
|
|
var docNoParam = new AutoDocNoGenerateParam(EnumAutoDocNoType.HandAuto, cCardNum)
|
|
{
|
|
IsCurrentDocNoByHand = false
|
|
};
|
|
|
|
var ds = GetVoucherDs(cCardNum, docNoParam, input);
|
|
|
|
if (ds == null)
|
|
{
|
|
throw new Exception("未能构建数据集");
|
|
}
|
|
|
|
//var context = new DefaultContextContainer();
|
|
//context.context["taskid"] = taskId;
|
|
|
|
var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds, docNoParam, new DefaultContextContainer());
|
|
|
|
return new BaseResult<dynamic>() { bSuccess = true, message = "新增成功", result = id };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logInfo.Error(ex.Message, ex);
|
|
|
|
return new BaseResult<dynamic>() { bSuccess = false, message = "新增失败", result = ex.Message };
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|