Browse Source

添加健康公示墙接口

M墨鱼—_mo 5 năm trước cách đây
mục cha
commit
4db3a686f4
18 tập tin đã thay đổi với 660 bổ sung7 xóa
  1. 1 0
      common/src/main/java/com/jpsoft/smart/cphandler/MsgHandler.java
  2. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java
  3. 13 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java
  4. 3 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java
  5. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java
  6. 15 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java
  7. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonInfoService.java
  8. 5 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java
  9. 54 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java
  10. 11 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonInfoServiceImpl.java
  11. 5 5
      common/src/main/java/com/jpsoft/smart/modules/common/service/IRedisService.java
  12. 4 0
      common/src/main/java/com/jpsoft/smart/modules/common/service/impl/RedisServiceImpl.java
  13. 14 0
      common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml
  14. 68 0
      common/src/main/resources/mapper/base/PersonDeviceLog.xml
  15. 10 0
      common/src/main/resources/mapper/base/PersonInfo.xml
  16. 2 1
      web/src/main/java/com/jpsoft/smart/config/WebMvcConfig.java
  17. 410 0
      web/src/main/java/com/jpsoft/smart/modules/mobile/controller/HealthShowApiController.java
  18. 39 1
      web/src/main/java/com/jpsoft/smart/modules/wechat/controller/WxCpController.java

+ 1 - 0
common/src/main/java/com/jpsoft/smart/cphandler/MsgHandler.java

@@ -22,6 +22,7 @@ public class MsgHandler extends AbstractHandler {
         final String msgType = wxMessage.getMsgType();
         if (msgType == null) {
             // 如果msgType没有,就自己根据具体报文内容做处理
+            return new TextBuilder().build("success", wxMessage, cpService);
         }
 
         if (!msgType.equals(WxConsts.XmlMsgType.EVENT)) {

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

@@ -63,4 +63,6 @@ public interface PersonDeviceFilterLogDAO {
     long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
 
     List<PersonInfo> findUndetectedByCompanyCode(@Param("searchParams") Map<String, Object> searchParams);
+
+    Integer getDayCheckedPersonNumByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list,  @Param("popedom") String popedom);
 }

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

@@ -1,5 +1,7 @@
 package com.jpsoft.smart.modules.base.dao;
 
+import cn.hutool.core.date.DateTime;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
@@ -33,4 +35,15 @@ public interface PersonDeviceLogDAO {
     List<PersonInfo> queryAttendanceList(String companyCode, Date startTime, Date endTime);
 
     PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax);
+
+    Integer getDayCheckedVistorNumByDeviceNoList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<String> list);
+
+    List<PersonDeviceLog> findLastPersonLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list);
+
+    List<PersonDeviceLog> findVisitorLogByDeviceNoList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<String> list);
+
+
+    List<PersonDeviceLog> findLastTeacherLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list);
+
+    List<PersonDeviceLog> findLastStudentLogByCompanyList(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("list") List<CompanyInfo> list);
 }

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

@@ -3,6 +3,7 @@ package com.jpsoft.smart.modules.base.dao;
 import java.util.List;
 
 import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import java.util.Map;
@@ -26,4 +27,6 @@ public interface PersonInfoDAO {
 	List<PersonInfo> findByCompanyCode(Map<String,Object> searchParams,List<Sort> sortList);
 
     long countByCompanyList(List<CompanyInfo> list);
+
+    long countByCompanyListAndPopedom(@Param("type") String type, @Param("list") List<CompanyInfo> list);
 }

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

@@ -73,4 +73,6 @@ public interface PersonDeviceFilterLogService {
     Integer countDetectedByCompanyId(String companyId, Date startDate, Date endDate);
 
     Page<PersonInfo> findUndetectedPersonList(Map<String,Object> searchParams,int pageNumber,int pageSize,boolean count);
+
+    Integer getDayCheckedPersonNumByCompanyList(Date startTime,Date endTime, List<CompanyInfo> list,String popedom);
 }

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

