修改测试
This commit is contained in:
parent
d23a9536f3
commit
3717d59286
@ -752,6 +752,8 @@ public class ResultRecordController extends AbstractController {
|
||||
Map<Long, ResultDetail> mapDetails =
|
||||
resultDetails.stream().collect(Collectors.toMap(ResultDetail::getId, Function.identity(), (e, r) -> e));
|
||||
|
||||
List<ResultDetail> updateResultDetails = new ArrayList<>();
|
||||
|
||||
//获取当前绩效的节点
|
||||
boolean isSetKeyResult = false;
|
||||
List<FlowRecord> 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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -50,4 +50,6 @@ public interface ResultDetailMapper extends BaseMapper<ResultDetail> {
|
||||
int deleteResultDetailByRecordId(@Param("recordId") Long recordId);
|
||||
|
||||
ResultDetail selectNotNoticeResultDetailByBackId(@Param("backId") Long backId);
|
||||
|
||||
List<ResultDetail> selectNotNoticeResultDetailByRecordId(@Param("recordId") Long recordId);
|
||||
}
|
||||
@ -74,4 +74,6 @@ public interface ResultDetailService extends IService<ResultDetail> {
|
||||
int deleteResultDetailByRecordId(Long recordId);
|
||||
|
||||
ResultDetail selectNotNoticeResultDetailByBackId(Long id);
|
||||
|
||||
List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId);
|
||||
}
|
||||
@ -350,4 +350,8 @@ public class ResultDetailServiceImpl extends ServiceImpl<ResultDetailMapper, Res
|
||||
return resultDetailMapper.selectNotNoticeResultDetailByBackId(backId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId){
|
||||
return resultDetailMapper.selectNotNoticeResultDetailByRecordId(recordId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,5 +207,9 @@
|
||||
select * from lz_result_detail where back_id = #{backId} and is_back = 2 order by priority asc
|
||||
</select>
|
||||
|
||||
<select id="selectNotNoticeResultDetailByRecordId" resultType="com.lz.modules.sys.entity.app.ResultDetail">
|
||||
select * from lz_result_detail where record_id = #{recordId} and is_back = 2 order by priority asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user