Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/V1.3.3^2
wanjing 11 months ago
parent
commit
5d8be1cf83
13 changed files with 337 additions and 137 deletions
  1. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionFileController.java
  2. +30
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspectionfile/ExportInspectionFileRequest.java
  3. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/flyer/UpdateFlyerService.java
  4. +9
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateInspectionStatusService.java
  5. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/IInspectionFileService.java
  6. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java
  7. +12
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/export/ExportInspectionFileByIdListService.java
  8. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/IReportServiceImpl.java
  9. +98
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByAutoService.java
  10. +129
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByManualService.java
  11. +6
    -115
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportService.java
  12. +34
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportServiceImpl.java
  13. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/logback.xml

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionFileController.java View File

* *
* 导出问题清单 * 导出问题清单
* *
* @param idList
* @param request
* @return * @return
*/ */
@GetMapping("/export/{idList}")
public void exportExcleByIdList(HttpServletRequest request, HttpServletResponse response, @PathVariable("idList") List<String> idList) {
iInspectionFileService.exportExcleByIdList(response, idList);
@GetMapping("/export")
public void exportExcleByIdList(HttpServletResponse response, ExportInspectionFileRequest request) {
iInspectionFileService.exportExcle(response, request);
} }
} }

+ 30
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/inspectionfile/ExportInspectionFileRequest.java View File

package com.tuoheng.admin.request.inspectionfile;

import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

/**
* 导出问题清单请求实体
*
* @author wanjing
* @team tuoheng
* @date 2023-12-01
*/
@Data
public class ExportInspectionFileRequest extends BaseQuery {

/**
* 任务ID
*/
private String inspectionId;

/**
* 问题编号
*/
private String questionId;

/**
* 问题状态:5待确认 10已忽略 15已确认 20已生成工单 25问题已处理
*/
private Integer status;
}

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/flyer/UpdateFlyerService.java View File

import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.ReportMapper; import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.admin.request.inspection.UpdateTaskByCodeRequest; import com.tuoheng.admin.request.inspection.UpdateTaskByCodeRequest;
import com.tuoheng.admin.service.report.generate.GenerateReportService;
import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JacksonUtil; import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
@Autowired @Autowired
private OffLineCompleteService offLineCompleteService; private OffLineCompleteService offLineCompleteService;


@Autowired
private GenerateReportService generateReportService;

/** /**
* 修改任务(修改任务状态和飞手信息) * 修改任务(修改任务状态和飞手信息)
* *
// 飞行完成 // 飞行完成
log.info("修改任务状态和飞手信息业务接口:飞行完成"); log.info("修改任务状态和飞手信息业务接口:飞行完成");
this.updateComplete(request, inspection); this.updateComplete(request, inspection);

// 任务完成后自动生成报告
generateReportService.generateByAuto(inspection.getId());
} }


// 直播 // 直播

+ 9
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateInspectionStatusService.java View File

import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum; import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.inspection.MissionStatusRequest; import com.tuoheng.admin.request.inspection.MissionStatusRequest;
import com.tuoheng.admin.service.report.generate.GenerateReportService;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@Autowired @Autowired
private UpdateWaittStatusService updateWaittStatusService; private UpdateWaittStatusService updateWaittStatusService;


@Autowired
private GenerateReportService generateReportService;

/** /**
* 添加任务 * 添加任务
* *
} }


if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) { if (AirPortTaskStatusEnum.FLIGHT.getCode() == missionStatusRequest.getStatus()) {
log.info("修改任务状态业务接口:修改执行中状态");
log.info("修改任务状态业务接口:执行中,inspectionId={}", inspection.getId());
status = InspectionStatusEnum.IN_FLIGHT.getCode(); status = InspectionStatusEnum.IN_FLIGHT.getCode();
updateFlightStatusService.updateFlightStatus(inspection, missionStatusRequest); updateFlightStatusService.updateFlightStatus(inspection, missionStatusRequest);
} else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) { } else if (AirPortTaskStatusEnum.WAIT.getCode() == missionStatusRequest.getStatus()) {
log.info("修改任务状态业务接口:修改待执行状态");
log.info("修改任务状态业务接口:飞行结束");
status = InspectionStatusEnum.FLIGHT_COMPLETED.getCode(); status = InspectionStatusEnum.FLIGHT_COMPLETED.getCode();
updateWaittStatusService.updateWaittStatus(inspection); updateWaittStatusService.updateWaittStatus(inspection);

// 任务完成后自动生成报告
generateReportService.generateByAuto(inspection.getId());
} }


this.updateEmergencyStatus(inspection, status); this.updateEmergencyStatus(inspection, status);

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/IInspectionFileService.java View File

* *
* 导出问题清单 * 导出问题清单
* *
* @param idList
* @param request
* *
* @return * @return
*/ */
JsonResult exportExcleByIdList(HttpServletResponse response, List<String> idList);
JsonResult exportExcle(HttpServletResponse response, ExportInspectionFileRequest request);
} }

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/InspectionFileServiceImpl.java View File

/** /**
* 导出问题清单 * 导出问题清单
* *
* @param idList
* @param request
* @return * @return
*/ */
@Override @Override
public JsonResult exportExcleByIdList(HttpServletResponse response, List<String> idList) {
return exportInspectionFileByIdListService.exportExcleByIdList(response, idList);
public JsonResult exportExcle(HttpServletResponse response, ExportInspectionFileRequest request) {
return exportInspectionFileByIdListService.exportExcle(response, request);
} }


} }

+ 12
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/export/ExportInspectionFileByIdListService.java View File

import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.InspectionFileMapper; import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.request.inspectionfile.ExportInspectionFileRequest;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.utils.DownloadUtil; import com.tuoheng.admin.utils.DownloadUtil;
import com.tuoheng.admin.utils.excel.CustomCellWriteWidthHandler; import com.tuoheng.admin.utils.excel.CustomCellWriteWidthHandler;
import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.FileUtils; import com.tuoheng.common.core.utils.FileUtils;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
* *
* @return * @return
*/ */
public JsonResult exportExcleByIdList(HttpServletResponse response, List<String> idList) {
log.info("进入导出任务问题清单接口");
public JsonResult exportExcle(HttpServletResponse response, ExportInspectionFileRequest request) {
log.info("进入导出任务问题清单接口, request={}", request);
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
JsonResult result = this.check(idList);
JsonResult result = this.check(request);
if (0 != result.getCode()) { if (0 != result.getCode()) {
log.info("导出任务问题清单:校验失败:{}", result.getMsg()); log.info("导出任务问题清单:校验失败:{}", result.getMsg());
return result; return result;
} }
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery()
.eq(InspectionFile::getTenantId, user.getTenantId()) .eq(InspectionFile::getTenantId, user.getTenantId())
.in(InspectionFile::getId, idList)
.eq(InspectionFile::getInspectionId, request.getInspectionId())
.eq(StringUtils.isNotEmpty(request.getQuestionId()), InspectionFile::getQuestionId, request.getQuestionId())
.eq(ObjectUtil.isNotEmpty(request.getStatus()), InspectionFile::getStatus, request.getStatus())
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode())); .eq(InspectionFile::getMark, MarkEnum.VALID.getCode()));
if (CollectionUtil.isEmpty(inspectionFileList)) { if (CollectionUtil.isEmpty(inspectionFileList)) {
log.info("问题列表不存在, idList={}", idList);
log.info("问题列表不存在, request={}", request);
return JsonResult.success(); return JsonResult.success();
} }
InspectionFile inspectionFile = inspectionFileList.get(0); InspectionFile inspectionFile = inspectionFileList.get(0);
/** /**
* 检查参数 * 检查参数
* *
* @param idList
* @param request
* @return * @return
*/ */
private JsonResult check(List<String> idList) {
if (CollectionUtil.isEmpty(idList)) {
private JsonResult check(ExportInspectionFileRequest request) {
if (StringUtils.isEmpty(request.getInspectionId())) {
throw new ServiceException("问题ID为空"); throw new ServiceException("问题ID为空");
} }
return JsonResult.success(); return JsonResult.success();

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/IReportServiceImpl.java View File

import com.tuoheng.admin.request.report.QueryReportPageListRequest; import com.tuoheng.admin.request.report.QueryReportPageListRequest;
import com.tuoheng.admin.service.report.export.ExportInspectionHandleReportService; import com.tuoheng.admin.service.report.export.ExportInspectionHandleReportService;
import com.tuoheng.admin.service.report.export.ExportInspectionReportService; import com.tuoheng.admin.service.report.export.ExportInspectionReportService;
import com.tuoheng.admin.service.report.generate.GenerateReportService;
import com.tuoheng.admin.service.report.generate.GenerateReportByManualService;
import com.tuoheng.admin.service.report.query.QueryInspectionHandleReportService; import com.tuoheng.admin.service.report.query.QueryInspectionHandleReportService;
import com.tuoheng.admin.service.report.query.QueryInspectionReportService; import com.tuoheng.admin.service.report.query.QueryInspectionReportService;
import com.tuoheng.admin.service.report.query.QueryReportPageListService; import com.tuoheng.admin.service.report.query.QueryReportPageListService;
public class IReportServiceImpl implements IReportService{ public class IReportServiceImpl implements IReportService{


@Autowired @Autowired
private GenerateReportService generateReportService;
private GenerateReportByManualService generateReportService;


@Autowired @Autowired
private QueryReportPageListService queryReportPageListService; private QueryReportPageListService queryReportPageListService;

+ 98
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByAutoService.java View File

package com.tuoheng.admin.service.report.generate;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.Report;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.report.GenerateReportCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.common.core.exception.ServiceException;
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;

/**
* 任务完成自动生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-11-30
*/
@Slf4j
@Service
public class GenerateReportByAutoService {

@Autowired
private ReportMapper reportMapper;

@Autowired
private InspectionMapper inspectionMapper;

/**
* 生成报告
*
* @return
*/
public JsonResult generate(String inspectionId) {
log.info("进入任务完成自动生成报告, inspectionId={}", inspectionId);
Report report = this.buildReport(inspectionId);

JsonResult result = this.addReport(report);
if (0 != result.getCode()) {
log.info("自动生成报告业务:添加报告记录失败:{}", result.getMsg());
throw new ServiceException("自动生成报告业务:添加报告记录失败");
}
return JsonResult.success();
}

/**
*
* 生成报告实体
*
* @param inspectionId
*/
private Report buildReport(String inspectionId) {
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getId, inspectionId)
.eq(Inspection::getMark, MarkEnum.VALID.getCode()));
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(inspection.getTenantId());
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser("");
report.setCreateTime(DateUtils.now());
return report;
}

/**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
*/
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, MarkEnum.VALID.getCode()));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());
}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("自动生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 129
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportByManualService.java View File

package com.tuoheng.admin.service.report.generate;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.code.report.GenerateReportCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-11-30
*/
@Slf4j
@Service
public class GenerateReportByManualService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private InspectionFileHandleMapper inspectionFileHandleMapper;

@Autowired
private ReportMapper reportMapper;

/**
* 生成报告
*
* @return
*/
public JsonResult generate(String id) {
log.info("进入生成报告业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("生成报告业务:校验参数失败:{}", result.getMsg());
return result;
}
Inspection inspection = (Inspection) result.getData();

Report report = this.buildReport(userId, tenantId, inspection);

result = this.addReport(report);
if (0 != result.getCode()) {
log.info("生成报告业务:添加报告记录失败:{}", result.getMsg());
return result;
}

return JsonResult.success(report);
}

/**
* 检查
*
* @param id
* @return
*/
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getCode(), GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
}
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
}

/**
*
* 生成报告实体
*
* @param inspection
*/
private Report buildReport(String userId, String tenantId, Inspection inspection) {
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(tenantId);
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser(userId);
report.setCreateTime(DateUtils.now());
return report;
}

/**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
*/
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, 1));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());

}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
}

+ 6
- 115
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportService.java View File

package com.tuoheng.admin.service.report.generate; package com.tuoheng.admin.service.report.generate;


import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.code.report.GenerateReportCodeEnum;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.service.report.query.GetInspectionFileStatusList;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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


/** /**
* 生成报告业务层处理 * 生成报告业务层处理
* *
* @author wanjing * @author wanjing
* @team tuoheng * @team tuoheng
* @date 2022-12-09
* @date 2023-11-30
*/ */
@Slf4j
@Service
public class GenerateReportService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionFileMapper inspectionFileMapper;

@Autowired
private InspectionFileHandleMapper inspectionFileHandleMapper;

@Autowired
private ReportMapper reportMapper;

/**
* 生成报告
*
* @return
*/
public JsonResult generate(String id) {
log.info("进入生成报告业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();

JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("生成报告业务:校验参数失败:{}", result.getMsg());
return result;
}
Inspection inspection = (Inspection) result.getData();

Report report = this.buildReport(userId, tenantId, inspection);

result = this.addReport(report);
if (0 != result.getCode()) {
log.info("生成报告业务:添加报告记录失败:{}", result.getMsg());
return result;
}

return JsonResult.success(report);
}
public interface GenerateReportService {


/** /**
* 检查
* 手动生成报告
* *
* @param id
* @return * @return
*/ */
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getCode(), GenerateReportCodeEnum.INSPECTION_ID_IS_NULL.getMsg());
}
Inspection inspection = inspectionMapper.selectOne(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getId, id)
.eq(Inspection::getMark, 1));
if (null == inspection) {
return JsonResult.error(GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), GenerateReportCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
return JsonResult.success(inspection);
}
JsonResult generateByManual(String id);


/**
*
* 生成报告实体
*
* @param inspection
*/
private Report buildReport(String userId, String tenantId, Inspection inspection) {
Report report = ReportConverMapper.INSTANCE.fromInspectionToReport(inspection);
// 任务编号:XJBG+日期+3位排序数字
String code = DateUtils.generateCode("XJBG");
report.setId("");
report.setReportCode(code);
report.setTenantId(tenantId);
report.setInspectionId(inspection.getId());
report.setInspectionCode(inspection.getCode());
report.setInspectionName(inspection.getName());
report.setCreateUser(userId);
report.setCreateTime(DateUtils.now());
return report;
}


/** /**
*
* 添加报告
* 每次生成报告,将上一次生成的报告给覆盖,因此直接将上次的删除,重新添加一条
*
* @param report
* 自动生成工单
*/ */
private JsonResult addReport(Report report) {
Report reportTmp = reportMapper.selectOne(Wrappers.<Report>lambdaQuery()
.eq(Report::getInspectionId, report.getInspectionId())
.eq(Report::getMark, 1));
if (null != reportTmp) {
reportMapper.deleteById(reportTmp.getId());
JsonResult generateByAuto(String id);


}
Integer rowCount = reportMapper.insert(report);
if (rowCount <= 0) {
log.info("生成报告业务:添加报告记录失败");
return JsonResult.error(GenerateReportCodeEnum.GENERATE_IS_FAILED.getCode(), GenerateReportCodeEnum.GENERATE_IS_FAILED.getMsg());
}
return JsonResult.success();
}
} }

+ 34
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/generate/GenerateReportServiceImpl.java View File

package com.tuoheng.admin.service.report.generate;

import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 生成报告业务层处理
*
* @author wanjing
* @team tuoheng
* @date 2023-11-30
*/
@Slf4j
@Service
public class GenerateReportServiceImpl implements GenerateReportService {

@Autowired
private GenerateReportByManualService generateReportByManualService;

@Autowired
private GenerateReportByAutoService generateReportByAutoService;

@Override
public JsonResult generateByManual(String id) {
return generateReportByManualService.generate(id);
}

@Override
public JsonResult generateByAuto(String id) {
return generateReportByAutoService.generate(id);
}
}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/logback.xml View File

<appender name="grpc-log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender"> <appender name="grpc-log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout"> <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout">
<Pattern>[th-waterway] %d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern>
<Pattern>[th-freeway] %d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern>
</layout> </layout>
</encoder> </encoder>
</appender> </appender>

Loading…
Cancel
Save