/// <summary> /// 1、“制损退料单”、“返工制损退料单”退料确认后参照生产退料单信息同步创建并审核杂发单、杂收单 /// 2、控制同一需求分类号下,领料单领料数量不超过供应数量(按严格匹配的料号)(领料控制逻辑看存储过程) /// </summary> /// <param name="args"></param> public void Notify(params object[] args) { if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) { return; } //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey; //key的有效性判断 if (key == null) { return; } //转成所需实体,同时判断有效性 UFIDA.U9.MO.Issue.IssueDoc issueDoc = (UFIDA.U9.MO.Issue.IssueDoc)key.GetEntity(); if (issueDoc == null) { return; } else { if (issueDoc.Org.Code == "300") { try { #region“制损退料单”、“返工制损退料单”退料确认后参照生产退料单信息同步创建并审核杂发单、杂收单 if (issueDoc.IssueDocType.Name.Trim() == "制损退料单" || issueDoc.IssueDocType.Name.Trim() == "返工制损退料单") { //单据从关闭状态到已核准状态,说明是取消退料操作 if (issueDoc.DocState == IssueTXNStateEnum.Approved && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Closed) { //存储过程控制取消退料操作是否开启 DataParamList dpL = new DataParamList(); dpL.Add(DataParamFactory.Create("Type", "BtnRecedeReverse", ParameterDirection.Input, DbType.String, 50));//禁用取消退料功能 dpL.Add(DataParamFactory.CreateOutput("IsOpen", DbType.String)); DataAccessor.RunSP("sp_Auctus_BEPlugin_Control", dpL); string isOpen = dpL["IsOpen"].Value.ToString(); if (isOpen == "1")//打开控制 { UFIDA.U9.InvDoc.MiscShip.MiscShipmentL miscShipLine = UFIDA.U9.InvDoc.MiscShip.MiscShipmentL.Finder.Find("DescFlexSegments.PrivateDescSeg29='" + issueDoc.DocNo + "'"); bool flag = false; string delDocs = ""; if (miscShipLine != null) { flag = true; delDocs += miscShipLine.MiscShip.DocNo; } UFIDA.U9.InvDoc.MiscRcv.MiscRcvTransL rcvTransLine = UFIDA.U9.InvDoc.MiscRcv.MiscRcvTransL.Finder.Find("DescFlexSegments.PrivateDescSeg29='" + issueDoc.DocNo + "'"); if (rcvTransLine != null) { flag = true; delDocs += rcvTransLine.MiscRcvTrans.DocNo; } if (flag) { throw new Exception("此单已生成杂收、杂发单,不能取消。如果需要取消需删除杂发、杂收单:" + delDocs); } } } //单据从已核准状态到关闭状态,说明是退料确认操作 if (issueDoc.DocState == IssueTXNStateEnum.Closed && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Approved) { //创建杂发单 #region 创建杂发杂收单 UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCreateMiscShipProxy shipSv = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCreateMiscShipProxy(); shipSv.MiscShipmentDTOList = new List <UFIDA.U9.ISV.MiscShipISV.IC_MiscShipmentDTOData>();//杂发SV参数 #region 杂发单数据 IC_MiscShipmentDTOData shipheadDto = new IC_MiscShipmentDTOData(); shipheadDto.BenefitOrg = Context.LoginOrg.ID; shipheadDto.BusinessDate = DateTime.Now; shipheadDto.MiscShipDocType = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); UFIDA.U9.InvDoc.MiscShip.MiscShipDocType shipDocType = UFIDA.U9.InvDoc.MiscShip.MiscShipDocType.Finder.Find("Code='MS30129' and Org=" + Context.LoginOrg.ID.ToString());//杂发单类型 shipheadDto.MiscShipDocType.ID = shipDocType.ID; shipheadDto.MiscShipDocType.Code = shipDocType.Code; shipheadDto.MiscShipDocType.Name = shipDocType.Name; shipheadDto.Org = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); shipheadDto.Org.ID = Context.LoginOrg.ID; shipheadDto.Org.Code = Context.LoginOrg.Code; shipheadDto.Org.Name = Context.LoginOrg.Name; shipheadDto.SOBAccountPeriod = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); UFIDA.U9.Base.SOB.SOBAccountingPeriod sobPeriod = UFIDA.U9.Base.SOB.SOBAccountingPeriod.GetSOBAccountingPeriod(UFIDA.U9.Base.SOB.SetofBooks.Finder.Find("org='" + Context.LoginOrg.ID.ToString() + "'"), DateTime.Now); shipheadDto.SOBAccountPeriod.ID = sobPeriod.ID; shipheadDto.SOBAccountPeriod.Code = sobPeriod.Code; shipheadDto.SOBAccountPeriod.Name = sobPeriod.DisplayName; #region 杂发行数据 UFIDA.U9.MO.Issue.IssueDocLine.EntityList lines = issueDoc.IssueDocLines;//退料行数据 shipheadDto.MiscShipLs = new List <IC_MiscShipmentLDTOData>(); for (int i = 0; i < lines.Count; i++) { UFIDA.U9.MO.Issue.IssueDocLine line = lines[i]; IC_MiscShipmentLDTOData shipLineDto = new IC_MiscShipmentLDTOData(); //扩展字段中记录杂发单的来源退料单号、行号 shipLineDto.DescFlexSegments = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegmentsData(); shipLineDto.DescFlexSegments.PrivateDescSeg2 = line.MO.DocNo; shipLineDto.DescFlexSegments.PrivateDescSeg29 = issueDoc.DocNo; shipLineDto.DescFlexSegments.PrivateDescSeg30 = line.LineNum.ToString(); shipLineDto.ItemInfo = new UFIDA.U9.CBO.SCM.Item.ItemInfoData(); shipLineDto.ItemInfo.ItemID = line.Item.ID; shipLineDto.ItemInfo.ItemCode = line.Item.Code; shipLineDto.ItemInfo.ItemName = line.Item.Name; shipLineDto.StoreUOMQty = line.IssuedQty; //库存数量 shipLineDto.CostUOMQty = line.IssuedQty; //成本数量 shipLineDto.StoreUOM = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); //库存单位 shipLineDto.StoreUOM.ID = line.StoreBaseUOM.ID; shipLineDto.StoreUOM.Code = line.StoreBaseUOM.Code; shipLineDto.StoreUOM.Name = line.StoreBaseUOM.Name; shipLineDto.Wh = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//存储地点 shipLineDto.Wh.ID = line.Wh.ID; shipLineDto.Wh.Code = line.Wh.Code; shipLineDto.Wh.Name = line.Wh.Name; shipLineDto.StoreType = line.StorageType.Value;//存储类型 if (issueDoc.HandleDept != null) { shipLineDto.BenefitDept = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//受益部门 shipLineDto.BenefitDept.ID = issueDoc.HandleDept.ID; shipLineDto.BenefitDept.Code = issueDoc.HandleDept.Code; shipLineDto.BenefitDept.Name = issueDoc.HandleDept.Name; } shipLineDto.BenefitPsn = new CommonArchiveDataDTOData(); if (issueDoc.HandlePerson != null) { shipLineDto.BenefitPsn.ID = issueDoc.HandlePerson.ID; shipLineDto.BenefitPsn.Code = issueDoc.HandlePerson.Code; shipLineDto.BenefitPsn.Name = issueDoc.HandlePerson.Name; } if (!string.IsNullOrEmpty(lines[i].LotNo)) { shipLineDto.LotInfo = new UFIDA.U9.CBO.SCM.PropertyTypes.LotInfoData(); shipLineDto.LotInfo.LotCode = lines[i].LotNo; //shipLineDto.LotInfo.LotMaster = new UFIDA.U9.Base.PropertyTypes.BizEntityKeyData(); //shipLineDto.LotInfo.LotMaster=lines[i].LotMaster } shipLineDto.OwnerOrg = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData();//货主组织 shipLineDto.OwnerOrg.ID = Context.LoginOrg.ID; shipLineDto.OwnerOrg.Code = Context.LoginOrg.Code; shipLineDto.OwnerOrg.Name = Context.LoginOrg.Name; shipheadDto.MiscShipLs.Add(shipLineDto); } #endregion #endregion shipSv.MiscShipmentDTOList.Add(shipheadDto); shipSv.TargetOrgCode = Context.LoginOrg.Code; shipSv.TargetOrgName = Context.LoginOrg.Name; List <CommonArchiveDataDTOData> liShipReturn = new List <CommonArchiveDataDTOData>(); liShipReturn = shipSv.Do(); #endregion //提交杂发单 #region CommonCommitMiscShipSV UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCommitMiscShipSVProxy shipCommitSV = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonCommitMiscShipSVProxy(); shipCommitSV.MiscShipmentKeyList = new List <CommonArchiveDataDTOData>(); shipCommitSV.MiscShipmentKeyList = liShipReturn; shipCommitSV.Do(); #endregion //审核杂发单 #region CommonApproveMiscShipSV UFIDA.U9.ISV.MiscShipISV.Proxy.CommonApproveMiscShipSVProxy shipApproveSV = new UFIDA.U9.ISV.MiscShipISV.Proxy.CommonApproveMiscShipSVProxy(); shipApproveSV.MiscShipmentKeyList = new List <CommonArchiveDataDTOData>(); shipApproveSV.MiscShipmentKeyList = liShipReturn; shipApproveSV.Do(); #endregion //创建杂收单,把上面创建的杂发单杂收了 #region 创建杂收单 UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCreateMiscRcvProxy rcvSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCreateMiscRcvProxy(); //杂收SV参数 rcvSV.TargetOrgCode = Context.LoginOrg.Code; rcvSV.TargetOrgName = Context.LoginOrg.Name; rcvSV.MiscRcvDTOList = new List <UFIDA.U9.ISV.MiscRcvISV.IC_MiscRcvDTOData>(); IC_MiscRcvDTOData rcvHeadDto = new IC_MiscRcvDTOData();//杂收单头 //dto.DocNo = "MR30190417999"; rcvHeadDto.MiscRcvDocType = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); UFIDA.U9.InvDoc.MiscRcv.MiscRcvDocType rcvDocType = UFIDA.U9.InvDoc.MiscRcv.MiscRcvDocType.Finder.Find("Code='MR30116' and Org= " + Context.LoginOrg.ID); rcvHeadDto.MiscRcvDocType.ID = rcvDocType.ID; rcvHeadDto.MiscRcvDocType.Code = rcvDocType.Code; rcvHeadDto.MiscRcvDocType.Name = rcvDocType.Name; rcvHeadDto.BusinessDate = DateTime.Now; //业务日期 rcvHeadDto.SOBAccountPeriod = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); //账期 rcvHeadDto.SOBAccountPeriod.ID = sobPeriod.ID; rcvHeadDto.SOBAccountPeriod.Code = sobPeriod.Code; rcvHeadDto.SOBAccountPeriod.Name = sobPeriod.DisplayName; rcvHeadDto.Org = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvHeadDto.Org.ID = Context.LoginOrg.ID;; rcvHeadDto.Org.Code = Context.LoginOrg.Code; rcvHeadDto.Org.Name = Context.LoginOrg.Name; rcvHeadDto.BenefitOrg = Context.LoginOrg.ID;//受益组织 #region 杂收行 rcvHeadDto.MiscRcvTransLs = new List <IC_MiscRcvTransLsDTOData>(); UFIDA.U9.CBO.SCM.Warehouse.Warehouse wh = UFIDA.U9.CBO.SCM.Warehouse.Warehouse.Finder.Find("Code='106' and Org=" + Context.LoginOrg.ID.ToString()); for (int i = 0; i < lines.Count; i++) { UFIDA.U9.MO.Issue.IssueDocLine line = lines[i]; IC_MiscRcvTransLsDTOData rcvLineDto = new IC_MiscRcvTransLsDTOData(); //扩展字段中记录杂发单的来源退料单号、行号 rcvLineDto.DescFlexSegments = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegmentsData(); rcvLineDto.DescFlexSegments.PrivateDescSeg2 = line.MO.DocNo; rcvLineDto.DescFlexSegments.PrivateDescSeg29 = issueDoc.DocNo; rcvLineDto.DescFlexSegments.PrivateDescSeg30 = line.LineNum.ToString(); rcvLineDto.ItemInfo = new UFIDA.U9.CBO.SCM.Item.ItemInfoData(); rcvLineDto.ItemInfo.ItemID = line.Item.ID; rcvLineDto.ItemInfo.ItemCode = line.Item.Code; rcvLineDto.ItemInfo.ItemName = line.Item.Name; rcvLineDto.Wh = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvLineDto.Wh.ID = wh.ID; rcvLineDto.Wh.Code = wh.Code; rcvLineDto.Wh.Name = wh.Name; rcvLineDto.BenefitDept = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvLineDto.BenefitDept.ID = issueDoc.HandleDept.ID; rcvLineDto.BenefitDept.Code = issueDoc.HandleDept.Code; rcvLineDto.BenefitDept.Name = issueDoc.HandleDept.Name; rcvLineDto.StoreUOMQty = line.IssuedQty; rcvLineDto.CostUOMQty = line.IssuedQty; rcvLineDto.CostUOM = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvLineDto.CostUOM.ID = line.StoreBaseUOM.ID; rcvLineDto.CostUOM.Code = line.StoreBaseUOM.Code; rcvLineDto.CostUOM.Name = line.StoreBaseUOM.Name; rcvLineDto.StoreUOM = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvLineDto.StoreUOM.ID = line.StoreBaseUOM.ID; rcvLineDto.StoreUOM.Code = line.StoreBaseUOM.Code; rcvLineDto.StoreUOM.Name = line.StoreBaseUOM.Name; rcvLineDto.IsZeroCost = true; //rcvLineDto.StoreUOM.ID = 1001708030115592; //rcvLineDto.StoreUOM.Code = "SL01"; //rcvLineDto.StoreUOM.Name = "PCS"; rcvLineDto.OwnerOrg = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); rcvLineDto.OwnerOrg.ID = Context.LoginOrg.ID; rcvLineDto.OwnerOrg.Code = Context.LoginOrg.Code; rcvLineDto.OwnerOrg.Name = Context.LoginOrg.Name; if (!string.IsNullOrEmpty(lines[i].LotNo)) { rcvLineDto.LotInfo = new UFIDA.U9.CBO.SCM.PropertyTypes.LotInfoData(); rcvLineDto.LotInfo.LotCode = lines[i].LotNo; } rcvHeadDto.MiscRcvTransLs.Add(rcvLineDto); } #endregion rcvSV.MiscRcvDTOList.Add(rcvHeadDto); List <CommonArchiveDataDTOData> liRcvReturn = new List <CommonArchiveDataDTOData>(); liRcvReturn = rcvSV.Do();//执行创建杂收单服务 #region 提交杂收单服务 UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCommitMiscRcvProxy rcvCommitSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonCommitMiscRcvProxy(); rcvCommitSV.TargetOrgCode = Context.LoginOrg.Code; rcvCommitSV.TargetOrgName = Context.LoginOrg.Name; rcvCommitSV.MiscRcvKeys = new List <CommonArchiveDataDTOData>(); rcvCommitSV.MiscRcvKeys = liRcvReturn; rcvCommitSV.Do(); #endregion #region 审核杂收单 UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonApproveMiscRcvProxy rcvApproveSV = new UFIDA.U9.ISV.MiscRcvISV.Proxy.CommonApproveMiscRcvProxy(); rcvApproveSV.TargetOrgCode = Context.LoginOrg.Code; rcvApproveSV.MiscRcvKeys = new List <CommonArchiveDataDTOData>(); rcvApproveSV.MiscRcvKeys = liRcvReturn; rcvApproveSV.Do(); #endregion #endregion } } #endregion #region 领料控制 //根据更新前后时间判断订单是否已审核,若beforeConfirmDate=confirmDate表示订单已审核 string beforeConfirmDate = ""; string confirmDate = ""; if (issueDoc.OriginalData.IssueItemOn != DateTime.MinValue) { beforeConfirmDate = issueDoc.OriginalData.IssueItemOn.ToString(); } if (issueDoc.IssueItemOn != DateTime.MinValue) { confirmDate = issueDoc.IssueItemOn.ToString(); } DataParamList dp = new DataParamList(); dp.Add(DataParamFactory.Create("DocNo", issueDoc.DocNo, ParameterDirection.Input, DbType.String, 50)); dp.Add(DataParamFactory.Create("BeforeConfirmDate", beforeConfirmDate, ParameterDirection.Input, DbType.String, 50)); dp.Add(DataParamFactory.Create("ConfirmDate", confirmDate, ParameterDirection.Input, DbType.String, 50)); dp.Add(DataParamFactory.CreateOutput("Result", DbType.String)); DataAccessor.RunSP("sp_auctus_BE_MoIssueDoc", dp); string result = dp["Result"].Value.ToString(); if (result != "1") { throw new Exception(result); } #endregion #region 提交流程到OA if (issueDoc.DocType.DescFlexField.PrivateDescSeg1 == "1" && issueDoc.DocState == IssueTXNStateEnum.Approving && issueDoc.OriginalData.DocState == IssueTXNStateEnum.Opened) { PubFunction pubFun = new PubFunction(); User user = User.Finder.FindByID(Context.LoginUserID);//U9用户信息 Dictionary <string, object> dicResult = new Dictionary <string, object>(); Dictionary <string, object> dicMain = GenerateMainInfo(issueDoc, user.Code); List <Dictionary <string, object> > liDt = GenerateDtInfo(issueDoc); BaseInfo baseInfo; string workflowid = ""; if (issueDoc.IssueType == IssueTypeEnum.Issue)//发料 { workflowid = PubFunction.GetOAInfoByCode("08"); } else if (issueDoc.IssueType == IssueTypeEnum.Withdrawal)//退料 { workflowid = PubFunction.GetOAInfoByCode("09"); } string requestName = ""; if (issueDoc.IssueType == IssueTypeEnum.Issue) { requestName = "生产领料单:" + issueDoc.DocNo; } else if (issueDoc.IssueType == IssueTypeEnum.Withdrawal) { requestName = "生产退料单:" + issueDoc.DocNo; } if (issueDoc.DescFlexField.PrivateDescSeg6 == "是")//提交流程或弃审后重新提交流程 { baseInfo = Utils.GenerateOABaseInfo(user.Code, workflowid, issueDoc.ID.ToString(), 1, issueDoc.DescFlexField.PrivateDescSeg5, 1, requestName); } else//驳回后重新提交 { baseInfo = Utils.GenerateOABaseInfo(user.Code, workflowid, issueDoc.ID.ToString(), 1, "", 1, requestName); } dicResult.Add("base", baseInfo); dicResult.Add("main", dicMain); dicResult.Add("dt1", liDt); List <Dictionary <string, object> > li = new List <Dictionary <string, object> >(); li.Add(dicResult); string json = JsonHelper.GetJsonJS(li); Utils.LogError("生产领料JSON"); Utils.LogError(json); string OAFlowID = pubFun.OAService(json); //更新扩展字段:OA流程ID和是否驳回 string sql = string.Format("update mo_IssueDoc set DescFlexField_PrivateDescSeg6='否',DescFlexField_PrivateDescSeg5='{0}' where ID={1}", OAFlowID, issueDoc.ID); DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null);//更新sql } #endregion } catch (Exception ex) { throw new Exception(ex.Message); } } } }
// CommonCreateMiscRcv public override HBH.DoNet.DevPlatform.EntityMapping.EntityResult Do() { //return base.Do(); EntityResult result = new EntityResult(); //result.Sucessfull = true; //result.Message = "调用【出库单】服务成功,但服务未实现!"; //return result; string className = this.GetType().FullName; // BPM用单号做唯一键,不用ID // 我们实体的ID,一般要求传入 第三方系统ID,如果第三方系统ID不是long(可能为字符串、或GUID),那么要求第三方系统,此ID强制赋值 为 1 ; //long id = this.ID; //if (id < 0) //{ // result.Sucessfull = false; // result.Message = string.Format("[{0}]执行失败,ID[{1}]不可转化为长整数或小于0 !" // , className // , this.ID // ); // return result; //} // DescFlexField.PrivateDescSeg3 if (this.ReturnNo.IsNull()) { result.Sucessfull = false; result.Message = "回运单号为空,无法生成ERP旧件回运杂收单!"; return(result); } // 检查系统中存在不,如果已存在,直接返回存在的单号; else { MiscRcvTrans rcvHead = MiscRcvTrans.Finder.Find("Org=@Org and DescFlexField.PrivateDescSeg3=@ReturnNo" , new OqlParam(Context.LoginOrg.ID) , new OqlParam(this.ReturnNo) ); if (rcvHead != null) { result.Sucessfull = true; string erpDocNo = rcvHead.DocNo; result.Message = string.Format("回运单号[{0}]已生成过ERP单据[{1}],无需再次生成!" , this.ReturnNo , erpDocNo ); if (erpDocNo.IsNotNullOrWhiteSpace()) { result.StringValue = erpDocNo; result.ListValue = new List <string>(); result.ListValue.Add(erpDocNo); } return(result); } } // 删除数量为空的行 bool isAllLineZero = true; if (this.ReturnOrderDtlDto != null && this.ReturnOrderDtlDto.Length > 0 ) { for (int i = this.ReturnOrderDtlDto.Length - 1; i >= 0; i--) { ReturnOrderDtlDto line = this.ReturnOrderDtlDto[i]; if (line != null) { //bool isDel = false; { decimal qty = PubClass.GetDecimal(line.AlreadyIn); //if (qty == 0) //{ // isDel = true; //} if (qty > 0) { isAllLineZero = false; break; } } //if (isDel) //{ // this.ReturnOrderDtlDto.RemoveAt(i); // continue; //} } } } if (isAllLineZero) { result.Sucessfull = false; result.Message = string.Format("回运单[{0}]没有行、或者行数量全部为0,不可生成ERP单据!" , this.ReturnNo ); return(result); } //result.Sucessfull = true; //result.Message = string.Format("调用U9服务[{0}]成功,不过服务未实现!" // , className // ); CommonCreateMiscRcvProxy proxy = new CommonCreateMiscRcvProxy(); proxy.MiscRcvDTOList = new List <UFIDA.U9.ISV.MiscRcvISV.IC_MiscRcvDTOData>(); if (this.ReturnOrderDtlDto != null && this.ReturnOrderDtlDto.Length > 0 ) { ReturnOrderDtlDto firstLine = this.ReturnOrderDtlDto[0]; IC_MiscRcvDTOData miscHead = new IC_MiscRcvDTOData(); miscHead.MiscRcvDocType = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); miscHead.MiscRcvDocType.Code = Const_MiscRcvDocTypeCode; // U9不需要回运日期,暂时不用 miscHead.BusinessDate = DateTime.Today; //miscHead.BusinessDate = this.ReturnDate.GetDateTime(DateTime.Today); miscHead.BenefitOrg = Context.LoginOrg.ID; // 备注:**退回三包旧件 **取经销商代码+名称 // DDC001运城金元阳退回三包旧件 //miscHead.Memo = this.ReMark; string dealerName = string.Empty; if (this.DealerCode.IsNotNullOrWhiteSpace()) { Customer dealer = Customer.Finder.Find("Org=@Org and Code=@Code" , new OqlParam(Context.LoginOrg.ID) , new OqlParam(this.DealerCode) ); dealerName = dealer.Name; } miscHead.Memo = string.Format("{0}{1}{2}" , this.DealerCode , dealerName , " 退回三包旧件" ); if (miscHead.DescFlexField == null) { miscHead.DescFlexField = new UFIDA.U9.Base.FlexField.DescFlexField.DescFlexSegmentsData(); } //miscHead.DescFlexField.PrivateDescSeg1 = firstLine.DmsSaleNo; //miscHead.DescFlexField.PrivateDescSeg2 = firstLine.DMSShipNo; miscHead.DescFlexField.PrivateDescSeg3 = this.ReturnNo; int lineNo = 0; miscHead.MiscRcvTransLs = new List <IC_MiscRcvTransLsDTOData>(); foreach (ReturnOrderDtlDto lineDTO in this.ReturnOrderDtlDto) { IC_MiscRcvTransLsDTOData miscLine = new IC_MiscRcvTransLsDTOData(); lineNo += 10; miscLine.DocLineNo = lineNo; miscLine.ItemInfo = new UFIDA.U9.CBO.SCM.Item.ItemInfoData(); //miscLine.ItemInfo.ItemCode = lineDTO.ErpMaterialCode; miscLine.ItemInfo.ItemCode = lineDTO.PartCode; //ItemMaster item = ItemMaster.Finder.Find("Org=@Org and Code=@Code" // , new OqlParam(Context.LoginOrg.ID) // , new OqlParam(lineDTO.PartCode) // ); //if (item != null) //{ // miscLine.ItemInfo.ItemID = item.ID; //} //miscLine.StoreUOMQty = lineDTO.AlreadyIn; miscLine.StoreUOMQty = lineDTO.AlreadyIn; //miscLine.CostUOMQty = miscLine.StoreUOMQty; miscLine.CostPrice = lineDTO.PartFee; miscLine.CostMny = miscLine.CostPrice * miscLine.StoreUOMQty; if (miscLine.CostPrice == 0) { miscLine.IsZeroCost = true; } miscLine.Wh = new UFIDA.U9.CBO.Pub.Controller.CommonArchiveDataDTOData(); //miscLine.Wh.Code = lineDTO.Warehouse; miscLine.Wh.Code = Const_MiscRcvWhCode; //Warehouse wh = Warehouse.Finder.Find("Org=@Org and Code=@Code" // , new OqlParam(Context.LoginOrg.ID) // , new OqlParam(Const_MiscRcvWhCode) // ); //if (wh != null) //{ // miscLine.Wh.ID = wh.ID; //} //miscLine.LotInfo = new UFIDA.U9.CBO.SCM.PropertyTypes.LotInfoData(); //miscLine.LotInfo.LotCode = lineDTO.LotCode; miscLine.SupplierInfo = new UFIDA.U9.CBO.SCM.Supplier.SupplierMISCInfoData(); miscLine.SupplierInfo.Code = lineDTO.OldSuptCode; miscLine.Memo = lineDTO.Remark; // 收益部门 miscLine.BenefitDept = new CommonArchiveDataDTOData(); miscLine.BenefitDept.Code = Const_MiscBenefitDept; miscLine.BenefitOwnerOrg = Context.LoginOrg.ID; miscHead.MiscRcvTransLs.Add(miscLine); } proxy.MiscRcvDTOList.Add(miscHead); } if (proxy.MiscRcvDTOList.Count > 0) { try { List <CommonArchiveDataDTOData> lstResult = proxy.Do(); if (lstResult != null && lstResult.Count > 0 && lstResult[0] != null ) { result.Sucessfull = true; string erpDocNo = lstResult[0].Code; if (erpDocNo.IsNotNullOrWhiteSpace()) { result.StringValue = erpDocNo; result.ListValue = new List <string>(); result.ListValue.Add(erpDocNo); } } else { result.Sucessfull = false; result.Message = "U9服务执行异常,无返回值!"; } } catch (Exception ex) { result.Sucessfull = false; result.Message = ex.Message; result.Trace = ex.StackTrace; } } else { result.Sucessfull = false; result.Message = string.Format("收货有效行为空!"); } return(result); }