지역주민감면 전출 확인 스케쥴러 추가
parent
8f882fca22
commit
06bfb6c946
@ -0,0 +1,135 @@
|
||||
package cfs.schd;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cfs.common.service.CfsCommonService;
|
||||
import cfs.common.util.CallWebService;
|
||||
import cfs.common.util.StringUtil;
|
||||
import cfs.schd.dao.SchdDao;
|
||||
import cfs.trsmrcv.web.CarInfoSearch;
|
||||
|
||||
@Component("localResidentsCarInfo")
|
||||
public class LocalResidentsCarInfo {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource(name="schdDao")
|
||||
private SchdDao schdDao;
|
||||
|
||||
@Resource(name="cfsCommonService")
|
||||
private CfsCommonService cfsCommonService;
|
||||
|
||||
public void checkMovingOut(){
|
||||
this.checkMovingOut_lastDigit("");
|
||||
}
|
||||
|
||||
public void checkMovingOut_lastDigit(String lastDigit){
|
||||
|
||||
SimpleDateFormat sdf8 = (new SimpleDateFormat("yyyyMMdd"));
|
||||
SimpleDateFormat sdf14 = (new SimpleDateFormat("yyyyMMddHHmmss"));
|
||||
|
||||
|
||||
Date now = new Date();
|
||||
String levyStdde = sdf8.format(now);
|
||||
String procStrtDttm = sdf14.format(now);
|
||||
|
||||
Map<String, String> carNoFilter = new HashMap<String, String>();
|
||||
if(lastDigit != null && !lastDigit.equals("")){
|
||||
carNoFilter.put("digit", lastDigit);
|
||||
}
|
||||
Map<String, Object> target = schdDao.selectMovingOutCheckTarget(carNoFilter);
|
||||
if(target == null){
|
||||
return;
|
||||
}
|
||||
|
||||
String carNo = target.get("CAR_NO").toString();
|
||||
|
||||
boolean isMovingOut = false;
|
||||
|
||||
//연계
|
||||
try {
|
||||
Map<String, String> carSearchMap = new HashMap<String, String>();
|
||||
String sysId = cfsCommonService.findCommonSecureGet("sysId");
|
||||
carSearchMap.put("sysId", sysId);
|
||||
carSearchMap.put("tranDate", procStrtDttm);
|
||||
String transId = schdDao.selectCarConnectSeq("");
|
||||
carSearchMap.put("transId", transId);
|
||||
|
||||
carSearchMap.put("levyStdde", levyStdde);
|
||||
carSearchMap.put("inqireSeCode", "3");
|
||||
carSearchMap.put("vhrno", carNo);
|
||||
carSearchMap.put("vin", "");
|
||||
|
||||
String url = cfsCommonService.findCommonSecureGet("ITF_CFS_O_001");
|
||||
CallWebService callWebService = new CallWebService(url);
|
||||
Map<String, String> carSearchResultMap = callWebService.callWebServicePost(carSearchMap);
|
||||
|
||||
if(carSearchResultMap == null
|
||||
|| carSearchResultMap.get("result") == null
|
||||
|| carSearchResultMap.get("result").toString().equals("")
|
||||
|| carSearchResultMap.get("result").toString().equals("FAIL")) {
|
||||
target.put("PROC_STRT_DTTM", procStrtDttm);
|
||||
schdDao.updateCarSearchFail(target);
|
||||
return;
|
||||
}
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject jsonData = (JSONObject)parser.parse(carSearchResultMap.get("data").toString());
|
||||
Map<String, String> carSearchResultData = new HashMap<String,String>();
|
||||
CarInfoSearch.setData(carSearchResultData, jsonData);
|
||||
|
||||
if(StringUtil.nullToNull(carSearchResultData.get("mberSeCode")).equals("")
|
||||
|| StringUtil.nullToNull(carSearchResultData.get("ownerLegaldongCode")).equals("")){
|
||||
target.put("PROC_STRT_DTTM", procStrtDttm);
|
||||
schdDao.updateCarSearchFail(target);
|
||||
return;
|
||||
}
|
||||
|
||||
if(carSearchResultData.get("mberSeCode").equals("11")
|
||||
&& carSearchResultData.get("ownerLegaldongCode").startsWith("11140")) {
|
||||
|
||||
isMovingOut = false;
|
||||
|
||||
} else {
|
||||
isMovingOut = true;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
target.put("PROC_STRT_DTTM", procStrtDttm);
|
||||
schdDao.updateCarSearchFail(target);
|
||||
return;
|
||||
}
|
||||
|
||||
if(isMovingOut){
|
||||
//전출로 인한 삭제
|
||||
target.put("PROC_STRT_DTTM", procStrtDttm);
|
||||
target.put("APPLY_DATE", procStrtDttm);
|
||||
schdDao.deleteMovingOut(target);
|
||||
|
||||
//감면마스터에서 삭제(보류)
|
||||
//schdDao.deleteGammyeon(target);
|
||||
|
||||
} else {
|
||||
//적용일시 업데이트
|
||||
target.put("PROC_STRT_DTTM", procStrtDttm);
|
||||
target.put("APPLY_DATE", procStrtDttm);
|
||||
schdDao.updateApplyDate(target);
|
||||
|
||||
//감면마스터에 등록(보류)
|
||||
//schdDao.insertGammyeon(target);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
package cfs.schd.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import cfs.WASInfo;
|
||||
import cfs.schd.LocalResidentsCarInfo;
|
||||
import cfs.schd.dao.SchdDao;
|
||||
|
||||
@Component("cfsDaemon")
|
||||
public class CfsDaemon {
|
||||
|
||||
private List<MovingOutDaemonThread> movingOutDaemons;
|
||||
|
||||
@Resource(name="schdDao")
|
||||
private SchdDao schdDao;
|
||||
|
||||
@Resource(name="localResidentsCarInfo")
|
||||
private LocalResidentsCarInfo localResidentsCarInfo;
|
||||
|
||||
List<String> digits = Arrays.asList("0","1","2","3","4","5","6","7","8","9");
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
createThread();
|
||||
|
||||
}
|
||||
|
||||
public void createThread() {
|
||||
|
||||
movingOutDaemons = new ArrayList<MovingOutDaemonThread>();
|
||||
|
||||
for(String digit : digits){
|
||||
MovingOutDaemonThread daemon = new MovingOutDaemonThread(digit);
|
||||
daemon.setDaemon(true);
|
||||
movingOutDaemons.add(daemon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String startDaemon(String daemonName) {
|
||||
String result = "";
|
||||
|
||||
if(countDaemon(daemonName) != 0){
|
||||
killDaemon(daemonName);
|
||||
return "기존 실행 중인 데몬 종료 요청함";
|
||||
}
|
||||
|
||||
String runWAS = schdDao.selectRunWas(daemonName);
|
||||
|
||||
if(!WASInfo.getWAS().equals(runWAS)){
|
||||
return "미실행WAS";
|
||||
}
|
||||
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null || movingOutDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
} else {
|
||||
for(MovingOutDaemonThread demon : movingOutDaemons){
|
||||
if(Thread.State.NEW == demon.getState()){
|
||||
demon.start();
|
||||
} else {
|
||||
demon.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = "시작됨";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int countDaemon(String daemonName) {
|
||||
int i = 0;
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null){
|
||||
return 0;
|
||||
}
|
||||
for(MovingOutDaemonThread daemon : movingOutDaemons){
|
||||
if(daemon.isAlive()){
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String killDaemon(String daemonName) {
|
||||
String result = "";
|
||||
|
||||
if(daemonName.equals("MOVING_OUT")){
|
||||
if(movingOutDaemons == null || movingOutDaemons.isEmpty()){
|
||||
result = "쓰레드없음";
|
||||
return result;
|
||||
}
|
||||
|
||||
if(countDaemon(daemonName) == 0){
|
||||
result = "이미 종료됨";
|
||||
return result;
|
||||
}
|
||||
|
||||
for(MovingOutDaemonThread daemon : movingOutDaemons){
|
||||
daemon.interrupt();
|
||||
}
|
||||
result = "종료 요청 완료";
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 지역주민 차량 전출 확인 스레드
|
||||
*/
|
||||
class MovingOutDaemonThread extends Thread {
|
||||
|
||||
private String lastDigit = null;
|
||||
|
||||
public MovingOutDaemonThread(String lastDigit){
|
||||
super("MOVING_OUT"+lastDigit);
|
||||
this.lastDigit = lastDigit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
|
||||
while(true){
|
||||
|
||||
localResidentsCarInfo.checkMovingOut_lastDigit(lastDigit);
|
||||
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package cfs.schd.config;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import cfs.WASInfo;
|
||||
import cfs.schd.PrpCarInfo;
|
||||
import cfs.schd.dao.SchdDao;
|
||||
import cfs.trsmrcv.dao.TrsmrcvDao;
|
||||
|
||||
@EnableScheduling
|
||||
@Component
|
||||
public class CfsScheduleCron {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource(name="prpCarInfo")
|
||||
private PrpCarInfo prpCarInfo;
|
||||
|
||||
@Resource(name="trsmrcvDao")
|
||||
private TrsmrcvDao trsmrcvDao;
|
||||
|
||||
@Resource(name="schdDao")
|
||||
private SchdDao schdDao;
|
||||
|
||||
@Resource(name="cfsDaemon")
|
||||
private CfsDaemon cfsDaemon;
|
||||
|
||||
/**
|
||||
* 사전등록결제 변동분 스케쥴
|
||||
*/
|
||||
@Scheduled(cron = "12 */4 * * * *")
|
||||
public void prpChgScheduleRun() {
|
||||
|
||||
String runWAS = schdDao.selectRunWas("ITF_CFS_O_037");
|
||||
|
||||
if(!WASInfo.getWAS().equals(runWAS)){
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> susinInfo = new HashMap<String, String>();
|
||||
susinInfo.put("DATETIME", (new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())));
|
||||
susinInfo.put("RUN_WAS", WASInfo.getWAS());
|
||||
susinInfo.put("CALL_URI", "없음(schedule)");
|
||||
susinInfo.put("REQ_IP", "");
|
||||
trsmrcvDao.insertConnSusinLog(susinInfo);
|
||||
|
||||
prpCarInfo.updatePrpChg();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 지역주민 차량 전출 확인 프로세스 시작
|
||||
*/
|
||||
//@Scheduled(cron = "0 0 21 * * *")
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cfs.schd.config;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@EnableScheduling
|
||||
@Component
|
||||
public class CfsScheduleFixedDelaly {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue