Sfoglia il codice sorgente

修改处理问题接口

tags/v1.0.0^2
chengwang 1 anno fa
parent
commit
1de250ed3e
4 ha cambiato i file con 134 aggiunte e 9 eliminazioni
  1. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/dto/UploadResultDto.java
  2. +49
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/InspectionFileHandleEnum.java
  3. +79
    -9
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileHandleServiceImpl.java
  4. +1
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java

+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/dto/UploadResultDto.java Vedi File

@@ -14,6 +14,11 @@ public class UploadResultDto {
*/
private String id;

/**
* 工单id
*/
private String workOrderId;

/**
* 租户id
*/

+ 49
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/InspectionFileHandleEnum.java Vedi File

@@ -0,0 +1,49 @@
package com.tuoheng.miniprogram.enums;

/**
* @Author ChengWang
* @Date 2022/12/12
*/
public enum InspectionFileHandleEnum {

INSPECTION_FILE_ID_IS_NULL(1210800, "问题id为空"),
TENANT_ID_IS_NULL(1210801, "租户id为空"),
USER_ID_IS_NULL(1210802, "用户id为空"),
USER_NAME_IS_NULL(1210803, "登录用户名为空"),
WORK_ORDER_ID_NULL(1210804, "登录用户名为空"),
USER_IS_NOT_EXIST(1210805, "用户为空"),
DEPT_ID_IS_NULL(1210806, "部门id为空"),
DATA_IS_NULL(1210807, "数据为空");


/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

InspectionFileHandleEnum(int code, String msg){
this.code = code;
this.msg = msg;
}

public int getCode() {
return code;
}

public void setCode(int code) {
this.code = code;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}
}

+ 79
- 9
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileHandleServiceImpl.java Vedi File

@@ -1,18 +1,26 @@
package com.tuoheng.miniprogram.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.SecurityUserUtils;
import com.tuoheng.common.core.utils.StringUtils;
import com.tuoheng.miniprogram.dao.InspectionFileHandleMapper;
import com.tuoheng.miniprogram.dao.InspectionFileMapper;
import com.tuoheng.miniprogram.entity.InspectionFileHandle;
import com.tuoheng.miniprogram.dao.*;
import com.tuoheng.miniprogram.entity.*;
import com.tuoheng.miniprogram.entity.dto.UploadResultDto;
import com.tuoheng.miniprogram.enums.InspectionFileHandleEnum;
import com.tuoheng.miniprogram.enums.ServiceExceptionEnum;
import com.tuoheng.miniprogram.service.IInspectionFileHandleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Author ChengWang
* @Date 2022/11/25
@@ -24,9 +32,18 @@ public class InspectionFileHandleServiceImpl implements IInspectionFileHandleSer
@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private UserMapper userMapper;

@Autowired
private InspectionFileHandleMapper inspectionFileHandleMapper;

@Autowired
private WorkOrderMapper workOrderMapper;

@Autowired
private WorkOrderFileMapper workOrderFileMapper;

/**
* 上传结果
* @param dto
@@ -34,25 +51,78 @@ public class InspectionFileHandleServiceImpl implements IInspectionFileHandleSer
*/
@Override
public JsonResult uploadResult(UploadResultDto dto) {
//登录用户信息
//String username = SecurityUserUtils.username();
String username = "admin";
if(StringUtils.isEmpty(username)){
return JsonResult.error(InspectionFileHandleEnum.USER_NAME_IS_NULL.getCode(),InspectionFileHandleEnum.USER_NAME_IS_NULL.getMsg());
}
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getMark, 1)
.eq(User::getUsername, username));
if(ObjectUtil.isNull(user)){
return JsonResult.error(InspectionFileHandleEnum.USER_IS_NOT_EXIST.getCode(),InspectionFileHandleEnum.USER_IS_NOT_EXIST.getMsg());
}
if(StringUtils.isEmpty(user.getId())){
return JsonResult.error(InspectionFileHandleEnum.USER_ID_IS_NULL.getCode(),InspectionFileHandleEnum.USER_ID_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(dto.getId())) {
return JsonResult.error("问题id为空");
return JsonResult.error(InspectionFileHandleEnum.INSPECTION_FILE_ID_IS_NULL.getCode(),InspectionFileHandleEnum.INSPECTION_FILE_ID_IS_NULL.getMsg());
}
if(StringUtils.isEmpty(dto.getTenantId())){
return JsonResult.error("租户id不存在");
if(StringUtils.isEmpty(user.getTenantId())){
return JsonResult.error(InspectionFileHandleEnum.TENANT_ID_IS_NULL.getCode(),InspectionFileHandleEnum.TENANT_ID_IS_NULL.getMsg());
}
//更新问题处理表
InspectionFileHandle inspectionFileHandle = new InspectionFileHandle();
inspectionFileHandle.setInspectionFileId(dto.getId());
inspectionFileHandle.setTenantId(dto.getTenantId());
inspectionFileHandle.setTenantId(user.getTenantId());
inspectionFileHandle.setHandlerImage(dto.getHandlerImage());
inspectionFileHandle.setHandlerResult(dto.getHandlerResult());
inspectionFileHandle.setHandlerUser("cw");
inspectionFileHandle.setCreateUser("cw");
inspectionFileHandle.setHandlerTime(DateUtils.now());
inspectionFileHandle.setHandlerUser(user.getId());
inspectionFileHandle.setCreateUser(user.getId());
inspectionFileHandle.setCreateTime(DateUtils.now());
inspectionFileHandle.setMark(1);
int count = inspectionFileHandleMapper.insert(inspectionFileHandle);
if(count<=0){
return JsonResult.error();
}
//更新问题表问题状态为已处理
InspectionFile inspectionFile = inspectionFileMapper.selectById(dto.getId());
if(ObjectUtil.isNull(inspectionFile)){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
inspectionFile.setStatus(25);
inspectionFile.setUpdateTime(DateUtils.now());
inspectionFile.setUpdateUser(user.getId());
int result = inspectionFileMapper.updateById(inspectionFile);
if(result<=0){
return JsonResult.error();
}
//更新工单状态,当前工单关联的任务问题处理完时,将工单状态改为已完成
if(StringUtils.isEmpty(dto.getWorkOrderId())){
return JsonResult.error(InspectionFileHandleEnum.WORK_ORDER_ID_NULL.getCode(),InspectionFileHandleEnum.WORK_ORDER_ID_NULL.getMsg());
}
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery()
.eq(WorkOrderFile::getWorkOrderId, dto.getWorkOrderId()));
if(StringUtils.isEmpty(workOrderFiles)){
return JsonResult.error(InspectionFileHandleEnum.DATA_IS_NULL.getCode(),InspectionFileHandleEnum.DATA_IS_NULL.getMsg());
}
List<String> inspectionFileList = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList());
Integer inspectionFileHandleCount = inspectionFileHandleMapper.selectCount(new LambdaQueryWrapper<InspectionFileHandle>()
.in(InspectionFileHandle::getInspectionFileId, inspectionFileList));
if(workOrderFiles.size()>inspectionFileHandleCount){
return JsonResult.success();
}
WorkOrder workOrder = workOrderMapper.selectById(dto.getWorkOrderId());
workOrder.setStatus(15);
workOrder.setUpdateUser(user.getId());
workOrder.setUpdateTime(DateUtils.now());
int i = workOrderMapper.updateById(workOrder);
if(i<=0){
return JsonResult.error();
}


return JsonResult.success();
}

+ 1
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java Vedi File

@@ -257,6 +257,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
if(ObjectUtil.isNotNull(workOrder)){
workOrder.setStatus(15);
workOrder.setUpdateTime(DateUtils.now());
workOrder.setUpdateUser(user.getId());
super.update(workOrder);
}
}

Loading…
Annulla
Salva