解决冲突

This commit is contained in:
wulin 2020-12-09 14:26:33 +08:00
commit de90f8b10a
9 changed files with 189 additions and 35 deletions

View File

@ -1,9 +1,8 @@
package com.lz.modules.performance.controller; package com.lz.modules.performance.controller;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.performance.req.ResultUpdateTakReq; import com.lz.modules.performance.req.ResultUpdateTaskReq;
import com.lz.modules.performance.res.ResultTaskDetailRes; import com.lz.modules.performance.res.ResultTaskDetailRes;
import com.lz.modules.performance.res.TaskListRes;
import com.lz.modules.performance.service.ResultTaskService; import com.lz.modules.performance.service.ResultTaskService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -40,7 +39,7 @@ public class ResultTaskController {
@PostMapping("/result/updateTask") @PostMapping("/result/updateTask")
@ApiOperation("任务修改") @ApiOperation("任务修改")
@ApiResponses({@ApiResponse(code = 200,message = "成功")}) @ApiResponses({@ApiResponse(code = 200,message = "成功")})
public R updateTask(ResultUpdateTakReq req){ public R updateTask(ResultUpdateTaskReq req){
int i = resultTaskService.saveOrUpdateResultTask(req); int i = resultTaskService.saveOrUpdateResultTask(req);
if(i>0){ if(i>0){
return R.ok(); return R.ok();

View File

@ -36,4 +36,5 @@ public interface ResultTaskMapper extends BaseMapper<ResultTask> {
List<ResultTaskDto> selectResultTasksByDetailId(Long detailId); List<ResultTaskDto> selectResultTasksByDetailId(Long detailId);
} }

View File

@ -12,7 +12,7 @@ import java.util.Date;
* <p> * <p>
* </p>*任务进度更新表 * </p>*任务进度更新表
* @author quyixiao * @author quyixiao
* @since 2020-12-08 * @since 2020-12-09
*/ */
@Data @Data
@ -43,6 +43,12 @@ public class TaskProcessRecord implements java.io.Serializable {
//1修改名称2修改进度 3名称和进度都修改 //1修改名称2修改进度 3名称和进度都修改
@ApiModelProperty(value = "1修改名称2修改进度 3名称和进度都修改", name = "type") @ApiModelProperty(value = "1修改名称2修改进度 3名称和进度都修改", name = "type")
private Integer type; private Integer type;
//任务 result_task得id
@ApiModelProperty(value = "任务 result_task得id ", name = "taskId")
private Long taskId;
//任务名称
@ApiModelProperty(value = "任务名称", name = "name")
private String name;
/** /**
* *
* @return * @return
@ -163,6 +169,36 @@ public class TaskProcessRecord implements java.io.Serializable {
this.type = type; this.type = type;
} }
/**
* 任务 result_task得id
* @return
*/
public Long getTaskId() {
return taskId;
}
/**
* 任务 result_task得id
* @param taskId
*/
public void setTaskId(Long taskId) {
this.taskId = taskId;
}
/**
* 任务名称
* @return
*/
public String getName() {
return name;
}
/**
* 任务名称
* @param name
*/
public void setName(String name) {
this.name = name;
}
@Override @Override
public String toString() { public String toString() {
return "TaskProcessRecord{" + return "TaskProcessRecord{" +
@ -174,6 +210,8 @@ public class TaskProcessRecord implements java.io.Serializable {
",remark=" + remark + ",remark=" + remark +
",label=" + label + ",label=" + label +
",type=" + type + ",type=" + type +
",taskId=" + taskId +
",name=" + name +
"}"; "}";
} }
} }

View File

@ -0,0 +1,40 @@
package com.lz.modules.performance.enums;
/**
* @Author: djc
* @Desc:
* @Date: 2020/12/9 14:08
*/
public enum ProcessRecordEnum {
NAME(1,"修改名称"),
PROCESS(2,"修改进度"),
ALL(3,"全部修改"),
;
private int type;
private String desc;
ProcessRecordEnum(int type, String desc) {
this.type = type;
this.desc = desc;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@ -11,7 +11,7 @@ import java.math.BigDecimal;
* @Date: 2020/12/9 10:32 * @Date: 2020/12/9 10:32
*/ */
@Data @Data
public class ResultUpdateTakReq { public class ResultUpdateTaskReq {
//绩效详情id //绩效详情id
@ApiModelProperty(value = "绩效详情id如果任务id为空必传", name = "detailId") @ApiModelProperty(value = "绩效详情id如果任务id为空必传", name = "detailId")
private Long detailId; private Long detailId;
@ -24,5 +24,8 @@ public class ResultUpdateTakReq {
//任务的当前进度 //任务的当前进度
@ApiModelProperty(value = "任务的当前进度", name = "processRate") @ApiModelProperty(value = "任务的当前进度", name = "processRate")
private BigDecimal processRate; private BigDecimal processRate;
//更新说明
@ApiModelProperty(value = "更新说明", name = "remake")
private String remake;
} }

View File

@ -2,7 +2,7 @@ package com.lz.modules.performance.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.modules.performance.entity.ResultTask; import com.lz.modules.performance.entity.ResultTask;
import com.lz.modules.performance.req.ResultUpdateTakReq; import com.lz.modules.performance.req.ResultUpdateTaskReq;
import com.lz.modules.performance.res.ResultTaskDetailRes; import com.lz.modules.performance.res.ResultTaskDetailRes;
/** /**
@ -33,7 +33,7 @@ public interface ResultTaskService extends IService<ResultTask> {
ResultTaskDetailRes taskDetail(Long detailId); ResultTaskDetailRes taskDetail(Long detailId);
int saveOrUpdateResultTask(ResultUpdateTakReq req); int saveOrUpdateResultTask(ResultUpdateTaskReq req);
} }

View File

@ -1,22 +1,28 @@
package com.lz.modules.performance.service.impl; package com.lz.modules.performance.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.common.utils.BigDecimalUtil;
import com.lz.modules.performance.dao.ResultTaskMapper; import com.lz.modules.performance.dao.ResultTaskMapper;
import com.lz.modules.performance.dto.ResultTaskDto; import com.lz.modules.performance.dto.ResultTaskDto;
import com.lz.modules.performance.entity.ResultTask; import com.lz.modules.performance.entity.ResultTask;
import com.lz.modules.performance.req.ResultUpdateTakReq; import com.lz.modules.performance.entity.TaskProcessRecord;
import com.lz.modules.performance.enums.ProcessRecordEnum;
import com.lz.modules.performance.req.ResultUpdateTaskReq;
import com.lz.modules.performance.res.ResultTaskDetailRes; import com.lz.modules.performance.res.ResultTaskDetailRes;
import com.lz.modules.performance.service.ResultTaskService; import com.lz.modules.performance.service.ResultTaskService;
import com.lz.modules.performance.service.TaskProcessRecordService;
import com.lz.modules.sys.entity.app.ResultDetail; import com.lz.modules.sys.entity.app.ResultDetail;
import com.lz.modules.sys.service.app.ResultDetailService; import com.lz.modules.sys.service.app.ResultDetailService;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer;
/** /**
* <p> * <p>
@ -36,6 +42,8 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
private ResultTaskMapper resultTaskMapper; private ResultTaskMapper resultTaskMapper;
@Autowired @Autowired
private ResultDetailService resultDetailService; private ResultDetailService resultDetailService;
@Autowired
private TaskProcessRecordService taskProcessRecordService;
@ -86,7 +94,7 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
} }
@Override @Override
public int saveOrUpdateResultTask(ResultUpdateTakReq req) { public int saveOrUpdateResultTask(ResultUpdateTaskReq req) {
Long tasklId = req.getTasklId(); Long tasklId = req.getTasklId();
Long detailId = req.getDetailId(); Long detailId = req.getDetailId();
if(tasklId==null && detailId == null){ if(tasklId==null && detailId == null){
@ -99,11 +107,62 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
resultTask = new ResultTask(); resultTask = new ResultTask();
BeanUtils.copyProperties(req,resultTask); BeanUtils.copyProperties(req,resultTask);
resultTask.setDetailId(detailId); resultTask.setDetailId(detailId);
return resultTaskMapper.insertResultTask(resultTask).intValue(); resultTaskMapper.insertResultTask(resultTask);
} }
log.info("绩效任务修改操作。。。"); else {
resultTask = resultTaskMapper.selectResultTaskById(tasklId); log.info("绩效任务修改操作。。。");
BeanUtils.copyProperties(req,resultTask); resultTask = resultTaskMapper.selectResultTaskById(tasklId);
return resultTaskMapper.updateResultTaskById(resultTask); BeanUtils.copyProperties(req,resultTask);
resultTaskMapper.updateResultTaskById(resultTask);
}
//修改总进度
ResultDetail resultDetail = resultDetailService.selectResultDetailById(detailId);
resultDetail.setProcessRate(caclateResultDetailProcess(detailId));
return resultDetailService.updateResultDetailById(resultDetail);
}
//计算总进度
private BigDecimal caclateResultDetailProcess(Long detailId){
List<ResultTaskDto> resultTaskDtos = resultTaskMapper.selectResultTasksByDetailId(detailId);
if(CollectionUtils.isEmpty(resultTaskDtos)){
log.info("未找到该绩效详情下得任务信息");
return BigDecimal.ZERO;
}
int size = resultTaskDtos.size();
BigDecimal rate = BigDecimal.ZERO;
for(ResultTaskDto dto:resultTaskDtos){
rate = BigDecimalUtil.add(rate,dto.getProcessRate());
}
return BigDecimalUtil.divide(rate,BigDecimal.valueOf(size)).setScale(2);
}
//记录变更记录
private void changeTaskProcess(ResultTask before,ResultUpdateTaskReq after){
TaskProcessRecord taskProcessRecord = new TaskProcessRecord();
taskProcessRecord.setTaskId(before.getId());
taskProcessRecord.setRemark(after.getRemake());
//判断修改了名称或进度
if(before.getName().equals(after.getName())){
if(before.getProcessRate().equals(after.getProcessRate())){
taskProcessRecord.setType(ProcessRecordEnum.ALL.getType());
return;
}
taskProcessRecord.setType(ProcessRecordEnum.NAME.getType());
return;
}
if(before.getProcessRate().equals(after.getProcessRate())){
taskProcessRecord.setType(ProcessRecordEnum.PROCESS.getType());
taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord);
}
} }
} }

View File

@ -12,12 +12,14 @@
<result column="remark" property="remark"/> <result column="remark" property="remark"/>
<result column="label" property="label"/> <result column="label" property="label"/>
<result column="type" property="type"/> <result column="type" property="type"/>
<result column="task_id" property="taskId"/>
<result column="name" property="name"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, process_rate AS processRate, remark AS remark, label AS label, type AS type id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, process_rate AS processRate, remark AS remark, label AS label, type AS type, task_id AS taskId, name AS name
</sql> </sql>
@ -30,35 +32,41 @@
<insert id="insertTaskProcessRecord" parameterType="TaskProcessRecord" useGeneratedKeys="true" keyProperty="id" > <insert id="insertTaskProcessRecord" parameterType="TaskProcessRecord" useGeneratedKeys="true" keyProperty="id" >
insert into lz_task_process_record( insert into lz_task_process_record(
<if test="processRate != null">process_rate, </if> <if test="processRate != null">process_rate, </if>
<if test="remark != null">remark, </if> <if test="remark != null">remark, </if>
<if test="label != null">label, </if> <if test="label != null">label, </if>
<if test="type != null">type, </if> <if test="type != null">type, </if>
is_delete, <if test="taskId != null">task_id, </if>
gmt_create, <if test="name != null">name, </if>
gmt_modified is_delete,
gmt_create,
gmt_modified
)values( )values(
<if test="processRate != null">#{ processRate}, </if> <if test="processRate != null">#{ processRate}, </if>
<if test="remark != null">#{ remark}, </if> <if test="remark != null">#{ remark}, </if>
<if test="label != null">#{ label}, </if> <if test="label != null">#{ label}, </if>
<if test="type != null">#{ type}, </if> <if test="type != null">#{ type}, </if>
0, <if test="taskId != null">#{ taskId}, </if>
now(), <if test="name != null">#{ name}, </if>
now() 0,
now(),
now()
) )
</insert> </insert>
<update id="updateTaskProcessRecordById" parameterType="TaskProcessRecord" > <update id="updateTaskProcessRecordById" parameterType="TaskProcessRecord" >
update update
lz_task_process_record lz_task_process_record
<trim prefix="set" suffixOverrides=","> <trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if> <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="processRate != null">process_rate = #{processRate},</if> <if test="processRate != null">process_rate = #{processRate},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="label != null">label = #{label},</if> <if test="label != null">label = #{label},</if>
<if test="type != null">type = #{type}</if> <if test="type != null">type = #{type},</if>
<if test="taskId != null">task_id = #{taskId},</if>
<if test="name != null">name = #{name}</if>
</trim> </trim>
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
@ -67,14 +75,16 @@
<update id="updateCoverTaskProcessRecordById" parameterType="TaskProcessRecord" > <update id="updateCoverTaskProcessRecordById" parameterType="TaskProcessRecord" >
update update
lz_task_process_record lz_task_process_record
set set
is_delete = #{isDelete}, is_delete = #{isDelete},
gmt_create = #{gmtCreate}, gmt_create = #{gmtCreate},
process_rate = #{processRate}, process_rate = #{processRate},
remark = #{remark}, remark = #{remark},
label = #{label}, label = #{label},
type = #{type} type = #{type},
task_id = #{taskId},
name = #{name}
,gmt_modified = now() ,gmt_modified = now()
where id = #{id} where id = #{id}
</update> </update>

View File

@ -84,8 +84,12 @@ public class MysqlMain {
List<TablesBean> list = new ArrayList<TablesBean>(); List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_result_task")); list.add(new TablesBean("lz_result_task"));
list.add(new TablesBean("lz_task_process_record"));
List<TablesBean> list2 = new ArrayList<TablesBean>(); List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments(); Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {