Przeglądaj źródła

驾驶舱工分排名导出

wanglt 2 tygodni temu
rodzic
commit
8ca8ddbca4

+ 42 - 2
ygtx-gxt/src/main/java/com/ygtx/gxt/controller/GxtRepairOrderController.java

@@ -2,19 +2,21 @@ package com.ygtx.gxt.controller;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Calendar;
 import java.util.List;
 import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.github.pagehelper.util.StringUtil;
 import com.ygtx.common.utils.DictUtils;
 import com.ygtx.common.utils.SecurityUtils;
 import com.ygtx.gxt.domain.*;
+import com.ygtx.gxt.domain.vo.GxtCompanyRankingVo;
 import com.ygtx.gxt.service.IGxtOrderScoreService;
 import com.ygtx.gxt.service.IGxtWorkOrderService;
 import com.ygtx.system.service.ISysConfigService;
@@ -431,6 +433,44 @@ public class GxtRepairOrderController extends BaseController
         return success(result);
     }
 
+    /**
+     * 导出排名列表
+     */
+    @Log(title = "导出排名列表", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportCompanyRank")
+    @ApiOperation("导出排名列表")
+    public void exportCompanyRanking(HttpServletResponse response, GxtUserScore userScore) {
+        Calendar calendar = Calendar.getInstance();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+        String monthPeriod = sdf.format(calendar.getTime());
+        List<GxtUserScore> list = gxtRepairOrderService.getCompanyRankingList();
+        List<GxtCompanyRankingVo> ranks = new ArrayList<>();
+        int currentRank = 1; // 当前排名
+        BigDecimal prevScore = null;
+
+        for (int i = 0; i < list.size(); i++) {
+            GxtUserScore item = list.get(i);
+            if (i==0) {
+                prevScore = item.getFinalScore();
+            }
+            if (prevScore.compareTo(item.getFinalScore())>0) {
+                currentRank = i + 1; // 分数变化,更新排名
+            }
+            // 相同分数排名相同
+            GxtCompanyRankingVo vo = new GxtCompanyRankingVo();
+            vo.setName(item.getNickName());
+            vo.setStation(item.getDeptName());
+            vo.setFinalScore(item.getFinalScore());
+            vo.setMonthPeriod(monthPeriod);
+            vo.setRank(currentRank); // 设置排名
+            ranks.add(vo);
+            prevScore = item.getFinalScore(); // 更新上一个分数
+        }
+        ExcelUtil<GxtCompanyRankingVo> util = new ExcelUtil<GxtCompanyRankingVo>(GxtCompanyRankingVo.class);
+
+        util.exportExcel(response, ranks, "公司排名数据");
+    }
+
     /**
      * 撤回维修工单
      */

+ 71 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/domain/vo/GxtCompanyRankingVo.java

@@ -0,0 +1,71 @@
+package com.ygtx.gxt.domain.vo;
+
+import com.ygtx.common.annotation.Excel;
+
+import java.math.BigDecimal;
+
+/**
+ * 用户月度评分统计表对象 gxt_user_score
+ * 
+ * @author ruoyi
+ * @date 2025-11-03
+ */
+public class GxtCompanyRankingVo
+{
+    @Excel(name = "排名")
+    private Integer rank;
+
+    @Excel(name = "名字")
+    private String name;
+
+    @Excel(name = "场站")
+    private String station;
+
+    /** 最终评分 */
+    @Excel(name = "工分")
+    private BigDecimal finalScore;
+
+    /** 统计月份(YYYY-MM) */
+    @Excel(name = "统计月份")
+    private String monthPeriod;
+
+    public Integer getRank() {
+        return rank;
+    }
+
+    public void setRank(Integer rank) {
+        this.rank = rank;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getStation() {
+        return station;
+    }
+
+    public void setStation(String station) {
+        this.station = station;
+    }
+
+    public BigDecimal getFinalScore() {
+        return finalScore;
+    }
+
+    public void setFinalScore(BigDecimal finalScore) {
+        this.finalScore = finalScore;
+    }
+
+    public String getMonthPeriod() {
+        return monthPeriod;
+    }
+
+    public void setMonthPeriod(String monthPeriod) {
+        this.monthPeriod = monthPeriod;
+    }
+}

+ 3 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/IGxtRepairOrderService.java

@@ -7,6 +7,7 @@ import com.ygtx.gxt.domain.GxtOrderData;
 import com.ygtx.gxt.domain.GxtRepairOrder;
 import com.ygtx.gxt.domain.GxtRepairOrderPerson;
 import com.ygtx.common.core.page.PageDomain;
+import com.ygtx.gxt.domain.GxtUserScore;
 
 /**
  * 维修工单Service接口
@@ -310,4 +311,6 @@ public interface IGxtRepairOrderService
      * @param repairOrder 维修工单
      */
     public void completePendingOrderDeductionData(GxtRepairOrder repairOrder);
+
+    public List<GxtUserScore> getCompanyRankingList();
 }

+ 11 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtRepairOrderServiceImpl.java

@@ -3070,4 +3070,15 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
             gxtOrderScoreDetailService.insertGxtOrderScoreDetail(detail);
         }
     }
