diff --git a/src/main/java/com/zhgd/xmgl/async/AsyncAiAnalyse.java b/src/main/java/com/zhgd/xmgl/async/AsyncAiAnalyse.java index 0bfaefc04..035859eef 100644 --- a/src/main/java/com/zhgd/xmgl/async/AsyncAiAnalyse.java +++ b/src/main/java/com/zhgd/xmgl/async/AsyncAiAnalyse.java @@ -150,6 +150,7 @@ public class AsyncAiAnalyse { enableMessageDevRuleService.sendSms(messageDevRule, templateParams, text, null); } enableMessageDevRuleService.sendSystemMessage(messageDevRule, "8"); + enableMessageDevRuleService.sendBroadcast(messageDevRule); }, threadPoolTaskExecutor); } diff --git a/src/main/java/com/zhgd/xmgl/call/ShiZiWangBroadcastCall.java b/src/main/java/com/zhgd/xmgl/call/ShiZiWangBroadcastCall.java new file mode 100644 index 000000000..7bbb387b8 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/call/ShiZiWangBroadcastCall.java @@ -0,0 +1,47 @@ +package com.zhgd.xmgl.call; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.io.FileUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSONObject; +import com.zhgd.xmgl.call.api.BroadcastManufacturer; +import com.zhgd.xmgl.modules.broadcast.entity.SmartBroadcastConfig; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Slf4j +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class ShiZiWangBroadcastCall implements BroadcastManufacturer { + private SmartBroadcastConfig config; + + @Override + public SmartBroadcastConfig getConfig() { + return config; + } + + @Override + public void setConfig(SmartBroadcastConfig config) { + this.config = config; + } + + @Override + public void playVoiceFile(List devSns, String fileName, String filePath) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("SerialNums", devSns); + jsonObject.put("PlayText", fileName); + jsonObject.put("PlayFileContent", Base64.encode(FileUtil.readBytes(filePath))); + String body = jsonObject.toJSONString(); + String url = "https://norsos.lionking110.com/sos/v1/mntn/adap/business/external/group/play"; + log.info("狮子王播放语音文件url:{},body:{}", url, body); + String result = HttpRequest.post(url) + .body(body) + .timeout(20000) + .execute().body(); + log.info("狮子王播放语音文件结果:{}", result); + } +} diff --git a/src/main/java/com/zhgd/xmgl/call/api/BroadcastManufacturer.java b/src/main/java/com/zhgd/xmgl/call/api/BroadcastManufacturer.java new file mode 100644 index 000000000..74d0ecf12 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/call/api/BroadcastManufacturer.java @@ -0,0 +1,22 @@ +package com.zhgd.xmgl.call.api; + +import com.zhgd.xmgl.modules.broadcast.entity.SmartBroadcastConfig; + +import java.util.List; + +public interface BroadcastManufacturer { + + SmartBroadcastConfig getConfig(); + + void setConfig(SmartBroadcastConfig config); + + /** + * 播放语音文件 + * + * @param devSns 设备snList + * @param fileName 文件名称 + * @param filePath 文件路径 + * @return + */ + void playVoiceFile(List devSns, String fileName, String filePath); +} diff --git a/src/main/java/com/zhgd/xmgl/call/factory/BroadcastManufacturerFactory.java b/src/main/java/com/zhgd/xmgl/call/factory/BroadcastManufacturerFactory.java new file mode 100644 index 000000000..f670a7b73 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/call/factory/BroadcastManufacturerFactory.java @@ -0,0 +1,33 @@ +package com.zhgd.xmgl.call.factory; + +import com.zhgd.jeecg.common.util.SpringContextUtils; +import com.zhgd.xmgl.call.ShiZiWangBroadcastCall; +import com.zhgd.xmgl.call.api.BroadcastManufacturer; +import com.zhgd.xmgl.modules.broadcast.entity.SmartBroadcastConfig; +import com.zhgd.xmgl.modules.broadcast.service.ISmartBroadcastConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Objects; + +@Component +public class BroadcastManufacturerFactory { + @Lazy + @Autowired + private ISmartBroadcastConfigService smartBroadcastConfigService; + + public BroadcastManufacturer getManufacturer(HashMap param) { + SmartBroadcastConfig config = smartBroadcastConfigService.getUseConfig(param); + if (config == null) { + return null; + } + BroadcastManufacturer manufacturer = null; + if (Objects.equals(config.getManufacturerType(), 1)) { + manufacturer = SpringContextUtils.getBean(ShiZiWangBroadcastCall.class); + manufacturer.setConfig(config); + } + return manufacturer; + } +} diff --git a/src/main/java/com/zhgd/xmgl/modules/environment/service/impl/EnvironmentAlarmServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/environment/service/impl/EnvironmentAlarmServiceImpl.java index 48f5584d4..98134c228 100644 --- a/src/main/java/com/zhgd/xmgl/modules/environment/service/impl/EnvironmentAlarmServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/environment/service/impl/EnvironmentAlarmServiceImpl.java @@ -842,6 +842,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl() + .put("projectSn", rule.getProjectSn()) + .build()); + manufacturer.playVoiceFile(StrUtil.split(rule.getBroadcastDevices(), ","), FileUtils.urlToFileName(rule.getVoiceFileConfiguration()), FileUtils.urlToFilePath(rule.getVoiceFileConfiguration())); + } + } + } diff --git a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java index cd46731fd..19f389e58 100644 --- a/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java +++ b/src/main/java/com/zhgd/xmgl/modules/risk/controller/RiskListSourceDataCenterController.java @@ -336,35 +336,6 @@ public class RiskListSourceDataCenterController { && DateUtil.compare(bo.getDate(), time) >= 0; } - /** - * 获取已排查的数量List - * - * @param sourceVos - * @return - */ - private List getSourceCheckNumBo(List sourceVos) { - List sourceIds = sourceVos.stream().map(RiskListSourceVo::getId).collect(Collectors.toList()); - List securityList = xzSecurityQualityInspectionRecordService.list(new LambdaQueryWrapper() - .eq(XzSecurityQualityInspectionRecord::getType, 10) - .in(XzSecurityQualityInspectionRecord::getEngineeringId, sourceIds) - ); - List unbuilts = riskListSourceUnbuiltService.list(new LambdaQueryWrapper() - .in(RiskListSourceUnbuilt::getSourceId, sourceIds)); - List collect = securityList.stream().map(o -> { - SourceCheckNumBo bo = new SourceCheckNumBo(); - bo.setSourceId(o.getEngineeringId()); - bo.setDate(DateUtil.parseDate(o.getInspectTime())); - return bo; - }).collect(Collectors.toList()); - collect.addAll(unbuilts.stream().map(o -> { - SourceCheckNumBo bo = new SourceCheckNumBo(); - bo.setSourceId(o.getSourceId()); - bo.setDate(o.getInspectionTime()); - return bo; - }).collect(Collectors.toList())); - return collect; - } - @ApiOperation(value = "风险类别占比图", notes = "风险类别占比图", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "Integer"), diff --git a/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoItemController.java b/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoItemController.java index fb862af99..5ccdc51cc 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoItemController.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/controller/VideoItemController.java @@ -1,16 +1,28 @@ package com.zhgd.xmgl.modules.video.controller; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.zhgd.annotation.OperLog; import com.zhgd.jeecg.common.api.vo.Result; +import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.xmgl.async.AsyncProject; +import com.zhgd.xmgl.modules.project.entity.ProjectVideoConfig; +import com.zhgd.xmgl.modules.project.service.IProjectVideoConfigService; +import com.zhgd.xmgl.modules.video.entity.VideoGroup; import com.zhgd.xmgl.modules.video.entity.VideoItem; +import com.zhgd.xmgl.modules.video.entity.dto.MoveGroupVideoItemDto; import com.zhgd.xmgl.modules.video.entity.vo.CaptureVo; import com.zhgd.xmgl.modules.video.entity.vo.HistoryCaptureVo; import com.zhgd.xmgl.modules.video.entity.vo.TalkURLsV2Vo; +import com.zhgd.xmgl.modules.video.service.IVideoGroupService; import com.zhgd.xmgl.modules.video.service.IVideoItemService; import com.zhgd.xmgl.modules.xz.entity.vo.CountStatusVo; +import com.zhgd.xmgl.util.ExcelUtils; +import com.zhgd.xmgl.util.MessageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -19,12 +31,16 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; -import java.util.List; -import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import java.util.*; import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Collectors; /** @@ -44,6 +60,12 @@ public class VideoItemController { private IVideoItemService videoItemService; @Autowired private AsyncProject asyncProject; + @Lazy + @Autowired + private IVideoGroupService videoGroupService; + @Lazy + @Autowired + private IProjectVideoConfigService projectVideoConfigService; /** * 添加 @@ -99,7 +121,6 @@ public class VideoItemController { return Result.ok(); } - @OperLog(operModul = "视频管理", operType = "修改视频设备地图坐标", operDesc = "修改视频设备地图坐标") @ApiOperation(value = "修改视频设备地图坐标", notes = "修改视频设备地图坐标", httpMethod = "POST") @PostMapping(value = "/updateVideoItemCoordinate") @@ -288,7 +309,6 @@ public class VideoItemController { return Result.success(videoItemService.selectUserVideoList(map)); } - @ApiOperation(value = "按照摄像头类型查询具有AI功能的摄像头数量", notes = "按照摄像头类型查询具有AI功能的摄像头数量") @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = true, dataType = "String"), @@ -367,7 +387,6 @@ public class VideoItemController { return Result.success(videoItemService.callPostPlaybackUrlsV2(map)); } - @ApiOperation(value = "统计监控点在线率", notes = "统计监控点在线率", httpMethod = "POST") @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), @@ -402,7 +421,6 @@ public class VideoItemController { return Result.success(videoItemService.searchCameraFromHk(param)); } - @ApiOperation(value = "根据视频设备监控点编号抓拍图片", notes = "根据视频设备监控点编号抓拍图片", httpMethod = "POST") @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = false, dataType = "String"), @@ -484,6 +502,128 @@ public class VideoItemController { return Result.ok(); } + @OperLog(operModul = "视频管理", operType = "批量删除", operDesc = "批量删除视频设备") + @ApiOperation(value = "批量删除视频设备", notes = "批量删除视频设备", httpMethod = "POST") + @ApiImplicitParam(name = "itemIds", value = "视频设备itemIds(多个,分隔)", paramType = "body", required = true, dataType = "String") + @PostMapping(value = "/deleteBatch") + public Result deleteBatch(@ApiIgnore @RequestBody Map map) { + Result result = new Result<>(); + String ids = MapUtils.getString(map, "itemIds"); + if (ids == null || "".equals(ids.trim())) { + result.error500("参数不识别!"); + } else { + videoItemService.removeByIds(Arrays.asList(ids.split(","))); + Result.success("删除成功!"); + } + return result; + } + @OperLog(operModul = "视频管理", operType = "移动视频设备", operDesc = "移动视频设备") + @ApiOperation(value = "移动视频设备", notes = "移动视频设备", httpMethod = "POST") + @PostMapping(value = "/moveGroup") + @Transactional(rollbackFor = Exception.class) + public Result moveGroup(@RequestBody MoveGroupVideoItemDto dto) { + List itemIds = dto.getItemIds(); + VideoGroup videoGroup = videoGroupService.getById(dto.getVideoGroupId()); + if (videoGroup == null) { + throw new OpenAlertException("视频分组不存在"); + } + videoItemService.update(null, new LambdaUpdateWrapper() + .set(VideoItem::getGroupId, dto.getVideoGroupId()) + .set(VideoItem::getParentObj, JSON.toJSONString(videoGroup)) + .in(VideoItem::getItemId, itemIds) + ); + return Result.ok(); + } + @ApiOperation(value = "导入模板下载", notes = "导入模板下载") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "String"), + @ApiImplicitParam(name = "videoType", value = "视频类型,1:萤石云,3:ISC,4:ICC", paramType = "body", required = true, dataType = "String"), + }) + @GetMapping("/downloadExcelTemplate") + public void downloadExcelTemplate(HttpServletResponse response, @RequestParam HashMap param) { + String projectSn = MapUtils.getString(param, "projectSn"); + Integer videoType = MapUtils.getInteger(param, "videoType"); + List groupNames = videoGroupService.list(new LambdaQueryWrapper() + .eq(VideoGroup::getProjectSn, projectSn)).stream().map(VideoGroup::getGroupName).collect(Collectors.toList()); + List pullDowns = Arrays.asList(new ExcelUtils.ExportExcelTemplatePullDown("视频分组", 0, groupNames)); + String downLoadFileName = null; + if (Objects.equals(videoType, 1)) { + downLoadFileName = "监控点导入模版(萤石云).xlsx"; + } else if (Objects.equals(videoType, 3)) { + downLoadFileName = "监控点导入模版(isc).xlsx"; + } else if (Objects.equals(videoType, 4)) { + downLoadFileName = "监控点导入模版(大华).xlsx"; + } + ExcelUtils.exportExcelTemplate("excel/videoitem/" + downLoadFileName, downLoadFileName, pullDowns, response); + } + + @ApiOperation(value = "导入excel", notes = "导入excel") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), + @ApiImplicitParam(name = "excelFile", value = "导入文件", paramType = "body", required = true, dataType = "String"), + @ApiImplicitParam(name = "videoType", value = "视频类型,1:萤石云,3:ISC,4:ICC", paramType = "body", required = true, dataType = "String"), + }) + @PostMapping(value = "/importExcel") + @Transactional(rollbackFor = Exception.class) + public Result importExcel(MultipartFile excelFile, @RequestBody HashMap param) { + try { + String projectSn = MapUtils.getString(param, "projectSn"); + Integer videoType = MapUtils.getInteger(param, "videoType"); + List> list = ExcelUtils.jxlExlToList(excelFile.getInputStream(), 0); + if (list == null || list.size() == 0) { + throw new OpenAlertException(MessageUtil.get("excelNotDataErr")); + } + Map groupMap = videoGroupService.list(new LambdaQueryWrapper() + .eq(VideoGroup::getProjectSn, projectSn)).stream().collect(Collectors.toMap(VideoGroup::getGroupName, Function.identity(), (o1, o2) -> o1)); + ProjectVideoConfig videoConfig = projectVideoConfigService.getOne(new LambdaQueryWrapper() + .eq(ProjectVideoConfig::getProjectSn, projectSn) + .eq(ProjectVideoConfig::getVideoType, videoType) + ); + if (videoConfig == null) { + throw new OpenAlertException("请先启用该视频类型"); + } + List videoItems = new ArrayList<>(); + List sucList = new ArrayList<>(); + List failVideoList = new ArrayList<>(); + List failGroupList = new ArrayList<>(); + for (Map importInfo : list) { + VideoGroup group = groupMap.get(importInfo.get("*视频分组")); + String videoName = importInfo.get("*设备名称"); + String serialNumber = importInfo.get("*监控点"); + String deviceType = importInfo.get("设备类型"); + String verificationCode = importInfo.get("*通道号"); + String aiVideoUrl = importInfo.get("AI分析视频地址"); + String mrql = importInfo.get("默认取流"); + Integer defaultStreamType = null; + if (StrUtil.isNotBlank(mrql)) { + defaultStreamType = Objects.equals(mrql, "子码流") ? 1 : 2; + } + Integer aiFunctionType = Objects.equals(importInfo.get("是否具有AI识别功能"), "是") ? 1 : 0; + if (group == null) { + failGroupList.add(videoName); + continue; + } + VideoItem videoItem = new VideoItem(); + videoItem.setVideoId(videoConfig.getId()); + videoItem.setVideoName(videoName); + videoItem.setSerialNumber(serialNumber); + videoItem.setVerificationCode(verificationCode); + videoItem.setDeviceType(videoItemService.getDeviceType(deviceType)); + videoItem.setCreateTime(new Date()); + videoItem.setDeviceState(2); + videoItem.setGroupId(group.getId()); + videoItem.setAiFunctionType(aiFunctionType); + videoItem.setParentObj(JSON.toJSONString(group)); + videoItem.setAiVideoUrl(aiVideoUrl); + videoItem.setDefaultStreamType(defaultStreamType); + videoItems.add(videoItem); + } + videoItemService.saveBatch(videoItems); + return Result.ok(StrUtil.format("导入完成。导入成功:你好,阿爸{};导入失败:嘉兴、囧扥就(),军方,周邓个(){}")); + } catch (Exception e) { + throw new OpenAlertException("导入excel失败", e); + } + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/video/entity/VideoItem.java b/src/main/java/com/zhgd/xmgl/modules/video/entity/VideoItem.java index 5dcf7bc1e..11b916bd4 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/entity/VideoItem.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/entity/VideoItem.java @@ -166,6 +166,12 @@ public class VideoItem implements Serializable { */ @ApiModelProperty(value = "默认码流类型:1、子码流,2、主码流,默认子码流") private Integer defaultStreamType; + /** + * 智能广播设备devSns(多个,分隔) + */ + @ApiModelProperty(value = "智能广播设备devSns(多个,分隔)") + private String broadcastDevs; + /** * 项目sn */ diff --git a/src/main/java/com/zhgd/xmgl/modules/video/entity/dto/MoveGroupVideoItemDto.java b/src/main/java/com/zhgd/xmgl/modules/video/entity/dto/MoveGroupVideoItemDto.java new file mode 100644 index 000000000..eb046949a --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/video/entity/dto/MoveGroupVideoItemDto.java @@ -0,0 +1,14 @@ +package com.zhgd.xmgl.modules.video.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class MoveGroupVideoItemDto { + @ApiModelProperty("视频设备idList") + private List itemIds; + @ApiModelProperty("视频分组id") + private Long videoGroupId; +} diff --git a/src/main/java/com/zhgd/xmgl/modules/video/mapper/xml/VideoItemMapper.xml b/src/main/java/com/zhgd/xmgl/modules/video/mapper/xml/VideoItemMapper.xml index d80e54833..90c56e454 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/mapper/xml/VideoItemMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/video/mapper/xml/VideoItemMapper.xml @@ -25,6 +25,9 @@ and vi.group_id = #{groupId} + + and vi.video_name = #{videoName} + and vi.item_id in diff --git a/src/main/java/com/zhgd/xmgl/modules/video/service/IVideoItemService.java b/src/main/java/com/zhgd/xmgl/modules/video/service/IVideoItemService.java index f4de674f3..76f739f49 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/service/IVideoItemService.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/service/IVideoItemService.java @@ -23,6 +23,14 @@ import java.util.concurrent.ExecutionException; * @version: V1.0 */ public interface IVideoItemService extends IService { + /** + * 根据设备类型文字获取对应的数字编码 + * + * @param deviceName 设备类型名称 + * @return 对应的数字编码 + */ + Integer getDeviceType(String deviceName); + /** * 添加视频设备列表信息 * diff --git a/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java index 0436946b7..f314fca9d 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java @@ -1,5 +1,6 @@ package com.zhgd.xmgl.modules.video.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; @@ -189,7 +190,7 @@ public class VideoItemServiceImpl extends ServiceImpl integerMap = getTotalAndOnlineNum(jsonObject); + jsonObject.putAll(integerMap); + } + } data.put("type", 2); return data; } + /** + * 递归统计所有下级有serialNumber的节点数量 + * 并设置总数和在线视频监控数量 + * + * @param jsonObject JSON对象 + * @return 包含totalNum和onlineNum的Map + */ + private static Map getTotalAndOnlineNum(JSONObject jsonObject) { + Map result = new HashMap<>(); + int totalNum = 0; + int onlineNum = 0; + // 检查当前节点是否有serialNumber(算作一个设备) + if (jsonObject.containsKey("videoName")) { + totalNum = 1; + // 假设在线状态字段为"online"或"status" + if (Objects.equals(jsonObject.getInteger("deviceState"), 1)) { + onlineNum = 1; + } + } + // 递归处理子节点 + JSONArray children = jsonObject.getJSONArray("children"); + if (CollUtil.isNotEmpty(children)) { + for (int i = 0; i < children.size(); i++) { + JSONObject child = children.getJSONObject(i); + Map childStats = getTotalAndOnlineNum(child); + // 累加子节点的统计结果 + totalNum += childStats.getOrDefault("totalNum", 0); + onlineNum += childStats.getOrDefault("onlineNum", 0); + child.putAll(childStats); + } + } + result.put("totalNum", totalNum); + result.put("onlineNum", onlineNum); + return result; + } + + @Override public List selecAllVideoList(Map map) { return videoItemMapper.selectProjectVideoList(map); @@ -1131,4 +1177,27 @@ public class VideoItemServiceImpl extends ServiceImpl> + * + * @param is + * @param index + * @return + * @throws Exception + */ public static List> jxlExlToList(InputStream is, int index) throws Exception { Workbook book = null; List> list = null; @@ -993,4 +1003,50 @@ public class ExcelUtils { // } //} + /** + * 导出excel模板 + * + * @param templatePath classPath文件路径 + * @param downLoadFileName 下载名称 + * @param pullDowns 下拉 + * @param response + */ + public static void exportExcelTemplate(String templatePath, String downLoadFileName, List pullDowns, HttpServletResponse response) { + try { + ClassPathResource classPathResource = new ClassPathResource(templatePath); + InputStream inputStream = classPathResource.getInputStream(); + XSSFWorkbook workbook = new XSSFWorkbook(inputStream); + //下拉列 + if (CollUtil.isNotEmpty(pullDowns)) { + for (ExportExcelTemplatePullDown pullDown : pullDowns) { + XSSFSheet sheet = workbook.getSheet(pullDown.getSheetName()); + for (int i = 0; i < pullDown.getContents().size(); i++) { + XSSFRow row = sheet.createRow(i); + XSSFCell cell = row.createCell(pullDown.getColumnIndex()); + cell.setCellType(CellType.STRING); + cell.setCellValue(pullDown.getContents().get(i)); + } + } + } + downLoadExcel(downLoadFileName, response, workbook); + } catch (IOException e) { + log.error("exportExcelTemplate:", e); + } + } + + @Data + public static class ExportExcelTemplatePullDown { + private String sheetName; + private Integer columnIndex; + private List contents; + + public ExportExcelTemplatePullDown(String sheetName, Integer columnIndex, List contents) { + this.contents = contents; + this.columnIndex = columnIndex; + this.sheetName = sheetName; + } + + public ExportExcelTemplatePullDown() { + } + } } diff --git a/src/main/java/com/zhgd/xmgl/util/FileUtils.java b/src/main/java/com/zhgd/xmgl/util/FileUtils.java index d75f8ef24..7d2b80915 100644 --- a/src/main/java/com/zhgd/xmgl/util/FileUtils.java +++ b/src/main/java/com/zhgd/xmgl/util/FileUtils.java @@ -174,11 +174,33 @@ public class FileUtils { return PathUtil.getBasePath() + "/" + fileUrl1; } + /** + * url(如:xxx*xxxx,xxx*xxxx,[],xxx.jpg等等)转换成本地文件名称 + * + * @param fileUrl + * @return + */ + public static String urlToFileName(String fileUrl) { + List fileObjs = parseUrlString(fileUrl); + if (CollUtil.isEmpty(fileObjs)) { + return null; + } + String fileName = fileObjs.get(0).getFileName(); + if (StrUtil.isNotBlank(fileName)) { + return fileName; + } + String fileUrl1 = fileObjs.get(0).getFileUrl(); + if (fileUrl1.contains("http") || fileUrl1.contains("https")) { + fileUrl1 = StringUtils.substringAfter(fileUrl1, "/image/"); + } + return new File(PathUtil.getBasePath() + "/" + fileUrl1).getName(); + } + public static void main(String[] args) { - System.out.println(urlToFilePath("图片2.png*http://jxj.zhgdyun.com:21000/image/68afb689e6ca0a85c0ef03dd.png")); - System.out.println(urlToFilePath("68afb8b6e6ca0a85c0ef03de.png*68afb8b6e6ca0a85c0ef03de.png")); - System.out.println(urlToFilePath("68afb8b6e6ca0a85c0ef03de.png")); - System.out.println(urlToFilePath("68afb8b6e6ca0a85c0ef03de.png,123.png")); + System.out.println(urlToFileName("图片2.png*http://jxj.zhgdyun.com:21000/image/0012710f3eac4542b30314130873ae6e1.png")); + System.out.println(urlToFileName("文件名称.png*0012710f3eac4542b30314130873ae6e.png")); + System.out.println(urlToFileName("0012710f3eac4542b30314130873ae6e1.png")); + System.out.println(urlToFileName("0012710f3eac4542b30314130873ae6e.png,123.png")); } @Data diff --git a/src/main/resources/excel/videoitem/监控点导入模版(isc).xlsx b/src/main/resources/excel/videoitem/监控点导入模版(isc).xlsx new file mode 100644 index 000000000..002d6b458 Binary files /dev/null and b/src/main/resources/excel/videoitem/监控点导入模版(isc).xlsx differ diff --git a/src/main/resources/excel/videoitem/监控点导入模版(大华).xlsx b/src/main/resources/excel/videoitem/监控点导入模版(大华).xlsx new file mode 100644 index 000000000..002d6b458 Binary files /dev/null and b/src/main/resources/excel/videoitem/监控点导入模版(大华).xlsx differ diff --git a/src/main/resources/excel/videoitem/监控点导入模版(萤石云).xlsx b/src/main/resources/excel/videoitem/监控点导入模版(萤石云).xlsx new file mode 100644 index 000000000..765c9f9b0 Binary files /dev/null and b/src/main/resources/excel/videoitem/监控点导入模版(萤石云).xlsx differ