@@ -1,6 +1,8 @@
 package com.jpsoft.smart.modules.base.service;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.json.JSONObject;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
@@ -35,4 +37,17 @@ public interface PersonDeviceLogService {
     List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime);
     List<PersonInfo> queryAttendanceList(String companyCode, Date startDate, Date endDate);
     PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax);
+
+    Integer getDayCheckedVistorNumByDeviceNoList(Date startTime, Date endTime, List<String> deviceNoList);
+
+    Page<PersonDeviceLog> findLastPersonLogByCompanyList(DateTime beginOfDay, DateTime endOfDay, List<CompanyInfo> list,int pageNum, int pageSize);
+
+    Page<PersonDeviceLog> findVisitorLogByDeviceNoList(DateTime beginOfDay, DateTime endOfDay, List<String> deviceNoList, int pageIndex, int pageSize);
+
+    Page<PersonDeviceLog> findAllPersonLogByCompanyListAndDeviceNoList(DateTime beginOfDay, DateTime endOfDay, List<CompanyInfo> list,List<String> deviceNoList, int pageIndex, int pageSize);
+
+
+    Page<PersonDeviceLog> findLastTeacherLogByCompanyList(Date beginOfDay, Date endOfDay, List<CompanyInfo> list, int pageIndex, int pageSize);
+
+    Page<PersonDeviceLog> findLastStudentLogByCompanyList(Date beginOfDay, Date endOfDay, List<CompanyInfo> list, int pageIndex, int pageSize);
 }

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

@@ -28,4 +28,6 @@ public interface PersonInfoService {
 	List<PersonInfo> findByCompanyCode(Map<String, Object> searchParams,List<Sort> sortList);
 
 	long countByCompanyList(List<CompanyInfo> list);
+
+	long countByCompanyListAndPopedom(String type ,List<CompanyInfo> list);
 }

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

@@ -254,6 +254,11 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
         return page;
     }
 
+    @Override
+    public Integer getDayCheckedPersonNumByCompanyList(Date startTime, Date endTime, List<CompanyInfo> list,String popedom) {
+        return personDeviceFilterLogDAO.getDayCheckedPersonNumByCompanyList(startTime,endTime,list,popedom);
+    }
+
     @Override
     public Integer getDayAbnormalNum(Date startTime, Date endTime) {
         return personDeviceFilterLogDAO.getDayAbnormalNum(startTime,endTime,temperatureConfig.getMax());

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

@@ -1,5 +1,6 @@
 package com.jpsoft.smart.modules.base.service.impl;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.json.JSONObject;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
@@ -214,4 +215,57 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     public PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax) {
         return personDeviceLogDAO.findLastPersonLog(personId,temperatureMax);
     }
