From 65ca50935315a89e219b7c974caf95dc28895ffc Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Thu, 16 Oct 2025 08:37:56 +0800
Subject: [PATCH] 修改
---
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
index 34eb0f0..5fb9619 100644
--- a/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
+++ b/hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java
@@ -1,5 +1,7 @@
package com.gkhy.hazmat.system.service.impl;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.hazmat.common.api.CommonPage;
import com.gkhy.hazmat.common.config.IdTableNameHandler;
@@ -17,8 +19,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* <p>
@@ -37,9 +41,14 @@
public CommonPage selectHazmatFlowList(HzHazmatFlow hazmatFlow) {
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
checkUserAllowed(null,currentUser);
- hazmatFlow.setCompanyId(currentUser.getCompanyId());
- //设置分表id
- IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
+ IdTableNameHandler.setCurrentId(hazmatFlow.getCompanyId());
+ }else {
+ hazmatFlow.setCompanyId(currentUser.getCompanyId());
+ //设置分表id
+ //todo
+ IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ }
PageUtils.startPage();
List<HzHazmatFlow> flowList = baseMapper.selectHazmatFlowList(hazmatFlow);
IdTableNameHandler.removeCurrentId();
@@ -53,6 +62,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
HzHazmatFlow hazmatFlow = baseMapper.selectById(hazmatFlowId);
+ IdTableNameHandler.removeCurrentId();
if (!hazmatFlow.getCompanyId().equals(currentUser.getCompanyId())) {
throw new ApiException("无权限查看其它企业数据");
}
@@ -68,6 +78,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
int row = baseMapper.insert(hazmatFlow);
+ IdTableNameHandler.removeCurrentId();
if (row < 1) {
throw new ApiException("新增危化品流向失败");
}
@@ -81,6 +92,7 @@
//设置分表id
IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
HzHazmatFlow hazmatFlow=baseMapper.selectById(hazmatFlowId);
+ IdTableNameHandler.removeCurrentId();
if(hazmatFlow==null){
throw new ApiException("流向信息不存在");
}
@@ -106,15 +118,19 @@
}
@Override
- public List<HzHazmatFlow> selectAllHazmatFlowByCode(String code) {
+ public List<HzHazmatFlow> selectAllHazmatFlowByCode(String code,Long companyId) {
SysUser currentUser=SecurityUtils.getLoginUser().getUser();
checkUserAllowed(null,currentUser);
if(!code.startsWith(CodePrexEnum.MATERIAL.getCode())){
throw new ApiException("条码格式不正确");
}
- //设置分表id
- IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
- HzHazmat hazmat=hazmatMapper.selectHazmatByCode(code,currentUser.getCompanyId());
+ if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
+ IdTableNameHandler.setCurrentId(companyId);
+ }else {
+ //设置分表id
+ IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ }
+ HzHazmat hazmat=hazmatMapper.selectHazmatByCode(code,currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())?companyId:currentUser.getCompanyId());
if(hazmat==null){
throw new ApiException("危化品条码数据不存在");
}
@@ -139,11 +155,15 @@
}
@Override
- public List<HzHazmatFlow> getAllHazmatFlowByHazmatId(Long hazmatId) {
+ public List<HzHazmatFlow> getAllHazmatFlowByHazmatId(Long hazmatId,Long companyId) {
SysUser currentUser=SecurityUtils.getLoginUser().getUser();
checkUserAllowed(null,currentUser);
- //设置分表id
- IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
+ IdTableNameHandler.setCurrentId(companyId);
+ }else {
+ //设置分表id
+ IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
+ }
HzHazmat hazmat=hazmatMapper.selectById(hazmatId);
if(hazmat==null){
throw new ApiException("危化品数据不存在");
@@ -159,8 +179,10 @@
throw new ApiException("管理员不能操作");
}
if(hazmatFlow!=null){
- if(!Objects.equals(user.getCompanyId(), hazmatFlow.getCompanyId())){
- throw new ApiException("无权限操作其他企业数据");
+ if (!user.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
+ if(!Objects.equals(user.getCompanyId(), hazmatFlow.getCompanyId())){
+ throw new ApiException("无权限操作其他企业数据");
+ }
}
}
}
--
Gitblit v1.9.2