Commit 000f3fd4 authored by neo's avatar neo

[DEV] add some conditon for approval protect

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