+
+    public List<GxtUserScore> getCompanyRankingList() {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        String permission = getJXY(loginUser.getUsername());
+        if (StringUtil.isNotEmpty(permission)) {
+            GxtUserScore userScore = new GxtUserScore();
+            userScore.setPermission(permission);
+            return gxtRepairOrderMapper.selectHomePageRank(userScore);
+        }
+        return new ArrayList<>();
+    }
 }

+ 48 - 1
ygtx-ui/src/views/index5.vue

@@ -270,8 +270,21 @@
       <!-- 新增的排名列表卡片 -->
         <div style="width: 100%;height: 100%;">
           <el-card class="floating-card ranking-table-card">
+            <div v-if="companyExport" class="ranking-toolbar">
+              <el-input
+                v-model="rankingSearchQuery"
+                placeholder="搜索..."
+                @keyup.enter="handleRankingSearch"
+                style="width: 300px;"
+                prefix-icon="search"
+                clearable
+              />
+              <el-button type="primary" @click="handleExportRank">
+                <i class="fa fa-download" style="margin-right: 8px;"></i>导出
+              </el-button>
+            </div>
             <div class="card-content">
-              <el-table :data="currentRankingData" style="width: 100%;" height="800">
+              <el-table :data="currentRankingData" style="width: 100%;" height="720">
                 <el-table-column prop="rank" label="排名" width="80" align="center"></el-table-column>
                 <el-table-column prop="name" label="名字" width="120" align="center">
                   <template #default="scope">
@@ -312,6 +325,9 @@ export default {
         orderCode: null,
         status: 0
       },
+      companyExport: false,
+      rankingSearchQuery: '',
+      companyRankList: [],
       orderPersonList: [],
       // 添加首页统计数据
       homePageData: {
@@ -366,8 +382,24 @@ export default {
         this.timer = null;
       }
     },
+    handleRankingSearch() {
+      if (this.rankingSearchQuery) {
+        const query = this.rankingSearchQuery.toLowerCase();
+        this.currentRankingData = this.companyRankList.filter(item => 
+          item.name.toLowerCase().includes(query) || item.station.toLowerCase().includes(query)
+        );
+      } else {
+        this.currentRankingData = this.companyRankList;
+      }
+    },
     // 新增的方法:显示排名列表
     showRankingList(type) {
+      if (this.currentRankingType != type && type === 'company') {
+        this.companyExport = true;
+        this.rankingSearchQuery = '';
+      } else {
+        this.companyExport = false;
+      }
       // 如果点击的是同一个排名类型,则隐藏列表卡片
       if (this.currentRankingType === type) {
         this.showRankingTable = false;
@@ -413,6 +445,7 @@ export default {
           });
         });
 
+        this.companyRankList = rankedData;
         this.currentRankingData = rankedData;
       }
     },
