From 03dbce0ba849005d060af569ffe3a58c0a1e0e45 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 23 五月 2025 14:24:06 +0800 Subject: [PATCH] 盘点再入库 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java | 63 ++++++++++++++++++++++++++++--- 1 files changed, 56 insertions(+), 7 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java index 6bb75cf..9a5470a 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java @@ -18,9 +18,12 @@ import com.vincent.rsf.server.manager.service.TaskService; import com.vincent.rsf.server.system.constant.SerialRuleCode; import com.vincent.rsf.server.system.utils.SerialRuleUtils; +import lombok.Synchronized; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -43,12 +46,21 @@ /** * 搴撳瓨鍑哄簱鐢熸垚鍑哄簱浠诲姟 + * type: check 鐩樼偣, stock: 搴撳瓨鍑哄簱 * * @param map * @return */ @Override + @Synchronized + @Transactional(rollbackFor = Exception.class) public R generateTask(Map<String, Object> map) { + String type; + if (!Objects.isNull(map.get("type")) && StringUtils.isNotBlank(map.get("type").toString())) { + type = map.get("type").toString(); + } else { + type = "stock"; + } if (Objects.isNull(map.get("siteNo"))) { throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�"); } @@ -64,6 +76,12 @@ if (Objects.isNull(loc)) { throw new CoolException("鏁版嵁閿欒锛氭墍閫夊簱瀛樹俊鎭笉瀛樺湪锛侊紒"); } + loc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); + + if (!locService.updateById(loc)) { + throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐ワ紒锛�"); + } + String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); task.setOrgLoc(loc.getCode()) .setTaskCode(ruleCode) @@ -77,16 +95,29 @@ } Double orgQty = locItems.stream().mapToDouble(LocItem::getAnfme).sum(); + Double workQty = locItems.stream().mapToDouble(LocItem::getWorkQty).sum(); List<LocItem> locItemList = listMap.get(key); Double outQty = locItemList.stream().mapToDouble(LocItem::getOutQty).sum(); - if (orgQty.compareTo(outQty) > 0) { - //鎷f枡鍑哄簱 - task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_IN.type); - } else { - //鍏ㄦ澘鍑哄簱 - task.setTaskType(TaskType.TASK_TYPE_OUT.type); + Task serviceOne = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, loc.getBarcode())); + if (!Objects.isNull(serviceOne)) { + throw new CoolException("鎵樼洏浠诲姟鎵ц涓紝涓嶈兘閲嶅鍒涘缓锛�"); } + + if (type.equals("stock")) { + Double useQty = Math.round((outQty + workQty) * 10000) / 10000.0; + if (orgQty.compareTo(useQty) > 0) { + //鎷f枡鍑哄簱 + task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type); + } else { + //鍏ㄦ澘鍑哄簱 + task.setTaskType(TaskType.TASK_TYPE_OUT.type); + } + } else if (type.equals("check")) { + //鐩樼偣鍑哄簱 + task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type); + } + if (!taskService.save(task)) { throw new CoolException("浠诲姟鍒涘缓澶辫触锛侊紒"); } @@ -113,7 +144,7 @@ } else { item.setWorkQty(qty); } - if (! locItemService.updateById(item)) { + if (!locItemService.updateById(item)) { throw new CoolException("搴撳瓨淇℃伅淇敼澶辫触锛侊紒"); } }); @@ -125,4 +156,22 @@ return R.ok("浠诲姟鐢熸垚瀹屾垚锛�!"); } + + /** + * 鐢熸垚绉诲簱浠诲姟 + * @param map + * @return + */ + @Override + public R gentMoveTask(Map<String, Object> map) { + if (Objects.isNull(map.get("targetLoc"))) { + + } + if (Objects.isNull(map.get("orgLoc"))) { + + } + + return null; + } + } -- Gitblit v1.9.1