| | |
| | | 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.*; |
| | |
| | | @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)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * 修改费用申请主 |
| | | * 修改费用申请 |
| | | */ |
| | | @ApiOperation("修改费用申请主") |
| | | //@PreAuthorize("@ss.hasPermi('project:fund:edit')") |
| | | @ApiOperation("修改费用申请") |
| | | @Log(title = "费用申请主", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | @PostMapping("/fundEdit") |
| | | @RepeatSubmit |
| | | public AjaxResult edit(@RequestBody ServiceFund serviceFund) { |
| | | 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) { |
| | |
| | | } else { |
| | | serviceFund.setFlowlevel(sf.getBackflowlevel()); |
| | | boolean bret = serviceFundService.updateById(serviceFund); |
| | | log.info("serviceFundService.updateById返参:{}", bret); |
| | | // if (bret) { |
| | | // addReiSharedDatd(serviceFund, 2); |
| | | // } |