You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
796 lines
34 KiB
796 lines
34 KiB
using ICS.WCF.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UFIDA.ISV.ApproveMiscShip;
|
|
using UFIDA.ISV.CommitMiscShip;
|
|
using UFIDA.ISV.CreateLotMaster;
|
|
using UFSoft.UBF.Service;
|
|
using UFSoft.UBF.Util.Context;
|
|
using www.ufida.org.EntityData;
|
|
|
|
namespace UFIDA.ISV.CreateBFMisShip
|
|
{
|
|
|
|
public class CustCreateBFMisShipSrvSub
|
|
{
|
|
public List<rtnRcvInfo> CustCreateBFMisShip(List<rCVhead> rCVInfoList)
|
|
{
|
|
#region 接口传入参数日志
|
|
StringBuilder firststrlog = new StringBuilder();
|
|
firststrlog.AppendLine("传入数据开始");
|
|
firststrlog.AppendLine("*****************************************************");
|
|
foreach (var item in rCVInfoList)
|
|
{
|
|
firststrlog.AppendLine("表头信息 :");
|
|
firststrlog.AppendLine("单据编号:" + item.DocNO);
|
|
firststrlog.AppendLine("单据类型:" + item.DocType);
|
|
firststrlog.AppendLine("组织编码:" + item.OrgCode);
|
|
firststrlog.AppendLine("客户编码:" + item.ClientCode);
|
|
int i = 0;
|
|
foreach (var line in item.lines)
|
|
{
|
|
i++;
|
|
firststrlog.AppendLine("表体信息" + i + " :");
|
|
firststrlog.AppendLine("料品编码:" + line.ItemCode);
|
|
firststrlog.AppendLine("料品数量:" + line.ReqQty);
|
|
firststrlog.AppendLine("批号:" + line.Batch);
|
|
firststrlog.AppendLine("仓库:" + line.WhCode);
|
|
}
|
|
}
|
|
firststrlog.AppendLine("*****************************************************");
|
|
firststrlog.AppendLine("传入数据结束");
|
|
Appconfig.WriteLogFile(firststrlog.ToString(), "创建杂发单");
|
|
#endregion
|
|
#region 服务调用框架结构
|
|
UFIDAU9ISVMiscShipISVICommonCreateMiscShipClient client = new UFIDAU9ISVMiscShipISVICommonCreateMiscShipClient();
|
|
//服务返回结果
|
|
UFIDAU9CBOPubControllerCommonArchiveDataDTOData[] returnItems;
|
|
//返回异常信息,目前还没有使用此属性
|
|
UFSoft.UBF.Exceptions1.MessageBase[] returnMsg;
|
|
//上下文信息
|
|
object context;
|
|
//传入 参数
|
|
UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData[] pOList;
|
|
//空
|
|
string[] splitBy = new string[] { };
|
|
|
|
string updatesql = "";
|
|
try
|
|
{
|
|
List<rtnRcvInfo> rtnpos = new List<rtnRcvInfo>();
|
|
long PickID = 0;
|
|
long ItemID = 0;
|
|
if (rCVInfoList == null || rCVInfoList.Count == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入参数不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
|
|
foreach (var item in rCVInfoList)
|
|
{
|
|
if (item.DocType == null || item.DocType == "")
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入单据类型不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
//if (item.ClientCode == null || item.ClientCode == "")
|
|
//{
|
|
// rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
// rtnpo.IsSuccess = false;
|
|
// rtnpo.Message = "传入客户信息不能为空";
|
|
// rtnpos.Add(rtnpo);
|
|
// return rtnpos;
|
|
//}
|
|
if (item.lines == null || item.lines.Count() == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入行信息不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
foreach (var _item in item.lines)
|
|
{
|
|
if (_item.ItemCode == null || _item.ItemCode == "")
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入行信息中料号不能为空!";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
if (_item.ReqQty == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入行信息中数量不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
if (_item.WhCode == null || _item.WhCode == "")
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入行信息中仓库不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
if (_item.DeptCode == null || _item.DeptCode == "")
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "传入行信息中部门不能为空";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//给上下文信息赋值
|
|
context = CreateContextObj();
|
|
//给传入参数赋值
|
|
|
|
//pOList = SetrCVDtos(rCVInfoList);
|
|
StringBuilder strlog = new StringBuilder();
|
|
strlog.AppendLine("创建杂发单");
|
|
strlog.AppendLine("*****************************************************");
|
|
string orgID = "";
|
|
List<UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData> shipList = new List<UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData>();
|
|
foreach (var rCVhead in rCVInfoList)
|
|
{
|
|
strlog.AppendLine("组织编码:" + rCVhead.OrgCode);
|
|
//获取组织ID
|
|
string orgsql = @"select ID from Base_Organization
|
|
where Code='{0}' ";
|
|
orgsql = string.Format(orgsql, rCVhead.OrgCode);
|
|
DataTable orgdt = DBhlper.Query(orgsql, Appconfig.GetU9ConnStr());
|
|
if (orgdt.Rows.Count == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "组织编码不存在";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("组织编码不存在!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
else
|
|
{
|
|
orgID = orgdt.Rows[0]["ID"].ToString();
|
|
}
|
|
//获取单据类型ID
|
|
string docsql = @"select ID from InvDoc_MiscShipDocType
|
|
where Code='{0}' AND Org='{1}'";
|
|
docsql = string.Format(docsql, rCVhead.DocType, orgID);
|
|
DataTable docdt = DBhlper.Query(docsql, Appconfig.GetU9ConnStr());
|
|
long docTypeID = 0;
|
|
if (docdt != null && docdt.Rows.Count > 0)
|
|
{
|
|
docTypeID = long.Parse(docdt.Rows[0]["ID"].ToString());
|
|
}
|
|
if (docTypeID == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "未获取到单据类型ID";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("未获取到单据类型ID!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData ship = new UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData();
|
|
ship.m_docNo = rCVhead.DocNO;
|
|
ship.m_miscShipDocType = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
ship.m_miscShipDocType.m_code = rCVhead.DocType;
|
|
ship.m_miscShipDocType.m_iD = docTypeID;
|
|
ship.m_benefitOrg = long.Parse(orgID);
|
|
ship.m_businessDate = DateTime.Now;
|
|
List<UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData> shipLineList = new List<UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData>();
|
|
foreach (rCVLine line in rCVhead.lines)
|
|
{
|
|
//获取料品ID
|
|
string sqlitem = @"select ID from CBO_ItemMaster
|
|
where Code='" + line.ItemCode + "' AND Org='" + orgID + "'";
|
|
sqlitem = string.Format(sqlitem);
|
|
DataTable dtitem = DBhlper.Query(sqlitem, Appconfig.GetU9ConnStr());
|
|
if (dtitem.Rows.Count > 0)
|
|
{
|
|
ItemID = long.Parse(dtitem.Rows[0]["ID"].ToString());
|
|
}
|
|
else
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "料品不存在!";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("料品不存在!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
//获取仓库ID
|
|
string sqlWH = @"select ID,Code from CBO_Wh
|
|
WHERE Code='" + line.WhCode + "' And Org='" + orgID + "' ";
|
|
sqlWH = string.Format(sqlWH);
|
|
DataTable _dtWH = DBhlper.Query(sqlWH, Appconfig.GetU9ConnStr());
|
|
string WHCode = string.Empty;
|
|
long WHID = 0;
|
|
if (_dtWH != null && _dtWH.Rows.Count > 0)
|
|
{
|
|
WHCode = _dtWH.Rows[0]["Code"].ToString();
|
|
WHID = long.Parse(_dtWH.Rows[0]["ID"].ToString());
|
|
}
|
|
if (string.IsNullOrWhiteSpace(WHCode))
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "未获取到仓库";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("未获取到仓库!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
//获取部门ID
|
|
string deptsql = @"select ID from CBO_Department
|
|
where Code='{0}' AND Org='{1}'";
|
|
deptsql = string.Format(deptsql, line.DeptCode, orgID);
|
|
DataTable deptdt = DBhlper.Query(deptsql, Appconfig.GetU9ConnStr());
|
|
long DeptID = 0;
|
|
if (deptdt != null && deptdt.Rows.Count > 0)
|
|
{
|
|
DeptID = long.Parse(deptdt.Rows[0]["ID"].ToString());
|
|
}
|
|
if (DeptID == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "未获取到部门";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("未获取到部门!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData shipLine = new UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData();
|
|
shipLine.m_benefitDept = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
shipLine.m_benefitDept.m_code = line.DeptCode;
|
|
shipLine.m_benefitDept.m_iD = DeptID;
|
|
shipLine.m_itemInfo = new UFIDAU9CBOSCMItemItemInfoData();
|
|
shipLine.m_itemInfo.m_itemCode = line.ItemCode;
|
|
shipLine.m_itemInfo.ItemID = ItemID;
|
|
shipLine.m_itemInfo.ItemID_SKey = new UFSoft.UBF.Business.BusinessEntity.EntityKey();
|
|
shipLine.m_itemInfo.ItemID_SKey.ID = ItemID;
|
|
shipLine.m_storeType = 4;
|
|
shipLine.m_costUOMQty = line.ReqQty;
|
|
shipLine.m_wh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
shipLine.m_wh.m_iD = WHID;
|
|
shipLine.m_benefitOrg = long.Parse(orgID);
|
|
shipLine.m_customerInfo = new UFIDAU9CBOSCMCustomerCustomerMISCInfoData();
|
|
shipLine.m_customerInfo.m_code = rCVhead.ClientCode;
|
|
shipLine.m_memo = line.Memo;
|
|
#region 批号处理(根据料品,仓库,数量查询符合条件的批号)
|
|
bool ItemIsLot = false;
|
|
bool WHIsLot = false;
|
|
string lotsql = @"select A.ID,ISNULL(LotParam,'') AS LotParam from CBO_ItemMaster A
|
|
LEFT JOIN CBO_InventoryInfo B
|
|
ON B.ItemMaster=A.ID
|
|
where A.ID='{0}' AND A.Org='{1}'";
|
|
lotsql = string.Format(lotsql, ItemID, orgID);
|
|
DataTable lotdt = DBhlper.Query(lotsql, Appconfig.GetU9ConnStr());
|
|
if (lotdt.Rows.Count != 0)
|
|
{
|
|
if (lotdt.Rows[0]["LotParam"].ToString() != "")
|
|
{
|
|
ItemIsLot = true;
|
|
}
|
|
}
|
|
lotsql = @"select Cast(IsLot AS nvarchar(10)) AS IsLot from CBO_WH
|
|
where ID='{0}'";
|
|
lotsql = string.Format(lotsql, WHID);
|
|
lotdt = DBhlper.Query(lotsql, Appconfig.GetU9ConnStr());
|
|
if (lotdt.Rows.Count != 0)
|
|
{
|
|
if (lotdt.Rows[0]["IsLot"].ToString() == "1")
|
|
{
|
|
WHIsLot = true;
|
|
}
|
|
}
|
|
if (ItemIsLot == true && WHIsLot == true)
|
|
{
|
|
lotsql = @"select LotInfo_LotCode,LotInfo_LotMaster_EntityID from InvTrans_WhQoh
|
|
where ItemInfo_ItemID='{0}' AND Wh='{1}'
|
|
AND StoreQty>={2} AND LotInfo_LotCode!='' AND LotInfo_LotCode IS NOT NULL";
|
|
lotsql = string.Format(lotsql, ItemID, WHID, line.ReqQty);
|
|
lotdt = DBhlper.Query(lotsql, Appconfig.GetU9ConnStr());
|
|
if (lotdt.Rows.Count == 0)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "出库物料对应批号没有足够的库存,库存杂发单生成失败!";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("出库物料对应批号没有足够的库存,库存杂发单生成失败!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
else
|
|
{
|
|
bool lotisexsist = false;
|
|
for (int i = 0; i < lotdt.Rows.Count; i++)
|
|
{
|
|
if (lotdt.Rows[i]["LotInfo_LotCode"].ToString() == line.Batch)
|
|
{
|
|
shipLine.m_lotInfo = new UFIDAU9CBOSCMPropertyTypesLotInfoData();
|
|
shipLine.m_lotInfo.m_lotCode = lotdt.Rows[0]["LotInfo_LotCode"].ToString();
|
|
shipLine.m_lotInfo.m_lotMaster = new UFIDAU9BasePropertyTypesBizEntityKeyData();
|
|
shipLine.m_lotInfo.m_lotMaster.m_entityID = long.Parse(lotdt.Rows[0]["LotInfo_LotMaster_EntityID"].ToString());
|
|
lotisexsist = true;
|
|
}
|
|
}
|
|
if (lotisexsist == false)
|
|
{
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = "库存中不存在可以出库的批号,库存杂发单生成失败!";
|
|
rtnpos.Add(rtnpo);
|
|
strlog.AppendLine("返回数据:");
|
|
strlog.AppendLine("库存中不存在可以出库的批号,库存杂发单生成失败!");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
return rtnpos;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
shipLineList.Add(shipLine);
|
|
strlog.AppendLine("料品编码:" + line.ItemCode);
|
|
strlog.AppendLine("料品数量:" + line.ReqQty);
|
|
strlog.AppendLine("仓库:" + WHCode);
|
|
|
|
}
|
|
ship.m_miscShipLs = shipLineList.ToArray();
|
|
shipList.Add(ship);
|
|
}
|
|
pOList = shipList.ToArray();
|
|
|
|
(client.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
|
|
(client.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;
|
|
List<string> shDocList = new List<string>();
|
|
UFIDAU9CBOPubControllerContextDTOData info = new UFIDAU9CBOPubControllerContextDTOData();
|
|
info.m_orgID = long.Parse(orgID);
|
|
info.m_orgCode = rCVInfoList[0].OrgCode;
|
|
info.m_userID = long.Parse(ConfigurationManager.AppSettings["userID"].ToString());
|
|
info.m_userCode = ConfigurationManager.AppSettings["userCode"].ToString();
|
|
info.m_cultureName = ConfigurationManager.AppSettings["cultureName"].ToString();
|
|
info.m_entCode = ConfigurationManager.AppSettings["enterpriseID"].ToString();
|
|
returnItems = client.Do(out returnMsg, context, pOList, info);
|
|
strlog.AppendLine("返回数据:");
|
|
foreach (var item in returnItems)
|
|
{
|
|
strlog.AppendLine("单号:" + item.m_code);
|
|
strlog.AppendLine("返回消息:杂发单生成成功!");
|
|
}
|
|
strlog.AppendLine("*****************************************************");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
if (returnItems.Count() > 0)
|
|
{
|
|
#region 提交杂发单
|
|
//提交杂发单
|
|
CustCommonitMisShip CommitCust = new CustCommonitMisShip();
|
|
CustCommonitMisShip.OperationResult_CommitMisShip commitResult = new CustCommonitMisShip.OperationResult_CommitMisShip();
|
|
commitResult = CommitCust.CustCommitMisShip(returnItems[0].m_code, rCVInfoList[0].OrgCode);
|
|
if (commitResult.IsSuccess == true)
|
|
{
|
|
#region 审核杂发单
|
|
CustApproveMiscShip ApproveCust = new CustApproveMiscShip();
|
|
CustApproveMiscShip.OperationResult_ApproveMisShip approveResult = new CustApproveMiscShip.OperationResult_ApproveMisShip();
|
|
approveResult = ApproveCust.CustApproveMis(returnItems[0].m_code, rCVInfoList[0].OrgCode);
|
|
if (approveResult.IsSuccess == true)
|
|
{
|
|
rtnpos = new List<rtnRcvInfo>();
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = true;
|
|
rtnpo.DocNo = returnItems[0].m_code;
|
|
rtnpo.Message = "杂发单创建成功!";
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
else
|
|
{
|
|
rtnpos = new List<rtnRcvInfo>();
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.DocNo = returnItems[0].m_code;
|
|
rtnpo.Message = "杂收单审核失败,失败原因:" + approveResult.Message;
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
rtnpos = new List<rtnRcvInfo>();
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.DocNo = returnItems[0].m_code;
|
|
rtnpo.Message = "杂发单提交失败,失败原因:" + commitResult.Message;
|
|
rtnpos.Add(rtnpo);
|
|
return rtnpos;
|
|
}
|
|
#endregion
|
|
|
|
rtnRcvInfo rtnpotrue = new rtnRcvInfo();
|
|
rtnpotrue.IsSuccess = true;
|
|
rtnpotrue.DocNo = returnItems[0].m_code;
|
|
rtnpotrue.Message = "杂发单创建成功!";
|
|
rtnpos.Add(rtnpotrue);
|
|
}
|
|
|
|
return rtnpos;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//异常信息捕获
|
|
List<rtnRcvInfo> rtnpos = new List<rtnRcvInfo>();
|
|
rtnRcvInfo rtnpo = new rtnRcvInfo();
|
|
rtnpo.IsSuccess = false;
|
|
rtnpo.Message = GetExceptionMessage(ex).Split('<')[0];
|
|
rtnpos.Add(rtnpo);
|
|
|
|
StringBuilder strlog = new StringBuilder();
|
|
strlog.AppendLine("创建杂发单");
|
|
strlog.AppendLine("*****************************************************");
|
|
strlog.AppendLine("修改创建人SQL:" + updatesql);
|
|
foreach (var item in rCVInfoList)
|
|
{
|
|
strlog.AppendLine("组织编码:" + item.OrgCode);
|
|
foreach (var line in item.lines)
|
|
{
|
|
strlog.AppendLine("料品编码:" + line.ItemCode);
|
|
strlog.AppendLine("料品数量:" + line.ReqQty);
|
|
strlog.AppendLine("仓库:" + line.WhCode);
|
|
strlog.AppendLine("批号:" + line.Batch);
|
|
}
|
|
}
|
|
strlog.AppendLine("返回消息:" + rtnpo.Message);
|
|
strlog.AppendLine("*****************************************************");
|
|
Appconfig.WriteLogFile(strlog.ToString(), "创建杂发单");
|
|
|
|
return rtnpos;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#region 表头类
|
|
public class rCVhead
|
|
{
|
|
private rCVLine[] _lines;
|
|
private string _DocType;
|
|
private string _OrgCode;
|
|
private string _ClientCode;
|
|
private string _DocNO;
|
|
|
|
//private string _DocType;
|
|
|
|
|
|
public rCVLine[] lines
|
|
{
|
|
get { return _lines; }
|
|
set { _lines = value; }
|
|
}
|
|
|
|
public string DocNO
|
|
{
|
|
get { return _DocNO; }
|
|
set { _DocNO = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单据类型
|
|
/// </summary>
|
|
public string DocType
|
|
{
|
|
get { return _DocType; }
|
|
set { _DocType = value; }
|
|
}
|
|
/// <summary>
|
|
/// 组织编码
|
|
/// </summary>
|
|
public string OrgCode
|
|
{
|
|
get { return _OrgCode; }
|
|
set { _OrgCode = value; }
|
|
}
|
|
/// <summary>
|
|
/// 客户
|
|
/// </summary>
|
|
public string ClientCode
|
|
{
|
|
get { return _ClientCode; }
|
|
set { _ClientCode = value; }
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 表体类
|
|
public class rCVLine
|
|
{
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public decimal ReqQty { get; set; }
|
|
|
|
public string WhCode { get; set; }
|
|
|
|
//public string BinCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 料号
|
|
/// </summary>
|
|
public string ItemCode { get; set; }
|
|
/// <summary>
|
|
/// 受益部门
|
|
/// </summary>
|
|
public string DeptCode { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 库存批号
|
|
/// </summary>
|
|
public string Batch { get; set; }
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
public string Memo { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 提取异常信息
|
|
/// <summary>
|
|
/// 提取异常信息
|
|
/// </summary>
|
|
/// <param name="ex"></param>
|
|
private string GetExceptionMessage(Exception ex)
|
|
{
|
|
string faultMessage = "未知错误,请查看ERP日志!";
|
|
|
|
System.TimeoutException timeoutEx = ex as System.TimeoutException;
|
|
if (timeoutEx != null)
|
|
{
|
|
faultMessage = "访问服务超时,请修改配置信息!";
|
|
}
|
|
else
|
|
{
|
|
FaultException<ServiceException> faultEx = ex as FaultException<ServiceException>;
|
|
if (faultEx == null)
|
|
{
|
|
faultMessage = ex.Message;
|
|
}
|
|
else
|
|
{
|
|
ServiceException serviceEx = faultEx.Detail;
|
|
if (serviceEx != null && !string.IsNullOrEmpty(serviceEx.Message)
|
|
&& !serviceEx.Message.Equals("fault", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
// 错误信息在faultEx.Message中,请提取,
|
|
// 格式为"Fault:料品不能为空,请录入\n 在....."
|
|
int startIndex = serviceEx.Message.IndexOf(":");
|
|
int endIndex = serviceEx.Message.IndexOf("\n");
|
|
if (endIndex == -1)
|
|
endIndex = serviceEx.Message.Length;
|
|
if (endIndex > 0 && endIndex > startIndex + 1)
|
|
{
|
|
faultMessage = serviceEx.Message.Substring(startIndex + 1, endIndex - startIndex - 1);
|
|
}
|
|
else
|
|
{
|
|
faultMessage = serviceEx.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return faultMessage;
|
|
}
|
|
#endregion
|
|
|
|
#region 给上下文信息赋值
|
|
/// <summary>
|
|
/// 给上下文信息赋值
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private ThreadContext CreateContextObj()
|
|
{
|
|
// 实例化应用上下文对象
|
|
ThreadContext thContext = new ThreadContext();
|
|
|
|
System.Collections.Generic.Dictionary<object, object> ns = new Dictionary<object, object>();
|
|
ns.Add("OrgID", ConfigurationManager.AppSettings["orgID"].ToString());
|
|
ns.Add("UserID", ConfigurationManager.AppSettings["userID"].ToString());
|
|
ns.Add("UserCode", ConfigurationManager.AppSettings["userCode"].ToString());
|
|
ns.Add("Datetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
ns.Add("CultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
|
|
ns.Add("EnterpriseID", ConfigurationManager.AppSettings["enterpriseID"].ToString());
|
|
ns.Add("DefaultCultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
|
|
thContext.nameValueHas = ns;
|
|
|
|
return thContext;
|
|
}
|
|
#endregion
|
|
|
|
#region 时间戳方法
|
|
private DateTime TimestampToDateTime(long timestamp)
|
|
{
|
|
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
long lTime = timestamp * 10000000;
|
|
TimeSpan nowTimeSpan = new TimeSpan(lTime);
|
|
DateTime resultDateTime = dateTimeStart.Add(nowTimeSpan);
|
|
return resultDateTime;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#region 上下文类信息
|
|
public class contextInfo
|
|
{
|
|
private long _OrgID;
|
|
private string _OrgCode;
|
|
private long _UserID;
|
|
private string _UserCode;
|
|
private DateTime _Datetime;
|
|
private string _CultureName;
|
|
private string _EnterpriseID;
|
|
|
|
|
|
/// <summary>
|
|
/// 组织ID
|
|
/// </summary>
|
|
public long OrgID
|
|
{
|
|
get { return _OrgID; }
|
|
set { _OrgID = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 组织编码
|
|
/// </summary>
|
|
public string OrgCode
|
|
{
|
|
get { return _OrgCode; }
|
|
set { _OrgCode = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 操作员ID
|
|
/// </summary>
|
|
public long UserID
|
|
{
|
|
get { return _UserID; }
|
|
set { _UserID = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 操作员编码
|
|
/// </summary>
|
|
public string UserCode
|
|
{
|
|
get { return _UserCode; }
|
|
set { _UserCode = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间
|
|
/// </summary>
|
|
public DateTime Datetime
|
|
{
|
|
get { return _Datetime; }
|
|
set { _Datetime = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 语言
|
|
/// </summary>
|
|
public string CultureName
|
|
{
|
|
get { return _CultureName; }
|
|
set { _CultureName = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 企业ID号
|
|
/// </summary>
|
|
public string EnterpriseID
|
|
{
|
|
get { return _EnterpriseID; }
|
|
set { _EnterpriseID = value; }
|
|
}
|
|
|
|
public contextInfo()
|
|
{
|
|
CultureName = "zh-CN";
|
|
Datetime = DateTime.Now;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 返回信息类
|
|
public class rtnRcvInfo
|
|
{
|
|
public string DocNo { get; set; }
|
|
public bool IsSuccess { get; set; }
|
|
public string Message { get; set; }
|
|
public rtnRcvLine[] rtnLines { get; set; }
|
|
}
|
|
|
|
public class rtnRcvLine
|
|
{
|
|
public int LineNo { get; set; }
|
|
|
|
//public string srcDocNo { get; set; }
|
|
|
|
//public int srcLineNo { get; set; }
|
|
|
|
//public decimal reqQty { get; set; }
|
|
|
|
//public string proCode { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 表体类
|
|
//public class rCVLine
|
|
//{
|
|
// /// <summary>
|
|
// /// 来源采购订单
|
|
// /// </summary>
|
|
// public string srcDocPONo { get; set; }
|
|
|
|
// private int _srcDocPOLineNo;
|
|
// private decimal _reqQty;
|
|
// public string WhCode { get; set; }
|
|
|
|
// /// <summary>
|
|
// /// 炉号
|
|
// /// </summary>
|
|
// public string FurnaceNo { get; set; }
|
|
|
|
// /// <summary>
|
|
// /// 数量
|
|
// /// </summary>
|
|
// public decimal ReqQty
|
|
// {
|
|
// get { return _reqQty; }
|
|
// set { _reqQty = value; }
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// 来源采购订单行
|
|
// /// </summary>
|
|
// public int srcDocPOLineNo
|
|
// {
|
|
// get { return _srcDocPOLineNo; }
|
|
// set { _srcDocPOLineNo = value; }
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
|
|
}
|