From 041ad7a15ac011294568d8958f8100254aaf8f5d Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Fri, 15 Dec 2023 14:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=80=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E8=A1=A8=EF=BC=8C=E5=AE=8C=E6=88=90=E6=8A=95=E8=B5=84?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProfitDistributionController.java | 5 ++- .../controller/TopicController.java | 32 ++++++++++++------- .../service/ProfitDistributionService.java | 2 +- .../fund_investment/service/TopicService.java | 6 ++-- .../ProfitDistributionServiceImpl.java | 11 ++++++- .../service/serviceImpl/TopicServiceImpl.java | 32 +++++++++++++------ 6 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java index 47bfc6b..beed75f 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java @@ -1,7 +1,6 @@ package com.sztzjy.fund_investment.controller; import com.sztzjy.fund_investment.annotation.AnonymousAccess; -import com.sztzjy.fund_investment.entity.Fundraising; import com.sztzjy.fund_investment.entity.ProfitDistribution; import com.sztzjy.fund_investment.service.ISysFundraisingService; import com.sztzjy.fund_investment.service.ProfitDistributionService; @@ -23,12 +22,12 @@ public class ProfitDistributionController { @Autowired private ProfitDistributionService profitDistributionService; @Autowired - ISysFundraisingService fundraisingService; + private ISysFundraisingService fundraisingService; @AnonymousAccess @PostMapping("/submit") @ApiOperation("页面提交") - public ResultEntity submit(@ApiParam("传id(UUID),flowID,用户输入8个框的内容(可用资金,自有资金和优先级LP必传)") ProfitDistribution profitDistribution) { + public ResultEntity submit(@ApiParam("传id(UUID),flowID,用户输入7个框的内容(可用资金,自有资金和优先级LP必传)") @RequestBody ProfitDistribution profitDistribution) { return profitDistributionService.submit(profitDistribution); } diff --git a/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java index ac48fd5..17503df 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/TopicController.java @@ -8,12 +8,14 @@ import com.sztzjy.fund_investment.mapper.FlowMapper; import com.sztzjy.fund_investment.mapper.PerformanceScoreMapper; import com.sztzjy.fund_investment.mapper.TopicsMapper; import com.sztzjy.fund_investment.mapper.UserMapper; +import com.sztzjy.fund_investment.service.PerformanceScoreService; import com.sztzjy.fund_investment.service.TopicService; import com.sztzjy.fund_investment.util.ResultEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -37,6 +39,8 @@ public class TopicController { @Autowired private PerformanceScoreMapper performanceScoreMapper; @Autowired + private PerformanceScoreService performanceScoreService; + @Autowired private UserMapper userMapper; @Autowired private FlowMapper flowMapper; @@ -62,8 +66,9 @@ public class TopicController { @GetMapping("getRandomTopic") @ApiOperation("知识测评,项目估值,项目尽调,答题页面返回随机6条数据") @AnonymousAccess - public ResultEntity> getRandomTopic(@ApiParam("题目来源模块:知识测评题库,项目尽调题库,项目估值题库") @RequestParam String module) { - return new ResultEntity>(topicService.getRandomTopic(module)); + public ResultEntity> getRandomTopic(@ApiParam("题目来源模块:知识测评题库,项目尽调题库,项目估值题库") @RequestParam String module, + @RequestParam String flowId) { + return new ResultEntity>(topicService.getRandomTopic(module, flowId)); } @@ -71,11 +76,11 @@ public class TopicController { * @author xcj * @Date 2023/11/21 */ - @GetMapping("getIPOTopicTwo") + @PostMapping("getIPOTopicTwo") @ApiOperation("IPO页面弹窗2使用返回随机6条数据") @AnonymousAccess - public ResultEntity> getIPOTopicTwo() { - return new ResultEntity>(topicService.getIPOTopicTwo()); + public ResultEntity> getIPOTopicTwo(@RequestParam String flowId) { + return new ResultEntity>(topicService.getIPOTopicTwo(flowId)); } @@ -86,8 +91,8 @@ public class TopicController { @PostMapping("getRightScore/{flowId}") @ApiOperation("知识测评,项目估值,项目尽调,IPO申请,判断答案对错算分") @AnonymousAccess - public ResultEntity> getRightScore(@ApiParam("需要ID和用户填写的答案") @PathVariable("flowId") String flowId, - @RequestBody List topics) { + public ResultEntity> getRightScore(@PathVariable("flowId") String flowId, + @ApiParam("需要ID和用户填写的答案、和module") @RequestBody List topics) { return topicService.getRightScore(topics, flowId); } @@ -99,8 +104,9 @@ public class TopicController { @PostMapping("getTopicRecord") @ApiOperation("知识测评、项目估值、项目尽调,IPO申请,回显答题记录") @AnonymousAccess - public ResultEntity> getTopicRecord(@ApiParam("getRightScore返回的ID集合") @RequestBody List ids) { - return new ResultEntity>(topicService.getTopicRecord(ids)); + public ResultEntity> getTopicRecord(@ApiParam("参考导入接口") @RequestParam String module, + @RequestParam String flowId) { + return new ResultEntity>(topicService.getTopicRecord(flowId, module)); } /* @@ -134,9 +140,13 @@ public class TopicController { @RequestParam String flowId, @RequestParam String schoolId) { + //不允许重复提交 + PerformanceScore byFlowId = performanceScoreService.getByFlowId(flowId); + if (byFlowId != null) { + return; + } //系统的第一个流程,新增一个得分对象 PerformanceScore performanceScore = new PerformanceScore(); - //观看2分钟以上得满分5分,否则不得分 BigDecimal score; if (time >= 120) { @@ -155,7 +165,7 @@ public class TopicController { User userTable = userMapper.selectByPrimaryKey(flow.getUserid()); performanceScore.setClassId(userTable.getClassId()); performanceScore.setPracticalCognitionTime(new Date()); - + performanceScore.setTotalScore(BigDecimal.ZERO); //防止后面算分有问题,在第一个步骤初始化成0 // performanceScore.setKnowledgeAssessmentScore(BigDecimal.ZERO); // performanceScore.setFundraisingScore(BigDecimal.ZERO); diff --git a/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java b/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java index a1a0a86..0acd77d 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java +++ b/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java @@ -8,7 +8,7 @@ import com.sztzjy.fund_investment.util.ResultEntity; * @Date 2023/12/6 */ public interface ProfitDistributionService { - ResultEntity submit(ProfitDistribution profitDistribution); + ResultEntity submit(ProfitDistribution profitDistribution); ProfitDistribution echo(String flowId); } diff --git a/src/main/java/com/sztzjy/fund_investment/service/TopicService.java b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java index d2400bb..57a3b67 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/TopicService.java +++ b/src/main/java/com/sztzjy/fund_investment/service/TopicService.java @@ -15,11 +15,11 @@ import java.util.List; public interface TopicService { ResultEntity> getRightScore(List topics,String flowId); - List getIPOTopicTwo(); + List getIPOTopicTwo(String flowId); - List getRandomTopic(String module); + List getRandomTopic(String module,String flowId); - List getTopicRecord(List ids); + List getTopicRecord(String flowId,String module); int importFile(MultipartFile file,String schoolId,String module); } 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 4c6f4f2..7fe50d7 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 @@ -145,11 +145,17 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService * 分配顺序:①银行借款(本金+利息) ②优先级LP(本金+本金*10%) ③劣后级LP(本金) ④自有资金(本金) */ @Override - public ResultEntity submit(ProfitDistribution profitDistribution) { + public ResultEntity submit(ProfitDistribution profitDistribution) { //校验可用资金 if (profitDistribution.getUserAvailableFunds() == null) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入可用资金!"); } + ProfitDistributionExample example =new ProfitDistributionExample(); + example.createCriteria().andFlowIdEqualTo(profitDistribution.getFlowId()); + List profitDistributions = profitDistributionMapper.selectByExample(example); + if (!profitDistributions.isEmpty()){ + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请勿重复提交!"); + } //校验优先级LP和自有资金 if (profitDistribution.getUserRemainingOwnFunds() == null || profitDistribution.getUserRoundOwnFunds() == null || profitDistribution.getUserRoundPreferredLp() == null || profitDistribution.getUserRemainingEarningsPreferredLp() == null) { @@ -478,6 +484,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService ProfitDistributionExample profitDistributionExample = new ProfitDistributionExample(); profitDistributionExample.createCriteria().andFlowIdEqualTo(flowId); List profitDistributions = profitDistributionMapper.selectByExample(profitDistributionExample); + if (profitDistributions.isEmpty()){ + return null; + } return profitDistributions.get(0); } } diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java index 4c05b32..ba7ef04 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/TopicServiceImpl.java @@ -13,6 +13,7 @@ import org.apache.poi.ss.usermodel.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.util.FileCopyUtils; import org.springframework.web.multipart.MultipartFile; @@ -146,6 +147,11 @@ public class TopicServiceImpl implements TopicService { */ @Override public ResultEntity> getRightScore(List topics, String flowId) { + String module1 = topics.get(0).getModule(); + List topicRecord1 = getTopicRecord(flowId,module1); + if (!topicRecord1.isEmpty()){ + return new ResultEntity>(HttpStatus.BAD_REQUEST,"请勿重复提交!"); + } int score = 0; List list = new ArrayList<>(); String module = ""; @@ -278,7 +284,11 @@ public class TopicServiceImpl implements TopicService { // } @Override - public List getRandomTopic(String module) { + public List getRandomTopic(String module, String flowId) { + List topicRecord = getTopicRecord(flowId, module); + if (!topicRecord.isEmpty()) { + return null; + } TopicsExample topicsExample = new TopicsExample(); topicsExample.createCriteria().andModuleEqualTo(module); List topics = topicsMapper.selectByExampleWithBLOBs(topicsExample); @@ -298,22 +308,24 @@ public class TopicServiceImpl implements TopicService { * @Date 2023/11/21 */ @Override - public List getTopicRecord(List ids) { - List list = new ArrayList<>(); - for (String id : ids) { - TopicRecord topicRecord = topicRecordMapper.selectByPrimaryKey(id); - list.add(topicRecord); - } - return list; + public List getTopicRecord(String flowId, String module) { + TopicRecordExample example = new TopicRecordExample(); + example.createCriteria().andModuleEqualTo(module).andFlowIdEqualTo(flowId); + return topicRecordMapper.selectByExample(example); } /* IPO页面弹窗2使用返回随机6条数据 * @author xcj - * @Date 2023/11/21 + * @Date 2023/11/21 IPO上市板块题目,IPO上市条件题目 */ @Override - public List getIPOTopicTwo() { + public List getIPOTopicTwo(String flow) { + List IPOBKList = getTopicRecord(flow, Constant.IPOBK); + List IPOTJList = getTopicRecord(flow, Constant.IPOTJ); + if (!(IPOBKList.isEmpty()) || !(IPOTJList.isEmpty())) { + return null; + } int topicCountPerModule = 3; List topics = getRandomTopicsByModule(Constant.IPOBK, topicCountPerModule); List topics1 = getRandomTopicsByModule(Constant.IPOTJ, topicCountPerModule);