Commit 000f3fd4 authored by neo's avatar neo

[DEV] add some conditon for approval protect

parent 8605405b
......@@ -70,6 +70,12 @@ public class ApprovalController {
approvalService.checkTask(taskId, decide,comment);
}
@ResponseBody
@RequestMapping(value = "/status/{projectId}/{period}")
public String getApprovalStatus(@PathVariable String projectId,@PathVariable Integer period){
return approvalService.getApprovalStatus(projectId,period);
}
@RequestMapping(value = "/show/{procDefId}")//获取流程图
public void showImg(@PathVariable String procDefId, HttpServletResponse response) {
try {
......
......@@ -18,4 +18,5 @@ public class Exceptions {
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");
public static final ApiException NOT_FOUND_EXCEPTION = new NotFoundException("not found resources");
public static final ApiException REPORT_IN_PROCESS_OR_AGREED_EXCEPTION = new PreconditionFailedException("report in approval or agreed result");
}
package pwc.taxtech.atms.exception;
import org.springframework.http.ResponseEntity;
public class PreconditionFailedException extends ApiException {
public PreconditionFailedException() {
super();
}
public PreconditionFailedException(String message) {
super(message);
}
public PreconditionFailedException(String message, Throwable cause) {
super(message, cause);
}
public PreconditionFailedException(Throwable cause) {
super(cause);
}
@Override
public <Object> ResponseEntity handle() {
return ResponseEntity.notFound().build();
}
}
\ No newline at end of file
......@@ -172,4 +172,8 @@ public class ApprovalService {
public Template getTemplateInfo(Long templateId) {
return templateMapper.selectByPrimaryKey(templateId);
}
public String getApprovalStatus(String projectId, Integer period) {
return periodApproveMapper.getStatusByProjectIdAndPeriod(projectId,period);
}
}
......@@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.*;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dpo.ReportDto;
......@@ -30,7 +31,6 @@ import pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto;
import pwc.taxtech.atms.vat.dpo.DataSourceExtendDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper;
import java.io.File;
......@@ -102,6 +102,8 @@ public class ReportServiceImpl {
private DistributedIdService distributedIdService;
@Autowired
private PeriodJobMapper periodJobMapper;
@Autowired
private PeriodApproveMapper periodApprovalMapper;
public OperationResultDto<List<ReportDto>> getReportTemplate(String projectId, EnumServiceType serviceType, Integer periodParam) {
int period = periodParam != null ? periodParam : 0;
......@@ -256,7 +258,7 @@ public class ReportServiceImpl {
job.setStatus(WrapPeriodJobDto.STATUS_ERROR);
job.setErrorMsg("error update config with projectId " + projectId + " period" + period);
logger.error(ex.getMessage(), ex);
}finally {
} finally {
periodJobMapper.updateByPrimaryKey(job);
}
}
......@@ -461,6 +463,8 @@ public class ReportServiceImpl {
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(periodParam)
.andStatusEqualTo(WrapPeriodJobDto.STATUS_BEGIN);
MyAsserts.assertEmpty(periodJobMapper.selectByExample(example), Exceptions.TASK_HAS_BEGINNING);
String status = periodApprovalMapper.getStatusByProjectIdAndPeriod(projectId, periodParam);
MyAsserts.assertTrue(status == null || status.equals(Constant.APPROVAL_DISAGREED), Exceptions.REPORT_IN_PROCESS_OR_AGREED_EXCEPTION);
List<Template> templates = getTemplatesByProjectId(projectId);
......@@ -485,12 +489,12 @@ public class ReportServiceImpl {
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateAll();
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources,isMergeManualData, genJob);
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, isMergeManualData, genJob);
genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob);
}catch (Exception e){
} catch (Exception e) {
genJob.setStatus(WrapPeriodJobDto.STATUS_ERROR);
genJob.setErrorMsg("Sever error");
periodJobMapper.updateByPrimaryKey(genJob);
......@@ -706,7 +710,7 @@ public class ReportServiceImpl {
private Integer convertType(Integer dataSourceType) {
if (dataSourceType.equals(FormulaDataSourceDetailType.InputInvoiceDataSourceDto.getCode())) {
return CellDataSourceType.InputInvoice.getCode();
} else if(dataSourceType.equals(FormulaDataSourceDetailType.OutputInvoiceDataSourceDto.getCode())){
} else if (dataSourceType.equals(FormulaDataSourceDetailType.OutputInvoiceDataSourceDto.getCode())) {
return CellDataSourceType.OutputInvoice.getCode();
} else {
return CellDataSourceType.Formula.getCode();
......@@ -716,9 +720,10 @@ public class ReportServiceImpl {
private Integer convetToFType(Integer cellDataSourceType) {
if (cellDataSourceType.equals(CellDataSourceType.InputInvoice.getCode())) {
return FormulaDataSourceType.InputInvoice.getCode();
} if(cellDataSourceType.equals(CellDataSourceType.OutputInvoice.getCode())){
}
if (cellDataSourceType.equals(CellDataSourceType.OutputInvoice.getCode())) {
return FormulaDataSourceType.OutputInvoice.getCode();
}else {
} else {
return FormulaDataSourceType.Other.getCode();
}
}
......@@ -836,6 +841,9 @@ public class ReportServiceImpl {
public OperationResultDto addCellManualDataSource(ManualDataSourceDto data, String projectId) {
OperationResultDto operationResultDto = new OperationResultDto();
String status = periodApprovalMapper.getStatusByProjectIdAndPeriod(projectId, data.getPeriod());
MyAsserts.assertTrue(status == null || status.equals(Constant.APPROVAL_DISAGREED), Exceptions.REPORT_IN_PROCESS_OR_AGREED_EXCEPTION);
try {
if (data.getCellId() == null) {
......@@ -858,7 +866,8 @@ public class ReportServiceImpl {
PeriodCellData cellData = periodCellDataMapper.selectByPrimaryKey(data.getCellId());
if (cellData.getData() != data.getAmount().toString()) {
cellData.setData(data.getAmount().toString());
if(StringUtils.isEmpty(cellData.getFormulaExp()))cellData.setFormulaExp(data.getAmount().toString());
if (StringUtils.isEmpty(cellData.getFormulaExp()))
cellData.setFormulaExp(data.getAmount().toString());
periodCellDataMapper.updateByPrimaryKeySelective(cellData);
}
}
......
......@@ -133,4 +133,18 @@ public interface PeriodApproveMapper extends MyVatMapper {
"</where>" +
"</script>")
List<ApprovalTaskInfo> queryApprovalList(@Param("createId") String createId);
@Select("" +
"SELECT " +
" STATUS AS status " +
"FROM " +
" PERIOD_APPROVE " +
"WHERE " +
" PROJECT_ID = #{projectId} " +
" AND PERIOD = #{period} " +
" AND ROWNUM = 1 " +
"ORDER BY " +
" CREATE_TIME DESC" +
"")
String getStatusByProjectIdAndPeriod(@Param("projectId") String projectId, @Param("period") Integer period);
}
\ No newline at end of file
......@@ -2539,26 +2539,40 @@
};
$scope.commitApprove = function(){
SweetAlert.swal({
title: "warning!",
text: $translate.instant('报表提审后不能手工录入和重新生成!'),
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('Yes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
var approveParam={};
approveParam.projectId = vatSessionService.project.id;
approveParam.periodDate = vatSessionService.project.periodDate;
vatApproveService.commitNewApproval(approveParam);
vatApproveService.approvalStatus(vatSessionService.project.id,vatSessionService.project.month).success(function(result){
if(result&&result=='committed'){
SweetAlert.swal({
title: "warning!",
text: $translate.instant('报表提审中'),
type: "warning",
showCancelButton: true,
cancelButtonText: $translate.instant('No'),
closeOnCancel: true
});
}else{
SweetAlert.swal({
title: "warning!",
text: $translate.instant('报表提审后不能手工录入和重新生成!'),
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('Yes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
var approveParam={};
approveParam.projectId = vatSessionService.project.id;
approveParam.periodDate = vatSessionService.project.periodDate;
vatApproveService.commitNewApproval(approveParam);
}
});
}
});
});
}
$scope.doApprove = function(){
......
......@@ -23,6 +23,10 @@
checkTask:function(taskId,decide,comment){
return $http.put('/approval/check/'+taskId+'?decide='+decide+'&comment='+comment, {}, apiConfig.createVat());
},
approvalStatus:function(projectId,period){
return $http.get('/approval/'+projectId+'/'+period,apiConfig.createVat({ignoreLoadingBar: true}))
}
};
}]);
\ No newline at end of file
......@@ -350,7 +350,6 @@
}
};
var startCaculate2 = function () {
if (vatSessionService.project.projectStatusList[vatSessionService.month] >= constant.ProjectStatusEnum.Generated) {
swal({
......
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