indicator fixes
This commit is contained in:
parent
b584015256
commit
898b18e104
|
@ -428,31 +428,22 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
|||
this.tenantEntityManager.disableTenantFilters();
|
||||
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUser()).collectAs(new BaseFieldSet().ensure(TenantUser._tenant));
|
||||
List<IndicatorField> fields = new ArrayList<>();
|
||||
if (tenantUserEntities != null) {
|
||||
List<TenantEntity> tenantEntities = this.queryFactory.query(TenantQuery.class).disableTracking().ids(tenantUserEntities.stream().map(TenantUserEntity::getTenantId).distinct().toList()).collect();
|
||||
if (tenantEntities != null) {
|
||||
for (TenantEntity tenant: tenantEntities) {
|
||||
|
||||
IndicatorField field = new IndicatorField();
|
||||
field.setCode("tenant_code");
|
||||
field.setName("Tenant Code");
|
||||
field.setValueField(tenant.getCode());
|
||||
field.setBasetype(IndicatorFieldBaseType.String);
|
||||
field.setBasetype(IndicatorFieldBaseType.Keyword);
|
||||
fields.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
IndicatorField field1 = new IndicatorField();
|
||||
field1.setCode("user_id");
|
||||
field1.setName("User Id");
|
||||
field1.setValueField(this.kpiProperties.getUser().toString());
|
||||
field1.setBasetype(IndicatorFieldBaseType.String);
|
||||
field1.setBasetype(IndicatorFieldBaseType.Keyword);
|
||||
fields.add(field1);
|
||||
|
||||
IndicatorField field2 = new IndicatorField();
|
||||
field2.setCode("created_at");
|
||||
field2.setName("Created at");
|
||||
field2.setValueField(Instant.now().toString());
|
||||
field2.setBasetype(IndicatorFieldBaseType.Date);
|
||||
fields.add(field2);
|
||||
|
||||
|
@ -463,10 +454,15 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
|||
IndicatorField field3 = new IndicatorField();
|
||||
field3.setCode("user_name");
|
||||
field3.setName("User Name");
|
||||
field3.setValueField(user.getName());
|
||||
field3.setBasetype(IndicatorFieldBaseType.String);
|
||||
fields.add(field3);
|
||||
|
||||
IndicatorField field4 = new IndicatorField();
|
||||
field4.setCode("value");
|
||||
field4.setName("Value");
|
||||
field4.setBasetype(IndicatorFieldBaseType.Integer);
|
||||
fields.add(field4);
|
||||
|
||||
IndicatorSchema schema = new IndicatorSchema();
|
||||
schema.setId(this.kpiProperties.getId());
|
||||
schema.setFields(fields);
|
||||
|
@ -504,7 +500,33 @@ public class MaintenanceServiceImpl implements MaintenanceService {
|
|||
IndicatorPointEvent event = new IndicatorPointEvent();
|
||||
event.setIndicatorId(this.kpiProperties.getId());
|
||||
|
||||
event.add("user_id", this.kpiProperties.getUser());
|
||||
event.add("created_at", Instant.now());
|
||||
event.add("value", 1);
|
||||
|
||||
UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(this.kpiProperties.getUser()).firstAs(new BaseFieldSet().ensure(User._name));
|
||||
if (user == null) {
|
||||
throw new MyApplicationException("user not found");
|
||||
}
|
||||
|
||||
event.add("user_name", user.getName());
|
||||
|
||||
try {
|
||||
this.tenantEntityManager.disableTenantFilters();
|
||||
List<TenantUserEntity> tenantUserEntities = this.queryFactory.query(TenantUserQuery.class).disableTracking().userIds(this.kpiProperties.getUser()).collectAs(new BaseFieldSet().ensure(TenantUser._tenant));
|
||||
if (tenantUserEntities != null) {
|
||||
List<TenantEntity> tenantEntities = this.queryFactory.query(TenantQuery.class).disableTracking().ids(tenantUserEntities.stream().map(TenantUserEntity::getTenantId).distinct().toList()).collect();
|
||||
if (tenantEntities != null) {
|
||||
for (TenantEntity tenant: tenantEntities) {
|
||||
event.add("tenant_code", tenant.getCode());
|
||||
this.validatorFactory.validator(IndicatorPointEvent.IndicatorPointEventValidator.class).validateForce(event);
|
||||
this.indicatorPointEventHandler.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue