MobileTaskController.java
9.8 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package com.huaheng.mobile.task;
import com.alibaba.fastjson.JSONException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.ShipmentDomain;
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.domain.AjaxResult;
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
* @author Enzo Cotter
* @date 2019/12/15
*/
@CrossOrigin
@RestController
@RequestMapping("/mobile/task")
@Api(tags = {"手持立体库库存相关"}, value = "手持立体库库存相关")
public class MobileTaskController {
@Autowired
private TaskHeaderService taskHeaderService;
@Autowired
private TaskDetailService taskDetailService;
@Autowired
private InventoryTransactionService inventoryTransactionService;
@PostMapping("/searchTask")
@ApiOperation("移动端查询任务")
@Log(title = "移动端查询任务", action = BusinessType.OTHER)
public AjaxResult searchTask(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){
String companyCode = param.get("companyCode");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now = df.format(new Date());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, -7);
Date first = c.getTime();
String start = df.format(first);//前一天
LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper.eq(TaskHeader::getCompanyCode, companyCode)
.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.le(TaskHeader::getCreated, now)
.gt(TaskHeader::getCreated, start)
.orderByDesc(TaskHeader::getCreated);
List<TaskHeader> taslHeaderList = taskHeaderService.list(taskHeaderQueryWrapper);
return AjaxResult.success(taslHeaderList);
}
@PostMapping("/searchTaskInCondition")
@ApiOperation("移动端查询任务")
@Log(title = "移动端查询任务", action = BusinessType.OTHER)
public AjaxResult searchTaskInCondition(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){
String companyCode = param.get("companyCode");
String taskType = param.get("taskType");
String containerCode = param.get("containerCode");
String fromLocatrion = param.get("fromLocatrion");
String toLocation = param.get("toLocation");
String status = param.get("status");
String startTime = param.get("startTime");
String endTime = param.get("endTime");
LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper
.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(StringUtils.isNotEmpty(taskType), TaskHeader::getTaskType, taskType)
.eq(StringUtils.isNotEmpty(containerCode), TaskHeader::getContainerCode, containerCode)
.eq(StringUtils.isNotEmpty(fromLocatrion), TaskHeader::getFromLocation, fromLocatrion)
.eq(StringUtils.isNotEmpty(toLocation), TaskHeader::getToLocation, toLocation)
.eq(StringUtils.isNotEmpty(status), TaskHeader::getStatus, status)
.gt(StringUtils.isNotEmpty(startTime), TaskHeader::getCreated, startTime)
.le(StringUtils.isNotEmpty(endTime), TaskHeader::getCreated, endTime)
.orderByDesc(TaskHeader::getCreated);
if(status.equals("99")) {
taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper
.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(StringUtils.isNotEmpty(taskType), TaskHeader::getTaskType, taskType)
.eq(StringUtils.isNotEmpty(containerCode), TaskHeader::getContainerCode, containerCode)
.eq(StringUtils.isNotEmpty(fromLocatrion), TaskHeader::getFromLocation, fromLocatrion)
.eq(StringUtils.isNotEmpty(toLocation), TaskHeader::getToLocation, toLocation)
.le(StringUtils.isNotEmpty(status), TaskHeader::getStatus, status)
.gt(StringUtils.isNotEmpty(startTime), TaskHeader::getCreated, startTime)
.le(StringUtils.isNotEmpty(endTime), TaskHeader::getCreated, endTime)
.orderByDesc(TaskHeader::getCreated);
}
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderQueryWrapper);
return AjaxResult.success(taskHeaderList);
}
@PostMapping("/findTask")
@ApiOperation("移动端查询任务详情")
@Log(title = "移动端查询任务详情", action = BusinessType.OTHER)
public AjaxResult findTask(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){
String taskHeadId = param.get("taskHeadId");
String companyCode = param.get("companyCode");
if (StringUtils.isNull(taskHeadId)){
return AjaxResult.error("任务id为空");
} else if (StringUtils.isNull(companyCode)){
return AjaxResult.error("公司编码为空");
}
/* 查询入库单,如果数据库中不存在,则调用ERP接口拉取单据,成功后再次查询返回结果*/
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getId, taskHeadId);
TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
if(taskHeader == null) {
return AjaxResult.error("没有找到任务");
}
TaskDomain taskDomain = new TaskDomain();
taskDomain.setTaskHeader(taskHeader);
LambdaQueryWrapper<TaskDetail> taskDetailQueryWrapper = Wrappers.lambdaQuery();
taskDetailQueryWrapper.eq(TaskDetail::getTaskId, taskHeader.getId());
List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailQueryWrapper);
taskDomain.setTaskDetails(taskDetailList);
return AjaxResult.success(taskDomain);
}
@PostMapping("/searchTodayInfo")
@ApiOperation("移动端查询今天信息")
@Log(title = "移动端查询今天信息", action = BusinessType.OTHER)
public AjaxResult searchTodayInfo(@RequestBody @ApiParam(value = "物料号") Map<String, String> param){
TodayInfo todayInfo = new TodayInfo();
String companyCode = param.get("companyCode");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String now = df.format(new Date());
now = now + " 23:59:59";
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, 0);
Date first = c.getTime();
String start = df.format(first);//前一天
start = start + " 00:00:00";
LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper.eq(TaskHeader::getCompanyCode, companyCode)
.eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.le(TaskHeader::getCreated, now)
.gt(TaskHeader::getCreated, start)
.orderByDesc(TaskHeader::getCreated);
List<TaskHeader> taslHeaderList = taskHeaderService.list(taskHeaderQueryWrapper);
todayInfo.setTodayTAask(taslHeaderList.size());
LambdaQueryWrapper<InventoryTransaction> inventoryTransactionLambdaQueryWrapperQuery = Wrappers.lambdaQuery();
inventoryTransactionLambdaQueryWrapperQuery.eq(InventoryTransaction::getCompanyCode, companyCode)
.eq(InventoryTransaction::getWarehouseCode, ShiroUtils.getWarehouseCode())
.le(InventoryTransaction::getCreated, now)
.gt(InventoryTransaction::getCreated, start)
.orderByDesc(InventoryTransaction::getCreated);
int todayReceipt = 0, todayShipment = 0;
List<InventoryTransaction> inventoryTransactionList = inventoryTransactionService.list(inventoryTransactionLambdaQueryWrapperQuery);
if(inventoryTransactionList != null) {
for (InventoryTransaction inventoryTransaction : inventoryTransactionList) {
if(inventoryTransaction.getTransactionType() == 10) {
todayReceipt = todayReceipt + inventoryTransaction.getTaskQty().intValue();
} else if(inventoryTransaction.getTransactionType() == 20) {
todayShipment = todayShipment + inventoryTransaction.getTaskQty().intValue();
}
}
}
todayInfo.setTodayReceipt(todayReceipt);
todayInfo.setTodayShipment(todayShipment);
return AjaxResult.success(todayInfo);
}
}