관리자 동기화 배치 작업
This commit is contained in:
parent
5da5124047
commit
8494af9353
@ -208,4 +208,34 @@ public class JobLauncherController {
|
|||||||
|
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 관리자 유저 동기화 배치
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws JobInstanceAlreadyCompleteException
|
||||||
|
* @throws JobExecutionAlreadyRunningException
|
||||||
|
* @throws JobParametersInvalidException
|
||||||
|
* @throws JobRestartException
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 0 * * *")
|
||||||
|
public String adminUserStep()
|
||||||
|
throws JobInstanceAlreadyCompleteException,
|
||||||
|
JobExecutionAlreadyRunningException,
|
||||||
|
JobParametersInvalidException,
|
||||||
|
JobRestartException {
|
||||||
|
|
||||||
|
String jobName = "adminUserJob";
|
||||||
|
Job job = jobs.get(jobName);
|
||||||
|
if (job == null) {
|
||||||
|
return "Job " + jobName + " not found";
|
||||||
|
}
|
||||||
|
|
||||||
|
JobParameters jobParameters =
|
||||||
|
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||||
|
|
||||||
|
jobLauncher.run(job, jobParameters);
|
||||||
|
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,84 @@
|
|||||||
|
package com.interplug.qcast.batch.system;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.interplug.qcast.biz.user.UserService;
|
||||||
|
import com.interplug.qcast.biz.user.dto.AdminUserSyncResponse;
|
||||||
|
import com.interplug.qcast.util.InterfaceQsp;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.batch.core.Job;
|
||||||
|
import org.springframework.batch.core.JobExecutionListener;
|
||||||
|
import org.springframework.batch.core.Step;
|
||||||
|
import org.springframework.batch.core.configuration.annotation.StepScope;
|
||||||
|
import org.springframework.batch.core.job.builder.JobBuilder;
|
||||||
|
import org.springframework.batch.core.repository.JobRepository;
|
||||||
|
import org.springframework.batch.core.step.builder.StepBuilder;
|
||||||
|
import org.springframework.batch.item.ItemProcessor;
|
||||||
|
import org.springframework.batch.item.ItemReader;
|
||||||
|
import org.springframework.batch.item.ItemWriter;
|
||||||
|
import org.springframework.batch.item.support.ListItemReader;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
|
/** 관리자 유저 동기화 배치 */
|
||||||
|
@Configuration
|
||||||
|
public class AdminUserConfiguration implements JobExecutionListener {
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
private final InterfaceQsp interfaceQsp;
|
||||||
|
|
||||||
|
List<AdminUserSyncResponse> adminUserSyncList;
|
||||||
|
|
||||||
|
@Value("${qsp.master-admin-user-batch-url}")
|
||||||
|
private String qspInterfaceUrl;
|
||||||
|
|
||||||
|
public AdminUserConfiguration(UserService userService, InterfaceQsp interfaceQsp) {
|
||||||
|
this.userService = userService;
|
||||||
|
this.interfaceQsp = interfaceQsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Job adminUserJob(JobRepository jobRepository, Step adminUserStep) {
|
||||||
|
return new JobBuilder("adminUserJob", jobRepository).start(adminUserStep).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Step adminUserStep(
|
||||||
|
JobRepository jobRepository, PlatformTransactionManager transactionManager) throws Exception {
|
||||||
|
return new StepBuilder("adminUserStep", jobRepository)
|
||||||
|
.<AdminUserSyncResponse, AdminUserSyncResponse>chunk(100, transactionManager)
|
||||||
|
.reader(adminUserReader())
|
||||||
|
.processor(adminUserProcessor())
|
||||||
|
.writer(adminUserWriter())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@StepScope
|
||||||
|
public ItemReader<AdminUserSyncResponse> adminUserReader() throws Exception {
|
||||||
|
this.adminUserSyncList =
|
||||||
|
interfaceQsp.callApiData(
|
||||||
|
HttpMethod.GET,
|
||||||
|
qspInterfaceUrl,
|
||||||
|
null,
|
||||||
|
new TypeReference<List<AdminUserSyncResponse>>() {});
|
||||||
|
return (adminUserSyncList != null)
|
||||||
|
? new ListItemReader<>(adminUserSyncList)
|
||||||
|
: new ListItemReader<>(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ItemProcessor<AdminUserSyncResponse, AdminUserSyncResponse> adminUserProcessor() {
|
||||||
|
return item -> item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ItemWriter<AdminUserSyncResponse> adminUserWriter() {
|
||||||
|
return items -> {
|
||||||
|
userService.setAdminUserSyncSave((List<AdminUserSyncResponse>) items.getItems());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.interplug.qcast.batch.master;
|
package com.interplug.qcast.batch.system;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.interplug.qcast.biz.user.UserService;
|
import com.interplug.qcast.biz.user.UserService;
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.interplug.qcast.biz.user;
|
package com.interplug.qcast.biz.user;
|
||||||
|
|
||||||
|
import com.interplug.qcast.biz.user.dto.AdminUserSyncResponse;
|
||||||
import com.interplug.qcast.biz.user.dto.BusinessChargerSyncResponse;
|
import com.interplug.qcast.biz.user.dto.BusinessChargerSyncResponse;
|
||||||
import com.interplug.qcast.biz.user.dto.StoreRequest;
|
import com.interplug.qcast.biz.user.dto.StoreRequest;
|
||||||
import com.interplug.qcast.biz.user.dto.UserRequest;
|
import com.interplug.qcast.biz.user.dto.UserRequest;
|
||||||
@ -62,4 +63,22 @@ public interface UserMapper {
|
|||||||
*/
|
*/
|
||||||
int setBusinessChargerSyncSave(BusinessChargerSyncResponse businessChargerSyncData)
|
int setBusinessChargerSyncSave(BusinessChargerSyncResponse businessChargerSyncData)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 관리자 유저 정보 동기화 삭제
|
||||||
|
*
|
||||||
|
* @param adminUserSyncData
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
int deleteAdminUserSync(AdminUserSyncResponse adminUserSyncData) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 관리자 유저 정보 동기화 저장
|
||||||
|
*
|
||||||
|
* @param adminUserSyncData
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
int setAdminUserSyncSave(AdminUserSyncResponse adminUserSyncData) throws Exception;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.interplug.qcast.biz.user;
|
package com.interplug.qcast.biz.user;
|
||||||
|
|
||||||
|
import com.interplug.qcast.biz.user.dto.AdminUserSyncResponse;
|
||||||
import com.interplug.qcast.biz.user.dto.BusinessChargerSyncResponse;
|
import com.interplug.qcast.biz.user.dto.BusinessChargerSyncResponse;
|
||||||
import com.interplug.qcast.biz.user.dto.StoreRequest;
|
import com.interplug.qcast.biz.user.dto.StoreRequest;
|
||||||
import com.interplug.qcast.biz.user.dto.UserRequest;
|
import com.interplug.qcast.biz.user.dto.UserRequest;
|
||||||
@ -100,4 +101,23 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 관리자 유저 정보 동기화
|
||||||
|
*
|
||||||
|
* @param adminUserSyncList 관리자 유저 목록
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public int setAdminUserSyncSave(List<AdminUserSyncResponse> adminUserSyncList) throws Exception {
|
||||||
|
int cnt = 0;
|
||||||
|
for (AdminUserSyncResponse adminUserSyncData : adminUserSyncList) {
|
||||||
|
if ("1".equals(adminUserSyncData.getDelFlg())) {
|
||||||
|
cnt += userMapper.deleteAdminUserSync(adminUserSyncData);
|
||||||
|
} else {
|
||||||
|
cnt += userMapper.setAdminUserSyncSave(adminUserSyncData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.interplug.qcast.biz.user.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** 관리자 유저 동기화 Request */
|
||||||
|
@Data
|
||||||
|
public class AdminUserSyncResponse {
|
||||||
|
@Schema(description = "User ID")
|
||||||
|
String userId;
|
||||||
|
|
||||||
|
@Schema(description = "Company Name")
|
||||||
|
String companyName;
|
||||||
|
|
||||||
|
@Schema(description = "Category(Department Name)")
|
||||||
|
String category;
|
||||||
|
|
||||||
|
@Schema(description = "User Name")
|
||||||
|
String name;
|
||||||
|
|
||||||
|
@Schema(description = "Telephone No")
|
||||||
|
String tel;
|
||||||
|
|
||||||
|
@Schema(description = "Fax No")
|
||||||
|
String fax;
|
||||||
|
|
||||||
|
@Schema(description = "Mail")
|
||||||
|
String mail;
|
||||||
|
|
||||||
|
@Schema(description = "Group ID")
|
||||||
|
String groupId;
|
||||||
|
|
||||||
|
@Schema(description = "Delete Flag")
|
||||||
|
String delFlg;
|
||||||
|
}
|
||||||
@ -42,6 +42,7 @@ qsp:
|
|||||||
master-material-batch-url: /api/master/materialList
|
master-material-batch-url: /api/master/materialList
|
||||||
master-bom-batch-url: /api/master/bomList
|
master-bom-batch-url: /api/master/bomList
|
||||||
master-business-charger-batch-url: /api/user/businessChargerList
|
master-business-charger-batch-url: /api/user/businessChargerList
|
||||||
|
master-admin-user-batch-url: /api/admin/userList
|
||||||
simulation-guide-info-url: /api/simulation/guideInfo
|
simulation-guide-info-url: /api/simulation/guideInfo
|
||||||
aes256.key: jpqcellQ123456!!
|
aes256.key: jpqcellQ123456!!
|
||||||
auto.login.aes256.key: _autoL!!
|
auto.login.aes256.key: _autoL!!
|
||||||
|
|||||||
@ -42,6 +42,7 @@ qsp:
|
|||||||
master-material-batch-url: /api/master/materialList
|
master-material-batch-url: /api/master/materialList
|
||||||
master-bom-batch-url: /api/master/bomList
|
master-bom-batch-url: /api/master/bomList
|
||||||
master-business-charger-batch-url: /api/user/businessChargerList
|
master-business-charger-batch-url: /api/user/businessChargerList
|
||||||
|
master-admin-user-batch-url: /api/admin/userList
|
||||||
simulation-guide-info-url: /api/simulation/guideInfo
|
simulation-guide-info-url: /api/simulation/guideInfo
|
||||||
aes256.key: jpqcellQ123456!!
|
aes256.key: jpqcellQ123456!!
|
||||||
auto.login.aes256.key: _autoL!!
|
auto.login.aes256.key: _autoL!!
|
||||||
|
|||||||
@ -42,6 +42,7 @@ qsp:
|
|||||||
master-material-batch-url: /api/master/materialList
|
master-material-batch-url: /api/master/materialList
|
||||||
master-bom-batch-url: /api/master/bomList
|
master-bom-batch-url: /api/master/bomList
|
||||||
master-business-charger-batch-url: /api/user/businessChargerList
|
master-business-charger-batch-url: /api/user/businessChargerList
|
||||||
|
master-admin-user-batch-url: /api/admin/userList
|
||||||
simulation-guide-info-url: /api/simulation/guideInfo
|
simulation-guide-info-url: /api/simulation/guideInfo
|
||||||
aes256.key: jpqcellQ123456!!
|
aes256.key: jpqcellQ123456!!
|
||||||
auto.login.aes256.key: _autoL!!
|
auto.login.aes256.key: _autoL!!
|
||||||
|
|||||||
@ -286,4 +286,47 @@
|
|||||||
);
|
);
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteAdminUserSync" parameterType="com.interplug.qcast.biz.user.dto.AdminUserSyncResponse" >
|
||||||
|
DELETE FROM M_MANAGER_SITE_ACCESS_USER
|
||||||
|
WHERE USER_ID = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="setAdminUserSyncSave" parameterType="com.interplug.qcast.biz.user.dto.AdminUserSyncResponse" >
|
||||||
|
/* sqlid : com.interplug.qcast.user.setAdminUserSyncSave */
|
||||||
|
MERGE INTO M_MANAGER_SITE_ACCESS_USER AS A
|
||||||
|
USING ( SELECT #{userId} AS USER_ID ) AS D
|
||||||
|
ON A.USER_ID = D.USER_ID
|
||||||
|
WHEN MATCHED THEN
|
||||||
|
UPDATE SET
|
||||||
|
COMPANY_NAME = #{companyName}
|
||||||
|
, CATEGORY = #{category}
|
||||||
|
, NAME = #{name}
|
||||||
|
, TEL = #{tel}
|
||||||
|
, FAX = #{fax}
|
||||||
|
, MAIL = #{mail}
|
||||||
|
, GROUP_ID = #{groupId}
|
||||||
|
WHEN NOT MATCHED THEN
|
||||||
|
INSERT (
|
||||||
|
USER_ID
|
||||||
|
, PASSWORD
|
||||||
|
, COMPANY_NAME
|
||||||
|
, CATEGORY
|
||||||
|
, NAME
|
||||||
|
, TEL
|
||||||
|
, FAX
|
||||||
|
, MAIL
|
||||||
|
, GROUP_ID
|
||||||
|
) VALUES (
|
||||||
|
#{userId}
|
||||||
|
, #{userId}
|
||||||
|
, #{companyName}
|
||||||
|
, #{category}
|
||||||
|
, #{name}
|
||||||
|
, #{tel}
|
||||||
|
, #{fax}
|
||||||
|
, #{mail}
|
||||||
|
, #{groupId}
|
||||||
|
);
|
||||||
|
</insert>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user