From 243aeb989f371a502108da2490be99d9b64873f8 Mon Sep 17 00:00:00 2001 From: lulicheng Date: Fri, 2 Aug 2024 17:25:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 + .../com/ipsplm/config/WebSocketConfig.java | 19 +++ .../SimulationAnalysisController.java | 9 ++ .../simulation/SimulationAnalysisMapper.java | 13 +- .../entity/simulation/BufferNumBxg.java | 29 +++++ .../ipsplm/entity/simulation/BufferNumDj.java | 34 +++++ .../ipsplm/entity/simulation/BufferNumXe.java | 41 +++++++ .../ipsplm/entity/simulation/BufferNumXy.java | 29 +++++ .../ipsplm/entity/simulation/BufferNumZe.java | 116 ++++++++++++------ .../ipsplm/entity/simulation/BufferNumZy.java | 45 +++++++ .../entity/simulation/dto/BufferNumDTO.java | 13 ++ .../entity/simulation/vo/BufferNumVO.java | 12 +- .../entity/simulation/vo/FieldCnVO.java | 12 ++ .../simulation/ISimulationService.java | 12 ++ .../impl/SimulationAnalysisServiceImpl.java | 85 ++++++++++--- .../impl/SimulationServiceImpl.java | 84 +++++++++++++ .../com/ipsplm/ws/SimulationWebsocket.java | 104 ++++++++++++++++ src/main/resources/application.yml | 4 +- .../simulation/SimulationAnalysisMapper.xml | 26 ++-- 19 files changed, 619 insertions(+), 73 deletions(-) create mode 100644 src/main/java/com/ipsplm/config/WebSocketConfig.java create mode 100644 src/main/java/com/ipsplm/entity/simulation/dto/BufferNumDTO.java create mode 100644 src/main/java/com/ipsplm/entity/simulation/vo/FieldCnVO.java create mode 100644 src/main/java/com/ipsplm/service/simulation/ISimulationService.java create mode 100644 src/main/java/com/ipsplm/service/simulation/impl/SimulationServiceImpl.java create mode 100644 src/main/java/com/ipsplm/ws/SimulationWebsocket.java diff --git a/pom.xml b/pom.xml index 64c2140..ea401ce 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,11 @@ 5.7.22 + + org.springframework.boot + spring-boot-starter-websocket + + org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/com/ipsplm/config/WebSocketConfig.java b/src/main/java/com/ipsplm/config/WebSocketConfig.java new file mode 100644 index 0000000..5652641 --- /dev/null +++ b/src/main/java/com/ipsplm/config/WebSocketConfig.java @@ -0,0 +1,19 @@ +package com.ipsplm.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +@Configuration +@EnableWebSocket +public class WebSocketConfig { + /** + * 注入ServerEndpointExporter, + * 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint + */ + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } +} diff --git a/src/main/java/com/ipsplm/controller/simulation/SimulationAnalysisController.java b/src/main/java/com/ipsplm/controller/simulation/SimulationAnalysisController.java index 2945181..878fc57 100644 --- a/src/main/java/com/ipsplm/controller/simulation/SimulationAnalysisController.java +++ b/src/main/java/com/ipsplm/controller/simulation/SimulationAnalysisController.java @@ -3,6 +3,7 @@ package com.ipsplm.controller.simulation; import com.ipsplm.entity.dto.ResponseDTO; import com.ipsplm.service.simulation.ISimulationAnalysisService; +import com.ipsplm.service.simulation.ISimulationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -20,6 +21,9 @@ public class SimulationAnalysisController { @Autowired private ISimulationAnalysisService simulationAnalysisService; + @Autowired + private ISimulationService simulationService; + /** * 获取工厂设备利用率信息 * @param flag @@ -59,4 +63,9 @@ public class SimulationAnalysisController { public ResponseDTO getBufferNum(@RequestParam String process){ return ResponseDTO.ok(simulationAnalysisService.getBufferNum(process)); } + + @GetMapping("/test-socket") + public ResponseDTO testSocket(@RequestParam String param){ + return ResponseDTO.ok(simulationService.getPlantData(param)); + } } diff --git a/src/main/java/com/ipsplm/dao/simulation/SimulationAnalysisMapper.java b/src/main/java/com/ipsplm/dao/simulation/SimulationAnalysisMapper.java index 12b7ee6..c0688c6 100644 --- a/src/main/java/com/ipsplm/dao/simulation/SimulationAnalysisMapper.java +++ b/src/main/java/com/ipsplm/dao/simulation/SimulationAnalysisMapper.java @@ -3,6 +3,7 @@ package com.ipsplm.dao.simulation; import com.ipsplm.entity.simulation.*; import com.ipsplm.entity.simulation.vo.BufferVO; import com.ipsplm.entity.simulation.vo.PlantEquipmentUtilizationVO; +import com.ipsplm.entity.simulation.vo.FieldCnVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -85,33 +86,35 @@ public interface SimulationAnalysisMapper { * @param bufferNameList * @return */ - List getBufferNumDj(List bufferNameList); + List getBufferNumDj(@Param("bufferNameList") List bufferNameList); /** * 获取小二线缓存数量 * @param bufferNameList * @return */ - List getBufferNumXe(List bufferNameList); + List getBufferNumXe(@Param("bufferNameList") List bufferNameList); /** * 获取小一线缓存数量 * @param bufferNameList * @return */ - List getBufferNumXy(List bufferNameList); + List getBufferNumXy(@Param("bufferNameList") List bufferNameList); /** * 获取中二线缓存数量 * @param bufferNameList * @return */ - List getBufferNumZe(List bufferNameList); + List getBufferNumZe(@Param("bufferNameList") List bufferNameList); /** * 获取中一线缓存数量 * @param bufferNameList * @return */ - List getBufferNumZy(List bufferNameList); + List getBufferNumZy(@Param("bufferNameList") List bufferNameList); + + List getFieldInfo(@Param("tableId") Integer tableId,@Param("groupId") Integer groupId); } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumBxg.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumBxg.java index 2f374f9..5a5dc6e 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumBxg.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumBxg.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 不锈钢线缓存数量表 @@ -25,137 +27,164 @@ public class BufferNumBxg implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 不锈钢线流水线缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgBufferL; /** * 不锈钢弯管机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgWgjQ; /** * 不锈钢弯管机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgWgjH; /** * 不锈钢支管切断前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZgqdQ; /** * 不锈钢支管切断后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZgqdH; /** * 不锈钢小组立前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgXzlQ; /** * 不锈钢小组立后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgXzlH; /** * 不锈钢弯头焊接机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgWthjjQ; /** * 不锈钢弯头焊接机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgWthhjH; /** * 不锈钢装配平台1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZppt1Q; /** * 不锈钢装配平台1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZppt1H; /** * 不锈钢装配平台2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZppt2Q; /** * 不锈钢装配平台2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgZppt2H; /** * 不锈钢焊接工位1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw1Q; /** * 不锈钢焊接工位1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw1H; /** * 不锈钢焊接工位2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw2Q; /** * 不锈钢焊接工位2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw2H; /** * 不锈钢焊接工位3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw3Q; /** * 不锈钢焊接工位3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgHjgw3H; /** * 不锈钢一次完检前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgYcwjQ; /** * 不锈钢一次完检后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgYcwjH; /** * 不锈钢水试前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String bxgSsQ; /** * 探伤前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String tsQ; /** * 探伤后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String tsH; } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumDj.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumDj.java index a5a5c86..d9448ae 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumDj.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumDj.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 大径线缓存数量表 @@ -25,162 +27,194 @@ public class BufferNumDj implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 大径线流水线缓存区1 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djBuffer1L; /** * 大径线流水线缓存区2 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djBuffer2L; /** * 大径支管切断前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZgqdQ; /** * 大径支管切断后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZgqdH; /** * 大径小组立前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djXzlQ; /** * 大径小组立后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djXzlH; /** * 大径弯头焊接机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djWthjjQ; /** * 大径弯头焊接机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djWthhjH; /** * 大径装配平台1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt1Q; /** * 大径装配平台1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt1H; /** * 大径装配平台2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt2Q; /** * 大径装配平台2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt2H; /** * 大径装配平台3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt3Q; /** * 大径装配平台3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt3H; /** * 大径装配平台4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt4Q; /** * 大径装配平台4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djZppt4H; /** * 大径焊接工位1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw1Q; /** * 大径焊接工位1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw1H; /** * 大径焊接工位2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw2Q; /** * 大径焊接工位2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw2H; /** * 大径焊接工位3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw3Q; /** * 大径焊接工位3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw3H; /** * 大径焊接工位4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw4Q; /** * 大径焊接工位4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw4H; /** * 大径焊接工位5前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw5Q; /** * 大径焊接工位5后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djHjgw5H; /** * 大径一次完检前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djYcwjQ; /** * 大径一次完检后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djYcwjH; /** * 大径水试前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String djSsQ; } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumXe.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumXe.java index 45560a8..eca5b14 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumXe.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumXe.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 小二线缓存数量表 @@ -25,197 +27,236 @@ public class BufferNumXe implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 小二线流水线缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeBufferL; /** * 小二弯管机1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWgj1Q; /** * 小二弯管机1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWgj1H; /** * 小二弯管机2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWgj2Q; /** * 小二弯管机2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWgj2H; /** * 小二支管切断前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZgqdQ; /** * 小二支管切断后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZgqdH; /** * 小二小组立前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeXzlQ; /** * 小二小组立后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeXzlH; /** * 小二弯头焊接机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWthjjQ; /** * 小二弯头焊接机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeWthhjH; /** * 小二装配平台1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt1Q; /** * 小二装配平台1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt1H; /** * 小二装配平台2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt2Q; /** * 小二装配平台2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt2H; /** * 小二装配平台3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt3Q; /** * 小二装配平台3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt3H; /** * 小二装配平台4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt4Q; /** * 小二装配平台4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt4H; /** * 小二装配平台5前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt5Q; /** * 小二装配平台5后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeZppt5H; /** * 小二焊接工位1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw1Q; /** * 小二焊接工位1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw1H; /** * 小二焊接工位2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw2Q; /** * 小二焊接工位2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw2H; /** * 小二焊接工位3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw3Q; /** * 小二焊接工位3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw3H; /** * 小二焊接工位4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw4Q; /** * 小二焊接工位4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw4H; /** * 小二焊接工位5前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw5Q; /** * 小二焊接工位5后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeHjgw5H; /** * 小二一次完检前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeYcwjQ; /** * 小二一次完检后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeYcwjH; /** * 小二水试前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xeSsQ; /** * 机加工前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String jjgQ; /** * 机加工后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String jjgH; } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumXy.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumXy.java index 6f4f935..c5a5885 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumXy.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumXy.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 小一线缓存数量表 @@ -25,137 +27,164 @@ public class BufferNumXy implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 小一线流水线缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyBufferL; /** * 小一弯管机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyWgjQ; /** * 小一弯管机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyWgjH; /** * 小一支管切断前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZgqdQ; /** * 小一支管切断后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZgqdH; /** * 小一装配平台1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt1Q; /** * 小一装配平台1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt1H; /** * 小一装配平台2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt2Q; /** * 小一装配平台2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt2H; /** * 小一装配平台3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt3Q; /** * 小一装配平台3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt3H; /** * 小一装配平台4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt4Q; /** * 小一装配平台4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyZppt4H; /** * 小一焊接工位1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw1Q; /** * 小一焊接工位1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw1H; /** * 小一焊接工位2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw2Q; /** * 小一焊接工位2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw2H; /** * 小一焊接工位3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw3Q; /** * 小一焊接工位3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw3H; /** * 小一焊接工位4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw4Q; /** * 小一焊接工位4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyHjgw4H; /** * 小一一次完检前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyYcwjQ; /** * 小一一次完检后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xyYcwjH; /** * 小一水试前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String xySsQ; } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumZe.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumZe.java index f96368d..25bb8c1 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumZe.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumZe.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 中二线缓存数量表 @@ -25,202 +27,242 @@ public class BufferNumZe implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 中二线流水线缓存区1 */ - private String zeBuffer1L; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeBuffer1L; /** * 中二线流水线缓存区2 */ - private String zeBuffer2L; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeBuffer2L; /** * 中二弯管机前序缓存区 */ - private String zeWgjQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeWgjQ; /** * 中二弯管机后序缓存区 */ - private String zeWgjH; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeWgjH; /** * 中二支管切断前序缓存区 */ - private String zeZgqdQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZgqdQ; /** * 中二支管切断后序缓存区 */ - private String zeZgqdH; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZgqdH; /** * 中二小组立1前序缓存区 */ - private String zeXzl1Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeXzl1Q; /** * 中二小组立1后序缓存区 */ - private String zeXzl1H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeXzl1H; /** * 中二小组立2前序缓存区 */ - private String zeXzl2Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeXzl2Q; /** * 中二小组立2后序缓存区 */ - private String zeXzl2H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeXzl2H; /** * 中二弯头焊接机前序缓存区 */ - private String zeWthjjQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeWthjjQ; /** * 中二弯头焊接机后序缓存区 */ - private String zeWthhjH; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeWthhjH; /** * 中二装配平台1前序缓存区 */ - private String zeZppt1Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt1Q; /** * 中二装配平台1后序缓存区 */ - private String zeZppt1H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt1H; /** * 中二装配平台2前序缓存区 */ - private String zeZppt2Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt2Q; /** * 中二装配平台2后序缓存区 */ - private String zeZppt2H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt2H; /** * 中二装配平台3前序缓存区 */ - private String zeZppt3Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt3Q; /** * 中二装配平台3后序缓存区 */ - private String zeZppt3H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeZppt3H; /** * 中二焊接工位1前序缓存区 */ - private String zeHjgw1Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw1Q; /** * 中二焊接工位1后序缓存区 */ - private String zeHjgw1H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw1H; /** * 中二焊接工位2前序缓存区 */ - private String zeHjgw2Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw2Q; /** * 中二焊接工位2后序缓存区 */ - private String zeHjgw2H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw2H; /** * 中二焊接工位3前序缓存区 */ - private String zeHjgw3Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw3Q; /** * 中二焊接工位3后序缓存区 */ - private String zeHjgw3H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw3H; /** * 中二焊接工位4前序缓存区 */ - private String zeHjgw4Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw4Q; /** * 中二焊接工位4后序缓存区 */ - private String zeHjgw4H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw4H; /** * 中二焊接工位5前序缓存区 */ - private String zeHjgw5Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw5Q; /** * 中二焊接工位5后序缓存区 */ - private String zeHjgw5H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw5H; /** * 中二焊接工位6前序缓存区 */ - private String zeHjgw6Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw6Q; /** * 中二焊接工位6后序缓存区 */ - private String zeHjgw6H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw6H; /** * 中二焊接工位7前序缓存区 */ - private String zeHjgw7Q; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw7Q; /** * 中二焊接工位7后序缓存区 */ - private String zeHjgw7H; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeHjgw7H; /** * 中二一次完检前序缓存区 */ - private String zeYcwjQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeYcwjQ; /** * 中二一次完检后序缓存区 */ - private String zeYcwjH; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeYcwjH; /** * 中二水试前序缓存区 */ - private String zeSsQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String zeSsQ; /** * 探伤前序缓存区 */ - private String tsQ; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String tsQ; /** * 探伤后序缓存区 */ - private String tsH; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String tsH; } diff --git a/src/main/java/com/ipsplm/entity/simulation/BufferNumZy.java b/src/main/java/com/ipsplm/entity/simulation/BufferNumZy.java index c717c7d..9d39fce 100644 --- a/src/main/java/com/ipsplm/entity/simulation/BufferNumZy.java +++ b/src/main/java/com/ipsplm/entity/simulation/BufferNumZy.java @@ -3,10 +3,12 @@ package com.ipsplm.entity.simulation; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; + /** *

* 中一线缓存数量表 @@ -25,42 +27,50 @@ public class BufferNumZy implements Serializable { /** * 主键 */ + @JsonInclude(JsonInclude.Include.NON_NULL) @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 标志位 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private Long flag; /** * 记录时间 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String recordTime; /** * 中一线流水线缓存区1 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyBuffer1L; /** * 中一线流水线缓存区2 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyBuffer2L; /** * 中一弯管机1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyWgj1Q; /** * 中一弯管机1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyWgj1H; /** * 中一弯管机2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyWgj2Q; /** @@ -71,176 +81,211 @@ public class BufferNumZy implements Serializable { /** * 中一支管切断前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZgqdQ; /** * 中一支管切断后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZgqdH; /** * 中一小组立前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyXzlQ; /** * 中一小组立后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyXzlH; /** * 中一弯头焊接机前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyWthjjQ; /** * 中一弯头焊接机后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyWthhjH; /** * 中一装配平台1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt1Q; /** * 中一装配平台1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt1H; /** * 中一装配平台2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt2Q; /** * 中一装配平台2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt2H; /** * 中一装配平台3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt3Q; /** * 中一装配平台3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt3H; /** * 中一装配平台4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt4Q; /** * 中一装配平台4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt4H; /** * 中一装配平台5前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt5Q; /** * 中一装配平台5后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyZppt5H; /** * 中一焊接工位1前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw1Q; /** * 中一焊接工位1后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw1H; /** * 中一焊接工位2前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw2Q; /** * 中一焊接工位2后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw2H; /** * 中一焊接工位3前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw3Q; /** * 中一焊接工位3后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw3H; /** * 中一焊接工位4前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw4Q; /** * 中一焊接工位4后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw4H; /** * 中一焊接工位5前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw5Q; /** * 中一焊接工位5后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw5H; /** * 中一焊接工位6前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw6Q; /** * 中一焊接工位6后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw6H; /** * 中一焊接工位7前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw7Q; /** * 中一焊接工位7后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyHjgw7H; /** * 中一一次完检前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyYcwjQ; /** * 中一一次完检后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zyYcwjH; /** * 中一水试前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String zySsQ; /** * 探伤前序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String tsQ; /** * 探伤后序缓存区 */ + @JsonInclude(JsonInclude.Include.NON_NULL) private String tsH; } diff --git a/src/main/java/com/ipsplm/entity/simulation/dto/BufferNumDTO.java b/src/main/java/com/ipsplm/entity/simulation/dto/BufferNumDTO.java new file mode 100644 index 0000000..878dc04 --- /dev/null +++ b/src/main/java/com/ipsplm/entity/simulation/dto/BufferNumDTO.java @@ -0,0 +1,13 @@ +package com.ipsplm.entity.simulation.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class BufferNumDTO implements Serializable { + //y轴(Buffer数量) + private String bufferNum; + //缓冲描述 + private String bufferName; +} diff --git a/src/main/java/com/ipsplm/entity/simulation/vo/BufferNumVO.java b/src/main/java/com/ipsplm/entity/simulation/vo/BufferNumVO.java index 66227ec..6573e67 100644 --- a/src/main/java/com/ipsplm/entity/simulation/vo/BufferNumVO.java +++ b/src/main/java/com/ipsplm/entity/simulation/vo/BufferNumVO.java @@ -1,14 +1,14 @@ package com.ipsplm.entity.simulation.vo; +import com.ipsplm.entity.simulation.dto.BufferNumDTO; import lombok.Data; import java.io.Serializable; +import java.util.List; + @Data public class BufferNumVO implements Serializable { - //x轴(时间) - private String xTime; - //y轴(Buffer数量) - private String bufferNum; - //缓冲描述 - private String bufferName; + private String recordTime; + + private List bufferNumVOList; } diff --git a/src/main/java/com/ipsplm/entity/simulation/vo/FieldCnVO.java b/src/main/java/com/ipsplm/entity/simulation/vo/FieldCnVO.java new file mode 100644 index 0000000..8b07da1 --- /dev/null +++ b/src/main/java/com/ipsplm/entity/simulation/vo/FieldCnVO.java @@ -0,0 +1,12 @@ +package com.ipsplm.entity.simulation.vo; + +import lombok.Data; + +import java.io.Serializable; +@Data +public class FieldCnVO implements Serializable { + + private String fieldCode; + + private String fieldName; +} diff --git a/src/main/java/com/ipsplm/service/simulation/ISimulationService.java b/src/main/java/com/ipsplm/service/simulation/ISimulationService.java new file mode 100644 index 0000000..0b70a54 --- /dev/null +++ b/src/main/java/com/ipsplm/service/simulation/ISimulationService.java @@ -0,0 +1,12 @@ +package com.ipsplm.service.simulation; + +/** + * @Description 仿真Service + * @Author FanDongqiang + * @Date 2023/3/15 16:23 + * @Version 1.0 + */ +public interface ISimulationService { + + String getPlantData(Object param); +} diff --git a/src/main/java/com/ipsplm/service/simulation/impl/SimulationAnalysisServiceImpl.java b/src/main/java/com/ipsplm/service/simulation/impl/SimulationAnalysisServiceImpl.java index e69a749..4cf59ec 100644 --- a/src/main/java/com/ipsplm/service/simulation/impl/SimulationAnalysisServiceImpl.java +++ b/src/main/java/com/ipsplm/service/simulation/impl/SimulationAnalysisServiceImpl.java @@ -4,9 +4,8 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ipsplm.dao.simulation.SimulationAnalysisMapper; import com.ipsplm.entity.simulation.*; -import com.ipsplm.entity.simulation.vo.BufferVO; -import com.ipsplm.entity.simulation.vo.OeeVO; -import com.ipsplm.entity.simulation.vo.PlantEquipmentUtilizationVO; +import com.ipsplm.entity.simulation.dto.BufferNumDTO; +import com.ipsplm.entity.simulation.vo.*; import com.ipsplm.service.simulation.ISimulationAnalysisService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,7 +35,8 @@ public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService public List getPlantEquipmentUtilization(Long flag) { List plantEquipmentUtilization = simulationAnalysisMapper.getPlantEquipmentUtilization(flag); List oeeVOList = beanToKeyValue(plantEquipmentUtilization); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(null,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } /** @@ -63,27 +63,33 @@ public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService switch (tableCode) { case "buffernum_bxg": { List bufferNumBxgList = simulationAnalysisMapper.getBufferNumBxg(bufferNameList); - return bufferNumBxgList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(1,2); + return beanToKeyValue(bufferNumBxgList,fieldCnVOList); } case "buffernum_dj": { List bufferNumDjList = simulationAnalysisMapper.getBufferNumDj(bufferNameList); - return bufferNumDjList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(2,2); + return beanToKeyValue(bufferNumDjList,fieldCnVOList); } case "buffernum_xe": { List bufferNumXeList = simulationAnalysisMapper.getBufferNumXe(bufferNameList); - return bufferNumXeList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(3,2); + return beanToKeyValue(bufferNumXeList,fieldCnVOList); } case "buffernum_xy": { List bufferNumXyList = simulationAnalysisMapper.getBufferNumXy(bufferNameList); - return bufferNumXyList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(6,2); + return beanToKeyValue(bufferNumXyList,fieldCnVOList); } case "buffernum_ze": { List bufferNumZeList = simulationAnalysisMapper.getBufferNumZe(bufferNameList); - return bufferNumZeList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(5,2); + return beanToKeyValue(bufferNumZeList,fieldCnVOList); } case "buffernum_zy": { List bufferNumZyList = simulationAnalysisMapper.getBufferNumZy(bufferNameList); - return bufferNumZyList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(4,2); + return beanToKeyValue(bufferNumZyList,fieldCnVOList); } default: break; @@ -103,32 +109,38 @@ public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService case "oee_bxg": { List oeeBxgList = simulationAnalysisMapper.getOeeBxg(); List oeeVOList = beanToKeyValue(oeeBxgList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(7,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } case "oee_dj": { List oeeDjList = simulationAnalysisMapper.getOeeDj(); List oeeVOList = beanToKeyValue(oeeDjList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(12,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } case "oee_xe": { List oeeXeList = simulationAnalysisMapper.getOeeXe(); List oeeVOList = beanToKeyValue(oeeXeList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(9,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } case "oee_xy": { List oeeXyList = simulationAnalysisMapper.getOeeXy(); List oeeVOList = beanToKeyValue(oeeXyList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(8,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } case "oee_ze": { List oeeZeList = simulationAnalysisMapper.getOeeZe(); List oeeVOList = beanToKeyValue(oeeZeList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(11,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } case "oee_zy": { List oeeZyList = simulationAnalysisMapper.getOeeZy(); List oeeVOList = beanToKeyValue(oeeZyList); - return oeeVOList; + List fieldCnVOList = simulationAnalysisMapper.getFieldInfo(10,1); + return fieldNameToChinese(fieldCnVOList,oeeVOList); } default: break; @@ -161,4 +173,45 @@ public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService } return oeeVOList; } + public List fieldNameToChinese(List fieldCnVOList,List oeeVOList) { + for (OeeVO oeeVO : oeeVOList) { + for (FieldCnVO fieldCnVO : fieldCnVOList) { + if (oeeVO.getName().equals(fieldCnVO.getFieldCode())) { + oeeVO.setName(fieldCnVO.getFieldName()); + break; + } + } + } + return oeeVOList; + } + + public List beanToKeyValue(List bufferNumList,List fieldCnVOList) { + List bufferNumVOList = new ArrayList<>(); + for (Object buffernum : bufferNumList) { + JSONObject jsonObject = (JSONObject) JSON.toJSON(buffernum); + String recordTime = jsonObject.getString("recordTime"); + List bufferNumDTOList = new ArrayList<>(); + for (Map.Entry entry : jsonObject.entrySet()) { + BufferNumDTO bufferNumDTO = new BufferNumDTO(); + Object value = entry.getValue(); + String key = entry.getKey(); + if(value == null || "recordTime".equals(key)){ + continue; + } + for (FieldCnVO fieldCnVO : fieldCnVOList) { + if(key.equals(fieldCnVO.getFieldCode())){ + bufferNumDTO.setBufferName(fieldCnVO.getFieldName()); + break; + } + } + bufferNumDTO.setBufferNum((String) value); + bufferNumDTOList.add(bufferNumDTO); + } + BufferNumVO bufferNumVO = new BufferNumVO(); + bufferNumVO.setRecordTime(recordTime); + bufferNumVO.setBufferNumVOList(bufferNumDTOList); + bufferNumVOList.add(bufferNumVO); + } + return bufferNumVOList; + } } diff --git a/src/main/java/com/ipsplm/service/simulation/impl/SimulationServiceImpl.java b/src/main/java/com/ipsplm/service/simulation/impl/SimulationServiceImpl.java new file mode 100644 index 0000000..b31b593 --- /dev/null +++ b/src/main/java/com/ipsplm/service/simulation/impl/SimulationServiceImpl.java @@ -0,0 +1,84 @@ +package com.ipsplm.service.simulation.impl; + +import cn.hutool.json.JSONUtil; +import com.ipsplm.service.simulation.ISimulationService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.*; +import java.net.Socket; + +/** + * @Description 仿真Service实现类 + * @Author FanDongqiang + * @Date 2023/3/15 16:26 + * @Version 1.0 + */ +@Service +@Slf4j +public class SimulationServiceImpl implements ISimulationService { + + @Value("${plant.socket.ip}") + private String ip; + + @Value("${plant.socket.port}") + private Integer port; + + /** + * 获取仿真数据 + * + * @param param 仿真参数 + */ + @Override + public String getPlantData(Object param) { + Socket socket = null; + String receivedMessage = null; + try { + // 创建Socket对象,指定服务端的IP地址和端口号 + socket = new Socket(ip, port); + + // 获取输入流和输出流 输入流和输出流是通过socket对象来进行数据传输的。 + InputStream inputStream = socket.getInputStream(); + OutputStream outputStream = socket.getOutputStream(); + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream); + BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter); +// PrintWriter writer = new PrintWriter(outputStream, true); + + // 将用户输入的信息发送给服务端 +// writer.println(param); + bufferedWriter.write((String) param); + bufferedWriter.flush(); + long oldTime = System.currentTimeMillis(); + // 接收服务端的响应并打印 + long newTime = System.currentTimeMillis(); + // 接收服务器发送的消息 + byte[] buffer = new byte[1024]; + int length = inputStream.read(buffer); + receivedMessage = new String(buffer, 0, length); + if(newTime-oldTime > 210 * 1000) { + receivedMessage = "请求超时"; + log.info("请求超时"); + }else { + if (StringUtils.isNotEmpty(receivedMessage)) { + System.out.println("收到服务器发送的消息:" + receivedMessage); + return receivedMessage; + + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (socket != null) { + try { + // 关闭连接 + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return receivedMessage; + } +} diff --git a/src/main/java/com/ipsplm/ws/SimulationWebsocket.java b/src/main/java/com/ipsplm/ws/SimulationWebsocket.java new file mode 100644 index 0000000..78f198d --- /dev/null +++ b/src/main/java/com/ipsplm/ws/SimulationWebsocket.java @@ -0,0 +1,104 @@ +package com.ipsplm.ws; + +import com.ipsplm.service.simulation.ISimulationService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.websocket.OnClose; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +@Slf4j +@Component +@ServerEndpoint(value = "/websocket/simulation") +public class SimulationWebsocket { + private Session session; + + private static ISimulationService simulationService; + + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + private boolean isSimulationRunning = false; + + @Autowired + public void setService(ISimulationService simulationService) { + SimulationWebsocket.simulationService = simulationService; + } + + //存放websocket的集合 + private static CopyOnWriteArraySet webSocketSet = new CopyOnWriteArraySet<>(); + + + @OnOpen + public void OnOpen(Session session) { + this.session = session; + webSocketSet.add(this); + log.info("【websocket消息】有新的连接, 总数:{}", webSocketSet.size()); + } + + @OnMessage + public void onMessage(String message) { + log.info("【websocket消息】收到客户端发来的消息:{}", message); + if ("StartSimulation".equals(message)) { + //发送开始仿真的信息 + String result = simulationService.getPlantData(message); + if ("Simulation Started".equals(result)) { + isSimulationRunning = true; + log.info("【仿真开始】"); + scheduler.scheduleAtFixedRate(() -> { + if (isSimulationRunning) { + String data = simulationService.getPlantData("SimulationProgress"); + // 根据需要处理和发送获取到的数据 + log.info("【仿真数据】:" + data); + sendMessage(data); + if("1".equals(data) || "1.00".equals(data)){ + sendMessage("ending"); + isSimulationRunning = false; + scheduler.shutdown(); + } + } + }, 0, 10, TimeUnit.SECONDS); + } else { + sendMessage("Simulation Start Failed"); + } + } else if ("ResetSimulation".equals(message)) { + String resetSimulation = simulationService.getPlantData(message); + if ("Simulation Reset".equals(resetSimulation)) { + sendMessage("ending"); + } else { + sendMessage("Simulation Reset Failed"); + } + } else { + String resetSimulation = simulationService.getPlantData(message); + } + } + + @OnClose + public void onClose() { + webSocketSet.remove(this); + log.info("【websocket消息】连接断开, 总数:{}", webSocketSet.size()); + } + + + public void sendMessage(String message) { + for (SimulationWebsocket webSocket : webSocketSet) { + try { + synchronized (webSocket.session) { + if (webSocket.session.isOpen()) { + webSocket.session.getBasicRemote().sendText(message); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5b943b3..d92da30 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -23,8 +23,8 @@ spring: #仿真Socket plant: socket: - ip: - port: + ip: 127.0.0.1 + port: 30000 mybatis-plus: configuration: diff --git a/src/main/resources/mapper/simulation/SimulationAnalysisMapper.xml b/src/main/resources/mapper/simulation/SimulationAnalysisMapper.xml index 0fda5f8..4da196c 100644 --- a/src/main/resources/mapper/simulation/SimulationAnalysisMapper.xml +++ b/src/main/resources/mapper/simulation/SimulationAnalysisMapper.xml @@ -35,7 +35,7 @@ where bxg.flag = #{flag} - order by flag desc , status limit 9 + order by flag desc , status + \ No newline at end of file