ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java
@@ -434,67 +434,8 @@ @RepeatSubmit @Options(useGeneratedKeys = true, keyProperty = "id") public AjaxResult addOrUpdateNew(@RequestBody ServiceFundVO serviceFundVO) { Long id = null; if (serviceFundVO.getId() == null) { boolean b = serviceFundService.save(serviceFundVO); id = serviceFundVO.getId(); } else { serviceFundService.updateById(serviceFundVO); id = serviceFundVO.getId(); } List<ServiceFunddetail> serviceFunddetails = serviceFundVO.getServiceFunddetails(); double taxBefore = 0.0; double taxAfter = 0.0; for (ServiceFunddetail serviceFunddetail : serviceFunddetails) { serviceFunddetail.setFundid(id); log.info("serviceFunddetail的值为 : {}", serviceFunddetail); if (serviceFunddetail.getTaxedamount() != null && serviceFunddetail.getAmount() != null && serviceFunddetail.getTaxedamount() != 0.0 && serviceFunddetail.getAmount() != 0.0) { // 税前税后都不为空 if (serviceFunddetail.getId() == null) { serviceFunddetailService.save(serviceFunddetail); } else { serviceFunddetailService.updateById(serviceFunddetail); } continue; } else if (serviceFunddetail.getTaxedamount() != null && serviceFunddetail.getTaxedamount() != 0.0) { // 税后求税前,如果是专家费申请 或 伦理专家费申请 才会计算税前税后 if (StringUtils.isNotEmpty(serviceFundVO.getApplytype()) && serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { Double taxationBefore = Double.valueOf(TaxtUtils.getTaxationBefore(BigDecimal.valueOf(serviceFunddetail.getTaxedamount()))); // 税金 String taxation = TaxtUtils.getTaxation(BigDecimal.valueOf(taxationBefore)); serviceFunddetail.setAmount(Double.valueOf(taxationBefore)); serviceFunddetail.setTaxamount(Double.parseDouble(taxation)); } } else if (serviceFunddetail.getAmount() != null && serviceFunddetail.getAmount() != 0.0) { // 税前求税后,如果是专家费申请 或 伦理专家费申请 才会计算税前税后 if (StringUtils.isNotEmpty(serviceFundVO.getApplytype()) && serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { double tax = Double.parseDouble(TaxtUtils.getTaxation(BigDecimal.valueOf(serviceFunddetail.getAmount()))); BigDecimal taxAfterMoney = BigDecimal.valueOf(serviceFunddetail.getAmount()).subtract(BigDecimal.valueOf(tax)); serviceFunddetail.setTaxamount(tax); serviceFunddetail.setTaxedamount(taxAfterMoney.doubleValue()); } } //根据id判断是新增还是修改 if (serviceFunddetail.getId() == null) { serviceFunddetailService.save(serviceFunddetail); } else { serviceFunddetailService.updateById(serviceFunddetail); } if (serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { //如果是专家费申请 或 伦理专家费申请 才会计算税前税后 taxBefore = taxBefore + serviceFunddetail.getAmount(); taxAfter = taxAfter + serviceFunddetail.getTaxedamount(); } } //将税前、税后金额更新到fund表中 serviceFundVO.setPretaxcost(taxBefore); serviceFundVO.setTaxedcost(taxAfter); serviceFundService.updateById(serviceFundVO); // //将计算好的数据,保存到detail表中 // serviceFunddetailService.saveBatch(serviceFunddetails); return AjaxResult.success(id); return AjaxResult.success(serviceFundService.addOrUpdateNew(serviceFundVO)); } ruoyi-project/src/main/java/com/ruoyi/project/service/IServiceFundService.java
@@ -1,6 +1,7 @@ package com.ruoyi.project.service; import java.util.List; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.project.domain.ServiceFund; import com.ruoyi.project.domain.ServiceFunddetail; @@ -9,16 +10,15 @@ /** * 费用申请主Service接口 * * * @author ruoyi * @date 2022-01-24 */ public interface IServiceFundService extends IService<ServiceFund> { public interface IServiceFundService extends IService<ServiceFund> { /** * 查询费用申请主列表 * * * @param serviceFund 费用申请主 * @return 费用申请主集合 */ @@ -29,11 +29,11 @@ List<ServiceFund> getInfoByInfoId(Long infoid); Long getFundId(Long infoid); /** * 往分享表中添加数据 * * @param id * @return */ @@ -52,7 +52,9 @@ String returnId(Long id); List<SpFinancialExpensesFundOut> getListBypower(String PAUSERNO, Integer PAFUNDTYPE, String PAAPPLICANT, String PAAPPLICATIONBEGTIME, String PAAPPLICATIONENDTIME, String PADEPARTMENT,Integer CHECKFLAG,Integer APPLYTYPE); List<SpFinancialExpensesFundOut> getListBypower(String PAUSERNO, Integer PAFUNDTYPE, String PAAPPLICANT, String PAAPPLICATIONBEGTIME, String PAAPPLICATIONENDTIME, String PADEPARTMENT, Integer CHECKFLAG, Integer APPLYTYPE); int countItem(Long infoid, Long itemid); Long addOrUpdateNew(ServiceFundVO serviceFundVO); } ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java
@@ -1,6 +1,7 @@ package com.ruoyi.project.service.impl; import java.io.File; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -9,13 +10,16 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.tax.TaxtUtils; import com.ruoyi.common.utils.HttpClientKit; import com.ruoyi.common.utils.bean.DtoConversionUtils; import com.ruoyi.project.domain.*; import com.ruoyi.project.domain.vo.*; import com.ruoyi.project.mapper.*; import com.ruoyi.project.service.IServiceFundSharedService; import com.ruoyi.project.service.IServiceFunddetailService; import com.ruoyi.project.service.IServiceFunddetailSharedService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -31,6 +35,7 @@ * @author ruoyi * @date 2022-01-24 */ @Slf4j @Service public class ServiceFundServiceImpl extends ServiceImpl<ServiceFundMapper, ServiceFund> implements IServiceFundService { @Autowired @@ -56,6 +61,9 @@ @Autowired IServiceFunddetailSharedService detailSharedService; @Autowired private IServiceFunddetailService serviceFunddetailService; /** @@ -659,6 +667,72 @@ return count; } @Override @Transactional public Long addOrUpdateNew(ServiceFundVO serviceFundVO) { Long id = null; if (serviceFundVO.getId() == null) { save(serviceFundVO); id = serviceFundVO.getId(); } else { updateById(serviceFundVO); id = serviceFundVO.getId(); } List<ServiceFunddetail> serviceFunddetails = serviceFundVO.getServiceFunddetails(); // 用于记录税前、税后的总和 double taxBefore = 0.0; double taxAfter = 0.0; for (ServiceFunddetail serviceFunddetail : serviceFunddetails) { serviceFunddetail.setFundid(id); if (serviceFunddetail.getTaxedamount() != null && serviceFunddetail.getAmount() != null && serviceFunddetail.getTaxedamount() != 0.0 && serviceFunddetail.getAmount() != 0.0) { // 税前税后都不为空 if (serviceFunddetail.getId() == null) { serviceFunddetailService.save(serviceFunddetail); } else { serviceFunddetailService.updateById(serviceFunddetail); } continue; } else if (serviceFunddetail.getTaxedamount() != null && serviceFunddetail.getTaxedamount() != 0.0) { // 税后求税前,如果是专家费申请 或 伦理专家费申请 才会计算税前税后 if (StringUtils.isNotEmpty(serviceFundVO.getApplytype()) && serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { Double taxationBefore = Double.valueOf(TaxtUtils.getTaxationBefore(BigDecimal.valueOf(serviceFunddetail.getTaxedamount()))); // 税金 String taxation = TaxtUtils.getTaxation(BigDecimal.valueOf(taxationBefore)); serviceFunddetail.setAmount(Double.valueOf(taxationBefore)); serviceFunddetail.setTaxamount(Double.parseDouble(taxation)); } } else if (serviceFunddetail.getAmount() != null && serviceFunddetail.getAmount() != 0.0) { // 税前求税后,如果是专家费申请 或 伦理专家费申请 才会计算税前税后 if (StringUtils.isNotEmpty(serviceFundVO.getApplytype()) && serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { double tax = Double.parseDouble(TaxtUtils.getTaxation(BigDecimal.valueOf(serviceFunddetail.getAmount()))); BigDecimal taxAfterMoney = BigDecimal.valueOf(serviceFunddetail.getAmount()).subtract(BigDecimal.valueOf(tax)); serviceFunddetail.setTaxamount(tax); serviceFunddetail.setTaxedamount(taxAfterMoney.doubleValue()); } } //根据id判断是新增还是修改 if (serviceFunddetail.getId() == null) { serviceFunddetailService.save(serviceFunddetail); } else { serviceFunddetailService.updateById(serviceFunddetail); } if (serviceFundVO.getApplytype().equals("1") || serviceFundVO.getApplytype().equals("2")) { //如果是专家费申请 或 伦理专家费申请 才会计算税前税后 taxBefore = taxBefore + serviceFunddetail.getAmount(); taxAfter = taxAfter + serviceFunddetail.getTaxedamount(); } } //将税前、税后金额更新到fund表中 serviceFundVO.setPretaxcost(taxBefore); serviceFundVO.setTaxedcost(taxAfter); updateById(serviceFundVO); return id; } int uploadOAFileAndUpdateDb(ServiceFundShared remShare) { //上传OA文件 //String strUrl = "http://129.88.242.39:8899/seeyon/rest/token?userName=opo&password=127814f8-84e8-4304-84a5-a71573567efd&loginName=demo3";