Commit 8d1410fd1bcd48eea6e69e3c8e7d5facec787732

Authored by 游杰
1 parent 501e5c6e

增加车架库特殊处理

src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
... ... @@ -45,10 +45,8 @@ import org.springframework.transaction.annotation.Transactional;
45 45  
46 46 import javax.annotation.Resource;
47 47 import java.math.BigDecimal;
48   -import java.util.ArrayList;
49   -import java.util.Date;
50   -import java.util.List;
51   -import java.util.Map;
  48 +import java.text.MessageFormat;
  49 +import java.util.*;
52 50  
53 51 /**
54 52 * 入库任务创建和完成
... ... @@ -219,6 +217,32 @@ public class ReceiptTaskService {
219 217 return AjaxResult.success("生成上架任务成功").setData(taskIds);
220 218 }
221 219  
  220 +
  221 + /**
  222 + * 自动生成容器编码
  223 + * @return 容器编码
  224 + */
  225 + @Transactional
  226 + public String createContainer(){
  227 + String code = MessageFormat.format("{0}{1}",
  228 + "LS",
  229 + String.format("%d", Calendar.getInstance().getTimeInMillis()));
  230 + Container container = new Container();
  231 + container.setCode(code);
  232 + container.setWarehouseCode(ShiroUtils.getWarehouseCode());
  233 + container.setCompanyCode(ShiroUtils.getCompanyCodeList().get(0));
  234 + container.setContainerType("LS");
  235 + container.setCreatedBy(ShiroUtils.getLoginName());
  236 + container.setLastUpdated(new Date());
  237 + container.setLastUpdatedBy(ShiroUtils.getLoginName());
  238 + container.setEnable(true);
  239 + container.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
  240 + if (!containerService.save(container)){
  241 + throw new ServiceException("新增容器失败");
  242 + }
  243 + return code;
  244 + }
  245 +
222 246 /**
223 247 * 完成入库任务
224 248 * @param task 任务
... ... @@ -234,11 +258,16 @@ public class ReceiptTaskService {
234 258 if (StringUtils.isEmpty(task.getToLocation())) {
235 259 throw new ServiceException("任务" + task.getId() + "没有目的库位,执行中止");
236 260 }
  261 +
237 262 BigDecimal totalQty = BigDecimal.ZERO;
238 263 List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(task.getId());
239 264 if (taskDetailList.isEmpty()) {
240 265 throw new ServiceException("任务明细为空");
241 266 }
  267 + String containerCode = null;
  268 + if(task.getZoneCode().equals("C")) {
  269 + containerCode = createContainer();
  270 + }
242 271 InventoryHeader inventoryHeader = null;
243 272 if(task.getTaskType().equals(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT)) {
244 273 LambdaQueryWrapper<InventoryHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
... ... @@ -282,7 +311,12 @@ public class ReceiptTaskService {
282 311 Location location = locationService.getLocationByCode(task.getToLocation(), ShiroUtils.getWarehouseCode());
283 312 inventoryHeader.setZoneCode(location.getZoneCode());
284 313 inventoryHeader.setTotalWeight(task.getWeight());
285   - inventoryHeader.setContainerCode(task.getContainerCode());
  314 + if(task.getZoneCode().equals("C")) {
  315 + inventoryHeader.setContainerCode(containerCode);
  316 + inventoryHeader.setUserDef2(task.getContainerCode());
  317 + } else {
  318 + inventoryHeader.setContainerCode(task.getContainerCode());
  319 + }
286 320 inventoryHeader.setContainerStatus(QuantityConstant.STATUS_CONTAINER_SOME);
287 321 inventoryHeader.setTotalQty(new BigDecimal(0));
288 322 inventoryHeader.setTotalLines(0);
... ... @@ -305,7 +339,6 @@ public class ReceiptTaskService {
305 339 /*查询入库单明细*/
306 340 ReceiptDetail receiptDetail = receiptDetailService.getById(taskDetail.getBillDetailId());
307 341 if (StringUtils.isNotNull(receiptDetail)) {
308   -
309 342 totalQty = this.addInventoryDetail(taskDetail, receiptDetail, inventoryHeader);
310 343 //修改组盘表状态为完成
311 344 ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail();
... ... @@ -323,6 +356,8 @@ public class ReceiptTaskService {
323 356 receiptDetailService.updateById(receiptDetail);
324 357 receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId());
325 358 materialWarningService.materialWarning(taskDetail.getMaterialCode(), taskDetail.getCompanyCode());
  359 + taskDetail.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
  360 + taskDetailService.updateById(taskDetail);
326 361 }
327 362 }
328 363 if (StringUtils.isNull(inventoryHeader)) {
... ... @@ -338,7 +373,13 @@ public class ReceiptTaskService {
338 373  
339 374 //修改库位状态和对应的容器
340 375 Location location = new Location();
341   - location.setContainerCode(task.getContainerCode());
  376 + if(task.getZoneCode().equals("C")) {
  377 + location.setContainerCode(containerCode);
  378 + location.setUserDef2(task.getContainerCode());
  379 + containerService.updateLocationCodeAndStatus(containerCode, task.getToLocation(), QuantityConstant.STATUS_CONTAINER_EMPTY);
  380 + } else {
  381 + location.setContainerCode(task.getContainerCode());
  382 + }
342 383 location.setWarehouseCode(ShiroUtils.getWarehouseCode());
343 384 location.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY);
344 385 LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper = Wrappers.lambdaUpdate();
... ... @@ -349,7 +390,9 @@ public class ReceiptTaskService {
349 390 }
350 391 //修改容器状态和对应的库位
351 392 Container container = new Container();
352   - container.setLocationCode(task.getToLocation());
  393 + if(!task.getZoneCode().equals("C")) {
  394 + container.setLocationCode(task.getToLocation());
  395 + }
353 396 container.setStatus(QuantityConstant.STATUS_CONTAINER_SOME);
354 397 LambdaUpdateWrapper<Container> containerLambdaUpdateWrapper = Wrappers.lambdaUpdate();
355 398 containerLambdaUpdateWrapper.eq(Container::getCode, task.getContainerCode());
... ...