@@ -540,6 +573,10 @@ export default {
     handleExport() {
       this.download("gxt/orderperson/exportOrderScorePerson", this.queryParams, `工分明细列表_${new Date().getTime()}.xlsx`);
     },
+    // 导出公司工分排名数据
+    handleExportRank() {
+      this.download("gxt/repairOrder/exportCompanyRank", this.queryParams, `公司工分排名数据_${new Date().getTime()}.xlsx`);
+    },
     handleWorkOrderClick(row) {
       // 记录来源路由和工单编码
       if (!row.orderCode) return;
@@ -1159,5 +1196,15 @@ export default {
   .ranking-table-card {
     width: 100%;
     height: 100%;
+    box-sizing: border-box;
   }
+
+  /* 排名列表顶部工具栏样式 */
+  .ranking-toolbar {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 20px;
+  }
+
 </style>

+ 49 - 3
ygtx-ui/src/views/index6.vue

@@ -270,8 +270,21 @@
       <!-- 新增的排名列表卡片 -->
         <div style="width: 100%;height: 100%;">
           <el-card class="floating-card ranking-table-card">
+            <div v-if="companyExport" class="ranking-toolbar">
+              <el-input
+                v-model="rankingSearchQuery"
+                placeholder="搜索..."
+                @keyup.enter="handleRankingSearch"
+                style="width: 300px;"
+                prefix-icon="search"
+                clearable
+              />
+              <el-button type="primary" @click="handleExportRank">
+                <i class="fa fa-download" style="margin-right: 8px;"></i>导出
+              </el-button>
+            </div>
             <div class="card-content">
-              <el-table :data="currentRankingData" style="width: 100%;" height="800">
+              <el-table :data="currentRankingData" style="width: 100%;" height="720">
                 <el-table-column prop="rank" label="排名" width="80" align="center"></el-table-column>
                 <el-table-column prop="name" label="名字" width="120" align="center">
                   <template #default="scope">
@@ -312,6 +325,9 @@ export default {
         orderCode: null,
         status: 0
       },
+      companyExport: false,
+      rankingSearchQuery: '',
+      companyRankList: [],
       orderPersonList: [],
       // 添加首页统计数据
       homePageData: {
@@ -366,8 +382,24 @@ export default {
         this.timer = null;
       }
     },
+    handleRankingSearch() {
+      if (this.rankingSearchQuery) {
+        const query = this.rankingSearchQuery.toLowerCase();
+        this.currentRankingData = this.companyRankList.filter(item => 
+          item.name.toLowerCase().includes(query) || item.station.toLowerCase().includes(query)
+        );
+      } else {
+        this.currentRankingData = this.companyRankList;
+      }
+    },
     // 新增的方法:显示排名列表
     showRankingList(type) {
+      if (this.currentRankingType != type && type === 'company') {
+        this.companyExport = true;
+        this.rankingSearchQuery = '';
+      } else {
+        this.companyExport = false;
+      }
       // 如果点击的是同一个排名类型,则隐藏列表卡片
       if (this.currentRankingType === type) {
         this.showRankingTable = false;
@@ -412,7 +444,8 @@ export default {
             finalScore: item.finalScore || 0
           });
         });
-        
+
+        this.companyRankList = rankedData;
         this.currentRankingData = rankedData;
       }
     },
@@ -539,6 +572,10 @@ export default {
     handleExport() {
       this.download("gxt/orderperson/exportOrderScorePerson", this.queryParams, `工分明细列表_${new Date().getTime()}.xlsx`);
     },
+    // 导出公司工分排名数据
+    handleExportRank() {
+      this.download("gxt/repairOrder/exportCompanyRank", this.queryParams, `公司工分排名数据_${new Date().getTime()}.xlsx`);
+    },
     handleWorkOrderClick(row) {
       // 记录来源路由和工单编码
       if (!row.orderCode) return;
@@ -1142,10 +1179,19 @@ export default {
   .top-aligned .data-description {
     align-self: stretch;
   }
-  
+
   /* 新增的排名列表卡片样式 */
   .ranking-table-card {
     width: 100%;
     height: 100%;
+    box-sizing: border-box;
+  }
+
+  /* 排名列表顶部工具栏样式 */
+  .ranking-toolbar {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 20px;
   }
 </style>