Commit df01b2b9 authored by suhuiguang's avatar suhuiguang

fix(jyjc): 报检规则4.0开发

1.增加日志打印计时
parent df0593d0
......@@ -7,7 +7,6 @@ import com.yeejoin.amos.boot.module.jyjc.biz.file.inspectapp.factory.support.Doc
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
@Service
@RequiredArgsConstructor
......@@ -20,13 +19,8 @@ public class DocGenerateService {
public String generateDoc(String appSeq) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
DocGenerationRequest docGenerationRequest = defaultDocGenerateAdapter.prepareRequest(appSeq);
DocGenerator docGenerator = docGeneratorFactory.getGenerator(docGenerationRequest);
String path = docGenerator.generate(appSeq);
stopWatch.stop();
log.info("生成报检申请表耗时:{}秒", stopWatch.getTotalTimeMillis());
return path;
return docGenerator.generate(appSeq);
}
}
......@@ -23,11 +23,12 @@ public class DocUpdateService {
@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void genDocAndUpdate(String appSeq) {
log.info("开始异步生成报检申请表");
log.info("异步生成报检申请表开始");
String filePath = docGenerateService.generateDoc(appSeq);
LambdaUpdateWrapper<JyjcInspectionApplication> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(JyjcInspectionApplication::getInspectAppUrl, filePath);
updateWrapper.eq(BaseEntity::getSequenceNbr, appSeq);
repository.update(null, updateWrapper);
log.info("异步生成报检申请表结束");
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.file.inspectapp.strategy;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.common.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication;
......@@ -21,6 +22,7 @@ import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
......@@ -45,12 +47,19 @@ public class GenericDocGeneratorStrategy implements SupportableDocGenerator {
@Override
public String generate(String appSeq) {
StopWatch stopWatch = new StopWatch();
stopWatch.start("1.组织数据");
Map<String, Object> params = appDocCmService.getBaseInFo(appSeq);
JyjcInspectionApplication inspectionApplication = jyjcInspectionApplicationService.getBaseMapper().selectById(appSeq);
params.put("numberOfEquip", inspectionApplication.getNumberOfEquip());
setEquipExcelData(inspectionApplication, params);
stopWatch.stop();
stopWatch.start("2.文件生成及上传");
this.setRequestContext();
return this.generatePdfAndUpload(params);
String path = this.generatePdfAndUpload(params);
stopWatch.stop();
log.info("生成台套气瓶申请表耗时:{}", stopWatch.prettyPrint(TimeUnit.SECONDS));
return path;
}
private void setRequestContext() {
......
......@@ -13,12 +13,14 @@ import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import cn.hutool.core.date.StopWatch;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service
@Slf4j
......@@ -40,11 +42,18 @@ public class PipelineDocGeneratorStrategy implements SupportableDocGenerator {
@Override
public String generate(String appSeq) {
StopWatch stopWatch = new StopWatch();
stopWatch.start("1.组织数据");
Map<String, Object> params = appDocCmService.getBaseInFo(appSeq);
JyjcInspectionApplication inspectionApplication = jyjcInspectionApplicationService.getBaseMapper().selectById(appSeq);
this.setPipelineInfo(params, inspectionApplication);
stopWatch.stop();
stopWatch.start("2.文件生成及上传");
this.setRequestContext();
return this.generatePdfAndUpload(params);
String path = this.generatePdfAndUpload(params);
stopWatch.stop();
log.info("生成管道报检申请表耗时:{}", stopWatch.prettyPrint(TimeUnit.SECONDS));
return path;
}
private void setRequestContext() {
......
......@@ -88,6 +88,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.RequestBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -1934,8 +1935,13 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
public String genDocPath(String appSeq) {
StopWatch watch = new StopWatch();
watch.start();
DocGenerationRequest docGenerationRequest = defaultDocGenerateAdapter.prepareRequest(appSeq);
DocGenerator docGenerator = docGeneratorFactory.getGenerator(docGenerationRequest);
return docGenerator.generate(appSeq);
String path = docGenerator.generate(appSeq);
watch.stop();
log.info("生成报检申请表耗时:{}秒", watch.getTotalTimeSeconds());
return path;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment