0

私が作成した Delphi アプリケーションで現在実行されているプロセスがあり、Web アプリケーションで実行される Java プロセスに変換する必要があります。基本的に、州の財務 (レガシー) システムでは、特定の出力でこのファイルが必要です。Delphi では次のようになります。

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 で Format オプションに相当するものはありますか? それとも、テキスト ファイルに保存される TStringList ですか?

情報をありがとう....Java プログラミングをあまりやったことがありません!

レスリー

4

1 に答える 1

1

これらはすべて、Java (または他の多くの言語) での比較的単純な操作です。Java での使用例では、ここに示すように、JDBC を介してデータベースに直接アクセスするのがおそらく最も簡単です。データを取得したら、String.format(...)を使用して必要な方法でデータをフォーマットし、ファイルに書き込むことができます (ここで説明されているように)。

于 2010-03-08T17:38:10.160 に答える