不给新增企业不一致的车辆
This commit is contained in:
parent
055a6cec25
commit
f3ebaed470
@ -38,10 +38,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@ -145,7 +142,7 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
//expressions
|
||||
List<Expression> expressions = new ArrayList<>();
|
||||
if (!DataScopeInterceptor.findIgnoreDataScope(parameter, ds)) {
|
||||
if (user.getAccountType() == SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue()) {
|
||||
if (Objects.equals(user.getAccountType(), SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue())) {
|
||||
List<String> filterEnterprises = getNeedFilterLeftExpression(plainSelect, getFieldEnterpriseTables(), ds);
|
||||
if (CollUtil.isNotEmpty(filterEnterprises)) {
|
||||
List<String> enterpriseIds = userEnterpriseService.getEnterpriseIdsIfSubProject();
|
||||
|
||||
@ -3,6 +3,7 @@ package com.zhgd.mybatis;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport;
|
||||
@ -45,9 +46,19 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
return true;
|
||||
}
|
||||
if (parameter instanceof Map) {
|
||||
for (Object val : ((Map<?, ?>) parameter).values()) {
|
||||
if (val instanceof String) {
|
||||
if (val.equals(Cts.IGNORE_DATA_SCOPE)) {
|
||||
Map<?, ?> map = (Map<?, ?>) parameter;
|
||||
for (Object k : map.keySet()) {
|
||||
if (k instanceof String) {
|
||||
if (k.equals(Cts.IGNORE_DATA_SCOPE)) {
|
||||
//查询只有一个参数map的时候key等于IGNORE_DATA_SCOPE
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Object val = map.get(k);
|
||||
if (val instanceof QueryWrapper) {
|
||||
String sqlSegment = ((QueryWrapper) val).getSqlSegment();
|
||||
if (StrUtil.isNotBlank(sqlSegment) && sqlSegment.contains(Cts.IGNORE_DATA_SCOPE_CONDITION)) {
|
||||
//调用mybatisplus的mapper方法使用last方法添加参数IGNORE_DATA_SCOPE_CONDITION
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -106,6 +117,7 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
|
||||
PluginUtils.MPStatementHandler mpSh = PluginUtils.mpStatementHandler(sh);
|
||||
MappedStatement ms = mpSh.mappedStatement();
|
||||
@ -145,6 +157,7 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
//dataScopeHandler.addParam(insert, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
|
||||
try {
|
||||
if (SecurityUtils.getUser() == null) {
|
||||
@ -169,6 +182,7 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processSelect(Select select, int index, String sql, Object obj) {
|
||||
this.processSelectBody(select.getSelectBody(), obj);
|
||||
}
|
||||
|
||||
@ -60,7 +60,15 @@ public interface Cts {
|
||||
String HK_SYNC_AUTH_SUCCESS_KEY = "hkSyncAuthSuccess:";
|
||||
String TL_HK_SYNC_ID = "tl_hk_sync_id";
|
||||
String TL_IS_NOMAL_INTERFACE = "isNormalInterface";
|
||||
/**
|
||||
* 忽略数据权限
|
||||
*/
|
||||
String IGNORE_DATA_SCOPE = "ignoreDataScope";
|
||||
/**
|
||||
* 忽略数据权限查询条件
|
||||
*/
|
||||
String IGNORE_DATA_SCOPE_CONDITION = " and 'ignoreDataScope' = 'ignoreDataScope' ";
|
||||
|
||||
String DOT = ".";
|
||||
/**
|
||||
* 人员安全评分最高
|
||||
|
||||
@ -27,7 +27,6 @@ public interface CarInfoMapper extends BaseMapper<CarInfo> {
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@DataScope(includeTable = "car_info")
|
||||
Page<CarInfo> selectCarList(Page<CarInfo> page, @Param("param") Map<String, Object> map);
|
||||
|
||||
/**
|
||||
|
||||
@ -118,13 +118,18 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
validTime(c);
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, c.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, c.getCarNumber());
|
||||
.eq(CarInfo::getCarNumber, c.getCarNumber())
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION)
|
||||
;
|
||||
CarInfo old = carInfoMapper.selectOne(queryWrapper);
|
||||
c.setSendSuccessStatus(4);
|
||||
if (old != null) {
|
||||
if (Objects.equals(old.getCarModuleType(), CarInfoCarModuleTypeEnum.GD.getValue())) {
|
||||
throw new OpenAlertException("该车辆已存在,请勿重复添加!");
|
||||
}
|
||||
if (!Objects.equals(old.getEnterpriseId(), c.getEnterpriseId())) {
|
||||
throw new OpenAlertException("已存在企业不一致的车辆!");
|
||||
}
|
||||
Date now = new Date();
|
||||
boolean isHk = projectCarCameraConfigService.isHikvisionConfig(c.getProjectSn());
|
||||
if (!isHk) {
|
||||
@ -222,7 +227,8 @@ public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> impl
|
||||
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CarInfo::getProjectSn, carInfo.getProjectSn())
|
||||
.eq(CarInfo::getCarNumber, carInfo.getCarNumber())
|
||||
.ne(CarInfo::getId, carInfo.getId());
|
||||
.ne(CarInfo::getId, carInfo.getId())
|
||||
.last(Cts.IGNORE_DATA_SCOPE_CONDITION);
|
||||
int count = carInfoMapper.selectCount(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new OpenAlertException(MessageUtil.get("carNumberExistErr"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user