This commit is contained in:
杜建超 2020-12-09 14:22:55 +08:00
parent bd6f92ee76
commit 9dc42c3414
9 changed files with 186 additions and 36 deletions

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import java.util.Date;
* <p>
* </p>*任务进度更新表
* @author quyixiao
* @since 2020-12-08
* @since 2020-12-09
*/
@Data
@ -43,6 +43,12 @@ public class TaskProcessRecord implements java.io.Serializable {
//1修改名称2修改进度 3名称和进度都修改
@ApiModelProperty(value = "1修改名称2修改进度 3名称和进度都修改", name = "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
@ -163,6 +169,36 @@ public class TaskProcessRecord implements java.io.Serializable {
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
public String toString() {
return "TaskProcessRecord{" +
@ -174,6 +210,8 @@ public class TaskProcessRecord implements java.io.Serializable {
",remark=" + remark +
",label=" + label +
",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
*/
@Data
public class ResultUpdateTakReq {
public class ResultUpdateTaskReq {
//绩效详情id
@ApiModelProperty(value = "绩效详情id如果任务id为空必传", name = "detailId")
private Long detailId;
@ -24,5 +24,8 @@ public class ResultUpdateTakReq {
//任务的当前进度
@ApiModelProperty(value = "任务的当前进度", name = "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.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;
/**
@ -33,7 +33,7 @@ public interface ResultTaskService extends IService<ResultTask> {
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;
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.dto.ResultTaskDto;
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.service.ResultTaskService;
import com.lz.modules.performance.service.TaskProcessRecordService;
import com.lz.modules.sys.entity.app.ResultDetail;
import com.lz.modules.sys.service.app.ResultDetailService;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
/**
* <p>
@ -36,6 +42,8 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
private ResultTaskMapper resultTaskMapper;
@Autowired
private ResultDetailService resultDetailService;
@Autowired
private TaskProcessRecordService taskProcessRecordService;
@ -86,7 +94,7 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
}
@Override
public int saveOrUpdateResultTask(ResultUpdateTakReq req) {
public int saveOrUpdateResultTask(ResultUpdateTaskReq req) {
Long tasklId = req.getTasklId();
Long detailId = req.getDetailId();
if(tasklId==null && detailId == null){
@ -99,11 +107,62 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
resultTask = new ResultTask();
BeanUtils.copyProperties(req,resultTask);
resultTask.setDetailId(detailId);
return resultTaskMapper.insertResultTask(resultTask).intValue();
resultTaskMapper.insertResultTask(resultTask);
}
log.info("绩效任务修改操作。。。");
resultTask = resultTaskMapper.selectResultTaskById(tasklId);
BeanUtils.copyProperties(req,resultTask);
return resultTaskMapper.updateResultTaskById(resultTask);
else {
log.info("绩效任务修改操作。。。");
resultTask = resultTaskMapper.selectResultTaskById(tasklId);
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="label" property="label"/>
<result column="type" property="type"/>
<result column="task_id" property="taskId"/>
<result column="name" property="name"/>
</resultMap>
<!-- 通用查询结果列 -->
<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>
@ -30,35 +32,41 @@
<insert id="insertTaskProcessRecord" parameterType="TaskProcessRecord" useGeneratedKeys="true" keyProperty="id" >
insert into lz_task_process_record(
<if test="processRate != null">process_rate, </if>
<if test="remark != null">remark, </if>
<if test="label != null">label, </if>
<if test="type != null">type, </if>
is_delete,
gmt_create,
gmt_modified
<if test="processRate != null">process_rate, </if>
<if test="remark != null">remark, </if>
<if test="label != null">label, </if>
<if test="type != null">type, </if>
<if test="taskId != null">task_id, </if>
<if test="name != null">name, </if>
is_delete,
gmt_create,
gmt_modified
)values(
<if test="processRate != null">#{ processRate}, </if>
<if test="remark != null">#{ remark}, </if>
<if test="label != null">#{ label}, </if>
<if test="type != null">#{ type}, </if>
0,
now(),
now()
<if test="processRate != null">#{ processRate}, </if>
<if test="remark != null">#{ remark}, </if>
<if test="label != null">#{ label}, </if>
<if test="type != null">#{ type}, </if>
<if test="taskId != null">#{ taskId}, </if>
<if test="name != null">#{ name}, </if>
0,
now(),
now()
)
</insert>
<update id="updateTaskProcessRecordById" parameterType="TaskProcessRecord" >
update
lz_task_process_record
lz_task_process_record
<trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="processRate != null">process_rate = #{processRate},</if>
<if test="remark != null">remark = #{remark},</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>
,gmt_modified = now()
where id = #{id}
@ -67,14 +75,16 @@
<update id="updateCoverTaskProcessRecordById" parameterType="TaskProcessRecord" >
update
lz_task_process_record
set
lz_task_process_record
set
is_delete = #{isDelete},
gmt_create = #{gmtCreate},
process_rate = #{processRate},
remark = #{remark},
label = #{label},
type = #{type}
type = #{type},
task_id = #{taskId},
name = #{name}
,gmt_modified = now()
where id = #{id}
</update>

View File

@ -84,7 +84,7 @@ public class MysqlMain {
List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_result_detail"));
list.add(new TablesBean("lz_task_process_record"));
List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();