ShippingCombinationController.java
6.1 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
package com.huaheng.pc.shipment.shippingCombination.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.pc.config.material.service.MaterialServiceImpl;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService;
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel;
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailServiceImpl;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.shipment.shippingCombination.service.ShippingCombinationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@RequestMapping("/shipment/shippingCombination")
public class ShippingCombinationController extends BaseController {
private String prefix = "shipment/shippingCombination";
@Autowired
MaterialServiceImpl materialService;
@Autowired
ShipmentDetailServiceImpl shipmentDetailService;
@Autowired
ShippingCombinationService shippingCombinationService;
@Autowired
ShipmentContainerHeaderService shipmentContainerHeaderService;
@Autowired
ShipmentContainerDetailService shipmentContainerDetailService;
@Autowired
ShipmentHeaderService shipmentHeaderService;
@Autowired
InventoryDetailService inventoryDetailService;
/**
* 打开出库组盘页面
* @param shipmentCode
* @param map
* @return
*/
@RequiresPermissions("shipment:shippingCombination:view")
@GetMapping()
public String ShippingCombination(String shipmentCode, ModelMap map){
map.put("code", shipmentCode);
return prefix+"/shippingCombination";
}
/**
* 获取单据列表
* @param code
* @return
*/
@GetMapping("/listShipmentDetail")
@ResponseBody
public AjaxResult listShipmentDetail(String code){
if(StringUtils.isEmpty(code)){
return null;
}
LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode,code)
.in(ShipmentDetail::getCompanyCode,ShiroUtils.getCompanyCodeList())
.eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode());
List<ShipmentDetail> shipmentDetails =shipmentDetailService.list(lambdaQueryWrapper) ;
return AjaxResult.success(shipmentDetails);
}
/**
* 获取能出库的库存列表
* @param code,id
* @return
*/
@PostMapping("/getInventory")
@ResponseBody
public TableDataInfo getInventory(String code, Integer id){
//找到主单的账套和u8仓库
LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentHeader::getCode,code)
.eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode());
ShipmentHeader shipmentHeader=shipmentHeaderService.getOne(lambdaQueryWrapper);
if(shipmentHeader==null){
throw new ServiceException("找不到主单");
}
//找到子单物料
ShipmentDetail shipmentDetail=new ShipmentDetail();
shipmentDetail=shipmentDetailService.getById(id);
if(shipmentDetail==null){
throw new ServiceException("找不到子单");
}
LambdaQueryWrapper<InventoryDetail> lam = Wrappers.lambdaQuery();
lam.eq(InventoryDetail::getWarehouseCode,shipmentHeader.getWarehouseCode())
.eq(InventoryDetail::getCompanyCode,shipmentHeader.getCompanyCode())
.eq(InventoryDetail::getMaterialName,shipmentDetail.getMaterialCode());
List<InventoryDetail> list= inventoryDetailService.list(lam);
return getDataTable(list);
}
/**
* 保存组盘
* @param shipmentCombinationModel
* @return
*/
@RequiresPermissions("shipment:shippingCombination:combination")
@PostMapping("/Addcombination")
@ResponseBody
public AjaxResult Addcombination(ShipmentCombinationModel shipmentCombinationModel){
ShipmentContainerHeader shipmentContainerHeader= shipmentContainerHeaderService.combination(shipmentCombinationModel);
return AjaxResult.success(shipmentContainerHeader.getId());
}
/**
* 自动组盘
* @param shipmentCode
* @return
*/
@RequiresPermissions("shipment:shippingCombination:combination")
@PostMapping("/autoCombination")
@ResponseBody
public AjaxResult autoCombination(String shipmentCode){
AjaxResult ajaxResult = shipmentContainerHeaderService.autoCombination(shipmentCode);
return ajaxResult;
}
/** 取消组盘
*
* @param shipmentContainerDetailIds
* @return
*/
@RequiresPermissions("shipment:shippingCombination:remove")
@PostMapping("/cancelCombination")
@ResponseBody
public AjaxResult cancelCombination(@RequestBody List<Integer> shipmentContainerDetailIds){
return shipmentContainerHeaderService.cancelCombinationDetail(shipmentContainerDetailIds);
}
}