Java tutorial
/* * Copyright 2010 MOPAS(Ministry of Public Administration and Security). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package egovframework.oe1.cms.sys.service.impl; import java.util.List; import java.util.StringTokenizer; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ApplicationObjectSupport; import org.springframework.stereotype.Service; import egovframework.oe1.cms.sys.service.EgovOe1ConsentCallbackService; import egovframework.oe1.cms.sys.service.EgovOe1ConsentManageService; import egovframework.oe1.cms.sys.service.EgovOe1SanctionConsentVO; import egovframework.oe1.cms.sys.service.EgovOe1SanctionSubmitVO; import egovframework.rte.fdl.idgnr.EgovIdGnrService; import egovframework.rte.fdl.string.EgovDateUtil; import egovframework.rte.fdl.string.EgovStringUtil; import egovframework.rte.psl.dataaccess.util.EgovMap; /** * ?? ? * @author ?1 * @since 2010.07.20 * @version 1.0 * @see <pre> * << ?(Modification Information) >> * * ? ? * ------- -------- --------------------------- * 2010.07.20 ? * * Copyright (C) 2009 by MOPAS All right reserved. * </pre> */ @Service("consentService") public class EgovOe1ConsentManageServiceImpl extends ApplicationObjectSupport implements EgovOe1ConsentManageService { // Log Log log = LogFactory.getLog(this.getClass()); /** consentDAO */ @Resource(name = "consentDAO") private EgovOe1ConsentManageDAO consentManageDAO; /** ID Generation */ @Resource(name = "egovConsentIdGnrService") private EgovIdGnrService egovIdGnrService; /** * ? - ? * @param submitVO * ?? * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#actionSanctionDrafting(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public String actionSanctionDrafting(EgovOe1SanctionSubmitVO submitVO) throws Exception { String drftSn = egovIdGnrService.getNextStringId(); log.debug(this.getClass() + " actionSanctionDrafting() submitVO : " + submitVO.toString()); String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); submitVO.setDrftDt(currentDate); submitVO.setDrftSn(drftSn); consentManageDAO.insertSanctionDraftWriting(submitVO); // ? Table? log.debug(this.getClass() + submitVO.getSanctnRouteId()); StringTokenizer stRouteId = new StringTokenizer(submitVO.getSanctnRouteId(), "|"); int routeIdCnt = stRouteId.countTokens(); String receiver[] = new String[routeIdCnt]; for (int i = 0; stRouteId.hasMoreTokens(); i++) receiver[i] = stRouteId.nextToken(); StringTokenizer stRouteSeCode = new StringTokenizer(submitVO.getSanctnRouteSeCode(), "|"); int routeSeCodeCnt = stRouteSeCode.countTokens(); String aprvlGb[] = new String[routeSeCodeCnt]; for (int i = 0; stRouteSeCode.hasMoreTokens(); i++) aprvlGb[i] = stRouteSeCode.nextToken(); log.debug(this.getClass() + " routeIdCnt is " + routeIdCnt); boolean firstConfirm = false; for (int i = 0; i < routeIdCnt; i++) { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setDrftSn(drftSn); sanctionConsentVO.setConfmOrdr(i + 1); if (aprvlGb[i].equals("1")) { // sanctionConsentVO.setDrftDt(currentDate); // sanctionConsentVO.setConfmDt(currentDate); // ? sanctionConsentVO.setConfmOpinion(submitVO.getDrftOpinion()); sanctionConsentVO.setSanctnTrgtYn("N"); } else if (aprvlGb[i].equals("2")) { if (!firstConfirm) { firstConfirm = true; sanctionConsentVO.setDrftDt(currentDate); sanctionConsentVO.setSanctnTrgtYn("Y"); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmResultCode(""); sanctionConsentVO.setConfmer(receiver[i]); sanctionConsentVO.setConfmSeCode(aprvlGb[i]); sanctionConsentVO.setConfmComptYn("N"); sanctionConsentVO.setDeleteYn("N"); sanctionConsentVO.setAtchFileId(""); consentManageDAO.insertSanctionConsent(sanctionConsentVO); } // Callback Method try { /* * ApplicationContext ctx = new * ClassPathXmlApplicationContext(new * String[] * {"egovframework/spring/context-*.xml"}); */ ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.draftingConsent(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } return String.valueOf(drftSn); } /** * ? - * @param submitVO * ?? * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#actionSanctionDraftingUpdt(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public String actionSanctionDraftingUpdt(EgovOe1SanctionSubmitVO submitVO) throws Exception { String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); submitVO.setDrftDt(currentDate); int resultUpdateSanctionDraftWriting = consentManageDAO.updateSanctionDraftWriting(submitVO); int resultdeleteSanctionConsent = consentManageDAO.deleteSanctionConsent(submitVO.getDrftSn()); log.debug(this.getClass() + " resultUpdateSanctionDraftWriting : " + resultUpdateSanctionDraftWriting); log.debug(this.getClass() + " resultdeleteSanctionConsent : " + resultdeleteSanctionConsent); // ? Table? log.debug(this.getClass() + " submitVO.getSanctnRouteId() : " + submitVO.getSanctnRouteId()); StringTokenizer stRouteId = new StringTokenizer(submitVO.getSanctnRouteId(), "|"); int routeIdCnt = stRouteId.countTokens(); String receiver[] = new String[routeIdCnt]; for (int i = 0; stRouteId.hasMoreTokens(); i++) receiver[i] = stRouteId.nextToken(); StringTokenizer stRouteSeCode = new StringTokenizer(submitVO.getSanctnRouteSeCode(), "|"); int routeSeCodeCnt = stRouteSeCode.countTokens(); String aprvlGb[] = new String[routeSeCodeCnt]; for (int i = 0; stRouteSeCode.hasMoreTokens(); i++) aprvlGb[i] = stRouteSeCode.nextToken(); log.debug(this.getClass() + " routeIdCnt : " + routeIdCnt); boolean firstConfirm = false; for (int i = 0; i < routeIdCnt; i++) { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setDrftSn(submitVO.getDrftSn()); sanctionConsentVO.setConfmOrdr(i + 1); if (aprvlGb[i].equals("1")) { // sanctionConsentVO.setDrftDt(currentDate); // sanctionConsentVO.setConfmDt(currentDate); // ? sanctionConsentVO.setConfmOpinion(submitVO.getDrftOpinion()); sanctionConsentVO.setSanctnTrgtYn("N"); } else if (aprvlGb[i].equals("2")) { if (!firstConfirm) { firstConfirm = true; sanctionConsentVO.setDrftDt(currentDate); sanctionConsentVO.setSanctnTrgtYn("Y"); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmResultCode(""); sanctionConsentVO.setConfmer(receiver[i]); sanctionConsentVO.setConfmSeCode(aprvlGb[i]); sanctionConsentVO.setConfmComptYn("N"); sanctionConsentVO.setDeleteYn("N"); sanctionConsentVO.setAtchFileId(""); consentManageDAO.insertSanctionConsent(sanctionConsentVO); } // Callback Method try { /* * EgovConsentCallbackService * callbackService = * (EgovConsentCallbackService) * EgovObjectUtil * .instantiate(submitVO.getJobClass()); */ ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.draftingConsent(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } return String.valueOf(submitVO.getDrftSn()); } /** * ? - ? ? ?// ? * . * @param drftSn * ?? * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionCourseList(java.lang.Integer) */ public List<EgovMap> selectSanctionCourseList(String drftSn) throws Exception { return consentManageDAO.selectSanctionCourseList(drftSn); } /** * ? - * @param submitVO * (drftSn:??) * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionRouteList(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public List<EgovMap> selectSanctionRouteList(EgovOe1SanctionSubmitVO submitVO) throws Exception { return consentManageDAO.selectSanctionRouteList(submitVO); } /** * ? - ? ? ? : ? . * @param mberNm * ? * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectGeneralMemberList(java.lang.String) */ public List<EgovMap> selectGeneralMemberList(String mberNm) throws Exception { return consentManageDAO.selectGeneralMemberList(mberNm); } /** * ? - ? ? ?? . * @param submitVO * VO * @return ?? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSubmitList(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public List<EgovMap> selectSubmitList(EgovOe1SanctionSubmitVO submitVO) throws Exception { return consentManageDAO.selectSubmitList(submitVO); } /** * ? - ? ? * @param searchVO * VO * @return ?? ? * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSubmitListTotCnt(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public int selectSubmitListTotCnt(EgovOe1SanctionSubmitVO submitVO) { return consentManageDAO.selectSubmitListTotCnt(submitVO); } /** * ? - ? ? ? . * @param submitVO * VO * @return ? ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionSubmit(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public EgovOe1SanctionSubmitVO selectSanctionSubmit(EgovOe1SanctionSubmitVO submitVO) throws Exception { EgovOe1SanctionSubmitVO resultVO = consentManageDAO.selectSanctionSubmit(submitVO); return resultVO; } /** * ? - ? ? . * @param submitVO * VO * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#updateSanctionDraftingDelete(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public int updateSanctionDraftingDelete(EgovOe1SanctionSubmitVO submitVO) throws Exception { return consentManageDAO.updateSanctionDraftingDelete(submitVO); } /** * - ? ?? . * @param consentVO * VO * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionConfirmList(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public List<EgovMap> selectSanctionConfirmList(EgovOe1SanctionConsentVO consentVO) throws Exception { return consentManageDAO.selectSanctionConfirmList(consentVO); } /** * - ? ? * @param consentVO * VO * @return * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionConfirmListTotCnt(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public int selectSanctionConfirmListTotCnt(EgovOe1SanctionConsentVO consentVO) { return consentManageDAO.selectSanctionConfirmListTotCnt(consentVO); } /** * - ? ? . * @param consentVO * VO * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionConfirm(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public EgovOe1SanctionSubmitVO selectSanctionConfirm(EgovOe1SanctionSubmitVO submitVO) throws Exception { EgovOe1SanctionSubmitVO resultVO = consentManageDAO.selectSanctionConfirm(submitVO); // ? ?? ?/ ? ? // . String apSttus = consentManageDAO.selectSanctionStatus(resultVO); resultVO.setApSttus(apSttus); log.debug(this.getClass() + " selectSanctionConfirm()"); return resultVO; } /** * - ? . * @param consentVO * VO * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#updateSanctionConfirmDelete(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public int updateSanctionConfirmDelete(EgovOe1SanctionSubmitVO submitVO) throws Exception { return consentManageDAO.updateSanctionConfirmDelete(submitVO); } /** * - ? ?? . * @param consentVO * VO * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionDispatchList(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public List<EgovMap> selectSanctionDispatchList(EgovOe1SanctionConsentVO consentVO) throws Exception { return consentManageDAO.selectSanctionDispatchList(consentVO); } /** * ?? ? . * @param consentVO * VO * @return * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionDispatchListTotCnt(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public int selectSanctionDispatchListTotCnt(EgovOe1SanctionConsentVO consentVO) { return consentManageDAO.selectSanctionDispatchListTotCnt(consentVO); } /** * - ? ? . * @param consentVO * VO * @return * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#selectSanctionDispatch(egovframework.mgt.cmm.consent.service.SanctionConsentVO) */ public EgovOe1SanctionSubmitVO selectSanctionDispatch(EgovOe1SanctionSubmitVO submitVO) throws Exception { EgovOe1SanctionSubmitVO resultVO = consentManageDAO.selectSanctionDispatch(submitVO); log.debug(this.getClass() + " selectSanctionDispatch()"); return resultVO; } /** * ? ? ? ? ? . ?? * ? callback . * @param submitVO * ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#confirmSanctionSubmit(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public void confirmSanctionSubmit(EgovOe1SanctionConsentVO consentVO) throws Exception { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setConfmResultCode("1"); sanctionConsentVO.setDrftSn(consentVO.getDrftSn()); sanctionConsentVO.setConfmOrdr(consentVO.getConfmOrdr()); sanctionConsentVO.setConfmOpinion(consentVO.getConfmOpinion()); String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); sanctionConsentVO.setConfmDt(currentDate); sanctionConsentVO.setDrftDt(currentDate); int result = consentManageDAO.updateSanctionConfirmReturn(sanctionConsentVO); String nextAprvlMemberSeq = consentManageDAO.selectNextConfirmMemberSeq(sanctionConsentVO.getDrftSn()); String nextAprvlMember = consentManageDAO.selectNextConfirmMember(sanctionConsentVO.getDrftSn()); // ?? (? ? ? ) if (EgovStringUtil.isEmpty(nextAprvlMemberSeq)) { consentManageDAO.updateSanctionConfirmComplete(sanctionConsentVO); consentManageDAO.updateSanctionDispatchTime(sanctionConsentVO); // MASTER TABLE(?) EgovOe1SanctionSubmitVO sanctionSubmitVO = new EgovOe1SanctionSubmitVO(); sanctionSubmitVO.setDrftSttusCode("2"); // sanctionSubmitVO.setDrftSn(sanctionConsentVO.getDrftSn()); int resultStatusCode = consentManageDAO.updateDraftingStatusCode(sanctionSubmitVO); log.debug(this.getClass() + " resultStatusCode : " + resultStatusCode); } else { // ? sanctionConsentVO.setConfmOrdr(Integer.valueOf(nextAprvlMemberSeq)); consentManageDAO.updateNextTargetSet(sanctionConsentVO); } } /** * ? ? . ?? * callback . * @param submitVO * * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#returnSanctionSubmit(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public void returnSanctionSubmit(EgovOe1SanctionSubmitVO submitVO) throws Exception { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setConfmResultCode("2"); sanctionConsentVO.setDrftSn(submitVO.getDrftSn()); sanctionConsentVO.setConfmOrdr(submitVO.getConfmOrdr()); sanctionConsentVO.setConfmOpinion(submitVO.getConfmOpinion()); String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); sanctionConsentVO.setConfmDt(currentDate); sanctionConsentVO.setDrftDt(currentDate); submitVO.setDrftSttusCode("3"); // submitVO.setDrftSn(sanctionConsentVO.getDrftSn()); consentManageDAO.updateDraftingStatusCode(submitVO); int returnResult = consentManageDAO.updateSanctionConfirmReturn(sanctionConsentVO); int saveComplete = consentManageDAO.updateSanctionConfirmComplete(sanctionConsentVO); log.debug(this.getClass() + " returnResult : " + returnResult + ", saveComplete : " + saveComplete); // Callback Method try { ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.returnConsent(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } } /** * ? ? ? ? . ?? * ? callback . * @param submitVO * * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#cancelSanctionSubmit(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public void cancelSanctionSubmit(EgovOe1SanctionSubmitVO submitVO) throws Exception { String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); submitVO.setConfmDt(currentDate); submitVO.setDrftSttusCode("4"); // ? int result1 = consentManageDAO.updateDraftingStatusCode(submitVO); int result2 = consentManageDAO.updateSanctionConfirmDate(submitVO); log.debug(this.getClass() + " result1 : " + result1); log.debug(this.getClass() + " result2 : " + result2); // Callback Method try { ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.cancelSubmit(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } } /** * ex. ? ?? ? ? ?? * SanctionSubmitVO submitVO = new * SanctionSubmitVO(); submitVO.setDrftSj(""); * submitVO.setDrftCn(""); * submitVO.setDrafter(user.getId()); * submitVO.setSanctnRouteId(user.getId() + "|" + * "?ID"); submitVO.setSanctnRouteSeCode("1|4"); * submitVO.setSysId("CHM"); String drftSn = * consentService.actionSanctionDrafting(submitVO); * consentService.completeSanction(drftSn); * @param drftSn * ?? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#completeSanction(java.lang.String) */ public void completeSanction(String drftSn) throws Exception { EgovOe1SanctionConsentVO consentVO = new EgovOe1SanctionConsentVO(); consentVO.setDrftSn(drftSn); consentManageDAO.updateSanctionConfirmComplete(consentVO); EgovOe1SanctionSubmitVO submitVO = new EgovOe1SanctionSubmitVO(); submitVO.setDrftSttusCode("2"); // submitVO.setDrftSn(consentVO.getDrftSn()); int completeSanction = consentManageDAO.updateDraftingStatusCode(submitVO); log.debug(this.getClass() + " completeSanction : " + completeSanction); } }