|
|
|
@ -1,23 +1,20 @@ |
|
|
|
package com.biutag.supervision.service; |
|
|
|
package com.biutag.supervision.service; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
|
|
|
import com.biutag.supervision.mapper.SupTaskTestingAlcoholMapper; |
|
|
|
import com.biutag.supervision.mapper.SupTaskTestingAlcoholPeopleMapper; |
|
|
|
import com.biutag.supervision.mapper.SupTaskTestingAlcoholPeopleMapper; |
|
|
|
import com.biutag.supervision.pojo.dto.TaskProblemDto; |
|
|
|
import com.biutag.supervision.pojo.dto.TaskProblemDto; |
|
|
|
import com.biutag.supervision.pojo.dto.TaskTestingAlcoholPeopleDto; |
|
|
|
import com.biutag.supervision.pojo.dto.TaskTestingAlcoholPeopleDto; |
|
|
|
import com.biutag.supervision.pojo.entity.SupDepart; |
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
import com.biutag.supervision.pojo.entity.SupPolice; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.entity.SupTaskTestingAlcoholPeople; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.vo.FileVo; |
|
|
|
import com.biutag.supervision.pojo.vo.FileVo; |
|
|
|
import com.biutag.supervision.util.JSON; |
|
|
|
import com.biutag.supervision.util.JSON; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.Base64; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +27,7 @@ import java.util.Objects; |
|
|
|
public class SupTaskTestingAlcoholPeopleAsyncService { |
|
|
|
public class SupTaskTestingAlcoholPeopleAsyncService { |
|
|
|
|
|
|
|
|
|
|
|
private final FileService fileService; |
|
|
|
private final FileService fileService; |
|
|
|
|
|
|
|
private final SupTaskTestingAlcoholMapper taskTestingAlcoholMapper; |
|
|
|
private final SupTaskTestingAlcoholPeopleMapper baseMapper; |
|
|
|
private final SupTaskTestingAlcoholPeopleMapper baseMapper; |
|
|
|
private final SupTaskProblemService taskProblemService; |
|
|
|
private final SupTaskProblemService taskProblemService; |
|
|
|
private final SupPoliceService policeService; |
|
|
|
private final SupPoliceService policeService; |
|
|
|
@ -41,12 +39,7 @@ public class SupTaskTestingAlcoholPeopleAsyncService { |
|
|
|
if (!testingFiles.isEmpty()) { |
|
|
|
if (!testingFiles.isEmpty()) { |
|
|
|
for (FileVo testingFile : testingFiles) { |
|
|
|
for (FileVo testingFile : testingFiles) { |
|
|
|
String base64 = testingFile.getBase64(); |
|
|
|
String base64 = testingFile.getBase64(); |
|
|
|
if (base64.contains(",")) { |
|
|
|
String filePath = fileService.uploadBase64(base64, testingFile.getFileName()); |
|
|
|
base64 = base64.substring(base64.indexOf(",") + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
byte[] decodedBytes = Base64.getDecoder().decode(base64); |
|
|
|
|
|
|
|
ByteArrayInputStream is = new ByteArrayInputStream(decodedBytes); |
|
|
|
|
|
|
|
String filePath = fileService.upload(is, is.available(), FileUtil.extName(testingFile.getFileName())); |
|
|
|
|
|
|
|
testingFile.setFilePath(filePath); |
|
|
|
testingFile.setFilePath(filePath); |
|
|
|
testingFile.setBase64(null); |
|
|
|
testingFile.setBase64(null); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -58,6 +51,13 @@ public class SupTaskTestingAlcoholPeopleAsyncService { |
|
|
|
} |
|
|
|
} |
|
|
|
dto.setTestingFiles(testingFiles); |
|
|
|
dto.setTestingFiles(testingFiles); |
|
|
|
saveProblem(dto); |
|
|
|
saveProblem(dto); |
|
|
|
|
|
|
|
List<SupTaskTestingAlcoholPeople> peopleList = baseMapper.selectList(new LambdaQueryWrapper<SupTaskTestingAlcoholPeople>().eq(SupTaskTestingAlcoholPeople::getTaskId, dto.getTaskId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long detected = peopleList.stream().filter(item -> "已检测".equals(item.getTestingResult())).count(); |
|
|
|
|
|
|
|
long problemCount = taskProblemService.count(new LambdaQueryWrapper<SupTaskProblem>().eq(SupTaskProblem::getTaskId, dto.getTaskId())); |
|
|
|
|
|
|
|
String summary = String.format("应检%s人、已检%s人,未检%s人,发现%s哥问题。", peopleList.size(), detected, peopleList.size() - detected, problemCount); |
|
|
|
|
|
|
|
taskTestingAlcoholMapper.update(new LambdaUpdateWrapper<SupTaskTestingAlcohol>().eq(SupTaskTestingAlcohol::getTaskId, dto.getTaskId()) |
|
|
|
|
|
|
|
.set(SupTaskTestingAlcohol::getSummary, summary)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void saveProblem(TaskTestingAlcoholPeopleDto dto) { |
|
|
|
public void saveProblem(TaskTestingAlcoholPeopleDto dto) { |
|
|
|
|