Add JavaSrc: cobol-tna-system COBOL->Java conversion (ZAN01-06/KIN01-09/KYU01-09 + 变换规则 doc)
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
import dto.ZandatacPar;
|
||||
import dto.ZanendacPar;
|
||||
import dto.Zan01Rec;
|
||||
import dto.Zan05Rec;
|
||||
import dto.ZanmsgacPar;
|
||||
import util.ConvUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* ============================================================
|
||||
* 銆怌OBOL鈫扟ava銆慞ROGRAM-ID. ZAN02CHK 鈫?绫?Zan02ChkMain
|
||||
* ============================================================
|
||||
* 鏅傞枔甯噸瑜囥儊銈с儍銈? OVT-VSORT(R01) 銇悓涓€绀惧摗銉诲悓涓€鏃ヤ粯鍐呫仹
|
||||
* 鍓嶃儸銈炽兗銉夌祩浜嗘檪鍒?> 鐝鹃枊濮嬫檪鍒?銇倝 ERROR-LOG(W02) 銇嚭鍔涖€? * 銇濄倢浠ュ銇?OVT-NODUP(W01) 銇稿嚭鍔涖€? * 鈥昏ō瑷堟浉婧栨嫚銆侰OBOL 銇ㄦ暣鍚堛€? */
|
||||
public class Zan02ChkMain {
|
||||
|
||||
private static final String PRGIDX = "ZAN02CHK";
|
||||
private static final int CNS_MSGSTR = 1;
|
||||
private static final int CNS_MSGFIN = 2;
|
||||
private static final int CNS_MSGSUBEEK = 5;
|
||||
private static final int CNS_MSGIINKES = 6;
|
||||
private static final int CNS_MSGOUTKES = 7;
|
||||
private static final int CNS_MSGKEYINF = 33;
|
||||
private static final int CNS_KN0002 = 2;
|
||||
private static final int CNS_ABD999 = 999;
|
||||
private static final int CNS_ERR_CAT02 = 2;
|
||||
|
||||
private static final String R01_PATH = "data/ZAN02R01.txt";
|
||||
private static final String W01_PATH = "data/ZAN02W01.txt";
|
||||
private static final String W02_PATH = "data/ZAN02W02.txt";
|
||||
|
||||
private long cunR01Inn = 0;
|
||||
private long cunW01Out = 0;
|
||||
private long cunW02Out = 0;
|
||||
|
||||
private int wrkU06;
|
||||
private String wrkR01Eof = "0";
|
||||
private String r01Line = "";
|
||||
|
||||
private final ZandatacPar d01 = new ZandatacPar();
|
||||
private final ZanmsgacPar m00 = new ZanmsgacPar();
|
||||
private final ZanendacPar e01 = new ZanendacPar();
|
||||
|
||||
private Zan01Rec r01Rec = new Zan01Rec();
|
||||
private Zan01Rec prevRec = new Zan01Rec();
|
||||
|
||||
private BufferedReader r01In;
|
||||
private BufferedWriter w01Out;
|
||||
private BufferedWriter w02Out;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new Zan02ChkMain().run();
|
||||
}
|
||||
|
||||
private void run() {
|
||||
initProc();
|
||||
while (!"1".equals(wrkR01Eof)) {
|
||||
majProc();
|
||||
}
|
||||
stpProc();
|
||||
}
|
||||
|
||||
private void initProc() {
|
||||
msgOut(CNS_MSGSTR, "", "");
|
||||
msgCompiled();
|
||||
wrkU06 = 0;
|
||||
wrkR01Eof = "0";
|
||||
d01.reset();
|
||||
Sub01DatSub.execute(d01);
|
||||
if (d01.getD01FkiCod() != 0) {
|
||||
msgOut(CNS_MSGSUBEEK, "SUB01DAT", String.valueOf(d01.getD01FkiCod()));
|
||||
abend();
|
||||
return;
|
||||
}
|
||||
wrkU06 = d01.getD01UbsUdate();
|
||||
try {
|
||||
r01In = FileIo.openReader(R01_PATH);
|
||||
w01Out = FileIo.openWriter(W01_PATH);
|
||||
w02Out = FileIo.openWriter(W02_PATH);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("FILE OPEN ERROR", e);
|
||||
}
|
||||
readR01();
|
||||
// 1浠剁洰: W01鍑哄姏 + 鍓嶃儸銈炽兗銉夊垵鏈熷寲
|
||||
if (!"1".equals(wrkR01Eof)) {
|
||||
r01Rec.fromRecordLine(r01Line);
|
||||
prevRec.fromRecordLine(r01Line);
|
||||
try {
|
||||
w01Out.write(r01Rec.toRecordLine());
|
||||
w01Out.newLine();
|
||||
cunW01Out++;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("WRITE W01 ERROR", e);
|
||||
}
|
||||
readR01();
|
||||
}
|
||||
}
|
||||
|
||||
private void readR01() {
|
||||
try {
|
||||
String line = r01In.readLine();
|
||||
if (line == null) {
|
||||
wrkR01Eof = "1";
|
||||
} else {
|
||||
r01Line = line;
|
||||
cunR01Inn++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("READ ERROR", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void majProc() {
|
||||
if (!"1".equals(wrkR01Eof)) {
|
||||
r01Rec.fromRecordLine(r01Line);
|
||||
checkDupProc();
|
||||
readR01();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDupProc() {
|
||||
if (prevRec.getEmpId().equals(r01Rec.getEmpId())
|
||||
&& prevRec.getApplDate().equals(r01Rec.getApplDate())) {
|
||||
int prevEnd = ConvUtil.parseIntSafe(prevRec.getEndTime(), 0);
|
||||
int curStart = ConvUtil.parseIntSafe(r01Rec.getStartTime(), 0);
|
||||
if (prevEnd > curStart) {
|
||||
overlapErrProc();
|
||||
} else {
|
||||
normalOutProc();
|
||||
}
|
||||
} else {
|
||||
keyBrProc();
|
||||
}
|
||||
}
|
||||
|
||||
private void overlapErrProc() {
|
||||
Zan05Rec rec = new Zan05Rec();
|
||||
rec.setErrCategory(String.valueOf(CNS_ERR_CAT02));
|
||||
rec.setErrDetail("OVERLAP: " + prevRec.getEmpId() + "," + prevRec.getApplDate());
|
||||
try {
|
||||
w02Out.write(rec.toRecordLine());
|
||||
w02Out.newLine();
|
||||
cunW02Out++;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("WRITE W02 ERROR", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void normalOutProc() {
|
||||
try {
|
||||
w01Out.write(r01Rec.toRecordLine());
|
||||
w01Out.newLine();
|
||||
cunW01Out++;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("WRITE W01 ERROR", e);
|
||||
}
|
||||
prevRec.fromRecordLine(r01Rec.toRecordLine());
|
||||
}
|
||||
|
||||
private void keyBrProc() {
|
||||
prevRec.fromRecordLine(r01Rec.toRecordLine());
|
||||
normalOutProc();
|
||||
}
|
||||
|
||||
private void stpProc() {
|
||||
try {
|
||||
if (r01In != null) {
|
||||
r01In.close();
|
||||
}
|
||||
if (w01Out != null) {
|
||||
w01Out.close();
|
||||
}
|
||||
if (w02Out != null) {
|
||||
w02Out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("CLOSE ERROR", e);
|
||||
}
|
||||
msgInkCnt("ZAN02R01", cunR01Inn);
|
||||
msgOutCnt("ZAN02W01", cunW01Out);
|
||||
msgOutCnt("ZAN02W02", cunW02Out);
|
||||
msgOut(CNS_MSGFIN, "", "");
|
||||
}
|
||||
|
||||
private void msgOut(final int code, final String p1, final String p2) {
|
||||
m00.reset();
|
||||
m00.setM00MsgCod(code);
|
||||
m00.setM00Umkdats2201(p1);
|
||||
m00.setM00Umkdats2202(p2);
|
||||
m00.setM00Umkdats2203(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2204(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2205(PRGIDX);
|
||||
Sub02MsgSub.execute(m00);
|
||||
}
|
||||
|
||||
private void msgCompiled() {
|
||||
m00.reset();
|
||||
m00.setM00MsgCod(CNS_MSGKEYINF);
|
||||
m00.setM00Umkdats2201("2026-06-14");
|
||||
m00.setM00Umkdats2202("COMPILED");
|
||||
m00.setM00Umkdats2203(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2204(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2205(PRGIDX);
|
||||
Sub02MsgSub.execute(m00);
|
||||
}
|
||||
|
||||
private void msgInkCnt(final String dd, final long cnt) {
|
||||
m00.reset();
|
||||
m00.setM00MsgCod(CNS_MSGIINKES);
|
||||
m00.setM00Umkdats2201(dd);
|
||||
m00.setM00Umkdats2202(String.valueOf(cnt));
|
||||
m00.setM00Umkdats2203(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2204(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2205(PRGIDX);
|
||||
Sub02MsgSub.execute(m00);
|
||||
}
|
||||
|
||||
private void msgOutCnt(final String dd, final long cnt) {
|
||||
m00.reset();
|
||||
m00.setM00MsgCod(CNS_MSGOUTKES);
|
||||
m00.setM00Umkdats2201(dd);
|
||||
m00.setM00Umkdats2202(String.valueOf(cnt));
|
||||
m00.setM00Umkdats2203(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2204(String.valueOf(CNS_KN0002));
|
||||
m00.setM00Umkdats2205(PRGIDX);
|
||||
Sub02MsgSub.execute(m00);
|
||||
}
|
||||
|
||||
private void abend() {
|
||||
e01.reset();
|
||||
e01.setE01AbdCod(CNS_ABD999);
|
||||
Sub03EndSub.execute(e01);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user