自动化立体仓库 - WMS系统
#
LSH
2022-09-23 23d414032034cbd4557198338124af212da13c74
#
2个文件已添加
2个文件已修改
144 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/MoveLocScheduler.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/handler/MoveLocHandler.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -15,15 +15,12 @@
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
import com.zy.common.model.DetlDto;
import com.zy.common.model.enums.WorkNoType;
import com.zy.common.utils.NodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.spel.ast.NullLiteral;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.tools.JavaCompiler;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -63,8 +60,6 @@
    private TestMastService testMastService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private WorkService workService;
    @Override
    @Transactional
@@ -667,12 +662,14 @@
        TestMast testMast = testMastService.selectOne(wrapper);
        if(null != testMast){
            if (testMast.getStatus()==3){
                Date date = new Date();
                testMast.setStatus(4);
                testMast.setModiTime(new Date());
                testMast.setModiTime(date);
                if (!testMastService.update(testMast,wrapper)){
                    throw new CoolException("更改测试状态失败");
                }
                locMast.setPackStatus(3);
                testMast.setModiTime(date);
                if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){
                    throw new CoolException("更改产品状态失败");
                }
@@ -683,17 +680,6 @@
            }
        } else {
            throw new CoolException("状态异常");
        }
        //移库开始,查询目标库位
        LocMast targetLocNo = locMastService.selectOne(new EntityWrapper<LocMast>()
                .eq("row1",2)
                .eq("loc_sts","O")
                .eq("fire_status", 0)
                .eq("pack_status",0));
        if (targetLocNo != null){
            workService.locMove(review.getLocNo(),targetLocNo.getLocNo(),(long)Integer.parseInt(review.getUserId()));
        }else {
            throw new CoolException("没有空库位");
        }
        return success;
    }
src/main/java/com/zy/asrs/task/MoveLocScheduler.java
New file
@@ -0,0 +1,34 @@
package com.zy.asrs.task;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.FireOutHandler;
import com.zy.asrs.task.handler.MoveLocHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class MoveLocScheduler {
    @Value("${wcs-slave.doubleDeep}")
    private boolean confirmDeep;
    @Autowired
    private MoveLocHandler moveLocHandler;
    /**
     *
     */
    @Scheduled(cron = "0/3 * * * * ? ")
    private void execute() {
        if (confirmDeep) return;
        ReturnT<String> result = moveLocHandler.start();
        if (!result.isSuccess()) {
//            log.error("测试完成移库失败");
        }
    }
}
src/main/java/com/zy/asrs/task/handler/MoveLocHandler.java
New file
@@ -0,0 +1,82 @@
package com.zy.asrs.task.handler;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.TestMastService;
import com.zy.asrs.service.WorkService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.Date;
import java.util.List;
/**
 * Created by vincent on 2020/7/6
 */
@Service
@Slf4j
public class MoveLocHandler extends AbstractHandler<String> {
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private TestMastService testMastService;
    @Autowired
    private WorkService workService;
    @Transactional
    public ReturnT<String> start() {
        try {
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("loc_sts", "F")
                    .eq("pack_status", 3)
                    .eq("row1", 2)
                    .eq("loc_type1", (short) 1)
                    .eq("fire_status",0)
            );
            if (!Cools.isEmpty(locMasts)){
                for (LocMast locMast:locMasts){
                    TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                            .eq("loc_no",locMast.getLocNo())
                            .eq("barcode",locMast.getBarcode())
                    );
                    if (!Cools.isEmpty(testMast)){
                        if (testMast.getStatus()==4){
                            //移库开始,查询目标库位
                            LocMast targetLocNo = locMastService.queryFreeLocMast(1,(short)2);
                            if (Cools.isEmpty(targetLocNo)){
                                targetLocNo=locMastService.queryFreeLocMast(2,(short)2);
                            }
                            if (targetLocNo != null){
                                workService.locMove(locMast.getLocNo(),targetLocNo.getLocNo(),(long)Integer.parseInt(testMast.getUserId()));
                            }else {
                                log.error("没有空库位");
                            }
                        }else if (testMast.getStatus()!=4) {
                            log.error("测试状态异常,库位号为:" + testMast.getLocNo());
                        }
                    }else {
                        log.error("测试库位:"+locMast.getLocNo()+"所属测试档为空");
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return FAIL.setMsg(e.getMessage());
        }
        return SUCCESS;
    }
}
src/main/java/com/zy/common/service/CommonService.java
@@ -198,13 +198,13 @@
                Integer ruleId = Integer.parseInt(Parameter.get().getFindLocRule());
                if (ruleId == 0){//默认规则
                    locMast = locMastService.queryFreeLocMast(1, locTypeDto.getLocType1());
                    locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1());
                } else if (ruleId == 1){ //按测试设备排序,优先排满单台设备
                    locMast = locMastService.queryFreeLocMast1(1, locTypeDto.getLocType1());
                    locMast = locMastService.queryFreeLocMast1(2, locTypeDto.getLocType1());
                } else if (ruleId == 2){//按通道排序,均匀分配每台设备
                    locMast = locMastService.queryFreeLocMast2(1, locTypeDto.getLocType1(), curRow);
                    locMast = locMastService.queryFreeLocMast2(2, locTypeDto.getLocType1(), curRow);
                } else {
                    locMast = locMastService.queryFreeLocMast(1, locTypeDto.getLocType1());
                    locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1());
                }
            }