Esempio n. 1
0
        public MaterialLoading GetMaterialLoading(string loadingNo)
        {
            MaterialLoading obj = new MaterialLoading();

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
                MethodReturnResult <MaterialLoading> result = client.Get(loadingNo);
                if (result.Code <= 0 && result.Data != null)
                {
                    obj = result.Data;
                }
            }
            return(obj);
        }
Esempio n. 2
0
        public async Task <ActionResult> Save(MaterialLoadingViewModel model)
        {
            MethodReturnResult rst = new MethodReturnResult();

            try
            {
                using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
                {
                    MaterialLoading obj = new MaterialLoading()
                    {
                        Key = model.LoadingNo.ToUpper(),
                        RouteOperationName = model.RouteOperationName,
                        ProductionLineCode = model.ProductionLineCode,
                        EquipmentCode      = model.EquipmentCode,
                        Operator           = model.Operator,
                        LoadingTime        = model.LoadingTime,
                        Description        = model.Description,
                        Editor             = User.Identity.Name,
                        Creator            = User.Identity.Name
                    };

                    char splitChar      = ',';
                    var  ItemNos        = Request["ItemNo"].Split(splitChar);
                    var  LineStoreNames = Request["LineStoreName"].Split(splitChar);
                    var  MaterialCodes  = Request["MaterialCode"].Split(splitChar);
                    var  MaterialLots   = Request["MaterialLot"].Split(splitChar);
                    var  Qtys           = Request["LoadingQty"].Split(splitChar);

                    List <MaterialLoadingDetail> lst = new List <MaterialLoadingDetail>();
                    for (int i = 0; i < ItemNos.Length; i++)
                    {
                        lst.Add(new MaterialLoadingDetail()
                        {
                            Key = new MaterialLoadingDetailKey()
                            {
                                LoadingKey = model.LoadingNo,
                                ItemNo     = i + 1
                            },
                            LineStoreName = LineStoreNames[i].ToUpper(),
                            OrderNumber   = model.OrderNumber,
                            MaterialCode  = MaterialCodes[i].ToUpper(),
                            MaterialLot   = MaterialLots[i].ToUpper(),
                            LoadingQty    = Convert.ToDouble(Qtys[i]),
                            CurrentQty    = Convert.ToDouble(Qtys[i]),
                            Editor        = User.Identity.Name,
                            Creator       = User.Identity.Name
                        });
                    }

                    rst = await client.AddAsync(obj, lst);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(LSMResources.StringResource.MaterialLoading_Save_Success
                                                    , obj.Key);
                    }
                }
            }
            catch (Exception ex)
            {
                rst.Code    = 1000;
                rst.Message = ex.Message;
                rst.Detail  = ex.ToString();
            }
            return(Json(rst));
        }
Esempio n. 3
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"));
        }