/// <summary> /// /// </summary> /// <param name="SchedulingId">产线信息</param> /// <returns></returns> public ActionResult Edit(DateTime?SDate, string SchedulingProNo, int SchedulingId = 0, int PSId = 0) { IList <Pro_PSDetail> PSDetail = new List <Pro_PSDetail>(); Pro_SchedulingLine fristLine = new Pro_SchedulingLine(); Pro_PS model = new Pro_PS(); if (PSId > 0) { //编辑 model = Smart.Instance.Pro_PSBizService.GetAllDomain(QueryCondition.Instance.AddEqual("Id", PSId.ToString()))[0]; //只加载一个产线,即 不能修改其他产线,下拉框只能选择一个 List <Pro_SchedulingLine> scheduList = new List <Pro_SchedulingLine>(); scheduList.Add(new Pro_SchedulingLine { Id = model.LineId, ProLineNo = model.ProLineNo }); ViewBag.AllLine = new SelectList(scheduList, "Id", "ProLineNo", fristLine.Id); //获取明细 PSDetail = Smart.Instance.Pro_PSDetailBizService.GetAllDomain(QueryCondition.Instance.AddOrderBy("Id", true).AddEqual("MainId", PSId.ToString())); } else { //新增 if (SDate == null) { SDate = DateTime.Now; } //1.获取所有产线信息 var allLineList = Smart.Instance.Pro_SchedulingLineBizService.GetAllDomain(QueryCondition.Instance.AddOrderBy("Id", true).AddEqual("MainId", SchedulingId.ToString())); if (allLineList.Count > 0) { fristLine = allLineList[0]; model = new Pro_PS { FinalEveningNum = fristLine.EveningShift, FinalMiddleNum = fristLine.MiddleShift, FinalMorningNum = fristLine.MorningShift, ProLineNo = fristLine.ProLineNo, ProDate = DateTime.Now, }; } model.SchedulingProNo = SchedulingProNo; model.ProDate = SDate.Value; ViewBag.AllLine = new SelectList(allLineList, "Id", "ProLineNo", fristLine.Id); PSDetail = Smart.Instance.Pro_PSDetailBizService.GetPSDetailBySchedulingLineId(model, fristLine, SDate.Value); } ViewBag.PSModel = model; return(View(PSDetail)); }
public JsonResult GetGoodList(int LineId, DateTime SDate) { //1.获取所有产线信息 Pro_SchedulingLine fristLine = Smart.Instance.Pro_SchedulingLineBizService.GetAllDomain(QueryCondition.Instance.AddOrderBy("Id", true).AddEqual("Id", LineId.ToString()))[0]; Pro_PS model = new Pro_PS(); model = new Pro_PS { FinalEveningNum = fristLine.EveningShift, FinalMiddleNum = fristLine.MiddleShift, FinalMorningNum = fristLine.MorningShift, ProLineNo = fristLine.ProLineNo, ProDate = DateTime.Now, }; ViewBag.PSModel = model; var pSDetail = Smart.Instance.Pro_PSDetailBizService.GetPSDetailBySchedulingLineId(model, fristLine, SDate); return(Json(new { PSModel = model, PSDetail = pSDetail })); }
public IList <Pro_PSDetail> GetPSDetailBySchedulingLineId(Pro_PS psModel, Pro_SchedulingLine fristLine, DateTime SDate) { IList <Pro_PSDetail> psDetail = new List <Pro_PSDetail>(); //产线对应的产品信息 IList <Pro_SchedulingGoods> schedulingGoods = new Pro_SchedulingGoodsDao().GetListBySchedulingLineId(Util.QueryCondition.Instance.AddEqual("Id", fristLine.Id.ToString()) .AddEqual("SDate", SDate.ToString("yyyy-MM-dd"))); int classNum = 0; //计算班次 if (psModel.FinalEveningNum != null) { classNum++; } if (psModel.FinalMiddleNum != null) { classNum++; } if (psModel.FinalMorningNum > 0) { classNum++; } //每天开始时间为8:00 修改成 7:30 //1班次 8:00~08:00 //2班次 8:00~ 12:45 12:45~08:00 //3班次 8:00 ~ 16:00 16:00~00:00 00:00~08:00 DateTime time = Convert.ToDateTime(SDate.ToString("yyyy-MM-dd") + " 07:30:00"); int i = 1; foreach (var good in schedulingGoods) { Pro_PSDetail model = new Pro_PSDetail { GoodNo = good.GoodNo, GoodName = good.GoodName, ShipTo = good.ShipTo, ShipToName = good.ShipToName, PackNum = good.PackNum, Qty = good.SNum, ProOrderIndex = i, SType = good.SType, STypeString = EnumOperate.GetEnumDesc((VisualSmart.Util.Menus.ClassType)good.SType) }; //产能 根据早中晚判断产能基本参数 decimal channeng = 0; if (model.SType == 2 && good.MorningNum != null) { channeng = good.MorningNum > 0 ? (Convert.ToDecimal(good.SNum) / good.MorningNum.Value) : 0; model.ChanNeng = good.MorningNum.Value; } else if (model.SType == 3 && good.MiddleNum != null) { channeng = good.MiddleNum > 0 ? (Convert.ToDecimal(good.SNum) / good.MiddleNum.Value) : 0; model.ChanNeng = good.MiddleNum.Value; } else if (model.SType == 4 && good.EveningNum != null) { channeng = good.EveningNum > 0 ? (Convert.ToDecimal(good.SNum) / good.EveningNum.Value) : 0; model.ChanNeng = good.EveningNum.Value; } channeng = channeng * 60 * 60; //1班次 8:00~08:00 model.StartTime = time; time = time.AddSeconds(Convert.ToDouble(channeng)); model.EndTime = time; //if (classNum == 1) //{ // //1班次 8:00~08:00 // model.StartTime = time; // time = time.AddSeconds(channeng); // model.EndTime = time; //} //else if (classNum == 2) //{ // //2班次 8:00~ 12:45 12:45~08:00 // if (model.SType > 2) // { // } // else // { // model.StartTime = time; // time = time.AddSeconds(channeng); // model.EndTime = time; // } //} //else if (classNum == 3) //{ // //3班次 8:00 ~ 16:00 16:00~00:00 00:00~08:00 // model.StartTime = time; // time = time.AddSeconds(channeng); // model.EndTime = time; //} psDetail.Add(model); i++; } return(psDetail); }
/// <summary> /// 网络订单列表-导出 /// </summary> /// <param name="detailList"></param> /// <param name="sceneryName"></param> public string ExportOrderDetailExcel(IList <Pro_PSDetail> detailList, Pro_PS model, string title) { var columns = new List <string> { "序号", "零件号", "零件名称", "班次", "客户(ship-to)", "整箱包装数", "产能", "数量", "开始时间", "结束时间", }; IWorkbook workbook = new XSSFWorkbook(); var dsi = PropertySetFactory.CreateDocumentSummaryInformation(); dsi.Company = "NPOI Team"; var si = PropertySetFactory.CreateSummaryInformation(); si.Subject = "NPOI SDK Example"; var sheetName = "PS详细"; if (string.IsNullOrEmpty(title)) { sheetName = title + "--" + sheetName; } else { sheetName = title + "--" + sheetName; } var sheet = workbook.CreateSheet(sheetName); //表头样式 加粗 浅灰色 var headerStyle = workbook.CreateCellStyle(); SetExcelBoderStyle(headerStyle); var headerFont = workbook.CreateFont(); //headerFont.Boldweight = (short)FontBoldWeight.BOLD; headerStyle.SetFont(headerFont); //数据样式 var allStyle = workbook.CreateCellStyle(); //allStyle.BorderTop = BorderStyle.THIN; //allStyle.BorderBottom = BorderStyle.THIN; //allStyle.BorderLeft = BorderStyle.THIN; //allStyle.BorderRight = BorderStyle.THIN; //allStyle.TopBorderColor = IndexedColors.BLACK.Index; //allStyle.BottomBorderColor = IndexedColors.BLACK.Index; //allStyle.LeftBorderColor = IndexedColors.BLACK.Index; //allStyle.RightBorderColor = IndexedColors.BLACK.Index; sheet.CreateRow(0); sheet.CreateRow(1); sheet.CreateRow(2); sheet.CreateRow(3); sheet.CreateRow(4); //AddRow(0, 0, 0, 10, "生产日期: " + model.ProDate.ToString("yyyy-MM-dd"), workbook, sheet, 13, HorizontalAlignment.LEFT); //AddRow(1, 1, 0, 10, "生 产 线: " + model.ProLineNo, workbook, sheet, 13, NPOI.SS.UserModel.HorizontalAlignment.LEFT); //AddRow(2, 2, 0, 10, "早班人数: " + (model.FinalMorningNum ?? 0).ToString(), workbook, sheet, 13, NPOI.SS.UserModel.HorizontalAlignment.LEFT); //AddRow(3, 3, 0, 10, "中班人数: " + (model.FinalMiddleNum ?? 0).ToString(), workbook, sheet, 13, NPOI.SS.UserModel.HorizontalAlignment.LEFT); //AddRow(4, 4, 0, 10, "晚班人数: " + (model.FinalEveningNum ?? 0).ToString(), workbook, sheet, 13, NPOI.SS.UserModel.HorizontalAlignment.LEFT); sheet.CreateRow(5); for (var i = 0; i < columns.Count; i++) { sheet.GetRow(5).CreateCell(i).SetCellValue(columns[i]); sheet.GetRow(5).GetCell(i).CellStyle = headerStyle; } sheet.GetRow(5).HeightInPoints = 18; if (detailList != null && detailList.Count > 0) { for (var i = 5; i < (detailList.Count + 5); i++) { sheet.CreateRow(1 + i); var item = detailList[i - 5]; sheet.GetRow(1 + i).CreateCell(0).SetCellValue(item.ProOrderIndex.ToString()); sheet.GetRow(1 + i).CreateCell(1).SetCellValue(item.GoodNo); sheet.GetRow(1 + i).CreateCell(2).SetCellValue(item.GoodName); sheet.GetRow(1 + i) .CreateCell(3) .SetCellValue(EnumOperate.GetEnumDesc((ClassType)item.SType)); sheet.GetRow(1 + i) .CreateCell(4) .SetCellValue(item.ShipTo); sheet.GetRow(1 + i).CreateCell(5).SetCellValue(item.PackNum.ToString()); sheet.GetRow(1 + i).CreateCell(6).SetCellValue(item.ChanNeng.ToString()); sheet.GetRow(1 + i) .CreateCell(7) .SetCellValue(item.Qty.ToString()); sheet.GetRow(1 + i).CreateCell(8).SetCellValue(item.StartTime.ToString("yyyy-MM-dd HH:mm:ss")); sheet.GetRow(1 + i).CreateCell(9).SetCellValue(item.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); for (var j = 0; j < columns.Count; j++) { sheet.GetRow(1 + i).GetCell(j).CellStyle = allStyle; } } } //设置列宽 sheet.SetColumnWidth(0, 1200); sheet.SetColumnWidth(1, 4600); sheet.SetColumnWidth(2, 5600); sheet.SetColumnWidth(3, 2600); sheet.SetColumnWidth(4, 3600); sheet.SetColumnWidth(5, 3600); sheet.SetColumnWidth(6, 2600); //设置列宽 sheet.SetColumnWidth(7, 2600); sheet.SetColumnWidth(8, 4600); sheet.SetColumnWidth(9, 4600); sheet.ForceFormulaRecalculation = true; return(CommonMethod.WriteToFileAndGetFileUrl(workbook, sheetName)); }