문제

현재 작성한 델파이 응용 프로그램에서 실행되는 프로세스가 있으며 웹 응용 프로그램에서 실행될 Java 프로세스로 변환해야합니다. 기본적으로 우리의 주 금융 (레거시) 시스템에는이 파일이 특정 출력으로 필요합니다. 델파이에서는 다음과 같습니다.

procedure CreateSHAREJournalFile(AppDate : string; ClassCode : string; BudgetRef : String; AccountNumber : string; FYEStep : integer);
var
GLFileInfo : TStrings;
MPayFormat, HPayFormat, TPayFormat : string;
const
//this is the fixed length format for each item in the file
HeaderFormat = '%-1s%-5s%-10s%-8s%-12s%-10s%-21s%-3s%-71s%-3s%-20s%-1s';
DetailFormat = '%-1s%-5s%-9s%-10s%-10s%-10s%-10s%-8s%-6s%-5s%-5s%-5s%-8s%-25s%-10s%-60s%-28s%-66s%-28s';
begin
  try
//get the data from the query
    with dmJMS.qryShare do
    begin
      SQL.Clear;
      SQL.Add('SELECT SUM(TOTHRPAY) As HourPay, SUM(TOTMLPAY) As MilePay, SUM(TOTALPAY) AS TotalPay FROM JMPCHECK INNER JOIN JMPMAIN ON JMPCHECK.JURNUM = JMPMAIN.JURNUM WHERE PANELID LIKE ''' + Copy(AppDate, 3, 6) + '%'' ');
      if FYEStep > -1 then
        SQL.Add('AND WARRANTNO = ' + QUotedStr(IntToStr(FYEStep)));
      Active := True;
//assign totals to variables so they can be padded with leading zeros
    MPayFormat := FieldByName('MilePay').AsString;
    while length(MPayFormat) < 28 do <br>MPayFormat := '0' + MPayFormat;
    HPayFormat := FieldByName('HourPay').AsString;
    while length(HPayFormat) < 28 do <br>HPayFormat := '0' + HPayFormat;
    TPayFormat := Format('%f' ,[(FieldByName('TotalPay').AsCurrency)]);
    while length(TPayFormat) < 27 do
    TPayFormat := '0' + TPayFormat;
    TPayFormat := '-' + TPayFormat;
//create a TStringlist to put each line item into
    GLFileInfo := TStringList.Create;
//add header info using HeaderFormat defined above
    GLFileInfo.Add(Format(HeaderFormat, ['H', '21801', 'NEXT', FormatDateTime('MMDDYYYY', Today), '', 'ACTUALS', '', 'EXT', '', 'EXT', '', 'N']));
//add detail info using DetailFormat defined above
    GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '1', 'ACTUALS', AccountNumber, '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', AccountNumber + '0300', '', MPayFormat, '', MPayFormat]));
    GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '2', 'ACTUALS', AccountNumber, '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', AccountNumber + '0100', '', HPayFormat, '', HPayFormat]));
    GLFileInfo.Add(Format(DetailFormat, ['L', '21801', '3', 'ACTUALS', '101900', '', '1414000000', '111500', '', '01200', ClassCode, '', BudgetRef, '', '', '', TPayFormat, '', TPayFormat]));
//save TStringList to text file
    GLFileINfo.SaveToFile(ExtractFilePath(Application.ExeName) + 'FileTransfer\GL_' + formatdateTime('mmddyy', Today) + SequenceID + '24400' + '.txt');
    end;
  finally
    GLFileINfo.Free;
  end;
end;

형식 옵션에 대한 Java에 해당하는 것이 있습니까? 아니면 텍스트 파일에 저장하는 tstringlist?

모든 정보에 감사드립니다 .... 많은 Java 프로그래밍을하지 않았습니다!

레슬리

도움이 되었습니까?

해결책

이들은 모두 Java (또는 그 문제에 대한 다른 많은 언어)에서 비교적 간단한 작업입니다. Java의 유스 케이스의 경우 표시된대로 JDBC를 통해 데이터베이스에 직접 액세스하는 것이 가장 쉽습니다. 여기. 데이터를 검색 한 후에는 사용할 수 있습니다 string.format (...) 필요한 방식으로 데이터를 작성하려면 파일에 쓸 수 있습니다 (설명대로 여기).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top