PDAController.java
6.6 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
package com.huaheng.api.erp.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.erp.domain.ERPReceipt;
import com.huaheng.api.erp.domain.PDAInventory;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
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 io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
@RestController
@RequestMapping("/API/WMS/v2")
public class PDAController extends BaseController {
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private ShipmentHeaderService shipmentHeaderService;
@Resource
private ShipmentDetailService shipmentDetailService;
@PostMapping("/lockInventory")
@ApiOperation("锁定库存")
@ResponseBody
@ApiLogger(apiName = "锁定库存", from="PDA")
@Transactional(rollbackFor = Exception.class)
public AjaxResult lockInventory(@RequestBody PDAInventory pdaInventory) {
String locationCode = pdaInventory.getLocationCode();
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getLocationCode, locationCode);
List<InventoryDetail> inventoryDetailList =
inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
if(inventoryDetailService == null) {
throw new ServiceException("");
}
return null;
}
@PostMapping("/clearInventory")
@ApiOperation("释放库存")
@ResponseBody
@ApiLogger(apiName = "释放库存", from="PDA")
@Transactional(rollbackFor = Exception.class)
public AjaxResult clearInventory(@RequestBody PDAInventory pdaInventory) {
String locationCode = pdaInventory.getLocationCode();
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getLocationCode, locationCode);
List<InventoryDetail> inventoryDetailList =
inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
if(inventoryDetailList == null) {
throw new ServiceException("");
}
return null;
}
@PostMapping("/createShipment")
@ApiOperation("创建销售出库单")
@ResponseBody
@ApiLogger(apiName = "创建销售出库单", from="PDA")
@Transactional(rollbackFor = Exception.class)
public AjaxResult createShipment(@RequestBody PDAInventory pdaInventory) {
String platformCode = pdaInventory.getPlatformCode();
List<String> refereCodeList = pdaInventory.getReferCodeList();
if(StringUtils.isEmpty(platformCode)) {
return AjaxResult.error("没有月台号");
}
if (!(refereCodeList != null && refereCodeList.size() > 0)){
return AjaxResult.error("没有订单");
}
LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
shipmentHeaderLambdaQueryWrapper.in(ShipmentHeader::getReferCode, refereCodeList);
List<ShipmentHeader> shipmentHeaders = shipmentHeaderService.list(shipmentHeaderLambdaQueryWrapper);
if(!(shipmentHeaders != null && shipmentHeaders.size() > 0)) {
return AjaxResult.error("没有找到出库单");
}
for (ShipmentHeader shipmentHeader :shipmentHeaders){
int isCreated = shipmentHeader.getIsCreated();
if(isCreated == 1) {
return AjaxResult.error("出库单已经有创建单据");
}
LambdaQueryWrapper<ShipmentDetail> shipmentDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode, shipmentHeader.getCode());
List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(shipmentDetailLambdaQueryWrapper);
if(shipmentDetails.size() == 0) {
return AjaxResult.error("没有找到出库单详情");
}
String warehouseCode = QuantityConstant.DEFAULT_WAREHOUSE;
String companyCode = QuantityConstant.DEFAULT_COMPANY;
ShipmentHeader shipmentHeader1 = new ShipmentHeader();
String code = shipmentHeaderService.createCode("SO");
shipmentHeader1.setCode(code);
shipmentHeader1.setWarehouseCode(warehouseCode);
shipmentHeader1.setCompanyCode(companyCode);
shipmentHeader1.setTotalQty(BigDecimal.ZERO);
shipmentHeader1.setTotalWeight(BigDecimal.ZERO);
shipmentHeader1.setTotalLines(0);
shipmentHeader1.setPriority(100);
shipmentHeader1.setFirstStatus(0);
shipmentHeader1.setLastStatus(0);
shipmentHeader1.setShipmentType("SO");
shipmentHeader1.setCreatedBy(QuantityConstant.PLATFORM_ERP);
shipmentHeaderService.save(shipmentHeader1);
for(ShipmentDetail shipmentDetail : shipmentDetails) {
shipmentDetail.setCreatedBy(QuantityConstant.PLATFORM_WMS);
shipmentDetail.setLastUpdatedBy(QuantityConstant.PLATFORM_WMS);
shipmentDetail.setSoEntryId(null);
shipmentDetail.setFHTZDetail(null);
shipmentDetail.setTaskQty(new BigDecimal(0));
shipmentDetail.setId(null);
shipmentDetail.setShipmentId(shipmentHeader1.getId());
shipmentDetail.setShipmentCode(shipmentHeader1.getCode());
}
shipmentDetailService.saveBatch(shipmentDetails);
shipmentHeader.setIsCreated(1);
shipmentHeaderService.updateById(shipmentHeader);
}
return AjaxResult.success("创建销售出库单成功");
}
}