自动化立体仓库 - WMS系统
ZY
2024-09-21 58dc66a9d999c7d350e1ee4bf32b8d85b6e20e00
src/main/java/com/zy/third/erp/task/ERPInHedTBScheduler.java
@@ -1,5 +1,6 @@
package com.zy.third.erp.task;
import com.core.common.Cools;
import com.zy.common.service.erp.ErpSqlServer;
import com.zy.third.erp.entity.InDetTB;
import com.zy.third.erp.entity.InHedTB;
@@ -26,52 +27,57 @@
    @Autowired
    private ERPInOrOutTBSchedulerMS inMS;
    private ERPInOrOutService inMS;
    @Autowired
    private ErpSqlServer erpSqlServer;
    //@Transactional(rollbackFor = Throwable.class)
    @Scheduled(cron = "${erp.refreshtime}")
    public void InHedTBScheduler() {
        log.info("InHedTBScheduler开始了");
        //log.info("InHedTBScheduler开始了");
        if (!erpEnabled) return;
        String sqlInHed = "select * from erp_InHedTB where LKName='中扬二期'";
        List<InHedTB> inHeds = erpSqlServer.select(sqlInHed, InHedTB.class);
        if (inHeds.size() > 0) {
        if (!inHeds.isEmpty()) {
            for (InHedTB inHed : inHeds) {
                System.out.println(inHed);
                if (!Cools.isEmpty(inHed.getTemp3()) && inHed.getTemp3().equals("fault")) {
                    continue;
                }
                HashMap<String, String> condition = new HashMap<>();
                condition.put("BillNo", "'" + inHed.getBillNo() + "'");
                List<InDetTB> inDetTBS = erpSqlServer.selectList(InDetTB.class, condition);
                HashMap<String, Object> hedAndDet = new HashMap<>();
                hedAndDet.put("hed", inHed);
                hedAndDet.put("det", inDetTBS);
                boolean result = inMS.createOrder(inHed, inDetTBS);
                if (result) {
                try {
                    inMS.createInOrder(inHed, inDetTBS);
                    log.info("入库单据成功,{}", inHed);
                    move(hedAndDet);
                } else {
                    String sql = "UPDATE erp_InHedTB SET Temp3 = ‘fault’ WHERE BillNo = '" + inHed.getBillNo() + "'";
                } catch (Exception e) {
                    e.printStackTrace();
                    String sql = "UPDATE erp_InHedTB SET Temp3 = 'fault' WHERE BillNo = '" + inHed.getBillNo() + "'";
                    erpSqlServer.update(sql);
                }
            }
        }
    }
    @Transactional
    @Transactional(rollbackFor = Throwable.class)
    public void move(HashMap<String, Object> hedAndDet) {
        InHedTB hed = (InHedTB) hedAndDet.get("hed");
        ArrayList<InDetTB> dets = (ArrayList<InDetTB>) hedAndDet.get("det");
        HashMap<String, String> condition = new HashMap<>();
        condition.put("BillNo", "'" + hed.getBillNo() + "'");
        erpSqlServer.delete(InHedTB.class, condition);
        for (InDetTB det : dets) {
            HashMap<String, String> condition2 = new HashMap<>();
            condition2.put("BillNo", "'" + det.getBillNo() + "'");
            condition2.put("iNo", String.valueOf(det.getINO()));
            erpSqlServer.delete(InDetTB.class, condition2);
        }
    }