|
@@ -1,22 +1,28 @@
|
|
|
package com.sysu.admin.controller.lz.ns.site;
|
|
|
|
|
|
+import com.querydsl.core.types.dsl.BooleanExpression;
|
|
|
import com.sysu.admin.controller.lz.ns.NsActionRecordService;
|
|
|
import com.sysu.admin.controller.lz.ns.NsActionTreeService;
|
|
|
import com.sysu.admin.controller.lz.ns.NsTaskService;
|
|
|
import com.sysu.admin.controller.lz.ns.NsTypeService;
|
|
|
-import com.sysu.admin.controller.lz.ns.bean.NsActionRecord;
|
|
|
-import com.sysu.admin.controller.lz.ns.bean.NsActionTree;
|
|
|
-import com.sysu.admin.controller.lz.ns.bean.NsTask;
|
|
|
-import com.sysu.admin.controller.lz.ns.bean.NsType;
|
|
|
+import com.sysu.admin.controller.lz.ns.bean.*;
|
|
|
+import com.sysu.admin.controller.lz.ns.site.vo.LzTaskVo;
|
|
|
import com.sysu.admin.controller.lz.ns.site.vo.LzUserVo;
|
|
|
import com.sysu.admin.site.CommonVo;
|
|
|
import com.sysu.admin.support.system.user.User;
|
|
|
import com.sysu.admin.support.system.user.UserService;
|
|
|
import com.sysu.admin.support.system.user_role.UserRole;
|
|
|
import com.sysu.admin.support.system.user_role.UserRoleService;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationHelper;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationResult;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationVo;
|
|
|
import com.xiesx.fastboot.base.result.BaseResult;
|
|
|
import com.xiesx.fastboot.base.result.R;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -43,13 +49,35 @@ public class NsTaskController {
|
|
|
private NsActionTreeService actionTreeService;
|
|
|
|
|
|
@RequestMapping("/list")
|
|
|
- public BaseResult list(){
|
|
|
+ public PaginationResult list(@RequestBody LzTaskVo lzTaskVo){
|
|
|
List<NsActionTree> nsActionTrees = actionTreeService.findAll();
|
|
|
+ // 分页
|
|
|
+ Pageable pageable = PageRequest.of(lzTaskVo.getPage(), lzTaskVo.getLimit(), Sort.by(Sort.Direction.DESC, User.FIELDS.createDate));
|
|
|
+
|
|
|
Map<Integer, NsActionTree> integerNsActionTreeMap = listToMap(nsActionTrees);
|
|
|
- List<NsTask> nsTaskList = nsTaskService.findAll(Sort.by("id"));
|
|
|
+ QNsTask qNsTask = QNsTask.nsTask;
|
|
|
+ BooleanExpression expression = qNsTask.nsTypeId.eq(lzTaskVo.getTypeId());
|
|
|
+ if(lzTaskVo.getStatus() != null){
|
|
|
+ expression = expression.and(qNsTask.status.eq(lzTaskVo.getStatus()));
|
|
|
+ }
|
|
|
+ List<NsTask> nullTasks = new ArrayList<>();
|
|
|
+ Page<NsTask> nsTaskList = get(expression, pageable, integerNsActionTreeMap, nullTasks);
|
|
|
+ if(nullTasks.size() > 0){
|
|
|
+ nsTaskService.deleteAll(nullTasks);
|
|
|
+ nsTaskList = get(expression, pageable, integerNsActionTreeMap, nullTasks);
|
|
|
+ }
|
|
|
+ return PaginationHelper.create(nsTaskList);
|
|
|
+ }
|
|
|
|
|
|
- nsTaskList.forEach(nsTask -> {
|
|
|
- nsTask.setRecordList(nsActionRecordService.findAllByTaskId(nsTask.getId()));
|
|
|
+ private Page<NsTask> get(BooleanExpression expression, Pageable pageable, Map<Integer, NsActionTree> integerNsActionTreeMap, List<NsTask> nullTasks){
|
|
|
+ Page<NsTask> nsTaskList = nsTaskService.findAll(expression, pageable);
|
|
|
+
|
|
|
+ nsTaskList.toList().forEach(nsTask -> {
|
|
|
+ List<NsActionRecord> nsActionRecordList = nsActionRecordService.findAllByTaskId(nsTask.getId());
|
|
|
+ if(nsActionRecordList.size() == 0){
|
|
|
+ nullTasks.add(nsTask);
|
|
|
+ }
|
|
|
+ nsTask.setRecordList(nsActionRecordList);
|
|
|
StringBuffer ns = new StringBuffer();
|
|
|
nsTask.getRecordList().stream().forEach(nsActionRecord -> {
|
|
|
NsActionTree a = integerNsActionTreeMap.get(nsActionRecord.getActionId());
|
|
@@ -60,8 +88,11 @@ public class NsTaskController {
|
|
|
User user = userService.findOne(nsTask.getUserId().longValue());
|
|
|
nsTask.setUserName(user.getNickname());
|
|
|
});
|
|
|
- return R.succ(nsTaskList);
|
|
|
+ return nsTaskList;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Map<Integer, NsActionTree> listToMap(List<NsActionTree> nsActionTrees){
|
|
|
Map<Integer, NsActionTree> map = new HashMap<>();
|
|
|
nsActionTrees.forEach(nsActionTree -> {
|
|
@@ -83,9 +114,15 @@ public class NsTaskController {
|
|
|
|
|
|
@RequestMapping("/audit")
|
|
|
public BaseResult audit(@RequestBody CommonVo commonVo){
|
|
|
- NsTask nsTask = nsTaskService.findOne(commonVo.getId().intValue());
|
|
|
- nsTask.setStatus(2);
|
|
|
- nsTaskService.save(nsTask);
|
|
|
- return R.succ();
|
|
|
+ if(ObjectUtils.isNotEmpty(commonVo.getIds())){
|
|
|
+ commonVo.getIds().stream().forEach(aLong -> {
|
|
|
+ NsTask nsTask = nsTaskService.findOne(aLong.intValue());
|
|
|
+ nsTask.setStatus(3);
|
|
|
+ nsTaskService.save(nsTask);
|
|
|
+ });
|
|
|
+ return R.succ();
|
|
|
+ }
|
|
|
+ throw new RuntimeException("没有ids");
|
|
|
+
|
|
|
}
|
|
|
}
|