From 8b8c655968159a016f9b3b9ca42c5fec2abc2f4b Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期一, 07 八月 2023 17:17:34 +0800 Subject: [PATCH] 修改方法名 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java | 72 +++++++++++------------------------- 1 files changed, 22 insertions(+), 50 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java index 9c08f28..fc830e8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceFundController.java @@ -12,6 +12,7 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.tax.TaxtUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.DtoConversionUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.project.domain.*; @@ -23,8 +24,10 @@ import freemarker.template.TemplateException; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Options; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.io.*; @@ -41,6 +44,7 @@ * @author ruoyi * @date 2022-01-24 */ +@Slf4j @Api("璐圭敤鐢宠涓�") @RestController @RequestMapping("/project/fund") @@ -427,51 +431,14 @@ */ @ApiOperation("鏂板璐圭敤姹囨��") @Log(title = "鏂板璐圭敤姹囨��", businessType = BusinessType.INSERT) - @PostMapping("/addnew") + @PostMapping("/addOrUpdateNew") @RepeatSubmit @Options(useGeneratedKeys = true, keyProperty = "id") - public AjaxResult addnew(@RequestBody ServiceFundVO serviceFundVO) { - boolean b = serviceFundService.save(serviceFundVO); - Long id = serviceFundVO.getId(); -// if (b) { -// addReiSharedDatd(serviceFundVO, 1); -// } - List<ServiceFunddetail> serviceFunddetails = serviceFundVO.getServiceFunddetails(); -// serviceFunddetails.forEach(item -> item.setFundid(id)); + public AjaxResult addOrUpdateNew(@RequestBody ServiceFundVO serviceFundVO) { - //taxBefore銆乼axAfter鐢ㄦ潵璁板綍绋庡墠绋庡悗鐨勬�婚噾棰濓紝涓嶇敤绠$◣鐜� - double taxBefore = 0.0; - double taxAfter = 0.0; - for (ServiceFunddetail serviceFunddetail : serviceFunddetails) { - serviceFunddetail.setFundid(id); - if (serviceFunddetail.getTaxedamount() != 0.0 && serviceFunddetail.getAmount() != 0.0 && serviceFunddetail.getTaxedamount() != null && serviceFunddetail.getTaxedamount() != null) { - // 绋庡墠绋庡悗閮戒笉涓虹┖ - continue; - } else if (serviceFunddetail.getTaxedamount() != 0.0 && serviceFunddetail.getTaxedamount() != null) { - // 绋庡悗姹傜◣鍓� - 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() != 0.0 && serviceFunddetail.getAmount() != null) { - // 绋庡墠姹傜◣鍚� - 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()); - } - taxBefore = taxBefore + serviceFunddetail.getAmount(); - taxAfter = taxAfter + serviceFunddetail.getTaxedamount(); - } - //灏嗙◣鍓嶃�佺◣鍚庨噾棰濇洿鏂板埌fund琛ㄤ腑 - serviceFundVO.setPretaxcost(taxBefore); - serviceFundVO.setTaxedcost(taxAfter); - serviceFundService.updateById(serviceFundVO); - //灏嗚绠楀ソ鐨勬暟鎹紝淇濆瓨鍒癲etail琛ㄤ腑 - serviceFunddetailService.saveBatch(serviceFunddetails); - return AjaxResult.success(id); + return AjaxResult.success(serviceFundService.addOrUpdateNew(serviceFundVO)); } + /** * 瀹℃牳璐圭敤 @@ -616,15 +583,19 @@ /** - * 淇敼璐圭敤鐢宠涓� + * 淇敼璐圭敤鐢宠 */ - @ApiOperation("淇敼璐圭敤鐢宠涓�") - //@PreAuthorize("@ss.hasPermi('project:fund:edit')") + @ApiOperation("淇敼璐圭敤鐢宠") @Log(title = "璐圭敤鐢宠涓�", businessType = BusinessType.UPDATE) - @PutMapping + @PostMapping("/fundEdit") @RepeatSubmit - public AjaxResult edit(@RequestBody ServiceFund serviceFund) { - List<ServiceFund> infoByInfoIdList = serviceFundService.getInfoByInfoId(serviceFund.getInfoid()); + public AjaxResult fundEdit(@RequestBody ServiceFund serviceFund) { + log.info("淇敼璐圭敤鐢宠鍏ュ弬:{}", serviceFund); + List<ServiceFund> infoByInfoIdList = serviceFundService.queryInfoById(serviceFund); + log.info("淇敼璐圭敤鐢宠锛岄�氳繃鍏ュ弬鏌ヨ serviceFundService.queryInfoById鏁版嵁涓虹┖,鍏ュ弬:{}", infoByInfoIdList.size()); + if (CollectionUtils.isEmpty(infoByInfoIdList)) { + return toAjax(false); + } for (ServiceFund sf : infoByInfoIdList) { //濡傛灉绛変簬100锛岃鏄庡凡缁忚蛋鍒板尰闄㈣储鍔¢偅杈逛簡锛涜储鍔¢偅杈瑰彇鏁版嵁鏄粠鍒嗕韩琛ㄥ彇锛屾墍浠ワ紝杩欓噷鐩存帴寰�鍒嗕韩琛ㄩ噷娣诲姞鏁版嵁灏辫浜� if (sf.getBackflowlevel() == 100 || sf.getBackflowlevel() == 199) { @@ -640,6 +611,7 @@ } else { serviceFund.setFlowlevel(sf.getBackflowlevel()); boolean bret = serviceFundService.updateById(serviceFund); + log.info("serviceFundService.updateById杩斿弬:{}", bret); // if (bret) { // addReiSharedDatd(serviceFund, 2); // } @@ -719,11 +691,11 @@ dataMap.put("JXZXM", serviceFund.getDonorname() == null ? "" : serviceFund.getDonorname()); dataMap.put("JSR", serviceFund.getUsername() == null ? "" : serviceFund.getUsername()); // dataMap.put("FYXM1", "鏀粯涓撳璐圭敤锛屽叾涓◣鍓嶉噾棰�" + serviceFund.getPretaxcost() + "鍏冿紝绋庡悗閲戦" + serviceFund.getTaxedcost() + "鍏冦��"); - dataMap.put("FYXM1", "浜轰綋鍣ㄥ畼鎹愮尞涓撳鍔冲姟璐�:" + serviceFund.getTaxedcost() + "鍏� (鍏朵腑绋庡悗璐圭敤鐢变腑蹇冩壙鎷呯◣璐�)銆�"); + dataMap.put("FYXM1", "浜轰綋鍣ㄥ畼鎹愮尞涓撳鍔冲姟璐�:" + serviceFund.getPretaxcost() + "鍏� (鍏朵腑绋庡悗璐圭敤鐢变腑蹇冩壙鎷呯◣璐�)銆�"); dataMap.put("FYXM2", ""); dataMap.put("FYXM3", ""); - dataMap.put("JEXS", serviceFund.getAmountrequested()); - dataMap.put("JEDS", convert(serviceFund.getAmountrequested()) + "鏁�"); + dataMap.put("JEXS", serviceFund.getPretaxcost()); + dataMap.put("JEDS", convert(serviceFund.getPretaxcost()) + "鏁�"); dataMap.put("BXBZ", serviceFund.getRemark() == null ? "" : serviceFund.getRemark()); -- Gitblit v1.9.3