|
@@ -4,6 +4,8 @@ import cn.ezhizao.common.exception.ServiceException;
|
|
|
import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
|
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
+import cn.ezhizao.framework.lock.DistributionLock;
|
|
|
+import cn.ezhizao.framework.lock.LockKey;
|
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
@@ -149,44 +151,66 @@ public class BizFinancialReportTaxNonZeroController extends BaseController {
|
|
|
@ResponseBody
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public AjaxResult saveDetail(@RequestBody BizFinancialReportTaxDetail detail) {
|
|
|
- detail.setVerifierTime(new Date());
|
|
|
- detail.setVerifierId(getUserId());
|
|
|
- boolean bool = financialReportTaxDetaiIsZerolService.saveOrUpdate(detail);
|
|
|
- Map<String, Object> conditions = new HashMap<>(1);
|
|
|
- conditions.put("financialReportTaxDetailId", detail.getId());
|
|
|
- detail.setVerifierId(getUserId());
|
|
|
- financialReportTaxDetailReportIsZeroService.physicallyDelete(conditions);
|
|
|
- detail.getReportFiles().forEach(l -> {
|
|
|
- l.setFinancialReportTaxId(detail.getFinancialReportTaxId());
|
|
|
- l.setFinancialReportTaxDetailId(detail.getId());
|
|
|
- });
|
|
|
- bool = bool && (detail.getReportFiles().isEmpty() || financialReportTaxDetailReportIsZeroService.saveBatch(detail.getReportFiles()));
|
|
|
+ String join = LockKey.join(LockKey.REPORTTAXNONZERODETAIL,detail.getFinancialReportTaxId(),detail.getYear(),detail.getMonth(),detail.getCompanyId());
|
|
|
+ DistributionLock lock = new DistributionLock(join);
|
|
|
+ try {
|
|
|
+ lock.lock();
|
|
|
+ if(null == detail.getId()){
|
|
|
+ Long count = financialReportTaxDetaiIsZerolService
|
|
|
+ .lambdaQuery()
|
|
|
+ .eq(BizFinancialReportTaxDetail::getDeleted,0)
|
|
|
+ .eq(BizFinancialReportTaxDetail::getYear,detail.getYear())
|
|
|
+ .eq(BizFinancialReportTaxDetail::getMonth,detail.getMonth())
|
|
|
+ .eq(BizFinancialReportTaxDetail::getFinancialReportTaxId,detail.getFinancialReportTaxId())
|
|
|
+ .count();
|
|
|
+ if(null != count && count > 0) {
|
|
|
+ return error("已经保存过数据,不可重复提交");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detail.setVerifierTime(new Date());
|
|
|
+ detail.setVerifierId(getUserId());
|
|
|
+ boolean bool = financialReportTaxDetaiIsZerolService.saveOrUpdate(detail);
|
|
|
+ Map<String, Object> conditions = new HashMap<>(1);
|
|
|
+ conditions.put("financialReportTaxDetailId", detail.getId());
|
|
|
+ detail.setVerifierId(getUserId());
|
|
|
+ financialReportTaxDetailReportIsZeroService.physicallyDelete(conditions);
|
|
|
+ detail.getReportFiles().forEach(l -> {
|
|
|
+ l.setFinancialReportTaxId(detail.getFinancialReportTaxId());
|
|
|
+ l.setFinancialReportTaxDetailId(detail.getId());
|
|
|
+ });
|
|
|
+ bool = bool && (detail.getReportFiles().isEmpty() || financialReportTaxDetailReportIsZeroService.saveBatch(detail.getReportFiles()));
|
|
|
|
|
|
- Map<String, Object> delCondition = new HashMap<>();
|
|
|
- delCondition.put("financialReportTaxDetailId", detail.getId());
|
|
|
- financialMergeService.physicallyDelete(delCondition);
|
|
|
+ Map<String, Object> delCondition = new HashMap<>();
|
|
|
+ delCondition.put("financialReportTaxDetailId", detail.getId());
|
|
|
+ financialMergeService.physicallyDelete(delCondition);
|
|
|
|
|
|
- bool = bool && checkDeduction(detail);
|
|
|
+ bool = bool && checkDeduction(detail);
|
|
|
|
|
|
- SysFileStorage delConditions = new SysFileStorage();
|
|
|
- delConditions.setMasterId(detail.getId());
|
|
|
- delConditions.setMasterTableName("biz_financial_report_tax_detail");
|
|
|
- fileStorageService.physicalDelete(delConditions);
|
|
|
- List<SysFileStorage> fileStorages = detail.getFiles();
|
|
|
+ SysFileStorage delConditions = new SysFileStorage();
|
|
|
+ delConditions.setMasterId(detail.getId());
|
|
|
+ delConditions.setMasterTableName("biz_financial_report_tax_detail");
|
|
|
+ fileStorageService.physicalDelete(delConditions);
|
|
|
+ List<SysFileStorage> fileStorages = detail.getFiles();
|
|
|
|
|
|
- fileStorages.forEach(l -> {
|
|
|
- l.setMasterId(detail.getId());
|
|
|
- l.setMasterTableName("biz_financial_report_tax_detail");
|
|
|
- });
|
|
|
- BizHistory bizHistory = new BizHistory();
|
|
|
- bizHistory.setTableName("biz_financial_report_tax");
|
|
|
- bizHistory.setCompanyId(detail.getCompanyId());
|
|
|
- bizHistory.setBelongPeriod(detail.getYear() + "-" + String.format("%02d", Integer.valueOf(detail.getMonth())) );
|
|
|
- bizHistory.setEvent("保存");
|
|
|
- bizHistory.setTenantId(getTenantId());
|
|
|
- bizHistoryService.save(bizHistory);
|
|
|
- bool = bool && (fileStorages.isEmpty() || fileStorageService.saveOrUpdateBatch(fileStorages));
|
|
|
- return bool ? success(detail) : error();
|
|
|
+ fileStorages.forEach(l -> {
|
|
|
+ l.setMasterId(detail.getId());
|
|
|
+ l.setMasterTableName("biz_financial_report_tax_detail");
|
|
|
+ });
|
|
|
+ BizHistory bizHistory = new BizHistory();
|
|
|
+ bizHistory.setTableName("biz_financial_report_tax");
|
|
|
+ bizHistory.setCompanyId(detail.getCompanyId());
|
|
|
+ bizHistory.setBelongPeriod(detail.getYear() + "-" + String.format("%02d", Integer.valueOf(detail.getMonth())) );
|
|
|
+ bizHistory.setEvent("保存");
|
|
|
+ bizHistory.setTenantId(getTenantId());
|
|
|
+ bizHistoryService.save(bizHistory);
|
|
|
+ bool = bool && (fileStorages.isEmpty() || fileStorageService.saveOrUpdateBatch(fileStorages));
|
|
|
+ return bool ? success(detail) : error();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return error("保存失败");
|
|
|
+ } finally {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|