diff --git a/src/main/java/cokr/xit/fims/cmmn/Hangul.java b/src/main/java/cokr/xit/fims/cmmn/Hangul.java index 236321a3..acf6feb9 100644 --- a/src/main/java/cokr/xit/fims/cmmn/Hangul.java +++ b/src/main/java/cokr/xit/fims/cmmn/Hangul.java @@ -19,7 +19,9 @@ public class Hangul { * @return */ public int getByteLength(String str) { - + if(str == null) { + return 0; + } int byteLen = 0; for(int i=0;i 60) { - throw new RuntimeException("[F]위반법규가 60byte를 초과하여 오류가 발생하였습니다."); - } - B01[6] = law; - String crdnPlc = crdnInfo.string("CRDN_PLC"); - if(hangul.getByteLength(crdnPlc) > 60) { - throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다."); - } - B01[7] = crdnPlc; + b01.set(7, law); + b01.set(8, crdnInfo.string("CRDN_PLC")); + String crdnSpareaCd = crdnInfo.string("CRDN_SPAREA_CD"); if(crdnSpareaCd.equals("00")) { crdnSpareaCd = ""; } else if(crdnSpareaCd.equals("06") || crdnSpareaCd.equals("07")) { crdnSpareaCd = "03"; } - B01[8] = crdnSpareaCd; - - if(this.gujesiStng != null && !this.gujesiStng.equals("")) { - B01[9] = gujesiStng; - } else { - B01[9] = "1"; - } - - if(crdnInfo.string("STDG_CD").equals("")) { - B01[10] = "0000000000"; - } else { - B01[10] = crdnInfo.string("STDG_CD"); - } - - B01[11] = crdnInfo.string("GPS_X"); - B01[12] = crdnInfo.string("GPS_Y"); + b01.set(9, crdnSpareaCd); + b01.set(10, this.gujesiStng); + b01.set(11, crdnInfo.string("STDG_CD")); + b01.set(12, crdnInfo.string("GPS_X")); + b01.set(13, crdnInfo.string("GPS_Y")); int atchFileCnt = crdnInfo.number("ATCH_FILE_CNT").intValue(); if(atchFileCnt > this.maxImageFileCnt) { atchFileCnt = this.maxImageFileCnt; } - B01[13] = Integer.toString(atchFileCnt); + b01.set(14, Integer.toString(atchFileCnt)); - return B01; + return b01; } @Override - public String[] extractForBPV(DataObject crdnInfo) { - String[] C01 = new String[14]; - Hangul hangul = new Hangul(3); + public C01 extractForBPV(DataObject crdnInfo, boolean includeTxt) { + C01 c01 = new C01(includeTxt); - C01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM"); - C01[1] = crdnInfo.string("VHRNO"); + c01.set(1, crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM")); + c01.set(2, crdnInfo.string("VHRNO")); String crdnSeCd = crdnInfo.string("CRDN_SE_CD"); if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) { throw new RuntimeException("[F]잘못된 단속구분입니다."); } - C01[2] = crdnSeCd; - C01[3] = crdnInfo.string("TEAM_ID"); + c01.set(3, crdnSeCd); + c01.set(4, crdnInfo.string("TEAM_ID")); String vltnCd = crdnInfo.string("VLTN_CD"); - C01[4] = vltnCd; + c01.set(5, vltnCd); String law = CmmnUtil.spacedJoin(crdnInfo.string("VLTN_LAW_NM"), crdnInfo.string("VLTN_LAW1"), crdnInfo.string("VLTN_LAW2")); - if(hangul.getByteLength(law) > 60) { - throw new RuntimeException("[F]위반법규가 60byte를 초과하여 오류가 발생하였습니다."); - } - - C01[5] = law; - String crdnPlc = crdnInfo.string("CRDN_PLC"); - if(hangul.getByteLength(crdnPlc) > 60) { - throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다."); - } - C01[6] = crdnPlc; - - if(this.gujesiStng != null && !this.gujesiStng.equals("")) { - C01[7] = gujesiStng; - } else { - C01[7] = "1"; - } - - if(crdnInfo.string("STDG_CD").equals("")) { - C01[8] = "0000000000"; - } else { - C01[8] = crdnInfo.string("STDG_CD"); - } - - C01[9] = crdnInfo.string("GPS_X"); - C01[10] = crdnInfo.string("GPS_Y"); - C01[11] = crdnInfo.string("MOSC_X"); - C01[12] = crdnInfo.string("MOSC_Y"); + c01.set(6, law); + c01.set(7, crdnInfo.string("CRDN_PLC")); + c01.set(8, this.gujesiStng); + c01.set(9, crdnInfo.string("STDG_CD")); + c01.set(10, crdnInfo.string("GPS_X")); + c01.set(11, crdnInfo.string("GPS_Y")); + c01.set(12, crdnInfo.string("MOSC_X")); + c01.set(13, crdnInfo.string("MOSC_Y")); int atchFileCnt = crdnInfo.number("ATCH_FILE_CNT").intValue(); if(atchFileCnt > this.maxImageFileCnt) { atchFileCnt = this.maxImageFileCnt; } - C01[13] = Integer.toString(atchFileCnt); + c01.set(14, Integer.toString(atchFileCnt)); - return C01; + return c01; } @Override diff --git a/src/main/java/cokr/xit/fims/crdn/send/nxrp/LinkFileMaker.java b/src/main/java/cokr/xit/fims/crdn/send/nxrp/LinkFileMaker.java index e4f42051..b54d50be 100644 --- a/src/main/java/cokr/xit/fims/crdn/send/nxrp/LinkFileMaker.java +++ b/src/main/java/cokr/xit/fims/crdn/send/nxrp/LinkFileMaker.java @@ -1,5 +1,7 @@ package cokr.xit.fims.crdn.send.nxrp; +import cokr.xit.fims.nxrp.B01; +import cokr.xit.fims.nxrp.C01; import cokr.xit.foundation.data.DataObject; public abstract class LinkFileMaker { @@ -24,7 +26,7 @@ public abstract class LinkFileMaker { return this.zipFileName; } - abstract public String[] extractForPVS(DataObject crdnInfo); - abstract public String[] extractForBPV(DataObject crdnInfo); + abstract public B01 extractForPVS(DataObject crdnInfo,boolean includeTxt); + abstract public C01 extractForBPV(DataObject crdnInfo,boolean includeTxt); abstract public void copyFile(String workPath, String filePath, int fileIndex, String... items); } diff --git a/src/main/java/cokr/xit/fims/crdn/send/nxrp/OnlyImageMaker.java b/src/main/java/cokr/xit/fims/crdn/send/nxrp/OnlyImageMaker.java index aa7e5a20..b42c1136 100644 --- a/src/main/java/cokr/xit/fims/crdn/send/nxrp/OnlyImageMaker.java +++ b/src/main/java/cokr/xit/fims/crdn/send/nxrp/OnlyImageMaker.java @@ -8,7 +8,8 @@ import java.util.Date; import org.apache.commons.io.FilenameUtils; -import cokr.xit.fims.cmmn.Hangul; +import cokr.xit.fims.nxrp.B01; +import cokr.xit.fims.nxrp.C01; import cokr.xit.foundation.data.DataObject; public class OnlyImageMaker extends LinkFileMaker { @@ -35,106 +36,54 @@ public class OnlyImageMaker extends LinkFileMaker { } @Override - public String[] extractForPVS(DataObject crdnInfo) { - String[] B01 = new String[11]; - Hangul hangul = new Hangul(3); + public B01 extractForPVS(DataObject crdnInfo, boolean includeTxt) { + B01 b01 = new B01(includeTxt); - B01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM"); - B01[1] = crdnInfo.string("VHRNO"); + b01.set(1, crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM")); + b01.set(2, crdnInfo.string("VHRNO")); String crdnSeCd = crdnInfo.string("CRDN_SE_CD"); if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) { throw new RuntimeException("[F]잘못된 단속구분입니다."); } - B01[2] = crdnSeCd; - B01[3] = crdnInfo.string("TEAM_ID"); - String vltnCd = crdnInfo.string("VLTN_CD"); - B01[4] = vltnCd; - - String crdnPlc = crdnInfo.string("CRDN_PLC"); - if(hangul.getByteLength(crdnPlc) > 60) { - throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다."); - } - B01[5] = crdnPlc; + b01.set(3, crdnSeCd); + b01.set(4, crdnInfo.string("TEAM_ID")); + b01.set(5, crdnInfo.string("VLTN_CD")); + b01.set(6, crdnInfo.string("CRDN_PLC")); String crdnSpareaCd = crdnInfo.string("CRDN_SPAREA_CD"); if(crdnSpareaCd.equals("00")) { crdnSpareaCd = ""; } else if(crdnSpareaCd.equals("06") || crdnSpareaCd.equals("07")) { crdnSpareaCd = "03"; } - B01[6] = crdnSpareaCd; - - if(this.gujesiStng != null && !this.gujesiStng.equals("")) { - B01[7] = gujesiStng; - } else { - B01[7] = "1"; - } - - if(crdnInfo.string("STDG_CD").equals("")) { - B01[8] = "0000000000"; - } else { - B01[8] = crdnInfo.string("STDG_CD"); - } + b01.set(7, crdnSpareaCd); + b01.set(8, this.gujesiStng); + b01.set(9, crdnInfo.string("STDG_CD")); + b01.set(10, crdnInfo.string("GPS_X")); + b01.set(11, crdnInfo.string("GPS_Y")); - String gpsX = crdnInfo.string("GPS_X"); - if(gpsX.equals("")) { - gpsX = "000"; - } - String gpsY = crdnInfo.string("GPS_Y"); - if(gpsY.equals("")) { - gpsY = "000"; - } - B01[9] = gpsX; - B01[10] = gpsY; - - return B01; + return b01; } @Override - public String[] extractForBPV(DataObject crdnInfo) { - String[] C01 = new String[10]; - Hangul hangul = new Hangul(3); + public C01 extractForBPV(DataObject crdnInfo, boolean includeTxt) { + C01 c01 = new C01(includeTxt); - C01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM"); - C01[1] = crdnInfo.string("VHRNO"); + c01.set(1, crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM")); + c01.set(2, crdnInfo.string("VHRNO")); String crdnSeCd = crdnInfo.string("CRDN_SE_CD"); if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) { throw new RuntimeException("[F]잘못된 단속구분입니다."); } - C01[2] = crdnSeCd; - C01[3] = crdnInfo.string("TEAM_ID"); - String vltnCd = crdnInfo.string("VLTN_CD"); - C01[4] = vltnCd; - - String crdnPlc = crdnInfo.string("CRDN_PLC"); - if(hangul.getByteLength(crdnPlc) > 60) { - throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다."); - } - C01[5] = crdnPlc; - - if(this.gujesiStng != null && !this.gujesiStng.equals("")) { - C01[6] = gujesiStng; - } else { - C01[6] = "1"; - } - - if(crdnInfo.string("STDG_CD").equals("")) { - C01[7] = "0000000000"; - } else { - C01[7] = crdnInfo.string("STDG_CD"); - } - - String gpsX = crdnInfo.string("GPS_X"); - if(gpsX.equals("")) { - gpsX = "000"; - } - String gpsY = crdnInfo.string("GPS_Y"); - if(gpsY.equals("")) { - gpsY = "000"; - } - C01[8] = gpsX; - C01[9] = gpsY; - - return C01; + c01.set(3, crdnSeCd); + c01.set(4, crdnInfo.string("TEAM_ID")); + c01.set(5, crdnInfo.string("VLTN_CD")); + c01.set(6, crdnInfo.string("CRDN_PLC")); + c01.set(7, this.gujesiStng); + c01.set(8, crdnInfo.string("STDG_CD")); + c01.set(9, crdnInfo.string("GPS_X")); + c01.set(10, crdnInfo.string("GPS_Y")); + + return c01; } @Override diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java index d7e92cc7..bf29382f 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java @@ -492,10 +492,12 @@ public class CrdnServiceBean extends AbstractServiceBean implements CrdnService try { String[] items = null; + boolean includeTxt = nxrpLinkSeDtlSn.equals("01"); + if(taskSeCd.equals("PVS")) { - items = linkFileMaker.extractForPVS(crdnInfo); + items = linkFileMaker.extractForPVS(crdnInfo,includeTxt).get(); } else if(taskSeCd.equals("BPV")) { - items = linkFileMaker.extractForBPV(crdnInfo); + items = linkFileMaker.extractForBPV(crdnInfo,includeTxt).get(); } if(nxrpLinkSeDtlSn.equals("01")) { @@ -528,6 +530,10 @@ public class CrdnServiceBean extends AbstractServiceBean implements CrdnService zipFile.close(); + for(File file : fileList) { + file.delete(); + } + Crdn crdn = new Crdn(); crdn.setCrdnId(crdnID); crdn.setModifiedBy(currentUser().getId()); diff --git a/src/main/java/cokr/xit/fims/nxrp/B01.java b/src/main/java/cokr/xit/fims/nxrp/B01.java new file mode 100644 index 00000000..e3aac491 --- /dev/null +++ b/src/main/java/cokr/xit/fims/nxrp/B01.java @@ -0,0 +1,63 @@ +package cokr.xit.fims.nxrp; + +import org.egovframe.rte.fdl.string.EgovStringUtil; + +import cokr.xit.fims.cmmn.Hangul; +import cokr.xit.fims.cmmn.UnnamedItems; + +public class B01 extends UnnamedItems { + + class HasText { + public static final int[] maxByteLen = {14,30,2,10,2,60,60,60,2,1,10,20,20,3}; + public static final String[] defaultValue = {"","","","","","","","","","1","0000000000","","",""}; + } + class NoText { + public static final int[] maxByteLen = {17,30,2,10,2,60,2,1,10,20,20,1,4}; + public static final String[] defaultValue = {"","","","","","","","1","0000000000","000","000","",""}; + } + + protected Hangul hangul; + protected boolean includeTxt; + + public B01(boolean includeTxt){ + this.hangul = new Hangul(3); + this.includeTxt = includeTxt; + + int itemCount = 0; + if(includeTxt) { + itemCount = 14; + } else { + String[] unused = {"파일순서", "확장자"}; + itemCount = 13 - unused.length; + } + + items = new String[itemCount]; + } + + @Override + public void set(int i, String str) { + if(this.includeTxt) { + if(HasText.maxByteLen[i-1] != 0 && hangul.getByteLength(str) > HasText.maxByteLen[i-1]) { + throw new RuntimeException("[F]"+i+"번째 항목 "+HasText.maxByteLen[i-1]+"바이트 초과 오류"); + } + + if(EgovStringUtil.null2void(str).equals("")) { + super.set(i, HasText.defaultValue[i-1]); + } else { + super.set(i, str); + } + + } else { + if(NoText.maxByteLen[i-1] != 0 && hangul.getByteLength(str) > NoText.maxByteLen[i-1]) { + throw new RuntimeException("[F]"+i+"번째 항목 "+NoText.maxByteLen[i-1]+"바이트 초과 오류"); + } + + if(EgovStringUtil.null2void(str).equals("")) { + super.set(i, NoText.defaultValue[i-1]); + } else { + super.set(i, str); + } + + } + } +} diff --git a/src/main/java/cokr/xit/fims/nxrp/C01.java b/src/main/java/cokr/xit/fims/nxrp/C01.java new file mode 100644 index 00000000..c360dbef --- /dev/null +++ b/src/main/java/cokr/xit/fims/nxrp/C01.java @@ -0,0 +1,63 @@ +package cokr.xit.fims.nxrp; + +import org.egovframe.rte.fdl.string.EgovStringUtil; + +import cokr.xit.fims.cmmn.Hangul; +import cokr.xit.fims.cmmn.UnnamedItems; + +public class C01 extends UnnamedItems { + + class HasText { + public static final int[] maxByteLen = {14,30,2,10,2,60,60,1,10,20,20,10,10,3}; + public static final String[] defaultValue = {"","","","","","","","1","0000000000","","","","",""}; + } + class NoText { + public static final int[] maxByteLen = {17,30,2,10,2,60,1,10,20,20,1,4}; + public static final String[] defaultValue = {"","","","","","","1","0000000000","000","000","",""}; + } + + protected Hangul hangul; + protected boolean includeTxt; + + public C01(boolean includeTxt){ + this.hangul = new Hangul(3); + this.includeTxt = includeTxt; + + int itemCount = 0; + if(includeTxt) { + itemCount = 14; + } else { + String[] unused = {"파일순서", "확장자"}; + itemCount = 12 - unused.length; + } + + items = new String[itemCount]; + } + + @Override + public void set(int i, String str) { + if(this.includeTxt) { + if(HasText.maxByteLen[i-1] != 0 && hangul.getByteLength(str) > HasText.maxByteLen[i-1]) { + throw new RuntimeException("[F]"+i+"번째 항목 "+HasText.maxByteLen[i-1]+"바이트 초과 오류"); + } + + if(EgovStringUtil.null2void(str).equals("")) { + super.set(i, HasText.defaultValue[i-1]); + } else { + super.set(i, str); + } + + } else { + if(NoText.maxByteLen[i-1] != 0 && hangul.getByteLength(str) > NoText.maxByteLen[i-1]) { + throw new RuntimeException("[F]"+i+"번째 항목 "+NoText.maxByteLen[i-1]+"바이트 초과 오류"); + } + + if(EgovStringUtil.null2void(str).equals("")) { + super.set(i, NoText.defaultValue[i-1]); + } else { + super.set(i, str); + } + + } + } +}