From 48db618606f0f0cafd1ce795f8bf26a0bcec2581 Mon Sep 17 00:00:00 2001 From: zhangchao <zc857179121@qq.com> Date: 星期六, 20 七月 2024 07:56:54 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/xgmFlasrs' into xgmFlasrs --- src/main/java/com/zy/third/erp/task/ERPInHedTBScheduler.java | 80 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/third/erp/task/ERPInHedTBScheduler.java b/src/main/java/com/zy/third/erp/task/ERPInHedTBScheduler.java new file mode 100644 index 0000000..34dc211 --- /dev/null +++ b/src/main/java/com/zy/third/erp/task/ERPInHedTBScheduler.java @@ -0,0 +1,80 @@ +package com.zy.third.erp.task; + +import com.zy.common.service.erp.ErpSqlServer; +import com.zy.third.erp.entity.InDetTB; +import com.zy.third.erp.entity.InHedTB; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * 鍏ュ簱鍗曟嵁 + */ +@Slf4j +@Component +public class ERPInHedTBScheduler { + + @Value("${erp.enabled}") + private Boolean erpEnabled; + + + @Autowired + private ERPInOrOutService inMS; + + + @Autowired + private ErpSqlServer erpSqlServer; + + + @Transactional(rollbackFor = Throwable.class) + @Scheduled(cron = "${erp.refreshtime}") + public void 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.isEmpty()) { + for (InHedTB inHed : inHeds) { + System.out.println(inHed); + 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.createInOrder(inHed, inDetTBS); + if (result) { + move(hedAndDet); + } else { + String sql = "UPDATE erp_InHedTB SET Temp3 = 鈥榝ault鈥� WHERE BillNo = '" + inHed.getBillNo() + "'"; + erpSqlServer.update(sql); + } + } + } + } + + + @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); + } + + } +} -- Gitblit v1.9.1