Browse Source

feat: ....

master
LeoAnn 1 day ago
parent
commit
3a8f9b199e
  1. BIN
      ruoyi-admin/src/main/resources/excel/flowResult.xls
  2. BIN
      ruoyi-admin/src/main/resources/excel/hyXsmsrsG.xls
  3. 15
      ruoyi-admin/src/test/java/com/ruoyi/swlscx/day/service/impl/HyDpCServiceImplTest.java
  4. 52
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/controller/ActualSurveyController.java
  5. 56
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/controller/ActualSurveyExportController.java
  6. 48
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/po/HyObqG.java
  7. 33
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/po/HyXsmsrsG.java
  8. 60
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/vo/HyObqGVo.java
  9. 44
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/vo/HyXsmsrsGVo.java
  10. 25
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/mapper/HyObqGMapper.java
  11. 25
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/mapper/HyXsmsrsGMapper.java
  12. 26
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/HyObqGService.java
  13. 22
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/HyXsmsrsGService.java
  14. 210
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/impl/HyObqGServiceImpl.java
  15. 187
      swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/impl/HyXsmsrsGServiceImpl.java
  16. 32
      swlscx/src/main/java/com/ruoyi/swlscx/basic/controller/BaseInfoController.java
  17. 4
      swlscx/src/main/java/com/ruoyi/swlscx/basic/mapper/HyStscAMapper.java
  18. 12
      swlscx/src/main/java/com/ruoyi/swlscx/basic/service/impl/HyStscAServiceImpl.java
  19. 11
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/controller/TimeTasksController.java
  20. 35
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/dto/YcResStatInfo.java
  21. 33
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/mapper/YcResTableInfoMapper.java
  22. 15
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/YcResTableInfoService.java
  23. 81
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/impl/TimeTasksServiceImpl.java
  24. 224
      swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/impl/YcResTableInfoServiceImpl.java
  25. 70
      swlscx/src/main/resources/mapper/actualSurvey/HyObqGMapper.xml
  26. 54
      swlscx/src/main/resources/mapper/actualSurvey/HyXsmsrsGMapper.xml
  27. 32
      swlscx/src/main/resources/mapper/basic/HyStscAMapper.xml
  28. 84
      swlscx/src/main/resources/mapper/synchronousData/YcResTableInfoMapper.xml

BIN
ruoyi-admin/src/main/resources/excel/flowResult.xls

Binary file not shown.

BIN
ruoyi-admin/src/main/resources/excel/hyXsmsrsG.xls

Binary file not shown.

15
ruoyi-admin/src/test/java/com/ruoyi/swlscx/day/service/impl/HyDpCServiceImplTest.java

@ -8,6 +8,7 @@ import com.ruoyi.swlscx.basic.service.YcExportTaskService;
import com.ruoyi.swlscx.common.PageParams; import com.ruoyi.swlscx.common.PageParams;
import com.ruoyi.swlscx.day.service.HyDcsFService; import com.ruoyi.swlscx.day.service.HyDcsFService;
import com.ruoyi.swlscx.day.service.HyDwtCService; import com.ruoyi.swlscx.day.service.HyDwtCService;
import com.ruoyi.swlscx.day.service.HyZscsBService;
import com.ruoyi.swlscx.excerpt.service.HyHltdzBService; import com.ruoyi.swlscx.excerpt.service.HyHltdzBService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +40,9 @@ class HyDpCServiceImplTest {
@Autowired @Autowired
private HyStscAService hyStscAService; private HyStscAService hyStscAService;
@Autowired
private HyZscsBService hyZscsBService;
@Test @Test
public void importData() throws Exception { public void importData() throws Exception {
@ -49,12 +53,13 @@ class HyDpCServiceImplTest {
// "逐潮高低潮位表201501-201701", // "逐潮高低潮位表201501-201701",
// "逐潮高低潮位表201701-202001" // "逐潮高低潮位表201701-202001"
// ,"逐潮高低潮位表202001-"); // ,"逐潮高低潮位表202001-");
List<String> stringList = Arrays.asList("日平均含沙量表195001-199001","日平均含沙量表199001-"); List<String> stringList = Arrays.asList("逐时潮水位表 (1)","逐时潮水位表 (2)","逐时潮水位表 (3)");
long newTime = System.currentTimeMillis(); long newTime = System.currentTimeMillis();
System.out.println("当前时间:" + newTime); System.out.println("当前时间:" + newTime);
for (String s : stringList) { for (String s : stringList) {
File file = new File("C:\\Users\\12974\\Desktop\\历史查询子系统\\历史数据\\日表类\\日平均含沙量表-已完成\\" + s + ".xls"); // File file = new File("C:\\Users\\12974\\Desktop\\历史查询子系统\\历史数据\\日表类\\日平均含沙量表-已完成\\" + s + ".xls");
File file = new File("C:\\Users\\12974\\Downloads\\" + s + ".xls");
// 创建 FileInputStream 对象 // 创建 FileInputStream 对象
FileInputStream fileInputStream = new FileInputStream(file); FileInputStream fileInputStream = new FileInputStream(file);
@ -65,7 +70,7 @@ class HyDpCServiceImplTest {
"application/vnd.ms-excel", "application/vnd.ms-excel",
fileInputStream fileInputStream
); );
hyDcsFService.importHyDcsFData(multipartFile); hyZscsBService.importHyZscsBData(multipartFile);
} }
System.out.println("总耗时:" + (System.currentTimeMillis() - newTime)); System.out.println("总耗时:" + (System.currentTimeMillis() - newTime));
} }
@ -74,4 +79,8 @@ class HyDpCServiceImplTest {
public void test() { public void test() {
System.out.println(hyStscAService.testSqlServer()); System.out.println(hyStscAService.testSqlServer());
} }
} }

52
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/controller/ActualSurveyController.java

@ -0,0 +1,52 @@
package com.ruoyi.swlscx.actualSurvey.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.R;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo;
import com.ruoyi.swlscx.actualSurvey.service.HyObqGService;
import com.ruoyi.swlscx.actualSurvey.service.HyXsmsrsGService;
import com.ruoyi.swlscx.basic.domain.vo.HyStscAVo;
import com.ruoyi.swlscx.common.PageParams;
import com.ruoyi.swlscx.year.domain.vo.HyYrpFVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author al
* @Date 2025/7/10 15:49
* @Description: TODO
* @Version
*/
@RestController
@RequestMapping("/actualSurvey")
public class ActualSurveyController {
@Autowired
private HyObqGService hyObqGService;
@Autowired
private HyXsmsrsGService hyXsmsrsGService;
/**
* 实测流量成果表
*/
@GetMapping("/getFlowResult")
public R getMonthRainList(Integer pageNum, Integer pageSize, String startTime, String endTime, String stcd, String stnm) {
PageParams pageParams = new PageParams(pageNum.longValue(), pageSize.longValue());
IPage<HyObqGVo> hyObqGVoIPage = hyObqGService.selectHyObqGDataByPageAndInfo(pageParams, startTime, endTime, stcd, stnm);
return R.ok().put("data", hyObqGVoIPage.getRecords()).put("count", hyObqGVoIPage.getTotal());
}
/**
* 实测大断面成果表
*/
@GetMapping("/getActualMeasurementList")
public R getActualMeasurementList(Integer pageNum, Integer pageSize, String startTime, String endTime, String stcd, String stnm) {
PageParams pageParams = new PageParams(pageNum.longValue(), pageSize.longValue());
IPage<HyXsmsrsGVo> hyXsmsrsGVoIPage = hyXsmsrsGService.selectHyXsmsrsGDataByPageAndInfo(pageParams, startTime, endTime, stcd, stnm);
return R.ok().put("data", hyXsmsrsGVoIPage.getRecords()).put("count", hyXsmsrsGVoIPage.getTotal());
}
}

56
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/controller/ActualSurveyExportController.java

@ -0,0 +1,56 @@
package com.ruoyi.swlscx.actualSurvey.controller;
import com.ruoyi.common.core.page.R;
import com.ruoyi.swlscx.actualSurvey.service.HyObqGService;
import com.ruoyi.swlscx.actualSurvey.service.HyXsmsrsGService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
/**
* @Author al
* @Date 2025/7/10 16:13
* @Description: TODO
* @Version
*/
@RequestMapping("/report")
@RestController
public class ActualSurveyExportController {
@Autowired
private HyObqGService hyObqGService;
@Autowired
private HyXsmsrsGService hyXsmsrsGService;
/**
* 导出实测流量成果表
*/
@RequestMapping("/flowResult")
public R exportHyObqGtList(HttpServletResponse response,
@RequestParam String startTime,
@RequestParam String endTime,
@RequestParam String stcd,
@RequestParam String stnm) {
return hyObqGService.exportHyObqGData(response, startTime, endTime, stcd, stnm);
}
/**
* 导出实测大断面成果表
*/
@RequestMapping("/actualMeasurement")
public R exportActualMeasurementList(HttpServletResponse response,
@RequestParam String startTime,
@RequestParam String endTime,
@RequestParam String stcd,
@RequestParam String stnm) {
return hyXsmsrsGService.exportHyXsmsrsGData(response, startTime, endTime, stcd, stnm);
}
}

