5 changed files with 200 additions and 75 deletions
@ -0,0 +1,53 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import cn.hutool.core.io.FileUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
import com.biutag.supervision.mapper.SupTaskProblemMapper; |
||||
import com.biutag.supervision.pojo.entity.SupTaskProblem; |
||||
import com.biutag.supervision.pojo.vo.FileVo; |
||||
import com.biutag.supervision.util.JSON; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.util.Base64; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2025/7/17 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class SupTaskProblemAsyncService { |
||||
|
||||
private final FileService fileService; |
||||
|
||||
private final SupTaskProblemMapper baseMapper; |
||||
|
||||
@Async |
||||
public void uploadFile(List<FileVo> files, Integer id) { |
||||
if (!files.isEmpty()) { |
||||
for (FileVo file : files) { |
||||
if (StrUtil.isNotBlank(file.getFilePath())) { |
||||
continue; |
||||
} |
||||
String base64 = file.getBase64(); |
||||
if (base64.contains(",")) { |
||||
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(file.getFileName())); |
||||
file.setFilePath(filePath); |
||||
file.setBase64(null); |
||||
} |
||||
LambdaUpdateWrapper<SupTaskProblem> updateWrapper = new LambdaUpdateWrapper<>(); |
||||
updateWrapper.eq(SupTaskProblem::getId, id) |
||||
.set(SupTaskProblem::getFiles, JSON.toJSONString(files)); |
||||
baseMapper.update(updateWrapper); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,120 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import cn.hutool.core.io.FileUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
import com.biutag.supervision.mapper.SupTaskTestingAlcoholPeopleMapper; |
||||
import com.biutag.supervision.pojo.dto.TaskProblemDto; |
||||
import com.biutag.supervision.pojo.dto.TaskTestingAlcoholPeopleDto; |
||||
import com.biutag.supervision.pojo.entity.SupDepart; |
||||
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.util.JSON; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.Base64; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2025/7/17 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class SupTaskTestingAlcoholPeopleAsyncService { |
||||
|
||||
private final FileService fileService; |
||||
private final SupTaskTestingAlcoholPeopleMapper baseMapper; |
||||
private final SupTaskProblemService taskProblemService; |
||||
private final SupPoliceService policeService; |
||||
private final SupDepartService departService; |
||||
|
||||
@Async |
||||
public void uploadFile(TaskTestingAlcoholPeopleDto dto) { |
||||
List<FileVo> testingFiles = dto.getTestingFiles().stream().filter(item -> StrUtil.isNotBlank(item.getBase64())).toList(); |
||||
if (!testingFiles.isEmpty()) { |
||||
for (FileVo testingFile : testingFiles) { |
||||
String base64 = testingFile.getBase64(); |
||||
if (base64.contains(",")) { |
||||
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.setBase64(null); |
||||
} |
||||
LambdaUpdateWrapper<SupTaskTestingAlcoholPeople> updateWrapper = new LambdaUpdateWrapper<>(); |
||||
updateWrapper.eq(SupTaskTestingAlcoholPeople::getTaskId, dto.getTaskId()) |
||||
.eq(SupTaskTestingAlcoholPeople::getEmpNo, dto.getEmpNo()) |
||||
.set(SupTaskTestingAlcoholPeople::getTestingFiles, JSON.toJSONString(testingFiles)); |
||||
baseMapper.update(updateWrapper); |
||||
} |
||||
dto.setTestingFiles(testingFiles); |
||||
saveProblem(dto); |
||||
} |
||||
|
||||
public void saveProblem(TaskTestingAlcoholPeopleDto dto) { |
||||
if ("已检测".equals(dto.getTestingResult())) { |
||||
if ("饮酒".equals(dto.getDrinkResult()) || "是".equals(dto.getIsIllegalBanquet())) { |
||||
SupPolice police = policeService.getByEmpNo(dto.getEmpNo()); |
||||
SupDepart depart = departService.getById(police.getOrgId()); |
||||
TaskProblemDto problemDto = new TaskProblemDto(); |
||||
TaskProblemDto.People people = new TaskProblemDto.People(); |
||||
people.setName(police.getName()); |
||||
people.setEmpNo(police.getEmpNo()); |
||||
people.setIdCode(police.getIdCode()); |
||||
problemDto.setHasProblem(true); |
||||
problemDto.setDepartId(police.getOrgId()); |
||||
problemDto.setPeoples(List.of(people)); |
||||
problemDto.setTaskId(dto.getTaskId()); |
||||
problemDto.setFiles(dto.getTestingFiles()); |
||||
// XX年X月X日X时X分,在“公安部六项规定”督察中,发现“XX”单位的“X”存在“违规宴请”的问题情况,请立即组织核实其当时情况。
|
||||
// XX年X月X日X时X分,在“公安部六项规定”督察中,发现“X”单位的“XX”存在“饮酒”的问题情况,请立即组织核实其当时情况.
|
||||
String thingDesc = String.format("%s,在“公安部六项规定”督察中,", dto.getTestingTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分"))); |
||||
if ("饮酒".equals(dto.getDrinkResult())) { |
||||
thingDesc += String.format("发现“%s”单位的“%s”存在“饮酒”%s的问题情况,", |
||||
depart.getName(), |
||||
police.getName(), |
||||
Objects.nonNull(dto.getAlcoholContent()) ? String.format("%s(mg/100ml)", dto.getAlcoholContent()) : ""); |
||||
} |
||||
if ("是".equals(dto.getIsIllegalBanquet())) { |
||||
thingDesc += String.format("发现“%s”单位的“%s”存在“违规宴请”的问题情况,", |
||||
depart.getName(), |
||||
police.getName()); |
||||
} |
||||
thingDesc += "请立即组织核实其当时情况。"; |
||||
problemDto.setThingDesc(thingDesc); |
||||
taskProblemService.save(problemDto); |
||||
} |
||||
} else { |
||||
String unTestingDesc = "其他".equals(dto.getUnTestingDesc()) ? dto.getUnTestingDescOther() : dto.getUnTestingDesc(); |
||||
if (!"请假".equals(unTestingDesc)) { |
||||
SupPolice police = policeService.getByEmpNo(dto.getEmpNo()); |
||||
SupDepart depart = departService.getById(police.getOrgId()); |
||||
TaskProblemDto problemDto = new TaskProblemDto(); |
||||
TaskProblemDto.People people = new TaskProblemDto.People(); |
||||
people.setName(police.getName()); |
||||
people.setEmpNo(police.getEmpNo()); |
||||
people.setIdCode(police.getIdCode()); |
||||
problemDto.setHasProblem(true); |
||||
problemDto.setDepartId(police.getOrgId()); |
||||
problemDto.setPeoples(List.of(people)); |
||||
problemDto.setTaskId(dto.getTaskId()); |
||||
// X年X月X日X时X分,在“公安部六项规定”督察中,发现“XX”单位的“XX”存在“联系不上”的问题情况,未参加监测,请立即组织核实其当时情况。
|
||||
problemDto.setThingDesc(String.format("%s,在“公安部六项规定”督察中,发现“%s”单位的“%s”存在“%s”的问题情况,未参加监测,请立即组织核实其当时情况。", |
||||
dto.getTestingTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分")), |
||||
depart.getName(), |
||||
police.getName(), |
||||
unTestingDesc)); |
||||
taskProblemService.save(problemDto); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue