From cf8979b72ca8032c72ab820a91d3fa0c9fa3e25d Mon Sep 17 00:00:00 2001 From: jjh Date: Fri, 10 May 2024 15:29:23 +0900 Subject: [PATCH] =?UTF-8?q?1.=20getOcrVrfcCode=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80.=202.=20getOcrband1=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EC=97=90=20spclBizCd=20=EC=B6=94=EA=B0=80.=203.=20getOcrband2,?= =?UTF-8?q?=20getOcrband3=20=ED=95=A8=EC=88=98=EC=97=90=20endsWith=20->=20?= =?UTF-8?q?equals=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/cmmn/CmmnUtil.java | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index f987d96f..3f913fcf 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -31,7 +31,6 @@ import javax.imageio.ImageIO; import org.apache.commons.io.FilenameUtils; import org.springframework.core.io.ClassPathResource; -import cokr.xit.fims.sndb.service.bean.SndngBean; import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.util.DateFormats; @@ -439,10 +438,38 @@ public class CmmnUtil { return convert; } - public static String getOcrband1(String deptCode, String fyr, String acntgSeCd, String txitmCd, String levyNo, String inspyNo) { + /**OCR 밴드의 검을 반환한다. + * @param vrfcCode 검증에 사용할 코드 + * ocrData OCR 데이터 + * bgngPstn 시작 위치 + * totalLength OCR 데이터의 총길이 + * @return 검증 코드 + * + */ + public static String getOcrVrfcCode(String vrfcCode, String strData, int totalLength) { + int temp = 0; + int cdTemp = 0; + String retCode = ""; + + for (int iLoop = 0; iLoop < totalLength; iLoop++) { + temp = (iLoop + vrfcCode.length()) % vrfcCode.length(); + cdTemp = cdTemp + (Integer.valueOf(strData.substring(iLoop, iLoop + 1)) * Integer.valueOf(vrfcCode.substring(temp, temp + 1))); + } + + retCode = String.valueOf(cdTemp % 10); + + return retCode; + } + + public static String getOcrband1(String deptCode, String spclBizCd, String fyr, String acntgSeCd, String txitmCd, String levyNo, String inspyNo) { if(deptCode.equals("")) { deptCode = "0000000"; } + if(spclBizCd.equals("")) { + spclBizCd = "0000"; + } if(fyr.equals("")) { fyr = "0000"; } @@ -458,15 +485,16 @@ public class CmmnUtil { if(inspyNo.equals("")) { inspyNo = "00"; } - String band1 = deptCode + "0000" + fyr + acntgSeCd + txitmCd + levyNo + inspyNo; + String band1 = deptCode + spclBizCd + fyr + acntgSeCd + txitmCd + levyNo + inspyNo; + + String ocrVrfcCode = getOcrVrfcCode("12357", band1, 31); + band1 = band1 + ocrVrfcCode; - String ocrVrfcCode = SndngBean.getOcrVrfcCode("12357", band1, 31); - band1 = band1+ocrVrfcCode; return band1; } public static String getOcrband2(String band1, String levySeCd, int sumAmt, String dudtYmd) { - if(dudtYmd.endsWith("")) { + if(dudtYmd.equals("")) { dudtYmd = "00000000"; } @@ -483,54 +511,58 @@ public class CmmnUtil { + String.format("%011d", sumAmt) + dudtYmd + "0"; - String ocrVrfcCode = SndngBean.getOcrVrfcCode("23571", band1 + band2, 53); + String ocrVrfcCode = getOcrVrfcCode("23571", band1 + band2, 53); band2 = band2 + ocrVrfcCode; band2 = band1 + band2; + return band2; } - public static String getOcrband3(String band2, int sumAmt, String dudtYmd, int afterSumAmt) { - if(dudtYmd.endsWith("")) { + public static String getOcrband3(String ocr1, int sumAmt, String dudtYmd, int afterSumAmt) { + if(dudtYmd.equals("")) { dudtYmd = "00000000"; } // OCR 2번째줄 54 // band3 = 국세 + 국세요율(납기후에 추가되는 가산금의 비율) + 시도세 + 시도세요율 + 시군구세 + 시군구세요율 - String band3 = "0000000000" + String band3 = "0000000000" + "00" + "0000000000" + "00" + String.format("%011d", sumAmt) + "00"; - String ocrVrfcCode = SndngBean.getOcrVrfcCode("35712", band3, 36); + String ocrVrfcCode = getOcrVrfcCode("35712", band3, 36); // band4 = 부과월 + 납기후처리 + 납기후금액(12자리) // 0=납기후 수납가능, 1=납기후 수납불가, 2=납기 무관, 7~9=납기후 수납가능 String band4 = dudtYmd.substring(4, 6) + "1" + String.format("%012d", afterSumAmt); - ocrVrfcCode = SndngBean.getOcrVrfcCode("57123", band3 + band4, 52); + ocrVrfcCode = getOcrVrfcCode("57123", band3 + band4, 52); band4 = band4 + ocrVrfcCode; // band5 = 전체 합산해서 검코드 구하기용, 사용하지는 않음 - String band5 = band2 + band3 + band4; - ocrVrfcCode = SndngBean.getOcrVrfcCode("71235", band5, 107); + String band5 = ocr1 + band3 + band4; + ocrVrfcCode = getOcrVrfcCode("71235", band5, 107); // band6 String band6 = band3 + band4 + ocrVrfcCode; + return band6; } public static void setOcrInfo(DataObject dataObject) { String deptCode = dataObject.string("DEPT_CD"); + String spclBizCd = dataObject.string("SPCL_BIZ_CD"); String fyr = dataObject.string("FYR"); String acntgSeCd = dataObject.string("ACNTG_SE_CD"); String txitmCd = dataObject.string("TXITM_CD"); String levyNo = dataObject.string("LEVY_NO"); String inspyNo = dataObject.string("INSPY_NO"); - String ocr0 = CmmnUtil.getOcrband1(deptCode,fyr, acntgSeCd, txitmCd, levyNo, inspyNo); + String ocr0 = CmmnUtil.getOcrband1(deptCode, spclBizCd, fyr, acntgSeCd, txitmCd, levyNo, inspyNo); + dataObject.set("OCR0", ocr0); dataObject.set("OCR0_1", ocr0.substring(0, 17)); dataObject.set("OCR0_2", ocr0.substring(17)); @@ -544,7 +576,6 @@ public class CmmnUtil { int afterSumAmt = dataObject.number("DUDT_AFTR_AMT").intValue(); // 납기후 금액 String ocr2 = CmmnUtil.getOcrband3(ocr1, sumAmt, dudtYmd, afterSumAmt); dataObject.set("OCR2", ocr2); - } public static String getBarcode(String rgSe, String sggCd, String sndngDtlId) {