浏览代码

前端的行为类型转换

Reiskuchen 5 年之前
父节点
当前提交
2fcc496243

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

@@ -48,16 +48,12 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         resultMap.put("date", todayDate);
         resultMap.put("date", todayDate);
         //时间占比 预先定义好长度为9的数组再向里面添加
         //时间占比 预先定义好长度为9的数组再向里面添加
         Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
         Integer[] timeArray = {0, 0, 0, 0, 0, 0, 0, 0, 0};
-        String[] stringArray = new String[9];
         for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
         for (TimeCalculation timeCalculation : timeCalculationMapper.selectList(new QueryWrapper<TimeCalculation>()
                 .eq("user_id", userId)
                 .eq("user_id", userId)
                 .eq("date", todayDate))) {
                 .eq("date", todayDate))) {
             timeArray[timeCalculation.getActionType()] += timeCalculation.getDuration();
             timeArray[timeCalculation.getActionType()] += timeCalculation.getDuration();
         }
         }
-        for(int i = 0; i <= 9; i++){
-            stringArray[i] = convertSecond(timeArray[i]);
-        }
-        resultMap.put("timeDistribution", stringArray);
+        resultMap.put("timeDistribution", timeArray);
         httpRespMsg.data = resultMap;
         httpRespMsg.data = resultMap;
         return httpRespMsg;
         return httpRespMsg;
     }
     }
@@ -97,17 +93,21 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
                 map.put("phone", userMap.get("phone"));
                 map.put("phone", userMap.get("phone"));
                 //然后根据日期和用户id获取到所有的记录 然后手动累加在一起
                 //然后根据日期和用户id获取到所有的记录 然后手动累加在一起
                 Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
                 Long[] timeArray = {0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L};
+                String[] stringArray = new String[9];
                 for (Map<String, Object> dataMap : timeCalculationMapper
                 for (Map<String, Object> dataMap : timeCalculationMapper
                         .getTodayStatistics((String) userMap.get("id"), date, companyId)) {
                         .getTodayStatistics((String) userMap.get("id"), date, companyId)) {
                     timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
                     timeArray[(int) dataMap.get("type")] += (Long) dataMap.get("duration");
                 }
                 }
-                map.put("statistics", timeArray);
+                for (int i = 0; i < 9; i++) {
+                    stringArray[i] = convertSecond(timeArray[i]);
+                }
+                map.put("statistics", stringArray);
                 //最后是数组的和
                 //最后是数组的和
                 Long sum = 0L;
                 Long sum = 0L;
                 for (Long singleNumber : timeArray) {
                 for (Long singleNumber : timeArray) {
                     sum += singleNumber;
                     sum += singleNumber;
                 }
                 }
-                map.put("sum", sum);
+                map.put("sum", convertSecond(sum));
                 resultList.add(map);
                 resultList.add(map);
             }
             }
             httpRespMsg.data = resultList;
             httpRespMsg.data = resultList;
@@ -176,7 +176,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         time = time % 3600;
         time = time % 3600;
         minute = time / 60;
         minute = time / 60;
         second = minute % 60;
         second = minute % 60;
-        return hour + "时" + minute + "分" + second + "秒";
+        return hour + "时" + minute + "分" + second + "秒";
     }
     }
 
 
     private String convertSecond(Long time) {
     private String convertSecond(Long time) {
@@ -185,6 +185,6 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         time = time % 3600;
         time = time % 3600;
         minute = time / 60;
         minute = time / 60;
         second = minute % 60;
         second = minute % 60;
-        return hour + "时" + minute + "分" + second + "秒";
+        return hour + "时" + minute + "分" + second + "秒";
     }
     }
 }
 }

+ 26 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/desktop/index.vue

@@ -28,7 +28,7 @@
             <!-- pic_type 这里需要一个巨长的三目运算符 -->
             <!-- pic_type 这里需要一个巨长的三目运算符 -->
             <!-- 0-编程,1-查资料,2-看文档,3-做设计,4-美工,5-运营,6-看小说,7-打游戏,8-听音乐 -->
             <!-- 0-编程,1-查资料,2-看文档,3-做设计,4-美工,5-运营,6-看小说,7-打游戏,8-听音乐 -->
             <!-- 现在基本都是null -->
             <!-- 现在基本都是null -->
-            <span>{{item.pic_type == null ? 0 : item.pic_type}}</span>
+            <span>{{converType(item.pic_type == null ? 0 : item.pic_type)}}</span>
             <div class="bottom clearfix">
             <div class="bottom clearfix">
               <el-link>
               <el-link>
                 <i class="fa fa-circle"></i>
                 <i class="fa fa-circle"></i>
@@ -98,6 +98,31 @@ export default {
     },
     },
     jumpTo(id) {
     jumpTo(id) {
       this.$router.push("/desktop/" + id);
       this.$router.push("/desktop/" + id);
+    },
+    //类型枚举转换
+    converType(type) {
+      switch (type) {
+        case 0:
+          return "编程";
+        case 1:
+          return "查资料";
+        case 2:
+          return "看文档";
+        case 3:
+          return "做设计";
+        case 4:
+          return "美工";
+        case 5:
+          return "运营";
+        case 6:
+          return "看小说";
+        case 7:
+          return "打游戏";
+        case 8:
+          return "听音乐";
+        default:
+          return "未知";
+      }
     }
     }
   },
   },
   created() {
   created() {

+ 29 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/desktop/unusual.vue

@@ -15,7 +15,9 @@
     >
     >
       <el-table-column type="index" width="60"></el-table-column>
       <el-table-column type="index" width="60"></el-table-column>
       <el-table-column prop="name" label="姓名" width="140" sortable></el-table-column>
       <el-table-column prop="name" label="姓名" width="140" sortable></el-table-column>
-      <el-table-column prop="type" label="行为"></el-table-column>
+      <el-table-column label="行为">
+        <template slot-scope="scope">{{converType(scope.row.type)}}</template>
+      </el-table-column>
       <el-table-column prop="time" label="时间" width="180" sortable></el-table-column>
       <el-table-column prop="time" label="时间" width="180" sortable></el-table-column>
       <el-table-column prop="date" label="日期" width="180" sortable></el-table-column>
       <el-table-column prop="date" label="日期" width="180" sortable></el-table-column>
     </el-table>
     </el-table>
@@ -87,6 +89,32 @@ export default {
     handleSizeChange(val) {
     handleSizeChange(val) {
       this.size = val;
       this.size = val;
       this.getDevianceList();
       this.getDevianceList();
+    },
+
+    //类型枚举转换
+    converType(type) {
+      switch (type) {
+        case 0:
+          return "编程";
+        case 1:
+          return "查资料";
+        case 2:
+          return "看文档";
+        case 3:
+          return "做设计";
+        case 4:
+          return "美工";
+        case 5:
+          return "运营";
+        case 6:
+          return "看小说";
+        case 7:
+          return "打游戏";
+        case 8:
+          return "听音乐";
+        default:
+          return "未知";
+      }
     }
     }
   },
   },
   created() {
   created() {