Selaa lähdekoodia

查询 导出

chenc 4 vuotta sitten
vanhempi
commit
1782d54aac

+ 9 - 0
src/app/entity/fbs/fbs-workshop-dispatch-list.ts

@@ -37,6 +37,15 @@ export class FbsWorkshopDispatchList extends Page{
 	projectName?:string;
 	//行号
 	rowNumber?:string;
+	//开始
+	start?:string;
+	//结束
+	end?:string;
+
+	latestCompletedQuantity?:string;
+  manHoursCompleted?:string;
+  numberEfficiency?:string;
+  workingHoursEfficiency?:string;
 	
 	fbsWorkshopDispatchListList?:FbsWorkshopDispatchList[]
 	

+ 23 - 21
src/app/routes/dashboard/analysis/analysis.component.html

@@ -63,28 +63,29 @@
 <!-- <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">
 <div nz-row [nzGutter]="24" class="pt-lg">
   <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24">
-    <nz-table  nzSize="small" #columnTable nzBordered [nzData]="listOfData"
-      [nzScroll]="{ x: widthLength+'px', y:'800px'}" [nzShowPagination]="false" [nzFrontPagination]="false">
+    <nz-table class="tableTdPadding"  nzSize="small" #columnTable nzBordered [nzData]="listOfData" 
+      [nzScroll]="{ x: widthLength+'px', y:'550px'}" [nzShowPagination]="false" [nzFrontPagination]="false">
       <thead>
         <tr>
-          <th nzWidth="60px"><strong>序号</strong></th>
-          <th nzWidth="100px"><strong>生产线</strong></th>
-          <th nzWidth="110px"><strong>生产订单号</strong></th>
-          <th nzWidth="120px"><strong>物料编码</strong></th>
-          <th nzWidth="100px"><strong>物料名称</strong></th>
-          <th nzWidth="80px"><strong>月度计划</strong></th>
-          <th nzWidth="80px"><strong>标准工时</strong></th>
-          <th nzWidth="110px"><strong>累计完成数量</strong></th>
-          <th nzWidth="110px"><strong>累计完成工时</strong></th>
+          <th nzWidth="60px" nzAlign="center"><strong>序号</strong></th>
+          <th nzWidth="100px" nzAlign="center"><strong>项目名称</strong></th>
+          <th nzWidth="110px" nzAlign="center"><strong>生产订单号</strong></th>
+          <th nzWidth="120px" nzAlign="center"><strong>物料编码</strong></th>
+          <th nzWidth="100px" nzAlign="center"><strong>物料名称</strong></th>
+          <th nzWidth="80px" nzAlign="center"><strong>月度计划</strong></th>
+          <th nzWidth="80px" nzAlign="center"><strong>标准工时</strong></th>
+          <th nzWidth="110px" nzAlign="center"><strong>累计完成数量</strong></th>
+          <th nzWidth="110px" nzAlign="center"><strong>累计完成工时</strong></th>
           <ng-container *ngFor="let date of dateList">
-            <th nzWidth="120px"><strong>当日计算数量</strong></th>
-            <th nzWidth="120px"><strong>当日完成数量</strong></th>
-            <th nzWidth="120px"><strong>当日完成工时 </strong></th>
-            <th nzWidth="120px"><strong>当日标准工时</strong></th>
-            <th nzWidth="120px"><strong>当日生产效率</strong></th>
-            <th nzWidth="100px"><strong>当日达成率</strong></th>
+            <th nzWidth="120px" nzAlign="center"><strong>当日计划数量</strong></th>
+            <th nzWidth="120px" nzAlign="center"><strong>当日完成数量</strong></th>
+            <th nzWidth="120px" nzAlign="center"><strong>当日完成工时 </strong></th>
+            <th nzWidth="120px" nzAlign="center"><strong>当日标准工时</strong></th>
+            <th nzWidth="120px" nzAlign="center"><strong>当日生产效率</strong></th>
+            <th nzWidth="100px" nzAlign="center"><strong>当日达成率</strong></th>
           </ng-container>
         </tr>
         <tr>
@@ -97,10 +98,10 @@
       </thead>
       <tbody>
         <tr *ngFor="let data of columnTable.data;let i = index">
-          <ng-container *ngIf="data.productionLineName!=='统计'">
+          <ng-container *ngIf="data.projectName!=='统计'">
           <!-- *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines" -->
           <td *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines">{{ data.sort }}</td>
-          <td *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines">{{ data.productionLineName }}</td>
+          <td *ngIf="data.mergeLines!=0" [attr.rowSpan]="data.mergeLines">{{ data.projectName }}</td>
           <td>{{ data.productionOrderNumberName }}</td>
           <td>{{data.productId}}</td>
           <td>{{data.product}}</td>
@@ -126,7 +127,7 @@
         </tr >
         <!-- 统计 -->
         <tr style="background-color:rgb(223, 223, 219)" *ngFor="let data of columnTable.data;let i = index">
-          <ng-container *ngIf="data.productionLineName==='统计'">
+          <ng-container *ngIf="data.projectName==='统计'">
           <td style="background-color:rgb(223, 223, 219)"></td>
           <td style="background-color:rgb(223, 223, 219)">统计</td>
           <td style="background-color:rgb(223, 223, 219)"></td>
@@ -273,7 +274,8 @@
     </nz-table>
   </div>
 </div>
-
+<button nz-button nzType="primary" (click)="export()" [nzLoading]="exportLoading">导出</button>
+</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">

+ 64 - 3
src/app/routes/dashboard/analysis/analysis.component.ts

@@ -1,6 +1,6 @@
 import { Component, ChangeDetectionStrategy, OnInit, ChangeDetectorRef, ElementRef } from '@angular/core';
 import { NzMessageService } from 'ng-zorro-antd';
-import { STColumn } from '@delon/abc';
+import { STColumn, XlsxService } from '@delon/abc';
 import { getTimeDistance } from '@delon/util';
 import { _HttpClient } from '@delon/theme';
 import { I18NService } from '@core';
@@ -13,6 +13,19 @@ import { FbsAbnormalWorkingHoursService } from 'app/services/fbs/fbs-abnormal-wo
   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;
+    }
+    `
+  ]
   // changeDetection: ChangeDetectionStrategy.OnPush,
 })
 export class DashboardAnalysisComponent implements OnInit {
@@ -63,7 +76,8 @@ export class DashboardAnalysisComponent implements OnInit {
     private cdr: ChangeDetectorRef,
     private projectFileService: ProjectFileService,
     private fbsWorkshopDispatchListService:FbsWorkshopDispatchListService,
-    private fbsAbnormalWorkingHoursService:FbsAbnormalWorkingHoursService
+    private fbsAbnormalWorkingHoursService:FbsAbnormalWorkingHoursService,
+    private xlsx: XlsxService
   ) { }
 
 
@@ -272,15 +286,17 @@ export class DashboardAnalysisComponent implements OnInit {
     return `&yen ${val.toFixed(2)}`;
   }
 
-
+  saveLoading=false;
   /**
    * 获取报表数据
    */
   getSumDispatchReport(){
+    this.saveLoading=true;
     this.fbsWorkshopDispatchListService.getSumDispatchReport().then((response)=>{
       this.listOfData=response.result;
       //获取时间集合数据
       this.getDateList();
+      this.saveLoading=false;
     })
   }
 
@@ -309,4 +325,49 @@ export class DashboardAnalysisComponent implements OnInit {
 
 
   listOfData=[]
+
+  /**
+   * 导出
+   */
+  exportLoading=false;
+  export(){
+    this.exportLoading=true;
+    let data = [];
+    let title = [
+      ['序号'], // 序号
+      ['项目名称'], // 项目名称
+      ['生产订单号'], // 生产订单号
+      ['物料编码'], // 物料编码
+      ['物料名称'], // 物料名称
+      ['月度计划'], // 月度计划
+      ['标准工时'], // 标准工时
+      ['累计完成数量'], // 累计完成数量
+      ['累计完成工时'], // 累计完成工时
+    ];
+    data.push(title);
+    this.listOfData.forEach(element => {
+      let row=[];
+      row.push(element.sort)
+      row.push(element.projectName)
+      row.push(element.productionOrderNumberName)
+      row.push(element.productId)
+      row.push(element.product)
+      row.push(element.numberOfTasksTotal)
+      row.push(element.standardWorkingHoursTotal)
+      row.push(element.quantityCompletedTotal)
+      row.push(element.manHoursCompletedTotal)
+      data.push(row);
+    });
+    // 导出
+    this.xlsx.export({
+      sheets: [
+        {
+          data: data,
+          name: '生产订单汇总导出',
+        },
+      ],
+      filename: '生产订单汇总导出.xlsx',
+    });
+    this.exportLoading=false;
+  }
 }

+ 30 - 8
src/app/routes/fbs-workshop-dispatch-list/list/list.component.html

@@ -1,19 +1,33 @@
 <page-header [action]="phActionTpl">
   <ng-template #phActionTpl>
     <button (click)="add()" nz-button nzType="primary">新建</button>
+    <button (click)="export()" nz-button nzType="primary" [nzLoading]="exportLoading">导出</button>
   </ng-template>
 </page-header>
 <nz-card>
   <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-label [nzSpan]="8">派工时间范围</nz-form-label>
           <nz-form-control [nzSpan]="16">
-            <input [(ngModel)]="fbsWorkshopDispatchList.name" name="name" nz-input
-              placeholder="请输入" />
+            <!-- <input [(ngModel)]="fbsWorkshopDispatchList.name" name="name" nz-input
+              placeholder="请输入" /> -->
+              <nz-date-picker name="fbsWorkshopDispatchList.start" [(ngModel)]="fbsWorkshopDispatchList.start" nzPlaceHolder="请选择" >
+              </nz-date-picker>
+          </nz-form-control>
+        </nz-form-item>
+      </div>
+      <div nz-col nzXs="24" nzSm="4" nzLg="8">
+        <nz-form-item class="nz-form-item">
+          <nz-form-label [nzSpan]="8"[nzNoColon]="true"></nz-form-label>
+          <nz-form-control [nzSpan]="16">
+            <!-- <input [(ngModel)]="fbsWorkshopDispatchList.name" name="name" nz-input
+              placeholder="请输入" /> -->
+              <nz-date-picker name="fbsWorkshopDispatchList.end" [(ngModel)]="fbsWorkshopDispatchList.end" nzPlaceHolder="请选择" >
+              </nz-date-picker>
           </nz-form-control>
         </nz-form-item>
       </div>
@@ -41,8 +55,12 @@
         <th>产品</th>
         <th>任务数量</th>
         <th>标准工时</th>
-        <th>计划开工时间</th>
-        <th>计划完工时间</th>
+        <th>完成数量</th>
+        <th>完成工时</th>
+        <th>达成率</th>
+        <th>生产效率</th>
+        <!-- <th>计划开工时间</th>
+        <th>计划完工时间</th> -->
         <th style="width:15%">{{ 'table.operation' | translate }}</th>
       </tr>
     </thead>
@@ -55,8 +73,12 @@
         <td>{{item.product}}</td>
         <td>{{item.numberOfTasks}}</td>
         <td>{{item.standardWorkingHours}}</td>
-        <td>{{item.plannedStartTime}}</td>
-        <td>{{item.plannedEndTime}}</td>
+        <td>{{item.latestCompletedQuantity}}</td>
+        <td>{{item.manHoursCompleted}}</td>
+        <td>{{item.numberEfficiency}}%</td>
+        <td>{{item.workingHoursEfficiency}}%</td>
+        <!-- <td>{{item.plannedStartTime}}</td>
+        <td>{{item.plannedEndTime}}</td> -->
         <td>
           <!-- 详情 -->
           <a (click)="view(item)">{{ 'table.view' | translate }}</a>

+ 112 - 21
src/app/routes/fbs-workshop-dispatch-list/list/list.component.ts

@@ -1,6 +1,6 @@
 import { Component, OnInit, ViewChild } from '@angular/core';
 import { _HttpClient, ModalHelper } from '@delon/theme';
-import { STColumn, STComponent } from '@delon/abc';
+import { STColumn, STComponent, XlsxService } from '@delon/abc';
 import { SFSchema } from '@delon/form';
 import { NzDrawerService, NzNotificationService } from 'ng-zorro-antd';
 import { FbsWorkshopDispatchListAddComponent } from '../add/add.component';
@@ -8,6 +8,7 @@ import { FbsWorkshopDispatchList } from 'app/entity/fbs/fbs-workshop-dispatch-li
 import { FbsWorkshopDispatchListUpdateComponent } from '../update/update.component';
 import { FbsWorkshopDispatchListViewComponent } from '../view/view.component';
 import { FbsWorkshopDispatchListService } from 'app/services/fbs/fbs-workshop-dispatch-list.service';
+import { DatePipe } from '@angular/common';
 
 @Component({
   selector: 'app-fbs-workshop-dispatch-list-list',
@@ -17,7 +18,9 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
   constructor(
     private nzDrawerService: NzDrawerService,
     private fbsWorkshopDispatchListService: FbsWorkshopDispatchListService,
-    private nzNotificationService: NzNotificationService
+    private nzNotificationService: NzNotificationService,
+    private datePipe: DatePipe,
+    private xlsx: XlsxService
   ) {}
 
   ngOnInit() {
@@ -37,8 +40,8 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
   /**
    * 查询按钮
    */
-  query(){
-    this.fbsWorkshopDispatchList.pageNo=1;
+  query() {
+    this.fbsWorkshopDispatchList.pageNo = 1;
     //主数据刷新
     this.getList();
   }
@@ -53,15 +56,103 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
   /**
    * 主数据查询
    */
-  getList(){
-    this.isLoading=true
-    this.fbsWorkshopDispatchListService.list(this.fbsWorkshopDispatchList).then((response)=>{
-      if(response.success){//查询成功
-        this.dataList=response.result.records;//表格数据
-        this.page=response.result;//分页数据
-        this.isLoading=false;
+  getList() {
+    this.isLoading = true;
+    //时间格式化
+    this.fbsWorkshopDispatchList.start = this.datePipe.transform(this.fbsWorkshopDispatchList.start, 'yyyy-MM-dd');
+    this.fbsWorkshopDispatchList.end = this.datePipe.transform(this.fbsWorkshopDispatchList.end, 'yyyy-MM-dd');
+    this.fbsWorkshopDispatchListService.list(this.fbsWorkshopDispatchList).then(response => {
+      if (response.success) {
+        //查询成功
+        this.dataList = response.result.records; //表格数据
+        this.getEfficiency(this.dataList); //计算效率
+        this.page = response.result; //分页数据
+        this.isLoading = false;
       }
-    })
+    });
+  }
+
+  /**
+   * 导出
+   */
+  exportLoading=false;
+  export() {
+    this.exportLoading=true;
+    //时间格式化
+    // this.fbsWorkshopDispatchList.start = this.datePipe.transform(this.fbsWorkshopDispatchList.start, 'yyyy-MM-dd');
+    // this.fbsWorkshopDispatchList.end = this.datePipe.transform(this.fbsWorkshopDispatchList.end, 'yyyy-MM-dd');
+    let fbsWorkshopDispatchList = new FbsWorkshopDispatchList();
+    fbsWorkshopDispatchList.pageSize = 20000;
+    fbsWorkshopDispatchList.start = this.datePipe.transform(this.fbsWorkshopDispatchList.start, 'yyyy-MM-dd');
+    fbsWorkshopDispatchList.end = this.datePipe.transform(this.fbsWorkshopDispatchList.end, 'yyyy-MM-dd');
+    this.fbsWorkshopDispatchListService.list(fbsWorkshopDispatchList).then(response => {
+      if (response.success) {
+        //查询成功
+        let dataList= response.result.records; //表格数据
+        this.getEfficiency(dataList); //计算效率
+        let data = [];
+        let title = [
+          ['姓名'], // 姓名
+          ['日期'], // 日期
+          ['生产订单号'], // 生产订单号
+          ['物料'], // 物料
+          ['任务数量'], // 任务数量
+          ['标准工时'], // 标准工时
+          ['完成数量'], // 完成数量
+          ['完成工时'], // 完成工时
+          ['达成率'], // 达成率
+          ['生产效率'], // 生产效率
+        ];
+        data.push(title);
+        dataList.forEach(element => {
+          let row = [];
+          row.push(element.name);
+          row.push(element.date);
+          row.push(element.productionOrderNumberName);
+          row.push(element.product);
+          row.push(element.numberOfTasks);
+          row.push(element.standardWorkingHours);
+          row.push(element.latestCompletedQuantity);
+          row.push(element.manHoursCompleted);
+          row.push(element.numberEfficiency+"%");
+          row.push(element.workingHoursEfficiency+"%");
+          data.push(row);
+        });
+        // 导出
+        this.xlsx.export({
+          sheets: [
+            {
+              data: data,
+              name: '派工单导出',
+            },
+          ],
+          filename: '派工单导出.xlsx',
+        });
+        this.exportLoading=false;
+      }
+    });
+  }
+
+  /**
+   * 计算效率
+   */
+  getEfficiency(dataList) {
+    dataList.forEach(element => {
+      let numberOfTasks = element.numberOfTasks; //任务数量
+      let standardWorkingHours = element.standardWorkingHours; //标准工时
+      let latestCompletedQuantity = element.latestCompletedQuantity; //完成数量
+      let manHoursCompleted = element.manHoursCompleted; //完成工时
+      if (latestCompletedQuantity && Number(latestCompletedQuantity) !== 0) {
+        element.numberEfficiency = ((Number(latestCompletedQuantity) / Number(numberOfTasks)) * 100).toFixed(0);
+      } else {
+        element.numberEfficiency = 0;
+      }
+      if (manHoursCompleted && Number(manHoursCompleted) !== 0) {
+        element.workingHoursEfficiency = ((Number(manHoursCompleted) / Number(standardWorkingHours)) * 100).toFixed(0);
+      } else {
+        element.workingHoursEfficiency = 0;
+      }
+    });
   }
 
   /**
@@ -97,7 +188,7 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
       nzWidth: window.innerWidth,
       nzBodyStyle: { height: 'calc(100% - 55px)', overflow: 'auto', 'padding-bottom': '53px' },
       nzContentParams: {
-        id:item.id
+        id: item.id,
       },
     });
   }
@@ -113,7 +204,7 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
       nzWidth: window.innerWidth,
       nzBodyStyle: { height: 'calc(100% - 55px)', overflow: 'auto', 'padding-bottom': '53px' },
       nzContentParams: {
-        id:item.id
+        id: item.id,
       },
     });
 
@@ -130,13 +221,13 @@ export class FbsWorkshopDispatchListListComponent implements OnInit {
    * 删除按钮
    */
   delete(item) {
-    this.fbsWorkshopDispatchListService.deleteAndChild(item.id).then((response)=>{
-      if(response.success){
-        this.nzNotificationService.success("删除成功","");
-        this.getList();//刷新
-      }else{
-        this.nzNotificationService.warning("删除失败","");
+    this.fbsWorkshopDispatchListService.deleteAndChild(item.id).then(response => {
+      if (response.success) {
+        this.nzNotificationService.success('删除成功', '');
+        this.getList(); //刷新
+      } else {
+        this.nzNotificationService.warning('删除失败', '');
       }
-    })
+    });
   }
 }