Browse Source

智能场景-智会议统计分析、会议总数、会议总次数、总人次、总时长柱状图接口
智能场景-访客管理

ZhangManMan 2 years ago
parent
commit
3ee953da93
24 changed files with 572 additions and 40 deletions
  1. 1 1
      src/main/java/com/sky/ioc/config/RestTemplateConfig.java
  2. 31 1
      src/main/java/com/sky/ioc/controller/scene/MeetingRoomController.java
  3. 28 0
      src/main/java/com/sky/ioc/controller/scene/SecurityController.java
  4. 4 4
      src/main/java/com/sky/ioc/controller/security/PersonController.java
  5. 22 0
      src/main/java/com/sky/ioc/entity/domain/space/Department.java
  6. 48 0
      src/main/java/com/sky/ioc/entity/params/scene/DoorAccessParam.java
  7. 43 0
      src/main/java/com/sky/ioc/entity/params/scene/ParkParam.java
  8. 1 2
      src/main/java/com/sky/ioc/entity/params/security/PersonParam.java
  9. 14 0
      src/main/java/com/sky/ioc/job/MeetingRecordJob.java
  10. 1 1
      src/main/java/com/sky/ioc/mapper/SecurityPersonMapper.java
  11. 27 0
      src/main/java/com/sky/ioc/mapper/meeting/MeetingRecordMapper.java
  12. 48 0
      src/main/java/com/sky/ioc/mapper/security/SecurityDoorRecordMapper.java
  13. 9 0
      src/main/java/com/sky/ioc/mapper/space/DepartmentMapper.java
  14. 11 0
      src/main/java/com/sky/ioc/service/meeting/MeetingRecordService.java
  15. 121 0
      src/main/java/com/sky/ioc/service/meeting/impl/MeetingRecordServiceImpl.java
  16. 0 1
      src/main/java/com/sky/ioc/service/parking/impl/ParkingServiceImpl.java
  17. 3 0
      src/main/java/com/sky/ioc/service/security/SecurityDoorRecordService.java
  18. 1 2
      src/main/java/com/sky/ioc/service/security/SecurityPersonService.java
  19. 33 1
      src/main/java/com/sky/ioc/service/security/impl/SecurityDoorRecordServiceImpl.java
  20. 1 4
      src/main/java/com/sky/ioc/service/security/impl/SecurityPersonServiceImpl.java
  21. 8 0
      src/main/java/com/sky/ioc/service/space/DepartmentService.java
  22. 70 0
      src/main/java/com/sky/ioc/service/space/impl/DepartmentServiceImpl.java
  23. 7 23
      src/main/java/com/sky/ioc/service/supermarket/impl/SupermarketServiceImpl.java
  24. 40 0
      src/main/java/com/sky/ioc/tool/MathUtils.java

+ 1 - 1
src/main/java/com/sky/ioc/config/RestTemplateConfig.java

@@ -64,7 +64,7 @@ public class RestTemplateConfig {
             return url;
         }
         url = StringUtils.removeStart(url, "/");
-        String baseUrl = StringUtils.appendIfMissing(dataIp, "/");
+        String baseUrl = StringUtils.appendIfMissing("http://"+dataIp, "/");
         return baseUrl + url;
     }
 }

+ 31 - 1
src/main/java/com/sky/ioc/controller/scene/MeetingRoomController.java

@@ -3,7 +3,9 @@ package com.sky.ioc.controller.scene;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.sky.ioc.entity.params.IocParam;
+import com.sky.ioc.entity.params.IocTimeRange;
 import com.sky.ioc.mapper.job.TokenMapper;
+import com.sky.ioc.service.meeting.MeetingRecordService;
 import com.sky.ioc.service.meeting.MeetingRoomService;
 import com.sky.ioc.tool.ReturnMsg;
 import io.swagger.annotations.Api;
@@ -18,7 +20,7 @@ import org.springframework.web.client.RestTemplate;
 
 import java.util.Map;
 
-@Api(tags ="智慧场景----配置会议")
+@Api(tags ="智慧场景----会议")
 @Slf4j
 @RestController
 @RequestMapping("/meetingroom")
