Example #1
0
        public ActionResult PagingQueryPackage(string where, string orderBy, int? currentPageNo, int? currentPageSize)
        {
            if (ModelState.IsValid)
            {
                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 (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {

                    PagingConfig cfg = new PagingConfig()
                    {
                        PageNo = pageNo,
                        PageSize = pageSize,
                        Where = where ?? string.Empty,
                        OrderBy = orderBy ?? string.Empty
                    };
                    MethodReturnResult<IList<PackageDetail>> result = client.GetDetail(ref cfg);
                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List = result.Data;
                    };
                }
            }
            return PartialView("_ListPartialPackage", new IVTestDataForPackageViewModel());
        }
Example #2
0
        public ActionResult QueryPackageNo(String packageNo)
        {
            if (!string.IsNullOrEmpty(packageNo))
            {
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <Package> result2 = client.Get(packageNo.Trim().ToUpper());
                    if (result2.Code == 0)
                    {
                        ViewBag.Package = result2.Data;
                    }
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@"Key.PackageNo='{0}'", packageNo.Trim().ToUpper()),
                        OrderBy  = "ItemNo"
                    };
                    MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PackageDetailList = result.Data;
                    }
                }
            }
            return(PartialView("_ListPackageQuery", new ZPVMLotPackageViewModel()));
        }
Example #3
0
        public ActionResult Query(string boxNo)
        {
            if (!string.IsNullOrEmpty(boxNo))
            {
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "ItemNo",
                        Where    = string.Format(@"Key.PackageNo='{0}' 
                                                AND EXISTS(FROM Package as p
                                                           WHERE p.Key=self.Key.PackageNo
                                                           AND PackageState='{1}' 
                                                           AND PackageType='{2}')"
                                                 , boxNo
                                                 , Convert.ToInt32(EnumPackageState.Packaging)
                                                 , Convert.ToInt32(EnumPackageType.Box))
                    };
                    MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PackageDetailList = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial", new PackageViewModel()));
        }
Example #4
0
        public async Task<ActionResult> QueryPackage(IVTestDataForPackageQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key.PackageNo,ItemNo",
                            Where = GetQueryCondition(model)
                        };
                        MethodReturnResult<IList<PackageDetail>> result = client.GetDetail(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return PartialView("_ListPartialPackage", new IVTestDataForPackageViewModel());
            }
            else
            {
                return View("IndexPackage", model);
            }
        }
Example #5
0
        public ActionResult Query(BoxQueryViewModel model)
        {
            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "Key.PackageNo,ItemNo",
                    Where   = GetQueryCondition(model)
                };
                MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(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));
            }
        }
Example #6
0
        public ActionResult Query(string packageNo)
        {
            //获取需要录入的批次号自定义特性
            IList <BaseAttribute> lstAttribute = new List <BaseAttribute>();

            using (BaseAttributeServiceClient client = new BaseAttributeServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Key.CategoryName='{0}'", "LotPackageAttribute")
                };

                MethodReturnResult <IList <BaseAttribute> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
                {
                    lstAttribute = result.Data;
                }
            }
            ViewBag.AttributeList = lstAttribute;

            if (!string.IsNullOrEmpty(packageNo))
            {
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "ItemNo",
                        Where    = string.Format(@"Key.PackageNo='{0}' 
                                                AND EXISTS(FROM Package as p
                                                           WHERE p.Key=self.Key.PackageNo
                                                           AND ( PackageState='{1}'  or  PackageState='{2}')
                                                           AND PackageType='{3}')"
                                                 , packageNo.ToUpper()
                                                 , Convert.ToInt32(EnumPackageState.Packaging)
                                                 , Convert.ToInt32(EnumPackageState.Packaged)
                                                 , Convert.ToInt32(EnumPackageType.Packet))
                    };

                    MethodReturnResult <Package> result2 = client.Get(packageNo.ToUpper());
                    if (result2.Code == 0)
                    {
                        ViewBag.Package = result2.Data;
                    }

                    MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);


                    if (result.Code == 0)
                    {
                        ViewBag.PackageDetailList = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial", new ZPVMLotViewModel()));
        }
Example #7
0
        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);
        }
Example #8
0
 //获取托明细
 public PackageDetail GetPackageDetail(string PackageNo)
 {
     using (PackageQueryServiceClient client = new PackageQueryServiceClient())
     {
         PagingConfig cfg = new PagingConfig()
         {
             IsPaging = false,
             Where    = string.Format("Key.PackageNo ='{0}' and ItemNo=1", PackageNo)
         };
         MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);
         if (result.Code <= 0 && result.Data != null)
         {
             return(result.Data[0]);
         }
     }
     return(null);
 }
