提交修改

This commit is contained in:
quyixiao 2021-01-27 12:14:05 +08:00
parent fd46292a0c
commit 1c3c7c3d23
8 changed files with 80 additions and 270 deletions

View File

@ -34,7 +34,7 @@ public abstract class BaseCommand<T> {
return (T) new Tuple(true); return (T) new Tuple(true);
} }
public Tuple doTaskParse (){ public Tuple doTaskParse() {
TaskDto taskDto = new TaskDto(); TaskDto taskDto = new TaskDto();
taskDto.setId(NumberUtil.objToLong(tokens[1])); taskDto.setId(NumberUtil.objToLong(tokens[1]));
int i = 2; int i = 2;

View File

@ -1,15 +1,22 @@
package com.lz.modules.command.base1000; package com.lz.modules.command.base1000;
import com.alibaba.fastjson.JSON;
import com.lz.common.utils.Constant; import com.lz.common.utils.Constant;
import com.lz.common.utils.NumberUtil;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.utils.t.Tuple; import com.lz.modules.app.utils.t.Tuple;
import com.lz.modules.app.utils.t.TwoTuple;
import com.lz.modules.command.BaseCommand; import com.lz.modules.command.BaseCommand;
import com.lz.modules.command.ICommand; import com.lz.modules.command.ICommand;
import com.lz.modules.command.annotation.Description; import com.lz.modules.command.annotation.Description;
import com.lz.modules.command.annotation.Name; import com.lz.modules.command.annotation.Name;
import com.lz.modules.command.annotation.Option; import com.lz.modules.command.annotation.Option;
import com.lz.modules.command.annotation.Summary; import com.lz.modules.command.annotation.Summary;
import com.lz.modules.flow.model.TaskDto;
import com.lz.modules.performance.service.ResultTaskService;
import com.lz.modules.third.service.TaskRespService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component("add") @Component("add")
@ -35,14 +42,36 @@ public class AddCommand extends BaseCommand<Tuple> implements ICommand<Tuple> {
private String rate; private String rate;
private String mark; private String mark;
@Autowired
private TaskRespService taskRespService;
@Autowired
private ResultTaskService resultTaskService;
@Override @Override
public R process(Tuple tuple) throws Exception { public R process(Tuple tuple) throws Exception {
tuple = doTaskParse();
return null; TwoTuple<Boolean, String> data = tuple.getData();
if (!data.getFirst()) {
return R.error(data.getSecond());
}
if (tokens.length < 3) {
return R.error("add 参数不对,如 task add 1 \"今天任务\"");
}
TaskDto taskDto = (TaskDto) tuple.getData().getSecond();
boolean flag = taskRespService.updateIndex(user, taskDto, "list");
if (!flag) {
return R.error("请先输入 list record");
}
log.info(" 添加数据 " + JSON.toJSONString(taskDto));
R r = resultTaskService.addOrUpdateTask(user, taskDto);
if (NumberUtil.objToIntDefault(r.get("code"), 500) != 200) { //如果返回值不是200
return r;
}
return R.ok(250, "添加任务成功");
} }
@Option(index = 0, shortName = "o") @Option(index = 0, shortName = "o")
@Description("任务操作") @Description("任务操作")
public void setOption(String option) { public void setOption(String option) {

View File

@ -14,7 +14,6 @@ import com.lz.modules.command.annotation.Name;
import com.lz.modules.command.annotation.Summary; import com.lz.modules.command.annotation.Summary;
import com.lz.modules.command.utils.CLI; import com.lz.modules.command.utils.CLI;
import com.lz.modules.command.utils.CLIConfigurator; import com.lz.modules.command.utils.CLIConfigurator;
import com.lz.modules.sys.entity.SysUserEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component("help") @Component("help")

View File

@ -1,74 +0,0 @@
package com.lz.modules.command.base1000;
import com.lz.common.utils.Constant;
import com.lz.common.utils.R;
import com.lz.modules.app.dto.ResultDto;
import com.lz.modules.app.utils.t.Tuple;
import com.lz.modules.app.utils.t.TwoTuple;
import com.lz.modules.command.BaseCommand;
import com.lz.modules.command.ICommand;
import com.lz.modules.command.annotation.Description;
import com.lz.modules.command.annotation.Name;
import com.lz.modules.command.annotation.Option;
import com.lz.modules.command.annotation.Summary;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.service.app.ResultDetailService;
import com.lz.modules.third.service.TaskRespService;
import com.lz.modules.third.utils.TaskConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("record")
@Name("record")
@Summary("查看绩效列表")
@Description(value = Constant.EXAMPLE +
" record list \n"
)
public class RecordCommand extends BaseCommand implements ICommand<Tuple> {
private String l;
@Autowired
private ResultDetailService resultDetailService;
@Autowired
private TaskRespService taskRespService;
@Override
public void init(SysUserEntity user, String[] tokens) throws Exception {
this.user = user;
this.tokens = tokens;
}
@Override
public Tuple check() throws Exception {
if (!list.equals(tokens[1])) {
return new Tuple(false, "record命令的第一个参数目前只能是 list");
}
return new Tuple(true);
}
@Override
public Tuple parse() throws Exception {
return new Tuple(true);
}
@Override
public R process(Tuple o) throws Exception {
List<ResultDto> listRecords = resultDetailService.listRecord(user);
taskRespService.deleteInsertLastResult(user, listRecords,tokens[0]); //保存索引和 id对应关系
TwoTuple<List<String>, List<List<String>>> recordData = TaskConvertUtils.convert(listRecords).getData();
return R.ok().put("header", recordData.getFirst()).put("data", recordData.getSecond());
}
@Option(shortName = "list")
@Description("绩效列表")
public void setL(String l) {
this.l = l;
}
}

View File

@ -1,180 +0,0 @@
package com.lz.modules.command.base1000;
import com.alibaba.fastjson.JSON;
import com.lz.common.utils.*;
import com.lz.modules.app.dto.ResultDto;
import com.lz.modules.app.utils.t.Tuple;
import com.lz.modules.app.utils.t.TwoTuple;
import com.lz.modules.command.BaseCommand;
import com.lz.modules.command.ICommand;
import com.lz.modules.command.annotation.*;
import com.lz.modules.command.utils.CLI;
import com.lz.modules.command.utils.CLIConfigurator;
import com.lz.modules.flow.model.TaskDto;
import com.lz.modules.performance.service.ResultTaskService;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.third.service.TaskRespService;
import com.lz.modules.third.utils.TaskConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.sound.midi.Soundbank;
import java.util.List;
@Component("task")
@Name("task")
@Summary("绩效任务查看 添加 或 更新 ")
@Description(Constant.EXAMPLE +
" task add 1 \"短信开发\"\n" +
" task add 1 \"短信开发\" 30 \n" +
" task add 1 \"短信开发\" 30 \"中途遇到问题,可能会慢一点\"\n" +
" task add 1 -n \"短信开发\" -r 30 \n" +
" task add 1 -n \"短信开发\" \n" +
" task add 1 -nr \"短信开发\" 30 \n" +
" task update 1 -r 30 -m \n" +
" task add 1 -n \"短信开发\" -r 30 -m \"中途遇到问题,可能会慢一点\"\n" +
" task add 1 -nrm \"短信开发\" 30 \"中途遇到问题,可能会慢一点\"\n"
)
@Slf4j
public class TaskCommand extends BaseCommand implements ICommand<Tuple> {
private String option;
private Long id;
private String name;
private String rate;
private String mark;
@Autowired
private ResultTaskService resultTaskService;
@Autowired
private TaskRespService taskRespService;
@Override
public void init(SysUserEntity user, String[] tokens) {
this.user = user;
this.tokens = tokens;
}
@Override
public Tuple check() throws Exception {
return new Tuple(true);
}
@Override
public Tuple parse() throws Exception {
return new Tuple(true);
}
@Override
public R process(Tuple tuple) throws Exception {
TwoTuple<Boolean, String> parse = tuple.getData();
if (!parse.getFirst()) {
return R.error(parse.getSecond());
}
if (add.equals(tokens[1])) {
return add();
} else if (update.equals(tokens[1])) {
return update();
} else if (list.equals(tokens[1])) {
return list();
}
return R.error("未知问题");
}
public R add() throws Exception {
Tuple tuple = doTaskParse();
TwoTuple<Boolean, String> data = tuple.getData();
if (!data.getFirst()) {
return R.error(data.getSecond());
}
if (tokens.length < 4) {
return R.error("task add 参数不对,如 task add 1 \"今天任务\"");
}
if (!NumberUtil.isNumeric(tokens[2])) {
return R.error("命令的第三个参数必需是数字");
}
TaskDto taskDto = (TaskDto) tuple.getData().getSecond();
boolean flag = taskRespService.updateIndex(user, taskDto,"record");
if (!flag) {
return R.error("请先输入 list record");
}
log.info(" 添加数据 " + JSON.toJSONString(taskDto));
R r = resultTaskService.addOrUpdateTask(user, taskDto);
if (NumberUtil.objToIntDefault(r.get("code"), 500) != 200) { //如果返回值不是200
return r;
}
return R.ok(250, "添加任务成功");
}
public R list() throws Exception {
List<ResultDto> list = resultTaskService.listResultTask(user);
taskRespService.deleteInsertLastResult(user, list,tokens[0]); //保存索引和 id对应关系
TwoTuple<List<String>, List<List<String>>> data = TaskConvertUtils.convert(list).getData();
return R.ok().put("header", data.getFirst()).put("data", data.getSecond());
}
public R update() {
Tuple tuple = doTaskParse();
TwoTuple<Boolean, String> data = tuple.getData();
if (!data.getFirst()) {
return R.error(data.getSecond());
}
if (tokens.length < 4) {
return R.error("task add 参数不对,如 task add 1 \"今天任务\"");
}
if (!NumberUtil.isNumeric(tokens[2])) {
return R.error("命令的第三个参数必需是数字");
}
TaskDto taskDto = (TaskDto) tuple.getData().getSecond();
boolean flag = taskRespService.updateIndex(user, taskDto,"task");
if (!flag) {
return R.error("请先输入 list task");
}
log.info(" 更新数据 " + JSON.toJSONString(taskDto));
R r = resultTaskService.addOrUpdateTask(user, taskDto);
if (NumberUtil.objToIntDefault(r.get("code"), 500) != 200) { //如果返回值不是200
return r;
}
return R.ok(250, "更新任务成功");
}
@Option(index = 0,shortName = "o")
@Description("任务操作")
public void setOption(String option) {
this.option = option;
}
@Option(index = 1,shortName = "id")
@Description("任务 id")
public void setId(Long id) {
this.id = id;
}
@Option(index = 2,shortName = "n")
@Description("任务名称")
public void setName(String name) {
this.name = name;
}
@Option(index = 3,shortName = "r")
@Description("任务进度")
public void setRate(String rate) {
this.rate = rate;
}
@Option(index = 4,shortName = "m")
@Description("任务说明")
public void setMark(String mark) {
this.mark = mark;
}
}

View File

@ -1,14 +1,22 @@
package com.lz.modules.command.base1000; package com.lz.modules.command.base1000;
import com.alibaba.fastjson.JSON;
import com.lz.common.utils.Constant; import com.lz.common.utils.Constant;
import com.lz.common.utils.NumberUtil;
import com.lz.common.utils.R; import com.lz.common.utils.R;
import com.lz.modules.app.utils.t.Tuple; import com.lz.modules.app.utils.t.Tuple;
import com.lz.modules.app.utils.t.TwoTuple;
import com.lz.modules.command.BaseCommand; import com.lz.modules.command.BaseCommand;
import com.lz.modules.command.ICommand; import com.lz.modules.command.ICommand;
import com.lz.modules.command.annotation.Description; import com.lz.modules.command.annotation.Description;
import com.lz.modules.command.annotation.Name; import com.lz.modules.command.annotation.Name;
import com.lz.modules.command.annotation.Option; import com.lz.modules.command.annotation.Option;
import com.lz.modules.command.annotation.Summary; import com.lz.modules.command.annotation.Summary;
import com.lz.modules.flow.model.TaskDto;
import com.lz.modules.performance.service.ResultTaskService;
import com.lz.modules.third.service.TaskRespService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component("add") @Component("add")
@ -25,6 +33,7 @@ import org.springframework.stereotype.Component;
" update 1.7 -n \"短信开发\" -r 30 -m \"中途遇到问题,可能会慢一点\"\n" + " update 1.7 -n \"短信开发\" -r 30 -m \"中途遇到问题,可能会慢一点\"\n" +
" update 1.8 -nrm \"短信开发\" 30 \"中途遇到问题,可能会慢一点\"\n" " update 1.8 -nrm \"短信开发\" 30 \"中途遇到问题,可能会慢一点\"\n"
) )
@Slf4j
public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple> { public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple> {
@ -34,14 +43,35 @@ public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple>
private String rate; private String rate;
private String mark; private String mark;
@Autowired
private TaskRespService taskRespService;
@Autowired
private ResultTaskService resultTaskService;
@Override @Override
public R process(Tuple tuple) throws Exception { public R process(Tuple tuple) throws Exception {
tuple = doTaskParse();
return null; TwoTuple<Boolean, String> data = tuple.getData();
if (!data.getFirst()) {
return R.error(data.getSecond());
}
if (tokens.length < 3) {
return R.error("update 参数不对,如 update 1.1 \"今天任务\"");
}
TaskDto taskDto = (TaskDto) tuple.getData().getSecond();
boolean flag = taskRespService.updateIndex(user, taskDto, "list");
if (!flag) {
return R.error("请先输入list 或 选择正确的索引 ,如1 or 1.x");
}
log.info(" 更新请求数据 " + JSON.toJSONString(taskDto));
R r = resultTaskService.addOrUpdateTask(user, taskDto);
if (NumberUtil.objToIntDefault(r.get("code"), 500) != 200) { //如果返回值不是200
return r;
}
return R.ok(250, "更新任务成功");
} }
@Option(index = 0, shortName = "o") @Option(index = 0, shortName = "o")
@Description("任务操作") @Description("任务操作")
public void setOption(String option) { public void setOption(String option) {
@ -74,5 +104,4 @@ public class UpdateCommand extends BaseCommand<Tuple> implements ICommand<Tuple>
} }
} }

View File

@ -31,7 +31,7 @@ public class TaskResp implements java.io.Serializable {
private Date gmtModified; private Date gmtModified;
//索引 //索引
@ApiModelProperty(value = "索引 ", name = "indexId") @ApiModelProperty(value = "索引 ", name = "indexId")
private Long indexId; private String indexId;
//用户 id //用户 id
@ApiModelProperty(value = "用户 id", name = "userId") @ApiModelProperty(value = "用户 id", name = "userId")
private Long userId; private Long userId;
@ -111,14 +111,14 @@ public class TaskResp implements java.io.Serializable {
* 索引 * 索引
* @return * @return
*/ */
public Long getIndexId() { public String getIndexId() {
return indexId; return indexId;
} }
/** /**
* 索引 * 索引
* @param indexId * @param indexId
*/ */
public void setIndexId(Long indexId) { public void setIndexId(String indexId) {
this.indexId = indexId; this.indexId = indexId;
} }

View File

@ -2,6 +2,7 @@ package com.lz.modules.third.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.modules.app.dto.ResultDto; import com.lz.modules.app.dto.ResultDto;
import com.lz.modules.command.BaseCommand;
import com.lz.modules.flow.model.TaskDto; import com.lz.modules.flow.model.TaskDto;
import com.lz.modules.sys.entity.SysUserEntity; import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.third.dao.TaskRespMapper; import com.lz.modules.third.dao.TaskRespMapper;
@ -70,8 +71,9 @@ public class TaskRespServiceImpl extends ServiceImpl<TaskRespMapper, TaskResp> i
List<TaskResp> taskRespList =new ArrayList<>(); List<TaskResp> taskRespList =new ArrayList<>();
for(ResultDto resultDto : list){ for(ResultDto resultDto : list){
TaskResp taskResp = new TaskResp(); TaskResp taskResp = new TaskResp();
/*taskResp.setIndexId(resultDto.getIndex()); taskResp.setIndexId(resultDto.getIndex());
taskResp.setResultId(resultDto.getId());*/ taskResp.setDetailId(resultDto.getDetailId());
taskResp.setTaskId(resultDto.getTaskId());
taskResp.setUserId(user.getUserId()); taskResp.setUserId(user.getUserId());
taskResp.setContent(resultDto.getContent()); taskResp.setContent(resultDto.getContent());
taskResp.setCommand(command); taskResp.setCommand(command);
@ -91,9 +93,14 @@ public class TaskRespServiceImpl extends ServiceImpl<TaskRespMapper, TaskResp> i
public boolean updateIndex(SysUserEntity userEntity, TaskDto taskDto,String 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.getId(),command);
if (taskResp != null) { if (taskResp != null) {
taskDto.setId(taskResp.getDetailId()); if(BaseCommand.add.equals(taskDto.getOption())){
taskDto.setId(taskResp.getDetailId());
}else{
taskDto.setId(taskResp.getTaskId());
}
return true; return true;
} }
return false; return false;
} }