1. 스케쥴러 스레드와 웹 스레드 분리

2. 국가유공자,장애인 연계 프로세스 데몬으로 변경
main
이범준 6 months ago
parent 4bf4baf437
commit 560638e753

@ -1,6 +1,7 @@
package cfs.schd;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@ -147,20 +148,28 @@ public class ExemptCarInfo {
}
public void getRdcxptInfoNtttnVhcle() {
public boolean getRdcxptInfoNtttnVhcle() {
ResultSmartPlatform result = new ResultSmartPlatform();
try {
List<Map<String, Object>> dspsnList = new ArrayList<Map<String,Object>>();
String url = "";
try{
//국가유공자 데이터 추출
List<Map<String, Object>> dspsnList = commSmartPlatformPRPService.exemptNtttn();
dspsnList = commSmartPlatformPRPService.exemptNtttn();
if(dspsnList == null || dspsnList.size() == 0){
logger.info("getRdcxptInfoNtttnVhcle_조회 실패(국가유공자 목록 없음)");
logger.info("getRdcxptInfoNtttnVhcle_조회 실패(국가유공자 목록 없음)");
result.setMsg(ResultSmartPlatform.STATUS_ERROR, ResultSmartPlatform.STATUS_ERROR_MESSAGE);
return ;
return true;
}
url = cfsCommonService.findCommonSecureGet("ITF_FIS_O_012");
for(Map<String, Object> dspsn : dspsnList){
}catch(Exception e) {
return true;
}
for(Map<String, Object> dspsn : dspsnList){
try {
//파라미터 설정
Map<String, String> pMap = new HashMap<String, String>();
@ -169,8 +178,7 @@ public class ExemptCarInfo {
pMap.put("transId", dspsn.get("TRANS_ID").toString());
pMap.put("carNo", dspsn.get("CAR_NO").toString());
// 사전등록결제 웹서비스 호출
String url = cfsCommonService.findCommonSecureGet("ITF_FIS_O_012");
//국가유공자 웹서비스 호출
CallWebService callWebService = new CallWebService(url);
Map<String, String> map = callWebService.callWebServicePost(pMap);
@ -182,56 +190,61 @@ public class ExemptCarInfo {
logger.info("getRdcxptInfoDspsnVhcle_조회 실패");
result.setMsg(ResultSmartPlatform.STATUS_ERROR, ResultSmartPlatform.STATUS_ERROR_MESSAGE);
return ;
}else {
//성공 처리 Table Insert
JSONParser parser = new JSONParser();
JSONObject jsonParam = (JSONObject)parser.parse(map.get("data").toString());
System.out.println("=== " + jsonParam.toJSONString());
Map<String, String> jMap = jsonParam;
jMap.put("carNo", pMap.get("carNo"));
commSmartPlatformPRPService.updateExemptNtttn(jMap);
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
continue;
}
}
//성공 처리 Table Insert
JSONParser parser = new JSONParser();
JSONObject jsonParam = (JSONObject)parser.parse(map.get("data").toString());
System.out.println("=== " + jsonParam.toJSONString());
Map<String, String> jMap = jsonParam;
jMap.put("carNo", pMap.get("carNo"));
commSmartPlatformPRPService.updateExemptNtttn(jMap);
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
}catch(RuntimeException e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
} catch (Exception e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
}
}catch(RuntimeException e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
} catch (Exception e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
}
return ;
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
return false;
}
public void getRdcxptInfoDspsnVhcle() {
public boolean getRdcxptInfoDspsnVhcle() {
ResultSmartPlatform result = new ResultSmartPlatform();
List<Map<String, Object>> dspsnList = new ArrayList<>();
String url = "";
try {
//장애인 테스트 데이터 추출
List<Map<String, Object>> dspsnList = commSmartPlatformPRPService.exemptDspsn();
dspsnList = commSmartPlatformPRPService.exemptDspsn();
if(dspsnList == null || dspsnList.size() == 0){
logger.info("getRdcxptInfoDspsnVhcle_조회 실패(장애인 목록 없음)");
result.setMsg(ResultSmartPlatform.STATUS_ERROR, ResultSmartPlatform.STATUS_ERROR_MESSAGE);
return ;
return true;
}
for(Map<String, Object> dspsn : dspsnList){
url = cfsCommonService.findCommonSecureGet("ITF_CFS_O_013");
} catch (Exception e) {
return true;
}
for(Map<String, Object> dspsn : dspsnList){
try {
//파라미터 설정
Map<String, String> pMap = new HashMap<String, String>();
pMap.put("sysId", "11-006");
pMap.put("tranDate", dspsn.get("TRAN_DATE").toString());
@ -241,7 +254,7 @@ public class ExemptCarInfo {
pMap.put("incarDt", dspsn.get("TRAN_DATE").toString());
// 사전등록결제 웹서비스 호출
String url = cfsCommonService.findCommonSecureGet("ITF_CFS_O_013");
CallWebService callWebService = new CallWebService(url);
Map<String, String> map = callWebService.callWebServicePost(pMap);
@ -253,7 +266,7 @@ public class ExemptCarInfo {
logger.info("getRdcxptInfoDspsnVhcle_조회 실패");
result.setMsg(ResultSmartPlatform.STATUS_ERROR, ResultSmartPlatform.STATUS_ERROR_MESSAGE);
return ;
continue;
}
//성공 처리 Table Insert
@ -265,24 +278,21 @@ public class ExemptCarInfo {
Map<String, String> jMap = jsonParam;
commSmartPlatformPRPService.updateExemptDspsn(jMap);
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
}catch(RuntimeException e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
} catch (Exception e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
}
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
}catch(RuntimeException e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
} catch (Exception e) {
e.printStackTrace();
result.setErrorMsg(ResultSmartPlatform.STATUS_ERROR_DEFAULT_DETAIL_CODE, null);
}
return ;
result.setMsg(ResultSmartPlatform.STATUS_SUCESS, "정상적으로 처리되었습니다.");
return false;
}

@ -11,6 +11,7 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cfs.WASInfo;
import cfs.schd.ExemptCarInfo;
import cfs.schd.LocalResidentsCarInfo;
import cfs.schd.dao.SchdDao;
@ -18,6 +19,8 @@ import cfs.schd.dao.SchdDao;
public class CfsDaemon {
private List<MovingOutDaemonThread> movingOutDaemons;
private List<NtttnDaemonThread> ntttnDaemons;
private List<DspsnDaemonThread> dspsnDaemons;
@Resource(name="schdDao")
private SchdDao schdDao;
@ -25,6 +28,9 @@ public class CfsDaemon {
@Resource(name="localResidentsCarInfo")
private LocalResidentsCarInfo localResidentsCarInfo;
@Resource(name="exemptCarInfo")
private ExemptCarInfo exemptCarInfo;
List<String> digits = Arrays.asList("0","1","2","3","4","5","6","7","8","9");
@PostConstruct
@ -41,18 +47,41 @@ public class CfsDaemon {
daemon.interrupt();
}
}
for(NtttnDaemonThread daemon : ntttnDaemons){
if(!daemon.isInterrupted()){
daemon.interrupt();
}
}
for(DspsnDaemonThread daemon : dspsnDaemons){
if(!daemon.isInterrupted()){
daemon.interrupt();
}
}
}
public void createThread() {
movingOutDaemons = new ArrayList<MovingOutDaemonThread>();
for(String digit : digits){
MovingOutDaemonThread daemon = new MovingOutDaemonThread(digit);
daemon.setDaemon(true);
movingOutDaemons.add(daemon);
}
ntttnDaemons = new ArrayList<NtttnDaemonThread>();
for(int i=0; i<1; i++){
NtttnDaemonThread daemon = new NtttnDaemonThread();
daemon.setDaemon(true);
ntttnDaemons.add(daemon);
}
dspsnDaemons = new ArrayList<DspsnDaemonThread>();
for(int i=0; i<1; i++){
DspsnDaemonThread daemon = new DspsnDaemonThread();
daemon.setDaemon(true);
dspsnDaemons.add(daemon);
}
}
public String startDaemon(String daemonName) {
@ -83,6 +112,34 @@ public class CfsDaemon {
}
}
result = "시작됨";
} else if(daemonName.equals("getRdcxptInfoNtttnVhcle")){
if(ntttnDaemons == null || ntttnDaemons.isEmpty()){
result = "쓰레드없음";
} else {
for(NtttnDaemonThread demon : ntttnDaemons){
if(Thread.State.NEW == demon.getState()){
demon.start();
} else {
demon.run();
}
}
}
result = "시작됨";
} else if(daemonName.equals("getRdcxptInfoDspsnVhcle")){
if(dspsnDaemons == null || dspsnDaemons.isEmpty()){
result = "쓰레드없음";
} else {
for(DspsnDaemonThread demon : dspsnDaemons){
if(Thread.State.NEW == demon.getState()){
demon.start();
} else {
demon.run();
}
}
}
result = "시작됨";
}
@ -103,7 +160,28 @@ public class CfsDaemon {
}
return i;
} else if(daemonName.equals("getRdcxptInfoNtttnVhcle")){
if(ntttnDaemons == null){
return 0;
}
for(NtttnDaemonThread daemon : ntttnDaemons){
if(daemon.isAlive()){
i++;
}
}
return i;
} else if(daemonName.equals("getRdcxptInfoDspsnVhcle")){
if(dspsnDaemons == null){
return 0;
}
for(DspsnDaemonThread daemon : dspsnDaemons){
if(daemon.isAlive()){
i++;
}
}
return i;
}
return 0;
}
@ -127,6 +205,38 @@ public class CfsDaemon {
result = "종료 요청 완료";
return result;
} else if(daemonName.equals("getRdcxptInfoNtttnVhcle")){
if(ntttnDaemons == null || ntttnDaemons.isEmpty()){
result = "쓰레드없음";
return result;
}
if(countDaemon(daemonName) == 0){
result = "이미 종료됨";
return result;
}
for(NtttnDaemonThread daemon : ntttnDaemons){
daemon.interrupt();
}
result = "종료 요청 완료";
return result;
} else if(daemonName.equals("getRdcxptInfoDspsnVhcle")){
if(dspsnDaemons == null || dspsnDaemons.isEmpty()){
result = "쓰레드없음";
return result;
}
if(countDaemon(daemonName) == 0){
result = "이미 종료됨";
return result;
}
for(DspsnDaemonThread daemon : dspsnDaemons){
daemon.interrupt();
}
result = "종료 요청 완료";
return result;
}
return result;
@ -163,4 +273,53 @@ public class CfsDaemon {
}
}
class NtttnDaemonThread extends Thread {
public NtttnDaemonThread(){
super("getRdcxptInfoNtttnVhcle");
}
@Override
public void run(){
while(true){
boolean end = exemptCarInfo.getRdcxptInfoNtttnVhcle();
if(end){
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
}
}
class DspsnDaemonThread extends Thread {
public DspsnDaemonThread(){
super("getRdcxptInfoDspsnVhcle");
}
@Override
public void run(){
while(true){
boolean end = exemptCarInfo.getRdcxptInfoDspsnVhcle();
if(end){
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
}
}
}

@ -1,6 +1,7 @@
package cfs.schd.config;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -38,9 +39,9 @@ public class CfsScheduleCron {
private CfsDaemon cfsDaemon;
/**
*
* 4
*/
@Scheduled(cron = "12 */4 * * * *")
//@Scheduled(cron = "12 */4 * * * *")
public void prpChgScheduleRun() {
String runWAS = schdDao.selectRunWas("ITF_CFS_O_037");
@ -54,79 +55,83 @@ public class CfsScheduleCron {
}
/**
*
* 1
*/
@Scheduled(cron = "0 0 2 * * *")
public void localResidentsMovingOutScheduleStart() {
//@Scheduled(cron = "0 0 * * * *")
public void getMultiChildFamilyScheduleRun() {
String runWAS = schdDao.selectRunWas("MOVING_OUT");
String runWAS = schdDao.selectRunWas("ITF_BRS_I_024");
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
cfsDaemon.startDaemon("MOVING_OUT");
exemptCarInfo.getMultiChildFamily();
exemptCarInfo.applyMultiChildFamily();
}
/**
*
*
*/
@Scheduled(cron = "0 0 7 * * *")
//@Scheduled(cron = "0 0 2 * * *")
public void localResidentsMovingOutScheduleStart() {
String runWAS = schdDao.selectRunWas("MOVING_OUT");
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
cfsDaemon.startDaemon("MOVING_OUT");
}
//@Scheduled(cron = "0 0 7 * * *")
public void localResidentsMovingOutScheduleStop() {
cfsDaemon.killDaemon("MOVING_OUT");
}
/**
*
*
*/
@Scheduled(cron = "0 0 * * * *")
public void getMultiChildFamilyScheduleRun() {
//@Scheduled(cron = "0 0 21 * * *")
public void getRdcxptInfoNtttnVhcleScheduleStart() {
String runWAS = schdDao.selectRunWas("ITF_BRS_I_024");
String runWAS = schdDao.selectRunWas("getRdcxptInfoNtttnVhcle");
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
exemptCarInfo.getMultiChildFamily();
cfsDaemon.startDaemon("getRdcxptInfoNtttnVhcle");
}
/**
*
*/
@Scheduled(cron = "0 30 * * * *")
public void applyMultiChildFamilyScheduleRun() {
//@Scheduled(cron = "0 55 21 * * *")
public void getRdcxptInfoNtttnVhcleScheduleEnd() {
String runWAS = schdDao.selectRunWas("ITF_BRS_I_024.5");
String runWAS = schdDao.selectRunWas("getRdcxptInfoNtttnVhcle");
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
exemptCarInfo.applyMultiChildFamily();
cfsDaemon.killDaemon("getRdcxptInfoNtttnVhcle");
}
/**
*
*
*/
@Scheduled(cron = "0 */5 21 * * *")
public void getRdcxptInfoNtttnVhcleScheduleRun() {
//@Scheduled(cron = "0 0 0 * * *")
public void getRdcxptInfoDspsnVhcleScheduleStart() {
String runWAS = schdDao.selectRunWas("getRdcxptInfoNtttnVhcle");
String runWAS = schdDao.selectRunWas("getRdcxptInfoDspsnVhcle");
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
exemptCarInfo.getRdcxptInfoNtttnVhcle();
cfsDaemon.startDaemon("getRdcxptInfoDspsnVhcle");
}
/**
*
*/
@Scheduled(cron = "0 */5 7 * * *")
public void getRdcxptInfoDspsnVhcleScheduleRun() {
//@Scheduled(cron = "0 55 7 * * *")
public void getRdcxptInfoDspsnVhcleScheduleEnd() {
String runWAS = schdDao.selectRunWas("getRdcxptInfoDspsnVhcle");
@ -134,13 +139,13 @@ public class CfsScheduleCron {
return;
}
exemptCarInfo.getRdcxptInfoDspsnVhcle();
cfsDaemon.killDaemon("getRdcxptInfoDspsnVhcle");
}
/**
* ,,
*/
@Scheduled(cron = "5 0 0 * * *")
//@Scheduled(cron = "5 0 0 * * *")
public void makeMasterScheduleRun() {
String runWAS = schdDao.selectRunWas("makeMaster");

@ -0,0 +1,20 @@
package cfs.schd.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@Configuration
public class SchedulingConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
ThreadPoolTaskScheduler tpts = new ThreadPoolTaskScheduler();
tpts.setThreadNamePrefix("scheduled-thread-");
tpts.setPoolSize(1);
tpts.initialize();
scheduledTaskRegistrar.setTaskScheduler(tpts);
}
}

@ -1,5 +1,6 @@
package cfs.trsmrcv.dao;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
@ -37,5 +38,4 @@ public interface TrsmrcvDao {
public String findPrprepayCnt(WorkerFareAdjustVO workerFareAdjustVO);
}

@ -2,6 +2,7 @@ package cfs.trsmrcv.web;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -21,12 +22,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cfs.WASInfo;
import cfs.common.service.CfsCommonService;
import cfs.common.util.CallWebService;
import cfs.common.util.ResultSmartPlatform;
import cfs.common.util.StringUtil;
import cfs.fine.service.FinePenaltyService;
import cfs.fine.service.impl.FinePenaltyServiceImpl;
import cfs.schd.config.CfsDaemon;
import cfs.schd.dao.SchdDao;
import cfs.trsmrcv.dao.TrsmrcvDao;
@ -44,14 +40,10 @@ public class TrsmrcvController {
@Resource(name="cfsDaemon")
private CfsDaemon cfsDaemon;
@Resource(name="cfsCommonService")
private CfsCommonService cfsCommonService;
@Resource(name="finePenaltyService")
private FinePenaltyService finePenaltyService;
@RequestMapping(value="/cfs/trsmrcv/sleep.do", method=RequestMethod.GET)
public @ResponseBody Map<String, Object> sleep(HttpServletRequest request) throws Exception {
TrsmrcvUtil.printRequestHeader(request);

Loading…
Cancel
Save