Example #9
0
        public ActionResult Save(LotReworkViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                ReworkParameter p = new ReworkParameter()
                {
                    Creator             = User.Identity.Name,
                    OperateComputer     = Request.UserHostAddress,
                    Operator            = User.Identity.Name,
                    RouteEnterpriseName = model.RouteEnterpriseName,
                    RouteName           = model.RouteName,
                    RouteStepName       = model.RouteStepName,
                    Remark       = model.Description,
                    LotNumbers   = new List <string>(),
                    MaterialCode = model.NewMaterialCode,
                    OrderNumber  = model.NewOrderNumber
                };
                //按批次返工。
                if (model.IsPackageNo == false)
                {
                    string lotNumber = model.LotNumber.ToUpper();
                    p.LotNumbers.Add(lotNumber);
                }
                else //按包装返工。
                {
                    using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            IsPaging = false,
                            Where    = string.Format("Key.PackageNo='{0}'", model.LotNumber)
                        };
                        MethodReturnResult <IList <PackageDetail> > rst1 = client.GetDetail(ref cfg);
                        if (rst1.Code > 0)
                        {
                            return(Json(rst1));
                        }

                        foreach (PackageDetail item in rst1.Data)
                        {
                            p.LotNumbers.Add(item.Key.ObjectNumber);
                        }
                    }

                    if (p.LotNumbers.Count <= 0)
                    {
                        result.Code    = 5;
                        result.Message = string.Format("包装 {0} 不存在。", model.LotNumber);
                        return(Json(result));
                    }
                }

                //foreach (string lotNumber in p.LotNumbers)
                //{
                //    //获取批值。
                //    result = GetLot(lotNumber);
                //    if (result.Code > 0)
                //    {
                //        return Json(result);
                //    }
                //}

                //批次返工操作。
                using (LotReworkServiceClient client = new LotReworkServiceClient())
                {
                    result = client.Rework(p);
                }
                if (result.Code == 0)
                {
                    result.Message = string.Format(" {0} 返工操作成功。", model.LotNumber);
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Example #10
0
        public async Task <ActionResult> ExportToExcel(LotPackageQueryViewModel model)
        {
            IList <PackageDetail> lstLotPackage = new List <PackageDetail>();

            ZPVMLotPackageViewModel m = new ZPVMLotPackageViewModel();

            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.PackageNo,ItemNo",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        lstLotPackage = 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 < lstLotPackage.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("包装号");

                    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("工单号");

                    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("花色");

                    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("最大电流");

                    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("填充因子");

                    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;
                }
                PackageDetail obj     = lstLotPackage[j];
                IRow          rowData = ws.CreateRow(j + 1);
                Lot           lot     = m.GetLotData(obj.Key.ObjectNumber);
                IVTestData    ivtest  = m.GetIVTestData(obj.Key.ObjectNumber);
                List <string> dic     = null;
                string        ff      = "";
                OemData       oemData = m.GetOemData(obj.Key.ObjectNumber);
                if (oemData != null)
                {
                    dic = m.GetCodeAndItemNo(oemData);
                    ff  = (oemData.FF * 100).ToString("F4");
                }
                else
                {
                    lot    = m.GetLotData(obj.Key.ObjectNumber);
                    ivtest = m.GetIVTestData(obj.Key.ObjectNumber);
                }

                #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.PackageNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.ItemNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.ObjectNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.OrderNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.MaterialCode);

                if (oemData != null)
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.Grade);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.Color);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PMAX);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.ISC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.IPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.VOC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.VPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ff);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PnName == null ? string.Empty : oemData.PnName);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PsSubCode);
                }
                else
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(lot != null ? lot.Grade : string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(lot != null ? lot.Color : string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefISC : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefIPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefVOC : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefVPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefFF : 0);

                    string powerName = string.Empty;
                    if (ivtest != null &&
                        !string.IsNullOrEmpty(ivtest.PowersetCode) &&
                        ivtest.PowersetItemNo != null)
                    {
                        powerName = m.GetPowersetName(ivtest.Key.LotNumber, ivtest.PowersetCode, ivtest.PowersetItemNo.Value);
                    }
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(powerName);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.PowersetSubCode : string.Empty);
                }

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(string.Format("{0:yyyy-MM-dd}", obj.CreateTime));
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotPackageData.xls"));
        }
