Commit f5beff55159fdde55acdf9c7607d44babcdc0f5f
1 parent
07aadff8
加上库位是否有容器搜索
Showing
1 changed file
with
308 additions
and
300 deletions
src/main/java/com/huaheng/pc/config/location/controller/LocationController.java
@@ -45,328 +45,336 @@ import java.util.stream.Collectors; | @@ -45,328 +45,336 @@ import java.util.stream.Collectors; | ||
45 | @RequestMapping("/config/location") | 45 | @RequestMapping("/config/location") |
46 | public class LocationController extends BaseController { | 46 | public class LocationController extends BaseController { |
47 | 47 | ||
48 | - private String prefix = "config/location"; | ||
49 | - | ||
50 | - @Resource | ||
51 | - private ContainerService containerService; | ||
52 | - @Resource | ||
53 | - private LocationService locationService; | ||
54 | - @Resource | ||
55 | - private InventoryDetailService inventoryDetailService; | ||
56 | - @Resource | ||
57 | - private MaterialService materialService; | ||
58 | - @Resource | ||
59 | - private DataSource dataSource; | ||
60 | - @Resource | ||
61 | - private Print print; | ||
62 | - | ||
63 | - @RequiresPermissions("config:location:view") | ||
64 | - @GetMapping() | ||
65 | - public String location () { | ||
66 | - return prefix + "/location"; | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | - * 查询库位列表 | ||
71 | - */ | ||
72 | - @ApiOperation(value = "查看库位列表", | ||
73 | - notes = "根据行、列、层、格、库位类型、库区、库位状态、容器编码、库位名称、库位编码、创建时间获取库位的详细信息", | ||
74 | - httpMethod = "POST") | ||
75 | - @RequiresPermissions("config:location:list") | ||
76 | - @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
77 | - @PostMapping("/list") | ||
78 | - @ResponseBody | ||
79 | - public TableDataInfo list ( | ||
80 | - @ApiParam(name = "location", value = "行、列、层、格、库位类型、库区、库位状态、容器编码、库位名称、库位编码") Location location, | ||
81 | - @ApiParam(name = "createdBegin", value = "起止时间") String createdBegin, | ||
82 | - @ApiParam(name = "createdEnd", value = "结束时间") String createdEnd) { | ||
83 | - LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(); | ||
84 | - PageDomain pageDomain = TableSupport.buildPageRequest(); | ||
85 | - Integer pageNum = pageDomain.getPageNum(); | ||
86 | - Integer pageSize = pageDomain.getPageSize(); | ||
87 | - lambdaQueryWrapper.gt(StringUtils.isNotEmpty(createdBegin), Location::getCreated, createdBegin) | ||
88 | - .lt(StringUtils.isNotEmpty(createdEnd), Location::getCreated, createdEnd) | ||
89 | - .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()) | ||
90 | - .eq(StringUtils.isNotEmpty(location.getCode()), Location::getCode, location.getCode()) | ||
91 | - .eq(StringUtils.isNotEmpty(location.getName()), Location::getName, location.getName()) | ||
92 | - .eq(StringUtils.isNotEmpty(location.getContainerCode()), Location::getContainerCode, location.getContainerCode()) | ||
93 | - .eq(StringUtils.isNotNull(location.getSystemCreated()), Location::getStatus, location.getStatus()) | ||
94 | - .eq(StringUtils.isNotEmpty(location.getZoneCode()), Location::getZoneCode, location.getZoneCode()) | ||
95 | - .eq(StringUtils.isNotNull(location.getIRow()), Location::getIRow, location.getIRow()) | ||
96 | - .eq(StringUtils.isNotNull(location.getIColumn()), Location::getIColumn, location.getIColumn()) | ||
97 | - .eq(StringUtils.isNotNull(location.getIGrid()), Location::getIGrid, location.getIGrid()) | ||
98 | - .eq(StringUtils.isNotNull(location.getILayer()), Location::getILayer, location.getILayer()) | ||
99 | - .eq(StringUtils.isNotEmpty(location.getStatus()), Location::getStatus, location.getStatus()) | ||
100 | - .eq(StringUtils.isNotEmpty(location.getLocationType()), Location::getLocationType, location.getLocationType()) | ||
101 | - .eq(Location::getDeleted, false) | ||
102 | - .orderByDesc(Location::getId); | ||
103 | - | ||
104 | - if(StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { | ||
105 | - /*使用分页查询*/ | ||
106 | - Page<Location> page = new Page<>(pageNum, pageSize); | ||
107 | - IPage<Location> iPage = locationService.page(page, lambdaQueryWrapper); | ||
108 | - return getMpDataTable(iPage.getRecords(), iPage.getTotal()); | ||
109 | - } else { | ||
110 | - List<Location> list = locationService.list(lambdaQueryWrapper); | ||
111 | - return getDataTable(list); | 48 | + private String prefix = "config/location"; |
49 | + | ||
50 | + @Resource | ||
51 | + private ContainerService containerService; | ||
52 | + @Resource | ||
53 | + private LocationService locationService; | ||
54 | + @Resource | ||
55 | + private InventoryDetailService inventoryDetailService; | ||
56 | + @Resource | ||
57 | + private MaterialService materialService; | ||
58 | + @Resource | ||
59 | + private DataSource dataSource; | ||
60 | + @Resource | ||
61 | + private Print print; | ||
62 | + | ||
63 | + @RequiresPermissions("config:location:view") | ||
64 | + @GetMapping() | ||
65 | + public String location() { | ||
66 | + return prefix + "/location"; | ||
112 | } | 67 | } |
113 | - } | ||
114 | - | ||
115 | - /** | ||
116 | - * 查询库位列表 | ||
117 | - */ | ||
118 | - @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
119 | - @PostMapping("/getAllLocation") | ||
120 | - @ResponseBody | ||
121 | - public AjaxResult getAllLocation (String type) { | ||
122 | - if(StringUtils.isEmpty(type)) { | ||
123 | - return AjaxResult.error("type不能为空"); | 68 | + |
69 | + /** | ||
70 | + * 查询库位列表 | ||
71 | + */ | ||
72 | + @ApiOperation(value = "查看库位列表", | ||
73 | + notes = "根据行、列、层、格、库位类型、库区、库位状态、容器编码、库位名称、库位编码、创建时间获取库位的详细信息", | ||
74 | + httpMethod = "POST") | ||
75 | + @RequiresPermissions("config:location:list") | ||
76 | + @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
77 | + @PostMapping("/list") | ||
78 | + @ResponseBody | ||
79 | + public TableDataInfo list( | ||
80 | + @ApiParam(name = "location", value = "行、列、层、格、库位类型、库区、库位状态、容器编码、库位名称、库位编码") Location location, | ||
81 | + @ApiParam(name = "createdBegin", value = "起止时间") String createdBegin, | ||
82 | + @ApiParam(name = "createdEnd", value = "结束时间") String createdEnd) { | ||
83 | + LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(); | ||
84 | + PageDomain pageDomain = TableSupport.buildPageRequest(); | ||
85 | + Integer pageNum = pageDomain.getPageNum(); | ||
86 | + Integer pageSize = pageDomain.getPageSize(); | ||
87 | + lambdaQueryWrapper.gt(StringUtils.isNotEmpty(createdBegin), Location::getCreated, createdBegin) | ||
88 | + .lt(StringUtils.isNotEmpty(createdEnd), Location::getCreated, createdEnd) | ||
89 | + .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()) | ||
90 | + .eq(StringUtils.isNotEmpty(location.getCode()), Location::getCode, location.getCode()) | ||
91 | + .eq(StringUtils.isNotEmpty(location.getName()), Location::getName, location.getName()) | ||
92 | + .eq(StringUtils.isNotEmpty(location.getContainerCode()), Location::getContainerCode, location.getContainerCode()) | ||
93 | + .eq(StringUtils.isNotNull(location.getSystemCreated()), Location::getStatus, location.getStatus()) | ||
94 | + .eq(StringUtils.isNotEmpty(location.getZoneCode()), Location::getZoneCode, location.getZoneCode()) | ||
95 | + .eq(StringUtils.isNotNull(location.getIRow()), Location::getIRow, location.getIRow()) | ||
96 | + .eq(StringUtils.isNotNull(location.getIColumn()), Location::getIColumn, location.getIColumn()) | ||
97 | + .eq(StringUtils.isNotNull(location.getIGrid()), Location::getIGrid, location.getIGrid()) | ||
98 | + .eq(StringUtils.isNotNull(location.getILayer()), Location::getILayer, location.getILayer()) | ||
99 | + .eq(StringUtils.isNotEmpty(location.getStatus()), Location::getStatus, location.getStatus()) | ||
100 | + .eq(StringUtils.isNotEmpty(location.getLocationType()), Location::getLocationType, location.getLocationType()) | ||
101 | + .eq(Location::getDeleted, false); | ||
102 | + | ||
103 | + if (StringUtils.isNotEmpty(location.getUserDef2())) { | ||
104 | + if ("有容器".equals(location.getUserDef2())) { | ||
105 | + lambdaQueryWrapper.apply("containerCode!='' and containerCode IS NOT null"); | ||
106 | + } else { | ||
107 | + lambdaQueryWrapper.apply("code in ( select CODE from location where containerCode='' or containerCode IS null) "); | ||
108 | + } | ||
109 | + lambdaQueryWrapper.orderByDesc(Location::getId); | ||
110 | + } | ||
111 | + | ||
112 | + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { | ||
113 | + /*使用分页查询*/ | ||
114 | + Page<Location> page = new Page<>(pageNum, pageSize); | ||
115 | + IPage<Location> iPage = locationService.page(page, lambdaQueryWrapper); | ||
116 | + return getMpDataTable(iPage.getRecords(), iPage.getTotal()); | ||
117 | + } else { | ||
118 | + List<Location> list = locationService.list(lambdaQueryWrapper); | ||
119 | + return getDataTable(list); | ||
120 | + } | ||
124 | } | 121 | } |
125 | 122 | ||
126 | - return AjaxResult.success(locationService.getAllLocation(type)); | ||
127 | - } | ||
128 | - | ||
129 | - | ||
130 | - /** | ||
131 | - * 新增库位 | ||
132 | - */ | ||
133 | - @GetMapping("/add") | ||
134 | - public String add () { | ||
135 | - return prefix + "/add"; | ||
136 | - } | ||
137 | - | ||
138 | - /** | ||
139 | - * 新增保存库位 | ||
140 | - */ | ||
141 | - @ApiOperation(value = "新增库位", notes = "新增单个库位", httpMethod = "POST") | ||
142 | - @RequiresPermissions("config:location:add") | ||
143 | - @Log(title = "配置-库存资料-库位管理", operating = "新增库位", action = BusinessType.INSERT) | ||
144 | - @PostMapping("/add") | ||
145 | - @ResponseBody | ||
146 | - public AjaxResult addSave (Location location) { | ||
147 | - AjaxResult result = locationService.addsave(location); | ||
148 | - return result; | ||
149 | - } | ||
150 | - | ||
151 | - | ||
152 | - /** | ||
153 | - * 批量新增库位 | ||
154 | - */ | ||
155 | - | ||
156 | - @GetMapping("/addBatch") | ||
157 | - public String addBatch () { | ||
158 | - return prefix + "/addBatch"; | ||
159 | - } | ||
160 | - | ||
161 | - | ||
162 | - /** | ||
163 | - * 批量新增保存库位 | ||
164 | - */ | ||
165 | - @RequiresPermissions("config:location:add") | ||
166 | - @ApiOperation(value = "新增库位", notes = "批量新增库位", httpMethod = "POST") | ||
167 | - @Log(title = "配置-库存资料-库位管理", operating = "新增库位", action = BusinessType.INSERT) | ||
168 | - @PostMapping("/addBatchSave") | ||
169 | - @ResponseBody | ||
170 | - public AjaxResult addBatchSave (String prefix, String firstRow, String lastRow, String firstColumn, String lastColumn, String firstLayer, String lastLayer, | ||
171 | - String firstGrid, String lastGrid, String roadway, String status, String zoneCode, String locationType, String high) { | ||
172 | - | ||
173 | - return toAjax(locationService.addBatchSave(prefix, Integer.parseInt(firstRow), Integer.parseInt(lastRow), | ||
174 | - Integer.parseInt(firstColumn), Integer.parseInt(lastColumn), Integer.parseInt(firstLayer), Integer.parseInt(lastLayer), | ||
175 | - Integer.parseInt(firstGrid), Integer.parseInt(lastGrid), roadway, status, zoneCode, locationType, high)); | ||
176 | - } | ||
177 | - | ||
178 | - /** | ||
179 | - * 修改库位 | ||
180 | - */ | ||
181 | - @GetMapping("/edit/{id}") | ||
182 | - public String edit (@PathVariable("id") Integer id, ModelMap mmap) { | ||
183 | - Location location = locationService.getById(id); | ||
184 | - mmap.put("location", location); | ||
185 | - return prefix + "/edit"; | ||
186 | - } | ||
187 | - | ||
188 | - /** | ||
189 | - * 修改物料 | ||
190 | - */ | ||
191 | - @GetMapping("/editBatch/{ids}") | ||
192 | - public String editBatch (@PathVariable("ids") String ids, ModelMap mmap) { | ||
193 | - mmap.put("ids", ids); | ||
194 | - return prefix + "/editBatch"; | ||
195 | - } | ||
196 | - | ||
197 | - /** | ||
198 | - * 修改保存库位 | ||
199 | - */ | ||
200 | - @RequiresPermissions("config:location:edit") | ||
201 | - @ApiOperation(value = "修改库位", notes = "批量修改库位", httpMethod = "POST") | ||
202 | - @Log(title = "配置-库存资料-库位管理", operating = "修改库位", action = BusinessType.UPDATE) | ||
203 | - @PostMapping("/edit") | ||
204 | - @ResponseBody | ||
205 | - public AjaxResult editSave (Location location) { | ||
206 | - String containerCode = location.getContainerCode(); | ||
207 | - if (StringUtils.isNotEmpty(containerCode)) { | ||
208 | - Container container = containerService.getContainerByCode(containerCode); | ||
209 | - if (container == null) { | ||
210 | - return AjaxResult.error("容器编码输入错误"); | ||
211 | - } | 123 | + /** |
124 | + * 查询库位列表 | ||
125 | + */ | ||
126 | + @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
127 | + @PostMapping("/getAllLocation") | ||
128 | + @ResponseBody | ||
129 | + public AjaxResult getAllLocation(String type) { | ||
130 | + if (StringUtils.isEmpty(type)) { | ||
131 | + return AjaxResult.error("type不能为空"); | ||
132 | + } | ||
133 | + | ||
134 | + return AjaxResult.success(locationService.getAllLocation(type)); | ||
212 | } | 135 | } |
213 | - location.setLastUpdatedBy(ShiroUtils.getName()); | ||
214 | - return toAjax(locationService.updateById(location)); | ||
215 | - } | ||
216 | - | ||
217 | - /** | ||
218 | - * 修改保存物料 | ||
219 | - */ | ||
220 | - @ApiOperation(value = "批量修改库位", notes = "批量修改库位", httpMethod = "POST") | ||
221 | - @RequiresPermissions("config:location:edit") | ||
222 | - @Log(title = "通用-库位管理", operating = "批量修改库位", action = BusinessType.UPDATE) | ||
223 | - @PostMapping("/editBatchSave") | ||
224 | - @ResponseBody | ||
225 | - public AjaxResult editBatchSave (String ids, String materialAreaCode, Integer high, String status) { | ||
226 | - String[] idArray = Convert.toStrArray(ids); | ||
227 | - LambdaUpdateWrapper<Location> wrapper = Wrappers.lambdaUpdate(); | ||
228 | - wrapper.in(Location::getId, idArray) | ||
229 | - .set(Location::getMaterialAreaCode, materialAreaCode) | ||
230 | - .set(Location::getHigh, high) | ||
231 | - .set(Location::getStatus, status); | ||
232 | - return toAjax(locationService.update(wrapper)); | ||
233 | - } | ||
234 | - | ||
235 | - /** | ||
236 | - * 删除库位 | ||
237 | - */ | ||
238 | - @RequiresPermissions("config:location:remove") | ||
239 | - @Log(title = "配置库存资料-库位管理", operating = "删除库位", action = BusinessType.DELETE) | ||
240 | - @ApiOperation(value = "删除库位", notes = "批量删除库位", httpMethod = "POST") | ||
241 | - @PostMapping("/remove") | ||
242 | - @ResponseBody | ||
243 | - public AjaxResult remove (String ids) { | ||
244 | - if(StringUtils.isEmpty(ids)) { | ||
245 | - return AjaxResult.error("id不能为空"); | 136 | + |
137 | + | ||
138 | + /** | ||
139 | + * 新增库位 | ||
140 | + */ | ||
141 | + @GetMapping("/add") | ||
142 | + public String add() { | ||
143 | + return prefix + "/add"; | ||
246 | } | 144 | } |
247 | - for (Integer id : Convert.toIntArray(ids)) { | ||
248 | - Location location = locationService.getById(id); | ||
249 | - if(StringUtils.isEmpty(location.getContainerCode())) { | ||
250 | - locationService.removeById(locationService.getById(id)); | ||
251 | - } else { | ||
252 | - return AjaxResult.error("库位(" + location.getCode() + ")不是空,或者有容器,不能删除成功!"); | ||
253 | - } | 145 | + |
146 | + /** | ||
147 | + * 新增保存库位 | ||
148 | + */ | ||
149 | + @ApiOperation(value = "新增库位", notes = "新增单个库位", httpMethod = "POST") | ||
150 | + @RequiresPermissions("config:location:add") | ||
151 | + @Log(title = "配置-库存资料-库位管理", operating = "新增库位", action = BusinessType.INSERT) | ||
152 | + @PostMapping("/add") | ||
153 | + @ResponseBody | ||
154 | + public AjaxResult addSave(Location location) { | ||
155 | + AjaxResult result = locationService.addsave(location); | ||
156 | + return result; | ||
254 | } | 157 | } |
255 | - return AjaxResult.success("删除成功!"); | ||
256 | - } | ||
257 | - | ||
258 | - /** | ||
259 | - * 查询库位列表 | ||
260 | - */ | ||
261 | - @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
262 | - @PostMapping("/getLocationInfo") | ||
263 | - @ResponseBody | ||
264 | - public AjaxResult getLocationInfo (String type, String row, String line, String layer, String grid) { | ||
265 | - if(StringUtils.isEmpty(type)) { | ||
266 | - return AjaxResult.error("type不能为空"); | 158 | + |
159 | + | ||
160 | + /** | ||
161 | + * 批量新增库位 | ||
162 | + */ | ||
163 | + | ||
164 | + @GetMapping("/addBatch") | ||
165 | + public String addBatch() { | ||
166 | + return prefix + "/addBatch"; | ||
267 | } | 167 | } |
268 | 168 | ||
269 | - /* 查询库位信息*/ | ||
270 | - LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | ||
271 | - locationLambdaQueryWrapper.eq(StringUtils.isNotEmpty(row), Location::getIRow, row) | ||
272 | - .eq(StringUtils.isNotEmpty(line), Location::getIColumn, line) | ||
273 | - .eq(StringUtils.isNotEmpty(layer), Location::getILayer, layer) | ||
274 | - .eq(Location::getIGrid, 1) // | ||
275 | - .eq(StringUtils.isNotEmpty(type), Location::getLocationType, type) | ||
276 | - .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()) | ||
277 | - .eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type); | ||
278 | - List<Location> locations = locationService.list(locationLambdaQueryWrapper); | ||
279 | - List<Location> locationList = new ArrayList<>(); | ||
280 | - | ||
281 | - /* 查询库存明细*/ | ||
282 | - LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery(); | ||
283 | - inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); | ||
284 | - List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambda); | ||
285 | - | ||
286 | - for (Location location1 : locations) { | ||
287 | - InventoryDetail inventoryDetail = null; | ||
288 | - String materialName = null; | ||
289 | - for (InventoryDetail inventoryDetail2 : inventoryDetailList) { | ||
290 | - if(location1.getCode().equals(inventoryDetail2.getLocationCode())) { | ||
291 | - inventoryDetail = inventoryDetail2; | 169 | + |
170 | + /** | ||
171 | + * 批量新增保存库位 | ||
172 | + */ | ||
173 | + @RequiresPermissions("config:location:add") | ||
174 | + @ApiOperation(value = "新增库位", notes = "批量新增库位", httpMethod = "POST") | ||
175 | + @Log(title = "配置-库存资料-库位管理", operating = "新增库位", action = BusinessType.INSERT) | ||
176 | + @PostMapping("/addBatchSave") | ||
177 | + @ResponseBody | ||
178 | + public AjaxResult addBatchSave(String prefix, String firstRow, String lastRow, String firstColumn, String lastColumn, String firstLayer, String lastLayer, | ||
179 | + String firstGrid, String lastGrid, String roadway, String status, String zoneCode, String locationType, String high) { | ||
180 | + | ||
181 | + return toAjax(locationService.addBatchSave(prefix, Integer.parseInt(firstRow), Integer.parseInt(lastRow), | ||
182 | + Integer.parseInt(firstColumn), Integer.parseInt(lastColumn), Integer.parseInt(firstLayer), Integer.parseInt(lastLayer), | ||
183 | + Integer.parseInt(firstGrid), Integer.parseInt(lastGrid), roadway, status, zoneCode, locationType, high)); | ||
184 | + } | ||
185 | + | ||
186 | + /** | ||
187 | + * 修改库位 | ||
188 | + */ | ||
189 | + @GetMapping("/edit/{id}") | ||
190 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) { | ||
191 | + Location location = locationService.getById(id); | ||
192 | + mmap.put("location", location); | ||
193 | + return prefix + "/edit"; | ||
194 | + } | ||
195 | + | ||
196 | + /** | ||
197 | + * 修改物料 | ||
198 | + */ | ||
199 | + @GetMapping("/editBatch/{ids}") | ||
200 | + public String editBatch(@PathVariable("ids") String ids, ModelMap mmap) { | ||
201 | + mmap.put("ids", ids); | ||
202 | + return prefix + "/editBatch"; | ||
203 | + } | ||
204 | + | ||
205 | + /** | ||
206 | + * 修改保存库位 | ||
207 | + */ | ||
208 | + @RequiresPermissions("config:location:edit") | ||
209 | + @ApiOperation(value = "修改库位", notes = "批量修改库位", httpMethod = "POST") | ||
210 | + @Log(title = "配置-库存资料-库位管理", operating = "修改库位", action = BusinessType.UPDATE) | ||
211 | + @PostMapping("/edit") | ||
212 | + @ResponseBody | ||
213 | + public AjaxResult editSave(Location location) { | ||
214 | + String containerCode = location.getContainerCode(); | ||
215 | + if (StringUtils.isNotEmpty(containerCode)) { | ||
216 | + Container container = containerService.getContainerByCode(containerCode); | ||
217 | + if (container == null) { | ||
218 | + return AjaxResult.error("容器编码输入错误"); | ||
219 | + } | ||
292 | } | 220 | } |
293 | - } | ||
294 | - List<InventoryDetail> inventoryDetails = inventoryDetailList.stream().filter(inventoryDetail1 -> | ||
295 | - inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList()); | ||
296 | - | ||
297 | - int userDef3 = 0; | ||
298 | - String status = location1.getStatus(); | ||
299 | - String containerCode = location1.getContainerCode(); | ||
300 | - List<String> materialNameList = inventoryDetails.stream().map(InventoryDetail::getMaterialName).collect(Collectors.toList()); | ||
301 | - List<String> batchList = inventoryDetails.stream().map(InventoryDetail::getBatch).collect(Collectors.toList()); | ||
302 | - List<String> materialCodeList = inventoryDetails.stream().map(InventoryDetail::getMaterialCode).collect(Collectors.toList()); | ||
303 | - List<BigDecimal> qtyList = inventoryDetails.stream().map(InventoryDetail::getQty).collect(Collectors.toList()); | ||
304 | - if(QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) { | ||
305 | - if(StringUtils.isEmpty(containerCode)) { | ||
306 | - userDef3 = LocationStatus.IDLE_EMPTY_LOCATION; | ||
307 | - } else { | ||
308 | - if(inventoryDetail == null) { | ||
309 | - userDef3 = LocationStatus.IDLE_EMPTY_CONTAINER; | ||
310 | - } else { | ||
311 | - location1.setMaterialName(materialNameList); | ||
312 | - location1.setMaterialCode(materialCodeList); | ||
313 | - location1.setBatch(batchList); | ||
314 | - location1.setQty(qtyList); | ||
315 | - userDef3 = LocationStatus.IDLE_FULL_CONTAINER; | ||
316 | - } | 221 | + location.setLastUpdatedBy(ShiroUtils.getName()); |
222 | + return toAjax(locationService.updateById(location)); | ||
223 | + } | ||
224 | + | ||
225 | + /** | ||
226 | + * 修改保存物料 | ||
227 | + */ | ||
228 | + @ApiOperation(value = "批量修改库位", notes = "批量修改库位", httpMethod = "POST") | ||
229 | + @RequiresPermissions("config:location:edit") | ||
230 | + @Log(title = "通用-库位管理", operating = "批量修改库位", action = BusinessType.UPDATE) | ||
231 | + @PostMapping("/editBatchSave") | ||
232 | + @ResponseBody | ||
233 | + public AjaxResult editBatchSave(String ids, String materialAreaCode, Integer high, String status) { | ||
234 | + String[] idArray = Convert.toStrArray(ids); | ||
235 | + LambdaUpdateWrapper<Location> wrapper = Wrappers.lambdaUpdate(); | ||
236 | + wrapper.in(Location::getId, idArray) | ||
237 | + .set(Location::getMaterialAreaCode, materialAreaCode) | ||
238 | + .set(Location::getHigh, high) | ||
239 | + .set(Location::getStatus, status); | ||
240 | + return toAjax(locationService.update(wrapper)); | ||
241 | + } | ||
242 | + | ||
243 | + /** | ||
244 | + * 删除库位 | ||
245 | + */ | ||
246 | + @RequiresPermissions("config:location:remove") | ||
247 | + @Log(title = "配置库存资料-库位管理", operating = "删除库位", action = BusinessType.DELETE) | ||
248 | + @ApiOperation(value = "删除库位", notes = "批量删除库位", httpMethod = "POST") | ||
249 | + @PostMapping("/remove") | ||
250 | + @ResponseBody | ||
251 | + public AjaxResult remove(String ids) { | ||
252 | + if (StringUtils.isEmpty(ids)) { | ||
253 | + return AjaxResult.error("id不能为空"); | ||
317 | } | 254 | } |
318 | - } else if(QuantityConstant.STATUS_LOCATION_LOCK.equals(status)) { | ||
319 | - if(StringUtils.isEmpty(containerCode)) { | ||
320 | - userDef3 = LocationStatus.LOCK_EMPTY_LOCATION; | ||
321 | - } else { | ||
322 | - if(inventoryDetail == null) { | ||
323 | - userDef3 = LocationStatus.LOCK_EMPTY_CONTAINER; | ||
324 | - } else { | ||
325 | - location1.setMaterialName(materialNameList); | ||
326 | - location1.setMaterialCode(materialCodeList); | ||
327 | - location1.setBatch(batchList); | ||
328 | - location1.setQty(qtyList); | ||
329 | - userDef3 = LocationStatus.LOCK_FULL_CONTAINER; | ||
330 | - } | 255 | + for (Integer id : Convert.toIntArray(ids)) { |
256 | + Location location = locationService.getById(id); | ||
257 | + if (StringUtils.isEmpty(location.getContainerCode())) { | ||
258 | + locationService.removeById(locationService.getById(id)); | ||
259 | + } else { | ||
260 | + return AjaxResult.error("库位(" + location.getCode() + ")不是空,或者有容器,不能删除成功!"); | ||
261 | + } | ||
331 | } | 262 | } |
332 | - } | 263 | + return AjaxResult.success("删除成功!"); |
264 | + } | ||
333 | 265 | ||
334 | - if(location1.getDeleted()) { | ||
335 | - if(StringUtils.isEmpty(containerCode)) { | ||
336 | - userDef3 = LocationStatus.DISABLE_EMPTY_LOCATION; | ||
337 | - } else { | ||
338 | - if(inventoryDetail == null) { | ||
339 | - userDef3 = LocationStatus.DISABLE_EMPTY_CONTAINER; | ||
340 | - } else { | ||
341 | - location1.setMaterialName(materialNameList); | ||
342 | - location1.setMaterialCode(materialCodeList); | ||
343 | - location1.setBatch(batchList); | ||
344 | - location1.setQty(qtyList); | ||
345 | - userDef3 = LocationStatus.DISABLE_FULL_CONTAINER; | ||
346 | - } | 266 | + /** |
267 | + * 查询库位列表 | ||
268 | + */ | ||
269 | + @Log(title = "配置-库存资料-库位管理", operating = "查看库位列表", action = BusinessType.GRANT) | ||
270 | + @PostMapping("/getLocationInfo") | ||
271 | + @ResponseBody | ||
272 | + public AjaxResult getLocationInfo(String type, String row, String line, String layer, String grid) { | ||
273 | + if (StringUtils.isEmpty(type)) { | ||
274 | + return AjaxResult.error("type不能为空"); | ||
347 | } | 275 | } |
348 | - } | ||
349 | 276 | ||
350 | - location1.setUserDef3(String.valueOf(userDef3)); | ||
351 | - locationList.add(location1); | 277 | + /* 查询库位信息*/ |
278 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | ||
279 | + locationLambdaQueryWrapper.eq(StringUtils.isNotEmpty(row), Location::getIRow, row) | ||
280 | + .eq(StringUtils.isNotEmpty(line), Location::getIColumn, line) | ||
281 | + .eq(StringUtils.isNotEmpty(layer), Location::getILayer, layer) | ||
282 | + .eq(Location::getIGrid, 1) // | ||
283 | + .eq(StringUtils.isNotEmpty(type), Location::getLocationType, type) | ||
284 | + .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()) | ||
285 | + .eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type); | ||
286 | + List<Location> locations = locationService.list(locationLambdaQueryWrapper); | ||
287 | + List<Location> locationList = new ArrayList<>(); | ||
288 | + | ||
289 | + /* 查询库存明细*/ | ||
290 | + LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery(); | ||
291 | + inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); | ||
292 | + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambda); | ||
293 | + | ||
294 | + for (Location location1 : locations) { | ||
295 | + InventoryDetail inventoryDetail = null; | ||
296 | + String materialName = null; | ||
297 | + for (InventoryDetail inventoryDetail2 : inventoryDetailList) { | ||
298 | + if (location1.getCode().equals(inventoryDetail2.getLocationCode())) { | ||
299 | + inventoryDetail = inventoryDetail2; | ||
300 | + } | ||
301 | + } | ||
302 | + List<InventoryDetail> inventoryDetails = inventoryDetailList.stream().filter(inventoryDetail1 -> | ||
303 | + inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList()); | ||
304 | + | ||
305 | + int userDef3 = 0; | ||
306 | + String status = location1.getStatus(); | ||
307 | + String containerCode = location1.getContainerCode(); | ||
308 | + List<String> materialNameList = inventoryDetails.stream().map(InventoryDetail::getMaterialName).collect(Collectors.toList()); | ||
309 | + List<String> batchList = inventoryDetails.stream().map(InventoryDetail::getBatch).collect(Collectors.toList()); | ||
310 | + List<String> materialCodeList = inventoryDetails.stream().map(InventoryDetail::getMaterialCode).collect(Collectors.toList()); | ||
311 | + List<BigDecimal> qtyList = inventoryDetails.stream().map(InventoryDetail::getQty).collect(Collectors.toList()); | ||
312 | + if (QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) { | ||
313 | + if (StringUtils.isEmpty(containerCode)) { | ||
314 | + userDef3 = LocationStatus.IDLE_EMPTY_LOCATION; | ||
315 | + } else { | ||
316 | + if (inventoryDetail == null) { | ||
317 | + userDef3 = LocationStatus.IDLE_EMPTY_CONTAINER; | ||
318 | + } else { | ||
319 | + location1.setMaterialName(materialNameList); | ||
320 | + location1.setMaterialCode(materialCodeList); | ||
321 | + location1.setBatch(batchList); | ||
322 | + location1.setQty(qtyList); | ||
323 | + userDef3 = LocationStatus.IDLE_FULL_CONTAINER; | ||
324 | + } | ||
325 | + } | ||
326 | + } else if (QuantityConstant.STATUS_LOCATION_LOCK.equals(status)) { | ||
327 | + if (StringUtils.isEmpty(containerCode)) { | ||
328 | + userDef3 = LocationStatus.LOCK_EMPTY_LOCATION; | ||
329 | + } else { | ||
330 | + if (inventoryDetail == null) { | ||
331 | + userDef3 = LocationStatus.LOCK_EMPTY_CONTAINER; | ||
332 | + } else { | ||
333 | + location1.setMaterialName(materialNameList); | ||
334 | + location1.setMaterialCode(materialCodeList); | ||
335 | + location1.setBatch(batchList); | ||
336 | + location1.setQty(qtyList); | ||
337 | + userDef3 = LocationStatus.LOCK_FULL_CONTAINER; | ||
338 | + } | ||
339 | + } | ||
340 | + } | ||
341 | + | ||
342 | + if (location1.getDeleted()) { | ||
343 | + if (StringUtils.isEmpty(containerCode)) { | ||
344 | + userDef3 = LocationStatus.DISABLE_EMPTY_LOCATION; | ||
345 | + } else { | ||
346 | + if (inventoryDetail == null) { | ||
347 | + userDef3 = LocationStatus.DISABLE_EMPTY_CONTAINER; | ||
348 | + } else { | ||
349 | + location1.setMaterialName(materialNameList); | ||
350 | + location1.setMaterialCode(materialCodeList); | ||
351 | + location1.setBatch(batchList); | ||
352 | + location1.setQty(qtyList); | ||
353 | + userDef3 = LocationStatus.DISABLE_FULL_CONTAINER; | ||
354 | + } | ||
355 | + } | ||
356 | + } | ||
357 | + | ||
358 | + location1.setUserDef3(String.valueOf(userDef3)); | ||
359 | + locationList.add(location1); | ||
360 | + } | ||
361 | + return AjaxResult.success(locations); | ||
352 | } | 362 | } |
353 | - return AjaxResult.success(locations); | ||
354 | - } | ||
355 | 363 | ||
356 | 364 | ||
357 | - @Log(title = "配置-库存资料-库位条码", operating = "库位条码打印", action = BusinessType.OTHER) | ||
358 | - // @ResponseBody // 错误1ajax是json数据而没有添加该注解返回值不为json所以不能够返回common.ajaxSetup.textStatus= "parsererror"报错 | ||
359 | - @GetMapping("/print/{ids}") | ||
360 | - public void print (@PathVariable("ids") Integer[] ids, ModelMap mmap) // arg1:物料id arg2:会话对象不需要直接返回 | ||
361 | - { | ||
362 | - print.jasperPrint(ids, prefix);// 不用返回json打印 | ||
363 | - } | 365 | + @Log(title = "配置-库存资料-库位条码", operating = "库位条码打印", action = BusinessType.OTHER) |
366 | + // @ResponseBody // 错误1ajax是json数据而没有添加该注解返回值不为json所以不能够返回common.ajaxSetup.textStatus= "parsererror"报错 | ||
367 | + @GetMapping("/print/{ids}") | ||
368 | + public void print(@PathVariable("ids") Integer[] ids, ModelMap mmap) // arg1:物料id arg2:会话对象不需要直接返回 | ||
369 | + { | ||
370 | + print.jasperPrint(ids, prefix);// 不用返回json打印 | ||
371 | + } | ||
364 | 372 | ||
365 | 373 | ||
366 | @Log(title = "监控-库位空闲监控-库位管理", operating = "查看库位空闲结果", action = BusinessType.GRANT) | 374 | @Log(title = "监控-库位空闲监控-库位管理", operating = "查看库位空闲结果", action = BusinessType.GRANT) |
367 | @PostMapping("/getIdleLocation") | 375 | @PostMapping("/getIdleLocation") |
368 | @ResponseBody | 376 | @ResponseBody |
369 | public AjaxResult<?> getIdleLocation() { | 377 | public AjaxResult<?> getIdleLocation() { |
370 | - return AjaxResult.success(locationService.getIdleLocation()); | 378 | + return AjaxResult.success(locationService.getIdleLocation()); |
371 | } | 379 | } |
372 | } | 380 | } |