fix: 优化过鱼历史查询

This commit is contained in:
tangwei 2026-07-16 11:52:30 +08:00
parent 59890a5659
commit 1e44d6ee4f
5 changed files with 158 additions and 18 deletions

View File

@ -89,10 +89,17 @@ public class FishDraftDataController {
return t;
});
// @PostMapping("/page")
// @Operation(summary = "分页查询过鱼数据(关联电站和设施)")
// public ResponseResult queryPageList(@RequestBody DataSourceRequest dataSourceRequest) {
// Page<FishDraftDataVO> result = fishDraftDataService.queryPageList(dataSourceRequest);
// return ResponseResult.successData(result);
// }
@PostMapping("/page")
@Operation(summary = "分页查询过鱼数据(关联电站和设施)")
public ResponseResult queryPageList(@RequestBody DataSourceRequest dataSourceRequest) {
Page<FishDraftDataVO> result = fishDraftDataService.queryPageList(dataSourceRequest);
@Operation(summary = "分页查询过鱼数据(关联电站和设施APPROVED状态时根据当前用户电站权限过滤")
public ResponseResult queryPageListWithScope(@RequestBody DataSourceRequest dataSourceRequest) {
Page<FishDraftDataVO> result = fishDraftDataService.queryPageListWithScope(dataSourceRequest);
return ResponseResult.successData(result);
}

View File

@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Set;
/**
* <p>
@ -33,6 +34,24 @@ public interface FishDraftDataMapper extends BaseMapper<FishDraftData> {
@Param("hbrvcd") String hbrvcd,
@Param("approvalId") String approvalId);
/**
* 关联查询过鱼数据分页含电站权限过滤
*/
Page<FishDraftDataVO> selectJoinPageWithStationScope(Page<FishDraftDataVO> page,
@Param("stcd") String stcd,
@Param("rstcd") String rstcd,
@Param("baseId") String baseId,
@Param("rvcd") String rvcd,
@Param("direction") String direction,
@Param("status") String status,
@Param("ftp") String ftp,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("userId") String userId,
@Param("hbrvcd") String hbrvcd,
@Param("approvalId") String approvalId,
@Param("stationCodes") Set<String> stationCodes);
/**
* 关联查询过鱼数据不分页
*/

View File

@ -20,6 +20,12 @@ public interface IFishDraftDataService extends IService<FishDraftData> {
*/
Page<FishDraftDataVO> queryPageList(DataSourceRequest dataSourceRequest);
/**
* 分页查询草稿数据关联电站和设施表含电站权限过滤
* status = APPROVED 根据当前用户有权限的电站编码过滤数据
*/
Page<FishDraftDataVO> queryPageListWithScope(DataSourceRequest dataSourceRequest);
/**
* 查询草稿数据列表关联电站和设施表不分页
*/

View File

@ -8,6 +8,7 @@ import com.yfd.platform.common.DataSourceLoadOptionsBase;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdRvcdDic;
import com.yfd.platform.qgc_base.mapper.SdRvcdDicMapper;
import com.yfd.platform.qgc_base.service.ICurrentUserDataScopeService;
import com.yfd.platform.qgc_data.domain.ApprovalMain;
import com.yfd.platform.qgc_data.domain.FishDraftData;
import com.yfd.platform.qgc_data.domain.SysUserDataScope;
@ -89,6 +90,9 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
@Resource
private ISdFpssRService sdFpssRService;
@Resource
private ICurrentUserDataScopeService currentUserDataScopeService;
@Resource
private PlatformTransactionManager transactionManager;
@ -108,19 +112,68 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
String direction = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "direction");
String status = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "status");
String STRDT = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "strdt");
String startTime=null;
String endTime=null;
String startTime = null;
String endTime = null;
// String userId = (SecurityUtils.hasPermission("sjtb:edit-review") || "admin".equals(SecurityUtils.getCurrentUsername())) ?null:SecurityUtils.getUserId();
String userId = SecurityUtils.getUserId();
if(StrUtil.isNotBlank(approvalId)){
userId=null;
if (StrUtil.isNotBlank(approvalId)) {
userId = null;
}
// 如果 startTime endTime 为空尝试从 TM 字段解析
if (StrUtil.isNotBlank(STRDT)&& STRDT.split( ",").length==2) {
startTime=STRDT.split(",")[0];
endTime=STRDT.split(",")[1];
if (StrUtil.isNotBlank(STRDT) && STRDT.split(",").length == 2) {
startTime = STRDT.split(",")[0];
endTime = STRDT.split(",")[1];
}
Page<FishDraftDataVO> resultPage = fishDraftDataMapper.selectJoinPage(page, stcd, rstcd, baseId, rvcd, direction, status, ftp, startTime, endTime,userId,hbrvcd,approvalId);
Page<FishDraftDataVO> resultPage = fishDraftDataMapper.selectJoinPage(page, stcd, rstcd, baseId, rvcd, direction, status, ftp, startTime, endTime, userId, hbrvcd, approvalId);
fillUserNames(resultPage.getRecords());
return resultPage;
}
@Override
public Page<FishDraftDataVO> queryPageListWithScope(DataSourceRequest dataSourceRequest) {
Page<FishDraftDataVO> page = KendoUtil.getPage(dataSourceRequest);
page.setSize(dataSourceRequest.getTake());
page.setCurrent(dataSourceRequest.getSkip());
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
String stcd = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stcd");
String approvalId = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "approvalId");
String rstcd = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "rstcd");
String hbrvcd = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "hbrvcd");
String rvcd = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "rvcd");
String baseId = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "baseId");
String ftp = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "ftp");
String direction = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "direction");
String status = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "status");
String STRDT = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "strdt");
String startTime = null;
String endTime = null;
String userId = SecurityUtils.getUserId();
if (StrUtil.isNotBlank(approvalId)) {
userId = null;
}
if (StrUtil.isNotBlank(STRDT) && STRDT.split(",").length == 2) {
startTime = STRDT.split(",")[0];
endTime = STRDT.split(",")[1];
}
// status = APPROVED 加上当前用户的电站权限过滤
Set<String> stationCodes = null;
if ("APPROVED".equals(status)) {
userId=null;
if (!currentUserDataScopeService.getCurrentUserDataScope().isManagedAdmin()) {
stationCodes = currentUserDataScopeService.getCurrentUserDataScope().getStationCodes();
// 如果用户没有电站权限且不是管理员返回空结果
if (stationCodes == null || stationCodes.isEmpty()) {
page.setRecords(Collections.emptyList());
page.setTotal(0);
return page;
}
}
}
Page<FishDraftDataVO> resultPage = fishDraftDataMapper.selectJoinPageWithStationScope(
page, stcd, rstcd, baseId, rvcd, direction, status, ftp,
startTime, endTime, userId, hbrvcd, approvalId, stationCodes);
fillUserNames(resultPage.getRecords());
return resultPage;
}
@ -262,7 +315,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
@Override
public boolean batchRemoveDraft(List<String> ids) {
long count = countByIdsAndLockFlag(ids, 1);
if(count > 0){
if (count > 0) {
return false;
}
String userId = SecurityUtils.getUserId();
@ -392,7 +445,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
// hbrvnmSet.add(hbrv.getRvnm());
// }
List<SdEngInfoBH> stationList = engInfoBHMapper.selectByRvcd(null,orgId);
List<SdEngInfoBH> stationList = engInfoBHMapper.selectByRvcd(null, orgId);
if (stationList != null) {
for (SdEngInfoBH station : stationList) {
if (station.getStcd() != null) {
@ -401,7 +454,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
if (station.getEnnm() != null) {
ennmSet.add(station.getEnnm());
}
if(station.getReachcdName() != null){
if (station.getReachcdName() != null) {
hbrvnmSet.add(station.getReachcdName());
}
}
@ -419,7 +472,7 @@ public class FishDraftDataServiceImpl extends ServiceImpl<FishDraftDataMapper, F
if (station.getEnnm() != null) {
ennmSet.add(station.getEnnm());
}
if(station.getReachcdName() != null){
if (station.getReachcdName() != null) {
hbrvnmSet.add(station.getReachcdName());
}

View File

@ -191,6 +191,61 @@
ORDER BY D.TM DESC, D.ROW_INDEX ASC
</select>
<select id="selectJoinPageWithStationScope" resultMap="JoinResultMap">
SELECT
<include refid="joinColumns"/>
FROM FISH_DRAFT_DATA D
LEFT JOIN SD_FPSS_B_H F ON D.STCD = F.STCD
LEFT JOIN SD_FISHDICTORY_B FB ON FB.ID = D.FTP
LEFT JOIN SD_ENGINFO_B_H E ON F.RSTCD = E.STCD
LEFT JOIN SD_HYDROBASE H ON E.BASE_ID = H.BASEID
<include refid="rvcdDisplayJoin"/>
WHERE D.DELETED_FLAG = 0
<if test="stcd != null and stcd != ''">
AND D.STCD = #{stcd}
</if>
<if test="userId != null and userId != ''">
AND D.CREATED_BY = #{userId}
</if>
<if test="ftp != null and ftp != ''">
AND D.FTP = #{ftp}
</if>
<if test="rstcd != null and rstcd != ''">
AND F.RSTCD = #{rstcd}
</if>
<if test="baseId != null and baseId != ''">
AND E.BASE_ID = #{baseId}
</if>
<if test="rvcd != null and rvcd != ''">
AND E.REACHCD = #{rvcd}
</if>
<if test="hbrvcd != null and hbrvcd != ''">
AND E.HBRVCD = #{hbrvcd}
</if>
<if test="direction != null and direction != ''">
AND D.DIRECTION = #{direction}
</if>
<if test="status != null and status != ''">
AND D.STATUS = #{status}
</if>
<if test="approvalId != null and approvalId != ''">
AND D.APPROVAL_ID = #{approvalId}
</if>
<if test="startTime != null and startTime != ''">
AND D.STRDT &gt;= TO_DATE(#{startTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="endTime != null and endTime != ''">
AND D.STRDT &lt;= TO_DATE(#{endTime}, 'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="stationCodes != null and stationCodes.size() > 0">
AND E.STCD IN
<foreach collection="stationCodes" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</if>
ORDER BY H.ORDER_INDEX ASC,E.ORDER_INDEX ASC, D.TM DESC, D.ROW_INDEX ASC
</select>
<select id="selectJoinList" resultMap="JoinResultMap">
SELECT
<include refid="joinColumns"/>