| | |
| | | * @param tags 标签 |
| | | * @param fields 字段 |
| | | */ |
| | | public void writeData(String measurement, Map<String, String> tags, Map<String, Object> fields) { |
| | | public void writeData(String measurement, Map<String, String> tags, Map<String, Object> fields,Long timestamp) { |
| | | Point point = Point.measurement(measurement) |
| | | .setTags(tags) |
| | | .setFields(fields) |
| | | .setTimestamp(Instant.now().toEpochMilli(), WritePrecision.MS); |
| | | .setTimestamp(timestamp, WritePrecision.MS); |
| | | try { |
| | | influxDBClient.writePoint(point); |
| | | } catch (Exception e) { |
| New file |
| | |
| | | package com.zy.acs.common.domain.mq; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | public class DeviceMessage implements Serializable { |
| | | |
| | | private String sourceHexStr; |
| | | |
| | | private Long timestamp = System.currentTimeMillis(); |
| | | |
| | | } |
| | |
| | | <artifactId>spring-boot-starter-data-redis</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.cool</groupId> |
| | | <artifactId>framework</artifactId> |
| | | <version>${cool.version}</version> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>acs-common</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.asrs.controller.requestParam.StationRequestParam; |
| | | import com.zy.asrs.controller.responseParam.StationResponseParam; |
| | | import com.zy.common.web.BaseController; |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.R; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.common.utils.News; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.controller.vo.PlcErrorTableVo; |
| | | import com.zy.acs.framework.annotations.ManagerAuth; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.asrs.controller.vo.SiteTableVo; |
| | | import com.zy.asrs.entity.Devp; |
| | | import com.zy.asrs.service.DevpService; |
| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.R; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.asrs.controller.requestParam.StaParam; |
| | | import com.zy.asrs.controller.responseParam.StationResponseParam; |
| | | import com.zy.asrs.controller.vo.PlcErrorTableVo; |
| | |
| | | */ |
| | | @ApiModelProperty(value = "备注") |
| | | private String memo; |
| | | |
| | | |
| | | public Devp setSqlData(Devp devp) { |
| | | this.setDevNo(devp.getDevNo()); |
| | | this.setWrkNo(devp.getWrkNo()); |
| | | this.setAutoing(devp.getAutoing() ); |
| | | this.setLoading(devp.getLoading() ); |
| | | this.setInEnable(devp.getInEnable()); |
| | | this.setOutEnable(devp.getOutEnable()); |
| | | this.setUpdateTime(new Date()); |
| | | return this; |
| | | } |
| | | } |
| | |
| | | @Repository |
| | | public interface DevpMapper extends BaseMapper<Devp> { |
| | | |
| | | List<Integer> getAvailableInSite(@Param("typeNo") Integer typeNo); |
| | | |
| | | List<Integer> getAvailableOutSite(@Param("typeNo") Integer typeNo); |
| | | Devp getDevpByDevNo(Integer devpNo); |
| | | } |
| | |
| | | |
| | | public interface DevpService extends IService<Devp> { |
| | | |
| | | /** |
| | | * 入库站 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Integer> getAvailableInSite(); |
| | | void updateBatchByDevpNo(List<Devp> devps); |
| | | |
| | | /** |
| | | * 空板入库站 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Integer> getAvailableEmptyInSite(); |
| | | |
| | | /** |
| | | * 出库站 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Integer> getAvailableOutSite(Integer typeNo); |
| | | |
| | | /** |
| | | * 空板出库站 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Integer> getAvailableEmptyOutSite(); |
| | | |
| | | /** |
| | | * 目标站点状态检测 |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.controller.requestParam.StationRequestParam; |
| | | import com.zy.asrs.controller.vo.OpenBusSubmitParam; |
| | | import com.zy.asrs.controller.vo.StationStatus; |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.entity.Devp; |
| | | import com.zy.asrs.mapper.DevpMapper; |
| | | import com.zy.asrs.service.DevpService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | @Service("basDevpService") |
| | | public class DevpServiceImpl extends ServiceImpl<DevpMapper, Devp> implements DevpService { |
| | | |
| | | |
| | | @Override |
| | | public List<Integer> getAvailableInSite() { |
| | | return this.baseMapper.getAvailableInSite(1); |
| | | public void updateBatchByDevpNo(List<Devp> devps) { |
| | | for (Devp devp : devps) { |
| | | Devp de = baseMapper.getDevpByDevNo(devp.getDevNo()); |
| | | if (de != null) { |
| | | de.setSqlData(devp); |
| | | baseMapper.updateById(de); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getAvailableEmptyInSite() { |
| | | return this.baseMapper.getAvailableInSite(10); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getAvailableOutSite(Integer typeNo) { |
| | | return this.baseMapper.getAvailableOutSite(typeNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getAvailableEmptyOutSite() { |
| | | return this.baseMapper.getAvailableOutSite(110); |
| | | } |
| | | |
| | | @Override |
| | | public Devp checkSiteStatus(Integer devpNo) { |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.controller.vo.ApplyInDto; |
| | | import com.zy.asrs.controller.vo.ApplyInRepsonseDto; |
| | | import com.zy.asrs.service.WmsMainService; |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.entity.WrkLastno; |
| | | import com.zy.asrs.mapper.WrkLastnoMapper; |
| | | import com.zy.asrs.service.WrkLastnoService; |
| | |
| | | package com.zy.asrs.utils; |
| | | |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.zy.acs.framework.common.Arith; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | |
| | | import java.text.DecimalFormat; |
| | |
| | | package com.zy.common; |
| | | |
| | | import com.core.common.BaseRes; |
| | | |
| | | import com.zy.acs.framework.common.BaseRes; |
| | | |
| | | public interface CodeRes extends BaseRes { |
| | | |
| | |
| | | package com.zy.common.config; |
| | | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.zy.acs.framework.annotations.ManagerAuth; |
| | | import com.zy.acs.framework.common.BaseRes; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.common.utils.Http; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.lang.Nullable; |
| | |
| | | package com.zy.common.config; |
| | | |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.common.domain.BaseResult; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import org.springframework.web.HttpRequestMethodNotSupportedException; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | |
| | | public class CoolExceptionHandler { |
| | | |
| | | @ExceptionHandler(Exception.class) |
| | | public R handlerException(HandlerMethod handler, Exception e) { |
| | | public BaseResult handlerException(HandlerMethod handler, Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(); |
| | | return BaseResult.error(); |
| | | } |
| | | |
| | | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) |
| | | public R handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { |
| | | return R.error(); |
| | | public BaseResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { |
| | | return BaseResult.error(); |
| | | } |
| | | |
| | | @ExceptionHandler(CoolException.class) |
| | | public R handleRRException(CoolException e) { |
| | | return R.parse(e.getMessage()); |
| | | public BaseResult handleRRException(Exception e) { |
| | | return BaseResult.error(e.getMessage()); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.R; |
| | | import com.zy.acs.framework.common.R; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | |
| | | package com.zy.common.utils; |
| | | |
| | | import com.core.common.Cools; |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Modifier; |
| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.core.controller.AbstractBaseController; |
| | | import com.zy.acs.framework.controller.AbstractBaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | return devp; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public StaProtocol clone() { |
| | | try { |
| | |
| | | package com.zy.core.operation.handler; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.asrs.controller.vo.ApplyInDto; |
| | | import com.zy.asrs.controller.vo.ApplyInRepsonseDto; |
| | | import com.zy.asrs.entity.Job; |
| | |
| | | package com.zy.core.operation.handler; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.entity.Job; |
| | | import com.zy.asrs.service.CtuMainService; |
| | | import com.zy.asrs.service.JobService; |
| | |
| | | package com.zy.core.operation.handler; |
| | | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.entity.Job; |
| | | import com.zy.asrs.enums.WorkNoTypeType; |
| | | import com.zy.asrs.service.CtuMainService; |
| | |
| | | package com.zy.core.thread; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.DateUtils; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.ThreadHandler; |
| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.DateUtils; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.asrs.entity.Devp; |
| | | import com.zy.asrs.service.DevpService; |
| | | import com.zy.asrs.utils.SpringContextUtil; |
| | |
| | | devps.add(staProtocol.toSqlModel()); |
| | | } |
| | | DevpService devpService = SpringContextUtil.getBean(DevpService.class); |
| | | if (null != devpService && !devpService.updateBatchById(devps)) { |
| | | if (null != devpService) { |
| | | devpService.updateBatchByDevpNo(devps); |
| | | } else { |
| | | throw new Exception("更新数据库数据失败"); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.Devp"> |
| | | <id column="dev_no" property="devNo"/> |
| | | <result column="dec_desc" property="decDesc"/> |
| | | <result column="dev_mk" property="devMk"/> |
| | | <result column="in_enable" property="inEnable"/> |
| | | <result column="out_enable" property="outEnable"/> |
| | | <result column="autoing" property="autoing"/> |
| | |
| | | <result column="barcode" property="barcode"/> |
| | | </resultMap> |
| | | |
| | | <select id="getAvailableInSite" resultType="java.lang.Integer"> |
| | | select abd.dev_no |
| | | from asr_bas_devp abd |
| | | left join asr_sta_desc asd on abd.dev_no = asd.stn_no |
| | | where 1 = 1 |
| | | and asd.type_no = #{typeNo} |
| | | and abd.in_enable = 'Y' |
| | | group by abd.dev_no |
| | | <select id="getDevpByDevNo" resultMap="BaseResultMap"> |
| | | select * from cv_devp where dev_no = #{devNo} |
| | | </select> |
| | | |
| | | <select id="getAvailableOutSite" resultType="java.lang.Integer"> |
| | | select abd.dev_no |
| | | from asr_bas_devp abd |
| | | left join asr_sta_desc asd on abd.dev_no = asd.stn_no |
| | | where 1 = 1 |
| | | and asd.type_no = #{typeNo} |
| | | and abd.out_enable = 'Y' |
| | | group by abd.dev_no |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | /* 表格容器 */ |
| | | .table-container { |
| | | flex: 1; |
| | | overflow: hidden; |
| | | overflow-x: hidden; |
| | | overflow-y: auto; |
| | | background: rgba(17, 24, 39, 0.5); |
| | | border-radius: 12px; |
| | | border: 1px solid rgba(59, 130, 246, 0.3); |
| | | backdrop-filter: blur(10px); |
| | | } |
| | | |
| | | /* 表格容器滚动条样式 */ |
| | | .table-container::-webkit-scrollbar { |
| | | width: 8px; |
| | | } |
| | | |
| | | .table-container::-webkit-scrollbar-track { |
| | | background: rgba(30, 41, 59, 0.3); |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .table-container::-webkit-scrollbar-thumb { |
| | | background: #3b82f6; |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .table-container::-webkit-scrollbar-thumb:hover { |
| | | background: #60a5fa; |
| | | } |
| | | |
| | | /* 现代化表格样式 */ |
| | | .modern-table { |
| | | width: 100%; |
| | | height: 100%; |
| | | table-layout: fixed; |
| | | border-collapse: separate; |
| | | border-spacing: 0; |
| | | background: transparent; |
| | | color: #e2e8f0; |
| | | } |
| | | |
| | | /* 设置表格列宽,确保适应容器 */ |
| | | .modern-table th, |
| | | .modern-table td { |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | } |
| | | |
| | | .modern-table thead { |
| | | position: sticky; |
| | | top: 0; |
| | | z-index: 10; |
| | | } |
| | | |
| | | /* 确保表格容器有最大高度,以便滚动 */ |
| | | .table-container { |
| | | max-height: calc(100vh - 200px); |
| | | } |
| | | |
| | | .modern-table th { |
| | |
| | | |
| | | .output-log { |
| | | width: 100%; |
| | | height: 150px; |
| | | height: 100px; |
| | | background: rgba(0, 0, 0, 0.3); |
| | | border: 1px solid rgba(59, 130, 246, 0.3); |
| | | border-radius: 8px; |
| | | color: #4ade80; |
| | | font-family: 'Courier New', monospace; |
| | | font-size: 12px; |
| | | padding: 15px; |
| | | padding: 10px; |
| | | resize: vertical; |
| | | } |
| | | |
| | |
| | | <main> |
| | | <!-- 站点状态数据监控版 --> |
| | | <section id="site-monitor" class="main-board"> |
| | | <div class="dashboard-header"> |
| | | <h2 class="dashboard-title">站点实时监控</h2> |
| | | </div> |
| | | <!-- <div class="dashboard-header">--> |
| | | <!-- <h3 class="dashboard-title">站点实时监控</h3>--> |
| | | <!-- </div>--> |
| | | |
| | | <!-- 表格容器 --> |
| | | <div class="table-container"> |
| | |
| | | // DOM加载完成后初始化 |
| | | $(document).ready(function () { |
| | | // 加载初始数据 |
| | | getPlcError(); |
| | | getSite(); |
| | | |
| | | // 初始化定时器 |
| | |
| | | function initTimers() { |
| | | // 每秒更新PLC错误、站点信息和IO模式 |
| | | timers.push(setInterval(() => { |
| | | getPlcError(); |
| | | if (!isSiteUpdatePaused) { |
| | | getSite(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // 获取PLC异常信息表 |
| | | function getPlcError() { |
| | | const tableEl = $('#plc-error-table'); |
| | | tableEl.children("tr").children("td").html(""); |
| | | |
| | | ajaxRequest({ |
| | | url: `${baseUrl}/site/table/plc/errors`, |
| | | method: 'POST', |
| | | success: (res) => { |
| | | if (res.data) { |
| | | const tableData = res.data; |
| | | for (let i = 0; i < tableData.length; i++) { |
| | | const tr = tableEl.find("tr").eq(i + 1); |
| | | tr.children("td").eq(0).html(tableData[i].no); |
| | | tr.children("td").eq(1).html(tableData[i].plcDesc); |
| | | tr.children("td").eq(2).html(tableData[i].error); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 获取站点信息表 |
| | | function getSite() { |
| | |
| | | package com.zy.acs.gateway.handler; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import com.zy.acs.common.domain.protocol.*; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.gateway.AbstractInboundHandler; |
| | |
| | | ctx.writeAndFlush(pathAckPac); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK.name()), agv_01_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK_RESPONSE.name()), agv_b1_down); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK_RESPONSE.name()), new DeviceMessage(pathAckPac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | AGV_06_UP agv_06_up = (AGV_06_UP) pac.getBody().getMessageBody(); |
| | | redis.push(RedisConstant.AGV_COMPLETE_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_06_up)); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PICK_PLACE_REQUEST.name()), agv_06_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PICK_PLACE_REQUEST.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | , pac.getHeader().getUniqueNo() + "_" + agv_02_up.getSerialNo() |
| | | , agv_02_up); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.COMMAND_ACK.name()), agv_02_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.COMMAND_ACK.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | redis.push(RedisConstant.AGV_COMPLETE_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_11_up)); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.ACTION_COMPLETE.name()), agv_11_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.ACTION_COMPLETE.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | // 动作完成应答 |
| | | if (null != ackType) { |
| | |
| | | |
| | | ctx.writeAndFlush(ackPac); |
| | | |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), agv_a1_down); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), new DeviceMessage(ackPac.getSourceHexStr())); |
| | | } |
| | | |
| | | break label; |
| | |
| | | // |
| | | // }); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_CODE_REPORT.name()), agv_12_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_CODE_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // }); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_WITHOUT_CODE_REPORT.name()), agv_13_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_WITHOUT_CODE_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // |
| | | // }); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.HEARTBEAT_REPORT.name()), agv_03_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.HEARTBEAT_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // }); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.SILO_REPORT.name()), agv_70_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.SILO_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | AGV_F0_UP agv_f0_up = (AGV_F0_UP) pac.getBody().getMessageBody(); |
| | | redis.push(RedisConstant.AGV_DATA_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_f0_up)); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.LOGIN_REPORT.name()), agv_f0_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.LOGIN_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | // 登录应答 |
| | | if (null != ackType) { |
| | | AgvPackage ackPac = AckMsgBuilder.ofSuccess(pac, ackType); |
| | | |
| | | ctx.writeAndFlush(ackPac); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), ackPac.getBody().getMessageBody()); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), new DeviceMessage(ackPac.getSourceHexStr())); |
| | | } |
| | | |
| | | // 30s redis |
| | |
| | | redis.push(RedisConstant.AGV_DATA_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_04_up)); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.FAULT_REPORT.name()), agv_04_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.FAULT_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.gateway.config.SystemProperties; |
| | |
| | | AgvPackage agvPackage = ProtocolUtils.installDownProtocol(protocol); |
| | | publisher.publish(agvPackage); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, protocol.getAgvNo()).replaceFirst(RabbitmqConstant.SPILT_REGEX, agvPackage.getHeader().getProtocolType().name()), agvPackage.getBody().getMessageBody()); |
| | | log.info("<UNK> >>> {}", JSON.toJSONString(agvPackage)); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, protocol.getAgvNo()).replaceFirst(RabbitmqConstant.SPILT_REGEX, agvPackage.getHeader().getProtocolType().name()),new DeviceMessage(agvPackage.getSourceHexStr())); |
| | | |
| | | } |
| | | } |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import com.zy.acs.hex.constant.InfluxDBConstant; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import com.zy.acs.hex.utils.ReflectionUtils; |
| | | import com.zy.acs.hex.utils.ObjectToMapUtils; |
| | | import com.zy.acs.hex.utils.StrUtils; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(Device msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | public void handle(DeviceMessage msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | log.info("routingKey:{},receive down message:{}", routingKey, msg); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ReflectionUtils.convertBean2Map(msg)); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ObjectToMapUtils.objectToMap(msg, false), msg.getTimestamp()); |
| | | } |
| | | |
| | | |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import com.zy.acs.hex.constant.InfluxDBConstant; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import com.zy.acs.hex.utils.ReflectionUtils; |
| | | import com.zy.acs.hex.utils.ObjectToMapUtils; |
| | | import com.zy.acs.hex.utils.StrUtils; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(Device msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | public void handle(DeviceMessage msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | log.info("routingKey:{},receive up message:{}", routingKey, msg); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ReflectionUtils.convertBean2Map(msg)); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ObjectToMapUtils.objectToMap(msg, false), msg.getTimestamp()); |
| | | } |
| | | |
| | | |
| | |
| | | package com.zy.acs.hex.consumer.listener; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | |
| | | public interface AbstractListener { |
| | | void handle(Device event, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel); |
| | | void handle(DeviceMessage event, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel); |
| | | } |
| | |
| | | @GetMapping(value = "/query") |
| | | @ResponseBody |
| | | public Object queryTest() { |
| | | return influxDBService.queryData("select * from device order by time desc limit 10"); |
| | | return influxDBService.queryData("select * from device order by time desc limit 10"); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.zy.acs.hex.domain; |
| | | |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | |
| New file |
| | |
| | | package com.zy.acs.hex.utils; |
| | | |
| | | import org.springframework.util.ReflectionUtils; |
| | | |
| | | import java.lang.reflect.Modifier; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class ObjectToMapUtils { |
| | | |
| | | public static Map<String, Object> objectToMap(Object obj, boolean includeSuperclass) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (obj == null) { |
| | | return map; |
| | | } |
| | | |
| | | ReflectionUtils.FieldCallback callback = field -> { |
| | | if (Modifier.isStatic(field.getModifiers())) { |
| | | return; |
| | | } |
| | | ReflectionUtils.makeAccessible(field); |
| | | map.put(field.getName(), ReflectionUtils.getField(field, obj)); |
| | | }; |
| | | |
| | | if (includeSuperclass) { |
| | | // 包含父类字段 |
| | | ReflectionUtils.doWithFields(obj.getClass(), callback); |
| | | } else { |
| | | // 仅当前类字段 |
| | | ReflectionUtils.doWithLocalFields(obj.getClass(), callback); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | // 正则表达式匹配 rcs.up. 开头,后面跟着两个版本号部分 |
| | | String regex = "^rcs\\.up\\.(\\*|[a-zA-Z0-9]+)\\.(\\*|[a-zA-Z0-9]+)$"; |
| | | if (routingKey.matches(regex)) { |
| | | // 分割字符串并返回版本号部分 |
| | | String[] parts = routingKey.split("\\."); |
| | | if (parts.length == 4) { |
| | | Map<String, String> data = new HashMap<>(); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_TYPE, parts[1]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_DEVICEID, parts[2]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_EVENT, parts[3]); |
| | | return data; |
| | | } |
| | | //if (routingKey.matches(regex)) { |
| | | // 分割字符串并返回版本号部分 |
| | | String[] parts = routingKey.split("\\."); |
| | | if (parts.length == 4) { |
| | | Map<String, String> data = new HashMap<>(); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_TYPE, parts[1]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_DEVICEID, parts[2]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_EVENT, parts[3]); |
| | | return data; |
| | | } |
| | | //} |
| | | // 如果格式不符合,返回空数组 |
| | | return null; |
| | | } |
| | |
| | | publisher-confirm-type: correlated |
| | | publisher-returns: true |
| | | # 消费者配置 |
| | | listener: |
| | | simple: |
| | | concurrency: 2 |
| | | max-concurrency: 10 |
| | | # listener: |
| | | # direct: |
| | | # 确认机制 |