From 3717d59286e14ee9b6fea6603ed068d1e55939f7 Mon Sep 17 00:00:00 2001 From: wulin Date: Mon, 7 Dec 2020 14:51:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResultRecordController.java | 148 ++++++++++-------- .../sys/dao/app/ResultDetailMapper.java | 2 + .../sys/service/app/ResultDetailService.java | 2 + .../app/impl/ResultDetailServiceImpl.java | 4 + .../mapper/app/ResultDetailMapper.xml | 4 + 5 files changed, 99 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java index 6eae6c67..e4d4ab94 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -752,6 +752,8 @@ public class ResultRecordController extends AbstractController { Map mapDetails = resultDetails.stream().collect(Collectors.toMap(ResultDetail::getId, Function.identity(), (e, r) -> e)); + List updateResultDetails = new ArrayList<>(); + //获取当前绩效的节点 boolean isSetKeyResult = false; List flowRecords = flowRecordService.selectFlowRecordByRecordIdStatus(dto.getId(), 2); @@ -762,8 +764,7 @@ public class ResultRecordController extends AbstractController { } } - String commandValue = ""; - int commandIndex = 1; + for (ResultRecortModelDto model:dto.getRecortModelDtos() ) { int index = 0; @@ -775,79 +776,43 @@ public class ResultRecordController extends AbstractController { ) {//排序 ResultDetail resultDetail = new ResultDetail(); BeanUtils.copyProperties(detailDto, resultDetail); - ResultDetail resultDetail1 = null; - if(!isSetKeyResult && resultDetail.getId() != null && mapDetails.containsKey(resultDetail.getId())){ - //这里判断是否有更新,或者删除 - resultDetail1 = mapDetails.get(resultDetail.getId()); - boolean isUp = false; - if(resultDetail.getIsDelete().intValue() == 1){//被删除了 - isUp = true; - }else{ - if(!resultDetail.getTarget().equals(resultDetail1.getTarget())){ - //打上标识 - isUp = true; - } - if(!resultDetail.getKeyResult().equals(resultDetail1.getKeyResult())){ - //打上标识 - isUp = true; - } - if(!resultDetail.getCheckWeight().equals(resultDetail1.getCheckWeight())){ - //打上标识 - isUp = true; - } - } - - if(isUp){ - resultDetail1.setId(null); - resultDetail1.setIsBack(2); - resultDetail1.setBackId(resultDetail.getId()); - inserts.add(resultDetail1); - } - }else{ - //查询本detail是否编辑过 - resultDetail1 = resultDetailService.selectNotNoticeResultDetailByBackId(resultDetail.getId()); - if(resultDetail1 != null){ - updates.add(resultDetail1); - } - - } - if(dto.getCommentId() != null && dto.getCommentId().intValue() > 0 && resultDetail1 != null){ - //有评论id - if(resultDetail1.getIsDelete().intValue() == 1){ - commandValue += (commandIndex + ":(删除)" + resultDetail1.getTarget() + "\r\n"); - commandIndex++; - resultDetail1.setIsBack(1); - }else{ + if(resultDetail.getIsDelete().intValue() == 1){//被删除了 + resultDetail.setIsBack(2); + resultDetail.setBackId(resultDetail.getId()); + updateResultDetails.add(resultDetail); + }else { + if(!isSetKeyResult && resultDetail.getId() != null && mapDetails.containsKey(resultDetail.getId())){ + //这里判断是否有更新,或者删除 boolean isUp = false; + ResultDetail resultDetail1 = null; + resultDetail1 = mapDetails.get(resultDetail.getId()); + + if(!resultDetail.getTarget().equals(resultDetail1.getTarget())){ //打上标识 - commandValue += ("(修改) 名称:" + - resultDetail1.getTarget()+ " 为:" + resultDetail.getTarget() + "\r\n"); isUp = true; - } if(!resultDetail.getKeyResult().equals(resultDetail1.getKeyResult())){ //打上标识 - commandValue += ("(修改) 考核标准:" + - resultDetail1.getKeyResult() + " 为:" + resultDetail.getTarget() + "\r\n"); isUp = true; } + if(!resultDetail.getCheckWeight().equals(resultDetail1.getCheckWeight())){ //打上标识 - commandValue += ("(修改) 权重:" + - resultDetail1.getCheckWeight().multiply(new BigDecimal(100)).intValue() + "% 为:" - + resultDetail.getCheckWeight().multiply(new BigDecimal(100)).intValue() + - "%\r\n"); isUp = true; } if(isUp){ - commandValue = commandValue + ":" + commandValue; - commandIndex++; - resultDetail1.setIsBack(1); + resultDetail1.setId(null); + resultDetail1.setIsBack(2); + resultDetail1.setBackId(resultDetail.getId()); + inserts.add(resultDetail1); } } + + } + resultDetail.setPriority(index); index++; @@ -908,14 +873,75 @@ public class ResultRecordController extends AbstractController { resultRecordService.updateResultRecordById(resultRecord); - if(dto.getCommentId() != null && dto.getCommentId().intValue() > 0 && commandValue.length() > 0){ + if(dto.getCommentId() != null && dto.getCommentId().intValue() > 0){ //修改评论信息 - resultCommentService.updateResultCommentCommentById(dto.getCommentId(), commandValue); + updateResultDetails.addAll(resultDetailService.selectNotNoticeResultDetailByRecordId(dto.getId())) ; + log.info("可能需要写入评论的内容条数{}", updateResultDetails.size()); + //去重 + mapDetails = updateResultDetails.stream().collect(Collectors.toMap(ResultDetail::getId, Function.identity(), (e, r) -> e)); + updateResultDetails = mapDetails.values().stream().collect(Collectors.toList()); + log.info("实际需要写入评论的内容条数{}", updateResultDetails.size()); + if(updateResultDetails.size() > 0){ + updates.addAll(inserts); + + mapDetails = updates.stream().collect(Collectors.toMap(ResultDetail::getId, Function.identity(), (e, r) -> e)); + + String commandValue = ""; + int commandIndex = 1; + for (ResultDetail resultDetail1:updateResultDetails + ) { + log.info("修改的对象为{}", resultDetail1); + if(resultDetail1.getIsDelete().intValue() == 1){ + commandValue += (commandIndex + ":(删除)" + resultDetail1.getTarget() + "\r\n"); + commandIndex++; + resultDetail1.setIsBack(1); + }else{ + + ResultDetail resultDetail = mapDetails.get(resultDetail1.getBackId()); + if(resultDetail != null){ + log.info("修改后的对象为{}", resultDetail1); + boolean isUp = false; + if(!resultDetail.getTarget().equals(resultDetail1.getTarget())){ + //打上标识 + commandValue += ("(修改) 名称:" + + resultDetail1.getTarget()+ " 为:" + resultDetail.getTarget() + "\r\n"); + isUp = true; + + } + if(!resultDetail.getKeyResult().equals(resultDetail1.getKeyResult())){ + //打上标识 + commandValue += ("(修改) 考核标准:" + + resultDetail1.getKeyResult() + " 为:" + resultDetail.getTarget() + "\r\n"); + isUp = true; + } + if(!resultDetail.getCheckWeight().equals(resultDetail1.getCheckWeight())){ + //打上标识 + commandValue += ("(修改) 权重:" + + resultDetail1.getCheckWeight().multiply(new BigDecimal(100)).intValue() + "% 为:" + + resultDetail.getCheckWeight().multiply(new BigDecimal(100)).intValue() + + "%\r\n"); + isUp = true; + } + if(isUp){ + commandValue = commandValue + ":" + commandValue; + commandIndex++; + resultDetail1.setIsBack(1); + } + } + + } + } + if(commandValue.length() > 0){ + log.info("需要写入评论,具体呢容为{}", commandValue); + resultDetailService.updateBatchById(updateResultDetails); + resultCommentService.updateResultCommentCommentById(dto.getCommentId(), commandValue); + } + } + + } return R.ok(); - - } /** diff --git a/src/main/java/com/lz/modules/sys/dao/app/ResultDetailMapper.java b/src/main/java/com/lz/modules/sys/dao/app/ResultDetailMapper.java index cf20b5a9..a99e12d1 100644 --- a/src/main/java/com/lz/modules/sys/dao/app/ResultDetailMapper.java +++ b/src/main/java/com/lz/modules/sys/dao/app/ResultDetailMapper.java @@ -50,4 +50,6 @@ public interface ResultDetailMapper extends BaseMapper { int deleteResultDetailByRecordId(@Param("recordId") Long recordId); ResultDetail selectNotNoticeResultDetailByBackId(@Param("backId") Long backId); + + List selectNotNoticeResultDetailByRecordId(@Param("recordId") Long recordId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/ResultDetailService.java b/src/main/java/com/lz/modules/sys/service/app/ResultDetailService.java index c7f5d852..8fe6ad2b 100644 --- a/src/main/java/com/lz/modules/sys/service/app/ResultDetailService.java +++ b/src/main/java/com/lz/modules/sys/service/app/ResultDetailService.java @@ -74,4 +74,6 @@ public interface ResultDetailService extends IService { int deleteResultDetailByRecordId(Long recordId); ResultDetail selectNotNoticeResultDetailByBackId(Long id); + + List selectNotNoticeResultDetailByRecordId(Long recordId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/sys/service/app/impl/ResultDetailServiceImpl.java b/src/main/java/com/lz/modules/sys/service/app/impl/ResultDetailServiceImpl.java index 075b03b9..83c04159 100644 --- a/src/main/java/com/lz/modules/sys/service/app/impl/ResultDetailServiceImpl.java +++ b/src/main/java/com/lz/modules/sys/service/app/impl/ResultDetailServiceImpl.java @@ -350,4 +350,8 @@ public class ResultDetailServiceImpl extends ServiceImpl selectNotNoticeResultDetailByRecordId(Long recordId){ + return resultDetailMapper.selectNotNoticeResultDetailByRecordId(recordId); + } } diff --git a/src/main/resources/mapper/app/ResultDetailMapper.xml b/src/main/resources/mapper/app/ResultDetailMapper.xml index a24c4744..50f504c4 100644 --- a/src/main/resources/mapper/app/ResultDetailMapper.xml +++ b/src/main/resources/mapper/app/ResultDetailMapper.xml @@ -207,5 +207,9 @@ select * from lz_result_detail where back_id = #{backId} and is_back = 2 order by priority asc + +