diff --git a/src/main/java/com/sztzjy/money_management/controller/CaseController.java b/src/main/java/com/sztzjy/money_management/controller/CaseController.java index 195785b..55f4880 100644 --- a/src/main/java/com/sztzjy/money_management/controller/CaseController.java +++ b/src/main/java/com/sztzjy/money_management/controller/CaseController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; import com.sztzjy.money_management.annotation.AnonymousAccess; import com.sztzjy.money_management.config.Constant; import com.sztzjy.money_management.entity.*; +import com.sztzjy.money_management.entity.dto.CaseInvestmentPlanDto; import com.sztzjy.money_management.mapper.CaseInfoMapper; import com.sztzjy.money_management.mapper.ChapterMapper; import com.sztzjy.money_management.mapper.ComCaseMapper; @@ -46,6 +47,12 @@ public class CaseController { return caseService.insertCase(caseInfo, json, operator, type); } + @PostMapping("/insertOrUpdateInvestmentPlan") + @ApiOperation("新增/编辑案例,投资规划") + private ResultEntity<HttpStatus> insertOrUpdateInvestmentPlan(@ApiParam("老师或管理员新增修改不传userId")@RequestBody CaseInvestmentPlanDto caseInvestmentPlanDto) { + return caseService.insertOrUpdateInvestmentPlan(caseInvestmentPlanDto); + } + @PostMapping("/ZHGHType") @ApiOperation("综合规划下方展示类型") @AnonymousAccess diff --git a/src/main/java/com/sztzjy/money_management/controller/GradeController.java b/src/main/java/com/sztzjy/money_management/controller/GradeController.java index 7217bb7..277d3a9 100644 --- a/src/main/java/com/sztzjy/money_management/controller/GradeController.java +++ b/src/main/java/com/sztzjy/money_management/controller/GradeController.java @@ -637,7 +637,7 @@ public class GradeController { @AnonymousAccess public ResultEntity<List<SynthesisPlanClient>> getSubmitStatusCaseListByUserId(String userId){ SynthesisPlanClientExample synthesisPlanClientExample = new SynthesisPlanClientExample(); - List submitStatusList=new ArrayList(); + List<String> submitStatusList=new ArrayList<>(); submitStatusList.add("未审核"); submitStatusList.add("已审核"); synthesisPlanClientExample.createCriteria().andUseridEqualTo(userId).andSubmitStatusIn(submitStatusList); diff --git a/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanDto.java b/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanDto.java new file mode 100644 index 0000000..f3a1a67 --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanDto.java @@ -0,0 +1,23 @@ +package com.sztzjy.money_management.entity.dto; + +import com.sztzjy.money_management.entity.*; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author xcj + * @Date 2024/8/30 + */ +@Data +public class CaseInvestmentPlanDto { + @ApiModelProperty("投资规划案例表") + private CaseInvestmentPlan investmentPlan; + @ApiModelProperty("投资规划-产品选择表") + private List<CaseInvestmentPlanSelectDto> caseInvestmentPlanSelectDtos; + @ApiModelProperty("案例信息表") + private CaseInfo caseInfo; + private String userId; + private String caseId; +} diff --git a/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanSelectDto.java b/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanSelectDto.java new file mode 100644 index 0000000..3da9b32 --- /dev/null +++ b/src/main/java/com/sztzjy/money_management/entity/dto/CaseInvestmentPlanSelectDto.java @@ -0,0 +1,30 @@ +package com.sztzjy.money_management.entity.dto; + +import com.sztzjy.money_management.entity.*; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author xcj + * @Date 2024/8/30 + */ +@Data +public class CaseInvestmentPlanSelectDto { + @ApiModelProperty("案例-投资规划-产品选择表") + private CaseInvestmentPlanSelect caseInvestmentPlanSelect; + + //其余表 + @ApiModelProperty("投资规划-银行储蓄信息表") + private List<CaseInvestmentPlanBankProductInfo> investmentPlanBankProductInfos; + @ApiModelProperty("投资规划-基金产品信息表") + private List<CaseInvestmentPlanFundProductInfo> investmentPlanFundProductInfos; + @ApiModelProperty("投资规划-保险产品信息表") + private List<CaseInvestmentPlanInsuranceProductInfo> investmentPlanInsuranceProductInfos; + @ApiModelProperty("投资规划-P2P产品信息表") + private List<CaseInvestmentPlanP2PProductInfo> investmentPlanP2PProductInfos; + @ApiModelProperty("投资规划-实物黄金信息表") + private List<CaseInvestmentPlanRealGoldProductInfo> investmentPlanRealGoldProductInfos; +} + diff --git a/src/main/java/com/sztzjy/money_management/mapper/CaseConsumptionPlanMapper.java b/src/main/java/com/sztzjy/money_management/mapper/CaseConsumptionPlanMapper.java index 21c665a..89caddb 100644 --- a/src/main/java/com/sztzjy/money_management/mapper/CaseConsumptionPlanMapper.java +++ b/src/main/java/com/sztzjy/money_management/mapper/CaseConsumptionPlanMapper.java @@ -4,6 +4,7 @@ import com.sztzjy.money_management.entity.CaseConsumptionPlan; import com.sztzjy.money_management.entity.CaseConsumptionPlanExample; import java.util.List; +import com.sztzjy.money_management.entity.CaseConsumptionPlanWithBLOBs; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @Mapper diff --git a/src/main/java/com/sztzjy/money_management/service/CaseService.java b/src/main/java/com/sztzjy/money_management/service/CaseService.java index 404652f..40b26b0 100644 --- a/src/main/java/com/sztzjy/money_management/service/CaseService.java +++ b/src/main/java/com/sztzjy/money_management/service/CaseService.java @@ -1,6 +1,7 @@ package com.sztzjy.money_management.service; import com.nimbusds.jose.shaded.gson.Gson; +import com.sztzjy.money_management.entity.dto.CaseInvestmentPlanDto; import com.sztzjy.money_management.util.ResultEntity; import org.springframework.http.HttpStatus; @@ -19,4 +20,6 @@ public interface CaseService { void commitTraining(String json, String type, String trainingId); ResultEntity addCorrelationTable(String type, String json, Gson gson, String operator); + + ResultEntity<HttpStatus> insertOrUpdateInvestmentPlan(CaseInvestmentPlanDto caseInvestmentPlanDto); } diff --git a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java index 6cf317a..6b0731a 100644 --- a/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java +++ b/src/main/java/com/sztzjy/money_management/service/impl/CaseServiceImpl.java @@ -5,6 +5,8 @@ import com.nimbusds.jose.shaded.gson.Gson; import com.nimbusds.jose.shaded.gson.JsonSyntaxException; import com.sztzjy.money_management.entity.*; import com.sztzjy.money_management.entity.dto.CaseDistributionOfPropertyFamilyDto; +import com.sztzjy.money_management.entity.dto.CaseInvestmentPlanDto; +import com.sztzjy.money_management.entity.dto.CaseInvestmentPlanSelectDto; import com.sztzjy.money_management.mapper.*; import com.sztzjy.money_management.service.CaseService; import com.sztzjy.money_management.util.ResultEntity; @@ -64,6 +66,21 @@ public class CaseServiceImpl implements CaseService { private CaseConsumptionPlanMapper caseConsumptionPlanMapper; @Autowired private CaseDistributionOfPropertyFamilyRecordsMapper caseDistributionOfPropertyFamilyRecordsMapper; + @Autowired + private CaseInvestmentPlanMapper investmentPlanMapper; + @Autowired + private CaseInvestmentPlanBankProductInfoMapper investmentPlanBankProductInfoMapper; + @Autowired + private CaseInvestmentPlanFundProductInfoMapper investmentPlanFundProductInfoMapper; + @Autowired + private CaseInvestmentPlanInsuranceProductInfoMapper investmentPlanInsuranceProductInfoMapper; + @Autowired + private CaseInvestmentPlanP2PProductInfoMapper investmentPlanP2PProductInfoMapper; + @Autowired + private CaseInvestmentPlanRealGoldProductInfoMapper investmentPlanRealGoldProductInfoMapper; + @Autowired + private CaseInvestmentPlanSelectMapper caseInvestmentPlanSelectMapper; + private void insertSynthesisPlanClient(CaseInfo newCase) { SynthesisPlanClient synthesisPlanClient = new SynthesisPlanClient(); @@ -137,9 +154,15 @@ public class CaseServiceImpl implements CaseService { e.printStackTrace(); return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "服务器错误,请联系管理员"); } + if (newCase != null) { + adminOrTeaInsert(operator, newCase); + } + //判断是哪种考核点 增加相关表 + return addCorrelationTable(type, json, gson, operator); + } + private void adminOrTeaInsert(String operator, CaseInfo newCase) { //老师或者管理员才操作 新增或编辑案例时 - String caseid = ""; if (operator.equals("master")) { CaseInfoExample example = new CaseInfoExample(); example.createCriteria().andIdCardEqualTo(newCase.getIdCard()); @@ -154,7 +177,7 @@ public class CaseServiceImpl implements CaseService { //综合规划需要额外新增一张表 if (newCase.getModel().equals("综合规划")) { ComCase comCase = new ComCase(); - comCase.setCaseid(caseid); + comCase.setCaseid(newCase.getCaseid()); comCase.setComCaseId(IdUtil.randomUUID()); comCase.setManageMoneyMattersType(newCase.getManageMoneyMattersType()); comCaseMapper.insert(comCase); @@ -173,8 +196,6 @@ public class CaseServiceImpl implements CaseService { synthesisPlanClientMapper.updateByPrimaryKeySelective(synthesisPlanClient); } } - //判断是哪种考核点 增加相关表 - return addCorrelationTable(type, json, gson, operator); } @@ -217,10 +238,10 @@ public class CaseServiceImpl implements CaseService { ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseRiskIndex.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseRiskIndexMapper.updateByPrimaryKeySelective(caseRiskIndex); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseRiskIndexMapper.updateByPrimaryKeySelective(caseRiskIndex); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财务分析-资产负债表")) { @@ -238,10 +259,10 @@ public class CaseServiceImpl implements CaseService { ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseFinanceLiability.getCaseId(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseFinanceLiabilityMapper.updateByPrimaryKeySelective(caseFinanceLiability); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseFinanceLiabilityMapper.updateByPrimaryKeySelective(caseFinanceLiability); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财务分析-收支储蓄表")) { @@ -260,10 +281,10 @@ public class CaseServiceImpl implements CaseService { ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseIncomeAndExpenses.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseIncomeAndExpensesMapper.updateByPrimaryKeySelective(caseIncomeAndExpenses); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseIncomeAndExpensesMapper.updateByPrimaryKeySelective(caseIncomeAndExpenses); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财务分析-现金流量表")) { @@ -277,19 +298,17 @@ public class CaseServiceImpl implements CaseService { //学生提交编辑 if (operator.equals("stu")) { String userId = caseCashFlow.getUserId(); - ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseCashFlow.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseCashFlowMapper.updateByPrimaryKeySelective(caseCashFlow); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseCashFlowMapper.updateByPrimaryKeySelective(caseCashFlow); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财务分析-财务比例分析")) { CaseFinancialRatiosWithBLOBs caseFinancialRatios = gson.fromJson(json, CaseFinancialRatiosWithBLOBs.class); if (StringUtils.isBlank(caseFinancialRatios.getCaseFinancialRatiosId())) { - caseFinancialRatios.setCaseFinancialRatiosId(IdUtil.randomUUID()); caseFinancialRatiosMapper.insert(caseFinancialRatios); return new ResultEntity<HttpStatus>(HttpStatus.OK, "新增成功!"); @@ -297,13 +316,12 @@ public class CaseServiceImpl implements CaseService { //学生提交编辑 if (operator.equals("stu")) { String userId = caseFinancialRatios.getUserId(); - ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseFinancialRatios.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseFinancialRatiosMapper.updateByPrimaryKeySelective(caseFinancialRatios); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseFinancialRatiosMapper.updateByPrimaryKeySelective(caseFinancialRatios); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("现金规划")) { @@ -319,10 +337,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseCashPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseCashPlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseCashPlanMapper.updateByPrimaryKeySelective(caseCashPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseCashPlanMapper.updateByPrimaryKeySelective(caseCashPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("生涯规划-教育规划")) { @@ -337,10 +355,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseLifeEducationPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseLifeEducationPlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseLifeEducationPlanMapper.updateByPrimaryKeySelective(caseLifeEducationPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseLifeEducationPlanMapper.updateByPrimaryKeySelective(caseLifeEducationPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("生涯规划-消费规划")) { @@ -355,10 +373,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseConsumptionPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseConsumptionPlan.getCaseId(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseConsumptionPlanMapper.updateByPrimaryKeySelective(caseConsumptionPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseConsumptionPlanMapper.updateByPrimaryKeySelective(caseConsumptionPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("生涯规划-创业规划")) { @@ -373,10 +391,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseStartAnUndertakingPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseStartAnUndertakingPlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseStartAnUndertakingPlanMapper.updateByPrimaryKeySelective(caseStartAnUndertakingPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseStartAnUndertakingPlanMapper.updateByPrimaryKeySelective(caseStartAnUndertakingPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("生涯规划-退休规划")) { @@ -391,10 +409,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseRetirementPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseRetirementPlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseRetirementPlanMapper.updateByPrimaryKeySelective(caseRetirementPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseRetirementPlanMapper.updateByPrimaryKeySelective(caseRetirementPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("生涯规划-保险规划")) { @@ -409,17 +427,13 @@ public class CaseServiceImpl implements CaseService { String userId = caseInsurancePlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseInsurancePlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseInsurancePlanMapper.updateByPrimaryKeySelective(caseInsurancePlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseInsurancePlanMapper.updateByPrimaryKeySelective(caseInsurancePlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } - if (type.equals("投资规划")) { - // todo 表暂时没有 - return null; - } - + //投资规划表比较多,单独写接口 if (type.equals("税务筹划")) { CaseTaxPlan caseTaxPlan = gson.fromJson(json, CaseTaxPlan.class); if (StringUtils.isBlank(caseTaxPlan.getCaseTaxPlanId())) { @@ -432,10 +446,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseTaxPlan.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseTaxPlan.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseTaxPlanMapper.updateByPrimaryKeySelective(caseTaxPlan); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseTaxPlanMapper.updateByPrimaryKeySelective(caseTaxPlan); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财产分配")) { @@ -464,10 +478,9 @@ public class CaseServiceImpl implements CaseService { String userId = dto.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(dto.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseDistributionOfPropertyMapper.updateByPrimaryKeySelective(caseDistributionOfPropertyWithBLOBs); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); - } + } //老师和学生编辑都走这里 + caseDistributionOfPropertyMapper.updateByPrimaryKeySelective(caseDistributionOfPropertyWithBLOBs); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } if (type.equals("财产传承")) { @@ -482,10 +495,10 @@ public class CaseServiceImpl implements CaseService { String userId = caseHeritageWithBLOBs.getUserId(); ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseHeritageWithBLOBs.getCaseid(), userId); if (result != null) return result; - } else { //老师和学生编辑都走这里 - caseHeritageMapper.updateByPrimaryKeySelective(caseHeritageWithBLOBs); - return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } + //老师和学生编辑都走这里 + caseHeritageMapper.updateByPrimaryKeySelective(caseHeritageWithBLOBs); + return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } } } catch ( @@ -496,8 +509,144 @@ public class CaseServiceImpl implements CaseService { return null; } - @Override + public ResultEntity<HttpStatus> insertOrUpdateInvestmentPlan(CaseInvestmentPlanDto caseInvestmentPlanDto) { + CaseInfo newCase = new CaseInfo(); + if (caseInvestmentPlanDto.getCaseInfo() != null) { + newCase = caseInvestmentPlanDto.getCaseInfo(); + } + //新增或修改案例信息表 + if (newCase != null) { + adminOrTeaInsert("master", newCase); + } + //老师和管理员新增/修改 只操作主表后返回 + ResultEntity<HttpStatus> flag = teaOrAdminUpdateOrInsertInvestmentPlan(caseInvestmentPlanDto); + if (StringUtils.isBlank(caseInvestmentPlanDto.getUserId())) { + return flag; + } + + try { + //学生操作多张表之后 最后返回 + if (StringUtils.isNotBlank(caseInvestmentPlanDto.getUserId())) { + //判断是否提交过 + ResultEntity<HttpStatus> result = getHttpStatusResultEntity(caseInvestmentPlanDto.getCaseId(), caseInvestmentPlanDto.getUserId()); + if (result != null) return result; + + //投资规划-产品选择表和其余五张表是一对多关系 + if (caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos() != null + && !caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos().isEmpty()) { + List<CaseInvestmentPlanSelectDto> investmentPlanSelects = caseInvestmentPlanDto.getCaseInvestmentPlanSelectDtos(); + + for (CaseInvestmentPlanSelectDto investmentPlanSelect : investmentPlanSelects) { + + CaseInvestmentPlanSelect caseInvestmentPlanSelect = investmentPlanSelect.getCaseInvestmentPlanSelect(); //产品选择表 + + //操作产品选择表 + //id为空则新增 + if (StringUtils.isBlank(caseInvestmentPlanSelect.getProductSelectId())) { + caseInvestmentPlanSelect.setProductSelectId(IdUtil.randomUUID()); + caseInvestmentPlanSelectMapper.insert(caseInvestmentPlanSelect); + } else { + caseInvestmentPlanSelectMapper.updateByPrimaryKeySelective(caseInvestmentPlanSelect); + } + + //投资规划-基金产品信息表 + if (investmentPlanSelect.getInvestmentPlanFundProductInfos() != null + && !investmentPlanSelect.getInvestmentPlanFundProductInfos().isEmpty()) { + List<CaseInvestmentPlanFundProductInfo> investmentPlanFundProductInfos = investmentPlanSelect.getInvestmentPlanFundProductInfos(); + for (CaseInvestmentPlanFundProductInfo investmentPlanFundProductInfo : investmentPlanFundProductInfos) { + //id为空则新增 + if (StringUtils.isBlank(investmentPlanFundProductInfo.getFundProductinfoId())) { + investmentPlanFundProductInfo.setFundProductinfoId(IdUtil.randomUUID()); + investmentPlanFundProductInfoMapper.insert(investmentPlanFundProductInfo); + } else { + investmentPlanFundProductInfoMapper.updateByPrimaryKeySelective(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()); + investmentPlanBankProductInfoMapper.insert(investmentPlanBankProductInfo); + } else { + investmentPlanBankProductInfoMapper.updateByPrimaryKeySelective(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()); + investmentPlanInsuranceProductInfoMapper.insert(investmentPlanInsuranceProductInfo); + } else { + investmentPlanInsuranceProductInfoMapper.updateByPrimaryKeySelective(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()); + investmentPlanP2PProductInfoMapper.insert(investmentPlanP2PProductInfo); + } else { + investmentPlanP2PProductInfoMapper.updateByPrimaryKeySelective(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()); + investmentPlanRealGoldProductInfoMapper.insert(investmentPlanRealGoldProductInfo); + } else { + investmentPlanRealGoldProductInfoMapper.updateByPrimaryKeySelective(investmentPlanRealGoldProductInfo); + } + } + } + } + } + } + } catch ( + Exception e) { + e.printStackTrace(); + return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR, "系统错误,请联系管理员!"); + } + return new ResultEntity<HttpStatus>(HttpStatus.OK, "操作成功!"); + } + + private ResultEntity<HttpStatus> teaOrAdminUpdateOrInsertInvestmentPlan(CaseInvestmentPlanDto caseInvestmentPlanDto) { + CaseInvestmentPlan investmentPlan = caseInvestmentPlanDto.getInvestmentPlan(); + + if (StringUtils.isBlank(investmentPlan.getCaseInvestmentPlanId())) { //主键为空为新增 + investmentPlan.setCaseInvestmentPlanId(IdUtil.randomUUID()); + investmentPlanMapper.insert(investmentPlan); + return new ResultEntity<HttpStatus>(HttpStatus.OK, "新增成功!"); + } else { + investmentPlanMapper.updateByPrimaryKeySelective(investmentPlan); + return new ResultEntity<HttpStatus>(HttpStatus.OK, "编辑成功!"); + } + } + + @Override //重新实训 先把数据库的数据替换成本次数据,再设置实训表中的数据,没分数则加上,有则不改 public void commitTraining(String json, String type, String trainingId) { StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId); @@ -641,7 +790,22 @@ public class CaseServiceImpl implements CaseService { } if (type.equals("生涯规划-消费规划")) { - //todo 暂无数据库表 + CaseConsumptionPlanWithBLOBs stuData = gson.fromJson(json, CaseConsumptionPlanWithBLOBs.class); + + CaseConsumptionPlanExample caseConsumptionPlanExample = new CaseConsumptionPlanExample(); + caseConsumptionPlanExample.createCriteria().andIsAnswerEqualTo("学生答案").andUserIdEqualTo(stuData.getUserId()).andCaseIdEqualTo(stuData.getCaseId()); + List<CaseConsumptionPlan> caseConsumptionPlans = caseConsumptionPlanMapper.selectByExampleWithBLOBs(caseConsumptionPlanExample); //todo 测试看下这里能不能查出来 + if (!caseConsumptionPlans.isEmpty()) { + for (CaseConsumptionPlan caseConsumptionPlan : caseConsumptionPlans) { + caseConsumptionPlanMapper.deleteByPrimaryKey(caseConsumptionPlan.getCaseConsumptionPlanId()); + } + } + + stuData.setCaseConsumptionPlanId(IdUtil.randomUUID()); + caseConsumptionPlanMapper.insert(stuData); + + //比较正确答案 + wrongCount = getCaseConsumptionPlanWrongCount(wrongCount, stuData); } @@ -775,6 +939,116 @@ public class CaseServiceImpl implements CaseService { } + //todo 消费规划表缺字段,对照一下再重新生成 + //todo 理财方案老师和管理员新增时多是一个考核点,学生端要填多条,可能有问题,这里对比的字段需要修改 + private int getCaseConsumptionPlanWrongCount(int wrongCount, CaseConsumptionPlanWithBLOBs stuData) { + CaseConsumptionPlanExample example = new CaseConsumptionPlanExample(); + example.createCriteria().andCaseIdEqualTo(stuData.getCaseId()).andIsAnswerEqualTo("题目答案"); + List<CaseConsumptionPlan> CaseConsumptionPlans = caseConsumptionPlanMapper.selectByExampleWithBLOBs(example); + + if (CaseConsumptionPlans != null && !CaseConsumptionPlans.isEmpty()) { + CaseConsumptionPlan rightData = CaseConsumptionPlans.get(0); + + if (stuData.getHouseArea() == null || !stuData.getHouseArea().equals(rightData.getHouseArea())) { + wrongCount += 1; + } + if (stuData.getHousePrice() == null || !stuData.getHousePrice().equals(rightData.getHousePrice())) { + wrongCount += 1; + } + if (stuData.getHouseDownPaymentPercent() == null || !stuData.getHouseDownPaymentPercent().equals(rightData.getHouseDownPaymentPercent())) { + wrongCount += 1; + } + if (stuData.getHouseLoanYear() == null || !stuData.getHouseLoanYear().equals(rightData.getHouseLoanYear())) { + wrongCount += 1; + } + if (stuData.getHouseLoanRate() == null || !stuData.getHouseLoanRate().equals(rightData.getHouseLoanRate())) { + wrongCount += 1; + } + if (stuData.getHouseDownPayment() == null || !stuData.getHouseDownPayment().equals(rightData.getHouseDownPayment())) { + wrongCount += 1; + } + if (stuData.getHouseTotalAmount() == null || !stuData.getHouseTotalAmount().equals(rightData.getHouseTotalAmount())) { + wrongCount += 1; + } + if (stuData.getHouseMonthlyAmount() == null || !stuData.getHouseMonthlyAmount().equals(rightData.getHouseMonthlyAmount())) { + wrongCount += 1; + } + if (stuData.getCarType() == null || !stuData.getCarType().equals(rightData.getCarType())) { + wrongCount += 1; + } + if (stuData.getCarPrice() == null || !stuData.getCarPrice().equals(rightData.getCarPrice())) { + wrongCount += 1; + } + if (stuData.getCarDownPaymentPercent() == null || !stuData.getCarDownPaymentPercent().equals(rightData.getCarDownPaymentPercent())) { + wrongCount += 1; + } + if (stuData.getCarLoanYear() == null || !stuData.getCarLoanYear().equals(rightData.getCarLoanYear())) { + wrongCount += 1; + } + if (stuData.getCarLoanRate() == null || !stuData.getCarLoanRate().equals(rightData.getCarLoanRate())) { + wrongCount += 1; + } + if (stuData.getPurchaseTax() == null || !stuData.getPurchaseTax().equals(rightData.getPurchaseTax())) { + wrongCount += 1; + } + if (stuData.getCarRegFee() == null || !stuData.getCarRegFee().equals(rightData.getCarRegFee())) { + wrongCount += 1; + } + if (stuData.getDisplacement() == null || !stuData.getDisplacement().equals(rightData.getDisplacement())) { + wrongCount += 1; + } + if (stuData.getVehicleAndVesselTax() == null || !stuData.getVehicleAndVesselTax().equals(rightData.getVehicleAndVesselTax())) { + wrongCount += 1; + } + if (stuData.getMotorVehicleCompulsory() == null || !stuData.getMotorVehicleCompulsory().equals(rightData.getMotorVehicleCompulsory())) { + wrongCount += 1; + } + if (stuData.getMotorVehicleCommercial() == null || !stuData.getMotorVehicleCommercial().equals(rightData.getMotorVehicleCommercial())) { + wrongCount += 1; + } + if (stuData.getCarDownPayment() == null || !stuData.getCarDownPayment().equals(rightData.getCarDownPayment())) { + wrongCount += 1; + } + if (stuData.getCarTotalAmount() == null || !stuData.getCarTotalAmount().equals(rightData.getCarTotalAmount())) { + wrongCount += 1; + } + if (stuData.getCarMonthlyAmount() == null || !stuData.getCarMonthlyAmount().equals(rightData.getCarMonthlyAmount())) { + wrongCount += 1; + } + if (stuData.getFirstAmount() == null || !stuData.getFirstAmount().equals(rightData.getFirstAmount())) { + wrongCount += 1; + } + if (stuData.getReturnOnInvestment() == null || !stuData.getReturnOnInvestment().equals(rightData.getReturnOnInvestment())) { + wrongCount += 1; + } + if (stuData.getDisposableInput() == null || !stuData.getDisposableInput().equals(rightData.getDisposableInput())) { + wrongCount += 1; + } + if (stuData.getMonthlyInvestment() == null || !stuData.getMonthlyInvestment().equals(rightData.getMonthlyInvestment())) { + wrongCount += 1; + } + if (stuData.getRegularYear() == null || !stuData.getRegularYear().equals(rightData.getRegularYear())) { + wrongCount += 1; + } + if (stuData.getTargetAmount() == null || !stuData.getTargetAmount().equals(rightData.getTargetAmount())) { + wrongCount += 1; + } + if (stuData.getShopHouseYear() == null || !stuData.getShopHouseYear().equals(rightData.getShopHouseYear())) { + wrongCount += 1; + } + if (stuData.getHouseAllMoney() == null || !stuData.getHouseAllMoney().equals(rightData.getHouseAllMoney())) { + wrongCount += 1; + } + if (stuData.getShopCarYear() == null || !stuData.getShopCarYear().equals(rightData.getShopCarYear())) { + wrongCount += 1; + } + if (stuData.getAnalysis() == null || !stuData.getAnalysis().equals(rightData.getAnalysis())) { + wrongCount += 1; + } + } + return wrongCount; + } + private int getCaseHeritageWrongCount(int wrongCount, CaseHeritageWithBLOBs stuData) { CaseHeritageExample example = new CaseHeritageExample(); example.createCriteria().andCaseidEqualTo(stuData.getCaseid()).andIsAnswerEqualTo("题目答案"); @@ -1737,8 +2011,8 @@ public class CaseServiceImpl implements CaseService { map.put(allType, caseInsurancePlans); } if (allType.equals("投资规划")) { - // todo 表暂时没有 - return null; + CaseInvestmentPlanDto caseInvestmentPlanDto = getCaseInvestmentPlanDto(caseID, userId, isAnswer); + map.put(allType, caseInvestmentPlanDto); } if (allType.equals("税务筹划")) { CaseTaxPlan caseTaxPlans = getCaseTaxPlans(caseID, userId, isAnswer); @@ -1788,8 +2062,7 @@ public class CaseServiceImpl implements CaseService { return new ResultEntity<>(getCaseInsurancePlans(caseID, userId, isAnswer)); } if (type.equals("投资规划")) { - // todo 表暂时没有 - return null; + return new ResultEntity<>(getCaseInvestmentPlanDto(caseID, userId, isAnswer)); } if (type.equals("税务筹划")) { return new ResultEntity<>(getCaseTaxPlans(caseID, userId, isAnswer)); @@ -1803,6 +2076,80 @@ public class CaseServiceImpl implements CaseService { return null; } + private CaseInvestmentPlanDto getCaseInvestmentPlanDto(String caseID, String userId, String isAnswer) { + //根据userid查出主对象 + CaseInvestmentPlanExample example = new CaseInvestmentPlanExample(); + CaseInvestmentPlanExample.Criteria criteria = example.createCriteria().andCaseIdEqualTo(caseID).andIsAnswerEqualTo(isAnswer); + if (StringUtils.isNotBlank(userId)) { + criteria.andUserIdEqualTo(userId); + } else { + criteria.andUserIdIsNull(); + } + List<CaseInvestmentPlan> caseInvestmentPlans = investmentPlanMapper.selectByExampleWithBLOBs(example); + if (caseInvestmentPlans.isEmpty()) { + return null; + } + + CaseInvestmentPlanDto dto = new CaseInvestmentPlanDto();//返回主对象 包含 CaseInvestmentPlan List<CaseInvestmentPlanSelectDto> + List<CaseInvestmentPlanSelectDto> caseInvestmentPlanSelectDtos = new ArrayList<>(); //包含CaseInvestmentPlanSelect 和其余五张表的list + + CaseInvestmentPlan caseInvestmentPlan = caseInvestmentPlans.get(0); + dto.setInvestmentPlan(caseInvestmentPlan); + + //老师或管理员 直接返回 + if (StringUtils.isNotBlank(userId)) { + return dto; + } + + String caseInvestmentPlanId = caseInvestmentPlan.getCaseInvestmentPlanId(); + CaseInvestmentPlanSelectExample investmentPlanSelectExample = new CaseInvestmentPlanSelectExample(); + investmentPlanSelectExample.createCriteria().andCaseInvestmentPlanIdEqualTo(caseInvestmentPlanId); + List<CaseInvestmentPlanSelect> investmentPlanSelects = caseInvestmentPlanSelectMapper.selectByExampleWithBLOBs(investmentPlanSelectExample); + + if (investmentPlanSelects != null && !investmentPlanSelects.isEmpty()) { + for (CaseInvestmentPlanSelect investmentPlanSelect : investmentPlanSelects) { + CaseInvestmentPlanSelectDto caseInvestmentPlanSelectDto =new CaseInvestmentPlanSelectDto(); + caseInvestmentPlanSelectDto.setCaseInvestmentPlanSelect(investmentPlanSelect); + String productSelectId = investmentPlanSelect.getProductSelectId(); + + //set剩余五张表 + //投资规划-银行储蓄信息表 + CaseInvestmentPlanBankProductInfoExample investmentPlanBankProductInfoExample =new CaseInvestmentPlanBankProductInfoExample(); + investmentPlanBankProductInfoExample.createCriteria().andProductSelectIdEqualTo(productSelectId); + List<CaseInvestmentPlanBankProductInfo> caseInvestmentPlanBankProductInfos = investmentPlanBankProductInfoMapper.selectByExample(investmentPlanBankProductInfoExample); + caseInvestmentPlanSelectDto.setInvestmentPlanBankProductInfos(caseInvestmentPlanBankProductInfos); + + //投资规划-基金产品信息表 + CaseInvestmentPlanFundProductInfoExample investmentPlanFundProductInfoExample =new CaseInvestmentPlanFundProductInfoExample(); + investmentPlanFundProductInfoExample.createCriteria().andProductSelectIdEqualTo(productSelectId); + List<CaseInvestmentPlanFundProductInfo> caseInvestmentPlanFundProductInfos = investmentPlanFundProductInfoMapper.selectByExample(investmentPlanFundProductInfoExample); + caseInvestmentPlanSelectDto.setInvestmentPlanFundProductInfos(caseInvestmentPlanFundProductInfos); + + //投资规划-保险产品信息表 + CaseInvestmentPlanInsuranceProductInfoExample investmentPlanInsuranceProductInfoExample =new CaseInvestmentPlanInsuranceProductInfoExample(); + investmentPlanInsuranceProductInfoExample.createCriteria().andProductSelectIdEqualTo(productSelectId); + List<CaseInvestmentPlanInsuranceProductInfo> caseInvestmentPlanInsuranceProductInfos = investmentPlanInsuranceProductInfoMapper.selectByExample(investmentPlanInsuranceProductInfoExample); + caseInvestmentPlanSelectDto.setInvestmentPlanInsuranceProductInfos(caseInvestmentPlanInsuranceProductInfos); + + //投资规划-P2P产品信息表 + CaseInvestmentPlanP2PProductInfoExample caseInvestmentPlanP2PProductInfoExample =new CaseInvestmentPlanP2PProductInfoExample(); + caseInvestmentPlanP2PProductInfoExample.createCriteria().andProductSelectIdEqualTo(productSelectId); + List<CaseInvestmentPlanP2PProductInfo> caseInvestmentPlanP2PProductInfos = investmentPlanP2PProductInfoMapper.selectByExample(caseInvestmentPlanP2PProductInfoExample); + caseInvestmentPlanSelectDto.setInvestmentPlanP2PProductInfos(caseInvestmentPlanP2PProductInfos); + + //投资规划-实物黄金信息表 + CaseInvestmentPlanRealGoldProductInfoExample caseInvestmentPlanRealGoldProductInfoExample =new CaseInvestmentPlanRealGoldProductInfoExample(); + caseInvestmentPlanRealGoldProductInfoExample.createCriteria().andProductSelectIdEqualTo(productSelectId); + List<CaseInvestmentPlanRealGoldProductInfo> caseInvestmentPlanRealGoldProductInfos = investmentPlanRealGoldProductInfoMapper.selectByExample(caseInvestmentPlanRealGoldProductInfoExample); + caseInvestmentPlanSelectDto.setInvestmentPlanRealGoldProductInfos(caseInvestmentPlanRealGoldProductInfos); + + caseInvestmentPlanSelectDtos.add(caseInvestmentPlanSelectDto); + } + } + dto.setCaseInvestmentPlanSelectDtos(caseInvestmentPlanSelectDtos); + return dto; + } + private CaseHeritageWithBLOBs getResultEntity(String caseID, String userId, String isAnswer) { CaseHeritageExample example = new CaseHeritageExample(); CaseHeritageExample.Criteria criteria = example.createCriteria().andCaseidEqualTo(caseID).andIsAnswerEqualTo(isAnswer);