#
Junjie
2025-02-14 ac4341ea6b66ae02427d39d35f41d42d78b2eb2e
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("参数不能为空");