江体小程序和zlb接口开发 #1
@@ -18,6 +18,7 @@ public enum ScheduleEnums {
|
|||||||
ZLB_SITE_QUERY_TASK(3, "zlb", "zlbSiteQueryTask"),
|
ZLB_SITE_QUERY_TASK(3, "zlb", "zlbSiteQueryTask"),
|
||||||
ZLB_SITE_DAY_TASK(3, "zlb", "zlbSiteDayTask"),
|
ZLB_SITE_DAY_TASK(3, "zlb", "zlbSiteDayTask"),
|
||||||
ZLB_ORDER_CREATE_TASK(3, "zlb", "zlbOrderCreateTask"),
|
ZLB_ORDER_CREATE_TASK(3, "zlb", "zlbOrderCreateTask"),
|
||||||
|
ZLB_USER_CONFIG_TASK(3, "zlb", "zlbUserConfigTask"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.xiang.common.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -9,6 +10,8 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface ZlbUserInfoMapper extends BaseMapper<ZlbUserInfo> {
|
public interface ZlbUserInfoMapper extends BaseMapper<ZlbUserInfo> {
|
||||||
|
|
||||||
|
@Delete("delete from zlb_user_info where 1=1")
|
||||||
|
int deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class ZlbTokenInfo {
|
|||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer loginInfoId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public class ZlbUserInfo {
|
|||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer loginInfoId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ public class ZlbSiteTask extends BaseScheduleTaskTemplate {
|
|||||||
|
|
||||||
TaskResult taskResult = new TaskResult();
|
TaskResult taskResult = new TaskResult();
|
||||||
//获取当前时间的后一天
|
//获取当前时间的后一天
|
||||||
Date date1 = DateUtils.addDate(new Date(), 0);
|
Date date1 = DateUtils.addDate(new Date(), 1);
|
||||||
Date date2 = DateUtils.addDate(new Date(), 1);
|
Date date2 = DateUtils.addDate(new Date(), 2);
|
||||||
Date date3 = DateUtils.addDate(new Date(), 2);
|
Date date3 = DateUtils.addDate(new Date(), 3);
|
||||||
String day1 = DateUtils.format(date1, DateUtils.ENUM_FORMAT_YMD);
|
String day1 = DateUtils.format(date1, DateUtils.ENUM_FORMAT_YMD);
|
||||||
String day2 = DateUtils.format(date2, DateUtils.ENUM_FORMAT_YMD);
|
String day2 = DateUtils.format(date2, DateUtils.ENUM_FORMAT_YMD);
|
||||||
String day3 = DateUtils.format(date3, DateUtils.ENUM_FORMAT_YMD);
|
String day3 = DateUtils.format(date3, DateUtils.ENUM_FORMAT_YMD);
|
||||||
|
|||||||
@@ -47,5 +47,10 @@ public class ZlbTaskConfig {
|
|||||||
zlbOrderTask.run();
|
zlbOrderTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "30 30 16 * * ?")
|
||||||
|
public void zlbUserConfig() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package com.xiang.service.module.jntyzx.zlb.schedule;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.common.enums.ScheduleEnums;
|
||||||
|
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||||
|
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||||
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||||
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||||
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||||
|
import com.xiang.common.pojo.schedule.TaskResult;
|
||||||
|
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||||
|
import com.xiang.common.service.IScheduleRunLogService;
|
||||||
|
import com.xiang.common.utils.DateUtils;
|
||||||
|
import com.xiang.service.module.jntyzx.zlb.service.ZlbSiteInfoService;
|
||||||
|
import com.xiang.service.module.jntyzx.zlb.service.ZlbTokenInfoService;
|
||||||
|
import com.xiang.service.module.jntyzx.zlb.service.ZlbUserInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-05-08 12:03
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ZlbUserConfigTask extends BaseScheduleTaskTemplate {
|
||||||
|
|
||||||
|
private final ZlbSiteInfoService zlbSiteInfoService;
|
||||||
|
private final ZlbUserInfoService zlbUserInfoService;
|
||||||
|
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||||
|
private final ZlbTokenInfoService zlbTokenInfoService;
|
||||||
|
|
||||||
|
public ZlbUserConfigTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||||
|
IScheduleRunLogService scheduleRunLogService,
|
||||||
|
ZlbSiteInfoService zlbSiteInfoService,
|
||||||
|
ZlbUserInfoService zlbUserInfoService,
|
||||||
|
ZlbTokenInfoService zlbTokenInfoService,
|
||||||
|
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||||
|
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||||
|
this.zlbSiteInfoService = zlbSiteInfoService;
|
||||||
|
this.zlbUserInfoService = zlbUserInfoService;
|
||||||
|
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||||
|
this.zlbTokenInfoService = zlbTokenInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTaskName() {
|
||||||
|
return ScheduleEnums.ZLB_USER_CONFIG_TASK.getTaskName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Integer getModule() {
|
||||||
|
return ScheduleEnums.ZLB_USER_CONFIG_TASK.getModeleCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getModuleName() {
|
||||||
|
return ScheduleEnums.ZLB_USER_CONFIG_TASK.getModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||||
|
TaskResult taskResult = new TaskResult();
|
||||||
|
LocalDate date = LocalDate.now().plusDays(1);
|
||||||
|
LambdaQueryWrapper<ZlbSiteInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(ZlbSiteInfo::getBelongDate, date);
|
||||||
|
List<ZlbSiteInfo> siteInfoList = zlbSiteInfoService.list(lambdaQueryWrapper);
|
||||||
|
if (CollectionUtils.isEmpty(siteInfoList)) {
|
||||||
|
log.info("日期:{}无场地信息", date);
|
||||||
|
jntyzxDingTalkFactory.sendMsg("日期:" + date + "无场地信息配置");
|
||||||
|
taskResult.setSuccess(Boolean.FALSE);
|
||||||
|
taskResult.setSummary("日期:" + date + "无场地信息配置");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
siteInfoList = filterSiteInfo(siteInfoList);
|
||||||
|
siteInfoList = sortSiteInfo(siteInfoList);
|
||||||
|
|
||||||
|
|
||||||
|
List<ZlbTokenInfo> users = zlbTokenInfoService.getAllUsers();
|
||||||
|
if (CollectionUtils.isEmpty(users)) {
|
||||||
|
log.info("日期:{}无用户信息", date);
|
||||||
|
jntyzxDingTalkFactory.sendMsg("日期:" + date + "无用户信息");
|
||||||
|
taskResult.setSuccess(Boolean.FALSE);
|
||||||
|
taskResult.setSummary("日期:" + date + "无用户信息");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
zlbUserInfoService.delAll();
|
||||||
|
List<ZlbUserInfo> list = Lists.newArrayList();
|
||||||
|
int i = 0;
|
||||||
|
for (ZlbTokenInfo user : users) {
|
||||||
|
ZlbSiteInfo zlbSiteInfo = siteInfoList.get(i);
|
||||||
|
ZlbUserInfo zlbUserInfo = new ZlbUserInfo();
|
||||||
|
zlbUserInfo.setLoginInfoId(user.getLoginInfoId());
|
||||||
|
zlbUserInfo.setName(user.getName());
|
||||||
|
zlbUserInfo.setWeek(DateUtils.getWeekDay(zlbSiteInfo.getBelongDate()));
|
||||||
|
zlbUserInfo.setType("1");
|
||||||
|
zlbUserInfo.setPlaceName(zlbSiteInfo.getPlaceName());
|
||||||
|
zlbUserInfo.setSiteTimeName(zlbSiteInfo.getDayEffectiveTimes());
|
||||||
|
zlbUserInfo.setIsBook(0);
|
||||||
|
list.add(zlbUserInfo);
|
||||||
|
i++;
|
||||||
|
if (i == siteInfoList.size()) {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
zlbUserInfoService.saveBatch(list);
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (ZlbUserInfo user : list) {
|
||||||
|
stringBuilder.append(user.getName()).append("配置预约:").append(user.getPlaceName()).append("\n");
|
||||||
|
}
|
||||||
|
jntyzxDingTalkFactory.sendMsg(stringBuilder.toString());
|
||||||
|
taskResult.setSuccess(Boolean.TRUE);
|
||||||
|
taskResult.setSummary(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ZlbSiteInfo> filterSiteInfo(List<ZlbSiteInfo> siteInfoList) {
|
||||||
|
return siteInfoList.stream().filter(item -> Objects.equals(item.getDayEffectiveTimes(), "20:00")).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ZlbSiteInfo> sortSiteInfo(List<ZlbSiteInfo> siteInfoList) {
|
||||||
|
if (CollectionUtils.isEmpty(siteInfoList)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
return siteInfoList.stream().sorted(Comparator.comparing(this::sort)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int sort(ZlbSiteInfo siteInfo) {
|
||||||
|
String placeName = siteInfo.getPlaceName();
|
||||||
|
if (placeName.contains("十号")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (placeName.contains("九号")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (placeName.contains("二号")) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (placeName.contains("八号")) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (placeName.contains("七号")) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package com.xiang.service.module.jntyzx.zlb.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author a123
|
* @author a123
|
||||||
* @description 针对表【zlb_token_info】的数据库操作Service
|
* @description 针对表【zlb_token_info】的数据库操作Service
|
||||||
@@ -11,4 +13,6 @@ import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
|||||||
public interface ZlbTokenInfoService extends IService<ZlbTokenInfo> {
|
public interface ZlbTokenInfoService extends IService<ZlbTokenInfo> {
|
||||||
|
|
||||||
ZlbTokenInfo queryByName(String name);
|
ZlbTokenInfo queryByName(String name);
|
||||||
|
|
||||||
|
List<ZlbTokenInfo> getAllUsers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.xiang.common.mapper.ZlbTokenInfoMapper;
|
|||||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author a123
|
* @author a123
|
||||||
* @description 针对表【zlb_token_info】的数据库操作Service实现
|
* @description 针对表【zlb_token_info】的数据库操作Service实现
|
||||||
@@ -22,6 +24,13 @@ public class ZlbTokenInfoServiceImpl extends ServiceImpl<ZlbTokenInfoMapper, Zlb
|
|||||||
wrapper.eq(ZlbTokenInfo::getName, name);
|
wrapper.eq(ZlbTokenInfo::getName, name);
|
||||||
return this.getOne(wrapper);
|
return this.getOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ZlbTokenInfo> getAllUsers() {
|
||||||
|
LambdaQueryWrapper<ZlbTokenInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(ZlbTokenInfo::getIsDel, 0);
|
||||||
|
return baseMapper.selectList(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,18 @@ package com.xiang.service.module.jntyzx.zlb.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ZlbUserInfoService extends IService<ZlbUserInfo> {
|
public interface ZlbUserInfoService extends IService<ZlbUserInfo> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询日期内未预订的用户
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ZlbUserInfo> getNoBookUsers(LocalDate date);
|
||||||
|
|
||||||
|
int delAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,22 @@ import com.xiang.common.mapper.ZlbUserInfoMapper;
|
|||||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ZlbUserInfoServiceImpl extends ServiceImpl<ZlbUserInfoMapper, ZlbUserInfo>
|
public class ZlbUserInfoServiceImpl extends ServiceImpl<ZlbUserInfoMapper, ZlbUserInfo>
|
||||||
implements ZlbUserInfoService {
|
implements ZlbUserInfoService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ZlbUserInfo> getNoBookUsers(LocalDate date) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delAll() {
|
||||||
|
return baseMapper.deleteAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user