package com.ggits.etlp.server.service; import com.ggits.etlp.server.common.Elapsed; import com.ggits.etlp.server.common.TimeUtils; import com.ggits.etlp.server.config.ApplicationConfig; import com.ggits.etlp.server.dao.mapper.BatchDaoService; import com.ggits.etlp.server.dao.mapper.ggits.GgitsMapper; import com.ggits.etlp.server.dao.mapper.sig.SigMapper; import com.ggits.etlp.server.dao.mapper.sig.batch.SigDao; import com.ggits.etlp.server.dto.EtlpInfo; import com.ggits.etlp.server.dto.RegionCenter; import com.ggits.etlp.server.entity.ggits.*; import com.ggits.etlp.server.entity.sig.TbGgitsEtlp; import com.ggits.etlp.server.entity.sig.TbInt; import com.ggits.etlp.server.repository.ApplicationRepository; import com.ggits.etlp.server.repository.EtlpConst; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @Slf4j @Getter @Service @RequiredArgsConstructor @Transactional(rollbackFor = {Exception.class}) public class GgitsEtlpService { private final ApplicationConfig config; private final ApplicationRepository repo; private final GgitsMapper gitsMapper; private final SigMapper sigMapper; private final SigDao dao; private final String[] etlpTables = { EtlpConst.etlpTableInt, EtlpConst.etlpTableFlow, EtlpConst.etlpTableOperPlan, EtlpConst.etlpTableDyPlan, EtlpConst.etlpTableResrvPlan, EtlpConst.etlpTableSignalMap }; private List centerList; @PostConstruct private void init() { log.info("GgitsEtlpService.init: start."); log.info("GgitsEtlpService.init: ..end."); } @PreDestroy public void destroyService() { log.error("GgitsEtlpService.destroy. system terminated......."); } private void initEtlp() { this.repo.loadDb(); this.centerList = new ArrayList<>(this.repo.getCenterMap().keySet()); Collections.sort(this.centerList); for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } center.setElapsed(0); center.initEtlp(); } for (String etlpTblNm : this.etlpTables) { List etlpList = this.sigMapper.selectGgitsEtlp(etlpTblNm); for (TbGgitsEtlp obj : etlpList) { RegionCenter center = this.repo.getCenterMap().get(obj.getRegionCd()); if (center != null) { center.updateEtlp(etlpTblNm, obj); } } } } public void run() { Elapsed elapsed = new Elapsed(); log.info("************************************************************************************************>"); log.info("GGITS DBASE ETLP TO SIG START."); initEtlp(); //교차로구성_연계, SCS_T_CON_INTLC etlpIntLc(); //교차로이동류_연계, SCS_T_CON_INTFLOW etlpIntFlow(); //교차로일계획_연계, SCS_T_CON_INTDPLAN etlpIntDPlan(); //교차로주간계획_연계, SCS_T_CON_INTWEEK etlpIntWeek(); //교차로예약계획_연계, SCS_T_CON_INTFPLAN etlpIntFPlan(); //교차로시그널맵_연계, SCS_T_CON_INTSIGMAP etlpIntSigmap(); log.info("GGITS DBASE ETLP TO SIG ..END. {}", elapsed.elapsedTimeStr()); log.info("<************************************************************************************************"); } private int getPageCount(int etlpCount) { int pageCount = (etlpCount / this.config.getPageCount()) + 1; if (0 == (etlpCount % this.config.getPageCount())) { pageCount--; } return pageCount; } private void updateEtlpResult(String tblName, List> etlpLists) { int result; Elapsed elapsed = new Elapsed(); try { result = this.dao.updateGgitsEtlp(etlpLists); log.info("updateGgitsEtlp: {}, {} EA, {}", tblName, result, elapsed.elapsedTimeStr()); } catch (Exception e) { log.error("updateGgitsEtlp: {}, {}, Exceptions: {}", tblName, etlpLists, e.getMessage()); } try { elapsed.reset(); if (this.config.isLoggingHist()) { result = this.dao.insertGgitsEtlpHist(etlpLists); log.info("insertGgitsEtlpHist: {}, {} EA, {}", tblName, result, elapsed.elapsedTimeStr()); } } catch (Exception e) { log.error("insertGgitsEtlpHist: {}, {}, Exceptions: {}", tblName, etlpLists, e.getMessage()); } } //교차로구성_연계, SCS_T_CON_INTLC private void etlpIntLc() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT, SCS_T_CON_INTLC START. ETLP: {}", this.config.isEtlpInt()); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int writeCount = 0; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpIntLc(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("================================================================================================>"); log.info("TB_INT, SCS_T_CON_INTLC START. {}, {}, {}, {}, ETLP: {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId(), this.config.isEtlpInt()); // this.sigMapper.initTbInt(center.getRegionCd()); HashMap intMap = new HashMap<>(); List intLists = this.sigMapper.selectTbInt(center.getRegionCd()); for (TbInt intInt : intLists) { intMap.put(intInt.getIntNo(), intInt); } Integer dataCount = this.gitsMapper.selectScsTConIntLcCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntLcCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT, SCS_T_CON_INTLC .READ. {}, {}, SIG: {} EA, GGITS: DATA({}) ETLP({}) EA. {}, ETLP: {}", center.getRegionCd(), center.getRegionNm(), intLists.size(), dataCount, etlpCount, job.elapsedTimeStr(), this.config.isEtlpInt()); if (etlpCount > 0) { List jobLists = this.gitsMapper.selectScsTConIntLc(center, etlp.getQryDt()); log.info("TB_INT, SCS_T_CON_INTLC .READ. {}, {}, SIG: {} EA, GGITS: {} EA. {}, ETLP: {}", center.getRegionCd(), center.getRegionNm(), intLists.size(), jobLists.size(), job.elapsedTimeStr(), this.config.isEtlpInt()); job.reset(); if (this.config.isEtlpInt()) { lists = new ArrayList<>(); for (TbScsTConIntLc obj : jobLists) { if (obj.getIntName() == null || obj.getIntName().isEmpty()) { TbInt orgInt = intMap.get(obj.getIntNo()); if (orgInt != null) { obj.setIntName(orgInt.getIntNm()); } if (obj.getIntName() == null || obj.getIntName().isEmpty()) { obj.setIntName("-"); } } HashMap param = obj.toSig(center.getRegionCd()); lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { writeCount += this.dao.updateTbInt(lists); lists = new ArrayList<>(); } } if (!lists.isEmpty()) { writeCount += this.dao.updateTbInt(lists); } } } etlp.endEtlp(true, writeCount); log.info("TB_INT, SCS_T_CON_INTLC WRITE. {}, {}, {} EA. {}, ETLP: {}", center.getRegionCd(), center.getRegionNm(), writeCount, elapsed.elapsedTimeStr(), this.config.isEtlpInt()); log.info("-------------------------------------------------------------------------------------------------"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT, SCS_T_CON_INTLC: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableInt)); } updateEtlpResult(EtlpConst.etlpTableInt, etlpLists); log.info("TB_INT, SCS_T_CON_INTLC ..END. {}, ETLP: {}", totElapsed.elapsedTimeStr(), this.config.isEtlpInt()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } //교차로이동류_연계, SCS_T_CON_INTFLOW private void etlpIntFlow() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW START."); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int invalidData = 0; int writeCount = 0; int currWriteCount; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpFlow(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW START. {}, {}, {}, {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId()); Integer dataCount = this.gitsMapper.selectScsTConIntFlowCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntFlowCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW .READ. {}, {}, DATA({}) ETLP({}) EA. {}", center.getRegionCd(), center.getRegionNm(), dataCount, etlpCount, job.elapsedTimeStr()); if (etlpCount > 0) { int pageCount = getPageCount(etlpCount); for (int ii = 0; ii < pageCount; ii++) { int fromSeq = (ii * this.config.getPageCount()); int toSeq = fromSeq + this.config.getPageCount(); fromSeq++; List result = this.gitsMapper.selectScsTConIntFlow(center, fromSeq, toSeq, etlp.getQryDt()); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW .READ. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, result.size()), job.elapsedTimeStr()); TimeUtils.sleep(500); job.reset(); lists = new ArrayList<>(); currWriteCount = 0; for(TbScsTConIntFlow obj: result) { HashMap param = obj.toSig(center.getRegionCd()); if (!param.isEmpty()) { lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { currWriteCount += this.dao.updateTbIntFlow(lists); lists = new ArrayList<>(); } } else { invalidData++; } } if (!lists.isEmpty()) { currWriteCount += this.dao.updateTbIntFlow(lists); } writeCount += currWriteCount; log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW WRITE. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, currWriteCount), job.elapsedTimeStr()); } } etlp.endEtlp(true, writeCount); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW WRITE. {}, {}, {} EA. Invalid Data {} EA. {}", center.getRegionCd(), center.getRegionNm(), writeCount, invalidData, elapsed.elapsedTimeStr()); log.info("-------------------------------------------------------------------------------------------------"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT_FLOW, SCS_T_CON_INTFLOW: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableFlow)); } updateEtlpResult(EtlpConst.etlpTableFlow, etlpLists); log.info("TB_INT_FLOW, SCS_T_CON_INTFLOW ..END. {}", totElapsed.elapsedTimeStr()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } //교차로일계획_연계, SCS_T_CON_INTDPLAN private void etlpIntDPlan() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN START."); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int writeCount = 0; int currWriteCount; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpOperPlan(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN START. {}, {}, {}, {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId()); Integer dataCount = this.gitsMapper.selectScsTConIntDPlanCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntDPlanCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN .READ. {}, {}, DATA({}) ETLP({}) EA. {}", center.getRegionCd(), center.getRegionNm(), dataCount, etlpCount, job.elapsedTimeStr()); if (etlpCount > 0) { int pageCount = getPageCount(etlpCount); for (int ii = 0; ii < pageCount; ii++) { int fromSeq = (ii * this.config.getPageCount()); int toSeq = fromSeq + this.config.getPageCount(); fromSeq++; List result = this.gitsMapper.selectScsTConIntDPlan(center, fromSeq, toSeq, etlp.getQryDt()); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN .READ. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, result.size()), job.elapsedTimeStr()); TimeUtils.sleep(500); job.reset(); lists = new ArrayList<>(); currWriteCount = 0; for(TbScsTConIntDPlan obj: result) { HashMap param = obj.toSig(center.getRegionCd()); lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { currWriteCount += this.dao.updateTbIntOperPlan(lists); lists = new ArrayList<>(); } } if (!lists.isEmpty()) { currWriteCount += this.dao.updateTbIntOperPlan(lists); } writeCount += currWriteCount; log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN WRITE. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, currWriteCount), job.elapsedTimeStr()); } } etlp.endEtlp(true, writeCount); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN WRITE. {}, {}, {} EA. {}", center.getRegionCd(), center.getRegionNm(), writeCount, elapsed.elapsedTimeStr()); log.info("-------------------------------------------------------------------------------------------------"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableOperPlan)); } updateEtlpResult(EtlpConst.etlpTableOperPlan, etlpLists); log.info("TB_INT_OPER_PLAN, SCS_T_CON_INTDPLAN ..END. {}", totElapsed.elapsedTimeStr()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } //교차로주간계획_연계, SCS_T_CON_INTWEEK private void etlpIntWeek() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK START."); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int writeCount = 0; int currWriteCount; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpDyPlan(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK START. {}, {}, {}, {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId()); Integer dataCount = this.gitsMapper.selectScsTConIntWeekCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntWeekCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK .READ. {}, {}, DATA({}) ETLP({}) EA. {}", center.getRegionCd(), center.getRegionNm(), dataCount, etlpCount, job.elapsedTimeStr()); if (etlpCount > 0) { int pageCount = getPageCount(etlpCount); for (int ii = 0; ii < pageCount; ii++) { int fromSeq = (ii * this.config.getPageCount()); int toSeq = fromSeq + this.config.getPageCount(); fromSeq++; List result = this.gitsMapper.selectScsTConIntWeek(center, fromSeq, toSeq, etlp.getQryDt()); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK .READ. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, result.size()), job.elapsedTimeStr()); TimeUtils.sleep(500); job.reset(); lists = new ArrayList<>(); currWriteCount = 0; for(TbScsTConIntWeek obj: result) { HashMap param = obj.toSig(center.getRegionCd()); lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { currWriteCount += this.dao.updateTbIntDyPlan(lists); lists = new ArrayList<>(); } } if (!lists.isEmpty()) { currWriteCount += this.dao.updateTbIntDyPlan(lists); } writeCount += currWriteCount; log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK WRITE. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, currWriteCount), job.elapsedTimeStr()); } } etlp.endEtlp(true, writeCount); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK WRITE. {}, {}, {} EA. {}", center.getRegionCd(), center.getRegionNm(), writeCount, elapsed.elapsedTimeStr()); log.info("-------------------------------------------------------------------------------------------------"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableDyPlan)); } updateEtlpResult(EtlpConst.etlpTableDyPlan, etlpLists); log.info("TB_INT_DY_PLAN, SCS_T_CON_INTWEEK ..END. {}", totElapsed.elapsedTimeStr()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } //교차로예약계획_연계, SCS_T_CON_INTFPLAN private void etlpIntFPlan() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN START."); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int writeCount = 0; int currWriteCount; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpResrvPlan(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN START. {}, {}, {}, {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId()); Integer dataCount = this.gitsMapper.selectScsTConIntFPlanCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntFPlanCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN .READ. {}, {}, DATA({}) ETLP({}) EA. {}", center.getRegionCd(), center.getRegionNm(), dataCount, etlpCount, job.elapsedTimeStr()); if (etlpCount > 0) { int pageCount = getPageCount(etlpCount); for (int ii = 0; ii < pageCount; ii++) { int fromSeq = (ii * this.config.getPageCount()); int toSeq = fromSeq + this.config.getPageCount(); fromSeq++; List result = this.gitsMapper.selectScsTConIntFPlan(center, fromSeq, toSeq, etlp.getQryDt()); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN .READ. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, result.size()), job.elapsedTimeStr()); TimeUtils.sleep(500); job.reset(); lists = new ArrayList<>(); currWriteCount = 0; for(TbScsTConIntFPlan obj: result) { HashMap param = obj.toSig(center.getRegionCd()); lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { currWriteCount += this.dao.updateTbIntResrvPlan(lists); lists = new ArrayList<>(); } } if (!lists.isEmpty()) { currWriteCount += this.dao.updateTbIntResrvPlan(lists); } writeCount += currWriteCount; log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN WRITE. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, currWriteCount), job.elapsedTimeStr()); } } etlp.endEtlp(true, writeCount); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN WRITE. {}, {}, {} EA. {}", center.getRegionCd(), center.getRegionNm(), writeCount, elapsed.elapsedTimeStr()); log.info("-------------------------------------------------------------------------------------------------"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableResrvPlan)); } updateEtlpResult(EtlpConst.etlpTableResrvPlan, etlpLists); log.info("TB_INT_RESRV_PLAN, SCS_T_CON_INTFPLAN ..END. {}", totElapsed.elapsedTimeStr()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } //교차로시그널맵_연계, SCS_T_CON_INTSIGMAP private void etlpIntSigmap() { log.info("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^>"); Elapsed elapsed = new Elapsed(); Elapsed totElapsed = new Elapsed(); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP START."); List> etlpLists = new ArrayList<>(); List> lists; for (String key : this.centerList) { RegionCenter center = this.repo.getCenterMap().get(key); if (center == null) { continue; } TimeUtils.sleep(500); elapsed.reset(); int writeCount = 0; int currWriteCount; Elapsed job = new Elapsed(); EtlpInfo etlp = center.getEtlpSigmap(); etlp.startEtlp(); try { MDC.put("id", center.getLogKey()); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP START. {}, {}, {}, {}", center.getRegionCd(), center.getRegionNm(), center.getMinNodeId(), center.getMaxNodeId()); Integer dataCount = this.gitsMapper.selectScsTConIntSigmapCount(center, EtlpConst.qryCountAll); Integer etlpCount = this.gitsMapper.selectScsTConIntSigmapCount(center, etlp.getQryDt()); etlp.setCount(dataCount, etlpCount); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP .READ. {}, {}, DATA({}) ETLP({}) EA. {}", center.getRegionCd(), center.getRegionNm(), dataCount, etlpCount, job.elapsedTimeStr()); if (etlpCount > 0) { int pageCount = getPageCount(etlpCount); for (int ii = 0; ii < pageCount; ii++) { int fromSeq = (ii * this.config.getPageCount()); int toSeq = fromSeq + this.config.getPageCount(); fromSeq++; List result = this.gitsMapper.selectScsTConIntSigmap(center, fromSeq, toSeq, etlp.getQryDt()); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP .READ. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, result.size()), job.elapsedTimeStr()); TimeUtils.sleep(500); job.reset(); lists = new ArrayList<>(); currWriteCount = 0; for(TbScsTConIntSigmap obj: result) { HashMap param = obj.toSig(center.getRegionCd()); lists.add(param); if (lists.size() >= BatchDaoService.MAX_BATCH_SIZE) { currWriteCount += this.dao.updateTbIntSignalMap(lists); lists = new ArrayList<>(); } } if (!lists.isEmpty()) { currWriteCount += this.dao.updateTbIntSignalMap(lists); } writeCount += currWriteCount; log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP WRITE. {}, {}, {}. {}", center.getRegionCd(), center.getRegionNm(), String.format("%6d ~ %6d, %6d EA", fromSeq, toSeq, currWriteCount), job.elapsedTimeStr()); } } etlp.endEtlp(true, writeCount); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP WRITE. {}, {}, {} EA. {}", center.getRegionCd(), center.getRegionNm(), writeCount, elapsed.elapsedTimeStr()); log.info("<================================================================================================"); } catch (Exception e) { etlp.endEtlp(false, writeCount); log.error("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP: {}, {}, Exceptions: {}", center.getRegionCd(), center.getRegionNm(), e.getMessage()); } finally { center.setElapsed(center.getElapsed() + elapsed.milliSeconds()); MDC.remove(center.getLogKey()); MDC.clear(); } etlpLists.add(etlp.toSig(center.getRegionCd(), EtlpConst.etlpTableSignalMap)); } updateEtlpResult(EtlpConst.etlpTableSignalMap, etlpLists); log.info("TB_INT_SIGNALMAP, SCS_T_CON_INTSIGMAP ..END. {}", totElapsed.elapsedTimeStr()); log.info("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } }