Преглед на файлове

提醒区域数量 接口

jz.kai преди 3 години
родител
ревизия
7d7a9dec02
променени са 1 файла, в които са добавени 66 реда и са изтрити 32 реда
  1. 66 32
      web/src/main/java/com/jpsoft/excellent/modules/mobile/IncidentApiController.java

+ 66 - 32
web/src/main/java/com/jpsoft/excellent/modules/mobile/IncidentApiController.java

@@ -2,6 +2,7 @@ package com.jpsoft.excellent.modules.mobile;
 
 import com.github.pagehelper.Page;
 import com.jpsoft.excellent.modules.base.dto.IncidentAttachmentDTO;
+import com.jpsoft.excellent.modules.base.dto.ShowCountDTO;
 import com.jpsoft.excellent.modules.base.entity.*;
 import com.jpsoft.excellent.modules.base.service.*;
 import com.jpsoft.excellent.modules.common.dto.MessageResult;
@@ -54,41 +55,14 @@ public class IncidentApiController {
 
         Map<String,Object> searchParams = new HashMap<>();
         searchParams.put("isFinished", "1");
-        searchParams.put("createBy", subject);
+
+        User user = userService.get(subject);
+        searchParams.put("specialClassId", "%" + user.getSpecialClassId() + "%");
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("batch_","asc"));
         sortList.add(new Sort("serial_no","asc"));
 
-        List<Role> roleList = userRoleService.findRoleByUserId(subject);
-        for(Role role : roleList) {
-            if("8d4dd9ac-dcf4-4178-885c-fd309f4be8f6".equals(role.getId()))
-                searchParams.put("createBy", null);
-        }
-
-        //搜索条件
-//        if (StringUtils.isNotEmpty(batch)) {
-//            searchParams.put("batch","%" + batch + "%");
-//        }
-//        if (StringUtils.isNotEmpty(serialNo)) {
-//            searchParams.put("serialNo","%" + serialNo + "%");
-//        }
-//        if (StringUtils.isNotEmpty(complainant)) {
-//            searchParams.put("complainant","%" + complainant + "%");
-//        }
-//        if (StringUtils.isNotEmpty(complainantPhone)) {
-//            searchParams.put("complainantPhone","%" + complainantPhone + "%");
-//        }
-//        if (StringUtils.isNotEmpty(areaId)) {
-//            searchParams.put("areaId",areaId);
-//        }
-//        if (StringUtils.isNotEmpty(specialClassId)) {
-//            searchParams.put("specialClassId","%"+specialClassId+"%");
-//        }
-//        if (StringUtils.isNotEmpty(isFinished)) {
-//            searchParams.put("isFinished",isFinished);
-//        }
-
         Integer green = 0;
         Integer yellow = 0;
         Integer red = 0;
@@ -227,9 +201,10 @@ public class IncidentApiController {
         int yellow = 0;
         int green = 0;
 
-        User user = userService.get(subject);
         Map<String,Object> searchParams = new HashMap<>();
-        searchParams.put("createBy", subject);
+
+        User user = userService.get(subject);
+        searchParams.put("specialClassId", "%" + user.getSpecialClassId() + "%");
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("batch_","asc"));
@@ -268,4 +243,63 @@ public class IncidentApiController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="提醒区域数量")
+    @RequestMapping(value = "countAreaByWarningLight",method = RequestMethod.POST)
+    public MessageResult<List> countAreaByWarningLight(@RequestAttribute String subject){
+        MessageResult<List> msgResult = new MessageResult<>();
+        List<Map> list = new ArrayList<>();
+        User user = userService.get(subject);
+
+        List<DataDictionary> dataDictionaryList = dataDictionaryService.findByCatalogName("区域");
+        for(DataDictionary dataDictionary : dataDictionaryList) {
+            int red = 0;
+            int yellow = 0;
+            int green = 0;
+
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("areaId", dataDictionary.getValue());
+            searchParams.put("specialClassId", "%" + user.getSpecialClassId() + "%");
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("batch_","asc"));
+            sortList.add(new Sort("serial_no","asc"));
+
+            Page<Incident> page = incidentService.pageSearch(searchParams,1,1000,false,sortList);
+            for(Incident incident : page.getResult()){
+                List<IncidentStep> incidentStepList = incidentStepService.findListByIncidentId(incident.getId());
+                incident.setLastStep(incidentStepList.get(incidentStepList.size()-1));
+
+                //报警灯
+                Date currentTime = new Date();
+                Date warnTime = incident.getLastStep().getWarnDate1();
+                Date allotedTime = incident.getLastStep().getAllotedDate();
+
+                if(incident.getIsFinished() == "0"){
+                    green++;
+                }
+                else {
+                    if (currentTime.before(warnTime)) {
+                        yellow++;
+                    } else if (currentTime.after(allotedTime)) {
+                        red++;
+                    } else {
+                        yellow++;
+                    }
+                }
+            }
+
+            Map<String,Object> map = new HashMap<>();
+            map.put("name",dataDictionary.getName());
+            map.put("red",red);
+            map.put("yellow",yellow);
+            map.put("green",green);
+            list.add(map);
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
+
+        return msgResult;
+    }
 }