fix: 增加到数统计接口
This commit is contained in:
parent
5bc8df47e2
commit
3d48fb05b4
@ -11,6 +11,7 @@ import com.yfd.platform.constant.Constant;
|
|||||||
import com.yfd.platform.system.domain.LoginUser;
|
import com.yfd.platform.system.domain.LoginUser;
|
||||||
import com.yfd.platform.system.domain.Message;
|
import com.yfd.platform.system.domain.Message;
|
||||||
import com.yfd.platform.system.service.IMessageService;
|
import com.yfd.platform.system.service.IMessageService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
@ -25,6 +26,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -36,6 +38,9 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
|||||||
FilterChain filterChain) throws ServletException, IOException {
|
FilterChain filterChain) throws ServletException, IOException {
|
||||||
//获取token
|
//获取token
|
||||||
String uri = httpServletRequest.getRequestURI();
|
String uri = httpServletRequest.getRequestURI();
|
||||||
|
if(uri.contains("/data/fishDraft/importZip")){
|
||||||
|
log.info("请求地址:{}", uri);
|
||||||
|
}
|
||||||
String token = httpServletRequest.getHeader("token");
|
String token = httpServletRequest.getHeader("token");
|
||||||
if (StrUtil.isEmpty(token) || "/user/login".equals(uri)) {
|
if (StrUtil.isEmpty(token) || "/user/login".equals(uri)) {
|
||||||
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
filterChain.doFilter(httpServletRequest, httpServletResponse);
|
||||||
|
|||||||
@ -26,9 +26,11 @@ import com.yfd.platform.common.DataSourceRequest;
|
|||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.data.domain.*;
|
import com.yfd.platform.data.domain.*;
|
||||||
import com.yfd.platform.data.domain.vo.FishDraftDataVO;
|
import com.yfd.platform.data.domain.vo.FishDraftDataVO;
|
||||||
|
import com.yfd.platform.data.domain.vo.FishStatisticsVO;
|
||||||
import com.yfd.platform.data.service.AttachmentUploadService;
|
import com.yfd.platform.data.service.AttachmentUploadService;
|
||||||
import com.yfd.platform.data.service.IFishDraftDataService;
|
import com.yfd.platform.data.service.IFishDraftDataService;
|
||||||
import com.yfd.platform.data.service.IFishImportService;
|
import com.yfd.platform.data.service.IFishImportService;
|
||||||
|
import com.yfd.platform.data.service.IFishStatisticsService;
|
||||||
import com.yfd.platform.data.service.IImportTaskService;
|
import com.yfd.platform.data.service.IImportTaskService;
|
||||||
import com.yfd.platform.data.utils.ZipFileUtil;
|
import com.yfd.platform.data.utils.ZipFileUtil;
|
||||||
import com.yfd.platform.utils.KendoUtil;
|
import com.yfd.platform.utils.KendoUtil;
|
||||||
@ -77,6 +79,9 @@ public class FishDraftDataController {
|
|||||||
@Resource
|
@Resource
|
||||||
private AttachmentUploadService attachmentUploadService;
|
private AttachmentUploadService attachmentUploadService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IFishStatisticsService fishStatisticsService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThreadPoolTaskExecutor taskExecutor;
|
private ThreadPoolTaskExecutor taskExecutor;
|
||||||
|
|
||||||
@ -100,6 +105,13 @@ public class FishDraftDataController {
|
|||||||
return ResponseResult.successData(list);
|
return ResponseResult.successData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/statistics")
|
||||||
|
@Operation(summary = "过鱼到数统计(按用户月度汇总,支持流域/电站多选过滤)")
|
||||||
|
public ResponseResult statistics(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page<FishStatisticsVO> result = fishStatisticsService.queryPage(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/getById")
|
@GetMapping("/getById")
|
||||||
@Operation(summary = "根据ID查询")
|
@Operation(summary = "根据ID查询")
|
||||||
public ResponseResult getById(@RequestParam String id) {
|
public ResponseResult getById(@RequestParam String id) {
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.yfd.platform.data.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FishStatisticsVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String contact;
|
||||||
|
|
||||||
|
private String basinNames;
|
||||||
|
|
||||||
|
private String stationNames;
|
||||||
|
|
||||||
|
private String reportMonth;
|
||||||
|
|
||||||
|
private Date minStrdt;
|
||||||
|
|
||||||
|
private Date maxEnddt;
|
||||||
|
|
||||||
|
private Integer totalFcnt;
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.yfd.platform.data.mapper;
|
||||||
|
|
||||||
|
import com.yfd.platform.data.domain.vo.FishStatisticsVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface FishStatisticsMapper {
|
||||||
|
|
||||||
|
List<FishStatisticsVO> queryStatistics(@Param("basinNames") List<String> basinNames,
|
||||||
|
@Param("stationNames") List<String> stationNames,
|
||||||
|
@Param("startRow") int startRow,
|
||||||
|
@Param("endRow") int endRow);
|
||||||
|
|
||||||
|
int countStatistics(@Param("basinNames") List<String> basinNames,
|
||||||
|
@Param("stationNames") List<String> stationNames);
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.yfd.platform.data.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.data.domain.vo.FishStatisticsVO;
|
||||||
|
|
||||||
|
public interface IFishStatisticsService {
|
||||||
|
|
||||||
|
Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest);
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.yfd.platform.data.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.data.domain.vo.FishStatisticsVO;
|
||||||
|
import com.yfd.platform.data.mapper.FishStatisticsMapper;
|
||||||
|
import com.yfd.platform.data.service.IFishStatisticsService;
|
||||||
|
import com.yfd.platform.utils.KendoUtil;
|
||||||
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class FishStatisticsServiceImpl implements IFishStatisticsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FishStatisticsMapper fishStatisticsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||||
|
|
||||||
|
String basinNamesStr = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "basinNames");
|
||||||
|
String stationNamesStr = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stationNames");
|
||||||
|
|
||||||
|
List<String> basinNames = parseFilterList(basinNamesStr);
|
||||||
|
List<String> stationNames = parseFilterList(stationNamesStr);
|
||||||
|
|
||||||
|
int take = dataSourceRequest.getTake();
|
||||||
|
int skip = dataSourceRequest.getSkip();
|
||||||
|
if (take <= 0) {
|
||||||
|
take = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
int startRow = skip;
|
||||||
|
int endRow = skip + take;
|
||||||
|
|
||||||
|
List<FishStatisticsVO> records = fishStatisticsMapper.queryStatistics(
|
||||||
|
basinNames, stationNames, startRow, endRow);
|
||||||
|
|
||||||
|
int total = fishStatisticsMapper.countStatistics(basinNames, stationNames);
|
||||||
|
|
||||||
|
Page<FishStatisticsVO> page = new Page<>();
|
||||||
|
page.setRecords(records);
|
||||||
|
page.setTotal(total);
|
||||||
|
page.setSize(take);
|
||||||
|
page.setCurrent(skip / take + 1L);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> parseFilterList(String filterValue) {
|
||||||
|
if (StrUtil.isBlank(filterValue)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return Arrays.asList(filterValue.split(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -116,7 +116,7 @@ spring:
|
|||||||
# 关键:文件超过 1KB 就写入磁盘临时文件,避免内存积压
|
# 关键:文件超过 1KB 就写入磁盘临时文件,避免内存积压
|
||||||
file-size-threshold: 1KB
|
file-size-threshold: 1KB
|
||||||
# 指定临时目录(确保 Docker 容器内该目录可写且有空间)
|
# 指定临时目录(确保 Docker 容器内该目录可写且有空间)
|
||||||
location: /qgc-platform/tmp/zip_import_temp
|
location: /tmp/upload
|
||||||
logging:
|
logging:
|
||||||
file:
|
file:
|
||||||
name: logs/platform-dev.log
|
name: logs/platform-dev.log
|
||||||
|
|||||||
137
backend/src/main/resources/mapper/data/FishStatisticsMapper.xml
Normal file
137
backend/src/main/resources/mapper/data/FishStatisticsMapper.xml
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
<?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.yfd.platform.data.mapper.FishStatisticsMapper">
|
||||||
|
|
||||||
|
<resultMap id="StatisticsResultMap" type="com.yfd.platform.data.domain.vo.FishStatisticsVO">
|
||||||
|
<result column="USER_ID" property="userId"/>
|
||||||
|
<result column="REAL_NAME" property="realName"/>
|
||||||
|
<result column="PHONE" property="phone"/>
|
||||||
|
<result column="CONTACT" property="contact"/>
|
||||||
|
<result column="BASIN_NAMES" property="basinNames"/>
|
||||||
|
<result column="STATION_NAMES" property="stationNames"/>
|
||||||
|
<result column="REPORT_MONTH" property="reportMonth"/>
|
||||||
|
<result column="MIN_STRDT" property="minStrdt"/>
|
||||||
|
<result column="MAX_ENDDT" property="maxEnddt"/>
|
||||||
|
<result column="TOTAL_FCNT" property="totalFcnt"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="statisticsQuery">
|
||||||
|
WITH user_scope_detail AS (
|
||||||
|
SELECT DISTINCT
|
||||||
|
su.ID AS USER_ID,
|
||||||
|
h.HBRVNM AS BASIN_NAME,
|
||||||
|
e.ENNM AS STATION_NAME
|
||||||
|
FROM QGC_REFA.SYS_USER su
|
||||||
|
JOIN QGC_REFA.SYS_USER_DATA_SCOPE sud
|
||||||
|
ON su.ID = sud.USER_ID
|
||||||
|
AND sud.STATUS = 1
|
||||||
|
AND sud.ORG_TYPE = 'HBRVCD'
|
||||||
|
JOIN QGC_REFA.SD_HBRV_DIC h
|
||||||
|
ON sud.ORG_ID = h.HBRVCD
|
||||||
|
AND h.ENABLED = 1
|
||||||
|
AND h.IS_DELETED = 0
|
||||||
|
JOIN QGC_REFA.SD_ENGINFO_B_H e
|
||||||
|
ON e.HBRVCD = h.HBRVCD
|
||||||
|
AND e.USFL = 1
|
||||||
|
WHERE su.STATUS = 1
|
||||||
|
AND su.REG_STATUS IN ('PENDING', 'APPROVED', 'REJECTED')
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
su.ID AS USER_ID,
|
||||||
|
h.HBRVNM AS BASIN_NAME,
|
||||||
|
e.ENNM AS STATION_NAME
|
||||||
|
FROM QGC_REFA.SYS_USER su
|
||||||
|
JOIN QGC_REFA.SYS_USER_DATA_SCOPE sud
|
||||||
|
ON su.ID = sud.USER_ID
|
||||||
|
AND sud.STATUS = 1
|
||||||
|
AND sud.ORG_TYPE = 'STATION'
|
||||||
|
JOIN QGC_REFA.SD_ENGINFO_B_H e
|
||||||
|
ON sud.ORG_ID = e.STCD
|
||||||
|
AND e.USFL = 1
|
||||||
|
JOIN QGC_REFA.SD_HBRV_DIC h
|
||||||
|
ON e.HBRVCD = h.HBRVCD
|
||||||
|
AND h.ENABLED = 1
|
||||||
|
AND h.IS_DELETED = 0
|
||||||
|
WHERE su.STATUS = 1
|
||||||
|
AND su.REG_STATUS IN ('PENDING', 'APPROVED', 'REJECTED')
|
||||||
|
),
|
||||||
|
user_scope AS (
|
||||||
|
SELECT
|
||||||
|
USER_ID,
|
||||||
|
RTRIM(
|
||||||
|
XMLAGG(XMLELEMENT(E, BASIN_NAME || ',') ORDER BY BASIN_NAME)
|
||||||
|
.EXTRACT('//text()').GETCLOBVAL(),
|
||||||
|
','
|
||||||
|
) AS BASIN_NAMES,
|
||||||
|
RTRIM(
|
||||||
|
XMLAGG(XMLELEMENT(E, STATION_NAME || ',') ORDER BY STATION_NAME)
|
||||||
|
.EXTRACT('//text()').GETCLOBVAL(),
|
||||||
|
','
|
||||||
|
) AS STATION_NAMES
|
||||||
|
FROM user_scope_detail
|
||||||
|
GROUP BY USER_ID
|
||||||
|
),
|
||||||
|
fish_monthly AS (
|
||||||
|
SELECT
|
||||||
|
CREATED_BY,
|
||||||
|
TO_CHAR(STRDT, 'YYYY-MM') AS REPORT_MONTH,
|
||||||
|
MIN(STRDT) AS MIN_STRDT,
|
||||||
|
MAX(STRDT) AS MAX_ENDDT,
|
||||||
|
SUM(FCNT) AS TOTAL_FCNT
|
||||||
|
FROM QGC_REFA.FISH_DRAFT_DATA
|
||||||
|
WHERE DELETED_FLAG = 0 AND STATUS IN ('PENDING','APPROVED')
|
||||||
|
GROUP BY CREATED_BY, TO_CHAR(STRDT, 'YYYY-MM')
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
us.USER_ID,
|
||||||
|
su.REAL_NAME,
|
||||||
|
su.PHONE,
|
||||||
|
su.NICKNAME || '/' || su.PHONE AS CONTACT,
|
||||||
|
us.BASIN_NAMES,
|
||||||
|
us.STATION_NAMES,
|
||||||
|
fm.REPORT_MONTH,
|
||||||
|
fm.MIN_STRDT,
|
||||||
|
fm.MAX_ENDDT,
|
||||||
|
fm.TOTAL_FCNT
|
||||||
|
FROM user_scope us
|
||||||
|
JOIN QGC_REFA.SYS_USER su
|
||||||
|
ON us.USER_ID = su.ID
|
||||||
|
LEFT JOIN fish_monthly fm
|
||||||
|
ON us.USER_ID = fm.CREATED_BY
|
||||||
|
WHERE 1 = 1
|
||||||
|
<if test="basinNames != null and basinNames.size() > 0">
|
||||||
|
AND (
|
||||||
|
<foreach collection="basinNames" item="name" separator=" OR ">
|
||||||
|
INSTR(us.BASIN_NAMES, #{name}) > 0
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="stationNames != null and stationNames.size() > 0">
|
||||||
|
AND (
|
||||||
|
<foreach collection="stationNames" item="name" separator=" OR ">
|
||||||
|
INSTR(us.STATION_NAMES, #{name}) > 0
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
ORDER BY fm.REPORT_MONTH, us.USER_ID
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="queryStatistics" resultMap="StatisticsResultMap">
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT t.*, ROWNUM rn FROM (
|
||||||
|
<include refid="statisticsQuery"/>
|
||||||
|
) t
|
||||||
|
WHERE ROWNUM <= #{endRow}
|
||||||
|
) WHERE rn > #{startRow}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countStatistics" resultType="int">
|
||||||
|
SELECT COUNT(*) FROM (
|
||||||
|
<include refid="statisticsQuery"/>
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user