From 043876f09d97cac3e63d184d1d5418fb6719c117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Tue, 24 Sep 2024 11:37:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E4=B8=80=E4=BA=9B=E5=86=85?= =?UTF-8?q?=E5=AE=B9=202.=E5=A2=9E=E5=8A=A0=E8=AF=AD=E9=9F=B3=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=8F=90=E9=86=92=E4=BF=A1=E6=81=AF=203.=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E6=97=B6=E6=90=BA?= =?UTF-8?q?=E5=B8=A6deviceId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/pgd/PgdTzjhController.java | 64 +++++++++++++++++++ .../controller/yuyin/YuyinController.java | 7 +- .../controller/zyjh/ZyjhController.java | 6 +- .../java/com/dsic/gj_erp/pc/DataFactory.java | 9 +-- .../java/com/dsic/gj_erp/ws/WsHandler.java | 4 ++ .../wsclient/WebSocketClientComponent.java | 39 ----------- .../gj_erp/wsclient/WebSocketService.java | 62 ++++++++++++++++-- .../gj_erp/wsclient/handler/HeartHandler.java | 56 ---------------- .../resources/mappers/jhgk/DmYdjhMapper.xml | 3 +- 9 files changed, 134 insertions(+), 116 deletions(-) delete mode 100644 src/main/java/com/dsic/gj_erp/wsclient/WebSocketClientComponent.java delete mode 100644 src/main/java/com/dsic/gj_erp/wsclient/handler/HeartHandler.java diff --git a/src/main/java/com/dsic/gj_erp/controller/pgd/PgdTzjhController.java b/src/main/java/com/dsic/gj_erp/controller/pgd/PgdTzjhController.java index 5b91f77..e3fcb76 100644 --- a/src/main/java/com/dsic/gj_erp/controller/pgd/PgdTzjhController.java +++ b/src/main/java/com/dsic/gj_erp/controller/pgd/PgdTzjhController.java @@ -172,6 +172,70 @@ public class PgdTzjhController { + returnMap.put("resourcesCodes",resourcesCodes); + returnMap.put("zyqs",zyqs); + returnMap.put("zyrys",zyrys); + returnMap.put("qgkw", qgkws); + returnMap.put("zylx", zylxs); + returnMap.put("pwwz", pwwzs); + returnMap.put("dhql", dhql); + /// zylx 流向 pwwz 抛丸位置 // QGKW 切割跨位 + + return new ResultBean(returnMap); + } + + + @PostMapping("/getPgdBase1") + @ResponseBody + @AuthFunction + public ResultBean getPgdBase1(HttpServletRequest req, @RequestBody Map map) throws Exception, CustomException { + Map returnMap = new HashMap(); + List cbbm = dmCbxxpService.list(new QueryWrapper().orderBy(true, true, "wgbs","cbbm","len(cbbm)")); + // 班组人员 + List gxry = emSbjgryService.list(); + List bmbm = syService.em_sbjbb_ZM("bmbm"); + // 多为 + List dwxxs = dwxxpService.list(); + List qys = dwxxpService.list(new QueryWrapper().select("DISTINCT qy as qy ")); + returnMap.put("qys", qys); + returnMap.put("dwxxs", dwxxs); + returnMap.put("dwxxs1", dwxxs); + + + List ycldws = ycldwService.ycldwList("ycl"); + returnMap.put("cbbm", cbbm); + returnMap.put("gxry", gxry); + returnMap.put("ycldws", ycldws); + returnMap.put("bmbm", bmbm); + + List qgkws1 = dm_zhbmpRepository.findByBMLB("QGKW"); + Listqgkws=new ArrayList<>(); + for (Dm_zhbmp qgkw : qgkws1) { + if(qgkw.getBmsm().equals("1") || qgkw.getBmsm().equals("2")|| qgkw.getBmsm().equals("3")||qgkw.getBmsm().equals("4") ){ + continue; + } + qgkws.add(qgkw); + } + List zylxs = dm_zhbmpRepository.findByBMLB("zylx"); + List pwwzs = dm_zhbmpRepository.findByBMLB("pwwz"); + List dhql = dm_zhbmpRepository.findByBMLB("DHQL"); + + List resourcesCodes = dmBzryService.list(new QueryWrapper().select("DISTINCT zyq as zyq ") + .eq("flag_status", "1").in("zyq","一区").orderBy(true,true,"zyq")); + + + List zyqs = dmBzryService.list(new QueryWrapper().select(" resources_code","zyq") + .eq("flag_status", "1").in("zyq","一区").ne("isnull(resources_code,'')","").groupBy("resources_code","zyq").orderBy(true,true,"resources_code")); + + List zyrys= dmBzryService.list(new QueryWrapper() + .eq("flag_status", "1").ne("isnull(zyq,'')","").in("zyq","一区").orderBy(true,true,"zyq")); + List kwxxs = dm_zhbmpRepository.findByBMLB("PBBM"); + + + + + + returnMap.put("resourcesCodes",resourcesCodes); returnMap.put("zyqs",zyqs); returnMap.put("zyrys",zyrys); diff --git a/src/main/java/com/dsic/gj_erp/controller/yuyin/YuyinController.java b/src/main/java/com/dsic/gj_erp/controller/yuyin/YuyinController.java index bec6334..0db668f 100644 --- a/src/main/java/com/dsic/gj_erp/controller/yuyin/YuyinController.java +++ b/src/main/java/com/dsic/gj_erp/controller/yuyin/YuyinController.java @@ -1,7 +1,6 @@ package com.dsic.gj_erp.controller.yuyin; import com.dsic.gj_erp.bean.ResultBean; -import com.dsic.gj_erp.wsclient.WebSocketClientComponent; import com.dsic.gj_erp.wsclient.WebSocketService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; @@ -16,8 +15,6 @@ public class YuyinController { private final WebSocketService socketService; - private final WebSocketClientComponent clientComponent; - /** * 重连语音上报websocket服务器 */ @@ -25,10 +22,10 @@ public class YuyinController { public ResultBean recon() throws Exception { WebSocketSession session = socketService.getSession(); if (session==null){ - clientComponent.init(); + socketService.init(); }else { socketService.disconnect(); - clientComponent.init(); + socketService.init(); } return new ResultBean<>(); } diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java index c08696e..d523c08 100644 --- a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java @@ -17,7 +17,6 @@ import com.dsic.gj_erp.service.zyjh.YcldwService; import com.dsic.gj_erp.service.zyjh.ZyjhService; import com.dsic.gj_erp.ws.WsHandler; import com.dsic.gj_erp.wsclient.Message; -import com.dsic.gj_erp.wsclient.WebSocketClientComponent; import com.dsic.gj_erp.wsclient.WebSocketService; import lombok.AllArgsConstructor; import org.springframework.transaction.annotation.Transactional; @@ -41,7 +40,6 @@ public class ZyjhController { private final WsHandler wsHandler; private final WebSocketService webSocketService; - private final WebSocketClientComponent webSocketClientComponent; /** * 作业计划执行,派工&反馈 @@ -82,7 +80,7 @@ public class ZyjhController { zyjhService.updateBatchById(list); if (dto.getAudioFlag()){ - Message result = Message.result(webSocketClientComponent.getErpId(), "1"); + Message result = Message.result(webSocketService.getErpId(), "1"); webSocketService.sendMessage(result.toString()); } @@ -90,7 +88,7 @@ public class ZyjhController { } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); if (dto.getAudioFlag()){ - Message result = Message.result(webSocketClientComponent.getErpId(), "0"); + Message result = Message.result(webSocketService.getErpId(), "0"); try { webSocketService.sendMessage(result.toString()); } catch (Exception ex) { 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 17f25bb..af52692 100644 --- a/src/main/java/com/dsic/gj_erp/pc/DataFactory.java +++ b/src/main/java/com/dsic/gj_erp/pc/DataFactory.java @@ -8,19 +8,17 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.dsic.gj_erp.bean.SpringContextHolder; -import com.dsic.gj_erp.bean.jcsj.DmBom; import com.dsic.gj_erp.bean.jcsj.EmGcrl; import com.dsic.gj_erp.bean.jcsj.EmSbcnp; import com.dsic.gj_erp.bean.jcsj.EmSbjbb; import com.dsic.gj_erp.bean.jhgk.DmSygdxq; import com.dsic.gj_erp.bean.jhgk.DmZrcjh; +import com.dsic.gj_erp.exception.ServiceException; import com.dsic.gj_erp.pc.dto.data.Bom; -import com.dsic.gj_erp.pc.dto.data.按批次合并的钢料需求; import com.dsic.gj_erp.pc.dto.data.钢料需求; import com.dsic.gj_erp.pc.dto.gx.*; import com.dsic.gj_erp.pc.dto.sb.*; import com.dsic.gj_erp.pc.dto.tlt.*; -import com.dsic.gj_erp.pc.dto.排产结果; import com.dsic.gj_erp.pc.dto.*; import com.dsic.gj_erp.pc.service.工序CD接口; import com.dsic.gj_erp.pc.service.订货计划滚动信息接口; @@ -33,7 +31,6 @@ import com.dsic.gj_erp.service.jhgk.DmZrcjhService; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.AtomicDouble; import lombok.extern.slf4j.Slf4j; -import lombok.val; import java.io.FileOutputStream; import java.io.OutputStream; @@ -43,7 +40,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; -import static com.dsic.gj_erp.pc.Manager.排产; import static com.dsic.gj_erp.pc.Manager.*; @Slf4j @@ -81,8 +77,7 @@ public class DataFactory { try { 均衡预占(按批次合并); }catch (Exception e){ -// e.printStackTrace(); - throw e; + throw new ServiceException(10001,"排产结果异常"); }finally { 清理冗余数据(list); } diff --git a/src/main/java/com/dsic/gj_erp/ws/WsHandler.java b/src/main/java/com/dsic/gj_erp/ws/WsHandler.java index 1b5f5af..6590fd3 100644 --- a/src/main/java/com/dsic/gj_erp/ws/WsHandler.java +++ b/src/main/java/com/dsic/gj_erp/ws/WsHandler.java @@ -46,6 +46,10 @@ public class WsHandler { socketIOServer.getBroadcastOperations().sendEvent("zyjhzx", object); } + public void complete(JSONObject object){ + socketIOServer.getBroadcastOperations().sendEvent("complete", object); + } + public void sendSlComplete(JSONObject object) { socketIOServer.getBroadcastOperations().sendEvent("slComplete", object); } diff --git a/src/main/java/com/dsic/gj_erp/wsclient/WebSocketClientComponent.java b/src/main/java/com/dsic/gj_erp/wsclient/WebSocketClientComponent.java deleted file mode 100644 index 9fdbc40..0000000 --- a/src/main/java/com/dsic/gj_erp/wsclient/WebSocketClientComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.dsic.gj_erp.wsclient; - - -import com.dsic.gj_erp.wsclient.handler.HeartHandler; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; - -@Component -@RequiredArgsConstructor -public class WebSocketClientComponent { - - @Value("${ws.client.url}") - private String url; - - @Getter - @Value("${ws.client.id}") - private String erpId; - - private final WebSocketService webSocketService; - private final HeartHandler heartHandler; - - @PostConstruct - public void init() { - // 发送消息示例 - try { - webSocketService.connect(this.url); - webSocketService.sendMessage(Message.reg(this.erpId).toString()); - heartHandler.execute(Message.heart(erpId)); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/src/main/java/com/dsic/gj_erp/wsclient/WebSocketService.java b/src/main/java/com/dsic/gj_erp/wsclient/WebSocketService.java index fac7ab6..a9b0b4b 100644 --- a/src/main/java/com/dsic/gj_erp/wsclient/WebSocketService.java +++ b/src/main/java/com/dsic/gj_erp/wsclient/WebSocketService.java @@ -1,22 +1,31 @@ package com.dsic.gj_erp.wsclient; +import cn.hutool.cron.CronUtil; +import cn.hutool.cron.task.Task; import com.alibaba.fastjson.JSONObject; import com.dsic.gj_erp.wsclient.handler.TipHandler; import com.dsic.gj_erp.wsclient.handler.ZxHandler; +import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.WebSocketConnectionManager; import org.springframework.web.socket.handler.TextWebSocketHandler; +import javax.annotation.PostConstruct; +import java.io.IOException; + @Slf4j @Service @RequiredArgsConstructor public class WebSocketService extends TextWebSocketHandler { + @Getter private WebSocketSession session; private final WebSocketClient client; @@ -24,6 +33,19 @@ public class WebSocketService extends TextWebSocketHandler { private final ZxHandler zxHandler; private final TipHandler tipHandler; + @Getter + @Value("${ws.client.url}") + private String url; + + @Getter + @Value("${ws.client.id}") + private String erpId; + + @PostConstruct + public void init() { + System.out.println("========开始连接语音WS服务器========"); + this.connect(this.url); + } public void connect(String uri) { WebSocketConnectionManager manager = new WebSocketConnectionManager(client, this, uri); @@ -47,6 +69,40 @@ public class WebSocketService extends TextWebSocketHandler { @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { this.session = session; // 处理连接后保存session + this.sendMessage(Message.reg(this.erpId).toString()); + this.heart(Message.heart(this.erpId)); + } + + @Override + public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws IOException { + if (this.session!=null){ + this.session.close(); + this.session=null; + } + } + + private boolean scheduleStartFlag=false; + + public void heart(Message message) { + synchronized (this){ + if (this.scheduleStartFlag){ + return; + } + this.scheduleStartFlag=true; + } + CronUtil.schedule("*/20 * * * * *", (Task) () -> { + try { + System.out.println("心跳"); + this.sendMessage(message.toString()); + } catch (Exception e) { + this.connect(this.url); + } + }); + + // 支持秒级别定时任务 + CronUtil.setMatchSecond(true); + CronUtil.start(); + } @Override @@ -60,14 +116,12 @@ public class WebSocketService extends TextWebSocketHandler { case TIP: tipHandler.execute(msg); break; + case ERROR: + tipHandler.execute(msg); case ZX: zxHandler.execute(msg); break; } } - public WebSocketSession getSession(){ - return this.session; - } - } diff --git a/src/main/java/com/dsic/gj_erp/wsclient/handler/HeartHandler.java b/src/main/java/com/dsic/gj_erp/wsclient/handler/HeartHandler.java deleted file mode 100644 index d71cdb0..0000000 --- a/src/main/java/com/dsic/gj_erp/wsclient/handler/HeartHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.dsic.gj_erp.wsclient.handler; - -import cn.hutool.cron.CronUtil; -import cn.hutool.cron.task.Task; -import com.alibaba.fastjson.JSONObject; -import com.dsic.gj_erp.wsclient.Message; -import com.dsic.gj_erp.wsclient.WebSocketService; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class HeartHandler implements IHandlerService{ - - private final WebSocketService webSocketService; - - private boolean scheduleStartFlag=false; - - @Value("${ws.client.url}") - private String url; - - @Getter - @Value("${ws.client.id}") - private String erpId; - - @Override - public boolean execute(Message message) { - if (this.scheduleStartFlag){ - return true; - } - CronUtil.schedule("*/10 * * * * *", (Task) () -> { - try { - System.out.println("心跳"); - webSocketService.sendMessage(message.toString()); - } catch (Exception e) { - if (webSocketService.getSession()==null){ - webSocketService.connect(this.url); - try { - webSocketService.sendMessage(Message.reg(this.erpId).toString()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - e.printStackTrace(); - } - }); - - // 支持秒级别定时任务 - CronUtil.setMatchSecond(true); - CronUtil.start(); - this.scheduleStartFlag=true; - return true; - } -} diff --git a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml index 40f4d66..fb7f656 100644 --- a/src/main/resources/mappers/jhgk/DmYdjhMapper.xml +++ b/src/main/resources/mappers/jhgk/DmYdjhMapper.xml @@ -796,13 +796,14 @@ then 'Y' else '' end, '01', - '01','01',dm_ydjh.dmrq,dm_ydjh.pkrqm,dm_ydjh.qjgrq,'01' + '01','01',dm_ydjh.dmrq dmjhrq,dm_ydjh.pkrq pkjhrq,dm_ydjh.qjgrq qjgjhrq,'01' from dm_ydjh,dm_bom LEFT JOIN dm_qfxq on dm_qfxq.DC_CH=dm_bom.dcch and dm_qfxq.DC_PL=dm_bom.pl and dm_qfxq.DC_FD=dm_bom.fd WHERE dm_ydjh.dc_ch= dm_bom.dcch and dm_ydjh.dc_pl=dm_bom.pl and dm_ydjh.tzbh=dm_bom.tzbh + and dm_ydjh.dc_fd=dm_bom.fd and dm_ydjh.id in #{item}