| | |
| | | |
| | | @GetMapping("/test") |
| | | public R test() { |
| | | notifyUtils.notify("task", 1, "9999", NotifyMsgType.SHUTTLE_MOVING, "data"); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), 2, "9999", NotifyMsgType.SHUTTLE_MOVE_COMPLETE); |
| | | notifyUtils.notify("task", 1, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVING, "data"); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), 2, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVE_COMPLETE); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | //工作号 |
| | | private String taskNo; |
| | | |
| | | //上级系统工作号 |
| | | private String superTaskNo; |
| | | |
| | | //消息类型 |
| | | private String msgType; |
| | | |
New file |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_http_request_log") |
| | | public class HttpRequestLog implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | private String request; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | private String response; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableField("create_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | public HttpRequestLog() {} |
| | | |
| | | public HttpRequestLog(String name,String request,String response,Date createTime) { |
| | | this.name = name; |
| | | this.request = request; |
| | | this.response = response; |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | // HttpRequestLog httpRequestLog = new HttpRequestLog( |
| | | // null, // |
| | | // null, // |
| | | // null, // |
| | | // null // |
| | | // ); |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.mapper; |
| | | |
| | | import com.zy.asrs.entity.HttpRequestLog; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface HttpRequestLogMapper extends BaseMapper<HttpRequestLog> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service; |
| | | |
| | | import com.zy.asrs.entity.HttpRequestLog; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | public interface HttpRequestLogService extends IService<HttpRequestLog> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.zy.asrs.mapper.HttpRequestLogMapper; |
| | | import com.zy.asrs.entity.HttpRequestLog; |
| | | import com.zy.asrs.service.HttpRequestLogService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("httpRequestLogService") |
| | | public class HttpRequestLogServiceImpl extends ServiceImpl<HttpRequestLogMapper, HttpRequestLog> implements HttpRequestLogService { |
| | | |
| | | } |
| | |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | //触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_TRANSPORT); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_TRANSPORT); |
| | | return false; |
| | | } |
| | | return false; |
| | |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | //触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_TRANSPORT); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_TRANSPORT); |
| | | return false; |
| | | } |
| | | return false; |
| | |
| | | //310.小车移动中 ==> 311.小车移动完成 |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//触发通知 |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) { |
| | | //204.小车充电中 ==> 205.小车充电完成 |
| | | wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//触发通知 |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts) { |
| | | //502.小车搬运中 ==> 509.移库完成 |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_LOC_MOVE.sts); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_DELIVERY);//触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_DELIVERY);//触发通知 |
| | | } else { |
| | | continue; |
| | | } |
| | |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | //触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_MOVING); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); |
| | | return false; |
| | | } |
| | | return false; |
| | |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_POWER_START);//触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_START);//触发通知 |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | //下发任务 |
| | | shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand); |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING); |
| | | //触发通知 |
| | | notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.SHUTTLE_MOVING); |
| | | return false; |
| | | } |
| | | return false; |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.domain.NotifyDto; |
| | | import com.zy.asrs.entity.HttpRequestLog; |
| | | import com.zy.asrs.service.HttpRequestLogService; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.RedisUtil; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private HttpRequestLogService httpRequestLogService; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | public synchronized void notifyShuttle(){ |
| | |
| | | for (ForkLiftSlave slave : slaveProperties.getForkLift()) { |
| | | notifyMsg(String.valueOf(SlaveType.ForkLift), slave.getId()); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | public synchronized void notifyTask(){ |
| | | notifyMsg("task", 1); |
| | | } |
| | | |
| | | private synchronized void notifyMsg(String notifyType, Integer device) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | HttpRequestLog httpRequestLog = new HttpRequestLog(); |
| | | httpRequestLog.setName(notifyUri + notifyUriPath); |
| | | httpRequestLog.setRequest(JSON.toJSONString(notifyDto)); |
| | | httpRequestLog.setCreateTime(new Date()); |
| | | |
| | | try { |
| | | //触发通知 |
| | | String response = new HttpHandler.Builder() |
| | |
| | | .setJson(JSON.toJSONString(notifyDto)) |
| | | .build() |
| | | .doPost(); |
| | | httpRequestLog.setResponse(response); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if(code == 200){ |
| | | //通知成功 |
| | | redisUtil.del(key); |
| | | |
| | | continue; |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | //保存记录 |
| | | httpRequestLogService.insert(httpRequestLog); |
| | | } |
| | | |
| | | //通知失败 |
| | |
| | | } |
| | | |
| | | //上报 |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //上报 |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //上报 |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //上报 |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //上报 |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast)); |
| | | notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast)); |
| | | } |
| | | } |
| | | |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | public synchronized boolean notify(String notifyType, Integer device, String taskNo, NotifyMsgType msgType) { |
| | | return append(notifyType, device, taskNo, msgType, null); |
| | | public synchronized boolean notify(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType) { |
| | | return append(notifyType, device, taskNo, superTaskNo, msgType, null); |
| | | } |
| | | |
| | | public synchronized boolean notify(String notifyType, Integer device, String taskNo, NotifyMsgType msgType, String data) { |
| | | return append(notifyType, device, taskNo, msgType, data); |
| | | public synchronized boolean notify(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType, String data) { |
| | | return append(notifyType, device, taskNo, superTaskNo, msgType, data); |
| | | } |
| | | |
| | | public synchronized List<String> takeKeys(String notifyType, Integer device) { |
| | |
| | | return key; |
| | | } |
| | | |
| | | private boolean append(String notifyType, Integer device, String taskNo, NotifyMsgType msgType, String data) { |
| | | private boolean append(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType, String data) { |
| | | String key = getKey(notifyType, device); |
| | | if(key == null){ |
| | | if (key == null) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | dto.setMsgDesc(msgType.desc); |
| | | dto.setData(data); |
| | | dto.setTaskNo(taskNo); |
| | | dto.setSuperTaskNo(superTaskNo); |
| | | |
| | | //重试次数 |
| | | Config notifyFailTimesConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyFailTimes")); |
| | |
| | | public static void main(String[] args) throws Exception { |
| | | CoolGenerator generator = new CoolGenerator(); |
| | | // mysql |
| | | // generator.url="localhost:3306/cool"; |
| | | // generator.username="root"; |
| | | // generator.password="xltys1995"; |
| | | // generator.table="sys_host"; |
| | | generator.sqlOsType = SqlOsType.MYSQL; |
| | | generator.url="localhost:3306/shuttle_rcs"; |
| | | generator.username="root"; |
| | | generator.password="root"; |
| | | generator.table="sys_http_request_log"; |
| | | // sqlserver |
| | | generator.sqlOsType = SqlOsType.SQL_SERVER; |
| | | generator.url="192.168.4.15:1433;databasename=tzskasrs"; |
| | | generator.username="sa"; |
| | | generator.password="sa@123"; |
| | | generator.table="asr_bas_shuttle"; |
| | | // generator.sqlOsType = SqlOsType.SQL_SERVER; |
| | | // generator.url="127.0.0.1:1433;databasename=tzskasrs"; |
| | | // generator.username="sa"; |
| | | // generator.password="sa@123"; |
| | | // generator.table="asr_bas_shuttle"; |
| | | generator.packagePath="com.zy.asrs"; |
| | | |
| | | generator.controller = false; |
| | |
| | | validation-timeout: 3000 |
| | | connection-test-query: select 1 |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:3306/lfdwcs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://127.0.0.1:3306/shuttle_rcs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | password: root |
| | | mvc: |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.mapper.HttpRequestLogMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.HttpRequestLog"> |
| | | <id column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | <result column="request" property="request" /> |
| | | <result column="response" property="response" /> |
| | | <result column="create_time" property="createTime" /> |
| | | |
| | | </resultMap> |
| | | |
| | | </mapper> |