차적 테스트 데이터 생성 기능 추가

main
이범준 1 year ago
parent ab1c3e1464
commit ea93224849

@ -49,7 +49,7 @@ public class DatasourceConfig2 {
public MapperConfigurer externalMapperConfigurer() { public MapperConfigurer externalMapperConfigurer() {
MapperConfigurer bean = new MapperConfigurer(); MapperConfigurer bean = new MapperConfigurer();
bean.setBasePackage("externalsystem.car"); bean.setBasePackage("externalsystem");
bean.setSqlSessionFactoryBeanName("externalSqlSession"); bean.setSqlSessionFactoryBeanName("externalSqlSession");
return bean; return bean;

@ -1,5 +1,7 @@
package externalsystem.car.dao; package externalsystem.car.dao;
import java.util.Map;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.foundation.component.AbstractMapper; import cokr.xit.foundation.component.AbstractMapper;
@ -8,4 +10,6 @@ import cokr.xit.foundation.data.DataObject;
@Mapper("carMapper") @Mapper("carMapper")
public interface CarMapper extends AbstractMapper { public interface CarMapper extends AbstractMapper {
DataObject selectCar(String vhrno); DataObject selectCar(String vhrno);
int insertCar(Map<String, Object> params);
} }

@ -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();
}

@ -18,12 +18,17 @@
*/ */
package testserver.wsdlserver.lvisserver; package testserver.wsdlserver.lvisserver;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource; import javax.annotation.Resource;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import externalsystem.car.dao.CarMapper; import externalsystem.car.dao.CarMapper;
import externalsystem.testpool.dao.TestPoolMapper;
@javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService", @javax.jws.WebService(name = "CarRegBasicInfo", portName = "CarRegBasicInfoPort",serviceName = "CarRegBasicInfoImplService",
targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo", targetNamespace = "componentNs:carregbasicinfo.reg.service.lvis/service.reg.CarRegBasicInfo",
@ -35,6 +40,9 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo {
@Resource(name = "carMapper") @Resource(name = "carMapper")
private CarMapper carMapper; private CarMapper carMapper;
@Resource(name = "testPoolMapper")
private TestPoolMapper testPoolMapper;
private static final Logger LOG = Logger.getLogger(CarRegBasicInfoImpl.class.getName()); private static final Logger LOG = Logger.getLogger(CarRegBasicInfoImpl.class.getName());
@Override @Override
@ -53,6 +61,37 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo {
String vhrno = findRegBasicParameter.getEaiRequestRs().get(0).getVHRNO(); String vhrno = findRegBasicParameter.getEaiRequestRs().get(0).getVHRNO();
DataObject carInfo = carMapper.selectCar(vhrno); 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<String, Object> params = new HashMap<String, Object>();
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) { if(carInfo != null) {
frbrerr.setPROCESSIMPRTYRESNCODE("00"); frbrerr.setPROCESSIMPRTYRESNCODE("00");
@ -72,6 +111,7 @@ public class CarRegBasicInfoImpl implements CarRegBasicInfo {
frbrerr.setVIN(carInfo.string("VIN")); frbrerr.setVIN(carInfo.string("VIN"));
frbrerr.setERSRREGISTDE(carInfo.string("ERSR_REGIST_DE")); frbrerr.setERSRREGISTDE(carInfo.string("ERSR_REGIST_DE"));
} }
r.getEaiResponseRs().add(frbrerr); r.getEaiResponseRs().add(frbrerr);
return r; 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;
}
}
} }

@ -22,4 +22,42 @@ FROM EXTERNAL_TB_CAR
WHERE VHRNO = #{vhrno} WHERE VHRNO = #{vhrno}
</select> </select>
<insert id="insertCar">
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}
)
</insert>
</mapper> </mapper>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="externalsystem.testpool.dao.TestPoolMapper">
<select id="selectRandomMber" resultType="dataobject">
SELECT *
FROM TESTPOOL_TB_MBER
ORDER BY RAND() LIMIT 1
</select>
<select id="selectRandomAddr" resultType="dataobject">
SELECT *
FROM TESTPOOL_TB_ADDR
ORDER BY RAND() LIMIT 1
</select>
<select id="selectRandomCarBasic" resultType="dataobject">
SELECT *
FROM TESTPOOL_TB_CAR_BASIC
ORDER BY RAND() LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save