⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calculatethreadunit.~pas

📁 华海成本核算辅助系统是基于用友U8企业资源管理系统开发的一套半成品成本统计分析软件。本软件界面美观、初始化简单、操作快捷、功能全面、报表多样等优点
💻 ~PAS
字号:
unit CalculateThreadUnit;

interface

uses
  Classes,SysUtils ;

type
  TCalculateThread = class(TThread)
  private
    { Private declarations }
    //出库总金额
    FCheckOutValue : Double ;
    //入库总金额
    FCheckInValue : Double ;
    //成本系数
    FCoefficient : Double ;
    //折旧系数
    FDepreciationCoefficient : Double ;
    //总折旧金额
    FAllDepreciation : Double ;
    //总时间 存货自定义项12
    FAllTime : Double ;
    //
    FDepCodeIndex : Integer ;
  public
    property DepCodeIndex: Integer read FDepCodeIndex write FDepCodeIndex;
  protected
    procedure Execute; override;
  end;

implementation

uses DMsemiUnit, EventUnit, ConfigUnit, ConfigObjectUnit, CommonUnit;

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TCalculateThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TCalculateThread }

procedure TCalculateThread.Execute;
var
  ltemp,lCurDepName,lCurDepCode : string ;
  lInx : Integer ;
  lCheckOutValue,lCheckInValue : Double ;
begin
  FreeOnTerminate := True ;
  try
    FCheckOutValue := 0 ;
    FCheckInValue := 0 ;
    gCalculateEvent.ProcessHitMessage('正在初始化...');
    DMSemi.CreateTable ;
    gCalculateEvent.ProcessHitMessage('正在获取自制件信息...');
    for lInx := 1 to High(aryDepCode) do
    begin
      if (FDepCodeIndex <> 0) and (lInx <> FDepCodeIndex) then
        Continue ;
      if (FDepCodeIndex <> 0) and (lInx > FDepCodeIndex) then
        Break ;
      //开始事务
      DMSemi.conDatabase.BeginTrans ;
      try
        {lCurDepCode 值说明
         030201 织带机装配车间
         030202 印染机装配车间
         030203 印花机装配车间
         030204 喷水机装配车间
         030205 喷气机装配车间
         030206 塑编机装配车间
         03 表示 其它部门}
         
        lCurDepCode := aryDepCode[lInx];
        lCurDepName := aryDepName[lInx];
        DMSemi.DepCode := lCurDepCode ;

        if (lCurDepCode=DEP_CODE_OTHER) then
          DMSemi.DepCodeContext := 'a.cDepCode<>''030201'' and a.cDepCode<>''030202'' and a.cDepCode<>''030203'' and a.cDepCode<>''030204'' and a.cDepCode<>''030205'' and a.cDepCode<>''030206'''
        else
          DMSemi.DepCodeContext := 'a.cDepCode='''+ lCurDepCode +'''' ;
      //  DMSemi.WhCode := aryWhcode[lInx];
        DMSemi.DepName := lCurDepName ;
        //取得本仓库入库的所有半成品
        DMSemi.CalculateGetAllThing;
        gCalculateEvent.ProcessHitMessage('正在计算出库总金额...');
        lCheckOutValue := DMSemi.CalculateCheckOutValue ;
        gCalculateEvent.ProcessHitMessage('正在计算入库总金额...');
        lCheckInValue := DMSemi.CalculateCheckInValue ;
        if (lCheckOutValue=0) then
          if (FDepCodeIndex <> 0) then
            raise EDBException.Create(lCurDepName +'的出库总金额为零!')
          else
          begin
            if DMSemi.conDatabase.InTransaction then
              DMSemi.conDatabase.RollbackTrans;
            Continue;
          end;

        if (lCheckInValue=0) then
          if (FDepCodeIndex <> 0) then
            raise EDBException.Create(lCurDepName +'的入库总金额为零!')
          else
          begin
            if DMSemi.conDatabase.InTransaction then
              DMSemi.conDatabase.RollbackTrans;
            Continue;
          end;
        //成本系数
        FCoefficient := lCheckOutValue / lCheckInValue ;
        ltemp := formatfloat('0.0000',FCoefficient);
        FCoefficient := StrToFloat(ltemp );
        //计算时间
        DMSemi.CalculateAllTime;
        FAllTime := DMSemi.CalculateTime ;
        FAllDepreciation := IniOptions.paramdepreciation ;
        if FAllDepreciation=0 then
          raise EDBException.Create('总折旧金额为零!');
        if falltime=0 then
          FDepreciationCoefficient:=0
        else
          FDepreciationCoefficient :=  FAllDepreciation /FAllTime ;
        ltemp := formatfloat('0.0000',FDepreciationCoefficient);
        FDepreciationCoefficient := StrToFloat(ltemp );
        gCalculateEvent.ProcessHitMessage('正在计算自制件成本...');
        DMSemi.CalculateWorkValue(FCoefficient);
        DMSemi.CalculateSingleCost(FCoefficient);
        DMSemi.CalculateCdatumCost;
        DMSemi.CalculateSingleDepreciation(FDepreciationCoefficient );
        DMSemi.CalculateSingleAllCost ;
        DMSemi.CalculateAllCost ;
        DMSemi.DoSum(lCheckOutValue,lCheckInValue) ;
        FCheckOutValue := FCheckOutValue + lCheckOutValue ;
        FCheckInValue := FCheckInValue + lCheckInValue ;
        gCalculateEvent.ProcessHitMessage('正在计算半成品入库实际总金额...');
        DMSemi.CalculateCheckInValue2;
      finally
        if DMSemi.conDatabase.InTransaction then
          DMSemi.conDatabase.CommitTrans ;
      end;
    end ;
    IniOptions.paramCheckOut := FCheckOutValue ;
    IniOptions.paramCheckIn := FCheckInValue ;
    IniOptions.paramCheckIn2 := DMSemi.CalculateCheckInValue3 ;
    gCalculateEvent.ProcessEndMessage('计算完成');
  except
    on E : Exception do
    begin
      if DMSemi.conDatabase.InTransaction then
        DMSemi.conDatabase.RollbackTrans ;
      gCalculateEvent.ProcessStatusMessage('计算过程出错,出错原因:' + E.Message);
      Terminate;
    end;
  end ;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -