| New file |
| | |
| | | package com.zy.third.task; |
| | | |
| | | import com.zy.third.entity.ExdInstockSource; |
| | | import com.zy.third.entity.ExdOutstockSource; |
| | | import com.zy.third.mapper.ExdInstockSourceMapper; |
| | | import com.zy.third.mapper.ExdOutstockSourceMapper; |
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * 读取入库单据 |
| | | */ |
| | | @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()); |
| | | for (ExdInstockSource exdInstockSource : exdInstockSources) { |
| | | exdInstockSource.setReadormsg(e.getMessage()); |
| | | exdInstockSource.setStatus(2); |
| | | 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()); |
| | | for (ExdOutstockSource exdOutstockSource : exdOutstockSources) { |
| | | exdOutstockSource.setStatus(2); |
| | | exdOutstockSource.setReadormsg(e.getMessage()); |
| | | exdOutstockSourceMapper.updateById(exdOutstockSource); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |