private DependencyObjectCollection GetPickListDataource(string pickListName, bool allowCheck) { IPickListDataService plDataSrv = this.GetService <IPickListDataService>(); DependencyObjectType type = new DependencyObjectType(pickListName); type.RegisterSimpleProperty("Value", typeof(string)); type.RegisterSimpleProperty("DisplayName", typeof(string)); if (allowCheck) { type.RegisterSimpleProperty("Select", typeof(bool)); } DependencyObjectCollection items = new DependencyObjectCollection(type); if (!allowCheck) { DependencyObject first = items.AddNew(); first["Value"] = ""; first["DisplayName"] = "--空白值--"; } foreach (var item in plDataSrv.GetPickListSortedData(pickListName)) { DependencyObject obj = items.AddNew(); obj["Value"] = item.Id; obj["DisplayName"] = item.DisplayName; if (allowCheck) { obj["Select"] = false; } } return(items); }
/// <summary> /// 组织新的集合 /// </summary> /// <param name="sourceCollection"></param> /// <param name="newCollection"></param> public void BuildCollectionValue(DependencyObjectCollection sourceCollection, DependencyObjectCollection newCollection) { foreach (DependencyObject subObj in sourceCollection) { DependencyObject newObj = newCollection.AddNew(); //简单属性赋值 foreach (DependencyProperty property in (sourceCollection.ItemDependencyObjectType as IDataEntityType).SimpleProperties) { if (_dateTimeProperties.Contains(property.Name)) { newObj[property.Name] = subObj[property.Name].ToDate(); } else if (_decimalProperties.Contains(property.Name)) { newObj[property.Name] = subObj[property.Name].ToDecimal(); } else { newObj[property.Name] = subObj[property.Name].ToStringExtension(); } } //集合属性赋值 foreach (DependencyProperty property in (sourceCollection.ItemDependencyObjectType as IDataEntityType).CollectionProperties) { DependencyObjectCollection subColl = property.GetValue(subObj) as DependencyObjectCollection; DependencyObjectCollection newC = newObj[property.Name] as DependencyObjectCollection; BuildCollectionValue(subColl, newC); } } }
/// <summary> /// 移除不需要的列 /// </summary> /// <param name="entity">实体集合</param> /// <param name="excludeColumns">需要移除的列</param> /// <returns></returns> private DependencyObjectCollection RemoveObjectType(DependencyObjectCollection entity, string[] excludeColumns) { DependencyObjectType cloneObjectType = new DependencyObjectType("collection1_clone"); IDataEntityType dataEntityType = entity.ItemDependencyObjectType; foreach (ISimpleProperty property in dataEntityType.SimpleProperties) { if (!excludeColumns.Contains(property.Name)) { cloneObjectType.RegisterSimpleProperty(property.Name, property.PropertyType); } } DependencyObjectCollection cloneObject = new DependencyObjectCollection(cloneObjectType);//克隆对象 foreach (DependencyObject item in entity) { var newItem = cloneObject.AddNew(); foreach (ISimpleProperty property in ((IDataEntityType)item.DependencyObjectType).SimpleProperties) { if (newItem.DependencyObjectType.Properties.Contains(property.Name)) { newItem[property.Name] = item[property.Name]; } } } return(cloneObject); }
/// <summary> /// 设置异常服务返回值 /// </summary> /// <param name="coll"></param> /// <param name="code"></param> /// <param name="sqlCode"></param> /// <param name="description"></param> /// <param name="reportNo"></param> public static void SetValue(DependencyObjectCollection coll, int code, string sqlCode, string description, string reportNo) { DependencyObject obj = coll.AddNew(); obj["code"] = code; obj["sql_code"] = sqlCode; obj["description"] = description; obj["report_no"] = reportNo; }
//20170209 add by liwei1 for P001-170203001 ===end=== private void InsertMR(DateTime report_datetime, string category, string recommendedOperations, DependencyObjectCollection resultColl, object docId) //20170209 modi by liwei1 for P001-170124001 增加参数:docId { DataTable dt = QueryForMoReceiptReq(report_datetime, category, recommendedOperations, docId); //20170209 modi by liwei1 for P001-170124001 增加参数:docId ValidateParaFilDoc(dt); //20161213 add by shenbao for B001-161213006 DataTable dt_d = QueryForMoReceipt_D(category, report_datetime, recommendedOperations); if (dt.Rows.Count > 0) { IQueryService qrySrv = GetService <IQueryService>();//20170405 add by wangrm for P001-170328001 ICreateService createSrv = GetService <ICreateService>("MO_RECEIPT_REQUISTION"); DependencyObject entity = createSrv.Create() as DependencyObject; ISaveService saveService = this.GetService <ISaveService>("MO_RECEIPT_REQUISTION"); List <IGrouping <object, DataRow> > groupDt = dt_d.AsEnumerable().GroupBy(a => (a.Field <object>("MO_RECEIPT_REQUISTION_ID"))).ToList(); IEFNETStatusStatusService efnetSrv = this.GetService <IEFNETStatusStatusService>(); IDocumentNumberGenerateService docNumberService = this.GetService <IDocumentNumberGenerateService>("MO_RECEIPT_REQUISTION"); foreach (DataRow dr in dt.Rows) { DependencyObject newEntity = new DependencyObject(entity.DependencyObjectType); DependencyObjectCollection newEntityDColl = newEntity["MO_RECEIPT_REQUISTION_D"] as DependencyObjectCollection; AddToEntity(newEntity, dr, dt.Columns, false); newEntity["DOC_NO"] = docNumberService.NextNumber(dr["DOC_ID"], dr["DOC_DATE"].ToDate().Date); List <IGrouping <object, DataRow> > entityDColl = groupDt.Where(c => c.Key.Equals(dr["MO_RECEIPT_REQUISTION_ID"])).ToList(); foreach (IGrouping <object, DataRow> groupDColl in entityDColl) { foreach (DataRow dr_d in groupDColl) { DependencyObject newEntityD = new DependencyObject(newEntityDColl.ItemDependencyObjectType); AddToEntity(newEntityD, dr_d, dt_d.Columns, true); newEntityDColl.Add(newEntityD); } } //20170428 add by wangyq for P001-170427001 ============begin========== DependencyObject resultObj = resultColl.AddNew(); resultObj["doc_no"] = newEntity["DOC_NO"]; //20170428 add by wangyq for P001-170427001 ============end========== //20170628 modi by zhangcn for P001-170327001 ===begin=== try { SetIgnoreWarningTag(); //忽略警告 saveService.Save(newEntity); //希望触发保存校验 } finally { ResetIgnoreWarningTag();// 重置警告 } //20170628 modi by zhangcn for P001-170327001 ===end=== //7.3自动签核 efnetSrv.GetFormFlow("MO_RECEIPT_REQUISTION.I01", dr["DOC_ID"], dr["Owner_Org_ROid"], new List <object>() { dr["MO_RECEIPT_REQUISTION_ID"] }); } } }
/// <summary> /// 新增单身 /// </summary> /// <param name="entityDColl"></param> /// <param name="detailScanList"></param> private void AddEntity_D(DependencyObjectCollection entityDColl, List <DependencyObject> detailScanList) { foreach (DependencyObject detailObj in detailScanList) { DependencyObject addDetail = entityDColl.AddNew(); addDetail["SequenceNumber"] = detailObj["SequenceNumber"]; addDetail["TRANSACTION_DOC_D_ID"] = detailObj["DETAIL_ID"]; addDetail["ITEM_ID"] = detailObj["ITEM_ID"]; addDetail["ITEM_DESCRIPTION"] = detailObj["ITEM_NAME"]; addDetail["ITEM_FEATURE_ID"] = detailObj["ITEM_FEATURE_ID"]; addDetail["ITEM_SPECIFICATION"] = detailObj["ITEM_SPECIFICATION"]; ((DependencyObject)addDetail["BO_ID"])["RTK"] = "OTHER"; ((DependencyObject)addDetail["BO_ID"])["ROid"] = Maths.GuidDefaultValue(); addDetail["BUSINESS_QTY"] = detailObj["picking_qty"]; addDetail["BUSINESS_UNIT_ID"] = detailObj["UNIT_ID"]; addDetail["SECOND_QTY"] = detailObj["SECOND_QTY"]; addDetail["INVENTORY_QTY"] = detailObj["INVENTORY_QTY"]; addDetail["WAREHOUSE_ID"] = detailObj["WAREHOUSE_ID"]; addDetail["BIN_ID"] = detailObj["BIN_ID"]; addDetail["ITEM_LOT_ID"] = detailObj["ITEM_LOT_ID"]; ((DependencyObject)addDetail["SOURCE_ID"])["RTK"] = "OTHER"; ((DependencyObject)addDetail["SOURCE_ID"])["ROid"] = Maths.GuidDefaultValue(); ((DependencyObject)addDetail["REFERENCE_SOURCE_ID"])["RTK"] = "OTHER"; ((DependencyObject)addDetail["REFERENCE_SOURCE_ID"])["ROid"] = Maths.GuidDefaultValue(); string invLevel = detailObj["INVENTORY_VALUATION_LEVEL"].ToStringExtension(); if (invLevel == "1") { ((DependencyObject)addDetail["COST_DOMAIN_ID"])["RTK"] = "COMPANY"; ((DependencyObject)addDetail["COST_DOMAIN_ID"])["ROid"] = detailObj["COMPANY_ID"]; } else { ((DependencyObject)addDetail["COST_DOMAIN_ID"])["RTK"] = "COST_DOMAIN"; if (invLevel == "2") { ((DependencyObject)addDetail["COST_DOMAIN_ID"])["ROid"] = detailObj["P_COST_DOMAIN_ID"]; } else if (invLevel == "3") { ((DependencyObject)addDetail["COST_DOMAIN_ID"])["ROid"] = detailObj["W_COST_DOMAIN_ID"]; } } addDetail["REMARK"] = string.Empty; addDetail["ApproveStatus"] = "N"; addDetail["ApproveDate"] = OrmDataOption.EmptyDateTime; addDetail["SN_COLLECTED_STATUS"] = detailObj["SN_COLLECTED_STATUS"]; addDetail["PLANT_ID"] = detailObj["PLANT_ID"]; } }
/// <summary> /// 获取企业信息 /// </summary> /// <returns></returns> public Hashtable GetCompany() { DependencyObjectType type = new DependencyObjectType("enterprise_detail"); type.RegisterSimpleProperty("enterprise_no", typeof(string)); type.RegisterSimpleProperty("enterprise_name", typeof(string)); DependencyObjectCollection enterpriseDetail = new DependencyObjectCollection(type); const string company = "99"; DependencyObject entity = enterpriseDetail.AddNew(); entity["enterprise_no"] = company; entity["enterprise_name"] = company; return(new Hashtable { { "enterprise_detail", enterpriseDetail } }); }
/// <summary> /// 插入临时表#Table_scan /// </summary> /// <param name="dtTempScanDetail"></param> /// <param name="collScan"></param> /// <param name="lstDocNos"></param> private void InsertTempTableData(DataTable dtTempScanDetail, DependencyObjectCollection collScan, List <string> lstDocNos) { foreach (DependencyObject objScan in collScan) { _lstQueryProperties.Add(OOQL.CreateConstants(objScan["site_no"]));//供后面查询使用 #region ScanDetail 单头与单身中的info_lot_no有关联 DependencyObjectCollection collScanDetail = objScan["scan_detail"] as DependencyObjectCollection; if (collScanDetail != null && collScanDetail.Count > 0) { foreach (DependencyObject objScanDetail in collScanDetail) { DataRow drScanDetail = dtTempScanDetail.NewRow(); // drScanDetail["Table_scan_detail_ID"] = _primaryKeySrv.CreateId("TRANSFER_DOC.TRANSFER_DOC_D"); drScanDetail["info_lot_no"] = objScanDetail["info_lot_no"]; drScanDetail["site_no"] = objScanDetail["site_no"]; drScanDetail["barcode_no"] = objScanDetail["barcode_no"]; drScanDetail["item_no"] = objScanDetail["item_no"]; drScanDetail["item_feature_no"] = objScanDetail["item_feature_no"]; drScanDetail["warehouse_no"] = objScanDetail["warehouse_no"]; drScanDetail["storage_spaces_no"] = objScanDetail["storage_spaces_no"]; drScanDetail["lot_no"] = objScanDetail["lot_no"]; drScanDetail["picking_qty"] = objScanDetail["picking_qty"].ToDecimal(); drScanDetail["picking_unit_no"] = objScanDetail["picking_unit_no"]; drScanDetail["doc_no"] = objScanDetail["doc_no"]; drScanDetail["seq"] = objScanDetail["seq"].ToInt32(); dtTempScanDetail.Rows.Add(drScanDetail);//添加行 //记录单号,后续保存和审核需要使用 string docNo = objScanDetail["doc_no"].ToStringExtension(); if (!Maths.IsEmpty(docNo) && !lstDocNos.Contains(docNo)) { lstDocNos.Add(docNo); //相同的单号只返回一次 DependencyObject objDocNo = _collDocNos.AddNew(); objDocNo["doc_no"] = docNo; //用于主方法返回值 } } } #endregion } }
/// <summary> /// /// </summary> /// <param name="employee_no">扫描人员</param> /// <param name="scan_type">扫描类型1.有箱条码 2.无箱条码</param> /// <param name="report_datetime">上传时间</param> /// <param name="picking_department_no">部门</param> /// <param name="recommended_operations">建议执行作业</param> /// <param name="recommended_function">A.新增 S.过帐</param> /// <param name="scan_doc_no">扫描单号</param> /// <param name="collScan"></param> public DependencyObjectCollection InertTransactionDoc(string employee_no, string scan_type, DateTime report_datetime, string picking_department_no, string recommended_operations, string recommended_function, string scan_doc_no, DependencyObjectCollection scanColl) { IInfoEncodeContainer InfoEncodeSrv = this.GetService <IInfoEncodeContainer>(); if (Maths.IsEmpty(recommended_operations)) { throw new BusinessRuleException(InfoEncodeSrv.GetMessage("A111201", "recommended_operations"));//‘入参【recommended_operations】未传值’ } if (Maths.IsEmpty(recommended_function)) { throw new BusinessRuleException(InfoEncodeSrv.GetMessage("A111201", "recommended_function"));//‘入参【recommended_function】未传值’ } DependencyObjectType type = new DependencyObjectType("ReturnCollection"); type.RegisterSimpleProperty("doc_no", typeof(string)); DependencyObjectCollection Rtn = new DependencyObjectCollection(type); if (scanColl.Count > 0) { string stockAction = string.Empty; string view = string.Empty; if (recommended_operations.StartsWith("11")) { stockAction = "-1"; view = "TRANSACTION_DOC.I02"; } else if (recommended_operations.StartsWith("12")) { stockAction = "1"; view = "TRANSACTION_DOC.I01"; } DependencyObjectCollection docColl = ValidateDocSet(stockAction, scanColl[0]["site_no"].ToStringExtension()); if (docColl.Count <= 0) { throw new BusinessRuleException(InfoEncodeSrv.GetMessage("A111275")); } DataTable dtScan = CreateDtScan(); DataTable dtScanDetail = CreateDtScanDetail(); PrepareDtForInsertScan(employee_no, picking_department_no, scanColl, dtScan, dtScanDetail); using (IConnectionService connService = this.GetService <IConnectionService>()) { _qurService = this.GetService <IQueryService>(); CreateTemp(); InsertTemp(dtScan, dtScanDetail); List <DependencyObject> saveEntities = AddEntity(docColl[0]["DOC_ID"], docColl[0]["SEQUENCE_DIGIT"].ToInt32(), report_datetime, stockAction); if (saveEntities.Count > 0) { using (ITransactionService transService = this.GetService <ITransactionService>()) { InsertBCLine(report_datetime);//20170413 add by wangyq for P001-170412001 需要在保存服务之前,保存自动审核会需要回写 //保存单据 ISaveService saveSrv = this.GetService <ISaveService>("TRANSACTION_DOC"); saveSrv.Save(saveEntities.ToArray()); UpdateTD();//更新 //InsertBCLine(report_datetime);//20170413 mark by wangyq for P001-170412001 //EFNET签核 foreach (DependencyObject item in saveEntities) { IEFNETStatusStatusService efnetSrv = this.GetService <IEFNETStatusStatusService>(); efnetSrv.GetFormFlow(view, item["DOC_ID"], ((DependencyObject)item["Owner_Org"])["ROid"], new object[] { item["TRANSACTION_DOC_ID"] }); } transService.Complete(); } foreach (DependencyObject item in saveEntities) { DependencyObject obj = Rtn.AddNew(); obj["doc_no"] = item["DOC_NO"]; } } } } return(Rtn); }
/// <summary> /// 更新领退料单 /// </summary> /// <param name="employeeNo">扫描人员</param> /// <param name="scanType">扫描类型 1.有箱条码 2.无箱条码</param> /// <param name="reportDatetime">上传时间</param> /// <param name="pickingDepartmentNo">领料部门</param> /// <param name="recommendedOperations">建议执行作业</param> /// <param name="recommendedFunction">A.新增 S.过帐</param> /// <param name="scanDocNo">扫描单号</param> /// <param name="collection">接口传入的领料单单身数据集合</param> public DependencyObjectCollection UpdateIssueReceipt(string employeeNo, string scanType, DateTime reportDatetime, string pickingDepartmentNo , string recommendedOperations, string recommendedFunction, string scanDocNo, DependencyObjectCollection collection) { DependencyObjectCollection rtnColl = CreateReturnCollection(); #region 参数检查 if (Maths.IsEmpty(recommendedOperations)) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "recommended_operations" })); } if (Maths.IsEmpty(recommendedFunction)) { throw new BusinessRuleException(EncodeSrv.GetMessage("A111201", new object[] { "recommended_function" })); } #endregion //创建临时表需要的DataTable和Mapping信息 DataTable issueReceiptD = null; List <BulkCopyColumnMapping> issueReceiptDMap = null; this.CreateRelateTable(ref issueReceiptD, ref issueReceiptDMap); List <string> docNos = new List <string>(); //记录单身的单号,保存时需要,可以避免后续再查 //组织数据BulkCopy需要的DataTable数据 InsertDataTable(issueReceiptD, collection, docNos); #region 更新逻辑 using (ITransactionService trans = this.GetService <ITransactionService>()) { IQueryService querySrv = this.GetService <IQueryService>(); //新增临时表 IDataEntityType issueReceiptDTmp = CreateIssueReceiptDTmpTable(querySrv); //批量新增到临时表 querySrv.BulkCopy(issueReceiptD, issueReceiptDTmp.Name, issueReceiptDMap.ToArray()); if (issueReceiptD.Rows.Count <= 00 || issueReceiptD.Rows.Count <= 0) //没有数据值不再往下执行 { return(rtnColl); } DataRow[] drs = issueReceiptD.Select("BARCODE_NO<>\'\'"); //利用临时表批量更新相关数据 //20170905 add by wangyq for P001-170717001 =================begin=================== if (recommendedOperations == "7-5") { UpdateBcCheckStatus(querySrv, issueReceiptDTmp); } else { //20170905 add by wangyq for P001-170717001 =================end=================== UpdateIssueReceiptD(querySrv, issueReceiptDTmp); }//20170905 add by wangyq for P001-170717001 if (drs.Length > 0) //条码不为""的记录大于0时,才执行如下更新,避免多余的性能损失 { bool bcLintFlag = UtilsClass.IsBCLineManagement(querySrv); if (bcLintFlag) { DeleteBCLine(querySrv, issueReceiptDTmp); //先删除 InsertBCLine(querySrv, issueReceiptDTmp); //再重新生成 } } //保存 DependencyObjectCollection ids = GetIssueReceipt(docNos); IReadService readSrv = this.GetService <IReadService>("ISSUE_RECEIPT"); object[] entities = readSrv.Read(ids.Select(c => c["ISSUE_RECEIPT_ID"]).ToArray()); if (entities != null && entities.Length > 0) { ISaveService saveSrv = this.GetService <ISaveService>("ISSUE_RECEIPT"); saveSrv.Save(entities); } //保存时没有自动审核的,需要重新审核 entities = readSrv.Read(ids.Where(c => !c["AUTO_APPROVE"].ToBoolean()).Select(c => c["ISSUE_RECEIPT_ID"]).ToArray()); IConfirmService confirmService = this.GetService <IConfirmService>("ISSUE_RECEIPT"); ILogOnService logOnSrv = this.GetService <ILogOnService>(); foreach (DependencyObject obj in entities) { ConfirmContext context = new ConfirmContext(obj.Oid, logOnSrv.CurrentUserId, reportDatetime.ToDate()); confirmService.Execute(context); } trans.Complete(); } #endregion #region 组织返回结果 foreach (string item in docNos) { DependencyObject obj = rtnColl.AddNew(); obj["doc_no"] = item; } #endregion return(rtnColl); }
public DependencyObjectCollection UpdateSalesIssue(string employeeNo, string scanType, DateTime reportDatetime, string pickingDepartmentNo , string recommendedOperations, string recommendedFunction, string scanDocNo, DependencyObjectCollection collection) { DependencyObjectCollection rtnColl = CreateReturnCollection(); #region 参数检查 IInfoEncodeContainer encodeSrv = this.GetService <IInfoEncodeContainer>(); if (Maths.IsEmpty(recommendedOperations)) { throw new BusinessRuleException(encodeSrv.GetMessage("A111201", new object[] { "recommended_operations" })); } if (Maths.IsEmpty(recommendedFunction)) { throw new BusinessRuleException(encodeSrv.GetMessage("A111201", new object[] { "recommended_function" })); } #endregion //创建临时表需要的DataTable和Mapping信息 DataTable dtEntityD = new DataTable(); List <BulkCopyColumnMapping> entityDMap = new List <BulkCopyColumnMapping>(); CreateRelateTable(dtEntityD, entityDMap); List <string> docNos = new List <string>(); //记录单身的单号,保存时需要,可以避免后续再查 //组织数据BulkCopy需要的DataTable数据 InsertDataTable(dtEntityD, collection, docNos); if (dtEntityD.Rows.Count <= 0) { return(rtnColl); } #region 更新逻辑 using (ITransactionService trans = this.GetService <ITransactionService>()) { using (IConnectionService connService = this.GetService <IConnectionService>()) { IQueryService querySrv = this.GetService <IQueryService>(); //新增临时表 IDataEntityType dtTemp = CreateDTmpTable(querySrv); //批量新增到临时表 querySrv.BulkCopy(dtEntityD, dtTemp.Name, entityDMap.ToArray()); //利用临时表批量更新相关数据 UpdateSalesIssueD(querySrv, dtTemp); DataRow[] drs = dtEntityD.Select("BARCODE_NO<>\'\'"); if (drs.Length > 0) //条码不为""的记录大于0时,才执行如下更新,避免多余的性能损失 { ICreateService createService = this.GetService <ICreateService>("PARA_FIL"); if (createService != null) //PARA_FIL实体存在,服务端可以这么判断 { bool bcLintFlag = UtilsClass.IsBCLineManagement(querySrv); if (bcLintFlag) { DeleteBCLine(querySrv, dtTemp); //先删除 InsertBCLine(querySrv, dtTemp); //再重新生成 } } } } //保存 DependencyObjectCollection ids = GetSalesIssue(docNos); IReadService readSrv = this.GetService <IReadService>("SALES_ISSUE"); object[] entities = readSrv.Read(ids.Select(c => c["SALES_ISSUE_ID"]).ToArray()); if (entities != null && entities.Length > 0) { ISaveService saveSrv = this.GetService <ISaveService>("SALES_ISSUE"); saveSrv.Save(entities); } //保存时没有自动审核的,需要重新审核 entities = readSrv.Read(ids.Where(c => !c["AUTO_APPROVE"].ToBoolean()).Select(c => c["SALES_ISSUE_ID"]).ToArray()); IConfirmService confirmService = this.GetService <IConfirmService>("SALES_ISSUE"); ILogOnService logOnSrv = this.GetService <ILogOnService>(); foreach (DependencyObject obj in entities) { ConfirmContext context = new ConfirmContext(obj.Oid, logOnSrv.CurrentUserId, reportDatetime.ToDate()); confirmService.Execute(context); } trans.Complete(); } #endregion #region 组织返回结果 foreach (string item in docNos) { DependencyObject obj = rtnColl.AddNew(); obj["doc_no"] = item; } #endregion return(rtnColl); }
/// <summary> /// 根据传入的条码,获取相应的到货单信息 /// </summary> /// <param name="barcode_no">扫描单号</param> /// <returns></returns> public Hashtable GetPurchaseArrivalQc(string barcode_no) { try { // 参数检查 if (Maths.IsEmpty(barcode_no)) { var infoCodeSer = GetService <IInfoEncodeContainer>(); //信息编码服务 throw new BusinessRuleException(infoCodeSer.GetMessage("A111201", "barcode_no")); //‘入参【barcode_no】未传值’ } //组织返回结果 Hashtable result = new Hashtable(); //获取返回值单头与receipt_list的信息 DependencyObjectCollection purchseArrivals = GetPurchaseArrival(barcode_no); if (purchseArrivals.Count > 0) { //返回单头信息在集合中存在都是一样的,只需要取第一笔即可 DependencyObject receiptData = purchseArrivals[0]; result.Add("delivery_no", receiptData["delivery_no"]); //送货单 result.Add("supplier_no", receiptData["supplier_no"]); //供应商 result.Add("supplier_name", receiptData["supplier_name"]); //供应商名称 result.Add("receipt_no", receiptData["receipt_no"]); //收货单 result.Add("receipt_date", receiptData["receipt_date"]); //收货时间 //返回值中添加receipt_list数据 DependencyObjectCollection receiptList = new DependencyObjectCollection(StructureReceiptList()); foreach (DependencyObject item in purchseArrivals) { DependencyObject newItem = receiptList.AddNew(); newItem["seq"] = item["seq"]; newItem["item_no"] = item["item_no"]; newItem["item_name"] = item["item_name"]; newItem["item_spec"] = item["item_spec"]; newItem["item_feature_no"] = item["item_feature_no"]; newItem["item_feature_name"] = item["item_feature_name"]; newItem["unit_no"] = item["unit_no"]; newItem["receipt_qty"] = item["receipt_qty"]; newItem["ok_qty"] = item["ok_qty"]; newItem["unqualified_qty"] = item["unqualified_qty"]; //20170801 add by liwei1 for P001-170717001 newItem["checkdestroy_qty"] = item["checkdestroy_qty"]; //20170801 add by liwei1 for P001-170717001 newItem["result_type"] = item["result_type"]; newItem["qc_group"] = item["qc_group"]; newItem["qc_degree"] = item["qc_degree"]; newItem["qc_level"] = item["qc_level"]; newItem["qc_type"] = item["qc_type"]; //获取qc_list数据 object plantId = GetPlantId(item["ITEM_ID"], item["RECEIVE_Owner_Org_ROid"], item["OPERATION_ID"]); DependencyObjectCollection getQcList = GetQcList(plantId); //判断是否存在数据,如果存在数据返回对应数据,如果不存在应该返回一笔空数据给APP,否则json与标准存在差异化 if (getQcList.Count > 0) { foreach (DependencyObject qcListItem in getQcList) { DependencyObject inspectionQty = GetInspectionQty(plantId, qcListItem["INSPECTION_ITEM_ID"], item["receipt_qty"].ToDecimal(), item["STRICTNESS_DEGREE"].ToStringExtension()); DependencyObject qcListEntityItem = ((DependencyObjectCollection)newItem["qc_list"]).AddNew(); qcListEntityItem["qc_seq"] = qcListItem["qc_seq"]; qcListEntityItem["test_no"] = qcListItem["test_no"]; qcListEntityItem["test_name"] = qcListItem["test_name"]; qcListEntityItem["defect_level"] = qcListItem["defect_level"]; qcListEntityItem["reject_qty"] = qcListItem["reject_qty"]; if (inspectionQty != null) { qcListEntityItem["test_qty"] = inspectionQty["SAMPLE_SIZE_1ST"]; qcListEntityItem["acceptable_qty"] = inspectionQty["AC_1ST"]; qcListEntityItem["rejected_qty"] = inspectionQty["RE_1ST"]; } else { qcListEntityItem["test_qty"] = qcListEntityItem["acceptable_qty"] = qcListEntityItem["rejected_qty"] = 0; } qcListEntityItem["reason_qty"] = qcListItem["reason_qty"]; qcListEntityItem["return_qty"] = qcListItem["return_qty"]; qcListEntityItem["reason_no"] = string.Empty; qcListEntityItem["measure_max"] = qcListItem["measure_max"]; qcListEntityItem["measure_min"] = qcListItem["measure_min"]; qcListEntityItem["result_type"] = qcListItem["result_type"]; #region 与SD确认过,返回空对象即可,无需给默认值 SetDefaultValue(qcListEntityItem); #endregion } } else { DependencyObject qcListEntityItem = ((DependencyObjectCollection)newItem["qc_list"]).AddNew(); qcListEntityItem["defect_level"] = qcListEntityItem["result_type"] = qcListEntityItem["test_name"] = qcListEntityItem["reason_no"] = qcListEntityItem["test_no"] = string.Empty; SetDefaultValue(qcListEntityItem); } } result.Add("receipt_list", receiptList); } return(result); } catch (Exception) { throw; } }
/// <summary> /// 移动应用自动产生批号服务 /// </summary> /// <param name="program_job_no">作业编号</param> /// <param name="status">执行动作</param> /// <param name="item_no">料件编号</param> /// <param name="item_feature_no">产品特征</param> /// <param name="site_no">营运据点</param> /// <param name="object_no">供货商编号//作業編號=1.2.3為必要輸入</param> /// <param name="action">动作:Q.查询 I.新增</param> /// <param name="lot_no">批号:当动作=Q时,为必输</param> /// <returns></returns> public Hashtable LotNoAndSerialNoCoding(string program_job_no, string status, string item_no, string item_feature_no, string site_no, string object_no, string action, string lot_no) //20170109 modi by wangyq for P001-170118001 添加后两个参数 //20170109 add by wangyq for P001-170118001 =============begin============== { if (action == "Q" && string.IsNullOrEmpty(lot_no)) { throw new ArgumentNullException("lot_no"); } //20170109 add by wangyq for P001-170118001 =============end============== string[] convertJobNos = new string[] { "1", "2", "3", "9" }; DependencyObjectType resultType = new DependencyObjectType("lot_detail"); resultType.RegisterSimpleProperty("lot_no", typeof(string)); resultType.RegisterSimpleProperty("item_no", typeof(string)); resultType.RegisterSimpleProperty("item_feature_no", typeof(string)); //20170109 add by wangyq for P001-170118001 =============begin============== resultType.RegisterSimpleProperty("lot_description", typeof(string)); resultType.RegisterSimpleProperty("effective_date", typeof(string)); resultType.RegisterSimpleProperty("effective_deadline", typeof(string)); resultType.RegisterSimpleProperty("remarks", typeof(string)); //20170109 add by wangyq for P001-170118001 =============end============== DependencyObjectCollection sourceDocDetail = new DependencyObjectCollection(resultType); IdEntity idEntity = ConvertToId(item_no, item_feature_no, site_no, object_no); if (action == "I") //新增逻辑20170109 add by wangyq for P001-170118001 { if (convertJobNos.Contains(program_job_no)) { Digiwin.ERP.Common.Business.ILotNoAndSerialNoCodingService commonLotSerialService = this.GetServiceForThisTypeKey <Digiwin.ERP.Common.Business.ILotNoAndSerialNoCodingService>(); DependencyObject commonLotResult = commonLotSerialService.LotNoAndSerialNoCoding("1", idEntity.PlantId, idEntity.ItemId, idEntity.SupplierId, idEntity.ItemFeatureId, DateTime.Now.Date, true);//20170410 modi by wangrm 启萌口述新需求 OLD:false->true DependencyObject resultObj = sourceDocDetail.AddNew(); resultObj["lot_no"] = commonLotResult["LOT_CODE"]; resultObj["item_no"] = item_no; resultObj["item_feature_no"] = item_feature_no; //20170109 add by wangyq for P001-170118001 =============begin============== //resultObj["lot_description"] = commonLotResult["LOT_CODE"];//20170509 modi by liwei1 for B001-170505004 resultObj["lot_description"] = string.Empty;//20170509 add by liwei1 for B001-170505004 resultObj["effective_date"] = commonLotResult["EFFECTIVE_DATE"].ToDate().ToString("yyyy-MM-dd"); resultObj["effective_deadline"] = commonLotResult["INEFFECTIVE_DATE"].ToDate().ToString("yyyy-MM-dd"); resultObj["remarks"] = string.Empty; //20170109 add by wangyq for P001-170118001 =============end============== InsertItemLot(commonLotResult, idEntity.ItemId, idEntity.ItemFeatureId);//20170106 add by wangyq for P001-161230002 增加批号的新增数据库逻辑 } } else if (action == "Q") //20170109 add by wangyq for P001-170118001 =============begin============== { QueryNode node = OOQL.Select(OOQL.CreateProperty("ITEM_LOT.LOT_CODE"), OOQL.CreateProperty("ITEM_LOT.LOT_DESCRIPTION"), OOQL.CreateProperty("ITEM_LOT.EFFECTIVE_DATE"), OOQL.CreateProperty("ITEM_LOT.INEFFECTIVE_DATE"), OOQL.CreateProperty("ITEM_LOT.REMARK")) .From("ITEM_LOT", "ITEM_LOT") .Where(OOQL.AuthFilter("ITEM_LOT", "ITEM_LOT") & (OOQL.CreateProperty("ITEM_LOT.ITEM_ID") == OOQL.CreateConstants(idEntity.ItemId) & OOQL.CreateProperty("ITEM_LOT.ITEM_FEATURE_ID") == OOQL.CreateConstants(idEntity.ItemFeatureId) & OOQL.CreateProperty("ITEM_LOT.LOT_CODE") == OOQL.CreateConstants(lot_no))); DependencyObjectCollection lotColl = this.GetService <IQueryService>().ExecuteDependencyObject(node); foreach (DependencyObject lotObj in lotColl) { DependencyObject resultObj = sourceDocDetail.AddNew(); resultObj["lot_no"] = lotObj["LOT_CODE"]; resultObj["item_no"] = item_no; resultObj["item_feature_no"] = item_feature_no; resultObj["lot_description"] = lotObj["LOT_DESCRIPTION"]; resultObj["effective_date"] = lotObj["EFFECTIVE_DATE"].ToDate().ToString("yyyy-MM-dd"); resultObj["effective_deadline"] = lotObj["INEFFECTIVE_DATE"].ToDate().ToString("yyyy-MM-dd"); resultObj["remarks"] = lotObj["REMARK"]; } } //20170109 add by wangyq for P001-170118001 =============end============== //组合返回结果 Hashtable result = new Hashtable(); //添加单据下载数据 result.Add("lot_detail", sourceDocDetail); return(result); }