自动化立体仓库 - WMS系统
#
Junjie
1 天以前 757e410a3580adaaa305741903062371f98d778d
src/main/java/com/zy/common/web/WcsController.java
@@ -7,28 +7,26 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.result.FindLocNoAttributeVo;
import com.zy.asrs.entity.result.StorageResult;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.CodeRes;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.web.param.GetLocNoReassignParam;
import com.zy.common.web.param.NotifyDto;
import com.zy.common.web.param.SearchLocParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ReactiveTypeDescriptor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by vincent on 2020/10/30
@@ -78,6 +76,15 @@
        return R.ok(map);
    }
    @PostMapping("/reassign/loc/v1")
    @ResponseBody
    @Transactional
    public synchronized R getLocNoReassign(@RequestBody(required = false) GetLocNoReassignParam param) {
        log.info("收到WCS重新分配入库接口请求====>>入参:{}", param);
        StartupDto dto = startupFullReassign(param.getTaskNo(), param.getRow());
        log.info("WCS入库接口返参:{}", dto);
        return R.ok().add(dto);
    }
    @PostMapping("/pakin/loc/v1")
    @ResponseBody
@@ -371,6 +378,78 @@
        return dto;
    }
    /**
     * 全板入库-重新分配
     */
    @Transactional
    public StartupDto startupFullReassign(String workNo, int[] row) {
        WrkMast sourceWrkMast = wrkMastService.selectByTaskNo(workNo);
        if(sourceWrkMast == null) {
            throw new CoolException(workNo + "工作数据不存在");
        }
        List<WrkDetl> sourceWrkDetlList = wrkDetlService.selectByWrkNo(sourceWrkMast.getWrkNo());
        if (sourceWrkDetlList.isEmpty()) {
            throw new CoolException(workNo + "工作明细数据不存在");
        }
        FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo();
        findLocNoAttributeVo.setMatnr(sourceWrkDetlList.get(0).getMatnr());
        LocMast sourceLocMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", sourceWrkMast.getLocNo()));
        if (sourceLocMast == null) {
            throw new CoolException(sourceWrkMast.getLocNo() + "库位数据不存在");
        }
        LocTypeDto locTypeDto = new LocTypeDto();
        locTypeDto.setLocType1(sourceLocMast.getLocType1());
        StartupDto dto = commonService.getLocNoToWmsDev(1, sourceWrkMast.getSourceStaNo(), findLocNoAttributeVo, locTypeDto, sourceWrkMast.getBarcode(), row);
        if (dto == null) {
            throw new CoolException("找不到空库位");
        }
        Date now = new Date();
        // 生成工作档
        sourceWrkMast.setIoTime(new Date());
        sourceWrkMast.setWrkSts(2L); // 工作状态:生成入库ID
        sourceWrkMast.setIoType(1); // 入出库状态:1.入库
        sourceWrkMast.setIoPri(13D); // 优先级
        sourceWrkMast.setCrnNo(dto.getCrnNo());
        sourceWrkMast.setSourceStaNo(dto.getSourceStaNo());
        sourceWrkMast.setStaNo(dto.getStaNo());
        sourceWrkMast.setLocNo(loc(dto.getLocNo()));
        sourceWrkMast.setModiTime(now);
        boolean res = wrkMastService.updateById(sourceWrkMast);
        if (!res) {
            throw new CoolException("保存工作档失败");
        }
        // 更新源库位状态
        if (sourceLocMast.getLocSts().equals("S")) {
            sourceLocMast.setLocSts("O");
            sourceLocMast.setModiTime(now);
            if (!locMastService.updateById(sourceLocMast)) {
                throw new CoolException("改变库位状态失败");
            }
        } else {
            throw new CoolException(dto.getLocNo() + "目标库位状态不属于入库预约中");
        }
        // 更新目标库位状态
        LocMast locMast = locMastService.selectById(loc(dto.getLocNo()));
        if (locMast.getLocSts().equals("O")) {
            locMast.setLocSts("S"); // S.入库预约
            locMast.setModiTime(now);
            if (!locMastService.updateById(locMast)) {
                throw new CoolException("改变库位状态失败");
            }
        } else {
            throw new CoolException(dto.getLocNo() + "目标库位已被占用");
        }
        return dto;
    }
    public String loc(String locNo){
        String[] split = locNo.split("-");
        return Utils.getLocNo(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Integer.parseInt(split[2]));