zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WorkController.java
@@ -58,65 +58,12 @@ @PostMapping("/loc/adjust") @Transactional public R locAdjust(@RequestBody LocAdjustParam param) { if (param == null) { return R.error("参数不能为空"); try { workService.locAdjust(param); return R.ok(); } catch (Exception e) { return R.error(e.getMessage()); } if (Cools.isEmpty(param.getLocNo())) { return R.error("库位号不能为空"); } if (param.getDetls() == null) { return R.error("库存明细不能为空"); } Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getLocNo())); if (loc == null) { return R.error("库位不存在"); } //删除源库存 locDetlService.removeLocDetl(loc.getId()); List<MatField> matFields = matFieldService.list(new LambdaQueryWrapper<MatField>().eq(MatField::getUnique, 1)); for (Map<String, Object> map : param.getDetls()) { LocDetl locDetl = JSON.parseObject(JSON.toJSONString(map), LocDetl.class); HashMap<String, Object> uniqueFields = new HashMap<>(); for (Map.Entry<String, Object> entry : map.entrySet()) { for (MatField field : matFields) { if (entry.getKey().equals(field.getName())) { uniqueFields.put(entry.getKey(), entry.getValue()); } } } locDetl.setAnfme(Double.parseDouble(map.get("qty").toString())); locDetl.syncFieldMap(uniqueFields); if (locDetl.getAnfme() <= 0D) { throw new CoolException("数量不能小于0"); } locDetl.setId(null); locDetl.setLocId(loc.getId()); locDetl.setLocNo(loc.getLocNo()); boolean save = locDetlService.save(locDetl); if (!save) { throw new CoolException("库存调整失败"); } //插入库存明细字段 for (MatField matField : matFields) { LocDetlField locDetlField = new LocDetlField(); locDetlField.setDetlId(locDetl.getId()); locDetlField.setFieldId(matField.getId()); locDetlField.setName(matField.getName()); locDetlField.setValue(Optional.ofNullable(uniqueFields.get(matField.getName()).toString()).orElse("")); locDetlFieldService.save(locDetlField); } } return R.ok(); } @OperationLog("库存移转") zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WorkService.java
@@ -3,6 +3,7 @@ import com.zy.asrs.wms.asrs.entity.Loc; import com.zy.asrs.wms.asrs.entity.param.FieldParam; import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; import com.zy.asrs.wms.asrs.entity.param.LocAdjustParam; import com.zy.asrs.wms.asrs.entity.param.LocTransferParam; import java.util.List; @@ -39,6 +40,9 @@ //拣料任务 boolean pickTask(Long taskId); //库存调整 boolean locAdjust(LocAdjustParam param); //库位移转 boolean locTransfer(LocTransferParam param); zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
@@ -1,5 +1,6 @@ package com.zy.asrs.wms.asrs.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.R; @@ -8,6 +9,7 @@ import com.zy.asrs.wms.asrs.entity.enums.*; import com.zy.asrs.wms.asrs.entity.param.FieldParam; import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; import com.zy.asrs.wms.asrs.entity.param.LocAdjustParam; import com.zy.asrs.wms.asrs.entity.param.LocTransferParam; import com.zy.asrs.wms.asrs.service.*; import com.zy.asrs.wms.utils.LocUtils; @@ -70,6 +72,8 @@ private OrderUtils orderUtils; @Autowired private WaveDetlService waveDetlService; @Autowired private MatFieldService matFieldService; @Override public String generateTaskNo(Long taskType) { @@ -686,6 +690,71 @@ } @Override @Transactional public boolean locAdjust(LocAdjustParam param) { if (param == null) { throw new CoolException("参数不能为空"); } if (Cools.isEmpty(param.getLocNo())) { throw new CoolException("库位号不能为空"); } if (param.getDetls() == null) { throw new CoolException("库存明细不能为空"); } Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getLocNo())); if (loc == null) { throw new CoolException("库位不存在"); } //删除源库存 locDetlService.removeLocDetl(loc.getId()); List<MatField> matFields = matFieldService.list(new LambdaQueryWrapper<MatField>().eq(MatField::getUnique, 1)); for (Map<String, Object> map : param.getDetls()) { LocDetl locDetl = JSON.parseObject(JSON.toJSONString(map), LocDetl.class); HashMap<String, Object> uniqueFields = new HashMap<>(); for (Map.Entry<String, Object> entry : map.entrySet()) { for (MatField field : matFields) { if (entry.getKey().equals(field.getName())) { uniqueFields.put(entry.getKey(), entry.getValue()); } } } locDetl.setAnfme(Double.parseDouble(map.get("qty").toString())); locDetl.syncFieldMap(uniqueFields); if (locDetl.getAnfme() <= 0D) { throw new CoolException("数量不能小于0"); } locDetl.setId(null); locDetl.setLocId(loc.getId()); locDetl.setLocNo(loc.getLocNo()); boolean save = locDetlService.save(locDetl); if (!save) { throw new CoolException("库存调整失败"); } //插入库存明细字段 for (MatField matField : matFields) { LocDetlField locDetlField = new LocDetlField(); locDetlField.setDetlId(locDetl.getId()); locDetlField.setFieldId(matField.getId()); locDetlField.setName(matField.getName()); locDetlField.setValue(Optional.ofNullable(uniqueFields.get(matField.getName()).toString()).orElse("")); locDetlFieldService.save(locDetlField); } } return true; } @Override @Transactional public boolean locTransfer(LocTransferParam param) { if (param == null) { throw new CoolException("参数不能为空");