Example #11
0
        public ActionResult ExportToExcel(BoxQueryViewModel model)
        {
            IList <PackageDetail> lstPackageDetail = new List <PackageDetail>();

            PackageViewModel m = new PackageViewModel();

            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "Key.PackageNo,ItemNo",
                    Where   = GetQueryCondition(model)
                };
                MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                if (result.Code == 0)
                {
                    lstPackageDetail = 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 < lstPackageDetail.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.BoxViewModel_BoxNo);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("项目号");

                    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_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(ZPVCResources.StringResource.PackageViewModel_Code);

                    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_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("装箱时间");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作人");

                    #endregion
                    font.Boldweight = 5;
                }

                PackageDetail obj            = lstPackageDetail[j];
                IRow          rowData        = ws.CreateRow(j + 1);
                Package       packageObj     = m.GetPackage(obj.Key.ObjectNumber);
                PackageInfo   packageInfoObj = m.GetPackageInfo(obj.Key.ObjectNumber);
                //ProductionLine plObj = m.GetProductionLine(packageInfoObj.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.PackageNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.ItemNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.ObjectNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.OrderNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.MaterialCode);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.ProductId : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.ConfigCode : string.Empty);

                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(packageInfoObj != null ? packageInfoObj.EfficiencyName : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.Grade : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.Color : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.PNType : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.LineCode : string.Empty);

                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", "BoxData.xls"));
        }
        public ActionResult Save(LotReworkViewModel model)
        {
            MethodReturnResult result    = new MethodReturnResult();
            string             error_mes = string.Empty;

            try
            {
                ReworkParameter p = new ReworkParameter()
                {
                    Creator             = User.Identity.Name,
                    OperateComputer     = Request.UserHostAddress,
                    Operator            = User.Identity.Name,
                    RouteEnterpriseName = model.RouteEnterpriseName,
                    RouteName           = model.RouteName,
                    RouteStepName       = model.RouteStepName,
                    Remark          = model.Description,
                    LotNumbers      = new List <string>(),
                    MaterialCode    = model.NewMaterialCode,
                    OrderNumber     = model.NewOrderNumber,
                    IsPackageRework = true
                };
                //按包装返工。
                //string lotNumber = model.LotNumber.ToUpper();
                //string[] arrlotNumber = model.LotNumber.Split(',');
                //foreach (var data in arrlotNumber)
                //{
                //    using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                //    {

                //        PagingConfig cfg = new PagingConfig()
                //        {
                //            IsPaging = false,
                //            Where = string.Format("Key.PackageNo='{0}'", data.Trim())
                //        };
                //        MethodReturnResult<IList<PackageDetail>> rst1 = client.GetDetail(ref cfg);
                //        if (rst1.Code > 0)
                //        {
                //            return Json(rst1);
                //        }

                //        foreach (PackageDetail item in rst1.Data)
                //        {
                //            p.LotNumbers.Add(item.Key.ObjectNumber);
                //        }
                //    }
                //}

                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format("Key.PackageNo='{0}'", model.LotNumber)
                    };
                    MethodReturnResult <IList <PackageDetail> > rst1 = client.GetDetail(ref cfg);
                    if (rst1.Code > 0)
                    {
                        return(Json(rst1));
                    }

                    foreach (PackageDetail item in rst1.Data)
                    {
                        p.LotNumbers.Add(item.Key.ObjectNumber);
                    }
                }

                if (p.LotNumbers.Count <= 0)
                {
                    //result.Code = 5;
                    //result.Message = string.Format("包装 {0} 不存在。", model.LotNumber);
                    //return Json(result);
                    error_mes = REback(model.LotNumber);
                    if (!string.IsNullOrEmpty(error_mes))
                    {
                        result.Code    = 5;
                        result.Message = string.Format(error_mes);
                        return(Json(result));
                    }
                }
                //string error_mes = string.Empty;
                //error_mes = REback(p.LotNumbers[0]);
                //if (!string.IsNullOrEmpty(error_mes))
                //{
                //    result.Code = 5;
                //    result.Message = string.Format(error_mes);
                //    return Json(result);
                //}
                using (LotReworkServiceClient client = new LotReworkServiceClient())
                {
                    result = client.Rework(p);
                }
                if (result.Code == 0)
                {
                    result.Message = string.Format(" {0} 投料操作成功。", model.LotNumber);
                    //using (LotReworkServiceClient client = new LotReworkServiceClient())
                    //{
                    //   result = client.LotUpdate();
                    //   if (result.Code == 0)
                    //   {
                    //       result.Message =result.Message + string.Format(" 更新批次操作成功。");
                    //   }
                    //}
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Example #13
0
        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);
        }