Browse Source

事件表PO类修改

hxd 3 months ago
parent
commit
ba584c3668
17 changed files with 208 additions and 38 deletions
  1. 7 0
      portal-service-application/src/main/java/com/hfln/portal/application/controller/pub/PubController.java
  2. 2 2
      portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java
  3. 1 1
      portal-service-application/src/test/java/com/hfln/portal/application/controller/wap/EventControllerTest.java
  4. 17 6
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/event/AlarmEventDTO.java
  5. 1 4
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/event/EventListDTO.java
  6. 1 1
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java
  7. 2 0
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/PubGateway.java
  8. 2 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java
  9. 45 3
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/PubGatewayImpl.java
  10. 2 0
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/UserGatewayImpl.java
  11. 2 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/mqtt/MqttSubHandle.java
  12. 20 9
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/AlarmEvent.java
  13. 2 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/EventList.java
  14. 12 5
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/StayTime.java
  15. 2 0
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/OssFileService.java
  16. 1 1
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/EventServiceImpl.java
  17. 89 0
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/OssFileServiceImpl.java

+ 7 - 0
portal-service-application/src/main/java/com/hfln/portal/application/controller/pub/PubController.java

@@ -34,4 +34,11 @@ public class PubController {
         return ApiResult.success(pubGateway.query(dicType));
     }
 
+//
+//    @PostMapping(value = "/uploadWJ")
+//    @Operation(summary = "上传文件")
+//    public ApiResult<Void> uploadCommonFile(@Valid @RequestParam MultipartFile file , String fileType) throws IOException {
+//        pubGateway.uploadWJ(file, fileType);
+//        return ApiResult.success();
+//    }
 }

+ 2 - 2
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/DeviceController.java

@@ -86,8 +86,8 @@ public class DeviceController {
 
     @GetMapping("/getWcTimes")
     @Operation(summary = "查询当天上厕所次数")
-    public ApiResult<WcTimesQueryRes> getWcTimes(@RequestParam("devId") Long devId, @RequestParam("time") String time) {
-        return ApiResult.success(deviceGateway.getWcTimes(devId, time));
+    public ApiResult<WcTimesQueryRes> getWcTimes(@RequestParam("clientId") Long clientId, @RequestParam("time") String time) {
+        return ApiResult.success(deviceGateway.getWcTimes(clientId, time));
     }
 
     @PostMapping("/transfer")

+ 1 - 1
portal-service-application/src/test/java/com/hfln/portal/application/controller/wap/EventControllerTest.java

@@ -46,7 +46,7 @@ class EventControllerTest {
         event.setDevId(TEST_DEVICE_ID);
         event.setEventListId(1L);
         event.setPose(1);
-        event.setEvent(1);
+        event.setEventType(1);
         event.setIsHandle(0);
         events.add(event);
         

+ 17 - 6
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/event/AlarmEventDTO.java

@@ -8,20 +8,31 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class AlarmEventDTO extends BaseVO {
 
-    private Long stayTimeId;
+    private Long alarmEventId;
 
     /**
-     * dev_info表id
+     * 设备ID
      */
-    private Long devId;
+    private Long clientId;
 
+    /**
+     * 姿势
+     */
     private Byte pose;
 
-    private String targetPoints;
+    /**
+     * 停留时间表主键id
+     */
+    private Long stayTimeId;
 
-    private String event;
+    /**
+     * 告警类型
+     */
+    private String eventType;
 
-    private String desc;
 
+    /**
+     * 是否处理
+     */
     private Integer isHandle;
 } 

+ 1 - 4
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/event/EventListDTO.java

@@ -1,8 +1,5 @@
 package com.hfln.portal.common.dto.data.event;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.hfln.portal.common.vo.BaseVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -39,7 +36,7 @@ public class EventListDTO extends BaseVO {
      * 事件类型
      */
     @Schema(description = "事件类型")
-    private Integer event;
+    private Integer eventType;
 
     /**
      * 是否处理:0-未处理,1-已处理

+ 1 - 1
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/DeviceGateway.java

@@ -97,7 +97,7 @@ public interface DeviceGateway {
 
     String getFloorPlan(String groupUuid);
 
-    WcTimesQueryRes getWcTimes(Long devId, String time);
+    WcTimesQueryRes getWcTimes(Long client, String time);
 
 
 

+ 2 - 0
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/PubGateway.java

@@ -8,5 +8,7 @@ public interface PubGateway {
 
 
     List<DicItemDto> query(String dicType);
+
+//    void uploadWJ(MultipartFile file,  String fileType) throws IOException;
 }
 

+ 2 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -811,11 +811,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
     }
 
     @Override
-    public WcTimesQueryRes getWcTimes(Long devId, String time) {
+    public WcTimesQueryRes getWcTimes(Long clientId, String time) {
 
         LocalDate inputDate = LocalDate.parse(time);
         LocalDate tomorrow = inputDate.plusDays(1);
-        List<AlarmEvent> list = alarmEventService.list(new LambdaQueryWrapper<AlarmEvent>().eq(AlarmEvent::getDevId, devId).ge(AlarmEvent::getCreateTime, inputDate).lt(AlarmEvent::getCreateTime, tomorrow));
+        List<AlarmEvent> list = alarmEventService.list(new LambdaQueryWrapper<AlarmEvent>().eq(AlarmEvent::getClientId, clientId).ge(AlarmEvent::getCreateTime, inputDate).lt(AlarmEvent::getCreateTime, tomorrow));
         WcTimesQueryRes res = new WcTimesQueryRes();
         if (CollectionUtils.isEmpty(list)) {
 

+ 45 - 3
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/PubGatewayImpl.java

@@ -1,27 +1,69 @@
 package com.hfln.portal.infrastructure.gateway.impl;
 
+import cn.hfln.framework.extension.BizException;
 import com.hfln.portal.common.dto.data.pub.DicItemDto;
 import com.hfln.portal.domain.customer.util.CopyUtils;
+import com.hfln.portal.domain.exception.ErrorEnum;
 import com.hfln.portal.domain.gateway.PubGateway;
+import com.hfln.portal.infrastructure.po.TblOssFile;
+import com.hfln.portal.infrastructure.service.OssFileService;
 import com.hfln.portal.infrastructure.service.TblDicItemService;
-import com.hfln.portal.infrastructure.service.TblDicService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.List;
 
 @Slf4j
 @Service
 public class PubGatewayImpl implements PubGateway {
 
-    @Autowired
-    private TblDicService tblDicService;
 
     @Autowired
     private TblDicItemService tblDicItemService;
+
+
+    @Autowired
+    private OssFileService ossFileService;
+
+
     @Override
     public List<DicItemDto> query(String dicType) {
         return CopyUtils.copyList(tblDicItemService.queryByDicType(dicType), DicItemDto.class);
     }
+
+
+//    @Override
+//    public void uploadWJ(MultipartFile file, String fileType) throws IOException {
+//
+//        // 1. 校验文件非空
+//        if (file.isEmpty()) {
+//            throw new BizException(ErrorEnum.FILE_IS_EMPTY.getErrorCode(), ErrorEnum.FILE_IS_EMPTY.getErrorMessage());
+//        }
+//
+//        // 2. 校验文件类型参数
+//        if (StringUtils.isEmpty(fileType)) {
+//            throw new BizException(ErrorEnum.FILE_TYPE_IS_NULL.getErrorCode(), ErrorEnum.FILE_TYPE_IS_NULL.getErrorMessage());
+//        }
+//
+//        // 3. 获取原始文件名
+//        String originalFilename = file.getOriginalFilename();
+//
+//        String objectName = originalFilename;
+//        // 4. 调用封装好的上传方法
+//        String fileUrl = ossFileService.uploadFile(file, objectName);  // <<< 调用你的封装方法
+//
+//        // 5. 保存数据库记录
+//        TblOssFile ossFile = new TblOssFile();
+//        ossFile.setBusiType(fileType);
+//        ossFile.setBusiKey("0");
+//        ossFile.setFileName(originalFilename);
+//        ossFile.setOssUrl(fileUrl);  // <<< 存完整外链地址
+//        ossFileService.save(ossFile);
+//    }
+
 }
+

+ 2 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/UserGatewayImpl.java

@@ -595,6 +595,8 @@ public class UserGatewayImpl implements UserGateway {
         ossFileService.save(ossFile);
     }
 
+
+
     private boolean checkPngMagicNumber(byte[] fileHeader) {
         byte[] pngMagicNumber = {(byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
         return Arrays.equals(Arrays.copyOfRange(fileHeader, 0, 8), pngMagicNumber);

+ 2 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/mqtt/MqttSubHandle.java

@@ -173,7 +173,7 @@ public class MqttSubHandle {
                         eventListVO.setPose(pose);
                         eventListVO.setIsHandle(0);
                         eventListVO.setTargetPoints(targetPointsStr);
-                        eventListVO.setEvent(messageType);
+                        eventListVO.setEventType(messageType);
                         eventService.save(eventListVO);
                     }
                 }
@@ -355,7 +355,7 @@ public class MqttSubHandle {
                         eventListVO.setPose(pose);
                         eventListVO.setIsHandle(0);
                         eventListVO.setTargetPoints(targetPointsStr);
-                        eventListVO.setEvent(messageType);
+                        eventListVO.setEventType(messageType);
                         eventService.save(eventListVO);
                     }
                 }

+ 20 - 9
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/AlarmEvent.java

@@ -7,7 +7,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 /**
- * 停留时间
+ * 告警事件
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -17,20 +17,31 @@ public class AlarmEvent extends BasePO {
      * 主键ID
      */
     @TableId(type = IdType.ASSIGN_ID)
-    private Long stayTimeId;
+    private Long alarmEventId;
 
     /**
-     * dev_info表id
+     * 设备ID
      */
-    private Long devId;
+    private Long clientId;
 
-    private Byte pose;
+    /**
+     * 滞留时间表主键id
+     */
+    private Long stayTimeId;
 
-    private String targetPoints;
+    /**
+     * 姿势
+     */
+    private Byte pose;
 
-    private String event;
+    /**
+     * 事件类型
+     */
+    private Integer eventType;
 
-    private String desc;
+    /**
+     * 是否处理
+     */
+    private Integer isHandle ;
 
-    private Integer isHandle;
 } 

+ 2 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/EventList.java

@@ -8,7 +8,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 /**
- * 事件列表表
+ * 跌倒事件列表表
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -39,7 +39,7 @@ public class EventList extends BasePO {
     /**
      * 事件类型
      */
-    private Byte event;
+    private Byte eventType;
 
     /**
      * 是否处理:0-未处理,1-已处理

+ 12 - 5
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/po/StayTime.java

@@ -6,7 +6,7 @@ import lombok.EqualsAndHashCode;
 import java.time.LocalDateTime;
 
 /**
- * 留时间表
+ * 留时间表
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -19,6 +19,11 @@ public class StayTime extends BasePO {
     private Long stayTimeId;
 
     /**
+     * dev_info表id
+     */
+    private Long devId;
+
+    /**
      * 设备id
      */
     private String clientId;
@@ -28,10 +33,6 @@ public class StayTime extends BasePO {
      */
     private String devName;
 
-    /**
-     * dev_info表id
-     */
-    private Long devId;
 
     /**
      * 进入时间
@@ -47,4 +48,10 @@ public class StayTime extends BasePO {
      * 停留时长(秒)
      */
     private Integer stayTime;
+
+    /**
+     * 类型
+     */
+
+    private Integer type;
 } 

+ 2 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/OssFileService.java

@@ -12,4 +12,6 @@ public interface OssFileService extends IService<TblOssFile> {
 
 
     TblOssFile queryOneFile(String busiType, String busiKey);
+
+//    String uploadFile(MultipartFile file, String objectName) throws IOException;
 }

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/EventServiceImpl.java

@@ -19,7 +19,7 @@ public class EventServiceImpl extends ServiceImpl<EventListMapper, EventList> im
 
         // 2. 构建查询条件
         LambdaQueryWrapper<EventList> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(EventList::getDevId, devId).eq(EventList::getEvent, 3);
+        queryWrapper.eq(EventList::getDevId, devId).eq(EventList::getEventType, 3);
 
         // 3. 添加日期条件
         if (Objects.nonNull(start)) {

+ 89 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/OssFileServiceImpl.java

@@ -1,19 +1,37 @@
 package com.hfln.portal.infrastructure.service.impl;
 
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.model.ObjectMetadata;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hfln.portal.infrastructure.mapper.TblOssFileMapper;
 import com.hfln.portal.infrastructure.po.BasePO;
 import com.hfln.portal.infrastructure.po.TblOssFile;
 import com.hfln.portal.infrastructure.service.OssFileService;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.List;
 import java.util.Objects;
 
 @Service
 public class OssFileServiceImpl extends ServiceImpl<TblOssFileMapper, TblOssFile> implements OssFileService {
 
+    @Value("${oss.endpoint}")
+    private  String ENDPOINT;
+
+    @Value("${oss.accessKey.id}")
+    private String ACCESS_KEY_ID;
+
+    @Value("${oss.accessKey.secret}")
+    private String ACCESS_KEY_SECRET;
+
+    public String BUCKET_NAME = "hflnxx";
+
     @Override
     public List<TblOssFile> queryFile(String busiType, String busiKey) {
 
@@ -37,4 +55,75 @@ public class OssFileServiceImpl extends ServiceImpl<TblOssFileMapper, TblOssFile
         }
         return this.baseMapper.selectOne(queryWrapper);
     }
+
+//    /**
+//     * 上传文件到 OSS 并设置为 inline 显示
+//     * @return
+//     */
+//    @Override
+//    public String uploadFile(MultipartFile file, String objectName) throws IOException {
+//        // 1. 获取文件名后缀
+//        String originalFilename = file.getOriginalFilename();
+//        String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+//        // 2. 通过后缀获取 contentType
+//        String contentType = getContentType(suffix);
+//
+//
+//        OSS ossClient = new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
+//
+//        try (InputStream inputStream = file.getInputStream()) {
+//            ObjectMetadata metadata = new ObjectMetadata();
+//
+//            // 设置内容类型
+//            metadata.setContentType(contentType);
+//
+//            // 设置浏览器打开方式为 inline(非 attachment)
+//            metadata.setContentDisposition("inline");
+//
+//            // 上传文件
+//            ossClient.putObject(BUCKET_NAME, objectName, inputStream, metadata);
+//        } finally {
+//            ossClient.shutdown();
+//        }
+//
+//        // 返回文件的公网地址
+//        return "http://" +"static.radar-power.asia/" + objectName;
+//    }
+//
+//    public static String getContentType(String filenameExtension) {
+//        if (filenameExtension.equalsIgnoreCase(".bmp")) {
+//            return "image/bmp";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".gif")) {
+//            return "image/gif";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".jpeg") ||
+//                filenameExtension.equalsIgnoreCase(".jpg")) {
+//            return "image/jpeg";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".png")) {
+//            return "image/png";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".html")) {
+//            return "text/html";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".txt")) {
+//            return "text/plain";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".vsd")) {
+//            return "application/vnd.visio";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".pptx") ||
+//                filenameExtension.equalsIgnoreCase(".ppt")) {
+//            return "application/vnd.ms-powerpoint";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".docx") ||
+//                filenameExtension.equalsIgnoreCase(".doc")) {
+//            return "application/msword";
+//        }
+//        if (filenameExtension.equalsIgnoreCase(".xml")) {
+//            return "text/xml";
+//        }
+//        return "application/octet-stream";  // 默认类型(通用二进制)
+//    }
 }