|
|
|
@ -56,6 +56,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ProjectServiceImpl implements ProjectService { |
|
|
|
private static final String SALES_ROLE_NAME = "sales"; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TransNoControlService transNoControlService; |
|
|
|
@Autowired |
|
|
|
@ -111,6 +113,9 @@ public class ProjectServiceImpl implements ProjectService { |
|
|
|
// } |
|
|
|
// } |
|
|
|
// boolean shouldApplySuperFlagCondition = inData.getUserName() != null && !inData.getUserName().isEmpty() && !superFlag; |
|
|
|
String currentUserName = getCurrentUserName(inData.getUserName()); |
|
|
|
inData.setUserName(currentUserName); |
|
|
|
inData.setSalesRole(isSalesRoleUser(currentUserName)); |
|
|
|
IPage<PlmProjectInfoData> resultList = this.projectDao.projectInfoSearch( |
|
|
|
new Page<PlmProjectInfoData>(inData.getPage(), inData.getLimit()), inData, false); |
|
|
|
|
|
|
|
@ -612,6 +617,8 @@ public class ProjectServiceImpl implements ProjectService { |
|
|
|
String orderClause = conditionMap.get("order"); |
|
|
|
whereClause = (whereClause.isEmpty() ? "site = '" + data.getSite() + "'" : whereClause + " AND site = '" + data.getSite() + "'").trim(); |
|
|
|
orderClause = orderClause.trim(); |
|
|
|
String currentUserName = getCurrentUserName(data.getUserName()); |
|
|
|
boolean salesRoleUser = isSalesRoleUser(currentUserName); |
|
|
|
// List<String> list = sysRoleDao.getSuperFlag(data.getUserId()); |
|
|
|
// boolean superFlag = false; |
|
|
|
// if (list != null) { |
|
|
|
@ -626,7 +633,9 @@ public class ProjectServiceImpl implements ProjectService { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("whereClause", whereClause); |
|
|
|
params.put("orderClause", orderClause); |
|
|
|
params.put("userName", data.getUserName()); |
|
|
|
params.put("userName", currentUserName); |
|
|
|
params.put("currentUserName", currentUserName); |
|
|
|
params.put("salesRole", salesRoleUser); |
|
|
|
params.put("site", data.getSite()); |
|
|
|
params.put("flag", false); |
|
|
|
IPage<PlmProjectInfoData> resultList = this.projectDao.projectInfoSearchByAnyField(new Page<PlmProjectInfoData>(data.getNo(), data.getSize()), params); |
|
|
|
@ -646,4 +655,20 @@ public class ProjectServiceImpl implements ProjectService { |
|
|
|
IPage<PlmProjectPartData> resultList = this.projectDao.projectPartSearchByAnyField(new Page<PlmProjectPartData>(data.getNo(), data.getSize()), params); |
|
|
|
return new PageUtils(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
private String getCurrentUserName(String fallbackUserName) { |
|
|
|
SysUserEntity sysUserEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
if (sysUserEntity != null && StringUtils.hasText(sysUserEntity.getUsername())) { |
|
|
|
return sysUserEntity.getUsername(); |
|
|
|
} |
|
|
|
return fallbackUserName; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isSalesRoleUser(String userName) { |
|
|
|
if (!StringUtils.hasText(userName)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
List<Long> roleList = sysRoleDao.findRoleIdByUsernameAndRoleName(userName, SALES_ROLE_NAME); |
|
|
|
return roleList != null && !roleList.isEmpty(); |
|
|
|
} |
|
|
|
} |