This commit is contained in:
杜建超 2020-12-07 17:03:40 +08:00
commit c79aa12a08
10 changed files with 159 additions and 33 deletions

View File

@ -125,7 +125,6 @@ public class ResultRecordController extends AbstractController {
@Autowired
private ResourceService resourceService;
@Autowired
private ChartResultService chartResultService;
@ -754,6 +753,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);
@ -764,6 +765,7 @@ public class ResultRecordController extends AbstractController {
}
}
for (ResultRecortModelDto model:dto.getRecortModelDtos()
) {
int index = 0;
@ -775,37 +777,45 @@ public class ResultRecordController extends AbstractController {
) {//排序
ResultDetail resultDetail = new ResultDetail();
BeanUtils.copyProperties(detailDto, resultDetail);
if(!isSetKeyResult && resultDetail.getId() != null && mapDetails.containsKey(resultDetail.getId())){
//这里判断是否有更新或者删除
ResultDetail resultDetail1 = mapDetails.get(resultDetail.getId());
boolean isUp = false;
if(!resultDetail.getTarget().equals(resultDetail1.getTarget())){
//打上标识
isUp = true;
if(resultDetail.getIsDelete() != null && resultDetail.getIsDelete().intValue() == 1){//被删除了
resultDetail.setIsBack(2);
resultDetail.setBackId(resultDetail.getId());
updateResultDetails.add(resultDetail);
}else if(resultDetail.getId() == null){
resultDetail.setIsBack(3);//新增
}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())){
//打上标识
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);
}
}
if(!resultDetail.getKeyResult().equals(resultDetail1.getKeyResult())){
//打上标识
isUp = true;
resultDetail1.setKeyResult("<s>" + resultDetail1.getKeyResult() + "</s>");
}
if(resultDetail.getIsDelete().intValue() == 1){//被删除了
resultDetail.setIsDelete(0);
isUp = true;
}
if(!resultDetail.getCheckWeight().equals(resultDetail1.getCheckWeight())){
//打上标识
isUp = true;
}
if(isUp){
resultDetail1.setId(null);
resultDetail1.setIsBack(1);
resultDetail1.setTarget("<s>" + resultDetail1.getTarget() + "</s>");
resultDetail1.setBackId(resultDetail.getId());
inserts.add(resultDetail1);
}
}
resultDetail.setPriority(index);
index++;
@ -866,9 +876,83 @@ public class ResultRecordController extends AbstractController {
resultRecordService.updateResultRecordById(resultRecord);
if(dto.getCommentId() != null && dto.getCommentId().intValue() > 0){
//修改评论信息
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() + "\n");
commandIndex++;
resultDetail1.setIsBack(1);
}else if(resultDetail1.getIsBack().intValue() == 3){
commandValue += (commandIndex + "(新增) 指标" + resultDetail1.getTarget() + "\n");
commandIndex++;
resultDetail1.setIsBack(0);
}else{
ResultDetail resultDetail = mapDetails.get(resultDetail1.getBackId());
if(resultDetail != null){
log.info("修改后的对象为{}", resultDetail1);
boolean isUp = false;
String value = "";
String heard = "";
if(!resultDetail.getTarget().equals(resultDetail1.getTarget())){
//打上标识
value += ("(修改) 名称:" +
resultDetail1.getTarget()+ " \n(为)\n" + resultDetail.getTarget() + "\n");
isUp = true;
}else{
heard = "指标:" + resultDetail1.getTarget() + "\n";
}
if(!resultDetail.getKeyResult().equals(resultDetail1.getKeyResult())){
//打上标识
value += ("(修改) 考核标准:" +
resultDetail1.getKeyResult() + "\n(为)\n" + resultDetail.getKeyResult() + "\n");
isUp = true;
}
if(!resultDetail.getCheckWeight().equals(resultDetail1.getCheckWeight())){
//打上标识
value += ("(修改) 权重:" +
resultDetail1.getCheckWeight().multiply(new BigDecimal(100)).intValue() + "%\n(为)\n"
+ resultDetail.getCheckWeight().multiply(new BigDecimal(100)).intValue() +
"%\n");
isUp = true;
}
if(isUp){
commandValue += (commandIndex + "" + heard + value);
commandIndex++;
resultDetail1.setIsBack(1);
}
}
}
}
if(commandValue.length() > 0){
log.info("需要写入评论,具体呢容为{}", commandValue);
resultDetailService.updateBatchById(updateResultDetails);
resultCommentService.updateResultCommentCommentById(dto.getCommentId(), commandValue);
}
}
}
return R.ok();
}
/**

View File

@ -34,7 +34,7 @@ public class ResultRecordDetailDto {
@ApiModelProperty(value = "备注", name = "remark")
private String remark;
@ApiModelProperty(value = "业绩评论id", name = "commandId")
private Long commandId;
private Long commentId;
//员工id
@ApiModelProperty(value = "员工id", name = "staffId")
private Long staffId;

View File

@ -38,4 +38,5 @@ public interface ResultCommentMapper extends BaseMapper<ResultComment> {
ResultComment selectLastComment(@Param("recordId") Long recordId);
int updateResultCommentCommentById(@Param("commandId") Long commandId, @Param("commandValue") String commandValue);
}

View File

@ -48,4 +48,8 @@ public interface ResultDetailMapper extends BaseMapper<ResultDetail> {
List<ResultDetailDto> selectDtosByRecordId(@Param("recordResultId") Long id, @Param("modelId") Long modelId);
int deleteResultDetailByRecordId(@Param("recordId") Long recordId);
ResultDetail selectNotNoticeResultDetailByBackId(@Param("backId") Long backId);
List<ResultDetail> selectNotNoticeResultDetailByRecordId(@Param("recordId") Long recordId);
}

View File

@ -40,4 +40,6 @@ public interface ResultCommentService extends IService<ResultComment> {
void addOrUpdateComment(ResultRecordReq req, Long userId, int status , FlowRecord lastUsedFlowRecord);
int updateResultCommentCommentById(Long commandId, String commandValue);
}

View File

@ -72,4 +72,8 @@ public interface ResultDetailService extends IService<ResultDetail> {
List<ResultDetailDto> selectDtosByRecordId(Long id, Long modelId);
int deleteResultDetailByRecordId(Long recordId);
ResultDetail selectNotNoticeResultDetailByBackId(Long id);
List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId);
}

View File

@ -113,4 +113,9 @@ public class ResultCommentServiceImpl extends ServiceImpl<ResultCommentMapper, R
}
}
@Override
public int updateResultCommentCommentById(Long commandId, String commandValue){
return resultCommentMapper.updateResultCommentCommentById(commandId, commandValue);
}
}

View File

@ -345,4 +345,13 @@ public class ResultDetailServiceImpl extends ServiceImpl<ResultDetailMapper, Res
return resultDetailMapper.deleteResultDetailByRecordId(recordId);
}
@Override
public ResultDetail selectNotNoticeResultDetailByBackId(Long backId){
return resultDetailMapper.selectNotNoticeResultDetailByBackId(backId);
}
@Override
public List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId){
return resultDetailMapper.selectNotNoticeResultDetailByRecordId(recordId);
}
}

View File

@ -109,6 +109,15 @@
select * from lz_result_comment where record_id=#{recordId} and is_delete = 0 order by id desc limit 1
</select>
<update id="updateResultCommentCommentById" parameterType="ResultComment" >
update
lz_result_comment
set
opt_desc = '修改了目标',
comment = #{commandValue}
,gmt_modified = now()
where id = #{commandId}
</update>

View File

@ -147,7 +147,7 @@
<select id="selectByRecordId" resultType="com.lz.modules.sys.entity.app.ResultDetail">
select * from lz_result_detail where record_id=#{recordResultId} and is_delete = 0 order by type asc ,priority desc
select * from lz_result_detail where record_id=#{recordResultId} and is_delete = 0 and is_back=0 order by type asc ,priority desc
</select>
<select id="selectByRecordIdType" resultType="com.lz.modules.sys.entity.app.ResultDetail">
@ -196,12 +196,20 @@
</insert>
<select id="selectDtosByRecordId" resultType="com.lz.modules.flow.model.ResultDetailDto">
select * from lz_result_detail where record_id=#{recordResultId} and model_id = #{modelId} and is_delete = 0 order by priority asc
select * from lz_result_detail where record_id=#{recordResultId} and model_id = #{modelId} and is_delete = 0 and (is_back = 0 or is_back = 3) order by priority asc
</select>
<update id="deleteResultDetailByRecordId" parameterType="java.lang.Long">
update lz_result_detail set is_delete = 1, gmt_modified = now() where record_id=#{recordId} and is_delete = 0
</update>
<select id="selectNotNoticeResultDetailByBackId" resultType="com.lz.modules.sys.entity.app.ResultDetail">
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 or is_back = 3) order by priority asc
</select>
</mapper>