123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- 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<String> 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<TbGgitsEtlp> 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<HashMap<String, Object>> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<Integer, TbInt> intMap = new HashMap<>();
- List<TbInt> 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<TbScsTConIntLc> 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<String, Object> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<TbScsTConIntFlow> 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<String, Object> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<TbScsTConIntDPlan> 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<String, Object> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<TbScsTConIntWeek> 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<String, Object> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<TbScsTConIntFPlan> 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<String, Object> 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<HashMap<String, Object>> etlpLists = new ArrayList<>();
- List<HashMap<String, Object>> 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<TbScsTConIntSigmap> 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<String, Object> 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("<^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
- }
- }
|