diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16dc712 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/Insurance_rock/ diff --git a/Insurance_rock/.classpath b/Insurance_rock/.classpath index 65b7cd6..f00af9b 100644 --- a/Insurance_rock/.classpath +++ b/Insurance_rock/.classpath @@ -6,7 +6,5 @@ - - diff --git a/Insurance_rock/DB/newContract.txt b/Insurance_rock/DB/newContract.txt new file mode 100644 index 0000000..d800886 --- /dev/null +++ b/Insurance_rock/DB/newContract.txt @@ -0,0 +1 @@ +123 \ No newline at end of file diff --git a/Insurance_rock/bin/.gitignore b/Insurance_rock/bin/.gitignore deleted file mode 100644 index 0fb2d98..0000000 --- a/Insurance_rock/bin/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/dao/ -/Accident/ -/Account/ -/Channel/ -/CompensateTeam/ -/Contract/ -/Customer/ -/FinancialDirector/ -/Insurance/ -/Main/ -/Payment/ -/Policyholder/ -/Provision/ -/SalesTeam/ -/User/ diff --git a/Insurance_rock/bin/Accident/Accident.class b/Insurance_rock/bin/Accident/Accident.class index 5f167c2..af91d53 100644 Binary files a/Insurance_rock/bin/Accident/Accident.class and b/Insurance_rock/bin/Accident/Accident.class differ diff --git a/Insurance_rock/bin/Accident/AccidentList.class b/Insurance_rock/bin/Accident/AccidentList.class index 29fddfb..4011236 100644 Binary files a/Insurance_rock/bin/Accident/AccidentList.class and b/Insurance_rock/bin/Accident/AccidentList.class differ diff --git a/Insurance_rock/bin/Accident/AccidentListImpl.class b/Insurance_rock/bin/Accident/AccidentListImpl.class index 03a8318..0f4b0d2 100644 Binary files a/Insurance_rock/bin/Accident/AccidentListImpl.class and b/Insurance_rock/bin/Accident/AccidentListImpl.class differ diff --git a/Insurance_rock/bin/Account/Account.class b/Insurance_rock/bin/Account/Account.class index 72454d2..86d31e9 100644 Binary files a/Insurance_rock/bin/Account/Account.class and b/Insurance_rock/bin/Account/Account.class differ diff --git a/Insurance_rock/bin/Channel/Channel.class b/Insurance_rock/bin/Channel/Channel.class index 645983a..2a3def4 100644 Binary files a/Insurance_rock/bin/Channel/Channel.class and b/Insurance_rock/bin/Channel/Channel.class differ diff --git a/Insurance_rock/bin/Channel/ChannelList.class b/Insurance_rock/bin/Channel/ChannelList.class index 6ff74f4..9a42a30 100644 Binary files a/Insurance_rock/bin/Channel/ChannelList.class and b/Insurance_rock/bin/Channel/ChannelList.class differ diff --git a/Insurance_rock/bin/Channel/ChannelListImpl.class b/Insurance_rock/bin/Channel/ChannelListImpl.class index f0d8ec8..2e7054d 100644 Binary files a/Insurance_rock/bin/Channel/ChannelListImpl.class and b/Insurance_rock/bin/Channel/ChannelListImpl.class differ diff --git a/Insurance_rock/bin/CompensateTeam/DamageAssessment.class b/Insurance_rock/bin/CompensateTeam/DamageAssessment.class index a5d1457..b91eb41 100644 Binary files a/Insurance_rock/bin/CompensateTeam/DamageAssessment.class and b/Insurance_rock/bin/CompensateTeam/DamageAssessment.class differ diff --git a/Insurance_rock/bin/Contract/Contract.class b/Insurance_rock/bin/Contract/Contract.class index 8460c57..f01e3fb 100644 Binary files a/Insurance_rock/bin/Contract/Contract.class and b/Insurance_rock/bin/Contract/Contract.class differ diff --git a/Insurance_rock/bin/Contract/ContractList.class b/Insurance_rock/bin/Contract/ContractList.class index 4201132..a1eb7ba 100644 Binary files a/Insurance_rock/bin/Contract/ContractList.class and b/Insurance_rock/bin/Contract/ContractList.class differ diff --git a/Insurance_rock/bin/Contract/ContractListImpl.class b/Insurance_rock/bin/Contract/ContractListImpl.class index 5005b58..54c9dd8 100644 Binary files a/Insurance_rock/bin/Contract/ContractListImpl.class and b/Insurance_rock/bin/Contract/ContractListImpl.class differ diff --git a/Insurance_rock/bin/Customer/Customer$Esex.class b/Insurance_rock/bin/Customer/Customer$Esex.class index b7e8acf..bce52fd 100644 Binary files a/Insurance_rock/bin/Customer/Customer$Esex.class and b/Insurance_rock/bin/Customer/Customer$Esex.class differ diff --git a/Insurance_rock/bin/Customer/Customer.class b/Insurance_rock/bin/Customer/Customer.class index fef8909..481cdb1 100644 Binary files a/Insurance_rock/bin/Customer/Customer.class and b/Insurance_rock/bin/Customer/Customer.class differ diff --git a/Insurance_rock/bin/Customer/CustomerList.class b/Insurance_rock/bin/Customer/CustomerList.class index 2a3f86c..7725e56 100644 Binary files a/Insurance_rock/bin/Customer/CustomerList.class and b/Insurance_rock/bin/Customer/CustomerList.class differ diff --git a/Insurance_rock/bin/Customer/CustomerListImpl.class b/Insurance_rock/bin/Customer/CustomerListImpl.class index c3e5395..d32fc63 100644 Binary files a/Insurance_rock/bin/Customer/CustomerListImpl.class and b/Insurance_rock/bin/Customer/CustomerListImpl.class differ diff --git a/Insurance_rock/bin/FinancialDirector/InsuranceJudge.class b/Insurance_rock/bin/FinancialDirector/InsuranceJudge.class index 9964b90..31b26a3 100644 Binary files a/Insurance_rock/bin/FinancialDirector/InsuranceJudge.class and b/Insurance_rock/bin/FinancialDirector/InsuranceJudge.class differ diff --git a/Insurance_rock/bin/Insurance/GeneralInsurance.class b/Insurance_rock/bin/Insurance/GeneralInsurance.class index e070c2f..1d09311 100644 Binary files a/Insurance_rock/bin/Insurance/GeneralInsurance.class and b/Insurance_rock/bin/Insurance/GeneralInsurance.class differ diff --git a/Insurance_rock/bin/Insurance/HouseInsurance.class b/Insurance_rock/bin/Insurance/HouseInsurance.class index bb2aa4d..e5895c0 100644 Binary files a/Insurance_rock/bin/Insurance/HouseInsurance.class and b/Insurance_rock/bin/Insurance/HouseInsurance.class differ diff --git a/Insurance_rock/bin/Insurance/Insurance$EInsurance.class b/Insurance_rock/bin/Insurance/Insurance$EInsurance.class index 32d01b9..5bee9ca 100644 Binary files a/Insurance_rock/bin/Insurance/Insurance$EInsurance.class and b/Insurance_rock/bin/Insurance/Insurance$EInsurance.class differ diff --git a/Insurance_rock/bin/Insurance/Insurance.class b/Insurance_rock/bin/Insurance/Insurance.class index 16e2be9..6c5a74f 100644 Binary files a/Insurance_rock/bin/Insurance/Insurance.class and b/Insurance_rock/bin/Insurance/Insurance.class differ diff --git a/Insurance_rock/bin/Insurance/InsuranceList.class b/Insurance_rock/bin/Insurance/InsuranceList.class index 17388ab..90b26ef 100644 Binary files a/Insurance_rock/bin/Insurance/InsuranceList.class and b/Insurance_rock/bin/Insurance/InsuranceList.class differ diff --git a/Insurance_rock/bin/Insurance/InsuranceListImpl.class b/Insurance_rock/bin/Insurance/InsuranceListImpl.class index c4d5a09..ff0f96c 100644 Binary files a/Insurance_rock/bin/Insurance/InsuranceListImpl.class and b/Insurance_rock/bin/Insurance/InsuranceListImpl.class differ diff --git a/Insurance_rock/bin/Main/Main.class b/Insurance_rock/bin/Main/Main.class index c5b7a40..9aaec72 100644 Binary files a/Insurance_rock/bin/Main/Main.class and b/Insurance_rock/bin/Main/Main.class differ diff --git a/Insurance_rock/bin/Payment/Payment$EInsuranceType.class b/Insurance_rock/bin/Payment/Payment$EInsuranceType.class index 0236f1c..7800943 100644 Binary files a/Insurance_rock/bin/Payment/Payment$EInsuranceType.class and b/Insurance_rock/bin/Payment/Payment$EInsuranceType.class differ diff --git a/Insurance_rock/bin/Payment/Payment.class b/Insurance_rock/bin/Payment/Payment.class index 568054a..a8419a6 100644 Binary files a/Insurance_rock/bin/Payment/Payment.class and b/Insurance_rock/bin/Payment/Payment.class differ diff --git a/Insurance_rock/bin/Payment/PaymentList.class b/Insurance_rock/bin/Payment/PaymentList.class index de7b4ed..ea94fe2 100644 Binary files a/Insurance_rock/bin/Payment/PaymentList.class and b/Insurance_rock/bin/Payment/PaymentList.class differ diff --git a/Insurance_rock/bin/Payment/PaymentListImpl.class b/Insurance_rock/bin/Payment/PaymentListImpl.class index c1ed0b3..2de2eb0 100644 Binary files a/Insurance_rock/bin/Payment/PaymentListImpl.class and b/Insurance_rock/bin/Payment/PaymentListImpl.class differ diff --git a/Insurance_rock/bin/Policyholder/FeePayment.class b/Insurance_rock/bin/Policyholder/FeePayment.class index 9809503..2aff826 100644 Binary files a/Insurance_rock/bin/Policyholder/FeePayment.class and b/Insurance_rock/bin/Policyholder/FeePayment.class differ diff --git a/Insurance_rock/bin/Provision/Provision$einsuranceType.class b/Insurance_rock/bin/Provision/Provision$einsuranceType.class index 69cf711..3b9e4d7 100644 Binary files a/Insurance_rock/bin/Provision/Provision$einsuranceType.class and b/Insurance_rock/bin/Provision/Provision$einsuranceType.class differ diff --git a/Insurance_rock/bin/Provision/Provision.class b/Insurance_rock/bin/Provision/Provision.class index 0d3889e..f8cdef5 100644 Binary files a/Insurance_rock/bin/Provision/Provision.class and b/Insurance_rock/bin/Provision/Provision.class differ diff --git a/Insurance_rock/bin/Provision/ProvisionList.class b/Insurance_rock/bin/Provision/ProvisionList.class index 0779949..14fe122 100644 Binary files a/Insurance_rock/bin/Provision/ProvisionList.class and b/Insurance_rock/bin/Provision/ProvisionList.class differ diff --git a/Insurance_rock/bin/Provision/ProvisionListImpl.class b/Insurance_rock/bin/Provision/ProvisionListImpl.class index adb63fa..205711c 100644 Binary files a/Insurance_rock/bin/Provision/ProvisionListImpl.class and b/Insurance_rock/bin/Provision/ProvisionListImpl.class differ diff --git a/Insurance_rock/bin/SalesTeam/ChannelManagement.class b/Insurance_rock/bin/SalesTeam/ChannelManagement.class index 301878d..962356d 100644 Binary files a/Insurance_rock/bin/SalesTeam/ChannelManagement.class and b/Insurance_rock/bin/SalesTeam/ChannelManagement.class differ diff --git a/Insurance_rock/bin/SalesTeam/CustomerManagement.class b/Insurance_rock/bin/SalesTeam/CustomerManagement.class index 3acdac6..1e46255 100644 Binary files a/Insurance_rock/bin/SalesTeam/CustomerManagement.class and b/Insurance_rock/bin/SalesTeam/CustomerManagement.class differ diff --git a/Insurance_rock/bin/SalesTeam/InsuranceSales.class b/Insurance_rock/bin/SalesTeam/InsuranceSales.class index ff0d08c..ca54f1b 100644 Binary files a/Insurance_rock/bin/SalesTeam/InsuranceSales.class and b/Insurance_rock/bin/SalesTeam/InsuranceSales.class differ diff --git a/Insurance_rock/bin/User/CompensateTeam.class b/Insurance_rock/bin/User/CompensateTeam.class index 49c85b0..912e8d5 100644 Binary files a/Insurance_rock/bin/User/CompensateTeam.class and b/Insurance_rock/bin/User/CompensateTeam.class differ diff --git a/Insurance_rock/bin/User/ContractTeam.class b/Insurance_rock/bin/User/ContractTeam.class index 35f42e0..fd03669 100644 Binary files a/Insurance_rock/bin/User/ContractTeam.class and b/Insurance_rock/bin/User/ContractTeam.class differ diff --git a/Insurance_rock/bin/User/FinancialDirector.class b/Insurance_rock/bin/User/FinancialDirector.class index d7e3060..1170e41 100644 Binary files a/Insurance_rock/bin/User/FinancialDirector.class and b/Insurance_rock/bin/User/FinancialDirector.class differ diff --git a/Insurance_rock/bin/User/SalesTeam.class b/Insurance_rock/bin/User/SalesTeam.class index 91f9852..16f3f87 100644 Binary files a/Insurance_rock/bin/User/SalesTeam.class and b/Insurance_rock/bin/User/SalesTeam.class differ diff --git a/Insurance_rock/bin/dao/AccidentDao.class b/Insurance_rock/bin/dao/AccidentDao.class new file mode 100644 index 0000000..55fceb8 Binary files /dev/null and b/Insurance_rock/bin/dao/AccidentDao.class differ diff --git a/Insurance_rock/bin/dao/ApplyContractDao.class b/Insurance_rock/bin/dao/ApplyContractDao.class new file mode 100644 index 0000000..db5464d Binary files /dev/null and b/Insurance_rock/bin/dao/ApplyContractDao.class differ diff --git a/Insurance_rock/bin/dao/ContractAccidentDao.class b/Insurance_rock/bin/dao/ContractAccidentDao.class new file mode 100644 index 0000000..a5a8fe7 Binary files /dev/null and b/Insurance_rock/bin/dao/ContractAccidentDao.class differ diff --git a/Insurance_rock/bin/dao/ContractDao.class b/Insurance_rock/bin/dao/ContractDao.class new file mode 100644 index 0000000..7ad64c0 Binary files /dev/null and b/Insurance_rock/bin/dao/ContractDao.class differ diff --git a/Insurance_rock/bin/dao/CustomerDao.class b/Insurance_rock/bin/dao/CustomerDao.class new file mode 100644 index 0000000..482f686 Binary files /dev/null and b/Insurance_rock/bin/dao/CustomerDao.class differ diff --git a/Insurance_rock/bin/dao/CustomerRankDao.class b/Insurance_rock/bin/dao/CustomerRankDao.class new file mode 100644 index 0000000..3245294 Binary files /dev/null and b/Insurance_rock/bin/dao/CustomerRankDao.class differ diff --git a/Insurance_rock/bin/dao/Dao.class b/Insurance_rock/bin/dao/Dao.class new file mode 100644 index 0000000..babf2bc Binary files /dev/null and b/Insurance_rock/bin/dao/Dao.class differ diff --git a/Insurance_rock/bin/dao/FailContractDao.class b/Insurance_rock/bin/dao/FailContractDao.class new file mode 100644 index 0000000..5c33673 Binary files /dev/null and b/Insurance_rock/bin/dao/FailContractDao.class differ diff --git a/Insurance_rock/bin/dao/GeneralRateDao.class b/Insurance_rock/bin/dao/GeneralRateDao.class new file mode 100644 index 0000000..dea1bbb Binary files /dev/null and b/Insurance_rock/bin/dao/GeneralRateDao.class differ diff --git a/Insurance_rock/bin/dao/HouseRateDao.class b/Insurance_rock/bin/dao/HouseRateDao.class new file mode 100644 index 0000000..0026355 Binary files /dev/null and b/Insurance_rock/bin/dao/HouseRateDao.class differ diff --git a/Insurance_rock/bin/dao/IRankDao.class b/Insurance_rock/bin/dao/IRankDao.class new file mode 100644 index 0000000..b75f078 Binary files /dev/null and b/Insurance_rock/bin/dao/IRankDao.class differ diff --git a/Insurance_rock/bin/dao/InsuranceDao.class b/Insurance_rock/bin/dao/InsuranceDao.class new file mode 100644 index 0000000..eddfc08 Binary files /dev/null and b/Insurance_rock/bin/dao/InsuranceDao.class differ diff --git a/Insurance_rock/bin/dao/PaymentDao.class b/Insurance_rock/bin/dao/PaymentDao.class new file mode 100644 index 0000000..e892803 Binary files /dev/null and b/Insurance_rock/bin/dao/PaymentDao.class differ diff --git a/Insurance_rock/bin/dao/ProvisionDao.class b/Insurance_rock/bin/dao/ProvisionDao.class new file mode 100644 index 0000000..b9b1fa3 Binary files /dev/null and b/Insurance_rock/bin/dao/ProvisionDao.class differ diff --git a/Insurance_rock/bin/dao/RegisterGeneralRateDao.class b/Insurance_rock/bin/dao/RegisterGeneralRateDao.class new file mode 100644 index 0000000..33413a4 Binary files /dev/null and b/Insurance_rock/bin/dao/RegisterGeneralRateDao.class differ diff --git a/Insurance_rock/bin/dao/RegisterHouseRate.class b/Insurance_rock/bin/dao/RegisterHouseRate.class new file mode 100644 index 0000000..33926c2 Binary files /dev/null and b/Insurance_rock/bin/dao/RegisterHouseRate.class differ diff --git a/Insurance_rock/bin/dao/RegisterInsuranceDao.class b/Insurance_rock/bin/dao/RegisterInsuranceDao.class new file mode 100644 index 0000000..f814a8c Binary files /dev/null and b/Insurance_rock/bin/dao/RegisterInsuranceDao.class differ diff --git a/Insurance_rock/bin/dao/RenewContractDao.class b/Insurance_rock/bin/dao/RenewContractDao.class new file mode 100644 index 0000000..9d7dd1d Binary files /dev/null and b/Insurance_rock/bin/dao/RenewContractDao.class differ diff --git a/Insurance_rock/src/Accident/Accident.java b/Insurance_rock/src/Accident/Accident.java index 83d18ea..33a5e3e 100644 --- a/Insurance_rock/src/Accident/Accident.java +++ b/Insurance_rock/src/Accident/Accident.java @@ -1,17 +1,9 @@ package Accident; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.sql.ResultSet; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; + +import dao.AccidentDao; //121234536456123 /** @@ -21,23 +13,30 @@ */ public class Accident { - private LocalDate accidentDate; - private String content; + private String ID; private String contractID; + private String customerID; private String customerName; + private String phoneNum; + private LocalDate accidentDate; + private String content; + private int totalCost; private int damagePer; - private String ID; private String kindOfCost; - private int liablityCost; - private int liablityRate; private boolean payCompleted; - private String phoneNum; - private int totalCost; - private File file; - -// AccidentListImpl accidentListimpl; + private int liablityRate; + private int liablityCost; + private AccidentDao accidentDAO; + private int Num; + public String getCustomerID() { + return customerID; + } + + public void setCustomerID(String customerID) { + this.customerID = customerID; + } public Accident() { - + this.accidentDAO = new AccidentDao(); } public LocalDate getAccidentDate() { @@ -140,87 +139,77 @@ public void finalize() throws Throwable { } - public void add() { - if (!file.exists()) { - try { - file.createNewFile(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else { - try { - FileWriter fileWriter = new FileWriter(file, true); - int payCompletedCheck = 0; - if (this.payCompleted) { - payCompletedCheck = 1; - } - // 사고번호ID, 계약번호 ,가입자명, 연락처,사고날짜,사고내용 ,손해정도,비용종류,지급여부,총비용,책임비용,책임비율 - fileWriter.write(this.getID() + " " + this.getContractID() + " " + this.getCustomerName() + " " - + this.getPhoneNum() + " " + this.getAccidentDate() + " " + this.getContent() + " " - + this.getDamagePer() + " " + this.getKindOfCost() + " " + payCompletedCheck + " " - + this.getTotalCost() + " " + this.getLiablityCost() + " " + this.getLiablityRate() + "\n"); + public boolean edit() { + return true; + } - fileWriter.close(); + public int getNum() { + return Num; + } + + public void setNum(int num) { + Num = num; + } + - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + public void survey() { } - public boolean edit() { - return true; + + + + + public boolean addaccident() {//사고번호ID, 계약ID ,고객ID,가입자명, 연락처,사고날짜,사고내용 ,총비용,손해정도,비용종류,지급여부,책임비율,책임비용 +// + return accidentDAO.creat(this); + // TODO Auto-generated method stub + } - public void search(String customerName_inser, LocalDate accidentDate_inser, boolean empty) { - // 검색한것을 보여줄려면...? 가입자명과 사고날짜가 같다면. 거기에 해당하는 파일 내용 보여주기. - Path path = Paths.get(".//DB//Accident_DB.txt"); - Charset cs = StandardCharsets.UTF_8; - List list = new ArrayList(); - String[] readfilesplit = null; - try { - list = Files.readAllLines(path,cs); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - for(String readLine : list) { - readfilesplit = readLine.split(" "); - String strDate = readfilesplit[4]; - DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - LocalDate strToLocalDateTime = LocalDate.parse(strDate, format); + public ResultSet retriveaccident() { + // TODO Auto-generated method stub + return accidentDAO.retriveaccident(this); - if(readfilesplit[2].equals(customerName_inser) && strToLocalDateTime.isEqual(accidentDate_inser)) { - System.out.println(readLine); - System.out.println(customerName_inser+"님의 해당 사고날짜의 정보가 출력되었습니다."); - empty = false; - } - } - - // 다읽어보구... 해당하는것만 set해서 넣어... 그리고 get으로 가져와. - // set의 정보와 VectorList의 비교는 다름! set한것을 Vertor에 넣기! - -// //사고번호ID, 계약번호 ,가입자명, 연락처,사고날짜,사고내용 ,손해정도,비용종류,지급여부,총비용,책임비용,책임비율 -// this.setID(readfilesplit[0]); -// this.setContractID(readfilesplit[1]); -// this.setCustomerName(readfilesplit[2]); -// this.setPhoneNum(readfilesplit[3]); -// this.setAccidentDate(readfilesplit[4]); -// this.setContent(readfilesplit[5]); -// this.setDamagePer(readfilesplit[6]); -// this.setKindOfCost(readfilesplit[7]); -// this.setPayCompleted(readfilesplit[8]); -// this.setTotalCost(readfilesplit[9]); -// this.setLiablityCost(readfilesplit[10]); -// this.setLiablityRate(readfilesplit[11]); + } + + + + public boolean updatedate(LocalDate accidentdate) { + return accidentDAO.updatedate(this , accidentdate); } - public void survey() { + public void updatecontent(String content) { + accidentDAO.updatecontent(this , content); + + } + public void updatetotal(int totalCost) { + accidentDAO.updatetotal(this , totalCost); + + } + + public void updateDamage(int damagePer) { + accidentDAO.updateDamage(this , damagePer); + + } + + public void updateKind(String kindOfCost) { + accidentDAO.updateKind(this , kindOfCost); + } + public void updateLiablityCost(int liablityCost) { + accidentDAO.updateLiablityCost(this , liablityCost); } + + public void updateLiablityRate(int liablityRate) { + accidentDAO.updateLiablityRate(this , liablityRate); + + } + + + + + }// end Accident \ No newline at end of file diff --git a/Insurance_rock/src/Accident/AccidentList.java b/Insurance_rock/src/Accident/AccidentList.java index 486c626..7f398c4 100644 --- a/Insurance_rock/src/Accident/AccidentList.java +++ b/Insurance_rock/src/Accident/AccidentList.java @@ -1,5 +1,7 @@ package Accident; +import java.sql.ResultSet; +import java.time.LocalDate; import java.util.ArrayList; @@ -11,9 +13,10 @@ public interface AccidentList { public boolean add(Accident accident); public boolean delete(String ID); - public void update(); + public ResultSet update(); - public ArrayList get(String phoneNum, String customerName); + public ArrayList get(String customerName_inser, String phoneNum_inser); + public ArrayList getAll(); }//end AccidentList \ No newline at end of file diff --git a/Insurance_rock/src/Accident/AccidentListImpl.java b/Insurance_rock/src/Accident/AccidentListImpl.java index 6ff2f3e..1c38a83 100644 --- a/Insurance_rock/src/Accident/AccidentListImpl.java +++ b/Insurance_rock/src/Accident/AccidentListImpl.java @@ -1,6 +1,14 @@ package Accident; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; import java.util.ArrayList; +import java.util.UUID; + +import Contract.Contract; +import dao.AccidentDao; +import dao.ContractDao; /** @@ -11,14 +19,28 @@ public class AccidentListImpl implements AccidentList { private ArrayList accidentList = new ArrayList(); + private AccidentDao accidentDAO; public AccidentListImpl(){ + this.accidentDAO = new AccidentDao(); + +// this.setAccident(); + + } + + private void setAccident() { + ResultSet resultSet = accidentDAO.retrive(); + //사고번호ID, 계약ID ,고객ID,가입자명, 연락처,사고날짜,사고내용 ,총비용,손해정도,비용종류,지급여부,책임비율,책임비용 + + + } public void finalize() throws Throwable { } + public boolean add(Accident accident){ if(this.accidentList.add(accident)) { return true; @@ -33,14 +55,40 @@ public boolean delete(String ID){ return false; } - public void update(){ + + + public ArrayList get(String customerName_inser, String phoneNum_inser) { + ArrayList inforAccident = new ArrayList(); + for(Accident accident: this.accidentList) { + if(accident.getCustomerName().equals(customerName_inser) && accident.getPhoneNum().equals(phoneNum_inser)) { + inforAccident.add(accident); + } + } + + if(!(inforAccident.isEmpty())) { + return inforAccident; + } + // TODO Auto-generated method stub + return null; + } + @Override + public ArrayList getAll() { + return this.accidentList; } - public ArrayList get(String phoneNum, String customerName) { + public void getcontract() { + + // TODO Auto-generated method stub + + } + + + + public ArrayList get(String customerName_inser, LocalDate accidentDate_inser) { ArrayList inforAccident = new ArrayList(); for(Accident accident: this.accidentList) { - if(accident.getPhoneNum().equals(phoneNum) && accident.getCustomerName().equals(customerName)) { + if(accident.getCustomerName().equals(customerName_inser) && accident.getAccidentDate().isEqual(accidentDate_inser)) { inforAccident.add(accident); } } @@ -51,4 +99,28 @@ public ArrayList get(String phoneNum, String customerName) { // TODO Auto-generated method stub return null; } + + public Accident getNum(int num) { + for(Accident accident: this.accidentList) { + if(accident.getNum() == num ) { + return accident; + } + } + // TODO Auto-generated method stub + return null; + + } + + @Override + public ResultSet update() { + // TODO Auto-generated method stub + return null; + } + + + + + + + }//end AccidentListImpl \ No newline at end of file diff --git a/Insurance_rock/src/Channel/Channel.java b/Insurance_rock/src/Channel/Channel.java index 8e7174c..249d2cc 100644 --- a/Insurance_rock/src/Channel/Channel.java +++ b/Insurance_rock/src/Channel/Channel.java @@ -3,12 +3,16 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.util.ArrayList; import java.util.Scanner; +import dao.ChannelDao; + public class Channel { private String channelID; @@ -18,11 +22,16 @@ public class Channel { private int monthlyExpense; private int sumOfExpense; private ChannelList channelList; + private ChannelDao channelDAO; - public Channel() { - } + public Channel() { + this.channelList = new ChannelListImpl(); + this.channelDAO = new ChannelDao(); + + this.setChnnel(); + } public void showChannel() { if (!(this.channelList == null)) { System.out @@ -38,35 +47,30 @@ public void showChannel() { System.out.println(); } } - } - - public void setChnnel() { - this.channelList = new ChannelListImpl(); + private void setChnnel() { + ResultSet resultSet = channelDAO.retrive(); + try { - File file = new File(".//DB//Channel.txt"); - - @SuppressWarnings("resource") - Scanner fileScanner = new Scanner(file); - - while (fileScanner.hasNextLine()) { - Channel tempChannel = new Channel(); - tempChannel.setChannelID(fileScanner.next()); - tempChannel.setChannelName(fileScanner.next()); - tempChannel.setRegisterDate(LocalDate.parse(fileScanner.next())); - tempChannel.setNumOfRegister(fileScanner.nextInt()); - tempChannel.setMonthlyExpense(fileScanner.nextInt()); - tempChannel.setSumOfExpense(fileScanner.nextInt()); - fileScanner.nextLine(); - this.channelList.add(tempChannel); + while (resultSet.next()) { + Channel tempChannel = new Channel(); + tempChannel.setChannelID(resultSet.getString("ChannelID")); + tempChannel.setChannelName(resultSet.getString("channelName")); + tempChannel.setRegisterDate(LocalDate.parse(resultSet.getString("registerDate"))); + tempChannel.setNumOfRegister(resultSet.getInt("numOfRegister")); + tempChannel.setMonthlyExpense(resultSet.getInt("monthlyExpense")); + tempChannel.setSumOfExpense(resultSet.getInt("sumOfExpense")); + this.channelList.add(tempChannel); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - } catch (IOException e) { - System.out.println( - "파일 접근 중 문제가 생겨 보험 정보를 불러오지 못했습니다. 잠시후 다시 실행 해주십시오. 해당 문제가 계속 발생할 시에는 사내 시스템 관리팀(1234-5678)에게 문의 주시기 바랍니다."); - e.printStackTrace(); - } - } + + + +} public void addChannel() { Scanner scanner = new Scanner(System.in); diff --git a/Insurance_rock/src/CompensateTeam/DamageAssessment.java b/Insurance_rock/src/CompensateTeam/DamageAssessment.java index c12498a..37769a6 100644 --- a/Insurance_rock/src/CompensateTeam/DamageAssessment.java +++ b/Insurance_rock/src/CompensateTeam/DamageAssessment.java @@ -1,83 +1,151 @@ package CompensateTeam; +import java.sql.ResultSet; +import java.sql.SQLException; import java.time.LocalDate; import java.util.Scanner; import java.util.UUID; import Accident.Accident; +import Accident.AccidentListImpl; import Contract.Contract; +import Contract.ContractListImpl; public class DamageAssessment { - Accident accident; - Contract contract; + private ContractListImpl contractList; + private AccidentListImpl accidentList; + private Accident accident; + private Contract contract; public DamageAssessment() { + this.accidentList = new AccidentListImpl(); + this.accident = new Accident(); + this.contractList = new ContractListImpl(); this.contract = new Contract(); + } public boolean selectAccidentMenagement(Scanner scanner) { - System.out.println("1. 사고검색, 2. 사고 추가, 0. 취소"); - String selectNum = scanner.next(); - this.accident = new Accident(); + boolean isSearch = false; + boolean overcheck = false; + while (!isSearch) { + System.out.println("사고를 접수하기 위한 메뉴 선택해주세요."); + System.out.println("1. 검색, 2. 추가, 0. 취소 "); + String selectNum = scanner.next(); + switch (selectNum) { + case "1": + overcheck = search(); + if (!overcheck) { + showAccident(); + return compansate(scanner); + } + break; + case "2": + overcheck = addcheck(); + if (!overcheck) { + showConctarct(scanner); + return add(scanner); + } + break; + case "0": + System.out.println("취소되었습니다. 전 선택창으로 돌아갑니다"); + return true; + default: + System.out.println("선택 이상함"); + break; + } + } + return isSearch; + + } + private boolean compansate(Scanner scanner) { + System.out.println("1. 보상금 지급, 2. 수정"); + String selectNum = scanner.next(); switch (selectNum) { case "1": - search(); - break; + return paycompansate(scanner); + case "2": - add(); - break; - case "0": - System.out.println("취소되었습니다. 전 선택창으로 돌아갑니다"); - return true; - default: - System.out.println("선택 이상함"); + update(scanner); break; } return false; - } + } - private void search() { - Scanner scanner = new Scanner(System.in); + private boolean paycompansate(Scanner scanner) { + System.out.println("보상금을 지급할 계약을 선택해주세요."); + int num; + num = scanner.nextInt(); + this.accident = accidentList.getNum(num); + System.out.println(" 가입자명 : " + this.accident.getCustomerName()+"\n 연락처: "+ this.accident.getPhoneNum()+ "\n 사고번호 : "+ this.accident.getID() + + "\n 의 사고의"+ this.accident.getLiablityCost() + "원을 지급하겠습니까? \n 지급을 원하시면 1번, 취소를 원하시면 2번을 입력해주세요."); + String selectNum = scanner.next(); + if(selectNum.equals("1")) { + requestconstomer(); + }else if(selectNum.equals("2")) { + System.out.println("홈 화면으로 돌아갑니다."); + return true; + } + return false; + + } - System.out.println("<사고내역을 출력할 가입자명과 사고날짜를 입력해 주세요.>"); - System.out.println("가입자명 :"); - String customerName_inser = scanner.nextLine(); + private void requestconstomer() { + + // TODO Auto-generated method stub + + } - System.out.println("사고날짜 [년(공백) 월(공백) 일] :"); - String date = scanner.nextLine(); + private void showAccident() { + System.out.println( + "-------------------------------------------------------------------------------------------------------------------------------------------------------"); + System.out.printf("%10s %35s %7s %7s %10s %20s %18s %15s %15s %15s %15s %15s", "사고ID", "계약ID", "고객ID", "가입자명", + "연락처", "사고날짜", "사고내용", "총비용", "손해정도", "비용종류", "지급여부", "책입비율", "책임비용"); + System.out.println(); + System.out.println( + "------------------------------------------------------------------------------------------------------------------------------------------------------------"); - String[] dateArray = date.split(" "); - int[] intArray = new int[dateArray.length]; + for (Accident accident : this.accidentList.getAll()) { - for (int i = 0; i < intArray.length; i++) { - intArray[i] = Integer.parseInt(dateArray[i]); + System.out.format("%5s %7s %7s %7s %20s %12s %7s %15s %7s %12s %15s %10s", + accident.getNum() + "." + accident.getID(), accident.getContractID(), accident.getCustomerID(), + accident.getCustomerName(), accident.getPhoneNum(), accident.getAccidentDate(), + accident.getContent(), accident.getTotalCost(), accident.getDamagePer(), accident.getKindOfCost(), + accident.isPayCompleted(), accident.getLiablityRate(), accident.getLiablityCost()); + System.out.println(); } - LocalDate accidentDate_inser = LocalDate.of(intArray[0], intArray[1], intArray[2]); - boolean empty = false; - if (!empty) { - accident.search(customerName_inser, accidentDate_inser, empty); - System.out.println("1. 보상금 지급, 2. 수정"); - String selectNum = scanner.next(); - switch (selectNum) { - case "1": - - break; - case "2": + } - break; - } - } else {// E3. DB접근에 실패한 경우 - System.out.println("DB 접근 오류: 정보 접근에 실패하였습니다. 해당 문제가 계속 발생할 시에는 사내시스템 관리팀(1234-5678)에게 문의 주시기 바랍니다."); + private void showConctarct(Scanner scanner) { + // CosntractList. + + System.out.println("<사고를 추가할 계약을 선택하세요.>"); + System.out.println( + "------------------------------------------------------------------------------------------------------------------------------"); + System.out.printf("%5s %7s %7s %7s %10s %20s %18s %15s %15s %15s %15s %15s %15s", "계약ID", "고객ID", "가입자명", "연락처", + "보험ID", "보험이름", "납부방식", "보험료", "미납액", "담보액", "지급액", "가입일", "만료일"); + System.out.println(); + System.out.println( + "------------------------------------------------------------------------------------------------------------------------------"); + for (Contract contract : this.contractList.getAll()) { + System.out.format("%5s %7s %7s %7s %20s %12s %7s %15s %7s %12s %15s %10s %10s", contract.getContractID(), + contract.getCustomerID(), contract.getCustomerName(), contract.getPhoneNum(), + contract.getInsuranceID(), contract.getInsuranceName(), contract.getPaymentCycle(), + contract.getInsuranceFee(), contract.getUnpaidFee(), contract.getSecurityFee(), + contract.getProvisionFee(), contract.getStartDate(), contract.getEndDate()); + System.out.println(); } + // TODO Auto-generated method stub + } - private void add() { + private boolean addcheck() { // 가입자명, 사고날짜, 연락처가 해당 고객과 동일하다면 거기에 이어서 사고내역 추가하기 검색은 불러오기. Scanner scanner = new Scanner(System.in); @@ -89,33 +157,237 @@ private void add() { System.out.println("연락처 :"); String phoneNum_inser = scanner.nextLine(); - System.out.println("사고날짜 [년(공백) 월(공백) 일:"); - String date = scanner.nextLine(); + contract.setCustomerName(customerName_inser); + contract.setPhoneNum(phoneNum_inser); + // + ResultSet resultSet = contract.retrivecontract(); + // 사고번호ID, 계약ID ,고객ID,가입자명, 연락처,사고날짜,사고내용 ,총비용,손해정도,비용종류,지급여부,책임비율,책임비용 + + try { + while (resultSet.next()) { + Contract contract = new Contract(); + contract.setContractID(resultSet.getString("contractID")); + contract.setCustomerID(resultSet.getString("customerID")); + contract.setCustomerName(resultSet.getString("customerName")); + contract.setPhoneNum(resultSet.getString("customerPhoneNum")); + contract.setInsuranceID(resultSet.getString("insuranceID")); + contract.setInsuranceName(resultSet.getString("insuranceName")); + contract.setPaymentCycle(resultSet.getInt("paymentCycle")); + contract.setInsuranceFee(resultSet.getInt("insuranceFee")); + contract.setUnpaidFee(resultSet.getInt("unpaidFee")); + contract.setSecurityFee(resultSet.getInt("securityFee")); + contract.setProvisionFee(resultSet.getInt("provisionFee")); + contract.setStartDate(LocalDate.parse(resultSet.getString("startDate"))); + contract.setEndDate(LocalDate.parse(resultSet.getString("endDate"))); + contractList.add(contract); + } // 계약ID, 고객ID, 가입자명, 연락처, 보험ID, 보험이름, 납부방식, 보험료, 미납액, 담보액, 지급액, 가입일, 만료일 + } catch (SQLException e) { + System.out.println( + "파일 접근 중 문제가 생겨 사고정보를 불러오지 못했습니다. 잠시후 다시 실행 해주십시오. 해당 문제가 계속 발생할 시에는 사내 시스템 관리팀(1234-5678)에게 문의 주시기 바랍니다."); + // TODO Auto-generated catch block + e.printStackTrace(); + } + + boolean overcheck = false; + while (!overcheck) { + if (this.contractList.getcheck(customerName_inser, phoneNum_inser) != null) { + return overcheck = false; + } else { + System.out.println("해당 계약이 존재하지 않습니다. 다시 입력해주세요."); + return overcheck = true; + } + } + return overcheck; + + } - String[] dateArray = date.split(" "); - int[] intArray = new int[dateArray.length]; + // 사고정보(사고내용, 비용, 종류, 손해정도, 총비용, 책임 비용, 책임비율 )입력창과 계약 목록 선택창??과 추가, 취소버튼을 출력. - for (int i = 0; i < intArray.length; i++) { - intArray[i] = Integer.parseInt(dateArray[i]); + private boolean search() { + Scanner scanner = new Scanner(System.in); + boolean overcheck = true; + + System.out.println("<사고내역을 출력할 가입자명과 사고날짜를 입력해 주세요.>"); + System.out.println("가입자명 :"); + String customerName_inser = scanner.nextLine(); + System.out.println("<사고날짜>"); + System.out.println("년도 : "); + int year = scanner.nextInt(); + System.out.println("월 : "); + int monty = scanner.nextInt(); + System.out.println("일 : "); + int date = scanner.nextInt(); + +// String[] dateArray = date.split(" "); +// int[] intArray = new int[dateArray.length]; +// +// for (int i = 0; i < intArray.length; i++) { +// intArray[i] = Integer.parseInt(dateArray[i]); +// +// } + LocalDate accidentDate_inser = LocalDate.of(year, monty, date); + accident.setCustomerName(customerName_inser); + accident.setAccidentDate(accidentDate_inser); + + ResultSet resultSet = accident.retriveaccident(); + int num = 1; + try { + while (resultSet.next()) { + Accident accident = new Accident(); + accident.setNum(num); + accident.setID(resultSet.getString("accidentID")); + accident.setContractID(resultSet.getString("contractID")); + accident.setCustomerID(resultSet.getString("customerID")); + accident.setCustomerName(resultSet.getString("customerName")); + accident.setPhoneNum(resultSet.getString("customerPhoneNum")); + accident.setAccidentDate(LocalDate.parse(resultSet.getString("accidentDate"))); + accident.setContent(resultSet.getString("content")); + accident.setTotalCost(resultSet.getInt("totalCost")); + accident.setDamagePer(resultSet.getInt("damagePer")); + accident.setKindOfCost(resultSet.getString("kindOfCost")); + accident.setPayCompleted(resultSet.getBoolean("payCompleted")); + accident.setLiablityRate(resultSet.getInt("liablityRate")); + accident.setLiablityCost(resultSet.getInt("liablityCost")); + overcheck = false; + num++; + accidentList.add(accident); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - LocalDate accidentDate_inser = LocalDate.of(intArray[0], intArray[1], intArray[2]); - - // 임의의 데이터------------------------어떻게 가져와야할지 모르겠어서 우선 get set함. - contract.setCustomerName("여다은"); - contract.setPhoneNum("01031932436"); - contract.setContractID("a"); - // --------------------------------- - String content = null; - String kindOfCost = null; - int damagePer = 0; - int totalCost = 0; - int liablityCost = 0; - int liablityRate = 0; - if (contract.getCustomerName().equals(customerName_inser) && contract.getPhoneNum().equals(phoneNum_inser)) { - // 고객이 있다면, 사고를 접수할건데 그 데이터의 연결은 어떻게 하지? - System.out.println("<사고내용, 종류, 손해정도, 총비용, 책임 비용, 책임비율을 입력하세요>"); + if(accidentList.get(customerName_inser, accidentDate_inser) != null) { + return overcheck; + }else { + System.out.println("사고정보를 찾지못했습니다.사고날짜와 가입자명을 오탈자없이 적어주세요"); + } + +// isSearch = accident.search(customerName_inser, accidentDate_inser, isSearch); + + return overcheck; + + } + + private void update(Scanner scanner) { + System.out.println("수정할 보험을 선택해주세요."); + int num; + num = scanner.nextInt(); + this.accident = accidentList.getNum(num); + + if(num != 0) { + System.out.println("수정할 항목을 선택해주세요."); + System.out.println("1. 사고날짜 : "+ this.accident.getAccidentDate()); + System.out.println("2. 사고내용 :"+ this.accident.getContent()); + System.out.println("3. 총비용 : "+this.accident.getTotalCost()); + System.out.println("4. 손해정도 : "+this.accident.getDamagePer()); + System.out.println("5. 비용종류 : "+ this.accident.getKindOfCost()); + System.out.println("6. 책임비용 :"+this.accident.getLiablityCost()); + System.out.println("7. 책임비율 : "+this.accident.getLiablityRate()); + String selectNum = scanner.next(); + if(selectNum.equals("1")) { + System.out.println("수정할 사고날짜를 입력해주세요"); + System.out.println("년도 : "); + int year = scanner.nextInt(); + System.out.println("월 : "); + int monty = scanner.nextInt(); + System.out.println("일 : "); + int date = scanner.nextInt(); + LocalDate accidentdate = LocalDate.of(year, monty, date); + this.accident.updatedate(accidentdate); + this.accident.setAccidentDate(accidentdate); + }else if(selectNum.equals("2")) { + System.out.println("수정할 사고내용을 입력해주세요"); + String content = scanner.next(); + accident.updatecontent(content); + this.accident.setContent(content); + }else if(selectNum.equals("3")) { + System.out.println("수정할 총비용을 입력해주세요"); + int totalCost = scanner.nextInt(); + accident.updatetotal(totalCost); + this.accident.setTotalCost(totalCost); + }else if(selectNum.equals("4")) { + System.out.println("수정할 손해정도를 입력해주세요"); + int damagePer = scanner.nextInt(); + accident.updateDamage(damagePer); + this.accident.setDamagePer(damagePer); + }else if(selectNum.equals("5")) { + System.out.println("수정할 비용종류를 입력해주세요"); + String kindOfCost = scanner.next(); + accident.updateKind(kindOfCost); + this.accident.setKindOfCost(kindOfCost); + }else if(selectNum.equals("6")) { + System.out.println("수정할 책임비용을 입력해주세요"); + int liablityCost= scanner.nextInt(); + accident.updateLiablityCost(liablityCost); + this.accident.setLiablityCost(liablityCost); + }else if(selectNum.equals("7")) { + System.out.println("수정할 총비율을 입력해주세요"); + int liablityRate = scanner.nextInt(); + accident.updateLiablityRate(liablityRate); + this.accident.setLiablityRate(liablityRate); + } + + System.out.println("사고정보가 변경되었습니다."); + System.out.println( + "-------------------------------------------------------------------------------------------------------------------------------------------------------"); + System.out.printf("%10s %35s %7s %7s %10s %20s %18s %15s %15s %15s %15s %15s", "사고ID", "계약ID", "고객ID", "가입자명", + "연락처", "사고날짜", "사고내용", "총비용", "손해정도", "비용종류", "지급여부", "책입비율", "책임비용"); + System.out.println(); + System.out.println( + "------------------------------------------------------------------------------------------------------------------------------------------------------------"); + + System.out.format("%5s %7s %7s %7s %20s %12s %7s %15s %7s %12s %15s %10s", + accident.getNum() + "." + accident.getID(), accident.getContractID(), accident.getCustomerID(), + accident.getCustomerName(), accident.getPhoneNum(), accident.getAccidentDate(), + accident.getContent(), accident.getTotalCost(), accident.getDamagePer(), accident.getKindOfCost(), + accident.isPayCompleted(), accident.getLiablityRate(), accident.getLiablityCost()); + System.out.println(); + + System.exit(0); + + } + + + + } + + + private boolean add(Scanner scanner) { + + String contractID = null; + boolean isSearch = false; + while (!isSearch) { + System.out.println("<<사고를 추가할 계약번호(ID)을 입력해주세요.>>"); + contractID = scanner.next(); + if (this.contractList.get(contractID) != null) { + isSearch = true; + } else { + System.out.println("해당 계약이 존재하지 않습니다. 다시 입력해주세요."); + + } + } + if (isSearch) { + + String content = null; + String kindOfCost = null; + int damagePer = 0; + int totalCost = 0; + int liablityCost = 0; + int liablityRate = 0; + + System.out.println("<사고날짜, 사고내용, 종류, 손해정도, 총비용, 책임 비용, 책임비율을 입력하세요>"); + System.out.println("<사고날짜>"); + System.out.println("년도:"); + int year = scanner.nextInt(); + System.out.println("월:"); + int month = scanner.nextInt(); + System.out.println("일"); + int date = scanner.nextInt(); + + LocalDate accidentDate_inser = LocalDate.of(year, month, date); + System.out.println("사고내용 :"); - content = scanner.nextLine(); + content = scanner.next(); System.out.println("종류 : "); kindOfCost = scanner.next(); @@ -132,24 +404,47 @@ private void add() { System.out.println("(숫자)책임 비율"); liablityRate = scanner.nextInt(); + // accidentList.get(customerName_inser, phoneNum_inser); + Contract contract = this.contractList.get(contractID); + accident.setID(UUID.randomUUID().toString()); accident.setContractID(contract.getContractID()); - accident.setPayCompleted(false); - accident.setAccidentDate(accidentDate_inser); + accident.setCustomerID(contract.getCustomerID()); accident.setCustomerName(contract.getCustomerName()); accident.setPhoneNum(contract.getPhoneNum()); + accident.setAccidentDate(accidentDate_inser); accident.setContent(content); - accident.setDamagePer(damagePer); accident.setKindOfCost(kindOfCost); + accident.setDamagePer(damagePer); accident.setTotalCost(totalCost); accident.setLiablityCost(liablityCost); + accident.setPayCompleted(false); accident.setLiablityRate(liablityRate); - accident.add();// 텍스트에 저장. + accidentList.add(accident); + } else { + System.out.println("추가가 취소되었습니다. 메인화면으로 돌아갑니다."); + } + // 사고번호ID, 계약ID ,고객ID,가입자명, 연락처,사고날짜,사고내용 ,총비용,손해정도,비용종류,지급여부,책임비율,책임비용 +// accidentList.addaccident(accidentDate_inser, content, kindOfCost, damagePer, totalCost, liablityCost, liablityRate); + + if (accident.addaccident()) { + System.out.println( + "-------------------------------------------------------------------------------------------------------------------------------------------------------"); + System.out.printf("%5s %7s %7s %7s %10s %20s %18s %15s %15s %15s %15s %15s", "사고ID", "계약ID", "고객ID", "고객이름", + "연락처", "사고날짜", "사고내용", "총비용", "손해정도", "비용종류", "지급여부", "책입비율", "책임비용"); + System.out.println(); + System.out.println( + "-------------------------------------------------------------------------------------------------------------------------------------------------------"); + + System.out.format("%5s %7s %7s %7s %20s %12s %7s %15s %7s %12s %15s %10s", accident.getID(), + accident.getContractID(), accident.getCustomerID(), accident.getCustomerName(), + accident.getPhoneNum(), accident.getAccidentDate(), accident.getContent(), accident.getTotalCost(), + accident.getDamagePer(), accident.getKindOfCost(), accident.isPayCompleted(), + accident.getLiablityRate(), accident.getLiablityCost()); + System.out.println(); System.out.println("사고정보가 추가되었습니다."); - } else {// E2. 고객에 해당하는 계약이 존재하지 않는 경우 - System.out.println("해당 고객이 가입한 보험이 존재하지 않습니다. 다시 입력해주세요."); } - // 사고정보(사고내용, 비용, 종류, 손해정도, 총비용, 책임 비용, 책임비율 )입력창과 계약 목록 선택창??과 추가, 취소버튼을 출력. + return isSearch; } diff --git a/Insurance_rock/src/Contract/Contract.java b/Insurance_rock/src/Contract/Contract.java index a365f08..80ab487 100644 --- a/Insurance_rock/src/Contract/Contract.java +++ b/Insurance_rock/src/Contract/Contract.java @@ -3,9 +3,12 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.sql.ResultSet; import java.time.LocalDate; import java.util.UUID; +import dao.ContractDao; + public class Contract { private String customerID; @@ -19,15 +22,15 @@ public class Contract { private String accidentHistory; private LocalDate endDate; private int insuranceFee; - private String paymentCycle; + private int paymentCycle; private int period; private int provisionFee; private int securityFee; private LocalDate startDate; private int unpaidFee; - + private ContractDao contractDAO; public Contract() { - + this.contractDAO = new ContractDao(); } public Contract(String contract) { @@ -144,11 +147,11 @@ public void setInsuranceID(String insuranceID) { this.insuranceID = insuranceID; } - public String getPaymentCycle() { + public int getPaymentCycle() { return paymentCycle; } - public void setPaymentCycle(String paymentCycle) { + public void setPaymentCycle(int paymentCycle) { this.paymentCycle = paymentCycle; } @@ -231,4 +234,12 @@ public void register() { } } + public ResultSet retrivecontract() { + return contractDAO.retrivecontract(this.getCustomerName(), this.getPhoneNum()); + + } + + + + }// end Contract \ No newline at end of file diff --git a/Insurance_rock/src/Contract/ContractListImpl.java b/Insurance_rock/src/Contract/ContractListImpl.java index 9b72c81..2a0abec 100644 --- a/Insurance_rock/src/Contract/ContractListImpl.java +++ b/Insurance_rock/src/Contract/ContractListImpl.java @@ -6,33 +6,58 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; import java.util.ArrayList; -public class ContractListImpl implements ContractList { +import Accident.Accident; +import Channel.Channel; +import dao.ContractDao; - private ArrayList contractList; +public class ContractListImpl implements ContractList { + private ArrayList contractList = new ArrayList(); + private Contract contract; + private ContractDao contractDAO; + public ContractListImpl(){ - init(); + this.contract = new Contract(); + this.contractDAO = new ContractDao(); +// this.setContract(); + } - private void init() { + + private void setContract() { + ResultSet resultSet = contractDAO.retrive(); + try { - BufferedReader contractFile = new BufferedReader(new FileReader(".//DB//ApplyContract.txt")); - this.contractList = new ArrayList(); - while (contractFile.ready()) { - String contract = contractFile.readLine(); - if (!contract.equals("")) { - this.contractList.add(new Contract(contract)); - } + while (resultSet.next()) { + Contract contract = new Contract(); + contract.setContractID(resultSet.getString("contractID")); + contract.setCustomerID(resultSet.getString("customerID")); + contract.setCustomerName(resultSet.getString("customerName")); + contract.setPhoneNum(resultSet.getString("customerPhoneNum")); + contract.setInsuranceID("insuranceID"); + contract.setInsuranceName(resultSet.getString("insuranceName")); + contract.setPaymentCycle(resultSet.getInt("paymentCycle")); + contract.setInsuranceFee(resultSet.getInt("insuranceFee")); + contract.setUnpaidFee(resultSet.getInt("unpaidFee")); + contract.setSecurityFee(resultSet.getInt("securityFee")); + contract.setProvisionFee(resultSet.getInt("provisionFee")); + contract.setStartDate(LocalDate.parse(resultSet.getString("startDate"))); + contract.setEndDate(LocalDate.parse(resultSet.getString("endDate"))); + + contractList.add(contract); } - contractFile.close(); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { + } catch (SQLException e) { + System.out.println( + "파일 접근 중 문제가 생겨 계약정보를 불러오지 못했습니다. 잠시후 다시 실행 해주십시오. 해당 문제가 계속 발생할 시에는 사내 시스템 관리팀(1234-5678)에게 문의 주시기 바랍니다."); + // TODO Auto-generated catch block e.printStackTrace(); } + // TODO Auto-generated method stub } @@ -67,6 +92,30 @@ public ArrayList get(String customerName, String phoneNum){ } + public ArrayList getAll() { + return this.contractList; + } + + + public Contract get(String contractID) { + for (Contract contract : this.contractList) { + if (contract.getContractID().equals(contractID)) { + return contract; + } + } + return null; + } + + + public Contract getcheck(String customerName_inser, String phoneNum_inser) { + for (Contract contract : this.contractList) { + if (contract.getCustomerName().equals(customerName_inser) && contract.getPhoneNum().equals(phoneNum_inser)) { + return contract; + } + } + return null; + } + // public boolean update(){ // // } diff --git a/Insurance_rock/src/ContractTeam/ContractManagement.java b/Insurance_rock/src/ContractTeam/ContractManagement.java index e664c1e..9863ff8 100644 --- a/Insurance_rock/src/ContractTeam/ContractManagement.java +++ b/Insurance_rock/src/ContractTeam/ContractManagement.java @@ -1,11 +1,46 @@ package ContractTeam; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.util.Scanner; + +import Accident.Accident; +import Accident.AccidentListImpl; +import Contract.Contract; +import Contract.ContractListImpl; +import dao.AccidentDao; +import dao.ContractDao; + public class ContractManagement { + + private Contract contract; + private ContractListImpl contractList; + private ContractDao contractDAO; + + public ContractManagement() { + this.contractList = new ContractListImpl(); + + } - public boolean searchContract() { + + public boolean searchContract(Scanner scanner) { return false; // TODO Auto-generated method stub } + public boolean viewContract(Scanner scanner) { + showContract(); + searchContract(scanner); + // TODO Auto-generated method stub + return false; + } + + private void showContract() { + + + } + + } diff --git a/Insurance_rock/src/Main/Main.java b/Insurance_rock/src/Main/Main.java index 7c3fd11..259b7c0 100644 --- a/Insurance_rock/src/Main/Main.java +++ b/Insurance_rock/src/Main/Main.java @@ -15,31 +15,33 @@ public class Main { public static void main(String[] args) { - - Scanner scanner = new Scanner(System.in); - System.out.println("1. 계약팀, 2. 금감원, 3. 마켓팅/영업팀, 4. 보상팀, 5.고객"); - String selectNum = scanner.next(); - - switch (selectNum) { - case "1": - selectContractTeam(scanner); - break; - case "2": - selectFinancialDirector(scanner); - break; - case "3": - selectSalesTeam(scanner); - break; - case "4": - selectCompensateTeam(scanner); - break; - - case "5": - selectCustomer(scanner); - break; - default: - System.out.println("제대로 입력해주세요."); - break; + + boolean continueSelect = false; + while(!continueSelect) { + Scanner scanner = new Scanner(System.in); + System.out.println("1. 계약팀, 2. 금감원, 3. 마켓팅/영업팀, 4. 보상팀, 5.고객"); + String selectNum = scanner.next(); + switch (selectNum) { + case "1": + selectContractTeam(scanner); + break; + case "2": + selectFinancialDirector(scanner); + break; + case "3": + selectSalesTeam(scanner); + break; + case "4": + selectCompensateTeam(scanner); + break; + case "5": + selectCustomer(scanner); + break; + default: + //while문 안먹음 사 + System.out.println("제대로 입력해주세요."); + break; + } } } @@ -61,7 +63,7 @@ private static void selectContractTeam(Scanner scanner) { break; case "3": ContractManagement contractManagement = new ContractManagement(); - continueSelect = contractManagement.searchContract(); + continueSelect = contractManagement.viewContract(scanner); break; case "0": System.exit(0); @@ -134,21 +136,25 @@ private static void selectCustomer(Scanner scanner) { } - private static void selectCompensateTeam(Scanner scanner) { - boolean continueSelect = true; + private static boolean selectCompensateTeam(Scanner scanner) { + boolean continueSelect = false; - while (continueSelect) { - System.out.println("1. 손해사정 "); + while (!continueSelect) { + System.out.println("1. 손해사정, 0. 취소 "); String selectNum = scanner.next(); switch (selectNum) { - case "1": + case "1": DamageAssessment damageAssessment = new DamageAssessment(); - continueSelect = damageAssessment.selectAccidentMenagement(scanner); - break; + return continueSelect = damageAssessment.selectAccidentMenagement(scanner); + + case "0": + System.out.println("취소되었습니다. 전 선택창으로 돌아갑니다"); + return true; default: System.out.println("선택 이상함"); break; } } + return continueSelect; } } diff --git a/Insurance_rock/src/SalesTeam/ChannelManagement.java b/Insurance_rock/src/SalesTeam/ChannelManagement.java index 3e4788c..09b3ba2 100644 --- a/Insurance_rock/src/SalesTeam/ChannelManagement.java +++ b/Insurance_rock/src/SalesTeam/ChannelManagement.java @@ -1,28 +1,37 @@ package SalesTeam; +import java.io.File; +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; import java.util.Scanner; import Channel.Channel; +import Channel.ChannelList; +import Channel.ChannelListImpl; +import dao.AccidentDao; +import dao.ChannelDao; public class ChannelManagement { - Channel channel; - + private Channel channel; + public ChannelManagement() { this.channel = new Channel(); - this.channel.setChnnel(); + + } + public void viewChannel() { - - showChannel(); + + this.channel.showChannel(); selectChannelManagement(); } - private void showChannel() { - this.channel.showChannel(); - } + private void selectChannelManagement() { Scanner scanner = new Scanner(System.in); @@ -88,7 +97,7 @@ private void editChannel() { System.out.println("해당 채널이 존재하지 않습니다. 다시 입력해주세요."); } } - + this.channel.editChannel(tempChannel); } diff --git a/Insurance_rock/src/User/CompensateTeam.java b/Insurance_rock/src/User/CompensateTeam.java index c742fce..b95e416 100644 --- a/Insurance_rock/src/User/CompensateTeam.java +++ b/Insurance_rock/src/User/CompensateTeam.java @@ -35,7 +35,7 @@ public void finalize() throws Throwable { public void add() { //accident.search(); - accident.add(); + //accident.add(); File file = new File(".//DB//Accident_DB.txt"); if (!file.exists()) { diff --git a/Insurance_rock/src/dao/AccidentDao.java b/Insurance_rock/src/dao/AccidentDao.java index ba318f0..564163d 100644 --- a/Insurance_rock/src/dao/AccidentDao.java +++ b/Insurance_rock/src/dao/AccidentDao.java @@ -1,37 +1,160 @@ package dao; import java.sql.ResultSet; +import java.time.LocalDate; -public class AccidentDao extends Dao { +import Accident.Accident; + +public class AccidentDao extends Dao { public AccidentDao() { super.connect(); } - public boolean create() { + + public ResultSet retrive() { + String query = "SELECT * FROM Accident"; + + System.out.println(query); + return super.retrive(query); + } + + + public boolean delete() { String query = ""; System.out.println(query); + return super.delete(query); + } + + + + + public boolean creat(Accident accident) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("insert into Accident values(") + .append("\'" + accident.getID() + "\',") + .append("\'" + accident.getContractID() + "\',") + .append("\'" + accident.getCustomerID() + "\',") + .append("\'" + accident.getCustomerName() + "\',") + .append("\'" + accident.getPhoneNum() + "\',") + .append("\'" + accident.getAccidentDate() + "\',") + .append("\'" + accident.getContent() + "\',") + .append("\'" + accident.getTotalCost() + "\',") + .append("\'" + accident.getDamagePer() + "\',") + .append("\'" + accident.getKindOfCost() + "\',") + .append( accident.isPayCompleted() + ",") + .append("\'" + accident.getLiablityRate() + "\',") + .append("\'" + accident.getLiablityCost() + "\')") + .toString(); + + System.out.println(query); + // TODO Auto-generated method stub return super.create(query); } - public ResultSet retrive() { - String query = ""; + + public ResultSet retriveaccident(Accident accident) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("select * from accident Where accidentDate =") + .append(" \'" + accident.getAccidentDate() + "\' AND ") + .append("customerName = \'" + accident.getCustomerName() + "\'") + .toString(); System.out.println(query); return super.retrive(query); } - public boolean update() { - String query = ""; + + public boolean updatedate(Accident accident, LocalDate accidentdate) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set accidentDate =") + .append("\'"+accidentdate + "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); System.out.println(query); return super.update(query); + } - public boolean delete() { - String query = ""; + + public boolean updatecontent(Accident accident, String content) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set content =") + .append("\'"+content + "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); System.out.println(query); - return super.delete(query); + return super.update(query); + } + + + public boolean updatetotal(Accident accident, int totalCost) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set totalCost =") + .append("\'"+totalCost + "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); + + System.out.println(query); + return super.update(query); + } + + + public boolean updateDamage(Accident accident, int damagePer) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set damagePer =") + .append("\'"+damagePer + "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); + + System.out.println(query); + return super.update(query); + } + + + public boolean updateKind(Accident accident, String kindOfCost) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set kindOfCost =") + .append("\'"+kindOfCost+ "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); + + System.out.println(query); + return super.update(query); + } + + + public boolean updateLiablityCost(Accident accident, int liablityCost) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set liablityCost =") + .append("\'"+liablityCost+ "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); + + System.out.println(query); + return super.update(query); + } + + + public boolean updateLiablityRate(Accident accident, int liablityRate) { + StringBuilder stringBuilder = new StringBuilder(); + + String query = stringBuilder.append("update accident set liablityRate =") + .append("\'"+liablityRate+ "\'") + .append("where accidentID = \'" + accident.getID() + "\'") + .toString(); + + System.out.println(query); + return super.update(query); } } diff --git a/Insurance_rock/src/dao/Channel.java b/Insurance_rock/src/dao/ChannelDao.java similarity index 82% rename from Insurance_rock/src/dao/Channel.java rename to Insurance_rock/src/dao/ChannelDao.java index 6888138..38c325d 100644 --- a/Insurance_rock/src/dao/Channel.java +++ b/Insurance_rock/src/dao/ChannelDao.java @@ -2,8 +2,8 @@ import java.sql.ResultSet; -public class Channel extends Dao { - public Channel() { +public class ChannelDao extends Dao { + public ChannelDao() { super.connect(); } @@ -15,7 +15,7 @@ public boolean create() { } public ResultSet retrive() { - String query = ""; + String query = "SELECT * FROM Channel"; System.out.println(query); return super.retrive(query); diff --git a/Insurance_rock/src/dao/ContractDao.java b/Insurance_rock/src/dao/ContractDao.java index 1cbf60a..043eead 100644 --- a/Insurance_rock/src/dao/ContractDao.java +++ b/Insurance_rock/src/dao/ContractDao.java @@ -15,7 +15,7 @@ public boolean create() { } public ResultSet retrive() { - String query = ""; + String query = "SELECT * FROM Contract"; System.out.println(query); return super.retrive(query); @@ -34,4 +34,22 @@ public boolean delete() { System.out.println(query); return super.delete(query); } + + public ResultSet select() { + String query = ""; + + System.out.println(query); + return super.retrive(query); + } + + public ResultSet retrivecontract(String customerName, String phoneNum) { + StringBuilder stringBuilder = new StringBuilder(); + String query = stringBuilder.append("select contractID, customerID, customerName, customerPhoneNum, insuranceID, insuranceName, paymentCycle, insuranceFee, unpaidFee, securityFee, provisionFee, startDate, endDate From Contract ") + .append("Where customerName = \'"+customerName+"\' AND ") + .append("customerPhoneNum = \'" + phoneNum +"\'" ) + .toString(); + + System.out.println(query); + return super.retrive(query); + } } diff --git a/Insurance_rock/src/dao/Dao.java b/Insurance_rock/src/dao/Dao.java index 7de8e69..dbbb3c8 100644 --- a/Insurance_rock/src/dao/Dao.java +++ b/Insurance_rock/src/dao/Dao.java @@ -15,7 +15,7 @@ public void connect() { try { Class.forName("com.mysql.cj.jdbc.Driver"); connect = DriverManager.getConnection( - "jdbc:mysql://localhost:3306/insurance_rock?serverTimezone=UTC&useSSL=false", "root", "1234"); + "jdbc:mysql://localhost:3306/insurance_rock?serverTimezone=UTC&useSSL=false", "root", "5C7vnrt7!"); } catch (SQLException | ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -62,4 +62,9 @@ public boolean delete(String query) { } return false; } + + public Object select(String query) { + // TODO Auto-generated method stub + return null; + } }