48
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/po/HyObqG.java

@ -0,0 +1,48 @@
package com.ruoyi.swlscx.actualSurvey.domain.po;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @Author al
* @Date 2025/7/10 15:44
* @Description: TODO
* @Version
*/
@Data
@TableName("hy_obq_g")
public class HyObqG {
private String id; // 唯一标识符
private String stcd; // 站码
private Integer yr; // 年份(整数类型)
private Integer mnth; // 月份(整数类型)
private Integer qobno; // 流量施测号数
private Date msqbgtm; // 测流起时间(使用LocalDateTime)
private Date msqedtm; // 测流止时间
private String xsqlc; // 测流断面位置
private String msqmt; // 测流方法
private Double bsggz; // 基本水尺水位
private Double q; // 流量
private String qrcd; // 流量注解码
private Double xstta; // 断面总面积
private Double xsa; // 断面过水面积
private String xsarcd; // 断面面积注解码
private Double xsavv; // 断面平均流速
private Double xsmxv; // 断面最大流速
private Double tpwd; // 水面宽
private Double xsavdp; // 断面平均水深
private Double xsmxdp; // 断面最大水深
private Double ibwd; // 水浸冰底宽度
private Double ibavdp; // 水浸冰底平均水深
private Double ibmxdp; // 水浸冰底最大水深
private Double rvsfsl; // 水面比降
private Double n; // 糙率
private String obnont; // 测次说明
}

33
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/po/HyXsmsrsG.java

@ -0,0 +1,33 @@
package com.ruoyi.swlscx.actualSurvey.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @Author al
* @Date 2025/7/11 15:39
* @Description: TODO
* @Version
*/
@Data
public class HyXsmsrsG {
private String stcd; // 站码
private Date obdt; // 施测日期
private Integer obno; // 测次号
private String vtno; // 垂线号
private BigDecimal di; // 起点距(米)
private BigDecimal rvbbel; // 河底高程(米)
private String rvbbelrcd; // 河底高程注解码
private BigDecimal odbrz; // 测时水位(米)
private String odbrzrcd; // 测时水位注解码
private String vtaz; // 垂线方位
private Integer nof; // 默认值1
}

60
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/vo/HyObqGVo.java

@ -0,0 +1,60 @@
package com.ruoyi.swlscx.actualSurvey.domain.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author al
* @Date 2025/7/10 15:44
* @Description: TODO
* @Version
*/
@Data
public class HyObqGVo implements Serializable {
private String id; // 唯一标识符
private String stcd; // 站码
private Integer yr; // 年份(整数类型)
private Integer mnth; // 月份(整数类型)
private Integer qobno; // 流量施测号数
private Date msqbgtm; // 测流起时间(使用LocalDateTime)
private Date msqedtm; // 测流止时间
private String xsqlc; // 测流断面位置
private String msqmt; // 测流方法
private Double bsggz; // 基本水尺水位
private Double q; // 流量
private String qrcd; // 流量注解码
private Double xstta; // 断面总面积
private Double xsa; // 断面过水面积
private String xsarcd; // 断面面积注解码
private Double xsavv; // 断面平均流速
private Double xsmxv; // 断面最大流速
private Double tpwd; // 水面宽
private Double xsavdp; // 断面平均水深
private Double xsmxdp; // 断面最大水深
private Double ibwd; // 水浸冰底宽度
private Double ibavdp; // 水浸冰底平均水深
private Double ibmxdp; // 水浸冰底最大水深
private Double rvsfsl; // 水面比降
private Double n; // 糙率
private String obnont; // 测次说明
/**站名**/
private String stnm;
/**
* 行政区划码
*/
private String addvcd;
private static final long serialVersionUID = 1L;
}

44
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/domain/vo/HyXsmsrsGVo.java

@ -0,0 +1,44 @@
package com.ruoyi.swlscx.actualSurvey.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author al
* @Date 2025/7/11 15:39
* @Description: TODO
* @Version
*/
@Data
public class HyXsmsrsGVo implements Serializable {
private String stcd; // 站码
private Date obdt; // 施测日期
private Integer obno; // 测次号
private String vtno; // 垂线号
private BigDecimal di; // 起点距(米)
private BigDecimal rvbbel; // 河底高程(米)
private String rvbbelrcd; // 河底高程注解码
private BigDecimal odbrz; // 测时水位(米)
private String odbrzrcd; // 测时水位注解码
private String vtaz; // 垂线方位
private Integer nof; // 默认值1
/**站名**/
private String stnm;
/**
* 行政区划码
*/
private String addvcd;
private static final long serialVersionUID = 1L;
}

25
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/mapper/HyObqGMapper.java

@ -0,0 +1,25 @@
package com.ruoyi.swlscx.actualSurvey.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyObqG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @Author al
* @Date 2025/7/10 15:46
* @Description: TODO
* @Version
*/
@Mapper
public interface HyObqGMapper extends BaseMapper<HyObqG> {
IPage<HyObqGVo> selectHyObqGDataByPageAndInfo(@Param("page") Page<HyObqGVo> page, @Param("map") Map<String, Object> map);
List<HyObqGVo> selectHyObqGData(@Param("map") Map<String, Object> map);
}

25
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/mapper/HyXsmsrsGMapper.java

@ -0,0 +1,25 @@
package com.ruoyi.swlscx.actualSurvey.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyXsmsrsG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @Author al
* @Date 2025/7/11 15:40
* @Description: TODO
* @Version
*/
@Mapper
public interface HyXsmsrsGMapper extends BaseMapper<HyXsmsrsG> {
IPage<HyXsmsrsGVo> selectHyXsmsrsGDataByPageAndInfo(@Param("page") Page<HyXsmsrsGVo> page, @Param("map") Map<String, Object> map);
List<HyXsmsrsGVo> selectHyXsmsrsGData(@Param("map") Map<String, Object> map);
}

26
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/HyObqGService.java

@ -0,0 +1,26 @@
package com.ruoyi.swlscx.actualSurvey.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyObqG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo;
import com.ruoyi.swlscx.common.PageParams;
import javax.servlet.http.HttpServletResponse;
/**
* @Author al
* @Date 2025/7/10 15:47
* @Description: TODO
* @Version
*/
public interface HyObqGService extends IService<HyObqG> {
/**
* 查询实测流量表
*/
IPage<HyObqGVo> selectHyObqGDataByPageAndInfo(PageParams pageParams, String startTime, String endTime, String stcd, String stnm);
R exportHyObqGData(HttpServletResponse response, String startTime, String endTime, String stcd, String stnm);
}

22
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/HyXsmsrsGService.java

@ -0,0 +1,22 @@
package com.ruoyi.swlscx.actualSurvey.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyXsmsrsG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo;
import com.ruoyi.swlscx.common.PageParams;
import javax.servlet.http.HttpServletResponse;
/**
* @Author al
* @Date 2025/7/11 15:40
* @Description: TODO
* @Version
*/
public interface HyXsmsrsGService extends IService<HyXsmsrsG> {
IPage<HyXsmsrsGVo> selectHyXsmsrsGDataByPageAndInfo(PageParams pageParams, String startTime, String endTime, String stcd, String stnm);
R exportHyXsmsrsGData(HttpServletResponse response, String startTime, String endTime, String stcd, String stnm);
}

210
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/impl/HyObqGServiceImpl.java

