PushDataServiceImpl.java
10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
package com.subsidy.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.Gson;
import com.subsidy.dto.renshe.*;
import com.subsidy.mapper.*;
import com.subsidy.model.*;
import com.subsidy.service.PushDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.service.RenshejuHistoryService;
import com.subsidy.util.RenSheJuConstant;
import com.subsidy.util.SMSUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* <p>
* 问题答疑表 服务实现类
* </p>
*
* @author Tuyp
* @since 2023-12-01
*/
@Service
public class PushDataServiceImpl extends ServiceImpl<PushAnsweringDataMapper, PushAnsweringDataDO> implements PushDataService {
@Autowired
private RenshejuHistoryMapper renshejuHistoryMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private PushOprDataMapper pushOprDataMapper;
@Autowired
private PushVodDataMapper pushVodDataMapper;
@Autowired
private ClassDictMapper classDictMapper;
@Autowired
private PushDetectionDataMapper pushDetectionDataMapper;
@Autowired
private PushExerciseDataMapper pushExerciseDataMapper;
@Autowired
private PushImageDataMapper pushImageDataMapper;
@Autowired
private PushAnsweringDataMapper pushAnsweringDataMapper;
@Autowired
private SMSUtils smsUtils;
@Transactional(rollbackFor = Exception.class)
public void post4() {
RenshejuHistoryDO renshejuHistoryDO = renshejuHistoryMapper.dailyData(RenSheJuConstant.POST_4);
// RenshejuHistoryDO renshejuHistoryDO =renshejuHistoryMapper.selectById(5362);
String input = renshejuHistoryDO.getInputParam();
Gson gson = new Gson();
ClassHourBehaviorDTO classHourBehaviorDTO = gson.fromJson(input, ClassHourBehaviorDTO.class);
List<ClassHourBasic> classHourBasics = classHourBehaviorDTO.getClassHourBasic();
for (ClassHourBasic chb : classHourBasics) {
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getIdCard, chb.getIdentity())
);
ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper<ClassDictDO>()
.lambda()
.eq(ClassDictDO::getClassCode, chb.getClassCode()));
List<LoginList> loginLists = chb.getLoginList();
if (loginLists.size() > 0) {
LoginList loginList = loginLists.get(0);
Date loginInTime = new Date(loginList.getStartTime());
Date loginOutTime = new Date(loginList.getEndTime());
String ip = loginList.getIp();
//opr
pushOprDataMapper.insertData(memberDO.getId(), "登录", ip, loginInTime);
pushOprDataMapper.insertData(memberDO.getId(), "登出", null, loginOutTime);
//回写视频数据
List<ChapterList3> chapterList = loginList.getChapterList();
for (ChapterList3 chapter : chapterList) {
pushVodDataMapper.insertData(classDictDO.getId(), Long.valueOf(chapter.getChapterCode()), memberDO.getId(), (chapter.getEndTime().intValue() - chapter.getStartTime().intValue()) / 1000, chapter.getPauseTime().intValue(), 0, new Date(chapter.getEndTime()), ip);
}
}
//回写活跃度数据
List<ActivityList> activityLists = chb.getActivityList();
for (ActivityList activityList : activityLists) {
pushDetectionDataMapper.insertData(classDictDO.getId(), activityList.getActivityDetection(), memberDO.getId(), new Date(activityList.getActivityTime()));
}
}
}
@Transactional(rollbackFor = Exception.class)
public void post5() {
RenshejuHistoryDO renshejuHistoryDO = renshejuHistoryMapper.dailyData(RenSheJuConstant.POST_5);
// RenshejuHistoryDO renshejuHistoryDO = renshejuHistoryMapper.selectById(5365);
String input = renshejuHistoryDO.getInputParam();
Gson gson = new Gson();
UploadChapterBehaviorDTO uploadChapterBehaviorDTO = gson.fromJson(input, UploadChapterBehaviorDTO.class);
System.out.println(uploadChapterBehaviorDTO);
List<ChapterExamBasic> chapterExamBasics = uploadChapterBehaviorDTO.getChapterExamBasic();
for (ChapterExamBasic ceb : chapterExamBasics) {
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getIdCard, ceb.getIdentity())
);
ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper<ClassDictDO>()
.lambda()
.eq(ClassDictDO::getClassCode, ceb.getClassCode()));
//考试活跃度 学时里已经推过全部的活跃度了
// List<ActivityList> activityLists = ceb.getActivityList();
// for (ActivityList activityList : activityLists) {
// pushDetectionDataMapper.insertData(classDictDO.getId(), activityList.getActivityDetection(), memberDO.getId(), new Date(activityList.getActivityTime()));
// }
//考试表
List<ExamList> examLists = ceb.getExamList();
for (ExamList examList : examLists) {
pushExerciseDataMapper.pushExamData(classDictDO.getId(), new Date(examList.getStartTime()), memberDO.getId(), new Date(examList.getEndTime()), ceb.getExamTime().intValue());
}
}
}
@Transactional(rollbackFor = Exception.class)
public void post6() {
RenshejuHistoryDO renshejuHistoryDO = renshejuHistoryMapper.dailyData(RenSheJuConstant.POST_6);
// RenshejuHistoryDO renshejuHistoryDO = renshejuHistoryMapper.selectById(5366);
String input = renshejuHistoryDO.getInputParam();
Gson gson = new Gson();
UploadClassAnswerQuestionBehaviorDTO uploadClassAnswerQuestionBehaviorDTO = gson.fromJson(input, UploadClassAnswerQuestionBehaviorDTO.class);
System.out.println(uploadClassAnswerQuestionBehaviorDTO);
List<AnswerBasic> answerBasics = uploadClassAnswerQuestionBehaviorDTO.getAnswerBasic();
for (AnswerBasic ab : answerBasics) {
ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper<ClassDictDO>()
.lambda()
.eq(ClassDictDO::getClassCode, ab.getClassCode()));
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getIdCard, ab.getIdentity())
);
List<AnswerAndQuestionList> answerAndQuestionLists = ab.getAnswerAndQuestionList();
for (AnswerAndQuestionList aaql : answerAndQuestionLists) {
pushAnsweringDataMapper.insertAnswerData(classDictDO.getId(), memberDO.getId(), new Date(aaql.getQuestion()), new Date(aaql.getAnswer()));
}
}
}
@Transactional(rollbackFor = Exception.class)
public void post7() {
List<RenshejuHistoryDO> renshejuHistoryDOS = renshejuHistoryMapper.dailyDatas(RenSheJuConstant.POST_7);
// List<Long> longs = new ArrayList<Long>();
// longs.add(5370L);
// longs.add(5372L);
// longs.add(5373L);
// longs.add(5376L);
// longs.add(5377L);
// List<RenshejuHistoryDO> renshejuHistoryDOS = renshejuHistoryMapper.selectList(new QueryWrapper<RenshejuHistoryDO>()
// .lambda()
// .in(RenshejuHistoryDO::getId,longs));
for (RenshejuHistoryDO renshejuHistoryDO : renshejuHistoryDOS) {
String input = renshejuHistoryDO.getInputParam();
Gson gson = new Gson();
UploadImageDTO uploadImageDTO = gson.fromJson(input, UploadImageDTO.class);
System.out.println(uploadImageDTO);
ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper<ClassDictDO>()
.lambda()
.eq(ClassDictDO::getClassCode, uploadImageDTO.getClassCode()));
List<ImageDetailList> imageDetailList = uploadImageDTO.getImageDetailList();
for (ImageDetailList idl : imageDetailList) {
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getIdCard, idl.getIdentity())
);
pushImageDataMapper.pushImageData(classDictDO.getId(), idl.getDetectionType(), memberDO.getId(), idl.getProcessType(), new Date(idl.getActivityTime()));
}
}
}
public void sendWarning() {
HashMap<String, List<Long>> hashMap = new HashMap();
//视频
List<Long> vodList = pushVodDataMapper.vodIds();
//答疑
List<Long> answerList = pushAnsweringDataMapper.answerList();
//考试
List<Long> examList = pushExerciseDataMapper.examList();
//活跃度
List<Long> activityList = pushDetectionDataMapper.activityList();
//人脸
List<Long> imageList = pushImageDataMapper.imageList();
if (vodList.size()+answerList.size()+examList.size()+activityList.size()+imageList.size()>0){
List<String> telephones = Arrays.asList(new String[]{"15201936167", "18201963812"});
for (String telephone : telephones) {
smsUtils.sendWarning("SMS_460945631", telephone, null);
}
}
}
public HashMap<String, List<Long>> check() {
HashMap<String, List<Long>> hashMap = new HashMap();
//视频
List<Long> vodList = pushVodDataMapper.vodIds();
hashMap.put("视频", vodList);
//答疑
List<Long> answerList = pushAnsweringDataMapper.answerList();
hashMap.put("答疑", answerList);
//考试
List<Long> examList = pushExerciseDataMapper.examList();
hashMap.put("考试", examList);
//活跃度
List<Long> activityList = pushDetectionDataMapper.activityList();
hashMap.put("活跃度", activityList);
//人脸
List<Long> imageList = pushImageDataMapper.imageList();
hashMap.put("人脸", imageList);
return hashMap;
}
}