+
+    @Override
+    public Integer getDayCheckedVistorNumByDeviceNoList(Date startTime, Date endTime, List<String> deviceNoList) {
+        return personDeviceLogDAO.getDayCheckedVistorNumByDeviceNoList(startTime,endTime,deviceNoList);
+    }
+
+    @Override
+    public Page<PersonDeviceLog> findLastPersonLogByCompanyList(DateTime beginOfDay, DateTime endOfDay, List<CompanyInfo> list,int pageNum, int pageSize) {
+
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageNum, pageSize).doSelectPage(() -> {
+            personDeviceLogDAO.findLastPersonLogByCompanyList(beginOfDay,endOfDay,list);
+        });
+
+        return page;
+    }
+
+    @Override
+    public Page<PersonDeviceLog> findVisitorLogByDeviceNoList(DateTime beginOfDay, DateTime endOfDay, List<String> deviceNoList, int pageIndex, int pageSize) {
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageIndex, pageSize).doSelectPage(() -> {
+            personDeviceLogDAO.findVisitorLogByDeviceNoList(beginOfDay,endOfDay,deviceNoList);
+        });
+
+        return page;
+    }
+
+    @Override
+    public Page<PersonDeviceLog> findAllPersonLogByCompanyListAndDeviceNoList(DateTime beginOfDay, DateTime endOfDay, List<CompanyInfo> list, List<String> deviceNoList, int pageIndex, int pageSize) {
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageIndex, pageSize).doSelectPage(() -> {
+            personDeviceLogDAO.findLastPersonLogByCompanyList(beginOfDay,endOfDay,list).addAll(personDeviceLogDAO.findVisitorLogByDeviceNoList(beginOfDay,endOfDay,deviceNoList));
+        });
+
+        return page;
+    }
+
+    @Override
+    public Page<PersonDeviceLog> findLastTeacherLogByCompanyList(Date beginOfDay, Date endOfDay, List<CompanyInfo> list, int pageIndex, int pageSize) {
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageIndex, pageSize).doSelectPage(() -> {
+            personDeviceLogDAO.findLastTeacherLogByCompanyList(beginOfDay,endOfDay,list);
+        });
+
+        return page;
+    }
+
+    @Override
+    public Page<PersonDeviceLog> findLastStudentLogByCompanyList(Date beginOfDay, Date endOfDay, List<CompanyInfo> list, int pageIndex, int pageSize) {
+        Page<PersonDeviceLog> page = PageHelper.startPage(pageIndex, pageSize).doSelectPage(() -> {
+            personDeviceLogDAO.findLastStudentLogByCompanyList(beginOfDay,endOfDay,list);
+        });
+
+        return page;
+    }
+
+
 }

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

@@ -100,6 +100,17 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 		return personInfoDAO.countByCompanyList(list);
 	}
 
