| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | private Boolean erpEnabled; |
| | | |
| | | @Autowired |
| | | private ERPItemSchedulerMS erpItemSchedulerMS; |
| | | private ERPItemService erpItemService; |
| | | |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | |
| | | |
| | | |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | @Scheduled(cron = "${erp.refreshtime}") |
| | | public void ItemScheduler() { |
| | | log.info("ItemScheduler开始了"); |
| | | //log.info("ItemScheduler开始了"); |
| | | if (!erpEnabled) return; |
| | | String sqlItemTB = "select * from erp_ItemTB where LKName='中扬二期'"; |
| | | String sqlItemTB = "select TOP 1000 * from erp_ItemTB where LKName='中扬二期'"; |
| | | List<ItemTB> itemTBS = erpSqlServer.select(sqlItemTB, ItemTB.class); |
| | | if (itemTBS != null && itemTBS.size() > 0) { |
| | | for (ItemTB itemTB : itemTBS) { |
| | | System.out.println(itemTB); |
| | | log.info("新增物料成功,{}", itemTB); |
| | | //00代表新增 |
| | | if (itemTB.getFlag().equals("00")) { |
| | | erpItemSchedulerMS.addToMainDatabase(itemTB); |
| | | erpItemService.addToMainDatabase(itemTB); |
| | | } |
| | | //22代表删除 |
| | | if (itemTB.getFlag().equals("22")) { |
| | | erpItemSchedulerMS.deleteFromMainDatabase(itemTB); |
| | | log.info("删除物料成功,{}", itemTB); |
| | | erpItemService.deleteFromMainDatabase(itemTB); |
| | | } |
| | | moveToBak(itemTB); |
| | | } |