<!-- <div nz-row nzGutter="24">
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD01项目<br/>
      85%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD02项目<br/>
      50%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD03项目<br/>
      90%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD04项目<br/>
      40%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_danger">
      CD05项目<br/>
      30%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD06项目<br/>
      25%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_danger">
      CD07项目<br/>
      15%
    </div>
  </nz-col>
  <nz-col nzXs="12" nzSm="6" nzMd="3" nzLg="3">
    <div class="block_normal">
      CD08项目<br/>
      0%
    </div>
  </nz-col>
</div> -->

<!-- <div nz-row [nzGutter]="24" class="pt-lg">
  <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24">
    <nz-card [nzLoading]="loading" [nzBordered]="false" nzTitle="{{'last.90.days.project.statistics' | translate}}"
      class="mb-0">
      <g2-pie *ngIf="isVisible" [data]="projectFeeData" [hasLegend]="true" [subTitle]="'项目状态（个数）' | translate" [height]="600"
        [lineWidth]="4" [total]="projectFeeTotal" [valueFormat]="projectFeeFormat" [inner]="0.4">
      </g2-pie>
    </nz-card>
  </div>
</div> -->
<!-- class="tableTdPadding" -->
<!-- <th nzLeft="0px" nzWidth="60px"><strong>序号</strong></th>
<th nzLeft="60px" nzWidth="100px"><strong>生产线</strong></th>
<th nzLeft="160px" nzWidth="100px"><strong>订单编号</strong></th> -->
<nz-spin [nzSpinning]="saveLoading">
  <form nz-form>
    <div nz-row [nzGutter]="{xs:12,sm:15,md:29,lg: 36, xl: 40}">
      <div nz-col nzXs="24" nzSm="4" nzLg="8">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="8">订单编号</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <!-- <input [(ngModel)]="fbsWorkshopDispatchList.productionOrderNumberName" name="productionOrderNumberName" nz-input
            placeholder="请输入" /> -->
            <nz-select [(ngModel)]="fbsWorkshopDispatchList.productionOrderNumberName" name="productionOrderNumberName"
              style="width: 100%" nzShowSearch nzAllowClear nzPlaceHolder="请选择">
              <ng-container *ngFor="let list of listOfDataSelect">
                <nz-option [nzLabel]="list.productionOrderNumberName" [nzValue]="list.productionOrderNumberName">
                </nz-option>
              </ng-container>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col nzXs="24" nzSm="4" nzLg="4">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="8">年份</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <input [(ngModel)]="fbsWorkshopDispatchList.year" name="year" nz-input placeholder="请输入" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col nzXs="24" nzSm="4" nzLg="4">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="8">月份</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <input [(ngModel)]="fbsWorkshopDispatchList.month" name="month" nz-input placeholder="请输入" />
          </nz-form-control>
        </nz-form-item>
      </div>
      <!-- 按钮 -->
      <div nz-col nzXs="24" nzSm="4" nzLg="2">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="2" [nzNoColon]="true"></nz-form-label>
          <nz-form-control [nzSpan]="16">
            <!-- 查询 -->
            <button nz-button nzType="primary" (click)="getSumDispatchReport()">查询</button>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col nzXs="24" nzSm="4" nzLg="6">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="16">是否显示已完成订单</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <!-- 查询 -->
            <nz-switch [(ngModel)]="isSwitch" name="isSwitch" nzCheckedChildren="是" nzUnCheckedChildren="否"
              (ngModelChange)="isSwitchChange()">
            </nz-switch>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>

  </form>
  <div nz-row [nzGutter]="24">
    <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24">
      <nz-table class="tableTdPadding" nzSize="small" #columnTable nzBordered [nzData]="listOfData"
        [nzScroll]="{ x: widthLength+'px', y:'550px'}" [nzShowPagination]="false" [nzFrontPagination]="false">
        <thead>
          <tr>
            <!-- <th nzLeft="0px" nzWidth="60px" nzAlign="center" style="background-color:rgb(223, 223, 219)"><strong>序号</strong></th>
          <th nzLeft="58px" nzWidth="100px" nzAlign="center" style="background-color:rgb(223, 223, 219)"><strong>项目名称</strong></th>
          <th nzLeft="157px" nzWidth="110px" nzAlign="center" style="background-color:rgb(223, 223, 219)"><strong>订单编号</strong></th>
          <th nzLeft="265px" nzWidth="120px" nzAlign="center" style="background-color:rgb(223, 223, 219)"><strong>物料编码</strong></th>
          <th nzLeft="383px" nzWidth="200px" nzAlign="center" style="background-color:rgb(223, 223, 219)"><strong>物料名称</strong></th> -->

            <th nzLeft="0px" rowSpan="2" nzWidth="30px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>序号</strong></th>
            <th nzLeft="29px" rowSpan="2" nzWidth="80px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>项目名称</strong></th>
            <th nzLeft="108px" rowSpan="2" nzWidth="110px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>订单编号</strong></th>
            <th nzLeft="217px" rowSpan="2" nzWidth="120px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>物料编码</strong></th>
            <th nzLeft="336px" rowSpan="2" nzWidth="100px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>物料名称</strong></th>
            <th nzLeft="436px" rowSpan="2" nzWidth="70px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>计划数量</strong></th>
            <th nzLeft="506px" rowSpan="2" nzWidth="70px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>标准工时</strong></th>
            <th nzLeft="576px" rowSpan="2" nzWidth="70px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>完成数量</strong></th>
            <th nzLeft="645px" rowSpan="2" nzWidth="70px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
              <strong>实际工时</strong></th>
              <th nzLeft="714px" rowSpan="2" nzWidth="80px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
                <strong>订单达成率</strong></th>
                <th nzLeft="794px" rowSpan="2" nzWidth="70px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
                  <strong>生产效率</strong></th>
                  <th nzLeft="864px" rowSpan="2" nzWidth="100px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
                    <strong>计划开完工时间</strong></th>
                  <th nzLeft="964px" rowSpan="2" nzWidth="50px" nzAlign="center" style="background-color:rgb(223, 223, 219)">
                    <strong>状态</strong></th>
            <ng-container *ngFor="let date of dateList">
              <th nzWidth="100px" nzAlign="center"><strong>当日计划数量</strong></th>
              <th nzWidth="100px" nzAlign="center"><strong>当日完成数量</strong></th>
              <th nzWidth="100px" nzAlign="center"><strong>当日完成工时 </strong></th>
              <th nzWidth="100px" nzAlign="center"><strong>当日标准工时</strong></th>
              <th nzWidth="100px" nzAlign="center"><strong>当日生产效率</strong></th>
              <th nzWidth="100px" nzAlign="center"><strong>当日达成率</strong></th>
            </ng-container>
          </tr>
          <tr>
            <!-- <th colspan="5" nzLeft="0px"></th>
          <th colspan="4" ></th> -->
            <!-- <th colspan="9" ></th> -->
            <ng-container *ngFor="let date of dateList;let i=index">
              <th colspan="6" *ngIf="i%2===0" style="background-color:rgb(223, 223, 219)">
                <strong>{{date.finalTime|date:'y-MM-dd'}}</strong></th>
              <th colspan="6" *ngIf="i%2!==0"><strong>{{date.finalTime|date:'y-MM-dd'}}</strong></th>
            </ng-container>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of columnTable.data;let i = index">
            <ng-container *ngIf="data.projectName!=='统计'&&data.isSwitch">
              <!-- *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines" -->
              <td nzLeft="0px" nzAlign="center" *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines">
                {{ data.sort }}</td>
              <td nzLeft="29px" *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines">{{ data.projectName }}</td>
              <td nzLeft="108px">{{ data.productionOrderNumberName }}</td>
              <td nzLeft="217px">{{data.productId}}</td>
              <td nzLeft="336px">{{data.product}}</td>
              <td nzLeft="436px" nzAlign="center">{{data.surplusNumberOfTasksTotal}}</td>
              <td nzLeft="506px" nzAlign="center">{{data.surplusStandardWorkingHoursTotal}}</td>
              <td nzLeft="576px" nzAlign="center">{{data.quantityCompletedTotal}}</td>
              <td nzLeft="645px" nzAlign="center">{{data.manHoursCompletedTotal}}</td>
              <td nzLeft="714px" nzAlign="center">{{data.achievementRate}}%</td>
              <td nzLeft="794px" nzAlign="center">{{data.productionEfficiency}}%</td>
              <td nzLeft="864px" nzAlign="center">{{data.startDate}}至{{data.dueDate}}</td>
              <td nzLeft="964px" nzAlign="center">
                <ng-container *ngIf="data.lackOfMaterialState=='正常'">
                  {{data.lackOfMaterialState}}
                </ng-container>
                <ng-container *ngIf="data.lackOfMaterialState=='待料'">
                  <span style="color: red;">{{data.lackOfMaterialState}}</span>
                </ng-container>
              </td>
              <ng-container *ngFor="let dateChild of data.fbsWorkshopDispatchListList">
                <td nzAlign="center">{{dateChild.numberOfTasks}}</td>
                <td nzAlign="center">{{dateChild.qualifiedNumber}}</td>
                <td nzAlign="center">{{dateChild.manHoursCompleted}}</td>
                <td nzAlign="center">{{dateChild.standardWorkingHours}}</td>
                <td nzAlign="center">
                  <ng-container *ngIf="dateChild.productionEfficiency">{{dateChild.productionEfficiency}}%
                  </ng-container>
                  <ng-container *ngIf="!dateChild.productionEfficiency">0%</ng-container>
                </td>
                <td nzAlign="center">
                  <ng-container *ngIf="dateChild.achievementRate">{{dateChild.achievementRate}}%</ng-container>
                  <ng-container *ngIf="!dateChild.achievementRate">0%</ng-container>
                </td>
              </ng-container>
            </ng-container>
          </tr>
          <!-- 统计 -->
          <tr style="background-color:rgb(223, 223, 219)" *ngFor="let data of columnTable.data;let i = index">
            <ng-container *ngIf="data.projectName==='统计'">
              <td nzLeft="0px" style="background-color:rgb(223, 223, 219)"></td>
              <td nzLeft="29px" style="background-color:rgb(223, 223, 219);font-weight:bolder" nzAlign="center">
                <!-- 剩余工时 -->标准总工时
              </td>
              <td nzLeft="108px" style="background-color:rgb(223, 223, 219)" nzAlign="center">
                <!-- {{data.remainingWorkTotal}} -->{{data.standardWorkingHoursTotal}}
              </td>
              <td nzLeft="217px" style="background-color:rgb(223, 223, 219);font-weight:bolder" nzAlign="center"></td>
              <td nzLeft="336px" style="background-color:rgb(223, 223, 219);font-weight:bolder">统计</td>
              <td nzLeft="436px" nzAlign="center">{{data.surplusNumberOfTasksTotal}}</td>
              <td nzLeft="506px" nzAlign="center">{{data.surplusStandardWorkingHoursTotal}}</td>
              <td nzLeft="576px" nzAlign="center">{{data.quantityCompletedTotal}}</td>
              <td nzLeft="645px" nzAlign="center">{{data.manHoursCompletedTotal}}</td>
              <td nzLeft="714px" nzAlign="center"></td>
              <td nzLeft="794px" nzAlign="center" colSpan="3"></td>
              <!-- <td nzLeft="836px" nzAlign="center"></td> -->
              <ng-container *ngFor="let dateChild of data.fbsWorkshopDispatchListList">
                <td nzAlign="center">{{dateChild.numberOfTasks}}</td>
                <td nzAlign="center">{{dateChild.qualifiedNumber}}</td>
                <td nzAlign="center">{{dateChild.manHoursCompleted}}</td>
                <td nzAlign="center">{{dateChild.standardWorkingHours}}</td>
                <td nzAlign="center">
                  <ng-container *ngIf="dateChild.productionEfficiency">{{dateChild.productionEfficiency}}%
                  </ng-container>
                  <ng-container *ngIf="!dateChild.productionEfficiency">0%</ng-container>
                </td>
                <td nzAlign="center">
                  <ng-container *ngIf="dateChild.achievementRate">{{dateChild.achievementRate}}%</ng-container>
                  <ng-container *ngIf="!dateChild.achievementRate">0%</ng-container>
                </td>
              </ng-container>
            </ng-container>
          </tr>
          <tr></tr>
        </tbody>
        <!-- 异常工时 -->
        <tbody>
          <tr>
            <td  nzLeft="0px"></td>
            <td  nzLeft="29px" nzAlign="center" style="font-weight:bolder">月订单达成率</td>
            <td  nzLeft="108px" nzAlign="center">{{achievementRateTotal}}%</td>
            <td  nzLeft="217px" nzAlign="center" style="font-weight:bolder">月生产效率</td>
            <td  nzLeft="336px" nzAlign="center">{{productivityTotal}}%</td>
            <td  nzLeft="436px" colSpan="8"></td>
            <td [colSpan]="dateList.length*6" rowSpan="2"></td>
          </tr>
          <tr>
            <td  nzLeft="0px"></td>
            <td  nzLeft="29px" nzAlign="center" style="font-weight:bolder">月出勤工时</td>
            <td  nzLeft="108px" nzAlign="center">{{abnormalWorkingHours.attendanceHours}}</td>
            <td  nzLeft="217px" nzAlign="center" style="font-weight:bolder">月加班工时</td>
            <td  nzLeft="336px" nzAlign="center">{{abnormalWorkingHours.overtimeHours}}</td>
            <td  nzLeft="436px" nzAlign="center" style="font-weight:bolder" colSpan="2">月其他工时</td>
            <td  nzLeft="576px" nzAlign="center">{{abnormalWorkingHours.other}}</td>
            <td  nzLeft="645px" nzAlign="center" style="font-weight:bolder" colSpan="2">月异常工时</td>
            <td  nzLeft="794px" nzAlign="center">{{abnormalWorkingHours.quality}}</td>
            <td  nzLeft="864px" nzAlign="center" style="font-weight:bolder">月仓库工时</td>
            <td  nzLeft="964px" nzAlign="center" >{{abnormalWorkingHours.plan}}</td>
          </tr>
          <!-- <tr>
            <td  nzLeft="0px"></td>
            <td  nzLeft="29px" nzAlign="center" style="font-weight:bolder">总达成率</td>
            <td  nzLeft="109px" nzAlign="center">{{achievementRateTotal}}%</td>
            <td  nzLeft="218px" nzAlign="center" style="font-weight:bolder">总生产效率</td>
            <td  nzLeft="337px" nzAlign="center">{{productivityTotal}}%</td>
            <td nzLeft="437px" class="bolder">出勤总工时</td>
            <td nzLeft="486px" nzAlign="center">{{AbnormalWorkingHoursTotal.attendanceHours}}</td>
            <td nzLeft="536px" colSpan="4" nzAlign="right" class="bolder">出勤情况</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>应到人数</td>
              <td nzAlign="center">{{abnormalWorkingHours.numberOfPeopleToArrive}}</td>
              <td>实到人数</td>
              <td nzAlign="center">{{abnormalWorkingHours.actualNumberOfPeople}}</td>
              <td>出勤工时</td>
              <td nzAlign="center">{{abnormalWorkingHours.attendanceHours}}</td>
            </ng-container>
          </tr>
          <tr>
            <td nzLeft="0px" colspan="5" rowSpan="9"></td>
            <td nzLeft="437px" class="bolder">加班总工时</td>
            <td nzLeft="486px" nzAlign="center">{{AbnormalWorkingHoursTotal.overtimeHours}}</td>
            <td nzLeft="536px" colSpan="4" nzAlign="right" class="bolder">加班记录</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>加班工时</td>
              <td nzAlign="center">{{abnormalWorkingHours.overtimeHours}}</td>
              <td>加班原因</td>
              <td colSpan="3">{{abnormalWorkingHours.overtimeReason}}</td>
            </ng-container>
          </tr>
          <tr>
            
            <td nzLeft="437px" rowSpan="2" class="bolder">其他总工时</td>
            <td nzLeft="486px" rowSpan="2" nzAlign="center">{{AbnormalWorkingHoursTotal.train}}</td>
            <td nzLeft="536px" colSpan="4" rowSpan="2" nzAlign="right" class="bolder">其他工时统计</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>培训</td>
              <td nzAlign="center">{{abnormalWorkingHours.train}}</td>
              <td>会议</td>
              <td nzAlign="center">{{abnormalWorkingHours.meeting}}</td>
              <td>5S</td>
              <td nzAlign="center">{{abnormalWorkingHours.fiveS}}</td>
            </ng-container>
          </tr>
          <tr>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>研发</td>
              <td nzAlign="center">{{abnormalWorkingHours.researchAndDevelopment}}</td>
              <td></td>
              <td></td>
              <td></td>
              <td></td>
            </ng-container>
          </tr>
          <tr>
            <td nzLeft="437px" rowSpan="3" class="bolder">异常总工时统计</td>
            <td nzLeft="486px" rowSpan="3" nzAlign="center">{{AbnormalWorkingHoursTotal.abnormalWorkingHours}}</td>
            <td nzLeft="536px" colSpan="4" rowSpan="3" nzAlign="right" class="bolder">异常工时统计</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>质量</td>
              <td nzAlign="center">{{abnormalWorkingHours.quality}}</td>
              <td>设计</td>
              <td nzAlign="center">{{abnormalWorkingHours.design}}</td>
              <td>返工</td>
              <td nzAlign="center">{{abnormalWorkingHours.rework}}</td>
            </ng-container>
          </tr>
          <tr>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>物料</td>
              <td nzAlign="center">{{abnormalWorkingHours.materiel}}</td>
              <td>能源</td>
              <td nzAlign="center">{{abnormalWorkingHours.energy}}</td>
              <td>其他</td>
              <td nzAlign="center">{{abnormalWorkingHours.other}}</td>
            </ng-container>
          </tr>
          <tr>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>设备</td>
              <td nzAlign="center">{{abnormalWorkingHours.equipment}}</td>
              <td>计划</td>
              <td nzAlign="center">{{abnormalWorkingHours.plan}}</td>
              <td></td>
              <td></td>
            </ng-container>
          </tr>
          <tr>
            <td nzLeft="437px" rowSpan="2" class="bolder">仓库总工时统计</td>
            <td nzLeft="486px" rowSpan="2" nzAlign="center">{{AbnormalWorkingHoursTotal.warehouse}}</td>
            <td nzLeft="536px" colSpan="4" rowSpan="2" nzAlign="right" class="bolder">仓库工时统计</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>配料</td>
              <td nzAlign="center">{{abnormalWorkingHours.mixedIngredients}}</td>
              <td>入库</td>
              <td nzAlign="center">{{abnormalWorkingHours.warehousing}}</td>
              <td>打包</td>
              <td nzAlign="center">{{abnormalWorkingHours.pack}}</td>
            </ng-container>
          </tr>
          <tr>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td>其他</td>
              <td nzAlign="center">{{abnormalWorkingHours.warehouseOthers}}</td>
              <td>备注</td>
              <td nzAlign="center" colSpan="3">{{abnormalWorkingHours.memo}}</td>
            </ng-container>
          </tr>


          <tr>
            <td nzLeft="437px" colSpan="6" class="bolder">异常原因描述</td>
            <ng-container *ngFor="let abnormalWorkingHours of abnormalWorkingHoursList">
              <td colSpan="6">
                <ng-container *ngFor="let describe of abnormalWorkingHours.fbsAbnormalWorkingHoursDescribeList">
                  <ng-container *ngIf="describe.describes">
                    {{describe.describes}}<br>
                  </ng-container>
                </ng-container>
              </td>
            </ng-container>
          </tr> -->

        </tbody>
      </nz-table>
    </div>
  </div>
  <form nz-form>
    <div nz-row [nzGutter]="{xs:12,sm:15,md:29,lg: 36, xl: 40}">
      <!-- 按钮 -->
      <div nz-col nzXs="24" nzSm="4" nzLg="4">
        <nz-form-item class="nz-form-item">
          <nz-form-label [nzSpan]="2" [nzNoColon]="true"></nz-form-label>
          <nz-form-control [nzSpan]="16">
            <!-- 查询 -->
            <button nz-button nzType="primary" (click)="export()" [nzLoading]="exportLoading">导出</button>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
  </form>

