Przeglądaj źródła

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 lat temu
rodzic
commit
6d5b78724a

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -67,4 +67,6 @@ public interface PersonDeviceFilterLogDAO {
     Integer getDayCheckedPersonNumByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list,  @Param("popedom") String popedom);
 
     int deleteExpiredVisitorRecord(@Param("limit") int limit);
+
+    List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("companyInfo") CompanyInfo companyInfo);
 }

+ 24 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/CompanyRecordReportDTO.java

@@ -0,0 +1,24 @@
+package com.jpsoft.smart.modules.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-7 9:20
+ */
+@Data
+public class CompanyRecordReportDTO {
+
+    @ApiModelProperty(value = "公司名称")
+    private String companyName;
+
+    @ApiModelProperty(value = "公司人数")
+    private Integer personTotal;
+
+    @ApiModelProperty(value = "公司检测人数")
+    private Integer checkPersonTotal;
+
+    @ApiModelProperty(value = "公司未检测人姓名")
+    private String unCheckPersonName;
+}

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -77,4 +77,6 @@ public interface PersonDeviceFilterLogService {
     Integer getDayCheckedPersonNumByCompanyList(Date startTime,Date endTime, List<CompanyInfo> list,String popedom);
 
     int deleteExpiredVisitorRecord(int limit);
+
+    List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime,CompanyInfo companyInfo);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java

@@ -288,4 +288,9 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     public int deleteExpiredVisitorRecord(int limit) {
         return personDeviceFilterLogDAO.deleteExpiredVisitorRecord(limit);
     }
+
+    @Override
+    public List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime, CompanyInfo companyInfo) {
+        return personDeviceFilterLogDAO.getDayCheckedPersonByCompanyList(beginTime,endTime,companyInfo);
+    }
 }

+ 14 - 0
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -390,4 +390,18 @@
         )
         order by a.id_ asc
     </select>
+
+    <select id="getDayCheckedPersonByCompanyList" resultMap="PersonDeviceFilterLogMap">
+        <![CDATA[
+         select * from base_person_device_filter_log a left join base_person_info b
+        on a.person_id = b.id_
+        where  a.record_time>=#{startDate}
+        and a.record_time<#{endDate}
+        and a.del_flag=0
+        and b.company_id = #{companyInfo.id}
+
+        ]]>
+
+        group by a.person_id order by a.record_time desc
+    </select>
 </mapper>

+ 160 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/ReportController.java

@@ -0,0 +1,160 @@
+package com.jpsoft.smart.modules.base.controller;
+
+import cn.hutool.core.date.DateUtil;
+import com.github.pagehelper.util.StringUtil;
+import com.jpsoft.smart.modules.base.dto.CompanyRecordReportDTO;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.entity.PersonCompany;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
+import com.jpsoft.smart.modules.base.service.PersonCompanyService;
+import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-7 8:53
+ */
+
+@Slf4j
+@RequestMapping("/report")
+@RestController
+public class ReportController {
+
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @Autowired
+    private PersonInfoService personInfoService;
+
+    @Autowired
+    private PersonDeviceFilterLogService personDeviceFilterLogService;
+
+
+    @ApiOperation(value = "获取每个单位的人数和打卡人数")
+    @PostMapping("getCompanyRecordReport")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query")
+    })
+    public MessageResult<Map> getCompanyRecordReport(@RequestParam(value="timeRanges") String timeRanges,@RequestAttribute String subject) {
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+        HashMap<String, Object> map = new HashMap<>();
+        try {
+            User user = userService.get(subject);
+            List<CompanyInfo> list = new ArrayList<>();
+
+            //系统管理者和非系统管理者公司列表
+            if (userService.hasRole(subject, "SYSADMIN")) {
+                list = companyInfoService.list();
+            }else {
+                CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+                list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+            }
+
+            //查询时间
+            Date beginTime = DateUtil.beginOfDay(new Date());
+            Date endTime = DateUtil.endOfDay(new Date());
+            if(StringUtil.isNotEmpty(timeRanges)){
+                String[] timeRangeArray = timeRanges.split(",");
+                if(timeRangeArray.length==1){
+                    beginTime = DateUtil.parse(timeRangeArray[0]);
+                }
+                else if(timeRangeArray.length==2){
+                    beginTime = DateUtil.parse(timeRangeArray[0]);
+                    endTime = DateUtil.parse(timeRangeArray[1]);
+                }
+            }
+
+
+            //结果集
+            List<CompanyRecordReportDTO> companyRecordReportDTOS = new ArrayList<>();
+            //所有公司人员总数初始化
+            Integer totalPersonNum = 0;
+            //所有公司已测人数初始化
+            Integer checkTotalPersonNum = 0;
+            if (list.size()>0){
+                for (CompanyInfo companyInfo : list){
+                 //   List<CompanyInfo> companyInfoList = new ArrayList<>();
+                    //对象封装成集合方便后续使用
+               //     companyInfoList.add(companyInfo);
+                    //结果集对象初始化
+                    CompanyRecordReportDTO companyRecordReportDTO = new CompanyRecordReportDTO();
+                    //查询公司的所有未删除对象
+                    List<PersonInfo> personInfoList = personInfoService.findByCompanyId(companyInfo.getId());
+
+                    //总人数
+                    totalPersonNum = totalPersonNum+ personInfoList.size();
+
+                    //过滤记录表中时间区间内的非重复数据
+                    List<PersonDeviceFilterLog> personDeviceFilterLogs = personDeviceFilterLogService.getDayCheckedPersonByCompanyList(beginTime,endTime,companyInfo);
+                    //总已测人数
+                    checkTotalPersonNum = checkTotalPersonNum + personDeviceFilterLogs.size();
+
+                    //查询出已测温对象
+                    List<PersonInfo> checkPersonList = new ArrayList<>();
+                    if (personDeviceFilterLogs.size()>0){
+                        for (PersonDeviceFilterLog personDeviceFilterLog : personDeviceFilterLogs){
+                            PersonInfo personInfo = personInfoService.get(personDeviceFilterLog.getPersonId().longValue());
+                            if (personInfo != null){
+                                checkPersonList.add(personInfo);
+                            }
+                        }
+                    }
+                    //查询出未测温对象
+                    personInfoList.removeAll(checkPersonList);
+                    //未测试人员姓名集合初始化
+                    String name = "";
+                    if (personInfoList.size()>0){
+                        for (PersonInfo personInfo : personInfoList){
+                            name = name +","+ personInfo.getName();
+
+                        }
+                        name = name.substring(1);
+                    }
+
+               //     Integer checkPersonTotal = personDeviceFilterLogService.getDayCheckedPersonNumByCompanyList(beginTime,endTime,companyInfoList,null);
+                    companyRecordReportDTO.setCompanyName(companyInfo.getName());
+                    companyRecordReportDTO.setPersonTotal(personInfoList.size());
+                    companyRecordReportDTO.setCheckPersonTotal(personDeviceFilterLogs.size());
+                    companyRecordReportDTO.setUnCheckPersonName(name);
+                    companyRecordReportDTOS.add(companyRecordReportDTO);
+
+
+                }
+            }
+            map.put("list",companyRecordReportDTOS);
+            map.put("totalPersonNum",totalPersonNum);
+            map.put("checkTotalPersonNum",checkTotalPersonNum);
+
+            msgResult.setData(map);
+            msgResult.setResult(true);
+            msgResult.setMessage("获取成功");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            msgResult.setData(map);
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+        }
+
+
+        return msgResult;
+    }
+}