@@ -26,10 +28,38 @@ public class MeetingRoomController {
 
     @Autowired
     MeetingRoomService meetingRoomService;
+
+    @Autowired
+    MeetingRecordService meetingRecordService;
+
     @ApiOperation("会议室总览")
     @PostMapping("/getMeetingRoomList")
     public ReturnMsg getMeetingRoomList(@RequestParam(value = "date", required=false)String date){
         return meetingRoomService.getMeetingRoomStatus(date);
     }
 
+
+    @ApiOperation("统计分析--会议总数")
+    @PostMapping("/getMeetingTotal")
+    public ReturnMsg getMeetingTotal(@RequestBody IocTimeRange iocTimeRange){
+        return meetingRecordService.getMeetingRecordTotal(iocTimeRange);
+    }
+
+
+    @ApiOperation("统计分析--会议总次数")
+    @PostMapping("/getMeetingTimes")
+    public ReturnMsg getMeetingTimes(@RequestBody IocTimeRange iocTimeRange){
+        return meetingRecordService.getMeetingAnalysissTimes(iocTimeRange);
+    }
+
+    @ApiOperation("统计分析--会议总人次")
+    @PostMapping("/getMeetingPersons")
+    public ReturnMsg getMeetingPersons(@RequestBody IocTimeRange iocTimeRange){
+        return meetingRecordService.getMeetingAnalysissPerson(iocTimeRange);
+    }
+    @ApiOperation("统计分析--会议时长")
+    @PostMapping("/getMeetingMinutes")
+    public ReturnMsg getMeetingMinutes(@RequestBody IocTimeRange iocTimeRange){
+        return meetingRecordService.getMeetingAnalysissMinutes(iocTimeRange);
+    }
 }

+ 28 - 0
src/main/java/com/sky/ioc/controller/scene/SecurityController.java

@@ -0,0 +1,28 @@
+package com.sky.ioc.controller.scene;
+
+import com.sky.ioc.entity.domain.security.SecurityDoorRecord;
+import com.sky.ioc.entity.params.scene.DoorAccessParam;
+import com.sky.ioc.service.security.SecurityDoorRecordService;
+import com.sky.ioc.tool.ReturnMsg;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags ="智慧场景----智安防")
+@Slf4j
+@RestController
+@RequestMapping("/security")
+public class SecurityController {
+
+    @Autowired
+    SecurityDoorRecordService securityDoorRecordService;
+
+    @ApiOperation("门禁管理")
+    @PostMapping("/getDoorAccessList")
+    public ReturnMsg getDoorAccessList(@RequestBody DoorAccessParam doorAccessParam){
+        return securityDoorRecordService.pageList(doorAccessParam);
+    }
+
+}

+ 4 - 4
src/main/java/com/sky/ioc/controller/security/PersonController.java

@@ -1,8 +1,9 @@
 package com.sky.ioc.controller.security;
 
+import com.sky.ioc.entity.domain.security.SecurityDoor;
 import com.sky.ioc.entity.domain.security.SecurityDoorRecord;
 import com.sky.ioc.entity.params.IocParam;
-import com.sky.ioc.entity.params.Security.PersonParam;
+import com.sky.ioc.entity.params.security.PersonParam;
 import com.sky.ioc.service.personnel.PersonnelService;
 import com.sky.ioc.service.security.SecurityDoorRecordService;
 import com.sky.ioc.service.security.SecurityDoorService;
@@ -13,7 +14,6 @@ import com.sky.ioc.tool.ReturnMsg;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -70,12 +70,12 @@ public class PersonController {
     }
 
     @Autowired
-    BuildingFloorService buildingFloorService;
+    SecurityDoorRecordService securityDoorRecordService;
 
     @ApiOperation("门禁数据")
     @PostMapping("/getDoor")
     public ReturnMsg getDoor(){
-        return buildingFloorService.getBuildingFloorList();
+        return securityDoorRecordService.getSecurityDoorRecordData();
     }
 
 

+ 22 - 0
src/main/java/com/sky/ioc/entity/domain/space/Department.java

@@ -0,0 +1,22 @@
+package com.sky.ioc.entity.domain.space;
+
+import lombok.Data;
+
+@Data
+public class Department {
+    private Integer id;
+
+    private String name;
+
+    private String oriId;
+
+    private String fullName;
+
+    private Integer sort;
+
+    private String code;
+
+    private String parentId;
+
+    private Integer companyId;
+}

+ 48 - 0
src/main/java/com/sky/ioc/entity/params/scene/DoorAccessParam.java

@@ -0,0 +1,48 @@
+package com.sky.ioc.entity.params.scene;
+
+import lombok.Data;
+
+@Data
+public class DoorAccessParam {
+
+    /**
+     * 人员类型
+     *  1自有员工 2协作员工 3访客
+     * */
+    private Integer type;
+
+    /**姓名*/
+    private String name;
+
+    /**
+     * 设备名称
+     * */
+    private String equipment;
+    /**
+     * 分页数
+     */
+    private Integer pageSize =10;
+
+    /**
+     * 分页数
+     */
+    private Integer pageStart =0;
+
+    /** 开始时间 */
+    private String startTime;
+
+    /** 结束时间 */
+    private String endTime;
+
+    /**
+     *通行方向
+     * 1 进
+     * 2 出
+     */
+    private Integer direction;
+
+    /**
+     * 部门id
+     * */
+    private Integer deptId;
+}

+ 43 - 0
src/main/java/com/sky/ioc/entity/params/scene/ParkParam.java

@@ -0,0 +1,43 @@
+package com.sky.ioc.entity.params.scene;
+
+import lombok.Data;
+
+@Data
+public class ParkParam {
+
+    /**
+     * 支付方式
+     *  1手机支付 2人工 3年卡
+     * */
+    private Integer paytype;
+
+    /**
+     *订单状态
+     * 1 待支付
+     * 2 已支付
+     */
+    private Integer orderStatus;
+
+    /**
+     * 车牌号
+     * */
+    private String carCode;
+
+    /**
+     * 分页数
+     */
+    private Integer pageSize =10;
+
+    /**
+     * 分页数
+     */
+    private Integer pageStart =0;
+
+    /** 开始时间 */
+    private String startTime;
+
+    /** 结束时间 */
+    private String endTime;
+
+
+}

+ 1 - 2
src/main/java/com/sky/ioc/entity/params/Security/PersonParam.java → src/main/java/com/sky/ioc/entity/params/security/PersonParam.java

@@ -1,6 +1,5 @@
-package com.sky.ioc.entity.params.Security;
+package com.sky.ioc.entity.params.security;
 
-import com.sky.ioc.entity.params.IocTimeRange;
 import lombok.Data;
 
 @Data

+ 14 - 0
src/main/java/com/sky/ioc/job/MeetingRecordJob.java

@@ -2,7 +2,9 @@ package com.sky.ioc.job;
 
 import com.sky.ioc.service.parking.ParkService;
 import com.sky.ioc.service.meeting.MeetingRecordService;
+import com.sky.ioc.service.parking.ParkingService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -19,11 +21,23 @@ public class MeetingRecordJob implements Job {
     @Autowired
     ParkService parkService;
 
+    @Autowired
+    ParkingService parkingService;
+
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         log.info(String.format("同步会议数据!  时间:" + new Date()));
         recordService.getMeetingRecordList();
         log.info(String.format("同步停车数据!  时间:" + new Date()));
         parkService.getParkData();
+        log.info(String.format("同步车位数据!  时间:" + new Date()));
+        parkingService.getParkingData();
+    }
+
+    public static void main(String[] args) {
+        String url ="/api/meeting/MEETING/record/list";
+        url = StringUtils.removeStart(url, "/");
+        String baseUrl = StringUtils.appendIfMissing("http://"+"192.168.1.45:9001", "/");
+        System.out.println(baseUrl+url);
     }
 }

+ 1 - 1
src/main/java/com/sky/ioc/mapper/SecurityPersonMapper.java

@@ -2,7 +2,7 @@ package com.sky.ioc.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sky.ioc.entity.domain.security.SecurityPerson;
-import com.sky.ioc.entity.params.Security.PersonParam;
+import com.sky.ioc.entity.params.security.PersonParam;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;

+ 27 - 0
src/main/java/com/sky/ioc/mapper/meeting/MeetingRecordMapper.java

@@ -3,6 +3,7 @@ package com.sky.ioc.mapper.meeting;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sky.ioc.entity.domain.meeting.MeetingRecord;
 import com.sky.ioc.entity.params.IocParam;
+import com.sky.ioc.entity.params.IocTimeRange;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -27,4 +28,30 @@ public interface MeetingRecordMapper extends BaseMapper<MeetingRecord> {
                                                @Param("endTime") String endTime,
                                                @Param("roomId") Integer roomId);
 
+
+    @Select("<script> " +
+            "SELECT count(1) FROM meeting_record  where 1=1 " +
+            "<if test='timeRange!=null and timeRange.startDate!=null  '>" +
+            "<![CDATA[ and start_time >= #{timeRange.startDate} " +
+            " AND end_time <= #{timeRange.endDate} ]]> " +
+            "</if>" +
+            "</script>")
+    Long  countByTime(@Param("timeRange") IocTimeRange timeRange);
+    @Select("<script> " +
+            "SELECT coalesce(sum(person_num),0) FROM meeting_record  where 1=1 " +
+            "<if test='timeRange!=null and timeRange.startDate!=null  '>" +
+            "<![CDATA[ and start_time >= #{timeRange.startDate} " +
+            " AND end_time <= #{timeRange.endDate} ]]> " +
+            "</if>" +
+            " </script>")
+    Long  totalPersonByTime(@Param("timeRange") IocTimeRange timeRange);
+
+    @Select("<script> " +
+            "SELECT coalesce(sum(minutes),0) FROM meeting_record  where 1=1 " +
+            "<if test='timeRange!=null and timeRange.startDate!=null  '>" +
+            "<![CDATA[ and start_time >= #{timeRange.startDate} " +
+            " AND end_time <= #{timeRange.endDate} ]]> " +
+            "</if>" +
+            " </script>")
+    Long  totalMinutesByTime(@Param("timeRange") IocTimeRange timeRange);
 }

+ 48 - 0
src/main/java/com/sky/ioc/mapper/security/SecurityDoorRecordMapper.java

