From 5fcc7366b8728eed6727a1ca1aa9c837bf7d3fb9 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Tue, 22 Aug 2023 10:27:34 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=A9=EB=B6=80=EC=9E=90=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EB=94=94=20=ED=8F=AC=ED=95=A8=ED=95=9C=20=EC=B0=A8?= =?UTF-8?q?=EC=A0=81=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fims/crdn/service/bean/ImportBean.java | 66 ++++----------- src/main/java/cokr/xit/fims/payer/Payer.java | 11 +++ .../xit/fims/payer/service/PayerService.java | 9 +- .../fims/payer/service/bean/PayerBean.java | 83 ++++++++++++++++--- .../payer/service/bean/PayerServiceBean.java | 7 ++ .../xit/fims/payer/web/PayerController.java | 13 +++ .../sql/mapper/fims/payer-mapper.xml | 6 +- 7 files changed, 127 insertions(+), 68 deletions(-) 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 dc42b82d..cc804b33 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 @@ -174,65 +174,27 @@ public class ImportBean extends AbstractComponent { BasicInfoRequest req = new BasicInfoRequest(); req.setLevy_stdde(crdn.getCrdnYmd()); req.setVhrno(crdn.getVhrno()); + req.setSggCd(crdn.getSggCd()); return req; }).toList(); - Map vehicleInfoMap = vehicleInfoBean.getBasicInfo(reqs); + Map payers = payerBean.getVehicleOwners(reqs).stream() + .collect(Collectors.toMap(payer -> payer.getVhrno(), payer -> payer)); crdns.forEach(crdn -> { - String vhrno = crdn.getVhrno(); - BasicInfoResponse resp = vehicleInfoMap.get(vhrno); - if (resp == null) return; - - BasicInfoResponse.BasicInfo basicInfo = resp.getBasicInfo(); - Payer payer = getPayer(crdn.getSggCd(), basicInfo); - if (payer != null) - crdn.setRtpyrId(payer.getRtpyrId()); // TODO: 차적 차량번호 + 소유자 회원번호 == tb_payer.차량번호 + 납부자 번호 -> tb_payer.납부자 id - crdn.setVin(basicInfo.getVin()); - crdn.setVhclNm(basicInfo.getCnm()); - crdn.setVhclColor(basicInfo.getColor_nm()); - crdn.setUseFuelCd(basicInfo.getUse_fuel_code()); - crdn.setFfnlgCarmdlCd(getCarModel.apply(basicInfo.getVhcty_asort_code(), basicInfo.getMxmm_ldg())); + Payer payer = payers.get(crdn.getVhrno()); + if (payer == null) return; + + BasicInfoResponse.BasicInfo vehicle = payer.getVehicleInfo(); + crdn.setSggCd(payer.getSggCd()); // 시군구 데이터 정리되면 지울 것 + crdn.setRtpyrId(payer.getRtpyrId()); + crdn.setVin(vehicle.getVin()); + crdn.setVhclNm(vehicle.getCnm()); + crdn.setVhclColor(vehicle.getColor_nm()); + crdn.setUseFuelCd(vehicle.getUse_fuel_code()); + crdn.setFfnlgCarmdlCd(getCarModel.apply(vehicle.getVhcty_asort_code(), vehicle.getMxmm_ldg())); }); } - private Payer getPayer(String sggCd, BasicInfoResponse.BasicInfo basicInfo) { - Payer payer = new Payer(); - - payer.setSggCd(sggCd); - String vhrno = basicInfo.getVhrno(); - payer.setVhrno(vhrno); - payer.setRtpyrSeCd(basicInfo.getMber_se_code()); - String rtpyrNo = basicInfo.getMber_se_no(); - payer.setRtpyrNo(rtpyrNo); - payer.setRtpyrNm(basicInfo.getMber_nm()); - payer.setRtpyrTelno(basicInfo.getTelno()); - payer.setRoadNmCd(basicInfo.getUse_strnghld_road_nm_code()); - payer.setUdgdSeCd(basicInfo.getUsgsrhld_undgrnd_buld_se_code()); - String str = basicInfo.getUse_strnghld_buld_main_no(); - if (!isEmpty(str)) - payer.setBmno(toInt(str)); - str = basicInfo.getUse_strnghld_buld_sub_no(); - if (!isEmpty(str)) - payer.setBsno(toInt(str)); - payer.setStdgCd(basicInfo.getUse_strnghld_legaldong_code()); - payer.setDongCd(basicInfo.getUse_strnghld_adstrd_code()); - payer.setMtnSeCd(basicInfo.getUse_strnghld_mntn()); - str = basicInfo.getUse_strnghld_lnbr(); - if (!isEmpty(str)) - payer.setMno(toInt(str)); - str = basicInfo.getUse_strnghld_ho(); - if (!isEmpty(str)) - payer.setSno(toInt(str)); - payer.setDtlAddr(basicInfo.getUse_strnghld_adres_nm()); - payer.setWholAddr(basicInfo.getOwner_adres_full()); - - boolean saved = payerBean.create(payer); - if (saved) - return payer; - - return payerBean.getPayer(vhrno, rtpyrNo); - } - public int createCvlcpts(List petitions) { int affected = 0; UnaryOperator parseDate = str -> { diff --git a/src/main/java/cokr/xit/fims/payer/Payer.java b/src/main/java/cokr/xit/fims/payer/Payer.java index e73f94f9..17e7df52 100644 --- a/src/main/java/cokr/xit/fims/payer/Payer.java +++ b/src/main/java/cokr/xit/fims/payer/Payer.java @@ -1,6 +1,7 @@ package cokr.xit.fims.payer; import cokr.xit.foundation.AbstractEntity; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoResponse; import lombok.Getter; import lombok.Setter; @@ -160,4 +161,14 @@ public class Payer extends AbstractEntity { * 납부자 휴대 전화번호 */ private String rtpyrMblTelno; + + /** 차량 기본정보 */ + private BasicInfoResponse.BasicInfo vehicleInfo; + + /**"차량번호-납부자번호"를 반환한다. + * @return "차량번호-납부자번호" + */ + public String getKey() { + return String.format("%s-%s", vhrno, rtpyrNo); + } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/fims/payer/service/PayerService.java b/src/main/java/cokr/xit/fims/payer/service/PayerService.java index bc50ecc5..5bf47d18 100644 --- a/src/main/java/cokr/xit/fims/payer/service/PayerService.java +++ b/src/main/java/cokr/xit/fims/payer/service/PayerService.java @@ -5,6 +5,7 @@ import java.util.List; import cokr.xit.fims.payer.Payer; import cokr.xit.fims.payer.PayerQuery; import cokr.xit.foundation.data.DataObject; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoRequest; /**납부자 대장 관리 서비스 인터페이스. * @@ -51,5 +52,11 @@ public interface PayerService { * @param rtpyrIds 납부자 아이디 * @return 저장된 정보수 */ - public int remove(String... rtpyrIds); + int remove(String... rtpyrIds); + + /**주어진 조건의 차량 및 소유자(납부자) 정보를 반환한다. + * @param req 자동차 기본정보 조회 조건 + * @return 차량 및 소유자(납부자) 정보 + */ + Payer getVehicleOwner(BasicInfoRequest req); } \ No newline at end of file diff --git a/src/main/java/cokr/xit/fims/payer/service/bean/PayerBean.java b/src/main/java/cokr/xit/fims/payer/service/bean/PayerBean.java index 3fda3b0e..846b5801 100644 --- a/src/main/java/cokr/xit/fims/payer/service/bean/PayerBean.java +++ b/src/main/java/cokr/xit/fims/payer/service/bean/PayerBean.java @@ -1,6 +1,8 @@ package cokr.xit.fims.payer.service.bean; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.Resource; @@ -11,8 +13,11 @@ import cokr.xit.fims.payer.PayerQuery; import cokr.xit.fims.payer.dao.PayerMapper; import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.data.DataObject; +import cokr.xit.interfaces.lvis.service.bean.VehicleInfoBean; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoRequest; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoResponse; -/**납부자 대장 정보 관리 Bean +/**납부자 정보 관리 Bean * *

상세 설명: * @@ -24,21 +29,23 @@ import cokr.xit.foundation.data.DataObject; */ @Component("payerBean") public class PayerBean extends AbstractComponent { - /** 납부자 대장 정보 DAO */ + /** 납부자 정보 DAO */ @Resource(name = "payerMapper") private PayerMapper payerMapper; + @Resource(name = "vehicleInfoBean") + private VehicleInfoBean vehicleInfoBean; - /**지정한 조건에 따라 납부자 대장 목록을 조회하여 반환한다. - * @param req 납부자 대장 조회 조건 - * @return 납부자 대장 목록 + /**지정한 조건에 따라 납부자 목록을 조회하여 반환한다. + * @param req 납부자 조회 조건 + * @return 납부자 목록 */ public List getPayerList(PayerQuery req) { return payerMapper.selectPayerList(req); } - /**지정한 조건에 따라 납부자 대장 객체들을 반환한다. - * @param req 납부자 대장 조회 조건 - * @return 납부자 대장 객체 목록 + /**지정한 조건에 따라 납부자 객체들을 반환한다. + * @param req 납부자 조회 조건 + * @return 납부자 객체 목록 */ public List getPayers(PayerQuery req) { return payerMapper.selectPayers(req); @@ -50,8 +57,8 @@ public class PayerBean extends AbstractComponent { return !payers.isEmpty() ? payers.get(0) : null; } - /**납부자 대장 정보를 등록한다. - * @param payer 납부자 대장 + /**납부자 정보를 등록한다. + * @param payer 납부자 * @return 저장 여부 *

  • 저장됐으면 true
  • *
  • 그렇지 않으면 false
  • @@ -61,8 +68,8 @@ public class PayerBean extends AbstractComponent { return payerMapper.insert(payer); } - /**납부자 대장 정보를 수정한다. - * @param payer 납부자 대장 + /**납부자 정보를 수정한다. + * @param payer 납부자 * @return 저장 여부 *
    • 저장됐으면 true
    • *
    • 그렇지 않으면 false
    • @@ -72,11 +79,61 @@ public class PayerBean extends AbstractComponent { return payerMapper.update(payer); } - /**납부자 대장 정보를 삭제한다. + /**납부자 정보를 삭제한다. * @param rtpyrIds 납부자 아이디 * @return 저장된 정보수 */ public int remove(String... rtpyrIds) { return payerMapper.delete(rtpyrIds); } + + public List getVehicleOwners(List reqs) { + Map vehicleMap = vehicleInfoBean.getBasicInfo(reqs).stream() + .collect(Collectors.toMap(resp -> resp.getBasicInfo().getKey(), resp -> resp)); + + return vehicleMap.values().stream() + .map(resp -> getPayer(resp.getBasicInfo())) + .toList(); + } + + /**시군구 코드와 차량 기본정보에서 납부자 정보를 생성하거나, 등록정보에서 조회하여 반환한다.(차량번호 / 납부자 번호 / 시군구 기준) + * @param basicInfo 차량 기본정보 + * @return 납부자 정보 + */ + private Payer getPayer(BasicInfoResponse.BasicInfo basicInfo) { + Payer payer = new Payer(); + + payer.setSggCd(basicInfo.getSggCd()); + String vhrno = basicInfo.getVhrno(); + payer.setVhrno(vhrno); + payer.setRtpyrSeCd(basicInfo.getMber_se_code()); + String rtpyrNo = basicInfo.getMber_se_no(); + payer.setRtpyrNo(rtpyrNo); + payer.setRtpyrNm(basicInfo.getMber_nm()); + payer.setRtpyrTelno(basicInfo.getTelno()); + payer.setRoadNmCd(basicInfo.getUse_strnghld_road_nm_code()); + payer.setUdgdSeCd(basicInfo.getUsgsrhld_undgrnd_buld_se_code()); + String str = basicInfo.getUse_strnghld_buld_main_no(); + if (!isEmpty(str)) + payer.setBmno(toInt(str)); + str = basicInfo.getUse_strnghld_buld_sub_no(); + if (!isEmpty(str)) + payer.setBsno(toInt(str)); + payer.setStdgCd(basicInfo.getUse_strnghld_legaldong_code()); + payer.setDongCd(basicInfo.getUse_strnghld_adstrd_code()); + payer.setMtnSeCd(basicInfo.getUse_strnghld_mntn()); + str = basicInfo.getUse_strnghld_lnbr(); + if (!isEmpty(str)) + payer.setMno(toInt(str)); + str = basicInfo.getUse_strnghld_ho(); + if (!isEmpty(str)) + payer.setSno(toInt(str)); + payer.setDtlAddr(basicInfo.getUse_strnghld_adres_nm()); + payer.setWholAddr(basicInfo.getOwner_adres_full()); + + Payer result = create(payer) ? payer : getPayer(vhrno, rtpyrNo); + if (result != null) + result.setVehicleInfo(basicInfo); + return result; + } } \ No newline at end of file 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 198d2793..268864af 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 @@ -11,6 +11,7 @@ import cokr.xit.fims.payer.PayerQuery; import cokr.xit.fims.payer.service.PayerService; import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoRequest; /**납부자 대장 서비스 구현체. * @@ -52,4 +53,10 @@ public class PayerServiceBean extends AbstractServiceBean implements PayerServic public int remove(String... rtpyrIds) { return payerBean.remove(rtpyrIds); } + + @Override + public Payer getVehicleOwner(BasicInfoRequest req) { + List payers = payerBean.getVehicleOwners(List.of(req)); + return !payers.isEmpty() ? payers.get(0) : null; + } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/fims/payer/web/PayerController.java b/src/main/java/cokr/xit/fims/payer/web/PayerController.java index 3d9630a9..918c9c40 100644 --- a/src/main/java/cokr/xit/fims/payer/web/PayerController.java +++ b/src/main/java/cokr/xit/fims/payer/web/PayerController.java @@ -4,6 +4,7 @@ import java.util.List; import javax.annotation.Resource; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @@ -12,6 +13,7 @@ import cokr.xit.fims.payer.Payer; import cokr.xit.fims.payer.PayerQuery; import cokr.xit.fims.payer.service.PayerService; import cokr.xit.foundation.web.AbstractController; +import cokr.xit.interfaces.lvis.service.reg.BasicInfoRequest; /**납부자 서비스의 웹 컨트롤러 * @@ -23,6 +25,7 @@ import cokr.xit.foundation.web.AbstractController; * ================================ * */ +@Controller @RequestMapping(name = "납부자", value = "/payer") public class PayerController extends AbstractController { /**납부자 서비스*/ @@ -100,4 +103,14 @@ public class PayerController extends AbstractController { .addObject("affected", affected) .addObject("saved", affected > 0); } + + @PostMapping(name = "차량/납부자 조회", value = "/vehicle.do") + public ModelAndView getVehicleOwner(BasicInfoRequest req) { + Payer payer = payerService.getVehicleOwner(req); + boolean found = payer != null; + return new ModelAndView("jsonView") + .addObject("found", found) + .addObject("rtpyrId", found ? payer.getRtpyrId() : null) + .addObject("vehicle", found ? payer.getVehicleInfo() : null); + } } \ No newline at end of file diff --git a/src/main/resources/sql/mapper/fims/payer-mapper.xml b/src/main/resources/sql/mapper/fims/payer-mapper.xml index 04bc5a0a..d6e5e041 100644 --- a/src/main/resources/sql/mapper/fims/payer-mapper.xml +++ b/src/main/resources/sql/mapper/fims/payer-mapper.xml @@ -96,8 +96,9 @@ /* 납부자 대장 등록(payerMapper.insertPayer) */ - + SELECT CONCAT(THIS_YEAR, LPAD(IFNULL(SUBSTR(MAX(RTPYR_ID), 5) + 1, 1), 16, '0')) NEW_ID + , IFNULL(#{sggCd}, '41480') SGG_CD FROM TB_PAYER A , (SELECT DATE_FORMAT(CURRENT_DATE, '%Y') THIS_YEAR) B WHERE RTPYR_ID LIKE CONCAT(THIS_YEAR, '%') @@ -138,7 +139,7 @@ INSERT INTO TB_PAYER ( , MDFR ) SELECT #{rtpyrId} - , '41480' + , #{sggCd} , #{vhrno} , #{rtpyrInptSeCd} , #{rtpyrSeCd} @@ -177,6 +178,7 @@ SELECT #{rtpyrId} FROM TB_PAYER B WHERE VHRNO = #{vhrno} AND RTPYR_NO = #{rtpyrNo} + AND SGG_CD = #{sggCd} ) /* 납부자 대장 등록(payerMapper.insertHistory) */