提交修改

This commit is contained in:
quyixiao 2021-01-27 14:24:17 +08:00
parent 1c3c7c3d23
commit 023d3afdee
14 changed files with 375 additions and 313 deletions

View File

@ -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));
}
}

View File

@ -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;
}
}

View File

@ -68,6 +68,7 @@ public abstract class BaseCommand<T> {
i++;
}
taskDto.setOption(tokens[0]);
taskDto.setIndex(tokens[1]);
return new Tuple(true, taskDto);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -25,18 +25,12 @@ 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>
@ -55,7 +49,8 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
@Autowired
private ResultTaskMapper resultTaskMapper;
@Autowired
private ResultDetailService resultDetailService;;
private ResultDetailService resultDetailService;
;
@Autowired
private TaskProcessRecordService taskProcessRecordService;
@Autowired
@ -66,35 +61,30 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
private ResultDetailMapper resultDetailMapper;
@Override
public ResultTask selectResultTaskById(Long id) {
return resultTaskMapper.selectResultTaskById(id);
}
@Override
public Long insertResultTask(ResultTask resultTask) {
return resultTaskMapper.insertResultTask(resultTask);
}
@Override
public int updateResultTaskById(ResultTask resultTask) {
return resultTaskMapper.updateResultTaskById(resultTask);
}
@Override
public int updateCoverResultTaskById(ResultTask resultTask) {
return resultTaskMapper.updateCoverResultTaskById(resultTask);
}
@Override
public int deleteResultTaskById(Long id) {
return resultTaskMapper.deleteResultTaskById(id);
@ -171,8 +161,7 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
//将插入的id传递过去
req.setTaskId(resultTask.getId());
changeTaskProcess(null, req, null);
}
else {
} else {
log.info("绩效任务修改操作。。。");
resultTask = resultTaskMapper.selectResultTaskById(tasklId);
@ -292,7 +281,6 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
}
@Override
public List<ResultTask> selectResultTasksByDetailId(Long detailId) {
return resultTaskMapper.selectResultTasksByDetailId(detailId);
@ -335,20 +323,49 @@ public class ResultTaskServiceImpl extends ServiceImpl<ResultTaskMapper, ResultT
@Override
public List<ResultDto> listResultTask(SysUserEntity user) {
List<ResultDto> list = new ArrayList<>();
List<ResultDto> resultDtos = resultDetailMapper.listRecord(user.getUserId());
if (CollectionUtils.isEmpty(resultDtos)) {
return Collections.EMPTY_LIST;
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;
}
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;
}
@Override
public R addOrUpdateTask(SysUserEntity user, TaskDto second) {

View File

@ -80,5 +80,5 @@ public interface ResultDetailService extends IService<ResultDetail> {
List<ResultDetail> selectNotNoticeResultDetailByRecordId(Long recordId);
List<ResultDto> listRecord(SysUserEntity user);
}

View File

@ -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());
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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());

View File

@ -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()));

View File

@ -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}
and r.flow_process &lt; 4
) b
</select>
</mapper>

View File

@ -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>