@ -0,0 +1,210 @@
package com.ruoyi.swlscx.actualSurvey.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyObqG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo;
import com.ruoyi.swlscx.actualSurvey.mapper.HyObqGMapper;
import com.ruoyi.swlscx.actualSurvey.service.HyObqGService;
import com.ruoyi.swlscx.basic.domain.po.YcExportTask;
import com.ruoyi.swlscx.basic.service.YcExportTaskService;
import com.ruoyi.swlscx.common.PageParams;
import com.ruoyi.swlscx.common.constants.SystemConstants;
import com.ruoyi.swlscx.common.utils.CommonUtils;
import com.ruoyi.swlscx.common.utils.ExcelUtils;
import com.ruoyi.swlscx.common.utils.Query;
import com.ruoyi.swlscx.month.domain.vo.HyMptEVo;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Author al
* @Date 2025/7/10 15:47
* @Description: TODO
* @Version
*/
@Service
public class HyObqGServiceImpl extends ServiceImpl<HyObqGMapper, HyObqG>
implements HyObqGService {
@Override
public IPage<HyObqGVo> selectHyObqGDataByPageAndInfo(PageParams pageParams, String startTime, String endTime, String stcd, String stnm) {
Map<String, Object> map = CommonUtils.getMonthDataMap(pageParams, startTime, endTime, stcd, stnm);
return this.baseMapper.selectHyObqGDataByPageAndInfo(new Query<HyObqGVo>().getPage(map), map);
}
@Override
public R exportHyObqGData(HttpServletResponse response, String startTime, String endTime, String stcd, String stnm) {
Long userId = SecurityUtils.getUserId();
String tableName = "实测流量表";
return taskAndExport(tableName,startTime, endTime, stcd, stnm, userId);
}
@Resource
private ThreadPoolExecutor labelThreadPool;
@Resource
private YcExportTaskService ycExportTaskService;
@Resource
private ThreadPoolExecutor importThreadPool;
@Autowired
private ApplicationContext context;
private R taskAndExport(String tableName,String startTime, String endTime, String stcd, String stnm, Long userId) {
String startNewTime="";
String endNewTime="";
if (ObjectUtils.isNotEmpty(startTime) ){
startNewTime=startTime.substring(0,6);
}
if (ObjectUtils.isNotEmpty(endTime)){
endNewTime=endTime.substring(0,6);
}
String filename = tableName + startNewTime + "-" + endNewTime;
// 查询是否已存在相同条件且未完成的任务
List<YcExportTask> ongoingTasks = ycExportTaskService.list(
new QueryWrapper<YcExportTask>()
.eq("user_id", userId)
.eq("filename", filename)
.eq("status", 0) // 状态为0表示任务未完成
);
if (!ongoingTasks.isEmpty()) {
return R.error("当前任务正在下载中,请稍后重试");
}
YcExportTask ycExportTask = new YcExportTask();
String pathPeffix = RuoYiConfig.getExportPath() +
File.separator + userId + File.separator+
DateUtils.parseDateToStr("yyyy-MM-dd",DateUtils.getNowDate()) + File.separator +
DateUtils.parseDateToStr("HH_mm",DateUtils.getNowDate())+File.separator;
ycExportTask.setFilename(filename);
ycExportTask.setUserId(userId);
ycExportTask.setStartTime(new Date());
ycExportTask.setStatus(0);
ycExportTask.setFilepath(pathPeffix);
ycExportTaskService.save(ycExportTask);
CompletableFuture.runAsync(() -> {
try {
File dest = new File(pathPeffix);
if (!dest.exists()) {
dest.mkdirs();
}
String fullPath = pathPeffix + filename;
exportBlackData(fullPath, startTime, endTime, stcd, stnm);
ycExportTask.setStatus(1);
ycExportTask.setEndTime(new Date());
ycExportTaskService.updateById(ycExportTask);
} catch (Exception e) {
log.error(e.getMessage(), e);
R.error("任务下载失败");
}
}, labelThreadPool);
return R.ok("任务已提交,请稍后下载");
}
private void exportBlackData(String tableName, String startTime, String endTime, String stcd, String stnm) {
Map<String, Object> rainMap = CommonUtils.getMonthDataMap(new PageParams(0L, 1000000000L), startTime, endTime, stcd, stnm);
ExcelUtils.excelBackExport2("flowResult.xls", tableName, (Sheet sheet, CellStyle style) ->
dataModel1(rainMap, sheet, style));
}
public int dataModel1(Map<String, Object> map, Sheet sheet, CellStyle style) {
// 批量查询数据
List<HyObqGVo> hyObqGVos = this.baseMapper.selectHyObqGData(map);
// 定义当前sheet的行号
int rowIndex = 2; // 从第二行开始写入数据
// 定义全局序号
int globalIndex = 1; // 从1开始
// 定义当前sheet的编号
int sheetIndex = 1;
// 最大行数限制
int maxRowsPerSheet = 65536; // 对于 .xls 文件,最大行数为 65536
int batchSize = 1000; // 每次批量处理1000行,减少逐行写入的开销
// 复制表头到新sheet的逻辑
ExcelUtils.copyHeader(sheet, style);
// 批量处理数据
for (int i = 0; i < hyObqGVos.size(); i += batchSize) {
// 处理一批数据
int toIndex = Math.min(i + batchSize, hyObqGVos.size());
List<HyObqGVo> batchList = hyObqGVos.subList(i, toIndex);
// 批量写入数据
for (HyObqGVo vo : batchList) {
// 如果当前行数达到最大行数,创建新sheet
if (rowIndex >= maxRowsPerSheet) {
sheetIndex++;
sheet = sheet.getWorkbook().createSheet("实测流量表" + sheetIndex);
rowIndex = 2; // 重置行号
// 复制表头到新sheet
ExcelUtils.copyHeader(sheet, style);
}
// 创建新行并写入数据
Row row = ExcelUtils.createRow(sheet, rowIndex);
// 使用 globalIndex 作为序号
ExcelUtils.formatCell(row, 0, String.valueOf(globalIndex), style);
ExcelUtils.formatCell(row, 1, vo.getStcd() != null ? vo.getStcd() : "", style);
ExcelUtils.formatCell(row, 2, vo.getStnm() != null ? vo.getStnm() : "", style);
ExcelUtils.formatCell(row, 3, vo.getAddvcd() != null ? vo.getAddvcd() : "", style);
ExcelUtils.formatCell(row, 4, vo.getYr() != null ? vo.getYr().toString() : "", style);
ExcelUtils.formatCell(row, 5, vo.getMnth() != null ? vo.getMnth().toString() : "", style);
ExcelUtils.formatCell(row, 6, vo.getQobno() != null ? vo.getQobno().toString() : "", style);
ExcelUtils.formatCell(row, 7, vo.getMsqbgtm() != null ? DateUtils.parseDateToStr(SystemConstants.TIME_FORMAT,vo.getMsqbgtm()) : "", style);
ExcelUtils.formatCell(row, 8, vo.getMsqedtm() != null ? DateUtils.parseDateToStr(SystemConstants.TIME_FORMAT,vo.getMsqedtm()) : "", style);
ExcelUtils.formatCell(row, 9, vo.getXsqlc() != null ? vo.getXsqlc() : "", style);
ExcelUtils.formatCell(row, 10, vo.getMsqmt() != null ? vo.getMsqmt() : "", style);
ExcelUtils.formatCell(row, 11, vo.getBsggz() != null ? vo.getBsggz().toString() : "", style);
ExcelUtils.formatCell(row, 12, vo.getQ() != null ? vo.getQ().toString() : "", style);
ExcelUtils.formatCell(row, 13, vo.getQrcd() != null ? vo.getQrcd() : "", style);
ExcelUtils.formatCell(row, 14, vo.getXstta() != null ? vo.getXstta().toString() : "", style);
ExcelUtils.formatCell(row, 15, vo.getXsa() != null ? vo.getXsa().toString() : "", style);
ExcelUtils.formatCell(row, 16, vo.getXsarcd() != null ? vo.getXsarcd() : "", style);
ExcelUtils.formatCell(row, 17, vo.getXsavv() != null ? vo.getXsavv().toString() : "", style);
ExcelUtils.formatCell(row, 18, vo.getXsmxv() != null ? vo.getXsmxv().toString() : "", style);
ExcelUtils.formatCell(row, 19, vo.getTpwd() != null ? vo.getTpwd().toString() : "", style);
ExcelUtils.formatCell(row, 20, vo.getXsavdp() != null ? vo.getXsavdp().toString() : "", style);
ExcelUtils.formatCell(row, 21, vo.getXsmxdp() != null ? vo.getXsmxdp().toString() : "", style);
ExcelUtils.formatCell(row, 22, vo.getIbwd() != null ? vo.getIbwd().toString() : "", style);
ExcelUtils.formatCell(row, 23, vo.getIbavdp() != null ? vo.getIbavdp().toString() : "", style);
ExcelUtils.formatCell(row, 24, vo.getIbmxdp() != null ? vo.getIbmxdp().toString() : "", style);
ExcelUtils.formatCell(row, 25, vo.getRvsfsl() != null ? vo.getRvsfsl().toString() : "", style);
ExcelUtils.formatCell(row, 26, vo.getN() != null ? vo.getN().toString() : "", style);
ExcelUtils.formatCell(row, 27, vo.getObnont() != null ? vo.getObnont() : "", style);
// 增加行号和全局序号
rowIndex++;
globalIndex++;
}
}
return 0;
}
}

