功能优化
This commit is contained in:
parent
51250a0b3a
commit
3315b69a88
|
|
@ -161,9 +161,29 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
}
|
||||
}
|
||||
}
|
||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
if (deptId != null) {
|
||||
bean.setImpUnit(deptId.toString());
|
||||
String deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
||||
Set<String> targetUnits = new HashSet<>(Arrays.asList(
|
||||
"101", "102", "309", "327", "330", "333", "337", "338",
|
||||
"339", "340", "341", "342", "344", "345", "346", "347",
|
||||
"348", "349"
|
||||
));
|
||||
if (targetUnits.contains(deptId)) {
|
||||
bean.setImpUnit(deptId);
|
||||
} else {
|
||||
//判断祖籍是否包含分公司
|
||||
String ancestors = mapper.getAncestors(deptId);
|
||||
if (ancestors != null && !ancestors.isEmpty()) {
|
||||
// 将ancestors转换为集合
|
||||
String[] parts = ancestors.split(",");
|
||||
for (String part : parts) {
|
||||
String trimmedPart = part.trim();
|
||||
// Check if the trimmed part is in our target set
|
||||
if (targetUnits.contains(trimmedPart)) {
|
||||
bean.setImpUnit(trimmedPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 查询目前在用的设备信息
|
||||
|
|
@ -800,9 +820,29 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
}
|
||||
}
|
||||
}
|
||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
if (deptId != null) {
|
||||
bean.setImpUnit(deptId.toString());
|
||||
String deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
||||
Set<String> targetUnits = new HashSet<>(Arrays.asList(
|
||||
"101", "102", "309", "327", "330", "333", "337", "338",
|
||||
"339", "340", "341", "342", "344", "345", "346", "347",
|
||||
"348", "349"
|
||||
));
|
||||
if (targetUnits.contains(deptId)) {
|
||||
bean.setImpUnit(deptId);
|
||||
} else {
|
||||
//判断祖籍是否包含分公司
|
||||
String ancestors = mapper.getAncestors(deptId);
|
||||
if (ancestors != null && !ancestors.isEmpty()) {
|
||||
// 将ancestors转换为集合
|
||||
String[] parts = ancestors.split(",");
|
||||
for (String part : parts) {
|
||||
String trimmedPart = part.trim();
|
||||
// Check if the trimmed part is in our target set
|
||||
if (targetUnits.contains(trimmedPart)) {
|
||||
bean.setImpUnit(trimmedPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取项目部总数
|
||||
|
|
|
|||
|
|
@ -355,4 +355,11 @@ public interface SelectMapper {
|
|||
* @return
|
||||
*/
|
||||
List<MaterialBackPreApply> getProDepartmentByPro(MaterialBackPreApply bean);
|
||||
|
||||
/**
|
||||
* 查询祖级部门id
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
String getAncestors(String deptId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.material.common.service.impl;
|
|||
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.config.DateTimeHelper;
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.domain.*;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
|
|
@ -258,22 +259,40 @@ public class SelectServiceImpl implements SelectService {
|
|||
// 根据用户名判断用户是否为班组长
|
||||
BmTeam teamData = mapper.getTeamData(username);
|
||||
List<BmProject> list = new ArrayList<>();
|
||||
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
|
||||
// 检查用户是否具有特殊角色
|
||||
boolean hasSpecialRole = hasSpecialRole(userRoles);
|
||||
if (!hasSpecialRole) {
|
||||
String deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
|
||||
Set<String> targetUnits = new HashSet<>(Arrays.asList(
|
||||
"101", "102", "309", "327", "330", "333", "337", "338",
|
||||
"339", "340", "341", "342", "344", "345", "346", "347",
|
||||
"348", "349"
|
||||
));
|
||||
if (targetUnits.contains(deptId)) {
|
||||
bmProject.setImpUnit(deptId);
|
||||
} else {
|
||||
//判断祖籍是否包含分公司
|
||||
String ancestors = mapper.getAncestors(deptId);
|
||||
if (ancestors != null && !ancestors.isEmpty()) {
|
||||
// 将ancestors转换为集合
|
||||
String[] parts = ancestors.split(",");
|
||||
for (String part : parts) {
|
||||
String trimmedPart = part.trim();
|
||||
// Check if the trimmed part is in our target set
|
||||
if (targetUnits.contains(trimmedPart)) {
|
||||
bmProject.setImpUnit(trimmedPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bmProject.getIsApp() != null && bmProject.getIsApp()) {
|
||||
list = mapper.getProjectInfo(bmProject);
|
||||
if (!hasSpecialRole) {
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
if (teamData == null) {
|
||||
// 根据用户名查询项目部信息
|
||||
List<String> departId = mapper.getDepartId(username);
|
||||
// 根据项目部id查询工程信息
|
||||
if (CollectionUtils.isEmpty(departId)) {
|
||||
return AjaxResult.success(Collections.emptyList());
|
||||
}
|
||||
List<String> projectIdList = mapper.getProjectId(departId);
|
||||
if (CollectionUtils.isNotEmpty(projectIdList)) {
|
||||
// 找出list中projectId与projectIdList中相同的数据
|
||||
list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList());
|
||||
}
|
||||
} else {
|
||||
if (teamData != null) {
|
||||
// 根据班组用户查询工程信息
|
||||
List<String> teamList = mapper.getProjectIdByUseName(username);
|
||||
if (CollectionUtils.isEmpty(teamList)) {
|
||||
|
|
@ -284,11 +303,35 @@ public class SelectServiceImpl implements SelectService {
|
|||
list = list.stream().filter(info -> teamList.contains(info.getProjectId())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
// 根据用户名查询项目部信息
|
||||
List<String> departId = mapper.getDepartId(username);
|
||||
// 根据项目部id查询工程信息
|
||||
if (!CollectionUtils.isEmpty(departId)) {
|
||||
List<String> projectIdList = mapper.getProjectId(departId);
|
||||
if (CollectionUtils.isNotEmpty(projectIdList)) {
|
||||
// 找出list中projectId与projectIdList中相同的数据
|
||||
list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否具有特殊角色
|
||||
* @param userRoles
|
||||
* @return
|
||||
*/
|
||||
private boolean hasSpecialRole(Set<String> userRoles) {
|
||||
if (userRoles == null) {
|
||||
return false;
|
||||
}
|
||||
List<String> allowedRoles = GlobalConstants.allowedRoles;
|
||||
return allowedRoles.stream().anyMatch(userRoles::contains);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领用申请往来单位下拉选专用
|
||||
* @param bmUnit
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bp.imp_unit AS impUnit,
|
||||
bu.bzz_idcard AS idCard,
|
||||
bp.pro_center AS proCenter,
|
||||
sd.dept_name AS departName
|
||||
sd.dept_name AS departName,
|
||||
'站内库存' AS teamName
|
||||
FROM
|
||||
slt_agreement_info sai
|
||||
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||
|
|
@ -1320,6 +1321,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="typeModelName != null and typeModelName != ''">
|
||||
AND mt.type_name like concat('%',#{typeModelName},'%')
|
||||
</if>
|
||||
<if test="teamName != null and teamName != ''">
|
||||
AND '站内库存' like concat('%',#{teamName},'%')
|
||||
</if>
|
||||
<if test="projectIdList != null and projectIdList.size() > 0">
|
||||
and bp.external_id in
|
||||
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
||||
|
|
@ -1348,7 +1352,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bp.imp_unit AS impUnit,
|
||||
bu.bzz_idcard AS idCard,
|
||||
bp.pro_center AS proCenter,
|
||||
sd.dept_name AS departName
|
||||
sd.dept_name AS departName,
|
||||
'站内库存' AS teamName
|
||||
FROM
|
||||
clz_slt_agreement_info sai
|
||||
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||
|
|
@ -1376,6 +1381,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="typeName != null and typeName != ''">
|
||||
AND mt2.type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="teamName != null and teamName != ''">
|
||||
AND '站内库存' like concat('%',#{teamName},'%')
|
||||
</if>
|
||||
<if test="typeModelName != null and typeModelName != ''">
|
||||
AND mt.type_name like concat('%',#{typeModelName},'%')
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -475,11 +475,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT
|
||||
pro_id AS proId,
|
||||
pro_name AS proName,
|
||||
external_id AS projectId
|
||||
external_id AS projectId,
|
||||
imp_unit AS impUnit
|
||||
FROM
|
||||
bm_project
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
<if test="impUnit != null and impUnit != ''">
|
||||
and imp_unit = #{impUnit}
|
||||
</if>
|
||||
</select>
|
||||
<!-- <select id="getTeamList" resultType="com.bonus.material.common.domain.vo.SelectVo">-->
|
||||
<!-- /*根据工程id查询班组*/-->
|
||||
|
|
@ -1098,4 +1102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE bai.project_id = #{proId}
|
||||
and bu.type_id = '36'
|
||||
</select>
|
||||
|
||||
<select id="getAncestors" resultType="java.lang.String">
|
||||
select ancestors from sys_dept where dept_id = #{deptId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue