Commit 03a361e6 by chenweisong

更新

parent b3f8ecf7
...@@ -9,7 +9,9 @@ import com.keymobile.rest.service.TaskService; ...@@ -9,7 +9,9 @@ import com.keymobile.rest.service.TaskService;
import com.keymobile.rest.service.UserService; import com.keymobile.rest.service.UserService;
import com.keymobile.rest.vo.DataVo; import com.keymobile.rest.vo.DataVo;
import com.keymobile.rest.vo.ExcelVO; import com.keymobile.rest.vo.ExcelVO;
import com.keymobile.rest.vo.TaskVO; import com.sun.xml.internal.ws.wsdl.writer.document.ParamType;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -25,9 +27,6 @@ import java.util.Map; ...@@ -25,9 +27,6 @@ import java.util.Map;
@RequestMapping(path = "/api") @RequestMapping(path = "/api")
public class IndexCtrl { public class IndexCtrl {
private int pageSize = 10;
private String orderBy = "descending"; //
private String propBy = "id"; // groupBy
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
...@@ -40,17 +39,16 @@ public class IndexCtrl { ...@@ -40,17 +39,16 @@ public class IndexCtrl {
@ApiOperation(value = "获取首页收数列表") @ApiOperation(value = "获取首页收数列表")
@PostMapping(value = "/task/list") @PostMapping(value = "/task/list")
public Map getTaskList(@RequestParam(required = false) String name, @RequestParam(required = false) Integer pageNo) { public Map getTaskList(@RequestParam Integer pageNo, @RequestParam Integer pageSize, @RequestParam(required = false) String name) {
if (pageNo == null) {
pageNo = 1;
}
Page<Task> taskList; Page<Task> taskList;
String orderBy = "descending"; //
String propBy = "id"; // groupBy
if (name != null) { if (name != null) {
taskList = taskService.findAllByName(name, pageNo, pageSize, orderBy, propBy); taskList = taskService.findAllByName(name, pageNo, pageSize, orderBy, propBy);
} else { } else {
taskList = taskService.findAll(pageNo, pageSize, orderBy, propBy); taskList = taskService.findAll(pageNo, pageSize, orderBy, propBy);
} }
return ImmutableMap.of("code", 200, "data", taskList.getContent()); return ImmutableMap.of("code", 200, "data", ImmutableMap.of("list", taskList.getContent(), "total", taskList.getTotalElements()));
} }
...@@ -62,9 +60,17 @@ public class IndexCtrl { ...@@ -62,9 +60,17 @@ public class IndexCtrl {
} }
@ApiOperation(value = "新建收数") @ApiOperation(value = "新建收数")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "收数名称", dataType = "String", required = true, paramType = "query"),
@ApiImplicitParam(name = "type", value = "收数类型 1为手动发起 2为自动发起", dataType = "Integer", required = true, paramType = "query"),
@ApiImplicitParam(name = "startAt", value = "自动发起需要提写的时间", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "userIds", value = "补录人员ids 用逗号隔开", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "excelIds", value = "新建的模板ids 用逗号隔开", dataType = "String", paramType = "query"),
})
@PostMapping(value = "/task/create") @PostMapping(value = "/task/create")
public Map createTask(TaskVO vo) { public Map createTask(@RequestParam String name, @RequestParam Integer type,
long id = taskService.create(vo); @RequestParam(required = false) String startAt, @RequestParam(required = false) String userIds, @RequestParam(required = false) String excelIds) {
long id = taskService.create(name, type, startAt, userIds, excelIds);
return ImmutableMap.of("code", 200, "data", id); return ImmutableMap.of("code", 200, "data", id);
} }
...@@ -107,8 +113,8 @@ public class IndexCtrl { ...@@ -107,8 +113,8 @@ public class IndexCtrl {
@ApiOperation(value = "新建模板") @ApiOperation(value = "新建模板")
@PostMapping(value = "/excel/create") @PostMapping(value = "/excel/create")
public Map saveExcel(ExcelVO vo) { public Map saveExcel(@RequestParam String config, @RequestParam(required = false) String desc) {
int id = excelService.create(vo); long id = excelService.create(config, desc);
return ImmutableMap.of("code", 200, "data", id); return ImmutableMap.of("code", 200, "data", id);
} }
......
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.rest.dao.*; import com.keymobile.rest.dao.*;
import com.keymobile.rest.model.Excel;
import com.keymobile.rest.vo.ExcelVO; import com.keymobile.rest.vo.ExcelVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,7 +19,11 @@ public class ExcelService { ...@@ -18,7 +19,11 @@ public class ExcelService {
private RecordInfoDao recordInfoDao; private RecordInfoDao recordInfoDao;
public int create(ExcelVO vo) { public long create(String config , String desc) {
return 0; Excel excel = new Excel();
excel.setConfig(config);
excel.setDesc(desc);
excelDao.save(excel);
return excel.getId();
} }
} }
...@@ -9,14 +9,17 @@ import com.keymobile.rest.model.Excel; ...@@ -9,14 +9,17 @@ import com.keymobile.rest.model.Excel;
import com.keymobile.rest.model.RecordInfo; import com.keymobile.rest.model.RecordInfo;
import com.keymobile.rest.model.Task; import com.keymobile.rest.model.Task;
import com.keymobile.rest.model.User; import com.keymobile.rest.model.User;
import com.keymobile.rest.vo.TaskVO;
import javassist.compiler.ast.ASTList; import javassist.compiler.ast.ASTList;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.sql.Array; import java.sql.Array;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -36,36 +39,40 @@ public class TaskService { ...@@ -36,36 +39,40 @@ public class TaskService {
@Autowired @Autowired
private RecordInfoDao recordInfoDao; private RecordInfoDao recordInfoDao;
@Value("${}")
private String PRO = "";
public Task get(long id) { public Task get(long id) {
return taskDao.getOne(id); return taskDao.getOne(id);
} }
public long create(TaskVO vo) {
public long create(String name, Integer type, String startAt, String userIds, String excelIds) {
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime()); Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
Task task = new Task(); Task task = new Task();
task.setCreateAt(now); task.setCreateAt(now);
task.setStatus(Task.STATUS_UNRELEASED); task.setStatus(Task.STATUS_UNRELEASED);
task.setJudge(vo.getJudge()); task.setJudge(Task.JUDGE_NEED);
task.setName(vo.getName()); task.setName(name);
task.setType(vo.getType()); task.setType(type);
if (vo.getType() == Task.TYPE_AUTO) { if (type == Task.TYPE_AUTO) {
task.setStartAt(vo.getStartAt()); task.setStartAt(Timestamp.valueOf(startAt));
} }
task.setUser(getLoginUser()); task.setUser(getLoginUser());
taskDao.save(task); taskDao.save(task);
// 新建excel实例 // 新建excel实例
if (vo.getExcelIds() != null) { if (excelIds != null) {
String[] excelIds = vo.getExcelIds().split(","); String[] excelIdArr = excelIds.split(",");
List<Long> ids = Arrays.asList(excelIds).stream().map(Long::parseLong).collect(Collectors.toList()); List<Long> ids = Arrays.asList(excelIdArr).stream().map(Long::parseLong).collect(Collectors.toList());
List<Excel> excelList = excelDao.findAllByIdIn(ids); List<Excel> excelList = excelDao.findAllByIdIn(ids);
excelList.forEach(excel -> { excelList.forEach(excel -> {
excel.setTask(task); excel.setTask(task);
// 新建补录人员任务关联 // 新建补录人员任务关联
if (vo.getUserIds() != null) { if (userIds != null) {
String[] userStrIds = vo.getUserIds().split(","); String[] userStrIdArr = userIds.split(",");
List<Long> userIds = Arrays.asList(userStrIds).stream().map(Long::parseLong).collect(Collectors.toList()); List<Long> userIdList = Arrays.asList(userStrIdArr).stream().map(Long::parseLong).collect(Collectors.toList());
List<User> userList = userDao.findAllByIdIn(userIds); List<User> userList = userDao.findAllByIdIn(userIdList);
userList.forEach(user -> { userList.forEach(user -> {
RecordInfo info = new RecordInfo(); RecordInfo info = new RecordInfo();
info.setUser(user); info.setUser(user);
...@@ -82,7 +89,15 @@ public class TaskService { ...@@ -82,7 +89,15 @@ public class TaskService {
public void start(long id) { public void start(long id) {
Task task = taskDao.getOne(id);
// 启动流程 // 启动流程
// 获取流的引擎
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
processEngine.getRepositoryService()
.createDeployment()
.addClasspathResource("demo.bpmn")
.addClasspathResource("demo.bpmn.png")
.deploy();
} }
public void pass(long id) { public void pass(long id) {
...@@ -93,6 +108,16 @@ public class TaskService { ...@@ -93,6 +108,16 @@ public class TaskService {
} }
public Page<Task> findAll(int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize);
return taskDao.findAll(pageable);
}
public Page<Task> findAllByName(String name, int pageNo, int pageSize) {
Pageable pageable = convert(pageNo, pageSize);
return taskDao.findAllByNameLike(("%" + name + "%"), pageable);
}
public Page<Task> findAll(int pageNo, int pageSize, String orderBy, String propBy) { public Page<Task> findAll(int pageNo, int pageSize, String orderBy, String propBy) {
Pageable pageable = convert(pageNo, pageSize, orderBy, propBy); Pageable pageable = convert(pageNo, pageSize, orderBy, propBy);
return taskDao.findAll(pageable); return taskDao.findAll(pageable);
...@@ -104,14 +129,27 @@ public class TaskService { ...@@ -104,14 +129,27 @@ public class TaskService {
} }
private Pageable convert(int pageNo, int pageSize, String orderBy, String propBy) { private Pageable convert(int pageNo, int pageSize, String orderBy, String propBy) {
pageNo--;
if (pageNo < 0) {
pageNo = 0;
}
Sort.Direction direction = orderBy.equals("descending") ? Sort.Direction.DESC : Sort.Direction.ASC; Sort.Direction direction = orderBy.equals("descending") ? Sort.Direction.DESC : Sort.Direction.ASC;
Sort order_; Sort sort;
if (propBy.contains("-")) { if (propBy.contains("-")) {
order_ = Sort.by(direction, propBy.split("-")); sort = Sort.by(direction, propBy.split("-"));
} else { } else {
order_ = Sort.by(direction, propBy); sort = Sort.by(direction, propBy);
}
Pageable pageable = PageRequest.of(pageNo, pageSize, sort);
return pageable;
}
private Pageable convert(int pageNo, int pageSize) {
pageNo--;
if (pageNo < 0) {
pageNo = 0;
} }
Pageable pageable = PageRequest.of(pageNo, pageSize, order_); Pageable pageable = PageRequest.of(pageNo, pageSize);
return pageable; return pageable;
} }
......
...@@ -47,6 +47,8 @@ server: ...@@ -47,6 +47,8 @@ server:
# prefer-ip-address: true # prefer-ip-address: true
# hostname: 192.168.0.13 # hostname: 192.168.0.13
security: security:
permit: true permit: true
authUser: root authUser: root
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1583416072125" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema"> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1583416072125" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="demo" isClosed="false" isExecutable="true" name="demo" processType="None"> <process id="demo" isClosed="false" isExecutable="true" name="demo" processType="None">
<startEvent id="Start" name="Start"/> <startEvent id="Start" name="Start"/>
<userTask activiti:assignee="chenws" activiti:exclusive="true" id="_3" name="请假"/> <userTask activiti:assignee="chenws" activiti:exclusive="true" id="请假" name="请假"/>
<sequenceFlow id="_4" sourceRef="Start" targetRef="_3"/> <sequenceFlow id="_4" sourceRef="Start" targetRef="请假"/>
<userTask activiti:assignee="主管" activiti:exclusive="true" id="主管" name="主管"/> <userTask activiti:assignee="主管" activiti:exclusive="true" id="主管" name="主管"/>
<sequenceFlow id="_6" sourceRef="_3" targetRef="主管"/> <sequenceFlow id="_6" sourceRef="请假" targetRef="主管"/>
<userTask activiti:assignee="总监" activiti:exclusive="true" id="总监" name="总监"/> <userTask activiti:assignee="总监" activiti:exclusive="true" id="总监" name="总监"/>
<sequenceFlow id="_8" sourceRef="主管" targetRef="总监"/> <sequenceFlow id="_8" sourceRef="主管" targetRef="总监"/>
<endEvent id="_9" name="EndEvent"/> <endEvent id="_9" name="EndEvent"/>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3"> <bpmndi:BPMNShape bpmnElement="请假" id="Shape-请假">
<omgdc:Bounds height="55.0" width="85.0" x="155.0" y="115.0"/> <omgdc:Bounds height="55.0" width="85.0" x="155.0" y="115.0"/>
<bpmndi:BPMNLabel> <bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
......
...@@ -53,13 +53,18 @@ public class ProcessTest { ...@@ -53,13 +53,18 @@ public class ProcessTest {
@Test @Test
public void zhuguan() { public void zhuguan() {
try { // try {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
List<ProcessDefinition> processDefList = processEngine.getRepositoryService().createProcessDefinitionQuery() //
.orderByProcessDefinitionVersion().asc()//按照版本的升序排列 // List<ProcessDefinition> processDefList = processEngine.getRepositoryService().createProcessDefinitionQuery()
.list(); // .orderByProcessDefinitionVersion().asc()//按照版本的升序排列
for (ProcessDefinition processDefinition : processDefList) { // .list();
System.out.println(processDefinition.getName()); // for (ProcessDefinition processDefinition : processDefList) {
// System.out.println(processDefinition.getName());
//
// runtimeService.startProcessInstanceByKey(processDefinition.getKey());//流程的名称,也可以使用ByID来启动流
// repositoryService.deleteDeployment(processDefinition.getDeploymentId()); // repositoryService.deleteDeployment(processDefinition.getDeploymentId());
// repositoryService.suspendProcessDefinitionByKey(processDefinition.getKey()); // repositoryService.suspendProcessDefinitionByKey(processDefinition.getKey());
...@@ -73,9 +78,9 @@ public class ProcessTest { ...@@ -73,9 +78,9 @@ public class ProcessTest {
// runtimeService.deleteProcessInstance(pi.getId(), "删除原因");//删除流程 // runtimeService.deleteProcessInstance(pi.getId(), "删除原因");//删除流程
// }); // });
} // }
List<Task> tasks = processEngine.getTaskService().createTaskQuery().list(); List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskAssignee("chenws").list();
for (Task task : tasks) { for (Task task : tasks) {
System.out.println(task.getName() + "***" + task.getAssignee()); System.out.println(task.getName() + "***" + task.getAssignee());
} }
...@@ -83,8 +88,8 @@ public class ProcessTest { ...@@ -83,8 +88,8 @@ public class ProcessTest {
// DeploymentBuilder deployBuilder = repositoryService.createDeployment().; // DeploymentBuilder deployBuilder = repositoryService.createDeployment().;
} catch (Exception e) { // } catch (Exception e) {
System.out.println(e.getMessage()); // System.out.println(e.getMessage());
} // }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment