public ActionResult Query(PackageQueryViewModel model) { using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = GetQueryCondition(model) }; MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", new PackageViewModel())); } else { return(View("Index", model)); } }
private bool SetPrintObject(Package obj, ref dynamic d) { PackageInfo packageInfo = null; using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { MethodReturnResult <PackageInfo> rst = client.Get(obj.Key); if (rst.Code == 0) { packageInfo = rst.Data; } else { return(false); } } d.PackageNo = obj.Key.ToUpper(); d.ProdId = packageInfo.ProductId; d.PartNo = packageInfo.ConfigCode; d.Grade = packageInfo.Grade; d.Color = packageInfo.Color; d.PNType = packageInfo.PNType; d.Eff = packageInfo.EfficiencyName; d.Qty = string.Format("{0}PCS", obj.Quantity); return(true); }
public ActionResult PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } return(PartialView("_ListPartial", new PackageViewModel())); }
public ActionResult Query(string lineCode) { using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { PagingConfig cfg = new PagingConfig() { OrderBy = "Key Desc", Where = string.Format(@"LineCode='{0}' AND EXISTS(FROM Package as p WHERE p.Key=self.Key AND p.PackageState=0)" , lineCode) }; MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", new PackageViewModel())); } else { return(View("Index", new PackageViewModel())); } }
public PackageInfo GetPackageInfo(string packageNo) { using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { MethodReturnResult <PackageInfo> result = client.Get(packageNo); return(result.Data); } }
private bool SetPrintObject(Package obj, ref dynamic d) { //获取箱第一包的数据 string packageNo = string.Empty; PackageInfo packageInfo = new PackageInfo(); using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key.PackageNo='{0}' AND Key.ObjectType='{1}'" , obj.Key , Convert.ToInt32(EnumPackageObjectType.Packet)), OrderBy = "ItemNo" }; MethodReturnResult <IList <PackageDetail> > rst = client.GetDetail(ref cfg); if (rst.Code <= 0 && rst.Data != null && rst.Data.Count > 0) { packageNo = rst.Data[0].Key.ObjectNumber; } } if (string.IsNullOrEmpty(packageNo)) { return(false); } using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { MethodReturnResult <PackageInfo> rst = client.Get(packageNo); if (rst.Code <= 0 && rst.Data != null) { packageInfo = rst.Data; } else { return(false); } } d.CartonNo = obj.Key.ToUpper(); d.Color = packageInfo.Color; d.Date = obj.CreateTime.Value.ToString("yyyy.MM.dd"); d.Eff = packageInfo.EfficiencyName; d.Grade = packageInfo.Grade; d.PartNo = packageInfo.ConfigCode; d.PNType = packageInfo.PNType; d.ProdID = packageInfo.ProductId; d.Qty = string.Format("{0}PCS", obj.Quantity); return(true); }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format("删除包({0}) 数据成功。" , key); } return(Json(result)); } }
public ActionResult ExportToExcel(PackageQueryViewModel model) { IList <PackageInfo> lstPackage = new List <PackageInfo>(); PackageViewModel m = new PackageViewModel(); using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = GetQueryCondition(model) }; MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg); if (result.Code == 0) { lstPackage = result.Data; } } //创建工作薄。 IWorkbook wb = new HSSFWorkbook(); //设置EXCEL格式 ICellStyle style = wb.CreateCellStyle(); style.FillForegroundColor = 10; //有边框 style.BorderBottom = BorderStyle.THIN; style.BorderLeft = BorderStyle.THIN; style.BorderRight = BorderStyle.THIN; style.BorderTop = BorderStyle.THIN; IFont font = wb.CreateFont(); font.Boldweight = 10; style.SetFont(font); ISheet ws = null; for (int j = 0; j < lstPackage.Count; j++) { if (j % 65535 == 0) { ws = wb.CreateSheet(); IRow row = ws.CreateRow(0); #region //列名 ICell cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(StringResource.ItemNo); //项目号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_PackageNo); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Qty); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Code); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Name); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Grade); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Color); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_PNType); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_LineCode); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_OrderNumber); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_MaterialCode); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("产品编号"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("包装时间"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("操作人"); #endregion font.Boldweight = 5; } PackageInfo obj = lstPackage[j]; IRow rowData = ws.CreateRow(j + 1); Package packageObj = m.GetPackage(obj.Key); ProductionLine plObj = m.GetProductionLine(obj.LineCode); #region //数据 ICell cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(j + 1); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Key); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(packageObj != null ? packageObj.Quantity : 0); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.ConfigCode); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.EfficiencyName); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Grade); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Color); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.PNType); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(plObj != null ? plObj.Name : obj.LineCode); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(packageObj.OrderNumber); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(packageObj.MaterialCode); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.ProductId); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.CreateTime)); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Creator); #endregion } MemoryStream ms = new MemoryStream(); wb.Write(ms); ms.Flush(); ms.Position = 0; return(File(ms, "application/vnd.ms-excel", "LotPackageData.xls")); }
public ActionResult GetCode(string q, string group, string lineCode, bool isChange) { string packageNo = string.Empty; //生成包装号。 if (isChange) { string line = string.Empty; using (ProductionLineServiceClient client = new ProductionLineServiceClient()) { MethodReturnResult <ProductionLine> result = client.Get(lineCode); if (result.Code <= 0) { line = result.Data.Attr1; } } if (!string.IsNullOrEmpty(line)) { string prefix = string.Format("C{0:yyMMdd}{1}", DateTime.Now, line); int itemNo = 0; using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key LIKE '{0}%'" , prefix), OrderBy = "Key Desc" }; MethodReturnResult <IList <PackageInfo> > result = client.Get(ref cfg); if (result.Code <= 0 && result.Data.Count > 0) { string maxPackageNo = result.Data[0].Key.Replace(prefix, ""); int.TryParse(maxPackageNo, out itemNo); } itemNo++; } packageNo = prefix + itemNo.ToString("0000"); } } //获取配置信息。 using (EfficiencyConfigurationServiceClient client = new EfficiencyConfigurationServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Key.Code LIKE '{0}%' AND Key.Group='{1}'" , q , group) }; MethodReturnResult <IList <EfficiencyConfiguration> > result = client.Get(ref cfg); if (result.Code <= 0) { return(Json(from item in result.Data select new { @label = item.Key.Code, @value = item.Key.Code, @Name = item.Name, @Lower = item.Lower, @Upper = item.Upper, @Grade = item.Grade, @Color = item.Color, @PackageNo = packageNo, @MaterialCode = item.MaterialCode ?? string.Empty }, JsonRequestBehavior.AllowGet)); } } return(Json(null, JsonRequestBehavior.AllowGet)); }
public ActionResult Save(PackageViewModel model) { MethodReturnResult result = new MethodReturnResult(); try { if (!string.IsNullOrEmpty(model.PackageNo)) { model.PackageNo = model.PackageNo.Trim().ToUpper(); } Package p = new Package() { Key = model.PackageNo, CreateTime = DateTime.Now, Creator = User.Identity.Name, IsLastPackage = false, Editor = User.Identity.Name, EditTime = DateTime.Now, MaterialCode = model.MaterialCode, OrderNumber = model.OrderNumber, PackageState = EnumPackageState.Packaging, PackageType = EnumPackageType.Packet, Quantity = model.Qty.Value }; PackageInfo obj = new PackageInfo() { Key = model.PackageNo, Color = model.Color, CreateTime = DateTime.Now, Creator = User.Identity.Name, Editor = User.Identity.Name, EditTime = DateTime.Now, ConfigGroup = model.Group, ConfigCode = model.Code.Trim(), Grade = model.Grade, LineCode = model.LineCode, EfficiencyLower = model.Lower, EfficiencyUpper = model.Upper, EfficiencyName = model.Name, PNType = model.PNType }; //根据物料号获取产品编号。 Material m = null; using (MaterialServiceClient client = new MaterialServiceClient()) { MethodReturnResult <Material> rst = client.Get(model.MaterialCode); if (rst.Code == 0) { m = rst.Data; } } if (m != null) { obj.ProductId = string.Format("{0}{1}{2}", m.Spec, model.Style, model.Technology); } //新增包装数据。 using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { result = client.Add(p, obj); if (result.Code <= 0) { result.Message = string.Format("保存 {0} 成功。", p.Key); } else { return(Json(result)); } } MethodReturnResult result1 = PrintPrivate(model, obj); result.Message += result1.Message; result.Code = result1.Code; } catch (Exception ex) { result.Code = 1000; result.Detail = ex.ToString(); result.Message = ex.Message; } return(Json(result)); }
private MethodReturnResult PrintPrivate(BoxViewModel model) { MethodReturnResult result = new MethodReturnResult(); //不需要进行标签打印。 if (model.PrintQty <= 0 || string.IsNullOrEmpty(model.PrinterName) || string.IsNullOrEmpty(model.PrintLabelCode)) { return(result); } //获取打印机名称 ClientConfig printer = null; using (ClientConfigServiceClient client = new ClientConfigServiceClient()) { MethodReturnResult <ClientConfig> rst = client.Get(model.PrinterName); if (rst.Code > 0) { return(rst); } printer = rst.Data; } //获取打印条码内容 PrintLabel label = null; using (PrintLabelServiceClient client = new PrintLabelServiceClient()) { MethodReturnResult <PrintLabel> rst = client.Get(model.PrintLabelCode); if (rst.Code > 0) { return(rst); } label = rst.Data; } //获取箱数据 Package box = new Package(); using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { MethodReturnResult <Package> rst = client.Get(model.BoxNo); if (rst.Code <= 0 && rst.Data != null) { box = rst.Data; } else { result = rst; if (result.Code == 1002) { result.Message = string.Format("箱 {0} 数据不存在。", model.BoxNo); } return(result); } } if (box.Quantity <= 0) { result.Code = 2001; result.Message = string.Format("箱 {0} 中数量为零,请确认。", model.BoxNo); return(result); } //获取箱第一包的数据 string packageNo = string.Empty; PackageInfo obj = new PackageInfo(); using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 0, PageSize = 1, Where = string.Format("Key.PackageNo='{0}' AND Key.ObjectType='{1}'" , model.BoxNo , Convert.ToInt32(EnumPackageObjectType.Packet)), OrderBy = "ItemNo" }; MethodReturnResult <IList <PackageDetail> > rst = client.GetDetail(ref cfg); if (rst.Code <= 0 && rst.Data != null && rst.Data.Count > 0) { packageNo = rst.Data[0].Key.ObjectNumber; } } if (!string.IsNullOrEmpty(packageNo)) { using (PackageInfoServiceClient client = new PackageInfoServiceClient()) { MethodReturnResult <PackageInfo> rst = client.Get(packageNo); if (rst.Code <= 0 && rst.Data != null) { obj = rst.Data; } else { result = rst; return(result); } } } //根据打印数量设置打印机模板。 using (IPrintHelper helper = PrintHelperFactory.CreatePrintHelper(label.Content)) { //打印动态内容。 dynamic d = new ExpandoObject(); d.CartonNo = model.BoxNo.ToUpper(); d.Color = obj.Color; d.Date = box.CreateTime.Value.ToString("yyyy.MM.dd"); d.Eff = obj.EfficiencyName; d.Grade = obj.Grade; d.PartNo = obj.ConfigCode; d.PNType = obj.PNType; d.ProdID = obj.ProductId; d.Qty = string.Format("{0}PCS", box.Quantity); d.PrintQty = model.PrintQty; bool bSuccess = false; //根据打印机类型,调用不同的打印方法。 if (printer.ClientType == EnumClientType.NetworkPrinter) { string[] vals = printer.IPAddress.Split(':'); string port = "9100"; if (vals.Length > 1) { port = vals[1]; } bSuccess = helper.NetworkPrint(vals[0], port, label.Content, d); } else if (printer.ClientType == EnumClientType.RawPrinter) { bSuccess = helper.RAWPrint(printer.IPAddress, label.Content, d); } else { result.Code = 1001; result.Message = "打印失败,打印机类型不正确。"; return(result); } //返回打印结果。 if (bSuccess == false) { result.Code = 1001; result.Message = "箱标签打印失败。"; return(result); } } return(result); }