自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-03-30 e429033bedde0bf5f997411e688495c9518ec469
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -19,7 +19,6 @@
import com.zy.common.service.CommonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -112,7 +111,14 @@
        // 生成工作档明细
        List<DetlDto> detlDtos = new ArrayList<>();
        param.getList().forEach(elem -> {
            detlDtos.add(new DetlDto(elem.getMatNo(), elem.getCount()));
            DetlDto detlDto = new DetlDto(elem.getMatNo(), elem.getBatch(), elem.getAnfme());
            if (DetlDto.has(detlDtos, detlDto)) {
                DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                assert detlDto1 != null;
                detlDto1.setAnfme(detlDto1.getAnfme() + detlDto.getAnfme());
            } else {
                detlDtos.add(detlDto);
            }
        });
        wrkDetlService.createWorkDetail(workNo, detlDtos, param.getBarcode(), userId);
        // 更新源站点信息
@@ -146,10 +152,7 @@
        List<LocDetlDto> locDetlDtos = new ArrayList<>();
        for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) {
            if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) {
                LocDetl sqlParam = new LocDetl();
                sqlParam.setLocNo(paramLocDetl.getLocNo());
                sqlParam.setMatnr(paramLocDetl.getMatnr());
                LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam));
                LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch());
                if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount()));
            }
        }
@@ -157,7 +160,7 @@
            // 启动出库开始 101.出库
            stockOut(staNo, locDetlDtos, null, userId);
        } else {
            throw new CoolException("库位物料不存在");
            throw new CoolException("库存不存在");
        }
    }
@@ -821,56 +824,6 @@
        if (!locMastService.updateById(locMast)) {
            throw new CoolException("修改库位状态失败");
        }
    }
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private boolean pickSite = false;
    private void stockOutRe(WrkMast wrkMast, List<WrkDetl> wrkDetls) {
        for (WrkDetl wrkDetl : wrkDetls) {
            List<LocDetl> locDetls = locDetlService.selectPakoutByRule(wrkDetl.getMatnr());
            double issued = wrkDetl.getAnfme();
            for (LocDetl locDetl : locDetls) {
                if (issued > 0) {
                    // 生成出库工作档
                    // 全板
                    if (issued>=locDetl.getAnfme()) {
                        BasDevp staNo = basDevpService.checkSiteStatus(103);
                        List<LocDetlDto> detlDtos = new ArrayList<>();
                        LocDetlDto dto = new LocDetlDto();
                        dto.setLocDetl(locDetl);
                        dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued);
                        detlDtos.add(dto);
                        stockOut(staNo, detlDtos, 101, 9527L);
                        // 拣料
                    } else {
                        int priorCount = jdbcTemplate.queryForObject("select isnull(count(*),0) from man_prior where 1=1 and matnr = '" + wrkDetl.getMatnr() + "'", Integer.class);
                        if (priorCount > 0) {
                            BasDevp staNo = basDevpService.checkSiteStatus(103);
                            List<LocDetlDto> detlDtos = new ArrayList<>();
                            LocDetlDto dto = new LocDetlDto();
                            dto.setLocDetl(locDetl);
                            dto.setCount(locDetl.getAnfme());
                            detlDtos.add(dto);
                            stockOut(staNo, detlDtos, 101, 9527L);
                        } else {
                            BasDevp staNo = basDevpService.checkSiteStatus(pickSite?113:109);
                            List<LocDetlDto> detlDtos = new ArrayList<>();
                            LocDetlDto dto = new LocDetlDto();
                            dto.setLocDetl(locDetl);
                            dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued);
                            detlDtos.add(dto);
                            stockOut(staNo, detlDtos, 103, 9527L);
                        }
                    }
                    // 剩余待出数量递减
                    issued = issued - locDetl.getAnfme();
                }
            }
        }
        pickSite = !pickSite;
    }
}