#
luxiaotao1123
2020-06-17 51d80adb1a4c31aef17eecd976fd9d51306ce8a9
#
1个文件已添加
2个文件已修改
185 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/WorkService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/OutLocDto.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/WorkService.java
@@ -1,8 +1,12 @@
package com.zy.asrs.service;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.param.EmptyPlateOutParam;
import com.zy.asrs.entity.param.FullStoreParam;
import com.zy.asrs.entity.param.StockOutParam;
import java.util.List;
public interface WorkService {
@@ -16,7 +20,14 @@
     * 全板出库
     * @return 库位号
     */
    String startupFullTakeStore(StockOutParam param, Long userId);
    void startupFullTakeStore(StockOutParam param, Long userId);
    /**
     * 出库作业
     * @param staNo 目标站点
     * @param locDetls 待出库物料
     */
    void stockOut(BasDevp staNo, List<LocDetl> locDetls, Long userId);
    /**
     * 空板入库
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -10,21 +10,23 @@
import com.zy.asrs.entity.param.FullStoreParam;
import com.zy.asrs.entity.param.StockOutParam;
import com.zy.asrs.service.*;
import com.zy.common.model.OutLocDto;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
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.Date;
import java.util.List;
import java.util.*;
/**
 * Created by vincent on 2020/6/11
 */
@Service
public class WorkServiceImpl implements WorkService {
    // 工作号生成规则默认类型
    private static final int DEFAULT_WORK_NO_TYPE = 0;
    @Autowired
    private WrkMastService wrkMastService;
@@ -51,7 +53,7 @@
        // 源站点状态检测
        BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo());
        // 生成工作号
        int workNo = commonService.getWorkNo(0);
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 检索库位
        StartupDto dto = commonService.getLocNo(1, 1, param.getDevpNo());
        // 生成工作档
@@ -109,10 +111,121 @@
    }
    @Override
    public String startupFullTakeStore(StockOutParam param, Long userId) {
        // todo
    @Transactional
    public void startupFullTakeStore(StockOutParam param, Long userId) {
        // 目标站点状态检测
        BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
        // 获取库位明细
        List<LocDetl> locDetls = new ArrayList<>();
        for (StockOutParam.LocDetl locDetl : param.getLocDetls()) {
            if (!Cools.isEmpty(locDetl.getLocNo(), locDetl.getMatnr())) {
                LocDetl sqlParam = new LocDetl();
                sqlParam.setLocNo(locDetl.getLocNo());
                sqlParam.setMatnr(locDetl.getMatnr());
                LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam));
                if (null != one) locDetls.add(one);
            }
        }
        if (!locDetls.isEmpty()) {
            // 启动出库开始
            stockOut(staNo, locDetls, userId);
        } else {
            throw new CoolException("库位物料不存在");
        }
    }
        return null;
    @Override
    @Transactional
    public void stockOut(BasDevp staNo, List<LocDetl> locDetls, Long userId) {
        // 生成工作号
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 合并同类项
        Set<String> locNos = new HashSet<>();
        locDetls.forEach(locDetl -> locNos.add(locDetl.getLocNo()));
        List<OutLocDto> dtos = new ArrayList<>();
        for (String locNo : locNos) {
            List<LocDetl> list = new ArrayList<>();
            Iterator<LocDetl> iterator = locDetls.iterator();
            while (iterator.hasNext()) {
                LocDetl locDetl = iterator.next();
                if (locNo.equals(locDetl.getLocNo())) {
                    list.add(locDetl);
                    iterator.remove();
                }
            }
            dtos.add(new OutLocDto(locNo, list));
        }
        // 生成工作档
        for (OutLocDto dto : dtos) {
            // 获取库位
            LocMast locMast = locMastService.selectById(dto.getLocNo());
            // 获取路径
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", 101)
                    .eq("stn_no", staNo.getDevNo())
                    .eq("crn_no", locMast.getCrnNo());
            StaDesc staDesc = staDescService.selectOne(wrapper);
            if (Cools.isEmpty(staDesc)) {
                throw new CoolException("出库路径不存在");
            }
            // 生成工作档
            WrkMast wrkMast = new WrkMast();
            wrkMast.setWrkNo(workNo);
            wrkMast.setIoTime(new Date());
            wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
            wrkMast.setIoType(101); // 入出库状态:101.出库
            wrkMast.setIoPri(13D); // 优先级:13
            wrkMast.setCrnNo(locMast.getCrnNo());
            wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站
            wrkMast.setStaNo(staDesc.getStnNo()); // 目标站
            wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位
            wrkMast.setFullPlt("Y"); // 满板:Y
            wrkMast.setPicking("N"); // 拣料
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk("N"); // 空板
            wrkMast.setLinkMis("N");
            wrkMast.setAppeUser(userId); // 操作人员数据
            wrkMast.setAppeTime(new Date());
            wrkMast.setModiUser(userId);
            wrkMast.setModiTime(new Date());
            if (!wrkMastService.insert(wrkMast)) {
                throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo());
            }
            // 生成工作档明细
            for (LocDetl locDetl : dto.getLocDetls()) {
                WrkDetl wrkDetl = new WrkDetl();
                wrkDetl.setWrkNo(workNo);
                wrkDetl.setIoTime(new Date());
                wrkDetl.setMatnr(locDetl.getMatnr());
                wrkDetl.setAnfme(locDetl.getAnfme());
                wrkDetl.setZmatid(locDetl.getZmatid());
                wrkDetl.setTbpos(locDetl.getTbpos());
                wrkDetl.setTbnum(locDetl.getTbnum());
                wrkDetl.setLgnum(locDetl.getLgnum());
                wrkDetl.setAltme(locDetl.getAltme());
                wrkDetl.setBname(locDetl.getBname());
                wrkDetl.setMaktx(locDetl.getMaktx());
                wrkDetl.setAppeTime(new Date());
                wrkDetl.setAppeUser(userId);
                wrkDetl.setModiTime(new Date());
                wrkDetl.setModiUser(userId);
                if (!wrkDetlService.insert(wrkDetl)) {
                    throw new CoolException("保存工作档明细失败");
                }
            }
            // 修改库位状态:   F.在库 ====>>> R.出库预约
            locMast = locMastService.selectById(dto.getLocNo());
            if (locMast.getLocType().equals("F")) {
                locMast.setLocType("R");
                locMast.setModiUser(userId);
                locMast.setModiTime(new Date());
                if (!locMastService.updateById(locMast)) {
                    throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo());
                }
            } else {
                throw new CoolException(dto.getLocNo() + "库位不是在库状态");
            }
        }
    }
    @Override
