自动化立体仓库 - WMS系统
admin
2021-09-01 e84d4700e32dba450aa4d239779fc39f38ae4afa
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -17,10 +17,16 @@
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.WaitMatchkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -30,6 +36,7 @@
 */
@Service
public class WorkServiceImpl implements WorkService {
    static int i =1;
    // 工作号生成规则默认类型
    private static final int DEFAULT_WORK_NO_TYPE = 0;
@@ -58,6 +65,10 @@
    private WrkMastLogService wrkMastLogService;
    @Autowired
    private WrkDetlLogService wrkDetlLogService;
    @Autowired
    private WaitMatchkService waitMatchkService;
    @Autowired
    private IoCompleteService ioCompleteService;
    @Override
    @Transactional
@@ -155,6 +166,7 @@
    @Override
    @Transactional
    public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId) {
        // 合并同类项
        Set<String> locNos = new HashSet<>();
        locDetlDtos.forEach(dto -> locNos.add(dto.getLocDetl().getLocNo()));
@@ -166,13 +178,47 @@
                LocDetlDto dto = iterator.next();
                if (locNo.equals(dto.getLocDetl().getLocNo())) {
                    list.add(dto);
                    iterator.remove();
//                    iterator.remove();
                }
            }
            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) {
            // 判断入出库类型:101.全板出库 or 103.拣料出库
            if (ioType == null) {
                ioType = dto.isAll() ? 101 : 103;
@@ -190,6 +236,8 @@
            }
            // 生成工作号
            int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
            // 生成工作档
            WrkMast wrkMast = new WrkMast();
            wrkMast.setWrkNo(workNo);
@@ -485,6 +533,32 @@
        } 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();
@@ -500,10 +574,22 @@
    @Override
    @Transactional
    public void adjustLocDetl(LocDetlAdjustParam param, Long userId) {
        //根据库位号找寻库位
        LocMast locMast = locMastService.selectById(param.getLocNo());
        //判断
        if (Cools.isEmpty(locMast)) {
            throw new CoolException("库位不存在");
        }
        //查询库位状态
        if (locMast.getLocSts().equals("O")){
            //更新库位状态
            locMast.setLocSts("F");
//            boolean b = locMastService.updateById(locMast);
            if (!locMastService.updateById(locMast)){
                throw new CoolException("更新库位状态失败");
            }
        }
        for (LocDetlAdjustParam.LocDetlAdjust adjust : param.getList()) {
            if (Cools.isEmpty(adjust.getMatNo())) {
                throw new CoolException(BaseRes.PARAM);
@@ -526,6 +612,7 @@
                locDetl.setModiTime(new Date());
                locDetl.setAppeUser(userId);
                locDetl.setAppeTime(new Date());
                locDetl.setZpallet(param.getZpallet());//托盘号
                if (!locDetlService.insert(locDetl)) {
                    throw new CoolException("保存库存明细失败");
                }