包头bug修改
This commit is contained in:
parent
6b8de9bbfa
commit
01a2a16d26
@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler;
|
||||
import com.zhgd.annotation.DataScope;
|
||||
import com.zhgd.jeecg.common.util.SpringContextUtils;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.UserDevice;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.UserDevGroup;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IUserDevGroupService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IUserDeviceService;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
@ -63,6 +63,8 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
public static final String DEV_FIELD = "devField";
|
||||
public static final String DEV_MAPPER = "dev_mapper";
|
||||
public static final String ALIAS_NAME = "aliasName";
|
||||
public static final String DEVICE_FIELD = "devField";
|
||||
public static final String PROJECT_FIELD = "projectField";
|
||||
@Lazy
|
||||
@Autowired
|
||||
EnvironmentUtil environmentUtil;
|
||||
@ -209,6 +211,17 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
return tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* 装置和项目组
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private HashMap<String, Map<String, Object>> getFieldDevProjectTables() {
|
||||
HashMap<String, Map<String, Object>> tables = new HashMap<>(16);
|
||||
tables.put("danger_environment_evaluate", new MapBuilder<String, Object>().put(DEVICE_FIELD, "device_id").put(PROJECT_FIELD, "project_group_id").build());
|
||||
return tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目组
|
||||
*
|
||||
@ -365,21 +378,57 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
// }
|
||||
// }
|
||||
|
||||
//项目组权限
|
||||
List<String> groupNames = getNeedFilterLeftExpression(plainSelect, this.getFieldGroupsTables(), ds);
|
||||
if (CollUtil.isNotEmpty(groupNames)) {
|
||||
List<String> groupIds = userDevGroupService.getGroupIds();
|
||||
for (String item : groupNames) {
|
||||
inExpression(item, groupIds, plainSelect);
|
||||
}
|
||||
}
|
||||
// //项目组权限
|
||||
// List<String> groupNames = getNeedFilterLeftExpression(plainSelect, this.getFieldGroupsTables(), ds);
|
||||
// if (CollUtil.isNotEmpty(groupNames)) {
|
||||
// List<String> groupIds = userDevGroupService.getGroupIds();
|
||||
// for (String item : groupNames) {
|
||||
// inExpression(item, groupIds, plainSelect);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //装置权限
|
||||
// List<String> unitNames = getNeedFilterLeftExpression(plainSelect, this.getFieldDevUnitTables(), ds);
|
||||
// if (CollUtil.isNotEmpty(unitNames)) {
|
||||
// List<String> unitIds = userDevGroupService.getUnitIds();
|
||||
// for (String item : unitNames) {
|
||||
// inExpression(item, unitIds, plainSelect);
|
||||
// }
|
||||
// }
|
||||
|
||||
//装置权限
|
||||
List<String> unitNames = getNeedFilterLeftExpression(plainSelect, this.getFieldDevUnitTables(), ds);
|
||||
if (CollUtil.isNotEmpty(unitNames)) {
|
||||
List<String> unitIds = userDevGroupService.getUnitIds();
|
||||
for (String item : unitNames) {
|
||||
inExpression(item, unitIds, plainSelect);
|
||||
//装置、项目组权限
|
||||
List<Map<String, Object>> devMap = getNeedFilterLeftExpression(plainSelect, ds, this.getFieldDevProjectTables(), true);
|
||||
if (CollUtil.isNotEmpty(devMap)) {
|
||||
for (Map<String, Object> item : devMap) {
|
||||
String projectField = MapUtils.getString(item, PROJECT_FIELD);
|
||||
String deviceField = MapUtils.getString(item, DEVICE_FIELD);
|
||||
String aliasName = MapUtils.getString(item, ALIAS_NAME);
|
||||
List<UserDevGroup> list1 = userDevGroupService.list(new LambdaQueryWrapper<UserDevGroup>()
|
||||
.eq(UserDevGroup::getUserId, SecurityUtils.getUser().getUserId()));
|
||||
List<UserDevGroup> devs = list1.stream().filter(o -> Objects.equals(o.getType(), 1)).collect(Collectors.toList());
|
||||
String sql;
|
||||
List<String> s = new ArrayList<>();
|
||||
for (UserDevGroup dev : devs) {
|
||||
List<UserDevGroup> groupList = list1.stream().filter(o -> o.getNodeId().contains(dev.getDevGroupId().toString()) && Objects.equals(o.getType(), 2)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(groupList)) {
|
||||
for (UserDevGroup group : groupList) {
|
||||
String s1 = StrUtil.format("({}.{}={} and {}.{}={})", aliasName, deviceField, dev.getDevGroupId(), aliasName, projectField, group.getDevGroupId());
|
||||
s.add(s1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isEmpty(s)) {
|
||||
sql = StrUtil.format(" ({}.{}=-1 and {}.{}=-1) ", aliasName, deviceField, aliasName, projectField);
|
||||
} else {
|
||||
sql = "(" + StrUtil.join(" OR ", s) + ")";
|
||||
}
|
||||
Expression expression = null;
|
||||
try {
|
||||
expression = CCJSqlParserUtil.parseCondExpression(sql);
|
||||
expressions.add(expression);
|
||||
} catch (JSQLParserException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,11 +611,15 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
return getNeedFilterLeftExpression(plainSelect, tables, ds, false);
|
||||
}
|
||||
|
||||
private List<Map<String ,Object>> getNeedFilterLeftExpression(PlainSelect plainSelect, DataScope ds, Map<String, Map<String, Object>> param) {
|
||||
ArrayList<Map<String ,Object>> rtList = new ArrayList<>();
|
||||
private List<Map<String, Object>> getNeedFilterLeftExpression(PlainSelect plainSelect, DataScope ds, Map<String, Map<String, Object>> param) {
|
||||
return getNeedFilterLeftExpression(plainSelect, ds, param, false);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getNeedFilterLeftExpression(PlainSelect plainSelect, DataScope ds, Map<String, Map<String, Object>> param, boolean onlyAlas) {
|
||||
ArrayList<Map<String, Object>> rtList = new ArrayList<>();
|
||||
String[] dsArr = ds.includeTable();
|
||||
if (dsArr.length > 0) {
|
||||
Map<String, Map<String ,Object>> nt = new HashMap<>(16);
|
||||
Map<String, Map<String, Object>> nt = new HashMap<>(16);
|
||||
for (String ds1 : dsArr) {
|
||||
if (param.containsKey(ds1)) {
|
||||
nt.put(ds1, param.get(ds1));
|
||||
@ -585,7 +638,12 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
aliasName = alias.getName();
|
||||
}
|
||||
Map<String, Object> map = param.get(name);
|
||||
String e = (StringUtils.isEmpty(aliasName) ? name : aliasName) + "." + map.get(DATA_FIELD).toString();
|
||||
String e;
|
||||
if (onlyAlas) {
|
||||
e = (StringUtils.isEmpty(aliasName) ? name : aliasName);
|
||||
} else {
|
||||
e = (StringUtils.isEmpty(aliasName) ? name : aliasName) + "." + map.get(DATA_FIELD).toString();
|
||||
}
|
||||
map.put(ALIAS_NAME, e);
|
||||
rtList.add(map);
|
||||
}
|
||||
@ -606,7 +664,12 @@ public class DataScopeHandler implements DataPermissionHandler {
|
||||
aliasName = alias.getName();
|
||||
}
|
||||
Map<String, Object> map = param.get(aliasName);
|
||||
String e = (StringUtils.isEmpty(aliasName) ? joinTable.getName() : aliasName) + "." + param.get(aliasName).get(DATA_FIELD).toString();
|
||||
String e;
|
||||
if (onlyAlas) {
|
||||
e = (StringUtils.isEmpty(aliasName) ? joinTable.getName() : aliasName);
|
||||
} else {
|
||||
e = (StringUtils.isEmpty(aliasName) ? joinTable.getName() : aliasName) + "." + param.get(aliasName).get(DATA_FIELD).toString();
|
||||
}
|
||||
map.put(ALIAS_NAME, e);
|
||||
rtList.add(map);
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ public class DeviceUnitController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "seeI", value = "1项目子账号只看到自己的数据", paramType = "query", required = false, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<DeviceUnit>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
|
||||
@ -179,9 +179,9 @@ public class PipelineWeldingRecordController {
|
||||
return Result.success(pipelineWeldingRecordService.queryById(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出excel记录", notes = "导出excel记录", httpMethod = "POST")
|
||||
@ApiOperation(value = "导出excel记录", notes = "导出excel记录", httpMethod = "GET")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public void exportXls(HttpServletRequest request, HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
|
||||
public void exportXls(HttpServletRequest request, HttpServletResponse response, @RequestParam HashMap<String, Object> param) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
try {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.baotou.mapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -22,7 +23,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@DataScope
|
||||
public interface DeviceUnitMapper extends BaseMapper<DeviceUnit> {
|
||||
|
||||
List<DeviceUnit> queryList(@Param(Constants.WRAPPER)QueryWrapper<DeviceUnit> queryWrapper);
|
||||
List<DeviceUnit> queryList(@Param(Constants.WRAPPER) QueryWrapper<DeviceUnit> queryWrapper,@Param("param") HashMap<String, Object> param);
|
||||
|
||||
IPage<DeviceUnit> queryList(Page<DeviceUnit> page,@Param(Constants.WRAPPER) QueryWrapper<DeviceUnit> queryWrapper);
|
||||
IPage<DeviceUnit> queryList(Page<DeviceUnit> page, @Param(Constants.WRAPPER) QueryWrapper<DeviceUnit> queryWrapper,@Param("param") HashMap<String, Object> param);
|
||||
}
|
||||
|
||||
@ -3,12 +3,27 @@
|
||||
<mapper namespace="com.zhgd.xmgl.modules.baotou.mapper.DeviceUnitMapper">
|
||||
|
||||
<select id="queryList" resultType="com.zhgd.xmgl.modules.baotou.entity.DeviceUnit">
|
||||
select t.*,
|
||||
select * from (select
|
||||
group_concat(distinct pg.project_group_name) as project_group_name,
|
||||
group_concat(distinct ei.enterprise_name) as epc_contractor_name,
|
||||
group_concat(distinct ei3.enterprise_name) as construction_unit_name,
|
||||
group_concat(distinct pgu.supervising_unit_id) as supervising_unit_ids,
|
||||
group_concat(distinct ei4.enterprise_name) as supervising_unit_name
|
||||
<if test="param.accountType == '6'.toString() ">
|
||||
, group_concat(distinct pg.id) as project_group_ids
|
||||
</if>
|
||||
<if test="param.accountType != '6'.toString() ">
|
||||
, t.project_group_ids
|
||||
</if>
|
||||
,t.device_unit_name
|
||||
,t.device_unit_no
|
||||
,t.construction_unit_ids
|
||||
,t.project_sn
|
||||
,t.create_date
|
||||
,t.update_date
|
||||
,t.epc_contractor_ids
|
||||
,t.sort
|
||||
,t.id
|
||||
from
|
||||
device_unit t
|
||||
join project_group pg on find_in_set(pg.id,t.project_group_ids)
|
||||
@ -16,8 +31,18 @@
|
||||
left join enterprise_info ei on find_in_set(ei.id,t.epc_contractor_ids)
|
||||
left join enterprise_info ei3 on find_in_set(ei3.id,t.construction_unit_ids)
|
||||
left join enterprise_info ei4 on find_in_set(ei4.id,pgu.supervising_unit_id)
|
||||
${ew.customSqlSegment}
|
||||
where 1=1
|
||||
<if test="param.projectSn != null and param.projectSn != ''">
|
||||
and t.project_sn = #{param.projectSn}
|
||||
</if>
|
||||
<if test="param.seeI == '1'.toString() and param.accountType == '6'.toString() ">
|
||||
and
|
||||
<foreach item="item" index="index" collection="param.myDevGroups" open="(" separator="or" close=")">
|
||||
( t.id=#{item.devId} and pgu.project_group_id=#{item.groupId} )
|
||||
</foreach>
|
||||
</if>
|
||||
group by t.id
|
||||
order by t.sort
|
||||
</select>
|
||||
order by t.sort)t
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -1,36 +1,47 @@
|
||||
package com.zhgd.xmgl.modules.baotou.service.impl;
|
||||
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.DeviceUnit;
|
||||
import com.zhgd.xmgl.modules.baotou.mapper.DeviceUnitMapper;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IDeviceUnitService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.DeviceUnit;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.UserDevGroup;
|
||||
import com.zhgd.xmgl.modules.baotou.mapper.DeviceUnitMapper;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IDeviceUnitService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IUserDevGroupService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 装置管理
|
||||
* @author: pds
|
||||
* @date: 2024-08-06
|
||||
* @date: 2024-08-06
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DeviceUnitServiceImpl extends ServiceImpl<DeviceUnitMapper, DeviceUnit> implements IDeviceUnitService {
|
||||
@Autowired
|
||||
private DeviceUnitMapper deviceUnitMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IUserDevGroupService userDevGroupService;
|
||||
|
||||
@Override
|
||||
public IPage<DeviceUnit> queryPageList(HashMap<String, Object> param) {
|
||||
QueryWrapper<DeviceUnit> queryWrapper = this.getQueryWrapper(param);
|
||||
Page<DeviceUnit> page = PageUtil.getPage(param);
|
||||
IPage<DeviceUnit> pageList = baseMapper.queryList(page, queryWrapper);
|
||||
IPage<DeviceUnit> pageList = baseMapper.queryList(page, queryWrapper, param);
|
||||
pageList.setRecords(this.dealList(pageList.getRecords()));
|
||||
return pageList;
|
||||
}
|
||||
@ -38,16 +49,46 @@ public class DeviceUnitServiceImpl extends ServiceImpl<DeviceUnitMapper, DeviceU
|
||||
@Override
|
||||
public List<DeviceUnit> queryList(HashMap<String, Object> param) {
|
||||
QueryWrapper<DeviceUnit> queryWrapper = getQueryWrapper(param);
|
||||
return dealList(baseMapper.queryList(queryWrapper));
|
||||
return dealList(baseMapper.queryList(queryWrapper, param));
|
||||
}
|
||||
|
||||
private QueryWrapper<DeviceUnit> getQueryWrapper(HashMap<String, Object> param) {
|
||||
String alias = "t.";
|
||||
QueryWrapper<DeviceUnit> queryWrapper = QueryGenerator.initPageQueryWrapper(DeviceUnit.class, param, alias, false);
|
||||
QueryWrapper<DeviceUnit> queryWrapper = QueryGenerator.initPageQueryWrapper(DeviceUnit.class, param, true);
|
||||
//查自己的
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
if (user != null) {
|
||||
param.put("accountType", user.getAccountType());
|
||||
param.put("userId", user.getUserId());
|
||||
if (Objects.equals(user.getAccountType(), 6)) {
|
||||
List<UserDevGroup> list1 = userDevGroupService.list(new LambdaQueryWrapper<UserDevGroup>()
|
||||
.eq(UserDevGroup::getUserId, SecurityUtils.getUser().getUserId()));
|
||||
List<UserDevGroup> devs = list1.stream().filter(o -> Objects.equals(o.getType(), 1)).collect(Collectors.toList());
|
||||
List<Map<String, String>> s = new ArrayList<>();
|
||||
for (UserDevGroup dev : devs) {
|
||||
List<UserDevGroup> groupList = list1.stream().filter(o -> o.getNodeId().contains(dev.getDevGroupId().toString()) && Objects.equals(o.getType(), 2)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(groupList)) {
|
||||
for (UserDevGroup group : groupList) {
|
||||
HashMap<String, String> m = new HashMap<>();
|
||||
m.put("devId", dev.getDevGroupId().toString());
|
||||
m.put("groupId", group.getDevGroupId().toString());
|
||||
s.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isEmpty(s)) {
|
||||
HashMap<String, String> m = new HashMap<>();
|
||||
m.put("devId", "-1");
|
||||
m.put("groupId", "-1");
|
||||
s.add(m);
|
||||
}
|
||||
param.put("myDevGroups", s);
|
||||
}
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private List<DeviceUnit> dealList(List<DeviceUnit> list) {
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -60,7 +101,7 @@ public class DeviceUnitServiceImpl extends ServiceImpl<DeviceUnitMapper, DeviceU
|
||||
@Override
|
||||
public void edit(DeviceUnit deviceUnit) {
|
||||
DeviceUnit oldDeviceUnit = baseMapper.selectById(deviceUnit.getId());
|
||||
if(oldDeviceUnit==null) {
|
||||
if (oldDeviceUnit == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
baseMapper.updateById(deviceUnit);
|
||||
@ -69,7 +110,7 @@ public class DeviceUnitServiceImpl extends ServiceImpl<DeviceUnitMapper, DeviceU
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
DeviceUnit deviceUnit = baseMapper.selectById(id);
|
||||
if(deviceUnit==null) {
|
||||
if (deviceUnit == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
baseMapper.deleteById(id);
|
||||
|
||||
@ -80,6 +80,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/xmgl/pipelineWeldingRecord/exportXls").permitAll()
|
||||
.antMatchers("/xmgl/hat/httpAlarmServer").permitAll()
|
||||
.antMatchers("/xmgl/qualitySupervise/flow/**").permitAll()
|
||||
.antMatchers("/xmgl/civilizeConstruction/flow/**").permitAll()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user