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 25a2ec5..9799c40 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 @@ -855,38 +855,58 @@ public class CaseServiceImpl implements CaseService { if (type.equals("财产分配")) { CaseDistributionOfPropertyFamilyDto dto = gson.fromJson(json, CaseDistributionOfPropertyFamilyDto.class); - dto.setCaseDistributionOfPropertyId(IdUtil.randomUUID()); if (operator.equals("master")) { dto.setCaseid(IdUtil.randomUUID()); } CaseDistributionOfPropertyWithBLOBs caseDistributionOfPropertyWithBLOBs = new CaseDistributionOfPropertyWithBLOBs(); - + BeanUtils.copyProperties(dto, caseDistributionOfPropertyWithBLOBs); + //id为空 新增 if (StringUtils.isBlank(dto.getCaseDistributionOfPropertyId())) { - BeanUtils.copyProperties(dto, caseDistributionOfPropertyWithBLOBs); + dto.setCaseDistributionOfPropertyId(IdUtil.randomUUID()); caseDistributionOfPropertyWithBLOBs.setCaseDistributionOfPropertyId(IdUtil.randomUUID()); caseDistributionOfPropertyMapper.insert(caseDistributionOfPropertyWithBLOBs); - - //需要多存一张记录表,多条数据 - if (operator.equals("stu")) { - List recordsList = dto.getCaseDistributionOfPropertyFamilyRecordsList(); - List addList = dto.getCaseDistributionOfPropertyFamilyRecordsList(); - for (CaseDistributionOfPropertyFamilyRecords caseDistributionOfPropertyFamilyRecords : recordsList) { + } + //需要多存一张记录表,多条数据 + if (operator.equals("stu")) { + List recordsList = dto.getCaseDistributionOfPropertyFamilyRecordsList(); + List addList = new ArrayList<>(); + for (CaseDistributionOfPropertyFamilyRecords caseDistributionOfPropertyFamilyRecords : recordsList) { + if (StringUtils.isBlank(caseDistributionOfPropertyFamilyRecords.getCaseDistributionOfPropertyFamilyRecordsId())) { caseDistributionOfPropertyFamilyRecords.setCaseDistributionOfPropertyFamilyRecordsId(IdUtil.randomUUID()); caseDistributionOfPropertyFamilyRecords.setCaseDistributionOfPropertyId(caseDistributionOfPropertyWithBLOBs.getCaseDistributionOfPropertyId()); caseDistributionOfPropertyFamilyRecords.setCreateTime(new Date()); addList.add(caseDistributionOfPropertyFamilyRecords); } + } + if (!addList.isEmpty()) { caseDistributionOfPropertyFamilyRecordsMapper.batchInsert(addList); + return new ResultEntity(HttpStatus.OK, "新增成功!"); } - return new ResultEntity(HttpStatus.OK, "新增成功!"); } //学生提交编辑 if (operator.equals("stu")) { String userId = dto.getUserId(); ResultEntity result = getHttpStatusResultEntity(dto.getCaseid(), userId); if (result != null) return result; - } //老师和学生编辑都走这里 + } + + //老师和学生编辑都走这里 caseDistributionOfPropertyMapper.updateByPrimaryKeySelective(caseDistributionOfPropertyWithBLOBs); + + List recordsList = dto.getCaseDistributionOfPropertyFamilyRecordsList(); + if (!recordsList.isEmpty()) { + for (CaseDistributionOfPropertyFamilyRecords caseDistributionOfPropertyFamilyRecords : recordsList) { + //先删掉老数据 + CaseDistributionOfPropertyFamilyRecordsExample example = new CaseDistributionOfPropertyFamilyRecordsExample(); + example.createCriteria().andCaseidEqualTo(caseDistributionOfPropertyFamilyRecords.getCaseid()).andUserIdEqualTo(caseDistributionOfPropertyFamilyRecords.getUserId()) + .andCaseDistributionOfPropertyIdEqualTo(caseDistributionOfPropertyFamilyRecords.getCaseDistributionOfPropertyId()); + List list = caseDistributionOfPropertyFamilyRecordsMapper.selectByExample(example); + if (!list.isEmpty()) { + caseDistributionOfPropertyFamilyRecordsMapper.deleteByPrimaryKey(list.get(0).getCaseDistributionOfPropertyFamilyRecordsId()); + } + caseDistributionOfPropertyFamilyRecordsMapper.insert(caseDistributionOfPropertyFamilyRecords); + } + } return new ResultEntity<>(HttpStatus.OK, "编辑成功!"); } @@ -1045,7 +1065,7 @@ public class CaseServiceImpl implements CaseService { } } } - return new ResultEntity(HttpStatus.OK,"操作成功"); + return new ResultEntity(HttpStatus.OK, "操作成功"); } // CaseInfo newCase = new CaseInfo(); @@ -1182,23 +1202,23 @@ public class CaseServiceImpl implements CaseService { // return new ResultEntity(HttpStatus.OK, "操作成功!"); // } - - private ResultEntity teaOrAdminUpdateOrInsertInvestmentPlan(CaseInvestmentPlanDto - caseInvestmentPlanDto) { - if (caseInvestmentPlanDto.getInvestmentPlan() == null) { - return null; - } - CaseInvestmentPlan investmentPlan = caseInvestmentPlanDto.getInvestmentPlan(); - - if (StringUtils.isBlank(investmentPlan.getCaseInvestmentPlanId())) { //主键为空为新增 - investmentPlan.setCaseInvestmentPlanId(IdUtil.randomUUID()); - investmentPlanMapper.insert(investmentPlan); - return new ResultEntity(HttpStatus.OK, "新增成功!"); - } else { - investmentPlanMapper.updateByPrimaryKeySelective(investmentPlan); - return new ResultEntity(HttpStatus.OK, "编辑成功!"); - } - } +// +// private ResultEntity teaOrAdminUpdateOrInsertInvestmentPlan(CaseInvestmentPlanDto +// caseInvestmentPlanDto) { +// if (caseInvestmentPlanDto.getInvestmentPlan() == null) { +// return null; +// } +// CaseInvestmentPlan investmentPlan = caseInvestmentPlanDto.getInvestmentPlan(); +// +// if (StringUtils.isBlank(investmentPlan.getCaseInvestmentPlanId())) { //主键为空为新增 +// investmentPlan.setCaseInvestmentPlanId(IdUtil.randomUUID()); +// investmentPlanMapper.insert(investmentPlan); +// return new ResultEntity(HttpStatus.OK, "新增成功!"); +// } else { +// investmentPlanMapper.updateByPrimaryKeySelective(investmentPlan); +// return new ResultEntity(HttpStatus.OK, "编辑成功!"); +// } +// } @Override //重新实训 先把数据库的数据替换成本次数据,再设置实训表中的数据,没分数则加上,有则不改。2、算分只算老师端设置的考核点 public void commitTraining(String json, String type, String trainingId) { @@ -2473,6 +2493,10 @@ public class CaseServiceImpl implements CaseService { CaseDistributionOfPropertyFamilyDto objectResultEntity = getObjectResultEntity(caseID, userId, isAnswer); map.put(allType, objectResultEntity); } + if (allType.equals("财产传承")) { + CaseHeritageWithBLOBs resultEntity = getResultEntity(caseID, userId, isAnswer); + map.put(allType, resultEntity); + } } return new ResultEntity<>(map); } diff --git a/src/main/resources/mapper/CaseDistributionOfPropertyFamilyRecordsMapper.xml b/src/main/resources/mapper/CaseDistributionOfPropertyFamilyRecordsMapper.xml index 99e61cd..77a2cd2 100644 --- a/src/main/resources/mapper/CaseDistributionOfPropertyFamilyRecordsMapper.xml +++ b/src/main/resources/mapper/CaseDistributionOfPropertyFamilyRecordsMapper.xml @@ -299,7 +299,7 @@ (#{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.create_time,jdbcType=TIMESTAMP}, + #{item.customerRelationship,jdbcType=VARCHAR}, #{item.annualIncome,jdbcType=DECIMAL}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.userId,jdbcType=VARCHAR}, #{item.isAnswer,jdbcType=VARCHAR})