From 437f8e2b89a18363a1073fdbb3ab99bcd840a757 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期一, 21 四月 2025 10:51:36 +0800
Subject: [PATCH] 危化品新版修改

---
 hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatFlowServiceImpl.java |   43 +++++++++++++++++++++++++++++++------------
 1 files changed, 31 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 461412e..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();
@@ -109,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("危化品条码数据不存在");
         }
@@ -142,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("危化品数据不存在");
@@ -162,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