|
|
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.BFIssueApprove; using UFIDA.ISV.BFIssueDelete; using UFSoft.UBF.Exceptions1; using UFSoft.UBF.Service; using UFSoft.UBF.Util.Context; using www.ufida.org.EntityData;
namespace UFIDA.ISV.CreateAboveIssue { public class CustCreateAboveIssue { /// <summary>
/// 创建领料单
/// </summary>
/// <returns></returns>
///
public OperationResult CreateAboveIssue(List<IssueAboveData> modellist) { #region 入口日志
StringBuilder beginstrlog = new StringBuilder(); beginstrlog.AppendLine("日志记录开始"); beginstrlog.AppendLine("*****************************************************"); foreach (IssueAboveData model in modellist) { beginstrlog.AppendLine("领料部门:" + model.DeptNo); beginstrlog.AppendLine("生产订单:" + model.MoCode); beginstrlog.AppendLine("组织编码:" + model.OrgCode); beginstrlog.AppendLine("备注:" + model.Memo); foreach (IssueLineData lineinfo in model.linelist) { bool isLotCheck = Appconfig.WHLotCheckState(lineinfo.WHCode, model.OrgCode); if (isLotCheck == false) { lineinfo.Batch = ""; } beginstrlog.AppendLine("领料料号:" + lineinfo.ItemCode); beginstrlog.AppendLine("领料数量:" + lineinfo.ItemQty); beginstrlog.AppendLine("存储地点:" + lineinfo.WHCode); beginstrlog.AppendLine("领料批号:" + lineinfo.Batch); beginstrlog.AppendLine("领料供应商:" + lineinfo.Vender); } } beginstrlog.AppendLine("*****************************************************"); Appconfig.WriteLogFile(beginstrlog.ToString(), "创建U9领料单"); #endregion
OperationResult result = new OperationResult(); ThreadContext context = CreateContextObj(); string OrgID = ""; try { string _MOCode = string.Empty; UFIDAU9ISVMOICreateIssue4ExternalClient client = new UFIDAU9ISVMOICreateIssue4ExternalClient(); MessageBase[] message = null; List<UFIDAU9ISVMOIssueDTOData> molist = new List<UFIDAU9ISVMOIssueDTOData>(); UFIDAU9ISVMOIssueDTOData mo = new UFIDAU9ISVMOIssueDTOData(); List<UFIDAU9ISVMOPickListDTOData> PL = new List<UFIDAU9ISVMOPickListDTOData>();
foreach (IssueAboveData model in modellist) { mo = new UFIDAU9ISVMOIssueDTOData(); PL = new List<UFIDAU9ISVMOPickListDTOData>(); if (!string.IsNullOrWhiteSpace(model.MoCode)) { string orgsql = @"select ID from Base_Organization
where Code='{0}'";
orgsql = string.Format(orgsql, model.OrgCode); DataTable orgdt = DBhlper.Query(orgsql, Appconfig.GetU9ConnStr()); if (orgdt.Rows.Count != 0) { OrgID = orgdt.Rows[0]["ID"].ToString(); } else { throw new Exception("未获取到组织!"); } //验证该工单的备料表中是否存在数据
int p = Appconfig.IsExistcPickList(model.MoCode);
if (p > 0) { #region 遍历入参LL单行
foreach (var item in model.linelist) { bool IsVMI = false; string strCcode = item.ItemCode; //子料
decimal _useQty = item.ItemQty; //子件使用量
string _strWhID = string.Empty;//仓库ID
string WHID = "";
if (!string.IsNullOrWhiteSpace(strCcode)) { //虚拟库位 ZP1-01 20190912新增过滤虚拟库位
string _SqlDbType = @" select Distinct ID,Code from CBO_WH
where Code='" + item.WHCode + "' AND Org='" + OrgID + "'";
_SqlDbType = string.Format(_SqlDbType); DataTable _SqlDbTypedt = DBhlper.Query(_SqlDbType, Appconfig.GetU9ConnStr()); if (_SqlDbTypedt != null && _SqlDbTypedt.Rows.Count > 0) { WHID = _SqlDbTypedt.Rows[0]["ID"].ToString(); } else { result.MESSAGE = "传入仓库不存在!"; result.IsSuccess = false; return result; } }
UFIDAU9ISVMOPickListDTOData PLS = new UFIDAU9ISVMOPickListDTOData();
int i = Appconfig.IsExistItem(strCcode); if (i < 1) { result.MESSAGE = "料品编码不存在!"; result.IsSuccess = false; return result; }
Decimal MOQty = 0; long MOID = 0; _MOCode = model.MoCode; DataTable _dt = Appconfig.GetMOQtyAndID(model.MoCode); if (_dt != null && _dt.Rows.Count > 0) { foreach (DataRow _item in _dt.Rows) { string _strMOQty = string.Empty; string _strMOID = string.Empty;
_strMOQty = _item["ProductQty"].ToString(); if (!string.IsNullOrWhiteSpace(_strMOQty)) { MOQty = Decimal.Parse(_strMOQty);//生产订单数量
} _strMOID = _item["ID"].ToString(); if (!string.IsNullOrWhiteSpace(_strMOID)) { MOID = long.Parse(_strMOID); } } }
string mOPickList = string.Empty; mOPickList = Appconfig.GetMoPickListID(model.MoCode, strCcode);// 1001903220007058;// iPickid;
Decimal IssuedQty = 0; //已发放数量
Decimal ActualReqQty = 0; //实际需求数量
if (!string.IsNullOrWhiteSpace(mOPickList)) { //已发放数量-领料未发数量
DataTable dtQty = Appconfig.GetQtyBymOPickList(model.MoCode, strCcode); if (dtQty != null && dtQty.Rows.Count > 0) { ActualReqQty = Decimal.Parse(dtQty.Rows[0]["ActualReqQty"].ToString()); } PLS.m_mOPickList = long.Parse(mOPickList); } else { result.MESSAGE = "备料表单ID不存在!工单:'" + model.MoCode + "',料号:'" + strCcode + "' "; result.IsSuccess = false; return result; }
//PLS.m_issueQty = useQty * MOQty - SendQty;// item.issueQty* useQty;//1; //应发数量
if (ActualReqQty < _useQty) { result.MESSAGE += "该料品" + strCcode + "需要领用的数量大于未领数量不能创建改料品的领用;"; } else { //if (useQty * MOQty - SendQty - IssueNotDeliverQty > 0)
//{
//20190920修改ZM
//PLS.m_issuedQty = useQty * MOQty - SendQty - IssueNotDeliverQty;// item.issuedQty* useQty;// 1; //实发数量
PLS.m_issueQty = _useQty; PLS.m_issuedQty = _useQty;// item.issuedQty* useQty;// 1; //实发数量
//仓库
if (!string.IsNullOrWhiteSpace(WHID)) { PLS.m_issueWh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); //PLS.m_issueWh.m_code = strWhCode;// "004";//cWh;
PLS.m_issueWh.m_iD = long.Parse(WHID);// "004";//cWh;
} //发货单位
PLS.m_issueUOM = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); string uom = Appconfig.GetMaterialUOM(strCcode); if (!string.IsNullOrWhiteSpace(uom)) { PLS.m_issueUOM.m_iD = long.Parse(uom);// Appconfig.GetMaterialUOM(item.ItemCode);// 1001607080022602;// iMaterialOutUOM;
} PLS.m_aCDType = 0; PLS.m_storageType = 4;//存储类型
//SourceDoc_SrcDocNo
PLS.SourceIssueDocLine = MOID; #region 获取批号ID
long LotID = 0; if (item.Batch != "") { string lotsql = @"SELECT ID FROM Lot_LotMaster
WHERE LotCode='{0}' AND ItemCode='{1}' AND ItemOwnerOrg='{2}'";
lotsql = string.Format(lotsql, item.Batch, item.ItemCode, OrgID); DataTable lotdt = DBhlper.Query(lotsql, Appconfig.GetU9ConnStr()); if (lotdt.Rows.Count == 0) { result.MESSAGE += "传入批号对应料号无关联,获取批号ID失败!"; result.IsSuccess = false; return result; } else { LotID = long.Parse(lotdt.Rows[0]["ID"].ToString()); } } #endregion
if (LotID != 0) { PLS.m_lot = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); PLS.m_lot.m_code = item.Batch; PLS.m_lot.m_iD = LotID; } if (IsVMI == true) { PLS.m_supplier = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); PLS.m_supplier.m_code = item.Vender; }
PL.Add(PLS); }
}
#endregion
} else { result.MESSAGE += "该工单没有备料表信息 "; result.IsSuccess = false;
return result; } if (PL != null && PL.Count() > 0) { mo.m_issueType = 0; //部门
mo.m_dept = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); mo.m_dept.m_code = model.DeptNo;// "MY0601";
mo.m_docType = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData(); #region 获取生产订单单据类型(作为生产领料单的业务类型)
string IssueDocType = ""; int IssueBusinessType = 0; string doctypesql = @"select B.Code AS DocTypeCode,B.BusinessType from MO_MO A
LEFT JOIN MO_MODocType B ON B.ID=A.MODocType AND B.Org=A.Org";
doctypesql = string.Format(doctypesql, model.MoCode, OrgID); DataTable doctypedt = DBhlper.Query(doctypesql, Appconfig.GetU9ConnStr()); if (doctypedt.Rows.Count != 0) { IssueDocType = doctypedt.Rows[0]["DocTypeCode"].ToString(); IssueBusinessType = int.Parse(doctypedt.Rows[0]["BusinessType"].ToString()); } #endregion
mo.m_docType.m_code = IssueDocType; mo.m_businessType = IssueBusinessType; string BusinessType = Appconfig.GetBusinessType(model.DocTypeCode); mo.m_srcDoc = new UFIDAU9MOPropertyTypesMOSourceDocData();// _MOCode;
mo.m_srcDoc.m_srcDocNo = _MOCode;
mo.m_memo = model.Memo; //备注
mo.m_pickListDTOs = PL.ToArray();
molist.Add(mo); } else { result.MESSAGE += "传入的数据未获取到创建领料的信息 "; result.IsSuccess = false;
return result; } } else { result.MESSAGE += "该工单号不能为空 "; result.IsSuccess = false;
return result; } }
UFIDAU9ISVMOIssueKeyDTOData[] _result = null; _result = client.Do(out message, context, molist.ToArray()); List<string> LLCodeList = new List<string>(); if (_result != null && _result.Count() > 0) { foreach (var item in _result) { if (!string.IsNullOrWhiteSpace(item.m_docNo)) { LLCodeList.Add(item.m_docNo); } } } #region 审核生产领料单
CustApproveIssue approveIssue = new CustApproveIssue(); CustApproveIssue.OperationResult approveresult = new CustApproveIssue.OperationResult(); approveresult = approveIssue.CustBFApproveIssue(LLCodeList, modellist[0].OrgCode); #endregion
if (approveresult.IsSuccess == true) { foreach (string docno in LLCodeList) { result.LLCode += docno + ";"; } result.IsSuccess = true; result.MESSAGE = "成功创建领料单!"; } else { #region 审核失败日志
StringBuilder strlog = new StringBuilder(); strlog.AppendLine("审核失败日志记录开始"); strlog.AppendLine("*****************************************************"); foreach (string code in LLCodeList) { strlog.AppendLine("领料单号:" + code); } strlog.AppendLine("失败原因:" + approveresult.MESSAGE); strlog.AppendLine("*****************************************************"); Appconfig.WriteLogFile(strlog.ToString(), "创建U9领料单"); #endregion
#region 审核失败时删除所有生成的领料单
CustBFIssueDelete issueDelete = new CustBFIssueDelete(); issueDelete.CustDeleteIssue(LLCodeList, OrgID); #endregion
result.IsSuccess = false; result.MESSAGE = "领料单审核失败,生成的领料单已经删除,失败原因:" + approveresult.MESSAGE; } } catch (Exception ex) { #region 错误日志
StringBuilder strlog = new StringBuilder(); strlog.AppendLine("错误日志记录开始"); strlog.AppendLine("*****************************************************"); foreach (IssueAboveData model in modellist) { strlog.AppendLine("领料部门:" + model.DeptNo); strlog.AppendLine("生产订单:" + model.MoCode); strlog.AppendLine("组织编码:" + model.OrgCode); strlog.AppendLine("备注:" + model.Memo); foreach (IssueLineData lineinfo in model.linelist) { strlog.AppendLine("领料料号:" + lineinfo.ItemCode); strlog.AppendLine("领料数量:" + lineinfo.ItemQty); strlog.AppendLine("存储地点:" + lineinfo.WHCode); } } strlog.AppendLine("失败原因:" + GetExceptionMessage(ex)); strlog.AppendLine("*****************************************************"); Appconfig.WriteLogFile(strlog.ToString(), "创建U9领料单"); #endregion
string Message = GetExceptionMessage(ex); result.IsSuccess = false; result.MESSAGE += Message; } //"必需设置请指定IssueDTO.BusinessType属性,生产线日计划:51,标准生产:47,返工生产:48,报废生产:49"
return result; }
# region 辅助方法
/// <summary>
/// 创建上下文
/// </summary>
/// <returns></returns>
private static 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 提取异常信息
/// <summary>
/// 提取异常信息
/// </summary>
/// <param name="ex"></param>
private static 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
public class OperationResult { /// <summary>
/// 结果状态,默认值false
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
///处理消息
/// </summary>
public string MESSAGE { get; set; }
/// <summary>
/// 输出领料订单
/// </summary>
public string LLCode { get; set; } }
#region 20190705
//public OperationResult CreateIssue_20190701bak(IssueData model)
//{
// OperationResult result = new OperationResult();
// ThreadContext context = CreateContextObj();
// //MO-19050007 11020007
// try
// {
// string _MOCode = string.Empty;
// UFIDAU9ISVMOICreateIssue4ExternalClient client = new UFIDAU9ISVMOICreateIssue4ExternalClient();
// MessageBase[] message = null;
// List<UFIDAU9ISVMOIssueDTOData> molist = new List<UFIDAU9ISVMOIssueDTOData>();
// UFIDAU9ISVMOIssueDTOData mo = new UFIDAU9ISVMOIssueDTOData();
// List<UFIDAU9ISVMOPickListDTOData> PL = new List<UFIDAU9ISVMOPickListDTOData>();
// if (model != null && model.lines.Count > 0)
// {
// foreach (var item in model.lines)
// {
// if (!string.IsNullOrWhiteSpace(item.ItemCode))
// {
// DataTable dt = Appconfig.GetCcodeListByMcode(item.ItemCode);
// if (dt != null && dt.Rows.Count > 0)
// {
// foreach (DataRow row in dt.Rows)
// {
// string strCcode = row["ccode"].ToString(); //子料
// decimal useQty = Decimal.Parse(row["useQty"].ToString()); //子件使用量
// string strUnitCode = row["UnitCode"].ToString(); //单位
// //string strWhCode = row["WhCode"].ToString(); //仓库
// //string strBinCode = row["BinCode"].ToString(); //库位
// string strWhCode = item.WhCode; //row["WhCode"].ToString(); //仓库
// string strBinCode = item.BinCode;//row["BinCode"].ToString(); //库位
// UFIDAU9ISVMOPickListDTOData PLS = new UFIDAU9ISVMOPickListDTOData();
// int i = Appconfig.IsExistItem(strCcode);
// if (i < 1)
// {
// result.MESSAGE = "料品编码不存在!";
// result.IsSuccess = false;
// return result;
// }
// #region 注释
// //if (!string.IsNullOrWhiteSpace(item.BinCode))
// //{
// // int j = Appconfig.IsExistcPos(item.BinCode);
// // if (i < 1)
// // {
// // result.MESSAGE = "库位编码不存在!";
// // result.IsSuccess = false;
// // return result;
// // }
// // else
// // {
// // PLS.m_issueBin = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// // PLS.m_issueBin.m_code = item.BinCode;
// // }
// //}
// //string WhCode = string.Empty;
// //if (!string.IsNullOrWhiteSpace(item.BinCode))
// //{
// // WhCode = Appconfig.GetWhCodeByBin(item.BinCode);
// //}
// #endregion
// Decimal MOQty = 0;
// long MOID = 0;
// _MOCode = item.MoCode;
// DataTable _dt = Appconfig.GetMOQtyAndID(item.MoCode);
// if (_dt != null && _dt.Rows.Count > 0)
// {
// foreach (DataRow _item in _dt.Rows)
// {
// string _strMOQty = string.Empty;
// string _strMOID = string.Empty;
// _strMOQty = _item["ProductQty"].ToString();
// if (!string.IsNullOrWhiteSpace(_strMOQty))
// {
// MOQty = Decimal.Parse(_strMOQty);
// }
// _strMOID = _item["ID"].ToString();
// if (!string.IsNullOrWhiteSpace(_strMOID))
// {
// MOID = long.Parse(_strMOID);
// }
// }
// }
// string mOPickList = string.Empty;
// mOPickList = Appconfig.GetMoPickListID(item.MoCode, strCcode);// 1001903220007058;// iPickid;
// Decimal IssuedQty = 0; //已发放数量
// Decimal IssueNotDeliverQty = 0; //领料未发数量
// Decimal SendQty = 0; //已发放数量
// if (!string.IsNullOrWhiteSpace(mOPickList))
// {
// //已发放数量-领料未发数量
// DataTable dtQty = Appconfig.GetQtyBymOPickList(item.MoCode);
// if (dtQty != null && dtQty.Rows.Count > 0)
// {
// //IssuedQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// IssueNotDeliverQty = Decimal.Parse(dtQty.Rows[0]["TotalIssueNotDeliverQty"].ToString());
// SendQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// }
// PLS.m_mOPickList = long.Parse(mOPickList);
// }
// else
// {
// result.MESSAGE = "备料表单ID不存在!工单:'" + item.MoCode + "',料号:'" + strCcode + "' ";
// result.IsSuccess = false;
// return result;
// }
// //根据工单获取已发掉的料数量
// //Decimal SendQty = Appconfig.GetMOSendQty(item.MoCode);
// //PLS.m_issueQty = useQty * MOQty - SendQty;// item.issueQty* useQty;//1; //应发数量
// PLS.m_issueQty = useQty * MOQty;// item.issueQty* useQty;//1; //应发数量
// //产生领料单的数量为:实际需求数量-已发放数量-领料未发数量
// //PLS.m_issuedQty = useQty * MOQty - SendQty;// item.issuedQty* useQty;// 1; //实发数量
// if (useQty * MOQty - SendQty - IssueNotDeliverQty > 0)
// {
// PLS.m_issuedQty = useQty * MOQty - SendQty - IssueNotDeliverQty;// item.issuedQty* useQty;// 1; //实发数量
// if (!string.IsNullOrWhiteSpace(strBinCode))
// {
// PLS.m_issueBin = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// PLS.m_issueBin.m_code = strBinCode;
// }
// //仓库
// if (!string.IsNullOrWhiteSpace(strWhCode))
// {
// PLS.m_issueWh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// PLS.m_issueWh.m_code = strWhCode;// "004";//cWh;
// }
// //发货单位
// PLS.m_issueUOM = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// string uom = Appconfig.GetMaterialUOM(strCcode);
// if (!string.IsNullOrWhiteSpace(uom))
// {
// PLS.m_issueUOM.m_iD = long.Parse(uom);// Appconfig.GetMaterialUOM(item.ItemCode);// 1001607080022602;// iMaterialOutUOM;
// }
// PLS.m_aCDType = 0;
// //Decimal MOQty = Decimal.Parse(Appconfig.GetMOQty(item.MoCode));
// PLS.m_storageType = 4;//存储类型
// //SourceDoc_SrcDocNo
// PLS.SourceIssueDocLine = MOID;
// PL.Add(PLS);
// }
// else
// {
// result.MESSAGE = "该工单料品数量已经领料完成,不能继续领料" + item.MoCode + "',料号:'" + strCcode + "' ";
// result.IsSuccess = false;
// return result;
// }
// }
// }
// }
// }
// }
// //部门
// mo.m_dept = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// mo.m_dept.m_code = model.DeptNo;// "MY0601";
// mo.m_docType = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// mo.m_docType.m_code = model.DocTypeCode;//"1"; 单据类型
// //mo.m_businessType = model.BusinessType;// 47;//标准生产
// string BusinessType = Appconfig.GetBusinessType(model.DocTypeCode);
// if (!string.IsNullOrWhiteSpace(BusinessType))
// {
// mo.m_businessType = Int32.Parse(BusinessType);// 47;//标准生产
// }
// mo.m_srcDoc = new UFIDAU9MOPropertyTypesMOSourceDocData();// _MOCode;
// mo.m_srcDoc.m_srcDocNo = _MOCode;
// mo.m_memo = model.Memo; //备注
// mo.m_pickListDTOs = PL.ToArray();
// molist.Add(mo);
// UFIDAU9ISVMOIssueKeyDTOData[] _result = null;
// _result = client.Do(out message, context, molist.ToArray());
// if (_result != null && _result.Count() > 0)
// {
// foreach (var item in _result)
// {
// result.LLCode = item.m_docNo;
// if (!string.IsNullOrWhiteSpace(item.m_docNo))
// {
// result.IsSuccess = true;
// result.MESSAGE = "成功创建领料单!";
// }
// }
// }
// #region 错误
// // //class UFIDA.U9.MO.MO.MO has no such field: Code in AttributeMap when Compiling OQL: Code=@Code and Org=@Org
// // //领料单1001906120110350不存在单行信息
// // //未将对象引用设置到对象的实例。
// // //领料单1001906140000062不存在单行信息
// // //领料单1001906140000083不存在单行信息
// // //领料单1001906140000105不存在单行信息
// // //领料单1001906140000106不存在单行信息
// // //必需设置单据类型
// // //领料单1001906170000093不存在单行信息
// // //领料单1001906170000104不存在单行信息
// #endregion
// }
// catch (Exception ex)
// {
// string Message = GetExceptionMessage(ex);
// result.IsSuccess = false;
// result.MESSAGE = Message;
// }
// return result;
//}
//public OperationResult CreateIssue(IssueData model)
//{
// OperationResult result = new OperationResult();
// ThreadContext context = CreateContextObj();
// //MO-19050007 11020007
// try
// {
// string _MOCode = string.Empty;
// UFIDAU9ISVMOICreateIssue4ExternalClient client = new UFIDAU9ISVMOICreateIssue4ExternalClient();
// MessageBase[] message = null;
// List<UFIDAU9ISVMOIssueDTOData> molist = new List<UFIDAU9ISVMOIssueDTOData>();
// UFIDAU9ISVMOIssueDTOData mo = new UFIDAU9ISVMOIssueDTOData();
// List<UFIDAU9ISVMOPickListDTOData> PL = new List<UFIDAU9ISVMOPickListDTOData>();
// if (model != null && model.lines.Count > 0)
// {
// foreach (var item in model.lines)
// {
// //if (!string.IsNullOrWhiteSpace(item.ItemCode))
// //{
// //验证该工单的备料表中是否存在数据
// int p = Appconfig.IsExistcPickList(item.MoCode);
// if (p > 0)
// {
// #region 根据备料表获取数据
// DataTable dt = Appconfig.GetPickList(item.MoCode);
// if (dt != null && dt.Rows.Count > 0)
// {
// foreach (DataRow row in dt.Rows)
// {
// string strCcode = row["ccode"].ToString(); //子料
// decimal useQty = Decimal.Parse(row["useQty"].ToString()); //子件使用量
// string strUnitCode = row["UnitCode"].ToString(); //单位
// //string strWhCode = row["WhCode"].ToString(); //仓库
// //string strBinCode = row["BinCode"].ToString(); //库位
// string strWhCode = item.WhCode; //row["WhCode"].ToString(); //仓库
// string strBinCode = item.BinCode;//row["BinCode"].ToString(); //库位
// UFIDAU9ISVMOPickListDTOData PLS = new UFIDAU9ISVMOPickListDTOData();
// int i = Appconfig.IsExistItem(strCcode);
// if (i < 1)
// {
// result.MESSAGE = "料品编码不存在!";
// result.IsSuccess = false;
// return result;
// }
// Decimal MOQty = 0;
// long MOID = 0;
// _MOCode = item.MoCode;
// DataTable _dt = Appconfig.GetMOQtyAndID(item.MoCode);
// if (_dt != null && _dt.Rows.Count > 0)
// {
// foreach (DataRow _item in _dt.Rows)
// {
// string _strMOQty = string.Empty;
// string _strMOID = string.Empty;
// _strMOQty = _item["ProductQty"].ToString();
// if (!string.IsNullOrWhiteSpace(_strMOQty))
// {
// MOQty = Decimal.Parse(_strMOQty);//生产订单数量
// }
// _strMOID = _item["ID"].ToString();
// if (!string.IsNullOrWhiteSpace(_strMOID))
// {
// MOID = long.Parse(_strMOID);
// }
// }
// }
// string mOPickList = string.Empty;
// mOPickList = Appconfig.GetMoPickListID(item.MoCode, strCcode);// 1001903220007058;// iPickid;
// Decimal IssuedQty = 0; //已发放数量
// Decimal IssueNotDeliverQty = 0; //领料未发数量
// Decimal SendQty = 0; //已发放数量
// if (!string.IsNullOrWhiteSpace(mOPickList))
// {
// //已发放数量-领料未发数量
// DataTable dtQty = Appconfig.GetQtyBymOPickList(item.MoCode);
// if (dtQty != null && dtQty.Rows.Count > 0)
// {
// //IssuedQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// IssueNotDeliverQty = Decimal.Parse(dtQty.Rows[0]["TotalIssueNotDeliverQty"].ToString());
// SendQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// }
// PLS.m_mOPickList = long.Parse(mOPickList);
// }
// else
// {
// result.MESSAGE = "备料表单ID不存在!工单:'" + item.MoCode + "',料号:'" + strCcode + "' ";
// result.IsSuccess = false;
// return result;
// }
// //根据工单获取已发掉的料数量
// //Decimal SendQty = Appconfig.GetMOSendQty(item.MoCode);
// //PLS.m_issueQty = useQty * MOQty - SendQty;// item.issueQty* useQty;//1; //应发数量
// PLS.m_issueQty = useQty * MOQty;// item.issueQty* useQty;//1; //应发数量
// //产生领料单的数量为:实际需求数量-已发放数量-领料未发数量
// //PLS.m_issuedQty = useQty * MOQty - SendQty;// item.issuedQty* useQty;// 1; //实发数量
// if (useQty * MOQty - SendQty - IssueNotDeliverQty > 0)
// {
// PLS.m_issuedQty = useQty * MOQty - SendQty - IssueNotDeliverQty;// item.issuedQty* useQty;// 1; //实发数量
// if (!string.IsNullOrWhiteSpace(strBinCode))
// {
// PLS.m_issueBin = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// PLS.m_issueBin.m_code = strBinCode;
// }
// //仓库
// if (!string.IsNullOrWhiteSpace(strWhCode))
// {
// PLS.m_issueWh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// PLS.m_issueWh.m_code = strWhCode;// "004";//cWh;
// }
// //发货单位
// PLS.m_issueUOM = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// string uom = Appconfig.GetMaterialUOM(strCcode);
// if (!string.IsNullOrWhiteSpace(uom))
// {
// PLS.m_issueUOM.m_iD = long.Parse(uom);// Appconfig.GetMaterialUOM(item.ItemCode);// 1001607080022602;// iMaterialOutUOM;
// }
// PLS.m_aCDType = 0;
// //Decimal MOQty = Decimal.Parse(Appconfig.GetMOQty(item.MoCode));
// PLS.m_storageType = 4;//存储类型
// //SourceDoc_SrcDocNo
// PLS.SourceIssueDocLine = MOID;
// PL.Add(PLS);
// }
// else
// {
// result.MESSAGE = "该工单料品数量已经领料完成,不能继续领料" + item.MoCode + "',料号:'" + strCcode + "' ";
// result.IsSuccess = false;
// return result;
// }
// }
// }
// #endregion
// }
// else
// {
// result.MESSAGE = "该工单没有备料表信息 ";
// result.IsSuccess = false;
// return result;
// }
// #region 20190705注释ZM
// //else
// //{
// // #region 根据BOM展开获取数据
// // DataTable dt = Appconfig.GetCcodeListByMcode(item.ItemCode);
// // if (dt != null && dt.Rows.Count > 0)
// // {
// // foreach (DataRow row in dt.Rows)
// // {
// // string strCcode = row["ccode"].ToString(); //子料
// // decimal useQty = Decimal.Parse(row["useQty"].ToString()); //子件使用量
// // string strUnitCode = row["UnitCode"].ToString(); //单位
// // //string strWhCode = row["WhCode"].ToString(); //仓库
// // //string strBinCode = row["BinCode"].ToString(); //库位
// // string strWhCode = item.WhCode; //row["WhCode"].ToString(); //仓库
// // string strBinCode = item.BinCode;//row["BinCode"].ToString(); //库位
// // UFIDAU9ISVMOPickListDTOData PLS = new UFIDAU9ISVMOPickListDTOData();
// // int i = Appconfig.IsExistItem(strCcode);
// // if (i < 1)
// // {
// // result.MESSAGE = "料品编码不存在!";
// // result.IsSuccess = false;
// // return result;
// // }
// // #region 注释
// // //if (!string.IsNullOrWhiteSpace(item.BinCode))
// // //{
// // // int j = Appconfig.IsExistcPos(item.BinCode);
// // // if (i < 1)
// // // {
// // // result.MESSAGE = "库位编码不存在!";
// // // result.IsSuccess = false;
// // // return result;
// // // }
// // // else
// // // {
// // // PLS.m_issueBin = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// // // PLS.m_issueBin.m_code = item.BinCode;
// // // }
// // //}
// // //string WhCode = string.Empty;
// // //if (!string.IsNullOrWhiteSpace(item.BinCode))
// // //{
// // // WhCode = Appconfig.GetWhCodeByBin(item.BinCode);
// // //}
// // #endregion
// // Decimal MOQty = 0;
// // long MOID = 0;
// // _MOCode = item.MoCode;
// // DataTable _dt = Appconfig.GetMOQtyAndID(item.MoCode);
// // if (_dt != null && _dt.Rows.Count > 0)
// // {
// // foreach (DataRow _item in _dt.Rows)
// // {
// // string _strMOQty = string.Empty;
// // string _strMOID = string.Empty;
// // _strMOQty = _item["ProductQty"].ToString();
// // if (!string.IsNullOrWhiteSpace(_strMOQty))
// // {
// // MOQty = Decimal.Parse(_strMOQty);
// // }
// // _strMOID = _item["ID"].ToString();
// // if (!string.IsNullOrWhiteSpace(_strMOID))
// // {
// // MOID = long.Parse(_strMOID);
// // }
// // }
// // }
// // string mOPickList = string.Empty;
// // mOPickList = Appconfig.GetMoPickListID(item.MoCode, strCcode);// 1001903220007058;// iPickid;
// // Decimal IssuedQty = 0; //已发放数量
// // Decimal IssueNotDeliverQty = 0; //领料未发数量
// // Decimal SendQty = 0; //已发放数量
// // if (!string.IsNullOrWhiteSpace(mOPickList))
// // {
// // //已发放数量-领料未发数量
// // DataTable dtQty = Appconfig.GetQtyBymOPickList(item.MoCode);
// // if (dtQty != null && dtQty.Rows.Count > 0)
// // {
// // //IssuedQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// // IssueNotDeliverQty = Decimal.Parse(dtQty.Rows[0]["TotalIssueNotDeliverQty"].ToString());
// // SendQty = Decimal.Parse(dtQty.Rows[0]["IssuedQty"].ToString());
// // }
// // PLS.m_mOPickList = long.Parse(mOPickList);
// // }
// // else
// // {
// // result.MESSAGE = "备料表单ID不存在!工单:'" + item.MoCode + "',料号:'" + strCcode + "' ";
// // result.IsSuccess = false;
// // return result;
// // }
// // //根据工单获取已发掉的料数量
// // //Decimal SendQty = Appconfig.GetMOSendQty(item.MoCode);
// // //PLS.m_issueQty = useQty * MOQty - SendQty;// item.issueQty* useQty;//1; //应发数量
// // PLS.m_issueQty = useQty * MOQty;// item.issueQty* useQty;//1; //应发数量
// // //产生领料单的数量为:实际需求数量-已发放数量-领料未发数量
// // //PLS.m_issuedQty = useQty * MOQty - SendQty;// item.issuedQty* useQty;// 1; //实发数量
// // if (useQty * MOQty - SendQty - IssueNotDeliverQty > 0)
// // {
// // PLS.m_issuedQty = useQty * MOQty - SendQty - IssueNotDeliverQty;// item.issuedQty* useQty;// 1; //实发数量
// // if (!string.IsNullOrWhiteSpace(strBinCode))
// // {
// // PLS.m_issueBin = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// // PLS.m_issueBin.m_code = strBinCode;
// // }
// // //仓库
// // if (!string.IsNullOrWhiteSpace(strWhCode))
// // {
// // PLS.m_issueWh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// // PLS.m_issueWh.m_code = strWhCode;// "004";//cWh;
// // }
// // //发货单位
// // PLS.m_issueUOM = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// // string uom = Appconfig.GetMaterialUOM(strCcode);
// // if (!string.IsNullOrWhiteSpace(uom))
// // {
// // PLS.m_issueUOM.m_iD = long.Parse(uom);// Appconfig.GetMaterialUOM(item.ItemCode);// 1001607080022602;// iMaterialOutUOM;
// // }
// // PLS.m_aCDType = 0;
// // //Decimal MOQty = Decimal.Parse(Appconfig.GetMOQty(item.MoCode));
// // PLS.m_storageType = 4;//存储类型
// // //SourceDoc_SrcDocNo
// // PLS.SourceIssueDocLine = MOID;
// // PL.Add(PLS);
// // }
// // else
// // {
// // result.MESSAGE = "该工单料品数量已经领料完成,不能继续领料" + item.MoCode + "',料号:'" + strCcode + "' ";
// // result.IsSuccess = false;
// // return result;
// // }
// // }
// // }
// // #endregion
// //}
// #endregion
// //}
// }
// }
// //部门
// mo.m_dept = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// mo.m_dept.m_code = model.DeptNo;// "MY0601";
// mo.m_docType = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
// mo.m_docType.m_code = model.DocTypeCode;//"1"; 单据类型
// //mo.m_businessType = model.BusinessType;// 47;//标准生产
// string BusinessType = Appconfig.GetBusinessType(model.DocTypeCode);
// if (!string.IsNullOrWhiteSpace(BusinessType))
// {
// mo.m_businessType = Int32.Parse(BusinessType);// 47;//标准生产
// }
// mo.m_srcDoc = new UFIDAU9MOPropertyTypesMOSourceDocData();// _MOCode;
// mo.m_srcDoc.m_srcDocNo = _MOCode;
// mo.m_memo = model.Memo; //备注
// mo.m_pickListDTOs = PL.ToArray();
// molist.Add(mo);
// UFIDAU9ISVMOIssueKeyDTOData[] _result = null;
// _result = client.Do(out message, context, molist.ToArray());
// if (_result != null && _result.Count() > 0)
// {
// foreach (var item in _result)
// {
// result.LLCode = item.m_docNo;
// if (!string.IsNullOrWhiteSpace(item.m_docNo))
// {
// result.IsSuccess = true;
// result.MESSAGE = "成功创建领料单!";
// }
// }
// }
// #region 错误
// // //class UFIDA.U9.MO.MO.MO has no such field: Code in AttributeMap when Compiling OQL: Code=@Code and Org=@Org
// // //领料单1001906120110350不存在单行信息
// // //未将对象引用设置到对象的实例。
// // //领料单1001906140000062不存在单行信息
// // //领料单1001906140000083不存在单行信息
// // //领料单1001906140000105不存在单行信息
// // //领料单1001906140000106不存在单行信息
// // //必需设置单据类型
// // //领料单1001906170000093不存在单行信息
// // //领料单1001906170000104不存在单行信息
// #endregion
// }
// catch (Exception ex)
// {
// string Message = GetExceptionMessage(ex);
// result.IsSuccess = false;
// result.MESSAGE = Message;
// }
// return result;
//}
#endregion
}
}
|