已重命名2个文件
已删除1个文件
已修改11个文件
已添加12个文件
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import javax.persistence.Column; |
| | | import javax.persistence.Entity; |
| | | import javax.persistence.Id; |
| | | import javax.persistence.Table; |
| | | |
| | | import javax.persistence.*; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description ç½å
³é
ç½® |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Id |
| | | @Column(name = "id", columnDefinition = "varchar(40) COMMENT 'ç½å
³ID'") |
| | | @Column(name = "id", columnDefinition = "varchar(40) COMMENT 'ç½å
³ID,åSN'") |
| | | @TableField("id") |
| | | private String id; |
| | | |
| | |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @Column(name = "heartbeat_time", columnDefinition = "DATETIME COMMENT 'å¿è·³æ¶é´'") |
| | | @Temporal(TemporalType.TIMESTAMP) |
| | | @TableField("heartbeat_time") |
| | | private Date heartbeatTime; |
| | | |
| | | } |
| | |
| | | import com.fzzy.igds.data.BaseResp; |
| | | import com.fzzy.igds.data.IgdsBaseParam; |
| | | import com.fzzy.igds.domain.EventInfo; |
| | | import com.fzzy.igds.domain.SnapRecord; |
| | | import com.fzzy.igds.mapper.EventInfoMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.DateUtil; |
| | |
| | | return eventInfoMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * æä¹
åä¿å |
| | | * @param info |
| | | */ |
| | | public void addData(EventInfo info) { |
| | | if(StringUtils.isBlank(info.getId())){ |
| | | info.setId(ContextUtil.generateId()); |
| | | } |
| | | if(StringUtils.isBlank(info.getCompanyId())){ |
| | | info.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | |
| | | info.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | info.setUpdateTime(new Date()); |
| | | info.setCreateBy(ContextUtil.getLoginUserName()); |
| | | info.setCreateTime(new Date()); |
| | | eventInfoMapper.insert(info); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.domain.FileInfo; |
| | | import com.fzzy.igds.mapper.FileMapper; |
| | | import com.fzzy.igds.utils.Base64Util; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param id |
| | | */ |
| | | public void delFile(String id) { |
| | | fileMapper.deleteById(id); |
| | | } |
| | | |
| | | /** |
| | | * è·ååºå
¥åºæä»¶è·¯å¾ |
| | | * æ ¹æ®ç±»åè·åæä»¶è·¯å¾ |
| | | * @param pathTag |
| | | * @return |
| | | */ |
| | |
| | | if(StringUtils.isBlank(pathTag)){ |
| | | pathTag = "COMMON"; |
| | | } |
| | | if("EVENT".equals(pathTag)) return getEventFilePath(); |
| | | if("SNAP".equals(pathTag)) return getSnapFilePath(); |
| | | if("INOUT".equals(pathTag)) return getInoutFilePath(); |
| | | if("PATROL".equals(pathTag)) return getPatrolFilePath(); |
| | | if("DEPT".equals(pathTag)) return getDeptFilePath(); |
| | | if("TEMP".equals(pathTag)) return getTempFilePath(); |
| | | if("CONF".equals(pathTag)) return getConfPath(); |
| | | if("TEMPLATE".equals(pathTag)) return getTemplateFilePath(); |
| | | if("WORD".equals(pathTag)) return getWordPath(); |
| | | |
| | | return getCommonFilePath(); |
| | | } |
| | | |
| | | /** |
| | | * è·ååºå
¥åºæä»¶è·¯å¾ |
| | | * è·åäºä»¶æä»¶è·¯å¾ |
| | | * @return |
| | | */ |
| | | public String getEventFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "EVENT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * è·åæææä»¶è·¯å¾ |
| | | * @return |
| | | */ |
| | | public String getSnapFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "SNAP/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * è·åå·¡æ£æä»¶è·¯å¾ |
| | | * @return |
| | | */ |
| | | public String getPatrolFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "INOUT/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | String basePath = FrameworkConfig.getProfile() + "PATROL/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | |
| | | |
| | | /** |
| | | * è·å临æ¶è·¯å¾ |
| | | * @param companyId |
| | | * @return |
| | | */ |
| | | public String getTempFilePath(String companyId) { |
| | | public String getTempFilePath() { |
| | | |
| | | String basePath = FrameworkConfig.getProfile() + "TEMP/"; |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(companyId)) { |
| | | basePath += companyId + "/"; |
| | | } |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * è·å模æ¿è·¯å¾ï¼æææ¨¡æ¿ç»ä¸æ¾å¨TEMPLATE/ç®å½ä¸ |
| | | * @return |
| | | */ |
| | | public String getTemplateFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "TEMPLATE/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * è·åwordè·¯å¾ |
| | | * @return |
| | | */ |
| | | public String getWordPath() { |
| | | |
| | | String basePath = FrameworkConfig.getProfile() + "WORD/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * base64转å¾çä¿å |
| | | * @param filePath |
| | | * @param imgData |
| | | */ |
| | | public void baseImg2Disk(String filePath, String imgData) { |
| | | Base64Util.generateImage(imgData, filePath); |
| | | } |
| | | |
| | | /** |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * è·å模æ¿è·¯å¾ï¼æææ¨¡æ¿ç»ä¸æ¾å¨TEMPLATE/ç®å½ä¸ |
| | | * @return |
| | | */ |
| | | public String getTemplateFilePath() { |
| | | String basePath = FrameworkConfig.getProfile() + "TEMPLATE/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | |
| | | /** |
| | | * è·åwordè·¯å¾ |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public String getWordPath(String deptId) { |
| | | if(StringUtils.isBlank(deptId)){ |
| | | deptId = "0000"; |
| | | } |
| | | String basePath = FrameworkConfig.getProfile() + deptId + "/WORD/"; |
| | | File file = new File(basePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | return basePath; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | |
| | | if (StringUtils.isEmpty(ser.getDeptId())) { |
| | | ser.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | if (StringUtils.isBlank(ser.getUpdateBy())) { |
| | | |
| | | ser.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | ser.setUpdateTime(new Date()); |
| | | if (StringUtils.isBlank(ser.getCreateBy())) { |
| | | ser.setHeartbeatTime(new Date()); |
| | | ser.setCreateBy(ContextUtil.getLoginUserName()); |
| | | ser.setCreateTime(new Date()); |
| | | ser.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | ser.setUpdateTime(new Date()); |
| | | gatewaySerMapper.insert(ser); |
| | | } else { |
| | | ser.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | ser.setUpdateTime(new Date()); |
| | | gatewaySerMapper.updateById(ser); |
| | | } |
| | | |
| | | refreshCache(ser.getCompanyId()); |
| | | } |
| | | |
| | | /** |
| | | * 弿¥æ´æ°ç½å
³ç¶æ |
| | | * @param ser ä¿¡æ¯ |
| | | * @param status ç¶æ |
| | | * @param isUpdateTime æ¯å¦æ´æ°å¿è·³æ¶é´ |
| | | */ |
| | | @Async |
| | | public void updateStatus(GatewaySer ser, String status, boolean isUpdateTime) { |
| | | |
| | | if(isUpdateTime){ |
| | | //å¿è·³æ¶é´ |
| | | ser.setHeartbeatTime(new Date()); |
| | | } |
| | | |
| | | ser.setUpdateTime(new Date()); |
| | | ser.setStatus(status); |
| | | gatewaySerMapper.updateById(ser); |
| | | |
| | | setCacheSer(ser); |
| | | } |
| | | |
| | | /** |
| | |
| | | //å é¤ç¼å |
| | | delCache(ser); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åæºIDè·ååæºä¿¡æ¯ |
| | | * |
| | | * @param companyId |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public List<GatewaySer> getCacheSerByDeptId(String companyId, String deptId) { |
| | | if (StringUtils.isEmpty(deptId)) { |
| | | return null; |
| | | } |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEVICE_SER_LIST, deptId) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null == keys) { |
| | | return null; |
| | | } |
| | | |
| | | List<GatewaySer> list = new ArrayList<>(); |
| | | for (String key : keys) { |
| | | list.add((GatewaySer) redisCache.getCacheObject(key)); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | List<GatewaySer> list = new ArrayList<>(); |
| | | GatewaySer ser = null; |
| | | for (String key : keys) { |
| | | ser = (GatewaySer) redisCache.getCacheObject(key); |
| | |
| | | import com.fzzy.igds.domain.Camera; |
| | | import com.fzzy.igds.mapper.CameraMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.DateUtil; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åæ´æ°çæ§æ°é |
| | | * @param deptId |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public int getUpdateCount(String deptId, Date start, Date end) { |
| | | |
| | | QueryWrapper<Camera> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | if(StringUtils.isNotBlank(deptId)){ |
| | | queryWrapper.eq("dept_id", deptId); |
| | | } |
| | | if (null != start) { |
| | | queryWrapper.ge("update_time", start); |
| | | } |
| | | if (null != end) { |
| | | queryWrapper.le("update_time", end); |
| | | } |
| | | |
| | | return cameraMapper.selectCount(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * ä¿åæ°æ® |
| | | * @param data |
| | | */ |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.data.BaseResp; |
| | | import com.fzzy.igds.data.IgdsBaseParam; |
| | | import com.fzzy.igds.domain.SnapConf; |
| | | import com.fzzy.igds.mapper.SnapConfMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®IDæ¥è¯¢è¯¦æ
|
| | | * |
| | | * @param id 主é®ID |
| | | * @return å®ä½å¯¹è±¡ |
| | | * è·åæ´æ°é
ç½®æ°é |
| | | * @param deptId |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public SnapConf selectById(String id) { |
| | | return snapConfMapper.selectById(id); |
| | | public int getUpdateCount(String deptId, Date start, Date end) { |
| | | |
| | | QueryWrapper<SnapConf> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | if(StringUtils.isNotBlank(deptId)){ |
| | | queryWrapper.eq("dept_id", deptId); |
| | | } |
| | | if (null != start) { |
| | | queryWrapper.ge("update_time", start); |
| | | } |
| | | if (null != end) { |
| | | queryWrapper.le("update_time", end); |
| | | } |
| | | return snapConfMapper.selectCount(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | |
| | | return BaseResp.error("æ´æ°å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å 餿å®IDçæ°æ® |
| | | * |
| | | * @param param è¦å é¤çè®°å½ |
| | | * @return æä½ç»æ |
| | | */ |
| | | public BaseResp deleteData(SnapConf param) { |
| | | return snapConfMapper.deleteById(param) > 0 ? BaseResp.success() : BaseResp.error("å é¤å¤±è´¥"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ´æ°æ§è¡æ¶é´ |
| | |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æ°æ® |
| | | * |
| | | * æä¹
åä¿å |
| | | * @param snapRecord |
| | | * @author sgj |
| | | * @date 2025/12/10 |
| | | */ |
| | | public BaseResp addData(SnapRecord snapRecord) { |
| | | public void addData(SnapRecord snapRecord) { |
| | | if(StringUtils.isBlank(snapRecord.getId())){ |
| | | snapRecord.setId(ContextUtil.generateId()); |
| | | } |
| | | if(StringUtils.isBlank(snapRecord.getCompanyId())){ |
| | | snapRecord.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | |
| | | snapRecord.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | snapRecord.setUpdateTime(new Date()); |
| | | snapRecord.setCreateBy(ContextUtil.getLoginUserName()); |
| | | snapRecord.setCreateTime(new Date()); |
| | | return snapRecordMapper.insert(snapRecord) > 0 ? BaseResp.success() : BaseResp.error("æ·»å 失败"); |
| | | snapRecordMapper.insert(snapRecord); |
| | | } |
| | | |
| | | /** |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.utils; |
| | | |
| | | import sun.misc.BASE64Decoder; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import java.io.*; |
| | | |
| | | /** |
| | | * @Description å¾çBaseå¤ç |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:07 |
| | | */ |
| | | public class Base64Util { |
| | | |
| | | public static String BASE_IMG_START = "data:image/jpg;base64,"; |
| | | |
| | | /** |
| | | * æ ¹æ®å°åï¼æå¾ç转æ¢ä¸ºBase64å符串 |
| | | * <p> |
| | | * data:image/jpg;base64, |
| | | * |
| | | * @param diskFile |
| | | * @return |
| | | */ |
| | | public static String getImageStr(String diskFile) { |
| | | InputStream in = null; |
| | | byte[] data = null; |
| | | // 读åå¾çåèæ°ç» |
| | | try { |
| | | in = new FileInputStream(diskFile); |
| | | data = new byte[in.available()]; |
| | | in.read(data); |
| | | // in.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | if (null != in) |
| | | in.close(); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | BASE64Encoder encoder = new BASE64Encoder(); |
| | | return BASE_IMG_START + encoder.encode(data); |
| | | } |
| | | |
| | | /** |
| | | * 对åèæ°ç»å符串è¿è¡Base64è§£ç å¹¶çæå¾ç |
| | | * |
| | | * @param imgStr |
| | | * @return |
| | | */ |
| | | public static boolean generateImage(String imgStr, String diskFile) { |
| | | if (imgStr == null) |
| | | return false; |
| | | |
| | | if (imgStr.startsWith("data:")) { |
| | | imgStr = imgStr.substring(BASE_IMG_START.length()); |
| | | } |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | OutputStream out = null; |
| | | try { |
| | | // Base64è§£ç |
| | | byte[] b = decoder.decodeBuffer(imgStr); |
| | | for (int i = 0; i < b.length; ++i) { |
| | | if (b[i] < 0) { |
| | | b[i] += 256; |
| | | } |
| | | } |
| | | // çæjpegå¾ç |
| | | out = new FileOutputStream(diskFile); |
| | | out.write(b); |
| | | out.flush(); |
| | | // out.close(); |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } finally { |
| | | try { |
| | | if (null != out) |
| | | out.close(); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.api.v1.service.*; |
| | | import com.fzzy.igds.api.v1.util.ApiV1Constant; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.fzzy.igds.service.GatewaySerService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @Description ç管æ¥å£è§£æå
¥å£ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 10:25 |
| | | */ |
| | | @Slf4j |
| | | @Controller |
| | | @RequestMapping("api/igdss/v1") |
| | | public class ApiV1Controller { |
| | | |
| | | @Resource |
| | | private GatewaySerService gatewaySerService; |
| | | @Resource |
| | | private ApiV1Service3010 apiV1Service3010; |
| | | @Resource |
| | | private ApiV1Service3020 apiV1Service3020; |
| | | @Resource |
| | | private ApiV1Service3021 apiV1Service3021; |
| | | @Resource |
| | | private ApiV1Service3030 apiV1Service3030; |
| | | @Resource |
| | | private ApiV1Service3031 apiV1Service3031; |
| | | |
| | | |
| | | @PostMapping |
| | | @ResponseBody |
| | | public ApiV1Resp<Object> gateway(@RequestBody ApiV1Req<JSONObject> req) { |
| | | |
| | | log.info("è´¨æ¼ç管æ¥å£V1ï¼æ¶å°åºåºç½å
³ä¿¡æ¯={}", req); |
| | | try { |
| | | |
| | | //åæ°æ ¡éª |
| | | if (req == null) { |
| | | return ApiV1Resp.error("åæ°æè¯¯ï¼", req); |
| | | } |
| | | |
| | | //æ ¡éªæ¥å£ç¼ç åç½å
³SN |
| | | if (StringUtils.isEmpty(req.getFunctionId()) || StringUtils.isEmpty(req.getSn())) { |
| | | return ApiV1Resp.error("åæ°æè¯¯ï¼", req); |
| | | } |
| | | |
| | | //æ ¡éªç½å
³æ¯å¦åå¨ |
| | | GatewaySer gatewaySer = gatewaySerService.getCacheSerById(null, req.getSn()); |
| | | if (null == gatewaySer) { |
| | | return ApiV1Resp.error("å½åç½å
³<SN=" + req.getSn() + ">ææªæ·»å ï¼è¯·æ ¸æ¥ï¼", req); |
| | | } |
| | | |
| | | //弿¥æ´æ°ç½å
³ç¶æ |
| | | gatewaySerService.updateStatus(gatewaySer, Constant.YN_Y, ApiV1Constant.API_FUNCTION_3010.equals(req.getFunctionId())); |
| | | |
| | | //è§£æ |
| | | String functionId = req.getFunctionId(); |
| | | switch (functionId) { |
| | | case ApiV1Constant.API_FUNCTION_3010: |
| | | return apiV1Service3010.analysis(req, gatewaySer); |
| | | case ApiV1Constant.API_FUNCTION_3020: |
| | | return apiV1Service3020.analysis(req, gatewaySer); |
| | | case ApiV1Constant.API_FUNCTION_3021: |
| | | return apiV1Service3021.analysis(req, gatewaySer); |
| | | case ApiV1Constant.API_FUNCTION_3030: |
| | | return apiV1Service3030.analysis(req, gatewaySer); |
| | | case ApiV1Constant.API_FUNCTION_3031: |
| | | return apiV1Service3031.analysis(req, gatewaySer); |
| | | } |
| | | |
| | | return ApiV1Resp.error("æ¥å£ç¼ç <" + functionId + ">ä¸åå¨ï¼è¯·æ ¸æ¥ï¼", req); |
| | | |
| | | } catch (Exception e) { |
| | | |
| | | log.info("è´¨æ¼ç管æ¥å£V1ï¼æ¥å£è§£æå¼å¸¸={}", e.toString()); |
| | | |
| | | return ApiV1Resp.error("è§£æå¼å¸¸ï¼", req); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.data; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description æ¥å£è¯·æ±å°è£
ç±» |
| | | * @Author CZT |
| | | * @Date 2026/1/7 9:59 |
| | | */ |
| | | @Data |
| | | public class ApiV1Req<T> implements Serializable { |
| | | |
| | | /*-----æ¶æ¯å¤´-----*/ |
| | | private String sn; //设å¤ãç³»ç»ç¼ç |
| | | private String auth; //æéæ è¯ |
| | | private String sign; //æéç¾å |
| | | private String outId; //èªå®ä¹ç¼ç |
| | | private String functionId; //åè½ç |
| | | private Long timestamp; //æ¶é´æ³ |
| | | |
| | | /*-----æ¶æ¯ä½-----*/ |
| | | private T data; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.data; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import lombok.Data; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description æ¥å£åå¤å°è£
ç±» |
| | | * @Author CZT |
| | | * @Date 2026/1/7 10:02 |
| | | */ |
| | | @Data |
| | | public class ApiV1Resp<T> implements Serializable { |
| | | |
| | | /** |
| | | * è¿åç |
| | | */ |
| | | public static final String CODE_SUCCESS = "200"; |
| | | public static final String CODE_ERROR = "400"; |
| | | |
| | | /*-----æ¶æ¯å¤´-----*/ |
| | | private String sn; //设å¤ãç³»ç»ç¼ç |
| | | private String auth; //æéæ è¯ |
| | | private String sign; //æéç¾å |
| | | private String outId; //èªå®ä¹ç¼ç |
| | | private String functionId; //åè½ç |
| | | private Long timestamp; //æ¶é´æ³ |
| | | private String respCode; //è¿åç |
| | | private String respMsg; //è¿å说æ |
| | | |
| | | /*-----æ¶æ¯ä½-----*/ |
| | | private T data; |
| | | |
| | | |
| | | public ApiV1Resp() { |
| | | super(); |
| | | } |
| | | |
| | | public ApiV1Resp(String respCode, String respMsg, T data, ApiV1Req<JSONObject> req) { |
| | | this.data = data; |
| | | this.sn = req.getSn(); |
| | | this.auth = req.getAuth(); |
| | | this.sign = req.getSign(); |
| | | this.outId = req.getOutId(); |
| | | this.functionId = req.getFunctionId(); |
| | | this.timestamp = System.currentTimeMillis(); |
| | | this.respCode = respCode; |
| | | this.respMsg = respMsg; |
| | | } |
| | | |
| | | public static ApiV1Resp<Object> success(Object data, ApiV1Req<JSONObject> req) { |
| | | return new ApiV1Resp<>(CODE_SUCCESS, null, data, req); |
| | | } |
| | | |
| | | public static ApiV1Resp<Object> error(String respMsg, ApiV1Req<JSONObject> req) { |
| | | return new ApiV1Resp<>(CODE_ERROR, respMsg, null, req); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.data; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description ææä¿¡æ¯å°è£
ç±» |
| | | * @Author CZT |
| | | * @Date 2026/1/7 10:20 |
| | | */ |
| | | @Data |
| | | public class Param3030 implements Serializable { |
| | | |
| | | private String cameraId; |
| | | private String cameraName; |
| | | private String result; |
| | | private String tags; |
| | | private String snapTime; |
| | | private String imgBase64; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.data; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author CZT |
| | | * @Date 2026/1/7 10:21 |
| | | */ |
| | | @Data |
| | | public class Param3031 implements Serializable { |
| | | |
| | | private String cameraId; |
| | | private String cameraName; |
| | | private String name; |
| | | private String bizType; |
| | | private String type; |
| | | private String level; |
| | | private String info; |
| | | private String time; |
| | | private String tags; |
| | | private String imgBase64; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.service; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.api.v1.util.ApiV1Constant; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.fzzy.igds.service.SecCameraService; |
| | | import com.fzzy.igds.service.SnapConfService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description å¿è·³è§£æ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:01 |
| | | */ |
| | | @Component |
| | | public class ApiV1Service3010 { |
| | | |
| | | @Resource |
| | | private SecCameraService cameraService; |
| | | @Resource |
| | | private SnapConfService snapConfService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) { |
| | | |
| | | Date end = new Date(); |
| | | Date start = gatewaySer.getHeartbeatTime(); |
| | | String functionId = ""; |
| | | |
| | | //夿ææé
ç½®æ¯å¦ææ´æ° |
| | | int snapConfCount = snapConfService.getUpdateCount(gatewaySer.getDeptId(), start, end); |
| | | if (snapConfCount > 0) { |
| | | functionId += ApiV1Constant.API_FUNCTION_3020 + ","; |
| | | } |
| | | |
| | | //å¤æçæ§æ¯ææ´æ° |
| | | int cameraCount = cameraService.getUpdateCount(gatewaySer.getDeptId(), start, end); |
| | | if (cameraCount > 0) { |
| | | functionId += ApiV1Constant.API_FUNCTION_3021 + ","; |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(functionId)) { |
| | | req.setFunctionId(functionId); |
| | | } |
| | | |
| | | return ApiV1Resp.success(null, req); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.service; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.fzzy.igds.domain.SnapConf; |
| | | import com.fzzy.igds.service.SnapConfService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description ææé
置解æ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:03 |
| | | */ |
| | | @Component |
| | | public class ApiV1Service3020 { |
| | | |
| | | @Resource |
| | | private SnapConfService snapConfService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) { |
| | | |
| | | //è·ååºåºä¸ææææé
ç½® |
| | | List<SnapConf> list = snapConfService.selectList(gatewaySer.getDeptId()); |
| | | |
| | | if(null == list || list.isEmpty()){ |
| | | return ApiV1Resp.error("æªè·åå°ææé
置信æ¯ï¼", req); |
| | | } |
| | | |
| | | return ApiV1Resp.success(list, req); |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.service; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.domain.Camera; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.fzzy.igds.service.SecCameraService; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description çæ§é
置解æ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:05 |
| | | */ |
| | | @Component |
| | | public class ApiV1Service3021 { |
| | | |
| | | @Resource |
| | | private SecCameraService cameraService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) { |
| | | |
| | | //è·ååºåºä¸ææçæ§ä¿¡æ¯ |
| | | List<Camera> list = cameraService.getCameraByDeptId(gatewaySer.getCompanyId(), gatewaySer.getDeptId()); |
| | | |
| | | if(null == list || list.isEmpty()){ |
| | | return ApiV1Resp.error("æªè·åå°çæ§ä¿¡æ¯ï¼", req); |
| | | } |
| | | |
| | | return ApiV1Resp.success(list, req); |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.service; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.api.v1.data.Param3030; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fzzy.igds.domain.SnapRecord; |
| | | import com.fzzy.igds.service.FileService; |
| | | import com.fzzy.igds.service.SnapRecordService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description ææè§£æ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:07 |
| | | */ |
| | | @Component |
| | | public class ApiV1Service3030 { |
| | | |
| | | @Resource |
| | | private SnapRecordService snapRecordService; |
| | | @Resource |
| | | private FileService fileService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) throws Exception{ |
| | | |
| | | //转å为对象 |
| | | List<Param3030> list = JSONObject.parseArray(req.getData().toString(), Param3030.class); |
| | | |
| | | if(null == list || list.isEmpty()){ |
| | | return ApiV1Resp.error("ææä¿¡æ¯ä¸ºç©ºï¼ä¸è§£æï¼", req); |
| | | } |
| | | |
| | | step1(list, gatewaySer); |
| | | |
| | | return ApiV1Resp.success(null, req); |
| | | } |
| | | |
| | | /** |
| | | * 弿¥è§£æ |
| | | * @param list |
| | | */ |
| | | @Async |
| | | public void step1(List<Param3030> list, GatewaySer gatewaySer) throws Exception { |
| | | |
| | | SnapRecord snapRecord; |
| | | for (Param3030 param3030 : list) { |
| | | snapRecord = new SnapRecord(); |
| | | snapRecord.setId(ContextUtil.generateId()); |
| | | snapRecord.setCompanyId(gatewaySer.getCompanyId()); |
| | | snapRecord.setDeptId(gatewaySer.getDeptId()); |
| | | snapRecord.setCameraId(param3030.getCameraId()); |
| | | snapRecord.setResult(param3030.getResult()); |
| | | snapRecord.setTags(param3030.getTags()); |
| | | snapRecord.setSnapTime(DateUtils.parseDate(param3030.getSnapTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | //base64转å为å¾çä¿å |
| | | String savePath = fileService.getFileSavePath("SNAP"); |
| | | String fileName = ContextUtil.UUID() + ".jpg"; |
| | | String filePath = savePath+fileName; |
| | | fileService.baseImg2Disk(filePath, param3030.getImgBase64()); |
| | | |
| | | //设置ä¿åå¾çè·¯å¾ |
| | | snapRecord.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | |
| | | snapRecordService.addData(snapRecord); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.service; |
| | | |
| | | import com.fzzy.igds.api.v1.data.ApiV1Req; |
| | | import com.fzzy.igds.api.v1.data.ApiV1Resp; |
| | | import com.fzzy.igds.api.v1.data.Param3030; |
| | | import com.fzzy.igds.api.v1.data.Param3031; |
| | | import com.fzzy.igds.constant.WarnStatus; |
| | | import com.fzzy.igds.domain.EventInfo; |
| | | import com.fzzy.igds.domain.GatewaySer; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fzzy.igds.domain.SnapRecord; |
| | | import com.fzzy.igds.service.EventInfoService; |
| | | import com.fzzy.igds.service.FileService; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description AIäºä»¶è§£æ |
| | | * @Author CZT |
| | | * @Date 2026/1/7 11:09 |
| | | */ |
| | | @Component |
| | | public class ApiV1Service3031 { |
| | | |
| | | @Resource |
| | | private EventInfoService eventInfoService; |
| | | @Resource |
| | | private FileService fileService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<JSONObject> req, GatewaySer gatewaySer) throws Exception { |
| | | |
| | | //转å为对象 |
| | | List<Param3031> list = JSONObject.parseArray(req.getData().toString(), Param3031.class); |
| | | |
| | | if(null == list || list.isEmpty()){ |
| | | return ApiV1Resp.error("ææä¿¡æ¯ä¸ºç©ºï¼ä¸è§£æï¼", req); |
| | | } |
| | | |
| | | step1(list, gatewaySer); |
| | | |
| | | return ApiV1Resp.success(null, req); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 弿¥è§£æ |
| | | * @param list |
| | | */ |
| | | @Async |
| | | public void step1(List<Param3031> list, GatewaySer gatewaySer) throws Exception { |
| | | |
| | | EventInfo info; |
| | | for (Param3031 param : list) { |
| | | |
| | | info = new EventInfo(); |
| | | info.setId(ContextUtil.generateId()); |
| | | info.setCompanyId(gatewaySer.getCompanyId()); |
| | | info.setDeptId(gatewaySer.getDeptId()); |
| | | info.setSerId(param.getCameraId()); |
| | | info.setName(param.getName()); |
| | | info.setBizType(param.getBizType()); |
| | | info.setType(param.getType()); |
| | | info.setLevel(param.getLevel()); |
| | | info.setInfo(param.getInfo()); |
| | | info.setTime(DateUtils.parseDate(param.getTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | info.setTags(param.getTags()); |
| | | |
| | | |
| | | //base64转å为å¾çä¿å |
| | | String savePath = fileService.getFileSavePath("EVENT"); |
| | | String fileName = ContextUtil.UUID() + ".jpg"; |
| | | String filePath = savePath+fileName; |
| | | fileService.baseImg2Disk(filePath, param.getImgBase64()); |
| | | |
| | | //设置ä¿åå¾çè·¯å¾ |
| | | info.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | |
| | | eventInfoService.addData(info); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.igds.api.v1.util; |
| | | |
| | | /** |
| | | * @Description æ¥å£å¸¸éç±» |
| | | * @Author CZT |
| | | * @Date 2026/1/7 10:03 |
| | | */ |
| | | public class ApiV1Constant { |
| | | |
| | | /*----------æ¥å£ç¼ç ----------*/ |
| | | /** |
| | | * å¿è·³æ¥å£ç¼ç |
| | | */ |
| | | public static final String API_FUNCTION_3010 = "3010"; |
| | | /** |
| | | * 忥ææé
ç½®æ¥å£ç¼ç |
| | | */ |
| | | public static final String API_FUNCTION_3020 = "3020"; |
| | | /** |
| | | * åæ¥çæ§é
ç½®æ¥å£ç¼ç |
| | | */ |
| | | public static final String API_FUNCTION_3021 = "3021"; |
| | | /** |
| | | * æ¨éææä¿¡æ¯æ¥å£ç¼ç |
| | | */ |
| | | public static final String API_FUNCTION_3030 = "3030"; |
| | | public static final String API_FUNCTION_3031 = "3031"; |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | //è·å模æ¿è·¯å¾ |
| | | String templatePath = fileService.getTemplateFilePath(); |
| | | String templatePath = fileService.getFileSavePath("TEMPLATE"); |
| | | File file = new File(templatePath + templateName); |
| | | if (!file.exists()) { |
| | | log.error("æ¨¡æ¿æä»¶ä¸åå¨ï¼ä¸æ§è¡å¯¼åºï¼"); |
| | |
| | | } |
| | | |
| | | //è·åæä»¶ä¿åè·¯å¾,以åºåºåå¼ |
| | | String savePath = fileService.getWordPath(null); |
| | | String savePath = fileService.getFileSavePath(null); |
| | | |
| | | param.setTemplatePath(templatePath); |
| | | param.setTemplateName(templateName); |
| | |
| | | } |
| | | |
| | | result = ContextUtil.getTimeId() + ".xls"; |
| | | String tempPath = fileService.getTempFilePath(depot == null ? ContextUtil.getCompanyId() : depot.getCompanyId()); |
| | | String tempPath = fileService.getFileSavePath("TEMP"); |
| | | FileOutputStream fos = new FileOutputStream(tempPath + "/" + result); |
| | | toWorkbook.write(fos); |
| | | if (null != fos) fos.close(); |
| | |
| | | private HSSFWorkbook getFromWorkBook(GrainData data, Depot depot) throws Exception { |
| | | FileInputStream fis = null; |
| | | |
| | | String filePath = fileService.getConfPath(); |
| | | String filePath = fileService.getFileSavePath("CONF"); |
| | | try { |
| | | //è·å模ççåç§°ï¼æ³¨æçä»åç§°é
ç½®è§å |
| | | if (StringUtils.isEmpty(data.getCableCir())) { |
| | |
| | | @RequestMapping("/security/eventInfo") |
| | | public class EventInfoController { |
| | | |
| | | private static final String prefix = "security/eventInfo"; |
| | | private static final String prefix = "security"; |
| | | |
| | | @Resource |
| | | private EventInfoManager eventInfoManager; |
| | |
| | | @RequestMapping("/security/snap/snapRecord") |
| | | public class SnapRecordController { |
| | | |
| | | private static final String prefix = "security/snap/snapRecord"; |
| | | private static final String prefix = "security"; |
| | | |
| | | @Resource |
| | | private SnapRecordManager snapRecordManager; |