@@ -2,8 +2,56 @@ package com.sky.ioc.mapper.security;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sky.ioc.entity.domain.security.SecurityDoorRecord;
+import com.sky.ioc.entity.params.scene.DoorAccessParam;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface SecurityDoorRecordMapper extends BaseMapper<SecurityDoorRecord> {
+
+    @Select("<script>" +
+            "SELECT record.id, record.name,record.time,door.name as doorName,record.dept_id as deptId " +
+            "from  security_door_record record " +
+            "LEFT JOIN security_door door on record.door_id = door.id " +
+            "where 1=1 " +
+            "<if test='doorAccessParam!=null and doorAccessParam.startTime!=null'>" +
+            " and record.time BETWEEN  #{doorAccessParam.startTime} AND #{doorAccessParam.endTime}" +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.name!=\"\" and doorAccessParam.name!=null'>" +
+            " and record.name like #{doorAccessParam.name} " +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.equipment!=\"\" and doorAccessParam.equipment!=null'>" +
+            " and door.name like #{doorAccessParam.equipment} " +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.deptId!=null'>" +
+            " and record.dept_id = #{doorAccessParam.deptId} " +
+            "</if>" +
+            "ORDER BY record.id " +
+            "limit #{doorAccessParam.pageSize} OFFSET  #{doorAccessParam.pageStart}" +
+            "</script>")
+    List<Map<String,Object>> pageList(@Param("doorAccessParam")DoorAccessParam doorAccessParam);
+
+    @Select("<script>" +
+            "SELECT count(1) " +
+            "from  security_door_record record " +
+            "LEFT JOIN security_door door on record.door_id = door.id " +
+            "where 1=1 " +
+            "<if test='doorAccessParam!=null and doorAccessParam.startTime!=null'>" +
+            " and record.time between #{doorAccessParam.startTime} and #{doorAccessParam.endTime}" +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.name!=\"\" and doorAccessParam.name!=null'>" +
+            " and record.name like #{doorAccessParam.name} " +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.equipment!=\"\" and doorAccessParam.equipment!=null'>" +
+            " and door.name like #{doorAccessParam.equipment} " +
+            "</if>" +
+            "<if test='doorAccessParam!=null and doorAccessParam.deptId!=null'>" +
+            " and record.dept_id = #{doorAccessParam.deptId} " +
+            "</if>" +
+            "</script>")
+    Long  pageCount(@Param("doorAccessParam")DoorAccessParam doorAccessParam);
 }

+ 9 - 0
src/main/java/com/sky/ioc/mapper/space/DepartmentMapper.java

@@ -0,0 +1,9 @@
+package com.sky.ioc.mapper.space;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sky.ioc.entity.domain.space.Department;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface DepartmentMapper extends BaseMapper<Department> {
+}

+ 11 - 0
src/main/java/com/sky/ioc/service/meeting/MeetingRecordService.java

@@ -2,6 +2,7 @@ package com.sky.ioc.service.meeting;
 
 import com.sky.ioc.entity.domain.meeting.MeetingRecord;
 import com.sky.ioc.entity.params.IocParam;
+import com.sky.ioc.entity.params.IocTimeRange;
 import com.sky.ioc.tool.ReturnMsg;
 
 import java.util.List;
@@ -16,4 +17,14 @@ public interface MeetingRecordService {
     List<MeetingRecord> queryMeetingList(IocParam iocParam);
 
     ReturnMsg getMeetingRecordList();
+
+
+    ReturnMsg getMeetingRecordTotal(IocTimeRange timeRange);
+
+    ReturnMsg getMeetingAnalysissTimes(IocTimeRange iocTimeRange);
+
+    ReturnMsg getMeetingAnalysissPerson(IocTimeRange iocTimeRange);
+    ReturnMsg getMeetingAnalysissMinutes(IocTimeRange iocTimeRange);
+
+
 }

+ 121 - 0
src/main/java/com/sky/ioc/service/meeting/impl/MeetingRecordServiceImpl.java

@@ -1,12 +1,18 @@
 package com.sky.ioc.service.meeting.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sky.ioc.config.RestTemplateConfig;
+import com.sky.ioc.entity.Indeicator;
+import com.sky.ioc.entity.Label;
 import com.sky.ioc.entity.domain.meeting.MeetingRecord;
 import com.sky.ioc.entity.params.IocParam;
+import com.sky.ioc.entity.params.IocTimeRange;
 import com.sky.ioc.mapper.job.TokenMapper;
 import com.sky.ioc.mapper.meeting.MeetingRecordMapper;
 import com.sky.ioc.service.meeting.MeetingRecordService;
+import com.sky.ioc.tool.DateUtil;
+import com.sky.ioc.tool.MathUtils;
 import com.sky.ioc.tool.ReturnMsg;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +21,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
+import java.text.DecimalFormat;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -99,4 +107,117 @@ public class MeetingRecordServiceImpl implements MeetingRecordService {
         }
 
     }
