Commit b3973270 authored by sherlock's avatar sherlock

Merge branches 'dev_oracle' and 'dev_oracle_sherlock' of…

Merge branches 'dev_oracle' and 'dev_oracle_sherlock' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_oracle_sherlock
parents 680df9b8 a53b3ae4
......@@ -47,14 +47,17 @@ public class ReportController {
@RequestMapping(value = "getRunningJob/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public PeriodJob getRunningJob(@PathVariable String projectId, @PathVariable Integer period) {
return reportService.getRunningJob(projectId, period);
public PeriodJobDto getRunningJob(@PathVariable String projectId, @PathVariable Integer period) {
PeriodJob job = reportService.getRunningJob(projectId, period);
if (job != null)
return new PeriodJobDto().copyFromPeriodJob(job);
else return null;
}
@RequestMapping(value = "getJobStatus/{projectId}//{period}/{jobId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public PeriodJob getJobStatus(@PathVariable String projectId, @PathVariable Integer period, @PathVariable String jobId) {
return reportService.getJobStatus(projectId, period, jobId);
public PeriodJobDto getJobStatus(@PathVariable String projectId, @PathVariable Integer period, @PathVariable String jobId) {
return new PeriodJobDto().copyFromPeriodJob(reportService.getJobStatus(projectId, period, jobId));
}
@RequestMapping(value = "templateReferences/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
package pwc.taxtech.atms.dto.vatdto;
import io.jsonwebtoken.lang.Collections;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.entity.PeriodJob;
import java.util.Date;
import java.util.List;
import static pwc.taxtech.atms.dto.vatdto.WrapPeriodJobDto.*;
@Getter
@Setter
public class PeriodJobDto {
private String id;
private String name;
private String currentStep;
private String projectId;
private Integer period;
private String stepsCode;
private Date createTime;
private String status;
private String errorMsg;
private String jobStatus;
public PeriodJobDto copyFromPeriodJob(PeriodJob job) {
this.id = job.getId();
this.name = job.getName();
this.currentStep = job.getCurrentStep();
this.projectId = job.getProjectId();
this.period = job.getPeriod();
this.stepsCode = job.getStepsCode();
this.createTime = job.getCreateTime();
this.status = job.getStatus();
this.errorMsg = job.getErrorMsg();
MyAsserts.assertNotEmpty(stepsCode, Exceptions.SERVER_ERROR_EXCEPTION);
if (StringUtils.isBlank(status)) this.jobStatus = STATUS_BEGIN;
else {
List<WrapPeriodJobDto.Task> tasks = WrapPeriodJobDto.fromJson(status);
if (Collections.isEmpty(tasks)) this.jobStatus = STATUS_BEGIN;
else {
String[] codes = stepsCode.split(",");
if (tasks.stream().anyMatch(m -> m.status.equals(STATUS_ERROR))) this.jobStatus = STATUS_ERROR;
else if (tasks.size() < codes.length) this.jobStatus = STATUS_RUNNING;
else this.jobStatus = STATUS_END;
}
}
return this;
}
}
......@@ -20,6 +20,7 @@ import java.util.UUID;
public class WrapPeriodJobDto {
public static final String STATUS_BEGIN = "Begin";
public static final String STATUS_RUNNING = "Running";
public static final String STATUS_CANCEL = "Cancel";
public static final String STATUS_ERROR = "Error";
public static final String STATUS_END = "End";
......
......@@ -95,6 +95,7 @@ public class ReportGeneratorImpl {
String code = sheet.getSheetName();
logger.info("-------------------------------------Begin Job [{}]------------------------------------------------------", code);
setStatus(job,code,STATUS_BEGIN);
job.setCurrentStep(code);
periodJobMapper.updateByPrimaryKey(job);
Optional<PeriodTemplate> periodTemplate = resources.getPeriodTemplates().stream()
......
......@@ -516,7 +516,7 @@ public class ReportServiceImpl {
}
}
}).start();
operationResultDto.setData(genJob);
operationResultDto.setData(new PeriodJobDto().copyFromPeriodJob(genJob));
operationResultDto.setResult(true);
} catch (Exception ex) {
operationResultDto.setResult(false);
......
......@@ -120,7 +120,7 @@ public interface PeriodJobMapper extends MyVatMapper {
"FROM " +
" PERIOD_JOB " +
"WHERE " +
" STATUS = 'Begin' " +
" STATUS LIKE '%Begin%' " +
" AND PROJECT_ID = #{projectId} " +
" AND PERIOD =#{period}")
PeriodJob getRunningJob(@Param("projectId") String projectId, @Param("period") Integer period);
......
......@@ -283,7 +283,7 @@
$scope.readonly = true;
if(data && data.result)
updateTasksStatus(data.data);
if(data.data.status=='Begin'){
if(data.data.jobStatus=='Begin'||data.data.jobStatus=='Running'){
$scope.timer= $interval(function(){
vatReportService.getJobStatus(vatSessionService.project.id,vatSessionService.month,data.data.id).then(function(result){
if(result.data && result.status == 200){
......@@ -299,6 +299,12 @@
}
});
}
function isAllEnd(stepCode,status){
var statusList = JSON.parse(status);
var stepCodes = stepCode.split(",");
}
var startCaculate = function () {
......@@ -551,43 +557,47 @@
}else{
$scope.tasks[0].items[0].status = 'completed';
$scope.tasks[0].items[0].text= $translate.instant('completed');
var items = $scope.tasks[1].items;
var currentIndex = 0;
items.forEach(function(item,index){
if((job).currentStep == item.code){
currentIndex = index;
if(job.jobStatus == 'End'){
items.forEach(function(item,index){
item.status = 'completed';
});
if($scope.timer){
$interval.cancel($scope.timer);
vatCommonService.setProjectStatus(vatSessionService.project.id, vatSessionService.month, constant.ProjectStatusEnum.Generated
, constant.DictionaryDictKey.WFDataProcess, enums.FinishStatusEnum.Finished);
}
}else if(job.jobStatus=='Running'|| job.jobStatus=='Error'){
var tasks = JSON.parse(job.status)
items.forEach(function(item,index){
tasks.forEach(function(task){
if(task.code==item.code){
if(task.status == 'Error'){
item.status = 'error';
}else if(task.status == 'End'){
item.status = 'completed';
}else if(task.status == 'Begin'){
item.status = 'processing';
}
item.text = $translate.instant(item.status);
}
})
});
});
items.forEach(function(item,index){
if(index < currentIndex){
item.status ='completed';
}else if(index == currentIndex){
if(job.status == 'Error'){
item.status = 'error';
}else if(job.status == 'End'){
item.status = 'completed';
if($scope.timer){
$interval.cancel($scope.timer);
vatCommonService.setProjectStatus(vatSessionService.project.id, vatSessionService.month, constant.ProjectStatusEnum.Generated
, constant.DictionaryDictKey.WFDataProcess, enums.FinishStatusEnum.Finished);
}
}else if(job.status == 'Begin'){
item.status = 'processing';
}
}
item.text = $translate.instant(item.status);
});
if(job.jobStatus == 'Error'){
if($scope.timer)$interval.cancel($scope.timer);
}
}
}
}
var getInitTaskStatus = function(){
vatReportService.getRunningJob(vatSessionService.project.id,vatSessionService.month).then(function (result) {
if(result.data && result.status == 200){
updateTasksStatus(result.data);
if(result.data.status=='Begin'){
if(result.data.jobStatus=='Begin'||result.data.jobStatus=='Running'){
$scope.timer= $interval(function(){
vatReportService.getJobStatus(vatSessionService.project.id,vatSessionService.month,result.data.id)
.success(function(result){
......
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