Commit c8b75de4 by chenweisong

更新

parent ba069d91
...@@ -12,9 +12,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -12,9 +12,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
//@EnableFeignClients //@EnableFeignClients
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class, @EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.activiti.spring.boot.SecurityAutoConfiguration.class}) org.activiti.spring.boot.SecurityAutoConfiguration.class})
public class ActivitiApplication extends SpringBootServletInitializer{ public class ActivitiApplication extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ActivitiApplication.class, args); SpringApplication.run(ActivitiApplication.class, args);
} }
} }
...@@ -3,8 +3,12 @@ package com.keymobile.rest.ctrl; ...@@ -3,8 +3,12 @@ package com.keymobile.rest.ctrl;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
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.service.ExcelService;
import com.keymobile.rest.service.RecordDataService;
import com.keymobile.rest.service.TaskService; 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.ExcelVO;
import com.keymobile.rest.vo.TaskVO; import com.keymobile.rest.vo.TaskVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,7 +31,10 @@ public class IndexCtrl { ...@@ -27,7 +31,10 @@ public class IndexCtrl {
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@Autowired
private ExcelService excelService;
@Autowired
private RecordDataService recordDataService;
@Autowired @Autowired
private UserService userService; private UserService userService;
...@@ -56,14 +63,15 @@ public class IndexCtrl { ...@@ -56,14 +63,15 @@ public class IndexCtrl {
@ApiOperation(value = "新建收数") @ApiOperation(value = "新建收数")
@PostMapping(value = "/task/create") @PostMapping(value = "/task/create")
public Map createTask(TaskVO task) { public Map createTask(TaskVO vo) {
long id = taskService.create(vo);
return ImmutableMap.of("code", 200); return ImmutableMap.of("code", 200, "data", id);
} }
@ApiOperation(value = "手动发起收数") @ApiOperation(value = "手动发起收数")
@PostMapping(value = "/task/start") @PostMapping(value = "/task/start")
public Map startTask(@RequestParam int id) { public Map startTask(@RequestParam int id) {
taskService.start(id);
return ImmutableMap.of("code", 200); return ImmutableMap.of("code", 200);
} }
...@@ -71,6 +79,7 @@ public class IndexCtrl { ...@@ -71,6 +79,7 @@ public class IndexCtrl {
@ApiOperation(value = "审核通过收数") @ApiOperation(value = "审核通过收数")
@PostMapping(value = "/task/pass") @PostMapping(value = "/task/pass")
public Map passTask(@RequestParam int id) { public Map passTask(@RequestParam int id) {
taskService.pass(id);
return ImmutableMap.of("code", 200); return ImmutableMap.of("code", 200);
} }
...@@ -78,6 +87,7 @@ public class IndexCtrl { ...@@ -78,6 +87,7 @@ public class IndexCtrl {
@ApiOperation(value = "审核驳回收数") @ApiOperation(value = "审核驳回收数")
@PostMapping(value = "/task/reject") @PostMapping(value = "/task/reject")
public Map rejectTask(@RequestParam int id) { public Map rejectTask(@RequestParam int id) {
taskService.reject(id);
return ImmutableMap.of("code", 200); return ImmutableMap.of("code", 200);
} }
...@@ -89,5 +99,19 @@ public class IndexCtrl { ...@@ -89,5 +99,19 @@ public class IndexCtrl {
return ImmutableMap.of("code", 200, "data", userList); return ImmutableMap.of("code", 200, "data", userList);
} }
@ApiOperation(value = "新建模板")
@PostMapping(value = "/excel/create")
public Map saveExcel(ExcelVO vo) {
int id = excelService.create(vo);
return ImmutableMap.of("code", 200, "data", id);
}
@ApiOperation(value = "填写补录数据")
@PostMapping(value = "/excel/saveData")
public Map saveRecordData(DataVo vo) {
recordDataService.create(vo);
return ImmutableMap.of("code", 200);
}
} }
...@@ -6,4 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -6,4 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
public interface ExcelDao extends JpaRepository<Excel, Long> { public interface ExcelDao extends JpaRepository<Excel, Long> {
List<Excel> findAllByIdIn(List<Long> ids);
} }
...@@ -3,5 +3,12 @@ package com.keymobile.rest.dao; ...@@ -3,5 +3,12 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordData; import com.keymobile.rest.model.RecordData;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface ExcelDataDao extends JpaRepository<RecordData, Long> { public interface RecordDataDao extends JpaRepository<RecordData, Long> {
} }
package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface RecordInfoDao extends JpaRepository<RecordInfo, Long> {
}
...@@ -11,5 +11,4 @@ public interface TaskDao extends JpaRepository<Task, Long> { ...@@ -11,5 +11,4 @@ public interface TaskDao extends JpaRepository<Task, Long> {
Page<Task> findAllByNameLike(String valueOf, Pageable pageable); Page<Task> findAllByNameLike(String valueOf, Pageable pageable);
} }
...@@ -8,4 +8,7 @@ import java.util.List; ...@@ -8,4 +8,7 @@ import java.util.List;
public interface UserDao extends JpaRepository<User, Long> { public interface UserDao extends JpaRepository<User, Long> {
List<User> findAllByRole(int role); List<User> findAllByRole(int role);
List<User> findAllByIdIn(List<Long> ids);
} }
...@@ -9,6 +9,7 @@ import org.hibernate.annotations.CreationTimestamp; ...@@ -9,6 +9,7 @@ import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List;
/** /**
* spreadJs 配置的报表 * spreadJs 配置的报表
...@@ -23,6 +24,11 @@ public class Excel implements Serializable { ...@@ -23,6 +24,11 @@ public class Excel implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
@Column(columnDefinition = "VARCHAR(300) COMMENT 'SpreadJs表格配置'")
private String config;
@Column(columnDefinition = "VARCHAR(50) COMMENT '备注'")
private String desc;
@Column(columnDefinition = "DATETIME COMMENT '创建时间'") @Column(columnDefinition = "DATETIME COMMENT '创建时间'")
@CreationTimestamp @CreationTimestamp
...@@ -31,4 +37,8 @@ public class Excel implements Serializable { ...@@ -31,4 +37,8 @@ public class Excel implements Serializable {
// 级别游离关联, 当加载的时候急加载这个对象 // 级别游离关联, 当加载的时候急加载这个对象
@ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER) @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
private Task task; private Task task;
@OneToMany
@JsonIgnore
private List<RecordInfo> recordInfoList;
} }
...@@ -29,7 +29,7 @@ public class RecordData implements Serializable { ...@@ -29,7 +29,7 @@ public class RecordData implements Serializable {
private Timestamp createAt; private Timestamp createAt;
@ManyToOne @ManyToOne
@JsonIgnore
private RecordInfo recordInfo; private RecordInfo recordInfo;
} }
...@@ -33,6 +33,9 @@ public class RecordInfo implements Serializable { ...@@ -33,6 +33,9 @@ public class RecordInfo implements Serializable {
@JsonIgnore @JsonIgnore
List<RecordData> recordDataList; List<RecordData> recordDataList;
@ManyToOne
private Excel excel;
@OneToOne @OneToOne
private User user; private User user;
......
...@@ -22,6 +22,16 @@ import java.util.List; ...@@ -22,6 +22,16 @@ import java.util.List;
@Entity @Entity
public class Task implements Serializable { public class Task implements Serializable {
public static int TYPE_AUTO = 2;
public static int TYPE_MANUAL = 1;
public static int STATUS_RELEASED = 2;
public static int STATUS_UNRELEASED = 1;
public static int JUDGE_NEED = 2;
public static int JUDGE_NO_NEED = 1;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; private long id;
...@@ -39,6 +49,9 @@ public class Task implements Serializable { ...@@ -39,6 +49,9 @@ public class Task implements Serializable {
private int judge = 2; private int judge = 2;
@Column @Column
private long processId;
@Column
private Timestamp startAt; private Timestamp startAt;
@Column(nullable = false) @Column(nullable = false)
......
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.rest.dao.ExcelDao; import com.keymobile.rest.dao.*;
import com.keymobile.rest.dao.ExcelDataDao; 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;
import java.util.List;
@Service @Service
public class ExcelService { public class ExcelService {
@Autowired @Autowired
private TaskDao taskDao;
@Autowired
private UserDao userDao;
@Autowired
private ExcelDao excelDao; private ExcelDao excelDao;
@Autowired @Autowired
private ExcelDataDao excelDataDao; private RecordInfoDao recordInfoDao;
public int create(ExcelVO vo) {
return 0;
}
} }
package com.keymobile.rest.service;
import com.keymobile.rest.dao.ExcelDao;
import com.keymobile.rest.dao.RecordInfoDao;
import com.keymobile.rest.dao.TaskDao;
import com.keymobile.rest.dao.UserDao;
import com.keymobile.rest.vo.DataVo;
import com.keymobile.rest.vo.ExcelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class RecordDataService {
@Autowired
private TaskDao taskDao;
@Autowired
private UserDao userDao;
@Autowired
private ExcelDao excelDao;
@Autowired
private RecordInfoDao recordInfoDao;
public int create(DataVo vo) {
return 0;
}
}
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.activiti.utils.DateUtil;
import com.keymobile.rest.dao.ExcelDao;
import com.keymobile.rest.dao.RecordInfoDao;
import com.keymobile.rest.dao.TaskDao; import com.keymobile.rest.dao.TaskDao;
import com.keymobile.rest.dao.UserDao;
import com.keymobile.rest.model.Excel;
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.vo.TaskVO;
import javassist.compiler.ast.ASTList;
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;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -9,19 +18,66 @@ import org.springframework.data.domain.Pageable; ...@@ -9,19 +18,66 @@ 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 java.sql.Array;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class TaskService { public class TaskService {
@Autowired @Autowired
private TaskDao taskDao; private TaskDao taskDao;
@Autowired
private UserDao userDao;
@Autowired
private ExcelDao excelDao;
@Autowired
private RecordInfoDao recordInfoDao;
public Task get(long id) { public Task get(long id) {
return taskDao.getOne(id); return taskDao.getOne(id);
} }
public void save() { public long create(TaskVO vo) {
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
Task task = new Task();
task.setCreateAt(now);
task.setStatus(Task.STATUS_UNRELEASED);
task.setJudge(vo.getJudge());
task.setName(vo.getName());
task.setType(vo.getType());
if (vo.getType() == Task.TYPE_AUTO) {
task.setStartAt(vo.getStartAt());
}
task.setUser(getLoginUser());
taskDao.save(task);
// 新建excel实例
if (vo.getExcelIds() != null) {
String[] excelIds = vo.getExcelIds().split(",");
List<Long> ids = Arrays.asList(excelIds).stream().map(Long::parseLong).collect(Collectors.toList());
List<Excel> excelList = excelDao.findAllByIdIn(ids);
excelList.forEach(excel -> {
excel.setTask(task);
// 新建补录人员任务关联
if (vo.getUserIds() != null) {
String[] userStrIds = vo.getUserIds().split(",");
List<Long> userIds = Arrays.asList(userStrIds).stream().map(Long::parseLong).collect(Collectors.toList());
List<User> userList = userDao.findAllByIdIn(userIds);
userList.forEach(user -> {
RecordInfo info = new RecordInfo();
info.setUser(user);
info.setExcel(excel);
info.setCreateAt(now);
recordInfoDao.save(info);
});
}
});
excelDao.saveAll(excelList);
}
return task.getId();
} }
...@@ -29,6 +85,14 @@ public class TaskService { ...@@ -29,6 +85,14 @@ public class TaskService {
} }
public void pass(long id) {
}
public void reject(long id) {
}
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);
...@@ -51,4 +115,10 @@ public class TaskService { ...@@ -51,4 +115,10 @@ public class TaskService {
return pageable; return pageable;
} }
private User getLoginUser() {
User user = new User();
user.setRole(User.ROLE_MANAGER);
user.setUsername("管理员");
return user;
}
} }
...@@ -17,4 +17,5 @@ public class UserService { ...@@ -17,4 +17,5 @@ public class UserService {
return userDao.findAllByRole(role); return userDao.findAllByRole(role);
} }
} }
package com.keymobile.rest.vo;
public class DataVo {
}
package com.keymobile.rest.vo;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.sql.Timestamp;
@Data
public class ExcelVO {
private long id;
private String config;
private String desc;
}
package com.keymobile.rest.vo; package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.keymobile.rest.model.Excel;
import com.keymobile.rest.model.User;
import lombok.Data; import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.sql.Timestamp; import java.sql.Timestamp;
@Data @Data
public class TaskVO { public class TaskVO {
@Id
private long id; private long id;
private String name; private String name;
...@@ -26,4 +19,14 @@ public class TaskVO { ...@@ -26,4 +19,14 @@ public class TaskVO {
private Timestamp startAt; private Timestamp startAt;
private long userId; private long userId;
/*
新建文件id, 逗号隔开
*/
private String excelIds;
/*
补录人员id, 逗号隔开
*/
private String userIds;
} }
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