+
+    @Override
+    public ReturnMsg getMeetingRecordTotal(IocTimeRange timeRange) {
+        Indeicator indeicator = new Indeicator();
+        List<JSONObject> objects = new ArrayList<>();
+        objects.add(new JSONObject());
+        objects.add(new JSONObject());
+        objects.add(new JSONObject());
+        objects.add(new JSONObject());
+        objects.add(new JSONObject());
+        objects.add(new JSONObject());
+        Integer days = 0;
+        try {
+            days = DateUtil.daysBetween(timeRange.getStartDate(),timeRange.getEndDate());
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+        //总会议数
+        Long totalMeeting = meetingRecordMapper.countByTime(timeRange);
+        //总会议人次
+        Long totalPerson = meetingRecordMapper.totalPersonByTime(timeRange);
+        //总会议时长
+        Long totalMinutes = 0l;
+                //meetingRecordMapper.totalMinutesByTime(timeRange);
+        double avgMeeting = MathUtils.division(totalMeeting,days,2);
+        double avgPerson = MathUtils.division(totalMeeting,totalPerson,2);
+        double avgMinutes = MathUtils.division(totalMinutes,totalMeeting,2);
+        objects.get(0).put("value", totalMeeting);
+        objects.get(1).put("value", avgMeeting);
+        objects.get(2).put("value", totalPerson);
+        objects.get(3).put("value", avgPerson);
+        objects.get(4).put("value", totalMinutes);
+        objects.get(5).put("value", avgMinutes);
+        indeicator.setList(objects);
+        return ReturnMsg.ok(indeicator);
+    }
+
+    /**
+     * 统计总次数
+     * */
+    @Override
+    public ReturnMsg getMeetingAnalysissTimes(IocTimeRange iocTimeRange) {
+        String[] param = {"times"};
+        String startStr = iocTimeRange.getStartDate();
+        String endStr = iocTimeRange.getEndDate();
+        List<String> list = DateUtil.getBetweenDays(startStr, endStr);
+        String[] labKey = list.toArray(new String[0]);
+        List<Label> labels1 = new ArrayList<>();
+        for (int i = 0; i < labKey.length; i++) {
+            Label label = new Label();
+            JSONObject jsonObject = new JSONObject();
+            IocTimeRange iocTimeRange1 = new IocTimeRange();
+            iocTimeRange1.setStartDate(labKey[i]+" 00:00:00");
+            iocTimeRange1.setEndDate(labKey[i]+" 23:59:00");
+            long times = meetingRecordMapper.countByTime(iocTimeRange1);
+            jsonObject.put(param[0],times);
+            label.setJsonObject(jsonObject);
+            label.setLabel(labKey[i]);
+            labels1.add(label);
+        }
+        return ReturnMsg.ok(labels1);
+    }
+    /**
+     * 统计总人次
+     * */
+    @Override
+    public ReturnMsg getMeetingAnalysissPerson(IocTimeRange iocTimeRange) {
+        String[] param = {"person"};
+        String startStr = iocTimeRange.getStartDate();
+        String endStr = iocTimeRange.getEndDate();
+        List<String> list = DateUtil.getBetweenDays(startStr, endStr);
+        String[] labKey = list.toArray(new String[0]);
+        List<Label> labels1 = new ArrayList<>();
+        for (int i = 0; i < labKey.length; i++) {
+            Label label = new Label();
+            JSONObject jsonObject = new JSONObject();
+            IocTimeRange iocTimeRange1 = new IocTimeRange();
+            iocTimeRange1.setStartDate(labKey[i]+" 00:00:00");
+            iocTimeRange1.setEndDate(labKey[i]+" 23:59:00");
+            long person = meetingRecordMapper.totalPersonByTime(iocTimeRange1);
+            jsonObject.put(param[0],person);
+            label.setJsonObject(jsonObject);
+            label.setLabel(labKey[i]);
+            labels1.add(label);
+        }
+        return ReturnMsg.ok(labels1);
+    }
+    /**
+     * 统计总时长
+     * */
+    @Override
+    public ReturnMsg getMeetingAnalysissMinutes(IocTimeRange iocTimeRange) {
+        String[] param = {"minutes"};
+        String startStr = iocTimeRange.getStartDate();
+        String endStr = iocTimeRange.getEndDate();
+        List<String> list = DateUtil.getBetweenDays(startStr, endStr);
+        String[] labKey = list.toArray(new String[0]);
+        List<Label> labels1 = new ArrayList<>();
+        for (int i = 0; i < labKey.length; i++) {
+            Label label = new Label();
+            JSONObject jsonObject = new JSONObject();
+            IocTimeRange iocTimeRange1 = new IocTimeRange();
+            iocTimeRange1.setStartDate(labKey[i]+" 00:00:00");
+            iocTimeRange1.setEndDate(labKey[i]+" 23:59:00");
+            long minutes = 0;
+                    //meetingRecordMapper.totalMinutesByTime(iocTimeRange1);
+            jsonObject.put(param[0],minutes);
+            label.setJsonObject(jsonObject);
+            label.setLabel(labKey[i]);
+            labels1.add(label);
+        }
+        return ReturnMsg.ok(labels1);
+    }
 }

