Browse Source

BUG修复 导出问题全面修复,增加按点匹配导出文件

qinguocai 1 year ago
parent
commit
5b6084e026
50 changed files with 86 additions and 27 deletions
  1. 10 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskNoticeMapper.java
  2. 63 26
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AchievementServiceImpl.java
  3. 1 0
      ruoyi-system/src/main/resources/mapper/MeasureUploadMapper.xml
  4. 12 1
      ruoyi-system/src/main/resources/mapper/TaskNoticeMapper.xml
  5. BIN
      waterAffairs-admin/src/main/resources/excel/test10.xlsx
  6. BIN
      waterAffairs-admin/src/main/resources/excel/test11.xlsx
  7. BIN
      waterAffairs-admin/src/main/resources/excel/test12.xlsx
  8. BIN
      waterAffairs-admin/src/main/resources/excel/test13.xlsx
  9. BIN
      waterAffairs-admin/src/main/resources/excel/test14.xlsx
  10. BIN
      waterAffairs-admin/src/main/resources/excel/test15.xlsx
  11. BIN
      waterAffairs-admin/src/main/resources/excel/test16.xlsx
  12. BIN
      waterAffairs-admin/src/main/resources/excel/test17.xlsx
  13. BIN
      waterAffairs-admin/src/main/resources/excel/test18.xlsx
  14. BIN
      waterAffairs-admin/src/main/resources/excel/test19.xlsx
  15. BIN
      waterAffairs-admin/src/main/resources/excel/test20.xlsx
  16. BIN
      waterAffairs-admin/src/main/resources/excel/test21.xlsx
  17. BIN
      waterAffairs-admin/src/main/resources/excel/test22.xlsx
  18. BIN
      waterAffairs-admin/src/main/resources/excel/test23.xlsx
  19. BIN
      waterAffairs-admin/src/main/resources/excel/test24.xlsx
  20. BIN
      waterAffairs-admin/src/main/resources/excel/test25.xlsx
  21. BIN
      waterAffairs-admin/src/main/resources/excel/test26.xlsx
  22. BIN
      waterAffairs-admin/src/main/resources/excel/test27.xlsx
  23. BIN
      waterAffairs-admin/src/main/resources/excel/test28.xlsx
  24. BIN
      waterAffairs-admin/src/main/resources/excel/test29.xlsx
  25. BIN
      waterAffairs-admin/src/main/resources/excel/test30.xlsx
  26. BIN
      waterAffairs-admin/src/main/resources/excel/test31.xlsx
  27. BIN
      waterAffairs-admin/src/main/resources/excel/test32.xlsx
  28. BIN
      waterAffairs-admin/src/main/resources/excel/test33.xlsx
  29. BIN
      waterAffairs-admin/src/main/resources/excel/test34.xlsx
  30. BIN
      waterAffairs-admin/src/main/resources/excel/test35.xlsx
  31. BIN
      waterAffairs-admin/src/main/resources/excel/test36.xlsx
  32. BIN
      waterAffairs-admin/src/main/resources/excel/test37.xlsx
  33. BIN
      waterAffairs-admin/src/main/resources/excel/test38.xlsx
  34. BIN
      waterAffairs-admin/src/main/resources/excel/test39.xlsx
  35. BIN
      waterAffairs-admin/src/main/resources/excel/test40.xlsx
  36. BIN
      waterAffairs-admin/src/main/resources/excel/test41.xlsx
  37. BIN
      waterAffairs-admin/src/main/resources/excel/test42.xlsx
  38. BIN
      waterAffairs-admin/src/main/resources/excel/test43.xlsx
  39. BIN
      waterAffairs-admin/src/main/resources/excel/test44.xlsx
  40. BIN
      waterAffairs-admin/src/main/resources/excel/test45.xlsx
  41. BIN
      waterAffairs-admin/src/main/resources/excel/test46.xlsx
  42. BIN
      waterAffairs-admin/src/main/resources/excel/test47.xlsx
  43. BIN
      waterAffairs-admin/src/main/resources/excel/test48.xlsx
  44. BIN
      waterAffairs-admin/src/main/resources/excel/test49.xlsx
  45. BIN
      waterAffairs-admin/src/main/resources/excel/test5.xlsx
  46. BIN
      waterAffairs-admin/src/main/resources/excel/test50.xlsx
  47. BIN
      waterAffairs-admin/src/main/resources/excel/test6.xlsx
  48. BIN
      waterAffairs-admin/src/main/resources/excel/test7.xlsx
  49. BIN
      waterAffairs-admin/src/main/resources/excel/test8.xlsx
  50. BIN
      waterAffairs-admin/src/main/resources/excel/test9.xlsx

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskNoticeMapper.java

