diff --git a/src/main/java/cokr/xit/custom/boot/DatasourceConfig2.java b/src/main/java/cokr/xit/custom/boot/DatasourceConfig2.java index 3e500c0a..98d4cb93 100644 --- a/src/main/java/cokr/xit/custom/boot/DatasourceConfig2.java +++ b/src/main/java/cokr/xit/custom/boot/DatasourceConfig2.java @@ -49,7 +49,7 @@ public class DatasourceConfig2 { public MapperConfigurer externalMapperConfigurer() { MapperConfigurer bean = new MapperConfigurer(); - bean.setBasePackage("externalsystem.car"); + bean.setBasePackage("externalsystem"); bean.setSqlSessionFactoryBeanName("externalSqlSession"); return bean; diff --git a/src/main/java/externalsystem/car/dao/CarMapper.java b/src/main/java/externalsystem/car/dao/CarMapper.java index fb4f5095..5f25dd67 100644 --- a/src/main/java/externalsystem/car/dao/CarMapper.java +++ b/src/main/java/externalsystem/car/dao/CarMapper.java @@ -1,5 +1,7 @@ package externalsystem.car.dao; +import java.util.Map; + import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import cokr.xit.foundation.component.AbstractMapper; @@ -8,4 +10,6 @@ import cokr.xit.foundation.data.DataObject; @Mapper("carMapper") public interface CarMapper extends AbstractMapper { DataObject selectCar(String vhrno); + + int insertCar(Map params); } \ No newline at end of file diff --git a/src/main/java/externalsystem/testpool/dao/TestPoolMapper.java b/src/main/java/externalsystem/testpool/dao/TestPoolMapper.java new file mode 100644 index 00000000..4e44cf17 --- /dev/null +++ b/src/main/java/externalsystem/testpool/dao/TestPoolMapper.java @@ -0,0 +1,13 @@ +package externalsystem.testpool.dao; + +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +import cokr.xit.foundation.component.AbstractMapper; +import cokr.xit.foundation.data.DataObject; + +@Mapper("testPoolMapper") +public interface TestPoolMapper extends AbstractMapper { + DataObject selectRandomMber(); + DataObject selectRandomAddr(); + DataObject selectRandomCarBasic(); +} diff --git a/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java b/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java index 5a96966a..b971da9e 100644 --- a/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java +++ b/src/main/java/testserver/wsdlserver/lvisserver/CarRegBasicInfoImpl.java @@ -18,12 +18,17 @@ */ package testserver.wsdlserver.lvisserver; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.annotation.Resource; import cokr.xit.foundation.data.DataObject; import externalsystem.car.dao.CarMapper; +import externalsystem.testpool.dao.TestPoolMapper; @javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService", targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo", @@ -35,6 +40,9 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo { @Resource(name = "carMapper") private CarMapper carMapper; + @Resource(name = "testPoolMapper") + private TestPoolMapper testPoolMapper; + private static final Logger LOG = Logger.getLogger(CarRegBasicInfoImpl.class.getName()); @Override @@ -53,8 +61,39 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo { String vhrno = findRegBasicParameter.getEaiRequestRs().get(0).getVHRNO(); DataObject carInfo = carMapper.selectCar(vhrno); + + if(carInfo == null && !vhrno.equals("")) { + if(isValidCarNumber(vhrno)) { + DataObject randMber = testPoolMapper.selectRandomMber(); + DataObject randAddr= testPoolMapper.selectRandomAddr(); + DataObject randCarBasic = testPoolMapper.selectRandomCarBasic(); + + Map params = new HashMap(); + params.put("vhrno", vhrno); + params.put("mberSeCode", randMber.string("MBER_SE_CODE")); + params.put("mberNm", randMber.string("MBER_NM")); + params.put("mberSeNo", randMber.string("MBER_SE_NO")); + params.put("useStrnghldRoadNmCode", randAddr.string("ROAD_NM_CODE")); + params.put("useStrnghldBuldSeCode", randAddr.string("BULD_SE_CODE")); + params.put("useStrnghldBuldMainNo", randAddr.string("BULD_MAIN_NO")); + params.put("useStrnghldBuldSubNo", randAddr.string("BULD_SUB_NO")); + params.put("useStrnghldAdresNm", randAddr.string("ADRES_NM")); + params.put("cnm", randCarBasic.string("CNM")); + params.put("colorNm", randCarBasic.string("COLOR_NM")); + params.put("vhctyAsortCode", randCarBasic.string("VHCTY_ASORT_CODE")); + params.put("mxmmLdg", randCarBasic.string("MXMM_LDG")); + params.put("vin", randCarBasic.string("VIN")); + params.put("ersrRegistDe", randCarBasic.string("ERSR_REGIST_DE")); + + int effected = carMapper.insertCar(params); + if(effected == 1) { + carInfo = carMapper.selectCar(vhrno); + } + } + } + if(carInfo != null) { - frbrerr.setPROCESSIMPRTYRESNCODE("00"); + frbrerr.setPROCESSIMPRTYRESNCODE("00"); frbrerr.setVHRNO(carInfo.string("VHRNO")); frbrerr.setMBERSECODE(carInfo.string("MBER_SE_CODE")); @@ -72,6 +111,7 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo { frbrerr.setVIN(carInfo.string("VIN")); frbrerr.setERSRREGISTDE(carInfo.string("ERSR_REGIST_DE")); } + r.getEaiResponseRs().add(frbrerr); return r; } @@ -92,5 +132,32 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo { } + public static boolean isValidCarNumber(String carNum){ + + boolean returnValue = false; + + try{ + String regex = "^\\d{2,3}[가|나|다|라|마|거|너|더|러|머|버|서|어|저|고|노|도|로|모|보|소|오|조|구|누|두|루|무|부|수|우|주|바|사|아|자|허|배|호|하\\x20]\\d{4}/*$"; + + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(carNum); + if (m.matches()) { + returnValue = true; + }else{ + //2번째 패턴 처리 + regex = "^[서울|부산|대구|인천|대전|광주|울산|제주|경기|강원|충남|전남|전북|경남|경북|세종]{2}\\d{2}[가|나|다|라|마|거|너|더|러|머|버|서|어|저|고|노|도|로|모|보|소|오|조|구|누|두|루|무|부|수|우|주|바|사|아|자|허|배|호|하\\x20]\\d{4}$"; + p = Pattern.compile(regex); + m = p.matcher(carNum); + if (m.matches()) { + returnValue = true; + } + } + + return returnValue; + + }catch(Exception e){ + return false; + } + } } \ No newline at end of file diff --git a/src/main/resources/sql/externalmapper/car-mapper.xml b/src/main/resources/sql/externalmapper/car-mapper.xml index 8fffd99f..4c2ec81b 100644 --- a/src/main/resources/sql/externalmapper/car-mapper.xml +++ b/src/main/resources/sql/externalmapper/car-mapper.xml @@ -22,4 +22,42 @@ FROM EXTERNAL_TB_CAR WHERE VHRNO = #{vhrno} + +INSERT + INTO EXTERNAL_TB_CAR ( + VHRNO + , MBER_SE_CODE + , MBER_NM + , MBER_SE_NO + , USE_STRNGHLD_ROAD_NM_CODE + , USE_STRNGHLD_BULD_MAIN_NO + , USE_STRNGHLD_BULD_SUB_NO + , USE_STRNGHLD_ADRES_NM + , USGSRHLD_UNDGRND_BULD_SE_CODE + , CNM + , COLOR_NM + , VHCTY_ASORT_CODE + , MXMM_LDG + , VIN + , ERSR_REGIST_DE +) +VALUES ( + #{vhrno} + , #{mberSeCode} + , #{mberNm} + , #{mberSeNo} + , #{useStrnghldRoadNmCode} + , #{useStrnghldBuldMainNo} + , #{useStrnghldBuldSubNo} + , #{useStrnghldAdresNm} + , #{useStrnghldBuldSeCode} + , #{cnm} + , #{colorNm} + , #{vhctyAsortCode} + , #{mxmmLdg} + , #{vin} + , #{ersrRegistDe} +) + + \ No newline at end of file diff --git a/src/main/resources/sql/externalmapper/testpool-mapper.xml b/src/main/resources/sql/externalmapper/testpool-mapper.xml new file mode 100644 index 00000000..14d50fc0 --- /dev/null +++ b/src/main/resources/sql/externalmapper/testpool-mapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + \ No newline at end of file