|
|
@@ -0,0 +1,105 @@ |
|
|
|
package com.tuoheng.admin.service.inspectionfile.deleted; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.entity.InspectionFile; |
|
|
|
import com.tuoheng.admin.enums.InspectionFileStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.code.inspectionfile.InspectionFileIgnoreCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.InspectionFileMapper; |
|
|
|
import com.tuoheng.admin.mapper.InspectionMapper; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.common.core.utils.DateUtils; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 任务问题删除业务层处理 |
|
|
|
* |
|
|
|
* @author wanjing |
|
|
|
* @team tuoheng |
|
|
|
* @date 2023-09-19 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class InspectionFileDeletedService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private InspectionFileMapper inspectionFileMapper; |
|
|
|
|
|
|
|
public JsonResult deleted(List<String> idList) { |
|
|
|
log.info("进入任务问题删除业务, idList:{}", idList.toString()); |
|
|
|
String userId = CurrentUserUtil.getUserId(); |
|
|
|
JsonResult result = this.check(idList); |
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("进入任务问题删除业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
// 忽略任务问题 |
|
|
|
result = this.updateInspectionFileStatus(userId, idList); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查参数 |
|
|
|
* |
|
|
|
* @param idList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check(List<String> idList) { |
|
|
|
// 判断任务id是否为空 |
|
|
|
if (CollectionUtil.isEmpty(idList)) { |
|
|
|
return JsonResult.error(InspectionFileIgnoreCodeEnum.INSPECTION_FILE_ID_IS_NULL.getCode(), InspectionFileIgnoreCodeEnum.INSPECTION_FILE_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 判断任务是否存在 |
|
|
|
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>() |
|
|
|
.in(InspectionFile::getId, idList) |
|
|
|
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode())); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(inspectionFileList)) { |
|
|
|
return JsonResult.error(InspectionFileIgnoreCodeEnum.INSPECTION_FILE_IS_NOT_EXIST.getCode(), InspectionFileIgnoreCodeEnum.INSPECTION_FILE_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
for (InspectionFile inspectionFile : inspectionFileList) { |
|
|
|
if (InspectionFileStatusEnum.WAIT_CONFIRMED.getCode() != inspectionFile.getStatus() && InspectionFileStatusEnum.CONFIRMED.getCode() != inspectionFile.getStatus()) { |
|
|
|
return JsonResult.error(InspectionFileIgnoreCodeEnum.NOT_WAIT_CONFIRMED_OR_CONFIRMED_CAN_IGNORED.getCode(), InspectionFileIgnoreCodeEnum.NOT_WAIT_CONFIRMED_OR_CONFIRMED_CAN_IGNORED.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 删除问题 |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param idList |
|
|
|
*/ |
|
|
|
private JsonResult updateInspectionFileStatus(String userId, List<String> idList) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("mark", MarkEnum.NOTVALID.getCode()); |
|
|
|
map.put("updateUser", userId); |
|
|
|
map.put("updateTime", DateUtils.now()); |
|
|
|
map.put("idList", idList); |
|
|
|
Integer rowCount = inspectionFileMapper.updateByIdList(map); |
|
|
|
if (rowCount <= 0) { |
|
|
|
log.info("删除问题失败"); |
|
|
|
return JsonResult.error(InspectionFileIgnoreCodeEnum.IGNORE_IS_FAILED.getCode(), InspectionFileIgnoreCodeEnum.IGNORE_IS_FAILED.getMsg()); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
|
|
|
|
} |