Commit aae9f6a9 authored by neo's avatar neo

[Optimial] fixed gen data to async

parent 178b5b36
......@@ -32,22 +32,11 @@ public class ReportController {
return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
}
@RequestMapping(value = "updateConfig/{projectId}/{ifDeleteManualDataSource}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto updateConfig(@PathVariable String projectId,
@PathVariable Boolean ifDeleteManualDataSource,
@PathVariable Integer period,
@RequestParam String generator,
@RequestParam Boolean mergeManual) {
return reportService.updateConfig(projectId, period, ifDeleteManualDataSource, generator, mergeManual);
// OperationResultDto operationResultDto = new OperationResultDto();
// operationResultDto.setResult(true);
// return operationResultDto;
}
@RequestMapping(value = "generateByTotal/{projectId}/{ifDeleteManualDataSource}/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto generateAllData(@PathVariable String projectId, @PathVariable Boolean ifDeleteManualDataSource,
@PathVariable Integer period, @RequestParam Optional<String> generator) {
return reportService.generateData(projectId, EnumServiceType.VAT, ifDeleteManualDataSource, period, null, generator);
@PathVariable Integer period, @RequestParam Optional<String> generator,
@RequestParam Boolean mergeManual) {
return reportService.generateData(projectId, EnumServiceType.VAT, mergeManual, period, null, generator);
}
@RequestMapping(value = "templateReferences/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
package pwc.taxtech.atms.dto.vatdto;
import lombok.Getter;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.TemplateGroup;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.service.impl.Message;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplate;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Getter
public class PeriodResources {
Project project;
List<PeriodTemplate> periodTemplates = new ArrayList<>();
List<PeriodCellTemplate> periodCellTemplates = new ArrayList<>();
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = new ArrayList<>();
public void setProject(Project project) {
this.project = project;
}
public void putAllTemplate(List<PeriodTemplate> periodTemplates) {
periodTemplates.addAll(periodTemplates);
}
public List<Long> getTemolateIds() {
MyAsserts.assertNotEmpty(periodTemplates, Exceptions.NOT_FOUND_TEMPLATE_EXCEPTION);
return periodTemplates.stream()
.map(PeriodTemplate::getTemplateId)
.collect(Collectors.toList());
}
public void putAllCellTemplate(List<PeriodCellTemplate> periodCellTemplates) {
periodCellTemplates.addAll(periodCellTemplates);
}
public void putAllCellTemplateConfig(List<PeriodCellTemplateConfig> periodCellTemplateConfigs) {
periodCellTemplateConfigs.addAll(periodCellTemplateConfigs);
}
public Long getTemplateGroupId(){
return periodTemplates.get(0).getTemplateGroupId();
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.entity.Template;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.entity.PeriodJob;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class WrapPeriodJobDto {
public static final String STATUS_BEGIN = "Begin";
public static final String STATUS_CANCEL = "Cancel";
public static final String STATUS_ERROR = "Error";
public static final String STATUS_END = "End";
public static final String STEP_UPDATE_CONFIG = "UpdateConfig";
public static PeriodJob createReportGenJob(String projectId, Integer period, List<Template> templates) {
MyAsserts.assertNotEmpty(templates, Exceptions.NOT_FOUND_TEMPLATE_EXCEPTION);
PeriodJob job = new PeriodJob();
job.setCreateTime(new Date());
job.setName("Gen All Report");
job.setProjectId(projectId);
job.setPeriod(period);
job.setId(UUID.randomUUID().toString());
job.setStatus(STATUS_BEGIN);
job.setCurrentStep(STEP_UPDATE_CONFIG);
StringBuilder builder = new StringBuilder(STEP_UPDATE_CONFIG);
templates.forEach(m -> {
builder.append(",").append(m.getCode());
});
job.setStepsCode(builder.toString());
return job;
}
}
package pwc.taxtech.atms.exception;
import org.springframework.http.ResponseEntity;
import javax.net.ssl.SSLEngineResult;
import static org.springframework.http.HttpStatus.CONFLICT;
public class ConflictException extends ApiException {
public ConflictException() {
super();
}
public ConflictException(String message) {
super(message);
}
public ConflictException(String message, Throwable cause) {
super(message, cause);
}
public ConflictException(Throwable cause) {
super(cause);
}
@Override
public <Object> ResponseEntity handle() {
return ResponseEntity.status(CONFLICT).build();
}
}
......@@ -10,6 +10,11 @@ public class Exceptions {
public static final ApiException EMPTY_PROJECT_PARAM = new BadParameterException("project is empty");
public static final ApiException EMPTY_PRIODDATE_PARAM = new BadParameterException("period data is empty");
public static final ApiException NOT_FOUND_REPORT_EXCEPTION = new NotFoundException("not found report");
public static final ApiException NOT_FOUND_TEMPLATE_EXCEPTION = new NotFoundException("not found template");
public static final ApiException REPORT_HAS_COMMIT_EXCEPTION = new AlreadyExistsException("report approval has commit");
public static final ApiException SERVER_ERROR_EXCEPTION= new ServerErrorException("server error exception");
public static final ApiException SERVER_ERROR_EXCEPTION = new ServerErrorException("server error exception");
public static final ApiException TASK_HAS_BEGINNING = new ConflictException("task has beginning ..");
public static final ApiException PROJECT_EMPTY_EXCEPTION = new BadParameterException("projectId is empty");
public static final ApiException PROJECT_PROJECT_EXCEPTION = new NotFoundException("not found project");
public static final ApiException NOT_FOUND_TEMPLATE_GROUP_EXCEPTION = new NotFoundException("not found template group");
}
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