| | |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service("interfaceService") |
| | | public class InterfaceServiceImpl implements InterfaceService { |
| | | |
| | | private static Logger logger = Logger.getLogger(ApiAction.class); |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private OpeUseFlowService opeUseFlowService; |
| | | |
| | | @Resource |
| | | private SysWarningService sysWarningService; |
| | | @Resource(name = "sysWarningDao") |
| | | SysWarningDao sysWarningDao; |
| | | @Resource(name = "sysWarehouseDao") |
| | | SysWarehouseDao sysWarehouseDao; |
| | | |
| | |
| | | }else{ |
| | | sysUser = sysUserDao.getSysUser(userID); |
| | | // 如果是管理员也可以开柜 |
| | | if(sysUser.getSeeFlag() == SeeFlag.MANAGE){ |
| | | if(sysUser.getSeeFlag() == SeeFlag.MANAGE||sysUser.getSeeFlag() == SeeFlag.LEADING){ |
| | | return "1"; |
| | | } else { |
| | | // 不可以打开柜子 |
| | |
| | | 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 && projects.size() > 0){ |
| | | userList = new ArrayList<>(); |
| | | for (String project : projects) { |
| | | List<SysUser> dataList = sysUserDao.getUserListByProject(project, startTime, endTime); |
| | | userList.addAll(dataList); |
| | | } |
| | | } |
| | | return userList; |
| | | } |
| | | |
| | | |
| | |
| | | logger.error("The containerCode has not been exists!"); |
| | | continue; |
| | | } |
| | | } else if (status.equals(2)){ |
| | | } |
| | | else if (status.equals(2)){ |
| | | /*SysWarehouseContainer container = sysWarehouseContainerDao |
| | | .getSysWarehouseContainerByContainerCode(containerCode); |
| | | if (Objects.isNull(container) == false) { |
| | |
| | | logger.error("The containerCode has not been exists!"); |
| | | } |
| | | } |
| | | opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | |
| | | //-1 状态 |
| | | if (status.equals(-1)){ |
| | | continue; |
| | | } |
| | | int i = opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | if (i < 1){ |
| | | opeReagentStatusDao.syncOpeReagentStatus(params); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 人员违规预警接口 |
| | | @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"); |
| | |
| | | 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){ |
| | | //获取实验室条码和具体地点 |
| | |
| | | } |
| | | //给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); |
| | |
| | | logger.info(resData2); |
| | | } |
| | | } |
| | | sysAlarmPersonDao.insertSysAlarmPerson(sysAlarmPerson); |
| | | |
| | | if(enable && "2".equals(warningId) ) { |
| | | List<Map> personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode); |
| | | Map param = new HashMap(); |
| | |
| | | }); |
| | | } |
| | | if (phones.length() >0){ |
| | | phones.deleteCharAt(phones.length() - 1);} |
| | | phones.deleteCharAt(phones.length() - 1); |
| | | |
| | | } |
| | | |
| | | String suffix = String.format("?head=%s&signature=%s&content=%s&telnumber=%s", head, signature, content, phones.toString().replace(" ", "")); |
| | | CloseableHttpClient client = HttpClients.createDefault(); |
| | |
| | | post.setHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | CloseableHttpResponse response = client.execute(post); |
| | | String resData = EntityUtils.toString(response.getEntity(),"UTF-8"); |
| | | client.close(); |
| | | JSONObject res = JSONObject.parseObject(resData); |
| | | if ("200".equals(res.getString("code")) && phones.length() >0){ |
| | | String memo = String.format("短信已发送[%s]", phones); |
| | | sysAlarmPerson.setMemo(memo); |
| | | } |
| | | logger.info(resData); |
| | | |
| | | } |
| | | sysAlarmPersonDao.insertSysAlarmPerson(sysAlarmPerson); |
| | | // 将人员扣分更新到人员表 |
| | | if (warningPoint == null) { |
| | | warningPoint = 0; |
| | | } |
| | | // SysUser user = sysUserDao.getSysUser(userId); |
| | | if (user != null) { |
| | | sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId()); |
| | | } |
| | | } |
| | | // 将人员扣分更新到人员表 |
| | | if (warningPoint == null) { |
| | | warningPoint = 0; |
| | | } |
| | | // SysUser user = sysUserDao.getSysUser(userId); |
| | | if (user != null) { |
| | | sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId()); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | } |
| | | int count = opeUseFlowService.getOpeUseFlow(opeUseFlow); |
| | | if (count < 1) { |
| | | |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | this.opeUseFlowService.insertOpeUseFlow(opeUseFlow); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | public JSONObject getUserInfo(JSONObject jsonObject) { |
| | | return null; |
| | | } |
| | | |
| | | // 人员违规预警接口 |
| | | @Override |
| | | public void delalarmperson(JSONObject jsonObject) throws Exception { |
| | | JSONArray dataArr = jsonObject.getJSONArray("data"); |
| | | Iterator<Object> dataIt = dataArr.iterator(); |
| | | while (dataIt.hasNext()) { |
| | | JSONObject dataJson = JSONObject.parseObject(dataIt.next().toString()); |
| | | // 货柜条码 containerCode String ○ |
| | | // 报警类别 warningId Integer ○ |
| | | if (!dataJson.containsKey("warningId") || !dataJson.containsKey("containerCode")) { |
| | | throw new ApiException(ApiStatus.PARAM_NO_EXIST); |
| | | } |
| | | String containerCode = dataJson.getString("containerCode"); |
| | | String warningId = dataJson.getString("warningId"); |
| | | List<String> warningList = Arrays.asList(warningId.split(",")); |
| | | List<String> warningList1 = new ArrayList<>(Arrays.asList("1","2","3","4","5","6")); |
| | | List<String> delWarnings = warningList1.stream().filter(o->!warningList.contains(o)).collect(Collectors.toList());//新的不在原有里面的 |
| | | |
| | | for (String warning : delWarnings){ |
| | | Map<String, String> metaMap = new HashMap<>(); |
| | | metaMap.put("groupId", "user_violate_type"); |
| | | metaMap.put("metaKey", warning); |
| | | |
| | | 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(warning) || "2".equals(warning))) { |
| | | SysWarning sysWarning = new SysWarning(); |
| | | sysWarning.setId(String.valueOf(sysAlarm.getId())); |
| | | sysWarning.setStatus(1); |
| | | sysWarning.setAlarmId(sysAlarm.getRefId()); |
| | | sysWarningService.updateSysWarning(sysWarning); |
| | | }else { |
| | | Map<String,Object> params = new HashMap<>(); |
| | | params.put("status",1); |
| | | params.put("id", String.valueOf(sysAlarm.getId())); |
| | | sysWarningDao.updateSysWarning(params); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |