|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.algorithm.api.alarm.entity.AlarmLog;
|
|
|
import com.zd.common.core.annotation.DataScope;
|
|
|
+import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.DateUtils;
|
|
|
import com.zd.common.core.utils.SecurityUtils;
|
|
|
import com.zd.laboratory.api.entity.SensorFunctionStatus;
|
|
|
@@ -14,6 +15,7 @@ import com.zd.laboratory.mapper.LabAbnormalMapper;
|
|
|
import com.zd.laboratory.mapper.LabPhotoNoteMapper;
|
|
|
import com.zd.laboratory.mapper.LabRiskPlanAbnormalLogMapper;
|
|
|
import com.zd.laboratory.service.ILabRiskPlanAbnormalLogService;
|
|
|
+import com.zd.model.constant.BaseConstants;
|
|
|
import com.zd.model.domain.per.PerPrefix;
|
|
|
import com.zd.model.entity.SubQueryConfig;
|
|
|
import com.zd.model.enums.HardwareTypeEnum;
|
|
|
@@ -23,6 +25,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.LongAdder;
|
|
|
|
|
|
/**
|
|
|
* 风险异常日志Service业务层处理
|
|
|
@@ -43,6 +46,9 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
|
|
|
@Autowired
|
|
|
public HardwareFunctionStatusConfig hardwareFunctionStatusConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询风险异常日志
|
|
|
*
|
|
|
@@ -271,7 +277,7 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
|
|
|
*/
|
|
|
@Override
|
|
|
@DataScope(deptAlias = "t", userAlias = "t", subAdmin = true)
|
|
|
- public List<SubDiyAppVO> selectLabRiskPlanAppList(LabRiskPlanAbnormalLogVO labRiskPlanAbnormalLogVo) {
|
|
|
+ public Map<String,Object> selectLabRiskPlanAppList(LabRiskPlanAbnormalLogVO labRiskPlanAbnormalLogVo) {
|
|
|
if(labRiskPlanAbnormalLogVo.getCount()==0){
|
|
|
Date d = new Date();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@@ -292,6 +298,8 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
|
|
|
riskPlanMap.add(a.getGroupId(),a);
|
|
|
});
|
|
|
|
|
|
+ Map<String,Object> allMap = new HashMap <>();
|
|
|
+ LongAdder longAdder = new LongAdder();
|
|
|
List<SubDiyAppVO> subSensorList = new ArrayList();
|
|
|
Optional.ofNullable(riskPlanMap).filter(a->a.size()>0).ifPresent(a->{
|
|
|
a.entrySet().forEach(b->{
|
|
|
@@ -324,7 +332,7 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
|
|
|
}
|
|
|
// appVo.setSubDiyVo(Optional.ofNullable(subDiy).filter(p->p.size()>0).orElseGet(Collections::emptyList).get(0));
|
|
|
appVo.setTodayHappenCount(todayHappenCount);
|
|
|
-
|
|
|
+ longAdder.add(todayHappenCount);
|
|
|
//加入实验室信息
|
|
|
if(riskPlanLogList.size()>0){
|
|
|
LabSubject subject = new LabSubject();
|
|
|
@@ -334,12 +342,62 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
|
|
|
appVo.setSubDiyNewVO(subDiyVOList.get(0));
|
|
|
}
|
|
|
}
|
|
|
+ appVo.setSubjectId(subjectId);
|
|
|
subSensorList.add(appVo);
|
|
|
|
|
|
});
|
|
|
}
|
|
|
);
|
|
|
- return subSensorList;
|
|
|
+ //todo 这里尝试组合预案和气瓶预警
|
|
|
+ Collection <String> cllKey = redisService.keys(BaseConstants.BEACON_MATE_NOTICE + "*");
|
|
|
+ for(String key:cllKey){
|
|
|
+ List <Map<String,Object>> beaconNoticeList = redisService.getCacheObject(key);
|
|
|
+ for(Map<String,Object> noticeMap : beaconNoticeList){
|
|
|
+ Boolean flag = Boolean.TRUE;
|
|
|
+ for(SubDiyAppVO subSensor : subSensorList){
|
|
|
+ Long subId = Long.parseLong(noticeMap.get("subId")+"");
|
|
|
+ if(subId.longValue() == subSensor.getSubjectId().longValue()){
|
|
|
+ flag = Boolean.FALSE;
|
|
|
+ subSensor.getSensorSet().add(noticeMap.get("gasName")+"气瓶非法带离!");
|
|
|
+ subSensor.setTodayHappenCount(subSensor.getTodayHappenCount()+1);
|
|
|
+ longAdder.add(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ Set<String> describeSet = new HashSet();
|
|
|
+
|
|
|
+ SubDiyAppVO appVo = new SubDiyAppVO();
|
|
|
+ describeSet.add(noticeMap.get("gasName")+"气瓶非法带离!");
|
|
|
+ Long subjectId = Long.parseLong(noticeMap.get("subId")+"");
|
|
|
+ SubQueryConfig subQueryConfig = new SubQueryConfig();
|
|
|
+ subQueryConfig.setDangerLevel(true);
|
|
|
+ subQueryConfig.setAddr(true);
|
|
|
+ subQueryConfig.setConversionDictSubName(true);
|
|
|
+ List<SubDiyVO> subDiy = subQueryManager.querySubs(subQueryConfig,subjectId);
|
|
|
+
|
|
|
+ appVo.setSensorSet(describeSet);
|
|
|
+ if(subDiy.size()>0){
|
|
|
+ appVo.setSubDiyVo(subDiy.get(0));
|
|
|
+ }
|
|
|
+ appVo.setTodayHappenCount(todayHappenCount+1);
|
|
|
+ longAdder.add(1);
|
|
|
+ //加入实验室信息
|
|
|
+ if(riskPlanLogList.size()>0){
|
|
|
+ LabSubject subject = new LabSubject();
|
|
|
+ subject.setId(subjectId);
|
|
|
+ List<SubDiyVO> subDiyVOList = subQueryManager.querySubs(subject, SubQueryConfig.subQueryConfigList);
|
|
|
+ if(subDiyVOList.size()>0){
|
|
|
+ appVo.setSubDiyNewVO(subDiyVOList.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appVo.setSubjectId(subjectId);
|
|
|
+ subSensorList.add(appVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allMap.put("list",subSensorList);
|
|
|
+ allMap.put("count",longAdder.sum());
|
|
|
+ return allMap;
|
|
|
}
|
|
|
|
|
|
|