Quellcode durchsuchen

bug

Signed-off-by: liuyc <56808083@qq.com>
liuyc vor 8 Monaten
Ursprung
Commit
ccb477f46b

+ 59 - 34
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialSummaryMonthlyController.java

@@ -1,8 +1,6 @@
 package org.springblade.business.controller;
 
-import com.aspose.cells.PageSetup;
-import com.aspose.cells.PaperSizeType;
-import com.aspose.cells.PdfSaveOptions;
+import com.aspose.cells.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -11,6 +9,9 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.*;
 import org.springblade.business.dto.TrialSummaryMonthlyEditDTO;
@@ -30,10 +31,7 @@ import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
 import java.io.*;
-import java.net.URLDecoder;
 import java.util.*;
 import java.util.List;
 import java.util.function.Function;
@@ -207,7 +205,7 @@ public class TrialSummaryMonthlyController {
     @PostMapping("/monthly/download")
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "月报汇总下载", notes = "传入TrialSummaryMonthlyPageDTO")
-    public void monthlyDownload(@RequestBody TrialSummaryMonthlyPageDTO dto, HttpServletResponse response) {
+    public R<Object> monthlyDownload(@RequestBody TrialSummaryMonthlyPageDTO dto) {
         List<Map<String, Object>> records = monthlyPage(dto).getData().getRecords();
         try (Workbook workbook = new XSSFWorkbook()) {
             Sheet sheet = workbook.createSheet("Sheet1");
@@ -278,24 +276,21 @@ public class TrialSummaryMonthlyController {
             sheet.setColumnWidth(3, 5000);
             sheet.setColumnWidth(4, 5000);
 
-            try (ServletOutputStream outputStream = response.getOutputStream();
-                 ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
-                String fileName = dto.getStartTime() + "~" + dto.getEndTime() + ".xlsx";
-                String decodedFileName = URLDecoder.decode(fileName, "UTF-8");
-                response.setHeader("Content-Disposition", "attachment; filename=\"" + decodedFileName + "\"");
-                response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-                workbook.write(byteArrayOutputStreamResult);
-                byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();
-                outputStream.write(excelBytesResult);
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+            workbook.write(byteArrayOutputStream);
+            byte[] excelBytes = byteArrayOutputStream.toByteArray();
+            ByteArrayResource resource = new ByteArrayResource(excelBytes);
+            MockMultipartFile multipartFile = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".xlsx", "application/vnd.ms-excel", resource.getInputStream());
 
-            } catch (IOException e) {
-                e.printStackTrace();
-            } finally {
-                workbook.close();
+            BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
+            if (bladeFile != null) {
+                return R.data(bladeFile.getLink());
             }
+
         } catch (IOException e) {
             e.printStackTrace();
         }
+        return R.fail("操作失败");
     }
 
     private void setCellValueWithNullCheck(Cell cell, String defaultValue, Object value) {
@@ -310,7 +305,12 @@ public class TrialSummaryMonthlyController {
     @ApiOperationSupport(order = 4)
     @ApiOperation(value = "月报汇总打印", notes = "传入TrialSummaryMonthlyPageDTO")
     public R<Object> monthlyPrint(@RequestBody TrialSummaryMonthlyPageDTO dto) {
-        List<Map<String, Object>> records = monthlyPage(dto).getData().getRecords();
+        IPage<Map<String, Object>> data = monthlyPage(dto).getData();
+        long size = data.getSize();
+        List<Map<String, Object>> records = data.getRecords();
+        if (records.size() <= 0) {
+            return R.data(null);
+        }
         try (Workbook workbook = new XSSFWorkbook()) {
             Sheet sheet = workbook.createSheet("Sheet1");
             Row titleRow_1 = sheet.createRow(0);
@@ -352,24 +352,49 @@ public class TrialSummaryMonthlyController {
             setCellValueWithNullCheck(titleRow_2.createCell(3), "不合格数", "");
             setCellValueWithNullCheck(titleRow_2.createCell(4), "备注", "");
 
+            if (records.size() < size) {
+                int a = (int) size - records.size();
+                for (long i = 0; i < a; i++) {
+                    records.add(new HashMap<>());
+                }
+            }
+
             int rowNum = 2;
             for (Map<String, Object> record : records) {
                 Row currentMonthRow = sheet.createRow(rowNum);
                 sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum + 1, 0, 0));
-                setCellValueWithNullCheck(currentMonthRow.createCell(0), "", record.get("trialProjectName"));
-
-                Map<String, Object> currentMonth = (Map<String, Object>) record.get("currentMonth");
-                setCellValueWithNullCheck(currentMonthRow.createCell(1), "本月", "");
-                setCellValueWithNullCheck(currentMonthRow.createCell(2), "", currentMonth.get("qualifiedTotal"));
-                setCellValueWithNullCheck(currentMonthRow.createCell(3), "", currentMonth.get("unQualifiedTotal"));
-                setCellValueWithNullCheck(currentMonthRow.createCell(4), "", currentMonth.get("remarks"));
 
-                Map<String, Object> totalMonth = (Map<String, Object>) record.get("totalMonth");
-                Row totalMonthRow = sheet.createRow(++rowNum);
-                setCellValueWithNullCheck(totalMonthRow.createCell(1), "累计", "");
-                setCellValueWithNullCheck(totalMonthRow.createCell(2), "", totalMonth.get("qualifiedTotal"));
-                setCellValueWithNullCheck(totalMonthRow.createCell(3), "", totalMonth.get("unQualifiedTotal"));
-                setCellValueWithNullCheck(totalMonthRow.createCell(4), "", totalMonth.get("remarks"));
+                if (ObjectUtil.isNotEmpty(record)) {
+                    setCellValueWithNullCheck(currentMonthRow.createCell(0), "", record.get("trialProjectName"));
+
+                    Map<String, Object> currentMonth = (Map<String, Object>) record.get("currentMonth");
+                    setCellValueWithNullCheck(currentMonthRow.createCell(1), "本月", "");
+                    setCellValueWithNullCheck(currentMonthRow.createCell(2), "", currentMonth.get("qualifiedTotal"));
+                    setCellValueWithNullCheck(currentMonthRow.createCell(3), "", currentMonth.get("unQualifiedTotal"));
+                    setCellValueWithNullCheck(currentMonthRow.createCell(4), "", currentMonth.get("remarks"));
+
+                    Map<String, Object> totalMonth = (Map<String, Object>) record.get("totalMonth");
+                    Row totalMonthRow = sheet.createRow(++rowNum);
+                    setCellValueWithNullCheck(totalMonthRow.createCell(1), "累计", "");
+                    setCellValueWithNullCheck(totalMonthRow.createCell(2), "", totalMonth.get("qualifiedTotal"));
+                    setCellValueWithNullCheck(totalMonthRow.createCell(3), "", totalMonth.get("unQualifiedTotal"));
+                    setCellValueWithNullCheck(totalMonthRow.createCell(4), "", totalMonth.get("remarks"));
+
+                } else {
+                    /*打印空行*/
+                    setCellValueWithNullCheck(currentMonthRow.createCell(0), "", "");
+
+                    setCellValueWithNullCheck(currentMonthRow.createCell(1), "", "");
+                    setCellValueWithNullCheck(currentMonthRow.createCell(2), "", "");
+                    setCellValueWithNullCheck(currentMonthRow.createCell(3), "", "");
+                    setCellValueWithNullCheck(currentMonthRow.createCell(4), "", "");
+
+                    Row totalMonthRow = sheet.createRow(++rowNum);
+                    setCellValueWithNullCheck(totalMonthRow.createCell(1), "", "");
+                    setCellValueWithNullCheck(totalMonthRow.createCell(2), "", "");
+                    setCellValueWithNullCheck(totalMonthRow.createCell(3), "", "");
+                    setCellValueWithNullCheck(totalMonthRow.createCell(4), "", "");
+                }
 
                 rowNum++;
             }

+ 10 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -1025,7 +1025,7 @@ public class TaskController extends BladeController {
         int totalCount = totalCountOptional.orElse(0);
 
         /*分页*/
-        sqlString.append(" ORDER BY create_time ASC LIMIT ? OFFSET ?;");
+        sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?;");
         params.add(size);
         params.add((current - 1) * size);
 
@@ -2535,6 +2535,9 @@ public class TaskController extends BladeController {
             middleMeterApplyService.saveBatch(middleMeterApplies, 1000);
             inventoryFormApplyService.saveBatch(inventoryFormApplies, 1000);
 
+            /*中间计量期状态修改=已审批*/
+            jdbcTemplate.update("UPDATE s_contract_meter_period SET approve_status = 2 WHERE id = ? ", task.getFormDataId());
+
         } else if (task.getMeterTaskType().equals(2)) {
             List<MaterialMeterFormTask> materialMeterFormTasks = materialMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<MaterialMeterFormTask>lambdaQuery()
                     .eq(MaterialMeterFormTask::getMeterPeriodId, task.getFormDataId())
@@ -2549,6 +2552,9 @@ public class TaskController extends BladeController {
             }
             materialMeterFormService.saveBatch(materialMeterForms, 1000);
 
+            /*材料计量期状态修改=已审批*/
+            jdbcTemplate.update("UPDATE s_meter_period SET approve_status = 2 WHERE id = ? ", task.getFormDataId());
+
         } else if (task.getMeterTaskType().equals(3)) {
             List<StartPayMeterFormTask> startPayMeterFormTasks = startPayMeterFormServiceTask.getBaseMapper().selectList(Wrappers.<StartPayMeterFormTask>lambdaQuery()
                     .eq(StartPayMeterFormTask::getMeterPeriodId, task.getFormDataId())
@@ -2563,6 +2569,9 @@ public class TaskController extends BladeController {
             }
             startPayMeterFormService.saveBatch(startPayMeterForms, 1000);
 
+            /*开工预付款计量期状态修改=已审批*/
+            jdbcTemplate.update("UPDATE s_meter_period SET approve_status = 2 WHERE id = ? ", task.getFormDataId());
+
         } else if (task.getMeterTaskType().equals(4)) {
             for (String dataId : task.getFormDataId().split(",")) {
                 ChangeTokenFormTask changeTokenFormTask = changeTokenFormServiceTask.getById(dataId);