提交修改
This commit is contained in:
parent
1c3c7c3d23
commit
023d3afdee
@ -3,8 +3,11 @@ package com.lz.common.utils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -653,11 +656,6 @@ public class StringUtil extends StringUtils {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println(realNameTo2("xxxxx"));
|
||||
}
|
||||
|
||||
/**
|
||||
* fmai 根据基数产生随机5位数
|
||||
*
|
||||
@ -726,4 +724,37 @@ public class StringUtil extends StringUtils {
|
||||
}
|
||||
return longList;
|
||||
}
|
||||
|
||||
public static String formateRate(BigDecimal processRate,int multiply) {
|
||||
if(processRate == null){
|
||||
return "0 %";
|
||||
}
|
||||
processRate = processRate.multiply(new BigDecimal(multiply));
|
||||
System.out.println(processRate);
|
||||
DecimalFormat df = new DecimalFormat("0");
|
||||
df.setRoundingMode(RoundingMode.HALF_UP);
|
||||
return df.format(processRate)+" %";
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String formateRate(String rate,int multiply) {
|
||||
if(StringUtil.isEmpty(rate)) {
|
||||
return "0 %";
|
||||
}
|
||||
BigDecimal processRate = NumberUtil.objToBigDecimalDefault(rate, BigDecimal.ZERO).multiply(new BigDecimal(multiply));
|
||||
System.out.println(processRate);
|
||||
DecimalFormat df = new DecimalFormat("0");
|
||||
df.setRoundingMode(RoundingMode.HALF_UP);
|
||||
return df.format(processRate) + " %";
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(formateRate(new BigDecimal(0.32),100));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -31,4 +31,13 @@ public class ResultDto {
|
||||
|
||||
|
||||
|
||||
|
||||
public ResultDto(@TaskHeader(value = "index", order = 0) String index, @TaskHeader(value = "进度", order = 1) String rate, Long detailId, @TaskHeader(value = "内容", order = 3) String content) {
|
||||
this.index = index;
|
||||
this.rate = rate;
|
||||
this.detailId = detailId;
|
||||
this.taskId = taskId;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -68,6 +68,7 @@ public abstract class BaseCommand<T> {
|
||||
i++;
|
||||
}
|
||||
taskDto.setOption(tokens[0]);
|
||||
taskDto.setIndex(tokens[1]);
|
||||
return new Tuple(true, taskDto);
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("add")
|
||||
@Name("add")
|
||||
@Component("update")
|
||||
@Name("update")
|
||||
@Summary("绩效任务查看 添加 或 更新 ")
|
||||
@Description(Constant.EXAMPLE +
|
||||
" update 1 \"短信开发\"\n" +
|
||||
@ -46,9 +46,17 @@ public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple>
|
||||
@Autowired
|
||||
private TaskRespService taskRespService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ResultTaskService resultTaskService;
|
||||
|
||||
public Tuple check() throws Exception {
|
||||
if(!tokens[1].contains(".")){
|
||||
return new Tuple(true,"目前绩效不支持更新,只有任务才支持更新");
|
||||
}
|
||||
return new Tuple(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R process(Tuple tuple) throws Exception {
|
||||
tuple = doTaskParse();
|
||||
@ -62,7 +70,7 @@ public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple>
|
||||
TaskDto taskDto = (TaskDto) tuple.getData().getSecond();
|
||||
boolean flag = taskRespService.updateIndex(user, taskDto, "list");
|
||||
if (!flag) {
|
||||
return R.error("请先输入list 或 选择正确的索引 ,如1 or 1.x");
|
||||
return R.error("请先输入list或选择正确的索引,如1 or 1.x,或你输入的x.x不存在");
|
||||
}
|
||||
log.info(" 更新请求数据 :" + JSON.toJSONString(taskDto));
|
||||
R r = resultTaskService.addOrUpdateTask(user, taskDto);
|
||||
|
||||
@ -44,4 +44,6 @@ public interface ResultTaskMapper extends BaseMapper<ResultTask> {
|
||||
int deleteResultTasksByDetailId(Long detailId);
|
||||
|
||||
List<ResultDto> listResultTask(@Param("detailIds") List<String> detailIds);
|
||||
|
||||
List<ResultTask> listResultTaskByDetailId(@Param("detailIds") List<Long> detailIds);
|
||||
}
|
||||
@ -25,27 +25,21 @@ import com.lz.modules.sys.entity.app.ResultDetail;
|
||||
import com.lz.modules.sys.service.app.ResultDetailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2020-12-08
|
||||
*/
|
||||
* <p>
|
||||
* 任务表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2020-12-08
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -53,223 +47,218 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
|
||||
|
||||
|
||||
@Autowired
|
||||
private ResultTaskMapper resultTaskMapper;
|
||||
private ResultTaskMapper resultTaskMapper;
|
||||
@Autowired
|
||||
private ResultDetailService resultDetailService;;
|
||||
private ResultDetailService resultDetailService;
|
||||
;
|
||||
@Autowired
|
||||
private TaskProcessRecordService taskProcessRecordService;
|
||||
private TaskProcessRecordService taskProcessRecordService;
|
||||
@Autowired
|
||||
private TaskProcessRecordMapper taskProcessRecordMapper;
|
||||
private TaskProcessRecordMapper taskProcessRecordMapper;
|
||||
@Autowired
|
||||
private StaffService staffService;
|
||||
private StaffService staffService;
|
||||
@Autowired
|
||||
private ResultDetailMapper resultDetailMapper;
|
||||
private ResultDetailMapper resultDetailMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultTask selectResultTaskById(Long id){
|
||||
return resultTaskMapper.selectResultTaskById(id);
|
||||
}
|
||||
@Override
|
||||
public ResultTask selectResultTaskById(Long id) {
|
||||
return resultTaskMapper.selectResultTaskById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insertResultTask(ResultTask resultTask){
|
||||
return resultTaskMapper.insertResultTask(resultTask);
|
||||
}
|
||||
@Override
|
||||
public Long insertResultTask(ResultTask resultTask) {
|
||||
return resultTaskMapper.insertResultTask(resultTask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateResultTaskById(ResultTask resultTask){
|
||||
return resultTaskMapper.updateResultTaskById(resultTask);
|
||||
}
|
||||
@Override
|
||||
public int updateResultTaskById(ResultTask resultTask) {
|
||||
return resultTaskMapper.updateResultTaskById(resultTask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateCoverResultTaskById(ResultTask resultTask){
|
||||
return resultTaskMapper.updateCoverResultTaskById(resultTask);
|
||||
}
|
||||
@Override
|
||||
public int updateCoverResultTaskById(ResultTask resultTask) {
|
||||
return resultTaskMapper.updateCoverResultTaskById(resultTask);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteResultTaskById(Long id) {
|
||||
return resultTaskMapper.deleteResultTaskById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteResultTaskById(Long id){
|
||||
return resultTaskMapper.deleteResultTaskById(id);
|
||||
}
|
||||
@Override
|
||||
public ResultTaskDetailRes taskDetail(Long detailId) {
|
||||
ResultTaskDetailRes res = new ResultTaskDetailRes();
|
||||
StaffEntity staffEntity = null;
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(detailId);
|
||||
if (resultDetail != null) {
|
||||
res.setProcessRate(resultDetail.getProcessRate());
|
||||
res.setTarget(resultDetail.getTarget());
|
||||
Long staffId = resultDetail.getStaffId();
|
||||
staffEntity = staffService.selectStaffById(staffId);
|
||||
}
|
||||
List<ResultTaskDto> resultTasks = resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
|
||||
@Override
|
||||
public ResultTaskDetailRes taskDetail(Long detailId) {
|
||||
ResultTaskDetailRes res = new ResultTaskDetailRes();
|
||||
StaffEntity staffEntity = null;
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(detailId);
|
||||
if(resultDetail != null){
|
||||
res.setProcessRate(resultDetail.getProcessRate());
|
||||
res.setTarget(resultDetail.getTarget());
|
||||
Long staffId = resultDetail.getStaffId();
|
||||
staffEntity = staffService.selectStaffById(staffId);
|
||||
}
|
||||
List<ResultTaskDto> resultTasks = resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
|
||||
//获取最近更新记录
|
||||
if(CollectionUtils.isNotEmpty(resultTasks)){
|
||||
StaffEntity finalStaffEntity = staffEntity;
|
||||
resultTasks.forEach(resultTaskDto -> {
|
||||
//获取最近更新记录
|
||||
if (CollectionUtils.isNotEmpty(resultTasks)) {
|
||||
StaffEntity finalStaffEntity = staffEntity;
|
||||
resultTasks.forEach(resultTaskDto -> {
|
||||
TaskProcessRecordDto taskProcessRecordDto = taskProcessRecordMapper.selectTaskProcessRecordLastByTaskId(resultTaskDto.getId());
|
||||
if(taskProcessRecordDto != null){
|
||||
//resultTaskDto.setLabel(taskProcessRecordDto.getLabel());
|
||||
if(taskProcessRecordDto.getUseType()==0){
|
||||
ProcessRecordEnum byType = ProcessRecordEnum.findByType(taskProcessRecordDto.getType());
|
||||
Optional.ofNullable(byType).ifPresent(processRecordEnum -> resultTaskDto.setTypeDesc(byType.getDesc()));
|
||||
if(finalStaffEntity !=null){
|
||||
resultTaskDto.setAvatar(finalStaffEntity.getAvatar());
|
||||
resultTaskDto.setStaffName(finalStaffEntity.getName());
|
||||
}
|
||||
}
|
||||
if(taskProcessRecordDto.getUseType()==1){
|
||||
resultTaskDto.setTypeDesc(taskProcessRecordDto.getLabel());
|
||||
StaffEntity staffEntity1 = staffService.selectStaffById(taskProcessRecordDto.getStaffId());
|
||||
if(staffEntity1 !=null){
|
||||
resultTaskDto.setAvatar(staffEntity1.getAvatar());
|
||||
resultTaskDto.setStaffName(staffEntity1.getName());
|
||||
if (taskProcessRecordDto != null) {
|
||||
//resultTaskDto.setLabel(taskProcessRecordDto.getLabel());
|
||||
if (taskProcessRecordDto.getUseType() == 0) {
|
||||
ProcessRecordEnum byType = ProcessRecordEnum.findByType(taskProcessRecordDto.getType());
|
||||
Optional.ofNullable(byType).ifPresent(processRecordEnum -> resultTaskDto.setTypeDesc(byType.getDesc()));
|
||||
if (finalStaffEntity != null) {
|
||||
resultTaskDto.setAvatar(finalStaffEntity.getAvatar());
|
||||
resultTaskDto.setStaffName(finalStaffEntity.getName());
|
||||
}
|
||||
}
|
||||
if (taskProcessRecordDto.getUseType() == 1) {
|
||||
resultTaskDto.setTypeDesc(taskProcessRecordDto.getLabel());
|
||||
StaffEntity staffEntity1 = staffService.selectStaffById(taskProcessRecordDto.getStaffId());
|
||||
if (staffEntity1 != null) {
|
||||
resultTaskDto.setAvatar(staffEntity1.getAvatar());
|
||||
resultTaskDto.setStaffName(staffEntity1.getName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
res.setResultTasks(resultTasks);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
res.setResultTasks(resultTasks);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R saveOrUpdateResultTask(ResultUpdateTaskReq req, Long userId) {
|
||||
Long tasklId = req.getTaskId();
|
||||
Long detailId = req.getDetailId();
|
||||
if(tasklId == null && detailId == null){
|
||||
log.error("任务保存或更新失败:tasklId, detailId都为空");
|
||||
return R.error();
|
||||
}
|
||||
ResultTask resultTask;
|
||||
if(tasklId == null){
|
||||
log.info("绩效任务新增操作。。。");
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(req.getDetailId());
|
||||
if(!userId.equals(resultDetail.getStaffId())){
|
||||
log.info("非本人任务不能添加");
|
||||
return R.error("非本人任务不能添加");
|
||||
}
|
||||
resultTask = new ResultTask();
|
||||
BeanUtils.copyProperties(req,resultTask);
|
||||
resultTask.setDetailId(detailId);
|
||||
resultTaskMapper.insertResultTask(resultTask);
|
||||
//将插入的id传递过去
|
||||
req.setTaskId(resultTask.getId());
|
||||
changeTaskProcess(null, req,null);
|
||||
}
|
||||
else {
|
||||
@Override
|
||||
public R saveOrUpdateResultTask(ResultUpdateTaskReq req, Long userId) {
|
||||
Long tasklId = req.getTaskId();
|
||||
Long detailId = req.getDetailId();
|
||||
if (tasklId == null && detailId == null) {
|
||||
log.error("任务保存或更新失败:tasklId, detailId都为空");
|
||||
return R.error();
|
||||
}
|
||||
ResultTask resultTask;
|
||||
if (tasklId == null) {
|
||||
log.info("绩效任务新增操作。。。");
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(req.getDetailId());
|
||||
if (!userId.equals(resultDetail.getStaffId())) {
|
||||
log.info("非本人任务不能添加");
|
||||
return R.error("非本人任务不能添加");
|
||||
}
|
||||
resultTask = new ResultTask();
|
||||
BeanUtils.copyProperties(req, resultTask);
|
||||
resultTask.setDetailId(detailId);
|
||||
resultTaskMapper.insertResultTask(resultTask);
|
||||
//将插入的id传递过去
|
||||
req.setTaskId(resultTask.getId());
|
||||
changeTaskProcess(null, req, null);
|
||||
} else {
|
||||
|
||||
log.info("绩效任务修改操作。。。");
|
||||
resultTask = resultTaskMapper.selectResultTaskById(tasklId);
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(resultTask.getDetailId());
|
||||
if(!userId.equals(resultDetail.getStaffId())){
|
||||
log.info("非本人任务不能修改");
|
||||
return R.error("非本人任务不能修改");
|
||||
}
|
||||
TaskProcessRecordDto taskProcessRecordDto = taskProcessRecordMapper.selectTaskProcessRecordLastByTaskId(tasklId);
|
||||
int i = changeTaskProcess(resultTask, req,taskProcessRecordDto);
|
||||
if(i<1){
|
||||
log.info("任务暂无变化,不做修改");
|
||||
}
|
||||
resultTask.setOrderBy(req.getOrderBy());
|
||||
if(StringUtil.isNotBlank(req.getName())){
|
||||
resultTask.setName(req.getName());
|
||||
}
|
||||
if(req.getProcessRate()!=null){
|
||||
resultTask.setProcessRate(req.getProcessRate());
|
||||
}
|
||||
resultTaskMapper.updateCoverResultTaskById(resultTask);
|
||||
log.info("绩效任务修改操作。。。");
|
||||
resultTask = resultTaskMapper.selectResultTaskById(tasklId);
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(resultTask.getDetailId());
|
||||
if (!userId.equals(resultDetail.getStaffId())) {
|
||||
log.info("非本人任务不能修改");
|
||||
return R.error("非本人任务不能修改");
|
||||
}
|
||||
TaskProcessRecordDto taskProcessRecordDto = taskProcessRecordMapper.selectTaskProcessRecordLastByTaskId(tasklId);
|
||||
int i = changeTaskProcess(resultTask, req, taskProcessRecordDto);
|
||||
if (i < 1) {
|
||||
log.info("任务暂无变化,不做修改");
|
||||
}
|
||||
resultTask.setOrderBy(req.getOrderBy());
|
||||
if (StringUtil.isNotBlank(req.getName())) {
|
||||
resultTask.setName(req.getName());
|
||||
}
|
||||
if (req.getProcessRate() != null) {
|
||||
resultTask.setProcessRate(req.getProcessRate());
|
||||
}
|
||||
resultTaskMapper.updateCoverResultTaskById(resultTask);
|
||||
|
||||
}
|
||||
//修改总进度
|
||||
if(detailId == null){
|
||||
detailId = resultTask.getDetailId();
|
||||
}
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(detailId);
|
||||
resultDetail.setProcessRate(BigDecimal.valueOf(caclateResultDetailProcess(detailId)));
|
||||
resultDetailService.updateResultDetailById(resultDetail);
|
||||
return R.ok();
|
||||
}
|
||||
//修改总进度
|
||||
if (detailId == null) {
|
||||
detailId = resultTask.getDetailId();
|
||||
}
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(detailId);
|
||||
resultDetail.setProcessRate(BigDecimal.valueOf(caclateResultDetailProcess(detailId)));
|
||||
resultDetailService.updateResultDetailById(resultDetail);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//计算总进度
|
||||
private Double caclateResultDetailProcess(Long detailId){
|
||||
List<ResultTaskDto> resultTaskDtos = resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
if(CollectionUtils.isEmpty(resultTaskDtos)){
|
||||
log.info("未找到该绩效详情下得任务信息");
|
||||
return 0d;
|
||||
}
|
||||
int size = resultTaskDtos.size();
|
||||
Double rate = 0d;
|
||||
for(ResultTaskDto dto:resultTaskDtos){
|
||||
if(dto.getProcessRate()!=null){
|
||||
rate = BigDecimalUtil.add(rate,dto.getProcessRate());
|
||||
}
|
||||
}
|
||||
double result = BigDecimalUtil.div(rate, size, 4);
|
||||
return result;
|
||||
//计算总进度
|
||||
private Double caclateResultDetailProcess(Long detailId) {
|
||||
List<ResultTaskDto> resultTaskDtos = resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
if (CollectionUtils.isEmpty(resultTaskDtos)) {
|
||||
log.info("未找到该绩效详情下得任务信息");
|
||||
return 0d;
|
||||
}
|
||||
int size = resultTaskDtos.size();
|
||||
Double rate = 0d;
|
||||
for (ResultTaskDto dto : resultTaskDtos) {
|
||||
if (dto.getProcessRate() != null) {
|
||||
rate = BigDecimalUtil.add(rate, dto.getProcessRate());
|
||||
}
|
||||
}
|
||||
double result = BigDecimalUtil.div(rate, size, 4);
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//记录变更记录
|
||||
private int changeTaskProcess(ResultTask beforeResultTask,ResultUpdateTaskReq req,TaskProcessRecordDto beforeTaskProcessRecord){
|
||||
TaskProcessRecord taskProcessRecord = new TaskProcessRecord();
|
||||
BeanUtils.copyProperties(req,taskProcessRecord);
|
||||
//新增操作
|
||||
if(beforeResultTask == null){
|
||||
taskProcessRecord.setType(ProcessRecordEnum.ADD.getType());
|
||||
taskProcessRecord.setLabel("新增key Results名称:" + req.getName() + ";进度:" + BigDecimalUtil.mul(req.getProcessRate(),BigDecimal.valueOf(100)).setScale(2) + "%");
|
||||
return taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord).intValue();
|
||||
}
|
||||
//判断修改了名称或进度
|
||||
int i = 0;
|
||||
String lebel = "key Results名称:" + beforeResultTask.getName();
|
||||
if(StringUtil.isNotBlank(req.getName()) && !req.getName().equals(beforeResultTask.getName())) {
|
||||
i|= (0x00000001<<0);
|
||||
lebel = lebel + " 改为 " + req.getName() + "\n";
|
||||
}
|
||||
if(req.getProcessRate()!=null && BigDecimalUtil.compareTo(beforeResultTask.getProcessRate(),req.getProcessRate())!=0){
|
||||
i|= (0x00000001<<1);
|
||||
lebel = lebel + "将进度:" +BigDecimalUtil.mul(beforeResultTask.getProcessRate(),BigDecimal.valueOf(100)).setScale(2)+ "%" + " 更新为 " + BigDecimalUtil.mul(req.getProcessRate(),BigDecimal.valueOf(100)).setScale(2)+ "%";
|
||||
}
|
||||
//记录变更记录
|
||||
private int changeTaskProcess(ResultTask beforeResultTask, ResultUpdateTaskReq req, TaskProcessRecordDto beforeTaskProcessRecord) {
|
||||
TaskProcessRecord taskProcessRecord = new TaskProcessRecord();
|
||||
BeanUtils.copyProperties(req, taskProcessRecord);
|
||||
//新增操作
|
||||
if (beforeResultTask == null) {
|
||||
taskProcessRecord.setType(ProcessRecordEnum.ADD.getType());
|
||||
taskProcessRecord.setLabel("新增key Results名称:" + req.getName() + ";进度:" + BigDecimalUtil.mul(req.getProcessRate(), BigDecimal.valueOf(100)).setScale(2) + "%");
|
||||
return taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord).intValue();
|
||||
}
|
||||
//判断修改了名称或进度
|
||||
int i = 0;
|
||||
String lebel = "key Results名称:" + beforeResultTask.getName();
|
||||
if (StringUtil.isNotBlank(req.getName()) && !req.getName().equals(beforeResultTask.getName())) {
|
||||
i |= (0x00000001 << 0);
|
||||
lebel = lebel + " 改为 " + req.getName() + "\n";
|
||||
}
|
||||
if (req.getProcessRate() != null && BigDecimalUtil.compareTo(beforeResultTask.getProcessRate(), req.getProcessRate()) != 0) {
|
||||
i |= (0x00000001 << 1);
|
||||
lebel = lebel + "将进度:" + BigDecimalUtil.mul(beforeResultTask.getProcessRate(), BigDecimal.valueOf(100)).setScale(2) + "%" + " 更新为 " + BigDecimalUtil.mul(req.getProcessRate(), BigDecimal.valueOf(100)).setScale(2) + "%";
|
||||
}
|
||||
|
||||
String remark = StringUtil.EMPTY;
|
||||
String remark = StringUtil.EMPTY;
|
||||
|
||||
if(req.getRemark() != null){
|
||||
if(beforeTaskProcessRecord != null){
|
||||
remark = beforeTaskProcessRecord.getRemark();
|
||||
}
|
||||
if(beforeTaskProcessRecord == null ||(!req.getRemark().equals(beforeTaskProcessRecord.getRemark()))){
|
||||
i|= (0x00000001<<2);
|
||||
lebel = lebel + "将进度说明更新为: " + req.getRemark();
|
||||
}
|
||||
}
|
||||
if (req.getRemark() != null) {
|
||||
if (beforeTaskProcessRecord != null) {
|
||||
remark = beforeTaskProcessRecord.getRemark();
|
||||
}
|
||||
if (beforeTaskProcessRecord == null || (!req.getRemark().equals(beforeTaskProcessRecord.getRemark()))) {
|
||||
i |= (0x00000001 << 2);
|
||||
lebel = lebel + "将进度说明更新为: " + req.getRemark();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(i==0){
|
||||
return -1;
|
||||
}
|
||||
if (i == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
taskProcessRecord.setTaskId(beforeResultTask.getId());
|
||||
taskProcessRecord.setDetailId(beforeResultTask.getDetailId());
|
||||
taskProcessRecord.setType(i);
|
||||
taskProcessRecord.setLabel(lebel);
|
||||
return taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord).intValue();
|
||||
taskProcessRecord.setTaskId(beforeResultTask.getId());
|
||||
taskProcessRecord.setDetailId(beforeResultTask.getDetailId());
|
||||
taskProcessRecord.setType(i);
|
||||
taskProcessRecord.setLabel(lebel);
|
||||
return taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord).intValue();
|
||||
/*if(!beforeResultTask.getName().equals(req.getName())){
|
||||
if(BigDecimalUtil.compareTo(beforeResultTask.getProcessRate(),req.getProcessRate())!=0){
|
||||
taskProcessRecord.setType(ProcessRecordEnum.ALL.getType());
|
||||
@ -289,103 +278,131 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
|
||||
return taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord).intValue();
|
||||
}
|
||||
return -1;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ResultTask> selectResultTasksByDetailId(Long detailId) {
|
||||
return resultTaskMapper.selectResultTasksByDetailId(detailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResultTask> selectResultTasksByDetailId(Long detailId){
|
||||
return resultTaskMapper.selectResultTasksByDetailId(detailId);
|
||||
}
|
||||
@Override
|
||||
public int deleteResultTasksByDetailId(Long detailId) {
|
||||
List<ResultTask> tasks = resultTaskMapper.selectResultTasksByDetailId(detailId);
|
||||
for (ResultTask task : tasks
|
||||
) {
|
||||
taskProcessRecordService.deleteTaskProcessRecordsByTaskId(task.getId());
|
||||
}
|
||||
return resultTaskMapper.deleteResultTasksByDetailId(detailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteResultTasksByDetailId(Long detailId) {
|
||||
List<ResultTask> tasks = resultTaskMapper.selectResultTasksByDetailId(detailId);
|
||||
for (ResultTask task : tasks
|
||||
) {
|
||||
taskProcessRecordService.deleteTaskProcessRecordsByTaskId(task.getId());
|
||||
}
|
||||
return resultTaskMapper.deleteResultTasksByDetailId(detailId);
|
||||
}
|
||||
@Override
|
||||
public R deleteTask(Long taskId, Long userId) {
|
||||
ResultTask resultTask = resultTaskMapper.selectResultTaskById(taskId);
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(resultTask.getDetailId());
|
||||
if (!userId.equals(resultDetail.getStaffId())) {
|
||||
log.info("非本人任务不能删除");
|
||||
return R.error("非本人任务不能删除");
|
||||
}
|
||||
resultTaskMapper.deleteResultTaskById(taskId);
|
||||
TaskProcessRecord taskProcessRecord = new TaskProcessRecord();
|
||||
taskProcessRecord.setTaskId(taskId);
|
||||
taskProcessRecord.setType(ProcessRecordEnum.DELETE.getType());
|
||||
taskProcessRecord.setLabel("将" + resultTask.getName() + "任务删除");
|
||||
taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord);
|
||||
//修改总进度
|
||||
resultDetail.setProcessRate(BigDecimal.valueOf(caclateResultDetailProcess(resultTask.getDetailId())));
|
||||
resultDetailService.updateResultDetailById(resultDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deleteTask(Long taskId,Long userId) {
|
||||
ResultTask resultTask = resultTaskMapper.selectResultTaskById(taskId);
|
||||
ResultDetail resultDetail = resultDetailService.selectResultDetailById(resultTask.getDetailId());
|
||||
if(!userId.equals(resultDetail.getStaffId())){
|
||||
log.info("非本人任务不能删除");
|
||||
return R.error("非本人任务不能删除");
|
||||
}
|
||||
resultTaskMapper.deleteResultTaskById(taskId);
|
||||
TaskProcessRecord taskProcessRecord = new TaskProcessRecord();
|
||||
taskProcessRecord.setTaskId(taskId);
|
||||
taskProcessRecord.setType(ProcessRecordEnum.DELETE.getType());
|
||||
taskProcessRecord.setLabel("将" +resultTask.getName() + "任务删除");
|
||||
taskProcessRecordService.insertTaskProcessRecord(taskProcessRecord);
|
||||
//修改总进度
|
||||
resultDetail.setProcessRate(BigDecimal.valueOf(caclateResultDetailProcess(resultTask.getDetailId())));
|
||||
resultDetailService.updateResultDetailById(resultDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResultTaskDto> selectResultTaskDtosByDetailId(Long detailId){
|
||||
return resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
}
|
||||
@Override
|
||||
public List<ResultTaskDto> selectResultTaskDtosByDetailId(Long detailId) {
|
||||
return resultTaskMapper.selectResultTaskDtosByDetailId(detailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResultDto> listResultTask(SysUserEntity user) {
|
||||
List<ResultDto> resultDtos = resultDetailMapper.listRecord(user.getUserId());
|
||||
if(CollectionUtils.isEmpty(resultDtos)){
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
List<String> detailIds = new ArrayList<>();//resultDtos.stream().map(resultDto -> resultDto.getId() + "").collect(Collectors.toList());
|
||||
|
||||
List<ResultDto> dtos = resultTaskMapper.listResultTask(detailIds);
|
||||
for(ResultDto resultDto:dtos){
|
||||
String rate = resultDto.getRate();
|
||||
BigDecimal bigDecimal = new BigDecimal(rate).setScale(4);
|
||||
resultDto.setRate((bigDecimal.doubleValue() * 100) + "%");
|
||||
}
|
||||
return dtos;
|
||||
List<ResultDto> list = new ArrayList<>();
|
||||
List<ResultDto> resultDtos = resultDetailMapper.listRecord(user.getUserId());
|
||||
if (CollectionUtils.isEmpty(resultDtos)) {
|
||||
return list;
|
||||
}
|
||||
List<Long> detailIds = new ArrayList<>();
|
||||
for (ResultDto resultDto : resultDtos) {
|
||||
detailIds.add(resultDto.getDetailId());
|
||||
}
|
||||
List<ResultTask> dtos = resultTaskMapper.listResultTaskByDetailId(detailIds);
|
||||
Map<Long, List<ResultTask>> map = new HashMap<>();
|
||||
for (ResultTask task : dtos) {
|
||||
List<ResultTask> resultTasks = map.get(task.getDetailId());
|
||||
if (resultTasks == null) {
|
||||
resultTasks = new ArrayList<>();
|
||||
}
|
||||
resultTasks.add(task);
|
||||
map.put(task.getDetailId(), resultTasks);
|
||||
}
|
||||
for (int i = 0; i < resultDtos.size(); i++) {
|
||||
ResultDto resultDto = resultDtos.get(i);
|
||||
Integer index1 = i + 1;
|
||||
resultDto.setIndex(index1 + "");
|
||||
resultDto.setRate(StringUtil.formateRate(resultDto.getRate(), 100));
|
||||
list.add(resultDto);
|
||||
List<ResultTask> resultTasks = map.get(resultDto.getDetailId());
|
||||
if (CollectionUtils.isNotEmpty(resultTasks)) {
|
||||
int j = 1;
|
||||
for (ResultTask resultTask : resultTasks) {
|
||||
ResultDto r = new ResultDto();
|
||||
r.setIndex(index1 + "." + j);
|
||||
r.setDetailId(resultDto.getDetailId());
|
||||
r.setContent(resultTask.getName());
|
||||
r.setTaskId(resultTask.getId());
|
||||
r.setRate(StringUtil.formateRate(resultTask.getProcessRate(), 100));
|
||||
j++;
|
||||
list.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addOrUpdateTask(SysUserEntity user, TaskDto second) {
|
||||
ResultUpdateTaskReq resultUpdateTaskReq = new ResultUpdateTaskReq();
|
||||
resultUpdateTaskReq.setRemark(second.getMark());
|
||||
if("update".equals(second.getOption())){
|
||||
resultUpdateTaskReq.setTaskId(second.getId());
|
||||
}else if("add".equals(second.getOption())){
|
||||
resultUpdateTaskReq.setDetailId(second.getId());
|
||||
if(StringUtil.isBlank(second.getRate())){
|
||||
resultUpdateTaskReq.setProcessRate(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
resultUpdateTaskReq.setName(second.getName());
|
||||
ResultTask resultTask = resultTaskMapper.selectResultTaskById(second.getId());
|
||||
if(resultTask!=null){
|
||||
resultUpdateTaskReq.setDetailId(resultTask.getDetailId());
|
||||
}
|
||||
String rate = second.getRate();
|
||||
BigDecimal rateRes;
|
||||
if(StringUtil.isNotBlank(rate)){
|
||||
rate = rate.trim();
|
||||
boolean contains = rate.contains("%");
|
||||
if(contains){
|
||||
rate = rate.replaceAll("%", "");
|
||||
}
|
||||
if(contains || new BigDecimal(rate).compareTo(BigDecimal.ONE)>-1){
|
||||
rateRes = new BigDecimal(rate).multiply(BigDecimal.valueOf(0.01));
|
||||
}else {
|
||||
rateRes = new BigDecimal(rate);
|
||||
}
|
||||
|
||||
resultUpdateTaskReq.setProcessRate(rateRes);
|
||||
@Override
|
||||
public R addOrUpdateTask(SysUserEntity user, TaskDto second) {
|
||||
ResultUpdateTaskReq resultUpdateTaskReq = new ResultUpdateTaskReq();
|
||||
resultUpdateTaskReq.setRemark(second.getMark());
|
||||
if ("update".equals(second.getOption())) {
|
||||
resultUpdateTaskReq.setTaskId(second.getId());
|
||||
} else if ("add".equals(second.getOption())) {
|
||||
resultUpdateTaskReq.setDetailId(second.getId());
|
||||
if (StringUtil.isBlank(second.getRate())) {
|
||||
resultUpdateTaskReq.setProcessRate(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
resultUpdateTaskReq.setName(second.getName());
|
||||
ResultTask resultTask = resultTaskMapper.selectResultTaskById(second.getId());
|
||||
if (resultTask != null) {
|
||||
resultUpdateTaskReq.setDetailId(resultTask.getDetailId());
|
||||
}
|
||||
String rate = second.getRate();
|
||||
BigDecimal rateRes;
|
||||
if (StringUtil.isNotBlank(rate)) {
|
||||
rate = rate.trim();
|
||||
boolean contains = rate.contains("%");
|
||||
if (contains) {
|
||||
rate = rate.replaceAll("%", "");
|
||||
}
|
||||
if (contains || new BigDecimal(rate).compareTo(BigDecimal.ONE) > -1) {
|
||||
rateRes = new BigDecimal(rate).multiply(BigDecimal.valueOf(0.01));
|
||||
} else {
|
||||
rateRes = new BigDecimal(rate);
|
||||
}
|
||||
|
||||
}
|
||||
return this.saveOrUpdateResultTask(resultUpdateTaskReq,user.getUserId());
|
||||
}
|
||||
resultUpdateTaskReq.setProcessRate(rateRes);
|
||||
|
||||
}
|
||||
return this.saveOrUpdateResultTask(resultUpdateTaskReq, user.getUserId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -80,5 +80,5 @@ public interface ResultDetailService extends IService<ResultDetail> {
|
||||
|
||||
List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId);
|
||||
|
||||
List<ResultDto> listRecord(SysUserEntity user);
|
||||
|
||||
}
|
||||
@ -359,14 +359,5 @@ public class ResultDetailServiceImpl extends ServiceImpl<ResultDetailMapper, Res
|
||||
return resultDetailMapper.selectNotNoticeResultDetailByRecordId(recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResultDto> listRecord(SysUserEntity user) {
|
||||
List<ResultDto> resultDtos = resultDetailMapper.listRecord(user.getUserId());
|
||||
for(ResultDto resultDto:resultDtos){
|
||||
String rate = resultDto.getRate();
|
||||
BigDecimal bigDecimal = new BigDecimal(rate).setScale(4);
|
||||
resultDto.setRate((bigDecimal.doubleValue() * 100) + "%");
|
||||
}
|
||||
return resultDetailMapper.listRecord(user.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public interface TaskRespMapper extends BaseMapper<TaskResp> {
|
||||
|
||||
void deleteTaskRespByUserId(@Param("userId") Long userId, @Param("command") String command);
|
||||
|
||||
TaskResp selectTaskRespByUserIdIndex(@Param("userId") Long userId, @Param("index") Long index, @Param("command") String command);
|
||||
TaskResp selectTaskRespByUserIdIndex(@Param("userId") Long userId, @Param("index") String index, @Param("command") String command);
|
||||
|
||||
void batchInsertTaskRespList(@Param("taskRespList") List<TaskResp> taskRespList);
|
||||
}
|
||||
@ -37,7 +37,7 @@ public interface TaskRespService extends IService<TaskResp> {
|
||||
|
||||
void deleteInsertLastResult(SysUserEntity user ,List<ResultDto> list,String command);
|
||||
|
||||
TaskResp selectTaskRespByUserIdIndex(Long userId, Long id,String command);
|
||||
TaskResp selectTaskRespByUserIdIndex(Long userId, String id,String command);
|
||||
|
||||
boolean updateIndex(SysUserEntity userEntity, TaskDto taskDto,String command);
|
||||
}
|
||||
@ -85,13 +85,13 @@ public class TaskRespServiceImpl extends ServiceImpl<TaskRespMapper, TaskResp> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskResp selectTaskRespByUserIdIndex(Long userId, Long index,String command ) {
|
||||
public TaskResp selectTaskRespByUserIdIndex(Long userId, String index,String command ) {
|
||||
return taskRespMapper.selectTaskRespByUserIdIndex(userId,index,command);
|
||||
}
|
||||
|
||||
|
||||
public boolean updateIndex(SysUserEntity userEntity, TaskDto taskDto,String command) {
|
||||
TaskResp taskResp = taskRespService.selectTaskRespByUserIdIndex(userEntity.getUserId(), taskDto.getId(),command);
|
||||
TaskResp taskResp = taskRespService.selectTaskRespByUserIdIndex(userEntity.getUserId(), taskDto.getIndex(),command);
|
||||
if (taskResp != null) {
|
||||
if(BaseCommand.add.equals(taskDto.getOption())){
|
||||
taskDto.setId(taskResp.getDetailId());
|
||||
|
||||
@ -118,12 +118,12 @@ public class TaskConvertUtils {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
/* ResultDto resultDto1 = new ResultDto(0, 10l, "哈哈0");
|
||||
ResultDto resultDto2 = new ResultDto(1, 11l, "哈哈1");
|
||||
ResultDto resultDto3 = new ResultDto(2, 12l, "哈哈2");
|
||||
ResultDto resultDto4 = new ResultDto(3, 13l, "哈哈3", "30%");
|
||||
ResultDto[] array = new ResultDto[]{resultDto1, resultDto2, resultDto3, resultDto4};*/
|
||||
List<ResultDto> resultDtos = Arrays.asList();
|
||||
ResultDto resultDto1 = new ResultDto("1.0", "30 %",1l, "哈哈0");
|
||||
ResultDto resultDto2 = new ResultDto("1.1", "30 %", 1l,2l,"哈哈1");
|
||||
ResultDto resultDto3 = new ResultDto("1.2", "30 %", 1l,"哈哈2");
|
||||
ResultDto resultDto4 = new ResultDto("1.3", "30 %",1l, "哈哈3");
|
||||
ResultDto[] array = new ResultDto[]{resultDto1, resultDto2, resultDto3, resultDto4};
|
||||
List<ResultDto> resultDtos = Arrays.asList(array);
|
||||
TwoTuple<List<String>, List<List<String>>> data = convert(resultDtos).getData();
|
||||
System.out.println(JSON.toJSONString(data.getFirst()));
|
||||
System.out.println(JSON.toJSONString(data.getSecond()));
|
||||
|
||||
@ -217,12 +217,10 @@
|
||||
</select>
|
||||
|
||||
<select id="listRecord" resultType="com.lz.modules.app.dto.ResultDto">
|
||||
SELECT @rownum:=@rownum+1 as 'index',b.id,b.target content,b.process_rate rate from (select @rownum:=0) a,(
|
||||
SELECT d.id,d.target,process_rate from lz_result_record r LEFT JOIN lz_result_detail d
|
||||
SELECT d.id as detailId ,d.target as content,d.process_rate as rate from lz_result_record r LEFT JOIN lz_result_detail d
|
||||
on r.id = d.record_id
|
||||
where r.is_delete = 0 and d.is_delete=0 and d.staff_id = #{staffId}
|
||||
where r.is_delete = 0 and d.is_delete=0 and d.staff_id = #{staffId}
|
||||
and r.flow_process < 4
|
||||
) b
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@ -101,7 +101,6 @@
|
||||
</select>
|
||||
|
||||
<select id="listResultTask" resultType="com.lz.modules.app.dto.ResultDto">
|
||||
|
||||
select @rownum:=@rownum+1 as 'index',id,name content,process_rate rate from (select @rownum:=0) a, lz_result_task where is_delete=0
|
||||
<if test="detailIds !=null">
|
||||
and detail_id in
|
||||
@ -111,5 +110,11 @@
|
||||
</if>
|
||||
order by id
|
||||
</select>
|
||||
<select id="listResultTaskByDetailId" resultType="com.lz.modules.performance.entity.ResultTask">
|
||||
select * from lz_result_task where detail_id in
|
||||
<foreach item="detailId" collection="detailIds" open="(" separator="," close=")">
|
||||
#{detailId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user