배치 QSP에서 수동으로 실행시킬 때 리턴 타입 변경
This commit is contained in:
parent
e8967aa333
commit
72aeafd138
@ -1,9 +1,12 @@
|
||||
package com.interplug.qcast.batch;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.JobParametersInvalidException;
|
||||
@ -16,6 +19,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ -38,26 +42,41 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@GetMapping("/batch/job/{jobName}") // Path Variable로 jobName을 받음
|
||||
public String launchJob(@PathVariable String jobName)
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public Map<String, Object> launchJob(@PathVariable String jobName)
|
||||
throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException, JobRestartException {
|
||||
|
||||
Job job = jobs.get(jobName);
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
if (job == null) {
|
||||
return "Job " + jobName + " not found";
|
||||
// return "Job " + jobName + " not found";
|
||||
resultMap.put("code", "FAILED");
|
||||
resultMap.put("message", "Job" + jobName + " not found");
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder()
|
||||
.addString("jobName", jobName)
|
||||
.addDate("time", new Date())
|
||||
.toJobParameters();
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("jobName", jobName)
|
||||
.addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
|
||||
|
||||
return "Job " + jobName + " started";
|
||||
|
||||
|
||||
BatchStatus status = jobExecution.getStatus();
|
||||
ExitStatus exitStatus = jobExecution.getExitStatus();
|
||||
|
||||
if ("COMPLETED".equals(status.toString())) {
|
||||
resultMap.put("code", status.toString());
|
||||
resultMap.put("message", exitStatus.getExitDescription());
|
||||
|
||||
} else {
|
||||
resultMap.put("code", status.toString());
|
||||
resultMap.put("message", exitStatus.getExitDescription());
|
||||
}
|
||||
|
||||
|
||||
// return "Job " + jobName + " started";
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,11 +90,8 @@ public class JobLauncherController {
|
||||
*/
|
||||
// @Scheduled(cron = "*/5 * * * * *")
|
||||
@Scheduled(cron = "0 55 23 * * *")
|
||||
public String storeAdditionalInfoJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String storeAdditionalInfoJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "storeAdditionalJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -101,11 +117,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 30 02 * * *")
|
||||
public String materialJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String materialJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "materialJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -132,11 +145,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 40 02 * * *")
|
||||
public String bomJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String bomJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "bomJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -164,11 +174,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 40 03 * * *")
|
||||
public String businessChargerJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String businessChargerJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "businessChargerJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -196,11 +203,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 01 * * *")
|
||||
public String adminUserJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String adminUserJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "adminUserJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -228,11 +232,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String priceJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String priceJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "priceJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -260,11 +261,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 10 03 * * *")
|
||||
public String commonCodeJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String commonCodeJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "commonCodeJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -291,11 +289,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 30 23 * * *")
|
||||
public String specialNoteDispItemAdditionalInfoJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String specialNoteDispItemAdditionalInfoJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
String jobName = "specialNoteDispItemAdditionalJob";
|
||||
Job job = jobs.get(jobName);
|
||||
if (job == null) {
|
||||
@ -322,11 +317,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "1 0 0 * * *")
|
||||
public String planConfirmJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String planConfirmJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "planConfirmJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -354,11 +346,8 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "1 20 0 * * *")
|
||||
public String estimateSyncJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
public String estimateSyncJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "estimateSyncJob";
|
||||
Job job = jobs.get(jobName);
|
||||
|
||||
@ -71,16 +71,12 @@ public class CommCodeService {
|
||||
public void setHeaderCodeSyncSave(List<HeadCodeRequest> headCodeList) throws Exception {
|
||||
// 헤더코드 동기화
|
||||
for (HeadCodeRequest headCodeReq : headCodeList) {
|
||||
try {
|
||||
if ("Y".equals(headCodeReq.getQcCommYn()) && "N".equals(headCodeReq.getDelYn())) {
|
||||
headCodeReq.setDelFlg(0);
|
||||
} else {
|
||||
headCodeReq.setDelFlg(1);
|
||||
}
|
||||
commCodeMapper.setHeadCodeSyncSave(headCodeReq);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
if ("Y".equals(headCodeReq.getQcCommYn()) && "N".equals(headCodeReq.getDelYn())) {
|
||||
headCodeReq.setDelFlg(0);
|
||||
} else {
|
||||
headCodeReq.setDelFlg(1);
|
||||
}
|
||||
commCodeMapper.setHeadCodeSyncSave(headCodeReq);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,16 +89,12 @@ public class CommCodeService {
|
||||
public void setCommonCodeSyncSave(List<DetailCodeRequest> detailCodeList) throws Exception {
|
||||
// 상세코드 동기화
|
||||
for (DetailCodeRequest detailCodeReq : detailCodeList) {
|
||||
try {
|
||||
if ("A".equals(detailCodeReq.getStatCd()) && "N".equals(detailCodeReq.getDelYn())) {
|
||||
detailCodeReq.setDelFlg(0);
|
||||
} else {
|
||||
detailCodeReq.setDelFlg(1);
|
||||
}
|
||||
commCodeMapper.setCommonCodeSyncSave(detailCodeReq);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
if ("A".equals(detailCodeReq.getStatCd()) && "N".equals(detailCodeReq.getDelYn())) {
|
||||
detailCodeReq.setDelFlg(0);
|
||||
} else {
|
||||
detailCodeReq.setDelFlg(1);
|
||||
}
|
||||
commCodeMapper.setCommonCodeSyncSave(detailCodeReq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user