diff --git a/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java b/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java index 87ff50d..5bf3913 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java @@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -72,6 +73,13 @@ public class InvestmentReportController { return investmentReportService.commitExperience(trainingReport); } + @AnonymousAccess + @PostMapping("saveExperience") + @ApiOperation("保存心得") + public ResultEntity saveExperience(@ApiParam("用户填写的心得") @RequestParam String text, @RequestParam String flowId, @RequestParam String schoolId) { + return investmentReportService.saveExperience(text,flowId,schoolId); + } + @AnonymousAccess @GetMapping("getExperience") @ApiOperation("心得回显") @@ -81,10 +89,12 @@ public class InvestmentReportController { return null; } TrainingReport trainingReport = trainingReports.get(0); - if (StringUtils.isBlank(trainingReport.getExperience())) { - return null; + if (!StringUtils.isBlank(trainingReport.getExperience())) { + return new ResultEntity<>(trainingReport.getExperience()); + } if (!StringUtils.isBlank(trainingReport.getVersion())) { + return new ResultEntity<>(trainingReport.getVersion()); } - return new ResultEntity<>(trainingReport.getExperience()); + return null; } @AnonymousAccess diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java index d982ab2..7ef81b6 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java @@ -67,7 +67,7 @@ public class ProfitManagementController { @ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案") @AnonymousAccess @GetMapping("/getExitTimeRightMarketValueAndFundEarnings") - public ResultEntity getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId, + public ResultEntity getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId, @ApiParam("退出时间") @RequestParam String exitTime, @ApiParam("随机生成的价格") @RequestParam BigDecimal price, @ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue, diff --git a/src/main/java/com/sztzjy/fund_investment/service/InvestmentReportService.java b/src/main/java/com/sztzjy/fund_investment/service/InvestmentReportService.java index 24eb249..0447c5e 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/InvestmentReportService.java +++ b/src/main/java/com/sztzjy/fund_investment/service/InvestmentReportService.java @@ -2,6 +2,7 @@ package com.sztzjy.fund_investment.service; import com.sztzjy.fund_investment.entity.TrainingReport; import com.sztzjy.fund_investment.util.ResultEntity; +import org.springframework.http.HttpStatus; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -16,4 +17,6 @@ public interface InvestmentReportService { List getTrainingReports(String flowId); ResultEntity commitExperience(TrainingReport trainingReport); + + ResultEntity saveExperience(String text, String flowId, String schoolId); } diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java index 273472e..160961b 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java @@ -106,7 +106,7 @@ public class InvestmentReportServiceImpl implements InvestmentReportService { if (StringUtils.isBlank(trainingReport.getExperience())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请先填写心得再提交!"); } - if (StringUtils.isBlank(trainingReport.getId()) || StringUtils.isBlank(trainingReport.getFlowId()) || StringUtils.isBlank(trainingReport.getSchoolId())) { + if (StringUtils.isBlank(trainingReport.getFlowId()) || StringUtils.isBlank(trainingReport.getSchoolId())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败!缺少所需的ID!"); } TrainingReportExample trainingReportExample = new TrainingReportExample(); @@ -122,10 +122,44 @@ public class InvestmentReportServiceImpl implements InvestmentReportService { trainingReportMapper.updateByPrimaryKeyWithBLOBs(dataTrainingReport); } } else { //为空新增 + trainingReport.setId(IdUtil.simpleUUID()); trainingReport.setUploadtime(new Date()); trainingReport.setStep(Constant.TZBG); trainingReportMapper.insert(trainingReport); } return new ResultEntity<>(HttpStatus.OK, "提交成功!"); } + + + + /* 保存实训心得 + * @author xcj + * @Date 2024/1/31 + */ + @Override + public ResultEntity saveExperience(String text,String flowId,String schoolId) { + TrainingReportExample trainingReportExample = new TrainingReportExample(); + trainingReportExample.createCriteria().andFlowIdEqualTo(flowId).andStepEqualTo(Constant.TZBG); + List trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); + //为空代表没有提交或保存过,新增一条 + if (trainingReports.isEmpty()){ + TrainingReport trainingReport = new TrainingReport(); + trainingReport.setFlowId(flowId); + trainingReport.setId(IdUtil.simpleUUID()); + trainingReport.setSchoolId(schoolId); + trainingReport.setUploadtime(new Date()); + trainingReport.setStep(Constant.TZBG); + trainingReport.setVersion(text); //新增保存功能,使用版本字段,没有再添加字段 + trainingReportMapper.insert(trainingReport); + return new ResultEntity<>(HttpStatus.OK,"保存成功!"); + }else { + TrainingReport trainingReport = trainingReports.get(0); + if (trainingReport.getExperience()!=null){ + return new ResultEntity<>(HttpStatus.BAD_REQUEST,"提交过不允许再保存!"); + } + trainingReport.setVersion(text); + trainingReportMapper.updateByPrimaryKeyWithBLOBs(trainingReport); + return new ResultEntity<>(HttpStatus.OK,"保存成功!"); + } + } } diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java index 29fdfcd..9dab20d 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java @@ -149,10 +149,10 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService if (profitDistribution.getUserAvailableFunds() == null) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入可用资金!"); } - ProfitDistributionExample example =new ProfitDistributionExample(); + ProfitDistributionExample example = new ProfitDistributionExample(); example.createCriteria().andFlowIdEqualTo(profitDistribution.getFlowId()); List profitDistributions = profitDistributionMapper.selectByExample(example); - if (!profitDistributions.isEmpty()){ + if (!profitDistributions.isEmpty()) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请勿重复提交!"); } //校验优先级LP和自有资金 @@ -295,16 +295,24 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService residualIncome = residualIncome.subtract(subordinatedLp); //剩余收益 // 2.剩余收益分配比例为,自有资金25%,优先级LP 30%,劣后级LP 45% BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 - BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.35)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 + BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.3)).setScale(2, RoundingMode.HALF_UP);//剩余优先级 BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); profitDistributionMapper.insert(profitDistribution); - if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && - twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 && - userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { - performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); + if (rightOwnFunds != null && userRoundOwnFunds != null && + userRoundPreferredLp != null && + userRoundSubordinatedLp != null && subordinatedLp != null && + userRemainingEarningsSubordinatedLp != null) { + if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && + rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && + twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && + twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 && + userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && + userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { + performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); + } } PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId); performanceScore.setProfitDistributionTime(new Date()); @@ -469,7 +477,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan); //剩余收益 //2.剩余收益分配比例为,自有资金25%,优先级LP 30%,劣后级LP 45% BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 - BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.35)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 + BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.3)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); @@ -498,7 +506,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService ProfitDistributionExample profitDistributionExample = new ProfitDistributionExample(); profitDistributionExample.createCriteria().andFlowIdEqualTo(flowId); List profitDistributions = profitDistributionMapper.selectByExample(profitDistributionExample); - if (profitDistributions.isEmpty()){ + if (profitDistributions.isEmpty()) { return null; } return profitDistributions.get(0); diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java index 1cec2b9..b180981 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java @@ -104,7 +104,7 @@ public class ProfitManagementServiceImpl implements ProfitManagementService { @Override public ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, BigDecimal userMarketValue, BigDecimal userFundEarnings) { - ExitTime exitTimeEntity =new ExitTime(); + ExitTime exitTimeEntity = new ExitTime(); List profitManagementList = getLineChart(flowId); if (profitManagementList.isEmpty()) { return null; @@ -134,14 +134,10 @@ public class ProfitManagementServiceImpl implements ProfitManagementService { PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId); performanceScore.setProfitManagementTime(new Date()); performanceScoreMapper.updateByPrimaryKey(performanceScore); - if (!(userMarketValue.compareTo(marketValue) == 0)) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue); - } else { + if (userMarketValue.compareTo(marketValue) == 0) { performanceScoreService.calculateScoreByModule("profitManagementFundExitScore", 3, flowId); } - if (!(userFundEarnings.compareTo(fundEarnings) == 0)) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings); - } else { + if (userFundEarnings.compareTo(fundEarnings) == 0) { performanceScoreService.calculateScoreByModule("profitManagementMarketValueExitScore", 3, flowId); } return null;