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.beans.factory.annotation.Value;
|
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;
|
|
@Value("${channel.equipmentRow}")
|
private Integer equipmentRow; //测试库位所在排号
|
@Value("${channel.quietRow}")
|
private Integer quietRow; //静置库位所在排号
|
|
@Transactional
|
public ReturnT<String> start() {
|
try {
|
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
|
.eq("loc_sts", "F")
|
.eq("pack_status", 3)
|
.eq("row1", equipmentRow)
|
.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())
|
.eq("status",4)
|
);
|
if (!Cools.isEmpty(testMast)){
|
if (testMast.getStatus()==4){
|
//移库开始,查询目标库位
|
LocMast targetLocNo = locMastService.queryFreeLocMast(quietRow,(short)2);
|
if (Cools.isEmpty(targetLocNo)){
|
targetLocNo=locMastService.queryFreeLocMast(equipmentRow,(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()+"所属测试档为空或者不状态为4");
|
}
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
return FAIL.setMsg(e.getMessage());
|
}
|
return SUCCESS;
|
}
|
|
}
|