Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
70a8733d
Commit
70a8733d
authored
Aug 08, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时作业晚上八点执行
parent
7fc3376e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
11 deletions
+52
-11
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/GroupPurchaseServiceImpl.java
...wdz/ch/wx/impl/distribution/GroupPurchaseServiceImpl.java
+6
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
...wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
+0
-3
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/SendMsgFromExcelJob.java
...src/main/java/com/wwdz/ch/wx/job/SendMsgFromExcelJob.java
+9
-8
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/OfficialAccountApiTest.java
.../test/java/com/wwdz/ch/wx/api/OfficialAccountApiTest.java
+37
-0
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/GroupPurchaseServiceImpl.java
View file @
70a8733d
...
...
@@ -370,6 +370,12 @@ public class GroupPurchaseServiceImpl implements GroupPurchaseService {
return
Result
.
failed
();
}
/**
* 废弃
* @param dto
* @return
*/
@Deprecated
@Override
public
Result
sendMsgFromExcel
(
GroupPurchaseRecordRequestDto
dto
)
{
try
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
View file @
70a8733d
...
...
@@ -876,7 +876,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
}
supplierItemVo
.
setIsCollected
(
true
);
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
itemId
);
logger
.
info
(
"藏品id:{}, 数据库查询结果:{}"
,
itemId
,
JsonUtils
.
from
(
supplierItem
));
if
(
supplierItem
.
getIsOnSale
())
{
supplierItemVo
.
setPostType
(
DistributionEnum
.
PostTypeEnum
.
SALE
.
getCode
());
supplierItemVo
.
setAppendImageUrl
(
APPEND_IMAGE_URL
);
...
...
@@ -932,7 +931,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo
.
setCollectorsAvatar
(
avatarList
);
}
EntityMapper
.
copyAttribute
(
supplierItem
,
supplierItemVo
);
logger
.
info
(
"藏品id:{}, 转换后结果:{}"
,
itemId
,
JsonUtils
.
from
(
supplierItemVo
));
supplierItemVo
.
setItemId
(
supplierItem
.
getId
());
supplierItemVo
.
setDistributionPrice
(
PriceUtil
.
convertPriceFenToYuan
(
supplierItem
.
getDistributionPrice
()));
supplierItemVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
supplierItem
.
getImages
(),
supplierItem
.
getVideos
()));
...
...
@@ -985,7 +983,6 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo
.
setBookIdList
(
list
);
}
}
logger
.
info
(
"藏品id:{}, 最终返回结果:{}"
,
itemId
,
JsonUtils
.
from
(
supplierItemVo
));
return
Result
.
success
(
supplierItemVo
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询上传的藏品详情 error : {}"
,
e
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/SendMsgFromExcelJob.java
View file @
70a8733d
...
...
@@ -43,17 +43,16 @@ public class SendMsgFromExcelJob {
RedissonClient
redissonClient
;
// 每年8月8日晚上8点执行一次
// @Scheduled(cron = "0 0 20 8 8 ?")
@Scheduled
(
cron
=
"0 20 15 8 8 ?"
)
@Scheduled
(
cron
=
"0 0 20 8 8 ?"
)
public
void
executeTask
()
{
RLock
lock
=
redissonClient
.
getLock
(
SENDMSGFROMEXCEL_KEY
);
if
(!
lock
.
tryLock
())
{
logger
.
warn
(
"给指定类目用户发送通知任务,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行"
,
Thread
.
currentThread
().
getId
());
logger
.
info
(
"给指定类目用户发送通知任务,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行"
,
Thread
.
currentThread
().
getId
());
return
;
}
logger
.
info
(
">>>>>>>>>>>> sendMsgFromExcel 开始执行 <<<<<<<<<<<<"
);
try
{
String
key
=
"xmly:sendMsgFromExcel"
;
String
key
=
"xmly:sendMsgFromExcel
:0808
"
;
Date
now
=
new
Date
();
if
(
redisUtils
.
hasKey
(
key
))
{
String
msg
=
"给指定类目用户发送通知任务正在重复执行"
;
...
...
@@ -74,12 +73,14 @@ public class SendMsgFromExcelJob {
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
url
=
wxAppletApi
.
getUrlLink
(
CommConsts
.
ITEM_OF_GROUPPURCHASE_URL
,
"itemId="
+
32894809
);
//发短信
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
);
logger
.
info
(
">>>>>>>>>>>> sendMsgFromExcel 发送通知给指定用户定时任务执行完成 <<<<<<<<<<<<"
);
}
catch
(
Exception
e
)
{
...
...
ch-wx-api/src/test/java/com/wwdz/ch/wx/api/OfficialAccountApiTest.java
View file @
70a8733d
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.WxAppletApi
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.entity.ConsignSaleSubscribeMsg
;
import
com.wwdz.ch.core.notify.AliSmsSender
;
import
com.wwdz.ch.core.util.PriceUtil
;
import
com.wwdz.ch.core.util.StringArrayExcelReadListener
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.utils.ExcelRead
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.io.InputStream
;
import
java.util.Date
;
import
java.util.List
;
@SpringBootTest
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
OfficialAccountApiTest
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OfficialAccountApiTest
.
class
);
@Autowired
OfficialAccountApi
officialAccountApi
;
...
...
@@ -69,4 +81,29 @@ public class OfficialAccountApiTest {
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment