From 603ea180dfb83a286b92f384d4fe10270b1848bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Thu, 23 May 2024 09:49:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=BB=88=E6=AD=A2=E6=8E=92?= =?UTF-8?q?=E4=BA=A7,=E5=BD=93bom=E6=97=A0=E6=B3=95=E4=B8=8A=E6=96=99?= =?UTF-8?q?=E6=97=B6=E7=BB=88=E6=AD=A2=E5=B9=B6=E8=BF=9B=E8=A1=8C=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jhgk/三月滚动排产控制器.java | 7 +++++ .../java/com/dsic/gj_erp/pc/DataFactory.java | 15 +++++++++-- .../dsic/gj_erp/pc/dto/套料图工序.java | 11 +++----- src/main/java/com/dsic/gj_erp/pc/排产.java | 27 +++++++------------ .../com/dsic/gj_erp/service/sy/SYService.java | 4 +-- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/dsic/gj_erp/controller/jhgk/三月滚动排产控制器.java b/src/main/java/com/dsic/gj_erp/controller/jhgk/三月滚动排产控制器.java index 7427a2e..58a4e06 100644 --- a/src/main/java/com/dsic/gj_erp/controller/jhgk/三月滚动排产控制器.java +++ b/src/main/java/com/dsic/gj_erp/controller/jhgk/三月滚动排产控制器.java @@ -41,6 +41,13 @@ public class 三月滚动排产控制器 { 排产.execute(from,to); } catch (InterruptedException e) { throw new RuntimeException(e); + } catch (RuntimeException e) { + e.printStackTrace(); + ResultBean resultBean = new ResultBean<>(); + resultBean.setStatus(10000); + resultBean.setSuccess(false); + resultBean.setMessage(e.getMessage()); + return resultBean; } finally { semaphore.release(); } diff --git a/src/main/java/com/dsic/gj_erp/pc/DataFactory.java b/src/main/java/com/dsic/gj_erp/pc/DataFactory.java index f8907f8..721e630 100644 --- a/src/main/java/com/dsic/gj_erp/pc/DataFactory.java +++ b/src/main/java/com/dsic/gj_erp/pc/DataFactory.java @@ -30,6 +30,7 @@ import java.io.OutputStream; import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -48,11 +49,12 @@ public class DataFactory { CountDownLatch latch = new CountDownLatch(钢料需求.getBomList().size()); 钢料需求.getBomList().forEach(bom -> { 套料图工序 _套料图工序 = 套料图工序工厂(bom); + AtomicBoolean atomicBoolean = new AtomicBoolean(false); if (_套料图工序!=null){ _套料图工序.set需求日期(钢料需求.getXzglxq()); es.execute(() -> { try{ - _套料图工序.run(); + _套料图工序.run(atomicBoolean); }finally { latch.countDown(); } @@ -60,6 +62,12 @@ public class DataFactory { }else { latch.countDown(); } + if(atomicBoolean.get()){ + String errText = StrUtil.format("船号:{},批量:{},图号:{},需求日期:{},不满足上料需求", + bom.getDcch(), bom.getPl(), bom.getTzbh(), bom.getXzglxq()); + 清理冗余数据(list); + throw new RuntimeException(errText); + } }); try { latch.await(10, TimeUnit.SECONDS);// 指定超时时间 @@ -68,7 +76,10 @@ public class DataFactory { } }); System.out.println(Manager.排产结果.size()); - //清理冗余数据 + 清理冗余数据(list); + } + + private static void 清理冗余数据(List<钢料需求> list){ list.forEach(钢料需求->{ 钢料需求.getBomList().forEach(bom -> { if (bom.get所在设备()!=null){ diff --git a/src/main/java/com/dsic/gj_erp/pc/dto/套料图工序.java b/src/main/java/com/dsic/gj_erp/pc/dto/套料图工序.java index e191c3a..bcca281 100644 --- a/src/main/java/com/dsic/gj_erp/pc/dto/套料图工序.java +++ b/src/main/java/com/dsic/gj_erp/pc/dto/套料图工序.java @@ -33,8 +33,7 @@ public abstract class 套料图工序 implements 套料图工序接口 { protected Date _需求日期; protected List 工序; - @Override - public void run() { + public void run(AtomicBoolean atomicBoolean) { if (ObjUtil.isEmpty(this.bom)||StrUtil.isEmpty(this.bom.getTzbh())){ return; } @@ -56,11 +55,9 @@ public abstract class 套料图工序 implements 套料图工序接口 { } } - if (bom.get已排工序().size()==0||bom.get已排工序().get(0) != _工序) { - if (_工序 == Constant.工序.上料){ - Manager.排产结果.add(this.bom); - System.out.println(this.bom.toString()); - } + if (bom.get已排工序().size()==0||bom.get已排工序().get(0) != Constant.工序.上料) { + Manager.排产结果.add(this.bom); + atomicBoolean.set(true); } } }); diff --git a/src/main/java/com/dsic/gj_erp/pc/排产.java b/src/main/java/com/dsic/gj_erp/pc/排产.java index aee3189..0387726 100644 --- a/src/main/java/com/dsic/gj_erp/pc/排产.java +++ b/src/main/java/com/dsic/gj_erp/pc/排产.java @@ -17,17 +17,15 @@ public class 排产 { List<排产结果> list; public static void execute(@NotNull String from, @NotNull String to) { - 排产 _排产=null; - try { - _排产 = 排产.of(from,to); - DataFactory.排产2(); - }catch (Exception e){ - e.printStackTrace(); - }finally { - if (_排产!=null){ - _排产.complete = true; - } - } + 排产 _排产 = 排产.of(from, to); + Manager.排产 = _排产; + Manager.from = from; + Manager.to = to; + DataFactory.加载工厂日历(); + DataFactory.加载套料图工序对应关系(); + DataFactory.加载设备信息(); + DataFactory.创建产能资源池(); + DataFactory.排产2(); } private static 排产 of(@NotNull String from, @NotNull String to){ @@ -36,13 +34,6 @@ public class 排产 { 排产.to = to; 排产.complete = false; 排产.list = new ArrayList<>(); - Manager.排产 = 排产; - Manager.from = from; - Manager.to = to; - DataFactory.加载工厂日历(); - DataFactory.加载套料图工序对应关系(); - DataFactory.加载设备信息(); - DataFactory.创建产能资源池(); return Manager.排产; } diff --git a/src/main/java/com/dsic/gj_erp/service/sy/SYService.java b/src/main/java/com/dsic/gj_erp/service/sy/SYService.java index f7c36c3..f886b9f 100644 --- a/src/main/java/com/dsic/gj_erp/service/sy/SYService.java +++ b/src/main/java/com/dsic/gj_erp/service/sy/SYService.java @@ -153,8 +153,8 @@ public class SYService { * @param bmm 编码名称 * @return 最大单据号(流水号) */ - @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class) -// @Transactional +// @Transactional(propagation = Propagation.REQUIRES_NEW,rollbackFor = Exception.class) + @Transactional public String f_getpjh(String zxt,String jg,String bmm){ entityManager.clear(); // 清除缓存 QDmBhdyp bhdy=QDmBhdyp.dmBhdyp;