修改实验实训提交接口

master
xiaoCJ
parent c8de79b2a6
commit 2b1a937f63

@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -46,7 +47,7 @@ public class CaseController {
private ComputeService computeService;
@PostMapping("/insertCase")
@ApiOperation("新增/编辑案例,老师和管理员新增根据caseInfo中的publish区分都是题目答案学生端新增传isAnswer为学生答案+userId")
@ApiOperation("新增/编辑案例,学生端新增传isAnswer为学生答案+userId")
private ResultEntity<HttpStatus> insertCase(@ApiParam("左侧caseInfo对象") @RequestParam(required = false) String caseInfo, //todo 传json字符串
@ApiParam("右侧考核点设置的参数对象") @RequestParam String json,
@ApiParam("老师或管理员操作传master,学生操作传stu") @RequestParam String operator,
@ -56,7 +57,7 @@ public class CaseController {
@PostMapping("/insertComprehensivePlanCase")
@ApiOperation("新增/编辑综合规划案例")
@ApiOperation("老师端或管理员/新增编辑综合规划案例")
private ResultEntity<HttpStatus> insertComprehensivePlanCase(@ApiParam("主表caseInfo必传") @RequestBody StuCaseDto stuCaseDto) {
return caseService.insertComprehensivePlanCase(stuCaseDto);
}
@ -64,8 +65,9 @@ public class CaseController {
@PostMapping("/getInsurancePro")
@ApiOperation("查询保险规划产品名称")
private ResultEntity<List<String>> getInsurancePro(@RequestParam String type) {
return new ResultEntity<List<String>>(insuranceProMapper.getInsurancePro(type));
@AnonymousAccess
private ResultEntity<List<Map<String, String>>> getInsurancePro(@RequestParam String type) {
return new ResultEntity<>(insuranceProMapper.getInsurancePro(type));
}
@PostMapping("/insertOrUpdateInvestmentPlan")
@ -217,8 +219,7 @@ public class CaseController {
@ApiOperation("年缴保费计算")
@AnonymousAccess
private ResultEntity<BigDecimal> getInsuranceExpense(@ApiParam("需要年龄,性别,保险年份,缴费方式,保险金额,InsuranceProId") @RequestBody CaseInvestmentPlanInsuranceProductInfo productInfo) {
BigDecimal AnnualPremium = computeService.getAnnualPremium(productInfo);
return new ResultEntity<BigDecimal>(AnnualPremium);
return computeService.getAnnualPremium(productInfo);
}

@ -3,14 +3,13 @@ package com.sztzjy.money_management.mapper;
import com.sztzjy.money_management.entity.InsurancePro;
import com.sztzjy.money_management.entity.InsuranceProExample;
import com.sztzjy.money_management.entity.InsuranceProWithBLOBs;
import java.util.List;
import com.sztzjy.money_management.util.ResultEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
@Mapper
public interface InsuranceProMapper {
long countByExample(InsuranceProExample example);
@ -41,6 +40,6 @@ public interface InsuranceProMapper {
int updateByPrimaryKey(InsurancePro record);
@Select("select name from insurance_pro where kind=#{type}")
List<String> getInsurancePro(@Param("type") String type);
@Select("select insurance_pro_id,name from insurance_pro where kind=#{type}")
List<Map<String, String>> getInsurancePro(@Param("type") String type);
}

@ -1,6 +1,7 @@
package com.sztzjy.money_management.service;
import com.sztzjy.money_management.entity.CaseInvestmentPlanInsuranceProductInfo;
import com.sztzjy.money_management.util.ResultEntity;
import java.math.BigDecimal;
@ -9,6 +10,6 @@ import java.math.BigDecimal;
* @Date 2024/10/9
*/
public interface ComputeService {
BigDecimal getAnnualPremium(CaseInvestmentPlanInsuranceProductInfo productInfo);
ResultEntity<BigDecimal> getAnnualPremium(CaseInvestmentPlanInsuranceProductInfo productInfo);
}

@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
@ -495,7 +494,6 @@ public class CaseServiceImpl implements CaseService {
// }
@Override
public ResultEntity<HttpStatus> insertCase(String caseInfo, String json, String operator, String type) {
Gson gson = new Gson();
@ -935,6 +933,15 @@ public class CaseServiceImpl implements CaseService {
ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseInvestmentPlanDto.getCaseId(), caseInvestmentPlanDto.getUserId());
if (result != null) return result;
CaseInvestmentPlan investmentPlan = caseInvestmentPlanDto.getInvestmentPlan();
String investmentPlanId = IdUtil.randomUUID();
if (StringUtils.isBlank(investmentPlan.getCaseInvestmentPlanId())) {
investmentPlan.setCaseInvestmentPlanId(investmentPlanId);
investmentPlanMapper.insert(investmentPlan);
} else {
investmentPlanMapper.updateByPrimaryKey(investmentPlan);
}
//投资规划-产品选择表和其余五张表是一对多关系
if (caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos() != null
&& !caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos().isEmpty()) {
@ -943,12 +950,11 @@ public class CaseServiceImpl implements CaseService {
for (CaseInvestmentPlanSelectDto investmentPlanSelect : investmentPlanSelects) {
CaseInvestmentPlanSelect caseInvestmentPlanSelect = investmentPlanSelect.getCaseInvestmentPlanSelect(); //产品选择表
String selectId = IdUtil.randomUUID();
//操作产品选择表
//id为空则新增 表不可能为null
if (caseInvestmentPlanSelect != null && StringUtils.isBlank(caseInvestmentPlanSelect.getProductSelectId())) {
caseInvestmentPlanSelect.setProductSelectId(IdUtil.randomUUID());
//todo caseid前端能否传过来
caseInvestmentPlanSelect.setCaseInvestmentPlanId(investmentPlanId);
caseInvestmentPlanSelectMapper.insert(caseInvestmentPlanSelect);
} else {
caseInvestmentPlanSelectMapper.updateByPrimaryKeySelective(caseInvestmentPlanSelect);
@ -962,6 +968,8 @@ public class CaseServiceImpl implements CaseService {
//id为空则新增
if (StringUtils.isBlank(investmentPlanFundProductInfo.getFundProductinfoId())) {
investmentPlanFundProductInfo.setFundProductinfoId(IdUtil.randomUUID());
investmentPlanFundProductInfo.setProductSelectId(selectId);
investmentPlanFundProductInfo.setAddTime(new Date());
investmentPlanFundProductInfoMapper.insert(investmentPlanFundProductInfo);
} else {
investmentPlanFundProductInfoMapper.updateByPrimaryKeySelective(investmentPlanFundProductInfo);
@ -976,6 +984,8 @@ public class CaseServiceImpl implements CaseService {
//id为空则新增
if (StringUtils.isBlank(investmentPlanBankProductInfo.getBankProductinfoId())) {
investmentPlanBankProductInfo.setBankProductinfoId(IdUtil.randomUUID());
investmentPlanBankProductInfo.setProductSelectId(selectId);
investmentPlanBankProductInfo.setAddTime(new Date());
investmentPlanBankProductInfoMapper.insert(investmentPlanBankProductInfo);
} else {
investmentPlanBankProductInfoMapper.updateByPrimaryKeySelective(investmentPlanBankProductInfo);
@ -991,6 +1001,8 @@ public class CaseServiceImpl implements CaseService {
//id为空则新增
if (StringUtils.isBlank(investmentPlanInsuranceProductInfo.getInsuranceProductinfoId())) {
investmentPlanInsuranceProductInfo.setInsuranceProductinfoId(IdUtil.randomUUID());
investmentPlanInsuranceProductInfo.setProductSelectId(selectId);
investmentPlanInsuranceProductInfo.setAddTime(new Date());
investmentPlanInsuranceProductInfoMapper.insert(investmentPlanInsuranceProductInfo);
} else {
investmentPlanInsuranceProductInfoMapper.updateByPrimaryKeySelective(investmentPlanInsuranceProductInfo);
@ -1005,6 +1017,8 @@ public class CaseServiceImpl implements CaseService {
//id为空则新增
if (StringUtils.isBlank(investmentPlanP2PProductInfo.getP2pProductinfoId())) {
investmentPlanP2PProductInfo.setP2pProductinfoId(IdUtil.randomUUID());
investmentPlanP2PProductInfo.setProductSelectId(selectId);
investmentPlanP2PProductInfo.setAddTime(new Date());
investmentPlanP2PProductInfoMapper.insert(investmentPlanP2PProductInfo);
} else {
investmentPlanP2PProductInfoMapper.updateByPrimaryKeySelective(investmentPlanP2PProductInfo);
@ -1020,6 +1034,8 @@ public class CaseServiceImpl implements CaseService {
//id为空则新增
if (StringUtils.isBlank(investmentPlanRealGoldProductInfo.getRealGoldProductId())) {
investmentPlanRealGoldProductInfo.setRealGoldProductId(IdUtil.randomUUID());
investmentPlanRealGoldProductInfo.setProductSelectId(selectId);
investmentPlanRealGoldProductInfo.setAddTime(new Date());
investmentPlanRealGoldProductInfoMapper.insert(investmentPlanRealGoldProductInfo);
} else {
investmentPlanRealGoldProductInfoMapper.updateByPrimaryKeySelective(investmentPlanRealGoldProductInfo);
@ -1269,21 +1285,154 @@ public class CaseServiceImpl implements CaseService {
wrongCount = getCaseInsurancePlanWrongCount(wrongCount, stuData);
}
// if (type.equals("投资规划")) {
// CaseInvestmentPlan stuInvestmentPlan = gson.fromJson(json, CaseInvestmentPlan.class);
// CaseInvestmentPlanExample caseInvestmentPlanExample = new CaseInvestmentPlanExample();
// caseInvestmentPlanExample.createCriteria().andIsAnswerEqualTo("学生答案").andUserIdEqualTo(stuInvestmentPlan.getUserId()).andCaseIdEqualTo(stuInvestmentPlan.getCaseId());
// List<CaseInvestmentPlan> caseInvestmentPlans = investmentPlanMapper.selectByExampleWithBLOBs(caseInvestmentPlanExample);
// if (!caseInvestmentPlans.isEmpty()) {
// for (CaseInvestmentPlan caseInvestmentPlan : caseInvestmentPlans) {
// investmentPlanMapper.deleteByPrimaryKey(caseInvestmentPlan.getCaseInvestmentPlanId());
// }
// }
// stuInvestmentPlan.setCaseInvestmentPlanId(IdUtil.randomUUID());
// investmentPlanMapper.insert(stuInvestmentPlan);
//
// //比较正确答案
// wrongCount = getCaseInvestmentPlan(wrongCount, stuInvestmentPlan);
// }
//先查询一次
if (type.equals("投资规划")) {
CaseInvestmentPlan stuInvestmentPlan = gson.fromJson(json, CaseInvestmentPlan.class);
CaseInvestmentPlanExample caseInvestmentPlanExample = new CaseInvestmentPlanExample();
caseInvestmentPlanExample.createCriteria().andIsAnswerEqualTo("学生答案").andUserIdEqualTo(stuInvestmentPlan.getUserId()).andCaseIdEqualTo(stuInvestmentPlan.getCaseId());
List<CaseInvestmentPlan> caseInvestmentPlans = investmentPlanMapper.selectByExampleWithBLOBs(caseInvestmentPlanExample);
if (!caseInvestmentPlans.isEmpty()) {
for (CaseInvestmentPlan caseInvestmentPlan : caseInvestmentPlans) {
investmentPlanMapper.deleteByPrimaryKey(caseInvestmentPlan.getCaseInvestmentPlanId());
CaseInvestmentPlanDto caseInvestmentPlanDto = gson.fromJson(json, CaseInvestmentPlanDto.class);
CaseInvestmentPlan investmentPlan = caseInvestmentPlanDto.getInvestmentPlan();
//投资规划-产品选择表和其余五张表是一对多关系
if (caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos() != null
&& !caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos().isEmpty()) {
List<CaseInvestmentPlanSelectDto> investmentPlanSelects = caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos();
for (CaseInvestmentPlanSelectDto investmentPlanSelect : investmentPlanSelects) {
CaseInvestmentPlanSelect caseInvestmentPlanSelect = investmentPlanSelect.getCaseInvestmentPlanSelect(); //产品选择表
String selectId = IdUtil.randomUUID();
//提交功能 主表必定不为空,把老数据查出来删掉
CaseInvestmentPlanExample example = new CaseInvestmentPlanExample();
example.createCriteria().andCaseIdEqualTo(investmentPlan.getCaseId()).andUserIdEqualTo(investmentPlan.getUserId()).andIsAnswerEqualTo("学生答案");
List<CaseInvestmentPlan> caseInvestmentPlans = investmentPlanMapper.selectByExampleWithBLOBs(example);
//删除老数据
if (caseInvestmentPlans != null) {
CaseInvestmentPlan caseInvestmentPlan = caseInvestmentPlans.get(0);
CaseInvestmentPlanSelectExample planSelectExample = new CaseInvestmentPlanSelectExample();
planSelectExample.createCriteria().andCaseInvestmentPlanIdEqualTo(caseInvestmentPlan.getCaseInvestmentPlanId());
List<CaseInvestmentPlanSelect> investmentPlanSelectsDataList = caseInvestmentPlanSelectMapper.selectByExampleWithBLOBs(planSelectExample);
if (investmentPlanSelectsDataList != null) {
CaseInvestmentPlanSelect investmentPlanSelectsData = investmentPlanSelectsDataList.get(0);
String productSelectId = investmentPlanSelectsData.getProductSelectId();
caseInvestmentPlanSelectMapper.deleteByPrimaryKey(productSelectId);
caseInvestmentPlanSelectMapper.deleteByPrimaryKey(productSelectId);
investmentPlanFundProductInfoMapper.deleteByPrimaryKey(productSelectId);
investmentPlanBankProductInfoMapper.deleteByPrimaryKey(productSelectId);
investmentPlanInsuranceProductInfoMapper.deleteByPrimaryKey(productSelectId);
investmentPlanP2PProductInfoMapper.deleteByPrimaryKey(productSelectId);
investmentPlanRealGoldProductInfoMapper.deleteByPrimaryKey(productSelectId);
}
investmentPlanMapper.deleteByPrimaryKey(caseInvestmentPlan.getCaseInvestmentPlanId());
}
//新增主表
String newCaseInvestmentPlanId = IdUtil.randomUUID();
investmentPlan.setCaseInvestmentPlanId(newCaseInvestmentPlanId);
investmentPlanMapper.insert(investmentPlan);
//下面都为新增操作
if (caseInvestmentPlanSelect != null) {
caseInvestmentPlanSelect.setProductSelectId(selectId);
caseInvestmentPlanSelect.setCaseInvestmentPlanId(newCaseInvestmentPlanId);
caseInvestmentPlanSelectMapper.insert(caseInvestmentPlanSelect);
}
//投资规划-基金产品信息表
if (investmentPlanSelect.getInvestmentPlanFundProductInfos() != null
&& !investmentPlanSelect.getInvestmentPlanFundProductInfos().isEmpty()) {
List<CaseInvestmentPlanFundProductInfo> investmentPlanFundProductInfos = investmentPlanSelect.getInvestmentPlanFundProductInfos();
for (CaseInvestmentPlanFundProductInfo investmentPlanFundProductInfo : investmentPlanFundProductInfos) {
if (StringUtils.isBlank(investmentPlanFundProductInfo.getFundProductinfoId())) {
investmentPlanFundProductInfo.setFundProductinfoId(IdUtil.randomUUID());
investmentPlanFundProductInfo.setProductSelectId(selectId);
investmentPlanFundProductInfo.setAddTime(new Date());
investmentPlanFundProductInfoMapper.insert(investmentPlanFundProductInfo);
}
}
}
//投资规划-银行储蓄信息表
if (investmentPlanSelect.getInvestmentPlanBankProductInfos() != null
&& !investmentPlanSelect.getInvestmentPlanBankProductInfos().isEmpty()) {
List<CaseInvestmentPlanBankProductInfo> investmentPlanBankProductInfos = investmentPlanSelect.getInvestmentPlanBankProductInfos(); //投资规划-银行储蓄信息表
for (CaseInvestmentPlanBankProductInfo investmentPlanBankProductInfo : investmentPlanBankProductInfos) {
//id为空则新增
if (StringUtils.isBlank(investmentPlanBankProductInfo.getBankProductinfoId())) {
investmentPlanBankProductInfo.setBankProductinfoId(IdUtil.randomUUID());
investmentPlanBankProductInfo.setProductSelectId(selectId);
investmentPlanBankProductInfo.setAddTime(new Date());
investmentPlanBankProductInfoMapper.insert(investmentPlanBankProductInfo);
}
}
}
//投资规划-保险产品信息表
if (investmentPlanSelect.getInvestmentPlanInsuranceProductInfos() != null
&& !investmentPlanSelect.getInvestmentPlanInsuranceProductInfos().isEmpty()) {
List<CaseInvestmentPlanInsuranceProductInfo> investmentPlanInsuranceProductInfos = investmentPlanSelect.getInvestmentPlanInsuranceProductInfos();//投资规划-保险产品信息表
for (CaseInvestmentPlanInsuranceProductInfo investmentPlanInsuranceProductInfo : investmentPlanInsuranceProductInfos) {
//id为空则新增
if (StringUtils.isBlank(investmentPlanInsuranceProductInfo.getInsuranceProductinfoId())) {
investmentPlanInsuranceProductInfo.setInsuranceProductinfoId(IdUtil.randomUUID());
investmentPlanInsuranceProductInfo.setProductSelectId(selectId);
investmentPlanInsuranceProductInfo.setAddTime(new Date());
investmentPlanInsuranceProductInfoMapper.insert(investmentPlanInsuranceProductInfo);
}
}
}
//投资规划-P2P产品信息表
if (investmentPlanSelect.getInvestmentPlanP2PProductInfos() != null
&& !investmentPlanSelect.getInvestmentPlanP2PProductInfos().isEmpty()) {
List<CaseInvestmentPlanP2PProductInfo> investmentPlanP2PProductInfos = investmentPlanSelect.getInvestmentPlanP2PProductInfos();//投资规划-P2P产品信息表
for (CaseInvestmentPlanP2PProductInfo investmentPlanP2PProductInfo : investmentPlanP2PProductInfos) {
//id为空则新增
if (StringUtils.isBlank(investmentPlanP2PProductInfo.getP2pProductinfoId())) {
investmentPlanP2PProductInfo.setP2pProductinfoId(IdUtil.randomUUID());
investmentPlanP2PProductInfo.setProductSelectId(selectId);
investmentPlanP2PProductInfo.setAddTime(new Date());
investmentPlanP2PProductInfoMapper.insert(investmentPlanP2PProductInfo);
}
}
}
//投资规划-实物黄金信息表
if (investmentPlanSelect.getInvestmentPlanRealGoldProductInfos() != null
&& !investmentPlanSelect.getInvestmentPlanRealGoldProductInfos().isEmpty()) {
List<CaseInvestmentPlanRealGoldProductInfo> investmentPlanRealGoldProductInfos = investmentPlanSelect.getInvestmentPlanRealGoldProductInfos();//投资规划-实物黄金信息表
for (CaseInvestmentPlanRealGoldProductInfo investmentPlanRealGoldProductInfo : investmentPlanRealGoldProductInfos) {
//id为空则新增
if (StringUtils.isBlank(investmentPlanRealGoldProductInfo.getRealGoldProductId())) {
investmentPlanRealGoldProductInfo.setRealGoldProductId(IdUtil.randomUUID());
investmentPlanRealGoldProductInfo.setProductSelectId(selectId);
investmentPlanRealGoldProductInfo.setAddTime(new Date());
investmentPlanRealGoldProductInfoMapper.insert(investmentPlanRealGoldProductInfo);
}
}
}
}
}
stuInvestmentPlan.setCaseInvestmentPlanId(IdUtil.randomUUID());
investmentPlanMapper.insert(stuInvestmentPlan);
//比较正确答案
wrongCount = getCaseInvestmentPlan(wrongCount, stuInvestmentPlan);
wrongCount = getCaseInvestmentPlan(wrongCount, investmentPlan);
}
if (type.equals("税务筹划")) {
@ -1354,7 +1503,8 @@ public class CaseServiceImpl implements CaseService {
wrongCount = getCaseHeritageWrongCount(wrongCount, stuData);
}
}
} catch (Exception e) {
} catch (
Exception e) {
e.printStackTrace();
throw new RuntimeException("实训提交失败");
}

@ -293,13 +293,13 @@
insert into case_distribution_of_property_family_records (case_distribution_of_property_family_records_id,
caseid,
case_distribution_of_property_id, name, age,
customer_relationship, annual_income, sort,
customer_relationship, annual_income, create_time,
user_id, is_answer)
values
<foreach collection="list" item="item" separator=",">
(#{item.caseDistributionOfPropertyFamilyRecordsId,jdbcType=VARCHAR}, #{item.caseid,jdbcType=VARCHAR},
#{item.caseDistributionOfPropertyId,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.age,jdbcType=INTEGER},
#{item.customerRelationship,jdbcType=VARCHAR}, #{item.annualIncome,jdbcType=DECIMAL}, #{item.sort,jdbcType=INTEGER},
#{item.customerRelationship,jdbcType=VARCHAR}, #{item.annualIncome,jdbcType=DECIMAL}, #{item.create_time,jdbcType=TIMESTAMP},
#{item.userId,jdbcType=VARCHAR}, #{item.isAnswer,jdbcType=VARCHAR})
</foreach>
</insert>

Loading…
Cancel
Save