diff --git a/src/Contract/Contract.java b/src/Contract/Contract.java index 7c5efa0..11a598a 100644 --- a/src/Contract/Contract.java +++ b/src/Contract/Contract.java @@ -1,6 +1,10 @@ package Contract; +import Customer.Customer; +import Insurance.Insurance; + import java.util.Date; +import java.util.HashMap; public class Contract { private int id; @@ -161,8 +165,17 @@ public boolean reexamine(String underwritingState, int employeeID, int insurance return false; } - public boolean calculateLossRatio(int insuranceID, int customerID){ - return false; + public HashMap calculateLossRatio(Insurance insurance, Customer customer){ + HashMap result = new HashMap<>(); + double estimatedEarning, estimatedPayment; + estimatedEarning = (this.period/this.paymentTerm) * this.premium; + estimatedPayment = this.paymentRate * insurance.getPrice(); + this.lossRatio = estimatedPayment/estimatedEarning; + result.put("estimatedEarning", Double.toString(estimatedEarning)); + result.put("estimatedPayment", Double.toString(estimatedPayment)); + result.put("lossRatio", Double.toString(this.lossRatio)); + result.put("isResult", "true"); + return result; } public double calculatePremium(int insuranceID, double paymentRate){ diff --git a/src/Contract/Reinsurance.java b/src/Contract/Reinsurance.java index 1be5b62..83b32e7 100644 --- a/src/Contract/Reinsurance.java +++ b/src/Contract/Reinsurance.java @@ -1,20 +1,130 @@ package Contract; +import Customer.Customer; +import Insurance.Insurance; + import java.util.HashMap; public class Reinsurance { - private HashMap reinsuranceContractDetails; private int id; - private HashMap reinsuranceCompanyManagerInfo; + //private HashMap reinsuranceContractDetails; + private int period; + private double paymentAmount; + private double contractRate; + private double lossRatio; + //private HashMap reinsuranceCompanyManagerInfo; + private String reinsuranceCompanyName; + private String reinsuranceCompanyManagerName; + private String reinsuranceCompanyManagerContract; private int contractID; private String contractResult; + private String rejectionReasons; - public Reinsurance(){ + public double getContractRate() { + return contractRate; + } + + public void setContractRate(double contractRate) { + this.contractRate = contractRate; + } + + public double getLossRatio() { + return lossRatio; + } + + public void setLossRatio(double lossRatio) { + this.lossRatio = lossRatio; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } + + public double getPaymentAmount() { + return paymentAmount; + } + + public void setPaymentAmount(double paymentAmount) { + this.paymentAmount = paymentAmount; + } + + public String getReinsuranceCompanyName() { + return reinsuranceCompanyName; + } + public void setReinsuranceCompanyName(String reinsuranceCompanyName) { + this.reinsuranceCompanyName = reinsuranceCompanyName; } + public String getReinsuranceCompanyManagerName() { + return reinsuranceCompanyManagerName; + } + + public void setReinsuranceCompanyManagerName(String reinsuranceCompanyManagerName) { + this.reinsuranceCompanyManagerName = reinsuranceCompanyManagerName; + } + + public String getReinsuranceCompanyManagerContract() { + return reinsuranceCompanyManagerContract; + } + + public void setReinsuranceCompanyManagerContract(String reinsuranceCompanyManagerContract) { + this.reinsuranceCompanyManagerContract = reinsuranceCompanyManagerContract; + } + + public int getContractID() { + return contractID; + } + + public void setContractID(int contractID) { + this.contractID = contractID; + } + + public String getContractResult() { + return contractResult; + } + + public void setContractResult(String contractResult) { + this.contractResult = contractResult; + } + + public String getRejectionReasons() { + return rejectionReasons; + } + + public void setRejectionReasons(String rejectionReasons) { + this.rejectionReasons = rejectionReasons; + } + + public Reinsurance(){ + + } + public HashMap calculateLossRatio(Contract contract, Insurance insurance){ + HashMap result = new HashMap<>(); + double estimatedEarning, estimatedPayment; + estimatedEarning = (contract.getPeriod()/contract.getPaymentTerm()) * contract.getPremium(); + estimatedPayment = (contract.getPaymentRate() * insurance.getPrice() * (1-this.contractRate)) + ((this.period) * this.paymentAmount); + this.lossRatio = estimatedPayment/estimatedEarning; + result.put("estimatedEarning", Double.toString(estimatedEarning)); + result.put("estimatedPayment", Double.toString(estimatedPayment)); + result.put("lossRatio", Double.toString(this.lossRatio)); + result.put("isResult", "true"); + return result; + } public HashMap contract(HashMap contractDetails, String reinsuracneCompanyManagerContact, HashMap employeeInfo){ return null; } diff --git a/src/Dao/ContractDao.java b/src/Dao/ContractDao.java new file mode 100644 index 0000000..b285630 --- /dev/null +++ b/src/Dao/ContractDao.java @@ -0,0 +1,126 @@ +package Dao; + +import Contract.Contract; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class ContractDao extends Dao{ + public ContractDao(){ + try { + super.connect(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + public void create(Contract contract){ + String query = "INSERT INTO Contract VALUES(" + + contract.getContractorID()+"," + + contract.getInsuranceID()+"," + + "'"+contract.getInsuredCustomerID()+"'," + + "'"+contract.getEmployeeID()+"'," + + contract.getFee()+"," + + contract.getPremium()+"," + + contract.getPaymentRate()+"," + + contract.getPeriod()+"," + + "'"+contract.getSignedDate()+"'," + + "'"+contract.getExpirationDate()+"'," + + contract.getPaymentTerm()+"," + + contract.getLossRatio()+"," + + "'"+contract.getUnderwritingState()+"'," + + "'"+contract.getRejectionReasons()+"'" + + ");"; + super.create(query); + } + public Contract retrieveById(int contractID) { + String query = "SELECT * FROM Contract WHERE id = '"+ + contractID+"';"; + Contract contract = null; + try { + ResultSet resultSet = super.retrieve(query); + while(resultSet.next()) { + contract = new Contract(); + contract.setId(resultSet.getInt("id")); + contract.setContractorID(resultSet.getInt("contractorID")); + contract.setInsuranceID(resultSet.getInt("insuranceID")); + contract.setInsuredCustomerID(resultSet.getString("insuredCustomerID")); + contract.setEmployeeID(resultSet.getString("employeeID")); + contract.setFee(resultSet.getDouble("fee")); + contract.setPremium(resultSet.getDouble("premium")); + contract.setPaymentRate(resultSet.getDouble("paymentRate")); + contract.setPeriod(resultSet.getInt("period")); + contract.setSignedDate(resultSet.getDate("signedDate")); + contract.setExpirationDate(resultSet.getDate("expirationDate")); + contract.setPaymentTerm(resultSet.getInt("paymentTerm")); + contract.setLossRatio(resultSet.getDouble("lossRatio")); + contract.setUnderwritingState(resultSet.getString("underwritingState")); + contract.setRejectionReasons(resultSet.getString("rejectionReasons")); + } + resultSet.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return contract; + } + public ArrayList retrieveAll() { + String query = "SELECT * FROM Contract;"; + ArrayList contractList = null; + try { + ResultSet resultSet = super.retrieve(query); + contractList = new ArrayList(); + while(resultSet.next()) { + Contract contract = new Contract(); + contract.setId(resultSet.getInt("id")); + contract.setContractorID(resultSet.getInt("contractorID")); + contract.setInsuranceID(resultSet.getInt("insuranceID")); + contract.setInsuredCustomerID(resultSet.getString("insuredCustomerID")); + contract.setEmployeeID(resultSet.getString("employeeID")); + contract.setFee(resultSet.getDouble("fee")); + contract.setPremium(resultSet.getDouble("premium")); + contract.setPaymentRate(resultSet.getDouble("paymentRate")); + contract.setPeriod(resultSet.getInt("period")); + contract.setSignedDate(resultSet.getDate("signedDate")); + contract.setExpirationDate(resultSet.getDate("expirationDate")); + contract.setPaymentTerm(resultSet.getInt("paymentTerm")); + contract.setLossRatio(resultSet.getDouble("lossRatio")); + contract.setUnderwritingState(resultSet.getString("underwritingState")); + contract.setRejectionReasons(resultSet.getString("rejectionReasons")); + contractList.add(contract); + + } + resultSet.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return contractList; + } + public void update(Contract contract){ + String query = "UPDATE Contract SET " + + "contractorID = " + contract.getContractorID() + ", " + + "insuranceID = " + contract.getInsuranceID() + ", " + + "insuredCustomerID = '" + contract.getInsuredCustomerID() + "', " + + "employeeID = '" + contract.getEmployeeID() + "', " + + "fee = " + contract.getFee() + ", " + + "premium = " + contract.getPremium() + ", " + + "paymentRate = " + contract.getPaymentRate() + ", " + + "period = " + contract.getPeriod() + ", " + + "signedDate = '" + contract.getSignedDate() + "', " + + "expirationDate = '" + contract.getExpirationDate() + "', " + + "paymentTerm = " + contract.getPaymentTerm() + ", " + + "lossRatio = " + contract.getLossRatio() + ", " + + "underwritingState = '" + contract.getUnderwritingState() + "', " + + "rejectionReasons = '" + contract.getRejectionReasons() + "'" + + "WHERE id = " + contract.getId() + ";"; + super.update(query); + } + public void deleteById(int contractID){ + String query = "DELETE FROM Contract WHERE id = "+contractID+";"; + super.delete(query); + } + public void deleteAll(){ + String query = "DELETE FROM Contract;"; + super.deleteAll(query); + } + +} diff --git a/src/Dao/ReinsuranceDao.java b/src/Dao/ReinsuranceDao.java new file mode 100644 index 0000000..636493b --- /dev/null +++ b/src/Dao/ReinsuranceDao.java @@ -0,0 +1,110 @@ +package Dao; + +import Contract.Reinsurance; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class ReinsuranceDao extends Dao{ + public ReinsuranceDao(){ + try { + super.connect(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + public void create(Reinsurance reinsurance){ + String query = "INSERT INTO Reinsurance VALUES(" + + reinsurance.getPeriod()+"," + + reinsurance.getPaymentAmount()+"," + + reinsurance.getContractRate()+"," + + reinsurance.getLossRatio()+"," + + "'"+reinsurance.getReinsuranceCompanyName()+"'," + + "'"+reinsurance.getReinsuranceCompanyManagerName()+"'," + + "'"+reinsurance.getReinsuranceCompanyManagerContract()+"'," + + "'"+reinsurance.getContractResult()+"'," + + "'"+reinsurance.getRejectionReasons()+"'," + + reinsurance.getContractID()+"," + + ");"; + super.create(query); + } + public Reinsurance retrieveById(int reinsuranceID) { + String query = "SELECT * FROM Reinsurance WHERE id = '"+ + reinsuranceID+"';"; + Reinsurance reinsurance = null; + try { + ResultSet resultSet = super.retrieve(query); + while(resultSet.next()) { + reinsurance = new Reinsurance(); + reinsurance.setId(resultSet.getInt("id")); + reinsurance.setPeriod(resultSet.getInt("period")); + reinsurance.setPaymentAmount(resultSet.getDouble("paymentAmount")); + reinsurance.setContractRate(resultSet.getDouble("contractRate")); + reinsurance.setLossRatio(resultSet.getDouble("lossRatio")); + reinsurance.setReinsuranceCompanyName(resultSet.getString("reinsuranceCompanyName")); + reinsurance.setReinsuranceCompanyManagerName(resultSet.getString("reinsuranceCompanyManagerName")); + reinsurance.setReinsuranceCompanyManagerContract(resultSet.getString("reinsuranceCompanyManagerContract")); + reinsurance.setContractResult(resultSet.getString("contractResult")); + reinsurance.setRejectionReasons(resultSet.getString("rejectionReasons")); + reinsurance.setContractID(resultSet.getInt("contractID")); + } + resultSet.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return reinsurance; + } + public ArrayList retrieveAll() { + String query = "SELECT * FROM Reinsurance;"; + ArrayList reinsuranceList = null; + try { + ResultSet resultSet = super.retrieve(query); + reinsuranceList = new ArrayList(); + while(resultSet.next()) { + Reinsurance reinsurance = new Reinsurance(); + reinsurance.setId(resultSet.getInt("id")); + reinsurance.setPeriod(resultSet.getInt("period")); + reinsurance.setPaymentAmount(resultSet.getDouble("paymentAmount")); + reinsurance.setContractRate(resultSet.getDouble("contractRate")); + reinsurance.setLossRatio(resultSet.getDouble("lossRatio")); + reinsurance.setReinsuranceCompanyName(resultSet.getString("reinsuranceCompanyName")); + reinsurance.setReinsuranceCompanyManagerName(resultSet.getString("reinsuranceCompanyManagerName")); + reinsurance.setReinsuranceCompanyManagerContract(resultSet.getString("reinsuranceCompanyManagerContract")); + reinsurance.setContractResult(resultSet.getString("contractResult")); + reinsurance.setRejectionReasons(resultSet.getString("rejectionReasons")); + reinsurance.setContractID(resultSet.getInt("contractID")); + reinsuranceList.add(reinsurance); + + } + resultSet.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return reinsuranceList; + } + public void update(Reinsurance reinsurance){ + String query = "UPDATE Reinsurance SET " + + "period = " + reinsurance.getPeriod() + ", " + + "paymentAmount = " + reinsurance.getPaymentAmount() + ", " + + "contractRate = " + reinsurance.getLossRatio() + ", " + + "lossRatio = " + reinsurance.getLossRatio() + ", " + + "reinsuranceCompanyName = '" + reinsurance.getReinsuranceCompanyName() + "', " + + "reinsuranceCompanyManagerName = '" + reinsurance.getReinsuranceCompanyManagerName() + "', " + + "reinsuranceCompanyManagerContract = '" + reinsurance.getReinsuranceCompanyManagerContract() + "', " + + "contractResult = '" + reinsurance.getContractResult() + "', " + + "rejectionReasons = '" + reinsurance.getRejectionReasons() + "', " + + "contractID = " + reinsurance.getContractID() + ", " + + "WHERE id = " + reinsurance.getId() + ";"; + super.update(query); + } + public void deleteById(int reinsuranceID){ + String query = "DELETE FROM Reinsurance WHERE id = "+reinsuranceID+";"; + super.delete(query); + } + public void deleteAll(){ + String query = "DELETE FROM Reinsurance;"; + super.deleteAll(query); + } + +} diff --git a/src/Employee/UWTeam.java b/src/Employee/UWTeam.java index 6133c9a..496a08e 100644 --- a/src/Employee/UWTeam.java +++ b/src/Employee/UWTeam.java @@ -1,6 +1,8 @@ package Employee; import Contract.Contract; +import util.Banker; +import util.BaseException; import java.util.ArrayList; import java.util.HashMap; @@ -11,12 +13,37 @@ public class UWTeam extends Employee { private ArrayList responsibleContractIDList; private String bankClerkContact; - public UWTeam(){ + public String getFfsContact() { + return ffsContact; + } + public void setFfsContact(String ffsContact) { + this.ffsContact = ffsContact; + } + public ArrayList getResponsibleContractIDList() { + return responsibleContractIDList; + } + public void setResponsibleContractIDList(ArrayList responsibleContractIDList) { + this.responsibleContractIDList = responsibleContractIDList; + } + public String getBankClerkContact() { + return bankClerkContact; + } + public void setBankClerkContact(String bankClerkContact) { + this.bankClerkContact = bankClerkContact; + } + public UWTeam(){ } - public HashMap requestCustomerInformation(HashMap basicCustomerInfo, String bankClerkContactContact){ - return null; + public HashMap requestCustomerInformation(HashMap basicCustomerInfo, String bankClerkContact) throws BaseException { + Banker banker = new Banker(bankClerkContact); + HashMap responseInfo = null; + try { + responseInfo = banker.requestInfo(basicCustomerInfo); + } catch (BaseException e) { + if(e.getMessage().equals("현재 고객 정보 요청에 대한 응답이 없어 재요청 하였습니다.")) responseInfo = banker.requestInfo(basicCustomerInfo); + } + return responseInfo; } public ArrayList getWaitStateContract(){ diff --git a/src/Insurance/Insurance.java b/src/Insurance/Insurance.java index 48acdc0..0c43221 100644 --- a/src/Insurance/Insurance.java +++ b/src/Insurance/Insurance.java @@ -16,6 +16,46 @@ public Insurance(){ } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public String getDetailedCategory() { + return detailedCategory; + } + + public void setDetailedCategory(String detailedCategory) { + this.detailedCategory = detailedCategory; + } + public HashMap getInfo(){ return null; } diff --git a/src/UI/DBFunctions.java b/src/UI/DBFunctions.java index 9418db0..65840df 100644 --- a/src/UI/DBFunctions.java +++ b/src/UI/DBFunctions.java @@ -83,7 +83,36 @@ public static boolean setDB(BufferedReader inputReader) throws IOException { "id VARCHAR(20) PRIMARY KEY,"+ "FOREIGN KEY (id) REFERENCES Employee (id) ON DELETE CASCADE ON UPDATE CASCADE"+ ");"); - + dao.execute("CREATE TABLE Contract(" + + "id INT AUTO_INCREMENT PRIMARY KEY," + + "fee DOUBLE," + + "premium DOUBLE," + + "paymentRate DOUBLE," + + "period INT," + + "signedDate DATE," + + "expirationDate DATE," + + "paymentTerm INT," + + "lossRatio DOUBLE," + + "underwritingState VARCHAR(50) DEFAULT '대기'," + + "rejectionReasons VARCHAR(200)," + + "FOREIGN KEY (contractorId) REFERENCES Customer (id) ON DELETE CASCADE ON UPDATE CASCADE" + +// "FOREIGN KEY (insuranceId) REFERENCES Insurance (id) ON DELETE CASCADE ON UPDATE CASCADE" + + "FOREIGN KEY (insuredCustomerId) REFERENCES InsuredCustomer (id) ON DELETE CASCADE ON UPDATE CASCADE" + + "FOREIGN KEY (employeeId) REFERENCES Employee (id) ON DELETE CASCADE ON UPDATE CASCADE" + + ");"); + dao.execute("CREATE TABLE Reinsurance(" + + "id INT AUTO_INCREMENT PRIMARY KEY," + + "period INT," + + "paymentAmount DOUBLE," + + "contractRate DOUBLE," + + "lossRatio DOUBLE," + + "reinsuranceCompanyName VARCHAR(200)," + + "reinsuranceCompanyManagerName VARCHAR(200)," + + "reinsuranceCompanyManagerContract VARCHAR(200)," + + "contractResult VARCHAR(200)," + + "rejectionReasons VARCHAR(200)," + + "FOREIGN KEY (contractId) REFERENCES Contract (id) ON DELETE CASCADE ON UPDATE CASCADE" + + ");"); /*Insert Values*/ registerEmployeeData(); registerCustomerData(); @@ -96,6 +125,8 @@ public static boolean setDB(BufferedReader inputReader) throws IOException { dao.execute("DROP TABLE InsuredCustomer;"); dao.execute("DROP TABLE Customer;"); dao.execute("DROP TABLE Accident;"); + dao.execute("DROP TABLE Contract;"); + dao.execute("DROP TABLE Reinsurance;"); diff --git a/src/UI/Main.java b/src/UI/Main.java index afa1849..4d0166e 100644 --- a/src/UI/Main.java +++ b/src/UI/Main.java @@ -11,6 +11,7 @@ import Employee.Employee; import Employee.AccidentReceptionTeam; import Employee.InvestigationTeam; +import Employee.UWTeam; import Accident.AccidentListImpl; import java.io.BufferedReader; import java.io.IOException; @@ -212,6 +213,10 @@ private static boolean showEmployeeMenu(BufferedReader inputReader) throws IOExc else if(currentEmployee instanceof InvestigationTeam){ } + else if(currentEmployee instanceof UWTeam){ + UWMain uwMain = new UWMain(currentEmployee); + isRemain = uwMain.showEmployeeMenu(inputReader); + } } return true; } diff --git a/src/UI/UWMain.java b/src/UI/UWMain.java new file mode 100644 index 0000000..81aa599 --- /dev/null +++ b/src/UI/UWMain.java @@ -0,0 +1,177 @@ +package UI; + +import Contract.Contract; +import Contract.Reinsurance; +import Customer.Customer; +import Dao.ContractDao; +import Dao.CustomerDao; +import Dao.ReinsuranceDao; +import Employee.Employee; +import Employee.UWTeam; +import Insurance.Insurance; +import util.BaseException; + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.HashMap; + +public class UWMain { + + private Employee employee; + private ContractDao contractDao; + private CustomerDao customerDao; + // private InsuranceDao insuranceDao; + private ReinsuranceDao reinsuranceDao; + public UWMain(Employee currentEmployee) { + this.employee = currentEmployee; + this.contractDao = new ContractDao(); + this.customerDao = new CustomerDao(); + //this.insuranceDao = new InsuranceDao(); + this.reinsuranceDao = new ReinsuranceDao(); + } + + + public boolean showEmployeeMenu(BufferedReader inputReader) throws IOException { + boolean isRemain = true; + String userChoiceValue; + while (isRemain) { + System.out.println("\n************************ UW Team MENU ************************"); + System.out.println("x. 로그아웃하기 logout"); + System.out.println("1. 고객 정보 요청하기 require customer info"); + System.out.println("2. 손해율 분석하기 calculate loss ratio"); + System.out.print("\nChoice: "); + userChoiceValue=inputReader.readLine().trim(); + + // E1(7초동안 화면 못 불러왔을 때) test code//////////////////// + int responseTime = (int) Math.random() * 10 +1; + if(responseTime >= 7) { + System.out.println("화면을 불러오지 못하고 있습니다. 같은 현상이 반복되면 고객센터에 신고해 주십시오.\n1. 확인"); + System.out.print("\nChoice: "); + inputReader.readLine().trim(); + continue; + } + //////////////////////////////////////////////////// + switch (userChoiceValue){ + case "x": + return false; + // 1. 고객정보 요청하기 + case "1": + HashMap basicCustomerInfo = new HashMap<>(); + HashMap responseInfo = null; + System.out.print("이름: "); basicCustomerInfo.put("name", inputReader.readLine().trim()); + System.out.print("\n주민등록번호: "); basicCustomerInfo.put("ssn", inputReader.readLine().trim()); + System.out.print("\n요청 사유: "); basicCustomerInfo.put("requestReason", inputReader.readLine().trim()); + try { + responseInfo = ((UWTeam) employee).requestCustomerInformation(basicCustomerInfo, ((UWTeam) employee).getBankClerkContact()); + } catch (BaseException e) {throw new RuntimeException(e);} + if(responseInfo.get("rejectReason") != null) System.out.println("고객 정보 요청이 거절되었습니다\n거절 사유: "+responseInfo.get("rejectReason")); + else{ + System.out.println("고객 정보가 조회 되었습니다.\n고객: "+basicCustomerInfo.get("name")+", "+basicCustomerInfo.get("ssn")+"\n고객의 정보"); + System.out.print("이름: "+responseInfo.get("name")); + System.out.print("\n나이: "+responseInfo.get("age")); + System.out.print("\n주소: "+responseInfo.get("address")); + System.out.print("\n재산: "+responseInfo.get("property")); + System.out.print("\n신용점수: "+responseInfo.get("creditScore")); + System.out.print("\n조회내역: "+responseInfo.get("viewHistory")); + System.out.print("\n변동내역: "+responseInfo.get("changeHistory")); + System.out.print("\n월 카드 사용금액: "+responseInfo.get("monthlyCardUsageAmount")); + System.out.print("\n대출내역: "+responseInfo.get("loanDetails")); + System.out.print("\n연체내역: "+responseInfo.get("overdueDetails")); + System.out.println("\n연대보증 내역: "+responseInfo.get("jointWarrantyDetails")); + } + break; + // 2. 손해율 분석하기 + case "2": + System.out.println("1. 보험 인수 손해율 계산, 2. 재보험 등록 손해율 계산"); + System.out.print("\nChoice: "); + userChoiceValue=inputReader.readLine().trim(); + switch (userChoiceValue){ + case "1": + System.out.println("손해율을 계산할 계약 ID를 입력해주세요."); + System.out.print("\nContract ID: "); + userChoiceValue=inputReader.readLine().trim(); + int contractId = Integer.parseInt(userChoiceValue); + Contract contract = contractDao.retrieveById(contractId); + Customer insuredCustomer =customerDao.retrieveById(contract.getInsuredCustomerID()); + HashMap reqCustomerInfos = new HashMap<>(); + HashMap insuredCustomerInfo = null; + reqCustomerInfos.put("name", insuredCustomer.getName()); + reqCustomerInfos.put("ssn", insuredCustomer.getRrn()); + reqCustomerInfos.put("requestReason", "보험 계약을 위한 고객 정보 요청"); + try { + insuredCustomerInfo = ((UWTeam) employee).requestCustomerInformation(reqCustomerInfos, ((UWTeam) employee).getBankClerkContact()); + } catch (BaseException e) {throw new RuntimeException(e);} + if(insuredCustomerInfo.get("rejectReason") != null) System.out.println("고객 정보 요청이 거절되었습니다\n거절 사유: "+insuredCustomerInfo.get("rejectReason")); + else{ + System.out.println("--고객 정보--\n고객: "+reqCustomerInfos.get("name")+", "+reqCustomerInfos.get("ssn")+"\n고객의 정보"); + System.out.print("이름: "+insuredCustomerInfo.get("name")); + System.out.print("\n나이: "+insuredCustomerInfo.get("age")); + System.out.print("\n주소: "+insuredCustomerInfo.get("address")); + System.out.print("\n재산: "+insuredCustomerInfo.get("property")); + System.out.print("\n신용점수: "+insuredCustomerInfo.get("creditScore")); + System.out.print("\n조회내역: "+insuredCustomerInfo.get("viewHistory")); + System.out.print("\n변동내역: "+insuredCustomerInfo.get("changeHistory")); + System.out.print("\n월 카드 사용금액: "+insuredCustomerInfo.get("monthlyCardUsageAmount")); + System.out.print("\n대출내역: "+insuredCustomerInfo.get("loanDetails")); + System.out.print("\n연체내역: "+insuredCustomerInfo.get("overdueDetails")); + System.out.println("\n연대보증 내역: "+insuredCustomerInfo.get("jointWarrantyDetails")); + } + // insuranceDao가 생성되면 주석 해제 +// Insurance insurance = insuranceDao.retrieveById(contract.getInsuranceID()); +// System.out.println("--보험 정보-- "); +// System.out.print("보험 상품 종류: "+insurance.getDetailedCategory()); +// System.out.print("\n상품 이름: "+insurance.getName()); +// System.out.print("\n지급 금액: "+insurance.getPrice()); +// System.out.print("\n계약 금액: "+contract.getPremium()); +// System.out.println("\n계약 기간: "+contract.getPeriod()); +// System.out.println("1. 손해율 분석 버튼"); +// System.out.print("\nChoice: "); +// inputReader.readLine(); +// HashMap result = contract.calculateLossRatio(insurance, insuredCustomer); +// if(result.get("isResult").equals("true")) { +// System.out.println("손해율 분석이 완료되었습니다."); +// System.out.print("예상 고객 납부금액: "+result.get("estimatedEarning")); +// System.out.print("\n예상 지급금액: "+result.get("estimatedPayment")); +// System.out.println("\n손해율: "+result.get("lossRatio")); +// } +// else{ +// System.out.println("손해율 측정에 실패하였습니다. 다시 시도해주세요."); +// } + break; + case "2": + System.out.println("손해율을 계산할 재보험 계약 ID를 입력해주세요."); + System.out.print("\nReinsurance Contract ID: "); + userChoiceValue=inputReader.readLine().trim(); + int reinsuranceId = Integer.parseInt(userChoiceValue); + Reinsurance reinsurance = reinsuranceDao.retrieveById(reinsuranceId); + System.out.println("--재보험 회사 정보--"); + System.out.print("재보험 회사 이름: "+reinsurance.getReinsuranceCompanyName()); + System.out.print("\n재보험 회사 담당자 이름: "+reinsurance.getReinsuranceCompanyManagerName()); + System.out.print("\n재보험 회사 담당자 연락처: "+reinsurance.getReinsuranceCompanyManagerContract()); + System.out.println("--계약 정보--"); + System.out.print("계약 금액: "+reinsurance.getPaymentAmount()); + System.out.print("\n계약 조건: "+reinsurance.getPeriod()); + System.out.println("\n재보험 대상 계약ID: "+reinsurance.getContractID()); + System.out.println("1. 손해율 분석 버튼"); + System.out.print("\nChoice: "); + inputReader.readLine(); + // insuranceDao가 생성되면 주석 해제 +// Contract targetContract = contractDao.retrieveById(reinsurance.getContractID()); +// Insurance targetInsurance = insuranceDao.retrieveById(targetContract.getInsuranceID()); +// HashMap result = reinsurance.calculateLossRatio(targetContract, targetInsurance); +// if(result.get("isResult").equals("true")) { +// System.out.println("손해율 분석이 완료되었습니다."); +// System.out.print("예상 고객 납부금액: "+result.get("estimatedEarning")); +// System.out.print("\n예상 지급금액: "+result.get("estimatedPayment")); +// System.out.println("\n손해율: "+result.get("lossRatio")); +// } +// else{ +// System.out.println("손해율 측정에 실패하였습니다. 다시 시도해주세요."); +// } + break; + } + } + } + return true; + } +} diff --git a/src/util/Banker.java b/src/util/Banker.java new file mode 100644 index 0000000..00f235e --- /dev/null +++ b/src/util/Banker.java @@ -0,0 +1,72 @@ +package util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; + +public class Banker { + BufferedReader inputReader; + public Banker(String bankClerkContact) { + this.inputReader = new BufferedReader(new InputStreamReader(System.in)); + } + + public HashMap requestInfo(HashMap basicCustomerInfo) throws BaseException{ + int responseTime = (int)Math.random()*10+1; + if(responseTime == 10) throw new BaseException("현재 고객 정보 요청에 대한 응답이 없어 재요청 하였습니다."); + System.out.println("____________은행원____________\n요청한 고객 정보" + + "\n이름: "+basicCustomerInfo.get("name")+"\n주민등록번호: "+basicCustomerInfo.get("ssn")+"\n요청 사유: "+basicCustomerInfo.get("requestReason")+ + "\n1. 요청 수락, 2. 요청 거절"); + System.out.print("\nChoice: "); + String bankerChoiceValue=null; + HashMap responseInfo = null; + try {bankerChoiceValue = inputReader.readLine().trim(); + switch (bankerChoiceValue){ + case "1": + responseInfo = inputCustomerInfo(basicCustomerInfo); + break; + case "2": + responseInfo = inputRejectReason(); + break; + } + }catch (IOException e) {throw new RuntimeException(e);} + return responseInfo; + } + private HashMap inputCustomerInfo(HashMap basicCustomerInfo) throws IOException { + HashMap responseInfo = new HashMap<>(); + System.out.println("1. 고객 정보 입력하기, 2. 고객 정보가 존재하지 않음"); + System.out.print("\nChoice: "); + String bankerChoiceValue = inputReader.readLine().trim(); + if(bankerChoiceValue.equals("2")) return inputRejectReason(); + else{ + System.out.print("이름: "); responseInfo.put("name", inputReader.readLine().trim()); + System.out.print("\n나이: "); responseInfo.put("age", inputReader.readLine().trim()); + System.out.print("\n주소: "); responseInfo.put("address", inputReader.readLine().trim()); + System.out.print("\n재산: "); responseInfo.put("property", inputReader.readLine().trim()); + System.out.print("\n신용점수: "); responseInfo.put("creditScore", inputReader.readLine().trim()); + System.out.print("\n조회내역: "); responseInfo.put("viewHistory", inputReader.readLine().trim()); + System.out.print("\n변동내역: "); responseInfo.put("changeHistory", inputReader.readLine().trim()); + System.out.print("\n월 카드 사용금액: "); responseInfo.put("monthlyCardUsageAmount", inputReader.readLine().trim()); + System.out.print("\n대출내역: "); responseInfo.put("loanDetails", inputReader.readLine().trim()); + System.out.print("\n연체내역: "); responseInfo.put("overdueDetails", inputReader.readLine().trim()); + System.out.print("\n연대보증 내역: "); responseInfo.put("jointWarrantyDetails", inputReader.readLine().trim()); + System.out.println("1. 전송하기"); System.out.print("\nChoice: "); inputReader.readLine().trim(); + // 고객 정보를 요청하다 E2 test code///////////////////////////// + int responseTime = (int)Math.random()*10+1; + if(responseTime == 10) { + System.out.println("고객 정보 전송에 실패하였습니다. 잠시 후 다시 시도해주세요."); + System.out.println("1. 전송하기"); System.out.print("\nChoice: "); inputReader.readLine().trim(); + } + ///////////////////////////////////////////////////////////// + return responseInfo; + } + } + private HashMap inputRejectReason() throws IOException { + HashMap responseInfo = new HashMap<>(); + System.out.print("거절 사유: "); responseInfo.put("rejectReason", inputReader.readLine().trim()); + System.out.println("1. 전송하기"); System.out.print("\nChoice: "); inputReader.readLine().trim(); + return responseInfo; + } + + +} diff --git a/src/util/BaseException.java b/src/util/BaseException.java new file mode 100644 index 0000000..b5dca90 --- /dev/null +++ b/src/util/BaseException.java @@ -0,0 +1,7 @@ +package util; + +public class BaseException extends Exception { + public BaseException(String message){ + super(message); + } +}