You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
7.6 KiB
Java

package cokr.xit.interfaces.sntris.fileoffer;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import cokr.xit.foundation.AbstractComponent;
public class Ye22NoticeReader extends AbstractComponent {
public List<Ye22NoticeInfoDTO> read(InputStream input, String charset) {
try (
InputStreamReader streamReader = new InputStreamReader(input, ifEmpty(charset, "EUC-KR"));
BufferedReader reader = new BufferedReader(streamReader);
) {
ArrayList<Ye22NoticeInfoDTO> result = new ArrayList<>();
while (reader.ready()) {
Ye22NoticeInfoDTO notice = read(reader.readLine().split("\t"));
if (notice == null) continue;
result.add(notice);
}
return result;
} catch (Exception e) {
throw runtimeException(e);
}
}
public List<Ye22NoticeInfoDTO> read(File file, String charset) {
try (FileInputStream input = new FileInputStream(file);) {
return read(input, charset);
} catch (Exception e) {
throw runtimeException(e);
}
}
private Ye22NoticeInfoDTO read(String[] strs) {
Ye22NoticeInfoDTO notice = null;
for (int i = 0; i < strs.length; ++i) {
String str = blankIfEmpty(strs[i]).trim();
if (isLabel(str)) return null;
if (notice == null)
notice = new Ye22NoticeInfoDTO();
fields
.get(i)
.setValue(notice, str);
}
return notice;
}
private static boolean isLabel(String str) {
return fields.stream()
.filter(field -> field.label.equals(str))
.count() > 0;
}
private static final List<Field> fields = List.of(new Field[] {
new Field("상태", (notice, str) -> {
notice.setBuStatusNm(str);
notice.setBuStatusCd(switch (str) {
case "완납" -> "1";
case "이중납" -> "2";
case "일부납" -> "3";
case "과납" -> "4";
case "오납" -> "5";
case "체납미조정" -> "8";
case "체납" -> "9";
case "체납/일부납" -> "93";
case "결손" -> "10";
case "신고종료" -> "11";
case "결손(시효)" -> "20";
case "결손(불납)" -> "21";
case "결손(부분)" -> "22";
case "결손(시효만료)" -> "23";
case "감면" -> "30";
default -> "0"; // 부과
});
}),
new Field("구분", null),
new Field("세목코드", (notice, str) -> notice.setSemokCd(str)),
new Field("세목명", (notice, str) -> notice.setSemokNm(str)),
new Field("물건종류", null),
new Field("과세년월", (notice, str) -> notice.setTaxYm(str)),
new Field("과세구분", (notice, str) -> {
notice.setTaxGubunNm(str);
notice.setTaxGubun(switch (str) {
case "정기" -> "1";
case "수시" -> "2";
case "신고" -> "3";
default -> "";
});
}),
new Field("과세번호", (notice, str) -> notice.setTaxNo(str)),
new Field("납세자구분", null),
new Field("가상주민번호", (notice, str) -> notice.setNapId(str)),
new Field("주민/법인번호", (notice, str) -> {
if (isEmpty(notice.getNapId()))
notice.setNapId(str);
}),
new Field("성명/법인명", (notice, str) -> notice.setNapNm(str)),
new Field("전자고지", null),
new Field("전화번호", null),
new Field("핸드폰번호", null),
new Field("거주상태", null),
new Field("과세대상", null),
new Field("총과세금액", null),
new Field("과세금액", null),
new Field("체납금액", (notice, str) -> notice.setCheAmt(toLong(str))),
new Field("이자총금액", null),
new Field("부가가치세", (notice, str) -> notice.setVatAmt(toLong(str))),
new Field("본세", (notice, str) -> notice.setTaxAmt(toLong(str))),
new Field("구세", (notice, str) -> notice.setGuse(toLong(str))),
new Field("국세", (notice, str) -> notice.setGukse(toLong(str))),
new Field("기금", (notice, str) -> notice.setGigum(toLong(str))),
new Field("본세이자", null),
new Field("구세이자", (notice, str) -> notice.setGuseIja(toLong(str))),
new Field("국세이자", (notice, str) -> notice.setGukseIja(toLong(str))),
new Field("기금이자", (notice, str) -> notice.setGigumIja(toLong(str))),
new Field("본세가산금", (notice, str) -> notice.setGuseIja(toLong(str))),
new Field("구세가산금", (notice, str) -> notice.setGuseGasanAmt(toLong(str))),
new Field("국세가산금", (notice, str) -> notice.setGukseGasanAmt(toLong(str))),
new Field("기금가산금", (notice, str) -> notice.setGigumGasanAmt(toLong(str))),
new Field("가산금총금액", null),
new Field("최초본세", null),
new Field("감액구분", null),
new Field("감액일자", null),
new Field("최초과세일자", (notice, str) -> notice.setTaxYmd(str)),
new Field("최초납기일자", (notice, str) -> notice.setNapgiYmd(str)),
new Field("과세일자", (notice, str) -> notice.setTaxYmd(str)),
new Field("납기일자", (notice, str) -> notice.setNapgiYmd(str)),
new Field("납부일자", (notice, str) -> notice.setNapbuYmd(str)),
new Field("납세자우편번호", (notice, str) -> notice.setNapDzipCd(str)),
new Field("납세자기본주소", (notice, str) -> notice.setNapDzipAddr(str)),
new Field("납세자상세주소", (notice, str) -> notice.setNapDdtlAddr(str)),
new Field("행정동", null),
new Field("기관코드", null),
new Field("기관명", null),
new Field("부과부서코드", (notice, str) -> notice.setBuseoCd(str)),
new Field("부과부서명", (notice, str) -> notice.setBuseoNm(str)),
new Field("수납부서코드", null),
new Field("수납부서명", null),
new Field("소관부서코드", null),
new Field("소관부서명", null),
new Field("소관부서담당자", null),
new Field("소관부서전화번호", null),
new Field("항목1", null),
new Field("항목2", null),
new Field("항목3", null),
new Field("항목4", null),
new Field("항목5", null),
new Field("항목6", null),
new Field("비고", null),
new Field("물건지 우편번호", null),
new Field("물건지주소", null),
new Field("물건지상세주소", null),
new Field("최초부과자", null),
new Field("납세번호", (notice, str) -> notice.setNapseNo(str)),
new Field("우리", (notice, str) -> notice.setWAccountNo(str)),
new Field("신한", (notice, str) -> notice.setSAccountNo(str)),
new Field("하나", (notice, str) -> notice.setHAccountNo(str)),
new Field("국민", (notice, str) -> notice.setKAccountNo(str)),
new Field("기업", (notice, str) -> notice.setIAccountNo(str)),
new Field("거소지주소", null),
new Field("전자납부번호", (notice, str) -> notice.setEnapbuNo(str)),
new Field("우체국", (notice, str) -> notice.setPAccountNo(str)),
new Field("외환", null),
new Field("씨티", (notice, str) -> notice.setCAccountNo(str)),
new Field("농협", (notice, str) -> notice.setNAccountNo(str)),
new Field("수협", (notice, str) -> notice.setFAccountNo(str)),
new Field("카카오", (notice, str) -> notice.setOAccountNo(str)),
new Field("k뱅크", (notice, str) -> notice.setQAccountNo(str)),
new Field("토스뱅크", null),
new Field("사업자번호(부가가치세)", null),
new Field("시구코드", (notice, str) -> notice.setSiguCd(str)),
new Field("시구명", (notice, str) -> notice.setSiguNm(str)),
new Field("자동이체여부", null),
new Field("법인대표자명", null),
new Field("재산번호", null)
});
private static class Field {
String label;
BiConsumer<Ye22NoticeInfoDTO, String> setter;
Field(String label, BiConsumer<Ye22NoticeInfoDTO, String> setter) {
this.label = label;
this.setter = setter;
}
void setValue(Ye22NoticeInfoDTO notice, String str) {
if (setter == null) return;
setter.accept(notice, str);
}
}
}