dcs 3 months ago
parent
commit
20c9b8aaa3

+ 14 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/OperateFlowDataController.java

@@ -111,6 +111,19 @@ public class OperateFlowDataController {
     @ApiOperation("设备看板-全生命周期")
     @RequestMapping(value = "/count/{deviceId}", method = RequestMethod.GET)
     public Response deviceCount(@PathVariable long deviceId) {
-        return Response.ok(operateFlowDataService.deviceCount(deviceId));
+        Map<Integer, Object> map = new HashMap<>();
+        for (int type = 1; type < 6; type++) {
+            Map<String, Object> countMap = operateFlowDataService.deviceCount(deviceId, type);
+            List<OperateFlowData> list = operateFlowDataService.deviceCountList(deviceId, type);
+            if (list.size() > 0) {
+                for (OperateFlowData of : list) {
+                    setName(of);
+                }
+            }
+            countMap.put("list", list);
+            map.put(type, countMap);
+        }
+        return Response.ok(map);
     }
+
 }

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/dao/OperateFlowDataDao.java

@@ -30,4 +30,6 @@ public interface OperateFlowDataDao {
 
     Map<String, Object> deviceCount(long deviceId, int type);
 
+    List<OperateFlowData> deviceCountList(long deviceId, int type);
+
 }

+ 5 - 7
virgo.api/src/main/java/com/bosshand/virgo/api/operate/service/OperateFlowDataService.java

@@ -8,7 +8,6 @@ import com.bosshand.virgo.core.utils.ContextUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -52,13 +51,12 @@ public class OperateFlowDataService {
         return JSON.toJSONString(operateFlowDataDao.census(projectId, startDate, endDate));
     }
 
-    public Map<Integer, Object> deviceCount(long deviceId) {
-        Map<Integer, Object> map = new HashMap<>();
-        for (int type = 1; type < 6; type++) {
-            map.put(type, operateFlowDataDao.deviceCount(deviceId, type));
-        }
-        return map;
+    public Map<String, Object> deviceCount(long deviceId, int type) {
+        return operateFlowDataDao.deviceCount(deviceId, type);
     }
 
+    public List<OperateFlowData> deviceCountList(long deviceId, int type) {
+        return operateFlowDataDao.deviceCountList(deviceId, type);
+    }
 
 }

+ 5 - 2
virgo.api/src/main/resources/mapper/OperateFlowDataMapper.xml

@@ -178,11 +178,11 @@
         INSERT INTO operate_flow_data(
             projectId, projectItemId,
             projectItemTargetId, projectItemTargetRoomId,
-            deviceLevelId,deviceId, date, projectFlowId, flowUserList, state, flowData, createdByUserId, document, receiver, attachment, flowType, type)
+            deviceLevelId,deviceId, date, projectFlowId, flowUserList, flowData, createdByUserId, document, receiver, attachment, flowType, type)
         VALUES
             (#{projectId}, #{projectItemId},
              #{projectItemTargetId}, #{projectItemTargetRoomId},
-             #{deviceLevelId}, #{deviceId}, now(), #{projectFlowId}, #{flowUserList}, #{state}, #{flowData}, #{createdByUserId}, #{document}, #{receiver}, #{attachment}, #{flowType}, #{type})
+             #{deviceLevelId}, #{deviceId}, now(), #{projectFlowId}, #{flowUserList}, #{flowData}, #{createdByUserId}, #{document}, #{receiver}, #{attachment}, #{flowType}, #{type})
     </insert>
 
     <delete id="delete">
@@ -219,5 +219,8 @@
         FROM  operate_flow_data WHERE deviceId = #{deviceId} and type = #{type}
     </select>
 
+    <select id="deviceCountList" resultMap="operateFlowDataResult">
+        <include refid="query"/>where a.deviceId = #{deviceId} and a.type = #{type}
+    </select>
 
 </mapper>