+	@Override
+	public long countByCompanyListAndPopedom(String type,List<CompanyInfo> list) {
+		if ("teacher".equals(type)){
+			return personInfoDAO.countByCompanyListAndPopedom("2",list);
+		}
+		if ("student".equals(type)){
+			return personInfoDAO.countByCompanyListAndPopedom("1",list);
+		}
+		return 0L;
+	}
+
 	@Override
 	public PersonInfo getIgnoreDelFlag(Long id) {
 		return personInfoDAO.getIgnoreDelFlag(id);

+ 5 - 5
common/src/main/java/com/jpsoft/smart/modules/common/service/IRedisService.java

@@ -60,8 +60,8 @@ public abstract class IRedisService<T> {
      *
      * @return
      */
-    public List<T> getAll() {
-        return hashOperations.values(getRedisKey(""));
+    public List<T> getAll(String jpkey) {
+        return hashOperations.values(getRedisKey(jpkey));
     }
 
     /**
@@ -97,9 +97,9 @@ public abstract class IRedisService<T> {
      */
     public void empty() {
         Set<String> set = hashOperations.keys(getRedisKey(""));
-        
-        for (String key : set) {  
+
+        for (String key : set) {
         	hashOperations.delete(getRedisKey(""), key);
-        }  
+        }
     }
 }

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/common/service/impl/RedisServiceImpl.java

@@ -10,6 +10,7 @@ public class RedisServiceImpl extends IRedisService<Object> {
     private static final String REDIS_KEY1 = "VERIFYCODE_REDIS_KEY";
     private static final String REDIS_KEY2 = "APITOKEN_REDIS_KEY";
     private static final String REDIS_KEY3 = "ACCESSTOKEN_REDIS_KEY";
+    private static final String REDIS_KEY4 = "PERSONINFO_REDIS_KEY";
 
 
     @SuppressWarnings("static-access")
@@ -24,6 +25,9 @@ public class RedisServiceImpl extends IRedisService<Object> {
         if (jpKey.equals("accessToken")){
             return REDIS_KEY3;
         }
+        if (jpKey.equals("personInfo")){
+            return REDIS_KEY4;
+        }
         if (StringUtils.isBlank(jpKey)){
             return REDIS_KEY;
         }

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

@@ -315,6 +315,20 @@
         and a.del_flag = 0
     </select>
 
+    <select id="getDayCheckedPersonNumByCompanyList" resultType="Integer">
+        select count(DISTINCT person_id) from base_person_device_filter_log a left join base_person_info b
+        on a.person_id = b.id_
+        where a.record_time >=#{startTime}
+        and a.record_time &lt;= #{endTime}
+        and b.company_id in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        </foreach>
+        and a.del_flag = 0
+        <if test="popedom!=null">
+            and b.popedom_ like #{popedom}
+        </if>
+    </select>
+
     <select id="getDayNormalNumByCompanyId" resultType="Integer">
         select count(DISTINCT person_id) from base_person_device_filter_log a left join base_person_info b
         on a.person_id = b.id_

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

@@ -199,4 +199,72 @@
             limit 1
         ]]>
     </select>
+
+    <select id="getDayCheckedVistorNumByDeviceNoList" resultType="Integer">
+        select count(*) from base_person_device_log where person_id = 0
+        and record_time >=#{startTime}
+        and record_time &lt;= #{endTime}
+        and device_no in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item}
+        </foreach>
+    </select>
+
+    <select id="findLastPersonLogByCompanyList" resultMap="PersonDeviceLogMap">
+
+        SELECT * from
+        (SELECT m.*,n.company_id as company_id
+        from base_person_device_log m LEFT JOIN base_person_info n
+        ON m.person_id = n.id_
+        where record_time>=#{startTime}
+        and record_time &lt;= #{endTime}
+        and company_id in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        </foreach>
+        ORDER BY record_time DESC) a
+        where person_id != 0  GROUP BY a.person_id ORDER BY record_time desc
+
+
+    </select>
+
+    <select id="findVisitorLogByDeviceNoList" resultMap="PersonDeviceLogMap">
+        select * from base_person_device_log
+        where person_id = 0
+        and record_time>=#{startTime}
+        and record_time &lt;= #{endTime}
+        and device_no in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item}
+        </foreach>
+        ORDER BY record_time DESC
+
+    </select>
+
+    <select id="findLastTeacherLogByCompanyList" resultMap="PersonDeviceLogMap">
+        SELECT * from
+        (SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_
+        from base_person_device_log m LEFT JOIN base_person_info n
+        ON m.person_id = n.id_
+        where record_time>=#{startTime}
+        and record_time &lt;= #{endTime}
+        and popedom_ like '%2%'
+        and company_id in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        </foreach>
+        ORDER BY record_time DESC) a
+        where person_id != 0  GROUP BY a.person_id ORDER BY record_time desc
+    </select>
+
+    <select id="findLastStudentLogByCompanyList" resultMap="PersonDeviceLogMap">
+        SELECT * from
+        (SELECT m.*,n.company_id as company_id,n.popedom_ as popedom_
+        from base_person_device_log m LEFT JOIN base_person_info n
+        ON m.person_id = n.id_
+        where record_time>=#{startTime}
+        and record_time &lt;= #{endTime}
+        and popedom_ = '1'
+        and company_id in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        </foreach>
+        ORDER BY record_time DESC) a
+        where person_id != 0  GROUP BY a.person_id ORDER BY record_time desc
+    </select>
 </mapper>

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

@@ -302,4 +302,14 @@
             #{item.id}
         </foreach>
     </select>
+
+    <select id="countByCompanyListAndPopedom" resultType="Long">
+        select count(*) from base_person_info where del_flag = 0
+        and popedom_ like #{type}
+        and
+        company_id in
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+            #{item.id}
+        </foreach>
+    </select>
 </mapper>

+ 2 - 1
web/src/main/java/com/jpsoft/smart/config/WebMvcConfig.java

@@ -68,6 +68,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/personInfoApi/validateCode")
 				.excludePathPatterns("/mobile/personInfoApi/findByOpenId")
 				.excludePathPatterns("/mobile/personDeviceLogApi/detail")
-				.excludePathPatterns("/mobile/PersonDeviceFilterLog/queryUnmeasureGroupList");
+				.excludePathPatterns("/mobile/PersonDeviceFilterLog/queryUnmeasureGroupList")
+				.excludePathPatterns("/mobile/healthShowApi/getCompanyToken");
 	}
 }