@@ -31,6 +31,16 @@ public interface TaskNoticeMapper {
      */
     Page<TaskNotice> queryAllByLimit(@Param("siteId") Long siteId, @Param("taskid") String taskid, Page page);
 
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param taskId 主键
+     * @return 实例对象
+     */
+    List<TaskNotice> queryByTaskId(String taskId);
+
+
     /**
      * 统计总行数
      *

+ 63 - 26
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AchievementServiceImpl.java

@@ -33,7 +33,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.net.URL;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
@@ -56,15 +55,14 @@ public class AchievementServiceImpl implements AchievementService {
     @Resource
     private SiteInfoMapper siteInfoMapper;
 
-    @Resource
-    private BerthingPointMapper berthingPointMapper;
-
     @Resource
     private SiteService siteService;
 
     @Autowired
     private BerthingPointConfigMapper berthingPointConfigMapper;
 
+    @Resource
+    private MeasureUploadMapper measureUploadMapper;
 
     @Override
     public Page<TaskResult> queryAchievement(AchievementQuery achievementQuery){
@@ -118,21 +116,29 @@ public class AchievementServiceImpl implements AchievementService {
             if (siteConfig ==  null){
                 throw new BaseException("该站点配置不存在");
             }
-
             //拿断面数据
-            BerthingPoint berthingPoint = berthingPointMapper.queryById(taskResult.getBerthingId());
-            if (berthingPoint == null){
-                throw new BaseException("断面不存在");
-            }
+//            BerthingPoint berthingPoint = berthingPointMapper.queryById(taskResult.getBerthingId());
+//            if (berthingPoint == null){
+//                throw new BaseException("断面不存在");
+//            }
             //拿停泊点数据
             BerthingPointConfig berthingPointConfig = berthingPointConfigMapper.queryById(taskResult.getStopId());
             if (berthingPointConfig == null){
                 throw new BaseException("停泊点配置不存在");
             }
 
+            //拿有水位的启点距和高程
+            List<BigDecimal> positionsList = JSONUtil.toList(taskResult.getPositions(), BigDecimal.class);
+            List<BigDecimal> elevationsList = JSONUtil.toList(taskResult.getElevations(), BigDecimal.class);
+            if (positionsList.size() < 5){
+                throw new BaseException("启点距少于5个不支持导出");
+            } else if (positionsList.size() > 50){
+                throw new BaseException("启点距大于50个点暂不支持导出");
+            }
+
             OutputStream outputStream = response.getOutputStream();
             // 模版文件
-            ClassPathResource classPathResource = new ClassPathResource("excel/test.xlsx");
+            ClassPathResource classPathResource = new ClassPathResource(String.format("excel/test%s.xlsx", positionsList.size()));
             InputStream inputStream = classPathResource.getStream();
             excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).excelType(ExcelTypeEnum.XLSX).autoCloseStream(Boolean.FALSE).build();
             WriteSheet writeSheet = EasyExcel.writerSheet().build();
@@ -166,12 +172,11 @@ public class AchievementServiceImpl implements AchievementService {
             excelWriter.fill(map, writeSheet);
 
             //拿断面数据
-            List<PrintExcelDTO> positionsList = JSONUtil.toList(berthingPoint.getPositions(), PrintExcelDTO.class);
+            List<PrintExcelDTO> berthingPointList = JSONUtil.toList(berthingPointConfig.getPositions(), PrintExcelDTO.class);
+
             //组装列表
             List<Map<String, Object>> dataList = new ArrayList<>();
             List<Map<String, Object>> pgList = new ArrayList<>();
-            List<Double> taskX = JSONUtil.toList(taskResult.getPositions(), Double.class);
-            List<Double> taskY = JSONUtil.toList(taskResult.getElevations(), Double.class);
             List<String> pointConfigfactors = JSONUtil.toList(berthingPointConfig.getFactors(), String.class);
             List<String> taskWspeeds = JSONUtil.toList(taskResult.getWspeeds(), String.class);
             List<String> taskStopwspeeds = JSONUtil.toList(taskResult.getStopwspeeds(), String.class);
@@ -179,6 +184,9 @@ public class AchievementServiceImpl implements AchievementService {
             List<String> acreages = JSONUtil.toList(taskResult.getAcreages(), String.class);
             List<String> taskFlows = JSONUtil.toList(taskResult.getFlows(), String.class);
 
+            //查询任务时间
+            List<MeasureUpload> measureUploadList = measureUploadMapper.queryBySiteIdTime(taskResult.getSiteId(), null , taskResult.getTaskid());
+
             int pnIndex = 0;
             for (int i = 0; i < positionsList.size(); i++) {
                 Map<String, Object> data = MapUtils.newHashMap();
@@ -191,18 +199,36 @@ public class AchievementServiceImpl implements AchievementService {
                 } else {
                     data.put("index", String.valueOf(i));
                 }
-                data.put("x", positionsList.get(i).getX().toString());
-                data.put("y", positionsList.get(i).getY().toString());
+                data.put("x", positionsList.get(i).toString());
+                data.put("y", elevationsList.get(i).toString());
                 data.put("waterlevel",taskResult.getWaterlevel());
-                data.put("subWlevel",BigDecimal.valueOf(taskResult.getWaterlevel()).subtract(BigDecimal.valueOf(positionsList.get(i).getY())));
+                data.put("subWlevel",BigDecimal.valueOf(taskResult.getWaterlevel()).subtract(elevationsList.get(i)));
 
-                if (pnIndex < taskX.size()) {
-                    if (taskX.get(pnIndex).equals(positionsList.get(i).getX()) && taskY.get(pnIndex).equals(positionsList.get(i).getY())) {
+                if (pnIndex < berthingPointList.size()) {
+                    BigDecimal position = positionsList.get(i).setScale(4, RoundingMode.HALF_UP);
+                    BigDecimal berthingPoint = new BigDecimal(String.valueOf(berthingPointList.get(pnIndex).getX())).setScale(4, RoundingMode.HALF_UP);
+                    if (position.equals(berthingPoint)) {
                         data.put("speed", String.valueOf(pnIndex + 1));
-                        data.put("time", "12:00");
+                        if (pnIndex <= measureUploadList.size() - 1) {
+                            data.put("time", measureUploadList.get(pnIndex).getCreateTime());
+                        } else {
+                            data.put("time", "");
+                        }
                         data.put("factors", pointConfigfactors.get(pnIndex));
-                        data.put("wspeeds", taskWspeeds.get(pnIndex));
-                        data.put("stopwspeeds", taskStopwspeeds.get(pnIndex));
+                        if (pnIndex < taskFlows.size()) {
+                            if (pnIndex < taskWspeeds.size()) {
+                                data.put("wspeeds", taskWspeeds.get(pnIndex));
+                            } else {
+                                data.put("wspeeds", "");
+                            }
+                        } else {
+                            data.put("wspeeds", "");
+                        }
+                        if (pnIndex < tasKPartwspeeds.size()) {
+                            data.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
+                        } else {
+                            data.put("partwspeeds", "");
+                        }
                         pnIndex = pnIndex + 1;
                     } else {
                         data.put("speed", "");
@@ -225,9 +251,15 @@ public class AchievementServiceImpl implements AchievementService {
             for (int i = 0; i < positionsList.size(); i++) {
                 Map<String, Object> pgData = MapUtils.newHashMap();
                 if (i < positionsList.size() - 1) {
-                    if (pnIndex < taskX.size()) {
-                        if (taskX.get(pnIndex).equals(positionsList.get(i).getX()) && taskY.get(pnIndex).equals(positionsList.get(i).getY())) {
-                            pgData.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
+                    if (pnIndex < berthingPointList.size()) {
+                        BigDecimal position = positionsList.get(i).setScale(4, RoundingMode.HALF_UP);
+                        BigDecimal berthingPoint = new BigDecimal(String.valueOf(berthingPointList.get(pnIndex).getX())).setScale(4, RoundingMode.HALF_UP);
+                        if (position.equals(berthingPoint)) {
+                            if (pnIndex < tasKPartwspeeds.size()) {
+                                pgData.put("partwspeeds", tasKPartwspeeds.get(pnIndex));
+                            } else {
+                                pgData.put("partwspeeds", "");
+                            }
                             if (i < 2) {
                                 pgData.put("add", acreages.get(0));//部分
                             } else {
@@ -236,11 +268,16 @@ public class AchievementServiceImpl implements AchievementService {
                                 BigDecimal add = bd1.add(bd2);
                                 pgData.put("add", add.toString());
                             }
-                            pgData.put("flows", taskFlows.get(pnIndex));//部分流量
+//                            pgData.put("flows", taskFlows.get(pnIndex));//部分流量
                             pnIndex = pnIndex + 1;
                         } else {
-                            pgData.put("partwspeeds","");
+                            pgData.put("partwspeeds", "");
                             pgData.put("add", "");
+//                            pgData.put("flows", "");
+                        }
+                        if (i < taskFlows.size()) {
+                            pgData.put("flows", taskFlows.get(i));
+                        } else {
                             pgData.put("flows", "");
                         }
                     }

+ 1 - 0
ruoyi-system/src/main/resources/mapper/MeasureUploadMapper.xml

@@ -38,6 +38,7 @@
         </if>
     </select>
 
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="MeasureUploadMap">
         select

+ 12 - 1
ruoyi-system/src/main/resources/mapper/TaskNoticeMapper.xml

@@ -18,11 +18,22 @@
     <!--查询单个-->
     <select id="queryById" resultMap="TaskNoticeMap">
         select
-start_id, taskid, workmode, planid, create_time, site_id, id, remark, code, pn
+            start_id, taskid, workmode, planid, create_time, site_id, id, remark, code, pn
         from task_notice
         where start_id = #{startId}
     </select>
 
+
+    <!--查询单个-->
+    <select id="queryByTaskId" resultMap="TaskNoticeMap">
+        select
+            start_id, taskid, workmode, planid, create_time, site_id, id, remark, code, pn
+        from task_notice
+        where taskid = #{taskid} and pn is not null
+    </select>
+
+
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="TaskNoticeMap">
         select

BIN
waterAffairs-admin/src/main/resources/excel/test10.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test11.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test12.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test13.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test14.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test15.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test16.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test17.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test18.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test19.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test20.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test21.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test22.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test23.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test24.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test25.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test26.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test27.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test28.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test29.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test30.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test31.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test32.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test33.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test34.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test35.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test36.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test37.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test38.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test39.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test40.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test41.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test42.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test43.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test44.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test45.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test46.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test47.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test48.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test49.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test5.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test50.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test6.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test7.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test8.xlsx


BIN
waterAffairs-admin/src/main/resources/excel/test9.xlsx