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; + } }