</nz-spin>
<nz-spin [nzSpinning]="planningReportLoading">
  <div nz-row [nzGutter]="{xs:12,sm:15,md:29,lg: 36, xl: 40}">
    <div nz-col nzXs="24" nzSm="4" nzLg="4">
      <nz-form-item class="nz-form-item">
        <nz-form-label [nzSpan]="6" ><strong>日期</strong></nz-form-label>
        <nz-form-control [nzSpan]="12">
          {{fbsWorkshopDispatchListPlanningReport.year}}
        </nz-form-control>
      </nz-form-item>
    </div>
    <div nz-col nzXs="24" nzSm="4" nzLg="4">
      <nz-form-item class="nz-form-item">
        <nz-form-label [nzSpan]="6" ><strong>周末</strong></nz-form-label>
        <nz-form-control [nzSpan]="12" >
          <span style="background-color: yellow;border:1px solid #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
    <div nz-row [nzGutter]="{xs:12,sm:15,md:29,lg: 36, xl: 40}">
    <div nz-col nzXs="24" nzSm="24" nzLg="24" >
     
      <nz-table  class="tableTdPadding" nzSize="small" #columnTable2 nzBordered [nzData]="planningReportList"
      [nzScroll]="{x:columnTable2Width+'px',y:'35vw'}" [nzShowPagination]="false" [nzFrontPagination]="false">
        <thead>
          <tr>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="40px" nzLeft="0px" nzAlign="center"><strong>序号</strong></th>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="90px" nzLeft="40px" nzAlign="center"><strong>订单编号</strong></th>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="90px" nzLeft="120px" nzAlign="center"><strong>物料编码</strong></th>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="120px" nzLeft="210px" nzAlign="center"><strong>物料名称</strong></th>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="40px" nzLeft="310px" nzAlign="center"><strong>数量</strong></th>
            <th style="background-color:rgb(223, 223, 219);" nzWidth="80px" nzLeft="350px" nzAlign="center"><strong>标准工时</strong></th>
            <!-- <th style="background-color:rgb(223, 223, 219);" nzWidth="4vw"><strong>{{fbsWorkshopDispatchListPlanningReport.year}}</strong></th> -->
            <ng-container *ngFor="let day of fbsWorkshopDispatchListPlanningReport.dayList">
              <ng-container *ngIf="day.week=='2'">
                <th style="background-color:rgb(223, 223, 219);padding: 2px;" nzWidth="25px" nzAlign="center">{{day.day}}</th>
              </ng-container>
              <ng-container *ngIf="day.week=='1'">
                <th style="background-color:yellow;padding: 2px;" nzWidth="25px" nzAlign="center">{{day.day}}</th>
              </ng-container>
              
            </ng-container>

          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let data of columnTable2.data;let i = index">
            <td nzLeft="0px" nzAlign="center" >{{i+1}}</td>
            <td nzLeft="40px">{{data.productionOrderNumberName}}</td>
            <td nzLeft="120px">{{data.productId}}</td>
            <td nzLeft="210px">{{data.product}}</td>
            <td nzLeft="310px" nzAlign="center">{{data.numberOfTasks}}</td>
            <td nzLeft="350px" nzAlign="center">{{data.standardWorkingHours}}</td>
            <!-- <td ></td> -->
            <ng-container *ngFor="let color of data.isColor">
              <ng-container *ngIf="color==='1'">
                <td style="background-color:greenyellow;"></td>
              </ng-container>
              <ng-container *ngIf="color==='0'">
                <td ></td>
              </ng-container>
            </ng-container>

          </tr>
        </tbody>
      </nz-table>
    </div>
  </div>
