1. getOcrVrfcCode 함수 추가.

2. getOcrband1 함수에 spclBizCd 추가.
3. getOcrband2, getOcrband3 함수에 endsWith -> equals 수정.
main
jjh 6 months ago
parent b9c11e7de2
commit cf8979b72c

@ -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
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
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,15 +511,16 @@ 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";
}
@ -503,34 +532,37 @@ public class CmmnUtil {
+ "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) {

Loading…
Cancel
Save