自动化立体仓库 - WMS系统
#
wang..123
2021-11-23 37960b9097bbde94e188e1275bde0201e8b26860
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -14,13 +14,13 @@
import com.zy.asrs.service.*;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.model.LocDetlDto;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.OutLocDto;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.ints.entity.IoComplete;
import com.zy.ints.entity.WaitMatchk;
import com.zy.ints.entity.WaitMatout;
import com.zy.ints.service.IoCompleteService;
import com.zy.ints.service.WaitMatchkLogService;
import com.zy.ints.service.WaitMatchkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -68,6 +68,8 @@
    @Autowired
    private WaitMatchkService waitMatchkService;
    @Autowired
    private WaitMatchkLogService waitMatchkLogService;
    @Autowired
    private IoCompleteService ioCompleteService;
    @Override
@@ -83,7 +85,9 @@
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 检索库位
        List<String> matNos = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatNo).distinct().collect(Collectors.toList());
        StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matNos, 0);
        LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
        locTypeDto.setLocType1((short) 1);
        StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(),false, matNos,locTypeDto, 0);
        // 生成工作档
        WrkMast wrkMast = new WrkMast();
        wrkMast.setWrkNo(workNo);
@@ -156,7 +160,7 @@
            }
        }
        if (!locDetlDtos.isEmpty()) {
            // 启动出库开始 101.出库
            // 启动出库开始 101.103出库
            stockOut(staNo, locDetlDtos, null, userId);
        } else {
            throw new CoolException("库位产品不存在");
@@ -183,38 +187,6 @@
            }
            dtos.add(new OutLocDto(locNo, list));
        }
        //生成盘点文档
        for (LocDetlDto locDetlDto : locDetlDtos) {
            String id="";
            //获取当前时间戳
            SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
            String temp = sf.format(new Date());
            //获取6位随机数
            int random=(int) ((Math.random()+1)*1000);
            id=temp+random;
//            String replace = UUID.randomUUID().toString().replace("-", "");
            LocDetl locDetl = locDetlDto.getLocDetl();
            //生成盘点档
            WaitMatchk waitMatchk = new WaitMatchk();
            waitMatchk.setBillNo(id);//订单编号
            waitMatchk.setLocNo(locDetl.getLocNo());//库位号
            waitMatchk.setStockQty(locDetl.getQty());
            waitMatchk.setMatNo(locDetl.getMatNo());//产品编号
            waitMatchk.setMatName(locDetl.getMatName());//铲平名称
            waitMatchk.setSeqNo(i);
            waitMatchk.setIoTime(new Date());
            waitMatchk.setZpallet(locDetl.getZpallet());
            waitMatchk.setAppeUser(userId); // 操作人员数据
            waitMatchk.setAppeTime(new Date());
            waitMatchk.setModiUser(userId);
            waitMatchk.setModiTime(new Date());
            if (!waitMatchkService.insert(waitMatchk)){
                throw new CoolException("保存盘点档失败");
            }
            i++;
        }
        // 生成工作档
        for (OutLocDto dto : dtos) {
@@ -236,7 +208,6 @@
            }
            // 生成工作号
            int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
            // 生成工作档
            WrkMast wrkMast = new WrkMast();
@@ -291,6 +262,48 @@
            } else {
                throw new CoolException(dto.getLocNo() + "库位不是在库状态");
            }
            if(ioType == 107) {
                //获取当前时间戳
                SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
                String temp = sf.format(new Date());
                //获取3位随机数
                Random rand = new Random();
                Integer r = rand.nextInt(900) + 100;
                String billNo = temp + r;
                //生成盘点通知档
                for (LocDetlDto locDetlDto : locDetlDtos) {
//            String replace = UUID.randomUUID().toString().replace("-", "");
                    LocDetl locDetl = locDetlDto.getLocDetl();
                    //////插入盘点档前,将通知档之前相同库位数据转历史档
                    List<WaitMatchk> waitMatchks = waitMatchkService.selectList(new EntityWrapper<WaitMatchk>().eq("loc_no",locDetl.getLocNo()));
                    for(WaitMatchk one : waitMatchks){
                        waitMatchkLogService.save(one.getBillNo(),one.getLocNo(),one.getMatNo());
                        waitMatchkService.delete(new EntityWrapper<WaitMatchk>().eq("bill_no",one.getBillNo()).eq("loc_no",one.getLocNo()).eq("mat_no",one.getMatNo()));
                    }
                    //生成盘点档
                    WaitMatchk waitMatchk = new WaitMatchk();
                    waitMatchk.setBillNo(billNo);//订单编号
                    waitMatchk.setLocNo(locDetl.getLocNo());//库位号
                    waitMatchk.setStockQty(locDetl.getQty());
                    waitMatchk.setMatNo(locDetl.getMatNo());//产品编号
                    waitMatchk.setMatName(locDetl.getMatName());//铲平名称
                    waitMatchk.setSeqNo(i);
//                waitMatchk.setIoTime(new Date());
                    waitMatchk.setZpallet(locDetl.getZpallet());
                    waitMatchk.setAppeUser(userId); // 操作人员数据
                    waitMatchk.setAppeTime(new Date());
                    waitMatchk.setModiUser(userId);
                    waitMatchk.setModiTime(new Date());
                    if (!waitMatchkService.insert(waitMatchk)) {
                        throw new CoolException("保存盘点档失败");
                    }
                    i++;
                }
            }
        }
    }
@@ -302,7 +315,9 @@
        // 生成工作号
        int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
        // 检索库位
        StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, null, 0);
        LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
        locTypeDto.setLocType1((short) 1);
        StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, true,null,locTypeDto, 0);
        // 生成工作档
        WrkMast wrkMast = new WrkMast();
        wrkMast.setWrkNo(workNo);
@@ -533,32 +548,7 @@
        } else if (wrkMast.getWrkSts() > 10) {
            wrkMast.setWrkSts(14L);
        }
        //查询明细
        List<WrkDetl> detls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", workNo));
        int i=1;
        for (WrkDetl detl : detls) {
            //生成回报档
            IoComplete ioComplete = new IoComplete();
            ioComplete.setBillNo(detl.getBillNo());
            ioComplete.setMatNo(detl.getMatNo());
            ioComplete.setMatName(detl.getMatName());
            ioComplete.setSeqNo(i);
            ioComplete.setQty(detl.getQty());
            ioComplete.setZpallet(detl.getZpallet());
            ioComplete.setAppeUser(userId);
            if (wrkMast.getWrkSts()==4L){
                ioComplete.setTaskType(1);
                ioComplete.setLocNo(wrkMast.getLocNo());
            }else if (wrkMast.getWrkSts()==14L){
                ioComplete.setTaskType(2);
                ioComplete.setLocNo(wrkMast.getSourceLocNo());
            }
            ioComplete.setAppeTime(new Date());
            if (!ioCompleteService.insert(ioComplete)){
                throw new CoolException("生成回报档失败");
            }
            i++;
        }
        // 完成操作人员记录
        wrkMast.setManuType("手动完成");
        Date now = new Date();
@@ -581,7 +571,7 @@
            throw new CoolException("库位不存在");
        }
        //查询库位状态
        if (locMast.getLocSts().equals("O")){
        if (locMast.getLocSts().equals("O") || locMast.getLocSts().equals("D")){
            //更新库位状态
            locMast.setLocSts("F");
//            boolean b = locMastService.updateById(locMast);