diff --git a/src/main/java/externalsystem/piss/web/PissController.java b/src/main/java/externalsystem/piss/web/PissController.java index ad410c5f..7abde032 100644 --- a/src/main/java/externalsystem/piss/web/PissController.java +++ b/src/main/java/externalsystem/piss/web/PissController.java @@ -1,23 +1,119 @@ package externalsystem.piss.web; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.web.AbstractController; +import externalsystem.car.dao.CarMapper; +import externalsystem.testpool.dao.TestPoolMapper; +import testserver.wsdlserver.lvisserver.CarRegBasicInfoImpl; -@RequestMapping(name="행정정보공동이용시스템 연계", value="/piss/api") - +@Controller +@RequestMapping(name="행정정보공동이용시스템 연계", value="/piss/api", method = RequestMethod.POST) public class PissController extends AbstractController { - @RequestMapping(name="차적", value="molit/SignguCarBassMatterInqireService") - public ModelAndView signguCarBassMatterInqireService(HttpServletRequest req) { - ModelAndView mav = new ModelAndView("jsonView"); + @Resource(name = "carMapper") + private CarMapper carMapper; + + @Resource(name = "testPoolMapper") + private TestPoolMapper testPoolMapper; + + @PostMapping(name="차적", value="molit/SignguCarBassMatterInqireService") + @ResponseBody + public String signguCarBassMatterInqireService(HttpServletRequest hreq, @RequestBody HashMap map) { + + //A01 + // + + Map carRes = new HashMap(); + carRes.put("CNTC_RESULT_CODE", "00"); + carRes.put("CNTC_RESULT_DLTS", ""); + carRes.put("ERROR", null); + + Map data = ((List>)map.get("data")).get(0); + String vhrno = data.get("VHRNO"); + + DataObject carInfo = carMapper.selectCar(vhrno); + + if(carInfo == null && !vhrno.equals("")) { + if(CarRegBasicInfoImpl.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); + } + } + } + + List> extInfo_list = new ArrayList<>(); + Map extInfo = new HashMap(); + + if(carInfo != null) { + + extInfo.put("VHRNO",carInfo.string("VHRNO")); + extInfo.put("MBER_SE_CODE",carInfo.string("MBER_SE_CODE")); + extInfo.put("MBER_NM",carInfo.string("MBER_NM")); + extInfo.put("MBER_SE_NO",carInfo.string("MBER_SE_NO")); + extInfo.put("USE_STRNGHLD_ROAD_NM_CODE",carInfo.string("USE_STRNGHLD_ROAD_NM_CODE")); + extInfo.put("USE_STRNGHLD_BULD_MAIN_NO",carInfo.string("USE_STRNGHLD_BULD_MAIN_NO")); + extInfo.put("USE_STRNGHLD_BULD_SUB_NO",carInfo.string("USE_STRNGHLD_BULD_SUB_NO")); + extInfo.put("USE_STRNGHLD_ADRES_NM",carInfo.string("USE_STRNGHLD_ADRES_NM")); + extInfo.put("USGSRHLD_UNDGRND_BULD_SE_CODE",carInfo.string("USGSRHLD_UNDGRND_BULD_SE_CODE")); + extInfo.put("CNM",carInfo.string("CNM")); + extInfo.put("COLOR_NM",carInfo.string("COLOR_NM")); + extInfo.put("VHCTY_ASORT_CODE",carInfo.string("VHCTY_ASORT_CODE")); + extInfo.put("MXMM_LDG",carInfo.string("MXMM_LDG")); + extInfo.put("VIN",carInfo.string("VIN")); + extInfo.put("ERSR_REGIST_DE",carInfo.string("ERSR_REGIST_DE")); + + extInfo_list.add(extInfo); + carRes.put("record", extInfo_list); + } else { + carRes.put("record", null); + } + + String str = toJson(carRes); + - //req. + System.out.println(str); - return mav; + String a = "{\"data\":["; + String b = "]}"; + str = a + str + b; + return str; } }