MobileShipmentController.java
5.61 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
package com.huaheng.mobile.shipment;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.exception.BusinessException;
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.domain.AjaxResult;
import com.huaheng.mobile.invenory.TaskIds;
import com.huaheng.pc.config.company.domain.Company;
import com.huaheng.pc.config.company.service.CompanyService;
import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author mahua
* @ClassName MobileShipmentController
* @projectName wms_xinyi
* @description: TODO
* @date 2020/2/1115:29
*/
@RestController
@RequestMapping("/mobile/shipment")
public class MobileShipmentController extends BaseController {
@Resource
private ShipmentHeaderService shipmentHeaderService;
@Resource
private ShipmentDetailService shipmentDetailService;
@Resource
private ShipmentContainerHeaderService shipmentContainerHeaderService;
@Resource
private CompanyService companyService;
@Autowired
private TaskHeaderService taskHeaderService;
/**
* 自动组盘
* @param shipmentCode
* @return
*/
@PostMapping("/autoCombination")
@ResponseBody
public AjaxResult autoCombination(String shipmentCode){
AjaxResult ajaxResult = shipmentContainerHeaderService.autoCombination(shipmentCode);
return ajaxResult;
}
/**
* 查询出库单主列表
*/
@Log(title = "出库-出库单", operating="查看出库主单", action = BusinessType.GRANT)
@PostMapping("/list")
public AjaxResult list(@RequestBody @ApiParam(value = "出库单号-referCode、货主编码-companyCode、出库单类型-shipmentType") Map<String, String> param) {
if (StringUtils.isEmpty(param.get("companyCode"))) {
return AjaxResult.error("上游系统单号为空");
} else if (StringUtils.isEmpty(param.get("shipmentType"))) {
return AjaxResult.error("类型为空");
} else if (StringUtils.isEmpty(param.get("referCode"))) {
return AjaxResult.error("上游系统单号为空");
}
LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(ShipmentHeader::getDeleted,false)
.in(ShipmentHeader::getCompanyCode, param.get("companyCode"))
.eq(ShipmentHeader::getShipmentType,param.get("shipmentType"))
.eq(ShipmentHeader::getReferCode, param.get("referCode"))
.orderByDesc(ShipmentHeader::getId);
ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(lambdaQueryWrapper);
if (shipmentHeader == null) {
// LambdaQueryWrapper<Company> lambdaQueryWrapper1 = Wrappers.lambdaQuery();
// lambdaQueryWrapper1.eq(Company::getCode, param.get("companyCode"));
// Company company = companyService.getOne(lambdaQueryWrapper1);
// shipmentHeaderService.findErpShipment(String.valueOf(company.getId()), param.get("shipmentType"), param.get("referCode"));
// shipmentHeader = shipmentHeaderService.getOne(lambdaQueryWrapper);
return AjaxResult.error("没有找到出库单");
}
LambdaQueryWrapper<ShipmentDetail> detailLambdaQueryWrapper = Wrappers.lambdaQuery();
detailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentId, shipmentHeader.getId());
Shipment shipment = new Shipment();
shipment.setShipmentHeader(shipmentHeader);
List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(detailLambdaQueryWrapper);
shipment.setShipmentDetailList(shipmentDetailList);
return AjaxResult.success(shipment);
}
/**
* 根据出库单号生成出库任务
*/
@PostMapping("/createShipmentTask")
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult createShipmentTask(@RequestBody List<TaskIds> taskDetails){
ShipmentTaskCreateModel shipmentTask = new ShipmentTaskCreateModel();
List<Integer> taskIds = new ArrayList<>();
for (TaskIds task : taskDetails) {
shipmentTask.setShipmentContainerHeaderIds(task.getTaskId());
AjaxResult ajaxResult = taskHeaderService.createTaskFromShipmentContainers(shipmentTask);
if(ajaxResult.hasErr()){
return ajaxResult;
}
Integer taskId = (Integer)ajaxResult.getData();
taskIds.add(taskId);
}
return AjaxResult.success(taskIds);
}
}