diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java index b931fea3..c88e3e92 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java @@ -2,6 +2,7 @@ package cokr.xit.fims.crdn.service.bean; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiFunction; @@ -21,9 +22,9 @@ import cokr.xit.fims.payer.service.bean.PayerBean; import cokr.xit.foundation.component.AbstractBean; import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.util.DateFormats; -import cokr.xit.interfaces.lvis.service.bean.VehicleInfoBean; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoExtRequest; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoExtResponse; import cokr.xit.interfaces.lvis.service.reg.BasicInfoRequest; -import cokr.xit.interfaces.lvis.service.reg.BasicInfoResponse; import cokr.xit.interfaces.smg.Petition; import cokr.xit.interfaces.smg.dao.SmgMapper; @@ -34,12 +35,13 @@ import cokr.xit.interfaces.smg.dao.SmgMapper; public class ImportBean extends AbstractBean { @Resource(name = "importMapper") private ImportMapper importMapper; + @Resource(name = "smgMapper") private SmgMapper smgMapper; + @Resource(name = "crdnCvlcptMapper") private CrdnCvlcptMapper cvlcptMapper; - @Resource(name = "vehicleInfoBean") - private VehicleInfoBean vehicleInfoBean; + @Resource(name = "payerBean") private PayerBean payerBean; @@ -198,23 +200,62 @@ public class ImportBean extends AbstractBean { * @param basicInfoMap */ private void setVehicleInfo(List crdns, BiFunction getCarModel) { - List reqs = crdns.stream() - .filter(crdn -> !isEmpty(crdn.getVhrno())) - .map(crdn -> { - BasicInfoRequest req = new BasicInfoRequest(); - req.setLevy_stdde(crdn.getCrdnYmd()); - req.setVhrno(crdn.getVhrno()); - req.setSggCd(crdn.getSggCd()); - return req; - }).toList(); - Map payers = payerBean.getVehicleOwners(reqs).stream() - .collect(Collectors.toMap(payer -> payer.getVhrno(), payer -> payer)); - - crdns.forEach(crdn -> { - Payer payer = payers.get(crdn.getVhrno()); + + Map payerMap = new HashMap(); + + if(1 == 1) { //TODO:행공센연계여부 + + List reqs = crdns.stream() + .filter(crdn -> !isEmpty(crdn.getVhrno())) + .map(crdn -> { + BasicInfoExtRequest req = new BasicInfoExtRequest(); + req.setLevy_stdde(crdn.getCrdnYmd()); + req.setVhrno(crdn.getVhrno()); + return req; + }).toList(); + + for(BasicInfoExtRequest req : reqs) { + Payer p = payerBean.getVehicleOwner(new BasicInfoExtRequest()); + crdns.forEach(crdn -> { + if(req.getLevy_stdde().equals(crdn.getCrdnYmd()) + && req.getVhrno().equals(crdn.getVhrno()) + ) { + payerMap.put(crdn.getCrdnYmd()+","+crdn.getVhrno(), p); + } + }); + } + + } else { + List reqs = crdns.stream() + .filter(crdn -> !isEmpty(crdn.getVhrno())) + .map(crdn -> { + BasicInfoRequest req = new BasicInfoRequest(); + req.setLevy_stdde(crdn.getCrdnYmd()); + req.setVhrno(crdn.getVhrno()); + req.setSggCd(crdn.getSggCd()); + return req; + }).toList(); + + + for(BasicInfoRequest req : reqs) { + + Payer p = payerBean.getVehicleOwners(List.of(req)).get(0); + crdns.forEach(crdn -> { + if(req.getLevy_stdde().equals(crdn.getCrdnYmd()) + && req.getVhrno().equals(crdn.getVhrno()) + ) { + payerMap.put(crdn.getCrdnYmd()+","+crdn.getVhrno(), p); + } + }); + } + + } + + for(Crdn crdn : crdns) { + Payer payer = payerMap.get(crdn.getCrdnYmd()+","+crdn.getVhrno()); if (payer == null) return; - BasicInfoResponse.BasicInfo vehicle = payer.getVehicleInfo(); + BasicInfoExtResponse.ExtInfo vehicle = payer.getVehicleInfo(); crdn.setSggCd(payer.getSggCd()); // 시군구 데이터 정리되면 지울 것 if(ifEmpty(vehicle.getErsr_regist_de(), () -> "").equals("")) { crdn.setRtpyrId(""); @@ -227,7 +268,7 @@ public class ImportBean extends AbstractBean { crdn.setUseFuelCd(vehicle.getUse_fuel_code()); crdn.setFfnlgCarmdlCd(getCarModel.apply(vehicle.getVhcty_asort_code(), vehicle.getMxmm_ldg())); crdn.setErsrRegYmd(vehicle.getErsr_regist_de()); - }); + } } public int createCvlcpts(List petitions) { diff --git a/src/main/java/cokr/xit/fims/payer/service/bean/PayerServiceBean.java b/src/main/java/cokr/xit/fims/payer/service/bean/PayerServiceBean.java index ffa89e29..d2d99f15 100644 --- a/src/main/java/cokr/xit/fims/payer/service/bean/PayerServiceBean.java +++ b/src/main/java/cokr/xit/fims/payer/service/bean/PayerServiceBean.java @@ -69,8 +69,8 @@ public class PayerServiceBean extends AbstractServiceBean implements PayerServic @Override public Payer getVehicleOwner(BasicInfoExtRequest req) { - List payers = payerBean.getVehicleOwners(req); - return !payers.isEmpty() ? payers.get(0) : null; + Payer payer = payerBean.getVehicleOwner(req); + return payer; } @Override