| | |
| | | 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; |
| | |
| | | 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> |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | @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("危化品条码数据不存在"); |
| | | } |
| | |
| | | } |
| | | |
| | | @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("危化品数据不存在"); |
| | |
| | | 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("无权限操作其他企业数据"); |
| | | } |
| | | } |
| | | } |
| | | } |