TaskDetailController.java
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.huaheng.pc.task.taskDetail.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.MobileTask;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.sql.rowset.serial.SerialException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 立库任务明细 信息操作处理
*
* @author huaheng
* @date 2018-08-19
*/
@Controller
@RequestMapping("/task/taskDetail")
public class TaskDetailController extends BaseController {
private String prefix = "task/taskDetail";
@Resource
private TaskDetailService taskDetailService;
@Resource
private TaskHeaderService taskHeaderService;
@RequiresPermissions("task:taskHeader:view")
@GetMapping("/{taskId}")
public String taskDetail(@PathVariable("taskId") String taskId, ModelMap mmap) {
mmap.put("taskId", taskId);
return prefix + "/taskDetail";
}
/**
* 查询立库任务明细列表
*/
@RequiresPermissions("task:taskHeader:list")
@Log(title = "任务-任务管理1", operating = "查看立库任务明细1", action = BusinessType.GRANT)
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(TaskDetail taskDetail) {
LambdaQueryWrapper<TaskDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(TaskDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
.in(TaskDetail::getCompanyCode, ShiroUtils.getCompanyCodeList())
.eq(TaskDetail::getTaskId, taskDetail.getTaskId());
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
/**
* 使用分页查询
* 700盘点
*/
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
Page<TaskDetail> page = new Page<>(pageNum, pageSize);
IPage<TaskDetail> iPage = taskDetailService.page(page, lambdaQueryWrapper);
List<TaskDetail> iPages = iPage.getRecords();
for (TaskDetail item : iPages) {
if (item.getTaskType() == 700) {
iPages = taskDetailService.preferenceRealize(iPages);
}
}
return getMpDataTable(iPages, iPage.getTotal());
} else {
List<TaskDetail> list = taskDetailService.list(lambdaQueryWrapper);
for (TaskDetail items : list) {
if (items.getTaskType() == 700) {
list = taskDetailService.preferenceRealize(list);
}
}
return getDataTable(list);
}
}
//@RequiresPermissions("task:taskHeader:report")
@Log(title = "任务", operating = "打印任务明细报表", action = BusinessType.OTHER)
@GetMapping("/report/{ids}")
public String report(@PathVariable("ids") Integer[] ids, ModelMap mmap) {
List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(ids);
mmap.put("task", taskDetailList);
TaskHeader taskHeader = taskHeaderService.getById(taskDetailList.get(0).getTaskId());
mmap.put("taskHeader",taskHeader);
//总行数,总物料数
int totalLines = 0;
totalLines = taskDetailList.size();
//总物料数
BigDecimal t = taskDetailList.stream()
.map(TaskDetail::getQty)
.reduce(BigDecimal.ZERO,BigDecimal::add);
int totalQty = t.intValue();
mmap.put("totalLines",totalLines);
mmap.put("totalQty",totalQty);
return prefix + "/report";
}
}