@@ -121,7 +234,7 @@
        // 源站点状态检测
        BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo);
        // 生成工作号
        int workNo = commonService.getWorkNo(0);
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 检索库位
        StartupDto dto = commonService.getLocNo(1, 10, devpNo);
        // 生成工作档
@@ -180,7 +293,7 @@
        }
        for (String locNo : param.getLocNos()) {
            // 获取工作号
            int workNo = commonService.getWorkNo(0);
            int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
            // 获取库位
            LocMast locMast = locMastService.selectById(locNo);
            if (Cools.isEmpty(locMast)) {
@@ -248,7 +361,7 @@
            throw new CoolException("移转库位属于不同堆垛机");
        }
        // 获取工作号
        int workNo = commonService.getWorkNo(0);
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 保存工作档
        WrkMast wrkMast = new WrkMast();
        wrkMast.setWrkNo(workNo);
src/main/java/com/zy/common/model/OutLocDto.java
New file
@@ -0,0 +1,39 @@
package com.zy.common.model;
import com.zy.asrs.entity.LocDetl;
import java.util.List;
/**
 * Created by vincent on 2020/6/17
 */
public class OutLocDto {
    private String locNo;
    private List<LocDetl> locDetls;
    public OutLocDto() {
    }
    public OutLocDto(String locNo, List<LocDetl> locDetls) {
        this.locNo = locNo;
        this.locDetls = locDetls;
    }
    public String getLocNo() {
        return locNo;
    }
    public void setLocNo(String locNo) {
        this.locNo = locNo;
    }
    public List<LocDetl> getLocDetls() {
        return locDetls;
    }
    public void setLocDetls(List<LocDetl> locDetls) {
        this.locDetls = locDetls;
    }
}