+ 0 - 1
src/main/java/com/sky/ioc/service/parking/impl/ParkingServiceImpl.java

@@ -198,7 +198,6 @@ public class ParkingServiceImpl implements ParkingService {
         // 获取响应信息
         String message = (String)body.get("msg");
         if(code==200){
-            ThreadLocalRandom random = ThreadLocalRandom.current();
             ArrayList list = (ArrayList) body.get("rows");
             if(list!=null&&list.size()>0){
                 parkingMapper.delete(null);

+ 3 - 0
src/main/java/com/sky/ioc/service/security/SecurityDoorRecordService.java

@@ -1,8 +1,11 @@
 package com.sky.ioc.service.security;
 
+import com.sky.ioc.entity.params.scene.DoorAccessParam;
 import com.sky.ioc.tool.ReturnMsg;
 
 public interface SecurityDoorRecordService {
 
     ReturnMsg getSecurityDoorRecordData();
+
+    ReturnMsg pageList(DoorAccessParam doorAccessParam);
 }

+ 1 - 2
src/main/java/com/sky/ioc/service/security/SecurityPersonService.java

@@ -1,7 +1,6 @@
 package com.sky.ioc.service.security;
 
-import com.sky.ioc.entity.params.IocParam;
-import com.sky.ioc.entity.params.Security.PersonParam;
+import com.sky.ioc.entity.params.security.PersonParam;
 import com.sky.ioc.tool.ReturnMsg;
 
 public interface SecurityPersonService {

+ 33 - 1
src/main/java/com/sky/ioc/service/security/impl/SecurityDoorRecordServiceImpl.java

@@ -1,9 +1,14 @@
 package com.sky.ioc.service.security.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.sky.ioc.config.RestTemplateConfig;
 import com.sky.ioc.entity.domain.security.SecurityDoorRecord;
+import com.sky.ioc.entity.domain.space.Department;
+import com.sky.ioc.entity.params.scene.DoorAccessParam;
 import com.sky.ioc.mapper.security.SecurityDoorRecordMapper;
+import com.sky.ioc.mapper.space.DepartmentMapper;
 import com.sky.ioc.service.security.SecurityDoorRecordService;
+import com.sky.ioc.service.space.DepartmentService;
 import com.sky.ioc.tool.ReturnMsg;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +18,7 @@ import org.springframework.web.client.RestTemplate;
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ThreadLocalRandom;
 
@@ -25,9 +31,14 @@ public class SecurityDoorRecordServiceImpl implements SecurityDoorRecordService
     @Autowired
     SecurityDoorRecordMapper securityDoorRecordMapper;
 
+    @Autowired
+    DepartmentMapper departmentMapper;
+
     final static  String SECURITY_DOOR_RECORD_URL="/api/safety/Hikvision/record/list";
     @Override
     public ReturnMsg getSecurityDoorRecordData() {
+        String[] persons = {"李劲","李良","宋明宇","陈涵亮","李超","章峰","梁松","方运诚","徐涵衍","万浩波",
+                "周浩广","许鸿博","荣浩博","许鸿畴","徐瀚文","陈浩初","程涵煦","许鸿与","徐廖文","吴初"};
         String url = restTemplateConfig.addBaseUrl(SECURITY_DOOR_RECORD_URL)+"?pageNum=1&pageSize=1000";;
         RestTemplate restTemplate = restTemplateConfig.build();
         ResponseEntity<Map> responseEntity = restTemplate.getForEntity(url, Map.class);
@@ -40,13 +51,18 @@ public class SecurityDoorRecordServiceImpl implements SecurityDoorRecordService
             if(list!=null&&list.size()>0){
                 securityDoorRecordMapper.delete(null);
                 for (int i=0;i<list.size();i++){
+                    Integer flag = random.nextInt(0,20);
+                    Integer flag2 = random.nextInt(1,322);
+                    String name = persons[flag];
                     LinkedHashMap json = (LinkedHashMap) list.get(i);
                     SecurityDoorRecord securityDoorRecord = new SecurityDoorRecord();
                     securityDoorRecord.setId((Integer) json.get("id"));
                     if(json.get("employeeName")!=null){
                         securityDoorRecord.setName(String.valueOf(json.get("employeeName")));
+                    }else{
+                        securityDoorRecord.setName(name);
                     }
-
+                    securityDoorRecord.setDept_id(flag2);
                     securityDoorRecord.setTime(String.valueOf(json.get("eventTime")));
                     securityDoorRecord.setDoorId(Integer.parseInt(String.valueOf(json.get("doorId"))));
                     securityDoorRecord.setInOutType(String.valueOf(json.get("inAndOutType")));
@@ -61,4 +77,20 @@ public class SecurityDoorRecordServiceImpl implements SecurityDoorRecordService
             return  ReturnMsg.fail(message);
         }
     }
+
+    @Override
+    public ReturnMsg pageList(DoorAccessParam doorAccessParam) {
+        long total = securityDoorRecordMapper.pageCount(doorAccessParam);
+        List<Map<String,Object>> lists = securityDoorRecordMapper.pageList(doorAccessParam);
+        for(Map<String,Object> map:lists){
+          //  map.get("deptId");
+           Department department = departmentMapper.selectById(Integer.parseInt(String.valueOf(map.get("deptid"))));
+           map.put("department",department.getName());
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("total",total);
+        jsonObject.put("data",lists);
+
+        return ReturnMsg.ok(jsonObject);
+    }
 }

+ 1 - 4
src/main/java/com/sky/ioc/service/security/impl/SecurityPersonServiceImpl.java

@@ -1,9 +1,6 @@
 package com.sky.ioc.service.security.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.sky.ioc.entity.domain.meeting.MeetingRecord;
-import com.sky.ioc.entity.domain.security.SecurityPerson;
-import com.sky.ioc.entity.params.Security.PersonParam;
+import com.sky.ioc.entity.params.security.PersonParam;
 import com.sky.ioc.mapper.SecurityPersonMapper;
 import com.sky.ioc.service.security.SecurityPersonService;
 import com.sky.ioc.tool.ReturnMsg;

+ 8 - 0
src/main/java/com/sky/ioc/service/space/DepartmentService.java

@@ -0,0 +1,8 @@
+package com.sky.ioc.service.space;
+
+import com.sky.ioc.tool.ReturnMsg;
+
+public interface DepartmentService {
+
+    ReturnMsg getDepartmentData();
+}

+ 70 - 0
src/main/java/com/sky/ioc/service/space/impl/DepartmentServiceImpl.java

@@ -0,0 +1,70 @@
+package com.sky.ioc.service.space.impl;
+
+import com.sky.ioc.config.RestTemplateConfig;
+import com.sky.ioc.entity.domain.space.Building;
+import com.sky.ioc.entity.domain.space.Department;
+import com.sky.ioc.mapper.space.BuildingMapper;
+import com.sky.ioc.mapper.space.DepartmentMapper;
+import com.sky.ioc.service.space.DepartmentService;
+import com.sky.ioc.tool.ReturnMsg;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+
+@Service
+@Slf4j
+public class DepartmentServiceImpl implements DepartmentService {
+
+    @Autowired
+    RestTemplateConfig restTemplateConfig;
+
+    @Autowired
+    DepartmentMapper departmentMapper;
+
+    final static  String BUILDING_URL="/api/space/SPACE/departmentOfficeArea/list";
+
+    @Override
+    public ReturnMsg getDepartmentData() {
+        String url = restTemplateConfig.addBaseUrl(BUILDING_URL)+"?pageNum=1&pageSize=1000";
+        // 创建RestTemplate
+        RestTemplate restTemplate = restTemplateConfig.build();
+        // 发送GET请求
+        ResponseEntity<Map> responseEntity = restTemplate.getForEntity(url, Map.class);
+        // 获取响应对象里的 body 对象
+        Map<String, Object> body = responseEntity.getBody();
+        // 获取状态码
+        Integer code = (Integer)body.get("code");
+        // 获取响应信息
+        String message = (String)body.get("msg");
+        if(code==200){
+            ThreadLocalRandom random = ThreadLocalRandom.current();
+            ArrayList list = (ArrayList) body.get("rows");
+            if(list!=null&&list.size()>0){
+                departmentMapper.delete(null);
+                for (int i=0;i<list.size();i++){
+                    LinkedHashMap json = (LinkedHashMap) list.get(i);
+                    Department department = new Department();
+                    department.setId((Integer) json.get("id"));
+                    department.setName(String.valueOf(json.get("name")));
+                    department.setFullName(String.valueOf(json.get("fullName")));
+                    department.setSort(Integer.parseInt(String.valueOf(json.get("sort"))));
+                    department.setOriId(String.valueOf(json.get("oriId")));
+                    department.setParentId(String.valueOf(json.get("parentId")));
+                    departmentMapper.insert(department);
+                }
+            }
+            return ReturnMsg.ok();
+
+        }else{
+            log.info("获取部门数据:"+message);
+            return  ReturnMsg.fail(message);
+        }
+    }
+}

+ 7 - 23
src/main/java/com/sky/ioc/service/supermarket/impl/SupermarketServiceImpl.java

@@ -8,10 +8,7 @@ import com.sky.ioc.entity.params.IocParam;
 import com.sky.ioc.entity.params.IocTimeRange;
 import com.sky.ioc.mapper.SupermarketOrderMapper;
 import com.sky.ioc.service.supermarket.SupermarketService;
-import com.sky.ioc.tool.DateUtil;
-import com.sky.ioc.tool.FalseData;
-import com.sky.ioc.tool.GeneralMethod;
-import com.sky.ioc.tool.ReturnMsg;
+import com.sky.ioc.tool.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -42,27 +39,14 @@ public class SupermarketServiceImpl implements SupermarketService {
         List<JSONObject> objects = indeicator.getList();
         Double totalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam);
         totalPrice = totalPrice == null ? 0 : totalPrice;
-        BigDecimal bigDecimal = new BigDecimal(totalPrice);
-        // 转换为万元(除以10000)保留两位小数
-        BigDecimal decimal = bigDecimal.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP);
-        totalPrice = decimal.doubleValue();
         Integer totalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam);
         Integer totalPerson = supermarketOrderMapper.getTotalPersonByCompanyIdAndDeptId(iocParam);
-        double avgPrice = 0d;
-        double avgPersonPrice = 0d;
-        if (totalPrice > 0) {
-            if (totalOrder > 0) {
-                BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder), 2, RoundingMode.HALF_UP);
-                avgPrice = avgPriceDec.doubleValue();
-            }
-            if (totalPerson > 0) {
-                BigDecimal avgPersonPriceDec = bigDecimal.divide(new BigDecimal(totalPerson), 2, RoundingMode.HALF_UP);
-                avgPersonPrice = avgPersonPriceDec.doubleValue();
-            }
-        }
+        double avgPrice = MathUtils.division(totalPrice,totalOrder,2);
+        double avgPersonPrice = MathUtils.division(totalPrice,totalPerson,2);
         ThreadLocalRandom random = ThreadLocalRandom.current();
         double compare = random.nextDouble(-1, 1);
         DecimalFormat decimalFormat = new DecimalFormat("#.0");
+        totalPrice = MathUtils.division(totalPrice,10000,2);
         compare = Double.parseDouble(decimalFormat.format(compare));
         objects.get(0).put("value", totalPrice);
         objects.get(0).put("compare", compare);
@@ -112,11 +96,11 @@ public class SupermarketServiceImpl implements SupermarketService {
             Double afternoonTotalPrice = supermarketOrderMapper.getTotalPriceByCompanyIdAndDeptId(iocParam2);
             afternoonTotalPrice = afternoonTotalPrice == null ? 0 : Double.valueOf(decimalFormat.format(afternoonTotalPrice));
             Integer afternoonTotalOrder = supermarketOrderMapper.getTotalOrderByCompanyIdAndDeptId(iocParam2);
-            BigDecimal bigDecimal = new BigDecimal(totalPrice+afternoonTotalPrice);
+           // BigDecimal bigDecimal = new BigDecimal(totalPrice+afternoonTotalPrice);
             double avgPrice = 0d;
             if (totalPrice+afternoonTotalPrice > 0) {
-                BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder+afternoonTotalOrder), 2, RoundingMode.HALF_UP);
-                avgPrice = avgPriceDec.doubleValue();
+              //  BigDecimal avgPriceDec = bigDecimal.divide(new BigDecimal(totalOrder+afternoonTotalOrder), 2, RoundingMode.HALF_UP);
+                avgPrice = MathUtils.division(totalPrice+afternoonTotalPrice,totalOrder+afternoonTotalOrder,2);
             }
             jsonObject.put(param[0],totalPrice);
             jsonObject.put(param[1],afternoonTotalPrice);

+ 40 - 0
src/main/java/com/sky/ioc/tool/MathUtils.java

@@ -0,0 +1,40 @@
+package com.sky.ioc.tool;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * 数字计算
+ * */
+public class MathUtils {
+
+    /**
+     * dividend 被除数
+     * divisor 除数
+     * decimals 保留小数
+     * */
+    public static double division(long dividend,long divisor,Integer decimals){
+        if(dividend==0||divisor==0){
+            return 0;
+        }else{
+            BigDecimal bigDecimal = new BigDecimal(dividend);
+            BigDecimal decimal = bigDecimal.divide(new BigDecimal(divisor), decimals, RoundingMode.HALF_UP);
+            return decimal.doubleValue();
+        }
+    }
+
+    /**
+     * dividend 被除数
+     * divisor 除数
+     * decimals 保留小数
+     * */
+    public static double division(double dividend,double divisor,Integer decimals){
+        if(dividend==0||divisor==0){
+            return 0;
+        }else{
+            BigDecimal bigDecimal = new BigDecimal(dividend);
+            BigDecimal decimal = bigDecimal.divide(new BigDecimal(divisor), decimals, RoundingMode.HALF_UP);
+            return decimal.doubleValue();
+        }
+    }
+}