From 66e82fe470542afb5dcfd9892f03d7dab39dd541 Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Mon, 21 Jul 2025 17:50:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=82=B9?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=9D=A3=E5=AF=9F=E8=AE=B0=E5=BD=95=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=AD=A3=E5=B8=B8=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8A=9E=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E9=80=80=E5=9B=9E=E5=AF=BC=E8=87=B4=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E4=BA=8C=E7=BA=A7=E6=9C=BA=E6=9E=84=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E5=8A=9E=E7=90=86=EF=BC=8C=E6=89=80=E9=98=9F=E5=86=8D=E9=80=80?= =?UTF-8?q?=E5=9B=9E=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupRiskPersonController.java | 5 +- .../flow/action/ThreeSignReturnAction.java | 4 +- .../com/biutag/supervision/job/RiskJob.java | 2 +- .../service/SupRiskPersonalService.java | 45 ---------------- .../SupRiskPersonalSupRecordAsyncService.java | 50 +++++++++++++++++ .../SupRiskPersonalSupRecordService.java | 53 ++++++++++++++++++- 6 files changed, 109 insertions(+), 50 deletions(-) create mode 100644 src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordAsyncService.java diff --git a/src/main/java/com/biutag/supervision/controller/mobileSupervision/SupRiskPersonController.java b/src/main/java/com/biutag/supervision/controller/mobileSupervision/SupRiskPersonController.java index 23b3b40..6e650e2 100644 --- a/src/main/java/com/biutag/supervision/controller/mobileSupervision/SupRiskPersonController.java +++ b/src/main/java/com/biutag/supervision/controller/mobileSupervision/SupRiskPersonController.java @@ -8,6 +8,7 @@ import com.biutag.supervision.pojo.param.SupRiskPersonalSupRecordQueryParam; import com.biutag.supervision.pojo.vo.SupRiskPersonalSupRecordVo; import com.biutag.supervision.pojo.vo.SupRiskPersonalVo; import com.biutag.supervision.service.SupRiskPersonalService; +import com.biutag.supervision.service.SupRiskPersonalSupRecordService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -19,6 +20,8 @@ public class SupRiskPersonController { private final SupRiskPersonalService supRiskPersonalService; + private final SupRiskPersonalSupRecordService riskPersonalSupRecordService; + @GetMapping Result> queryPage(SupRiskPersonalQueryParam queryParam){ return Result.success(supRiskPersonalService.page(queryParam)); @@ -32,7 +35,7 @@ public class SupRiskPersonController { //保存督察记录 @PostMapping("/saveSupRecord") Result saveSupRecord(@RequestBody SupRiskPersonalSupRecordDto supRecordDto){ - if( supRiskPersonalService.saveSupRecord(supRecordDto)){ + if( riskPersonalSupRecordService.saveSupRecord(supRecordDto)){ return Result.success(); }else{ return Result.failed("操作失败"); diff --git a/src/main/java/com/biutag/supervision/flow/action/ThreeSignReturnAction.java b/src/main/java/com/biutag/supervision/flow/action/ThreeSignReturnAction.java index f3c0f79..19c085f 100644 --- a/src/main/java/com/biutag/supervision/flow/action/ThreeSignReturnAction.java +++ b/src/main/java/com/biutag/supervision/flow/action/ThreeSignReturnAction.java @@ -100,15 +100,17 @@ public class ThreeSignReturnAction implements Action { public void addWork(String negativeId, boolean secondFlag) { String roleCode = secondFlag ? RoleCodeEnum.SECOND_ADMIN.getCode() : RoleCodeEnum.FIRST_ADMIN.getCode(); + Negative negative = negativeService.getById(negativeId); NegativeWork work = workService.getOne(new LambdaQueryWrapper() .eq(NegativeWork::getNegativeId, negativeId) + .eq(NegativeWork::getDepartId, negative.getHandleSecondDepartId()) .eq(NegativeWork::getRoleCode, roleCode)); if (Objects.nonNull(work)) { work.setUpdateTime(LocalDateTime.now()) .setStatus(WorkStatusEnum.todo.name()); workService.updateById(work); } else { - Negative negative = negativeService.getById(negativeId); + work = new NegativeWork() .setNegativeId(negativeId) .setRoleCode(roleCode) diff --git a/src/main/java/com/biutag/supervision/job/RiskJob.java b/src/main/java/com/biutag/supervision/job/RiskJob.java index 3151dbd..ea77687 100644 --- a/src/main/java/com/biutag/supervision/job/RiskJob.java +++ b/src/main/java/com/biutag/supervision/job/RiskJob.java @@ -69,7 +69,7 @@ public class RiskJob { if (!riskPersonalSupRecordService.exists(new LambdaQueryWrapper() .eq(SupRiskPersonalSupRecord::getTaskId, riskPersonal.getTaskId()) .eq(SupRiskPersonalSupRecord::getIdCode, riskPersonal.getIdCode()) - .between(SupRiskPersonalSupRecord::getSupTime, now.minusMinutes(remainder), now))) { + .between(SupRiskPersonalSupRecord::getSupTime, now.minusMinutes(remainder), LocalDateTime.now()))) { // 状态更新为未督察 riskPersonalService.update(new LambdaUpdateWrapper().eq(SupRiskPersonal::getIdCode, riskPersonal.getIdCode()) .set(SupRiskPersonal::getWorkStatus, WorkStatusEnum.todo.name())); diff --git a/src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java b/src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java index deed82d..87f9417 100644 --- a/src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java +++ b/src/main/java/com/biutag/supervision/service/SupRiskPersonalService.java @@ -2,42 +2,26 @@ package com.biutag.supervision.service; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.biutag.supervision.common.UserContextHolder; -import com.biutag.supervision.constants.AppConstants; -import com.biutag.supervision.constants.enums.WorkStatusEnum; import com.biutag.supervision.mapper.SupRiskPersonalMapper; import com.biutag.supervision.mapper.SupRiskPersonalSupRecordMapper; -import com.biutag.supervision.pojo.dto.SupRiskPersonalSupRecordDto; import com.biutag.supervision.pojo.entity.SupRiskPersonal; import com.biutag.supervision.pojo.entity.SupRiskPersonalSupRecord; -import com.biutag.supervision.pojo.entity.SupTask; -import com.biutag.supervision.pojo.model.UserAuth; import com.biutag.supervision.pojo.param.SupRiskPersonalQueryParam; import com.biutag.supervision.pojo.param.SupRiskPersonalSupRecordQueryParam; import com.biutag.supervision.pojo.vo.FileVo; import com.biutag.supervision.pojo.vo.SupRiskPersonalSupRecordVo; import com.biutag.supervision.pojo.vo.SupRiskPersonalVo; -import com.biutag.supervision.util.JSON; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import java.time.LocalDateTime; - @RequiredArgsConstructor @Service public class SupRiskPersonalService extends ServiceImpl { - - private final SupRiskPersonalSupRecordService supRecordService; - private final SupRiskPersonalSupRecordMapper supRiskPersonalSupRecordMapper; - private final SupTaskService taskService; - /** * 分页查询 * */ @@ -57,35 +41,6 @@ public class SupRiskPersonalService extends ServiceImpl().eq(SupRiskPersonal::getIdCode, supRecordDto.getIdCode()) - .set(SupRiskPersonal::getWorkStatus, WorkStatusEnum.done.name()) - .set(SupRiskPersonal::getSupStatus, supRecordDto.getSupStatus())); - if (!exists(new LambdaUpdateWrapper() - .eq(SupRiskPersonal::getTaskId, supRecordDto.getTaskId()) - .eq(SupRiskPersonal::getWorkStatus, WorkStatusEnum.todo.name()))) { - taskService.update(new LambdaUpdateWrapper().eq(SupTask::getId, supRecordDto.getTaskId()) - .set(SupTask::getTaskStatus, WorkStatusEnum.done.name())); - } - } - - return b; - } /** * 督察记录列表 diff --git a/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordAsyncService.java b/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordAsyncService.java new file mode 100644 index 0000000..6fcdd29 --- /dev/null +++ b/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordAsyncService.java @@ -0,0 +1,50 @@ +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.SupRiskPersonalSupRecordMapper; +import com.biutag.supervision.pojo.entity.SupRiskPersonalSupRecord; +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; + +@RequiredArgsConstructor +@Service +public class SupRiskPersonalSupRecordAsyncService { + + private final FileService fileService; + + private final SupRiskPersonalSupRecordMapper baseMapper; + + @Async + public void uploadFile(List 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 updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(SupRiskPersonalSupRecord::getId, id) + .set(SupRiskPersonalSupRecord::getFiles, JSON.toJSONString(files)); + baseMapper.update(updateWrapper); + } + } + +} diff --git a/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordService.java b/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordService.java index d763329..7f846f8 100644 --- a/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordService.java +++ b/src/main/java/com/biutag/supervision/service/SupRiskPersonalSupRecordService.java @@ -1,12 +1,61 @@ package com.biutag.supervision.service; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.biutag.supervision.mapper.SupRiskPersonalSupMapper; +import com.biutag.supervision.common.UserContextHolder; +import com.biutag.supervision.constants.AppConstants; +import com.biutag.supervision.constants.enums.WorkStatusEnum; import com.biutag.supervision.mapper.SupRiskPersonalSupRecordMapper; -import com.biutag.supervision.pojo.entity.SupRiskPersonalSup; +import com.biutag.supervision.pojo.dto.SupRiskPersonalSupRecordDto; +import com.biutag.supervision.pojo.entity.SupRiskPersonal; import com.biutag.supervision.pojo.entity.SupRiskPersonalSupRecord; +import com.biutag.supervision.pojo.entity.SupTask; +import com.biutag.supervision.pojo.model.UserAuth; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; + +@RequiredArgsConstructor @Service public class SupRiskPersonalSupRecordService extends ServiceImpl { + + private final SupTaskService taskService; + + private final SupRiskPersonalService riskPersonalService; + + private final SupRiskPersonalSupRecordAsyncService riskPersonalSupRecordAsyncService; + + /** + * 录入督察记录数据 + * */ + public Boolean saveSupRecord(SupRiskPersonalSupRecordDto supRecordDto){ + SupRiskPersonalSupRecord supRecord = new SupRiskPersonalSupRecord(); + BeanUtils.copyProperties(supRecordDto,supRecord); + supRecord.setCreateTime(LocalDateTime.now()); + UserAuth user = UserContextHolder.getCurrentUser(); + if (!AppConstants.USER_TYPE_SUPER.equals(user.getUserType())) { + supRecord.setCreateEmpNo(user.getEmpNo()); + supRecord.setCreateName(user.getUserName()); + } + //补充file + // supRecord.setFiles(JSON.toJSONString(supRecordDto.getFiles())); + boolean b = saveOrUpdate(supRecord); + if (b) { + + riskPersonalService.update(new LambdaUpdateWrapper().eq(SupRiskPersonal::getIdCode, supRecordDto.getIdCode()) + .set(SupRiskPersonal::getWorkStatus, WorkStatusEnum.done.name()) + .set(SupRiskPersonal::getSupStatus, supRecordDto.getSupStatus())); + if (!riskPersonalService.exists(new LambdaUpdateWrapper() + .eq(SupRiskPersonal::getTaskId, supRecordDto.getTaskId()) + .eq(SupRiskPersonal::getWorkStatus, WorkStatusEnum.todo.name()))) { + taskService.update(new LambdaUpdateWrapper().eq(SupTask::getId, supRecordDto.getTaskId()) + .set(SupTask::getTaskStatus, WorkStatusEnum.done.name())); + } + riskPersonalSupRecordAsyncService.uploadFile(supRecordDto.getFiles(), supRecord.getId()); + } + + return b; + } }