using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Kingdee.BOS.WebApi.Client;
namespace BLL
{
public class ClsKf_MoveStockBill
{
///
/// 根据过滤条件,返回源单信息-返回调拨申请单列表
///
/// 过滤条件
/// 错误信息
///
public DataSet GetKf_MoveStockRequestBillList(string sWhere, ref string sErr)
{
try
{
DAL.Cls_S_IF_MoveStockRequestBill_Lite dal = new DAL.Cls_S_IF_MoveStockRequestBill_Lite();
return dal.DisSourceBillList(sWhere);
}
catch (Exception e)
{
sErr = sErr + "," + e.Message;
return null;
}
}
//生成调拨单
public bool set_SaveMoveStockBill(Model.ClsKf_MoveStockBillMain oMain, string sHSourceType, ref string sErrMsg)
{
DAL.ClsKf_MoveStockBill dal = new DAL.ClsKf_MoveStockBill();
DAL.ClsKF_PonderationBillMain_Temp_View tmp = new DAL.ClsKF_PonderationBillMain_Temp_View();
dal.omodel = oMain;
//判断扫描记录,是否按照先进先出规则
if (!tmp.CheckICInventory_FIFO_Tmp(oMain.HInterID, oMain.HBillType, ref sErrMsg))
{
return false;
}
//获取系统参数
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
if (oSystemParameter.ShowBill(ref sErrMsg) == false)
{
sErrMsg = "获取系统参数失败! " + sErrMsg;
return false;
}
//
if (oSystemParameter.omodel.Kf_MoveStockBill_ERPMode.ToUpper() == "WISE") //判断同步模式是金蝶WISE
{
//上传前必填项判断
if (oMain.HSecManagerID == 0)
{
sErrMsg = "验收没有选择!";
return false;
}
if (oMain.HKeeperID == 0)
{
sErrMsg = "保管没有选择!";
return false;
}
//同步生成K3单据
if (sHSourceType == "3720")
{
if (dal.AddBill_PDA(ref sErrMsg))
{
//"保存成功!";
return true;
}
else
{
//"保存失败!";
return false;
}
}
else if (sHSourceType == "1402")
{
if (dal.AddBill_PDA_SeOutStock(ref sErrMsg))
{
//"保存成功!";
return true;
}
else
{
//"保存失败!";
return false;
}
}
else if (sHSourceType == "1243")
{
if (dal.AddBill_PDA_MoveStockRequest(ref sErrMsg))
{
//"保存成功!";
return true;
}
else
{
//"保存失败!";
return false;
}
}
else
{
if (dal.AddBill_PDA(ref sErrMsg))
{
//"保存成功!";
return true;
}
else
{
//"保存失败!";
return false;
}
}
}
if (oSystemParameter.omodel.Kf_MoveStockBill_ERPMode.ToUpper() == "CLOUD") //判断同步模式是金蝶CLOUD
{
if (set_SaveMoveBill_CLD(oMain, sHSourceType, oSystemParameter.omodel, ref sErrMsg) == true)
{
//"保存成功!";
return true;
}
else
{
//"保存失败!";
return false;
}
}
sErrMsg = "保存调拨单失败!" + sErrMsg;
return false;
}
//调拨单 (领料、销售、直接)CLOUD
public bool set_SaveMoveBill_CLD(Model.ClsKf_MoveStockBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
{
//领料调拨(源单:生产任务单-投料)
if (sHSourceType == "3720")
{
if (SaveMoveMaterOut_CLD(oMain, oSystemParameterMain, ref sErrMsg))
{
//"保存成功!";
sErrMsg = "保存成功!" + oMain.HBillNo;
return true;
}
else
{
//"保存失败!";
//sErrMsg = sErrMsg;
return false;
}
}
//发货调拨(源单:发货通知单)
else if (sHSourceType == "1402")
{
if (SaveMoveSellOut_CLD(oMain, oSystemParameterMain, ref sErrMsg))
{
//"保存成功!";
sErrMsg = "保存成功!" + oMain.HBillNo;
return true;
}
else
{
//"保存失败!";
//sErrMsg = sErrMsg;
return false;
}
}
//直接调拨
else if (sHSourceType == "-1")
{
if (SaveMoveOut_CLD(oMain, oSystemParameterMain, ref sErrMsg))
{
//"保存成功!";
sErrMsg = "保存成功!" + oMain.HBillNo;
return true;
}
else
{
//"保存失败!";
//sErrMsg = sErrMsg;
return false;
}
}
else
{
sErrMsg = "错误的源单类型";
return false;
}
}
//直接调拨
private bool SaveMoveOut_CLD(Model.ClsKf_MoveStockBillMain oMain, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
{
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
try
{
DataSet Ds;
//
oCn.BeginTran();
//写入WMS调拨单
//插入子表
oCn.RunProc("EXEC h_p_Kf_MoveStockBillSub_Insert " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'");
//插入主表
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
",HStockStyle" +
") " +
" values('1207','1207'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
",2012,1,'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
",'" + oMain.HStockStyle + "'" +
") ");
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
//审核单据
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
}
//根据TMP表 返回 子表信息
Ds = oCn.RunProcReturn("exec h_p_Kf_GetMoveOutBill_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetMoveOutBill_CLD");
if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
{
sErrMsg = "获取子表信息失败!";
oCn.RollBack();
return false;
}
else
{
string sJson_StockStyle = "";
if (oSystemParameterMain.WMS_CampanyName == "韩电") //系统参数 客户定制化名称 空白为通用
{
sJson_StockStyle = "\"F_CHLX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_CHLX"]) + "\","; //调拨类型
}
else
{
sJson_StockStyle = "";
}
string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[]," +
"\"Model\":{ " +
"\"FBillNo\":\"" + oMain.HBillNo + "\"," +
"\"FBillTypeID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\" }," +
"\"FBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBizType"]) + "\"," +
"\"FTransferDirect\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferDirect"]) + "\"," +
"\"FTransferBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferBizType"]) + "\"," +
"\"FSettleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleOrgId"]) + "\" }," +
"\"FSaleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSaleOrgId"]) + "\" }," +
"\"FStockOutOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOutOrgId"]) + "\" }," +
"\"FOwnerTypeOutIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeOutIdHead"]) + "\"," +
"\"FOwnerOutIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerOutIdHead"]) + "\" }," +
"\"FStockOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\" }," +
"\"FIsIncludedTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsIncludedTax"]) + "," +
"\"FIsPriceExcludeTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsPriceExcludeTax"]) + "," +
"\"FOwnerTypeIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeIdHead"]) + "\"," +
"\"FSETTLECURRID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLECURRID"]) + "\" }," +
"\"FOwnerIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerIdHead"]) + "\" }," +
//"\"FDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FBaseCurrId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBaseCurrId"]) + "\" }," +
sJson_StockStyle +
"\"FBillEntry\": [ ";
string sJson_Entry = "";
string sJson_SrcStockPlace = "";
string sJson_DestStockPlace = "";
for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
{
if (sJson_Entry != "")
{
sJson_Entry = sJson_Entry + " , ";
}
string sJson_BatchNo = "";
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
{
sJson_BatchNo = " \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"}, \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\" , ";
}
else
{
sJson_BatchNo = "";
}
if (oSystemParameterMain.WMS_CampanyName == "卓力") //系统参数 客户定制化名称 空白为通用
{
sJson_SrcStockPlace = "\"FSrcStockLocId\":{\"FSRCSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}},";
sJson_DestStockPlace = "\"FDestStockLocId\":{\"FDESTSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}},";
}
else
{
//调入仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) == "")
{
sJson_SrcStockPlace = "";
}
else
{
sJson_SrcStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}},";
}
//调出仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) == "")
{
sJson_DestStockPlace = "";
}
else
{
sJson_DestStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}},";
}
}
//自定义字段处理
sJson_Entry = sJson_Entry + " {\"FSEQ\":\"" + Convert.ToString(i + 1) + "\"," +
"\"FMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\" }," +
"\"FUnitID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\" }," +
"\"FQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQty"]) + "\"," +
"\"FSrcStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockId"]) + "\" }," +
sJson_SrcStockPlace +
//"\"FSrcStockLocId\":{\"FSRCSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}}," +
"\"FDestStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockId"]) + "\" }," +
sJson_DestStockPlace +
//"\"FDestStockLocId\":{\"FDESTSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}}," +
"\"FSrcStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockStatusId"]) + "\" }," +
"\"FDestStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockStatusId"]) + "\" }," +
// "\"FBusinessDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FOwnerTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeOutId"]) + "\"," +
"\"FOwnerOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerOutId"]) + "\" }," +
"\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
"\"FOwnerId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\" }," +
"\"FBaseUnitId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\" }," +
"\"FBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseQty"]) + "\"," +
"\"FISFREE\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "," +
"\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
"\"FKeeperId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperId"]) + "\" }," +
"\"FKeeperTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeOutId"]) + "\"," +
"\"FKeeperOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperOutId"]) + "\" }," +
"\"FDestMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestMaterialId"]) + "\" }," +
"\"FPriceUnitId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceUnitId"]) + "\" }," +
"\"FPriceQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceQty"]) + "\"," +
"\"FPriceBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FPriceQty"]) + "\"," +
"\"FTransReserveLink\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTransReserveLink"]) + "," +
"\"FCheckDelivery\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckDelivery"]) + "," +
//"\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," +
//"\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
//"\"FORDERTYPE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERTYPE"]) + "\" }," +
//"\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," +
//"\"FBillEntry_Link\": [ { " +
//"\"FBillEntry_Link_FFLOWID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWID"]) + "\"," +
//"\"FBillEntry_Link_FFLOWLINEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWLINEID"]) + "\"," +
//"\"FBillEntry_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FRuleId"]) + "\"," +
//"\"FBillEntry_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSTableName"]) + "\"," +
//"\"FBillEntry_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSBillId"]) + "\"," +
//"\"FBillEntry_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSId"]) + "\"," +
//" } ]
" } ";
}
string sJson_End = " ] }}";
string sJson = sJson_Main + sJson_Entry + sJson_End;
//从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
{
sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
return false;
}
//生成 直接调拨 1个物料1单
string HReturn;
ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
bool bLogin = client.Login(dbId, Pub_Class.ClsPub.sCLOUDUseName, Pub_Class.ClsPub.sCLOUDPsd, 2052);
if (bLogin)
{
var result = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
new object[] { "STK_TransferDirect", sJson });
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result2 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
new object[] { "STK_TransferDirect", sJson2 });
string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result3 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
new object[] { "STK_TransferDirect", sJson3 });
HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
}
else
{
HReturn = result.ToString();
}
if (HReturn.Contains("\"IsSuccess\":false") == true)
{
sErrMsg = "生成直接调拨单失败!" + HReturn + sJson;
oCn.RollBack();
return false;
}
else
{
oCn.Commit();
return true;
}
}
else
{
sErrMsg = "生成直接调拨单失败!登录失败!";
oCn.RollBack();
return false;
}
}
}
catch (Exception e)
{
sErrMsg = "生成直接调拨单失败!" + e.Message;
oCn.RollBack();
return false;
}
}
//领料调拨
private bool SaveMoveMaterOut_CLD(Model.ClsKf_MoveStockBillMain oMain, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
{
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
try
{
DataSet Ds;
//
oCn.BeginTran();
//写入WMS调拨单
//插入子表
oCn.RunProc("EXEC h_p_Kf_MoveStockBillSub_Insert " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'");
//插入主表
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
",HStockStyle" +
") " +
" values('1207','1207'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
",2012,1,'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
",'" + oMain.HStockStyle + "'" +
") ");
//更新关联数量
oCn.RunProc("exec h_p_Sc_UpDateMoveStockPPBomRelation_Add " + oMain.HInterID.ToString());
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
//审核单据
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
}
//返工生产调拨 回填条码档案源单信息
if (oSystemParameterMain.WMS_CampanyName == "韩电") //系统参数 客户定制化名称 空白为通用
{
oCn.RunProc("exec h_p_Kf_MoveMaterOut_UpdateSourceByBarCodeBill " + oMain.HInterID.ToString());
}
//根据TMP表 返回 子表信息
Ds = oCn.RunProcReturn("exec h_p_Kf_GetMoveMaterOutBill_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetMoveMaterOutBill_CLD");
if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
{
sErrMsg = "获取子表信息失败!";
oCn.RollBack();
return false;
}
else
{
string sJson_StockStyle = "";
if (oSystemParameterMain.WMS_CampanyName == "韩电") //系统参数 客户定制化名称 空白为通用
{
sJson_StockStyle = "\"F_CHLX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_CHLX"]) + "\","; //调拨类型
}
else
{
sJson_StockStyle = "";
}
string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[]," +
"\"Model\":{ " +
"\"FBillNo\":\"" + oMain.HBillNo + "\"," +
"\"FBillTypeID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\" }," +
"\"FBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBizType"]) + "\"," +
"\"FTransferDirect\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferDirect"]) + "\"," +
"\"FTransferBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferBizType"]) + "\"," +
"\"FSettleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleOrgId"]) + "\" }," +
"\"FSaleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSaleOrgId"]) + "\" }," +
"\"FStockOutOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOutOrgId"]) + "\" }," +
"\"FOwnerTypeOutIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeOutIdHead"]) + "\"," +
"\"FOwnerOutIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerOutIdHead"]) + "\" }," +
"\"FStockOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\" }," +
"\"FIsIncludedTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsIncludedTax"]) + "," +
"\"FIsPriceExcludeTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsPriceExcludeTax"]) + "," +
"\"FOwnerTypeIdHead \":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeIdHead"]) + "\"," +
"\"FSETTLECURRID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLECURRID"]) + "\" }," +
"\"FOwnerIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerIdHead"]) + "\" }," +
"\"FDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FBaseCurrId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBaseCurrId"]) + "\" }," +
sJson_StockStyle +
"\"FBillEntry\": [ ";
string sJson_Entry = "";
for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
{
if (sJson_Entry != "")
{
sJson_Entry = sJson_Entry + " , ";
}
string sJson_BatchNo = "";
string sJson_SrcStockPlace = "";
string sJson_DestStockPlace = "";
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
{
sJson_BatchNo = " \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"}, \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\" , ";
}
else
{
sJson_BatchNo = "";
}
//调入仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) == "")
{
sJson_SrcStockPlace = "";
}
else
{
sJson_SrcStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}},";
}
//调出仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) == "")
{
sJson_DestStockPlace = "";
}
else
{
sJson_DestStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}},";
}
//自定义字段处理
sJson_Entry = sJson_Entry + " { \"FSEQ\":\"" + Convert.ToString(i + 1) + "\"," +
"\"FMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\" }," +
"\"FUnitID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\" }," +
"\"FQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQty"]) + "\"," +
"\"FSrcStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockId"]) + "\" }," +
sJson_SrcStockPlace +
//"\"FSrcStockLocId\":{\"FSRCSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}}," +
"\"FDestStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockId"]) + "\" }," +
sJson_DestStockPlace +
//"\"FDestStockLocId\":{\"FDESTSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}}," +
"\"FSrcStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockStatusId"]) + "\" }," +
"\"FDestStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockStatusId"]) + "\" }," +
"\"FBusinessDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FOwnerTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeOutId"]) + "\"," +
"\"FOwnerOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerOutId"]) + "\" }," +
"\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
"\"FOwnerId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\" }," +
"\"FBaseUnitId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\" }," +
"\"FSecUnitID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSecUnitID"]) + "\" }," +
"\"FBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseQty"]) + "\"," +
"\"FISFREE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "\"," +
"\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
"\"FKeeperId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperId"]) + "\" }," +
"\"FKeeperTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeOutId"]) + "\"," +
"\"FKeeperOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperOutId"]) + "\" }," +
"\"FDestMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestMaterialId"]) + "\" }," +
"\"FTransReserveLink\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTransReserveLink"]) + "\"," +
"\"FCheckDelivery\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckDelivery"]) + "\"," +
sJson_BatchNo +
"\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," +
"\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
"\"FORDERTYPE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERTYPE"]) + "\" }," +
"\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," +
"\"FBillEntry_Link\": [ { " +
"\"FBillEntry_Link_FFLOWID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWID"]) + "\"," +
"\"FBillEntry_Link_FFLOWLINEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWLINEID"]) + "\"," +
"\"FBillEntry_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FRuleId"]) + "\"," +
"\"FBillEntry_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSTableName"]) + "\"," +
"\"FBillEntry_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSBillId"]) + "\"," +
"\"FBillEntry_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSId"]) + "\"," +
" } ] } ";
}
string sJson_End = " ] }}";
string sJson = sJson_Main + sJson_Entry + sJson_End;
//从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
{
sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
return false;
}
//生成 领料调拨 1个物料1单
string HReturn;
ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
bool bLogin = client.Login(dbId, Pub_Class.ClsPub.sCLOUDUseName, Pub_Class.ClsPub.sCLOUDPsd, 2052);
if (bLogin)
{
var result = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
new object[] { "STK_TransferDirect", sJson });
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result2 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
new object[] { "STK_TransferDirect", sJson2 });
string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result3 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
new object[] { "STK_TransferDirect", sJson3 });
HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
}
else
{
HReturn = result.ToString();
}
if (HReturn.Contains("\"IsSuccess\":false") == true)
{
sErrMsg = "生成领料调拨单失败!" + HReturn + sJson;
oCn.RollBack();
return false;
}
else
{
oCn.Commit();
return true;
}
}
else
{
sErrMsg = "生成领料调拨单失败!登录失败!";
oCn.RollBack();
return false;
}
}
}
catch (Exception e)
{
sErrMsg = "生成领料调拨单失败!" + e.Message;
oCn.RollBack();
return false;
}
}
//发货调拨
private bool SaveMoveSellOut_CLD(Model.ClsKf_MoveStockBillMain oMain, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
{
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
try
{
DataSet Ds;
//
oCn.BeginTran();
//写入WMS调拨单
//插入子表
oCn.RunProc("EXEC h_p_Kf_MoveStockBillSub_Insert_SeOutStock " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'");
//插入主表
oCn.RunProc("Insert Into Kf_ICStockBillMain " +
"(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
",HStockStyle" +
") " +
" values('1207','1207'," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "',convert(varchar(10),getdate(),120),'" + oMain.HMainSourceBillType + "'" +
",2012,1,'" + oMain.HRemark + "','" + oMain.HMaker + "',convert(varchar(10),getdate(),120)" +
", " + oMain.HSupID.ToString() + "," + oMain.HWHID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HEmpID.ToString() + "," + oMain.HManagerID.ToString() + "," + oMain.HSecManagerID.ToString() +
", " + oMain.HKeeperID.ToString() + "," + oMain.HDeptID.ToString() + ",'" + oMain.HExplanation + "','" + oMain.HInnerBillNo + "'," + DBUtility.ClsPub.BoolToString(oMain.HRedBlueFlag) +
",'" + oMain.HStockStyle + "'" +
") ");
//更新关联数量
oCn.RunProc("exec h_p_Xs_UpDateSeOutStockRelation_Add " + oMain.HInterID.ToString());
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
//审核单据
oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120),HBillStatus=2 where HInterID= " + oMain.HInterID.ToString());
}
//根据TMP表 返回 子表信息
Ds = oCn.RunProcReturn("exec h_p_Kf_GetMoveSellOutBill_CLD " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetMoveSellOutBill_CLD");
if (Ds == null || Ds.Tables[0].Rows.Count == 0 || Ds.Tables[1].Rows.Count == 0)
{
sErrMsg = "获取子表信息失败!";
oCn.RollBack();
return false;
}
else
{
string sJson_StockStyle = "";
if (oSystemParameterMain.WMS_CampanyName == "韩电") //系统参数 客户定制化名称 空白为通用
{
sJson_StockStyle = "\"F_CHLX\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_CHLX"]) + "\","; //调拨类型
}
else
{
sJson_StockStyle = "";
}
string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[]," +
"\"Model\":{ " +
"\"FBillNo\":\"" + oMain.HBillNo + "\"," +
"\"FBillTypeID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillTypeID"]) + "\" }," +
"\"FBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBizType"]) + "\"," +
"\"FTransferDirect\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferDirect"]) + "\"," +
"\"FTransferBizType\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FTransferBizType"]) + "\"," +
"\"FSettleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSettleOrgId"]) + "\" }," +
"\"FSaleOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSaleOrgId"]) + "\" }," +
"\"FStockOutOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOutOrgId"]) + "\" }," +
"\"FOwnerTypeOutIdHead\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeOutIdHead"]) + "\"," +
"\"FOwnerOutIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerOutIdHead"]) + "\" }," +
"\"FStockOrgId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FStockOrgId"]) + "\" }," +
"\"FIsIncludedTax\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsIncludedTax"]) + "\"," +
"\"FIsPriceExcludeTax\":" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FIsPriceExcludeTax"]) + "," +
"\"FOwnerTypeIdHead \":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerTypeIdHead"]) + "\"," +
"\"FSETTLECURRID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FSETTLECURRID"]) + "\" }," +
"\"FOwnerIdHead\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FOwnerIdHead"]) + "\" }," +
"\"FDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FBaseCurrId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBaseCurrId"]) + "\" }," +
sJson_StockStyle +
"\"FBillEntry\": [ ";
string sJson_Entry = "";
for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
{
if (sJson_Entry != "")
{
sJson_Entry = sJson_Entry + " , ";
}
string sJson_BatchNo = "";
string sJson_SrcStockPlace = "";
string sJson_DestStockPlace = "";
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["HISBATCHMANAGE"]) == "1") //是否启用批次管理
{
sJson_BatchNo = " \"FLOT\": {\"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\"}, \"FLOT_TEXT\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FLOT"]) + "\" , ";
}
else
{
sJson_BatchNo = "";
}
if (oSystemParameterMain.WMS_CampanyName == "卓力") //系统参数 客户定制化名称 空白为通用
{
sJson_SrcStockPlace = "\"FSrcStockLocId\":{\"FSRCSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}},";
sJson_DestStockPlace = "\"FDestStockLocId\":{\"FDESTSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}},";
}
else
{
//调入仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) == "")
{
sJson_SrcStockPlace = "";
}
else
{
sJson_SrcStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}},";
}
//调出仓位
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) == "")
{
sJson_DestStockPlace = "";
}
else
{
sJson_DestStockPlace = Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}},";
}
}
//自定义字段处理
sJson_Entry = sJson_Entry + " { \"FSEQ\":\"" + Convert.ToString(i + 1) + "\"," +
"\"FMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FMaterialId"]) + "\" }," +
"\"FUnitID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FUnitID"]) + "\" }," +
"\"FQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FQty"]) + "\"," +
"\"FSrcStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockId"]) + "\" }," +
sJson_SrcStockPlace +
//"\"FSrcStockLocId\":{\"FSRCSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockLocId"]) + "\"}}," +
"\"FDestStockId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockId"]) + "\" }," +
sJson_DestStockPlace +
//"\"FDestStockLocId\":{\"FDESTSTOCKLOCID__FF100002\":{\"FNUMBER\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockLocId"]) + "\"}}," +
"\"FSrcStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSrcStockStatusId"]) + "\" }," +
"\"FDestStockStatusId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestStockStatusId"]) + "\" }," +
"\"FBusinessDate\":\"" + oMain.HDate.ToShortDateString() + "\"," +
"\"FOwnerTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeOutId"]) + "\"," +
"\"FOwnerOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerOutId"]) + "\" }," +
"\"FOwnerTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerTypeId"]) + "\"," +
"\"FOwnerId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FOwnerId"]) + "\" }," +
"\"FBaseUnitId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseUnitId"]) + "\" }," +
"\"FSecUnitID\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSecUnitID"]) + "\" }," +
"\"FBaseQty\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBaseQty"]) + "\"," +
"\"FISFREE\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FISFREE"]) + "\"," +
"\"FKeeperTypeId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeId"]) + "\"," +
"\"FKeeperId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperId"]) + "\" }," +
"\"FKeeperTypeOutId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperTypeOutId"]) + "\"," +
"\"FKeeperOutId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FKeeperOutId"]) + "\" }," +
"\"FDestMaterialId\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FDestMaterialId"]) + "\" }," +
"\"FTransReserveLink\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FTransReserveLink"]) + "\"," +
"\"FCheckDelivery\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FCheckDelivery"]) + "\"," +
sJson_BatchNo +
"\"FSRCBILLTYPEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLTYPEID"]) + "\"," +
"\"FSRCBILLNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FSRCBILLNO"]) + "\"," +
"\"FORDERTYPE\":{ \"FNumber\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERTYPE"]) + "\" }," +
"\"FORDERNO\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FORDERNO"]) + "\"," +
"\"FBillEntry_Link\": [ { " +
"\"FBillEntry_Link_FFLOWID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWID"]) + "\"," +
"\"FBillEntry_Link_FFLOWLINEID\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FFLOWLINEID"]) + "\"," +
"\"FBillEntry_Link_FRuleId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FRuleId"]) + "\"," +
"\"FBillEntry_Link_FSTableName\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSTableName"]) + "\"," +
"\"FBillEntry_Link_FSBillId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSBillId"]) + "\"," +
"\"FBillEntry_Link_FSId\":\"" + Pub_Class.ClsPub.isStrNull(Ds.Tables[1].Rows[i]["FBillEntry_Link_FSId"]) + "\"," +
" } ] } ";
}
string sJson_End = " ] }}";
string sJson = sJson_Main + sJson_Entry + sJson_End;
//从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
{
sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
return false;
}
//生成 发货调拨 1个物料1单
string HReturn;
ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
bool bLogin = client.Login(dbId, Pub_Class.ClsPub.sCLOUDUseName, Pub_Class.ClsPub.sCLOUDPsd, 2052);
if (bLogin)
{
var result = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
new object[] { "STK_TransferDirect", sJson });
if (oSystemParameterMain.Kf_MoveStockBill_AutoCheck == "Y") //系统参数 自动审核
{
string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result2 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
new object[] { "STK_TransferDirect", sJson2 });
string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
var result3 = client.Execute("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
new object[] { "STK_TransferDirect", sJson3 });
HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
}
else
{
HReturn = result.ToString();
}
if (HReturn.Contains("\"IsSuccess\":false") == true)
{
sErrMsg = "生成发货调拨单失败!" + HReturn + sJson;
oCn.RollBack();
return false;
}
else
{
if (oSystemParameterMain.WMS_CampanyName == "韩电")
{
//调拨(源单发货通知单)时反写发货通知单、销售订单
if (Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_XSLX"]) == "外销")
{
//外销反写发货通知单、销售订单数量
oCn.RunProc("EXEC h_p_ToCLD_BackDataDELIVERYNOTICE_Move '" + oMain.HBillNo + "'");
}
else if (Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_XSLX"]) == "内销"
|| Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_XSLX"]) == "OEM"
|| Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["F_XSLX"]) == "电商")
{
//内销、OEM和电商 关闭发货通知单、销售订单
oCn.RunProc("EXEC h_p_ToCLD_BackDataDELIVERYNOTICE_Move_Close '" + oMain.HBillNo + "'");
}
}
oCn.Commit();
return true;
}
}
else
{
sErrMsg = "生成发货调拨单失败!登录失败!";
oCn.RollBack();
return false;
}
}
}
catch (Exception e)
{
sErrMsg = "生成发货调拨单失败!" + e.Message;
oCn.RollBack();
return false;
}
}
}
}