/// <summary> /// 计算容积率、载重量 /// </summary> /// <param name="entity"></param> /// <returns></returns> public IActionResult Calculate([FromBody] CheckEntityView entity) { Task.Run(() => //异步开始执行 { try { var addrUrl = _hostingEnvironment.WebRootPath + "/upload/" + entity.RealityTable; _checkTableAppService.InsertCableSummarizedBill(entity.NumberNo, addrUrl); var list = _checkTableAppService.GetBridgeInstancesListByNumberNo(entity.NumberNo); string file = _hostingEnvironment.WebRootPath + "/upload/" + entity.NumberNo + ".xlsx"; NPOIHelper nPOI = new NPOIHelper(file); List <ReportView> reports = new List <ReportView>(); foreach (var bridgeInstancese in list) { var reportView = _checkTableAppService.SummationCable(entity.NumberNo, bridgeInstancese.BridgeCode); reportView.BridgeCode = bridgeInstancese.BridgeCode; reportView.PassageType = bridgeInstancese.PassageType; reportView.SectionalArea = double.Parse(bridgeInstancese.SectionalArea); reportView.WeightLimit = double.Parse(bridgeInstancese.WeightLimit); reportView.PlotRatioLimit = double.Parse(bridgeInstancese.PlotRatioLimit); reportView.PlotRatio = Math.Round(reportView.CableArea / reportView.SectionalArea, 2); reports.Add(reportView); } var bridgelist = _bridgeConstantAppService.GetListToNotIn(list.Select(u => u.BridgeCode).ToList()); foreach (var item in bridgelist.GroupBy(u => u.BridgeCode)) { ReportView reportView = new ReportView(); reportView.CableArea = 0; reportView.CableWeight = 0; reportView.CableNumber = 0; reportView.CableCodes = ""; reportView.BridgeCode = item.Key; reportView.PassageType = string.Join("/", item.Select(u => u.PassageType)); reportView.SectionalArea = double.Parse(item.First().SectionalArea); reportView.WeightLimit = double.Parse(item.First().WeightLimit); reportView.PlotRatioLimit = double.Parse(item.First().PlotRatioLimit); reportView.PlotRatio = Math.Round(reportView.CableArea / reportView.SectionalArea, 2); reports.Add(reportView); } nPOI.Insert(reports.OrderByDescending(u => u.PlotRatio).ToList()); nPOI.Save(); _reportResultAppService.Create(new ReportResultDto() { Name = "生成计算容积率报告成功", Url = entity.NumberNo + ".xlsx", Description = entity.NumberNo }); } catch (Exception e) { Console.WriteLine(e); _reportResultAppService.Create(new ReportResultDto() { Name = "生成报告失败", Url = entity.NumberNo + ".xlsx", Description = entity.NumberNo }); } }); return(Ok(entity.NumberNo)); }
public IActionResult TransferFormat1([FromBody] CheckEntityView entity) { DeleteFile(entity.NumberNo + ".xlsx"); string file = _hostingEnvironment.WebRootPath + "/upload/" + entity.NumberNo + ".xlsx"; var designlist = _checkTableAppService.GetCableLayingDetailsListByNumberNo(entity.NumberNo); NPOIstaticHelper.DesignSourceCollect(file, designlist); return(DownLoad(entity.NumberNo + ".xlsx")); }
/// <summary> /// 校验 /// </summary> /// <param name="entity"></param> /// <returns></returns> public IActionResult Check([FromBody] CheckEntityView entity) { try { DeleteFile(entity.NumberNo + ".xlsx"); string webRootPath = _hostingEnvironment.WebRootPath; var designlist = _checkTableAppService.GetCableLayingDetailsListByNumberNo(entity.NumberNo); List <string> list = new List <string>(); Workbook wb = new Workbook(webRootPath + "/upload/" + entity.RealityTable); var sheet = wb.Worksheets[0]; var maxCol = sheet.Cells.MaxColumn + 1; for (int i = 1; i < sheet.Cells.MaxRow + 1; i++) { var cablecode = sheet.Cells[i, 2].Value.ToString().Trim(); var flag = designlist.Exists(u => u.CableCode == cablecode); sheet.Cells[i, maxCol].HtmlString = (!flag ? "<span style='color:red;'>和设计不一致</span>" : "<span style='color:blue;'>和设计一致</span>"); list.Add(cablecode); } var maxRow = sheet.Cells.MaxRow + 2; foreach (var detailse in designlist) { var flag = list.Exists(u => u == detailse.CableCode); if (!flag) { Aspose.Cells.Style style = sheet.Cells[maxRow, 2].GetStyle(); //设置背景颜色 style.ForegroundColor = System.Drawing.Color.Red; style.Pattern = BackgroundType.Solid; sheet.Cells[maxRow, 2].SetStyle(style); sheet.Cells[maxRow, 2].PutValue(detailse.CableCode); sheet.Cells[maxRow, 8].PutValue(detailse.Start.RoomCode); sheet.Cells[maxRow, 9].PutValue(detailse.Start.SystemName); sheet.Cells[maxRow, 10].PutValue(detailse.Start.EquitName); sheet.Cells[maxRow, 11].PutValue(detailse.Start.EquitCode); sheet.Cells[maxRow, 12].PutValue(detailse.End.RoomCode); sheet.Cells[maxRow, 13].PutValue(detailse.End.SystemName); sheet.Cells[maxRow, 14].PutValue(detailse.End.EquitName); sheet.Cells[maxRow, 15].PutValue(detailse.End.EquitCode); sheet.Cells[maxRow, 16].PutValue(detailse.SafePassage); sheet.Cells[maxRow, 17].PutValue(detailse.PressureVesselCode); sheet.Cells[maxRow, 18].PutValue(detailse.CabinCode); sheet.Cells[maxRow, 19].PutValue(detailse.PipeCode); sheet.Cells[maxRow, 20].PutValue(detailse.Version); sheet.Cells[maxRow, 21].PutValue(detailse.Specification); sheet.Cells[maxRow, 22].PutValue(detailse.Length); sheet.Cells[maxRow, 23].PutValue(detailse.PipeSpecification); sheet.Cells[maxRow, 24].PutValue(detailse.PipeLength); sheet.Cells[maxRow, 25].PutValue(detailse.CablePath); sheet.Cells[maxRow, 26].PutValue(detailse.Other); maxRow += 1; } } string fileExt = "." + entity.RealityTable.Split('.')[1]; //获取文件的ContentType var provider = new FileExtensionContentTypeProvider(); var memi = provider.Mappings[fileExt]; MemoryStream stream = new MemoryStream(); wb.Save(stream, Aspose.Cells.SaveFormat.Xlsx); stream.Position = 0; return(File(stream, memi)); } catch (Exception e) { Console.WriteLine(e); //throw; return(StatusCode(500, e.Message)); } }