187
swlscx/src/main/java/com/ruoyi/swlscx/actualSurvey/service/impl/HyXsmsrsGServiceImpl.java

@ -0,0 +1,187 @@
package com.ruoyi.swlscx.actualSurvey.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.swlscx.actualSurvey.domain.po.HyXsmsrsG;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo;
import com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo;
import com.ruoyi.swlscx.actualSurvey.mapper.HyXsmsrsGMapper;
import com.ruoyi.swlscx.actualSurvey.service.HyXsmsrsGService;
import com.ruoyi.swlscx.basic.domain.po.YcExportTask;
import com.ruoyi.swlscx.basic.service.YcExportTaskService;
import com.ruoyi.swlscx.common.PageParams;
import com.ruoyi.swlscx.common.constants.SystemConstants;
import com.ruoyi.swlscx.common.utils.CommonUtils;
import com.ruoyi.swlscx.common.utils.ExcelUtils;
import com.ruoyi.swlscx.common.utils.Query;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Author al
* @Date 2025/7/11 15:41
* @Description: TODO
* @Version
*/
@Service
public class HyXsmsrsGServiceImpl extends ServiceImpl<HyXsmsrsGMapper, HyXsmsrsG>
implements HyXsmsrsGService {
@Resource
private ThreadPoolExecutor labelThreadPool;
@Resource
private YcExportTaskService ycExportTaskService;
@Override
public IPage<HyXsmsrsGVo> selectHyXsmsrsGDataByPageAndInfo(PageParams pageParams, String startTime, String endTime, String stcd, String stnm) {
Map<String, Object> map = CommonUtils.getYearAndDayDataMap(pageParams, startTime, endTime, stcd, stnm);
return this.baseMapper.selectHyXsmsrsGDataByPageAndInfo(new Query<HyXsmsrsGVo>().getPage(map), map);
}
@Override
public R exportHyXsmsrsGData(HttpServletResponse response, String startTime, String endTime, String stcd, String stnm) {
Long userId = SecurityUtils.getUserId();
String tableName = "实测大断面成果表";
return taskAndExport(tableName,startTime, endTime, stcd, stnm, userId);
}
private R taskAndExport(String tableName,String startTime, String endTime, String stcd, String stnm, Long userId) {
String startNewTime="";
String endNewTime="";
if (ObjectUtils.isNotEmpty(startTime) ){
startNewTime=startTime.substring(0,6);
}
if (ObjectUtils.isNotEmpty(endTime)){
endNewTime=endTime.substring(0,6);
}
String filename = tableName + startNewTime + "-" + endNewTime;
// 查询是否已存在相同条件且未完成的任务
List<YcExportTask> ongoingTasks = ycExportTaskService.list(
new QueryWrapper<YcExportTask>()
.eq("user_id", userId)
.eq("filename", filename)
.eq("status", 0) // 状态为0表示任务未完成
);
if (!ongoingTasks.isEmpty()) {
return R.error("当前任务正在下载中,请稍后重试");
}
YcExportTask ycExportTask = new YcExportTask();
String pathPeffix = RuoYiConfig.getExportPath() +
File.separator + userId + File.separator+
DateUtils.parseDateToStr("yyyy-MM-dd",DateUtils.getNowDate()) + File.separator +
DateUtils.parseDateToStr("HH_mm",DateUtils.getNowDate())+File.separator;
ycExportTask.setFilename(filename);
ycExportTask.setUserId(userId);
ycExportTask.setStartTime(new Date());
ycExportTask.setStatus(0);
ycExportTask.setFilepath(pathPeffix);
ycExportTaskService.save(ycExportTask);
CompletableFuture.runAsync(() -> {
try {
File dest = new File(pathPeffix);
if (!dest.exists()) {
dest.mkdirs();
}
String fullPath = pathPeffix + filename;
exportBlackData(fullPath, startTime, endTime, stcd, stnm);
ycExportTask.setStatus(1);
ycExportTask.setEndTime(new Date());
ycExportTaskService.updateById(ycExportTask);
} catch (Exception e) {
log.error(e.getMessage(), e);
R.error("任务下载失败");
}
}, labelThreadPool);
return R.ok("任务已提交,请稍后下载");
}
private void exportBlackData(String tableName, String startTime, String endTime, String stcd, String stnm) {
Map<String, Object> rainMap = CommonUtils.getYearAndDayDataMap(new PageParams(0L, 1000000000L), startTime, endTime, stcd, stnm);
ExcelUtils.excelBackExport2("hyXsmsrsG.xls", tableName, (Sheet sheet, CellStyle style) ->
dataModel1(rainMap, sheet, style));
}
public int dataModel1(Map<String, Object> map, Sheet sheet, CellStyle style) {
// 批量查询数据
List<HyXsmsrsGVo> hyXsmsrsGVos = this.baseMapper.selectHyXsmsrsGData(map);
// 定义当前sheet的行号
int rowIndex = 2; // 从第二行开始写入数据
// 定义全局序号
int globalIndex = 1; // 从1开始
// 定义当前sheet的编号
int sheetIndex = 1;
// 最大行数限制
int maxRowsPerSheet = 65536; // 对于 .xls 文件,最大行数为 65536
int batchSize = 1000; // 每次批量处理1000行,减少逐行写入的开销
// 复制表头到新sheet的逻辑
ExcelUtils.copyHeader(sheet, style);
// 批量处理数据
for (int i = 0; i < hyXsmsrsGVos.size(); i += batchSize) {
// 处理一批数据
int toIndex = Math.min(i + batchSize, hyXsmsrsGVos.size());
List<HyXsmsrsGVo> batchList = hyXsmsrsGVos.subList(i, toIndex);
// 批量写入数据
for (HyXsmsrsGVo vo : batchList) {
// 如果当前行数达到最大行数,创建新sheet
if (rowIndex >= maxRowsPerSheet) {
sheetIndex++;
sheet = sheet.getWorkbook().createSheet("实测大断面成果表" + sheetIndex);
rowIndex = 2; // 重置行号
// 复制表头到新sheet
ExcelUtils.copyHeader(sheet, style);
}
// 创建新行并写入数据
Row row = ExcelUtils.createRow(sheet, rowIndex);
// 使用 globalIndex 作为序号
ExcelUtils.formatCell(row, 0, String.valueOf(globalIndex), style);
ExcelUtils.formatCell(row, 1, vo.getStcd() != null ? vo.getStcd() : "", style);
ExcelUtils.formatCell(row, 2, vo.getStnm() != null ? vo.getStnm() : "", style);
ExcelUtils.formatCell(row, 3, vo.getAddvcd() != null ? vo.getAddvcd() : "", style);
ExcelUtils.formatCell(row, 4, vo.getObdt() != null ? DateUtils.parseDateToStr(SystemConstants.TIME_FORMAT,vo.getObdt()) : "", style);
ExcelUtils.formatCell(row, 5, vo.getObno() != null ? vo.getObno().toString() : "", style);
ExcelUtils.formatCell(row, 6, vo.getVtno() != null ? vo.getVtno() : "", style);
ExcelUtils.formatCell(row, 7, vo.getDi() != null ? vo.getDi().toString() : "", style);
ExcelUtils.formatCell(row, 8, vo.getRvbbel() != null ? vo.getRvbbel().toString() : "", style);
ExcelUtils.formatCell(row, 9, vo.getRvbbelrcd() != null ? vo.getRvbbelrcd() : "", style);
ExcelUtils.formatCell(row, 10, vo.getOdbrz() != null ? vo.getOdbrz().toString() : "", style);
ExcelUtils.formatCell(row, 11, vo.getOdbrzrcd() != null ? vo.getOdbrzrcd() : "", style);
ExcelUtils.formatCell(row, 12, vo.getVtaz() != null ? vo.getVtaz() : "", style);
ExcelUtils.formatCell(row, 13, vo.getNof() != null ? vo.getNof() .toString(): "", style);
// 增加行号和全局序号
rowIndex++;
globalIndex++;
}
}
return 0;
}
}

32
swlscx/src/main/java/com/ruoyi/swlscx/basic/controller/BaseInfoController.java

