From b692129d17951742864177e620247e83c5b770ea Mon Sep 17 00:00:00 2001 From: tuyp Date: Wed, 18 Sep 2024 16:41:01 +0800 Subject: [PATCH] 拆班推送/班级里分组推送 --- src/main/java/com/subsidy/controller/RenSheJuController.java | 9 +++++++++ src/main/java/com/subsidy/dto/renshe/PushClassMembersDataDTO.java | 12 ++++++++++++ src/main/java/com/subsidy/mapper/RenSheJuMapper.java | 19 +++++++++++++++++-- src/main/java/com/subsidy/service/RenSheJuService.java | 5 +++-- src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------- src/main/java/com/subsidy/vo/renshe/VodClassIdsVO.java | 14 ++++++++++++++ src/main/resources/mapper/RenSheJuMapper.xml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 357 insertions(+), 105 deletions(-) create mode 100644 src/main/java/com/subsidy/dto/renshe/PushClassMembersDataDTO.java create mode 100644 src/main/java/com/subsidy/vo/renshe/VodClassIdsVO.java diff --git a/src/main/java/com/subsidy/controller/RenSheJuController.java b/src/main/java/com/subsidy/controller/RenSheJuController.java index 2d5b548..cbb9544 100644 --- a/src/main/java/com/subsidy/controller/RenSheJuController.java +++ b/src/main/java/com/subsidy/controller/RenSheJuController.java @@ -1,5 +1,7 @@ package com.subsidy.controller; +import com.subsidy.common.ResponseVO; +import com.subsidy.dto.renshe.PushClassMembersDataDTO; import com.subsidy.service.RenSheJuService; import com.subsidy.vo.renshe.RensheResponseVO; import com.subsidy.vo.renshe.RensheStringVO; @@ -7,6 +9,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -74,4 +77,10 @@ public class RenSheJuController { return renSheJuService.post6plus(); } + @PostMapping("pushClassMembersData") + @ApiOperation("推送某个班级前一天的数据 classId memberIds 逗号隔开") + public RensheResponseVO pushClassMembersData(@RequestBody PushClassMembersDataDTO pushClassMembersDataDTO) throws Exception{ + return renSheJuService.pushClassMembersData(pushClassMembersDataDTO); + } + } diff --git a/src/main/java/com/subsidy/dto/renshe/PushClassMembersDataDTO.java b/src/main/java/com/subsidy/dto/renshe/PushClassMembersDataDTO.java new file mode 100644 index 0000000..b6d4ad6 --- /dev/null +++ b/src/main/java/com/subsidy/dto/renshe/PushClassMembersDataDTO.java @@ -0,0 +1,12 @@ +package com.subsidy.dto.renshe; + +import lombok.Data; + +@Data +public class PushClassMembersDataDTO { + + private Long classId; + + private String memberIds; + +} diff --git a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java index 52637fa..8aaa2fc 100644 --- a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java +++ b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java @@ -35,9 +35,19 @@ public interface RenSheJuMapper { List newClasses(String classType); /** - * 前一天新增视频学习数据 + * 前一天班级的基本信息 */ - List dailyStudyInfo(Long classId); + List dailyStudyInfo(Long classId,List memberIds); + + /** + * 某班级去重学员 + */ + List classDistinctMember(Long classId); + + /** + * 查看前一天班级的数据条数 + */ + Integer dataCount(Long classId); /** * 前一天活跃度检测列表 @@ -131,6 +141,11 @@ public interface RenSheJuMapper { List vodClassIds(String classType); /** + * 产生数据班级+数据量 + */ + List vodClassCnt(String classType); + + /** * 产生考试数据的班级 */ List examClassIds(String classType); diff --git a/src/main/java/com/subsidy/service/RenSheJuService.java b/src/main/java/com/subsidy/service/RenSheJuService.java index 4ef8f7d..3e9be10 100644 --- a/src/main/java/com/subsidy/service/RenSheJuService.java +++ b/src/main/java/com/subsidy/service/RenSheJuService.java @@ -1,5 +1,6 @@ package com.subsidy.service; +import com.subsidy.dto.renshe.PushClassMembersDataDTO; import com.subsidy.vo.renshe.RensheResponseVO; import com.subsidy.vo.renshe.RensheStringVO; @@ -24,8 +25,8 @@ public interface RenSheJuService { RensheStringVO clear()throws IOException; - void test(); - RensheResponseVO post6plus() throws Exception ; + RensheResponseVO pushClassMembersData(PushClassMembersDataDTO pushClassMembersDataDTO) throws Exception ; + } diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index c20373f..2d83ca5 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -12,6 +12,7 @@ import com.subsidy.model.*; import com.subsidy.service.RenSheJuService; import com.subsidy.util.OSSUtils; import com.subsidy.util.RenSheJuConstant; +import com.subsidy.util.SMSUtils; import com.subsidy.vo.renshe.*; import net.sf.json.JSONObject; import okhttp3.*; @@ -21,8 +22,9 @@ import org.springframework.stereotype.Service; import java.io.IOException; import java.sql.Timestamp; -import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.IntStream; @Service public class RenSheJuServiceImpl implements RenSheJuService { @@ -42,6 +44,9 @@ public class RenSheJuServiceImpl implements RenSheJuService { @Autowired private ImageCheckRecordMapper imageCheckRecordMapper; + @Autowired + private SMSUtils smsUtils; + public RensheResponseVO classBaseInfo() throws IOException { OkHttpClient client = new OkHttpClient().newBuilder() @@ -69,7 +74,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { List imageClassIds = renSheJuMapper.imageClassIds("0"); Set classIds = new HashSet<>(); -// classIds.add(490L); vodClassIds.stream().forEach(x -> classIds.add(x)); examClassIds.stream().forEach(x -> classIds.add(x)); @@ -153,120 +157,143 @@ public class RenSheJuServiceImpl implements RenSheJuService { .build(); MediaType mediaType = MediaType.parse("application/json"); - ClassHourBehaviorDTO classHourBehaviorDTO = new ClassHourBehaviorDTO(); - - classHourBehaviorDTO.setPrivateKey(getSecret()); - List classHourBasics = new ArrayList<>(); - // 产生视频学习数据的班级 - List vodClassIds = renSheJuMapper.vodClassIds("0"); - -// List vodClassIds = new ArrayList<>(); -// vodClassIds.add(537L); - - List result = new ArrayList<>(); - - try { - for (Long classId : vodClassIds) { - //产生数据的班级 - List dailyStudyInfoVOS = renSheJuMapper.dailyStudyInfo(classId); - result.addAll(dailyStudyInfoVOS); + List vodClassIdsVOS = renSheJuMapper.vodClassCnt("0"); + + for (VodClassIdsVO vodClassIdsVO : vodClassIdsVOS) { + ClassHourBehaviorDTO classHourBehaviorDTO = new ClassHourBehaviorDTO(); + classHourBehaviorDTO.setPrivateKey(getSecret()); + + //查看该班级今天产生的数据条数 + int count = renSheJuMapper.dataCount(vodClassIdsVO.getClassId()); + List longs = renSheJuMapper.classDistinctMember(vodClassIdsVO.getClassId()); + if (count > 300) { + //某班级前一天数据人员去重 + int times = (int) Math.ceil((double) count / 300); + int block = (int) Math.ceil((double) longs.size() / times); + List> devide = devide(longs, block); + for (List memberIds : devide) { + try { + sendStudyData(client, mediaType, classHourBehaviorDTO, vodClassIdsVO.getClassId(), memberIds); + } catch (Exception e) { + e.printStackTrace(); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + List telephones = Arrays.asList("15201936167", "18201963812"); + for (String telephone : telephones) { + smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_3); + } + } + } + } else { + try { + sendStudyData(client, mediaType, classHourBehaviorDTO, vodClassIdsVO.getClassId(), longs); + } catch (Exception e) { + e.printStackTrace(); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + List telephones = Arrays.asList("15201936167", "18201963812"); + for (String telephone : telephones) { + smsUtils.sendWarning("SMS_460945631", telephone, "3"); + } + } } - for (DailyStudyInfoVO dailyStudyInfoVO : result) { - ClassHourBasic classHourBasic = new ClassHourBasic(); - BeanUtils.copyProperties(dailyStudyInfoVO, classHourBasic); - classHourBasic.setClassCode(dailyStudyInfoVO.getClassCode()); - - //找到当天每次上线下线时间 - //上线时间 - List loginRecords = renSheJuMapper.loginRecords(dailyStudyInfoVO.getMemberId()); - //下线时间 - List loginOutRecords = renSheJuMapper.loginOutRecords(dailyStudyInfoVO.getMemberId()); + } + return null; + } - List loginLists = new ArrayList<>(); - for (int i = 0; i < loginRecords.size(); i++) { - LoginList loginList = new LoginList(); - loginList.setIp(loginRecords.get(i).getIpAddress()); - loginList.setStartTime(Timestamp.valueOf(loginRecords.get(i).getCreateDate()).getTime()); - loginList.setEndTime(Timestamp.valueOf(loginOutRecords.get(i).getCreateDate()).getTime()); + public void sendStudyData(OkHttpClient client, MediaType mediaType, ClassHourBehaviorDTO classHourBehaviorDTO, Long classId, List memberIds) throws Exception { - //查看这个人该时间段的学习记录 - List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getClassId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); - if (chapterList3s.size() > 0) { - loginList.setChapterList(chapterList3s); - loginLists.add(loginList); - } + List classHourBasics = new ArrayList<>(); + //产生数据的班级 + List dailyStudyInfoVOS = renSheJuMapper.dailyStudyInfo(classId, memberIds); + for (DailyStudyInfoVO dailyStudyInfoVO : dailyStudyInfoVOS) { + ClassHourBasic classHourBasic = new ClassHourBasic(); + BeanUtils.copyProperties(dailyStudyInfoVO, classHourBasic); + classHourBasic.setClassCode(dailyStudyInfoVO.getClassCode()); + + //找到当天每次上线下线时间 + //上线时间 + List loginRecords = renSheJuMapper.loginRecords(dailyStudyInfoVO.getMemberId()); + //下线时间 + List loginOutRecords = renSheJuMapper.loginOutRecords(dailyStudyInfoVO.getMemberId()); + + List loginLists = new ArrayList<>(); + for (int i = 0; i < loginRecords.size(); i++) { + LoginList loginList = new LoginList(); + loginList.setIp(loginRecords.get(i).getIpAddress()); + loginList.setStartTime(Timestamp.valueOf(loginRecords.get(i).getCreateDate()).getTime()); + loginList.setEndTime(Timestamp.valueOf(loginOutRecords.get(i).getCreateDate()).getTime()); + + //查看这个人该时间段的学习记录 + List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getClassId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); + if (chapterList3s.size() > 0) { + loginList.setChapterList(chapterList3s); + loginLists.add(loginList); } - classHourBasic.setLoginList(loginLists); + } + classHourBasic.setLoginList(loginLists); - //活跃度列表 - List activityLists = new ArrayList<>(); - List activityDetectionDOS = renSheJuMapper.dailyActivities(dailyStudyInfoVO.getClassId(), dailyStudyInfoVO.getMemberId()); - for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { + //活跃度列表 + List activityLists = new ArrayList<>(); + List activityDetectionDOS = renSheJuMapper.dailyActivities(dailyStudyInfoVO.getClassId(), dailyStudyInfoVO.getMemberId()); + for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { - ActivityList activityList = new ActivityList(); + ActivityList activityList = new ActivityList(); - if (0 == dailyActivitiesVO.getCheckType()) { - activityList.setActivityDetection(2); - } else if (1 == dailyActivitiesVO.getCheckType()) { - activityList.setActivityDetection(1); - } - - activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); - activityLists.add(activityList); + if (0 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(2); + } else if (1 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(1); } - classHourBasic.setActivityList(activityLists); - classHourBasics.add(classHourBasic); - } - classHourBehaviorDTO.setClassHourBasic(classHourBasics); - System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + classHourBasic.setActivityList(activityLists); + classHourBasics.add(classHourBasic); + } - if (classHourBasics.size() > 0) { - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); - Request request = new Request.Builder() - .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassHourBehavior") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); + classHourBehaviorDTO.setClassHourBasic(classHourBasics); +// System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); + + if (classHourBasics.size() > 0) { + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassHourBehavior") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); - renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); - renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); - if (200 == response.code()) { - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); - } else { - renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); - } - renshejuHistoryMapper.insert(renshejuHistoryDO); - return rensheResponseVO; + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); } else { - RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); - renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); - renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); - renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); - renshejuHistoryMapper.insert(renshejuHistoryDO); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); } -// return null; - } catch (Exception e) { - e.printStackTrace(); + renshejuHistoryMapper.insert(renshejuHistoryDO); + classHourBasics.clear(); + } else { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); - renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); renshejuHistoryMapper.insert(renshejuHistoryDO); - - List telephones = Arrays.asList("15201936167", "18201963812"); -// for (String telephone : telephones) { -// smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_3); -// } } - return null; } + public RensheResponseVO uploadChapterBehavior() throws IOException { OkHttpClient client = new OkHttpClient().newBuilder() @@ -690,7 +717,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { List classIds = new ArrayList<>(); - classIds.add(477L); +// classIds.add(477L); for (Long classId : classIds) { @@ -780,6 +807,123 @@ public class RenSheJuServiceImpl implements RenSheJuService { return rensheStringVO; } + public RensheResponseVO pushClassMembersData(PushClassMembersDataDTO pushClassMembersDataDTO) throws Exception { + + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + +// 产生视频学习数据的班级 + + ClassHourBehaviorDTO classHourBehaviorDTO = new ClassHourBehaviorDTO(); + classHourBehaviorDTO.setPrivateKey(getSecret()); + + //查看该班级今天产生的数据条数 + List memberIds = new ArrayList<>(); + + String[] strings = pushClassMembersDataDTO.getMemberIds().split(","); + for (String string : strings) { + memberIds.add(Long.valueOf(string)); + } + + try { + List classHourBasics = new ArrayList<>(); + //产生数据的班级 + List dailyStudyInfoVOS = renSheJuMapper.dailyStudyInfo(pushClassMembersDataDTO.getClassId(), memberIds); + for (DailyStudyInfoVO dailyStudyInfoVO : dailyStudyInfoVOS) { + ClassHourBasic classHourBasic = new ClassHourBasic(); + BeanUtils.copyProperties(dailyStudyInfoVO, classHourBasic); + classHourBasic.setClassCode(dailyStudyInfoVO.getClassCode()); + + //找到当天每次上线下线时间 + //上线时间 + List loginRecords = renSheJuMapper.loginRecords(dailyStudyInfoVO.getMemberId()); + //下线时间 + List loginOutRecords = renSheJuMapper.loginOutRecords(dailyStudyInfoVO.getMemberId()); + + List loginLists = new ArrayList<>(); + for (int i = 0; i < loginRecords.size(); i++) { + LoginList loginList = new LoginList(); + loginList.setIp(loginRecords.get(i).getIpAddress()); + loginList.setStartTime(Timestamp.valueOf(loginRecords.get(i).getCreateDate()).getTime()); + loginList.setEndTime(Timestamp.valueOf(loginOutRecords.get(i).getCreateDate()).getTime()); + + //查看这个人该时间段的学习记录 + List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getClassId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); + if (chapterList3s.size() > 0) { + loginList.setChapterList(chapterList3s); + loginLists.add(loginList); + } + } + classHourBasic.setLoginList(loginLists); + + //活跃度列表 + List activityLists = new ArrayList<>(); + List activityDetectionDOS = renSheJuMapper.dailyActivities(dailyStudyInfoVO.getClassId(), dailyStudyInfoVO.getMemberId()); + for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { + + ActivityList activityList = new ActivityList(); + + if (0 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(2); + } else if (1 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(1); + } + + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + classHourBasic.setActivityList(activityLists); + classHourBasics.add(classHourBasic); + } + + classHourBehaviorDTO.setClassHourBasic(classHourBasics); + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); + + if (classHourBasics.size() > 0) { + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassHourBehavior") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + classHourBasics.clear(); + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + } catch (Exception e) { + e.printStackTrace(); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + List telephones = Arrays.asList("15201936167", "18201963812"); + for (String telephone : telephones) { + smsUtils.sendWarning("SMS_460945631", telephone, RenSheJuConstant.POST_3); + } + } + + return null; + } + public String getSecret() throws IOException { OkHttpClient client = new OkHttpClient().newBuilder() @@ -811,13 +955,25 @@ public class RenSheJuServiceImpl implements RenSheJuService { // String s = JSONObject.fromObject(getSecretVO).toString(); // System.out.println(s); - LocalDateTime localDateTime = LocalDateTime.now(); - System.out.println(localDateTime.toString()); +// LocalDateTime localDateTime = LocalDateTime.now(); +// System.out.println(localDateTime.toString()); + +// int ttl = 1600; +// int memCnt = 173; +// System.out.println((int) Math.ceil((double) ttl / 500) + "============="); + System.out.println(devide(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), 3)); } - public void test() { - System.out.println("132222222222222222222222222222"); + public static List> devide(List origin, int size) { + + int block = (origin.size() + size - 1) / size; + return IntStream.range(0, block) + .boxed().map(i -> { + int start = i * size; + int end = Math.min(start + size, origin.size()); + return origin.subList(start, end); + }).collect(Collectors.toList()); } -} +} \ No newline at end of file diff --git a/src/main/java/com/subsidy/vo/renshe/VodClassIdsVO.java b/src/main/java/com/subsidy/vo/renshe/VodClassIdsVO.java new file mode 100644 index 0000000..8328f01 --- /dev/null +++ b/src/main/java/com/subsidy/vo/renshe/VodClassIdsVO.java @@ -0,0 +1,14 @@ +package com.subsidy.vo.renshe; + +import lombok.Data; + +@Data +public class VodClassIdsVO { + + private Long classId; + + private String classCode; + + private Integer cnt; + +} diff --git a/src/main/resources/mapper/RenSheJuMapper.xml b/src/main/resources/mapper/RenSheJuMapper.xml index cc6919b..5f45e19 100644 --- a/src/main/resources/mapper/RenSheJuMapper.xml +++ b/src/main/resources/mapper/RenSheJuMapper.xml @@ -96,8 +96,36 @@ t.delete_date IS NULL AND t3.delete_date IS NULL AND t.class_id = #{classId} + + and t.member_id in + + #{id} + + + + + + +