+ 410 - 0
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/HealthShowApiController.java

@@ -0,0 +1,410 @@
+package com.jpsoft.smart.modules.mobile.controller;
+
+import cn.hutool.core.date.DateUtil;
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.*;
+import com.jpsoft.smart.modules.base.service.*;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.utils.DES3;
+import com.jpsoft.smart.modules.common.utils.JwtUtil;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import com.jpsoft.smart.modules.sys.entity.User;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.jsqlparser.expression.LongValue;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpSession;
+import java.util.*;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-3 9:33
+ * <p>
+ * 手机端健康公示
+ */
+@Slf4j
+@RestController
+@RequestMapping("/mobile/healthShowApi")
+public class HealthShowApiController {
+
+    @Value("${jwt.secret}")
+    private String jwtSecret;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @Autowired
+    private PersonDeviceFilterLogService personDeviceFilterLogService;
+
+    @Autowired
+    private PersonInfoService personInfoService;
+
+    @Autowired
+    private PersonDeviceLogService personDeviceLogService;
+
+    @Autowired
+    private CompanyDeviceRelationService companyDeviceRelationService;
+
+    @Autowired
+    private CheckNumCompanyService checkNumCompanyService;
+
+    @Autowired
+    private TotalCheckCompanyService totalCheckCompanyService;
+
+    @Autowired
+    private PersonCompanyService personCompanyService;
+
+    @ApiOperation(value = "数字数据")
+    @RequestMapping(value = "numData", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", paramType = "query", dataType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+    })
+    public MessageResult<Map> numData(String token, @RequestAttribute String subject) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        List<CompanyInfo> list = new ArrayList<>();
+        HashMap<String, Object> mapData = new HashMap<>();
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(subject);
+            if (companyInfo == null) {
+                PersonInfo personInfo = personInfoService.get(new Long(subject));
+                if (personInfo == null) {
+                    throw new Exception("参数异常");
+                }
+                if (personInfo.getPopedom().contains("3")) {
+                    List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+                    if (personCompanyList.size() > 0) {
+                        for (PersonCompany personCompany : personCompanyList) {
+                            CompanyInfo companyInfo1 = companyInfoService.get(personCompany.getCompanyId());
+                            if (companyInfo1 != null) {
+                                list.add(companyInfo1);
+                            }
+                        }
+                    }
+                }
+
+
+            } else {
+                list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+            }
+
+
+            if (list.size() > 0) {
+
+
+                List<String> deviceNoList = new ArrayList<>();
+                for (CompanyInfo companyInfo1 : list) {
+                    List<DeviceInfo> deviceInfoList = companyDeviceRelationService.findDeviceByCompanyId(companyInfo1.getId());
+                    for (DeviceInfo deviceInfo : deviceInfoList) {
+                        if (!deviceNoList.contains(deviceInfo.getDeviceNo())) {
+                            deviceNoList.add(deviceInfo.getDeviceNo());
+                        }
+                    }
+                }
+                Integer personNum = Math.toIntExact(personInfoService.countByCompanyList(list));
+                Integer checkedPersonNum = personDeviceFilterLogService.getDayCheckedPersonNumByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, null);
+                Integer checkedVisitorNum = personDeviceLogService.getDayCheckedVistorNumByDeviceNoList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), deviceNoList);
+                Integer num = checkNumCompanyService.getDayCheckNumByCompanyList(DateUtil.format(new Date(), "yyyy-MM-dd"), list);
+                Integer totalNum = totalCheckCompanyService.getTotalCheckNum(list);
+                Integer dayCheckNum = num == null ? 0 : num;
+                Integer totalCheckNum = totalNum == null ? dayCheckNum : totalNum + dayCheckNum;
+
+                Integer num2 = personDeviceFilterLogService.getDayAbnormalNumByCompanyList(DateUtil.beginOfDay(new Date()), new Date(), list);
+                Integer totalNum2 = totalCheckCompanyService.getTotalAbnormalNumByCompanyList(list);
+                Integer dayAbnormalNum = num2 == null ? 0 : num2;
+                Integer totalAbnormalNum = totalNum2 == null ? 0 : totalNum2 + dayAbnormalNum;
+
+                Integer normalDaysNum = totalCheckCompanyService.findMinNormalDayByCompanyList(list);
+                Integer normalDays = normalDaysNum == null ? 0 : normalDaysNum;
+
+
+                mapData.put("checkedPersonNum", checkedPersonNum);
+                mapData.put("personNum", personNum);
+                mapData.put("checkedVisitorNum", checkedVisitorNum);
+                mapData.put("totalCheckNum", totalCheckNum);
+                mapData.put("dayAbnormalNum", dayAbnormalNum);
+                mapData.put("totalAbnormalNum", totalAbnormalNum);
+                mapData.put("normalDays", normalDays);
+
+            }
+            msgResult.setMessage("查询成功");
+            msgResult.setResult(true);
+            msgResult.setData(mapData);
+
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+        }
+
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "图片数据")
+    @RequestMapping(value = "picData", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", paramType = "query", dataType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "type", value = "员工/访客(person/visitor)", required = true, paramType = "form", dataType = "String"),
+
+    })
+    public MessageResult<Map> picData(
+            @RequestParam(value = "type", defaultValue = "all") String type,
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "12") int pageSize,
+            String token, @RequestAttribute String subject) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        List<CompanyInfo> list = new ArrayList<>();
+        HashMap<String, Object> mapData = new HashMap<>();
+
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(subject);
+
+            if (companyInfo == null) {
+                PersonInfo personInfo = personInfoService.get(new Long(subject));
+                if (personInfo == null) {
+                    throw new Exception("参数异常");
+                }
+                if (personInfo.getPopedom().contains("3")) {
+                    List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+                    if (personCompanyList.size() > 0) {
+                        for (PersonCompany personCompany : personCompanyList) {
+                            CompanyInfo companyInfo1 = companyInfoService.get(personCompany.getCompanyId());
+                            if (companyInfo1 != null) {
+                                list.add(companyInfo1);
+                            }
+                        }
+                    }
+                }
+
+
+            } else {
+                list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+            }
+
+            if (list.size() > 0) {
+
+
+                List<String> deviceNoList = new ArrayList<>();
+                for (CompanyInfo companyInfo1 : list) {
+                    List<DeviceInfo> deviceInfoList = companyDeviceRelationService.findDeviceByCompanyId(companyInfo1.getId());
+                    for (DeviceInfo deviceInfo : deviceInfoList) {
+                        if (!deviceNoList.contains(deviceInfo.getDeviceNo())) {
+                            deviceNoList.add(deviceInfo.getDeviceNo());
+                        }
+                    }
+                }
+                Page<PersonDeviceLog> personDeviceLogList = new Page<>();
+                if ("all".equals(type)) {
+                    personDeviceLogList = personDeviceLogService.findAllPersonLogByCompanyListAndDeviceNoList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, deviceNoList, pageIndex, pageSize);
+                } else if ("person".equals(type)) {
+                    personDeviceLogList = personDeviceLogService.findLastPersonLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, pageIndex, pageSize);
+                } else if ("visitor".equals(type)) {
+                    personDeviceLogList = personDeviceLogService.findVisitorLogByDeviceNoList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), deviceNoList, pageIndex, pageSize);
+
+                }
+
+
+                msgResult.setData(PojoUtils.pageWrapper(personDeviceLogList));
+
+            } else {
+                msgResult.setData(mapData);
+            }
+
+            msgResult.setMessage("查询成功");
+            msgResult.setResult(true);
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+        }
+
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "学校数字数据")
+    @RequestMapping(value = "numDataForSchool", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", paramType = "query", dataType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
+    })
+    public MessageResult<Map> numDataForSchool(String token, @RequestAttribute String subject) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(subject);
+            if (companyInfo == null) {
+                throw new Exception("学校不存在");
+            }
+            List<CompanyInfo> list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+            List<String> deviceNoList = new ArrayList<>();
+            for (CompanyInfo companyInfo1 : list) {
+                List<DeviceInfo> deviceInfoList = companyDeviceRelationService.findDeviceByCompanyId(companyInfo1.getId());
+                for (DeviceInfo deviceInfo : deviceInfoList) {
+                    if (!deviceNoList.contains(deviceInfo.getDeviceNo())) {
+                        deviceNoList.add(deviceInfo.getDeviceNo());
+                    }
+                }
+            }
+            //应测教职工数
+            Integer teacherNum = Math.toIntExact(personInfoService.countByCompanyListAndPopedom("teacher", list));
+            //应测学生数
+            Integer studentNum = Math.toIntExact(personInfoService.countByCompanyListAndPopedom("student", list));
+            //已测教职工数
+            Integer checkedTeacherNum = personDeviceFilterLogService.getDayCheckedPersonNumByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, "2");
+            Integer checkedTeacherAndStudentNum = personDeviceFilterLogService.getDayCheckedPersonNumByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, "1");
+
+            //已测学生数
+            Integer checkedStudentNum = checkedTeacherAndStudentNum - checkedTeacherNum;
+
+            Integer num = checkNumCompanyService.getDayCheckNumByCompanyList(DateUtil.format(new Date(), "yyyy-MM-dd"), list);
+            Integer totalNum = totalCheckCompanyService.getTotalCheckNum(list);
+            Integer dayCheckNum = num == null ? 0 : num;
+            Integer totalCheckNum = totalNum == null ? dayCheckNum : totalNum + dayCheckNum;
+
+            Integer num2 = personDeviceFilterLogService.getDayAbnormalNumByCompanyList(DateUtil.beginOfDay(new Date()), new Date(), list);
+            Integer totalNum2 = totalCheckCompanyService.getTotalAbnormalNumByCompanyList(list);
+
+            //当日异常
+            Integer dayAbnormalNum = num2 == null ? 0 : num2;
+
+            //总异常
+            Integer totalAbnormalNum = totalNum2 == null ? 0 : totalNum2 + dayAbnormalNum;
+
+            Integer normalDaysNum = totalCheckCompanyService.findMinNormalDayByCompanyList(list);
+            //连续无异常天数
+            Integer normalDays = normalDaysNum == null ? 0 : normalDaysNum;
+
+            HashMap<String, Object> mapData = new HashMap<>();
+            mapData.put("teacherNum", teacherNum);
+            mapData.put("studentNum", studentNum);
+            mapData.put("checkedTeacherNum", checkedTeacherNum);
+            mapData.put("checkedStudentNum", checkedStudentNum);
+            mapData.put("dayAbnormalNum", dayAbnormalNum);
+            mapData.put("totalAbnormalNum", totalAbnormalNum);
+            mapData.put("normalDays", normalDays);
+            msgResult.setMessage("查询成功");
+            msgResult.setResult(true);
+            msgResult.setData(mapData);
+
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+        }
+
+
+        return msgResult;
+    }
+
+    @ApiOperation(value = "学校图片数据")
+    @RequestMapping(value = "picDataForSchool", method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "令牌", paramType = "query", dataType = "form"),
+            @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
+            @ApiImplicitParam(name = "type", value = "老师/学生(teacher/student)", required = true, paramType = "form", dataType = "String"),
+
+    })
+    public MessageResult<Map> picDataForSchool(
+            @RequestParam(value = "type", defaultValue = "all") String type,
+            @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
+            @RequestParam(value = "pageSize", defaultValue = "12") int pageSize,
+            String token, @RequestAttribute String subject) {
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(subject);
+            if (companyInfo == null) {
+                throw new Exception("公司不存在");
+            }
+            List<CompanyInfo> list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+            List<String> deviceNoList = new ArrayList<>();
+            for (CompanyInfo companyInfo1 : list) {
+                List<DeviceInfo> deviceInfoList = companyDeviceRelationService.findDeviceByCompanyId(companyInfo1.getId());
+                for (DeviceInfo deviceInfo : deviceInfoList) {
+                    if (!deviceNoList.contains(deviceInfo.getDeviceNo())) {
+                        deviceNoList.add(deviceInfo.getDeviceNo());
+                    }
+                }
+            }
+            Page<PersonDeviceLog> personDeviceLogList = new Page<>();
+            if ("all".equals(type)) {
+                personDeviceLogList = personDeviceLogService.findLastPersonLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, pageIndex, pageSize);
+            } else if ("teacher".equals(type)) {
+                personDeviceLogList = personDeviceLogService.findLastTeacherLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, pageIndex, pageSize);
+            } else if ("student".equals(type)) {
+                personDeviceLogList = personDeviceLogService.findLastStudentLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list, pageIndex, pageSize);
+
+            }
+
+
+            msgResult.setMessage("查询成功");
+            msgResult.setResult(true);
+            msgResult.setData(PojoUtils.pageWrapper(personDeviceLogList));
+
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            msgResult.setResult(false);
+            msgResult.setMessage(e.getMessage());
+        }
+
+
+        return msgResult;
+    }
+
+    @GetMapping("/getCompanyToken")
+    @ApiOperation(value = "根据公司id获取token")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "companyInfoId", paramType = "query", required = true, value = "公司id")
+    })
+    public MessageResult<String> getCompanyToken(String companyInfoId, @ApiIgnore HttpSession session) {
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(companyInfoId);
+
+            DES3 des3 = new DES3();
+
+
+            if (companyInfo != null) {
+
+                //生成token
+                String token = JwtUtil.createToken(jwtSecret, companyInfoId, DateTime.now().plusHours(6).toDate());
+
+                session.setAttribute("companyToken", token);
+
+                messageResult.setResult(true);
+                messageResult.setData(token);
+            } else {
+                messageResult.setResult(false);
+                messageResult.setMessage("公司不存在!");
+            }
+
+        } catch (Exception ex) {
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+}

+ 39 - 1
web/src/main/java/com/jpsoft/smart/modules/wechat/controller/WxCpController.java

@@ -5,6 +5,8 @@ import com.jpsoft.smart.config.WxCpConfiguration;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
+import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
 import me.chanjar.weixin.cp.util.crypto.WxCpCryptUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,7 +26,7 @@ public class WxCpController {
     private WxCpConfig wxCpConfig;
 
     @ApiOperation(value = "验证服务器地址的有效性")
-    @GetMapping("/get")
+    @GetMapping(produces = "text/plain;charset=utf-8")
     @ResponseBody
     public String index(@PathVariable Integer agentId,
                         @RequestParam(name = "msg_signature", required = false) String signature,
@@ -53,4 +55,40 @@ public class WxCpController {
 
 
     }
+
+    @PostMapping(produces = "application/xml; charset=UTF-8")
+    public String post(@PathVariable Integer agentId,
+                       @RequestBody String requestBody,
+                       @RequestParam("msg_signature") String signature,
+                       @RequestParam("timestamp") String timestamp,
+                       @RequestParam("nonce") String nonce) {
+        log.info("\n接收微信请求:[signature=[{}], timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
+                signature, timestamp, nonce, requestBody);
+
+        log.info(agentId.toString());
+        final WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
+        WxCpXmlMessage inMessage = WxCpXmlMessage.fromEncryptedXml(requestBody, wxCpService.getWxCpConfigStorage(),
+                timestamp, nonce, signature);
+        log.warn("\n消息解密后内容为:\n{} ", inMessage);
+        WxCpXmlOutMessage outMessage = this.route(agentId, inMessage);
+        if (outMessage == null) {
+            return "";
+        }
+
+        String out = outMessage.toEncryptedXml(wxCpService.getWxCpConfigStorage());
+        log.debug("\n组装回复信息:{}", out);
+        return out;
+    }
+
+    private WxCpXmlOutMessage route(Integer agentId, WxCpXmlMessage message) {
+        try {
+            return WxCpConfiguration.getRouters().get(agentId).route(message);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+
+        return null;
+    }
+
+
 }