| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import javax.imageio.IIOImage; |
| | | import javax.imageio.ImageIO; |
| | | import javax.imageio.ImageWriteParam; |
| | | import javax.imageio.ImageWriter; |
| | | import javax.imageio.stream.ImageOutputStream; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | |
| | | @Service |
| | |
| | | try { |
| | | // 获取文件的名称 |
| | | String fileName = "sczf/" + file.getOriginalFilename(); |
| | | byte[] newImg = file.getBytes(); |
| | | String originalFilename = file.getOriginalFilename(); |
| | | String fileType = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | if (".png".equalsIgnoreCase(fileType) || ".jpg".equalsIgnoreCase(fileType) || ".jpeg".equalsIgnoreCase(fileType)) { |
| | | if (file.getSize() > 2097152) { |
| | | newImg = compressUnderSize(file.getBytes(), 2097152); |
| | | } |
| | | } |
| | | ObjectMetadata objectMetadata = new ObjectMetadata(); |
| | | objectMetadata.setContentType(getcontentType(fileName.substring(fileName.lastIndexOf(".")))); |
| | | // 调用oss的方法实现长传 |
| | | // 第一个参数 bucketName |
| | | // 第二个参数 上传到oss的文件路径和文件名称 |
| | | ossClient.putObject(bucketName, fileName, new ByteArrayInputStream(file.getBytes()), objectMetadata); |
| | | ossClient.putObject(bucketName, fileName, new ByteArrayInputStream(newImg), objectMetadata); |
| | | // 关闭OSSClient。 |
| | | ossClient.shutdown(); |
| | | // 把上传的文件路径返回 (手动拼接) |
| | |
| | | // e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 按照 宽高 比例压缩 |
| | | * |
| | | * @param imgIs 待压缩图片输入流 |
| | | * @param scale 压缩刻度 |
| | | * @param out 输出 |
| | | * @return 压缩后图片数据 |
| | | * @throws IOException 压缩图片过程中出错 |
| | | */ |
| | | public byte[] compress(byte[] srcImgData, double scale) throws IOException { |
| | | BufferedImage bi = ImageIO.read(new ByteArrayInputStream(srcImgData)); |
| | | int width = (int) (bi.getWidth() * scale); // 源图宽度 |
| | | int height = (int) (bi.getHeight() * scale); // 源图高度 |
| | | |
| | | Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH); |
| | | BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
| | | |
| | | Graphics g = tag.getGraphics(); |
| | | g.setColor(Color.RED); |
| | | g.drawImage(image, 0, 0, null); // 绘制处理后的图 |
| | | g.dispose(); |
| | | |
| | | ByteArrayOutputStream bOut = new ByteArrayOutputStream(); |
| | | ImageIO.write(tag, "JPEG", bOut); |
| | | |
| | | return bOut.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 将图片压缩到指定大小以内 |
| | | * |
| | | * @param srcImgData 源图片数据 |
| | | * @param maxSize 目的图片大小 |
| | | * @return 压缩后的图片数据 |
| | | */ |
| | | public byte[] compressUnderSize(byte[] srcImgData, long maxSize) { |
| | | double scale = 0.9; |
| | | byte[] imgData = Arrays.copyOf(srcImgData, srcImgData.length); |
| | | |
| | | if (imgData.length > maxSize) { |
| | | do { |
| | | try { |
| | | imgData = compress(imgData, scale); |
| | | |
| | | } catch (IOException e) { |
| | | throw new IllegalStateException("压缩图片过程中出错,请及时联系管理员!", e); |
| | | } |
| | | |
| | | } while (imgData.length > maxSize); |
| | | } |
| | | |
| | | return imgData; |
| | | } |
| | | |
| | | private byte[] readInputStream(InputStream inStream) throws Exception { |
| | |
| | | |
| | | |
| | | public static String getcontentType(String FilenameExtension) { |
| | | if (FilenameExtension.equalsIgnoreCase(".mp4")||FilenameExtension.equalsIgnoreCase(".mov")) { |
| | | if (FilenameExtension.equalsIgnoreCase(".mp4") || FilenameExtension.equalsIgnoreCase(".mov")) { |
| | | return "video/mp4"; |
| | | } |
| | | if (FilenameExtension.equalsIgnoreCase(".bmp")) { |
| | |
| | | @RequestParam(required = false) Short source, |
| | | @RequestParam(required = false) Short type, |
| | | @RequestParam(required = false) Short time |
| | | ) { |
| | | ) { |
| | | AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | return CommonResult.success(iDisposeRecordService.listMyTask(num, user.getUserId(),type,source,time,current,pageSize)); |
| | | return CommonResult.success(iDisposeRecordService.listMyTask(num, user.getUserId(), type, source, time, current, pageSize)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询", response = MyBacklogVO.class) |
| | | @GetMapping("/query/count") |
| | | @LogSave(operationType = "我的待办-总数", contain = "查询总数") |
| | | public CommonResult searchMyTaskCount(@RequestParam(required = false) String num, |
| | | @RequestParam(required = false) Short source, |
| | | @RequestParam(required = false) Short type, |
| | | @RequestParam(required = false) Short time |
| | | ) { |
| | | AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | return CommonResult.success(iDisposeRecordService.listMyTaskCount(num, user.getUserId(), type, source, time)); |
| | | } |
| | | } |
| | |
| | | private CommonResult<List<DataDictionary>> listAll() { |
| | | try { |
| | | PageResult<Camera> pageResult = videoUtil.callPostCameras(1, 20, "0"); |
| | | System.out.println("海康视频成功:" + pageResult.getTotal()); |
| | | // System.out.println("海康视频成功:" + pageResult.getTotal()); |
| | | } catch (Exception ex) { |
| | | System.out.println("海康视频:" + ex.getMessage()); |
| | | } |
| | |
| | | @PostMapping("/HK/alarmReport") |
| | | @LogSave(operationType = "报警管理", contain = "海康视频报警推送") |
| | | public CommonResult hkAlarmReport(@RequestBody @Validated HKAlarmParam alarmParam) { |
| | | System.out.println("海康视频报警推送API:" + JSONObject.toJSONString(alarmParam)); |
| | | // System.out.println("海康视频报警推送API:" + JSONObject.toJSONString(alarmParam)); |
| | | videoAlarmReportService.saveFromHK(alarmParam); |
| | | return new CommonResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage()); |
| | | } |
| | |
| | | if (sessionDic.get(sessionId) < 10) { |
| | | sessionDic.remove(sessionId); |
| | | fileUrl = fileUrl.replace("Expires", "v"); |
| | | System.out.println("getImages获取图片地址:" + fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId + "&Signature=" + Signature); |
| | | // System.out.println("getImages获取图片地址:" + fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId + "&Signature=" + Signature); |
| | | URL url = null; |
| | | if (StringUtils.isNotBlank(OSSAccessKeyId) && StringUtils.isNotBlank(Signature)) { |
| | | url = new URL(fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId + "&Signature=" + Signature); |
| | |
| | | InputStream inputStream = conn.getInputStream();// 通过输入流获取图片数据 |
| | | |
| | | byte[] data = readInputStream(inputStream); |
| | | System.out.println("getImages获取图片成功"); |
| | | // System.out.println("getImages获取图片成功"); |
| | | |
| | | return data; |
| | | } |
| | |
| | | private CommonResult<?> getResult(String reqUrl, String param) { |
| | | try { |
| | | String token = getToken(); |
| | | System.out.println("定位接口url:" + url + reqUrl + param); |
| | | // System.out.println("定位接口url:" + url + reqUrl + param); |
| | | HttpHeaders deviceHeaders = new HttpHeaders(); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | deviceHeaders.add("X-Subject-Token", token); |
| | |
| | | private void postResult(String reqUrl, GpsSubscribe subscribe) { |
| | | try { |
| | | String token = getToken(); |
| | | System.out.println("定位接口url:" + url + reqUrl + subscribe.toString()); |
| | | // System.out.println("定位接口url:" + url + reqUrl + subscribe.toString()); |
| | | HttpHeaders deviceHeaders = new HttpHeaders(); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | deviceHeaders.add("X-Subject-Token", token); |
| | |
| | | |
| | | Page<MyBacklogVO> listMyTask(String num, Long userId, Short type, Short source, Short time, Integer current, Integer pageSize); |
| | | |
| | | Long listMyTaskCount(String num, Long userId, Short type, Short source, Short time); |
| | | |
| | | CommonResult saveOrUpdateUpload(UploadDisposingResultParam uploadDisposingResultParam); |
| | | } |
| | |
| | | registerState.add(BaseCaseStatus.REPORT); |
| | | Long registerLastMonthCount = baseCaseMapper.selectLastMonthCount(registerState); |
| | | Long registerRecentlyMonthCount = baseCaseMapper.selectRecentlyMonthCount(registerState); |
| | | System.out.println(disposeRecentlyMonthCount); |
| | | // System.out.println(disposeRecentlyMonthCount); |
| | | Double v3 = (registerRecentlyMonthCount - registerLastMonthCount) * 1.0 / registerLastMonthCount; |
| | | if (disposeLastMonthCount == 0) { |
| | | register.setRatio(null); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Long listMyTaskCount(String num, Long userId, Short type, Short source, Short time) { |
| | | LocalDateTime alarmTimeStart = null; |
| | | LocalDateTime alarmTimeEnd = null; |
| | | if (Objects.equals(time, LAST_WEEK)) { |
| | | alarmTimeStart = LocalDateTime.now().minusDays(7); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_MONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(1); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_THREEMONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(3); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } |
| | | return disposeRecordMapper.selectMyBackListTotal(userId, num, alarmTimeStart, alarmTimeEnd, source, type); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult saveOrUpdateUpload(UploadDisposingResultParam uploadDisposingResultParam) { |
| | | log.info("参数------------------>{}",uploadDisposingResultParam); |
| | | log.info("参数------------------>{}", uploadDisposingResultParam); |
| | | if (uploadDisposingResultParam.getArrivalTime() != null) { |
| | | uploadDisposingResultParam.setArrivalTime(uploadDisposingResultParam.getArrivalTime().replace("/", "-")); |
| | | } |
| | |
| | | disposeRecord.setWorkflowConfigStepId(workflowConfigStep.getId()); |
| | | disposeRecord.setHandlerRoleId(workflowConfigStep.getRoleId()); |
| | | boolean result = baseMapper.insert(disposeRecord) == 1 ? true : false; |
| | | if(!result){ |
| | | if (!result) { |
| | | CommonResult.failed("已提交,请勿重复提交"); |
| | | } |
| | | return CommonResult.success("add success"); |
| | |
| | | QueryWrapper<Message> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Message::getIsScan, 0).le(Message::getSendTime,new Date()); |
| | | //List<Message> messages = messageMapper.selectList(wrapper); |
| | | System.out.println("--------------------开始扫描短信信息-------------------大小为"); |
| | | // System.out.println("--------------------开始扫描短信信息-------------------大小为"); |
| | | List<Long> ids = new ArrayList<>(); |
| | | ids.add(3L); |
| | | ids.add(4L); |
| | |
| | | @Scheduled(cron = "0 0 1 * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void scheduledTask() { |
| | | System.out.println("海康:开始执行"); |
| | | // System.out.println("海康:开始执行"); |
| | | |
| | | findVideoList(1, 5); |
| | | |
| | |
| | | jsonBody.put("pageSize", pageSize); |
| | | jsonBody.put("treeCode", treeCode); |
| | | String body = jsonBody.toString(); |
| | | System.out.println("海康视频开始请求:"); |
| | | // System.out.println("海康视频开始请求:"); |
| | | //参数根据接口实际情况设置 |
| | | HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, null, null, "application/json", head); |
| | | try { |
| | | String strResult = EntityUtils.toString(result.getEntity()); |
| | | HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class); |
| | | System.out.println("海康视频结果:" + responseResult.toString()); |
| | | // System.out.println("海康视频结果:" + responseResult.toString()); |
| | | if ("0".equals(responseResult.getCode())) { |
| | | com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData(); |
| | | String strList = jsonObject.getString("list"); |
| | |
| | | String body = jsonBody.toString(); |
| | | //参数根据接口实际情况设置 |
| | | HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, null, null, "application/json", null); |
| | | System.out.println("海康完成请求"); |
| | | // System.out.println("海康完成请求"); |
| | | try { |
| | | String strResult = EntityUtils.toString(result.getEntity()); |
| | | System.out.println("海康返回结果:" + strResult); |
| | | // System.out.println("海康返回结果:" + strResult); |
| | | HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class); |
| | | if ("0".equals(responseResult.getCode())) { |
| | | com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData(); |
| | |
| | | String body = jsonBody.toString(); |
| | | //参数根据接口实际情况设置 |
| | | HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null, "application/json", head); |
| | | System.out.println("海康完成请求-getKHPresets"); |
| | | // System.out.println("海康完成请求-getKHPresets"); |
| | | try { |
| | | String strResult = EntityUtils.toString(result.getEntity()); |
| | | System.out.println("海康返回结果-getKHPresets:" + strResult); |
| | | // System.out.println("海康返回结果-getKHPresets:" + strResult); |
| | | HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class); |
| | | if ("0".equals(responseResult.getCode())) { |
| | | com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData(); |
| | |
| | | ums_admin_role_relation t1 |
| | | left JOIN ums_dispose_record t2 ON t1.role_id = t2.handler_role_id |
| | | left JOIN ums_base_case t3 ON t2.base_case_id=t3.id |
| | | inner join ums_sccg_region t5 on t5.id = t3.community_id |
| | | left join ums_sccg_region t5 on t5.id = t3.community_id |
| | | <where> |
| | | t1.admin_id = #{id} and t3.`code` is not null |
| | | AND t2.state = 0 |
| | |
| | | order by create_time desc |
| | | LIMIT #{pageIndex},#{pageSize}) nt |
| | | left JOIN ums_image_resources t4 ON nt.caseId=t4.belong_to_id |
| | | order by create_time desc |
| | | </select> |
| | | <select id="selectMyBackListTotal" resultType="java.lang.Long"> |
| | | select count( distinct id) from ( |
| | |
| | | ums_admin_role_relation t1 |
| | | left JOIN ums_dispose_record t2 ON t1.role_id = t2.handler_role_id |
| | | left JOIN ums_base_case t3 ON t2.base_case_id=t3.id |
| | | inner join ums_sccg_region t5 on t5.id = t3.community_id |
| | | left join ums_sccg_region t5 on t5.id = t3.community_id |
| | | <where> |
| | | t1.admin_id = #{id} and t3.`code` is not null |
| | | AND t2.state = 0 |
| | |
| | | FROM |
| | | ums_dispose_record t2 |
| | | LEFT JOIN ums_base_case t3 ON t2.base_case_id = t3.id |
| | | inner join ums_sccg_region t5 on t5.id = t3.community_id |
| | | left join ums_sccg_region t5 on t5.id = t3.community_id |
| | | <where> |
| | | t2.handler_id = #{id} |
| | | AND t2.state = 0 |
| | |
| | | signature = MD5Util.md5Encrypt(signature); |
| | | signature = MD5Util.md5Encrypt(userName + ":" + realm + ":" + signature); |
| | | signature = MD5Util.md5Encrypt(signature + ":" + randomKey); |
| | | System.out.println(signature); |
| | | // System.out.println(signature); |
| | | } |
| | | |
| | | @Test |
| | |
| | | LoginParamDto loginParamDto = LoginParamDto.builder().username("connect_test2").password("test@234").noCode(true).build(); |
| | | SmokeResultResponseDto<LoginResponseDto> responseDto = smokeDetectionService.loginAction(loginParamDto); |
| | | if (responseDto.getStatus() == 200) { |
| | | System.out.println(responseDto.getData().getToken()); |
| | | // System.out.println(responseDto.getData().getToken()); |
| | | redisService.set(RedisKey.SMOKE_TOKEN, responseDto.getData().getToken()); |
| | | } |
| | | } |
| | |
| | | if (responseDto.getStatus() == 200) { |
| | | AlarmMsgResponseDto dto = responseDto.getData(); |
| | | List<AlarmMsgDataVo> list = dto.getContent(); |
| | | System.out.println(list.size()); |
| | | // System.out.println(list.size()); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | smokeAlarmMsgTest(); |
| | |
| | | o.setTaskCode(result.getResult()); |
| | | o.setState(2); |
| | | baseCaseMapper.updateById(o); |
| | | System.out.println("--更新成功"); |
| | | // System.out.println("--更新成功"); |
| | | |
| | | } catch (Exception ex) { |
| | | |