</nz-spin>



<!-- <div nz-row [nzGutter]="24" class="pt-lg">
    <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24">
        <nz-card [nzLoading]="loading" [nzBordered]="false" [nzTitle]="'项目费用占比' | translate"  class="mb-0">
            <h4 class="margin:5px 0 5px 0;"></h4>
            <nz-table [nzShowPagination]="false">
                <thead>
                  <tr>
                    <th rowspan="2">序号</th>
                    <th rowspan="2">任务</th>
                    <th rowspan="2">负责人</th>
                    <th rowspan="2">开始<br/>时间</th>
                    <th rowspan="2">完成<br/>时间</th>
                    <th rowspan="2">工期</th>
                    <th rowspan="2">进度</th>
                    <th colspan="2">19年2月</th>
                    <th colspan="2">19年3月</th>
                    <th colspan="2">19年4月</th>
                    <th colspan="2">19年5月</th>
                    <th colspan="2">19年6月</th>
                    <th colspan="2">19年7月</th>
                    <th colspan="2">19年8月</th>
                    <th colspan="2">19年9月</th>
                  </tr>
                  <tr>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                    <th>10</th>
                    <th>25</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>1</td>
                    <td>CD01</td>
                    <td>张三</td>
                    <td>20190201</td>
                    <td>20190620</td>
                    <td>100d</td>
                    <td>85%</td>
                    <td class="work_done"></td>
                    <td class="work_done"></td>

                    <td class="work_done"></td>
                    <td class="work_done"></td>

                    <td class="work_done"></td>
                    <td class="work_done"></td>

                    <td class="work_done"></td>
                    <td class="work_done"></td>

                    <td class="work_doing"></td>
                    <td class="work_doing"></td>

                    <td></td>
                    <td></td>

                    <td></td>
                    <td></td>

                    <td></td>
                    <td></td>
                  </tr>
                  <tr>
                      <td>2</td>
                      <td>CD02</td>
                      <td>李四</td>
                      <td>20190301</td>
                      <td>20190926</td>
                      <td>150d</td>
                      <td>50%</td>
                      <td></td>
                      <td></td>
  
                      <td class="work_done"></td>
                      <td class="work_done"></td>
  
                      <td class="work_done"></td>
                      <td class="work_done"></td>
  
                      <td class="work_done"></td>
                      <td class="work_done"></td>
  
                      <td class="work_doing"></td>
                      <td class="work_doing"></td>
  
                      <td class="work_doing"></td>
                      <td class="work_doing"></td>
  
                      <td class="work_doing"></td>
                      <td class="work_doing"></td>
  
                      <td class="work_doing"></td>
                      <td></td>
                    </tr>
                    <tr>
                        <td>3</td>
                        <td>CD03</td>
                        <td>Jack</td>
                        <td>20190315</td>
                        <td>20190606</td>
                        <td>60d</td>
                        <td>90%</td>
                        <td></td>
                        <td></td>
    
                        <td class=""></td>
                        <td class="work_done"></td>
    
                        <td class="work_done"></td>
                        <td class="work_done"></td>
    
                        <td class="work_done"></td>
                        <td class="work_done"></td>
    
                        <td class="work_doing"></td>
                        <td class=""></td>
    
                        <td class=""></td>
                        <td class=""></td>
    
                        <td class=""></td>
                        <td class=""></td>
    
                        <td class=""></td>
                        <td></td>
                      </tr>
                      <tr>
                          <td>4</td>
                          <td>CD04</td>
                          <td>Alise</td>
                          <td>20190401</td>
                          <td>20190816</td>
                          <td>100d</td>
                          <td>40%</td>
                          <td></td>
                          <td></td>
      
                          <td class=""></td>
                          <td class=""></td>
      
                          <td class="work_done"></td>
                          <td class="work_done"></td>
      
                          <td class="work_done"></td>
                          <td class="work_doing"></td>
      
                          <td class="work_doing"></td>
                          <td class="work_doing"></td>
      
                          <td class="work_doing"></td>
                          <td class="work_doing"></td>
      
                          <td class="work_doing"></td>
                          <td class=""></td>
      
                          <td class=""></td>
                          <td></td>
                        </tr>
                        <tr>
                            <td>5</td>
                            <td>CD05</td>
                            <td>Tom</td>
                            <td>20190410</td>
                            <td>20190924</td>
                            <td>120d</td>
                            <td>30%</td>
                            <td></td>
                            <td></td>
        
                            <td class=""></td>
                            <td class=""></td>
        
                            <td class=""></td>
                            <td class="work_done"></td>
        
                            <td class="work_done"></td>
                            <td class="work_doing"></td>
        
                            <td class="work_doing"></td>
                            <td class="work_doing"></td>
        
                            <td class="work_doing"></td>
                            <td class="work_doing"></td>
        
                            <td class="work_doing"></td>
                            <td class="work_doing"></td>
        
                            <td class="work_doing"></td>
                            <td></td>
                          </tr>
                          <tr>
                              <td>6</td>
                              <td>CD06</td>
                              <td>王五</td>
                              <td>20190422</td>
                              <td>20190906</td>
                              <td>100d</td>
                              <td>25%</td>
                              <td></td>
                              <td></td>
          
                              <td class=""></td>
                              <td class=""></td>
          
                              <td class=""></td>
                              <td class=""></td>
          
                              <td class="work_done"></td>
                              <td class="work_done"></td>
          
                              <td class="work_doing"></td>
                              <td class="work_doing"></td>
          
                              <td class="work_doing"></td>
                              <td class="work_doing"></td>
          
                              <td class="work_doing"></td>
                              <td class="work_doing"></td>
          
                              <td class=""></td>
                              <td></td>
                            </tr>
                            <tr>
                                <td>7</td>
                                <td>CD07</td>
                                <td>超人</td>
                                <td>20190510</td>
                                <td>20190829</td>
                                <td>80d</td>
                                <td>15%</td>
                                <td></td>
                                <td></td>
            
                                <td class=""></td>
                                <td class=""></td>
            
                                <td class=""></td>
                                <td class=""></td>
            
                                <td class=""></td>
                                <td class="work_done"></td>
            
                                <td class="work_doing"></td>
                                <td class="work_doing"></td>
            
                                <td class="work_doing"></td>
                                <td class="work_doing"></td>
            
                                <td class="work_doing"></td>
                                <td class="work_doing"></td>
            
                                <td class=""></td>
                                <td class=""></td>
                              </tr>
                              <tr>
                                  <td>8</td>
                                  <td>CD08</td>
                                  <td>Mike</td>
                                  <td>20190527</td>
                                  <td>20190913</td>
                                  <td>80d</td>
                                  <td>0%</td>
                                  <td></td>
                                  <td></td>
              
                                  <td class=""></td>
                                  <td class=""></td>
              
                                  <td class=""></td>
                                  <td class=""></td>
              
                                  <td class=""></td>
                                  <td class=""></td>
              
                                  <td class="work_doing"></td>
                                  <td class="work_doing"></td>
              
                                  <td class="work_doing"></td>
                                  <td class="work_doing"></td>
              
                                  <td class="work_doing"></td>
                                  <td class="work_doing"></td>
              
                                  <td class="work_doing"></td>
                                  <td class=""></td>
                                </tr>
                </tbody>
              </nz-table>
          </nz-card>
    </div>
  </div>
<div nz-row [nzGutter]="24">
  <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="12">
    <nz-card [nzLoading]="loading" [nzBordered]="false" [nzTitle]="'2018年度成本分析' | translate" class="mb-0">
      
        <h4 class="margin:8px 0 32px 0;"></h4>
        <g2-pie *ngIf="salesPieData" [data]="feeData" [hasLegend]="true" [subTitle]="'' | translate" [height]="248" [lineWidth]="4" [total]=""
          [valueFormat]="feeFormat" [inner]="0">
        </g2-pie>
    </nz-card>
  </div>
  <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="12">
    <nz-card [nzLoading]="loading" [nzBordered]="false" [nzTitle]="'项目风险预警' | translate" 
      class="sales-card mb-0" >
      <h4 class="margin:8px 0 32px 0;"></h4>
      <g2-bar *ngIf="salesPieData" [data]="alertData" [height]="248" >
      </g2-bar>
    </nz-card>
  </div>
</div> -->





















import { Component, ChangeDetectionStrategy, OnInit, ChangeDetectorRef, ElementRef } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { STColumn, XlsxService } from '@delon/abc';
import { getTimeDistance } from '@delon/util';
import { _HttpClient } from '@delon/theme';
import { I18NService } from '@core';
import { yuan } from '@shared';
import { ProjectFileService } from 'app/services/projectFile/project-file.service';
import { FbsWorkshopDispatchListService } from 'app/services/fbs/fbs-workshop-dispatch-list.service';
import { FbsAbnormalWorkingHoursService } from 'app/services/fbs/fbs-abnormal-working-hours.service';
import { FbsWorkshopDispatchList } from 'app/entity/fbs/fbs-workshop-dispatch-list';
import { convertingNumbers } from '@shared/utils/shared';
import { FbsAbnormalWorkingHours } from 'app/entity/fbs/fbs-abnormal-working-hours';
@Component({
  selector: 'app-dashboard-analysis',
  templateUrl: './analysis.component.html',
  styleUrls: ['./analysis.component.less'],
  styles:[
    `
    table{
      border-collapse:collapse;border:none;
    }
    th{
      border:solid#000 1px;
    }
    td{
      border:solid#000 1px;
    }
    .bolder{
      font-weight:bolder;
    }
    
    `
  ]
  // changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DashboardAnalysisComponent implements OnInit {
  data: any = {};
  loading = true;
  date_range: Date[] = [];
  rankingListData: any[] = Array(7)
    .fill({})
    .map((item, i) => {
      return {
        title: this.i18n.fanyi('app.analysis.test', { no: i }),
        total: 323234,
      };
    });
  titleMap = {
    y1: this.i18n.fanyi('app.analysis.traffic'),
    y2: this.i18n.fanyi('app.analysis.payments'),
  };
  searchColumn: STColumn[] = [
    { title: '排名', i18n: 'app.analysis.table.rank', index: 'index' },
    {
      title: '搜索关键词',
      i18n: 'app.analysis.table.search-keyword',
      index: 'keyword',
      click: (item: any) => this.msg.success(item.keyword),
    },
    {
      type: 'number',
      title: '用户数',
      i18n: 'app.analysis.table.users',
      index: 'count',
      sorter: (a, b) => a.count - b.count,
    },
    {
      type: 'number',
      title: '周涨幅',
      i18n: 'app.analysis.table.weekly-range',
      index: 'range',
      render: 'range',
      sorter: (a, b) => a.range - b.range,
    },
  ];

  constructor(
    private http: _HttpClient,
    public msg: NzMessageService,
    private i18n: I18NService,
    private cdr: ChangeDetectorRef,
    private projectFileService: ProjectFileService,
    private fbsWorkshopDispatchListService:FbsWorkshopDispatchListService,
    private fbsAbnormalWorkingHoursService:FbsAbnormalWorkingHoursService,
    private xlsx: XlsxService
  ) { }


  ngOnInit() {
    // const offlineData: any[] = [];
    // for (let i = 0; i < 10; i += 1) {
    //   offlineData.push({
    //     name: `门店${i}`,
    //     cvr: Math.ceil(Math.random() * 9) / 10,
    //   });
    // };
    // offlineData.forEach((item: any, idx: number) => {
    //   item.show = idx === 0;
    //   item.chart = Object.assign([], offlineData);
    // });
    // this.http.get('/chart').subscribe((res: any) => {
    //   res.offlineData.forEach((item: any, idx: number) => {
    //     item.show = idx === 0;
    //     item.chart = Object.assign([], res.offlineChartData);
    //   });
    //   this.data = res;
    //   this.loading = false;
    // });
    
    this.getCircleChartData();
    this.feeTotal = `&yen ${this.feeData.reduce((pre, now) => now.y + pre, 0).toFixed(2)}`;
    this.alertTotal = `&yen ${this.feeData.reduce((pre, now) => now.y + pre, 0).toFixed(2)}`;
    this.getNow();
    this.getSumDispatchReport();
    this.getAbnormalWorkingHoursReport();
    this.getPlanningReport();
    this.getAbnormalWorkingHoursTotal();
  }

  /**
   * @description: 获取数据
   * @param {type} 
   * @author: 段亚鑫
   */
  isVisible = false;
  getCircleChartData() {
    this.projectFileService.queryStatusNum().then((response) => {
      this.projectFeeData = response.result.statusList;
      this.projectFeeTotal = response.result.sum;
      this.isVisible = true;
      this.loading = false;
      // this.chart.render();
    })
  }

  /**
  * @description: 渲染图表
  * @param {type} 
  * @author: 段亚鑫
  */
  chart: any;
  render(el: ElementRef) {
    const data = [{
      item: '事例一',
      count: 40,
      percent: 0.4
    }, {
      item: '事例二',
      count: 21,
      percent: 0.21
    }, {
      item: '事例三',
      count: 17,
      percent: 0.17
    }, {
      item: '事例四',
      count: 13,
      percent: 0.13
    }, {
      item: '事例五',
      count: 9,
      percent: 0.09
    }];
    this.chart = new G2.Chart({
      container: el.nativeElement,
      forceFit: true,
      height: 450,
      animate: false
    });
    this.chart.source(data, {
      percent: {
        formatter: function formatter(val) {
          val = val * 100 + '%';
          return val;
        }
      }
    });
    this.chart.coord('theta', {
      radius: 0.75,
      innerRadius: 0.6
    });
    this.chart.tooltip({
      showTitle: false,
      itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
    });
    // 文本
    this.chart.guide().html({
      position: ['50%', '50%'],
      html: '<div style="color:#8c8c8c;font-size: 14px;text-align: center;width: 10em;">主机<br><span style="color:#8c8c8c;font-size:20px">200</span>台</div>',
      alignX: 'middle',
      alignY: 'middle'
    });
    const interval = this.chart.intervalStack().position('percent').color('item').label('percent', {
      formatter: function formatter(val, item) {
        return item.point.item + ': ' + val;
      }
    }).tooltip('item*percent', function (item, percent) {
      percent = percent * 100 + '%';
      return {
        name: item,
        value: percent
      };
    }).style({
      lineWidth: 1,
      stroke: '#fff'
    });
    // this.chart.render();
    interval.setSelected(data[0]);
  }

  setDate(type: any) {
    this.date_range = getTimeDistance(type);
    setTimeout(() => this.cdr.detectChanges());
  }

  salesType = 'all';
  salesPieData: any;
  salesTotal = 0;
  changeSaleType() {
    this.salesPieData =
      this.salesType === 'all'
        ? this.data.salesTypeData
        : this.salesType === 'online'
          ? this.data.salesTypeDataOnline
          : this.data.salesTypeDataOffline;
    if (this.salesPieData) {
      this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0);
    }
    this.cdr.detectChanges();
  }

  handlePieValueFormat(value: any) {
    return yuan(value);
  }

  saleTabs: any[] = [{ key: 'sales', show: true }, { key: 'visits' }];
  salesChange(idx: number) {
    if (this.saleTabs[idx].show !== true) {
      this.saleTabs[idx].show = true;
      this.cdr.detectChanges();
    }
  }

  offlineIdx = 0;
  offlineChange(idx: number) {
    if (this.data.offlineData[idx].show !== true) {
      this.data.offlineData[idx].show = true;
      this.cdr.detectChanges();
    }
  }


  projectFeeTotal: any = null;
  projectFeeData = [
    // {x:'试剂/PD01',y:5.0,},
    // {x:'试剂/PDA',y:2.5,},
    // {x:'试剂/PR02',y:1.5,},
    // {x:'检测/PD01',y:5.5,},
    // {x:'检测/PDA',y:2.2,},
    // {x:'检测/PR02',y:1.6,},
    // {x:'会议/PD01',y:0.8,},
    // {x:'会议/PDA',y:3.2,},
    // {x:'会议/PR02',y:1.5,},
    // {x:'培训/PD01',y:2.5,},
    // {x:'培训/PDA',y:7.6,},
    // {x:'培训/PR02',y:1.8,},
    // {x:'会议/PD01',y:0.8,},
    // {x:'会议/PDA',y:3.2,},
    // {x:'人工/PR02',y:4.2,},
  ];
  projectFeeFormat(val: number) {
    // console.error(val)
    return val+"/个";
  }

  feeTotal: string;
  feeData = [
    { x: '一季度', y: 10000, },
    { x: '二季度', y: 40000, },
    { x: '三季度', y: 80000, },
    { x: '四季度', y: 30000, },
  ];
  feeFormat(val: number) {
    return `&yen ${val.toFixed(2)}`;
  }

  alertTotal: string;
  alertData = [
    { x: '办公费', y: 8000, },
    { x: '检测费', y: 12000, },
    { x: '设备采购费', y: 66000, },
    { x: '培训费', y: 45000, },
  ];
  alertFormat(val: number) {
    return `&yen ${val.toFixed(2)}`;
  }

  saveLoading=false;
  /**
   * 获取报表数据
   */
  listOfDataSelect=null;
  getSumDispatchReport(){
    this.saveLoading=true;
    this.fbsWorkshopDispatchListService.getSumDispatchReport(this.fbsWorkshopDispatchList).then((response)=>{
      this.listOfData=response.result;
      this.defaultSwitch();
      this.isSwitchChange();
      if(this.listOfDataSelect===null){
        this.listOfDataSelect=JSON.parse(JSON.stringify(response.result));
      }
      
      //获取时间集合数据
      this.getDateList();
      //总效率
      this.getEfficiencyTotal()
      this.saveLoading=false;
    })
  }

  achievementRateTotal="";//总达成率
  productivityTotal="";//生产率
  getEfficiencyTotal(){
    this.listOfData.forEach(element => {
      let numberOfTasksTotal=element.numberOfTasksTotal;//计划数量
      let standardWorkingHoursActualTotal=element.standardWorkingHoursActualTotal;//实际标准工时
      let quantityCompletedTotal=element.quantityCompletedTotal;//完成数量
      let manHoursCompletedTotal=element.manHoursCompletedTotal;//完成工时
      if(element.projectName==="统计"){
        this.achievementRateTotal=((Number(quantityCompletedTotal)/Number(numberOfTasksTotal))*100).toFixed(1);
        console.log("标准工时",standardWorkingHoursActualTotal)
        this.productivityTotal=((Number(standardWorkingHoursActualTotal)/Number(manHoursCompletedTotal))*100).toFixed(1)
      }
    });
  }

  /**
   * 工时报表的总工时
   */
  abnormalWorkingHours:FbsAbnormalWorkingHours={}
  getAbnormalWorkingHoursTotal(){
    this.fbsAbnormalWorkingHoursService.getTotal(this.fbsWorkshopDispatchList.year+"-"+this.fbsWorkshopDispatchList.month).then((response)=>{
      this.abnormalWorkingHours=response.result;
    })
  }

  /**
   * 获取时间列集合数据
   */
  widthLength=0;
  dateList=[];
  getDateList(){
    if(this.listOfData&&this.listOfData.length>0){
      this.dateList=this.listOfData[0].fbsWorkshopDispatchListList
      // this.widthLength=(this.listOfData[0].fbsWorkshopDispatchListList.length*700)+890;
      this.widthLength=(this.listOfData[0].fbsWorkshopDispatchListList.length*600)+1020;
    }
  }

  /**
   * 异常工时统计
   */
  abnormalWorkingHoursList:any=[];
  AbnormalWorkingHoursTotal:any={}
  getAbnormalWorkingHoursReport(){
    this.fbsAbnormalWorkingHoursService.getAbnormalWorkingHoursReport().then((response)=>{
      this.abnormalWorkingHoursList=response.result.fbsAbnormalWorkingHoursList;
      let attendanceHours=0;//出勤总工时
      let overtimeHours=0;//加班总工时
      let train=0;//其他总工时
      let abnormalWorkingHours=0;//异常总工时统计
      let warehouse=0;//仓库总工时统计
      this.abnormalWorkingHoursList.forEach(element => {
        if(element.attendanceHours){
          attendanceHours=attendanceHours+Number(element.attendanceHours);
        }
        if(element.overtimeHours){
        overtimeHours=overtimeHours+Number(element.overtimeHours);
        }
        train=train+Number(element.train)+Number(element.meeting)+Number(element.fiveS)+Number(element.researchAndDevelopment);
        abnormalWorkingHours=abnormalWorkingHours+Number(element.quality)+Number(element.design)+Number(element.rework)+Number(element.materiel)+Number(element.energy)+Number(element.other)+Number(element.equipment)+Number(element.plan);
        warehouse=warehouse+Number(element.mixedIngredients)+Number(element.warehousing)+Number(element.pack)+Number(element.warehouseOthers)
      });
      this.AbnormalWorkingHoursTotal.attendanceHours=attendanceHours;
      this.AbnormalWorkingHoursTotal.overtimeHours=overtimeHours;
      this.AbnormalWorkingHoursTotal.train=train;
      this.AbnormalWorkingHoursTotal.abnormalWorkingHours=abnormalWorkingHours;
      this.AbnormalWorkingHoursTotal.warehouse=warehouse;
    })
  }


  fbsWorkshopDispatchList:FbsWorkshopDispatchList={};


  listOfData=[]

  isSwitch=false;//是否显示已完成订单
  isSwitchChange(){
      this.listOfData.forEach(element => {
        if(element.status===4){
          if(this.isSwitch===false){
            element.isSwitch=false;
          }else{
            element.isSwitch=true;
          }
        }
      });
  }
  defaultSwitch(){
    this.listOfData.forEach(element => {
      if(element.status===4){
          element.isSwitch=false;
      }else{
        element.isSwitch=true;
      }
    });
  }

  /**
   * 导出
   */

   year="0";
   month="0";
   //初始化年月 默认当前年月
   getNow(){
    let date = new Date();
    this.fbsWorkshopDispatchList.year=date.getFullYear()+"";
    if(date.getMonth()<10){
      this.fbsWorkshopDispatchList.month="0"+(date.getMonth()+1)
    }else{
      this.fbsWorkshopDispatchList.month=(date.getMonth()+1)+"";
    }
    
   }
   
  exportLoading=false;
  export(){
    // let month=this.year.substring(2,4)+this.month;
    // this.fbsWorkshopDispatchListService.export(month).then((response)=>{
    //   let list=[];
    //   list=response.result

    // this.exportLoading=true;
    let data = [];
    let title = [
      ['项目名称'], // 项目名称
      ['订单编号'], // 订单编号
      ['物料编码'], // 物料编码
      ['物料名称'], // 物料名称
      ['计划数量'], // 月度计划
      ['标准工时'], // 标准工时
      ['完成数量'], // 累计完成数量
      ['实际工时'], // 累计完成工时
      ['订单达成率'], // 订单达成率
      ['计划生产效率'], // 计划生产效率
    ];
    data.push(title);
    this.listOfData.forEach(element => {
      let row=[];
      if(element.projectName=="统计"){
        row.push("标准总工时")
        row.push(element.standardWorkingHoursTotal)
        element.product="统计";
      }else{
        row.push(element.projectName)
        row.push(element.productionOrderNumberName)
      }
      
      row.push(element.productId)
      row.push(element.product)
      row.push(convertingNumbers(element.surplusNumberOfTasksTotal))//numberOfTasksTotal
      row.push(convertingNumbers(element.surplusStandardWorkingHoursTotal))//standardWorkingHoursTotal
      row.push(element.quantityCompletedTotal)//quantityCompletedTotal//latestCompletedQuantity
      row.push(convertingNumbers(element.manHoursCompletedTotal))
      if(element.projectName!="统计"){
        row.push(element.achievementRate+"%")
        if(element.productionEfficiency){
          row.push(element.productionEfficiency+"%")
        }else{
          row.push("0.0%")
        }
      }

      
      
      data.push(row);
    });
    
    let efficiencyTotal=[
      ['总达成率'],
      [this.achievementRateTotal+'%'],
      ['总生产效率'],
      [this.productivityTotal+'%'],
      ['出勤总工时'],
      [this.abnormalWorkingHours.attendanceHours],
      ['加班总工时'],
      [this.abnormalWorkingHours.overtimeHours],
      ['其他总工时'],
      [this.abnormalWorkingHours.other],
      ['异常总工时统计'],
      [this.abnormalWorkingHours.quality],
      ['仓库总工时统计'],
      [this.abnormalWorkingHours.plan]
    ];
    data.push(efficiencyTotal);
    // 导出
    this.xlsx.export({
      sheets: [
        {
          data: data,
          name: '生产订单汇总导出',
        },
      ],
      filename: '生产订单汇总导出.xlsx',
    });
    // this.exportLoading=false;
    // })
  }


  planningReportList=[]
  planningReportLoading=false;
  fbsWorkshopDispatchListPlanningReport:FbsWorkshopDispatchList={}
  columnTable2Width=0;
  getPlanningReport(){
    this.planningReportLoading=true;
    this.fbsWorkshopDispatchListService.getPlanningReport().then((response)=>{
      this.fbsWorkshopDispatchListPlanningReport=response.result;
      this.planningReportList=response.result.fbsWorkshopDispatchListList;
      this.columnTable2Width=response.result.dayList.length*25+420
      this.planningReportLoading=false;
    })
  }
}
