Exemplo n.º 1
0
        public async Task <ActionResult> DetailQuery(MaterialLoadingDetailQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "CreateTime Desc,Key.LoadingKey,Key.ItemNo",
                            Where   = GetWhereCondition(model)
                        };
                        MethodReturnResult <IList <MaterialLoadingDetail> > result = client.GetDetail(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_DetailListPartial", new MaterialLoadingDetailViewModel()));
            }
            else
            {
                return(View("Detail", model));
            }
        }
Exemplo n.º 2
0
        public ActionResult GetLoadingNo(string q, string orderNumber, string equipmentCode)
        {
            IList <MaterialLoadingDetail> lstDetail = new List <MaterialLoadingDetail>();

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"(Key.LoadingKey LIKE '{0}%'
                                             OR MaterialCode LIKE '{0}%'
                                             OR MaterialLot LIKE '{0}%')
                                             AND EXISTS(FROM MaterialLoading as p 
                                                        WHERE p.Key=self.Key.LoadingKey
                                                        AND p.EquipmentCode='{1}')
                                             AND CurrentQty>0
                                             AND OrderNumber='{2}'"
                                             , q
                                             , equipmentCode
                                             , orderNumber),
                    OrderBy = "Key"
                };

                MethodReturnResult <IList <MaterialLoadingDetail> > result = client.GetDetail(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstDetail = result.Data;
                }
            }

            return(Json(from item in lstDetail
                        select new
            {
                @value = item.MaterialLot,
                @label = @LSMResources.StringResource.MaterialUnloadingDetailViewModel_LoadingNo + ":" + item.Key.LoadingKey
                         + " " + @LSMResources.StringResource.MaterialUnloadingDetailViewModel_LoadingItemNo + ":" + item.Key.ItemNo
                         + " " + @LSMResources.StringResource.MaterialUnloadingDetailViewModel_MaterialLot + ":" + item.MaterialLot
                         + " " + GetMaterialName(item.MaterialCode),
                @LoadingNo = item.Key.LoadingKey,
                @LoadingItemNo = item.Key.ItemNo,
                @LineStoreName = item.LineStoreName,
                @MaterialCode = item.MaterialCode,
                @CurrentQty = item.CurrentQty
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> DetailPagingQuery(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 (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <MaterialLoadingDetail> > result = client.GetDetail(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_DetailListPartial", new MaterialLoadingDetailViewModel()));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> ExportToExcel(MaterialLoadingDetailQueryViewModel model)
        {
            IList <MaterialLoadingDetail> lst = new List <MaterialLoadingDetail>();

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "CreateTime Desc,Key.LoadingKey,Key.ItemNo",
                        Where    = GetWhereCondition(model)
                    };
                    MethodReturnResult <IList <MaterialLoadingDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        lst = 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);
            ICell  cell = null;
            IRow   row  = null;
            ISheet ws   = null;

            for (int j = 0; j < lst.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws  = wb.CreateSheet();
                    row = ws.CreateRow(0);
                    #region //列名
                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_LoadingNo);  //上料号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_RouteOperationName);  //工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_ProductionLineCode);  //生产线

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_EquipmentCode);  //设备

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("上料日期");  //上料时间

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_LoadingTime);  //上料时间

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_Operator);  //操作人

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_LineStoreName);  //线边仓

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingViewModel_OrderNumber);  //工单号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_MaterialCode);  //物料编码

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("物料名称");  //物料名称

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_MaterialLot);  //物料批号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_LoadingQty);  //上料数量

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_UnloadingQty);  //下料数量

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialLoadingDetailViewModel_CurrentQty);  //当前数量

                    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;
                }

                MaterialLoadingDetail obj = lst[j];
                MaterialLoading       objMaterialLoading = model.GetMaterialLoading(obj.Key.LoadingKey);
                Material m = model.GetMaterial(obj.MaterialCode);
                row = ws.CreateRow(j + 1);

                #region //数据
                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.LoadingKey);  //上料号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ItemNo);  //项目号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(objMaterialLoading.RouteOperationName);  //工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(objMaterialLoading.ProductionLineCode);  //生产线

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(objMaterialLoading.EquipmentCode);  //设备

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd}", objMaterialLoading.LoadingTime));  //上料日期

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", objMaterialLoading.LoadingTime));  //上料时间

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

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.LineStoreName);  //线边仓

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.OrderNumber);  //工单号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.MaterialCode);  //物料编码

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(m == null ? string.Empty : m.Name);  //物料名称

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.MaterialLot);  //物料批号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.LoadingQty);  //上料数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.UnloadingQty);  //下料数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.CurrentQty);  //当前数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Editor);  //编辑人

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime));  //编辑时间
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "MaterialLoadingData.xls"));
        }
Exemplo n.º 5
0
        public ActionResult GetLoadingNo(string q, string orderNumber, string equipmentCode)
        {
            //设备尚余上料明细
            IList <MaterialLoadingDetail> lstDetail = new List <MaterialLoadingDetail>();

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
//                Where = string.Format(@"(Key.LoadingKey LIKE '{0}%'
//                                             OR MaterialCode LIKE '{0}%'
//                                             OR MaterialLot LIKE '{0}%')
//                                             AND EXISTS(FROM MaterialLoading as p
//                                                        WHERE p.Key = self.Key.LoadingKey
//                                                        AND p.EquipmentCode = '{1}')
//                                             AND CurrentQty > 0
//                                             AND OrderNumber = '{2}'"
//                                             , q
//                                             , equipmentCode
//                                             , orderNumber),

                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@" MaterialLot LIKE '{0}%'
                                             AND EXISTS(FROM MaterialLoading as p 
                                                        WHERE p.Key = self.Key.LoadingKey
                                                        AND p.EquipmentCode = '{1}')
                                             AND CurrentQty > 0
                                             AND OrderNumber = '{2}'"
                                             , q
                                             , equipmentCode
                                             , orderNumber),
                    OrderBy = "Key"
                };

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

                if (result.Code <= 0 && result.Data != null)
                {
                    lstDetail = result.Data;
                }
            }

            //线边仓物料明细
//            IList<LineStoreMaterialDetail> lstLSMDetail = new List<LineStoreMaterialDetail>();
//            using (LineStoreMaterialServiceClient client = new LineStoreMaterialServiceClient())
//            {
//                PagingConfig cfg = new PagingConfig()
//                {
//                    IsPaging = false,
//                    Where = string.Format(@"Key.MaterialLot LIKE '{0}%'
//                                            AND Key.OrderNumber = '{1}'
//                                            AND EXISTS(FROM MaterialLoadingDetail as mloaddetail
//                                                       WHERE mloaddetail.LineStoreName = self.Key.LineStoreName
//                                                        AND mloaddetail.OrderNumber = self.Key.OrderNumber
//                                                        AND mloaddetail.MaterialCode = self.Key.MaterialCode
//                                                        AND mloaddetail.MaterialLot = self.Key.MaterialLot
//                                                        AND mloaddetail.OrderNumber = '{1}'
//                                                        AND mloaddetail.CurrentQty > 0
//                                                        AND EXISTS(FROM MaterialLoading as mload
//                                                                   WHERE mload.Key = mloaddetail.Key.LoadingKey
//                                                                     AND mload.EquipmentCode = '{2}'))"
//                                             , q
//                                             , orderNumber
//                                             , equipmentCode)
//                };

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

//                if (result.Code <= 0 && result.Data != null)
//                {
//                    lstLSMDetail = result.Data;
//                }
//            }

            //取得对应物料明细
            IList <Material> lstMaterial = new List <Material>();

            using (MaterialServiceClient client = new MaterialServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@" EXISTS(FROM MaterialLoadingDetail as mloaddetail
                                                    WHERE mloaddetail.MaterialCode = self.Key
                                                      AND mloaddetail.OrderNumber = '{0}'
                                                      AND mloaddetail.CurrentQty > 0
                                                      AND EXISTS(FROM MaterialLoading as mload
                                                                 WHERE mload.Key = mloaddetail.Key.LoadingKey            
                                                                   AND mload.EquipmentCode = '{1}'))"
                                             , orderNumber
                                             , equipmentCode)
                };

                MethodReturnResult <IList <Material> > result = client.Get(ref cfg);

                if (result.Code <= 0 && result.Data != null)
                {
                    lstMaterial = result.Data;
                }
            }

            //取得对应供应商明细
//            IList<Supplier> lstSupplier = new List<Supplier>();

