Jelajahi Sumber

1.如果为设置考勤时段,则查全天。
2.大屏修改。

zhengqiang 5 tahun lalu
induk
melakukan
bf16d72eca

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

@@ -55,4 +55,6 @@ public interface PersonDeviceLogDAO {
     int delete(String id);
 
     List<PersonDeviceLog> findExpiredVisitorRecord(@Param("limit") int limit);
+
+    long countByAttendance(String companyCode, Date beginDate, Date endDate);
 }

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

@@ -33,4 +33,6 @@ public interface PersonInfoDAO {
 	long countStudentByCompanyListAndPopedom(@Param("type") String type, @Param("list")List<CompanyInfo> list);
 
 	PersonInfo findById(long id);
+
+    long countByCompanyId(String companyId);
 }

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

@@ -55,4 +55,6 @@ public interface PersonDeviceLogService {
     List<PersonDeviceLog> findExpiredVisitorRecord(int limit);
 
     int delete(String id);
+
+    long countByAttendance(String companyCode, Date beginDate, Date endDate);
 }

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

@@ -32,4 +32,6 @@ public interface PersonInfoService {
 	long countByCompanyListAndPopedom(String type ,List<CompanyInfo> list);
 
 	PersonInfo findById(long longValue);
+
+    long countByCompanyId(String companyId);
 }

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

@@ -211,6 +211,11 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         return personDeviceLogDAO.queryAttendanceList(companyCode, startTime, endTime);
     }
 
+    @Override
+    public long countByAttendance(String companyCode, Date beginDate, Date endDate) {
+        return personDeviceLogDAO.countByAttendance(companyCode,beginDate,endDate);
+    }
+
     @Override
     public PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax) {
         return personDeviceLogDAO.findLastPersonLog(personId,temperatureMax);

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

@@ -120,4 +120,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public PersonInfo getIgnoreDelFlag(Long id) {
 		return personInfoDAO.getIgnoreDelFlag(id);
 	}
+
+	@Override
+	public long countByCompanyId(String companyId) {
+		return personInfoDAO.countByCompanyId(companyId);
+	}
 }

+ 12 - 0
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -359,4 +359,16 @@
             order by record_time asc limit ${limit}
         ]]>
     </select>
+    <select id="countByAttendance" resultType="long">
+        <![CDATA[
+            select count(distinct(c.person_id)) from base_person_info a,base_company_info b,base_person_device_log c
+            where a.company_id=b.id_
+            and a.id_=c.person_id
+            and b.code_ like #{companyCode}
+            and a.del_flag=0
+            and c.record_time>=#{startDate}
+            and c.record_time<=#{startDate}
+            and c.del_flag=0
+        ]]>
+    </select>
 </mapper>

+ 3 - 0
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -327,4 +327,7 @@
         a.id_=#{id} and a.del_flag = 0
         order by a.id_ asc
     </select>
+    <select id="countByCompanyId" resultType="long">
+        select count(*) from base_person_info where company_id=#{0} and del_flag=0
+    </select>
 </mapper>

+ 42 - 3
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -310,8 +310,10 @@ public class PersonDeviceLogApiController {
             @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
             @ApiImplicitParam(name="subject",value = "目标(不传)",paramType = "form")
     })
-    public MessageResult<List> queryCompanyList(String token,@RequestAttribute String subject){
-        MessageResult<List> messageResult = new MessageResult<>();
+    public MessageResult<Map> queryCompanyList(String token,@RequestAttribute String subject){
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        Map<String,Object> dataMap = new HashMap<>();
 
         try {
             PersonInfo personInfo = personInfoService.get(Long.valueOf(subject));
@@ -320,7 +322,44 @@ public class PersonDeviceLogApiController {
 
             List<CompanyInfo> companyList = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%",personInfo.getId());
 
-            messageResult.setData(companyList);
+            List<Map> mapList = companyList.stream().map((company)->{
+                Map<String,Object> map = new HashMap<>();
+
+                map.put("id",company.getId());
+                map.put("code",company.getCode());
+                map.put("name", company.getName());
+
+                return map;
+
+            }).collect(Collectors.toList());
+
+            DateTime beginTime =DateTime.now().withTimeAtStartOfDay();
+            DateTime endTime = beginTime.plusDays(1);
+            long sumPersonNum = 0;
+            long sumDetectedNum = 0;
+
+            for (Map map : mapList) {
+                String companyId = (String)map.get("id");
+                String companyCode = (String)map.get("code");
+
+                //单位
+                long personNum = personInfoService.countByCompanyId(companyId);
+                sumPersonNum += personNum;
+
+                //当日已测人数
+                long detectedNum = personDeviceLogService.countByAttendance(companyCode,beginTime.toDate(),endTime.toDate());
+                sumDetectedNum += sumDetectedNum;
+
+                map.put("personNum",personNum);
+                map.put("detectedNum",detectedNum);
+            }
+
+            //增加汇总
+            dataMap.put("list",mapList);
+            dataMap.put("sumPersonNum",sumPersonNum);
+            dataMap.put("sumDetectedNum",sumDetectedNum);
+
+            messageResult.setData(dataMap);
             messageResult.setResult(true);
         }
         catch (Exception ex){