| | |
| | | package com.panzhihua.common.utlis; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import com.panzhihua.common.model.dtos.wx.WxSubscribeDTO; |
| | | |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidDangerMemberVO; |
| | | import com.panzhihua.common.model.vos.community.reserve.FiveCount; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | @Slf4j |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送危险人员订阅消息通知 |
| | | * @param openId 用户openid |
| | | * @param accessToken token会话标识 |
| | | * @param fiveCount 统计数据 |
| | | */ |
| | | public static void sendSubscribeStatics(String openId, String accessToken, FiveCount fiveCount, String templateId){ |
| | | WxSubscribeDTO subscribeDTO = new WxSubscribeDTO(); |
| | | subscribeDTO.setTouser(openId); |
| | | subscribeDTO.setTemplate_id(templateId); |
| | | subscribeDTO.setPage("/packageB/pages/register/reportingStatistics/reportingStatistics"); |
| | | List<TemplateParam> paras=new ArrayList<TemplateParam>(); |
| | | paras.add(new TemplateParam("thing2", "报备总数"+fiveCount.getAllCount()+";"+"风险人员"+fiveCount.getDangerCount())); |
| | | paras.add(new TemplateParam("time3", DateUtils.getDateFormatString(DateUtils.addDay(new Date(),-1),"yyyy-MM-dd")+"0点到24点")); |
| | | paras.add(new TemplateParam("thing1","新冠疫情")); |
| | | paras.add(new TemplateParam("thing4", "社区报备数据统计")); |
| | | subscribeDTO.setTemplateParamList(paras); |
| | | try { |
| | | sendSubscribe(accessToken,subscribeDTO); |
| | | }catch (Exception e){ |
| | | log.error("危险人员订阅消息推送失败,失败原因:" + e.getMessage()); |
| | | } |
| | | } |
| | | public static void main(String[] args) { |
| | | |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | |
| | | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | |
| | | @SpringCloudApplication |
| | | @EnableFeignClients(basePackages = {"com.panzhihua.common.service"}) |
| | | @EnableEurekaClient |
| | | @EnableCircuitBreaker |
| | | @ComponentScan({"com.panzhihua.service_community", "com.panzhihua.common"}) |
| | | @EnableScheduling |
| | | public class ServiceCommunityApplication { |
| | | |
| | | public static void main(String[] args) { |
| | |
| | | * @return |
| | | */ |
| | | Integer countryStatics(@Param("departureCity") String departureCity, @Param("date") String date,@Param("localCity")String localCity); |
| | | |
| | | /** |
| | | * 7项统计 |
| | | * @param date |
| | | * @param localCity |
| | | * @return |
| | | */ |
| | | FiveCount pushStatics(@Param("date") String date,@Param("localCity") String localCity); |
| | | } |
New file |
| | |
| | | package com.panzhihua.service_community.schedule; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO; |
| | | import com.panzhihua.common.model.vos.community.reserve.FiveCount; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | import com.panzhihua.service_community.dao.ComActAcidMemberDao; |
| | | import com.panzhihua.service_community.dao.ComActAcidRecordDao; |
| | | import com.panzhihua.service_community.entity.ComActAcidMember; |
| | | import com.panzhihua.service_community.entity.ComActAcidRecord; |
| | | import com.panzhihua.service_community.service.ComActAcidMemberService; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import static java.util.Objects.nonNull; |
| | | |
| | | /** |
| | | * 定时每天早上推送当天防疫数据 |
| | | * @author zzj |
| | | */ |
| | | @Component |
| | | public class AcidSchedule { |
| | | @Resource |
| | | private ComActAcidMemberDao comActAcidMemberDao; |
| | | @Resource |
| | | private ComActAcidRecordDao comActAcidRecordDao; |
| | | |
| | | @Scheduled(cron = "0 0 9 * * *") |
| | | public void push(){ |
| | | List<ComActAcidMemberVO> comActAcidMemberList=comActAcidMemberDao.selectPushList(""); |
| | | comActAcidMemberList.forEach(comActAcidMember -> { |
| | | FiveCount fiveCount=comActAcidRecordDao.pushStatics(DateUtils.getDateFormatString(DateUtils.addDay(new Date(),-1),"yyyy-MM-dd"),comActAcidMember.getRelationName()); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getXQAppAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | WxUtil.sendSubscribeStatics(comActAcidMember.getOpenid(), accessToken, fiveCount, "Yr5idSziLRiRo0t07mcz284sMm41Kr2KsA5UmSc0jWU"); |
| | | }); |
| | | } |
| | | } |
| | |
| | | SELECT t1.id, t1.`name`, t1.phone, t2.openid |
| | | FROM com_act_acid_member t1 |
| | | JOIN sys_user t2 ON t1.phone = t2.phone AND `type` = 1 |
| | | WHERE t1.push_status = 1 AND t1.relation_name = #{relationName} |
| | | WHERE t1.push_status = 1 <if test="relationName!=null and relationName !=''">AND t1.relation_name = #{relationName}</if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | (select count(*) from com_act_acid_record where outside_city = '是' <if test="date!=null and date!=''"> and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59')</if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'"> and local_city like concat('%',#{localCity},'%')</if>) outsideCount |
| | | </select> |
| | | |
| | | <select id="pushStatics" resultType="com.panzhihua.common.model.vos.community.reserve.FiveCount"> |
| | | select (select count(*) from com_act_acid_record where 1=1 <if test="date!=null and date!=''"> and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59')</if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'"> and local_city like concat('%',#{localCity},'%')</if>) allCount, |
| | | (select count(*) from com_act_acid_danger_member t LEFT JOIN com_act_acid_danger_member t1 on t.record_id = t1.id where 1=1 <if test="date!=null and date!=''"> and t.create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59')</if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'"> and t1.local_city like concat('%',#{localCity},'%')</if>) dangerCount |
| | | </select> |
| | | |
| | | </mapper> |