From 4ac43fa87c355ff4a001110f5de7fe32acfd5289 Mon Sep 17 00:00:00 2001 From: 李宇 <986321569@qq.com> Date: 星期四, 21 一月 2021 10:16:07 +0800 Subject: [PATCH] 添加处理报警接口 --- src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java | 69 +++++++++++++++++++++++++++++++--- 1 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java index 5c4d719..a2ae000 100644 --- a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java +++ b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java @@ -41,6 +41,8 @@ @Resource private OpeUseFlowService opeUseFlowService; + @Resource + private SysWarningService sysWarningService; @Resource(name = "sysWarehouseDao") SysWarehouseDao sysWarehouseDao; @@ -1030,8 +1032,16 @@ if (containerCode==null||containerCode.isEmpty()) { throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[containerCode]"); } - - return sysUserDao.getUserListByContainerCodeNew(containerCode, startTime, endTime); + List<String> projects = sysLaboratoryContainer.selectProjectsByContainerCode(containerCode); + List<SysUser> userList = null; + if (projects != null) { + userList = new ArrayList<>(); + for (String project : projects) { + List<SysUser> dataList = sysUserDao.getUserListByProject(project, startTime, endTime); + userList.addAll(dataList); + } + } + return userList; } @@ -1261,6 +1271,10 @@ logger.error("The containerCode has not been exists!"); } } + //-1 状态 + if (status.equals(-1)){ + continue; + } opeReagentStatusDao.syncOpeReagentStatus(params); } @@ -1347,7 +1361,7 @@ // 人员违规预警接口 @Override - public void alarmperson(JSONObject jsonObject) throws ApiException, IOException { + public void alarmperson(JSONObject jsonObject) throws Exception { JSONArray dataArr = jsonObject.getJSONArray("data"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -1406,12 +1420,19 @@ Timestamp warnTime; try { Date warningTime = sdf.parse(warningTimeStr); + //不接收时间超过现在的数据 + if (warningTime.after(new Date())) { + throw new Exception("柜子时间发生错误"); + } warnTime = new Timestamp(warningTime.getTime()); sysAlarmPerson.setWarningTime(warnTime); } catch (ParseException e) { throw new ApiException(ApiStatus.PARAM_ERR); - } - // 将人员违规预警记录保存到数据库表 + } catch (Exception e) { + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + // 将人员违规预警记录保存到数据库表 int count = sysAlarmPersonDao.repeatedJudgment(containerCode, warningLevelInt, warnTime); if (count<1){ //获取实验室条码和具体地点 @@ -1429,7 +1450,7 @@ } //给daping系统发送信息 - if(!"".equals(alarmUrl) && ("1".equals(warningId) || "2".equals(warningId)|| "6".equals(warningId)) ) { + if(!"".equals(alarmUrl) && ("1".equals(warningId) || "2".equals(warningId))){ JSONObject json = new JSONObject(); json.put("barCode", location.get("barCode")); json.put("type", alarmType); @@ -1709,4 +1730,40 @@ public JSONObject getUserInfo(JSONObject jsonObject) { return null; } + + // 人员违规预警接口 + @Override + public void delalarmperson(JSONObject jsonObject) throws Exception { + String containerCode = jsonObject.getString("containerCode"); + String warningId = jsonObject.getString("warningId"); + // 货柜条码 containerCode String ○ + // 报警类别 warningId Integer ○ + if (StringUtils.isBlank(containerCode) || StringUtils.isBlank(warningId)) { + throw new ApiException(ApiStatus.PARAM_NO_EXIST); + } + Map<String, String> metaMap = new HashMap<>(); + metaMap.put("groupId", "user_violate_type"); + metaMap.put("metaKey", warningId); + + List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap); + if (baseMetaList == null || baseMetaList.size() != 1) { + throw new ApiException(ApiStatus.PARAM_ERR, ApiStatus.PARAM_ERR.getRetMsg() + "[warningId]"); + } + + SysAlarmPerson sysAlarmPerson = new SysAlarmPerson(); + sysAlarmPerson.setContainerCode(containerCode); + sysAlarmPerson.setWarningId(baseMetaList.get(0).getId()); + + List<SysAlarmPerson> sysAlarmPersonList = sysAlarmPersonDao.selectByCode(containerCode, baseMetaList.get(0).getId()); + // 将人员违规预警记录保存到数据库表 + for (SysAlarmPerson sysAlarm : sysAlarmPersonList) { + if (!"".equals(alarmUrl) && StringUtils.isNotBlank(sysAlarm.getRefId()) && ("1".equals(warningId) || "2".equals(warningId))) { + SysWarning sysWarning = new SysWarning(); + sysWarning.setId(String.valueOf(sysAlarm.getId())); + sysWarning.setStatus(1); + sysWarning.setAlarmId(sysAlarm.getRefId()); + sysWarningService.updateSysWarning(sysWarning); + } + } + } } -- Gitblit v1.9.2