From eeec8c90f5a93fb5b91050da25378395d8490b21 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sun, 7 Aug 2022 19:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8B=86?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/ShopStoreIntercourseMation.java | 45 ----- .../store/ShopStoreIntercourseMationRest.java | 24 --- .../eve/rest/shop/store/ShopStoreService.java | 51 ----- .../java/com/skyeye/eve/dao/MainPageDao.java | 4 - .../eve/service/impl/MainPageServiceImpl.java | 5 +- .../mapper/gateway/MainPageMapper.xml | 18 -- .../com/skyeye/sys/quartz/HotForumQuartz.java | 189 ------------------ .../quartz/ShopStoreIntercourseQuartz.java | 91 --------- .../src/main/resources/bootstrap.yml | 2 - 9 files changed, 3 insertions(+), 426 deletions(-) delete mode 100644 skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMation.java delete mode 100644 skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMationRest.java delete mode 100644 skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/rest/shop/store/ShopStoreService.java delete mode 100644 skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java delete mode 100644 skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/ShopStoreIntercourseQuartz.java diff --git a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMation.java b/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMation.java deleted file mode 100644 index a92d8d25..00000000 --- a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye - ******************************************************************************/ - -package com.skyeye.eve.entity.shop.store; - -import lombok.Data; - -/** - * @ClassName: ShopStoreIntercourseEntity - * @Description: - * @author: skyeye云系列--卫志强 - * @date: 2022/3/10 21:51 - * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. - * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 - */ -@Data -public class ShopStoreIntercourseMation { - - /** - * 保养门店id - */ - private String keepfitStoreId; - - /** - * 套餐购买门店 - */ - private String mealByStoreId; - - /** - * 总的耗材费用 - */ - private String mealAllSinglePrice; - - /** - * 创建日期,格式为:yyyy-MM-dd - */ - private String createTime; - - /** - * 状态 1.待套餐购买门店确认 2.待保养门店确认 3.已确认 - */ - private Integer state; - -} diff --git a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMationRest.java b/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMationRest.java deleted file mode 100644 index 0a14b200..00000000 --- a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/entity/shop/store/ShopStoreIntercourseMationRest.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye - ******************************************************************************/ - -package com.skyeye.eve.entity.shop.store; - -import lombok.Data; - -import java.util.List; - -/** - * @ClassName: ShopStoreIntercourseEntity - * @Description: 门店往来入参实体类 - * @author: skyeye云系列--卫志强 - * @date: 2022/3/10 21:51 - * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. - * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 - */ -@Data -public class ShopStoreIntercourseMationRest { - - private List shopStoreIntercourseMationList; - -} diff --git a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/rest/shop/store/ShopStoreService.java b/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/rest/shop/store/ShopStoreService.java deleted file mode 100644 index 4e91d972..00000000 --- a/skyeye-promote/skyeye-entity/src/main/java/com/skyeye/eve/rest/shop/store/ShopStoreService.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye - ******************************************************************************/ - -package com.skyeye.eve.rest.shop.store; - -import com.skyeye.common.client.ClientConfiguration; -import com.skyeye.eve.entity.shop.store.ShopStoreIntercourseMationRest; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * @ClassName: ShopStoreService - * @Description: 商城门店 - * @author: skyeye云系列--卫志强 - * @date: 2022/2/2 15:24 - * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. - * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 - */ -@FeignClient(value = "${webroot.skyeye-shop}", configuration = ClientConfiguration.class) -public interface ShopStoreService { - - /** - * 获取指定日期的支出/收入往来的数据 - * - * @param day 日期,格式为yyyy-MM-dd - * @return 指定日期的支出/收入往来的数据 - */ - @GetMapping("/queryStoreIntercourseByDay") - String queryStoreIntercourseByDay(@RequestParam("day") String day); - - /** - * 获取指定日期的支出/收入往来的数据---用于查指定日期的数据是否入库 - * - * @param day 日期,格式为yyyy-MM-dd - * @return 指定日期的支出/收入往来的数据 - */ - @GetMapping("/queryStoreIntercourseListByDay") - String queryStoreIntercourseListByDay(@RequestParam("day") String day); - - /** - * 新增支出/收入往来的数据 - * - * @param shopStoreIntercourseMationRest 支出/收入往来的数据 - */ - @PostMapping("/insertStoreIntercourse") - String insertStoreIntercourse(ShopStoreIntercourseMationRest shopStoreIntercourseMationRest); - -} diff --git a/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/dao/MainPageDao.java b/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/dao/MainPageDao.java index 8e843e82..ec7d9a6f 100644 --- a/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/dao/MainPageDao.java +++ b/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/dao/MainPageDao.java @@ -27,8 +27,4 @@ public interface MainPageDao { List> queryKnowledgeContentPhoneList(Map map); - int insertForumHotByList(List> list); - - int insertForumStatisticsDayByList(List> list); - } diff --git a/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/service/impl/MainPageServiceImpl.java b/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/service/impl/MainPageServiceImpl.java index 84578d28..634d5cab 100644 --- a/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/service/impl/MainPageServiceImpl.java +++ b/skyeye-promote/skyeye-gateway/src/main/java/com/skyeye/eve/service/impl/MainPageServiceImpl.java @@ -95,7 +95,8 @@ public class MainPageServiceImpl implements MainPageService { String createTime = ToolUtil.timeFormat(m.get("createTime").toString()); m.put("createTime", createTime); String key = ForumConstants.forumBrowseNumsByForumId(m.get("id").toString()); - if (ToolUtil.isBlank(jedisClient.get(key))) {//浏览量 + if (ToolUtil.isBlank(jedisClient.get(key))) { + // 浏览量 m.put("browseNum", 0); } else { String browseNum = jedisClient.get(key); @@ -103,7 +104,7 @@ public class MainPageServiceImpl implements MainPageService { } } //按浏览量和评论数给集合排序 - beans.sort(new Comparator>() {//Comparator 比较器. 需要实现比较方法 + beans.sort(new Comparator>() { @Override public int compare(Map m1, Map m2) { Integer m1num = Integer.parseInt(m1.get("browseNum").toString()) + Integer.parseInt(m1.get("commentNum").toString()); diff --git a/skyeye-promote/skyeye-gateway/src/main/resources/mapper/gateway/MainPageMapper.xml b/skyeye-promote/skyeye-gateway/src/main/resources/mapper/gateway/MainPageMapper.xml index dba058f5..78e194a1 100644 --- a/skyeye-promote/skyeye-gateway/src/main/resources/mapper/gateway/MainPageMapper.xml +++ b/skyeye-promote/skyeye-gateway/src/main/resources/mapper/gateway/MainPageMapper.xml @@ -138,22 +138,4 @@ LIMIT 8 - - insert into forum_hot - (id, forum_id, update_time) - values - - (#{item.id}, #{item.forumId}, #{item.time}) - - - - - insert into forum_statistics_day - (id, forum_id, browse_num, comment_num, create_time) - values - - (#{item.id}, #{item.forumId}, #{item.bnum}, #{item.cnum}, #{item.time}) - - - \ No newline at end of file diff --git a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java b/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java deleted file mode 100644 index da789d9f..00000000 --- a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye - ******************************************************************************/ - -package com.skyeye.sys.quartz; - -import com.skyeye.common.constans.ForumConstants; -import com.skyeye.common.util.DateAfterSpacePointTime; -import com.skyeye.common.util.DateUtil; -import com.skyeye.common.util.ToolUtil; -import com.skyeye.eve.dao.MainPageDao; -import com.skyeye.jedis.JedisClientService; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.text.DecimalFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * @ClassName: HotForumQuartz - * @Description: 每天凌晨两点去计算每日热门贴 - * @author: skyeye云系列--卫志强 - * @date: 2021/7/6 23:09 - * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. - * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 - */ -@Component -public class HotForumQuartz { - - private static Logger log = LoggerFactory.getLogger(HotForumQuartz.class); - - @Autowired - public JedisClientService jedisClient; - - @Autowired - public MainPageDao mainPageDao; - - /** - * 定时器计算每日热门贴 - */ - @XxlJob("hotForumQuartz") - public void editHotForumMation() { - try { - String yestoday = DateAfterSpacePointTime.getSpecifiedTime( - DateAfterSpacePointTime.ONE_DAY.getType(), DateUtil.getTimeAndToString(), DateUtil.YYYY_MM_DD, DateAfterSpacePointTime.AroundType.BEFORE); - String everydayBrowseKey = ForumConstants.forumEverydayBrowseIdsByTime(yestoday); - if (!ToolUtil.isBlank(jedisClient.get(everydayBrowseKey))) {//获取昨天被浏览过的帖子 - String str = jedisClient.get(everydayBrowseKey); - String[] forumarr = str.split(","); - List> beans = new LinkedList<>(); - List> list = new LinkedList<>(); - for (int i = 0, len = forumarr.length; i < len; i++) { - //计算一天的浏览量 - String browseNumsKey = ForumConstants.forumBrowseNumsByForumId(forumarr[i]); - String ybrowseNumsKey = ForumConstants.forumYesterdayBrowseNumsByForumId(forumarr[i]); - String bnownum = "0"; - if (!ToolUtil.isBlank(jedisClient.get(browseNumsKey))) { - bnownum = jedisClient.get(browseNumsKey);//帖子当前的浏览量 - } - String byestodaynum = "0"; - if (!ToolUtil.isBlank(jedisClient.get(ybrowseNumsKey))) { - byestodaynum = jedisClient.get(ybrowseNumsKey);//帖子昨天的浏览量 - } - String bnum = String.valueOf(Integer.parseInt(bnownum) - Integer.parseInt(byestodaynum));//帖子一天的浏览量 - - //计算一天的评论量 - String commentNumsKey = ForumConstants.forumCommentNumsByForumId(forumarr[i]); - String ycommentNumsKey = ForumConstants.forumYesterdayCommentNumsByForumId(forumarr[i]); - String cnownum = "0"; - if (!ToolUtil.isBlank(jedisClient.get(commentNumsKey))) { - cnownum = jedisClient.get(commentNumsKey);//帖子当前的评论量 - } - String cyestodaynum = "0"; - if (!ToolUtil.isBlank(jedisClient.get(ycommentNumsKey))) { - cyestodaynum = jedisClient.get(ycommentNumsKey);//帖子昨天的评论量 - } - String cnum = String.valueOf(Integer.parseInt(cnownum) - Integer.parseInt(cyestodaynum));//帖子一天的评论量 - - Map map = new HashMap<>(); - map.put("id", ToolUtil.getSurFaceId()); - map.put("forumId", forumarr[i]); - map.put("bnum", bnum); - map.put("cnum", cnum); - map.put("time", yestoday); - list.add(map); - jedisClient.set(ybrowseNumsKey, bnownum);//更新浏览量 - jedisClient.set(ycommentNumsKey, cnownum);//更新评论量 - - String everyforumEverydayNums = ForumConstants.everyforumEverydayNumsByIdAndTime(forumarr[i], yestoday); - jedisClient.set(everyforumEverydayNums, String.valueOf(Integer.parseInt(bnum) + Integer.parseInt(cnum)));//将每个帖子每天的浏览量+评论量存入redis中 - - if (list.size() >= 20) {//每20条数据保存一次 - mainPageDao.insertForumStatisticsDayByList(list);//将每天被浏览过的帖子存入统计表中 - if (!beans.isEmpty()) { - list.addAll(beans); - beans.clear(); - } - list = sortListByNums(list, yestoday);//根据近七天的浏览量和评论量的算术平均值对list进行排序 - beans.addAll(list.subList(0, 6));//取前六条放入beans中 - list.clear(); - } - } - - if (!list.isEmpty()) { - mainPageDao.insertForumStatisticsDayByList(list);//将每天被浏览过的帖子存入统计表中 - if (!beans.isEmpty()) { - list.addAll(beans); - beans.clear(); - } - list = sortListByNums(list, yestoday);//根据近七天的浏览量和评论量的算术平均值对list进行排序 - int count = list.size(); - int pageMaxSize = 6; - if (count < pageMaxSize) { - pageMaxSize = count; - } - beans.addAll(list.subList(0, pageMaxSize));//取前六条放入beans中 - } - - if (!beans.isEmpty()) { - mainPageDao.insertForumHotByList(beans); - } - jedisClient.del(everydayBrowseKey);//清空每天被浏览过的帖子 - } else { - jedisClient.del(everydayBrowseKey);//清空每天被浏览过的帖子 - } - } catch (Exception e) { - log.warn("editHotForumMation error.", e); - } - } - - /** - * 获取过去7天内的日期数组 - * - * @return 日期数组 - * @throws ParseException - */ - public static ArrayList pastDay(String time) throws ParseException { - ArrayList pastDaysList = new ArrayList<>(); - SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.YYYY_MM_DD); - Date date = sdf.parse(time); - for (int i = 6; i >= 0; i--) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - i); - Date today = calendar.getTime(); - String result = sdf.format(today); - pastDaysList.add(result); - } - return pastDaysList; - } - - /** - * 根据近七天的浏览量和评论量的算术平均值对list进行排序 - * - * @return 日期数组 - * @throws ParseException - */ - public List> sortListByNums(List> list, String time) throws ParseException { - DecimalFormat df = new DecimalFormat("0.00");//格式化小数 - for (Map m : list) { - ArrayList datelist = pastDay(time);//获取近七天的日期数组集合 - int nums = 0; - for (String date : datelist) { - String everyforumEverydayNum = ForumConstants.everyforumEverydayNumsByIdAndTime(m.get("forumId").toString(), date); - if (!ToolUtil.isBlank(jedisClient.get(everyforumEverydayNum))) {//获取每个帖子每天的浏览量+评论量 - nums += Integer.parseInt(jedisClient.get(everyforumEverydayNum)); - } - } - m.put("nums", String.valueOf(df.format((float) nums / 7)));//将帖子近七天的评论量、浏览量的算术平均值保留两位小数放入map中 - } - //按帖子近七天的评论量、浏览量的算术平均值给集合排序 - list.sort(new Comparator>() {//Comparator 比较器. 需要实现比较方法 - @Override - public int compare(Map m1, Map m2) { - Integer m1num = (int) Float.parseFloat(m1.get("nums").toString()) * 100; - Integer m2num = (int) Float.parseFloat(m2.get("nums").toString()) * 100; - int flag = m1num.compareTo(m2num); - return -flag; // 取反,按倒序排列 - } - }); - return list; - } - -} diff --git a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/ShopStoreIntercourseQuartz.java b/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/ShopStoreIntercourseQuartz.java deleted file mode 100644 index ee0d1a10..00000000 --- a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/ShopStoreIntercourseQuartz.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye - ******************************************************************************/ - -package com.skyeye.sys.quartz; - -import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; -import com.skyeye.common.client.ExecuteFeignClient; -import com.skyeye.common.util.DateAfterSpacePointTime; -import com.skyeye.common.util.DateUtil; -import com.skyeye.common.util.ToolUtil; -import com.skyeye.eve.entity.shop.store.ShopStoreIntercourseMation; -import com.skyeye.eve.entity.shop.store.ShopStoreIntercourseMationRest; -import com.skyeye.eve.rest.shop.store.ShopStoreService; -import com.skyeye.jedis.util.RedisLock; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Map; - -/** - * @ClassName: ShopStoreIntercourseQuartz - * @Description: 门店昨日支出/收入往来计算 - * @author: skyeye云系列--卫志强 - * @date: 2022/3/10 21:13 - * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. - * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 - */ -@Component -public class ShopStoreIntercourseQuartz { - - private static Logger log = LoggerFactory.getLogger(ShopStoreIntercourseQuartz.class); - - @Autowired - private ShopStoreService shopStoreService; - - private static final String LOCK_KEY = "calcShopStoreIntercourse"; - - /** - * 定时器计算门店昨日支出/收入往来信息,每天凌晨两点执行一次 - */ - @XxlJob("shopStoreIntercourseQuartz") - public void calcShopStoreIntercourse() { - log.info("定时器计算门店昨日支出/收入往来信息执行 start"); - RedisLock lock = new RedisLock(LOCK_KEY); - try { - if (!lock.lock()) { - // 加锁失败 - return; - } - // 得到昨天的时间 - String yesterdayTime = DateAfterSpacePointTime.getSpecifiedTime( - DateAfterSpacePointTime.ONE_DAY.getType(), DateUtil.getTimeAndToString(), DateUtil.YYYY_MM_DD, DateAfterSpacePointTime.AroundType.BEFORE); - log.info("yesterdayTime is {}.", yesterdayTime); - // 判断昨天的数据是否已经统计过并入库,如果已经统计过,则不会进行下一次的统计 - List> yesterdayData = ExecuteFeignClient.get(() -> shopStoreService.queryStoreIntercourseListByDay(yesterdayTime)).getRows(); - if (!CollectionUtils.isEmpty(yesterdayData)) { - log.info("已统计过昨日数据,不再进行统计"); - return; - } - log.info("开始统计"); - // 获取昨天的往来数据信息 - yesterdayData = ExecuteFeignClient.get(() -> shopStoreService.queryStoreIntercourseByDay(yesterdayTime)).getRows(); - List shopStoreIntercourse = JSONUtil.toList(JSON.toJSONString(yesterdayData), ShopStoreIntercourseMation.class); - shopStoreIntercourse.forEach(bean -> { - if (ToolUtil.isBlank(bean.getMealByStoreId())) { - bean.setState(2); - } else { - bean.setState(1); - } - }); - log.info("解析数据为 {}.", JSON.toJSONString(shopStoreIntercourse)); - ShopStoreIntercourseMationRest shopStoreIntercourseVO = new ShopStoreIntercourseMationRest(); - shopStoreIntercourseVO.setShopStoreIntercourseMationList(shopStoreIntercourse); - shopStoreService.insertStoreIntercourse(shopStoreIntercourseVO); - log.info("保存数据完成"); - } catch (Exception e) { - log.warn("calcShopStoreIntercourse error.", e); - } finally { - lock.unlock(); - } - log.info("定时器计算门店昨日支出/收入往来信息 end"); - } - -} diff --git a/skyeye-promote/skyeye-web/src/main/resources/bootstrap.yml b/skyeye-promote/skyeye-web/src/main/resources/bootstrap.yml index 9b2434d6..81dd7829 100644 --- a/skyeye-promote/skyeye-web/src/main/resources/bootstrap.yml +++ b/skyeye-promote/skyeye-web/src/main/resources/bootstrap.yml @@ -29,8 +29,6 @@ logging: com.skyeye.eve.dao: debug webroot: - # 商城服务 - skyeye-shop: skyeye-shop-${spring.profiles.active} # 工作流相关的服务 skyeye-flowable: skyeye-flowable-${spring.profiles.active} # xxl-job