自动化立体仓库 - WMS系统
#
lty
5 天以前 d8c9b9afb41c368a08d7e05d0f624c98bf72042a
src/main/java/com/zy/third/erp/task/ERPItemScheduler.java
@@ -7,6 +7,7 @@
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;
@@ -20,27 +21,31 @@
    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);
            }
@@ -54,6 +59,6 @@
     */
    //将数据从主表移动到bak表里
    private void moveToBak(ItemTB itemTB) {
        erpSqlServer.update("delete from erp_ItemTB where LKName='中扬二期' and ItemId = '" + itemTB.getItemId() + "'");
        erpSqlServer.update("delete from erp_ItemTB where LKName='高霖立库' and Item_id = '" + itemTB.getItemId() + "'");
    }
}