@ -14,7 +14,9 @@ import com.ruoyi.swlscx.basic.domain.vo.HyStscAVo;
import com.ruoyi.swlscx.basic.service.YcExportTaskService; import com.ruoyi.swlscx.basic.service.YcExportTaskService;
import com.ruoyi.swlscx.common.PageParams; import com.ruoyi.swlscx.common.PageParams;
import com.ruoyi.swlscx.basic.service.HyStscAService; import com.ruoyi.swlscx.basic.service.HyStscAService;
import com.ruoyi.swlscx.synchronousData.service.YcResTableInfoService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -27,6 +29,7 @@ import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -62,7 +65,14 @@ public class BaseInfoController {
public R getStationList(@RequestParam(value = "startTime",defaultValue = "") String startTime, public R getStationList(@RequestParam(value = "startTime",defaultValue = "") String startTime,
@RequestParam(value = "endTime",defaultValue = "")String endTime, @RequestParam(value = "endTime",defaultValue = "")String endTime,
@RequestParam(value = "type",defaultValue = "") String type) { @RequestParam(value = "type",defaultValue = "") String type) {
return R.ok().put("data", hyStscAService.getList(startTime,endTime,type)); HyStscASelectVo list = hyStscAService.getList(startTime, endTime, type);
int size = list.getChildren().size();
if (size == 0) {
return R.ok().put("data", list).put("count", 0);
}else {
return R.ok().put("data", list).put("count", size-1);
}
} }
/** /**
@ -154,7 +164,14 @@ public class BaseInfoController {
public R getStationListByType(@RequestParam(value = "type",defaultValue = "") String type, public R getStationListByType(@RequestParam(value = "type",defaultValue = "") String type,
@RequestParam(value = "startTime",defaultValue = "") String startTime, @RequestParam(value = "startTime",defaultValue = "") String startTime,
@RequestParam(value = "endTime",defaultValue = "")String endTime) { @RequestParam(value = "endTime",defaultValue = "")String endTime) {
return R.ok().put("data", hyStscAService.getStationListByType(startTime,endTime,type)); HyStscASelectVo list = hyStscAService.getStationListByType(startTime, endTime, type);
List<HyStscASelectVo> children = list.getChildren();
int size = children.size();
if (size == 0) {
return R.ok().put("data", list).put("count", 0);
}else {
return R.ok().put("data", list).put("count", size-1);
}
} }
@RequestMapping("/testConnection") @RequestMapping("/testConnection")
@ -195,4 +212,15 @@ public class BaseInfoController {
} }
@Autowired
private YcResTableInfoService ycResTableInfoService;
@RequestMapping("/getStatInfo")
public R getStatInfo(@RequestParam(value = "stcd",defaultValue = "") String stcds,
@RequestParam(value = "startTime",defaultValue = "") String startTime,
@RequestParam(value = "endTime",defaultValue = "")String endTime,
@RequestParam(value = "page") Integer pageNum,
@RequestParam(value = "limit") Integer pageSize) {
return ycResTableInfoService.getStatInfo(stcds,startTime,endTime,pageNum,pageSize);
}
} }

4
swlscx/src/main/java/com/ruoyi/swlscx/basic/mapper/HyStscAMapper.java

@ -54,6 +54,10 @@ public interface HyStscAMapper extends BaseMapper<HyStscA> {
List<HyDzC> listHyDzC(@Param("startTimeDay") String startTimeDay, @Param("endTimeDay") String endTimeDay); List<HyDzC> listHyDzC(@Param("startTimeDay") String startTimeDay, @Param("endTimeDay") String endTimeDay);
List<HyDpC> listHyDpc(@Param("startTimeDay") String startTimeDay, @Param("endTimeDay") String endTimeDay); List<HyDpC> listHyDpc(@Param("startTimeDay") String startTimeDay, @Param("endTimeDay") String endTimeDay);
List<String> getStatList(@Param("startTime") String startTime, @Param("endTime") String endTime);
List<String> getStatAllList();
} }

12
swlscx/src/main/java/com/ruoyi/swlscx/basic/service/impl/HyStscAServiceImpl.java

@ -268,6 +268,8 @@ public class HyStscAServiceImpl extends ServiceImpl<HyStscAMapper, HyStscA> impl
@Autowired @Autowired
private HyStscAService hyStscAService; private HyStscAService hyStscAService;
@Override @Override
public HyStscASelectVo getList(String startTime, String endTime, String type) { public HyStscASelectVo getList(String startTime, String endTime, String type) {
List<HyStscA> list = new ArrayList<>(); List<HyStscA> list = new ArrayList<>();
@ -749,6 +751,16 @@ public class HyStscAServiceImpl extends ServiceImpl<HyStscAMapper, HyStscA> impl
if (!stcds.isEmpty()) { if (!stcds.isEmpty()) {
list = this.list(Wrappers.lambdaQuery(HyStscA.class).in(HyStscA::getStcd, stcds)); list = this.list(Wrappers.lambdaQuery(HyStscA.class).in(HyStscA::getStcd, stcds));
} }
}else if (type.equals("YcStat")){
List<String> stcds = new ArrayList<>();
if (ObjectUtils.isNotEmpty(startTime) || ObjectUtils.isNotEmpty(endTime)){
stcds =this.baseMapper.getStatList(startTime, endTime);
}else {
stcds =this.baseMapper.getStatAllList();
}
if (!stcds.isEmpty()) {
list = this.list(Wrappers.lambdaQuery(HyStscA.class).in(HyStscA::getStcd, stcds));
}
} }

11
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/controller/TimeTasksController.java

@ -4,6 +4,7 @@ import com.ruoyi.common.core.page.R;
import com.ruoyi.swlscx.basic.service.YcExportTaskService; import com.ruoyi.swlscx.basic.service.YcExportTaskService;
import com.ruoyi.swlscx.synchronousData.dto.JHDayData; import com.ruoyi.swlscx.synchronousData.dto.JHDayData;
import com.ruoyi.swlscx.synchronousData.service.TimeTasksService; import com.ruoyi.swlscx.synchronousData.service.TimeTasksService;
import com.ruoyi.swlscx.synchronousData.service.YcResTableInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
@ -24,6 +25,9 @@ public class TimeTasksController {
@Autowired @Autowired
private TimeTasksService timeTasksService; private TimeTasksService timeTasksService;
@Autowired
private YcResTableInfoService ycResTableInfoService;
@RequestMapping("/importSqlserverToMysql") @RequestMapping("/importSqlserverToMysql")
public R importSqlserverToMysql(@RequestBody List<JHDayData> jhDayDataList, @RequestHeader("X-Type")String type) { public R importSqlserverToMysql(@RequestBody List<JHDayData> jhDayDataList, @RequestHeader("X-Type")String type) {
@ -268,4 +272,11 @@ public class TimeTasksController {
} }
@RequestMapping("/test666")
public R getTest666(){
return ycResTableInfoService.getYcResTableInfo();
}
} }

35
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/dto/YcResStatInfo.java

@ -0,0 +1,35 @@
package com.ruoyi.swlscx.synchronousData.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.springframework.data.annotation.Id;
/**
* @Author al
* @Date 2025/7/8 15:35
* @Description: TODO
* @Version
*/
@Data
public class YcResStatInfo {
private Long id;
private String stcd;
private String stnm;
private String sType;
private String resType;
private Long resTableId;
private String resTable;
private String statYear;
private String oldYear;
}

33
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/mapper/YcResTableInfoMapper.java

@ -0,0 +1,33 @@
package com.ruoyi.swlscx.synchronousData.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.swlscx.basic.domain.vo.HyStscAVo;
import com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @Author al
* @Date 2025/7/8 15:18
* @Description: TODO
* @Version
*/
@Mapper
public interface YcResTableInfoMapper {
List<YcResStatInfo> getResTableByDay(@Param("tableName") String tableName);
void saveBatch(List<YcResStatInfo> ycResStatInfoList);
IPage<YcResStatInfo> getPageList(@Param("page") Page<HyStscAVo> page, @Param("param")Map<String,Object> map);
List<YcResStatInfo> getResTableRainXPList(@Param("tableName") String tableName);
List<YcResStatInfo> getResTableRainrexBList(@Param("tableName") String tableName);
List<YcResStatInfo> getResTableTMList(@Param("tableName") String tableName);
}

15
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/YcResTableInfoService.java

@ -0,0 +1,15 @@
package com.ruoyi.swlscx.synchronousData.service;
import com.ruoyi.common.core.page.R;
/**
* @Author al
* @Date 2025/7/8 15:18
* @Description: TODO
* @Version
*/
public interface YcResTableInfoService {
R getYcResTableInfo();
R getStatInfo(String stcds, String startTime, String endTime,Integer pageNum,Integer pageSize);
}

81
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/impl/TimeTasksServiceImpl.java

@ -23,6 +23,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Year; import java.time.Year;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -60,7 +61,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日雨量数据 * 获取江河湖库日雨量数据
*/ */
@Override @Override
@Scheduled(cron = "0 10 0 18 * ?") @Scheduled(cron = "0 10 0 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getDayRainData() { public void getDayRainData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -97,7 +98,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日平均流量表 * 获取江河湖库日平均流量表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 20 0 18 * ?") @Scheduled(cron = "0 20 0 13 * ?")
@Override @Override
public void getDayQData() { public void getDayQData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -134,7 +135,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日平均输沙率表 * 获取江河湖库日平均输沙率表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 30 0 18 * ?") @Scheduled(cron = "0 30 0 13 * ?")
@Override @Override
public void getDayDqsData() { public void getDayDqsData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -173,7 +174,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日平均含沙量表 * 获取江河湖库日平均含沙量表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 40 0 18 * ?") @Scheduled(cron = "0 40 0 13 * ?")
@Override @Override
public void getDayDcsData() { public void getDayDcsData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -212,7 +213,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日时段最大降水表 * 获取江河湖库日时段最大降水表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 50 0 18 * ?") @Scheduled(cron = "0 50 0 13 * ?")
@Override @Override
public void getDayDmxpData() { public void getDayDmxpData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -252,7 +253,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日水面蒸发量表 * 获取江河湖库日水面蒸发量表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 0 1 18 * ?") // 每月19号01:00执行 @Scheduled(cron = "0 0 1 13 * ?") // 每月19号01:00执行
@Override @Override
public void getDayDweData() { public void getDayDweData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -291,7 +292,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日水温表 * 获取江河湖库日水温表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 10 1 18 * ?") @Scheduled(cron = "0 10 1 13 * ?")
@Override @Override
public void getDayDwtData() { public void getDayDwtData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -329,7 +330,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库日平均水位表 * 获取江河湖库日平均水位表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 20 1 18 * ?") @Scheduled(cron = "0 20 1 13 * ?")
@Override @Override
public void getDayDzcData() { public void getDayDzcData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -367,7 +368,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库时段最大洪量表 * 获取江河湖库时段最大洪量表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 30 1 18 * ?") @Scheduled(cron = "0 30 1 13 * ?")
@Override @Override
public void getDayImxfwData() { public void getDayImxfwData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -401,7 +402,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
} }
getDateService.insertRainData(stcds, SWTableEnum.DAY_MXFW.value());} getDateService.insertRainData(stcds, SWTableEnum.DAY_MXFW.value());}
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 40 1 18 * ?") @Scheduled(cron = "0 40 1 13 * ?")
@Override @Override
public void getFdheexData() { public void getFdheexData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -435,7 +436,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
}getDateService.insertRainData(stcds, SWTableEnum.DP_FDHEEX.value());} }getDateService.insertRainData(stcds, SWTableEnum.DP_FDHEEX.value());}
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 50 1 18 * ?") @Scheduled(cron = "0 50 1 13 * ?")
@Override @Override
public void getHltdzData() { public void getHltdzData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -466,7 +467,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
TimeUnit.HOURS);stcds.add("HyHltdzB:"+ycStation.getStcd());} TimeUnit.HOURS);stcds.add("HyHltdzB:"+ycStation.getStcd());}
getDateService.insertRainData(stcds, SWTableEnum.DP_HLTDZ.value());} getDateService.insertRainData(stcds, SWTableEnum.DP_HLTDZ.value());}
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 0 2 18 * ?") @Override @Scheduled(cron = "0 0 2 13 * ?") @Override
public void getHmxpData() { public void getHmxpData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
String[] startAndEndTime = getStartAndEndTime(); String[] startAndEndTime = getStartAndEndTime();
@ -495,7 +496,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
getDateService.insertRainData(stcds, SWTableEnum.DP_HMXP.value());} getDateService.insertRainData(stcds, SWTableEnum.DP_HMXP.value());}
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 10 2 18 * ?") @Scheduled(cron = "0 10 2 13 * ?")
@Override @Override
public void getMmxpData() { public void getMmxpData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -535,7 +536,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月含沙量表 * 获取江河湖库月含沙量表
*/ */
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
@Scheduled(cron = "0 20 2 18 * ?") @Scheduled(cron = "0 20 2 13 * ?")
@Override @Override
public void getMtcsData() { public void getMtcsData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -579,7 +580,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月降水表数据 * 获取江河湖库月降水表数据
*/ */
@Override @Override
@Scheduled(cron = "0 30 2 18 * ?") @Scheduled(cron = "0 30 2 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthRainData() { public void getMonthRainData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -620,7 +621,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月流量表数据 * 获取江河湖库月流量表数据
*/ */
@Override @Override
@Scheduled(cron = "0 40 2 18 * ?") @Scheduled(cron = "0 40 2 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthQData() { public void getMonthQData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -663,7 +664,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月输沙率表 * 获取江河湖库月输沙率表
*/ */
@Override @Override
@Scheduled(cron = "0 50 2 18 * ?") @Scheduled(cron = "0 50 2 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthMtqsData() { public void getMonthMtqsData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -704,7 +705,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月潮位表 * 获取江河湖库月潮位表
*/ */
@Override @Override
@Scheduled(cron = "0 0 3 18 * ?") @Scheduled(cron = "0 0 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthMttdzData() { public void getMonthMttdzData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -772,7 +773,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月水面蒸发量表 * 获取江河湖库月水面蒸发量表
*/ */
@Override @Override
@Scheduled(cron = "0 10 3 18 * ?") @Scheduled(cron = "0 10 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthMtweData() { public void getMonthMtweData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -815,7 +816,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月水温表 * 获取江河湖库月水温表
*/ */
@Override @Override
@Scheduled(cron = "0 20 3 18 * ?") @Scheduled(cron = "0 20 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthMtwtData() { public void getMonthMtwtData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -857,7 +858,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库月河道水位表 * 获取江河湖库月河道水位表
*/ */
@Override @Override
@Scheduled(cron = "0 30 3 18 * ?") @Scheduled(cron = "0 30 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getMonthRiverData() { public void getMonthRiverData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -902,7 +903,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库降水量摘录表 * 获取江河湖库降水量摘录表
*/ */
@Override @Override
@Scheduled(cron = "0 40 3 18 * ?") @Scheduled(cron = "0 40 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getHourRainData() { public void getHourRainData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -941,7 +942,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库水库洪水水位要素摘录表 * 获取江河湖库水库洪水水位要素摘录表
*/ */
@Override @Override
@Scheduled(cron = "0 50 3 18 * ?") @Scheduled(cron = "0 50 3 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getRvfhexData() { public void getRvfhexData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -978,7 +979,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库水闸洪水水文要素摘录表 * 获取江河湖库水闸洪水水文要素摘录表
*/ */
@Override @Override
@Scheduled(cron = "0 0 4 18 * ?") @Scheduled(cron = "0 0 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getWsfhexData() { public void getWsfhexData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1017,7 +1018,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年含沙量表 * 获取江河湖库年含沙量表
*/ */
@Override @Override
@Scheduled(cron = "0 10 4 18 * ?") @Scheduled(cron = "0 10 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYrcsData() { public void getYrcsData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1053,7 +1054,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年流量表 * 获取江河湖库年流量表
*/ */
@Override @Override
@Scheduled(cron = "0 20 4 18 * ?") @Scheduled(cron = "0 20 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearQData() { public void getYearQData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1090,7 +1091,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年降水表 * 获取江河湖库年降水表
*/ */
@Override @Override
@Scheduled(cron = "0 30 4 18 * ?") @Scheduled(cron = "0 30 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearRainData() { public void getYearRainData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1128,7 +1129,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年潮位表 * 获取江河湖库年潮位表
*/ */
@Override @Override
@Scheduled(cron = "0 40 4 18 * ?") @Scheduled(cron = "0 40 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearTideData() { public void getYearTideData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1195,7 +1196,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年水面蒸发量表 * 获取江河湖库年水面蒸发量表
*/ */
@Override @Override
@Scheduled(cron = "0 50 4 18 * ?") @Scheduled(cron = "0 50 4 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearMtweData() { public void getYearMtweData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1236,7 +1237,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库年水温表 * 获取江河湖库年水温表
*/ */
@Override @Override
@Scheduled(cron = "0 0 5 18 * ?") @Scheduled(cron = "0 0 5 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearWtData() { public void getYearWtData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1274,7 +1275,7 @@ public class TimeTasksServiceImpl implements TimeTasksService {
* 获取江河湖库河道年水位表 * 获取江河湖库河道年水位表
*/ */
@Override @Override
@Scheduled(cron = "0 10 5 18 * ?") @Scheduled(cron = "0 10 5 13 * ?")
@DataSource(DataSourceType.SLAVE) @DataSource(DataSourceType.SLAVE)
public void getYearYrzData() { public void getYearYrzData() {
List<HyStscA> ycStations = getYcStations(); List<HyStscA> ycStations = getYcStations();
@ -1331,15 +1332,19 @@ public class TimeTasksServiceImpl implements TimeTasksService {
private static String[] getStartAndEndTime() { private static String[] getStartAndEndTime() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime endDate = LocalDateTime.now()
.withHour(0)
.withMinute(0)
.withSecond(0);
LocalDateTime startDate = endDate.minusMonths(6); // 获取当前年份的1月1日 00:00:00(今年开始时刻)
LocalDateTime startDate = LocalDate.now()
.withMonth(1) // 设置为1月
.withDayOfMonth(1) // 设置为1号
.atStartOfDay(); // 转换为当天的00:00:00 [7,8](@ref)
// 获取当前精确时间(至今)
LocalDateTime endDate = LocalDateTime.now();
return new String[]{ return new String[]{
endDate.format(formatter), // endTime startDate.format(formatter), // 今年开始时间
startDate.format(formatter) // startTime endDate.format(formatter) // 当前时间
}; };
} }

224
swlscx/src/main/java/com/ruoyi/swlscx/synchronousData/service/impl/YcResTableInfoServiceImpl.java

@ -0,0 +1,224 @@
package com.ruoyi.swlscx.synchronousData.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.swlscx.basic.domain.vo.HyStscAVo;
import com.ruoyi.swlscx.common.utils.Query;
import com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo;
import com.ruoyi.swlscx.synchronousData.enums.SWTableEnum;
import com.ruoyi.swlscx.synchronousData.mapper.YcResTableInfoMapper;
import com.ruoyi.swlscx.synchronousData.service.YcResTableInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author al
* @Date 2025/7/8 15:18
* @Description: TODO
* @Version
*/
@Service
public class YcResTableInfoServiceImpl implements YcResTableInfoService {
@Autowired
private YcResTableInfoMapper ycResTableInfoMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public R getYcResTableInfo() {
//逐日降水
List<YcResStatInfo> ycResStatInfoList = ycResTableInfoMapper.getResTableRainXPList(SWTableEnum.MONTH_RAIN.value());
ycResStatInfoList.forEach(i -> {
i.setSType("P");
i.setResType("雨量资料");
i.setResTableId(1L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("逐日降水数据表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoList);
//最大小时降水表(1)
List<YcResStatInfo> ycResStatInfoMMXPList = ycResTableInfoMapper.getResTableRainXPList(SWTableEnum.DP_MMXP.value());
ycResStatInfoMMXPList.forEach(i -> {
i.setSType("P");
i.setResType("雨量资料");
i.setResTableId(2L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("各时段最大降水表(1)");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoMMXPList);
//最大小时降水表(2)
List<YcResStatInfo> ycResStatInfoHMXPList = ycResTableInfoMapper.getResTableRainXPList(SWTableEnum.DP_HMXP.value());
ycResStatInfoHMXPList.forEach(i -> {
i.setSType("P");
i.setResType("雨量资料");
i.setResTableId(3L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("各时段最大降水表(2)");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoHMXPList);
//降水量摘录表
List<YcResStatInfo> ycResStatInfoPrexBList = ycResTableInfoMapper.getResTableRainrexBList(SWTableEnum.DP_HOUR.value());
ycResStatInfoPrexBList.forEach(i -> {
i.setSType("P");
i.setResType("雨量资料");
i.setResTableId(4L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("降水量摘录表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoPrexBList);
//逐日平均水位表
List<YcResStatInfo> ycResStatInfoZDayList = ycResTableInfoMapper.getResTableRainXPList(SWTableEnum.MONTH_RIVER.value());
ycResStatInfoZDayList.forEach(i -> {
i.setSType("Z");
i.setResType("水位资料");
i.setResTableId(5L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("逐日平均水位表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoZDayList);
// 水闸洪水水文要素摘录表
List<YcResStatInfo> ycResStatInfoSZList2 = ycResTableInfoMapper.getResTableTMList(SWTableEnum.DP_WSFHEX.value());
ycResStatInfoSZList2.forEach(i -> {
i.setSType("Z");
i.setResType("水位资料");
i.setResTableId(6L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("水闸洪水水文要素摘录表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoSZList2);
// 逐潮高低潮位表
List<YcResStatInfo> ycResStatInfoZCList2 = ycResTableInfoMapper.getResTableTMList(SWTableEnum.DP_HLTDZ.value());
ycResStatInfoZCList2.forEach(i -> {
i.setSType("Z");
i.setResType("水位资料");
i.setResTableId(7L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("逐潮高低潮位表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoZCList2);
// 潮位月年统计表
List<YcResStatInfo> ycResStatInfoCWList2 = ycResTableInfoMapper.getResTableRainXPList(SWTableEnum.MONTH_MTTDZ.value());
ycResStatInfoCWList2.forEach(i -> {
i.setSType("Z");
i.setResType("水位资料");
i.setResTableId(8L);
String statYear = i.getStatYear();
i.setStatYear(formatYears(statYear));
i.setOldYear(statYear);
i.setResTable("潮位月年统计表");
}
);
ycResTableInfoMapper.saveBatch(ycResStatInfoCWList2);
return R.ok().put("data", ycResStatInfoSZList2);
}
public static String formatYears(String yearStr) {
if (yearStr == null || yearStr.isEmpty()) {
return "";
}
// 拆分年份并转换为整数集合
String[] yearArray = yearStr.split(",");
List<Integer> years = new ArrayList<>();
for (String year : yearArray) {
try {
years.add(Integer.parseInt(year.trim()));
} catch (NumberFormatException ignored) {
}
}
if (years.isEmpty()) return "";
// 排序年份
Collections.sort(years);
// 合并连续年份
List<String> parts = new ArrayList<>();
int start = years.get(0);
int prev = start;
for (int i = 1; i < years.size(); i++) {
int current = years.get(i);
if (current == prev + 1) { // 连续年份
prev = current;
} else { // 非连续年份
addYearPart(parts, start, prev);
start = current;
prev = current;
}
}
addYearPart(parts, start, prev); // 处理最后一组
return String.join(",", parts);
}
private static void addYearPart(List<String> parts, int start, int end) {
if (start == end) {
parts.add(String.valueOf(start));
} else {
parts.add(start + "-" + end);
}
}
@Override
public R getStatInfo(String stcds, String startTime, String endTime, Integer pageNum, Integer pageSize) {
Map<String, Object> map = new HashMap<>();
map.put("page", Convert.toStr(pageNum));
map.put("limit", Convert.toStr(pageSize));
List<String> filteredList = Collections.emptyList();
if (stcds != null) {
if (stcds.contains("all")) {
stcds = "";
}
filteredList = Arrays.stream(stcds.split(","))
.filter(s -> s != null && !s.trim().isEmpty())
.map(String::trim)
.collect(Collectors.toList());
}
System.out.println("stcds: "+stcds);
map.put("stcds", filteredList.isEmpty() ? null : filteredList);
IPage<YcResStatInfo> ycResStatInfoIPage = ycResTableInfoMapper.getPageList(new Query<HyStscAVo>().getPage(map), map);
return R.ok().put("data", ycResStatInfoIPage.getRecords()).put("count", ycResStatInfoIPage.getTotal());
}
}

70
swlscx/src/main/resources/mapper/actualSurvey/HyObqGMapper.xml

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.swlscx.actualSurvey.mapper.HyObqGMapper">
<select id="selectHyObqGDataByPageAndInfo" resultType="com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo">
select hsa.stcd,hme.yr,hme.mnth,hme.qobno,hme.msqbgtm,hme.msqedtm,hme.xsqlc,hme.msqmt,hme.bsggz,hme.q,hme.qrcd,hme.xstta, hme.xsa,hme.xsarcd
, hme.xsavv,hme.xsmxv , hme.tpwd , hme.xsavdp , hme.xsmxdp , hme.ibwd , hme.ibavdp,hme.ibmxdp,hme.rvsfsl,hme.n
, hme.obnont,hsa.stnm,hsa.addvcd from hy_obq_g hme
left join hy_stsc_a hsa on hme.stcd = hsa.stcd
<where>
<trim prefixOverrides="and">
<if test="map.stcd != null and map.stcd.size >0">
and hme.stcd in <foreach collection="map.stcd" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
</if>
<if test="map.stnm != null and map.stnm != ''">
and hsa.stnm like concat('%',#{map.stnm},'%')
</if>
<if test="map.startYear != null and map.startYear != ''">
and hme.yr >= #{map.startYear}
</if>
<if test="map.endYear != null and map.endYear != ''">
and hme.yr &lt;= #{map.endYear}
</if>
<if test="map.startTime != null and map.startTime != ''">
and CONCAT(hme.yr, LPAD(hme.MNTH, 2, '0')) &gt;= #{map.startTime}
</if>
<if test="map.endTime != null and map.endTime != ''">
and CONCAT(hme.yr, LPAD(hme.MNTH, 2, '0')) &lt;= #{map.endTime}
</if>
</trim>
</where>
order by hme.yr , hme.MNTH ,hme.msqbgtm
</select>
<select id="selectHyObqGData" resultType="com.ruoyi.swlscx.actualSurvey.domain.vo.HyObqGVo">
select hsa.stcd,hme.yr,hme.mnth,hme.qobno,hme.msqbgtm,hme.msqedtm,hme.xsqlc,hme.msqmt,hme.bsggz,hme.q,hme.qrcd,hme.xstta, hme.xsa,hme.xsarcd
, hme.xsavv,hme.xsmxv , hme.tpwd , hme.xsavdp , hme.xsmxdp , hme.ibwd , hme.ibavdp,hme.ibmxdp,hme.rvsfsl,hme.n
, hme.obnont,hsa.stnm,hsa.addvcd from hy_obq_g hme
left join hy_stsc_a hsa on hme.stcd = hsa.stcd
<where>
<trim prefixOverrides="and">
<if test="map.stcd != null and map.stcd.size >0">
and hme.stcd in <foreach collection="map.stcd" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
</if>
<if test="map.stnm != null and map.stnm != ''">
and hsa.stnm like concat('%',#{map.stnm},'%')
</if>
<if test="map.startYear != null and map.startYear != ''">
and hme.yr >= #{map.startYear}
</if>
<if test="map.endYear != null and map.endYear != ''">
and hme.yr &lt;= #{map.endYear}
</if>
<if test="map.startTime != null and map.startTime != ''">
and CONCAT(hme.yr, LPAD(hme.MNTH, 2, '0')) &gt;= #{map.startTime}
</if>
<if test="map.endTime != null and map.endTime != ''">
and CONCAT(hme.yr, LPAD(hme.MNTH, 2, '0')) &lt;= #{map.endTime}
</if>
</trim>
</where>
order by hme.yr , hme.MNTH ,hme.msqbgtm
</select>
</mapper>

54
swlscx/src/main/resources/mapper/actualSurvey/HyXsmsrsGMapper.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.swlscx.actualSurvey.mapper.HyXsmsrsGMapper">
<select id="selectHyXsmsrsGDataByPageAndInfo" resultType="com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo">
select hsa.stcd,hme.obdt,hme.obno,hme.vtno,hme.di,hme.rvbbel,hme.rvbbelrcd,hme.odbrz,hme.odbrzrcd,hme.vtaz,hme.nof
,hsa.stnm,hsa.addvcd from hy_xsmsrs_g hme
left join hy_stsc_a hsa on hme.stcd = hsa.stcd
<where>
<trim prefixOverrides="and">
<if test="map.stcd != null and map.stcd.size >0">
and hme.stcd in
<foreach collection="map.stcd" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
</if>
<if test="map.startTime != null and map.startTime != ''">
and hme.OBDT >= #{map.startTime}
</if>
<if test="map.endTime != null and map.endTime != ''">
and hme.OBDT &lt;= #{map.endTime}
</if>
</trim>
</where>
order by hme.stcd,hme.OBDT,hme.obno
</select>
<select id="selectHyXsmsrsGData" resultType="com.ruoyi.swlscx.actualSurvey.domain.vo.HyXsmsrsGVo">
select hsa.stcd,hme.obdt,hme.obno,hme.vtno,hme.di,hme.rvbbel,hme.rvbbelrcd,hme.odbrz,hme.odbrzrcd,hme.vtaz,hme.nof
,hsa.stnm,hsa.addvcd from hy_xsmsrs_g hme
left join hy_stsc_a hsa on hme.stcd = hsa.stcd
<where>
<trim prefixOverrides="and">
<if test="map.stcd != null and map.stcd.size >0">
and hme.stcd in
<foreach collection="map.stcd" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
</if>
<if test="map.startTime != null and map.startTime != ''">
and hme.OBDT >= #{map.startTime}
</if>
<if test="map.endTime != null and map.endTime != ''">
and hme.OBDT &lt;= #{map.endTime}
</if>
</trim>
</where>
order by hme.stcd,hme.OBDT,hme.obno
</select>
</mapper>

32
swlscx/src/main/resources/mapper/basic/HyStscAMapper.xml

@ -221,4 +221,36 @@ WITH
select stcd,dt from hy_dq_c where dt >= #{startTimeDay} and dt &lt;= #{endTimeDay} select stcd,dt from hy_dq_c where dt >= #{startTimeDay} and dt &lt;= #{endTimeDay}
</select> </select>
<select id="getStatList" resultType="string">
SELECT DISTINCT stcd
FROM yc_res_stat_info
WHERE
-- 检查单个年份是否在目标区间
EXISTS (
SELECT 1
FROM (
SELECT TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(old_year, ',', n), ',', -1)) AS year_part
FROM (
SELECT 1 AS n UNION SELECT 2 UNION SELECT 3 -- 按需扩展至足够拆分数量
) numbers
WHERE n &lt;= LENGTH(old_year) - LENGTH(REPLACE(old_year, ',', '')) + 1
) split_years
WHERE
-- 处理单个年份
(year_part NOT LIKE '%-%' AND year_part BETWEEN #{startTime} AND #{endTime})
OR
-- 处理年份范围
(year_part LIKE '%-%'
AND CAST(SUBSTRING_INDEX(year_part, '-', 1) AS UNSIGNED) &lt;= #{endTime}
AND CAST(SUBSTRING_INDEX(year_part, '-', -1) AS UNSIGNED) >= #{startTime}
)
);
</select>
<select id="getStatAllList" resultType="string">
SELECT DISTINCT stcd
FROM yc_res_stat_info
</select>
</mapper> </mapper>

84
swlscx/src/main/resources/mapper/synchronousData/YcResTableInfoMapper.xml

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.swlscx.synchronousData.mapper.YcResTableInfoMapper">
<select id="getResTableByDay" resultType="com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo">
SELECT stcd,
group_concat(tm) as statYear
FROM (SELECT a.stcd,
LEFT(a.dt, 4) tm
FROM ${tableName} a
JOIN hy_stsc_a b ON a.stcd = b.stcd
GROUP BY stcd,
LEFT(dt, 4)) a
GROUP BY stcd
</select>
<insert id="saveBatch" parameterType="java.util.List">
INSERT INTO yc_res_stat_info
(stcd, s_type, res_table_id, res_type, res_table,stat_year,old_year)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.stcd}, #{item.sType}, #{item.resTableId}, #{item.resType}, #{item.resTable},
#{item.statYear}, #{item.oldYear})
</foreach>
ON DUPLICATE KEY UPDATE
res_type = VALUES(res_type),
res_table = VALUES(res_table),
stat_year = VALUES(stat_year),
old_year = VALUES(old_year)
</insert>
<select id="getPageList" resultType="com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo">
SELECT a.stcd,
b.stnm,
a.s_type,
a.res_table_id,
a.res_type,
a.res_table,
a.stat_year
FROM yc_res_stat_info a
left join hy_stsc_a b on a.stcd = b.stcd
<where>
<trim prefixOverrides="and">
<if test="param.stcds != null and param.stcds.size >0">
a.stcd in <foreach collection="param.stcds" item="stcd" separator="," open="(" close=")">
#{stcd}
</foreach>
</if>
</trim>
</where>
order by a.stcd
</select>
<select id="getResTableRainXPList" resultType="com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo">
SELECT stcd,
group_concat(yr) as statYear
FROM (SELECT a.stcd,
yr
FROM ${tableName} a
JOIN hy_stsc_a b ON a.stcd = b.stcd
GROUP BY stcd,
yr) a
GROUP BY stcd
</select>
<select id="getResTableRainrexBList" resultType="com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo" >
SELECT stcd, GROUP_CONCAT(DISTINCT LEFT(bgtm, 4)) AS statYear
FROM ${tableName} a
WHERE EXISTS (SELECT 1 FROM hy_stsc_a b WHERE a.stcd = b.stcd)
GROUP BY stcd
</select>
<select id="getResTableTMList" resultType="com.ruoyi.swlscx.synchronousData.dto.YcResStatInfo">
SELECT stcd, GROUP_CONCAT(DISTINCT LEFT(tm, 4)) AS statYear
FROM ${tableName} a
WHERE EXISTS (SELECT 1 FROM hy_stsc_a b WHERE a.stcd = b.stcd)
GROUP BY stcd
</select>
</mapper>
Loading…
Cancel
Save