protected override bool FillValuesImpl(String templateFileName, IList<object> list) { try { if (list == null || list.Count < 2) return false; InspectOrder inspectOrder = (InspectOrder)(list[0]); IList<InspectResult> inspectResultList = (IList<InspectResult>)(list[1]); if (inspectOrder == null || inspectResultList == null || inspectResultList.Count == 0) { return false; } IList<UnqualifiedGoodsView> unqualifiedGoodsList = new List<UnqualifiedGoodsView>(); foreach (InspectResult inspectResult in inspectResultList) { if (!inspectResult.IsPrinted) { inspectResult.PrintNo = inspectOrder.InspectNo; inspectResult.IsPrinted = true; } inspectResult.LastModifyDate = DateTime.Now; inspectResult.LastModifyUser = inspectOrder.CreateUser; inspectResult.PrintCount += 1; inspectResultMgr.UpdateInspectResult(inspectResult); UnqualifiedGoodsView ufg = new UnqualifiedGoodsView(); ufg.Item = inspectResult.InspectOrderDetail.LocationLotDetail.Item; ufg.RejectedQty = inspectResult.RejectedQty.HasValue ? inspectResult.RejectedQty.Value : 0; ufg.DefectClassification = inspectResult.InspectOrderDetail.DefectClassification; ufg.DefectFactor = inspectResult.InspectOrderDetail.DefectFactor; ufg.Disposition = inspectResult.InspectOrderDetail.Disposition; ufg.FinishGoods = inspectResult.InspectOrderDetail.FinishGoods; ufg.LocationFrom = inspectResult.InspectOrderDetail.LocationFrom; bool isExist = false; foreach (UnqualifiedGoodsView unq in unqualifiedGoodsList) { if (unq.Item.Code == ufg.Item.Code && unq.LocationFrom.Code == ufg.LocationFrom.Code) //&& unq.DefectClassification == ufg.DefectClassification //&& unq.DefectFactor == ufg.DefectFactor //&& unq.Disposition == ufg.Disposition //&& ((unq.FinishGoods == null && unq.FinishGoods == null) || (unq.FinishGoods != null && unq.FinishGoods != null && //unq.FinishGoods.Code == ufg.FinishGoods.Code))) { isExist = true; } if (isExist) { unq.RejectedQty += ufg.RejectedQty; break; } } if (!isExist) { unqualifiedGoodsList.Add(ufg); } } this.CopyPage(inspectResultList.Count); this.FillHead(inspectOrder); int pageIndex = 1; int rowIndex = 0; int rowTotal = 0; foreach (UnqualifiedGoodsView unqualifiedGoods in unqualifiedGoodsList) { //零件名称 Part Name this.SetRowCell(pageIndex, rowIndex, 0, unqualifiedGoods.Item.Description); //"零件号Part No." this.SetRowCell(pageIndex, rowIndex, 1, unqualifiedGoods.Item.Code); //工位号 Sta. No. this.SetRowCell(pageIndex, rowIndex, 2, string.Empty); //"数量 QTY." this.SetRowCell(pageIndex, rowIndex, 3, unqualifiedGoods.RejectedQty.ToString("0.########")); //"缺陷 Defect" if (unqualifiedGoods.DefectClassification != null && unqualifiedGoods.DefectClassification != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTCLASSIFICATION, unqualifiedGoods.DefectClassification); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 4, codeMaster.Description); } } //"因素" if (unqualifiedGoods.DefectFactor != null && unqualifiedGoods.DefectFactor != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTFACTOR, unqualifiedGoods.DefectFactor); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 5, codeMaster.Description); } } //处理方法 Disposition if (unqualifiedGoods.Disposition != null && unqualifiedGoods.Disposition != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DISPOSITION, unqualifiedGoods.Disposition); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 6, codeMaster.Description); //inspectOrderDetail.Disposition } } //起末库位 this.SetRowCell(pageIndex, rowIndex, 7, unqualifiedGoods.LocationFrom.Code); //总成零件号 this.SetRowCell(pageIndex, rowIndex, 8, unqualifiedGoods.FinishGoods == null ? string.Empty : unqualifiedGoods.FinishGoods.Code); if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行 { pageIndex++; rowIndex = 0; } else { rowIndex++; } rowTotal++; } this.sheet.DisplayGridlines = false; this.sheet.IsPrintGridlines = false; } catch (Exception) { return false; } return true; }
protected override bool FillValuesImpl(String templateFileName, IList <object> list) { try { if (list == null || list.Count < 2) { return(false); } InspectOrder inspectOrder = (InspectOrder)(list[0]); IList <InspectResult> inspectResultList = (IList <InspectResult>)(list[1]); if (inspectOrder == null || inspectResultList == null || inspectResultList.Count == 0) { return(false); } IList <UnqualifiedGoodsView> unqualifiedGoodsList = new List <UnqualifiedGoodsView>(); foreach (InspectResult inspectResult in inspectResultList) { if (!inspectResult.IsPrinted) { inspectResult.PrintNo = inspectOrder.InspectNo; inspectResult.IsPrinted = true; } inspectResult.LastModifyDate = DateTime.Now; inspectResult.LastModifyUser = inspectOrder.CreateUser; inspectResult.PrintCount += 1; inspectResultMgr.UpdateInspectResult(inspectResult); UnqualifiedGoodsView ufg = new UnqualifiedGoodsView(); ufg.Item = inspectResult.InspectOrderDetail.LocationLotDetail.Item; ufg.RejectedQty = inspectResult.RejectedQty.HasValue ? inspectResult.RejectedQty.Value : 0; ufg.DefectClassification = inspectResult.InspectOrderDetail.DefectClassification; ufg.DefectFactor = inspectResult.InspectOrderDetail.DefectFactor; ufg.Disposition = inspectResult.InspectOrderDetail.Disposition; ufg.FinishGoods = inspectResult.InspectOrderDetail.FinishGoods; ufg.LocationFrom = inspectResult.InspectOrderDetail.LocationFrom; bool isExist = false; foreach (UnqualifiedGoodsView unq in unqualifiedGoodsList) { if (unq.Item.Code == ufg.Item.Code && unq.LocationFrom.Code == ufg.LocationFrom.Code) //&& unq.DefectClassification == ufg.DefectClassification //&& unq.DefectFactor == ufg.DefectFactor //&& unq.Disposition == ufg.Disposition //&& ((unq.FinishGoods == null && unq.FinishGoods == null) || (unq.FinishGoods != null && unq.FinishGoods != null && //unq.FinishGoods.Code == ufg.FinishGoods.Code))) { isExist = true; } if (isExist) { unq.RejectedQty += ufg.RejectedQty; break; } } if (!isExist) { unqualifiedGoodsList.Add(ufg); } } this.CopyPage(inspectResultList.Count); this.FillHead(inspectOrder); int pageIndex = 1; int rowIndex = 0; int rowTotal = 0; foreach (UnqualifiedGoodsView unqualifiedGoods in unqualifiedGoodsList) { //零件名称 Part Name this.SetRowCell(pageIndex, rowIndex, 0, unqualifiedGoods.Item.Description); //"零件号Part No." this.SetRowCell(pageIndex, rowIndex, 1, unqualifiedGoods.Item.Code); //工位号 Sta. No. this.SetRowCell(pageIndex, rowIndex, 2, string.Empty); //"数量 QTY." this.SetRowCell(pageIndex, rowIndex, 3, unqualifiedGoods.RejectedQty.ToString("0.########")); //"缺陷 Defect" if (unqualifiedGoods.DefectClassification != null && unqualifiedGoods.DefectClassification != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTCLASSIFICATION, unqualifiedGoods.DefectClassification); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 4, codeMaster.Description); } } //"因素" if (unqualifiedGoods.DefectFactor != null && unqualifiedGoods.DefectFactor != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTFACTOR, unqualifiedGoods.DefectFactor); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 5, codeMaster.Description); } } //处理方法 Disposition if (unqualifiedGoods.Disposition != null && unqualifiedGoods.Disposition != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DISPOSITION, unqualifiedGoods.Disposition); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 6, codeMaster.Description); //inspectOrderDetail.Disposition } } //起末库位 this.SetRowCell(pageIndex, rowIndex, 7, unqualifiedGoods.LocationFrom.Code); //总成零件号 this.SetRowCell(pageIndex, rowIndex, 8, unqualifiedGoods.FinishGoods == null ? string.Empty : unqualifiedGoods.FinishGoods.Code); if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行 { pageIndex++; rowIndex = 0; } else { rowIndex++; } rowTotal++; } this.sheet.DisplayGridlines = false; this.sheet.IsPrintGridlines = false; } catch (Exception) { return(false); } return(true); }