|
@@ -2,7 +2,10 @@ package com.rongwei.trainingcommon.sys.utils;
|
|
|
|
|
|
import com.rongwei.commonservice.serial.service.SysSerialNumberService;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
|
|
|
+import com.rongwei.rwadmincommon.system.vo.SysOrganizationVo;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
+import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -13,6 +16,10 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.MINUS_ONE;
|
|
|
|
|
|
/**
|
|
|
* TrainingUtils class
|
|
@@ -47,6 +54,23 @@ public class TrainingUtils {
|
|
|
return currUser;
|
|
|
}
|
|
|
|
|
|
+ public static String getCurrentUserFactoryId(SysUserVo currentUser) {
|
|
|
+ if (currentUser == null) {
|
|
|
+ currentUser = getCurrentUser();
|
|
|
+ }
|
|
|
+ List<SysOrganizationVo> organizationDoList = currentUser.getOrganizationDoList();
|
|
|
+ String factoryId = organizationDoList.stream()
|
|
|
+ .filter(org -> MINUS_ONE.equals(org.getPid()))
|
|
|
+ .map(SysOrganizationDo::getId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ if (StringUtils.isBlank(factoryId)) {
|
|
|
+ factoryId = organizationDoList.stream().map(info -> info.getFullpid().split(",")[1]).distinct().collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ return factoryId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
redisService = autoRedisService;
|