public string _GetLoadView(string dateIndexTo, string dateIndex, DateTime planVersion, string item, CodeMaster.TimeUnit dateType) { IList<object> param = new List<object>(); string hql = " from RccpMiPlan as r where r.PlanVersion=? and DateType=?"; param.Add(planVersion); param.Add(dateType); if (!string.IsNullOrEmpty(dateIndex)) { hql += " and r.DateIndex>=? "; param.Add(dateIndex); } if (!string.IsNullOrEmpty(dateIndexTo)) { hql += " and r.DateIndex<=? "; param.Add(dateIndexTo); } if (!string.IsNullOrEmpty(item)) { hql += " and r.Item=? "; param.Add(item); } IList<RccpMiPlan> rccpMiPlanList = genericMgr.FindAll<RccpMiPlan>(hql, param.ToArray()); if (rccpMiPlanList.Count == 0) { return Resources.EXT.ControllerLan.Con_NoRecord; } return GetStringRccpMiPlanView(rccpMiPlanList); }
public string _GetList(DateTime? planVersion, CodeMaster.ResourceGroup? resourceGroup, string flow, bool isShowDetail) { if (!resourceGroup.HasValue || !planVersion.HasValue) { return Resources.EXT.ControllerLan.Con_PlanVersionAndResourceGroupCanNotBeEmpty; } return planMgr.GetMrpInvIn(planVersion.Value, resourceGroup.Value, flow, isShowDetail); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { CodeMaster type = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE, e.Row.Cells[6].Text.Trim()); if (type != null) { e.Row.Cells[6].Text = type.Description; } } }
public static DateTime GetEndStartTime(CodeMaster.TimeUnit timePeriodType, DateTime endTime) { if (timePeriodType == CodeMaster.TimeUnit.Hour) { return endTime.Date.AddDays(1).AddHours(-1); } else { return GetStartTime(timePeriodType, endTime); } }
public static DateTime GetEndTime(CodeMaster.TimeUnit timePeriodType, DateTime startTime) { DateTime nextStartTime = startTime; //天结束 if (timePeriodType == CodeMaster.TimeUnit.Hour || timePeriodType == CodeMaster.TimeUnit.Day) { nextStartTime = startTime.Date.AddDays(1); } //周结束 else if (timePeriodType == CodeMaster.TimeUnit.Week) { nextStartTime = GetStartTime(timePeriodType, startTime).AddDays(7); } //月结束 else if (timePeriodType == CodeMaster.TimeUnit.Month) { nextStartTime = GetStartTime(timePeriodType, startTime).AddMonths(1); } //季结束 else if (timePeriodType == CodeMaster.TimeUnit.Quarter) { int month = startTime.Date.Month; if (month < 4) { nextStartTime = new DateTime(startTime.Date.Year, 3, 1); } else if (month < 7) { nextStartTime = new DateTime(startTime.Date.Year, 6, 1); } else if (month < 10) { nextStartTime = new DateTime(startTime.Date.Year, 9, 1); } else { nextStartTime = new DateTime(startTime.Date.Year, 12, 1); } nextStartTime = nextStartTime.AddMonths(1); } else if (timePeriodType == CodeMaster.TimeUnit.Year) { nextStartTime = GetStartTime(timePeriodType, startTime).AddYears(1); } DateTime time = nextStartTime.AddMilliseconds(-1); return time; }
public static DateTime GetStartTime(CodeMaster.TimeUnit timePeriodType, DateTime startTime) { DateTime time = startTime; //天起始 if (timePeriodType == CodeMaster.TimeUnit.Day || timePeriodType == CodeMaster.TimeUnit.Hour) { time = startTime.Date; } //周起始 else if (timePeriodType == CodeMaster.TimeUnit.Week) { int dayOfWeek = (int)(startTime.AddDays(-_weekStartDay).DayOfWeek); time = startTime.Date.AddDays(-(double)dayOfWeek); } //月起始 else if (timePeriodType == CodeMaster.TimeUnit.Month) { time = new DateTime(startTime.Date.Year, startTime.Date.Month, 1); } //季起始 else if (timePeriodType == CodeMaster.TimeUnit.Quarter) { int month = startTime.Date.Month; if (month < 4) { time = new DateTime(startTime.Date.Year, 1, 1); } else if (month < 7) { time = new DateTime(startTime.Date.Year, 4, 1); } else if (month < 10) { time = new DateTime(startTime.Date.Year, 7, 1); } else { time = new DateTime(startTime.Date.Year, 10, 1); } } //年起始 else if (timePeriodType == CodeMaster.TimeUnit.Year) { time = new DateTime(startTime.Date.Year, 1, 1); } return time; }
protected void Page_Load(object sender, EventArgs e) { IList<CodeMaster> listCodeMaster = TheCodeMasterMgr.GetAllCodeMaster(); List<CodeMaster> listTemp = new List<CodeMaster>(); CodeMaster temp = new CodeMaster(); foreach (CodeMaster codeMaster in listCodeMaster) { if (temp.Code != codeMaster.Code) { listTemp.Add(codeMaster); } temp = codeMaster; } this.ddlCode.DataSource = listTemp; this.ddlCode.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { IList <CodeMaster> listCodeMaster = TheCodeMasterMgr.GetAllCodeMaster(); List <CodeMaster> listTemp = new List <CodeMaster>(); CodeMaster temp = new CodeMaster(); foreach (CodeMaster codeMaster in listCodeMaster) { if (temp.Code != codeMaster.Code) { listTemp.Add(codeMaster); } temp = codeMaster; } this.ddlCode.DataSource = listTemp; this.ddlCode.DataBind(); }
protected virtual ProjectInvoiceStatus GetProjectInvoiceStatusFromReader(IDataReader reader) { EntityConverter <ProjectInvoiceStatus> projectInvoiceStatusEntity = new EntityConverter <ProjectInvoiceStatus>(); EntityConverter <InvoiceType> invoiceTypeEntity = new EntityConverter <InvoiceType>(); EntityConverter <CodeMaster> codemasterEntity = new EntityConverter <CodeMaster>(); ProjectInvoiceStatus projectInvoiceStatus = projectInvoiceStatusEntity.Convert(reader); InvoiceType invoiceType = new InvoiceType(); CodeMaster codemaster = new CodeMaster(); codemaster = codemasterEntity.Convert(reader); invoiceType = invoiceTypeEntity.Convert(reader); projectInvoiceStatus.InvoiceType1 = invoiceType; projectInvoiceStatus.codeMaster = codemaster; return(projectInvoiceStatus); }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string week = e.Row.Cells[3].Text; switch (week) { case "Monday": e.Row.Cells[3].Text = "${Common.Week.Monday}"; break; case "Tuesday": e.Row.Cells[3].Text = "${Common.Week.Tuesday}"; break; case "Wednesday": e.Row.Cells[3].Text = "${Common.Week.Wednesday}"; break; case "Thursday": e.Row.Cells[3].Text = "${Common.Week.Thursday}"; break; case "Friday": e.Row.Cells[3].Text = "${Common.Week.Friday}"; break; case "Saturday": e.Row.Cells[3].Text = "${Common.Week.Saturday}"; break; case "Sunday": e.Row.Cells[3].Text = "${Common.Week.Sunday}"; break; default: break; } CodeMaster type = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE, e.Row.Cells[4].Text.Trim()); if (type != null) { e.Row.Cells[4].Text = type.Description; } } }
public void RunRccp(CodeMaster.TimeUnit dateType) { User user = SecurityContextHolder.Get(); DateTime planVersion = DateTime.Now; var snapTime = this.genericMgr.FindAll<MrpSnapMaster> (@"from MrpSnapMaster m where m.IsRelease =? and m.Type=? order by m.SnapTime desc", new object[] { true, CodeMaster.SnapType.Rccp }, 0, 1).First().SnapTime; string dateIndex = string.Empty; if(dateType == CodeMaster.TimeUnit.Week) { dateIndex = Utility.DateTimeHelper.GetWeekOfYear(planVersion); } else if(dateType == CodeMaster.TimeUnit.Month) { dateIndex = planVersion.ToString("yyyy-MM"); } RunRccp(planVersion, snapTime, dateType, dateIndex, user); }
protected virtual void PreRenderText() { if (this.ServicePath == null || this.ServicePath == string.Empty) { this.ServicePath = "com.Sconit.Web.CodeMasterMgrProxy"; } if (this.ServiceMethod == null || this.ServiceMethod == string.Empty) { this.ServiceMethod = "GetCachedCodeMaster"; } if (this.Code == null || this.Code == string.Empty) { throw new TechnicalException("Code not specified."); } //if (this.Value == null || this.Value == string.Empty) //{ // //throw new TechnicalException("Value not specified."); // return; //} string serviceParameters = "string:" + this.Code + ",string:" + this.Value; try { CodeMaster codeMaster = ReflectHelper.InvokeServiceMethod(this.ServicePath, this.ServiceMethod, serviceParameters) as CodeMaster; if (codeMaster != null) { //this.Text = codeMaster.Value + " [" + codeMaster.Description + "]"; this.Text = codeMaster.Description; } } catch { } }
protected void GV_List_Detail_RowDataBound(object sender, GridViewRowEventArgs e) { if (this.isExport) { if (e.Row.RowType == DataControlRowType.DataRow) { com.Sconit.Control.CodeMstrLabel lblDefectClassification = ((com.Sconit.Control.CodeMstrLabel)e.Row.FindControl("lblDefectClassification")); com.Sconit.Control.CodeMstrLabel lblDisposition = ((com.Sconit.Control.CodeMstrLabel)e.Row.FindControl("lblDisposition")); com.Sconit.Control.CodeMstrLabel lblDefectFactor = ((com.Sconit.Control.CodeMstrLabel)e.Row.FindControl("lblDefectFactor")); if (lblDefectClassification.Value != string.Empty) { CodeMaster cmDefectClassification = TheCodeMasterMgr.LoadCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTCLASSIFICATION, lblDefectClassification.Value); if (cmDefectClassification != null) { lblDefectClassification.Text = cmDefectClassification.Description; } } if (lblDisposition.Value != string.Empty) { CodeMaster cmDisposition = TheCodeMasterMgr.LoadCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DISPOSITION, lblDisposition.Value); if (cmDisposition != null) { lblDisposition.Text = cmDisposition.Description; } } if (lblDefectFactor.Value != string.Empty) { CodeMaster cmlblDefectFactor = TheCodeMasterMgr.LoadCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTFACTOR, lblDefectFactor.Value); if (cmlblDefectFactor != null) { lblDefectFactor.Text = cmlblDefectFactor.Description; } } } } }
public string GetRandomTheme(string themeType) { IList <CodeMaster> iListCodeMaster = GetCachedCodeMaster(themeType); if (iListCodeMaster.Count != 0) { Random random = new Random(); int i = 0; int r = random.Next(0, iListCodeMaster.Count - 1); CodeMaster codeMaster = (CodeMaster)iListCodeMaster[r]; while (codeMaster.Value == "Random" && (i < 100)) { r = random.Next(0, iListCodeMaster.Count - 1); codeMaster = (CodeMaster)iListCodeMaster[r]; i++; } return(codeMaster.Value); } else { return(null); } }
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); }
public static DateTime GetNextStartTime(CodeMaster.TimeUnit timePeriodType, DateTime startTime) { DateTime nextStartTime = startTime; //下一天 if (timePeriodType == CodeMaster.TimeUnit.Day) { nextStartTime = startTime.Date.AddDays(1); } //下一周 else if (timePeriodType == CodeMaster.TimeUnit.Week) { nextStartTime = GetStartTime(timePeriodType, startTime).AddDays(7); } //下一月 else if (timePeriodType == CodeMaster.TimeUnit.Month) { nextStartTime = GetStartTime(timePeriodType, startTime).AddMonths(1); } //下一季 else if (timePeriodType == CodeMaster.TimeUnit.Quarter) { int month = startTime.Date.Month; if (month < 4) { nextStartTime = new DateTime(startTime.Date.Year, 3, 1); } else if (month < 7) { nextStartTime = new DateTime(startTime.Date.Year, 6, 1); } else if (month < 10) { nextStartTime = new DateTime(startTime.Date.Year, 9, 1); } else { nextStartTime = new DateTime(startTime.Date.Year, 12, 1); } nextStartTime = nextStartTime.AddMonths(1); } //下一年 else if (timePeriodType == CodeMaster.TimeUnit.Year) { nextStartTime = GetStartTime(timePeriodType, startTime).AddYears(1); } //下一小时 else if (timePeriodType == CodeMaster.TimeUnit.Hour) { nextStartTime = startTime.AddHours(1); } return nextStartTime; }
public static bool CompareDateTime(DateTime dateTime1, DateTime dateTime2, CodeMaster.TimeUnit periodType) { dateTime1 = GetStartTime(periodType, dateTime1); dateTime2 = GetStartTime(periodType, dateTime2); if (dateTime1 == dateTime2) { return true; } return false; }
public ActionResult Export(DateTime? planVersion, CodeMaster.ResourceGroup? resourceGroup, string flow ) { var table = _GetList(planVersion, resourceGroup, flow, true); return new DownloadFileActionResult(table, "InvInPlan.xls"); }
public RejectMaster CreateRejectMaster(CodeMaster.HandleResult rejectHandleResult, IList<InspectResult> inspectResultList, DateTime effectiveDate) { #region 检查 if (inspectResultList == null) { throw new BusinessException("不合格品处理结果不能为空。"); } IList<InspectResult> noneZeroInspectResultList = inspectResultList.Where(i => i.CurrentHandleQty > 0).ToList(); if (noneZeroInspectResultList == null || noneZeroInspectResultList.Count == 0) { throw new BusinessException("不合格品处理结果不能为空。"); } foreach (InspectResult inspectResult in noneZeroInspectResultList) { if (inspectResult.JudgeQty < (inspectResult.HandleQty + inspectResult.CurrentHandleQty)) { throw new BusinessException("不合格品的处理数超过了判定数。"); } } #region 检查不合格品处理是否在同一个区域中 #region 查询Location string hql = string.Empty; IList<object> paras = new List<object>(); foreach (string locationCode in noneZeroInspectResultList.Select(i => i.CurrentLocation).Distinct()) { if (hql == string.Empty) { hql = "from Location where Code in (?"; } else { hql += ", ?"; } paras.Add(locationCode); } hql += ")"; IList<Location> locationList = this.genericMgr.FindAll<Location>(hql, paras.ToArray()); #endregion IList<string> regionList = locationList.Select(l => l.Region).Distinct().ToList(); if (regionList != null && regionList.Count > 1) { throw new BusinessException("不合格品的库位属于不同区域不能合并处理。"); } string region = regionList.Single(); #endregion #endregion #region 生成不合格品处理单 #region 生成不合格品处理单头 RejectMaster rejectMaster = new RejectMaster(); rejectMaster.Status = CodeMaster.RejectStatus.Create; rejectMaster.Region = region; rejectMaster.HandleResult = rejectHandleResult; rejectMaster.RejectNo = this.numberControlMgr.GetRejectNo(rejectMaster); //條碼還是數量 rejectMaster.InspectType = noneZeroInspectResultList.Where(r => r.HuId != null).Count() > 0 ? com.Sconit.CodeMaster.InspectType.Barcode : com.Sconit.CodeMaster.InspectType.Quantity; this.genericMgr.Create(rejectMaster); #endregion #region 生成不合格品处理单明细 int seq = 1; foreach (InspectResult inspectResult in noneZeroInspectResultList) { RejectDetail rejectDetail = Mapper.Map<InspectResult, RejectDetail>(inspectResult); rejectDetail.Sequence = seq++; rejectDetail.HandleQty = inspectResult.CurrentHandleQty; rejectDetail.HandledQty = 0; rejectDetail.FailCode = inspectResult.FailCode; rejectDetail.RejectNo = rejectMaster.RejectNo; rejectDetail.ManufactureParty = inspectResult.ManufactureParty; rejectMaster.AddRejectDetail(rejectDetail); this.genericMgr.Create(rejectDetail); } #endregion #endregion #region 更新判定结果 foreach (InspectResult inspectResult in noneZeroInspectResultList) { inspectResult.HandleQty += inspectResult.CurrentHandleQty; if (inspectResult.HandleQty == inspectResult.JudgeQty) { inspectResult.IsHandle = true; } this.genericMgr.Update(inspectResult); } #endregion return rejectMaster; }
public IList<ActingBill> GetRecalculatePrice(CodeMaster.BillType billType, string party, string flow, string receiptNo, string externalReceiptNo, string item, string currency, DateTime startDate, DateTime endDate, bool includeNoEstPrice) { string hql = @"select a from ActingBill as a where Type = ? and EffectiveDate >= ? and EffectiveDate <= ? and IsClose=? "; List<object> para = new List<object>(); para.Add(billType); para.Add(startDate.Date); para.Add(endDate.Date); para.Add(false); if (!includeNoEstPrice) { hql += " and (exists (select 1 from PlanBill as p where p.Id=a.PlanBill and p.IsProvisionalEstimate=?))"; para.Add(true); } if (!string.IsNullOrWhiteSpace(party)) { hql += " and Party = ?"; para.Add(party); } if (!string.IsNullOrWhiteSpace(flow)) { hql += " and Flow = ?"; para.Add(flow); } if (!string.IsNullOrWhiteSpace(receiptNo)) { hql += " and ReceiptNo = ?"; para.Add(receiptNo); } if (!string.IsNullOrWhiteSpace(externalReceiptNo)) { hql += " and ExternalReceiptNo = ?"; para.Add(externalReceiptNo); } if (!string.IsNullOrWhiteSpace(item)) { hql += " and Item = ?"; para.Add(item); } if (!string.IsNullOrWhiteSpace(currency)) { hql += " and Currency = ?"; para.Add(currency); } var actingBillList = this.genericMgr.FindAll<ActingBill>(hql, para.ToArray()); var newActingBillList = new List<ActingBill>(); if (actingBillList != null && actingBillList.Count > 0) { foreach (ActingBill actingBill in actingBillList) { PriceListDetail priceListDetail = this.itemMgr.GetItemPrice (actingBill.Item, actingBill.Uom, actingBill.PriceList, actingBill.Currency, actingBill.EffectiveDate); if (priceListDetail != null &&//正式价不能更新成暂估价 !priceListDetail.IsProvisionalEstimate) { actingBill.IsIncludeTax = false; //待开票明细都是不含税金额 if (actingBill.IsIncludeTax) //如果价格单含税,待开票金额要转为不含税金额 { Tax tax = this.genericMgr.FindById<Tax>(actingBill.Tax); actingBill.CurrentRecalculatePrice = priceListDetail.UnitPrice / (1 + tax.Rate); } else { actingBill.CurrentRecalculatePrice = priceListDetail.UnitPrice; } //if (actingBill.IsProvisionalEstimate != priceListDetail.IsProvisionalEstimate) //{ // actingBill.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate; // this.genericMgr.Update(actingBill); //} newActingBillList.Add(actingBill); } } } return newActingBillList; }
private void GenMiRccp(DateTime planVersion, CodeMaster.TimeUnit dateType, string dateIndex, IList<MrpFlowDetail> mrpFlowDetailList, List<RccpTransGroup> rccpTransGroupList, BusinessException businessException) { var itemDiscontinueList = this.genericMgr.FindAll<ItemDiscontinue>(); var rccpMiPlanList = new List<RccpMiPlan>(); var workCalendars = this.genericMgr.FindAll<WorkCalendar> (@" from WorkCalendar as w where w.DateType =? and w.ResourceGroup=? and w.DateIndex between ? and ? ", new object[] { dateType, CodeMaster.ResourceGroup.MI, dateIndex, rccpTransGroupList.Max(p => p.DateIndex) }); double cleanTime = double.Parse(systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.MiCleanTime)); var miFlowDetailList = mrpFlowDetailList.Where(p => p.ResourceGroup == CodeMaster.ResourceGroup.MI); foreach(var groupRccpTrans in rccpTransGroupList) { DateTime dateFrom = DateTime.Now; if(dateType == CodeMaster.TimeUnit.Week) { dateFrom = Utility.DateTimeHelper.GetWeekIndexDateFrom(groupRccpTrans.DateIndex); } else { dateFrom = DateTime.Parse(groupRccpTrans.DateIndex + "-01"); } var mrpFlowDetail = miFlowDetailList.FirstOrDefault(p => p.ResourceGroup == CodeMaster.ResourceGroup.MI && p.Item == groupRccpTrans.Item && p.StartDate <= dateFrom && p.EndDate > dateFrom); if(mrpFlowDetail != null) { var workCalendar = workCalendars.FirstOrDefault(p => p.DateIndex == groupRccpTrans.DateIndex && p.Flow == mrpFlowDetail.Flow); var miPlan = new RccpMiPlan(); DateTime planDate = DateTime.Now; if(workCalendar != null) { miPlan.HaltTime = workCalendar.HaltTime * 24 * 60; miPlan.TrialProduceTime = workCalendar.TrialTime * 24 * 60; miPlan.Holiday = workCalendar.Holiday * 24 * 60; miPlan.UpTime = workCalendar.UpTime * 24 * 60; if(dateType == CodeMaster.TimeUnit.Month) { planDate = DateTime.Parse(groupRccpTrans.DateIndex + "-01"); //miPlan.UpTime = DateTime.DaysInMonth(planDate.Year, planDate.Month) * 24 * 60 * ((8 * 60 - cleanTime) / (8 * 60)); //miPlan.UpTime = workCalendar.UpTime * 24 * 60; } else if(dateType == CodeMaster.TimeUnit.Week) { planDate = Utility.DateTimeHelper.GetWeekIndexDateFrom(groupRccpTrans.DateIndex); //miPlan.HaltTime = (7 - workCalendar.Holiday) * 24 * 60 * (cleanTime / (8 * 60)); //miPlan.UpTime = (7 - workCalendar.Holiday) * 24 * 60 * ((8 * 60 - cleanTime) / (8 * 60)); } } else { //出错 businessException.AddMessage("没有找到炼胶的工作日历"); } miPlan.ProductLine = mrpFlowDetail.Flow; miPlan.Item = groupRccpTrans.Item; miPlan.DateIndex = groupRccpTrans.DateIndex; miPlan.DateType = dateType; miPlan.PlanVersion = planVersion; miPlan.Qty = groupRccpTrans.Qty; var miItem = this.itemMgr.GetCacheItem(groupRccpTrans.Item); if(miItem == null) { businessException.AddMessage(new Message(CodeMaster.MessageType.Error, string.Format("没有找到此物料{0}的对应的工时", groupRccpTrans.Item))); } else { miPlan.WorkHour = miItem.WorkHour; } miPlan.CheRateQty = mrpFlowDetail.UnitCount; //替代物料 var itemDiscontinues = itemDiscontinueList.Where(p => p.Item == miPlan.Item && p.StartDate <= planDate && (!p.EndDate.HasValue || (p.EndDate.HasValue && p.EndDate.Value > planDate))).OrderBy(p => p.Priority).ToList(); var items = new List<string>(); items.Add(miPlan.Item); items.AddRange(itemDiscontinues.Select(p => p.DiscontinueItem)); //可委外的物料 var flowDetail = mrpFlowDetailList.FirstOrDefault(f => f.Type == CodeMaster.OrderType.SubContract && items.Contains(f.Item)); if(flowDetail != null) { miPlan.SubFlowDetail = flowDetail; } rccpMiPlanList.Add(miPlan); //this.genericMgr.Create(miPlan); } } var groupMiPlans = (from p in rccpMiPlanList group p by new { p.ProductLine, p.DateIndex, p.UpTime } into g select new { ProductLine = g.Key.ProductLine, DateIndex = g.Key.DateIndex, UpTime = g.Key.UpTime, List = g }).OrderBy(p => p.DateIndex).ThenBy(p => p.ProductLine); var purchasePlanList = new List<PurchasePlan>(); foreach(var groupMiPlan in groupMiPlans) { double requireTime = groupMiPlan.List.Sum(p => p.RequireTime); double currentTime = requireTime - groupMiPlan.UpTime; if(currentTime > 0) { DateTime dateFrom = DateTime.Now; if(dateType == CodeMaster.TimeUnit.Week) { dateFrom = Utility.DateTimeHelper.GetWeekIndexDateFrom(groupMiPlan.DateIndex); } else { dateFrom = DateTime.Parse(groupMiPlan.DateIndex + "-01"); } foreach(var plan in groupMiPlan.List) { if(plan.SubFlowDetail != null) { double currentQty = (currentTime / plan.WorkHour) * plan.CheRateQty; double subQty = currentQty > plan.Qty ? plan.Qty : currentQty; currentTime = currentTime - (subQty / plan.CheRateQty) * plan.WorkHour; var purchasePlan = new PurchasePlan(); purchasePlan.Item = plan.Item; //purchasePlan.Sequence = plan.SubFlowDetail.Sequence; purchasePlan.Flow = plan.SubFlowDetail.Flow; purchasePlan.LocationTo = plan.SubFlowDetail.LocationTo; purchasePlan.OrderType = plan.SubFlowDetail.Type; purchasePlan.WindowTime = dateFrom; purchasePlan.StartTime = dateFrom.AddHours(-plan.SubFlowDetail.LeadTime); purchasePlan.Qty = subQty; purchasePlan.PlanQty = subQty; purchasePlan.DateType = dateType; purchasePlan.PlanVersion = planVersion; purchasePlanList.Add(purchasePlan); plan.SubQty = subQty; plan.Qty -= subQty; //auto update } } } } #region Create this.genericMgr.BulkInsert<RccpMiPlan>(rccpMiPlanList); this.genericMgr.BulkInsert<PurchasePlan>(purchasePlanList); #endregion Create }
public virtual void CreateCodeMaster(CodeMaster entity) { Create(entity); }
public virtual void CreateCodeMaster(CodeMaster entity) { entityDao.CreateCodeMaster(entity); }
public virtual void UpdateCodeMaster(CodeMaster entity) { Update(entity); }
public Message(CodeMaster.MessageType messageType, string messageKey, params string[] messageParams) { this.MessageType = messageType; this.messageKey = messageKey; this.messageParams = messageParams; }
private void SwitchModule(CodeMaster.TerminalPermission module) { if (module == CodeMaster.TerminalPermission.M_Switch) { if (this.user != null) { this.ucModuleSelect = new UCModuleSelect(this.user); this.ucModuleSelect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.ucModuleSelect.ModuleSelectExitEvent += new ModuleSelectExitHandler(this.LoadUCLogin); this.AddModule(this.ucModuleSelect); this.Text = "模块选择_Sconit_SD"; } else { this.ucModuleSelect.ModuleSelectExitEvent += new ModuleSelectExitHandler(this.LoadUCLogin); this.LoadUCLogin(); } } else if (module == CodeMaster.TerminalPermission.Client_OrderShip) { UCShip ucShip = new UCShip(this.user);//.GetUCShip(user); ucShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucShip); ucShip.tbBarCode.Focus(); this.Text = "发货"; } else if (module == CodeMaster.TerminalPermission.Client_Receive) { UCReceive ucReceive = new UCReceive(this.user);//.GetUCReceive(this.user); ucReceive.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucReceive); ucReceive.tbBarCode.Focus(); this.Text = "收货"; } else if (module == CodeMaster.TerminalPermission.Client_Transfer) { UCTransfer ucTransfer = new UCTransfer(this.user);//.GetUCTransfer(this.user); ucTransfer.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucTransfer); ucTransfer.tbBarCode.Focus(); this.Text = "移库"; } else if (module == CodeMaster.TerminalPermission.Client_PickList) { UCPickList ucPickList = new UCPickList(this.user); ucPickList.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickList); ucPickList.tbBarCode.Focus(); this.Text = "拣货"; } else if (module == CodeMaster.TerminalPermission.Client_PickListShip) { UCPickListShip UCPickListShip = new UCPickListShip(this.user);//.GetUCPickListShip(this.user); UCPickListShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(UCPickListShip); UCPickListShip.tbBarCode.Focus(); this.Text = "拣货发货"; } else if (module == CodeMaster.TerminalPermission.Client_PutAway) { UCPutAway ucPutAway = new UCPutAway(this.user);//.GetUCPutAway(this.user); ucPutAway.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPutAway); ucPutAway.tbBarCode.Focus(); this.Text = "上架"; } else if (module == CodeMaster.TerminalPermission.Client_Pickup) { var ucPickUp = new UCPickUp(this.user);//.GetUCPickUp(this.user); ucPickUp.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickUp); this.Text = "下架"; } else if (module == CodeMaster.TerminalPermission.Client_AnDon) { UCAnDon ucAnDon = new UCAnDon(this.user);//.GetUCAnDon(this.user); ucAnDon.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); AddModule(ucAnDon); ucAnDon.tbBarCode.Focus(); this.Text = "按灯"; //this.ucDevanning.Height = height; } else if (module == CodeMaster.TerminalPermission.Client_StockTaking) { UCStockTaking ucStockTaking = new UCStockTaking(this.user);//.GetUCStockTaking(this.user); ucStockTaking.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucStockTaking); ucStockTaking.tbBarCode.Focus(); this.Text = "盘点"; } else if (module == CodeMaster.TerminalPermission.Client_MaterialIn) { UCMaterialIn ucMaterialIn = new UCMaterialIn(this.user, false);//.GetUCMaterialIn(this.user, false); ucMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMaterialIn); ucMaterialIn.tbBarCode.Focus(); this.Text = "投料"; } else if (module == CodeMaster.TerminalPermission.Client_ForceMaterialIn) { var ucForceMaterialIn = new UCForceMaterialIn(this.user, false); ucForceMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucForceMaterialIn); ucForceMaterialIn.tbBarCode.Focus(); this.Text = "强制投料"; } else if (module == CodeMaster.TerminalPermission.Client_Qualify) { var ucJudgeInspect = new UCJudgeInspect(this.user); ucJudgeInspect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucJudgeInspect); ucJudgeInspect.tbBarCode.Focus(); this.Text = "合格"; } else if (module == CodeMaster.TerminalPermission.Client_RePack) { var ucRePack = new UCRePack(this.user); ucRePack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucRePack); ucRePack.tbBarCode.Focus(); this.Text = "翻箱"; } else if (module == CodeMaster.TerminalPermission.Client_UnPack) { var ucUnPack = new UCUnPack(this.user); ucUnPack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucUnPack); ucUnPack.tbBarCode.Focus(); this.Text = "拆箱"; } else if (module == CodeMaster.TerminalPermission.Client_Pack) { var ucPack = new UCPack(this.user); ucPack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPack); ucPack.tbBarCode.Focus(); this.Text = "装箱"; } else if (module == CodeMaster.TerminalPermission.Client_Inspect) { var ucInspect = new UCInspect(this.user); ucInspect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucInspect); ucInspect.tbBarCode.Focus(); this.Text = "报验"; } else if (module == CodeMaster.TerminalPermission.Client_WorkerWaste) { var ucWorkerWaste = new UCWorkerWaste(this.user); ucWorkerWaste.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucWorkerWaste); ucWorkerWaste.tbBarCode.Focus(); this.Text = "工废"; } else if (module == CodeMaster.TerminalPermission.Client_PickListOnline) { var ucPickListOnline = new UCPickListOnline(this.user); ucPickListOnline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickListOnline); ucPickListOnline.tbBarCode.Focus(); this.Text = "拣货单上线"; } else if (module == CodeMaster.TerminalPermission.Client_HuStatus) { var ucHuStatus = new UCHuStatus(this.user); ucHuStatus.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucHuStatus); ucHuStatus.tbBarCode.Focus(); this.Text = "条码状态"; } else if (module == CodeMaster.TerminalPermission.Client_ProductionOnline) { UCProductOrderOnline ucProductOrderOnline = new UCProductOrderOnline(this.user);//.GetUCProductOrderOnline(this.user); ucProductOrderOnline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucProductOrderOnline); ucProductOrderOnline.tbBarCode.Focus(); this.Text = "上线"; } else if (module == CodeMaster.TerminalPermission.Client_MiscInOut) { UCMisInOut ucMisInOut = new UCMisInOut(this.user);//.GetUCMisInOut(this.user); ucMisInOut.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMisInOut); ucMisInOut.tbBarCode.Focus(); this.Text = "计划外出入库"; } else if (module == CodeMaster.TerminalPermission.Client_HuClone) { UCHuClone ucHuClone = new UCHuClone(this.user);//.GetUCHuClone(this.user); ucHuClone.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucHuClone); ucHuClone.tbBarCode.Focus(); this.Text = "条码克隆"; } else if (module == CodeMaster.TerminalPermission.Client_MaterialReturn) { UCMaterialIn ucMaterialIn = new UCMaterialIn(this.user, true);//.GetUCMaterialIn(this.user, true); ucMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMaterialIn); ucMaterialIn.tbBarCode.Focus(); this.Text = "退料"; } else if (module == CodeMaster.TerminalPermission.Client_Freeze) { UCFreeze ucFreeze = new UCFreeze(this.user);//.GetUCFreeze(this.user); ucFreeze.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucFreeze); ucFreeze.tbBarCode.Focus(); this.Text = "库存冻结"; } else if (module == CodeMaster.TerminalPermission.Client_UnFreeze) { UCUnFreeze ucUnFreeze = new UCUnFreeze(this.user);//.GetUCUnFreeze(this.user); ucUnFreeze.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucUnFreeze); ucUnFreeze.tbBarCode.Focus(); this.Text = "库存冻结"; } else if (module == CodeMaster.TerminalPermission.Client_QuickReturn) { UCQuickReturn ucQuickReturn = new UCQuickReturn(this.user); ucQuickReturn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucQuickReturn); ucQuickReturn.tbBarCode.Focus(); this.Text = "快速退库"; } else if (module == CodeMaster.TerminalPermission.Client_ProductionOffline) { UCReceiveProdOrder ucReceiptProdOrder = new UCReceiveProdOrder(this.user); ucReceiptProdOrder.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucReceiptProdOrder); ucReceiptProdOrder.tbBarCode.Focus(); this.Text = "生产收货"; } else if (module == CodeMaster.TerminalPermission.Client_FiReceipt) { UCFiReceipt uc = new UCFiReceipt(this.user);//.GetUCFiReceipt(this.user); uc.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(uc); uc.tbBarCode.Focus(); this.Text = "后加工生产入库"; } else if (module == CodeMaster.TerminalPermission.Client_StartAging) { UCHuAging uc = new UCHuAging(this.user, true);//.GetUCHuAging(this.user, true); uc.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(uc); uc.tbBarCode.Focus(); this.Text = "老化开始"; } else if (module == CodeMaster.TerminalPermission.Client_Aging) { UCHuAging uc = new UCHuAging(this.user, false);//.GetUCHuAging(this.user, false); uc.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(uc); uc.tbBarCode.Focus(); this.Text = "老化结束"; } else if (module == CodeMaster.TerminalPermission.Client_Filter) { UCHuFilter uc = new UCHuFilter(this.user);//.GetUCHuFilter(this.user); uc.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(uc); uc.tbBarCode.Focus(); this.Text = "过滤"; } else if (module == CodeMaster.TerminalPermission.Client_SparePartChk) { UCSpChk uc = new UCSpChk(this.user);//.GetUCHuFilter(this.user); uc.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(uc); uc.tbBarCode.Focus(); this.Text = "Check"; } }
private void AsyncRun(DateTime snapTime, Sconit.Entity.ACC.User user, CodeMaster.SnapType snapType) { Async async = new Async(mrpMgr.GenMrpSnapShot); async.BeginInvoke(snapTime, user, false, snapType, null, null); }
public JsonResult _RunMrpSnap(CodeMaster.SnapType snapType) { try { DateTime snapTime = DateTime.Now; AsyncRun(snapTime, this.CurrentUser, snapType); object obj = new { }; SaveSuccessMessage(string.Format(Resources.EXT.ControllerLan.Con_PrepareingDataForPlan, snapTime)); return Json(obj); } catch (Exception ex) { return Json(ex.Message); } }
public PickList CreatePickList(IList <OrderLocationTransaction> orderLocationTransactionList, User user) { List <OrderLocationTransaction> targetOrderLocationTransactionList = new List <OrderLocationTransaction>(); OrderLocationTransactionComparer orderLocationTransactionComparer = new OrderLocationTransactionComparer(); if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0) { foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactionList) { if (orderLocationTransaction.CurrentShipQty > 0) { targetOrderLocationTransactionList.Add(orderLocationTransaction); } } } if (targetOrderLocationTransactionList.Count == 0) { throw new BusinessErrorException("Order.Error.PickUp.DetailEmpty"); } else { //按FromLocation、零件号、单位、单包装排序 targetOrderLocationTransactionList.Sort(orderLocationTransactionComparer); } string orderType = null; Party partyFrom = null; Party partyTo = null; ShipAddress shipFrom = null; ShipAddress shipTo = null; string dockDescription = null; bool? isShipScanHu = null; bool? isReceiptScanHu = null; bool? isAutoReceive = null; decimal? completeLatency = null; string grGapTo = null; string asnTemplate = null; string receiptTemplate = null; string flow = null; DateTime? windowTime = null; bool? isAsnUniqueReceipt = null; #region 判断OrderHead的PartyFrom, PartyTo, ShipFrom, ShipTo, DockDescription是否一致 foreach (OrderLocationTransaction orderLocationTransaction in targetOrderLocationTransactionList) { OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; //判断OrderHead的Type是否一致 if (orderType == null) { orderType = orderHead.Type; } else if (orderHead.Type != orderType) { throw new BusinessErrorException("Order.Error.PickUp.OrderTypeNotEqual"); } //判断OrderHead的PartyFrom是否一致 if (partyFrom == null) { partyFrom = orderHead.PartyFrom; } else if (orderHead.PartyFrom.Code != partyFrom.Code) { throw new BusinessErrorException("Order.Error.PickUp.PartyFromNotEqual"); } //判断OrderHead的PartyFrom是否一致 if (partyTo == null) { partyTo = orderHead.PartyTo; } else if (orderHead.PartyTo.Code != partyTo.Code) { throw new BusinessErrorException("Order.Error.PickUp.PartyToNotEqual"); } //判断OrderHead的ShipFrom是否一致 if (shipFrom == null) { shipFrom = orderHead.ShipFrom; } else if (!AddressHelper.IsAddressEqual(orderHead.ShipFrom, shipFrom)) { throw new BusinessErrorException("Order.Error.PickUp.ShipFromNotEqual"); } //判断OrderHead的ShipTo是否一致 if (shipTo == null) { shipTo = orderHead.ShipTo; } else if (!AddressHelper.IsAddressEqual(orderHead.ShipTo, shipTo)) { throw new BusinessErrorException("Order.Error.PickUp.ShipToNotEqual"); } //判断OrderHead的DockDescription是否一致 if (dockDescription == null) { dockDescription = orderHead.DockDescription; } else if (orderHead.DockDescription != dockDescription) { throw new BusinessErrorException("Order.Error.PickUp.DockDescriptionNotEqual"); } //判断OrderHead的IsShipScanHu是否一致 if (isShipScanHu == null) { isShipScanHu = orderHead.IsShipScanHu; } else if (orderHead.IsShipScanHu != isShipScanHu) { throw new BusinessErrorException("Order.Error.PickUp.IsShipScanHuNotEqual"); } //判断OrderHead的IsReceiptScanHu是否一致 if (isReceiptScanHu == null) { isReceiptScanHu = orderHead.IsReceiptScanHu; } else if (orderHead.IsReceiptScanHu != isReceiptScanHu) { throw new BusinessErrorException("Order.Error.PickUp.IsReceiptScanHuNotEqual"); } //判断OrderHead的IsAutoReceipt是否一致 if (isAutoReceive == null) { isAutoReceive = orderHead.IsAutoReceive; } else if (orderHead.IsAutoReceive != isAutoReceive) { throw new BusinessErrorException("Order.Error.PickUp.IsAutoReceiveNotEqual"); } //判断OrderHead的CompleteLatency是否一致 if (completeLatency == null) { completeLatency = orderHead.CompleteLatency; } else { if (orderHead.CompleteLatency.HasValue && orderHead.CompleteLatency != completeLatency) { throw new BusinessErrorException("Order.Error.PickUp.CompleteLatencyNotEqual"); } } //判断OrderHead的GoodsReceiptGapTo是否一致 if (grGapTo == null) { grGapTo = orderHead.GoodsReceiptGapTo; } else { if (orderHead.GoodsReceiptGapTo != null && orderHead.GoodsReceiptGapTo != grGapTo) { throw new BusinessErrorException("Order.Error.PickUp.GoodsReceiptGapToNotEqual"); } } //判断OrderHead的AsnTemplate是否一致 if (asnTemplate == null) { asnTemplate = orderHead.AsnTemplate; } else { if (orderHead.AsnTemplate != null && orderHead.AsnTemplate != asnTemplate) { throw new BusinessErrorException("Order.Error.PickUp.AsnTemplateNotEqual"); } } //判断OrderHead的ReceiptTemplate是否一致 if (receiptTemplate == null) { receiptTemplate = orderHead.ReceiptTemplate; } else { if (orderHead.ReceiptTemplate != null && orderHead.ReceiptTemplate != receiptTemplate) { throw new BusinessErrorException("Order.Error.PickUp.ReceiptTemplateNotEqual"); } } //判断OrderHead的Flow是否一致 if (flow == null) { flow = orderHead.Flow; } else if (orderHead.Flow != flow) { //throw new BusinessErrorException("Order.Error.PickUp.FlowNotEqual"); } //寻找最小的WindowTime if (!windowTime.HasValue) { windowTime = orderHead.WindowTime; } else if (windowTime.Value > orderHead.WindowTime) { windowTime = orderHead.WindowTime; } //判断OrderHead的IsAsnUniqueReceipt是否一致 if (isAsnUniqueReceipt == null) { isAsnUniqueReceipt = orderHead.IsAsnUniqueReceipt; } else if (orderHead.IsAsnUniqueReceipt != isAsnUniqueReceipt) { throw new BusinessErrorException("Order.Error.PickUp.IsAsnUniqueReceiptNotEqual"); } } #endregion #region 创建捡货单头 DateTime dateTimeNow = DateTime.Now; PickList pickList = new PickList(); pickList.PickListNo = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_PICKLIST); pickList.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT; pickList.PickBy = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PICK_BY).Value; pickList.OrderType = orderType; pickList.PartyFrom = partyFrom; pickList.PartyTo = partyTo; pickList.ShipFrom = shipFrom; pickList.ShipTo = shipTo; pickList.DockDescription = dockDescription; pickList.CreateDate = dateTimeNow; pickList.CreateUser = user; pickList.LastModifyDate = dateTimeNow; pickList.LastModifyUser = user; pickList.IsShipScanHu = isShipScanHu.Value; pickList.IsReceiptScanHu = isReceiptScanHu.Value; pickList.IsAutoReceive = isAutoReceive.Value; pickList.CompleteLatency = completeLatency; pickList.GoodsReceiptGapTo = grGapTo; pickList.AsnTemplate = asnTemplate; pickList.ReceiptTemplate = receiptTemplate; pickList.Flow = flow; pickList.WindowTime = windowTime.Value; pickList.IsAsnUniqueReceipt = isAsnUniqueReceipt.Value; this.CreatePickList(pickList); #endregion #region 创建捡货单明细 int index = 0; IList <LocationLotDetail> locationLotDetailList = null; IList <LocationLotDetail> occupiedLocationLotDetailList = null; //捡货占用库存 for (int i = 0; i < targetOrderLocationTransactionList.Count; i++) { OrderLocationTransaction orderLocationTransaction = targetOrderLocationTransactionList[i]; //本次循环OrderLocationTransaction OrderLocationTransaction lastOrderLocationTransaction = i == 0 ? null : targetOrderLocationTransactionList[i - 1]; //上次OrderLocationTransaction List <PickListDetail> pickListDetailList = new List <PickListDetail>(); //本次生成的PickListDetail列表 OrderDetail orderDetail = orderLocationTransaction.OrderDetail; OrderHead orderHead = orderDetail.OrderHead; decimal shipQty = orderLocationTransaction.CurrentShipQty; //库存单位 #region 过量拣货判断 decimal pickedQty = 0; //其它拣货单的待拣货数量,只考虑Submit和InProcess状态 IList <PickListDetail> pickedPickListDetailList = this.pickListDetailMgr.GetPickedPickListDetail(orderLocationTransaction.Id); if (pickedPickListDetailList != null && pickedPickListDetailList.Count > 0) { foreach (PickListDetail pickListDetail in pickedPickListDetailList) { if (pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT || pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS) { pickedQty += pickListDetail.Qty; } } } //累计发货数量 + 待捡货数量 + 本次拣货数量 不能大于 订单数量 if ((orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0) + shipQty + pickedQty > orderLocationTransaction.OrderedQty) { throw new BusinessErrorException("MasterData.PickList.Error.PickExcceed", orderLocationTransaction.Item.Code); } #endregion //比较本次OrderLocationTransaction和上次OrderLocationTransaction,如果不相同需重新查找locationLotDetailList和重置index //为了处理订单合并捡货时,相同零件推荐的Hu/LotNo不重复问题 if (lastOrderLocationTransaction == null || orderLocationTransactionComparer.Compare(lastOrderLocationTransaction, orderLocationTransaction) == -1) { index = 0; #region 零头发货选项查询待拣货列表 string oddShipOption = orderDetail.OddShipOption; if (oddShipOption == null || oddShipOption.Trim() == string.Empty) { CodeMaster codeMaster = this.codeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION); oddShipOption = codeMaster.Value; } if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_SHIP_FIRST) { //零头优先发、LotnNo先进先出、货架、包装 if (orderHead.IsPickFromBin) { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true, null, null, true); } else { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false, null, null, true); } #region 重新排序,把零头放在前面 if (locationLotDetailList != null && locationLotDetailList.Count > 0) { IList <LocationLotDetail> oddLocationLotDetailList = new List <LocationLotDetail>(); IList <LocationLotDetail> noOddLocationLotDetailList = new List <LocationLotDetail>(); foreach (LocationLotDetail locationLotDetail in locationLotDetailList) { if (!this.locationMgr.IsHuOcuppyByPickList(locationLotDetail.Hu.HuId)) { if (locationLotDetail.Hu.Qty < orderDetail.UnitCount) { oddLocationLotDetailList.Add(locationLotDetail); shipQty += locationLotDetail.Qty; //零头一定要先发走,不占用待拣货数量 } else { noOddLocationLotDetailList.Add(locationLotDetail); } } } locationLotDetailList = oddLocationLotDetailList; IListHelper.AddRange <LocationLotDetail>(locationLotDetailList, noOddLocationLotDetailList); } #endregion } else if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_NOT_SHIP) { //零头不发 if (orderHead.IsPickFromBin) { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true); } else { locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false); } } #endregion IList <PickListDetail> submitPickListDetailList = this.pickListDetailMgr.GetPickListDetail(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }); //IList<PickListResult> inprocessPickListResultList = this.pickListResultMgr.GetPickListResult(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS }); occupiedLocationLotDetailList = this.Convert2OccupiedLocationLotDetail(submitPickListDetailList, pickList.PickBy); } if (locationLotDetailList != null && locationLotDetailList.Count > 0) { PickListDetail lastestPickListDetail = null; for (; index < locationLotDetailList.Count; index++) { LocationLotDetail locationLotDetail = locationLotDetailList[index]; decimal locQty = locationLotDetail.Qty; if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU) { #region Hu捡货 #region 过滤掉已经被推荐的库存 if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0) { bool findMatch = false; foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList) { if (occupiedLocationLotDetail.Hu.HuId == locationLotDetail.Hu.HuId) { findMatch = true; continue; } } if (findMatch) { continue; } } #endregion shipQty -= locQty; PickListDetail pickListDetail = new PickListDetail(); pickListDetail.PickList = pickList; pickListDetail.OrderLocationTransaction = orderLocationTransaction; pickListDetail.Item = orderLocationTransaction.Item; pickListDetail.UnitCount = orderDetail.UnitCount; pickListDetail.Uom = orderDetail.Uom; pickListDetail.HuId = locationLotDetail.Hu.HuId; pickListDetail.LotNo = locationLotDetail.LotNo; pickListDetail.Location = locationLotDetail.Location; if (locationLotDetail.StorageBin != null) { pickListDetail.StorageArea = locationLotDetail.StorageBin.Area; pickListDetail.StorageBin = locationLotDetail.StorageBin; } pickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.CreatePickListDetail(pickListDetail); pickList.AddPickListDetail(pickListDetail); pickListDetailList.Add(pickListDetail); if (shipQty <= 0) { index++; break; } #endregion } else if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { #region LotNo捡货 #region 过滤掉已经被推荐的库存 if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0) { foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList) { if (occupiedLocationLotDetail.Item.Code == locationLotDetail.Item.Code && occupiedLocationLotDetail.LotNo == locationLotDetail.LotNo && occupiedLocationLotDetail.Location.Code == locationLotDetail.Location.Code && StorageBinHelper.IsStorageBinEqual(occupiedLocationLotDetail.StorageBin, locationLotDetail.StorageBin)) { if (locationLotDetail.Hu.Qty < orderDetail.UnitCount) { shipQty -= locationLotDetail.Qty; //如果零头被占用,需要扣减发货数量 } if (occupiedLocationLotDetail.Qty == 0) { continue; } if (occupiedLocationLotDetail.Qty - locQty >= 0) { occupiedLocationLotDetail.Qty -= locQty; locQty = 0; continue; } else { occupiedLocationLotDetail.Qty = 0; locQty -= occupiedLocationLotDetail.Qty; break; } } } if (locQty == 0) { continue; } } #endregion shipQty -= locQty; if (shipQty < 0) { locQty += shipQty; shipQty = 0; } if (lastestPickListDetail != null && lastestPickListDetail.LotNo == locationLotDetail.LotNo && StorageBinHelper.IsStorageBinEqual(lastestPickListDetail.StorageBin, locationLotDetail.StorageBin)) { #region 合并捡货数量 lastestPickListDetail.Qty += locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.UpdatePickListDetail(lastestPickListDetail); #endregion } else { #region 新增捡货明细 lastestPickListDetail = new PickListDetail(); lastestPickListDetail.PickList = pickList; lastestPickListDetail.OrderLocationTransaction = orderLocationTransaction; lastestPickListDetail.Item = orderLocationTransaction.Item; lastestPickListDetail.UnitCount = locationLotDetail.Hu.UnitCount; //可能拣货的包装和订单明细包装不一致,所以使用Hu上的单包装 lastestPickListDetail.Uom = orderDetail.Uom; lastestPickListDetail.LotNo = locationLotDetail.Hu.LotNo; lastestPickListDetail.Location = locationLotDetail.Location; if (locationLotDetail.StorageBin != null) { lastestPickListDetail.StorageArea = locationLotDetail.StorageBin.Area; lastestPickListDetail.StorageBin = locationLotDetail.StorageBin; } lastestPickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位 this.pickListDetailMgr.CreatePickListDetail(lastestPickListDetail); pickList.AddPickListDetail(lastestPickListDetail); pickListDetailList.Add(lastestPickListDetail); #endregion } if (shipQty <= 0) { index++; break; } #endregion } else { throw new TechnicalException("Invalied PickBy value:" + pickList.PickBy); } } } //if (pickListDetailList.Count == 0) //{ // throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory"); //} if (shipQty > 0) { PickListDetail pickListDetail = new PickListDetail(); pickListDetail.PickList = pickList; pickListDetail.OrderLocationTransaction = orderLocationTransaction; pickListDetail.Item = orderLocationTransaction.Item; pickListDetail.UnitCount = orderDetail.UnitCount; pickListDetail.Uom = orderDetail.Uom; pickListDetail.Location = orderLocationTransaction.Location; pickListDetail.Qty = shipQty / orderLocationTransaction.UnitQty; //订单单位 pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", user); //设置Memo为库存不足 pickList.AddPickListDetail(pickListDetail); this.pickListDetailMgr.CreatePickListDetail(pickListDetail); } if (pickListDetailList.Count > 0 && pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO) { string lotNo = string.Empty; bool hasMultiLotNo = false; foreach (PickListDetail pickListDetail in pickListDetailList) { if (lotNo == string.Empty) { lotNo = pickListDetail.LotNo; } else if (lotNo != pickListDetail.LotNo) { hasMultiLotNo = true; break; } } //设置Memo为多批号 if (hasMultiLotNo) { foreach (PickListDetail pickListDetail in pickListDetailList) { if (pickListDetail.Memo == null || pickListDetail.Memo.Trim() == string.Empty) { pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user); } else { pickListDetail.Memo += "; " + this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user); } this.pickListDetailMgr.UpdatePickListDetail(pickListDetail); } } } } #endregion //if (pickList.PickListDetails == null || pickList.PickListDetails.Count == 0) //{ // throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory"); //} return(pickList); }
public virtual void UpdateCodeMaster(CodeMaster entity) { entityDao.UpdateCodeMaster(entity); }
private void GenPurchaseRccp(DateTime planVersion, CodeMaster.TimeUnit dateType, BusinessException businessException, IList<MrpFlowDetail> mrpFlowDetailList, IEnumerable<RccpTransGroup> rccpTransGroupList, DateTime snapTime, User user) { if(businessException.GetMessages().Where(p => p.MessageType == CodeMaster.MessageType.Error).Count() > 0) { //如果有错误,退出,不产生采购物料需求 return; } var flowDetails = mrpFlowDetailList .Where(p => p.Type == CodeMaster.OrderType.Procurement || p.Type == CodeMaster.OrderType.CustomerGoods || p.Type == CodeMaster.OrderType.SubContract || p.Type == CodeMaster.OrderType.ScheduleLine); var purchasePlanList = new List<PurchasePlan>(); var rccpTransGroupByIndexList = (from p in rccpTransGroupList group p by p.DateIndex into g select new { DateIndex = g.Key, List = g }).OrderBy(p => p.DateIndex).ToList(); foreach(var rccpTransGroupByIndex in rccpTransGroupByIndexList) { DateTime windowTime = DateTime.Now; if(dateType == CodeMaster.TimeUnit.Week) { windowTime = DateTimeHelper.GetWeekIndexDateFrom(rccpTransGroupByIndex.DateIndex); } else if(dateType == CodeMaster.TimeUnit.Month) { windowTime = DateTime.Parse(rccpTransGroupByIndex.DateIndex + "-01"); } var mrpFlowDetailDic = flowDetails.Where(p => p.StartDate <= windowTime && p.EndDate > windowTime) .GroupBy(p => p.Item, (k, g) => new { k, g }) .ToDictionary(d => d.k, d => d.g); foreach(var groupRccpTrans in rccpTransGroupByIndex.List) { var mrpFlowDetails = mrpFlowDetailDic.ValueOrDefault(groupRccpTrans.Item); if(mrpFlowDetails != null) { foreach(var mrpFlowDetail in mrpFlowDetails) { var purchasePlan = new PurchasePlan(); purchasePlan.Item = groupRccpTrans.Item; //purchasePlan.Sequence = mrpFlowDetail.Sequence; purchasePlan.Flow = mrpFlowDetail.Flow; purchasePlan.LocationTo = mrpFlowDetail.LocationTo; purchasePlan.OrderType = mrpFlowDetail.Type; purchasePlan.WindowTime = windowTime; var leadDay = Utility.DateTimeHelper.TimeTranfer((decimal)mrpFlowDetail.LeadTime, CodeMaster.TimeUnit.Hour, CodeMaster.TimeUnit.Day); if(dateType == CodeMaster.TimeUnit.Week) { purchasePlan.StartTime = purchasePlan.WindowTime.AddDays(3).AddDays(-leadDay); purchasePlan.StartTime = Utility.DateTimeHelper.GetWeekStart(purchasePlan.StartTime); } else { purchasePlan.StartTime = purchasePlan.WindowTime.AddDays(15).AddDays(-leadDay); purchasePlan.StartTime = Utility.DateTimeHelper.GetStartTime(CodeMaster.TimeUnit.Month, purchasePlan.StartTime); } purchasePlan.Qty = (mrpFlowDetail.MrpWeight / mrpFlowDetails.Sum(p => p.MrpWeight)) * groupRccpTrans.Qty; purchasePlan.PlanQty = purchasePlan.Qty; purchasePlan.DateType = dateType; purchasePlan.PlanVersion = planVersion; purchasePlanList.Add(purchasePlan); } } else { if(groupRccpTrans.IsLastLevel) { businessException.AddMessage(new Message(CodeMaster.MessageType.Warning, "没有找到物料{0}的采购路线", groupRccpTrans.Item)); } } } } string hql = string.Empty; if(dateType == CodeMaster.TimeUnit.Week) { hql = "from FlowStrategy where IsCheckMrpWeeklyPlan =? and Flow in(?"; } else if(dateType == CodeMaster.TimeUnit.Month) { hql = "from FlowStrategy where IsCheckMrpMonthlyPlan =? and Flow in(?"; } var flowStategys = this.genericMgr.FindAllIn<FlowStrategy> (hql, purchasePlanList.Select(p => p.Flow).Where(p => !string.IsNullOrWhiteSpace(p)).Distinct(), new object[] { true }); var flowMasterDic = this.genericMgr.FindAllIn<FlowMaster> ("from FlowMaster where Code in(?", flowStategys.Select(p => p.Flow).Distinct()) .GroupBy(p => p.Code, (k, g) => new { k, g.First().Description }) .ToDictionary(d => d.k, d => d.Description); foreach(var flowStategy in flowStategys) { PurchasePlanMaster purchasePlanMaster = new PurchasePlanMaster(); purchasePlanMaster.DateType = dateType; purchasePlanMaster.Flow = flowStategy.Flow; purchasePlanMaster.FlowDescription = flowMasterDic[flowStategy.Flow]; purchasePlanMaster.PlanVersion = planVersion; purchasePlanMaster.SnapTime = snapTime; purchasePlanMaster.SourcePlanVersion = snapTime; purchasePlanMaster.CreateUserId = user.Id; purchasePlanMaster.CreateUserName = user.FullName; purchasePlanMaster.CreateDate = DateTime.Now; purchasePlanMaster.LastModifyUserId = user.Id; purchasePlanMaster.LastModifyUserName = user.FullName; purchasePlanMaster.LastModifyDate = DateTime.Now; this.genericMgr.Create(purchasePlanMaster); } purchasePlanList = purchasePlanList.Where(p => flowStategys.Select(q => q.Flow).Contains(p.Flow)).ToList(); this.genericMgr.BulkInsert<PurchasePlan>(purchasePlanList); }
public IList<BillIOB> GetBillIOB(CodeMaster.BillType billType, string party, string location, string item, DateTime startDate, DateTime endDate) { //PlanBillTransaction 生成寄售 寄售入 string hqlInStart = @"select p.Party,p.LocationFrom,p.Item,sum(p.BillQty*p.UnitQty) as BillQty , sum(p.BillAmount*p.UnitQty) as BillAmount from PlanBillTransaction p where p.EffectiveDate >= ? and p.EffectiveDate < ? and p.TransactionType in( ? , ? ) and BillTerm>? "; string hqlInEnd = @"select p.Party,p.LocationFrom,p.Item,sum(p.BillQty*p.UnitQty) as BillQty, sum(p.BillAmount*p.UnitQty) as BillAmount from PlanBillTransaction p where (p.EffectiveDate >= ? and p.EffectiveDate>= ?) and p.TransactionType in( ? , ? ) and BillTerm>? "; var paramIn = new List<object>(); paramIn.Add(startDate.Date); paramIn.Add(endDate.Date.AddDays(1)); if (billType == CodeMaster.BillType.Procurement) { paramIn.Add(CodeMaster.BillTransactionType.POPlanBill); paramIn.Add(CodeMaster.BillTransactionType.POPlanBillVoid); } else { paramIn.Add(CodeMaster.BillTransactionType.SOPlanBill); paramIn.Add(CodeMaster.BillTransactionType.SOPlanBillVoid); } paramIn.Add((int)com.Sconit.CodeMaster.OrderBillTerm.AfterInspection); //SettleBillTransaction 结算事务 PlanBill->ActBill string hqlOutStart = @"select p.Party,p.LocationFrom,p.Item,sum(p.BillQty*p.UnitQty) as BillQty , sum(p.BillAmount*p.UnitQty) as BillAmount from SettleBillTransaction p where p.EffectiveDate >= ? and p.EffectiveDate< ? and p.TransactionType in( ? , ? ) and BillTerm>? "; string hqlOutEnd = @"select p.Party,p.LocationFrom,p.Item,sum(p.BillQty*p.UnitQty) as BillQty, sum(p.BillAmount*p.UnitQty) as BillAmount from SettleBillTransaction p where (p.EffectiveDate >= ? and p.EffectiveDate>= ?) and p.TransactionType in( ? , ? ) and BillTerm>? "; var paramOut = new List<object>(); paramOut.Add(startDate.Date); paramOut.Add(endDate.Date.AddDays(1)); if (billType == CodeMaster.BillType.Procurement) { paramOut.Add(CodeMaster.BillTransactionType.POSettle); paramOut.Add(CodeMaster.BillTransactionType.POSettleVoid); } else { paramOut.Add(CodeMaster.BillTransactionType.SOSettle); paramOut.Add(CodeMaster.BillTransactionType.SOSettleVoid); } paramOut.Add((int)com.Sconit.CodeMaster.OrderBillTerm.AfterInspection); //当前寄售 string hqlEnd = @"select p.Party,p.LocationFrom,p.Item, sum((p.PlanQty+p.VoidQty-p.ActingQty)*p.UnitQty) as Qty, sum((p.PlanAmount+p.VoidAmount-p.ActingAmount)*p.UnitQty) as Amount, i.Uom,i.Description,i.ReferenceCode,l.Name,party.Name from PlanBill p,Item i,Location l,Party party where p.Item = i.Code and p.LocationFrom = l.Code and p.Party = party.Code and p.IsClose = ? and Type = ? "; var paramEnd = new List<object>(); paramEnd.Add(false); paramEnd.Add(billType); if (!string.IsNullOrWhiteSpace(party)) { hqlInStart += " and p.Party = ? "; hqlInEnd += " and p.Party = ? "; hqlOutStart += " and p.Party = ? "; hqlOutEnd += " and p.Party = ? "; hqlEnd += " and p.Party = ? "; paramIn.Add(party); paramOut.Add(party); paramEnd.Add(party); } if (!string.IsNullOrWhiteSpace(location)) { hqlInStart += " and p.LocationFrom = ? "; hqlInEnd += " and p.LocationFrom = ? "; hqlOutStart += " and p.LocationFrom = ? "; hqlOutEnd += " and p.LocationFrom = ? "; hqlEnd += " and p.LocationFrom = ? "; paramIn.Add(location); paramOut.Add(location); paramEnd.Add(location); } if (!string.IsNullOrWhiteSpace(item)) { hqlInStart += " and p.Item = ? "; hqlInEnd += " and p.Item = ? "; hqlOutStart += " and p.Item = ? "; hqlOutEnd += " and p.Item = ? "; hqlEnd += " and p.Item = ? "; paramIn.Add(item); paramOut.Add(item); paramEnd.Add(item); } hqlInStart += " group by p.Party,p.LocationFrom,p.Item "; hqlInEnd += " group by p.Party,p.LocationFrom,p.Item "; hqlOutStart += " group by p.Party,p.LocationFrom,p.Item "; hqlOutEnd += " group by p.Party,p.LocationFrom,p.Item "; hqlEnd += " group by p.Party,p.LocationFrom,p.Item,i.Uom,i.Description,i.ReferenceCode,l.Name,party.Name "; //In IList<object[]> billInStartList = this.genericMgr.FindAll<object[]>(hqlInStart, paramIn.ToArray()); IList<object[]> billInEndList = this.genericMgr.FindAll<object[]>(hqlInEnd, paramIn.ToArray()); //Out IList<object[]> billOutStartList = this.genericMgr.FindAll<object[]>(hqlOutStart, paramOut.ToArray()); IList<object[]> billOutEndList = this.genericMgr.FindAll<object[]>(hqlOutEnd, paramOut.ToArray()); //End IList<object[]> billEndList = this.genericMgr.FindAll<object[]>(hqlEnd, paramEnd.ToArray()); IList<BillIOB> billIOBList = new List<BillIOB>(); //期末寄售 foreach (object[] billEnd in billEndList) { BillIOB billIOB = new BillIOB(); billIOB.Party = (string)billEnd[0]; billIOB.Location = (string)billEnd[1]; billIOB.Item = (string)billEnd[2]; //当前数量 billIOB.EndQty = (decimal)billEnd[3]; billIOB.EndAmount = (decimal)billEnd[4]; billIOB.Uom = (string)billEnd[5]; billIOB.ItemDescription = (string)billEnd[6] + (string.IsNullOrWhiteSpace((string)billEnd[7]) ? string.Empty : "[" + (string)billEnd[7] + "]"); billIOB.LocationName = (string)billEnd[8]; billIOB.PartyName = (string)billEnd[9]; //寄售入 //推算出期末数:减去入 foreach (var billIn in billInEndList) { if (billIOB.Party == (string)billIn[0] && billIOB.Location == (string)billIn[1] && billIOB.Item == (string)billIn[2]) { billIOB.EndQty -= (decimal)billIn[3]; billIOB.EndAmount -= (decimal)billIn[4]; break; } } //记录入数 foreach (var billIn in billInStartList) { if (billIOB.Party == (string)billIn[0] && billIOB.Location == (string)billIn[1] && billIOB.Item == (string)billIn[2]) { billIOB.InQty = (decimal)billIn[3]; billIOB.InAmount = (decimal)billIn[4]; break; } } //寄售出 //推算出期末数:加上出 foreach (var billOut in billOutEndList) { if (billIOB.Party == (string)billOut[0] && billIOB.Location == (string)billOut[1] && billIOB.Item == (string)billOut[2]) { billIOB.EndQty += (decimal)billOut[3]; billIOB.EndAmount += (decimal)billOut[4]; break; } } //记录出数 foreach (var billOut in billOutStartList) { if (billIOB.Party == (string)billOut[0] && billIOB.Location == (string)billOut[1] && billIOB.Item == (string)billOut[2]) { billIOB.OutQty = (decimal)billOut[3]; billIOB.OutAmount = (decimal)billOut[4]; break; } } //计算出期初数 billIOB.StartQty = billIOB.EndQty + billIOB.OutQty - billIOB.InQty; billIOB.StartAmount = billIOB.EndAmount + billIOB.OutAmount - billIOB.InAmount; billIOBList.Add(billIOB); } //期末无,有出 foreach (var billOut in billOutStartList) { var billIOB = billIOBList.FirstOrDefault(p => p.Party == (string)billOut[0] && p.Location == (string)billOut[1] && p.Item == (string)billOut[2]); if (billIOB == null) { BillIOB newBillIOB = new BillIOB(); newBillIOB.Party = (string)billOut[0]; newBillIOB.Location = (string)billOut[1]; newBillIOB.Item = (string)billOut[2]; newBillIOB.InQty = (decimal)billOut[3]; newBillIOB.InAmount = (decimal)billOut[4]; newBillIOB.StartQty = -newBillIOB.InQty; newBillIOB.StartAmount = -newBillIOB.InAmount; var _item = this.genericMgr.FindById<Item>(newBillIOB.Item); newBillIOB.ItemDescription = _item.FullDescription; newBillIOB.Uom = _item.Uom; newBillIOB.LocationName = this.genericMgr.FindById<Location>(newBillIOB.Location).Name; newBillIOB.PartyName = this.genericMgr.FindById<Party>(newBillIOB.Item).Name; billIOBList.Add(newBillIOB); } } return billIOBList; }
public void RunRccp(DateTime planVersion, DateTime snapTime, CodeMaster.TimeUnit dateType, string dateIndex, User user) { lock(RunRccpLock) { planVersion = DateTime.Parse(planVersion.ToString("yyyy-MM-dd HH:mm:ss")); SecurityContextHolder.Set(user); log.Info(string.Format("---**------ SnapTime:{0} PlanVersion:{1} - 开始执行预测计划 ---", snapTime, planVersion)); BusinessException businessException = new BusinessException(); int rccpPlanVersion = 0; try { #region 获取RccpPlan log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始获取RccpPlan ---", snapTime, planVersion)); var rccpPlans = this.genericMgr.FindAll<RccpPlan> (@"from RccpPlan as m where m.DateIndex >= ? and DateType=? ", new object[] { dateIndex, dateType }); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束获取RccpPlan ---", snapTime, planVersion)); rccpPlanVersion = rccpPlans.Max(p => p.PlanVersion); #endregion #region 获取路线 log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始获取路线 ---", snapTime, planVersion)); var mrpFlowDetailList = this.genericMgr.FindAll<MrpFlowDetail> (@"from MrpFlowDetail as m where m.SnapTime = ?", new object[] { snapTime }); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束获取路线 ---", snapTime, planVersion)); #endregion #region 分解BOM log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始分解Bom ---", snapTime, planVersion)); var rccpTransList = GetRccpTrans(planVersion, rccpPlans, businessException); var rccpTransGroupList = (from r in rccpTransList group r by new { Item = r.Item, DateIndex = r.DateIndex, IsLastLevel = r.IsLastLevel, DateType = r.DateType } into g select new RccpTransGroup { PlanVersion = planVersion, DateType = g.Key.DateType, Item = g.Key.Item, DateIndex = g.Key.DateIndex, IsLastLevel = g.Key.IsLastLevel, Qty = g.Sum(r => r.Qty), ScrapPercentage = g.Sum(s => s.Qty) > 0 ? g.Sum(r => r.ScrapPercentage * (r.Qty / g.Sum(s => s.Qty))) : 0 }).ToList(); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束分解Bom ---", snapTime, planVersion)); #endregion #region 后加工 log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始执行后加工计划 ---", snapTime, planVersion)); GenFiRccp(planVersion, dateType, mrpFlowDetailList, rccpTransList, businessException); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束执行后加工计划 ---", snapTime, planVersion)); #endregion 后加工 #region 炼胶 委外 log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始执行炼胶计划 ---", snapTime, planVersion)); GenMiRccp(planVersion, dateType, dateIndex, mrpFlowDetailList, rccpTransGroupList, businessException); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束执行炼胶计划 ---", snapTime, planVersion)); #endregion 炼胶 #region 采购/委外等 log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始执行采购/委外计划 ---", snapTime, planVersion)); GenPurchaseRccp(planVersion, dateType, businessException, mrpFlowDetailList, rccpTransGroupList, snapTime, user); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束执行采购/委外计划 ---", snapTime, planVersion)); #endregion 采购/委外等 #region Create RccpTransGroup log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 开始记录RccpTrans/Group ---", snapTime, planVersion)); this.genericMgr.BulkInsert<RccpTransGroup>(rccpTransGroupList); log.Info(string.Format("--- SnapTime:{0} PlanVersion:{1} - 结束记录RccpTrans/Group ---", snapTime, planVersion)); #endregion } catch(Exception ex) { businessException.AddMessage(new Message(CodeMaster.MessageType.Error, ex.StackTrace)); log.Error(ex); } List<RccpLog> rccpLogs = new List<RccpLog>(); CodeMaster.MessageType status = CodeMaster.MessageType.Info; if(businessException.HasMessage) { var messages = businessException.GetMessages().GroupBy(p => new { Message = p.GetMessageString(), MessageType = p.MessageType }, (k, g) => new { k.Message, k.MessageType }); foreach(var message in messages) { RccpLog rccpLog = new RccpLog(); rccpLog.ErrorLevel = message.MessageType.ToString(); rccpLog.Message = message.Message; rccpLog.Logger = "RunRccp"; rccpLog.PlanVersion = planVersion; rccpLogs.Add(rccpLog); //this.genericMgr.Create(rccpLog); if(message.MessageType == CodeMaster.MessageType.Warning) { log.Warn(rccpLog.Message); } else if(message.MessageType == CodeMaster.MessageType.Error) { log.Error(rccpLog.Message); } else { log.Info(rccpLog.Message); } } if(messages.Count(f => f.MessageType == CodeMaster.MessageType.Error) > 0) { status = CodeMaster.MessageType.Error; } else if(messages.Count(f => f.MessageType == CodeMaster.MessageType.Warning) > 0) { status = CodeMaster.MessageType.Warning; } } #region 记录RccpPlanMaster RccpPlanMaster rccpPlanMaster = new RccpPlanMaster(); rccpPlanMaster.DateType = dateType; rccpPlanMaster.SnapTime = snapTime; rccpPlanMaster.PlanVersion = planVersion; rccpPlanMaster.Status = status; rccpPlanMaster.RccpPlanVersion = rccpPlanVersion; rccpPlanMaster.CreateUserId = user.Id; rccpPlanMaster.CreateUserName = user.FullName; rccpPlanMaster.CreateDate = DateTime.Now; rccpPlanMaster.LastModifyUserId = user.Id; rccpPlanMaster.LastModifyUserName = user.FullName; rccpPlanMaster.LastModifyDate = DateTime.Now; this.genericMgr.Create(rccpPlanMaster); #endregion double timetick = 1001 - (rccpPlanMaster.CreateDate - planVersion).TotalMilliseconds; timetick = timetick > 0 ? timetick : 0; Thread.Sleep((int)timetick); string infoMessage = string.Format("完成预测计划时间:{0},时间总计:{1}秒", DateTime.Now.ToLocalTime(), (DateTime.Now - planVersion).TotalSeconds); log.Info(infoMessage); RccpLog infoLog = new RccpLog(); infoLog.ErrorLevel = CodeMaster.MessageType.Info.ToString(); infoLog.Message = infoMessage; infoLog.Logger = "RunRccp"; infoLog.PlanVersion = planVersion; rccpLogs.Add(infoLog); this.genericMgr.BulkInsert<RccpLog>(rccpLogs); } }
public ActionResult ExportLoadDetail(string dateIndex, DateTime planVersion, string item, CodeMaster.TimeUnit dateType, string productLine) { var table = _GetLoadDetailView(dateIndex, planVersion, item, dateType, productLine); return new DownloadFileActionResult(table, "LoadDetail.xls"); }
public virtual void DeleteCodeMaster(CodeMaster entity) { Delete(entity); }
private void GenFiRccp(DateTime planVersion, CodeMaster.TimeUnit dateType, IList<MrpFlowDetail> mrpFlowDetailList, IList<RccpTrans> rccpTransList, BusinessException businessException) { var fiFlowDetailDic = mrpFlowDetailList.Where(p => p.ResourceGroup == CodeMaster.ResourceGroup.FI) .GroupBy(p => p.Item, (k, g) => new { k, g }).ToDictionary(d => d.k, d => d.g); var fiPlanList = new List<RccpFiPlan>(); var rccpTransGroups = rccpTransList.GroupBy(p => new { p.DateIndex, p.DateType, p.Item, p.PlanVersion, p.Model }, (k, g) => new { k, g }); foreach(var rccpTransGroup in rccpTransGroups) { DateTime dateFrom = DateTime.Now; if(dateType == CodeMaster.TimeUnit.Week) { dateFrom = Utility.DateTimeHelper.GetWeekIndexDateFrom(rccpTransGroup.k.DateIndex); } else { dateFrom = DateTime.Parse(rccpTransGroup.k.DateIndex + "-01"); } var mrpFlowDetail = (fiFlowDetailDic.ValueOrDefault(rccpTransGroup.k.Item) ?? new List<MrpFlowDetail>()) .FirstOrDefault(p => p.StartDate <= dateFrom && p.EndDate > dateFrom); if(mrpFlowDetail != null) { var fiPlan = new RccpFiPlan(); fiPlan.ProductLine = mrpFlowDetail.Flow; fiPlan.Machine = mrpFlowDetail.Machine == null ? string.Empty : mrpFlowDetail.Machine; fiPlan.Item = rccpTransGroup.k.Item; fiPlan.DateIndex = rccpTransGroup.k.DateIndex; fiPlan.DateType = dateType; fiPlan.PlanVersion = planVersion; fiPlan.Model = rccpTransGroup.k.Model ?? string.Empty; fiPlan.ModelRate = rccpTransGroup.g.First().ModelRate; fiPlan.Qty = rccpTransGroup.g.Sum(p => p.Qty); fiPlanList.Add(fiPlan); } } this.genericMgr.BulkInsert<RccpFiPlan>(fiPlanList); }
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); } int count = 0; foreach (InspectResult inspectResult in inspectResultList) { if (inspectResult.RejectedQty > 0) { count++; } } if (count == 0) { return(false); } this.CopyPage(count); this.FillHead(inspectOrder); int pageIndex = 1; int rowIndex = 0; int rowTotal = 0; foreach (InspectResult inspectResult in inspectResultList) { if (inspectResult.RejectedQty > 0) { //零件名称 Part Name this.SetRowCell(pageIndex, rowIndex, 0, inspectResult.InspectOrderDetail.LocationLotDetail.Item.Description); //"零件号Part No." this.SetRowCell(pageIndex, rowIndex, 1, inspectResult.InspectOrderDetail.LocationLotDetail.Item.Code); //工位号 Sta. No. this.SetRowCell(pageIndex, rowIndex, 2, string.Empty); //"数量 QTY." this.SetRowCell(pageIndex, rowIndex, 3, inspectResult.RejectedQty.Value.ToString("0.########")); //"缺陷" if (inspectResult.InspectOrderDetail.DefectClassification != null && inspectResult.InspectOrderDetail.DefectClassification != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTCLASSIFICATION, inspectResult.InspectOrderDetail.DefectClassification); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 4, codeMaster.Description); //inspectOrderDetail.DefectClassification } } //"因素" if (inspectResult.InspectOrderDetail.DefectFactor != null && inspectResult.InspectOrderDetail.DefectFactor != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DEFECTFACTOR, inspectResult.InspectOrderDetail.DefectFactor); if (codeMaster != null && codeMaster.Description != null && codeMaster.Description.Length > 0) { this.SetRowCell(pageIndex, rowIndex, 5, codeMaster.Description); //inspectOrderDetail.DefectFactor } } //处理方法 Disposition if (inspectResult.InspectOrderDetail.Disposition != null && inspectResult.InspectOrderDetail.Disposition != string.Empty) { CodeMaster codeMaster = codeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_INSPECT_DISPOSITION, inspectResult.InspectOrderDetail.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, inspectResult.InspectOrderDetail.LocationFrom.Code); //总成零件号 this.SetRowCell(pageIndex, rowIndex, 8, inspectResult.InspectOrderDetail.FinishGoods == null ? string.Empty : inspectResult.InspectOrderDetail.FinishGoods.Code); if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行 { pageIndex++; rowIndex = 0; } else { rowIndex++; } rowTotal++; } } this.sheet.DisplayGridlines = false; this.sheet.IsPrintGridlines = false; if (inspectOrder.IsPrinted == null || inspectOrder.IsPrinted == false) { inspectOrder.IsPrinted = true; inspectOrderMgr.UpdateInspectOrder(inspectOrder); } } catch (Exception) { return(false); } return(true); }
public RejectMaster CreateRejectMaster(CodeMaster.HandleResult rejectHandleResult, IList<InspectResult> inspectResultList) { return CreateRejectMaster(rejectHandleResult, inspectResultList, DateTime.Now); }
protected override void InitList() { if (this.ServicePath == null || this.ServicePath == string.Empty) { this.ServicePath = "com.Sconit.Web.CodeMasterMgrProxy"; } if (this.ServiceMethod == null || this.ServiceMethod == string.Empty) { this.ServiceMethod = "GetCachedCodeMaster"; } if (this.Code == null || this.Code == string.Empty) { throw new TechnicalException("Code not specified."); } else { this.ServiceParameter = "string:" + this.Code; } this.DescField = "Description"; this.ValueField = "Value"; IList<CodeMaster> list = ReflectHelper.InvokeServiceMethod(this.ServicePath, this.ServiceMethod, this.ServiceParameter) as IList<CodeMaster>; //IEnumerable<CodeMaster> i = list.OrderBy(codeMaster => codeMaster.Seq); this.Items.Clear(); if (this.IncludeBlankOption) { //因为list是CachedList,不能直接往里面插值,所以做了个倒手。:( CodeMaster codeMstr = new CodeMaster(); codeMstr.Code = this.BlankOptionValue; codeMstr.Description = this.BlankOptionDesc; IList<CodeMaster> newList = list; list = new List<CodeMaster>(); list.Add(codeMstr); foreach (CodeMaster codeMaster in newList) { list.Add(codeMaster); } } this.DataSource = list; this.DataTextField = this.DescField; this.DataValueField = this.ValueField; base.DataBind(); #region 默认值 if (this.DefaultSelectedValue == null && list != null) { foreach (CodeMaster codeMaster in list) { if (codeMaster.IsDefault) { this.DefaultSelectedValue = codeMaster.Value; break; } } } if (this.DefaultSelectedValue != null) { this.SelectedValue = this.DefaultSelectedValue; } #endregion }
public void ImportFlow(Stream inputStream, CodeMaster.OrderType flowType) { if (inputStream.Length == 0) { throw new BusinessException("Import.Stream.Empty"); } HSSFWorkbook workbook = new HSSFWorkbook(inputStream); ISheet sheet = workbook.GetSheetAt(0); IEnumerator rows = sheet.GetRowEnumerator(); ImportHelper.JumpRows(rows, 10); #region 列定义 // FlowMaster int colType = 1;//路线类型 int colCode = 2; // 路线代码 int colDesc = 3; // 路线描述 // FlowDet int colItem = 4; // 物料 int colUom = 5; // 单位 int colUnitCount = 6; // 单包装 int colUcDesc = 7; // 单包装 int colMinStock = 8;// int colMaxStock = 9;// // FlowStrategy int colLeadTime = 10; // 提前期 #endregion var errorMessage = new BusinessException(); int colCount = 10; List<List<string>> rowDataList = new List<List<string>>(); var items = this.genericMgr.FindAll<Item>().ToDictionary(d => d.Code, d => d); #region 读取数据 while (rows.MoveNext()) { HSSFRow row = (HSSFRow)rows.Current; if (!ImportHelper.CheckValidDataRow(row, 1, 8)) { break;//边界 } colCount++; var rowData = new List<string>(); #region FlowMaster rowData.Add("0"); rowData.Add(((int)flowType).ToString()); rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colCode))); if (string.IsNullOrWhiteSpace(rowData[2])) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.FlowCodeShouldNotEmpty, colCount.ToString())); } rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colDesc))); if (string.IsNullOrWhiteSpace(rowData[3])) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.FlowDescShouldNotEmpty, colCount.ToString())); } #endregion #region FlowDetail Item item = null; rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colItem))); if (!string.IsNullOrWhiteSpace(rowData[4])) { item = items.ValueOrDefault(rowData[4]); } if (item == null) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineItemNotFound, colCount.ToString(), rowData[4])); continue; } rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colUom))); if (string.IsNullOrWhiteSpace(rowData[5])) { rowData[5] = item.Uom; } else { try { Uom uom = this.genericMgr.FindById<Uom>(rowData[5].ToUpper()); rowData[5] = uom.Code; } catch (Exception) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineUomNotFound, colCount.ToString(), rowData[5])); } } rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colUnitCount))); if (string.IsNullOrWhiteSpace(rowData[6])) { rowData[6] = item.UnitCount.ToString(); } else { decimal unitCount = item.UnitCount; if (!decimal.TryParse(rowData[6], out unitCount)) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineUCIsNotNum, colCount.ToString())); } rowData[6] = unitCount == 0 ? item.UnitCount.ToString() : unitCount.ToString(); } //7 rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colUcDesc))); rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colMinStock))); if (string.IsNullOrWhiteSpace(rowData[8])) { rowData[8] = "0"; } else { decimal decVal = 0m; if (!decimal.TryParse(rowData[8], out decVal)) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineSafeInvIsNotNum, colCount.ToString())); } rowData[8] = decVal.ToString(); } rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colMaxStock))); if (string.IsNullOrWhiteSpace(rowData[9])) { rowData[9] = "0"; } else { decimal decVal = 0m; if (!decimal.TryParse(rowData[9], out decVal)) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineMaxInvIsNotNum, colCount.ToString())); } rowData[9] = decVal.ToString(); } #endregion #region FlowStrategy rowData.Add(ImportHelper.GetCellStringValue(row.GetCell(colLeadTime))); if (string.IsNullOrWhiteSpace(rowData[10])) { rowData[10] = "0"; } else { decimal leadTimeVal = 0m; if (!decimal.TryParse(rowData[10], out leadTimeVal)) { rowData[0] = "1"; errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.TheSpecialLineLeantimeIsNotNum, colCount.ToString())); } rowData[10] = leadTimeVal.ToString(); } #endregion rowData.Add(item.Description);//11 rowData.Add(item.Uom);//12 rowData.Add(item.ReferenceCode);//13 rowDataList.Add(rowData); } #endregion #region 验证 //Excle中重复性验证 var flowItems = rowDataList.Where(p => p[0] == "0") .Select(p => new { Type = (CodeMaster.OrderType)(int.Parse(p[1])), Flow = p[2], FlowDescription = p[3], Item = p[4], Uom = p[5], UnitCount = decimal.Parse(p[6]), UcDesc = p[7], MinStock = decimal.Parse(p[8]), MaxStock = decimal.Parse(p[9]), LeadTime = decimal.Parse(p[10]), ItemDescription = p[11], BaseUom = p[12], ReferenceCode = p[13] }); if (flowItems == null || flowItems.Count() == 0) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheImportIsNotEffect); throw errorMessage; } var flowItemGroup = flowItems.GroupBy(p => new { p.Flow, p.Item, p.Uom, p.UnitCount }, (k, g) => new { k, Count = g.Count() }) .Where(p => p.Count > 1).Select(p => new { p.k.Flow, p.k.Item }); foreach (var flowItem in flowItemGroup) { errorMessage.AddMessage(new Message(com.Sconit.CodeMaster.MessageType.Error, Resources.EXT.ServiceLan.DuplicateFlowDetail, flowItem.Flow, flowItem.Item)); } var distinctFlowItems = flowItems.GroupBy(p => new { p.Flow, p.Item }, (k, g) => new { k, j = g.First() }) .Select(p => p.j); var excelFlowMasterList = distinctFlowItems.GroupBy(p => p.Flow, (k, g) => new { Code = k, List = g }); var flowMasterDic = this.genericMgr.FindAllIn<FlowMaster>("from FlowMaster where Code in(?", excelFlowMasterList.Select(p => p.Code)).ToDictionary(d => d.Code, d => d); var flowStrategyDic = this.genericMgr.FindAllIn<FlowStrategy>("from FlowStrategy where Flow in(?", excelFlowMasterList.Select(p => p.Code)).ToDictionary(d => d.Flow, d => d); var allParty = this.genericMgr.FindAll<Party>().ToDictionary(d => d.Code, d => d.Code); var allPriceList = this.genericMgr.FindAll<PriceListMaster>().ToDictionary(d => d.Code, d => d.Code); var allAddress = this.genericMgr.FindAll<Address>().ToDictionary(d => d.Code, d => d.Code); var allLocation = this.genericMgr.FindAll<Location>().ToDictionary(d => d.Code, d => d.Code); foreach (var excelFlowMaster in excelFlowMasterList) { var firstFlowItem = excelFlowMaster.List.First(); var flowMaster = flowMasterDic.ValueOrDefault(excelFlowMaster.Code); var flowStrategy = flowStrategyDic.ValueOrDefault(excelFlowMaster.Code); if (flowType != firstFlowItem.Type) { errorMessage.AddMessage(Resources.EXT.ServiceLan.FlowTypeIsNotCorrect, firstFlowItem.Type.ToString()); continue; } #region flowMaster if (flowMaster == null) { #region FlowMaster赋值 var flowCodeSplits = excelFlowMaster.Code.Split('-'); var flowDescriptionSplits = firstFlowItem.FlowDescription.Split('-'); var newFlowMaster = new FlowMaster(); newFlowMaster.Code = excelFlowMaster.Code; newFlowMaster.Type = firstFlowItem.Type; newFlowMaster.Description = firstFlowItem.FlowDescription; newFlowMaster.IsListDet = true; newFlowMaster.IsPrintOrder = true; newFlowMaster.IsPrintAsn = true; newFlowMaster.IsPrintRceipt = true; newFlowMaster.IsShipExceed = true; newFlowMaster.IsShipFifo = true; newFlowMaster.IsAllowProvEstRec = true; newFlowMaster.ReceiveGapTo = CodeMaster.ReceiveGapTo.AdjectLocFromInv; //Code Desc1 IsActive Type RefFlow PartyFrom PartyTo ShipFrom ShipTo LocFrom LocTo BillAddr //PriceList Routing ReturnRouting Dock IsAutoCreate IsAutoRelease IsAutoStart IsAutoShip IsAutoReceive //IsAutoBill IsListDet IsManualCreateDet IsListPrice IsPrintOrder IsPrintAsn IsPrintRcpt IsShipExceed //IsRecExceed IsOrderFulfillUC IsShipFulfillUC IsRecFulfillUC IsShipScanHu IsRecScanHu IsCreatePL //IsInspect IsShipFifo IsRejInspect IsRecFifo IsShipByOrder IsAsnUniqueRec IsMRP IsCheckPartyFromAuth //IsCheckPartyToAuth RecGapTo RecTemplate OrderTemplate AsnTemplate HuTemplate BillTerm CreateHuOpt //MaxOrderCount MRPOpt IsPause PauseTime FlowStrategy ExtraDmdSource PickStrategy CreateUser CreateUserNm //CreateDate LastModifyUser LastModifyUserNm LastModifyDate DAUAT LastRefreshDate ResourceGroup //IsAllowProvEstRec UcDeviation OrderDeviation if (firstFlowItem.Type == CodeMaster.OrderType.Procurement || firstFlowItem.Type == CodeMaster.OrderType.CustomerGoods || firstFlowItem.Type == CodeMaster.OrderType.SubContract) { newFlowMaster.PartyFrom = flowCodeSplits[0]; var location = this.genericMgr.FindById<Location>(flowCodeSplits[1]); newFlowMaster.PartyTo = location.Region; if (firstFlowItem.Type == CodeMaster.OrderType.SubContract) { newFlowMaster.LocationFrom = newFlowMaster.PartyFrom; } newFlowMaster.LocationTo = location.Code; newFlowMaster.BillAddress = newFlowMaster.PartyFrom; newFlowMaster.PriceList = newFlowMaster.PartyFrom; newFlowMaster.IsReceiveScanHu = true; newFlowMaster.OrderTemplate = "ORD_Purchase.xls"; newFlowMaster.AsnTemplate = "ASN_Purchase.xls"; newFlowMaster.ReceiptTemplate = "REC_Receipt.xls"; newFlowMaster.HuTemplate = "BarCodePurchase2D.xls"; newFlowMaster.BillTerm = CodeMaster.OrderBillTerm.ReceivingSettlement; newFlowMaster.CreateHuOption = CodeMaster.CreateHuOption.None; newFlowMaster.IsListPrice = true; newFlowMaster.IsAsnUniqueReceive = true; newFlowMaster.IsAllowProvEstRec = true; } else if (firstFlowItem.Type == CodeMaster.OrderType.Distribution || firstFlowItem.Type == CodeMaster.OrderType.SubContractTransfer) { var location = this.genericMgr.FindById<Location>(flowCodeSplits[0]); newFlowMaster.LocationFrom = location.Code; newFlowMaster.PartyFrom = location.Region; newFlowMaster.PartyTo = flowCodeSplits[1]; if (firstFlowItem.Type == CodeMaster.OrderType.SubContractTransfer) { newFlowMaster.LocationTo = newFlowMaster.PartyTo; newFlowMaster.OrderTemplate = "ASN_Transfer.xls"; newFlowMaster.AsnTemplate = "ASN_Transfer.xls"; newFlowMaster.ReceiptTemplate = "REC_InvOut.xls"; newFlowMaster.HuTemplate = "BarCodeMI2D.xls"; } else { newFlowMaster.BillAddress = newFlowMaster.PartyTo; newFlowMaster.PriceList = newFlowMaster.PartyTo; newFlowMaster.OrderTemplate = "ORD_Sale.xls"; newFlowMaster.AsnTemplate = "ASN_Sale.xls"; newFlowMaster.ReceiptTemplate = "REC_Sale.xls"; newFlowMaster.HuTemplate = "BarCodeFI2D.xls"; newFlowMaster.BillTerm = CodeMaster.OrderBillTerm.ReceivingSettlement; newFlowMaster.CreateHuOption = CodeMaster.CreateHuOption.None; } newFlowMaster.IsRejectInspect = true; newFlowMaster.IsShipScanHu = true; newFlowMaster.IsCreatePickList = false; } else if (firstFlowItem.Type == CodeMaster.OrderType.Production) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheProdLineNotFound, excelFlowMaster.Code); } else if (firstFlowItem.Type == CodeMaster.OrderType.Transfer) { var locationFrom = this.genericMgr.FindById<Location>(flowCodeSplits[0]); var locationTo = this.genericMgr.FindById<Location>(flowCodeSplits[1]); newFlowMaster.PartyFrom = locationFrom.Region; newFlowMaster.PartyTo = locationTo.Region; newFlowMaster.LocationFrom = locationFrom.Code; newFlowMaster.LocationTo = locationTo.Code; newFlowMaster.IsShipScanHu = true; newFlowMaster.IsReceiveScanHu = true; newFlowMaster.IsCreatePickList = false; newFlowMaster.OrderTemplate = "ASN_Transfer.xls"; newFlowMaster.AsnTemplate = "ASN_Transfer.xls"; newFlowMaster.ReceiptTemplate = "REC_InvOut.xls"; newFlowMaster.HuTemplate = "BarCodeEX2D.xls"; newFlowMaster.CreateHuOption = CodeMaster.CreateHuOption.None; } newFlowMaster.ShipFrom = newFlowMaster.PartyFrom; newFlowMaster.ShipTo = newFlowMaster.PartyTo; #endregion #region 校验 bool isMark = false; if (!allParty.ContainsKey(newFlowMaster.PartyFrom)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.ThePartyFromNotFound, newFlowMaster.PartyFrom); isMark = true; } if (!allParty.ContainsKey(newFlowMaster.PartyTo)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.ThePartyToNotFound, newFlowMaster.PartyTo); isMark = true; } if (!string.IsNullOrWhiteSpace(newFlowMaster.LocationFrom) && !allLocation.ContainsKey(newFlowMaster.LocationFrom)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheLocFromNotFound, newFlowMaster.LocationFrom); isMark = true; } if (!string.IsNullOrWhiteSpace(newFlowMaster.LocationTo) && !allLocation.ContainsKey(newFlowMaster.LocationTo)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheLocToNotFound, newFlowMaster.LocationTo); isMark = true; } if (!string.IsNullOrWhiteSpace(newFlowMaster.PriceList) && !allPriceList.ContainsKey(newFlowMaster.PriceList)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.ThePriceListNotFound, newFlowMaster.PriceList); isMark = true; } if (!string.IsNullOrWhiteSpace(newFlowMaster.BillAddress) && !allAddress.ContainsKey(newFlowMaster.BillAddress)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheBillAddrNotFound, newFlowMaster.BillAddress); isMark = true; } if (!allAddress.ContainsKey(newFlowMaster.ShipFrom)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheShipAddrNotFound, newFlowMaster.ShipFrom); isMark = true; } if (!allAddress.ContainsKey(newFlowMaster.ShipTo)) { errorMessage.AddMessage(Resources.EXT.ServiceLan.TheShipToNotFound, newFlowMaster.ShipTo); isMark = true; } #endregion if (!isMark && !errorMessage.HasMessage) { try { this.genericMgr.Create(newFlowMaster); } catch (Exception ex) { errorMessage.AddMessage(ex.Message); } } } else { if (flowMaster.Description != firstFlowItem.FlowDescription && !errorMessage.HasMessage) { flowMaster.Description = firstFlowItem.FlowDescription; this.genericMgr.Update(flowMaster); } } #endregion #region FlowStrategy if (!errorMessage.HasMessage) { if (flowStrategy == null) { //Flow Strategy Desc1 LeadTime EmLeadTime TimeUnit var newFlowStrategy = new FlowStrategy(); newFlowStrategy.Flow = excelFlowMaster.Code; newFlowStrategy.Description = firstFlowItem.FlowDescription; newFlowStrategy.LeadTime = firstFlowItem.LeadTime; newFlowStrategy.TimeUnit = CodeMaster.TimeUnit.Hour; this.genericMgr.Create(newFlowStrategy); } else { flowStrategy.LeadTime = firstFlowItem.LeadTime; this.genericMgr.Update(flowStrategy); } } #endregion #region FlowDetail if (!errorMessage.HasMessage) { var flowDetailDic = this.genericMgr.FindAllIn<FlowDetail> ("from FlowDetail where Flow = ? and Item in(? ", excelFlowMaster.List.Select(p => p.Item), new object[] { excelFlowMaster.Code }) .GroupBy(p => p.Item, (k, g) => new { Item = k, FlowDetails = g }) .ToDictionary(d => d.Item, d => d.FlowDetails); var maxSeq = 10; var maxItemSeq = this.genericMgr.FindAllIn<FlowDetail> ("from FlowDetail where Flow = ? ", new object[] { excelFlowMaster.Code }).Select(p => p.Sequence).Max(); if (flowDetailDic.Values != null && flowDetailDic.Values.Count > 0) { maxSeq = flowDetailDic.Values.Max(p => p.Max(q => q.Sequence)); } foreach (var flowItem in excelFlowMaster.List) { //Id Flow Seq Item RefItemCode Uom BaseUom UC UCDesc MinUC StartDate EndDate Bom LocFrom LocTo //BillAddr PriceList Routing ReturnRouting Strategy ProdScan Container ContainerDesc IsAutoCreate //IsInspect IsRejInspect SafeStock MaxStock MinLotSize OrderLotSize RecLotSize BatchSize RoundUpOpt //BillTerm MrpWeight MrpTotal MrpTotalAdj ExtraDmdSource PickStrategy EBELN EBELP CreateUser //CreateUserNm CreateDate LastModifyUser LastModifyUserNm LastModifyDate BinTo IsChangeUC Machine Uom1 //var item = this.genericMgr.FindById<Item>(flowItem.Item); try { //todo check Details var flowDetail = (flowDetailDic.ValueOrDefault(flowItem.Item) ?? new List<FlowDetail>()) .FirstOrDefault(p => p.UnitCount == flowItem.UnitCount); if (flowDetail == null) { var newFlowDetail = new FlowDetail(); newFlowDetail.Flow = flowItem.Flow; newFlowDetail.Item = flowItem.Item; newFlowDetail.BaseUom = flowItem.BaseUom; newFlowDetail.Uom = flowItem.Uom; //newFlowDetail.ReferenceItemCode = flowItem.ReferenceCode; newFlowDetail.UnitCount = flowItem.UnitCount; newFlowDetail.MinUnitCount = flowItem.UnitCount; newFlowDetail.UnitCountDescription = flowItem.UcDesc; newFlowDetail.Sequence = maxSeq+maxItemSeq; newFlowDetail.SafeStock = flowItem.MinStock; newFlowDetail.MaxStock = flowItem.MaxStock; newFlowDetail.MrpWeight = 1; newFlowDetail.RoundUpOption = Sconit.CodeMaster.RoundUpOption.ToUp; maxSeq += 10; this.genericMgr.Create(newFlowDetail); } else { flowDetail.BaseUom = flowItem.BaseUom; flowDetail.Uom = flowItem.Uom; flowDetail.UnitCount = flowItem.UnitCount; flowDetail.MinUnitCount = flowItem.UnitCount; flowDetail.UnitCountDescription = flowItem.UcDesc; flowDetail.SafeStock = flowItem.MinStock; flowDetail.MaxStock = flowItem.MaxStock; this.genericMgr.Update(flowDetail); } } catch (Exception ex) { errorMessage.AddMessage(ex.Message); } } } #endregion } #endregion if (errorMessage.HasMessage) { throw errorMessage; } }
protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { #region text format string week = e.Row.Cells[1].Text; switch (week) { case "Monday": e.Row.Cells[1].Text = "${Common.Week.Monday}"; break; case "Tuesday": e.Row.Cells[1].Text = "${Common.Week.Tuesday}"; break; case "Wednesday": e.Row.Cells[1].Text = "${Common.Week.Wednesday}"; break; case "Thursday": e.Row.Cells[1].Text = "${Common.Week.Thursday}"; break; case "Friday": e.Row.Cells[1].Text = "${Common.Week.Friday}"; break; case "Saturday": e.Row.Cells[1].Text = "${Common.Week.Saturday}"; break; case "Sunday": e.Row.Cells[1].Text = "${Common.Week.Sunday}"; break; default: break; } CodeMaster type = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE, e.Row.Cells[5].Text.Trim()); if (type != null) { e.Row.Cells[5].Text = type.Description; } #endregion //#region border //e.Row.Cells[0].Attributes.Add("style", "border:1px solid blue"); //e.Row.Cells[1].Attributes.Add("style", "border:1px solid blue"); //e.Row.Cells[2].Attributes.Add("style", "border:1px solid blue"); //e.Row.Cells[3].Attributes.Add("style", "border:1px solid blue"); //e.Row.Cells[4].Attributes.Add("style", "border:1px solid blue"); //e.Row.Cells[5].Attributes.Add("style", "border:1px solid blue"); //#endregion #region add class 休息日和工作日以不同的背景色区分 if (e.Row.RowType == DataControlRowType.DataRow) { if ((String)(DataBinder.Eval(e.Row.DataItem, "Type")) == BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE_VALUE_WORK) { for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].Attributes.Add("class", "GVRow"); } } else { for (int i = 0; i < e.Row.Cells.Count; i++) { e.Row.Cells[i].Attributes.Add("class", "GVAlternatingRow"); } } } #endregion } }
/// <summary> /// Creates the project collection. /// </summary> /// <returns></returns> private List <Project> CreateProjectCollection() { ProjectVertical projectVertical = new ProjectVertical(); ProjectType projectType = new ProjectType(); CodeMaster codeMaster = new CodeMaster(); ProjectStatus projectStatus = new ProjectStatus(); Contact contact = new Contact(); contact.ContactID = 0; projectType.ProjectTypeID = 0; codeMaster.CodeMasterID = 0; projectStatus.ProjectStatusID = 0; List <Project> projectCollection = new List <Project> { new Project() { ProjectName = "MockProject" , DistributionList = string.Empty , ProjectVerticalID = 0 , ProjectVertical = projectVertical , Contact = contact , ProjectNumber = 0 , ProjectType = projectType , CodeMaster = codeMaster , InitialEstimatedPages = 0 , ExpectedStartDate = DateTime.Now , ProjectStatus = projectStatus , StatusDate = DateTime.Now , IsTypeSet = true , IsTranslations = true , IsHospitality = true , IsMedia = true , IsFiling = true , IsPrint = true , ExpectedFilingDate = null , Comments = "MockComments" }, new Project() { ProjectName = "MockProject1" , DistributionList = string.Empty , ProjectVerticalID = 1 , ProjectVertical = projectVertical , Contact = contact , ProjectNumber = 1 , ProjectType = projectType , CodeMaster = codeMaster , InitialEstimatedPages = 1 , ExpectedStartDate = DateTime.Now , ProjectStatus = projectStatus , StatusDate = DateTime.Now , IsTypeSet = false , IsTranslations = false , IsHospitality = false , IsMedia = false , IsFiling = false , IsPrint = false , ExpectedFilingDate = null , Comments = "MockComments1" }, }; return(projectCollection); }
public static double TimeTranfer(decimal sourceTime, CodeMaster.TimeUnit sourceTimeUnit, CodeMaster.TimeUnit targetTimeUnit) { if (sourceTimeUnit == targetTimeUnit) { return (double)sourceTime; } switch (sourceTimeUnit) { case CodeMaster.TimeUnit.Second: break; case CodeMaster.TimeUnit.Minute: sourceTime = sourceTime * 60; break; case CodeMaster.TimeUnit.Hour: sourceTime = sourceTime * 60 * 60; break; case CodeMaster.TimeUnit.Day: sourceTime = sourceTime * 60 * 60 * 24; break; case CodeMaster.TimeUnit.Week: sourceTime = sourceTime * 60 * 60 * 24 * 7; break; case CodeMaster.TimeUnit.Month: sourceTime = sourceTime * 60 * 60 * 24 * (DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); break; case CodeMaster.TimeUnit.Quarter: sourceTime = sourceTime * 60 * 60 * 24 * 91; break; case CodeMaster.TimeUnit.Year: sourceTime = sourceTime * 60 * 60 * 24 * 365; break; default: throw new TechnicalException("not supported time unit"); } switch (targetTimeUnit) { case CodeMaster.TimeUnit.Second: return (double)sourceTime; case CodeMaster.TimeUnit.Minute: return (double)sourceTime / 60; case CodeMaster.TimeUnit.Hour: return (double)sourceTime / 60 / 60; case CodeMaster.TimeUnit.Day: return (double)sourceTime / 60 / 60 / 24; case CodeMaster.TimeUnit.Week: return (double)sourceTime / 60 / 60 / 24 / 7; case CodeMaster.TimeUnit.Month: return (double)sourceTime / 60 / 60 / 24 / 30; case CodeMaster.TimeUnit.Quarter: return (double)sourceTime / 60 / 60 / 24 / 91; case CodeMaster.TimeUnit.Year: return (double)sourceTime / 60 / 60 / 24 / 365; default: throw new TechnicalException("not supported time unit."); } }
public virtual void DeleteCodeMaster(CodeMaster entity) { entityDao.DeleteCodeMaster(entity); }
private void SwitchModule(CodeMaster.TerminalPermission module) { //Rectangle rect = Screen.PrimaryScreen.WorkingArea; //int width = rect.Width; //int height = this.Height; if (module == CodeMaster.TerminalPermission.M_Switch) { if (this.user != null) { this.ucModuleSelect = new UCModuleSelect(this.user); this.ucModuleSelect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.ucModuleSelect.ModuleSelectExitEvent += new ModuleSelectExitHandler(this.LoadUCLogin); this.AddModule(this.ucModuleSelect); this.Text = "模块选择_Sconit_SD"; } else { this.ucModuleSelect.ModuleSelectExitEvent += new ModuleSelectExitHandler(this.LoadUCLogin); this.LoadUCLogin(); } } else if (module == CodeMaster.TerminalPermission.Client_OrderShip) { UCShip ucShip = UCShip.GetUCShip(user); ucShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucShip); ucShip.tbBarCode.Focus(); this.Text = "发货"; } else if (module == CodeMaster.TerminalPermission.Client_Receive) { UCReceive ucReceive = UCReceive.GetUCReceive(this.user); ucReceive.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucReceive); ucReceive.tbBarCode.Focus(); this.Text = "供应商收货"; } else if (module == CodeMaster.TerminalPermission.Client_Transfer) { UCTransfer ucTransfer = UCTransfer.GetUCTransfer(this.user); ucTransfer.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucTransfer); ucTransfer.tbBarCode.Focus(); this.Text = "移库"; } else if (module == CodeMaster.TerminalPermission.Client_PickList) { UCPick ucPickList = new UCPick(this.user); ucPickList.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickList); ucPickList.tbBarCode.Focus(); this.Text = "拣货"; } else if (module == CodeMaster.TerminalPermission.Client_QuickPick) { UCQuickPick ucQuickPick = new UCQuickPick(this.user); ucQuickPick.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucQuickPick); ucQuickPick.tbBarCode.Focus(); this.Text = "快速拣货"; } else if (module == CodeMaster.TerminalPermission.Client_PickListShip) { UCPickShip UCPickListShip = new UCPickShip(this.user); UCPickListShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(UCPickListShip); //UCPickListShip.tbBarCode.Focus(); this.Text = "拣货发货"; } else if (module == CodeMaster.TerminalPermission.Client_PutAway) { UCPutAway ucPutAway = UCPutAway.GetUCPutAway(this.user); ucPutAway.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPutAway); ucPutAway.tbBarCode.Focus(); this.Text = "上架"; } else if (module == CodeMaster.TerminalPermission.Client_Pickup) { var ucPickUp = UCPickUp.GetUCPickUp(this.user); ucPickUp.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickUp); this.Text = "下架"; } else if (module == CodeMaster.TerminalPermission.Client_ReceiveSQ) { var ucSQReceive = UCSQReceive.GetUCSQReceive(this.user); ucSQReceive.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucSQReceive); this.Text = "双桥条码收货"; } else if (module == CodeMaster.TerminalPermission.Client_AnDon) { UCAnDon ucAnDon = UCAnDon.GetUCAnDon(this.user); ucAnDon.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); AddModule(ucAnDon); ucAnDon.tbBarCode.Focus(); this.Text = "按灯"; //this.ucDevanning.Height = height; } else if (module == CodeMaster.TerminalPermission.Client_StockTaking) { UCStockTaking ucStockTaking = UCStockTaking.GetUCStockTaking(this.user); ucStockTaking.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucStockTaking); ucStockTaking.tbBarCode.Focus(); this.Text = "盘点"; } else if (module == CodeMaster.TerminalPermission.Client_MaterialIn) { UCMaterialIn ucMaterialIn = UCMaterialIn.GetUCMaterialIn(this.user); ucMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMaterialIn); ucMaterialIn.tbBarCode.Focus(); this.Text = "关键件追溯"; } else if (module == CodeMaster.TerminalPermission.Client_ForceMaterialIn) { var ucForceMaterialIn = UCForceMaterialIn.UCForceMaterialIns(this.user); ucForceMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucForceMaterialIn); ucForceMaterialIn.tbBarCode.Focus(); this.Text = "车架追溯"; } else if (module == CodeMaster.TerminalPermission.Client_ForceScanMaterialIn) { var ucScanForceMaterialIn = UCScanForceMaterialIn.UCScanForceMaterialIns(this.user); ucScanForceMaterialIn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucScanForceMaterialIn); ucScanForceMaterialIn.tbBarCode.Focus(); this.Text = "强制扫描"; } else if (module == CodeMaster.TerminalPermission.Client_Qualify) { var ucJudgeInspect = new UCJudgeInspect(this.user, JudgeResult.Qualified); ucJudgeInspect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucJudgeInspect); ucJudgeInspect.tbBarCode.Focus(); this.Text = "合格"; } else if (module == CodeMaster.TerminalPermission.Client_Reject) { var ucJudgeInspect = new UCJudgeInspect(this.user, JudgeResult.Rejected); this.ucJudgeInspect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucJudgeInspect); ucJudgeInspect.tbBarCode.Focus(); this.Text = "不合格"; } else if (module == CodeMaster.TerminalPermission.Client_RePack) { var ucRePack = new UCRePack(this.user); ucRePack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucRePack); ucRePack.tbBarCode.Focus(); this.Text = "翻箱"; } else if (module == CodeMaster.TerminalPermission.Client_UnPack) { var ucUnPack = new UCUnPack(this.user); ucUnPack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucUnPack); ucUnPack.tbBarCode.Focus(); this.Text = "拆箱"; } else if (module == CodeMaster.TerminalPermission.Client_Pack) { var ucPack = new UCPack(this.user); ucPack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPack); ucPack.tbBarCode.Focus(); this.Text = "装箱"; } else if (module == CodeMaster.TerminalPermission.Client_Inspect) { var ucInspect = new UCInspect(this.user); ucInspect.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucInspect); ucInspect.tbBarCode.Focus(); this.Text = "报验"; } else if (module == CodeMaster.TerminalPermission.Client_WorkerWaste) { var ucWorkerWaste = new UCWorkerWaste(this.user); ucWorkerWaste.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucWorkerWaste); ucWorkerWaste.tbBarCode.Focus(); this.Text = "工废"; } else if (module == CodeMaster.TerminalPermission.Client_PickListOnline) { var ucPickListOnline = new UCPickListOnline(this.user); ucPickListOnline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucPickListOnline); ucPickListOnline.tbBarCode.Focus(); this.Text = "拣货单上线"; } else if (module == CodeMaster.TerminalPermission.Client_HuStatus) { var ucHuStatus = new UCHuStatus(this.user); ucHuStatus.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucHuStatus); ucHuStatus.tbBarCode.Focus(); this.Text = "条码状态"; } else if (module == CodeMaster.TerminalPermission.Client_CabOnline) { UCCabOnline ucCabOnline = UCCabOnline.GetUCCabOnline(this.user); ucCabOnline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucCabOnline); ucCabOnline.tbBarCode.Focus(); this.Text = "驾驶室上线"; } else if (module == CodeMaster.TerminalPermission.Client_ScanEngine) { UCScanEngine ucScanEngine = UCScanEngine.GetUCScanEngine(this.user); ucScanEngine.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucScanEngine); ucScanEngine.tbBarCode.Focus(); this.Text = "扫描发动机"; } else if (module == CodeMaster.TerminalPermission.Client_ProductionOnline) { UCProductOrderOnline ucProductOrderOnline = UCProductOrderOnline.GetUCProductOrderOnline(this.user); ucProductOrderOnline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucProductOrderOnline); ucProductOrderOnline.tbBarCode.Focus(); this.Text = "上线"; } else if (module == CodeMaster.TerminalPermission.Client_VanOrderReceive) { AssemblyOffline ucAssemblyOffline = AssemblyOffline.GetAssemblyOffline(user); ucAssemblyOffline.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucAssemblyOffline); ucAssemblyOffline.tbBarCode.Focus(); this.Text = "整车入库"; } else if (module == CodeMaster.TerminalPermission.Client_ReceiveAnJiHu) { UCReceiveAnJiHu ucReceiveAnJiHu = UCReceiveAnJiHu.GetUCReceiveAnJiHu(user); ucReceiveAnJiHu.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucReceiveAnJiHu); ucReceiveAnJiHu.tbBarCode.Focus(); this.Text = "安吉条码收货"; } else if (module == CodeMaster.TerminalPermission.Client_ReceiveAnJiSeq) { UCRecAnJiSeqOrder ucRecAnJiSeqOrder = UCRecAnJiSeqOrder.GetUCRecAnJiSeqOrder(user); ucRecAnJiSeqOrder.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucRecAnJiSeqOrder); ucRecAnJiSeqOrder.tbBarCode.Focus(); this.Text = "安吉出库单收货"; } else if (module == CodeMaster.TerminalPermission.Client_SeqPack) { //UCSeqPack ucSeqPack = UCSeqPack.GetUCSeqPack(this.user); //ucSeqPack.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); //this.AddModule(ucSeqPack); //ucSeqPack.tbBarCode.Focus(); //this.Text = "排序装箱"; } else if (module == CodeMaster.TerminalPermission.Client_MiscInOut) { UCMisInOut ucMisInOut = UCMisInOut.GetUCMisInOut(this.user); ucMisInOut.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMisInOut); ucMisInOut.tbBarCode.Focus(); this.Text = "计划外出入库"; } else if (module == CodeMaster.TerminalPermission.Client_HuClone) { UCHuClone ucHuClone = UCHuClone.GetUCHuClone(this.user); ucHuClone.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucHuClone); ucHuClone.tbBarCode.Focus(); this.Text = "条码克隆"; } else if (module == CodeMaster.TerminalPermission.Client_MaterialReturn) { UCMaterialReturn ucMaterialReturn = new UCMaterialReturn(this.user); ucMaterialReturn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucMaterialReturn); ucMaterialReturn.tbBarCode.Focus(); this.Text = "退料"; } else if (module == CodeMaster.TerminalPermission.Client_SeqCancel) { //UCSeqCancel ucSeqCancel = UCSeqCancel.GetUCSeqCancel(this.user); //ucSeqCancel.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); //this.AddModule(ucSeqCancel); //ucSeqCancel.tbBarCode.Focus(); //this.Text = "排序装箱取消"; } else if (module == CodeMaster.TerminalPermission.Client_SeqShip) { //UCSeqShip ucSeqShip = UCSeqShip.GetUCSeqShip(this.user); //ucSeqShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); //this.AddModule(ucSeqShip); //ucSeqShip.tbBarCode.Focus(); //this.Text = "排序装箱发货"; } else if (module == CodeMaster.TerminalPermission.Client_QuickSeqShip) { //UCQuickSeqShip ucQuickSeqShip = UCQuickSeqShip.GetUCQuickSeqShip(this.user); //ucQuickSeqShip.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); //this.AddModule(ucQuickSeqShip); //ucQuickSeqShip.tbBarCode.Focus(); //this.Text = "排序单快速发货"; } else if (module == CodeMaster.TerminalPermission.Client_SubAssemblyOffLine) { UCSubAssemblyOffLine ucSubAssemblyOffLine = UCSubAssemblyOffLine.GetUCSubAssemblyOffLine(this.user); ucSubAssemblyOffLine.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucSubAssemblyOffLine); ucSubAssemblyOffLine.tbBarCode.Focus(); this.Text = "分装生产单下线"; } else if (module == CodeMaster.TerminalPermission.Client_Freeze) { UCFreeze ucFreeze = UCFreeze.GetUCFreeze(this.user); ucFreeze.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucFreeze); ucFreeze.tbBarCode.Focus(); this.Text = "库存冻结"; } else if (module == CodeMaster.TerminalPermission.Client_UnFreeze) { UCUnFreeze ucUnFreeze = UCUnFreeze.GetUCUnFreeze(this.user); ucUnFreeze.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucUnFreeze); ucUnFreeze.tbBarCode.Focus(); this.Text = "库存冻结"; } else if (module == CodeMaster.TerminalPermission.Client_TransKeyScan) { UCTransKeyScan ucTransKeyScan = new UCTransKeyScan(this.user); ucTransKeyScan.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucTransKeyScan); ucTransKeyScan.tbBarCode.Focus(); this.Text = "变速器关键件扫描"; } else if (module == CodeMaster.TerminalPermission.Client_ForceRecive) { UCForceReceive ucForceReceive = new UCForceReceive(this.user); ucForceReceive.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucForceReceive); ucForceReceive.tbBarCode.Focus(); this.Text = "强制收货"; } else if (module == CodeMaster.TerminalPermission.Client_QuickReturn) { UCQuickReturn ucQuickReturn = new UCQuickReturn(this.user); ucQuickReturn.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucQuickReturn); ucQuickReturn.tbBarCode.Focus(); this.Text = "快速退库"; } else if (module == CodeMaster.TerminalPermission.Client_CabTransfer) { UCCabTransfer ucCabTransfer = UCCabTransfer.GetUCCabTransfer(user); ucCabTransfer.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucCabTransfer); ucCabTransfer.tbBarCode.Focus(); this.Text = "驾驶室移库"; } else if (module == CodeMaster.TerminalPermission.Client_LotNoScan) { UCLotNoScan ucLotNoScan = UCLotNoScan.GetUCLotNoScan(this.user); ucLotNoScan.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); this.AddModule(ucLotNoScan); ucLotNoScan.tbBarCode.Focus(); this.Text = "批号管理"; } //else if (moduleType == BusinessConstants.ModuleType.Reuse) //{ // //this.ucReuse = new UCReuse(this.user, moduleType); // this.ucReuse.ModuleSelectionEvent += new ModuleSelectHandler(this.SwitchModule); // this.SwitchModule(this.ucReuse); // this.Text = "材料回用"; // this.ucReuse.InitialAll(); // this.ucReuse.Width = width; // //this.ucHuStatus.Height = height; //} }
protected override void InitList() { if (this.ServicePath == null || this.ServicePath == string.Empty) { this.ServicePath = "com.Sconit.Web.CodeMasterMgrProxy"; } if (this.ServiceMethod == null || this.ServiceMethod == string.Empty) { this.ServiceMethod = "GetCachedCodeMaster"; } if (this.Code == null || this.Code == string.Empty) { throw new TechnicalException("Code not specified."); } else { this.ServiceParameter = "string:" + this.Code; } this.DescField = "Description"; this.ValueField = "Value"; IList <CodeMaster> list = ReflectHelper.InvokeServiceMethod(this.ServicePath, this.ServiceMethod, this.ServiceParameter) as IList <CodeMaster>; //IEnumerable<CodeMaster> i = list.OrderBy(codeMaster => codeMaster.Seq); this.Items.Clear(); if (this.IncludeBlankOption) { //因为list是CachedList,不能直接往里面插值,所以做了个倒手。:( CodeMaster codeMstr = new CodeMaster(); codeMstr.Code = this.BlankOptionValue; codeMstr.Description = this.BlankOptionDesc; IList <CodeMaster> newList = list; list = new List <CodeMaster>(); list.Add(codeMstr); if (newList != null && newList.Count > 0) { foreach (CodeMaster codeMaster in newList) { list.Add(codeMaster); } } } this.DataSource = list; this.DataTextField = this.DescField; this.DataValueField = this.ValueField; base.DataBind(); #region 默认值 if (this.DefaultSelectedValue == null && list != null) { foreach (CodeMaster codeMaster in list) { if (codeMaster.IsDefault) { this.DefaultSelectedValue = codeMaster.Value; break; } } } if (this.DefaultSelectedValue != null) { this.SelectedValue = this.DefaultSelectedValue; } #endregion }
protected void Page_Load(object sender, EventArgs e) { branch_id = webUtil.GetParam("branch_id", ""); pages = webUtil.GetParam("pages", "1"); if (branch_id == "" || branch_id == null) { webUtil.Alert("잘못된 경로로 접근하셧습니다.", "/store/store_list.aspx"); return; } DataSet ds = null; DataSet ds1 = null; Hashtable param = new Hashtable(); param.Add("branch_id", branch_id); if (!IsPostBack) { Order cm = new Order(); ds = cm.selectBranchInfo(param); #region 마스터코드 바인딩 CodeMaster master = new CodeMaster(); ds1 = master.selectCodeMaster(param); packinginfo.DataSource = ds1.Tables[0]; packinginfo.DataBind(); #endregion if (DbUtil.ContainData(ds)) { DataRow branch = ds.Tables[0].Rows[0]; get_dt = branch["get_dt"].ToString(); a_branch_id = branch["a_branch_id"].ToString(); a_branch_nm = branch["a_branch_nm"].ToString(); a_branch_tel = branch["a_branch_tel"].ToString(); a_branch_addr = branch["a_branch_addr"].ToString(); a_delivery_time = branch["a_delivery_time"].ToString(); a_week_starttime = branch["a_week_starttime"].ToString(); a_week_endtime = branch["a_week_endtime"].ToString(); use_yn = branch["use_yn"].ToString(); a_end_starttime = branch["a_end_starttime"].ToString(); a_end_endtime = branch["a_end_endtime"].ToString(); order_branch_id = branch["order_branch_id"].ToString(); mid = branch["mid"].ToString(); mertkey = branch["mertkey"].ToString(); ocb_branch_id = branch["ocb_branch_id"].ToString(); ocb_branch_cn = branch["ocb_branch_cn"].ToString(); packing_type = branch["packing_type"].ToString(); home_yn = branch["home_yn"].ToString(); online_yn = branch["online_yn"].ToString(); ecoupon_yn = branch["ecoupon_yn"].ToString(); cesco_yn = branch["cesco_yn"].ToString(); carddisc_yn = branch["carddisc_yn"].ToString(); advance_yn = branch["advance_yn"].ToString(); bctop_yn = branch["bctop_yn"].ToString(); lat = branch["lat"].ToString(); lng = branch["lng"].ToString(); } } }