Reiskuchen 5 lat temu
rodzic
commit
94606dc49e

+ 17 - 15
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java

@@ -45,13 +45,13 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         //日期
         LocalDate todayDate = LocalDate.now(ZoneOffset.of("+8"));
         resultMap.put("date", todayDate);
-        //时间占比 预先定义好长度为9的数组再向里面添加
-        Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+        //时间占比 预先定义好长度为10的数组再向里面添加
+        Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
         //把当天所有行为分别加在一起装进数组
         for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
                 .eq("user_id", userId)
                 .eq("date", todayDate))) {
-            timeArray[timeCalculation.getActionType()] += timeCalculation.getDuration();
+            timeArray[timeCalculation.getActionType() + 1] += timeCalculation.getDuration();
         }
         resultMap.put("timeDistribution", timeArray);
         httpRespMsg.data = resultMap;
@@ -93,22 +93,24 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
                 map.put("name", userMap.get("name"));
                 map.put("phone", userMap.get("phone"));
                 //然后根据日期和用户id获取到所有的记录 然后手动累加在一起
-                Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
-                //编程 资料 文档 设计 美工 运营 小说 游戏 音乐
+                Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
+                //其他 编程 上网 文档 设计 美工 运营 看小说 影视娱乐 听音乐
                 for (Map<String, Object> dataMap : timeCalculationMapper
                         .getTodayStatistics((String) userMap.get("id"), date, companyId)) {
-                    timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
+                    timeArray[(int) dataMap.get("type") + 1] += (Long) dataMap.get("duration");
                 }
-                Long[] resultArray = new Long[5];
-                //编程 浏览 设计 办公 娱乐
-                resultArray[0] = timeArray[0];
-                resultArray[1] = timeArray[1] + timeArray[2];
-                resultArray[2] = timeArray[3] + timeArray[4];
-                resultArray[3] = timeArray[5];
-                resultArray[4] = timeArray[6] + timeArray[7] + timeArray[8];
+                Long[] resultArray = new Long[7];
+                //编程 上网 文档 设计 运营 娱乐 其他
+                resultArray[0] = timeArray[1];
+                resultArray[1] = timeArray[2];
+                resultArray[2] = timeArray[3];
+                resultArray[3] = timeArray[4] + timeArray[5];
+                resultArray[4] = timeArray[6];
+                resultArray[5] = timeArray[7] + timeArray[8] + timeArray[9];
+                resultArray[6] = timeArray[0];
                 //将后端的9中行为类型分门别类转换为前端的5种并转换为字符串格式
-                String[] stringArray = new String[5];
-                for (int i = 0; i < 5; i++) {
+                String[] stringArray = new String[7];
+                for (int i = 0; i < 7; i++) {
                     stringArray[i] = convertSecond(resultArray[i]);
                 }
                 map.put("statistics", stringArray);

+ 6 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/statistics.vue

@@ -33,10 +33,12 @@
       <el-table-column prop="name" label="姓名" width="140" sortable></el-table-column>
       <el-table-column prop="phone" label="手机" width="180"></el-table-column>
       <el-table-column prop="statistics[0]" label="编程" sortable></el-table-column>
-      <el-table-column prop="statistics[1]" label="浏览" sortable></el-table-column>
-      <el-table-column prop="statistics[2]" label="设计" sortable></el-table-column>
-      <el-table-column prop="statistics[3]" label="办公" sortable></el-table-column>
-      <el-table-column prop="statistics[4]" label="娱乐" sortable></el-table-column>
+      <el-table-column prop="statistics[1]" label="上网" sortable></el-table-column>
+      <el-table-column prop="statistics[5]" label="文档" sortable></el-table-column>
+      <el-table-column prop="statistics[3]" label="设计" sortable></el-table-column>
+      <el-table-column prop="statistics[4]" label="运营" sortable></el-table-column>
+      <el-table-column prop="statistics[5]" label="娱乐" sortable></el-table-column>
+      <el-table-column prop="statistics[6]" label="其他" sortable></el-table-column>
       <el-table-column prop="sum" label="总时长" width="180" sortable></el-table-column>
     </el-table>