| | |
| | | using AutoMapper; |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using Magicodes.ExporterAndImporter.Excel; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core; |
| | |
| | | residueQuantity = needQuantity; |
| | | return outStocks; |
| | | } |
| | | |
| | | //å¯¼åº |
| | | public override WebResponseContent Export(PageDataOptions options) |
| | | { |
| | | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport"; |
| | | IExporter exporter = new ExcelExporter(); |
| | | //æ·»å æ¡ä»¶ |
| | | string wheres = options.ValidatePageOptions(TProperties); |
| | | //è·åæåºå段 |
| | | Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(TProperties); |
| | | |
| | | List<Dt_StockInfo> entities = BaseDal.QueryData(wheres, orderbyDic); |
| | | List<Dt_StockInfoDetail> detdata = _stockInfoDetail.QueryData(); |
| | | List<Dt_StockInfodt> stolist= new List<Dt_StockInfodt>(); |
| | | for (int i = 0; i < entities.Count; i++) |
| | | { |
| | | Dt_StockInfoDetail dt_StockIndet = detdata.Where(x => x.StockId == entities[i].Id).FirstOrDefault(); |
| | | string MaterialTypet = "åææ"; |
| | | if (entities[i].MaterialType == (int)InventoryMaterialType.æå) |
| | | { |
| | | MaterialTypet = "æå"; |
| | | } |
| | | else if(entities[i].MaterialType == (int)InventoryMaterialType.空æ) |
| | | { |
| | | MaterialTypet = "空æ"; |
| | | } |
| | | |
| | | string Wlstatust = "å¾
æ£"; |
| | | if (entities[i].Wlstatus== (int)InventoryMaterialStatus.åæ ¼) |
| | | { |
| | | Wlstatust = "åæ ¼"; |
| | | } |
| | | else if (entities[i].Wlstatus == (int)InventoryMaterialStatus.ä¸åæ ¼) |
| | | { |
| | | Wlstatust = "ä¸åæ ¼"; |
| | | } |
| | | else if (entities[i].Wlstatus == (int)InventoryMaterialStatus.空æ) |
| | | { |
| | | Wlstatust = "空æ"; |
| | | } |
| | | else if (entities[i].Wlstatus == (int)InventoryMaterialStatus.éè´§) |
| | | { |
| | | Wlstatust = "éè´§"; |
| | | } |
| | | else if (entities[i].Wlstatus == (int)InventoryMaterialStatus.è¿å·¥) |
| | | { |
| | | Wlstatust = "è¿å·¥"; |
| | | } |
| | | else if (entities[i].Wlstatus == (int)InventoryMaterialStatus.ç¹é) |
| | | { |
| | | Wlstatust = "ç¹é"; |
| | | } |
| | | |
| | | Dt_StockInfodt dt_ = new Dt_StockInfodt() |
| | | { |
| | | PalletCode = entities[i].PalletCode, |
| | | MaterialType = MaterialTypet, |
| | | LocationCode = entities[i].LocationCode, |
| | | Wlstatus = Wlstatust, |
| | | MaterielCode = dt_StockIndet?.MaterielCode ?? "", // 妿 dt_StockIndet 为 nullï¼ä½¿ç¨ç©ºå符串ä½ä¸ºé»è®¤å¼ |
| | | MaterielName = dt_StockIndet?.MaterielName ?? "", |
| | | OrderNo = dt_StockIndet?.OrderNo ?? "", |
| | | BatchNo = dt_StockIndet?.BatchNo ?? "", |
| | | SerialNumber = dt_StockIndet?.SerialNumber ?? "", |
| | | StockQuantity = dt_StockIndet?.StockQuantity ?? 0, // å设 StockQuantity æ¯æ°å¼ç±»åï¼ä½¿ç¨ 0 ä½ä¸ºé»è®¤å¼ |
| | | BatchNoName = dt_StockIndet?.BatchNoName ?? "", |
| | | CreateDate = dt_StockIndet?.CreateDate ?? DateTime.MinValue, // å设 CreateDate æ¯æ¥æç±»åï¼ä½¿ç¨é»è®¤æ¶é´ |
| | | Remark = entities[i].Remark, |
| | | }; |
| | | stolist.Add(dt_); |
| | | } |
| | | |
| | | byte[] data = exporter.ExportAsByteArray(stolist).Result; |
| | | |
| | | string fileName = "1.xlsx"; |
| | | |
| | | FileHelper.WriteFile(savePath, fileName, data); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public class Dt_StockInfodt: Dt_StockInfoDetail |
| | | { |
| | | [ExporterHeader(DisplayName = "æçç¼å·")] |
| | | public string PalletCode { get; set; } |
| | | |
| | | [ExporterHeader(DisplayName = "ç±»å")] |
| | | public string MaterialType { get; set; } |
| | | |
| | | [ExporterHeader(DisplayName = "è´§ä½ç¼å·")] |
| | | public string LocationCode { get; set; } |
| | | |
| | | [ExporterHeader(DisplayName = "ç©æç¶æ")] |
| | | public string Wlstatus { get; set; } |
| | | } |
| | | } |
| | | } |