package com.zy.third.task;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.common.Cools;
|
import com.zy.asrs.entity.OrderDetl1;
|
import com.zy.asrs.service.impl.OrderDetl1ServiceImpl;
|
import com.zy.third.entity.ExdInstockSource;
|
import com.zy.third.entity.ExdInstockTarget;
|
import com.zy.third.entity.ExdOutstockSource;
|
import com.zy.third.entity.ExdOutstockTarget;
|
import com.zy.third.mapper.ExdInstockSourceMapper;
|
import com.zy.third.mapper.ExdOutstockSourceMapper;
|
import com.zy.third.service.ExdInstockTargetService;
|
import com.zy.third.service.ExdOutstockTargetService;
|
import com.zy.third.task.handler.OrderHandler;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Component
|
@Slf4j
|
public class OrderScheduler {
|
|
|
@Autowired
|
private OrderHandler orderHandler;
|
|
@Autowired
|
private ExdInstockSourceMapper exdInstockSourceMapper;
|
|
|
@Autowired
|
private ExdOutstockSourceMapper exdOutstockSourceMapper;
|
|
@Autowired
|
private ExdInstockTargetService exdInstockTargetService;
|
|
@Autowired
|
private ExdOutstockTargetService exdOutstockTargetService;
|
@Autowired
|
private OrderDetl1ServiceImpl orderDetl1ServiceImpl;
|
@Autowired
|
private OrderDetl1ServiceImpl orderDetl1Service;
|
|
|
/**
|
* 读取入库单据
|
*/
|
@Scheduled(cron = "0/10 * * * * ? ")
|
public void readInOrder() {
|
//log.info("读取入库单据");
|
List<String> orderNos = exdInstockSourceMapper.listOrderNo();
|
for (String orderNo : orderNos) {
|
List<ExdInstockSource> exdInstockSources = exdInstockSourceMapper.listAll(orderNo);
|
try {
|
boolean success = orderHandler.readInOrder(exdInstockSources).isSuccess();
|
for (ExdInstockSource exdInstockSource : exdInstockSources) {
|
if (success) {
|
exdInstockSource.setReadtime(new Date());
|
exdInstockSource.setStatus(1);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
} else {
|
exdInstockSource.setReadtime(new Date());
|
exdInstockSource.setStatus(2);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
}
|
}
|
} catch (Exception e) {
|
log.error("读取入库单据信息失败:{},{}", exdInstockSources, e.getMessage());
|
e.printStackTrace();
|
for (ExdInstockSource exdInstockSource : exdInstockSources) {
|
exdInstockSource.setReadormsg(e.getMessage());
|
exdInstockSource.setStatus(2);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
}
|
}
|
}
|
}
|
|
/**
|
* 读取入库单据,对erp标记为删除的订单进行删除
|
* status 5 --》 8 删除成功
|
* status 5 --》 7 删除失败
|
*/
|
@Scheduled(cron = "0/10 * * * * ? ")
|
public void deleteInOrder() {
|
//log.info("读取入库单据");
|
List<String> orderNos = exdInstockSourceMapper.deletelistOrderNo();
|
for (String orderNo : orderNos) {
|
List<ExdInstockSource> exdInstockSources = exdInstockSourceMapper.listAll(orderNo);
|
try {
|
boolean success = orderHandler.deletereadInOrder(exdInstockSources).isSuccess();
|
for (ExdInstockSource exdInstockSource : exdInstockSources) {
|
if (success) {
|
exdInstockSource.setReadtime(new Date());
|
exdInstockSource.setStatus(8);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
} else {
|
exdInstockSource.setReadtime(new Date());
|
exdInstockSource.setStatus(7);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
}
|
}
|
} catch (Exception e) {
|
// log.error("读取入库单据信息失败:{},{}", exdInstockSources, e.getMessage());
|
e.printStackTrace();
|
for (ExdInstockSource exdInstockSource : exdInstockSources) {
|
exdInstockSource.setReadormsg(e.getMessage());
|
exdInstockSource.setStatus(7);
|
exdInstockSourceMapper.updateById(exdInstockSource);
|
}
|
}
|
}
|
}
|
|
/**
|
* 读取出库单据
|
*/
|
@Scheduled(cron = "0/10 * * * * ? ")
|
public void readOutOrder() {
|
//log.info("读取出库单据");
|
List<String> orderNos = exdOutstockSourceMapper.listOrderNo();
|
for (String orderNo : orderNos) {
|
List<ExdOutstockSource> exdOutstockSources = exdOutstockSourceMapper.listAll(orderNo);
|
try {
|
boolean success = orderHandler.readOutOrder(exdOutstockSources).isSuccess();
|
for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
|
if (success) {
|
exdOutstockSource.setReadtime(new Date());
|
exdOutstockSource.setStatus(1);
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
} else {
|
exdOutstockSource.setReadtime(new Date());
|
exdOutstockSource.setStatus(2);
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
}
|
}
|
} catch (Exception e) {
|
log.error("读取出库单据信息失败:{},{}", exdOutstockSources, e.getMessage());
|
e.printStackTrace();
|
for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
|
exdOutstockSource.setStatus(2);
|
exdOutstockSource.setReadormsg(e.getMessage());
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
}
|
}
|
}
|
}
|
|
/**
|
* 读取删除出库单据
|
*/
|
@Scheduled(cron = "0/10 * * * * ? ")
|
public void deletereadOutOrder() {
|
//log.info("读取出库单据");
|
List<String> orderNos = exdOutstockSourceMapper.deletelistOrderNo();
|
for (String orderNo : orderNos) {
|
List<ExdOutstockSource> exdOutstockSources = exdOutstockSourceMapper.listAll(orderNo);
|
try {
|
boolean success = orderHandler.deletereadOutOrder(exdOutstockSources).isSuccess();
|
for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
|
if (success) {
|
exdOutstockSource.setReadtime(new Date());
|
exdOutstockSource.setStatus(8);
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
} else {
|
exdOutstockSource.setReadtime(new Date());
|
exdOutstockSource.setStatus(7);
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
}
|
}
|
} catch (Exception e) {
|
// log.error("读取出库单据信息失败:{},{}", exdOutstockSources, e.getMessage());
|
e.printStackTrace();
|
for (ExdOutstockSource exdOutstockSource : exdOutstockSources) {
|
exdOutstockSource.setStatus(7);
|
exdOutstockSource.setReadormsg(e.getMessage());
|
exdOutstockSourceMapper.updateById(exdOutstockSource);
|
}
|
}
|
}
|
}
|
|
/**
|
* 读取错误出库完成单据
|
*/
|
// @Scheduled(cron = "* 0/10 * * * ? ")
|
@Scheduled(cron = "0/10 * * * * ? ")
|
public void readOutOrdererror() {
|
List<ExdOutstockTarget> status = exdOutstockTargetService.selectList(new EntityWrapper<ExdOutstockTarget>().isNotNull("ReadorMsg"));
|
if (status.size() > 0) {
|
for (ExdOutstockTarget exdOutstockTarget : status) {
|
List<OrderDetl1> orderNo = orderDetl1Service.selectList(new EntityWrapper<OrderDetl1>().eq("order_no", exdOutstockTarget.getFbillno()));
|
if (!Cools.isEmpty(orderNo)) {
|
for (OrderDetl1 orderDetl1 : orderNo) {
|
if (!Cools.isEmpty(orderDetl1.getMemo())&&orderDetl1.getMemo().equals(exdOutstockTarget.getReadormsg())) {
|
break;
|
}
|
orderDetl1.setMemo(exdOutstockTarget.getReadormsg());
|
orderDetl1Service.updateById(orderDetl1);
|
}
|
}
|
}
|
}
|
|
}
|
|
/**
|
* 读取错误入库完成单据
|
*/
|
@Scheduled(cron = "* 0/10 * * * ? ")
|
// @Scheduled(cron = "0/10 * * * * ? ")
|
public void readInOrdererror() {
|
List<ExdInstockTarget> status = exdInstockTargetService.selectList(new EntityWrapper<ExdInstockTarget>().isNotNull("ReadorMsg"));
|
if (status.size() > 0) {
|
for (ExdInstockTarget exdInstockTarget : status) {
|
List<OrderDetl1> orderNo = orderDetl1Service.selectList(new EntityWrapper<OrderDetl1>().eq("order_no", exdInstockTarget.getFbillno()));
|
if (!Cools.isEmpty(orderNo)) {
|
for (OrderDetl1 orderDetl1 : orderNo) {
|
if (orderDetl1.getMemo().equals(exdInstockTarget.getReadormsg())) {
|
break;
|
}
|
orderDetl1.setMemo(exdInstockTarget.getReadormsg());
|
orderDetl1Service.updateById(orderDetl1);
|
}
|
}
|
|
}
|
}
|
|
}
|
|
}
|