4e7106d0 张雷

机构人员关系及相关接口修改

1 个父辈 44b90970
......@@ -53,4 +53,8 @@ public interface CommonSqlMapper {
* @return
*/
String getChildDepartId(@Param(value="departId") String departId);
String getChildFactorys(@Param(value="departId") String departId);
String getChildDepartByUserId(@Param(value="userId") String userId);
}
......
......@@ -50,7 +50,6 @@
delete from ${tableName} ${ew.customSqlSegment}
</delete>
<!-- 获取子部门集合-->
<select id="getChildDepartId" resultType="java.lang.String">
SELECT
......@@ -73,4 +72,31 @@
)
</select>
<select id="getChildFactorys" resultType="java.lang.String">
SELECT
GROUP_CONCAT( id SEPARATOR ',' ) AS depart_ids
FROM
sys_depart
WHERE
depart_type = '1'
AND (
parent_id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR parent_id IN ( SELECT id FROM sys_depart WHERE parent_id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
))
</select>
<select id="getChildDepartByUserId" resultType="java.lang.String">
select CONCAT(dep_id,',',dep_ids) AS ids
from sys_user_depart
where user_id = #{userId}
</select>
</mapper>
......
......@@ -46,4 +46,5 @@ public interface ICommonSqlService {
*/
String getChildDepartId( String departId);
String getChildFactorys(String departId);
}
......
......@@ -91,4 +91,9 @@ public class CommonSqlServiceImpl implements ICommonSqlService {
return commonSqlMapper.getChildDepartId(departId);
}
@Override
public String getChildFactorys(String departId) {
return commonSqlMapper.getChildFactorys(departId);
}
}
......
......@@ -83,15 +83,12 @@ public class ScreenDataController {
* 获取累计流量
*
* @param departId
* @param req
* @return
*/
@AutoLog(value = "污水处理情况")
@ApiOperation(value = "污水处理情况", notes = "污水处理情况")
@GetMapping(value = "/getWsclqk")
public Result<Map<String, Object>> getWsclqk(String departId,
HttpServletRequest req) {
public Result<Map<String, Object>> getWsclqk(String departId) {
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
Map<String, Object> resultMap = new HashMap<String, Object>();
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
......
......@@ -331,7 +331,8 @@ public class LoginController {
// 获取用户部门信息
JSONObject obj = new JSONObject();
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
// List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
List<SysDepart> departs = sysDepartService.queryUserDepartList(sysUser.getId());
obj.put("departs", departs);
// 获取用户角色信息
List<SysRole> roles = sysRoleService.queryUserRoles(sysUser.getId());
......
......@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.skua.modules.common.service.ICommonSqlService;
import com.skua.modules.system.service.ISysAreaService;
import com.skua.modules.system.service.ISysDictService;
import com.skua.modules.system.vo.SysFactoryInfo.*;
......@@ -68,7 +69,7 @@ public class SysFactoryInfoController {
@Autowired
private IWaterQualityInLevelService waterQualityInLevelService;
@Autowired
private ISequenceService sequenceService;
private ICommonSqlService iCommonSqlService;
@Autowired
private ISysAreaService sysAreaService;
@Autowired
......@@ -480,6 +481,13 @@ public class SysFactoryInfoController {
@GetMapping(value = "/queryByDepartId")
public Result queryByDepartId(@RequestParam(name = "departId", required = true) String departId) {
Result result = new Result();
String departs = iCommonSqlService.getChildFactorys(departId);
if(StringUtils.isNotEmpty(departs)){
String[] departArray = departs.split(",");
if(departArray.length>1){
departId = departs.split(",")[0];
}
}
SysFactoryInfoVO sysFactoryInfo = sysFactoryInfoService.getByDepartId(departId);
JSONObject jsonObject = sysDictService.translateTDictValue(sysFactoryInfo);
if (sysFactoryInfo == null) {
......
......@@ -201,7 +201,7 @@ public class SysUserController {
String departs = jsonObject.getString("selecteddeparts");
String manageDeparts = jsonObject.getString("selectedmanagedeparts");
sysUserService.editUserWithRole(user, roles);
sysUserService.editUserWithDepart(user, departs,manageDeparts);
sysUserService.editUserWithDepart(user, departs, manageDeparts);
result.success("修改成功!");
}
} catch (Exception e) {
......
......@@ -158,4 +158,8 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
@Anonymous
SysDepart getById(@Param("pid") String pid);
List<SysDepart> getChildDepartList(@Param("departIds") String departIds);
List<SysDepart> queryDepartsByIds(@Param("ids") String ids);
}
......
......@@ -332,4 +332,36 @@
depart_type,
depart_order
</select>
<select id="getChildDepartList" resultType="com.skua.modules.system.entity.SysDepart">
SELECT
*
FROM
sys_depart
WHERE
parent_id IN
<foreach item="item" index="index" collection="departIds.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR id IN
<foreach item="item" index="index" collection="departIds.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR parent_id IN ( SELECT id FROM sys_depart WHERE parent_id IN
<foreach item="item" index="index" collection="departIds.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
)
</select>
<select id="queryDepartsByIds" resultType="com.skua.modules.system.entity.SysDepart">
SELECT
*
FROM
sys_depart
WHERE
id IN
<foreach item="item" index="index" collection="ids.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
</select>
</mapper>
......
......@@ -180,4 +180,6 @@ public interface ISysDepartService extends IService<SysDepart>{
String getChildDepartId(String departIds);
List<SysDeptUserVO> queryDeptAndUserTreeList(String departId,String userType);
List<SysDepart> queryUserDepartList(String userId);
}
......
......@@ -10,9 +10,12 @@ import com.skua.core.service.ISequenceService;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.JwtUtil;
import com.skua.core.util.YouBianCodeUtil;
import com.skua.modules.common.mapper.CommonSqlMapper;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.entity.SysUserDepart;
import com.skua.modules.system.mapper.SysDepartMapper;
import com.skua.modules.system.mapper.SysUserDepartMapper;
import com.skua.modules.system.mapper.SysUserMapper;
import com.skua.modules.system.model.DepartIdModel;
import com.skua.modules.system.model.SysDepartTreeModel;
......@@ -28,6 +31,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
/**
......@@ -41,6 +45,10 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
private ISequenceService sequenceService;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private SysUserDepartMapper sysUserDepartMapper;
@Resource
private CommonSqlMapper commonSqlMapper;
/***
* 查询子集所有的部门
......@@ -83,7 +91,14 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
sysDepartQueryWrapper.orderByAsc("depart_order");
list = list(sysDepartQueryWrapper);
// 调用wrapTreeDataToTreeList方法生成树状数据
List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list,orgCode);
List<SysDepartTreeModel> listResult = new ArrayList<>();
String[] orgCodeArr = orgCode.split(",");
for (String jtCode : orgCodeArr) {
List<SysDepartTreeModel> jtList = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list,jtCode);
if(jtList.size() > 0){
listResult.addAll(jtList);
}
}
if (!StringUtils.isBlank(departType)) {
listResult = filterDepartList(listResult);
}
......@@ -121,10 +136,14 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
public String getJTCodeByUserId(String userId) {
String jtCode = "";
List<SysDepart> list = new ArrayList<>();
list = sysDepartMapper.queryUserDeparts(userId);
String ids = commonSqlMapper.getChildDepartByUserId(userId);
list = sysDepartMapper.queryDepartsByIds(ids);
// list = sysDepartMapper.queryUserDeparts(userId);
if(list.size() > 0){
//jtCode = list.get(0).getOrgCode().substring(0,3);
jtCode = list.get(0).getOrgCode();
// jtCode = list.get(0).getOrgCode();
for (SysDepart sysDepart : list) {
jtCode = sysDepart.getOrgCode() + "," + jtCode;
}
}else{
jtCode = "";
}
......@@ -141,7 +160,15 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
query.orderByAsc(SysDepart::getDepartOrder);
List<SysDepart> list = this.list(query);
// 调用wrapTreeDataToTreeList方法生成树状数据
List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,jtCode);
// List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,jtCode);
List<DepartIdModel> listResult = new ArrayList<>();
String[] orgCodeArr = jtCode.split(",");
for (String orgCode : orgCodeArr) {
List<DepartIdModel> jtList = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,orgCode);
if(jtList.size() > 0){
listResult.addAll(jtList);
}
}
return listResult;
}
......@@ -365,11 +392,18 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
if(BaseContextHandler.getUserId().equals("superadmin")){
list = sysDepartMapper.getSuperDepartTree();
}else{
//String jtCode = getJTCodeByUserId(BaseContextHandler.getUserCode());
list = sysDepartMapper.getDepartTree(jtCode);
}
// 调用wrapTreeDataToTreeList方法生成树状数据
List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,jtCode);
// List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,jtCode);
List<DepartIdModel> listResult = new ArrayList<>();
String[] orgCodeArr = jtCode.split(",");
for (String orgCode : orgCodeArr) {
List<DepartIdModel> jtList = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list,orgCode);
if(jtList.size() > 0){
listResult.addAll(jtList);
}
}
return listResult;
}
......@@ -454,12 +488,21 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
@Override
public Map<String,String> getAllDepartByUserId(String userId) {
Map<String,String> map = new HashMap<String,String>();
String departs = "";
//获取用户所属部门
Map<String,Object> sysDepartsMap = sysDepartMapper.queryUserDepartsMap(userId);
//获取用户部门情况
map.put("orgCode", ConvertUtils.getString(sysDepartsMap.get("orgCode")));
map.put("realDepartId", ConvertUtils.getString(sysDepartsMap.get("depId")));//去重
map.put("departIds", ConvertUtils.getString(sysDepartsMap.get("depIds")));//去重
List<SysDepart> departList = queryUserDepartList(userId);
if(departList.size() > 0){
for (SysDepart sysDepart : departList) {
departs = sysDepart.getId() + "," + departs;
}
}else{
departs = ConvertUtils.getString(sysDepartsMap.get("depIds"));
}
map.put("departIds", departs);//去重
return map;
}
......@@ -511,4 +554,22 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
return list;
}
@Override
public List<SysDepart> queryUserDepartList(String userId) {
List<SysDepart> departList = new ArrayList<>();
String departs = "";
List<SysUserDepart> list = sysUserDepartMapper.getUserDepartByUid(userId);
if(list.size() > 0){
SysUserDepart userDepart = list.get(0);
if(ConvertUtils.isNotEmpty(userDepart.getDepId())){
departs = userDepart.getDepId() + "," + departs;
}
if(ConvertUtils.isNotEmpty(userDepart.getDepIds())){
departs = userDepart.getDepIds() + "," + departs;
}
departList = sysDepartMapper.getChildDepartList(departs);
}
return departList;
}
}
......
......@@ -18,6 +18,7 @@ import com.skua.modules.alarmtmp.service.AlarmParamStandardConfigService;
import com.skua.modules.alarmtmp.service.AlarmRuleConfigService;
import com.skua.modules.alarmtmp.service.AlarmRuleLevelConfigService;
import com.skua.modules.alarmtmp.service.IAlarmRuleLevelConfigTemplateService;
import com.skua.modules.common.mapper.CommonSqlMapper;
import com.skua.modules.system.datestandard.entity.SysMonitorMetricInfo;
import com.skua.modules.system.datestandard.service.ISysMonitorMetricInfoService;
import com.skua.modules.system.entity.SysDepart;
......@@ -39,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
......@@ -48,10 +50,12 @@ import java.util.stream.Collectors;
@Service
public class SysFactoryInfoServiceImpl extends ServiceImpl<SysFactoryInfoMapper, SysFactoryInfo> implements ISysFactoryInfoService {
@Autowired
@Resource
private SysFactoryInfoMapper sysFactoryInfoMapper;
@Autowired
@Resource
private SysUserMapper sysUserMapper;
@Resource
private CommonSqlMapper commonSqlMapper;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
......@@ -69,8 +73,14 @@ public class SysFactoryInfoServiceImpl extends ServiceImpl<SysFactoryInfoMapper,
@Override
public SysFactoryInfoVO getByDepartId(String departId) {
SysFactoryInfoVO sysFactoryInfo = new SysFactoryInfoVO();
String departs = commonSqlMapper.getChildFactorys(departId);
if(StringUtils.isNotEmpty(departs)){
String[] departArray = departs.split(",");
if(departArray.length>1){
departId = departs.split(",")[0];
}
}
//获取厂站基本信息
sysFactoryInfo = sysFactoryInfoMapper.getByDepartId(departId);
SysDepart sysDepart = sysDepartService.getById(departId);
if (sysDepart != null && "-1".equals(sysDepart.getDepartType())) {
......
......@@ -209,13 +209,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Transactional
public void addUserWithDepart(SysUser user, String selectedParts, String selectedManageDeparts) {
// this.save(user); //保存角色的时候已经添加过一次了
if (ConvertUtils.isNotEmpty(selectedParts)) {
String[] arr = selectedParts.split(",");
for (String deaprtId : arr) {
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId, selectedManageDeparts);
sysUserDepartMapper.insert(userDeaprt);
}
}
// if (ConvertUtils.isNotEmpty(selectedParts)) {
// String[] arr = selectedParts.split(",");
// for (String deaprtId : arr) {
// SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId, selectedManageDeparts);
// sysUserDepartMapper.insert(userDeaprt);
// }
// }
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), selectedParts, selectedManageDeparts);
sysUserDepartMapper.insert(userDeaprt);
}
@Override
......@@ -224,13 +226,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次
//先删后加
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
if (ConvertUtils.isNotEmpty(departs)) {
String[] arr = departs.split(",");
for (String departId : arr) {
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId, selectedManageDeparts);
sysUserDepartMapper.insert(userDepart);
}
}
// if (ConvertUtils.isNotEmpty(departs)) {
// String[] arr = departs.split(",");
// for (String departId : arr) {
// SysUserDepart userDepart = new SysUserDepart(user.getId(), departId, selectedManageDeparts);
// sysUserDepartMapper.insert(userDepart);
// }
// }
SysUserDepart userDepart = new SysUserDepart(user.getId(), departs, selectedManageDeparts);
sysUserDepartMapper.insert(userDepart);
}
/**
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!