BUG修复
This commit is contained in:
parent
551f0f1488
commit
67c2904147
@ -1,26 +1,22 @@
|
||||
package com.zhgd.xmgl.modules.exam.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamCourseRecord;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamPaper;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamTrain;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamTrainRecord;
|
||||
import com.zhgd.xmgl.modules.exam.entity.*;
|
||||
import com.zhgd.xmgl.modules.exam.mapper.ExamTrainMapper;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamCourseRecordService;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamPaperService;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamTrainRecordService;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamTrainService;
|
||||
import com.zhgd.xmgl.modules.exam.service.*;
|
||||
import com.zhgd.xmgl.modules.exam.vo.ExamTrainRecordVo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.DateUtils;
|
||||
import com.zhgd.xmgl.util.EmailUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -28,6 +24,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -49,11 +46,14 @@ public class ExamTrainServiceImpl extends ServiceImpl<ExamTrainMapper, ExamTrain
|
||||
private IExamPaperService examPaperService;
|
||||
|
||||
@Autowired
|
||||
private ISystemUserService systemUserService;
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
private IWorkerInfoService workerInfoService;
|
||||
|
||||
@Autowired
|
||||
private IExamSubjectService examSubjectService;
|
||||
|
||||
@Autowired
|
||||
private IExamCourseRecordService examCourseRecordService;
|
||||
|
||||
@ -85,6 +85,7 @@ public class ExamTrainServiceImpl extends ServiceImpl<ExamTrainMapper, ExamTrain
|
||||
|
||||
@Override
|
||||
public boolean saveInfo(ExamTrain examTrain) {
|
||||
ExamSubject examSubject = examSubjectService.getById(examTrain.getSubjectId());
|
||||
List<ExamTrainRecord> recordList = examTrain.getExamTrainRecordList();
|
||||
if (examTrain.getExamPaperId() != null) {
|
||||
ExamPaper examPaper = examPaperService.getById(examTrain.getExamPaperId());
|
||||
@ -122,6 +123,13 @@ public class ExamTrainServiceImpl extends ServiceImpl<ExamTrainMapper, ExamTrain
|
||||
}
|
||||
examTrainRecordService.saveBatch(recordList);
|
||||
examCourseRecordService.saveBatch(examCourseRecordList);
|
||||
List<Long> workerIds = examTrain.getExamTrainRecordList().stream().map(e -> e.getWorkerId()).collect(Collectors.toList());
|
||||
String emails = workerInfoService.listByIds(workerIds).stream().map(w -> w.getPersonMail()).collect(Collectors.joining(","));
|
||||
emailUtils.sendHtmlMail(emails, "安全教育培训提醒", StrUtil.format("【尾矿固废资源综合利用项目】智慧工地管理系统提醒:您有一条培训通知请查收!\n" +
|
||||
"【{}】在【{}}】下发了一个培训计划名称为【{}}】、科目名称为【{}】、教育主题为【{}】的培训计划," +
|
||||
"需要您使用姓名、身份证号登录手机APP端进行课程学习及考试测评,培训有效期限为【{}】,未避免超期未参与培训导致您的安全积分被扣除," +
|
||||
"请在规定有效期限内参加培训!", user.getRealName(), new Date(), examTrain.getName(), examSubject.getName(),
|
||||
examTrain.getTitle(), examTrain.getTrainBeginTime() + " - " + examTrain.getTrainEndTime()));
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ public class XzRiskPredictionController {
|
||||
int pass = trainRecordList.stream().filter(t -> t.getIsPass() == 1).collect(Collectors.toList()).size();
|
||||
record.setPassRadio(new BigDecimal(pass).divide(new BigDecimal(trainRecordList.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
record.setPassRadio(new BigDecimal(1));
|
||||
record.setPassRadio(new BigDecimal(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,7 +678,7 @@ public class XzRiskPredictionController {
|
||||
int pass = trainRecordList.stream().filter(t -> t.getIsPass() == 1).collect(Collectors.toList()).size();
|
||||
record.setPassRadio(new BigDecimal(pass).divide(new BigDecimal(trainRecordList.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
record.setPassRadio(new BigDecimal(1));
|
||||
record.setPassRadio(new BigDecimal(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -795,11 +795,14 @@ public class XzRiskPredictionController {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 安全检查隐患
|
||||
List<XzSecurityQualityInspectionRecord> xzSecurityQualityInspectionRecords = allXzSecurityQualityInspectionRecords.stream().filter(x -> enterpriseIds.contains(x.getEnterpriseId())).collect(Collectors.toList());
|
||||
|
||||
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
||||
resultMap.put("total", new BigDecimal(xzSecurityQualityInspectionRecords.size()).divide(new BigDecimal(allXzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5).count();
|
||||
resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("security", 0);
|
||||
resultMap.put("total", 0);
|
||||
}
|
||||
// 安全评分
|
||||
List<WorkerInfo> list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
||||
@ -825,7 +828,7 @@ public class XzRiskPredictionController {
|
||||
BigDecimal limitTime = new BigDecimal(resultMap.get("limitTime").toString());
|
||||
BigDecimal levelRisk = new BigDecimal(resultMap.get("levelRisk").toString());
|
||||
BigDecimal safe = new BigDecimal(resultMap.get("safe").toString());
|
||||
resultMap.put("area", NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 4, security.doubleValue(),
|
||||
resultMap.put("area", NumberUtils.percent(PolygonUtil.calRadioArea(1.0, 5, security.doubleValue(),
|
||||
limitTime.doubleValue(), levelRisk.doubleValue(), safe.doubleValue()), 2));
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
import com.zhgd.xmgl.modules.car.service.ICarInfoService;
|
||||
import com.zhgd.xmgl.modules.exam.entity.*;
|
||||
@ -16,6 +18,7 @@ import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzMaterial;
|
||||
import com.zhgd.xmgl.modules.xz.service.IXzMaterialService;
|
||||
import com.zhgd.xmgl.util.EmailUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@ -70,7 +73,13 @@ public class ExamTask {
|
||||
private ICarInfoService carInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsyncHikvision asyncHikvision;
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
private IExamSubjectService examSubjectService;
|
||||
|
||||
@Autowired
|
||||
private ISystemUserService systemUserService;
|
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void xzMaterial() {
|
||||
@ -100,7 +109,7 @@ public class ExamTask {
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
public void examNotice() {
|
||||
List<Project> list = projectService.list();
|
||||
List<ExamNotice> noticeList = new ArrayList<>();
|
||||
@ -112,6 +121,9 @@ public class ExamTask {
|
||||
if (examNoticeConfig.getExamNum() != null && examNoticeConfig.getExamType() != null) {
|
||||
List<ExamTrain> examTrainList = examTrainService.list(Wrappers.<ExamTrain>lambdaQuery().eq(ExamTrain::getProjectSn, list.get(i).getProjectSn()));
|
||||
for (int j = 0; j < examTrainList.size(); j++) {
|
||||
SystemUser systemUser = systemUserService.getById(examTrainList.get(j).getCreateBy());
|
||||
ExamSubject examSubject = examSubjectService.getById(examTrainList.get(j).getSubjectId());
|
||||
StringBuilder examTrain = new StringBuilder();
|
||||
if (DateUtil.compare(examTrainList.get(j).getTrainBeginTime(), getTime(examNoticeConfig.getExamType(), examNoticeConfig.getExamNum())) <= 0) {
|
||||
List<ExamTrainRecord> examTrainRecordList = examTrainRecordService.list(Wrappers.<ExamTrainRecord>lambdaQuery().eq(ExamTrainRecord::getTrainId, examTrainList.get(j).getId()));
|
||||
for (int i1 = 0; i1 < examTrainRecordList.size(); i1++) {
|
||||
@ -130,6 +142,9 @@ public class ExamTask {
|
||||
examNotice.setEnterpriseId(workerInfo.getEnterpriseId());
|
||||
examNotice.setRecordId(examTrainRecordList.get(i1).getId());
|
||||
noticeList.add(examNotice);
|
||||
if (StringUtils.isNotBlank(workerInfo.getPersonMail()) && DateUtil.formatDate(examTrainList.get(j).getTrainBeginTime()).equals(DateUtil.formatDate(getTime(examNoticeConfig.getExamType(), examNoticeConfig.getExamNum())))) {
|
||||
examTrain.append(workerInfo.getPersonMail() + ",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,53 +166,22 @@ public class ExamTask {
|
||||
examNotice.setEnterpriseId(workerInfo.getEnterpriseId());
|
||||
examNotice.setRecordId(examCourseRecords.get(i2).getId());
|
||||
noticeList.add(examNotice);
|
||||
// if (StringUtils.isNotBlank(workerInfo.getPersonMail()) && DateUtil.formatDate(examTrainList.get(j).getTrainBeginTime()).equals(DateUtil.formatDate(getTime(examNoticeConfig.getExamType(), examNoticeConfig.getExamNum())))) {
|
||||
// examTrain.append(workerInfo.getPersonMail() + ",");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(examTrain) || examTrain.length() == 0) {
|
||||
emailUtils.sendHtmlMail(examTrain.toString(), "安全教育培训提醒", StrUtil.format("【尾矿固废资源综合利用项目】智慧工地管理系统提醒:您有一条培训通知请查收!\n" +
|
||||
"【{}】在【{}}】下发了一个培训计划名称为【{}}】、科目名称为【{}】、教育主题为【{}】的培训计划," +
|
||||
"需要您使用姓名、身份证号登录手机APP端进行课程学习及考试测评,培训有效期限为【{}】,未避免超期未参与培训导致您的安全积分被扣除," +
|
||||
"请在规定有效期限内参加培训!", systemUser.getRealName(), new Date(), examTrainList.get(j).getName(), examSubject.getName(),
|
||||
examTrainList.get(j).getTitle(), examTrainList.get(j).getTrainBeginTime() + " - " + examTrainList.get(j).getTrainEndTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (examNoticeConfig.getExamNum() != null && examNoticeConfig.getExamType() != null) {
|
||||
// List<ExamPaper> examPapers = examPaperService.list(Wrappers.<ExamPaper>lambdaQuery().eq(ExamPaper::getProjectSn, list.get(i)));
|
||||
// for (int j = 0; j < examPapers.size(); j++) {
|
||||
// if (DateUtil.compare(new Date(), getTime(examNoticeConfig.getExamType(), examNoticeConfig.getExamNum())) < 0) {
|
||||
// List<ExamRecord> examRecords = examRecordService.list(Wrappers.<ExamRecord>lambdaQuery().eq(ExamRecord::getExamId, examPapers.get(j)));
|
||||
// for (int i1 = 0; i1 < examRecords.size(); i1++) {
|
||||
// if (examRecords.get(i1).getScore() == null) {
|
||||
// ExamNotice examNotice = new ExamNotice();
|
||||
// examNotice.setWorkerId(examRecords.get(i1).getUserId());
|
||||
// examNotice.setWorkerName(examRecords.get(i1).getUserName());
|
||||
// examNotice.setType(1);
|
||||
// examNotice.setContent("参加安全教育课程考试");
|
||||
// examNotice.setProjectSn(list.get(i).getProjectSn());
|
||||
// noticeList.add(examNotice);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (examNoticeConfig.getCourseNum() != null && examNoticeConfig.getCourseType() != null) {
|
||||
// List<ExamCourse> examCourseList = examCourseService.list(Wrappers.<ExamCourse>lambdaQuery().eq(ExamCourse::getProjectSn, list.get(i)));
|
||||
// for (int j = 0; j < examCourseList.size(); j++) {
|
||||
// if (DateUtil.compare(new Date(), getTime(examNoticeConfig.getCourseType(), examNoticeConfig.getCourseNum())) < 0) {
|
||||
// List<ExamCourseRecord> examCourseRecords = examCourseRecordService.list(Wrappers.<ExamCourseRecord>lambdaQuery().eq(ExamCourseRecord::getCourseId, examCourseList.get(j)));
|
||||
//// List<ExamCourseTask> examCourseTasks = examCourseTaskService.list(Wrappers.<ExamCourseTask>lambdaQuery()
|
||||
//// .in(ExamCourseTask::getRecordId, examCourseRecords.stream().map(r -> r.getId()).collect(Collectors.toList())));
|
||||
// for (int i1 = 0; i1 < examCourseRecords.size(); i1++) {
|
||||
// if (examCourseRecords.get(i).getNumber() == null || examCourseRecords.get(i).getNumber() == 0) {
|
||||
// ExamNotice examNotice = new ExamNotice();
|
||||
// examNotice.setWorkerId(examCourseRecords.get(i1).getWorkerId().toString());
|
||||
// examNotice.setWorkerName(examCourseRecords.get(i1).getWorkerName());
|
||||
// examNotice.setType(1);
|
||||
// examNotice.setContent("参加安全教育课程学习");
|
||||
// examNotice.setProjectSn(list.get(i).getProjectSn());
|
||||
// noticeList.add(examNotice);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
examNoticeService.saveBatch(noticeList);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user