Commit 70a8733d authored by shiyu's avatar shiyu

定时作业晚上八点执行

parent 7fc3376e
...@@ -370,6 +370,12 @@ public class GroupPurchaseServiceImpl implements GroupPurchaseService { ...@@ -370,6 +370,12 @@ public class GroupPurchaseServiceImpl implements GroupPurchaseService {
return Result.failed(); return Result.failed();
} }
/**
* 废弃
* @param dto
* @return
*/
@Deprecated
@Override @Override
public Result sendMsgFromExcel(GroupPurchaseRecordRequestDto dto) { public Result sendMsgFromExcel(GroupPurchaseRecordRequestDto dto) {
try { try {
......
...@@ -876,7 +876,6 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -876,7 +876,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
} }
supplierItemVo.setIsCollected(true); supplierItemVo.setIsCollected(true);
SupplierItem supplierItem = supplierItemDao.findById(itemId); SupplierItem supplierItem = supplierItemDao.findById(itemId);
logger.info("藏品id:{}, 数据库查询结果:{}", itemId, JsonUtils.from(supplierItem));
if (supplierItem.getIsOnSale()) { if (supplierItem.getIsOnSale()) {
supplierItemVo.setPostType(DistributionEnum.PostTypeEnum.SALE.getCode()); supplierItemVo.setPostType(DistributionEnum.PostTypeEnum.SALE.getCode());
supplierItemVo.setAppendImageUrl(APPEND_IMAGE_URL); supplierItemVo.setAppendImageUrl(APPEND_IMAGE_URL);
...@@ -932,7 +931,6 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -932,7 +931,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setCollectorsAvatar(avatarList); supplierItemVo.setCollectorsAvatar(avatarList);
} }
EntityMapper.copyAttribute(supplierItem, supplierItemVo); EntityMapper.copyAttribute(supplierItem, supplierItemVo);
logger.info("藏品id:{}, 转换后结果:{}", itemId, JsonUtils.from(supplierItemVo));
supplierItemVo.setItemId(supplierItem.getId()); supplierItemVo.setItemId(supplierItem.getId());
supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice())); supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
...@@ -985,7 +983,6 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -985,7 +983,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setBookIdList(list); supplierItemVo.setBookIdList(list);
} }
} }
logger.info("藏品id:{}, 最终返回结果:{}", itemId, JsonUtils.from(supplierItemVo));
return Result.success(supplierItemVo); return Result.success(supplierItemVo);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询上传的藏品详情 error : {}", e); logger.error("查询上传的藏品详情 error : {}", e);
......
...@@ -43,17 +43,16 @@ public class SendMsgFromExcelJob { ...@@ -43,17 +43,16 @@ public class SendMsgFromExcelJob {
RedissonClient redissonClient; RedissonClient redissonClient;
// 每年8月8日晚上8点执行一次 // 每年8月8日晚上8点执行一次
// @Scheduled(cron = "0 0 20 8 8 ?") @Scheduled(cron = "0 0 20 8 8 ?")
@Scheduled(cron = "0 20 15 8 8 ?")
public void executeTask() { public void executeTask() {
RLock lock = redissonClient.getLock(SENDMSGFROMEXCEL_KEY); RLock lock = redissonClient.getLock(SENDMSGFROMEXCEL_KEY);
if (!lock.tryLock()) { if (!lock.tryLock()) {
logger.warn("给指定类目用户发送通知任务,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行", Thread.currentThread().getId()); logger.info("给指定类目用户发送通知任务,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行", Thread.currentThread().getId());
return; return;
} }
logger.info(">>>>>>>>>>>> sendMsgFromExcel 开始执行 <<<<<<<<<<<<"); logger.info(">>>>>>>>>>>> sendMsgFromExcel 开始执行 <<<<<<<<<<<<");
try { try {
String key = "xmly:sendMsgFromExcel"; String key = "xmly:sendMsgFromExcel:0808";
Date now = new Date(); Date now = new Date();
if (redisUtils.hasKey(key)) { if (redisUtils.hasKey(key)) {
String msg = "给指定类目用户发送通知任务正在重复执行"; String msg = "给指定类目用户发送通知任务正在重复执行";
...@@ -74,12 +73,14 @@ public class SendMsgFromExcelJob { ...@@ -74,12 +73,14 @@ public class SendMsgFromExcelJob {
logger.info(">>>>>>>>>> 喜马拉雅类目 excel 读取数据 : {} 条", dataList.size()); logger.info(">>>>>>>>>> 喜马拉雅类目 excel 读取数据 : {} 条", dataList.size());
dataList.stream().forEach(row -> { dataList.stream().forEach(row -> {
String phone = row.get(0); String phone = row.get(0);
logger.info("手机号: {}, 喜马拉雅类目, 发送短信成功", phone); String url = wxAppletApi.getUrlLink(CommConsts.ITEM_OF_GROUPPURCHASE_URL,"itemId=" + 32894809);
});
/* String url = wxAppletApi.getUrlLink(CommConsts.ITEM_OF_GROUPPURCHASE_URL,"itemId=" + 32894809);
//发短信 //发短信
String msg = "藏传手绘黄财神小唐卡开启众筹啦,请前往"+ url + "查看"; String msg = "藏传手绘黄财神小唐卡开启众筹啦,请前往"+ url + "查看";
aliSmsSender.sendSms("15757185512", msg);*/ aliSmsSender.sendSms(phone, msg);
logger.info("手机号: {}, 喜马拉雅类目, 发送短信成功", phone);
});
String successMsg = "给指定类目用户发送通知执行完成";
aliSmsSender.sendSms("15757185512", successMsg);
redisUtils.set(key, now, 3600 * 24); redisUtils.set(key, now, 3600 * 24);
logger.info(">>>>>>>>>>>> sendMsgFromExcel 发送通知给指定用户定时任务执行完成 <<<<<<<<<<<<"); logger.info(">>>>>>>>>>>> sendMsgFromExcel 发送通知给指定用户定时任务执行完成 <<<<<<<<<<<<");
} catch (Exception e) { } catch (Exception e) {
......
package com.wwdz.ch.wx.api; package com.wwdz.ch.wx.api;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.wwdz.ch.core.api.OfficialAccountApi; import com.wwdz.ch.core.api.OfficialAccountApi;
import com.wwdz.ch.core.api.WxAppletApi; import com.wwdz.ch.core.api.WxAppletApi;
import com.wwdz.ch.core.consts.CommConsts; import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg; import com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg;
import com.wwdz.ch.core.notify.AliSmsSender; import com.wwdz.ch.core.notify.AliSmsSender;
import com.wwdz.ch.core.util.PriceUtil; import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.core.util.StringArrayExcelReadListener;
import com.xxdxxs.utils.DateUtils; import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.ExcelRead;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.InputStream;
import java.util.Date; import java.util.Date;
import java.util.List;
@SpringBootTest @SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
public class OfficialAccountApiTest { public class OfficialAccountApiTest {
private static final Logger logger = LoggerFactory.getLogger(OfficialAccountApiTest.class);
@Autowired @Autowired
OfficialAccountApi officialAccountApi; OfficialAccountApi officialAccountApi;
...@@ -69,4 +81,29 @@ public class OfficialAccountApiTest { ...@@ -69,4 +81,29 @@ public class OfficialAccountApiTest {
aliSmsSender.sendSms("13645712452", msg); aliSmsSender.sendSms("13645712452", msg);
} }
@Test
public void sendSmsFromExcel() {
String fileName = "喜马拉雅品类用户手机号.xlsx";
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
StringArrayExcelReadListener listener = new StringArrayExcelReadListener();
ExcelReader reader = EasyExcelFactory.read(inputStream, listener).build();
ReadSheet readSheet = EasyExcel.readSheet(0).build();
reader.read(readSheet);
reader.finish();
List<String> head = listener.getHead();
logger.info("excel title = {}", head);
List<List<String>> dataList = listener.getData();
logger.info(">>>>>>>>>> excel 读取数据 : {} 条", dataList.size());
dataList.stream().forEach(row -> {
String phone = row.get(0);
logger.info("手机号: {}", phone);
});
/* String url = wxAppletApi.getUrlLink(CommConsts.ITEM_OF_GROUPPURCHASE_URL,"itemId=" + 32894809);
//发短信
String msg = "手工扎基拉姆财神唐卡开启众筹,请前往"+ url + "查看";
aliSmsSender.sendSms("13645712452", msg);*/
}
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment