فهرست منبع

更新校园预警代码

liu 2 سال پیش
والد
کامیت
dfee4974fc

+ 3 - 1
src/main/java/com/template/api/SmartFaceDiscernControllerAPI.java

@@ -1,6 +1,7 @@
 package com.template.api;
 
 import com.template.model.result.CommonResult;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -8,7 +9,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 @RequestMapping("/api/smartFaceDiscern")
 public interface SmartFaceDiscernControllerAPI {
 
-        @GetMapping(value = "/track")
+    @GetMapping(value = "/track")
+    @ApiOperation(value = "ѧÉú¹ì¼£", notes = "ѧÉú¹ì¼£", httpMethod = "GET")
     CommonResult track(@RequestParam Integer id, @RequestParam int dateTime);
 
 }

+ 6 - 4
src/main/java/com/template/api/SmartWarningControllerAPI.java

@@ -2,6 +2,7 @@ package com.template.api;
 
 import com.baomidou.mybatisplus.extension.api.R;
 import com.template.model.dto.OperationWarningDto;
+import com.template.model.dto.WarningDeletePushDto;
 import com.template.model.dto.WarningSavePushDto;
 import com.template.model.pojo.SmartWarning;
 import com.template.model.result.CommonResult;
@@ -12,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * @Author: binguo
@@ -60,7 +62,7 @@ public interface SmartWarningControllerAPI {
 
     @GetMapping(value = "/warningUserList")
     @ApiOperation(value = "预警推送用户分页", notes = "预警推送用户分页", httpMethod = "GET")
-    CommonResult warningUserList(@RequestParam int currentPage, @RequestParam int pageCount,Integer departmentId,String name);
+    CommonResult warningUserList(@RequestParam int currentPage, @RequestParam int pageCount,String name);
 
     @GetMapping(value = "/warningPushList")
     @ApiOperation(value = "可推送用户展示", notes = "预警推送用户分页", httpMethod = "GET")
@@ -70,9 +72,9 @@ public interface SmartWarningControllerAPI {
     @ApiOperation(value = "添加预警可推送用户", notes = "添加预警可推送用户", httpMethod = "POST")
     CommonResult warningSavePush(@RequestBody WarningSavePushDto warningSavePushDto);
 
-    @GetMapping(value = "/warningDeletePush")
-    @ApiOperation(value = "删除预警可推送用户", notes = "删除预警可推送用户", httpMethod = "GET")
-    CommonResult warningDeletePush(Integer id);
+    @PostMapping(value = "/warningDeletePush")
+    @ApiOperation(value = "删除预警可推送用户", notes = "删除预警可推送用户", httpMethod = "POST")
+    CommonResult warningDeletePush(@RequestBody WarningDeletePushDto warningDeletePushDto);
 
 
 }

+ 33 - 19
src/main/java/com/template/controller/SmartWarningController.java

@@ -10,7 +10,9 @@ import com.template.api.SmartWarningControllerAPI;
 import com.template.common.result.ResponseStatusEnum;
 import com.template.common.utils.*;
 import com.template.model.dto.OperationWarningDto;
+import com.template.model.dto.WarningDeletePushDto;
 import com.template.model.dto.WarningSavePushDto;
+import com.template.model.dto.WarningUserDto;
 import com.template.model.pojo.SmartDepartment;
 import com.template.model.pojo.SmartUser;
 import com.template.model.pojo.SmartWarning;
@@ -23,6 +25,7 @@ import com.template.services.SmartUserService;
 import com.template.services.SmartWarningService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RequestParam;
@@ -239,18 +242,18 @@ public class SmartWarningController implements SmartWarningControllerAPI {
     }
 
     @Override
-    public CommonResult warningUserList(int currentPage, int pageCount, Integer departmentId, String name) {
+    public CommonResult warningUserList(int currentPage, int pageCount, String name) {
         //获取该部门下的所有子级部门ID
-        List<Integer> childDepartmentIds = new ArrayList<>();
-        List<SmartDepartment> departments = smartDepartmentService.list(null);
-        childDepartmentIds.add(departmentId);
-        QueryDepartmentTreeRecords(departmentId, departments, childDepartmentIds);
-
-        if (departmentId == null) {
-            childDepartmentIds = null;
-        }
+//        List<Integer> childDepartmentIds = new ArrayList<>();
+//        List<SmartDepartment> departments = smartDepartmentService.list(null);
+//        childDepartmentIds.add(departmentId);
+//        QueryDepartmentTreeRecords(departmentId, departments, childDepartmentIds);
+//
+//        if (departmentId == null) {
+//            childDepartmentIds = null;
+//        }
 
-        PageUtils<UserVo> result = smartUserService.warningUserList(currentPage, pageCount, childDepartmentIds, name);
+        PageUtils<WarningUserDto> result = smartUserService.warningUserList(currentPage, pageCount, name);
         return CommonResult.ok(result);
     }
 
@@ -274,7 +277,7 @@ public class SmartWarningController implements SmartWarningControllerAPI {
         for (SmartUser smartUser : smartUsers) {
             String gzhOpenId = smartUser.getGzhOpenId();
             if (ObjectUtils.isEmpty(gzhOpenId)) {
-                return CommonResult.fail(smartUser.getName()+ "未关联公众号");
+                return CommonResult.fail(smartUser.getName() + "未关联公众号");
             }
             smartUser.setIsPush(1);
             smartUserService.updateSmartUser(smartUser);
@@ -284,20 +287,31 @@ public class SmartWarningController implements SmartWarningControllerAPI {
     }
 
     @Override
-    public CommonResult warningDeletePush(Integer id) {
+    public CommonResult warningDeletePush(WarningDeletePushDto warningDeletePushDto) {
+        List<Integer> ids = warningDeletePushDto.getIds();
 
-        if (ObjectUtils.isEmpty(id)) {
+        if (ObjectUtils.isEmpty(ids) && ids.size() == 0) {
             return CommonResult.fail();
         }
 
-        SmartUser smartById = smartUserService.getSmartById(id);
+        List<SmartUser> smartUserList = smartUserService.getSmartUserList(ids);
 
-        if (ObjectUtils.isEmpty(smartById)) {
-            return CommonResult.fail();
+        if (ObjectUtils.isEmpty(smartUserList)&&smartUserList.size()==0 ) {
+            return CommonResult.fail("无该用户");
         }
-        smartById.setIsPush(0);
-        int result = smartUserService.updateSmartUser(smartById);
-        return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");
+        ArrayList<SmartUser> smartUsers = new ArrayList<>();
+
+        for (SmartUser smartUser : smartUserList) {
+            smartUser.setIsPush(0);
+            smartUsers.add(smartUser);
+        }
+
+
+        boolean b = smartUserService.updateBatchById(smartUsers);
+        if (b) {
+            return CommonResult.ok("删除成功");
+        }
+        return CommonResult.fail("删除失败");
     }
 
 

+ 2 - 1
src/main/java/com/template/mapper/SmartUserMapper.java

@@ -1,6 +1,7 @@
 package com.template.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.template.model.dto.WarningUserDto;
 import com.template.model.pojo.SmartUser;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -31,7 +32,7 @@ public interface SmartUserMapper extends BaseMapper<SmartUser> {
 
     IPage<GradeVo> querySmartSecordPage(IPage<GradeVo> page, @Param("name") String name);
 
-    IPage<UserVo> warningUserList(Page<UserVo> page,@Param("departmentIds") List<Integer> departmentIds,@Param("name") String name);
+    IPage<WarningUserDto> warningUserList(Page<UserVo> page, @Param("name") String name);
 
     List<SmartUser> warningPushList();
 

+ 10 - 0
src/main/java/com/template/model/dto/WarningDeletePushDto.java

@@ -0,0 +1,10 @@
+package com.template.model.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class WarningDeletePushDto {
+    private List<Integer> ids;
+}

+ 19 - 0
src/main/java/com/template/model/dto/WarningUserDto.java

@@ -0,0 +1,19 @@
+package com.template.model.dto;
+
+import lombok.Data;
+
+@Data
+public class WarningUserDto {
+
+    private Integer id;
+
+    private String cardNo;
+
+    private String name;
+
+    private String departmentName;
+
+
+
+
+}

+ 51 - 0
src/main/java/com/template/model/pojo/SmartDataTaskErr.java

@@ -0,0 +1,51 @@
+package com.template.model.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 数据源操作日志
+ * </p>
+ *
+ * @author ceshi
+ * @since 2023-12-05
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="SmartDataTaskErr对象", description="数据源任务错误管理")
+public class SmartDataTaskErr implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键id")
+    @TableId(value = "e_id", type = IdType.AUTO)
+    private Integer eId;
+
+    @ApiModelProperty(value = "出错的任务id")
+    private Integer eTaskId;
+
+    @ApiModelProperty(value = "错误文本")
+    private String eMsg;
+
+    @ApiModelProperty(value = "发生错误次数")
+    private Integer eNum;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "发生错误时间")
+    private String eDateTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date eCreateTime;
+}

+ 5 - 2
src/main/java/com/template/services/SmartUserService.java

@@ -1,5 +1,6 @@
 package com.template.services;
 
+import com.template.model.dto.WarningUserDto;
 import com.template.model.pojo.SmartUser;
 import com.template.model.pojo.SmartUser;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -38,7 +39,7 @@ public interface SmartUserService extends IService<SmartUser> {
 
     int deleteSmartUserByIds(List<Integer> ids);
 
-    SmartUser getSmartById(int id);
+    List<SmartUser> getSmartUserList(List<Integer> ids);
 
     List<AffiliateUserVo> queryAffiliateUserById(@Param("id") Integer id);
 
@@ -51,7 +52,7 @@ public interface SmartUserService extends IService<SmartUser> {
     List<SmartUser> queryStudentDatas();
 	List<SmartUser> queryStudentBySchoolClass(Integer schoolClass);
 
-    PageUtils<UserVo> warningUserList(int currentPage, int pageCount, List<Integer> departmentIds, String name);
+    PageUtils<WarningUserDto> warningUserList(int currentPage, int pageCount, String name);
 
     List<SmartUser> warningPushList();
 
@@ -65,4 +66,6 @@ public interface SmartUserService extends IService<SmartUser> {
      * @return
      */
     SmartUser queryUserInfo(String name,String cardNo,String idCard);
+
+    SmartUser getSmartById(Integer id);
 }

+ 8 - 8
src/main/java/com/template/services/impl/SmartFaceDiscernServiceImpl.java

@@ -52,7 +52,7 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
     private Integer size = 20;
 
 //    @Scheduled(cron = "0 0/30 * * * ? ")
-    public void baiS()  {
+    public void baiS() {
         try {
             getFaceDiscern(page, size);
         } catch (Exception e) {
@@ -82,12 +82,13 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
         LocalDateTime endTime = now.withHour(23).withMinute(59).withSecond(59);
 //        开始时间
         data.put("record_begintime", stateTime.format(dateTimeFormatter1));
+//        data.put("record_begintime", "2024-01-22 00:00:00");
 //        结束时间
         data.put("record_endtime", endTime.format(dateTimeFormatter1));
-
+//        data.put("record_endtime", "2024-01-22 23:59:59");
 
         String dataString = data.toJSONString();
-        System.out.println(dataString);
+
 //        加密
         String aesStr = URLEncoder.encode(AesTestOne.encrypt(dataString, appSecret), "UTF-8");
 
@@ -159,14 +160,13 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
 //                    判断是否已经添加
                     LambdaQueryWrapper<SmartFaceDiscern> wrapperFD = new LambdaQueryWrapper<>();
                     wrapperFD.eq(SmartFaceDiscern::getDateTime, recordAddtime)
-                            .eq(SmartFaceDiscern::getId, smartUser.getId());
+                            .eq(SmartFaceDiscern::getUserId, smartUser.getId());
                     SmartFaceDiscern one = this.getOne(wrapperFD);
 
                     if (ObjectUtils.isEmpty(one)) {
                         this.save(smartFaceDiscern);
                     }
 
-
                 }
 
             }
@@ -177,9 +177,9 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
     @Override
     public List<SmartFaceDiscern> track(String stateTime, String endTime, Integer id) {
 
-        LambdaQueryWrapper<SmartFaceDiscern> wrapper=new LambdaQueryWrapper<>();
-        wrapper.between(SmartFaceDiscern::getDateTime,stateTime,endTime)
-                .eq(SmartFaceDiscern::getUserId,id)
+        LambdaQueryWrapper<SmartFaceDiscern> wrapper = new LambdaQueryWrapper<>();
+        wrapper.between(SmartFaceDiscern::getDateTime, stateTime, endTime)
+                .eq(SmartFaceDiscern::getUserId, id)
                 .orderByDesc(SmartFaceDiscern::getDateTime);
 
         List<SmartFaceDiscern> list = this.list(wrapper);

+ 13 - 3
src/main/java/com/template/services/impl/SmartUserServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.template.mapper.SmartUserMapper;
+import com.template.model.dto.WarningUserDto;
 import com.template.model.enumModel.eIdentityStatu;
 import com.template.model.pojo.SmartUser;
 import com.template.model.result.PageUtils;
@@ -144,7 +145,7 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
     }
 
     @Override
-    public SmartUser getSmartById(int id) {
+    public SmartUser getSmartById(Integer id) {
         QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
         queryWrapper.eq("is_cancel", 0);
         queryWrapper.eq("id", id);
@@ -168,11 +169,11 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
     }
 
     @Override
-    public PageUtils<UserVo> warningUserList(int currentPage, int pageCount, List<Integer> departmentIds, String name) {
+    public PageUtils<WarningUserDto> warningUserList(int currentPage, int pageCount, String name) {
         Page<UserVo> page = new Page<>();
         page.setCurrent(currentPage);
         page.setSize(pageCount);
-        IPage<UserVo> result = smartUserMapper.warningUserList(page, departmentIds, name);
+        IPage<WarningUserDto> result = smartUserMapper.warningUserList(page, name);
         return new PageUtils(result);
     }
 
@@ -197,4 +198,13 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
         return result;
     }
 
+    @Override
+    public List<SmartUser> getSmartUserList(List<Integer> ids) {
+        QueryWrapper<SmartUser> queryWrapper = new QueryWrapper();
+        queryWrapper.eq("is_cancel", 0);
+        queryWrapper.in("id", ids);
+        List<SmartUser> result = smartUserMapper.selectList(queryWrapper);
+        return result;
+    }
+
 }

+ 17 - 12
src/main/resources/mapper/template/SmartUserMapper.xml

@@ -117,22 +117,27 @@
         </if>
     </select>
 
-    <select id="warningUserList" resultType="com.template.model.vo.UserVo">
-        select *
-        from smart_user
-        where deleted = 0 and is_cancel = 0
-        <if test="departmentIds != null and departmentIds.size() > 0">
-            and department_id in
-            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
-                ${departmentId}
-            </foreach>
-        </if>
+    <select id="warningUserList" resultType="com.template.model.dto.WarningUserDto">
+        SELECT
+        su.id AS id,
+        su.`name` AS `name`,
+        su.card_no AS cardNo,
+        sd.`name` AS departmentName
+        FROM
+        `smart_user` su
+        LEFT JOIN smart_department sd ON sd.id = su.department_id and sd.deleted=0
+        where su.deleted = 0 and su.is_cancel = 0
         <if test="name != null and name != ''">
-            and name like '%' #{name} '%'
+            and su.`name` like '%' #{name} '%'
         </if>
     </select>
+
     <select id="warningPushList" resultType="com.template.model.pojo.SmartUser">
-        SELECT * FROM `smart_user` WHERE is_push=1 and is_cancel=0 and deleted = 0
+        SELECT *
+        FROM `smart_user`
+        WHERE is_push = 1
+          and is_cancel = 0
+          and deleted = 0
     </select>