sync
This commit is contained in:
parent
f103fc3fd4
commit
63a395d6ab
12 changed files with 782 additions and 14 deletions
|
|
@ -222,5 +222,3 @@ mvn webbpm:update-package -DexecuteNpmInstall=false -Dpath=resources-<your-versi
|
|||
в директорию: {your-project}\frontend\node_modules\@webbpm\base-package\
|
||||
```
|
||||
4. Запретите выполнение npm install при запуске студии. Для этого добавьте параметр `-DexecuteNpmInstall=false` в настройках Run/Debug Configurations студии
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ public class UserApplicationRole extends TableImpl<UserApplicationRoleRecord> {
|
|||
*/
|
||||
public final TableField<UserApplicationRoleRecord, Timestamp> UPDATED = createField(DSL.name("updated"), SQLDataType.TIMESTAMP(0).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "Дата и время последнего обновления записи");
|
||||
|
||||
/**
|
||||
* The column <code>public.user_application_role.finished</code>. Дата и
|
||||
* время окончания действия роли
|
||||
*/
|
||||
public final TableField<UserApplicationRoleRecord, Timestamp> FINISHED = createField(DSL.name("finished"), SQLDataType.TIMESTAMP(0), this, "Дата и время окончания действия роли");
|
||||
|
||||
private UserApplicationRole(Name alias, Table<UserApplicationRoleRecord> aliased) {
|
||||
this(alias, aliased, (Field<?>[]) null, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,22 @@ public class UserApplicationRoleRecord extends UpdatableRecordImpl<UserApplicati
|
|||
return (Timestamp) get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>public.user_application_role.finished</code>. Дата и
|
||||
* время окончания действия роли
|
||||
*/
|
||||
public void setFinished(Timestamp value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>public.user_application_role.finished</code>. Дата и
|
||||
* время окончания действия роли
|
||||
*/
|
||||
public Timestamp getFinished() {
|
||||
return (Timestamp) get(4);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -107,13 +123,14 @@ public class UserApplicationRoleRecord extends UpdatableRecordImpl<UserApplicati
|
|||
/**
|
||||
* Create a detached, initialised UserApplicationRoleRecord
|
||||
*/
|
||||
public UserApplicationRoleRecord(String userRoleId, String roleName, Timestamp created, Timestamp updated) {
|
||||
public UserApplicationRoleRecord(String userRoleId, String roleName, Timestamp created, Timestamp updated, Timestamp finished) {
|
||||
super(UserApplicationRole.USER_APPLICATION_ROLE);
|
||||
|
||||
setUserRoleId(userRoleId);
|
||||
setRoleName(roleName);
|
||||
setCreated(created);
|
||||
setUpdated(updated);
|
||||
setFinished(finished);
|
||||
resetChangedOnNotNull();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,376 @@
|
|||
package ru.micord.ervu.account_applications.model;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RecruitmentApiResponse {
|
||||
private int totalRows;
|
||||
private int page;
|
||||
private int perPage;
|
||||
private List<Record> records;
|
||||
|
||||
public int getTotalRows() {
|
||||
return totalRows;
|
||||
}
|
||||
|
||||
public void setTotalRows(int totalRows) {
|
||||
this.totalRows = totalRows;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getPerPage() {
|
||||
return perPage;
|
||||
}
|
||||
|
||||
public void setPerPage(int perPage) {
|
||||
this.perPage = perPage;
|
||||
}
|
||||
|
||||
public List<Record> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(
|
||||
List<Record> records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Record {
|
||||
private String id;
|
||||
private int version;
|
||||
private String schema;
|
||||
private String shortname;
|
||||
private String fullname;
|
||||
private String dns;
|
||||
private String email;
|
||||
private String phone;
|
||||
private String address;
|
||||
private String postalAddress;
|
||||
private String nsiDepartmentId;
|
||||
private String nsiOrganizationId;
|
||||
private String oktmo;
|
||||
private String orgOgrn;
|
||||
private String depOgrn;
|
||||
private String epguId;
|
||||
private String kpp;
|
||||
private String inn;
|
||||
private String okato;
|
||||
private String divisionType;
|
||||
private String tnsDepartmentId;
|
||||
private Boolean enabled;
|
||||
private String timezone;
|
||||
private Boolean reportsEnabled;
|
||||
private String subpoenaSeriesCode;
|
||||
private String addressId;
|
||||
private String postalAddressId;
|
||||
private String militaryCode;
|
||||
private Long createDate;
|
||||
private Long modified;
|
||||
private ParentRecord parent;
|
||||
private RegionInfo regionInfo;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public void setSchema(String schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getShortname() {
|
||||
return shortname;
|
||||
}
|
||||
|
||||
public void setShortname(String shortname) {
|
||||
this.shortname = shortname;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public void setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
|
||||
public String getDns() {
|
||||
return dns;
|
||||
}
|
||||
|
||||
public void setDns(String dns) {
|
||||
this.dns = dns;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getPostalAddress() {
|
||||
return postalAddress;
|
||||
}
|
||||
|
||||
public void setPostalAddress(String postalAddress) {
|
||||
this.postalAddress = postalAddress;
|
||||
}
|
||||
|
||||
public String getNsiDepartmentId() {
|
||||
return nsiDepartmentId;
|
||||
}
|
||||
|
||||
public void setNsiDepartmentId(String nsiDepartmentId) {
|
||||
this.nsiDepartmentId = nsiDepartmentId;
|
||||
}
|
||||
|
||||
public String getNsiOrganizationId() {
|
||||
return nsiOrganizationId;
|
||||
}
|
||||
|
||||
public void setNsiOrganizationId(String nsiOrganizationId) {
|
||||
this.nsiOrganizationId = nsiOrganizationId;
|
||||
}
|
||||
|
||||
public String getOktmo() {
|
||||
return oktmo;
|
||||
}
|
||||
|
||||
public void setOktmo(String oktmo) {
|
||||
this.oktmo = oktmo;
|
||||
}
|
||||
|
||||
public String getOrgOgrn() {
|
||||
return orgOgrn;
|
||||
}
|
||||
|
||||
public void setOrgOgrn(String orgOgrn) {
|
||||
this.orgOgrn = orgOgrn;
|
||||
}
|
||||
|
||||
public String getDepOgrn() {
|
||||
return depOgrn;
|
||||
}
|
||||
|
||||
public void setDepOgrn(String depOgrn) {
|
||||
this.depOgrn = depOgrn;
|
||||
}
|
||||
|
||||
public String getEpguId() {
|
||||
return epguId;
|
||||
}
|
||||
|
||||
public void setEpguId(String epguId) {
|
||||
this.epguId = epguId;
|
||||
}
|
||||
|
||||
public String getKpp() {
|
||||
return kpp;
|
||||
}
|
||||
|
||||
public void setKpp(String kpp) {
|
||||
this.kpp = kpp;
|
||||
}
|
||||
|
||||
public String getInn() {
|
||||
return inn;
|
||||
}
|
||||
|
||||
public void setInn(String inn) {
|
||||
this.inn = inn;
|
||||
}
|
||||
|
||||
public String getOkato() {
|
||||
return okato;
|
||||
}
|
||||
|
||||
public void setOkato(String okato) {
|
||||
this.okato = okato;
|
||||
}
|
||||
|
||||
public String getDivisionType() {
|
||||
return divisionType;
|
||||
}
|
||||
|
||||
public void setDivisionType(String divisionType) {
|
||||
this.divisionType = divisionType;
|
||||
}
|
||||
|
||||
public String getTnsDepartmentId() {
|
||||
return tnsDepartmentId;
|
||||
}
|
||||
|
||||
public void setTnsDepartmentId(String tnsDepartmentId) {
|
||||
this.tnsDepartmentId = tnsDepartmentId;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public Boolean getReportsEnabled() {
|
||||
return reportsEnabled;
|
||||
}
|
||||
|
||||
public void setReportsEnabled(Boolean reportsEnabled) {
|
||||
this.reportsEnabled = reportsEnabled;
|
||||
}
|
||||
|
||||
public ParentRecord getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(ParentRecord parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public RegionInfo getRegionInfo() {
|
||||
return regionInfo;
|
||||
}
|
||||
|
||||
public void setRegionInfo(
|
||||
RegionInfo regionInfo) {
|
||||
this.regionInfo = regionInfo;
|
||||
}
|
||||
|
||||
public String getSubpoenaSeriesCode() {
|
||||
return subpoenaSeriesCode;
|
||||
}
|
||||
|
||||
public void setSubpoenaSeriesCode(String subpoenaSeriesCode) {
|
||||
this.subpoenaSeriesCode = subpoenaSeriesCode;
|
||||
}
|
||||
|
||||
public String getAddressId() {
|
||||
return addressId;
|
||||
}
|
||||
|
||||
public void setAddressId(String addressId) {
|
||||
this.addressId = addressId;
|
||||
}
|
||||
|
||||
public String getPostalAddressId() {
|
||||
return postalAddressId;
|
||||
}
|
||||
|
||||
public void setPostalAddressId(String postalAddressId) {
|
||||
this.postalAddressId = postalAddressId;
|
||||
}
|
||||
|
||||
public String getMilitaryCode() {
|
||||
return militaryCode;
|
||||
}
|
||||
|
||||
public void setMilitaryCode(String militaryCode) {
|
||||
this.militaryCode = militaryCode;
|
||||
}
|
||||
|
||||
public Long getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Long createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Long getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Long modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class ParentRecord {
|
||||
private String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class RegionInfo {
|
||||
private String regionId;
|
||||
private String regionCode;
|
||||
|
||||
public String getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(String regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
|
||||
public String getRegionCode() {
|
||||
return regionCode;
|
||||
}
|
||||
|
||||
public void setRegionCode(String regionCode) {
|
||||
this.regionCode = regionCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package ru.micord.ervu.account_applications.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RoleApiResponse {
|
||||
private int totalRows;
|
||||
private int page;
|
||||
private int perPage;
|
||||
private List<RoleApiResponse.Record> records;
|
||||
|
||||
public int getTotalRows() {
|
||||
return totalRows;
|
||||
}
|
||||
|
||||
public void setTotalRows(int totalRows) {
|
||||
this.totalRows = totalRows;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public int getPerPage() {
|
||||
return perPage;
|
||||
}
|
||||
|
||||
public void setPerPage(int perPage) {
|
||||
this.perPage = perPage;
|
||||
}
|
||||
|
||||
public List<RoleApiResponse.Record> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(
|
||||
List<RoleApiResponse.Record> records) {
|
||||
this.records = records;
|
||||
}
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Record {
|
||||
private String id;
|
||||
private String displayName;
|
||||
private Long createDate;
|
||||
private Long modified;
|
||||
private Long finish;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public Long getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Long createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Long getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Long modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public Long getFinish() {
|
||||
return finish;
|
||||
}
|
||||
|
||||
public void setFinish(Long finish) {
|
||||
this.finish = finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
package ru.micord.ervu.account_applications.service;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.micord.ervu.account_applications.db_beans.public_.tables.records.RecruitmentRecord;
|
||||
import ru.micord.ervu.account_applications.db_beans.public_.tables.records.UserApplicationRoleRecord;
|
||||
import ru.micord.ervu.account_applications.model.RecruitmentApiResponse;
|
||||
import ru.micord.ervu.account_applications.model.RoleApiResponse;
|
||||
|
||||
import static ru.micord.ervu.account_applications.db_beans.public_.tables.Recruitment.RECRUITMENT;
|
||||
import static ru.micord.ervu.account_applications.db_beans.public_.tables.UserApplicationRole.USER_APPLICATION_ROLE;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
@Service
|
||||
public class ErvuDirectoriesService {
|
||||
|
||||
@Value("${ervu.http.timeout:30}")
|
||||
private int httpTimeout;
|
||||
@Value("${ervu.url}")
|
||||
private String ervuUrl;
|
||||
@Value("${ervu.page.size:50}")
|
||||
private Integer perPage;
|
||||
|
||||
@Autowired
|
||||
private DSLContext dsl;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
public void updateDirectories() {
|
||||
fetchAndUpsetRecruitmentData();
|
||||
fetchAndUpsetRoleData();
|
||||
}
|
||||
|
||||
public void fetchAndUpsetRecruitmentData() {
|
||||
int page = 1;
|
||||
boolean hasMorePages;
|
||||
Result<Record2<UUID, String>> ids = dsl.select(RECRUITMENT.ID, RECRUITMENT.IDM_ID).from(RECRUITMENT).fetch();
|
||||
try {
|
||||
do {
|
||||
String url = ervuUrl
|
||||
+ "/service/idm/domains?query=schema%3Din%3D%28Organization%2CDepartment%29&expand=parent&page="
|
||||
+ page + "&perPage=" + perPage;
|
||||
HttpRequest getReqDoc = HttpRequest.newBuilder(URI.create(url))
|
||||
.header(HttpHeaders.CONTENT_TYPE, "application/json")
|
||||
.GET()
|
||||
.timeout(Duration.ofSeconds(httpTimeout))
|
||||
.build();
|
||||
HttpResponse<String> getRespDoc = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(httpTimeout))
|
||||
.build()
|
||||
.send(getReqDoc, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
RecruitmentApiResponse recruitmentApiResponse = objectMapper.readValue(getRespDoc.body(),
|
||||
RecruitmentApiResponse.class
|
||||
);
|
||||
if (recruitmentApiResponse != null && recruitmentApiResponse.getRecords() != null) {
|
||||
upsertRecruitmentData(recruitmentApiResponse.getRecords(), ids);
|
||||
hasMorePages = recruitmentApiResponse.getRecords().size()
|
||||
== perPage;
|
||||
}
|
||||
else {
|
||||
hasMorePages = false;
|
||||
}
|
||||
page++;
|
||||
}
|
||||
while (hasMorePages);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void upsertRecruitmentData(List<RecruitmentApiResponse.Record> recordList, Result<Record2<UUID, String>> ids) {
|
||||
List<RecruitmentRecord> newRecruitmentRecords = new ArrayList<>();
|
||||
List<RecruitmentRecord> recruitmentRecords = new ArrayList<>();
|
||||
recordList.forEach(record -> {
|
||||
Timestamp updatedAt = Timestamp.from(Instant.ofEpochSecond(record.getModified()));
|
||||
Timestamp createdAt = Timestamp.from(Instant.ofEpochSecond(record.getCreateDate()));
|
||||
RecruitmentRecord recruitmentRecord = dsl.newRecord(RECRUITMENT);
|
||||
recruitmentRecord.setIdmId(record.getId());
|
||||
recruitmentRecord.setVersion(record.getVersion());
|
||||
recruitmentRecord.setSchema(record.getSchema());
|
||||
recruitmentRecord.setShortname(record.getShortname());
|
||||
recruitmentRecord.setFullname(record.getFullname());
|
||||
recruitmentRecord.setDns(record.getDns());
|
||||
recruitmentRecord.setEmail(record.getEmail());
|
||||
recruitmentRecord.setPhone(record.getPhone());
|
||||
recruitmentRecord.setAddress(record.getAddress());
|
||||
recruitmentRecord.setPostalAddress(record.getPostalAddress());
|
||||
recruitmentRecord.setNsiDepartmentId(record.getNsiDepartmentId());
|
||||
recruitmentRecord.setNsiOrganizationId(record.getNsiOrganizationId());
|
||||
recruitmentRecord.setOktmo(record.getOktmo());
|
||||
recruitmentRecord.setOrgOgrn(record.getOrgOgrn());
|
||||
recruitmentRecord.setDepOgrn(record.getDepOgrn());
|
||||
recruitmentRecord.setEpguId(record.getEpguId());
|
||||
recruitmentRecord.setKpp(record.getKpp());
|
||||
recruitmentRecord.setInn(record.getInn());
|
||||
recruitmentRecord.setOkato(record.getOkato());
|
||||
recruitmentRecord.setDivisionType(record.getDivisionType());
|
||||
recruitmentRecord.setTnsDepartmentId(record.getTnsDepartmentId());
|
||||
recruitmentRecord.setEnabled(record.getEnabled());
|
||||
recruitmentRecord.setTimezone(record.getTimezone());
|
||||
recruitmentRecord.setReportsEnabled(record.getReportsEnabled());
|
||||
recruitmentRecord.setParentId(record.getParent() != null ? record.getParent().getId() : null);
|
||||
recruitmentRecord.setSubpoenaSeriesCode(record.getSubpoenaSeriesCode());
|
||||
recruitmentRecord.setAddressId(record.getAddressId());
|
||||
recruitmentRecord.setPostalAddressId(record.getPostalAddressId());
|
||||
recruitmentRecord.setRegionId(record.getRegionInfo() != null ? record.getRegionInfo().getRegionId() : null);
|
||||
recruitmentRecord.setRegionCode(record.getRegionInfo() != null ? record.getRegionInfo().getRegionCode() : null);
|
||||
recruitmentRecord.setMilitaryCode(record.getMilitaryCode());
|
||||
recruitmentRecord.setCreatedAt(createdAt);
|
||||
recruitmentRecord.setUpdatedAt(updatedAt);
|
||||
boolean isExisting = false;
|
||||
for (Record2<UUID, String> resultRecord : ids) {
|
||||
if (resultRecord.get(RECRUITMENT.IDM_ID).equals(recruitmentRecord.getIdmId())) {
|
||||
recruitmentRecord.setId(resultRecord.get(RECRUITMENT.ID));
|
||||
recruitmentRecords.add(recruitmentRecord);
|
||||
isExisting = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExisting) {
|
||||
newRecruitmentRecords.add(recruitmentRecord);
|
||||
}
|
||||
});
|
||||
dsl.batchInsert(newRecruitmentRecords).execute();
|
||||
dsl.batchUpdate(recruitmentRecords).execute();
|
||||
}
|
||||
|
||||
public void fetchAndUpsetRoleData() {
|
||||
int page = 1;
|
||||
boolean hasMorePages;
|
||||
List<String> ids = dsl.select(USER_APPLICATION_ROLE.USER_ROLE_ID)
|
||||
.from(USER_APPLICATION_ROLE)
|
||||
.fetch(USER_APPLICATION_ROLE.USER_ROLE_ID);
|
||||
try {
|
||||
do {
|
||||
String url = ervuUrl
|
||||
+ "/service/idm/roles?query=ervuRole%3Dlike%3Dtrue&expand=parent&page="
|
||||
+ page + "&perPage=" + perPage;
|
||||
HttpRequest getReqDoc = HttpRequest.newBuilder(URI.create(url))
|
||||
.header(HttpHeaders.CONTENT_TYPE, "application/json")
|
||||
.GET()
|
||||
.timeout(Duration.ofSeconds(httpTimeout))
|
||||
.build();
|
||||
HttpResponse<String> getRespDoc = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(httpTimeout))
|
||||
.build()
|
||||
.send(getReqDoc, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
RoleApiResponse roleApiResponse = objectMapper.readValue(getRespDoc.body(),
|
||||
RoleApiResponse.class
|
||||
);
|
||||
if (roleApiResponse != null && roleApiResponse.getRecords() != null) {
|
||||
upsertRoleData(roleApiResponse.getRecords(), ids);
|
||||
hasMorePages = roleApiResponse.getRecords().size()
|
||||
== perPage;
|
||||
}
|
||||
else {
|
||||
hasMorePages = false;
|
||||
}
|
||||
page++;
|
||||
}
|
||||
while (hasMorePages);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void upsertRoleData(List<RoleApiResponse.Record> recordList, List<String> ids) {
|
||||
List<UserApplicationRoleRecord> newRoleRecords = new ArrayList<>();
|
||||
List<UserApplicationRoleRecord> roleRecords = new ArrayList<>();
|
||||
recordList.forEach(record -> {
|
||||
Timestamp updatedAt = Timestamp.from(Instant.ofEpochSecond(record.getModified()));
|
||||
Timestamp createdAt = Timestamp.from(Instant.ofEpochSecond(record.getCreateDate()));
|
||||
Timestamp finishAt = null;
|
||||
if (record.getFinish() != null) {
|
||||
finishAt = Timestamp.from(Instant.ofEpochSecond(record.getFinish()));
|
||||
}
|
||||
UserApplicationRoleRecord roleRecord = dsl.newRecord(USER_APPLICATION_ROLE);
|
||||
roleRecord.setUserRoleId(record.getId());
|
||||
roleRecord.setRoleName(record.getDisplayName());
|
||||
roleRecord.setCreated(createdAt);
|
||||
roleRecord.setUpdated(updatedAt);
|
||||
roleRecord.setFinished(finishAt);
|
||||
if (ids.contains(record.getId())) {
|
||||
roleRecords.add(roleRecord);
|
||||
}
|
||||
else {
|
||||
newRoleRecords.add(roleRecord);
|
||||
}
|
||||
});
|
||||
dsl.batchInsert(newRoleRecords).execute();
|
||||
dsl.batchUpdate(roleRecords).execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package ru.micord.ervu.account_applications.service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.springframework.scheduling.config.ScheduledTaskRegistrar.CRON_DISABLED;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
@Service
|
||||
public class ErvuDirectoriesUpdateShedulerService {
|
||||
|
||||
@Autowired
|
||||
private ErvuDirectoriesService ervuDirectoriesService;
|
||||
|
||||
@Value("${directory.update.cron:0 0 */1 * * *}")
|
||||
private String cronLoad;
|
||||
|
||||
@PostConstruct
|
||||
@Transactional
|
||||
public void init() {
|
||||
if (!cronLoad.equals(CRON_DISABLED)) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${directory.update.cron:0 0 */1 * * *}")
|
||||
@SchedulerLock(name = "updateDirectories")
|
||||
@Transactional
|
||||
public void run() {
|
||||
ervuDirectoriesService.updateDirectories();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
|
||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
|
||||
|
||||
<changeSet id="0001" author="tihomirov">
|
||||
<comment>add finished</comment>
|
||||
<sql>
|
||||
ALTER TABLE IF EXISTS public.user_application_role ADD COLUMN IF NOT EXISTS finished TIMESTAMP WITHOUT TIME ZONE;
|
||||
COMMENT ON COLUMN public.user_application_role.finished IS 'Дата и время окончания действия роли';
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
<include file="20250303_SUPPORT-8956_create_table_role.xml" relativeToChangelogFile="true"/>
|
||||
<include file="20250304_SUPPORT-8956_drop_security.xml" relativeToChangelogFile="true"/>
|
||||
<include file="20250307_ERVU-308_create_table_update.xml" relativeToChangelogFile="true"/>
|
||||
<include file="20250312-SUPPORT-8696_add_column_role.xml" relativeToChangelogFile="true"/>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2493,7 +2493,7 @@
|
|||
<entry>
|
||||
<key>method</key>
|
||||
<value>
|
||||
<simple>"setValue"</simple>
|
||||
<simple>"setValueByBusinessId"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -5616,7 +5616,7 @@
|
|||
<entry>
|
||||
<key>businessIdColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"fullname"}</simple>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"idm_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
|
|||
|
|
@ -799,7 +799,6 @@
|
|||
<componentRootId>a397e301-e715-4c6a-b289-5a27af3900d3</componentRootId>
|
||||
<name>Основные данные</name>
|
||||
<container>true</container>
|
||||
<expanded>false</expanded>
|
||||
<childrenReordered>false</childrenReordered>
|
||||
<scripts id="d1ce20ca-453b-4610-a2a5-bb6498db5cf5">
|
||||
<properties>
|
||||
|
|
@ -2522,7 +2521,7 @@
|
|||
<entry>
|
||||
<key>method</key>
|
||||
<value>
|
||||
<simple>"setValue"</simple>
|
||||
<simple>"setValueByBusinessId"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -3022,7 +3021,7 @@
|
|||
<entry>
|
||||
<key>method</key>
|
||||
<value>
|
||||
<simple>"setValue"</simple>
|
||||
<simple>"setValueByBusinessId"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -3623,7 +3622,7 @@
|
|||
<entry>
|
||||
<key>method</key>
|
||||
<value>
|
||||
<simple>"setValue"</simple>
|
||||
<simple>"setValueByBusinessId"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -5293,7 +5292,7 @@
|
|||
<entry>
|
||||
<key>businessIdColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"fullname"}</simple>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"idm_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -9219,7 +9218,7 @@
|
|||
<entry>
|
||||
<key>businessIdColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"fullname"}</simple>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"idm_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -13432,7 +13431,7 @@
|
|||
<entry>
|
||||
<key>businessIdColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"fullname"}</simple>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"idm_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
|
|||
|
|
@ -2493,7 +2493,7 @@
|
|||
<entry>
|
||||
<key>method</key>
|
||||
<value>
|
||||
<simple>"setValue"</simple>
|
||||
<simple>"setValueByBusinessId"</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
@ -5617,7 +5617,7 @@
|
|||
<entry>
|
||||
<key>businessIdColumn</key>
|
||||
<value>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"fullname"}</simple>
|
||||
<simple>{"schema":"public","table":"recruitment","entity":"recruitment","name":"idm_id"}</simple>
|
||||
</value>
|
||||
</entry>
|
||||
<entry>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue