Browse Source

更新最新代码

liu 2 years ago
parent
commit
6f3f4c9121

+ 13 - 0
src/main/java/com/template/api/SmartRelationControllerAPI.java

@@ -1,7 +1,20 @@
 package com.template.api;
 package com.template.api;
 
 
+import com.template.model.pojo.SmartSchool;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 
 
 @RequestMapping("/api/smartRelation")
 @RequestMapping("/api/smartRelation")
 public interface SmartRelationControllerAPI {
 public interface SmartRelationControllerAPI {
+
+    @PostMapping(value = "/getList")
+    @ApiOperation(value = "个人亲密度展示", notes = "个人亲密度展示", httpMethod = "GET")
+    CommonResult getList(@RequestParam int currentPage, @RequestParam int pageCount,@RequestParam Integer userId);
+
 }
 }

+ 12 - 0
src/main/java/com/template/controller/SmartRelationController.java

@@ -4,6 +4,8 @@ package com.template.controller;
 import com.template.annotation.DESRespondSecret;
 import com.template.annotation.DESRespondSecret;
 import com.template.api.SmartRelationControllerAPI;
 import com.template.api.SmartRelationControllerAPI;
 import com.template.model.pojo.SmartRelation;
 import com.template.model.pojo.SmartRelation;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
 import com.template.services.SmartRelationService;
 import com.template.services.SmartRelationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,5 +26,15 @@ public class SmartRelationController implements SmartRelationControllerAPI {
 
 
     @Autowired
     @Autowired
     SmartRelationService smartRelationService;
     SmartRelationService smartRelationService;
+
+
+    @Override
+    public CommonResult getList(int currentPage, int pageCount, Integer userId) {
+        PageUtils<SmartRelation> pageUtils=smartRelationService.getPage(currentPage,pageCount,userId);
+
+        return CommonResult.ok(pageUtils);
+    }
+
+
 }
 }
 
 

+ 2 - 0
src/main/java/com/template/mapper/SmartRelationMapper.java

@@ -2,6 +2,7 @@ package com.template.mapper;
 
 
 import com.template.model.pojo.SmartRelation;
 import com.template.model.pojo.SmartRelation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @author ceshi
  * @author ceshi
  * @since 2024-06-28
  * @since 2024-06-28
  */
  */
+@Repository
 public interface SmartRelationMapper extends BaseMapper<SmartRelation> {
 public interface SmartRelationMapper extends BaseMapper<SmartRelation> {
 
 
 }
 }

+ 3 - 0
src/main/java/com/template/model/pojo/SmartRelation.java

@@ -45,6 +45,9 @@ public class SmartRelation implements Serializable {
     @ApiModelProperty(value = "关联人名称")
     @ApiModelProperty(value = "关联人名称")
     private String relationName;
     private String relationName;
 
 
+    @ApiModelProperty(value = "时间")
+    private String dateTime;
+
     @ApiModelProperty(value = "次数")
     @ApiModelProperty(value = "次数")
     private Integer count;
     private Integer count;
 
 

+ 2 - 0
src/main/java/com/template/services/SmartRelationService.java

@@ -2,6 +2,7 @@ package com.template.services;
 
 
 import com.template.model.pojo.SmartRelation;
 import com.template.model.pojo.SmartRelation;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.template.model.result.PageUtils;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface SmartRelationService extends IService<SmartRelation> {
 public interface SmartRelationService extends IService<SmartRelation> {
 
 
+    PageUtils<SmartRelation> getPage(int currentPage, int pageCount, Integer userId);
 }
 }

+ 27 - 2
src/main/java/com/template/services/impl/SmartRelationServiceImpl.java

@@ -2,13 +2,18 @@ package com.template.services.impl;
 
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.template.config.ScheduleConfig;
 import com.template.config.ScheduleConfig;
+import com.template.model.dto.WarningUserDto;
 import com.template.model.pojo.SmartAccess;
 import com.template.model.pojo.SmartAccess;
 import com.template.model.pojo.SmartFaceDiscern;
 import com.template.model.pojo.SmartFaceDiscern;
 import com.template.model.pojo.SmartRelation;
 import com.template.model.pojo.SmartRelation;
 import com.template.mapper.SmartRelationMapper;
 import com.template.mapper.SmartRelationMapper;
 import com.template.model.pojo.SmartUser;
 import com.template.model.pojo.SmartUser;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.UserVo;
 import com.template.services.SmartAccessService;
 import com.template.services.SmartAccessService;
 import com.template.services.SmartFaceDiscernService;
 import com.template.services.SmartFaceDiscernService;
 import com.template.services.SmartRelationService;
 import com.template.services.SmartRelationService;
@@ -47,6 +52,9 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
     @Autowired
     @Autowired
     SmartUserService smartUserService;
     SmartUserService smartUserService;
 
 
+    @Autowired
+    SmartRelationMapper smartRelationMapper;
+
     @Async
     @Async
     @Scheduled(cron = "0 0 1 * * ? ")//每天凌晨一点
     @Scheduled(cron = "0 0 1 * * ? ")//每天凌晨一点
     public void getAccessSmartRelation() {
     public void getAccessSmartRelation() {
@@ -55,6 +63,7 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
             LocalDateTime now = LocalDateTime.now();
             LocalDateTime now = LocalDateTime.now();
             LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
             LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
             LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
             LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
+            String format = start.format(pattern);
 //            找到昨天的所有数据
 //            找到昨天的所有数据
             List<SmartAccess> accessList = smartAccessService.toDatelist(start, end);
             List<SmartAccess> accessList = smartAccessService.toDatelist(start, end);
 
 
@@ -74,7 +83,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
 //                        判断是否已添加,有的话则加1
 //                        判断是否已添加,有的话则加1
                         LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
                         LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
                         wrapper.eq(SmartRelation::getUserId, userId)
                         wrapper.eq(SmartRelation::getUserId, userId)
-                                .eq(SmartRelation::getRelationId, userId1);
+                                .eq(SmartRelation::getRelationId, userId1)
+                                .eq(SmartRelation::getDateTime,format);
                         SmartRelation one = this.getOne(wrapper);
                         SmartRelation one = this.getOne(wrapper);
                         if (ObjectUtils.isEmpty(one)) {
                         if (ObjectUtils.isEmpty(one)) {
                             SmartRelation smartRelation = new SmartRelation();
                             SmartRelation smartRelation = new SmartRelation();
@@ -87,6 +97,7 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
                                 smartRelation.setRelationName(smartById.getName());
                                 smartRelation.setRelationName(smartById.getName());
                             }
                             }
                             smartRelation.setCount(0);
                             smartRelation.setCount(0);
+                            smartRelation.setDateTime(format);
                             this.save(smartRelation);
                             this.save(smartRelation);
                         } else {
                         } else {
                             Integer count = one.getCount();
                             Integer count = one.getCount();
@@ -112,6 +123,9 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
             LocalDateTime now = LocalDateTime.now();
             LocalDateTime now = LocalDateTime.now();
             LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
             LocalDateTime start = now.withHour(0).withMinute(0).withSecond(0).minusDays(1);
             LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
             LocalDateTime end = now.withHour(23).withMinute(59).withSecond(59).minusDays(1);
+
+            String format = start.format(pattern);
+
 //            找到昨天的所有数据
 //            找到昨天的所有数据
             List<SmartFaceDiscern> faceDiscernList = smartFaceDiscernService.toDateList(start, end);
             List<SmartFaceDiscern> faceDiscernList = smartFaceDiscernService.toDateList(start, end);
 
 
@@ -131,7 +145,8 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
 //                        判断是否已添加,有的话则加1
 //                        判断是否已添加,有的话则加1
                         LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
                         LambdaQueryWrapper<SmartRelation> wrapper = new LambdaQueryWrapper<>();
                         wrapper.eq(SmartRelation::getUserId, userId)
                         wrapper.eq(SmartRelation::getUserId, userId)
-                                .eq(SmartRelation::getRelationId, userId1);
+                                .eq(SmartRelation::getRelationId, userId1)
+                                .eq(SmartRelation::getDateTime,format);
                         SmartRelation one = this.getOne(wrapper);
                         SmartRelation one = this.getOne(wrapper);
                         if (ObjectUtils.isEmpty(one)) {
                         if (ObjectUtils.isEmpty(one)) {
                             SmartRelation smartRelation = new SmartRelation();
                             SmartRelation smartRelation = new SmartRelation();
@@ -143,6 +158,7 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
                             if (ObjectUtils.isNotEmpty(smartById)) {
                             if (ObjectUtils.isNotEmpty(smartById)) {
                                 smartRelation.setRelationName(smartById.getName());
                                 smartRelation.setRelationName(smartById.getName());
                             }
                             }
+                            smartRelation.setDateTime(format);
                             smartRelation.setCount(0);
                             smartRelation.setCount(0);
                             this.save(smartRelation);
                             this.save(smartRelation);
                         } else {
                         } else {
@@ -162,4 +178,13 @@ public class SmartRelationServiceImpl extends ServiceImpl<SmartRelationMapper, S
     }
     }
 
 
 
 
+    @Override
+    public PageUtils<SmartRelation> getPage(int currentPage, int pageCount, Integer userId) {
+//        Page<UserVo> page = new Page<>();
+//        page.setCurrent(currentPage);
+//        page.setSize(pageCount);
+//        IPage<WarningUserDto> result = smartUserMapper.warningUserList(page, name);
+//        return new PageUtils(result);
+        return null;
+    }
 }
 }

+ 1 - 1
src/main/resources/mapper/template/SmartCarAccessMapper.xml

@@ -21,7 +21,7 @@
         <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
         <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
             and sca.data_time &gt;= #{startTime} and sca.data_time &lt;= #{endTime}
             and sca.data_time &gt;= #{startTime} and sca.data_time &lt;= #{endTime}
         </if>
         </if>
-        ORDER BY sca.date_time DESC
+        ORDER BY sca.data_time DESC
 
 
     </select>
     </select>
 </mapper>
 </mapper>