mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
feat(organization): 切换当前用户激活的机构
- 新增 Ctx.activeOrganizationId() 方法获取当前激活的机构 ID - 更新相关服务和控制器,使用新的激活机构 ID - 添加 OrganizationTreeDto 类用于组织树结构返回 - 实现 orgTree 方法获取组织树 - 新增 SwitchActiveOrgRequest 类用于切换激活机构请求 - 在 SessionService 中实现 switchActiveOrg 方法
This commit is contained in:
@@ -92,7 +92,7 @@ public class AcDeviceDataService extends BaseService<AcDeviceDataEntity, AcDevic
|
||||
request.setTimeDimension("day");
|
||||
}
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
String fields =
|
||||
CollectionUtils.isEmpty(request.getReportFields())
|
||||
|
||||
@@ -51,7 +51,7 @@ public class OrgScopeAop {
|
||||
|
||||
if (enabled) {
|
||||
|
||||
if (StringUtils.isEmpty(Ctx.currentUser().getOrganizationId())) {
|
||||
if (StringUtils.isEmpty(Ctx.activeOrganizationId())) {
|
||||
throw new BizException("当前用户未绑定机构, 无法进行机构数据过滤");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class OrgScopeAop {
|
||||
|
||||
Filter orgFilter = session.enableFilter("orgFilter");
|
||||
|
||||
orgFilter.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
orgFilter.setParameter("organizationId", Ctx.activeOrganizationId());
|
||||
} else {
|
||||
log.debug("当前session {} orgFilter已经启用, 忽略....", session);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class OrgBaseEntity extends BaseEntity {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
this.organizationId =
|
||||
Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
Ctx.isLoggedIn() ? Ctx.currentOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class OrgCommonEntity extends CommonEntity {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
this.organizationId =
|
||||
Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
Ctx.isLoggedIn() ? Ctx.currentOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class OrgCommonEntity extends CommonEntity {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
this.organizationId =
|
||||
Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
Ctx.isLoggedIn() ? Ctx.currentOrganizationId() : organizationId;
|
||||
}
|
||||
super.preUpdate();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class CoalAnalysisService extends BaseService<CoalAnalysisEntity, CoalAnalysisRe
|
||||
|
||||
List<CoalParameterDefEntity> parameters =
|
||||
coalParameterDefRepository.findByOrganizationId(
|
||||
Ctx.currentUser().getOrganizationId());
|
||||
Ctx.activeOrganizationId());
|
||||
|
||||
List<CoalParameterDefEntity> toCalculate =
|
||||
parameters.stream()
|
||||
|
||||
@@ -144,7 +144,7 @@ public class CoalParameterDefService
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
|
||||
List<CoalParameterDefEntity> allDef =
|
||||
this.repository.findByOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
this.repository.findByOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
Optional<CoalParameterDefEntity> type1 =
|
||||
allDef.stream()
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CoalWashingDailyAnalysisService
|
||||
public CoalWashingDailyAnalysisDto create(CreateCoalWashingDailyAnalysisDto request) {
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
validate(entity);
|
||||
|
||||
if (entity.getProduct() != null) {
|
||||
@@ -118,7 +118,7 @@ public class CoalWashingDailyAnalysisService
|
||||
}
|
||||
|
||||
this.mapper.updateEntity(entity, request);
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
validate(entity);
|
||||
if (entity.getProduct() != null) {
|
||||
@@ -146,7 +146,7 @@ public class CoalWashingDailyAnalysisService
|
||||
|
||||
entity.setKfItems(request.getKfItems());
|
||||
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
validate(entity);
|
||||
if (entity.getProduct() != null) {
|
||||
@@ -175,7 +175,7 @@ public class CoalWashingDailyAnalysisService
|
||||
|
||||
entity.setKfItems(kfItems);
|
||||
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
validate(entity);
|
||||
if (entity.getProduct() != null) {
|
||||
@@ -249,7 +249,7 @@ public class CoalWashingDailyAnalysisService
|
||||
|
||||
public Object report(CoalWashingDailyAnalysisCoalReportRequest request) {
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import cn.lihongjie.coal.loginUser.dto.LoginUserDto;
|
||||
import cn.lihongjie.coal.session.service.SessionService;
|
||||
import cn.lihongjie.coal.user.dto.UserDto;
|
||||
|
||||
@@ -7,6 +8,7 @@ import lombok.Getter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -72,4 +74,34 @@ public class Ctx {
|
||||
public static void setContext(ConfigurableApplicationContext context) {
|
||||
Ctx.context = context;
|
||||
}
|
||||
|
||||
public static String activeOrganizationId() {
|
||||
|
||||
|
||||
if (!isLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
LoginUserDto user = getAuthentication().getDto();
|
||||
|
||||
|
||||
return StringUtils.firstNonBlank(user.getActiveOrganizationId(), getAuthentication().getUser().getOrganizationId());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String currentOrganizationId() {
|
||||
|
||||
|
||||
if (!isLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return getAuthentication().getUser().getOrganizationId();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class JpaUtils {
|
||||
clazz,
|
||||
fieldName,
|
||||
value,
|
||||
Ctx.currentUser().getOrganizationId(),
|
||||
Ctx.activeOrganizationId(),
|
||||
null);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class JpaUtils {
|
||||
String fieldName,
|
||||
Object value,
|
||||
String selfId) {
|
||||
return hasDuplicate(entityManager, clazz, fieldName, value, Ctx.currentUser().getOrganizationId(), selfId);
|
||||
return hasDuplicate(entityManager, clazz, fieldName, value, Ctx.activeOrganizationId(), selfId);
|
||||
}
|
||||
|
||||
public static boolean hasDuplicate(
|
||||
|
||||
@@ -180,7 +180,7 @@ class DepartmentService extends BaseService<DepartmentEntity, DepartmentReposito
|
||||
public DepartmentDto findByName(String name) {
|
||||
|
||||
DepartmentEntity entity =
|
||||
repository.findByNameAndOrganizationId(name, Ctx.currentUser().getOrganizationId());
|
||||
repository.findByNameAndOrganizationId(name, Ctx.activeOrganizationId());
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DeviceService extends BaseService<DeviceEntity, DeviceRepository> {
|
||||
|
||||
switch (genRule) {
|
||||
case "0":
|
||||
String key = "device.global." + Ctx.currentUser().getOrganizationId();
|
||||
String key = "device.global." + Ctx.activeOrganizationId();
|
||||
|
||||
sequenceService.createSequence(key, 0);
|
||||
Long next = sequenceService.nextVal(key);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class EmpSalaryBatchService
|
||||
root.get("batchNo"), entity.getBatchNo()),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()));
|
||||
Ctx.activeOrganizationId()));
|
||||
}
|
||||
})
|
||||
> 0) {
|
||||
|
||||
@@ -49,17 +49,17 @@ public class EmpSalaryItemController {
|
||||
|
||||
@PostMapping("/genScript")
|
||||
public Object genScript() {
|
||||
return R.success(this.service.genScript(Ctx.currentUser().getOrganizationId()));
|
||||
return R.success(this.service.genScript(Ctx.activeOrganizationId()));
|
||||
}
|
||||
|
||||
@PostMapping("/genScriptWithCompileResult")
|
||||
public Object genScriptWithCompileResult(GenScriptRequest request) {
|
||||
return R.success(this.service.genScriptWithCompileResult(Ctx.currentUser().getOrganizationId(), request.isDebug()));
|
||||
return R.success(this.service.genScriptWithCompileResult(Ctx.activeOrganizationId(), request.isDebug()));
|
||||
}
|
||||
|
||||
@PostMapping("/init")
|
||||
public Object init() {
|
||||
this.service.initOrg(Ctx.currentUser().getOrganizationId());
|
||||
this.service.initOrg(Ctx.activeOrganizationId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +541,7 @@ public class EmpSalaryItemService
|
||||
criteriaBuilder.and(
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()),
|
||||
Ctx.activeOrganizationId()),
|
||||
criteriaBuilder.equal(
|
||||
root.get("name"), request.getName())))
|
||||
!= 0) {
|
||||
@@ -570,7 +570,7 @@ public class EmpSalaryItemService
|
||||
criteriaBuilder.and(
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()),
|
||||
Ctx.activeOrganizationId()),
|
||||
criteriaBuilder.equal(root.get("name"), newName),
|
||||
criteriaBuilder.notEqual(
|
||||
root.get("id"), request.getId())))
|
||||
|
||||
@@ -70,7 +70,7 @@ public class EmployeeController {
|
||||
}
|
||||
@PostMapping("/refreshAge")
|
||||
public Object refreshAge() {
|
||||
this.service.refreshAge(Ctx.currentUser().getOrganizationId());
|
||||
this.service.refreshAge(Ctx.activeOrganizationId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class FileService extends BaseService<FileEntity, FileRepository> {
|
||||
"%s/%s/%s"
|
||||
.formatted(
|
||||
activateProfile,
|
||||
Ctx.currentUser().getOrganizationId(),
|
||||
Ctx.activeOrganizationId(),
|
||||
StringUtils.defaultIfBlank(dir, "public")));
|
||||
InputStream inputStream = fis;
|
||||
String extension = FilenameUtils.getExtension(name.replace(":", "_"));
|
||||
@@ -269,7 +269,7 @@ public class FileService extends BaseService<FileEntity, FileRepository> {
|
||||
"%s/%s/%s"
|
||||
.formatted(
|
||||
activateProfile,
|
||||
Ctx.currentUser().getOrganizationId(),
|
||||
Ctx.activeOrganizationId(),
|
||||
StringUtils.defaultIfBlank(dir, "public")));
|
||||
InputStream inputStream = file;
|
||||
fileEntity.setObjectId(
|
||||
|
||||
@@ -136,7 +136,7 @@ public class InvoiceService extends BaseService<InvoiceEntity, InvoiceRepository
|
||||
root.get("invoiceNumber"), invoice.getInvoiceNumber()),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()));
|
||||
Ctx.activeOrganizationId()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -183,7 +183,7 @@ public class InvoiceService extends BaseService<InvoiceEntity, InvoiceRepository
|
||||
invoice.getInvoiceNumber()),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()));
|
||||
Ctx.activeOrganizationId()));
|
||||
}
|
||||
})
|
||||
> 0;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class JobPostService extends BaseService<JobPostEntity, JobPostRepository
|
||||
public JobPostDto findByName(String name) {
|
||||
|
||||
JobPostEntity post =
|
||||
repository.findByNameAndOrganizationId(name, Ctx.currentUser().getOrganizationId());
|
||||
repository.findByNameAndOrganizationId(name, Ctx.activeOrganizationId());
|
||||
|
||||
return mapper.toDto(post);
|
||||
}
|
||||
|
||||
@@ -21,4 +21,6 @@ public class LoginUserDto extends CommonDto {
|
||||
private LocalDateTime loginTime;
|
||||
private LocalDateTime lastActiveTime;
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
private String activeOrganizationId;
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public class LoginUserEntity extends CommonEntity {
|
||||
private LocalDateTime loginTime;
|
||||
private LocalDateTime lastActiveTime;
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
private String activeOrganizationId;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.Constants;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.loginUser.dto.CreateLoginUserDto;
|
||||
import cn.lihongjie.coal.loginUser.dto.LoginUserDto;
|
||||
import cn.lihongjie.coal.loginUser.dto.UpdateLoginUserDto;
|
||||
@@ -12,6 +13,7 @@ import cn.lihongjie.coal.loginUser.mapper.LoginUserMapper;
|
||||
import cn.lihongjie.coal.loginUser.repository.LoginUserRepository;
|
||||
import cn.lihongjie.coal.loginUserHis.service.LoginUserHisService;
|
||||
import cn.lihongjie.coal.ratelimit.RateLimiterService;
|
||||
import cn.lihongjie.coal.session.dto.SwitchActiveOrgRequest;
|
||||
import cn.lihongjie.coal.session.service.SessionService;
|
||||
import cn.lihongjie.coal.sysconfig.service.SysConfigService;
|
||||
import cn.lihongjie.coal.user.service.UserService;
|
||||
@@ -327,4 +329,24 @@ public class LoginUserService extends BaseService<LoginUserEntity, LoginUserRepo
|
||||
|
||||
loginUserHisService.logAdminLogout(request.getIds());
|
||||
}
|
||||
|
||||
public void switchActiveOrg(String sessionId, SwitchActiveOrgRequest request) {
|
||||
|
||||
LoginUserEntity entity = this.get(sessionId);
|
||||
if (entity == null) {
|
||||
throw new BizException("sessionNotFound", "会话不存在");
|
||||
}
|
||||
entity.setActiveOrganizationId(request.getNewOrgId());
|
||||
|
||||
|
||||
try {
|
||||
this.repository.save(entity);
|
||||
} catch (Exception e) {
|
||||
log.warn("切换机构失败", e);
|
||||
throw new BizException("切换机构失败");
|
||||
}
|
||||
|
||||
this.clearCache(sessionId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MeterLogService extends BaseService<MeterLogEntity, MeterLogReposit
|
||||
.orElseThrow(() -> new BizException("未找到对应的设备: " + y));
|
||||
})
|
||||
.memoized()
|
||||
.apply(Ctx.currentUser().getOrganizationId());
|
||||
.apply(Ctx.activeOrganizationId());
|
||||
|
||||
List<MeterLogEntity> logEntities =
|
||||
ExcelUtils.readFirstSheetToObjectList(
|
||||
|
||||
@@ -85,7 +85,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
public String pathToId(IdRequest request) {
|
||||
|
||||
String id =
|
||||
this.repository.pathToId(request.getId(), Ctx.currentUser().getOrganizationId());
|
||||
this.repository.pathToId(request.getId(), Ctx.activeOrganizationId());
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
NetDiskEntity entity = new NetDiskEntity();
|
||||
entity.setEntryType("0");
|
||||
entity.setName("/");
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
save(entity);
|
||||
|
||||
return entity;
|
||||
@@ -171,7 +171,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
if (StringUtils.isEmpty(request.getId())) {
|
||||
return this.mapper.toDto(
|
||||
repository.findALlByParentNullAndOrganizationId(
|
||||
Ctx.currentUser().getOrganizationId()));
|
||||
Ctx.activeOrganizationId()));
|
||||
}
|
||||
|
||||
NetDiskEntity entity = get(request.getId());
|
||||
@@ -244,7 +244,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
NetDiskEntity entity = new NetDiskEntity();
|
||||
entity.setName(first);
|
||||
entity.setEntryType("0");
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
entity.setParent(parent);
|
||||
save(entity);
|
||||
if (parent.getChildren() == null) {
|
||||
@@ -278,7 +278,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
criteriaBuilder.isNull(root.get("parent")),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId()),
|
||||
Ctx.activeOrganizationId()),
|
||||
criteriaBuilder.equal(root.get("entryType"), "0"),
|
||||
criteriaBuilder.equal(root.get("name"), "/"));
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
|
||||
long count =
|
||||
repository.countByParentNullAndOrganizationIdAndName(
|
||||
Ctx.currentUser().getOrganizationId(), name);
|
||||
Ctx.activeOrganizationId(), name);
|
||||
|
||||
if (count > 0) {
|
||||
throw new BizException("根目录已经存在同名文件/文件夹");
|
||||
@@ -724,7 +724,7 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
NetDiskEntity entity = new NetDiskEntity();
|
||||
entity.setEntryType("0");
|
||||
entity.setName("/");
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
entity.setOrganizationId(Ctx.activeOrganizationId());
|
||||
save(entity);
|
||||
|
||||
request.setId(entity.getId());
|
||||
|
||||
@@ -85,7 +85,7 @@ public class OrderNoRuleService extends BaseService<OrderNoRuleEntity, OrderNoRu
|
||||
|
||||
|
||||
public String genOrderNo(GenOrderNoRequest ruleCode) {
|
||||
return genOrderNo(ruleCode, Ctx.currentUser().getOrganizationId());
|
||||
return genOrderNo(ruleCode, Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class OrderNoRuleService extends BaseService<OrderNoRuleEntity, OrderNoRu
|
||||
request.setTime(LocalDateTime.now());
|
||||
return orderNoGenService.genOrderNo(
|
||||
request,
|
||||
Ctx.currentUser().getOrganizationId() + "-preview",
|
||||
Ctx.activeOrganizationId() + "-preview",
|
||||
ruleCode.getRuleTemplate());
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class OrderNoRuleService extends BaseService<OrderNoRuleEntity, OrderNoRu
|
||||
|
||||
|
||||
public void initDefault() {
|
||||
initDefault(Ctx.currentUser().getOrganizationId());
|
||||
initDefault(Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
public void initDefault(String orgId){
|
||||
@@ -148,7 +148,7 @@ public class OrderNoRuleService extends BaseService<OrderNoRuleEntity, OrderNoRu
|
||||
|
||||
orderNoGenService.updateSeq(
|
||||
rule.getCode(),
|
||||
Ctx.currentUser().getOrganizationId(),
|
||||
Ctx.activeOrganizationId(),
|
||||
rule.getRuleTemplate(),
|
||||
id.getNewSeq());
|
||||
return "success";
|
||||
|
||||
@@ -4,10 +4,7 @@ import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.organization.dto.CreateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.OrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.ResetAdminPasswordRequest;
|
||||
import cn.lihongjie.coal.organization.dto.UpdateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.*;
|
||||
import cn.lihongjie.coal.organization.service.OrganizationService;
|
||||
import cn.lihongjie.coal.user.dto.UserDto;
|
||||
|
||||
@@ -70,4 +67,10 @@ public class OrganizationController extends BaseController {
|
||||
public OrganizationDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/orgTree")
|
||||
public OrganizationTreeDto orgTree() {
|
||||
return this.service.orgTree();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class CreateOrganizationDto extends CommonDto {
|
||||
|
||||
private String parentId;
|
||||
private String parent;
|
||||
|
||||
private String orgAdminUserName;
|
||||
private String orgAdminPassword;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class OrganizationDto extends CommonDto {
|
||||
|
||||
private String parentId;
|
||||
private SimpleDto parent;
|
||||
|
||||
@Comment("最大用户数量")
|
||||
private Integer maxUser;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.lihongjie.coal.organization.dto;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonDto;
|
||||
import cn.lihongjie.coal.base.dto.SimpleDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class OrganizationTreeDto extends CommonDto {
|
||||
|
||||
private SimpleDto parent;
|
||||
|
||||
|
||||
private List<OrganizationTreeDto> children;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class UpdateOrganizationDto extends CommonDto {
|
||||
|
||||
private String parentId;
|
||||
private String parent;
|
||||
|
||||
|
||||
@Comment("最大用户数量")
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.lihongjie.coal.organization.mapper;
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.organization.dto.CreateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.OrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.OrganizationTreeDto;
|
||||
import cn.lihongjie.coal.organization.dto.UpdateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.entity.OrganizationEntity;
|
||||
|
||||
@@ -19,4 +20,7 @@ public interface OrganizationMapper
|
||||
OrganizationEntity,
|
||||
OrganizationDto,
|
||||
CreateOrganizationDto,
|
||||
UpdateOrganizationDto> {}
|
||||
UpdateOrganizationDto> {
|
||||
OrganizationTreeDto toTreeDto(OrganizationEntity organizationEntity);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,10 @@ import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.coalParameterDef.service.CoalParameterDefService;
|
||||
import cn.lihongjie.coal.common.Constants;
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.common.JpaUtils;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.organization.dto.CreateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.OrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.ResetAdminPasswordRequest;
|
||||
import cn.lihongjie.coal.organization.dto.UpdateOrganizationDto;
|
||||
import cn.lihongjie.coal.organization.dto.*;
|
||||
import cn.lihongjie.coal.organization.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.organization.mapper.OrganizationMapper;
|
||||
import cn.lihongjie.coal.organization.repository.OrganizationRepository;
|
||||
@@ -235,5 +233,12 @@ public class OrganizationService extends BaseService<OrganizationEntity, Organiz
|
||||
}
|
||||
|
||||
|
||||
public OrganizationTreeDto orgTree() {
|
||||
|
||||
String s = Ctx.currentOrganizationId();
|
||||
|
||||
|
||||
return this.mapper.toTreeDto(this.repository.get(s));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class OrganizationConfigService
|
||||
|
||||
public OrganizationConfigEntity getCurrentOrgConfig(){
|
||||
|
||||
return getOrgConfig(Ctx.currentUser().getOrganizationId());
|
||||
return getOrgConfig(Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
private OrganizationConfigEntity getOrgConfig(String organizationId) {
|
||||
|
||||
@@ -168,6 +168,6 @@ public class PdcDeviceService extends BaseService<PdcDeviceEntity, PdcDeviceRepo
|
||||
|
||||
public List<String> deviceGroups() {
|
||||
|
||||
return repository.deviceGroups(Ctx.currentUser().getOrganizationId());
|
||||
return repository.deviceGroups(Ctx.activeOrganizationId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PdcDeviceDataService
|
||||
|
||||
request.setTd("1 " + request.getTimeDimension());
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
return JpaUtils.execNativeQuery(
|
||||
em,
|
||||
@@ -164,7 +164,7 @@ public class PdcDeviceDataService
|
||||
? LocalDateTime.now()
|
||||
: request.getEndTime())
|
||||
.setParameter("deviceGroup", request.getDeviceGroup())
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.getSingleResult();
|
||||
|
||||
if (minMaxTime == null) {
|
||||
@@ -240,7 +240,7 @@ public class PdcDeviceDataService
|
||||
var maxBucket = Math.max(10, duration.getSeconds() / 100);
|
||||
|
||||
nativeQuery.setParameter("bucket", maxBucket + " second");
|
||||
nativeQuery.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
nativeQuery.setParameter("organizationId", Ctx.activeOrganizationId());
|
||||
|
||||
List<Map> list =
|
||||
JpaUtils.convertTuplesToMap(
|
||||
|
||||
@@ -122,7 +122,7 @@ public class PdcDeviceRealTimeDataService
|
||||
public List<Map> getRealTimeReport(
|
||||
GetRealTImeReportRequest request) {
|
||||
|
||||
List<String> deviceIds = this.repository.findDeviceIdsByGroup(request.getDeviceGroup(), Ctx.currentUser().getOrganizationId());
|
||||
List<String> deviceIds = this.repository.findDeviceIdsByGroup(request.getDeviceGroup(), Ctx.activeOrganizationId());
|
||||
|
||||
if (deviceIds.isEmpty()){
|
||||
return List.of();
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PurchaseOrderService
|
||||
if (StringUtils.isNotEmpty(request.getCode())) {
|
||||
|
||||
if (repository.existsByCodeAndOrganizationId(
|
||||
request.getCode(), Ctx.currentUser().getOrganizationId())) {
|
||||
request.getCode(), Ctx.activeOrganizationId())) {
|
||||
throw new RuntimeException("采购单号已存在");
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class PurchaseOrderService
|
||||
"select count(p) from PurchaseOrderEntity p where p.code = :code and p.id != :id and p.organizationId = :organizationId",
|
||||
Long.class)
|
||||
.setParameter("code", request.getCode())
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.setParameter("id", request.getId())
|
||||
.getSingleResult()
|
||||
> 0L) {
|
||||
@@ -274,7 +274,7 @@ public class PurchaseOrderService
|
||||
switch (currentOrgConfig.getPurchaseOrderNoRule()) {
|
||||
case "1" -> {
|
||||
return sequenceService.genSeq(
|
||||
"purchaseOrderNo." + Ctx.currentUser().getOrganizationId(),
|
||||
"purchaseOrderNo." + Ctx.activeOrganizationId(),
|
||||
currentOrgConfig.getPurchaseOrderNoPrefix(),
|
||||
currentOrgConfig.getPurchaseOrderNoAutoIncrLength(),
|
||||
currentOrgConfig.getPurchaseOrderNoStart(),
|
||||
@@ -283,7 +283,7 @@ public class PurchaseOrderService
|
||||
case "2" -> {
|
||||
return sequenceService.genSeq(
|
||||
"purchaseOrderNo."
|
||||
+ Ctx.currentUser().getOrganizationId()
|
||||
+ Ctx.activeOrganizationId()
|
||||
+ ObjectUtils.defaultIfNull(dto.getPurchaseDate(), LocalDate.now())
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMdd")),
|
||||
currentOrgConfig.getPurchaseOrderNoPrefix(),
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SaleOrderService extends BaseService<SaleOrderEntity, SaleOrderRepo
|
||||
if (StringUtils.isNotEmpty(request.getCode())) {
|
||||
|
||||
if (repository.existsByCodeAndOrganizationId(
|
||||
request.getCode(), Ctx.currentUser().getOrganizationId())) {
|
||||
request.getCode(), Ctx.activeOrganizationId())) {
|
||||
throw new RuntimeException("订单号已存在");
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class SaleOrderService extends BaseService<SaleOrderEntity, SaleOrderRepo
|
||||
"select count(p) from SaleOrderEntity p where p.code = :code and p.id != :id and p.organizationId = :organizationId",
|
||||
Long.class)
|
||||
.setParameter("code", request.getCode())
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.setParameter("id", request.getId())
|
||||
.getSingleResult()
|
||||
> 0L) {
|
||||
@@ -263,7 +263,7 @@ public class SaleOrderService extends BaseService<SaleOrderEntity, SaleOrderRepo
|
||||
switch (currentOrgConfig.getSaleOrderNoRule()) {
|
||||
case "1" -> {
|
||||
return sequenceService.genSeq(
|
||||
"SaleOrderNo." + Ctx.currentUser().getOrganizationId(),
|
||||
"SaleOrderNo." + Ctx.activeOrganizationId(),
|
||||
currentOrgConfig.getSaleOrderNoPrefix(),
|
||||
currentOrgConfig.getSaleOrderNoAutoIncrLength(),
|
||||
currentOrgConfig.getSaleOrderNoStart(),
|
||||
@@ -272,7 +272,7 @@ public class SaleOrderService extends BaseService<SaleOrderEntity, SaleOrderRepo
|
||||
case "2" -> {
|
||||
return sequenceService.genSeq(
|
||||
"SaleOrderNo."
|
||||
+ Ctx.currentUser().getOrganizationId()
|
||||
+ Ctx.activeOrganizationId()
|
||||
+ ObjectUtils.defaultIfNull(dto.getSaleDate(), LocalDate.now())
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMdd")),
|
||||
currentOrgConfig.getSaleOrderNoPrefix(),
|
||||
@@ -300,7 +300,7 @@ public class SaleOrderService extends BaseService<SaleOrderEntity, SaleOrderRepo
|
||||
if (CollectionUtils.isEmpty(request.getFieldInfos())) {
|
||||
request.setFieldInfos(new ArrayList<>());
|
||||
}
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.session.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class SwitchActiveOrgRequest {
|
||||
|
||||
|
||||
|
||||
private String newOrgId;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package cn.lihongjie.coal.session.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.common.Constants;
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.common.RequestUtils;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.ip.IpQueryService;
|
||||
@@ -15,6 +16,7 @@ import cn.lihongjie.coal.organization.service.OrganizationService;
|
||||
import cn.lihongjie.coal.ratelimit.RateLimiterService;
|
||||
import cn.lihongjie.coal.session.dto.CaptchaDto;
|
||||
import cn.lihongjie.coal.session.dto.LoginDto;
|
||||
import cn.lihongjie.coal.session.dto.SwitchActiveOrgRequest;
|
||||
import cn.lihongjie.coal.sms.service.SmsService;
|
||||
import cn.lihongjie.coal.smsTemplate.entity.SmsTemplateEntity;
|
||||
import cn.lihongjie.coal.smsTemplate.service.SmsTemplateService;
|
||||
@@ -40,6 +42,8 @@ import lombok.Data;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -56,10 +60,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -116,6 +117,67 @@ public class SessionService {
|
||||
|
||||
@Autowired SmsService smsService;
|
||||
|
||||
|
||||
|
||||
public void switchActiveOrg(SwitchActiveOrgRequest request){
|
||||
|
||||
String id = Ctx.currentUser().getId();
|
||||
|
||||
UserEntity userEntity = userService.get(id);
|
||||
|
||||
String organizationId = userEntity.getOrganizationId();
|
||||
|
||||
if (StringUtils.equals(request.getNewOrgId(), organizationId)){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BooleanUtils.isTrue(userEntity.getOrgAdmin())){
|
||||
|
||||
throw new BizException("noPermission", "无权限切换机构");
|
||||
}
|
||||
|
||||
|
||||
OrganizationEntity organization = organizationService.get(organizationId);
|
||||
|
||||
|
||||
if (CollectionUtils.isEmpty(organization.getChildren())) {
|
||||
|
||||
throw new BizException("noChildOrg", "无可用机构");
|
||||
}
|
||||
|
||||
Stack<OrganizationEntity> stack = new Stack<>();
|
||||
stack.push(organization);
|
||||
Boolean find = false;
|
||||
while (CollectionUtils.isNotEmpty(stack)){
|
||||
|
||||
OrganizationEntity pop = stack.pop();
|
||||
|
||||
if (StringUtils.equals(pop.getId(), request.getNewOrgId())){
|
||||
|
||||
find = true;
|
||||
break;
|
||||
}else {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(pop.getChildren())){
|
||||
|
||||
stack.addAll(pop.getChildren());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!find){
|
||||
|
||||
throw new BizException("noChildOrg", "无可用机构");
|
||||
}
|
||||
|
||||
loginUserService.switchActiveOrg(Ctx.getSessionId(), request);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void rebuildSession(String sessionId) {
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SmsService extends BaseService<SmsEntity, SmsRepository> {
|
||||
|
||||
@SneakyThrows
|
||||
public void sendSmsMessage(String phone, String templateParam, String sysTemplateCode) {
|
||||
sendSmsMessage(phone, templateParam, sysTemplateCode, Ctx.currentUser().getOrganizationId());
|
||||
sendSmsMessage(phone, templateParam, sysTemplateCode, Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
@@ -93,7 +93,7 @@ public class UserService extends BaseService<UserEntity, UserRepository> {
|
||||
|
||||
public UserDto create(CreateUserDto request) {
|
||||
|
||||
String organizationId = Ctx.currentUser().getOrganizationId();
|
||||
String organizationId = Ctx.activeOrganizationId();
|
||||
|
||||
OrganizationEntity organization = organizationService.get(organizationId);
|
||||
|
||||
@@ -226,7 +226,7 @@ public class UserService extends BaseService<UserEntity, UserRepository> {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
request.getIds().forEach(this::clearUserCache);
|
||||
|
||||
this.assertAdmin(Ctx.currentUser().getOrganizationId());
|
||||
this.assertAdmin(Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
public UserDto getById(String id) {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class OrgUniqValidator implements ConstraintValidator<OrgUniq, Object> {
|
||||
query.setParameter("organizationId", PropertyUtils.getProperty(value, "organizationId"));
|
||||
}catch (NoSuchMethodException e){
|
||||
|
||||
query.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
query.setParameter("organizationId", Ctx.activeOrganizationId());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
|
||||
@@ -121,12 +121,12 @@ public class WarehouseGoodsService
|
||||
criteriaBuilder.equal(root.get("code"), id),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId())),
|
||||
Ctx.activeOrganizationId())),
|
||||
criteriaBuilder.and(
|
||||
criteriaBuilder.equal(root.get("barCode"), id),
|
||||
criteriaBuilder.equal(
|
||||
root.get("organizationId"),
|
||||
Ctx.currentUser().getOrganizationId())));
|
||||
Ctx.activeOrganizationId())));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public class WarehouseReceiptService
|
||||
request.setRuleCode(RuleCodeConstant.KF_RKD);
|
||||
request.setTime(receipt0.getReceiptDate());
|
||||
receipt0.setReceiptNo(
|
||||
orderNoRuleService.genOrderNo(request, Ctx.currentUser().getOrganizationId()));
|
||||
orderNoRuleService.genOrderNo(request, Ctx.activeOrganizationId()));
|
||||
|
||||
entity.setReceipt0(receipt0);
|
||||
this.warehouseReceiptDetailRepository.saveAll(receipt0.getDetail());
|
||||
@@ -234,7 +234,7 @@ public class WarehouseReceiptService
|
||||
request.setRuleCode(RuleCodeConstant.KF_CKD);
|
||||
request.setTime(receipt1.getReceiptDate());
|
||||
receipt1.setReceiptNo(
|
||||
orderNoRuleService.genOrderNo(request, Ctx.currentUser().getOrganizationId()));
|
||||
orderNoRuleService.genOrderNo(request, Ctx.activeOrganizationId()));
|
||||
|
||||
entity.setReceipt1(receipt1);
|
||||
this.save(receipt1);
|
||||
@@ -544,7 +544,7 @@ public class WarehouseReceiptService
|
||||
|
||||
public Object report(WarehouseReportRequest request) {
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
@@ -945,7 +945,7 @@ from (
|
||||
|
||||
public Object supplierReport(WarehouseReportRequest request) {
|
||||
|
||||
request.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
request.setOrganizationId(Ctx.activeOrganizationId());
|
||||
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WeightColumnConfigController {
|
||||
|
||||
@PostMapping("/initDefault")
|
||||
public Object initDefault() {
|
||||
this.service.initDefault(Ctx.currentUser().getOrganizationId());
|
||||
this.service.initDefault(Ctx.activeOrganizationId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class WeightColumnConfigService
|
||||
|
||||
Long cnt = (Long) em.createQuery("select count(*) from WeightColumnConfigEntity where code = :variable and status = 1 and organizationId = :organizationId")
|
||||
.setParameter("variable", variable)
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.getSingleResult();
|
||||
|
||||
if ( cnt == null || cnt == 0) {
|
||||
@@ -146,7 +146,7 @@ public class WeightColumnConfigService
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
if (!page.hasContent()) {
|
||||
initDefault(Ctx.currentUser().getOrganizationId());
|
||||
initDefault(Ctx.activeOrganizationId());
|
||||
return list(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class WeightDeviceDataService
|
||||
em.createQuery(
|
||||
" from WeightDeviceEntity d where d.organizationId = :organizationId",
|
||||
WeightDeviceEntity.class)
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.getResultList();
|
||||
|
||||
List<Map> result = new ArrayList<>();
|
||||
@@ -214,7 +214,7 @@ where 二次过磅时间>='%s' and 二次过磅时间<='%s'
|
||||
em.createQuery(
|
||||
" from WeightDeviceEntity d where d.organizationId = :organizationId",
|
||||
WeightDeviceEntity.class)
|
||||
.setParameter("organizationId", Ctx.currentUser().getOrganizationId())
|
||||
.setParameter("organizationId", Ctx.activeOrganizationId())
|
||||
.getResultList();
|
||||
|
||||
List<Map> result = new ArrayList<>();
|
||||
@@ -368,7 +368,7 @@ where 二次过磅时间>='%s' and 二次过磅时间<='%s'
|
||||
}
|
||||
|
||||
public void recalculate(IdRequest id) {
|
||||
List<WeightColumnConfigEntity> configs = getConfigs(Ctx.currentUser().getOrganizationId());
|
||||
List<WeightColumnConfigEntity> configs = getConfigs(Ctx.activeOrganizationId());
|
||||
|
||||
if (CollectionUtils.isEmpty(configs)) {
|
||||
|
||||
@@ -611,8 +611,8 @@ where 二次过磅时间>='%s' and 二次过磅时间<='%s'
|
||||
Query selectQuery = em.createNativeQuery(selectSql, Tuple.class);
|
||||
Query countQuery = em.createNativeQuery(countSql, Integer.class);
|
||||
|
||||
selectQuery.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
countQuery.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
selectQuery.setParameter("organizationId", Ctx.activeOrganizationId());
|
||||
countQuery.setParameter("organizationId", Ctx.activeOrganizationId());
|
||||
|
||||
if (request.getStartTime() != null) {
|
||||
selectQuery.setParameter("startTime", request.getStartTime());
|
||||
|
||||
Reference in New Issue
Block a user