//            using (SupplierServiceClient client = new SupplierServiceClient())
//            {
//                PagingConfig cfg = new PagingConfig()
//                {
//                    IsPaging = false,
//                    Where = string.Format(@" EXISTS(FROM LineStoreMaterialDetail as p
//                                                    WHERE p.SupplierCode = self.Key
//                                                    AND p.Key.OrderNumber = '{0}'
//                                                    AND EXISTS(FROM MaterialLoadingDetail as mloaddetail
//                                                                   WHERE mloaddetail.LineStoreName = p.Key.LineStoreName
//                                                                      AND mloaddetail.OrderNumber = p.Key.OrderNumber
//                                                                      AND mloaddetail.MaterialCode = p.Key.MaterialCode
//                                                                      AND mloaddetail.MaterialLot = p.Key.MaterialLot
//                                                                      AND mloaddetail.OrderNumber = '{0}'
//                                                                      AND mloaddetail.CurrentQty > 0
//                                                                      AND EXISTS(FROM MaterialLoading as mload
//                                                                                   WHERE mload.Key = mloaddetail.Key.LoadingKey
//                                                                                     AND mload.EquipmentCode = '{1}')))"
//                                            , orderNumber
//                                            , equipmentCode)
//                };

//                MaterialLoading dd = new MaterialLoading();

//                MethodReturnResult<IList<Supplier>> result = client.Get(ref cfg);

//                if (result.Code <= 0 && result.Data != null)
//                {
//                    lstSupplier = result.Data;
//                }
//            }

            //var lnq = from item in lstDetail
            //          select new
            //          {
            //              @value = item.MaterialLot,
            //              @label = "上料号:[ " + item.Key.LoadingKey
            //                          + "," + item.Key.ItemNo + " ]"
            //                          + " 批次:[ " + item.MaterialLot + " ]"
            //                          + " 物料:[ " + item.MaterialCode
            //                          + "," + GetMaterialName(item.MaterialCode) + " ]"
            //                          + " 供应商:[" + (lstLSMDetail.Where(m => m.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                      ? lstLSMDetail.Where(m => m.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                      : string.Empty)
            //                          + "," + (lstSupplier.Where(m => m.Key == (lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                                                              ? lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                                                              : string.Empty)).SingleOrDefault() != null
            //                                      ? lstSupplier.Where(m => m.Key == (lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                                                              ? lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                                                              : string.Empty)).SingleOrDefault().Name
            //                                      : string.Empty) + "]",
            //              @LoadingNo = item.Key.LoadingKey,
            //              @LoadingItemNo = item.Key.ItemNo,
            //              @LineStoreName = item.LineStoreName,
            //              @MaterialCode = item.MaterialCode,
            //              @CurrentQty = item.CurrentQty,
            //              @MaterialDesc = (lstMaterial.Where(m => m.Key == item.MaterialCode).SingleOrDefault() != null
            //                                      ? lstMaterial.Where(m => m.Key == item.MaterialCode).SingleOrDefault().Name
            //                                      : string.Empty),
            //              @SupplierCode = (lstLSMDetail.Where(m => m.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                      ? lstLSMDetail.Where(m => m.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                      : string.Empty),
            //              @SupplierDesc = (lstSupplier.Where(m => m.Key == (lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                                                              ? lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                                                              : string.Empty)).SingleOrDefault() != null
            //                                      ? lstSupplier.Where(m => m.Key == (lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault() != null
            //                                                                              ? lstLSMDetail.Where(n => n.Key.MaterialLot == item.MaterialLot).SingleOrDefault().SupplierCode
            //                                                                              : string.Empty)).SingleOrDefault().Name
            //                                      : string.Empty)

            //          };

            var lnq = from item in lstDetail
                      select new
            {
                @value = item.MaterialLot,
                @label = "上料号:[ " + item.Key.LoadingKey
                         + "," + item.Key.ItemNo + " ]"
                         + " 批次:[ " + item.MaterialLot + " ]"
                         + " 物料:[ " + item.MaterialCode
                         + "," + GetMaterialName(item.MaterialCode) + " ]",
                @LoadingNo     = item.Key.LoadingKey,
                @LoadingItemNo = item.Key.ItemNo,
                @LineStoreName = item.LineStoreName,
                @MaterialCode  = item.MaterialCode,
                @CurrentQty    = item.CurrentQty,
                @MaterialDesc  = (lstMaterial.Where(m => m.Key == item.MaterialCode).SingleOrDefault() != null
                                                  ? lstMaterial.Where(m => m.Key == item.MaterialCode).SingleOrDefault().Name
                                                  : string.Empty)
            };

            return(Json(lnq, JsonRequestBehavior.AllowGet));
        }