From e0a61480eba85a78da08ec8ad2dd1f6d61e3baa5 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 1 Jan 2022 23:15:06 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 5.数据库/dump-mt_wms_qj-202112230921.sql | 1765 +++++++++++++++++ .../mt/wms/core/dal/entity/ParEleValue.java | 10 +- .../core/dal/mapper/ParEleValueMapper.java | 2 +- .../wms/core/dal/mapper/ParEleValueMapper.xml | 4 +- .../dal/service/ParEleValueServiceBiz.java | 2 +- .../impl/ParEleValueServiceBizImpl.java | 2 +- .../empty/controller/ElectricController.java | 124 +- .../wms/empty/params/AlarmInfoQueryParam.java | 4 +- .../service/impl/AlarmInfoServiceImpl.java | 2 +- .../service/impl/OutStockServiceImpl.java | 25 +- .../service/impl/StockInfoServiceImpl.java | 15 +- .../mt/wms/empty/task/AsynRunTaskService.java | 107 +- .../com/mt/wms/empty/task/RunTaskUtils.java | 37 +- .../com/mt/wms/empty/task/ScheduledTask.java | 30 +- .../com/mt/wms/empty/vo/CurrTaskDetVo.java | 2 +- .../java/com/mt/wms/empty/vo/StockInfoVo.java | 4 +- 16 files changed, 2099 insertions(+), 36 deletions(-) create mode 100644 5.数据库/dump-mt_wms_qj-202112230921.sql diff --git a/5.数据库/dump-mt_wms_qj-202112230921.sql b/5.数据库/dump-mt_wms_qj-202112230921.sql new file mode 100644 index 0000000..f982b4b --- /dev/null +++ b/5.数据库/dump-mt_wms_qj-202112230921.sql @@ -0,0 +1,1765 @@ +-- MySQL dump 10.13 Distrib 5.5.40, for Win64 (x86) +-- +-- Host: mysql.picaiba.com Database: mt_wms_qj +-- ------------------------------------------------------ +-- Server version 8.0.25 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `t_alarm_base` +-- + +DROP TABLE IF EXISTS `t_alarm_base`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_alarm_base` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '编码', + `alarm_class` varchar(128) DEFAULT '' COMMENT '报警类型,数据字典获取', + `alarm_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '报警编码', + `alarm_info` varchar(1024) NOT NULL COMMENT '报警内容', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报警基础表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_alarm_info` +-- + +DROP TABLE IF EXISTS `t_alarm_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_alarm_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `equipment_id` int NOT NULL COMMENT '设备id', + `equipment_name` varchar(128) DEFAULT '' COMMENT '设备名称', + `type` int DEFAULT '0' COMMENT '报警类型 0窑炉,1表示车辆,依次类推', + `alarm_code` varchar(128) NOT NULL COMMENT '报警编码', + `alarm_info` varchar(1024) DEFAULT '' COMMENT '报警内容', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报警信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_apms_check_result` +-- + +DROP TABLE IF EXISTS `t_apms_check_result`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_apms_check_result` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `sheet_no` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '生产单号', + `iden_card_num` varchar(128) NOT NULL COMMENT '标识卡号', + `hardness` varchar(128) DEFAULT '' COMMENT '硬度检验结果(合格、不合格、返工、作废)', + `metallography` varchar(128) DEFAULT '' COMMENT '金相检验结果(合格、不合格)', + `heart_hardness` float(8,2) DEFAULT '0.00' COMMENT '心部硬度检验值', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='apms推送检验结果表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_auto_exe_task` +-- + +DROP TABLE IF EXISTS `t_auto_exe_task`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_auto_exe_task` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `status` int DEFAULT '0' COMMENT '状态,0:新增,1:执行中,2完成', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `process_flow_id` bigint DEFAULT '0' COMMENT '工艺流程ID', + `process_flow_name` varchar(128) DEFAULT '' COMMENT '工艺流程名称', + `process_flow_type` int NOT NULL COMMENT '工艺类型,1表示第一种工艺流程,2表示第二种工艺流程', + `craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID', + `craft_code` varchar(128) DEFAULT '' COMMENT '工艺编码', + `warehouse_id` bigint DEFAULT '0' COMMENT '区域ID,区分不同操作区域', + `f_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `f_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `f_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `f_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `f_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `f_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `f_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `f_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `f_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `t_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `t_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `t_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `t_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `t_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `t_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `t_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `t_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `t_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `th_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `th_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `th_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `th_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `th_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `th_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `th_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `th_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `th_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `content` varchar(1024) DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='自动执行任务表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_auto_exe_task_his` +-- + +DROP TABLE IF EXISTS `t_auto_exe_task_his`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_auto_exe_task_his` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `status` int DEFAULT '0' COMMENT '状态,0:新增,1:执行中,2完成', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `process_flow_id` bigint DEFAULT '0' COMMENT '工艺流程ID', + `process_flow_name` varchar(128) DEFAULT '' COMMENT '工艺流程名称', + `process_flow_type` int NOT NULL COMMENT '工艺类型,1表示第一种工艺流程,2表示第二种工艺流程', + `craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID', + `craft_code` varchar(128) DEFAULT '' COMMENT '工艺编码', + `warehouse_id` bigint DEFAULT '0' COMMENT '区域ID,区分不同操作区域', + `f_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `f_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `f_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `f_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `f_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `f_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `f_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `f_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `f_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `t_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `t_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `t_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `t_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `t_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `t_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `t_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `t_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `t_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `th_task_id` bigint DEFAULT '0' COMMENT '执行任务ID,关联任务表:t_curr_task', + `th_det_task_code` varchar(128) NOT NULL COMMENT '任务编码,子任务编码对应任务表t_curr_task中task_code编码', + `th_equipment_type_id` bigint DEFAULT '0' COMMENT '设备类型ID,关联设备类型表:t_equipment_type', + `th_equipment_id` bigint DEFAULT '0' COMMENT '设备ID,关联设备表:t_kiln_info', + `th_craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `th_plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `th_in_tran_status` int DEFAULT '0' COMMENT '进炉运输状态,0:开始,1:运输中,2:运输完成', + `th_pro_status` int DEFAULT '0' COMMENT '加工状态,0:加工开始,1:加工中,2:加工完成', + `th_out_tran_status` int DEFAULT '0' COMMENT '出炉运输状态,0:开始,1:运输中,2:运输完成', + `content` varchar(1024) DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='自动执行任务表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_communication_log` +-- + +DROP TABLE IF EXISTS `t_communication_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_communication_log` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `type` int DEFAULT '0' COMMENT '类型,0:wms To wcs日志,1:wcs to wms日志\r\n2:wms to apms日志 3:apms to wms日志', + `code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '内部编码,系统自动生成', + `log_name` varchar(128) DEFAULT '' COMMENT '日志名称', + `content` varchar(1024) DEFAULT '' COMMENT '内容', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=288 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='通讯日志信息 包括wcs与wms apms与wms相互通讯'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_craft_info` +-- + +DROP TABLE IF EXISTS `t_craft_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_craft_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态,0:可用,1:不可用', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `craft_code` varchar(128) NOT NULL COMMENT '工艺号', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `plc_value` int NOT NULL COMMENT '对应PLC值', + `content` varchar(1024) DEFAULT '' COMMENT '说明', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='设备工艺信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_curr_task` +-- + +DROP TABLE IF EXISTS `t_curr_task`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_curr_task` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行,1执行中,2执行完成', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `is_auto` int DEFAULT '0' COMMENT '是否自动执行: 0手动,1自动,如果是自动任务这里要监控进出和到缓存区的调度任务', + `auto_exe_task_id` bigint DEFAULT '0' COMMENT '任务流程ID,关联流程表:t_auto_exe_task', + `kiln_id` bigint NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `kiln_name` varchar(128) DEFAULT '' COMMENT '窑炉名称', + `craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `begin_time` datetime DEFAULT NULL COMMENT '开始加工时间', + `end_time` datetime DEFAULT NULL COMMENT '加工结束时间', + `is_in` int DEFAULT '0' COMMENT '进炉状态: 0准备进炉,1正在加工,2加工完成', + `run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `start_position` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '开始位置', + `target_position` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '目标位置指的是窑炉的位置', + `is_cache` int DEFAULT '0' COMMENT '是否缓存,如果当前指的窑炉正在加工,系统自动分配货物到缓存位置,\r\n 并且记录缓存库位,这是当指定窑炉加工完成后系统先判断是否当前缓存有当前等待执行的任务,然后按照先来先执行原则(等待多个任务)自动调用车辆来执行', + `cache_satatus` int DEFAULT '0' COMMENT '缓存状态状态: 0准备进入缓存区,1正在进入缓存区,2缓存完成', + `cache_run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `location_id` bigint DEFAULT '0' COMMENT '库位id,关联库位表:t_location', + `location_name` varchar(128) DEFAULT '' COMMENT '库位名称', + `is_out` int DEFAULT '0' COMMENT '出炉状态: 0准备出炉,1正在加工,2加工完成', + `out_run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `out_start_position` varchar(128) DEFAULT '' COMMENT '开始位置', + `out_target_position` varchar(128) DEFAULT '' COMMENT '目标位置,指缓存位置', + `task_code` varchar(100) NOT NULL DEFAULT '' COMMENT '任务编码', + `sheet_no` varchar(128) DEFAULT NULL COMMENT '生产单号 APMS生成生产单后返回', + `task_type` int NOT NULL COMMENT '任务类型:0:入库到窑炉,1:入库到缓存区,2出库到 窑炉到缓存区,3缓存区出库', + `process_type` int NOT NULL COMMENT '加工类型:0 初始加工,1 复加工 ', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_curr_task_det` +-- + +DROP TABLE IF EXISTS `t_curr_task_det`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_curr_task_det` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `task_code` varchar(128) DEFAULT '' COMMENT '任务编码', + `curr_task_id` bigint NOT NULL COMMENT '当前任务id,关联当前任务表:t_curr_task', + `order_no` varchar(128) DEFAULT '' COMMENT '订单号,', + `iden_card_num` varchar(128) NOT NULL COMMENT '标识卡号,', + `product_name` varchar(128) DEFAULT '' COMMENT '产品名称', + `material_des` varchar(128) DEFAULT '' COMMENT '材料牌号 ', + `craft_ill` varchar(512) DEFAULT '' COMMENT '工艺要求 ', + `unit` varchar(32) DEFAULT '' COMMENT '单位', + `weight` float(8,2) DEFAULT '0.00' COMMENT '重量,手动输入', + `quantity` float(8,2) DEFAULT '0.00' COMMENT '数量,手动输入', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=254 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='当前任务明细'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_factory` +-- + +DROP TABLE IF EXISTS `t_factory`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_factory` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '0' COMMENT '删除标志,是否有效:0 可用 1不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) NOT NULL COMMENT '工厂编码', + `factory_name` varchar(256) NOT NULL COMMENT '工厂名称', + `address` varchar(512) DEFAULT '' COMMENT '工厂地址', + `description` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='工厂'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_in_stock_info` +-- + +DROP TABLE IF EXISTS `t_in_stock_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_in_stock_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0未开始执行,1正在执行,2执行完成', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `task_code` varchar(128) DEFAULT '' COMMENT '任务编码', + `task_id` bigint DEFAULT '0' COMMENT '任务id,关联当前任务表:currTask', + `kiln_id` bigint DEFAULT NULL COMMENT '窑炉id ,if(status == 0){从窑炉出来等待库存} else if(status == 1){到目标窑炉前缓存到库位}关联设备窑炉表:t_kiln_info', + `kiln_name` varchar(128) DEFAULT '' COMMENT '窑炉名称', + `location_id` bigint DEFAULT '0' COMMENT '库位id,关联库位表:t_location', + `location_name` varchar(128) DEFAULT '' COMMENT '库位名称', + `pallet_code` varchar(128) DEFAULT '' COMMENT '托盘编码', + `type` int DEFAULT '0' COMMENT '类型: 0等待出库,1到窑炉前缓存,2插单任务缓存', + `in_time` datetime DEFAULT NULL COMMENT '进入缓存区的时间,插单任务按倒叙执行,正常任务按顺序执行', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='缓存区存储情况'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_in_stock_info_his` +-- + +DROP TABLE IF EXISTS `t_in_stock_info_his`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_in_stock_info_his` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0未开始执行,1正在执行,2执行完成', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `task_code` varchar(128) DEFAULT '' COMMENT '任务编码', + `task_id` int DEFAULT '0' COMMENT '历史任务id,关联任务表:t_task_his', + `kiln_id` int NOT NULL COMMENT '窑炉id ,if(status == 0){从窑炉出来等待库存} else if(status == 1){到目标窑炉前缓存到库位}关联设备窑炉表:t_kiln_info', + `kiln_name` varchar(128) DEFAULT '' COMMENT '窑炉名称', + `location_id` int DEFAULT '0' COMMENT '库位id,关联库位表:t_location', + `location_name` varchar(128) DEFAULT '' COMMENT '库位名称', + `pallet_code` varchar(128) DEFAULT '' COMMENT '托盘编码', + `type` int DEFAULT NULL COMMENT '类型: 0等待出库,1到窑炉前缓存,2插单任务缓存', + `in_time` varchar(100) DEFAULT NULL COMMENT '进入缓存区的时间,插单任务按倒叙执行,正常任务按顺序执行', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='缓存区存储历史情况'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_kiln_info` +-- + +DROP TABLE IF EXISTS `t_kiln_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_kiln_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '编码 必须与AMPS相同', + `factory_id` int DEFAULT NULL COMMENT '绑定工厂id', + `kiln_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '窑炉名称 建议与AMPS相同', + `kiln_alias` varchar(256) DEFAULT '' COMMENT '窑炉别名', + `en` varchar(256) DEFAULT '' COMMENT '英语名称', + `type` varchar(64) DEFAULT '' COMMENT '设备类型,存储数据字典编码', + `ip` varchar(32) DEFAULT '' COMMENT 'ip地址', + `port_number` varchar(16) DEFAULT '' COMMENT '端口号', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='窑炉信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_location` +-- + +DROP TABLE IF EXISTS `t_location`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_location` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0空闲,1使用,2不可用', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `factory_id` int DEFAULT NULL COMMENT '绑定工厂id', + `warehouse_id` int DEFAULT NULL COMMENT '缓存区id,关联表:t_warehouse', + `location_name` varchar(256) NOT NULL COMMENT '货位名称', + `location_name_alias` varchar(256) DEFAULT NULL COMMENT '库位别名', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='库位表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_login_log` +-- + +DROP TABLE IF EXISTS `t_login_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_login_log` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `session_id` varchar(64) NOT NULL COMMENT '会话ID', + `account_id` bigint NOT NULL COMMENT '账号ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `corp_id` bigint DEFAULT NULL COMMENT '公司ID', + `hospital_id` bigint DEFAULT NULL COMMENT '医院ID', + `org_id` bigint DEFAULT NULL COMMENT '组织ID', + `account` varchar(32) NOT NULL COMMENT '账号', + `mobile` varchar(16) DEFAULT NULL COMMENT '手机号', + `user_name` varchar(64) DEFAULT NULL COMMENT '用户名称', + `corp_name` varchar(256) DEFAULT NULL COMMENT '公司名称', + `hospital_name` varchar(256) DEFAULT NULL COMMENT '医院名称', + `org_name` varchar(128) DEFAULT NULL COMMENT '组织名称,存放平台组织或者医院科室或者公司门店', + `user_type` int NOT NULL COMMENT '用户类型:1、平台用户,2、公司用户,3、医院用户,4、患者', + `app_type` int NOT NULL COMMENT '应用类型:1、pc,2、app,3、wechat,4、miniapp', + `app_code` int DEFAULT NULL COMMENT '应用编码:暂未使用', + `login_type` int NOT NULL DEFAULT '1' COMMENT '登录类型:1、自主登录,2、漫游登录', + `logout_type` int NOT NULL DEFAULT '1' COMMENT '退出类型:1、自主退出,2、管理退出,3,超时退出', + `login_time` datetime NOT NULL COMMENT '登录时间', + `logout_time` datetime NOT NULL COMMENT '退出时间', + `device_class` varchar(32) DEFAULT NULL COMMENT '设备类型', + `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称', + `device_brand` varchar(64) DEFAULT NULL COMMENT '设备品牌', + `os` varchar(64) DEFAULT NULL COMMENT '操作系统', + `browser` varchar(64) DEFAULT NULL COMMENT '浏览器', + `country` varchar(32) DEFAULT NULL COMMENT '国家', + `province` varchar(32) DEFAULT NULL COMMENT '省份', + `city` varchar(32) DEFAULT NULL COMMENT '地市', + `county` varchar(32) DEFAULT NULL COMMENT '区县', + `address` varchar(256) DEFAULT NULL COMMENT '地址', + `lng` varchar(16) DEFAULT NULL COMMENT '精度', + `lat` varchar(16) DEFAULT NULL COMMENT '纬度', + `isp` varchar(32) DEFAULT NULL COMMENT '网络服务提供商', + `ip` varchar(16) DEFAULT NULL COMMENT 'IP地址', + `user_agent` varchar(1024) DEFAULT NULL COMMENT '用户代理,存放用户登录时客户端信息', + `logout_address` varchar(256) DEFAULT NULL COMMENT '退出地址', + `logout_ip` varchar(16) DEFAULT NULL COMMENT '退出IP地址', + `logout_user_agent` varchar(1024) DEFAULT NULL COMMENT '退出用户代理,存放用户退出时客户端信息', + `abnormal_status` int NOT NULL DEFAULT '0' COMMENT '异常状态:0、正常,1、省份异常,2、地市异常,3、区县异常', + `ip_to_address_status` int NOT NULL DEFAULT '0' COMMENT 'ip转地址状态:0、未获取,1、登录地址获取成功,2、退出地址获取成功,-1、登录地址获取失败,-2、退出地址获取失败', + `ip_to_address_count` int NOT NULL DEFAULT '0' COMMENT 'ip转地址次数,最多转换3次,三次失败修改状态为失败(-1、-2)', + `ip_to_address_time` datetime DEFAULT NULL COMMENT 'ip转地址时间', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='登录日志表,存放历史会话信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_login_session` +-- + +DROP TABLE IF EXISTS `t_login_session`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_login_session` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `session_id` varchar(64) NOT NULL COMMENT '会话ID', + `account_id` bigint NOT NULL COMMENT '账号ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `corp_id` bigint DEFAULT NULL COMMENT '公司ID', + `hospital_id` bigint DEFAULT NULL COMMENT '医院ID', + `org_id` bigint DEFAULT NULL COMMENT '组织ID', + `account` varchar(32) NOT NULL COMMENT '账号', + `mobile` varchar(16) DEFAULT NULL COMMENT '手机号', + `user_name` varchar(64) DEFAULT NULL COMMENT '用户名称', + `corp_name` varchar(256) DEFAULT NULL COMMENT '公司名称', + `hospital_name` varchar(256) DEFAULT NULL COMMENT '医院名称', + `org_name` varchar(128) DEFAULT NULL COMMENT '组织名称,存放平台组织或者医院科室或者公司门店', + `user_type` int NOT NULL COMMENT '用户类型:1、平台用户,2、公司用户,3、医院用户,4、患者', + `app_type` int NOT NULL COMMENT '应用类型:1、pc,2、app,3、wechat,4、miniapp', + `app_code` int DEFAULT NULL COMMENT '应用编码:暂未使用', + `login_type` int NOT NULL DEFAULT '1' COMMENT '登录类型:1、自主登录,2、漫游登录', + `login_time` datetime NOT NULL COMMENT '登录时间', + `device_class` varchar(32) DEFAULT NULL COMMENT '设备类型', + `device_name` varchar(64) DEFAULT NULL COMMENT '设备名称', + `device_brand` varchar(64) DEFAULT NULL COMMENT '设备品牌', + `os` varchar(64) DEFAULT NULL COMMENT '操作系统', + `browser` varchar(64) DEFAULT NULL COMMENT '浏览器', + `country` varchar(32) DEFAULT NULL COMMENT '国家', + `province` varchar(32) DEFAULT NULL COMMENT '省份', + `city` varchar(32) DEFAULT NULL COMMENT '地市', + `county` varchar(32) DEFAULT NULL COMMENT '区县', + `address` varchar(256) DEFAULT NULL COMMENT '地址', + `lng` varchar(16) DEFAULT NULL COMMENT '精度', + `lat` varchar(16) DEFAULT NULL COMMENT '纬度', + `isp` varchar(32) DEFAULT NULL COMMENT '网络服务提供商', + `ip` varchar(16) DEFAULT NULL COMMENT 'IP地址', + `user_agent` varchar(1024) DEFAULT NULL COMMENT '用户代理,存放用户登录时客户端信息', + `ip_to_address_status` int NOT NULL DEFAULT '0' COMMENT 'ip转地址状态:0、未获取,1、登录地址获取成功,2、退出地址获取成功,-1、登录地址获取失败,-2、退出地址获取失败', + `ip_to_address_count` int NOT NULL DEFAULT '0' COMMENT 'ip转地址次数,最多转换3次,三次失败修改状态为失败(-1、-2)', + `ip_to_address_time` datetime DEFAULT NULL COMMENT 'ip转地址时间', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='登录会话表,存放在线用户信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_order_info` +-- + +DROP TABLE IF EXISTS `t_order_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_order_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `order_source` int NOT NULL COMMENT '来源:1.APMS 2.人工输入', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行,1执行中,2执行完成', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `order_no` varchar(128) NOT NULL COMMENT '订单号,APMS系统获取', + `old_order_no` varchar(128) DEFAULT NULL COMMENT '原订单号,APMS系统获取 返单时才存在', + `iden_card_num` varchar(128) NOT NULL COMMENT '标识卡号,APMS系统获取', + `customer_no` varchar(128) DEFAULT '' COMMENT '客户编码 APMS系统获取', + `customer_name` varchar(128) DEFAULT '' COMMENT '客户名称 APMS系统获取', + `product_name` varchar(128) DEFAULT '' COMMENT '产品名称 APMS系统获取', + `product_model` varchar(128) DEFAULT '' COMMENT '产品型号 APMS系统获取', + `material_des` varchar(128) DEFAULT '' COMMENT '材料牌号 APMS系统获取', + `craft_ill` varchar(512) DEFAULT '' COMMENT '工艺要求 APMS系统获取', + `unit` varchar(32) DEFAULT '' COMMENT '单位', + `weight` float(8,2) DEFAULT '0.00' COMMENT '重量', + `quantity` float(8,2) DEFAULT '0.00' COMMENT '数量', + `add_a` float(8,2) DEFAULT '0.00' COMMENT '扩展字段1', + `add_b` float(8,2) DEFAULT '0.00' COMMENT '扩展字段2', + `orther_a` varchar(128) DEFAULT '' COMMENT '扩展字段4', + `orther_b` varchar(128) DEFAULT '' COMMENT '扩展字段5', + `order_void` int NOT NULL DEFAULT '1' COMMENT '是否作废 1:正常 0:作废', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=254 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='订单任务表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_order_info_his` +-- + +DROP TABLE IF EXISTS `t_order_info_his`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_order_info_his` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `order_source` int NOT NULL COMMENT '来源:1.APMS 2.人工输入', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行,1执行中,2执行完成', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `order_no` varchar(128) NOT NULL COMMENT '订单号,APMS系统获取', + `old_order_no` varchar(128) DEFAULT NULL COMMENT '原订单号,APMS系统获取,返工单才存在', + `iden_card_num` varchar(128) NOT NULL COMMENT '标识卡号,APMS系统获取', + `customer_no` varchar(128) DEFAULT '' COMMENT '客户编码 APMS系统获取', + `customer_name` varchar(128) DEFAULT '' COMMENT '客户名称 APMS系统获取', + `product_name` varchar(128) DEFAULT '' COMMENT '产品名称 APMS系统获取', + `product_model` varchar(128) DEFAULT '' COMMENT '产品型号 APMS系统获取', + `material_des` varchar(128) DEFAULT '' COMMENT '材料牌号 APMS系统获取', + `craft_ill` varchar(512) DEFAULT '' COMMENT '工艺要求 APMS系统获取', + `unit` varchar(32) DEFAULT '' COMMENT '单位', + `weight` float(8,2) DEFAULT '0.00' COMMENT '重量', + `quantity` float(8,2) DEFAULT '0.00' COMMENT '数量', + `order_void` int NOT NULL DEFAULT '1' COMMENT '是否作废 1:正常 ,0:作废', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=258 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='订单任务历史表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_base` +-- + +DROP TABLE IF EXISTS `t_par_base`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_base` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `par_name` varchar(128) NOT NULL COMMENT '参数名称', + `unit` varchar(128) NOT NULL COMMENT '单位,数据字典获取', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='参数基础表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_ele_value` +-- + +DROP TABLE IF EXISTS `t_par_ele_value`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_ele_value` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `kiln_id` int NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `par_id` int NOT NULL COMMENT '参数id,关联参数表:t_par_info', + `a_voltagev_value` float(8,2) DEFAULT '0.00' COMMENT 'A相电压', + `b_voltagev_value` float(8,2) DEFAULT '0.00' COMMENT 'B相电压', + `c_voltagev_value` float(8,2) DEFAULT '0.00' COMMENT 'C相电压', + `a_current_value` float(8,2) DEFAULT '0.00' COMMENT 'A相电流', + `b_current_value` float(8,2) DEFAULT '0.00' COMMENT 'B相电流', + `c_current_value` float(8,2) DEFAULT '0.00' COMMENT 'C相电流', + `total_bat` float(8,2) DEFAULT '0.00' COMMENT '总电量,单位KW', + `add_a` float(8,2) DEFAULT '0.00' COMMENT '扩展字段1', + `add_b` float(8,2) DEFAULT '0.00' COMMENT '扩展字段2', + `add_c` float(8,2) DEFAULT '0.00' COMMENT '扩展字段3', + `orther_a` varchar(128) DEFAULT '' COMMENT '扩展字段4', + `orther_b` varchar(128) DEFAULT '' COMMENT '扩展字段5', + `orther_c` varchar(128) DEFAULT '' COMMENT '扩展字段6', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='窑炉电能参数值'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_gas_value` +-- + +DROP TABLE IF EXISTS `t_par_gas_value`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_gas_value` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `kiln_id` int NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `par_id` int NOT NULL COMMENT '参数id,关联参数表:t_par_info', + `set_nit_pot_value` float(8,2) DEFAULT '0.00' COMMENT '设定氮势值', + `actual_nit_pot_value` float(8,2) DEFAULT '0.00' COMMENT '实际氮势值', + `accept_nit_pot_value` float(8,2) DEFAULT '0.00' COMMENT '接受氮势值', + `nit_flow_value` float(10,2) DEFAULT '0.00' COMMENT '氮气流量', + `ammonia_flow_value` float(10,2) DEFAULT '0.00' COMMENT '氨气流量', + `car_dioxide_flow_value` float(10,2) DEFAULT '0.00' COMMENT '二氧化碳流量', + `add_a` float(8,2) DEFAULT '0.00' COMMENT '扩展字段1', + `add_b` float(8,2) DEFAULT '0.00' COMMENT '扩展字段2', + `add_c` float(8,2) DEFAULT '0.00' COMMENT '扩展字段3', + `orther_a` varchar(128) DEFAULT '' COMMENT '扩展字段4', + `orther_b` varchar(128) DEFAULT '' COMMENT '扩展字段5', + `orther_c` varchar(128) DEFAULT '' COMMENT '扩展字段6', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='窑炉使用气检测值'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_info` +-- + +DROP TABLE IF EXISTS `t_par_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `type` int NOT NULL COMMENT '参数类型,0 表示电能,1表示用气,3温度,4转速 依次类推', + `class_a` int DEFAULT '0' COMMENT '参数分类,eg:if (type ==0 && class_a== 0) {class_a== 0表示A向电压,class_a== 1,表示B向电压,class_a== 2,表示C向电压,依次类推} ', + `class_b` int DEFAULT '0' COMMENT '参数分类,eg:if (type ==0 && class_b== 0) {class_b== 0表示A向电流,class_b== 1,表示B向电流,class_b== 2,表示C向电流,依次类推} ', + `par_name` varchar(128) NOT NULL COMMENT '参数名称', + `unit` varchar(128) NOT NULL COMMENT '单位,数据字典获取', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='参数表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_rot_speed_value` +-- + +DROP TABLE IF EXISTS `t_par_rot_speed_value`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_rot_speed_value` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `kiln_id` int NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `par_id` int NOT NULL COMMENT '参数id,关联参数表:t_par_info', + `fan_speed_a_value` float(8,2) DEFAULT '0.00' COMMENT '后室风扇1运行速度值', + `fan_speed_b_value` float(8,2) DEFAULT '0.00' COMMENT '后室风扇2运行速度值', + `oil_sti_speed_a_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌1运行速度', + `oil_sti_speed_b_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌2运行速度', + `oil_sti_speed_c_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌3运行速度', + `oil_sti_speed_d_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌4运行速度', + `oil_sti_speed_e_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌5运行速度', + `oil_sti_speed_f_value` float(8,2) DEFAULT '0.00' COMMENT '油搅拌6运行速度', + `add_a` float(8,2) DEFAULT '0.00' COMMENT '扩展字段1', + `add_b` float(8,2) DEFAULT '0.00' COMMENT '扩展字段2', + `add_c` float(8,2) DEFAULT '0.00' COMMENT '扩展字段3', + `orther_a` varchar(128) DEFAULT '' COMMENT '扩展字段4', + `orther_b` varchar(128) DEFAULT '' COMMENT '扩展字段5', + `orther_c` varchar(128) DEFAULT '' COMMENT '扩展字段6', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='窑炉运转速度'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_par_tem_value` +-- + +DROP TABLE IF EXISTS `t_par_tem_value`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_par_tem_value` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1损坏', + `kiln_id` int NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `par_id` int NOT NULL COMMENT '参数id,关联参数表:t_par_info', + `set_tem_value` float(8,2) DEFAULT '0.00' COMMENT '设定温度值', + `act_tem_value` float(8,2) DEFAULT '0.00' COMMENT '实际温度值', + `oil_tank_act_tem_value` float(8,2) DEFAULT '0.00' COMMENT '油槽实际温度', + `oil_tank_set_tem_value` float(8,2) DEFAULT '0.00' COMMENT '油槽设定温度', + `take_over_set_tem_value` float(8,2) DEFAULT '0.00' COMMENT '接受设定温度', + `take_over_oil_set_tem_value` float(8,2) DEFAULT '0.00' COMMENT '接受设定油温度', + `add_a` float(8,2) DEFAULT '0.00' COMMENT '扩展字段1', + `add_b` float(8,2) DEFAULT '0.00' COMMENT '扩展字段2', + `add_c` float(8,2) DEFAULT '0.00' COMMENT '扩展字段3', + `orther_a` varchar(128) DEFAULT '' COMMENT '扩展字段4', + `orther_b` varchar(128) DEFAULT '' COMMENT '扩展字段5', + `orther_c` varchar(128) DEFAULT '' COMMENT '扩展字段6', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='窑炉温度监控'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_product_attr` +-- + +DROP TABLE IF EXISTS `t_product_attr`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_product_attr` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `product_id` int NOT NULL COMMENT '产品id,关联表:t_product_library', + `attr_name` varchar(128) NOT NULL COMMENT '属性名', + `attr_content` varchar(255) DEFAULT '' COMMENT '属性', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='产品属性表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_product_library` +-- + +DROP TABLE IF EXISTS `t_product_library`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_product_library` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `factory_id` int DEFAULT NULL COMMENT '绑定公司id', + `product_name` varchar(256) NOT NULL COMMENT '品名', + `spec` varchar(128) DEFAULT '' COMMENT '规格', + `type` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '分类,关联数据字典,如:涤纶', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='产品池'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_resource` +-- + +DROP TABLE IF EXISTS `t_resource`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_resource` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `service_id` bigint NOT NULL COMMENT '服务ID', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', + `url` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '请求地址,可以用于前端ajax调用,后端用于做权限控制', + `method` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE', + `subsystem` int NOT NULL DEFAULT '0' COMMENT '子系统:0、common,1、platform,2、partner,3、hospital,4、patient\r\n 用于限定维护菜单资源关系,公共资源允许所有菜单关联,其他资源只允许对应的菜单关联,如:平台菜单只允许关联到公共资源和平台资源', + `category` int NOT NULL DEFAULT '0' COMMENT '分类:0、common,1、pc,2、app,3、wechat,4、miniapp', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='资源表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_run_task` +-- + +DROP TABLE IF EXISTS `t_run_task`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_run_task` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `task_id` bigint DEFAULT NULL COMMENT '任务id,关联curr_task表', + `task_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '任务编码, 查看任务编码规则', + `start_position` varchar(128) DEFAULT '' COMMENT '开始位置', + `end_position` varchar(128) DEFAULT '' COMMENT '结束位置', + `vehicle_id` bigint NOT NULL COMMENT '车辆id,关联车辆表:t_vehicle_info', + `begin_time` datetime DEFAULT NULL COMMENT '任务开始时间,车辆接收任务时间', + `end_time` datetime DEFAULT NULL COMMENT '结束时间,车辆完成送货时间', + `status` int DEFAULT '0' COMMENT '状态,0:未执行,1:正在执行,2:执行成功,3:执行失败', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='执行任务信息表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_service` +-- + +DROP TABLE IF EXISTS `t_service`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_service` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '编码', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='服务表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sms_code` +-- + +DROP TABLE IF EXISTS `t_sms_code`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sms_code` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `mobile` varchar(11) NOT NULL COMMENT '手机号码', + `code` varchar(8) NOT NULL COMMENT '验证码', + `type` int NOT NULL COMMENT '1、注册\r\n 2、找回密码\r\n 3、动态密码', + `expires_time` datetime DEFAULT NULL COMMENT '过期时间', + `used_status` int NOT NULL DEFAULT '0' COMMENT '使用状态:0、未使用,1、已使用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='短信验证码表,过期时间和使用状态可以不用'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sms_scene` +-- + +DROP TABLE IF EXISTS `t_sms_scene`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sms_scene` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `corp_id` bigint NOT NULL DEFAULT '0' COMMENT '公司ID,0为公用,默认使用0对应的短信场景', + `type` int NOT NULL DEFAULT '0' COMMENT '场景类型\r\n 0、其他/未分类\r\n 1、注册\r\n 2、找回密码\r\n 3、动态密码\r\n 4、订单\r\n 5、支付\r\n 6、报告单\r\n 9、系统通知', + `code` varchar(32) NOT NULL COMMENT '场景编码,业务系统根据该编码区分不同的业务场景', + `name` varchar(64) NOT NULL COMMENT '场景名称', + `sign_id` bigint NOT NULL COMMENT '短信签名ID', + `template_id` bigint NOT NULL COMMENT '短信模板ID', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`), + UNIQUE KEY `ak_key_sms_code` (`corp_id`,`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='短信场景表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sms_send` +-- + +DROP TABLE IF EXISTS `t_sms_send`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sms_send` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `corp_id` bigint NOT NULL DEFAULT '0' COMMENT '公司ID,0为公用,默认使用0对应的短信场景', + `scene_id` bigint NOT NULL COMMENT '短信场景ID', + `template_code` varchar(32) NOT NULL COMMENT '模板编号,第三方模板编码,如阿里云短信模板code', + `type` int NOT NULL COMMENT '短信类型\r\n 0、其他/未分类\r\n 1、注册\r\n 2、找回密码\r\n 3、动态密码\r\n 4、订单\r\n 5、支付\r\n 6、报告单\r\n 9、系统通知', + `mobile` varchar(1024) NOT NULL COMMENT '手机号码,多个号码用户英文逗号(,)分隔', + `content` varchar(1024) NOT NULL COMMENT '短信内容', + `relation_id` varchar(48) DEFAULT NULL COMMENT '关联ID,如:用户ID、订单ID等', + `sid` varchar(48) DEFAULT NULL COMMENT '短信接口测ID', + `send` int DEFAULT NULL COMMENT '发送条数', + `result_code` varchar(64) DEFAULT NULL COMMENT '短信接口结果码', + `result_info` varchar(256) DEFAULT NULL COMMENT '短信接口结果说明', + `response` varchar(512) DEFAULT NULL COMMENT '短信接口响应消息,完整的响应包', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='短信发送表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sms_sign` +-- + +DROP TABLE IF EXISTS `t_sms_sign`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sms_sign` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `name` varchar(32) NOT NULL COMMENT '签名名称', + `apply_time` datetime DEFAULT NULL COMMENT '申请时间', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='短信签名表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sms_template` +-- + +DROP TABLE IF EXISTS `t_sms_template`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sms_template` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `type` int NOT NULL DEFAULT '2' COMMENT '模板类型:1、验证码,2、短信通知', + `code` varchar(32) NOT NULL COMMENT '模板编号,第三方模板编码,如阿里云短信模板code', + `name` varchar(128) NOT NULL COMMENT '模板名称', + `content` varchar(512) NOT NULL COMMENT '模板内容', + `description` varchar(512) DEFAULT NULL COMMENT '模板描述', + `apply_time` datetime DEFAULT NULL COMMENT '申请时间', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='短信模板表,用于定义阿里云短信模板'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_dict_data` +-- + +DROP TABLE IF EXISTS `t_sys_dict_data`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_dict_data` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `dict_type_id` bigint NOT NULL COMMENT '字典类型ID', + `type_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典类型编号', + `type_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '数据字典类型名称', + `data_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典编号', + `data_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '数据字典名称', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据字典表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_dict_type` +-- + +DROP TABLE IF EXISTS `t_sys_dict_type`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_dict_type` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `type_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据字典类型', + `type_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '类型名称', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据字典类型表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_file` +-- + +DROP TABLE IF EXISTS `t_sys_file`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_file` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `type_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件类型编号 如病例ID', + `file_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件编号', + `file_name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件名称', + `file_url` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件路径URL', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='文件表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_file_type` +-- + +DROP TABLE IF EXISTS `t_sys_file_type`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_file_type` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `type_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件类型编号', + `type_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '文件类型名称', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='文件类型表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_menu` +-- + +DROP TABLE IF EXISTS `t_sys_menu`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_menu` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `parent_id` bigint DEFAULT NULL COMMENT '父菜单ID', + `code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '菜单编码', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '菜单名称', + `icon` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '菜单图标', + `href` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '链接地址,可以是页面地址,也可以是函数事件', + `url` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '请求地址,可以用于前端ajax调用,后端用于做权限控制', + `method` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '请求类型:GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE', + `permission` varchar(256) DEFAULT NULL COMMENT '权限,可以有多个,用逗号分隔,可用于第三方权限框架扩展', + `category` int NOT NULL DEFAULT '1' COMMENT '分类:1、pc,2、app,3、wechat,4、miniapp', + `type` int NOT NULL DEFAULT '1' COMMENT '类型:1、module,2、menu,3、button', + `level` int DEFAULT '1' COMMENT '层级,从1开始', + `order_num` int DEFAULT '0' COMMENT '显示顺序', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`), + UNIQUE KEY `ak_sys_menu_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='菜单表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_menu_resource` +-- + +DROP TABLE IF EXISTS `t_sys_menu_resource`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_menu_resource` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `menu_id` bigint NOT NULL COMMENT '菜单ID', + `resource_id` bigint NOT NULL COMMENT '资源ID', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='菜单资源关系表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_org` +-- + +DROP TABLE IF EXISTS `t_sys_org`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_org` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `parent_id` bigint DEFAULT NULL COMMENT '父组织ID', + `genealogy_id` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '家谱ID,格式:/rootId/.../grandfatherId/parentId', + `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称', + `contact` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '联系人', + `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '联系电话', + `address` varchar(128) DEFAULT NULL COMMENT '联系地址', + `email` varchar(128) DEFAULT NULL COMMENT '邮箱', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统组织表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_post` +-- + +DROP TABLE IF EXISTS `t_sys_post`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_post` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `parent_id` bigint NOT NULL DEFAULT '0' COMMENT '上级岗位ID,第一个岗位的上级岗位ID填0', + `type` int NOT NULL DEFAULT '0' COMMENT '类型:0、内部岗位,1、代理商岗位', + `code` varchar(64) NOT NULL COMMENT '编码:\r\n 内部岗位:省区经理、provincial_manager,地市主管、area_manager,业务员、sale\r\n 代理商岗位:代理商、agent', + `name` varchar(128) NOT NULL COMMENT '名称', + `preset` int NOT NULL DEFAULT '0' COMMENT '预设标志:1 预设 0 非预设', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='岗位表,需根据岗位编码判断用户是否有销售、物流权限'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_role` +-- + +DROP TABLE IF EXISTS `t_sys_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色编码', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色名称', + `type` int NOT NULL DEFAULT '1' COMMENT '类型:1、平台,2、药店,3、医院', + `category` int NOT NULL DEFAULT '1' COMMENT '分类:1、pc,2、app,3、wechat,4、miniapp', + `manager_flag` int NOT NULL DEFAULT '0' COMMENT '管理角色标志:1 管理角色0 非管理角色,管理角色不允许修改角色菜单关系', + `preset` int NOT NULL DEFAULT '0' COMMENT '预设角色标志:1 预设 0 非预设', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`), + UNIQUE KEY `role_code` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_role_menu` +-- + +DROP TABLE IF EXISTS `t_sys_role_menu`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_role_menu` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `role_id` bigint NOT NULL COMMENT '角色ID', + `menu_id` bigint NOT NULL COMMENT '菜单ID', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色菜单关系表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_user` +-- + +DROP TABLE IF EXISTS `t_sys_user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_user` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `org_id` bigint NOT NULL COMMENT '组织ID', + `account` varchar(64) NOT NULL COMMENT '帐号', + `password` varchar(64) NOT NULL COMMENT '密码,存放加密后的密码,加密方式:md5(password+nonce_str),转成小写存储', + `code` varchar(32) NOT NULL COMMENT '工号', + `name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', + `sex` tinyint DEFAULT '1' COMMENT '性别:1、男性,2、女性,0、未知', + `mobile` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '系统用户手机号', + `phone` varchar(32) DEFAULT NULL COMMENT '电话号码', + `idcard` varchar(32) DEFAULT NULL COMMENT '身份证', + `birthday` date DEFAULT NULL COMMENT '生日', + `email` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '系统用户邮箱', + `portrait` varchar(256) DEFAULT NULL COMMENT '头像', + `wechat` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '微信', + `qq` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT 'QQ', + `address` varchar(256) DEFAULT NULL COMMENT '联系地址', + `nonce_str` varchar(64) NOT NULL COMMENT '密码随机串,用于加密明文密码', + `modify_password_time` datetime DEFAULT NULL COMMENT '修改密码时间', + `mobile_enabled` int NOT NULL DEFAULT '0' COMMENT '手机号码是否激活:0、未激活,1、激活,根据是否使用过短信验证码登录确认是否激活状态', + `enabled` int NOT NULL DEFAULT '1' COMMENT '启用状态:0 、停用,1、启用', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`), + UNIQUE KEY `user_mobile` (`mobile`), + KEY `ak_user_account` (`account`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统用户表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_user_post` +-- + +DROP TABLE IF EXISTS `t_sys_user_post`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_user_post` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `user_id` bigint NOT NULL COMMENT '用户ID', + `post_id` bigint NOT NULL COMMENT '岗位ID', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户岗位关系表,先限定一个用只有一种岗位'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_sys_user_role` +-- + +DROP TABLE IF EXISTS `t_sys_user_role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sys_user_role` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键,自增', + `user_id` bigint NOT NULL COMMENT '用户ID', + `role_id` bigint NOT NULL COMMENT '角色ID', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户角色关系表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_task_det_his` +-- + +DROP TABLE IF EXISTS `t_task_det_his`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_task_det_his` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行,', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `task_code` varchar(128) DEFAULT '' COMMENT '任务编码', + `task_id` bigint NOT NULL COMMENT '历史任务id,关联当前任务表:t_task_his', + `order_no` varchar(128) DEFAULT '' COMMENT '订单号', + `iden_card_num` varchar(128) NOT NULL COMMENT '标识卡号,', + `product_name` varchar(128) DEFAULT '' COMMENT '产品名称', + `material_des` varchar(128) DEFAULT '' COMMENT '材料牌号 ', + `craft_ill` varchar(512) DEFAULT '' COMMENT '工艺要求 ', + `unit` varchar(32) DEFAULT '' COMMENT '单位', + `weight` float(8,2) DEFAULT '0.00' COMMENT '重量,手动输入', + `quantity` float(8,2) DEFAULT '0.00' COMMENT '数量,手动输入', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=254 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务明细历史表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_task_his` +-- + +DROP TABLE IF EXISTS `t_task_his`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_task_his` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,每次修改记录要更新记录新增时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态: 0等待执行,1执行中,2执行完成', + `inter_code` varchar(128) NOT NULL COMMENT '内部编码,系统自动生成', + `is_auto` int DEFAULT '0' COMMENT '是否自动执行: 0手动,1自动,如果是自动任务这里要监控进出和到缓存区的调度任务', + `auto_exe_task_id` bigint DEFAULT '0' COMMENT '任务流程ID,关联流程表:t_auto_exe_task', + `kiln_id` bigint NOT NULL COMMENT '窑炉id,关联设备窑炉表:t_kiln_info', + `kiln_name` varchar(128) DEFAULT '' COMMENT '窑炉名称', + `craft_code_id` bigint DEFAULT '0' COMMENT '工艺号ID,关联工艺号表:t_craft_info', + `plc_value` int DEFAULT '0' COMMENT '工艺号对应PLC值', + `begin_time` datetime DEFAULT NULL COMMENT '开始加工时间', + `end_time` datetime DEFAULT NULL COMMENT '加工结束时间', + `is_in` int DEFAULT '0' COMMENT '进炉状态: 0准备进炉,1正在加工,2加工完成', + `run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `start_position` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '开始位置', + `target_position` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '目标位置指的是窑炉的位置', + `is_cache` int DEFAULT '0' COMMENT '是否缓存,如果当前指的窑炉正在加工,系统自动分配货物到缓存位置,\r\n 并且记录缓存库位,这是当指定窑炉加工完成后系统先判断是否当前缓存有当前等待执行的任务,然后按照先来先执行原则(等待多个任务)自动调用车辆来执行', + `cache_satatus` int DEFAULT '0' COMMENT '缓存状态状态: 0准备进入缓存区,1正在进入缓存区,2缓存完成', + `cache_run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `location_id` bigint DEFAULT '0' COMMENT '库位id,关联库位表:t_location', + `location_name` varchar(128) DEFAULT '' COMMENT '库位名称', + `is_out` int DEFAULT '0' COMMENT '出炉状态: 0准备出炉,1正在加工,2加工完成', + `out_run_task_id` bigint DEFAULT '0' COMMENT '调度任务ID,关联调度表:t_run_task', + `out_start_position` varchar(128) DEFAULT '' COMMENT '开始位置', + `out_target_position` varchar(128) DEFAULT '' COMMENT '目标位置,指缓存位置', + `task_code` varchar(100) NOT NULL DEFAULT '' COMMENT '任务编码', + `process_type` int NOT NULL COMMENT '加工类型:0 初始加工,1 复加工', + `task_type` int NOT NULL COMMENT '任务类型:0:入库到窑炉,1:入库到缓存区,2出库到 窑炉到缓存区,3缓存区出库', + `sheet_no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '生产单号 APMS生成生产单后返回', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务历史表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_task_source_log` +-- + +DROP TABLE IF EXISTS `t_task_source_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_task_source_log` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态,0:wms To wcs日期,1:wcs to wms日志', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `source` int DEFAULT '0' COMMENT '日志来源,0:APMS,1:手动,2:其它系统,依次类推', + `log_name` varchar(128) DEFAULT '' COMMENT '日志名称', + `content` varchar(1024) DEFAULT '' COMMENT '内容', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='任务来源日志信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_tray_info` +-- + +DROP TABLE IF EXISTS `t_tray_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_tray_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0:正常,1:损坏', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `tray_name` varchar(256) NOT NULL COMMENT '托盘名称', + `spec` varchar(256) DEFAULT NULL COMMENT '规格', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='托盘信息表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_vehicle_info` +-- + +DROP TABLE IF EXISTS `t_vehicle_info`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_vehicle_info` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1使用中,2损坏', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码,系统自动生成', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `factory_id` int DEFAULT NULL COMMENT '绑定工厂id', + `vehicle_name` varchar(256) NOT NULL COMMENT '车辆名称', + `vehicle_alias` varchar(256) DEFAULT '' COMMENT '车辆别名', + `en` varchar(256) DEFAULT '' COMMENT '英语名称', + `type` varchar(64) DEFAULT '' COMMENT '设备类型,存储数据字典编码', + `ip` varchar(32) DEFAULT '' COMMENT 'ip地址', + `port_number` varchar(16) DEFAULT '' COMMENT '端口号', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='RGV车辆信息'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_warehouse` +-- + +DROP TABLE IF EXISTS `t_warehouse`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_warehouse` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `create_time` datetime DEFAULT NULL COMMENT '添加时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `status` int DEFAULT '0' COMMENT '状态 0初始化,1已占用', + `inter_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '内部编码', + `code` varchar(128) DEFAULT '' COMMENT '编码', + `factory_id` int DEFAULT NULL COMMENT '绑定工厂id', + `warehouse_name` varchar(256) NOT NULL COMMENT '仓库名称', + `spec` varchar(128) DEFAULT '' COMMENT '规格', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '描述信息', + `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注', + `english_name` varchar(256) DEFAULT NULL COMMENT '英文名称', + `alias_name` varchar(256) DEFAULT NULL COMMENT '别名', + `number` int NOT NULL COMMENT '库位数量', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='缓存区表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_wcs_task` +-- + +DROP TABLE IF EXISTS `t_wcs_task`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_wcs_task` ( + `id` int NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `code` varchar(128) DEFAULT '' COMMENT '任务编码', + `iden_card_number` varchar(128) DEFAULT '' COMMENT '标识卡号', + `product_name` varchar(512) DEFAULT '' COMMENT '产品名称,有多个逗号隔开', + `material_grade` varchar(512) DEFAULT '' COMMENT '材料牌号,有多个逗号隔开', + `start_position` varchar(128) DEFAULT '' COMMENT '开始位置', + `end_position` varchar(128) DEFAULT '' COMMENT '结束位置', + `status` int DEFAULT '0' COMMENT '状态,0:未执行,1:正在执行,2:执行成功,3:执行失败', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='wcs 任务信息表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_wcs_task_log` +-- + +DROP TABLE IF EXISTS `t_wcs_task_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_wcs_task_log` ( + `id` int NOT NULL AUTO_INCREMENT, + `valid` int NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用,2停止', + `create_time` datetime DEFAULT NULL COMMENT '添加时间,入库时间', + `creator_id` int DEFAULT '0' COMMENT '创建人id', + `updater_id` int DEFAULT '0' COMMENT '更新人id', + `update_time` datetime DEFAULT NULL COMMENT '修改时间,更具修改时间来判断下次执行顺序,第一次修改时间和新增时间相同', + `version` varchar(11) DEFAULT '1' COMMENT '版本号 默认为 1', + `source` varchar(128) DEFAULT '' COMMENT '任务来源', + `receive_status` varchar(128) DEFAULT '是' COMMENT '接收状态', + `send_status` varchar(128) DEFAULT '否' COMMENT '发送状态', + `content` varchar(512) DEFAULT '' COMMENT '内容', + `code` varchar(128) DEFAULT '' COMMENT '编码 和 t_wcs_task 中的code 一直。用来对应wms传过来任务的 唯一标识', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='wcs 任务信息日志表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_wechat_template_message` +-- + +DROP TABLE IF EXISTS `t_wechat_template_message`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_wechat_template_message` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `account_id` bigint DEFAULT NULL COMMENT '账号ID', + `user_type` int NOT NULL DEFAULT '1' COMMENT '用户类型\r\n 1、平台\r\n 2、药店\r\n 3、医院\r\n 4、患者', + `user_id` bigint NOT NULL COMMENT '用户ID', + `open_id` varchar(128) NOT NULL COMMENT '微信用户ID', + `template_id` varchar(128) NOT NULL COMMENT '消息模板ID', + `title` varchar(128) NOT NULL COMMENT '标题', + `content` varchar(512) NOT NULL COMMENT '消息内容', + `url` varchar(128) NOT NULL COMMENT '链接地址', + `message_id` varchar(128) DEFAULT NULL COMMENT '消息ID', + `status` int NOT NULL DEFAULT '0' COMMENT '状态\r\n 0、未发送\r\n 1、发送中\r\n 2、已发送\r\n -1、失败', + `reserved` varchar(128) DEFAULT NULL COMMENT '预留字段', + `remark` varchar(512) DEFAULT NULL COMMENT '备注', + `valid` tinyint NOT NULL DEFAULT '1' COMMENT '删除标志,是否有效:1 可用 0不可用', + `creator` bigint DEFAULT NULL COMMENT '创建人', + `creator_name` varchar(64) DEFAULT NULL COMMENT '创建人姓名', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `updater` bigint DEFAULT NULL COMMENT '更新人', + `updater_name` varchar(64) DEFAULT NULL COMMENT '更新人姓名', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `version` int DEFAULT '0' COMMENT '版本号', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='微信模板消息表'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping routines for database 'mt_wms_qj' +-- +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-12-23 9:21:37 diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java index 89d315f..173b6e1 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2021-12-27 */ @Data @EqualsAndHashCode(callSuper = false) @@ -104,10 +104,10 @@ public class ParEleValue extends Model { private Float totalBat; /** - * 扩展字段1 + * 时间段类型。0:半小时,1:天,2:月 */ - @TableField("add_a") - private Float addA; + @TableField("date_type") + private Integer dateType; /** * 扩展字段2 @@ -166,7 +166,7 @@ public class ParEleValue extends Model { public static final String TOTAL_BAT = "total_bat"; - public static final String ADD_A = "add_a"; + public static final String DATE_TYPE = "date_type"; public static final String ADD_B = "add_b"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java index 91720d9..9f2ff8d 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2021-12-27 */ public interface ParEleValueMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml index 9016bf5..b49df70 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml @@ -17,7 +17,7 @@ - + @@ -27,7 +27,7 @@ - id, create_time, inter_code, status, kiln_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, add_a, add_b, add_c, orther_a, orther_b, orther_c + id, create_time, inter_code, status, kiln_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, date_type, add_b, add_c, orther_a, orther_b, orther_c diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java index 10e5569..ada7c94 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2021-12-27 */ public interface ParEleValueServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java index 7f867ff..e55672d 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2021-12-27 */ @Service public class ParEleValueServiceBizImpl extends ServiceImpl implements ParEleValueServiceBiz { diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java index a2c6090..d10813d 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java @@ -12,6 +12,7 @@ import com.mt.wms.empty.params.ElectricQueryParam; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -19,12 +20,17 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.PostConstruct; import javax.validation.groups.Default; +import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * @Author: liguanghao @@ -37,6 +43,34 @@ import java.util.List; @Api(value = "电能消耗相关接口", tags = "电能消耗相关接口", hidden = false) public class ElectricController extends BaseController { + + //@PostConstruct + public void test(){ + LocalDateTime time=LocalDateTime.of(2021, 3, 31, 0, 0, 0); + Float f=29000F; + + LocalDate timeDate=time.toLocalDate(); + LocalDateTime timeEnd = LocalDateTime.of(timeDate, LocalTime.MAX).minus(5,ChronoUnit.SECONDS); + for (int i = 0; i < 10; i++) { + + ParEleValue parEleValue=new ParEleValue(); + parEleValue.setDateType(2); + parEleValue.setParId(1); + parEleValue.setKilnId(1); + parEleValue.setTotalBat(Float.valueOf(String.valueOf(f+(Math.random()*24000)))); + parEleValue.setCreateTime(timeEnd); + timeEnd=timeEnd.plus(1,ChronoUnit.MONTHS); + f=parEleValue.getTotalBat(); + parEleValueServiceBiz.save(parEleValue); + System.out.println(parEleValue); + } + + } + + public void test1(){ + + } + @Autowired private ParEleValueServiceBiz parEleValueServiceBiz; @@ -44,10 +78,7 @@ public class ElectricController extends BaseController { @ApiOperation(value = "根据窑炉id获取电能消耗情况") private R list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) { Long kiln = electricQueryParam.getKilnId(); - //窑炉id为0代表全部 - if (kiln==0){ - - }else { + //窑炉id为0代表全部,存储的时候计算全部 JSONObject jsonObject=new JSONObject(); //指定时间节点 LocalDate timeDate = electricQueryParam.getTime().toLocalDate(); @@ -71,12 +102,13 @@ public class ElectricController extends BaseController { List yesterdayEleValueList = parEleValueServiceBiz.list(new QueryWrapper() .eq("kiln_id", kiln) .between("create_time", yesterdayStart, yesterdayEnd) + .eq("date_type",0) .orderByAsc("create_time")); Float yesterdayTotalBat= yesterdayEleValueList.get(yesterdayEleValueList.size()-1).getTotalBat()-yesterdayEleValueList.get(0).getTotalBat(); jsonObject.put("yesterdayCountEle",yesterdayTotalBat); //指定日期当天的电能消耗 - if (electricQueryParam.getDateType()==1){ + if (electricQueryParam.getDateType()==0){ List dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper() .eq("kiln_id", kiln) .between("create_time", timeStart, timeEnd) @@ -88,12 +120,90 @@ public class ElectricController extends BaseController { } jsonObject.put("dateCountEle",dateCountEle); //分时消耗量 + Map timeJsonObject=new LinkedHashMap(); for (int i = 0; i < dateEleValueList.size() - 1; ++i) { // TODO: 2021/12/16 float eleValue = dateEleValueList.get(i).getTotalBat() - dateEleValueList.get(i - 1).getTotalBat(); + int j=i+1; + if (j%2==0){ + String time=(j-1)/2+":30"; + timeJsonObject.put(time,eleValue); + }else { + String time=(j-1)/2+":00"; + timeJsonObject.put(time,eleValue); + } } + jsonObject.put("timeEle",timeJsonObject); } - } - return null; + //指定日期当周的每天电能消耗 + if(electricQueryParam.getDateType()==1){ + LocalDate monday = timeDate.with(DayOfWeek.MONDAY); + LocalDate sunday = timeDate.with(DayOfWeek.SUNDAY); + List timeWeekEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", monday, sunday.plusDays(1)) + .eq("date_type", 1) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeWeekEleValueList.size()!=0){ + dateCountEle= timeWeekEleValueList.get(timeWeekEleValueList.size()-1).getTotalBat()-timeWeekEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeWeekEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + //指定日期当月的每天电能消耗 + if(electricQueryParam.getDateType()==2){ + LocalDate firstday = LocalDate.of(timeDate.getYear(), timeDate.getMonthValue(), 1); + LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfMonth()); + List timeMonthEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", firstday, lastDay.plusDays(1)) + .eq("date_type", 1) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeMonthEleValueList.size()!=0){ + dateCountEle= timeMonthEleValueList.get(timeMonthEleValueList.size()-1).getTotalBat()-timeMonthEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeMonthEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + //指定日期当年的每月电能消耗 + if(electricQueryParam.getDateType()==2){ + LocalDate firstDay = timeDate.with(TemporalAdjusters.firstDayOfYear()); + LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfYear()); + List timeYearEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", firstDay, lastDay.plusDays(1)) + .eq("date_type", 2) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeYearEleValueList.size()!=0){ + dateCountEle= timeYearEleValueList.get(timeYearEleValueList.size()-1).getTotalBat()-timeYearEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeYearEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + return successful(jsonObject.toJSONString()); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AlarmInfoQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AlarmInfoQueryParam.java index 853688c..d92670b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AlarmInfoQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AlarmInfoQueryParam.java @@ -24,9 +24,9 @@ public class AlarmInfoQueryParam extends BasePageParam { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "设备ID", required = false) - private Long equipmentID; + private Long equipmentId; - @ApiModelProperty(value = "报警类型", required = true) + @ApiModelProperty(value = "报警类型0窑炉,1表示车辆", required = true) private Integer type; @ApiModelProperty(value = "开始时间", required = false) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AlarmInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AlarmInfoServiceImpl.java index f8d4e69..bad72a4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AlarmInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AlarmInfoServiceImpl.java @@ -33,7 +33,7 @@ public class AlarmInfoServiceImpl extends BaseService implements AlarmInfoServic QueryWrapper wrapper = new QueryWrapper<>(); wrapper.between(alarmInfoQueryParam.getStartTime() != null, AlarmInfo.CREATE_TIME, alarmInfoQueryParam.getStartTime(), alarmInfoQueryParam.getEndTime()) .eq(AlarmInfo.TYPE, alarmInfoQueryParam.getType()) - .eq(alarmInfoQueryParam.getEquipmentID() != null, AlarmInfo.EQUIPMENT_ID, alarmInfoQueryParam.getEquipmentID()) + .eq(alarmInfoQueryParam.getEquipmentId() != null, AlarmInfo.EQUIPMENT_ID, alarmInfoQueryParam.getEquipmentId()) .orderByDesc(AlarmInfo.CREATE_TIME); Page page = alarmInfoServiceBiz.page(new Page<>(alarmInfoQueryParam.getCurrent(), alarmInfoQueryParam.getSize()), wrapper); return successful(new PageVo<>(page, AlarmInfoVo.class)); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java index 0978720..ce7a873 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java @@ -3,13 +3,19 @@ package com.mt.wms.empty.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.InStockInfo; +import com.mt.wms.core.dal.entity.InStockInfoHis; +import com.mt.wms.core.dal.entity.RunTask; import com.mt.wms.core.dal.entity.VehicleInfo; +import com.mt.wms.core.dal.service.InStockInfoHisServiceBiz; import com.mt.wms.core.dal.service.InStockInfoServiceBiz; +import com.mt.wms.core.dal.service.RunTaskServiceBiz; import com.mt.wms.core.dal.service.VehicleInfoServiceBiz; +import com.mt.wms.core.dal.service.impl.InStockInfoHisServiceBizImpl; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.OutStockParam; import com.mt.wms.empty.service.OutStockService; import com.mt.wms.empty.task.AsynRunTaskService; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,11 +39,14 @@ public class OutStockServiceImpl extends BaseService implements OutStockService private AsynRunTaskService asynRunTaskService; @Resource private InStockInfoServiceBiz inStockInfoServiceBiz; + @Resource + private RunTaskServiceBiz runTaskServiceBiz; + @Override public R outTask(OutStockParam outStockParam) { // TODO: 2021/12/17 出库 - Long localtionId = outStockParam.getLocaltionId(); + Long locationId = outStockParam.getLocaltionId(); //提升台 Integer code = outStockParam.getCode(); //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 @@ -52,14 +61,22 @@ public class OutStockServiceImpl extends BaseService implements OutStockService }else { return R.failed("暂无可用车辆!请稍后重试!"); } + //生成调度任务 + RunTask runTask=new RunTask(); + runTask.setBeginTime(LocalDateTime.now()); + runTask.setVehicleId(vehicleInfoList.get(0).getId()); + // TODO: 2021/12/22 库位id对应的位置 ,提升平台对应的位置 + runTask.setStartPosition("库位位置"); + runTask.setEndPosition("提升台位置"); + setCommonField(runTask); + runTaskServiceBiz.save(runTask); //异步调用车辆 - asynRunTaskService.asynRunOutStock(); + asynRunTaskService.asynRunOutStock(runTask.getId(),locationId); //修改库位状态 InStockInfo inStockInfo = inStockInfoServiceBiz - .getOne(new QueryWrapper().eq("Location_id", localtionId)); + .getOne(new QueryWrapper().eq("Location_id", locationId)); inStockInfo.setStatus(1); inStockInfoServiceBiz.updateById(inStockInfo); return R.ok("操作成功"); - } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java index b1c3797..d06772e 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java @@ -5,9 +5,11 @@ import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.CurrTaskDet; import com.mt.wms.core.dal.entity.InStockInfo; import com.mt.wms.core.dal.entity.Location; +import com.mt.wms.core.dal.entity.OrderInfo; import com.mt.wms.core.dal.service.CurrTaskDetServiceBiz; import com.mt.wms.core.dal.service.InStockInfoServiceBiz; import com.mt.wms.core.dal.service.LocationServiceBiz; +import com.mt.wms.core.dal.service.OrderInfoServiceBiz; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.StockInfoQueryParam; @@ -36,11 +38,18 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic private LocationServiceBiz locationServiceBiz; @Resource private CurrTaskDetServiceBiz currTaskDetServiceBiz; + @Resource + private OrderInfoServiceBiz orderInfoServiceBiz; @Override public R> get(IdParam idParam) { Long taskId = inStockInfoServiceBiz.getById(idParam).getTaskId(); List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq("curr_task_id", taskId)); List currTaskDetVoList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); + for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList + ) { + String costomerName = orderInfoServiceBiz.getOne(new QueryWrapper().eq("order_no", currTaskDetVo.getOrderNo())).getCustomerName(); + currTaskDetVo.setCustomer(costomerName); + } return successful(currTaskDetVoList); } @@ -55,11 +64,13 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic //库位为空 if (location.getStatus()!=1){ stockInfoVo.setEmpty(1); - stockInfoVo.setLocaltionId(location.getId()); + stockInfoVo.setLocationId(location.getId()); + stockInfoVo.setLocationName(location.getLocationNameAlias()); }else { InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper() - .eq("localtion_id", location.getId())); + .eq("location_id", location.getId())); BeanUtils.copyProperties(inStockInfo,stockInfoVo); + stockInfoVo.setEmpty(0); } stockInfoVoList.add(stockInfoVo); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index cf3f6a8..0d33167 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -7,6 +7,7 @@ import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.IDGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,7 +33,8 @@ public class AsynRunTaskService extends BaseService { private LocationServiceBiz locationServiceBiz; @Resource private InStockInfoServiceBiz inStockInfoServiceBiz; - + @Resource + private InStockInfoHisServiceBiz inStockInfoHisServiceBiz; //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉 @Async("asyncServiceExecutor") public void asynRunTask(Long currTaskId,Long vehicleId){ @@ -84,6 +86,7 @@ public class AsynRunTaskService extends BaseService { runTask.setVehicleId(vehicleId); runTask.setBeginTime(LocalDateTime.now()); runTask.setStartPosition(currTask.getStartPosition()); + // TODO: 2021/12/28 location对应的点位 runTask.setEndPosition(location.getCode()); runTaskServiceBiz.save(runTask); //更新 location 表对应库位状态为占用 @@ -135,12 +138,108 @@ public class AsynRunTaskService extends BaseService { } //窑炉加工完成,调用车辆入库到缓存区 @Async("asyncServiceExecutor") - public void asynRunTaskForKilnToWarehouse(Long kilnId,Long vehicleId){ - + public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId){ + CurrTask currTask = currTaskServiceBiz.getById(currTaskId); + // TODO: 2021/12/28 location排序 + Location location = locationServiceBiz.list(new QueryWrapper() + .eq(Location.STATUS, 1) + .eq(Location.VALID, 1)).get(0); + currTask.setOutStartPosition(currTask.getTargetPosition()); + // TODO: 2021/12/28 location对应的点位 + currTask.setOutTargetPosition(location.getCode()); + currTaskServiceBiz.updateById(currTask); + //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 + RunTask runTask=new RunTask(); + setCommonField(runTask); + runTask.setTaskId(currTask.getId()); + runTask.setTaskCode(currTask.getTaskCode()); + runTask.setVehicleId(vehicleId); + runTask.setBeginTime(LocalDateTime.now()); + runTask.setStartPosition(currTask.getOutStartPosition()); + runTask.setEndPosition(currTask.getOutTargetPosition()); + runTaskServiceBiz.save(runTask); + //更新 location 表对应库位状态为占用 + location.setStatus(1); + location.setUpdateTime(LocalDateTime.now()); + locationServiceBiz.updateById(location); + currTask.setOutRunTaskId(runTask.getId()); + currTaskServiceBiz.updateById(currTask); + //添加一条库位详情到in_stock_info表 + InStockInfo inStockInfo=new InStockInfo(); + inStockInfo.setStatus(1); + inStockInfo.setInterCode(IDGenerator.gen("HCT", "yyyyMMddHHmm", 2, "WAREHOUSE_CODE")); + inStockInfo.setTaskId(currTask.getId()); + inStockInfo.setTaskCode(currTask.getTaskCode()); + inStockInfo.setKilnId(currTask.getKilnId()); + inStockInfo.setKilnName(currTask.getKilnName()); + inStockInfo.setLocationId(location.getId()); + inStockInfo.setLocationName(location.getLocationNameAlias()); + inStockInfo.setType(0); + setCommonField(inStockInfo); + inStockInfoServiceBiz.save(inStockInfo); + // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) + if (true){ + //更新关系表状态为完成 + runTask.setUpdateTime(LocalDateTime.now()); + runTask.setStatus(2); + runTask.setEndTime(LocalDateTime.now()); + runTaskServiceBiz.updateById(runTask); + //更新currTask表 + currTask.setIsOut(2); + currTask.setUpdateTime(LocalDateTime.now()); + currTask.setStatus(2); + currTaskServiceBiz.updateById(currTask); + //更新in_stock_info表 + inStockInfo.setStatus(2); + inStockInfo.setInTime(LocalDateTime.now()); + inStockInfoServiceBiz.updateById(inStockInfo); + }else { + runTask.setStatus(3); + runTask.setUpdateTime(LocalDateTime.now()); + runTaskServiceBiz.updateById(runTask); + logger.info("任务 "+currTask.getTaskCode()+" 车辆从窑炉到缓存区过程中失败。"); + // TODO: 2021/12/14 websocket推送到前端 + } } //出库。起点为缓存区库位,终点为提升台 @Async("asyncServiceExecutor") - public void asynRunOutStock(){ + public void asynRunOutStock(Long runTaskId,Long locationId){ + //修改调度任务状态 + RunTask runTask = runTaskServiceBiz.getById(runTaskId); + //修改缓存区状态 + InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper() + .eq("location_id", locationId)); + inStockInfo.setStatus(1); + inStockInfoServiceBiz.updateById(inStockInfo); + // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) + + if (true){ + //更新关系表状态为完成 + runTask.setUpdateTime(LocalDateTime.now()); + runTask.setStatus(2); + runTask.setEndTime(LocalDateTime.now()); + runTaskServiceBiz.updateById(runTask); + //更新in_stock_info表 + inStockInfo.setStatus(2); + inStockInfo.setInTime(LocalDateTime.now()); + inStockInfoServiceBiz.updateById(inStockInfo); + //缓存区存储历史 + InStockInfoHis inStockInfoHis=new InStockInfoHis(); + BeanUtils.copyProperties(inStockInfo,inStockInfoHis); + inStockInfoHisServiceBiz.save(inStockInfoHis); + inStockInfoServiceBiz.removeById(inStockInfo.getId()); + //更新库位状态 + Location location = locationServiceBiz.getById(locationId); + location.setStatus(0); + locationServiceBiz.updateById(location); + + }else { + runTask.setStatus(3); + runTask.setUpdateTime(LocalDateTime.now()); + runTaskServiceBiz.updateById(runTask); + logger.info("任务 "+runTask.getTaskCode()+" 车辆从缓存区到提升平台过程中失败。"); + // TODO: 2021/12/14 websocket推送到前端 + } } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index 0c74d34..a3da4b1 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -106,7 +106,40 @@ public class RunTaskUtils { * 呼叫车辆暂存缓存区,车辆调度任务结束后,(结束后再查询缓存区队列避免车辆路线冲突)查询该窑炉的缓存区队列,开始下一托盘货物调度进窑炉 * @return */ - public R runTaskForOutKiln(){ - return null; + public R runTaskForOutKiln(Long kilnId){ + //查询正在该窑炉加工的currTask + CurrTask currTask = currTaskServiceBiz.getOne(new QueryWrapper() + .eq("is_in", 1) + .eq("status", 1) + .eq("kiln_id", kilnId)); + //查询缓存区库位是否已满 + int count = locationServiceBiz.count(new QueryWrapper() + .eq(Location.STATUS, 0) + .eq(Location.VALID, 1)); + //缓存区未满 + if (count >0) { + //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() + .eq(VehicleInfo.STATUS, 0) + .eq(VehicleInfo.VALID, 1)); + if (vehicleInfoList.size()>0){ + VehicleInfo vehicleInfo = vehicleInfoList.get(0); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + }else { + return R.failed("暂无可用车辆!请稍后重试!"); + } + currTask.setIsOut(0); + currTask.setTaskType(2); + currTask.setUpdateTime(LocalDateTime.now()); + currTaskServiceBiz.updateById(currTask); + + //异步调用车辆 + asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId()); + return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); + }else { + return R.ok("当前缓存区已满,无法从加工炉出炉到缓存区。"); + } } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 0a1d395..8e3abd3 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -14,6 +14,34 @@ public class ScheduledTask { */ @Scheduled public void taskForStockToKiln(){ - //遍历窑炉状态,若加工完毕,查询空车,占用,异步处理,继续遍历下一个窑炉状态 + //遍历currTask为进行中且is_in为正在加工的窑炉状态,若加工完毕,调用runTaskForOutKiln } + + //每个小时的0分和30分执行 + @Scheduled(cron = "0 0/30 * * * ?") + //获取全部窑炉每半小时电能消耗数据,计算,存储 + public void getAllEleValue(){ + // TODO: 2021/12/27 + // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id + // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + } + + //每日23:55执行 + @Scheduled(cron = "0 55 23 * * ?") + //获取全部窑炉每天电能消耗数据,计算,存储 + public void getAllEleValueForDay(){ + // TODO: 2021/12/27 + // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id + // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + } + + //每月最后一日23:55执行 + @Scheduled(cron = "0 55 23 L * ?") + //获取全部窑炉每天电能消耗数据,计算,存储 + public void getAllEleValueForMonth(){ + // TODO: 2021/12/27 + // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id + // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskDetVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskDetVo.java index c0c7f09..638db88 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskDetVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskDetVo.java @@ -87,7 +87,7 @@ public class CurrTaskDetVo extends BaseVo implements PageVo.ConvertVo { * 单位 */ @ApiModelProperty("单位") - private Float unit; + private String unit; /** * 数量,手动输入 diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/StockInfoVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/StockInfoVo.java index c51829e..c4eae5d 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/StockInfoVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/StockInfoVo.java @@ -36,12 +36,12 @@ public class StockInfoVo extends BaseVo implements PageVo.ConvertVo{ * 库位id */ @ApiModelProperty(value = "库位id",example = "0") - private Long localtionId; + private Long locationId; /** * 库位名称 */ @ApiModelProperty(value = "库位名称",example = "0") - private String localtionName; + private String locationName; /** * 任务id */ From b2f279d9a644c946764195bffc3dc5065e283fc5 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Thu, 3 Mar 2022 23:51:07 +0800 Subject: [PATCH 02/19] lgh --- .../basic/controller/CraftInfoController.java | 89 +++ .../mt/wms/basic/params/CraftInfoParam.java | 53 ++ .../wms/basic/params/CraftInfoQueryParam.java | 31 + .../wms/basic/service/CraftInfoService.java | 73 ++ .../service/impl/CraftInfoServiceImpl.java | 97 +++ .../java/com/mt/wms/basic/vo/CraftInfoVo.java | 55 ++ .../java/com/mt/wms/core/MyGenerator.java | 2 +- .../com/mt/wms/core/dal/entity/AlarmInfo.java | 12 +- .../mt/wms/core/dal/entity/AutoExeTask.java | 26 +- .../com/mt/wms/core/dal/entity/KilnInfo.java | 12 +- .../mt/wms/core/dal/entity/ParEleValue.java | 14 +- .../mt/wms/core/dal/entity/ParGasValue.java | 54 +- .../wms/core/dal/entity/ParRotSpeedValue.java | 12 +- .../mt/wms/core/dal/entity/ParTemValue.java | 36 +- .../mt/wms/core/dal/entity/PlcNameSpace.java | 98 +++ .../com/mt/wms/core/dal/entity/PointInfo.java | 91 +++ .../wms/core/dal/mapper/AlarmInfoMapper.java | 2 +- .../wms/core/dal/mapper/AlarmInfoMapper.xml | 3 +- .../core/dal/mapper/AutoExeTaskMapper.java | 2 +- .../wms/core/dal/mapper/AutoExeTaskMapper.xml | 5 +- .../wms/core/dal/mapper/KilnInfoMapper.java | 2 +- .../core/dal/mapper/ParEleValueMapper.java | 2 +- .../wms/core/dal/mapper/ParEleValueMapper.xml | 3 +- .../core/dal/mapper/ParGasValueMapper.java | 2 +- .../wms/core/dal/mapper/ParGasValueMapper.xml | 11 +- .../dal/mapper/ParRotSpeedValueMapper.java | 2 +- .../dal/mapper/ParRotSpeedValueMapper.xml | 3 +- .../core/dal/mapper/ParTemValueMapper.java | 2 +- .../wms/core/dal/mapper/ParTemValueMapper.xml | 9 +- .../core/dal/mapper/PlcNameSpaceMapper.java | 16 + .../core/dal/mapper/PlcNameSpaceMapper.xml | 22 + .../wms/core/dal/mapper/PointInfoMapper.java | 16 + .../wms/core/dal/mapper/PointInfoMapper.xml | 21 + .../core/dal/service/AlarmInfoServiceBiz.java | 2 +- .../dal/service/AutoExeTaskServiceBiz.java | 2 +- .../core/dal/service/KilnInfoServiceBiz.java | 2 +- .../dal/service/ParEleValueServiceBiz.java | 2 +- .../dal/service/ParGasValueServiceBiz.java | 2 +- .../service/ParRotSpeedValueServiceBiz.java | 2 +- .../dal/service/ParTemValueServiceBiz.java | 2 +- .../dal/service/PlcNameSpaceServiceBiz.java | 16 + .../core/dal/service/PointInfoServiceBiz.java | 16 + .../service/impl/AlarmInfoServiceBizImpl.java | 2 +- .../impl/AutoExeTaskServiceBizImpl.java | 2 +- .../service/impl/KilnInfoServiceBizImpl.java | 2 +- .../impl/ParEleValueServiceBizImpl.java | 2 +- .../impl/ParGasValueServiceBizImpl.java | 2 +- .../impl/ParRotSpeedValueServiceBizImpl.java | 2 +- .../impl/ParTemValueServiceBizImpl.java | 2 +- .../impl/PlcNameSpaceServiceBizImpl.java | 20 + .../service/impl/PointInfoServiceBizImpl.java | 20 + .../wms/core/utils/CodeGeneratorHelper.java | 24 + .../com/mt/wms/core/utils/HttpClient.java | 7 +- .../empty/controller/AutoTaskController.java | 54 ++ .../empty/controller/CurrTaskController.java | 137 +++- ...cController.java => EnergyController.java} | 52 +- .../wms/empty/params/AutoCurrTaskParam.java | 24 + .../mt/wms/empty/params/AutoTaskParam.java | 25 + .../wms/empty/params/AutoTaskQueryParam.java | 28 + .../wms/empty/params/ElectricQueryParam.java | 3 + .../mt/wms/empty/params/StepInfoParam.java | 25 + .../mt/wms/empty/params/TaskCreateParam.java | 8 +- .../mt/wms/empty/service/AutoTaskService.java | 51 ++ .../mt/wms/empty/service/CurrTaskService.java | 8 + .../service/impl/AutoTaskServiceImpl.java | 77 +++ .../service/impl/CurrTaskServiceImpl.java | 33 +- .../mt/wms/empty/task/AsynRunTaskService.java | 634 +++++++++++++++++- .../com/mt/wms/empty/task/RunTaskUtils.java | 193 ++++-- .../com/mt/wms/empty/task/ScheduledTask.java | 454 ++++++++++++- .../mt/wms/empty/task/TaskDistanceUtils.java | 87 ++- .../wms/empty/task/VehicleCollisionUtils.java | 13 +- .../java/com/mt/wms/empty/vo/AutoTaskVo.java | 236 +++++++ 6.program/wms-gateway/pom.xml | 5 + 73 files changed, 2946 insertions(+), 210 deletions(-) create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/CraftInfoController.java create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoParam.java create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoQueryParam.java create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/service/CraftInfoService.java create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java create mode 100644 6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/CraftInfoVo.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PlcNameSpace.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PointInfo.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.xml create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.xml create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PlcNameSpaceServiceBiz.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PointInfoServiceBiz.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PlcNameSpaceServiceBizImpl.java create mode 100644 6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PointInfoServiceBizImpl.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java rename 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/{ElectricController.java => EnergyController.java} (79%) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskParam.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskQueryParam.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/StepInfoParam.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/service/AutoTaskService.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AutoTaskVo.java diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/CraftInfoController.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/CraftInfoController.java new file mode 100644 index 0000000..9e58232 --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/CraftInfoController.java @@ -0,0 +1,89 @@ +package com.mt.wms.basic.controller; + +import com.mt.wms.basic.params.AlarmBaseParam; +import com.mt.wms.basic.params.AlarmBaseQueryParam; +import com.mt.wms.basic.params.CraftInfoParam; +import com.mt.wms.basic.params.CraftInfoQueryParam; +import com.mt.wms.basic.service.AlarmBaseService; +import com.mt.wms.basic.service.CraftInfoService; +import com.mt.wms.basic.vo.AlarmBaseVo; +import com.mt.wms.basic.vo.CraftInfoVo; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.IDGenerator; +import com.mt.wms.core.validator.groups.AddGroup; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.validator.groups.UpdateGroup; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2021/10/9 11:09 + * @Version 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "craftInfo") +@Slf4j +@Api(value = "工艺基础信息管理", tags = "工艺基础信息管理", hidden = false) +public class CraftInfoController extends BaseController { + + @Autowired + private CraftInfoService craftInfoService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取报警基础信息") + private R get(@Validated @RequestBody IdParam idParam) { + return craftInfoService.get(idParam); + } + + @PostMapping(value = "list") + @ApiOperation(value = "获取报警基础信息列表") + private R> list(@Validated({Default.class}) @RequestBody CraftInfoQueryParam craftInfoQueryParam) { + return craftInfoService.list(craftInfoQueryParam); + } + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页报警基础信息") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody CraftInfoQueryParam craftInfoQueryParam) { + return craftInfoService.page(craftInfoQueryParam); + } + + @PostMapping(value = "add") + @ApiOperation(value = "新增") + private R add(@Validated({AddGroup.class, Default.class}) @RequestBody CraftInfoParam craftInfoParam) { + return craftInfoService.add(craftInfoParam); + } + + @PostMapping(value = "update") + @ApiOperation(value = "更新") + private R update(@Validated({UpdateGroup.class, Default.class}) @RequestBody CraftInfoParam craftInfoParam) { + return craftInfoService.update(craftInfoParam); + } + + @PostMapping(value = "delete") + @ApiOperation(value = "删除报警基础信息") + private R delete(@Validated @RequestBody IdParam idParam) { + return craftInfoService.delete(idParam); + } + + @PostMapping(value = "codeGenerator") + @ApiOperation(value = "编码生成") + private R codeGenerator() { + return successful(IDGenerator.gen("GY", "yyyyMMddHHmm", 2, "CRAFTINFO_CODE")); + } +} diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoParam.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoParam.java new file mode 100644 index 0000000..c6478ff --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoParam.java @@ -0,0 +1,53 @@ +package com.mt.wms.basic.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.validator.groups.UpdateGroup; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; + +/** + * @Author: liguanghao + * @Date: 2022/1/25 21:34 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "工艺基础信息参数对象", description = "用于新增和更新工艺基础信息") +public class CraftInfoParam extends BaseParam { + private static final long serialVersionUID = 1L; + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键",required = false, example = "1") + @NotNull(message = "xxID不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 编码 + */ + @ApiModelProperty(value = "编码", example = "1") + private String code; + /** + * 工艺号 + */ + @ApiModelProperty(value = "工艺号", example = "1") + @NotNull(message = "工艺号不能为空") + private String craftCode; + /** + * plc值 + */ + @ApiModelProperty(value = "plc值", example = "1") + @NotNull(message = "plc值不能为空") + private Integer plcValue; + /** + * 说明 + */ + @ApiModelProperty(value = "说明", example = "1") + private String content; +} diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoQueryParam.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoQueryParam.java new file mode 100644 index 0000000..6267388 --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/CraftInfoQueryParam.java @@ -0,0 +1,31 @@ +package com.mt.wms.basic.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: liguanghao + * @Date: 2022/1/25 21:37 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "报警基础信息查询参数", description = "用于查询报警基础信息") +public class CraftInfoQueryParam extends BasePageParam { + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键",required = false, example = "1") + private Long id; + + /** + * 工艺号 + */ + @ApiModelProperty(value = "工艺号",required = false, example = "1") + private String craftCode; +} diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/CraftInfoService.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/CraftInfoService.java new file mode 100644 index 0000000..862c1f2 --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/CraftInfoService.java @@ -0,0 +1,73 @@ +package com.mt.wms.basic.service; + +import com.mt.wms.basic.params.AlarmBaseParam; +import com.mt.wms.basic.params.AlarmBaseQueryParam; +import com.mt.wms.basic.params.CraftInfoParam; +import com.mt.wms.basic.params.CraftInfoQueryParam; +import com.mt.wms.basic.vo.AlarmBaseVo; +import com.mt.wms.basic.vo.CraftInfoVo; +import com.mt.wms.core.dal.entity.CraftInfo; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; + +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2021/10/9 10:46 + * @Version 1.0 + */ +public interface CraftInfoService { + + /** + * 获取xx + * + * @param idParam 主键参数 + * @return xx + */ + R get(IdParam idParam); + + /** + * 获取xx列表 + * + * @param craftInfoQueryParam xx查询参数 + * @return xx列表 + */ + R> list(CraftInfoQueryParam craftInfoQueryParam); + + /** + * 获取xx分页列表 + * + * @param craftInfoQueryParam xx查询参数 + * @return xx分页列表 + */ + R> page(CraftInfoQueryParam craftInfoQueryParam); + + + /** + * 新增xx + * + * @param craftInfoParam xx参数 + * @return 主键 + */ + R add(CraftInfoParam craftInfoParam); + + /** + * 更新xx + * + * @param craftInfoParam xx参数 + * @return 主键 + */ + R update(CraftInfoParam craftInfoParam); + + + /** + * 删除xx + * + * @param idParam 主键参数 + * @return 主键 + */ + R delete(IdParam idParam); +} diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java new file mode 100644 index 0000000..34fb50b --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java @@ -0,0 +1,97 @@ +package com.mt.wms.basic.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.basic.params.AlarmBaseParam; +import com.mt.wms.basic.params.AlarmBaseQueryParam; +import com.mt.wms.basic.params.CraftInfoParam; +import com.mt.wms.basic.params.CraftInfoQueryParam; +import com.mt.wms.basic.service.AlarmBaseService; +import com.mt.wms.basic.service.CraftInfoService; +import com.mt.wms.basic.vo.AlarmBaseVo; +import com.mt.wms.basic.vo.CraftInfoVo; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.AlarmBase; +import com.mt.wms.core.dal.entity.CraftInfo; +import com.mt.wms.core.dal.service.AlarmBaseServiceBiz; +import com.mt.wms.core.dal.service.CraftInfoServiceBiz; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2021/10/9 10:49 + * @Version 1.0 + */ +@Service +@Transactional +public class CraftInfoServiceImpl extends BaseService implements CraftInfoService { + + @Resource + private CraftInfoServiceBiz craftInfoServiceBiz; + + @Override + public R get(IdParam idParam) { + Assert.notNull(ApiErrorCode.INVALID_PARAMETER,idParam.getId()); + CraftInfo craftInfo = craftInfoServiceBiz.getById(idParam.getId()); + CraftInfoVo craftInfoVo = CraftInfoVo.builder().build(); + BeanUtils.copyProperties(craftInfo,craftInfoVo); + return successful(craftInfoVo); + } + + @Override + public R> list(CraftInfoQueryParam craftInfoQueryParam) { + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq(CraftInfo.VALID,1); + List craftInfoList = craftInfoServiceBiz.list(wrapper); + List craftInfoVoList = com.mt.wms.core.utils.BeanUtils.copyList(craftInfoList, CraftInfoVo.class); + return successful(craftInfoVoList); + } + + @Override + public R> page(CraftInfoQueryParam craftInfoQueryParam) { + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(craftInfoQueryParam.getCraftCode()),CraftInfo.CRAFT_CODE,craftInfoQueryParam.getCraftCode()) + .orderByDesc(CraftInfo.CREATE_TIME); + Page page = craftInfoServiceBiz.page(new Page<>(craftInfoQueryParam.getCurrent(), craftInfoQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page,CraftInfoVo.class)); + } + + @Override + public R add(CraftInfoParam craftInfoParam) { + QueryWrapper wrapper=new QueryWrapper<>(); + + CraftInfo craftInfo=new CraftInfo(); + BeanUtils.copyProperties(craftInfoParam,craftInfo); + setCommonField(craftInfo); + craftInfoServiceBiz.save(craftInfo); + return successful(IdVo.builder().id(craftInfo.getId()).build()); + } + + @Override + public R update(CraftInfoParam craftInfoParam) { + CraftInfo craftInfo = craftInfoServiceBiz.getById(craftInfoParam.getId()); + CraftInfo updateCraftInfo=new CraftInfo(); + BeanUtils.copyProperties(craftInfoParam,updateCraftInfo); + setUpdateCommonField(updateCraftInfo); + craftInfoServiceBiz.updateById(updateCraftInfo); + return successful(IdVo.builder().id(updateCraftInfo.getId()).build()); + } + + @Override + public R delete(IdParam idParam) { + craftInfoServiceBiz.removeById(idParam.getId()); + return successful(IdVo.builder().id(idParam.getId()).build()); + } +} diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/CraftInfoVo.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/CraftInfoVo.java new file mode 100644 index 0000000..11d0acd --- /dev/null +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/CraftInfoVo.java @@ -0,0 +1,55 @@ +package com.mt.wms.basic.vo; + +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: liguanghao + * @Date: 2022/1/25 21:27 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "工艺信息视图对象", description = "用于查询工艺信息信息") +public class CraftInfoVo extends BaseVo implements PageVo.ConvertVo{ + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键,更新时需要填写", example = "1") + private Long id; + + /** + * 编码 + */ + @ApiModelProperty(value = "编码", example = "1") + private String code; + /** + * 工艺号 + */ + @ApiModelProperty(value = "工艺号", example = "1") + private String craftCode; + /** + * plc值 + */ + @ApiModelProperty(value = "plc值", example = "1") + private Integer plcValue; + /** + * 状态 + */ + @ApiModelProperty(value = "状态", example = "1") + private Integer status; + /** + * 说明 + */ + @ApiModelProperty(value = "说明", example = "1") + private String content; +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java index 2fcbb18..f229ea6 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java @@ -106,7 +106,7 @@ public class MyGenerator { @Test public void generateCodeWithInjectConfigForAllTable() { - generateByTablesWithInjectConfig(new String[]{"t_apms_check_result"}); + generateByTablesWithInjectConfig(new String[]{"t_auto_exe_task"}); } public static void main(String[] args) { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AlarmInfo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AlarmInfo.java index 9f99e45..2d3f6ac 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AlarmInfo.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AlarmInfo.java @@ -19,7 +19,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ @Data @EqualsAndHashCode(callSuper = false) @@ -92,7 +92,7 @@ public class AlarmInfo extends Model { * 设备id */ @TableField("equipment_id") - private Integer equipmentId; + private Long equipmentId; /** * 设备名称 @@ -130,6 +130,12 @@ public class AlarmInfo extends Model { @TableField("note") private String note; + /** + * 加工任务编码(炉子报警时记录) + */ + @TableField("task_code") + private String taskCode; + public static final String ID = "id"; @@ -165,6 +171,8 @@ public class AlarmInfo extends Model { public static final String NOTE = "note"; + public static final String TASK_CODE = "task_code"; + @Override protected Serializable pkVal() { return this.id; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java index 43f43de..d9b3a9e 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java @@ -19,7 +19,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-12-14 + * @since 2022-03-03 */ @Data @EqualsAndHashCode(callSuper = false) @@ -117,6 +117,12 @@ public class AutoExeTask extends Model { @TableField("f_equipment_id") private Long fEquipmentId; + /** + * 设备名称(炉子名称) + */ + @TableField("f_equipment_name") + private String fEquipmentName; + /** * 工艺号ID,关联工艺号表:t_craft_info */ @@ -165,6 +171,12 @@ public class AutoExeTask extends Model { @TableField("t_equipment_type_id") private Long tEquipmentTypeId; + /** + * 设备名称 + */ + @TableField("t_equipment_name") + private String tEquipmentName; + /** * 设备ID,关联设备表:t_kiln_info */ @@ -219,6 +231,12 @@ public class AutoExeTask extends Model { @TableField("th_equipment_type_id") private Long thEquipmentTypeId; + /** + * 设备名称 + */ + @TableField("th_equipment_name") + private String thEquipmentName; + /** * 设备ID,关联设备表:t_kiln_info */ @@ -292,6 +310,8 @@ public class AutoExeTask extends Model { public static final String F_EQUIPMENT_ID = "f_equipment_id"; + public static final String F_EQUIPMENT_NAME = "f_equipment_name"; + public static final String F_CRAFT_CODE_ID = "f_craft_code_id"; public static final String F_PLC_VALUE = "f_plc_value"; @@ -308,6 +328,8 @@ public class AutoExeTask extends Model { public static final String T_EQUIPMENT_TYPE_ID = "t_equipment_type_id"; + public static final String T_EQUIPMENT_NAME = "t_equipment_name"; + public static final String T_EQUIPMENT_ID = "t_equipment_id"; public static final String T_CRAFT_CODE_ID = "t_craft_code_id"; @@ -326,6 +348,8 @@ public class AutoExeTask extends Model { public static final String TH_EQUIPMENT_TYPE_ID = "th_equipment_type_id"; + public static final String TH_EQUIPMENT_NAME = "th_equipment_name"; + public static final String TH_EQUIPMENT_ID = "th_equipment_id"; public static final String TH_CRAFT_CODE_ID = "th_craft_code_id"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/KilnInfo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/KilnInfo.java index de2dc14..74c98a7 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/KilnInfo.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/KilnInfo.java @@ -19,7 +19,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ @Data @EqualsAndHashCode(callSuper = false) @@ -71,7 +71,7 @@ public class KilnInfo extends Model { private String version; /** - * 状态 0初始化,1损坏 + * 状态 0初始化,1损坏 ,2 工作中 */ @TableField("status") private Integer status; @@ -83,7 +83,7 @@ public class KilnInfo extends Model { private String interCode; /** - * 编码 + * 编码 必须与AMPS相同 */ @TableField("code") private String code; @@ -95,7 +95,7 @@ public class KilnInfo extends Model { private Integer factoryId; /** - * 窑炉名称 + * 窑炉名称 建议与AMPS相同 */ @TableField("kiln_name") private String kilnName; @@ -113,10 +113,10 @@ public class KilnInfo extends Model { private String en; /** - * 设备类型,存储数据字典编码 + * 设备类型,存储数据字典编码,修改为1:加工炉,2:回火炉,3:氮化炉,4:清洗炉 */ @TableField("type") - private String type; + private Integer type; /** * ip地址 diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java index 173b6e1..ff044d3 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParEleValue.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-12-27 + * @since 2022-03-01 */ @Data @EqualsAndHashCode(callSuper = false) @@ -53,7 +53,13 @@ public class ParEleValue extends Model { * 窑炉id,关联设备窑炉表:t_kiln_info */ @TableField("kiln_id") - private Integer kilnId; + private Long kilnId; + + /** + * 任务id + */ + @TableField("task_id") + private Long taskId; /** * 参数id,关联参数表:t_par_info @@ -104,7 +110,7 @@ public class ParEleValue extends Model { private Float totalBat; /** - * 时间段类型。0:半小时,1:天,2:月 + * 时间段类型。0:半小时,1:天,2:月 */ @TableField("date_type") private Integer dateType; @@ -150,6 +156,8 @@ public class ParEleValue extends Model { public static final String KILN_ID = "kiln_id"; + public static final String TASK_ID = "task_id"; + public static final String PAR_ID = "par_id"; public static final String A_VOLTAGEV_VALUE = "a_voltagev_value"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParGasValue.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParGasValue.java index f85d211..c377257 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParGasValue.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParGasValue.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Data @EqualsAndHashCode(callSuper = false) @@ -53,7 +53,13 @@ public class ParGasValue extends Model { * 窑炉id,关联设备窑炉表:t_kiln_info */ @TableField("kiln_id") - private Integer kilnId; + private Long kilnId; + + /** + * 任务id + */ + @TableField("task_id") + private Long taskId; /** * 参数id,关联参数表:t_par_info @@ -62,13 +68,13 @@ public class ParGasValue extends Model { private Integer parId; /** - * 设定氮势值 + * 设定氮/碳势值 */ @TableField("set_nit_pot_value") private Float setNitPotValue; /** - * 实际氮势值 + * 实际氮/碳势值 */ @TableField("actual_nit_pot_value") private Float actualNitPotValue; @@ -80,46 +86,46 @@ public class ParGasValue extends Model { private Float acceptNitPotValue; /** - * 氮气流量 + * 氮气量 */ @TableField("nit_flow_value") private Float nitFlowValue; /** - * 氨气流量 + * 氨气量 */ @TableField("ammonia_flow_value") private Float ammoniaFlowValue; /** - * 二氧化碳流量 + * 二氧化碳量 */ @TableField("car_dioxide_flow_value") private Float carDioxideFlowValue; /** - * 扩展字段1 + * 甲烷量 */ - @TableField("add_a") - private Float addA; + @TableField("methanol_flow") + private Float methanolFlow; /** - * 扩展字段2 + * 丙烷量 */ - @TableField("add_b") - private Float addB; + @TableField("propane_flow") + private Float propaneFlow; /** - * 扩展字段3 + * 氢含量 */ - @TableField("add_c") - private Float addC; + @TableField("hydrogen_content") + private Float hydrogenContent; /** - * 扩展字段4 + * 分解率 */ - @TableField("orther_a") - private String ortherA; + @TableField("decomposition_rate") + private Float decompositionRate; /** * 扩展字段5 @@ -144,6 +150,8 @@ public class ParGasValue extends Model { public static final String KILN_ID = "kiln_id"; + public static final String TASK_ID = "task_id"; + public static final String PAR_ID = "par_id"; public static final String SET_NIT_POT_VALUE = "set_nit_pot_value"; @@ -158,13 +166,13 @@ public class ParGasValue extends Model { public static final String CAR_DIOXIDE_FLOW_VALUE = "car_dioxide_flow_value"; - public static final String ADD_A = "add_a"; + public static final String METHANOL_FLOW = "methanol_flow"; - public static final String ADD_B = "add_b"; + public static final String PROPANE_FLOW = "propane_flow"; - public static final String ADD_C = "add_c"; + public static final String HYDROGEN_CONTENT = "hydrogen_content"; - public static final String ORTHER_A = "orther_a"; + public static final String DECOMPOSITION_RATE = "decomposition_rate"; public static final String ORTHER_B = "orther_b"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParRotSpeedValue.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParRotSpeedValue.java index 2de692e..5ed725a 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParRotSpeedValue.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParRotSpeedValue.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Data @EqualsAndHashCode(callSuper = false) @@ -53,7 +53,13 @@ public class ParRotSpeedValue extends Model { * 窑炉id,关联设备窑炉表:t_kiln_info */ @TableField("kiln_id") - private Integer kilnId; + private Long kilnId; + + /** + * 任务id + */ + @TableField("task_id") + private Long taskId; /** * 参数id,关联参数表:t_par_info @@ -156,6 +162,8 @@ public class ParRotSpeedValue extends Model { public static final String KILN_ID = "kiln_id"; + public static final String TASK_ID = "task_id"; + public static final String PAR_ID = "par_id"; public static final String FAN_SPEED_A_VALUE = "fan_speed_a_value"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParTemValue.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParTemValue.java index 227b20a..92fdd77 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParTemValue.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/ParTemValue.java @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Data @EqualsAndHashCode(callSuper = false) @@ -53,7 +53,13 @@ public class ParTemValue extends Model { * 窑炉id,关联设备窑炉表:t_kiln_info */ @TableField("kiln_id") - private Integer kilnId; + private Long kilnId; + + /** + * 任务id + */ + @TableField("task_id") + private Long taskId; /** * 参数id,关联参数表:t_par_info @@ -98,22 +104,22 @@ public class ParTemValue extends Model { private Float takeOverOilSetTemValue; /** - * 扩展字段1 + * 外一区温度 */ - @TableField("add_a") - private Float addA; + @TableField("outer_zone1_temp") + private Float outerZone1Temp; /** - * 扩展字段2 + * 外二区温度 */ - @TableField("add_b") - private Float addB; + @TableField("outer_zone2_temp") + private Float outerZone2Temp; /** - * 扩展字段3 + * 炉压 */ - @TableField("add_c") - private Float addC; + @TableField("furnace_pressure") + private Float furnacePressure; /** * 扩展字段4 @@ -144,6 +150,8 @@ public class ParTemValue extends Model { public static final String KILN_ID = "kiln_id"; + public static final String TASK_ID = "task_id"; + public static final String PAR_ID = "par_id"; public static final String SET_TEM_VALUE = "set_tem_value"; @@ -158,11 +166,11 @@ public class ParTemValue extends Model { public static final String TAKE_OVER_OIL_SET_TEM_VALUE = "take_over_oil_set_tem_value"; - public static final String ADD_A = "add_a"; + public static final String OUTER_ZONE1_TEMP = "outer_zone1_temp"; - public static final String ADD_B = "add_b"; + public static final String OUTER_ZONE2_TEMP = "outer_zone2_temp"; - public static final String ADD_C = "add_c"; + public static final String FURNACE_PRESSURE = "furnace_pressure"; public static final String ORTHER_A = "orther_a"; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PlcNameSpace.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PlcNameSpace.java new file mode 100644 index 0000000..7e171bb --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PlcNameSpace.java @@ -0,0 +1,98 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * PLC变量nameSpace对照表 + *

+ * + * @author mt + * @since 2022-02-28 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_plc_name_space") +public class PlcNameSpace extends Model { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableField("id") + private Long id; + + /** + * 设备类型,1:多用加工炉,2:氮化炉,3:回火炉,4:清洗机,5:rgv + */ + @TableField("eq_type") + private Integer eqType; + + /** + * 变量名称 + */ + @TableField("name") + private String name; + + /** + * 变量的含义 + */ + @TableField("note") + private String note; + + /** + * 设备id + */ + @TableField("eq_id") + private Long eqId; + + /** + * 设备名称 + */ + @TableField("eq_name") + private String eqName; + + /** + * 变量类型,0:变量,1:报警变量 + */ + @TableField("type") + private Integer type; + + /** + * 备注 + */ + @TableField("remark") + private String remark; + + + public static final String ID = "id"; + + public static final String EQ_TYPE = "eq_type"; + + public static final String NAME = "name"; + + public static final String NOTE = "note"; + + public static final String EQ_ID = "eq_id"; + + public static final String EQ_NAME = "eq_name"; + + public static final String TYPE = "type"; + + public static final String REMARK = "remark"; + + @Override + protected Serializable pkVal() { + return null; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PointInfo.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PointInfo.java new file mode 100644 index 0000000..ce91718 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/PointInfo.java @@ -0,0 +1,91 @@ +package com.mt.wms.core.dal.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import java.time.LocalDate; +import com.baomidou.mybatisplus.annotation.Version; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 点位信息表 + *

+ * + * @author mt + * @since 2022-03-02 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_point_info") +public class PointInfo extends Model { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableField("id") + private Integer id; + + /** + * 点位编码,对应plc + */ + @TableField("code") + private Long code; + + /** + * 点位对应的设备名称 + */ + @TableField("name") + private String name; + + /** + * 点位说明;关联对应表数据的code,窑炉code,库位code等等 + */ + @TableField("note") + private String note; + + /** + * 类型:1 炉子,2 液压台,3 库位 + */ + @TableField("type") + private Integer type; + + /** + * 距离原点的距离 + */ + @TableField("distance") + private Double distance; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDate createTime; + + + public static final String ID = "id"; + + public static final String CODE = "code"; + + public static final String NAME = "name"; + + public static final String NOTE = "note"; + + public static final String TYPE = "type"; + + public static final String DISTANCE = "distance"; + + public static final String CREATE_TIME = "create_time"; + + @Override + protected Serializable pkVal() { + return null; + } + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.java index efcd14a..10b3ddb 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ public interface AlarmInfoMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.xml index 583af1b..0bb44af 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AlarmInfoMapper.xml @@ -21,11 +21,12 @@ + - id, valid, create_time, creator_id, updater_id, update_time, version, status, inter_code, code, equipment_id, equipment_name, type, alarm_code, alarm_info, description, note + id, valid, create_time, creator_id, updater_id, update_time, version, status, inter_code, code, equipment_id, equipment_name, type, alarm_code, alarm_info, description, note, task_code diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java index 30b7379..5770058 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-12-14 + * @since 2022-03-03 */ public interface AutoExeTaskMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.xml index 65ed0ca..689b00e 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.xml @@ -19,6 +19,7 @@ + @@ -27,6 +28,7 @@ + @@ -36,6 +38,7 @@ + @@ -47,7 +50,7 @@ - id, valid, create_time, status, inter_code, process_flow_id, process_flow_name, process_flow_type, craft_code_id, craft_code, warehouse_id, f_task_id, f_det_task_code, f_equipment_type_id, f_equipment_id, f_craft_code_id, f_plc_value, f_in_tran_status, f_pro_status, f_out_tran_status, t_task_id, t_det_task_code, t_equipment_type_id, t_equipment_id, t_craft_code_id, t_plc_value, t_in_tran_status, t_pro_status, t_out_tran_status, th_task_id, th_det_task_code, th_equipment_type_id, th_equipment_id, th_craft_code_id, th_plc_value, th_in_tran_status, th_pro_status, th_out_tran_status, content + id, valid, create_time, status, inter_code, process_flow_id, process_flow_name, process_flow_type, craft_code_id, craft_code, warehouse_id, f_task_id, f_det_task_code, f_equipment_type_id, f_equipment_id, f_equipment_name, f_craft_code_id, f_plc_value, f_in_tran_status, f_pro_status, f_out_tran_status, t_task_id, t_det_task_code, t_equipment_type_id, t_equipment_name, t_equipment_id, t_craft_code_id, t_plc_value, t_in_tran_status, t_pro_status, t_out_tran_status, th_task_id, th_det_task_code, th_equipment_type_id, th_equipment_name, th_equipment_id, th_craft_code_id, th_plc_value, th_in_tran_status, th_pro_status, th_out_tran_status, content diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/KilnInfoMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/KilnInfoMapper.java index 12ad5da..c67d846 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/KilnInfoMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/KilnInfoMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ public interface KilnInfoMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java index 9f2ff8d..3ef60b5 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-12-27 + * @since 2022-03-01 */ public interface ParEleValueMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml index b49df70..d3287af 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParEleValueMapper.xml @@ -9,6 +9,7 @@ + @@ -27,7 +28,7 @@ - id, create_time, inter_code, status, kiln_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, date_type, add_b, add_c, orther_a, orther_b, orther_c + id, create_time, inter_code, status, kiln_id, task_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, date_type, add_b, add_c, orther_a, orther_b, orther_c diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.java index 90b0338..d28761c 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParGasValueMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.xml index 2300bb1..c3444ad 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParGasValueMapper.xml @@ -9,6 +9,7 @@ + @@ -16,17 +17,17 @@ - - - - + + + + - id, create_time, inter_code, status, kiln_id, par_id, set_nit_pot_value, actual_nit_pot_value, accept_nit_pot_value, nit_flow_value, ammonia_flow_value, car_dioxide_flow_value, add_a, add_b, add_c, orther_a, orther_b, orther_c + id, create_time, inter_code, status, kiln_id, task_id, par_id, set_nit_pot_value, actual_nit_pot_value, accept_nit_pot_value, nit_flow_value, ammonia_flow_value, car_dioxide_flow_value, methanol_flow, propane_flow, hydrogen_content, decomposition_rate, orther_b, orther_c diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.java index 459939d..0be2e6c 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParRotSpeedValueMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.xml index da49be0..f6de4ae 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParRotSpeedValueMapper.xml @@ -9,6 +9,7 @@ + @@ -28,7 +29,7 @@ - id, create_time, inter_code, status, kiln_id, par_id, fan_speed_a_value, fan_speed_b_value, oil_sti_speed_a_value, oil_sti_speed_b_value, oil_sti_speed_c_value, oil_sti_speed_d_value, oil_sti_speed_e_value, oil_sti_speed_f_value, add_a, add_b, add_c, orther_a, orther_b, orther_c + id, create_time, inter_code, status, kiln_id, task_id, par_id, fan_speed_a_value, fan_speed_b_value, oil_sti_speed_a_value, oil_sti_speed_b_value, oil_sti_speed_c_value, oil_sti_speed_d_value, oil_sti_speed_e_value, oil_sti_speed_f_value, add_a, add_b, add_c, orther_a, orther_b, orther_c diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.java index a878f79..a32b277 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParTemValueMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.xml index 5ff43f3..653b053 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.xml +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/ParTemValueMapper.xml @@ -9,6 +9,7 @@ + @@ -16,9 +17,9 @@ - - - + + + @@ -26,7 +27,7 @@ - id, create_time, inter_code, status, kiln_id, par_id, set_tem_value, act_tem_value, oil_tank_act_tem_value, oil_tank_set_tem_value, take_over_set_tem_value, take_over_oil_set_tem_value, add_a, add_b, add_c, orther_a, orther_b, orther_c + id, create_time, inter_code, status, kiln_id, task_id, par_id, set_tem_value, act_tem_value, oil_tank_act_tem_value, oil_tank_set_tem_value, take_over_set_tem_value, take_over_oil_set_tem_value, outer_zone1_temp, outer_zone2_temp, furnace_pressure, orther_a, orther_b, orther_c diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.java new file mode 100644 index 0000000..4801fec --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.PlcNameSpace; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * PLC变量nameSpace对照表 Mapper 接口 + *

+ * + * @author mt + * @since 2022-02-28 + */ +public interface PlcNameSpaceMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.xml new file mode 100644 index 0000000..4a5026e --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PlcNameSpaceMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + id, eq_type, name, note, eq_id, eq_name, type, remark + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.java new file mode 100644 index 0000000..0569c1c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.mapper; + +import com.mt.wms.core.dal.entity.PointInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 点位信息表 Mapper 接口 + *

+ * + * @author mt + * @since 2022-03-02 + */ +public interface PointInfoMapper extends BaseMapper { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.xml b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.xml new file mode 100644 index 0000000..338679c --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/PointInfoMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + id, code, name, note, type, distance, create_time + + + diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AlarmInfoServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AlarmInfoServiceBiz.java index 041b3aa..61e90ab 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AlarmInfoServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AlarmInfoServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ public interface AlarmInfoServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java index 300aeb1..b8c8da7 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-12-14 + * @since 2022-03-03 */ public interface AutoExeTaskServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/KilnInfoServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/KilnInfoServiceBiz.java index 21b0b85..ff51ddc 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/KilnInfoServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/KilnInfoServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ public interface KilnInfoServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java index ada7c94..5ad49eb 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParEleValueServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-12-27 + * @since 2022-03-01 */ public interface ParEleValueServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParGasValueServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParGasValueServiceBiz.java index 9bceed2..29226f5 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParGasValueServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParGasValueServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParGasValueServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParRotSpeedValueServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParRotSpeedValueServiceBiz.java index 0d8017f..65257d2 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParRotSpeedValueServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParRotSpeedValueServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParRotSpeedValueServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParTemValueServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParTemValueServiceBiz.java index d93f2e8..af57376 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParTemValueServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/ParTemValueServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ public interface ParTemValueServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PlcNameSpaceServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PlcNameSpaceServiceBiz.java new file mode 100644 index 0000000..5abbed7 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PlcNameSpaceServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.PlcNameSpace; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * PLC变量nameSpace对照表 服务类 + *

+ * + * @author mt + * @since 2022-02-28 + */ +public interface PlcNameSpaceServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PointInfoServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PointInfoServiceBiz.java new file mode 100644 index 0000000..b3950db --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/PointInfoServiceBiz.java @@ -0,0 +1,16 @@ +package com.mt.wms.core.dal.service; + +import com.mt.wms.core.dal.entity.PointInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 点位信息表 服务类 + *

+ * + * @author mt + * @since 2022-03-02 + */ +public interface PointInfoServiceBiz extends IService { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AlarmInfoServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AlarmInfoServiceBizImpl.java index 73f1564..269d7fa 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AlarmInfoServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AlarmInfoServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ @Service public class AlarmInfoServiceBizImpl extends ServiceImpl implements AlarmInfoServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java index c19bd7c..e6072f0 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-12-14 + * @since 2022-03-03 */ @Service public class AutoExeTaskServiceBizImpl extends ServiceImpl implements AutoExeTaskServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/KilnInfoServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/KilnInfoServiceBizImpl.java index e2e3158..23f78f5 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/KilnInfoServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/KilnInfoServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2022-02-28 */ @Service public class KilnInfoServiceBizImpl extends ServiceImpl implements KilnInfoServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java index e55672d..aa3e822 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParEleValueServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-12-27 + * @since 2022-03-01 */ @Service public class ParEleValueServiceBizImpl extends ServiceImpl implements ParEleValueServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParGasValueServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParGasValueServiceBizImpl.java index 07870cd..2baf129 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParGasValueServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParGasValueServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Service public class ParGasValueServiceBizImpl extends ServiceImpl implements ParGasValueServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParRotSpeedValueServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParRotSpeedValueServiceBizImpl.java index a8c1f10..bacce4f 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParRotSpeedValueServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParRotSpeedValueServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Service public class ParRotSpeedValueServiceBizImpl extends ServiceImpl implements ParRotSpeedValueServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParTemValueServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParTemValueServiceBizImpl.java index 80abb00..ee1b3a3 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParTemValueServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/ParTemValueServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2021-11-18 + * @since 2022-03-01 */ @Service public class ParTemValueServiceBizImpl extends ServiceImpl implements ParTemValueServiceBiz { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PlcNameSpaceServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PlcNameSpaceServiceBizImpl.java new file mode 100644 index 0000000..2f85252 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PlcNameSpaceServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.PlcNameSpace; +import com.mt.wms.core.dal.mapper.PlcNameSpaceMapper; +import com.mt.wms.core.dal.service.PlcNameSpaceServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * PLC变量nameSpace对照表 服务实现类 + *

+ * + * @author mt + * @since 2022-02-28 + */ +@Service +public class PlcNameSpaceServiceBizImpl extends ServiceImpl implements PlcNameSpaceServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PointInfoServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PointInfoServiceBizImpl.java new file mode 100644 index 0000000..753a588 --- /dev/null +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/PointInfoServiceBizImpl.java @@ -0,0 +1,20 @@ +package com.mt.wms.core.dal.service.impl; + +import com.mt.wms.core.dal.entity.PointInfo; +import com.mt.wms.core.dal.mapper.PointInfoMapper; +import com.mt.wms.core.dal.service.PointInfoServiceBiz; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 点位信息表 服务实现类 + *

+ * + * @author mt + * @since 2022-03-02 + */ +@Service +public class PointInfoServiceBizImpl extends ServiceImpl implements PointInfoServiceBiz { + +} diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java index 521cdab..30fbb06 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java @@ -27,7 +27,23 @@ public class CodeGeneratorHelper { */ public static final String ORDER_CODE = "ORDER_CODE"; + /** + * 报警编码 + */ + public static final String ALARM_CODE = "ALARM_CODE"; + /** + * 自动任务编码 + */ + public static final String AUTO_TASK_CODE = "AUTO_TASK_CODE"; + /** + * 生成自动任务编码 + * + * @return 订单编号 + */ + public static String getAutoTaskCode() { + return IDGenerator.gen("ZD", "yyyyMMdd", 6, AUTO_TASK_CODE); + } /** * 生成订单编号 * @@ -36,5 +52,13 @@ public class CodeGeneratorHelper { public static String getOrderCode() { return IDGenerator.gen("20", "yyyyMMdd", 6, ORDER_CODE); } + /** + * 生成报警编码 + * + * @return 报警编码 + */ + public static String getAlarmCode() { + return IDGenerator.gen("BJ", "yyyyMMdd", 6, ALARM_CODE); + } } diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java index 917f248..ed1b953 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.util.concurrent.TimeUnit; /** * 使用 OKhttp 请求 Api 数据 @@ -46,7 +47,11 @@ public class HttpClient { } public static String httpPost(String url, String json) throws IOException { - OkHttpClient httpClient = new OkHttpClient(); + //OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(300L, TimeUnit.SECONDS) + .writeTimeout(300, TimeUnit.SECONDS) + .readTimeout(300, TimeUnit.SECONDS) + .build(); RequestBody requestBody = RequestBody.create(JSON, json); Request request = new Request.Builder() .url(url) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java new file mode 100644 index 0000000..e566688 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java @@ -0,0 +1,54 @@ +package com.mt.wms.empty.controller; + +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.validator.groups.PageGroup; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.AutoTaskQueryParam; +import com.mt.wms.empty.service.AutoTaskService; +import com.mt.wms.empty.vo.AutoTaskVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.groups.Default; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 23:35 + * @Version 1.0 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "autoTask") +@Slf4j +@Api(value = "自动任务相关接口", tags = "自动任务相关接口", hidden = false) +public class AutoTaskController extends BaseController { + @Autowired + private AutoTaskService autoTaskService; + + @PostMapping(value = "get") + @ApiOperation(value = "获取自动任务基础信息") + private R get(@Validated @RequestBody IdParam idParam) { + return autoTaskService.get(idParam); + } + + + @PostMapping(value = "page") + @ApiOperation(value = "获取分页自动任务基础信息") + private R> page(@Validated({PageGroup.class, Default.class}) @RequestBody AutoTaskQueryParam autoTaskQueryParam) { + return autoTaskService.page(autoTaskQueryParam); + } + + private R stop(@Validated @RequestBody IdParam idParam){ + return autoTaskService.stop(idParam); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 9defeb6..a55d2de 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -1,19 +1,23 @@ package com.mt.wms.empty.controller; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.mt.wms.basic.service.KilnInfoService; import com.mt.wms.basic.vo.KilnInfoVo; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.AutoExeTask; import com.mt.wms.core.dal.entity.CurrTask; +import com.mt.wms.core.dal.service.AutoExeTaskServiceBiz; +import com.mt.wms.core.dal.service.CurrTaskServiceBiz; import com.mt.wms.core.params.BasePageParam; import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.CodeGeneratorHelper; +import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; -import com.mt.wms.empty.params.ApmsCreateProcessSheet; -import com.mt.wms.empty.params.CreateItem; -import com.mt.wms.empty.params.CurrTaskQueryParam; -import com.mt.wms.empty.params.TaskCreateParam; +import com.mt.wms.empty.params.*; import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; import com.mt.wms.empty.service.OrderInfoService; @@ -24,6 +28,8 @@ import com.mt.wms.empty.vo.CurrTaskQueryVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -31,10 +37,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Map; +import java.util.*; /** * @author xcc @@ -56,6 +62,11 @@ public class CurrTaskController extends BaseController { private ApmsController apmsControl; @Autowired private KilnInfoService kilnInfoService; + @Autowired + private CurrTaskServiceBiz currTaskServiceBiz; + @Autowired + private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @PostMapping(value = "createProcessTask") @ApiOperation(value = "订单加工-创建一个加工任务至任务队列") @@ -124,6 +135,114 @@ public class CurrTaskController extends BaseController { } } + @PostMapping(value = "createAutoTask") + @ApiOperation(value = "订单加工-创建多个个分步骤加工任务至任务队列") + public R createAutoTask(@Validated @RequestBody AutoCurrTaskParam autoCurrTaskParam){ + List detParams = autoCurrTaskParam.getDetParams(); + //自动任务循环添加多条currTask + AutoExeTask autoExeTask=new AutoExeTask(); + for (TaskCreateParam param:detParams + ) { + //验证标识卡号正确无误。 + orderInfoService.verifyTaskInfoByIdenCardNum(param.getDetParams()); + //验证炉子编码信息在apms正确无误 + R kilnInfoVoR = kilnInfoService.get(IdParam.builder().id(param.getKilnId()).build()); + String kilnCode = kilnInfoVoR.getData().getCode(); + R bm = apmsControl.getStoveCodeByWorkShopCode("BM"); + ArrayList> stoveCodes = bm.getData().getStoveCodes(); + //验证apms数据中存在这个炉子 + boolean verifyCodes = false; + ArrayList codeStr = new ArrayList<>(); + stoveCodes.forEach(kilnMap -> { + codeStr.add(kilnMap.get("code")); + }); + for (String s : codeStr) + { + if (s.equals(kilnCode)) + { + verifyCodes = true; + break; + } + } + if (!verifyCodes) + { + return failed("创建失败,APMS中验证炉号" + kilnCode + "失败!"); + } + + //通知apms创建一个生产单 + ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet(); + apmsCreateSheet.setWorkShopCode("BM"); + apmsCreateSheet.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsCreateSheet.setTechCode(param.getCraftCode()); + //fixme 暂时没有正式user,使用测试账户 + apmsCreateSheet.setStartUser("QJJP03"); + ArrayList createItems = new ArrayList<>(); + param.getDetParams().forEach(e -> { + CreateItem createItem = new CreateItem(); + createItem.setItemCode(e.getIdenCardNum()); + createItem.setQuantity(e.getQuantity().intValue()); + createItem.setWeight(e.getWeight().doubleValue()); + createItems.add(createItem); + }); + apmsCreateSheet.setStoveCode(kilnCode); + apmsCreateSheet.setItems(createItems); + R processSheet = apmsControl.createProcessSheet(apmsCreateSheet); + + if (processSheet.getData().getSuccess()) + { + //apms创建成功后写入数据库 + R mainTask = currTaskService.createProcessTask(param); + currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); + CurrTask currTask = currTaskServiceBiz.getById(mainTask.getData().getId()); + //工艺步骤中第一步 + if (param.getAutoTaskStep()==1){ + autoExeTask.setInterCode(CodeGeneratorHelper.getAutoTaskCode()); + autoExeTask.setProcessFlowType(param.getAutoTaskType()); + autoExeTask.setFTaskId(currTask.getId()); + autoExeTask.setFDetTaskCode(currTask.getTaskCode()); + autoExeTask.setFEquipmentId(currTask.getKilnId()); + autoExeTask.setFEquipmentName(currTask.getKilnName()); + autoExeTask.setFCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setFPlcValue(currTask.getPlcValue()); + setCommonField(autoExeTask); + autoExeTaskServiceBiz.save(autoExeTask); + } + if (param.getAutoTaskStep()==2){ + autoExeTask.setTTaskId(currTask.getId()); + autoExeTask.setTDetTaskCode(currTask.getTaskCode()); + autoExeTask.setTEquipmentId(currTask.getKilnId()); + autoExeTask.setTEquipmentName(currTask.getKilnName()); + autoExeTask.setTCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setTPlcValue(currTask.getPlcValue()); + setUpdateCommonField(autoExeTask); + autoExeTaskServiceBiz.updateById(autoExeTask); + } + if (param.getAutoTaskStep()==3){ + autoExeTask.setThTaskId(currTask.getId()); + autoExeTask.setThDetTaskCode(currTask.getTaskCode()); + autoExeTask.setThEquipmentId(currTask.getKilnId()); + autoExeTask.setThEquipmentName(currTask.getKilnName()); + autoExeTask.setThCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setThPlcValue(currTask.getPlcValue()); + setUpdateCommonField(autoExeTask); + autoExeTaskServiceBiz.updateById(autoExeTask); + } + String sheetNo = processSheet.getData().getSheetNo(); + //将返回的生产单号写入到主任务中。 + CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId()); + currTaskById.setSheetNo(sheetNo); + currTaskService.updateCurrTaskById(currTaskById); + //生成详细任务中的检验结果数据在apms推送生产单结果时创建 + return successful("创建成功,任务添加至等待执行队列。"); + + } + else + { + return failed("创建失败,APMS报错:" + processSheet.getData().getMsg()); + } + } + return null; + } @PostMapping(value = "mainCurrentTaskNow") @ApiOperation(value = "首页-获取当前执行中的任务") @@ -148,4 +267,10 @@ public class CurrTaskController extends BaseController { public R deleteBySheetNo(@Validated @RequestBody String sheetNo) { return currTaskService.deleteBySheetNo(sheetNo); } + @PostMapping(value = "runTask") + @ApiOperation(value = "执行任务") + public R runTask(@Validated @RequestBody Long taskId) { + //点击执行按钮会判断当前任务是否为自动任务,如果是自动任务会去自动任务查一下该自动任务的上一步是否已完成(仅非一步时) + return currTaskService.runTask(taskId); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java similarity index 79% rename from 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java rename to 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index d10813d..ad1145e 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ElectricController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -6,7 +6,13 @@ import com.google.gson.JsonObject; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; import com.mt.wms.core.dal.entity.ParEleValue; +import com.mt.wms.core.dal.entity.ParGasValue; +import com.mt.wms.core.dal.entity.ParRotSpeedValue; +import com.mt.wms.core.dal.entity.ParTemValue; import com.mt.wms.core.dal.service.ParEleValueServiceBiz; +import com.mt.wms.core.dal.service.ParGasValueServiceBiz; +import com.mt.wms.core.dal.service.ParRotSpeedValueServiceBiz; +import com.mt.wms.core.dal.service.ParTemValueServiceBiz; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.ElectricQueryParam; import io.swagger.annotations.Api; @@ -41,7 +47,7 @@ import java.util.Map; @RequestMapping(CommonConstant.API_MODULE_BASE + "electric") @Slf4j @Api(value = "电能消耗相关接口", tags = "电能消耗相关接口", hidden = false) -public class ElectricController extends BaseController { +public class EnergyController extends BaseController { //@PostConstruct @@ -56,7 +62,7 @@ public class ElectricController extends BaseController { ParEleValue parEleValue=new ParEleValue(); parEleValue.setDateType(2); parEleValue.setParId(1); - parEleValue.setKilnId(1); + parEleValue.setKilnId(1L); parEleValue.setTotalBat(Float.valueOf(String.valueOf(f+(Math.random()*24000)))); parEleValue.setCreateTime(timeEnd); timeEnd=timeEnd.plus(1,ChronoUnit.MONTHS); @@ -67,16 +73,18 @@ public class ElectricController extends BaseController { } - public void test1(){ - - } - @Autowired private ParEleValueServiceBiz parEleValueServiceBiz; + @Autowired + private ParGasValueServiceBiz parGasValueServiceBiz; + @Autowired + private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; + @Autowired + private ParTemValueServiceBiz parTemValueServiceBiz; @PostMapping(value = "eletric") - @ApiOperation(value = "根据窑炉id获取电能消耗情况") - private R list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) { + @ApiOperation(value = "根据窑炉id获取消耗情况") + public R list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) { Long kiln = electricQueryParam.getKilnId(); //窑炉id为0代表全部,存储的时候计算全部 JSONObject jsonObject=new JSONObject(); @@ -206,4 +214,32 @@ public class ElectricController extends BaseController { } return successful(jsonObject.toJSONString()); } + @PostMapping(value = "energyList") + @ApiOperation(value = "根据加工炉id获取能源消耗情况") + public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ + //传入任务号,窑炉号,查询消耗数据,返回json字符串 + //电能消耗 + List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + //氮气、甲醇、丙烷、氨气消耗量 + List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + //油搅拌转速趋势 + List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + //温度趋势(实际温度、设定温度) + List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + JSONObject jsonObject=new JSONObject(); + jsonObject.put("ele",parEleValueList); + jsonObject.put("gas",parGasValueList); + jsonObject.put("rot",parRotSpeedValueList); + jsonObject.put("tem",parTemValueList); + return R.ok(jsonObject.toJSONString()); + } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java new file mode 100644 index 0000000..6d719de --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java @@ -0,0 +1,24 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2022/2/27 22:18 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "自动currTask参数", description = "自动currTask参数") +public class AutoCurrTaskParam extends BaseParam { + @ApiModelProperty(value = "详细信息", required = true) + private List detParams; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskParam.java new file mode 100644 index 0000000..ae70657 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskParam.java @@ -0,0 +1,25 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 23:09 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "自动任务参数", description = "自动任务参数") +public class AutoTaskParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "autoTaskId", required = true) + private Long id; + +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskQueryParam.java new file mode 100644 index 0000000..c43206a --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoTaskQueryParam.java @@ -0,0 +1,28 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.base.BaseParam; +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 23:09 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "自动任务查询参数", description = "自动任务查询参数") +public class AutoTaskQueryParam extends BasePageParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "autoTaskId", required = true) + private Long id; + + @ApiModelProperty(value = "任务状态:执行中、未执行", required = true) + private Integer status; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java index c537f26..6df70ba 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java @@ -25,6 +25,9 @@ public class ElectricQueryParam extends BaseParam { @ApiModelProperty(value = "窑炉id", required = true) private Long kilnId; + @ApiModelProperty(value = "任务id", required = true) + private Long taskId; + @ApiModelProperty(value = "时间节点", required = true) private LocalDateTime time; diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/StepInfoParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/StepInfoParam.java new file mode 100644 index 0000000..65ee356 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/StepInfoParam.java @@ -0,0 +1,25 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.base.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: liguanghao + * @Date: 2022/2/27 22:23 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "工艺步骤参数", description = "工艺步骤参数") +public class StepInfoParam extends BaseParam { + @ApiModelProperty(value = "窑炉id", required = true) + private Long kilnId; + + @ApiModelProperty(value = "工艺号id", required = true) + private Long craftId; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java index 90d1fe9..6f778bb 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskCreateParam.java @@ -24,8 +24,12 @@ public class TaskCreateParam extends BaseParam { // @ApiModelProperty(value = "托盘号") // private String palletCode; -@ApiModelProperty(value = "起点(提升平台)", required = true) -private String startPosition; + @ApiModelProperty(value = "自动任务类型", required = true) + private Integer autoTaskType; + @ApiModelProperty(value = "自动任务步骤标识", required = true) + private Integer autoTaskStep; + @ApiModelProperty(value = "起点(提升平台)", required = true) + private String startPosition; @ApiModelProperty(value = "终点位置", required = true) private String targetPosition; @ApiModelProperty(value = "加工类型:0 初始加工,1 复加工", required = true) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/AutoTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/AutoTaskService.java new file mode 100644 index 0000000..0f152c2 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/AutoTaskService.java @@ -0,0 +1,51 @@ +package com.mt.wms.empty.service; + +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.AutoTaskParam; +import com.mt.wms.empty.params.AutoTaskQueryParam; +import com.mt.wms.empty.vo.AutoTaskVo; + +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 23:14 + * @Version 1.0 + */ +public interface AutoTaskService { + /** + * 获取xx + * + * @param idParam 主键参数 + * @return xx + */ + R get(IdParam idParam); + + /** + * 获取xx列表 + * + * @param autoTaskQueryParam xx查询参数 + * @return xx列表 + */ + R> list(AutoTaskQueryParam autoTaskQueryParam); + + /** + * 获取xx分页列表 + * + * @param autoTaskQueryParam xx查询参数 + * @return xx分页列表 + */ + R> page(AutoTaskQueryParam autoTaskQueryParam); + + + /** + * 终止自动任务 + * + * @param idParam xx参数 + * @return 主键 + */ + R stop(IdParam idParam); +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java index a334cad..41ac197 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java @@ -6,6 +6,7 @@ import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.AutoCurrTaskParam; import com.mt.wms.empty.params.CurrTaskQueryParam; import com.mt.wms.empty.params.TaskCreateParam; import com.mt.wms.empty.vo.CurrTaskMainQueryVo; @@ -82,4 +83,11 @@ public interface CurrTaskService { * @return 结果 */ R> currentTaskMainPage(BasePageParam param); + + /** + * 执行任务 + */ + R runTask(Long taskId); + + R createAutoTask(AutoCurrTaskParam autoCurrTaskParam); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java new file mode 100644 index 0000000..db85c4a --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java @@ -0,0 +1,77 @@ +package com.mt.wms.empty.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mt.wms.core.api.Assert; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.AutoExeTask; +import com.mt.wms.core.dal.entity.AutoExeTaskHis; +import com.mt.wms.core.dal.service.AutoExeTaskHisServiceBiz; +import com.mt.wms.core.dal.service.AutoExeTaskServiceBiz; +import com.mt.wms.core.errorcode.ApiErrorCode; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.vo.IdVo; +import com.mt.wms.core.vo.PageVo; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.AutoTaskParam; +import com.mt.wms.empty.params.AutoTaskQueryParam; +import com.mt.wms.empty.service.AutoTaskService; +import com.mt.wms.empty.vo.AutoTaskVo; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 23:18 + * @Version 1.0 + */ +@Service +@Transactional +public class AutoTaskServiceImpl extends BaseService implements AutoTaskService { + @Resource + private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @Resource + private AutoExeTaskHisServiceBiz autoExeTaskHisServiceBiz; + @Override + public R get(IdParam idParam) { + Assert.notNull(ApiErrorCode.INVALID_PARAMETER,idParam.getId()); + AutoExeTask autoExeTask=autoExeTaskServiceBiz.getById(idParam.getId()); + AutoTaskVo autoTaskVo=AutoTaskVo.builder().build(); + org.springframework.beans.BeanUtils.copyProperties(autoExeTask,autoTaskVo); + return successful(autoTaskVo); + } + + @Override + public R> list(AutoTaskQueryParam autoTaskQueryParam) { + return null; + } + + @Override + public R> page(AutoTaskQueryParam autoTaskQueryParam) { + QueryWrapper wrapper=new QueryWrapper<>(); + wrapper.eq((autoTaskQueryParam.getStatus()!=null&&("").equals(autoTaskQueryParam.getStatus())),AutoExeTask.STATUS,autoTaskQueryParam.getStatus()); + Page page = autoExeTaskServiceBiz.page(new Page<>(autoTaskQueryParam.getCurrent(), autoTaskQueryParam.getSize()), wrapper); + return successful(new PageVo<>(page,AutoTaskVo.class)); + } + + @Override + public R stop(IdParam idParam) { + AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(idParam.getId()); + //状态置为终止 + autoExeTask.setStatus(3); + autoExeTaskServiceBiz.updateById(autoExeTask); + //记录到自动任务历史表 + AutoExeTaskHis autoExeTaskHis=new AutoExeTaskHis(); + BeanUtils.copyProperties(autoExeTask,autoExeTaskHis); + autoExeTaskHisServiceBiz.save(autoExeTaskHis); + //释放后续步骤 + // TODO: 2022/3/3 + autoExeTaskServiceBiz.removeById(autoExeTask); + return null; + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index b08f638..cffaa9d 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -1,38 +1,43 @@ package com.mt.wms.empty.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mt.wms.core.api.Assert; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.*; -import com.mt.wms.core.dal.service.CraftInfoServiceBiz; -import com.mt.wms.core.dal.service.CurrTaskServiceBiz; -import com.mt.wms.core.dal.service.OrderInfoServiceBiz; +import com.mt.wms.core.dal.service.*; import com.mt.wms.core.params.BasePageParam; import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.IDGenerator; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; import com.mt.wms.empty.controller.ApmsController; import com.mt.wms.empty.enums.TaskTypeEnum; +import com.mt.wms.empty.params.AutoCurrTaskParam; import com.mt.wms.empty.params.CurrTaskQueryParam; import com.mt.wms.empty.params.TaskCreateParam; import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; import com.mt.wms.empty.service.TaskDetHisService; import com.mt.wms.empty.service.TaskHisService; +import com.mt.wms.empty.task.TaskDistanceUtils; import com.mt.wms.empty.vo.ApmsEndProcessVo; import com.mt.wms.empty.vo.CurrTaskMainQueryVo; import com.mt.wms.empty.vo.CurrTaskQueryVo; import com.mt.wms.empty.vo.CurrTaskVo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; +import java.io.IOException; +import java.util.*; /** * 服务实现类 @@ -45,6 +50,7 @@ import java.util.List; @Transactional public class CurrTaskServiceImpl extends BaseService implements CurrTaskService { + private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired CurrTaskServiceBiz currTaskServiceBiz; @@ -64,6 +70,10 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService OrderInfoServiceBiz orderInfoServiceBiz; @Autowired CraftInfoServiceBiz craftInfoServiceBiz; + @Autowired + VehicleInfoServiceBiz vehicleInfoServiceBiz; + @Autowired + TaskDistanceUtils taskDistanceUtils; @Override public CurrTaskVo getCurrTask(IdParam idParam) { @@ -132,7 +142,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Override public R deleteBySheetNo(String sheetNo) { - CurrTask byId = currTaskServiceBiz.getById(new QueryWrapper().eq(CurrTask.SHEET_NO, sheetNo)); + CurrTask byId = currTaskServiceBiz.getOne(new QueryWrapper().eq(CurrTask.SHEET_NO, sheetNo)); //如果尚未执行(状态 0) if (byId.getStatus() == 0) { @@ -185,4 +195,15 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService }); return successful(pageVo); } + + @Override + public R runTask(Long taskId) { + CurrTask currTask = currTaskServiceBiz.getById(taskId); + return null; + } + + @Override + public R createAutoTask(AutoCurrTaskParam autoCurrTaskParam) { + return null; + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 0d33167..6837aa3 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -1,19 +1,28 @@ package com.mt.wms.empty.task; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.IDGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.IOException; import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; /** * @Author: liguanghao @@ -35,10 +44,73 @@ public class AsynRunTaskService extends BaseService { private InStockInfoServiceBiz inStockInfoServiceBiz; @Resource private InStockInfoHisServiceBiz inStockInfoHisServiceBiz; + @Resource + private TaskDistanceUtils taskDistanceUtils; + @Resource + private VehicleInfoServiceBiz vehicleInfoServiceBiz; + @Resource + private PointInfoServiceBiz pointInfoServiceBiz; + @Resource + private KilnInfoServiceBiz kilnInfoServiceBiz; + @Resource + private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz; + @Resource + private ParTemValueServiceBiz parTemValueServiceBiz; + @Resource + private ParEleValueServiceBiz parEleValueServiceBiz; + @Resource + private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; + @Resource + private ParGasValueServiceBiz parGasValueServiceBiz; //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉 @Async("asyncServiceExecutor") public void asynRunTask(Long currTaskId,Long vehicleId){ CurrTask currTask = currTaskServiceBiz.getById(currTaskId); + VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); + Integer otherNowPoint=0; + if (vehicleId==1){ + // TODO: 2022/2/26 获取RGV2当前位置 + otherNowPoint=1; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + while (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + //type=1为 入 + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 39); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + } + }else { + //获取RGV1当前位置 + otherNowPoint=2; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + while (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 1); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + } + } + //新建一条执行任务的关系表存放任务执行信息 RunTask runTask=new RunTask(); runTask.setTaskId(currTask.getId()); @@ -50,9 +122,33 @@ public class AsynRunTaskService extends BaseService { runTask.setBeginTime(LocalDateTime.now()); runTaskServiceBiz.save(runTask); // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果 - + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); + Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); + Map json = new HashMap(); + // taskType 1 搬运 + json.put("taskType", 1); + json.put("sendRow", endPoint); + json.put("pickRow",startPoint); + json.put("taskNo",currTaskId); + json.put("ideNumber",1); + json.put("processNumber",currTask.getPlcValue()); + String taskJson = JSON.toJSONString(json); + String result =null; + try { + if (vehicleId==1){ + result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + } + if (vehicleId==2){ + result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + JSONObject jsonObject = JSON.parseObject(result); + int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); //执行成功,托盘进炉 - if (true){ + if (status==1){ //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setEndTime(LocalDateTime.now()); @@ -63,21 +159,104 @@ public class AsynRunTaskService extends BaseService { currTask.setRunTaskId(runTask.getId()); currTask.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); + //更新小车状态 + vehicle.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicle); + }else { + runTask.setStatus(3); + runTask.setUpdateTime(LocalDateTime.now()); + runTaskServiceBiz.updateById(runTask); + logger.info("任务 "+currTask.getTaskCode()+" 车辆从液压台台到窑炉过程中失败。"); + // TODO: 2021/12/14 websocket推送到前端,小车管理界面添加一个重置小车状态的接口。 + } + } + + // TODO: 2022/2/26 修改下面的 方法加上小车操作如上 + //窑炉可用未满的情况下,调用车辆起点为缓存区终点为窑炉 + public void asynRunTaskForStockToKiln(Long stockInfokId,Long vehicleId){ + InStockInfo inStockInfo = inStockInfoServiceBiz.getById(stockInfokId); + Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); + Long currTaskId = inStockInfo.getTaskId(); + CurrTask currTask = currTaskServiceBiz.getById(currTaskId); + Integer otherNowPoint=0; + if (vehicleId==1){ + // TODO: 2022/2/26 获取RGV2当前位置 + otherNowPoint=1; + }else { + //获取RGV1当前位置 + otherNowPoint=2; + } + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), currTask.getTargetPosition(), otherNowPoint); + while (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + } + + //新建一条执行任务的关系表存放任务执行信息 + RunTask runTask=new RunTask(); + runTask.setTaskId(currTask.getId()); + runTask.setTaskCode(currTask.getTaskCode()); + runTask.setVehicleId(vehicleId); + // TODO: 2022/2/16 起点为库位 + runTask.setStartPosition(location.getCode()); + runTask.setEndPosition(currTask.getTargetPosition()); + setCommonField(runTask); + runTask.setBeginTime(LocalDateTime.now()); + runTaskServiceBiz.save(runTask); + //修改缓存区存储情况表状态 + inStockInfo.setStatus(1); + inStockInfoServiceBiz.updateById(inStockInfo); + // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果 + + //执行成功,托盘进炉 + if (true){ + //更新调度表状态为完成 + runTask.setUpdateTime(LocalDateTime.now()); + runTask.setEndTime(LocalDateTime.now()); + runTask.setStatus(2); + runTaskServiceBiz.updateById(runTask); + //更改缓存区存储状态,添加缓存区存储历史情况记录 + inStockInfo.setStatus(2); + inStockInfoServiceBiz.updateById(inStockInfo); + InStockInfoHis inStockInfoHis=new InStockInfoHis(); + BeanUtils.copyProperties(inStockInfo,inStockInfoHis); + inStockInfoHisServiceBiz.save(inStockInfoHis); + inStockInfoServiceBiz.removeById(inStockInfo); + //更新currTask表状态 + currTask.setIsIn(1); + currTask.setRunTaskId(runTask.getId()); + currTask.setUpdateTime(LocalDateTime.now()); + currTaskServiceBiz.updateById(currTask); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到窑炉过程中失败。"); - // TODO: 2021/12/14 websocket推送到前端 + // TODO: 2021/12/14 websocket推送到前端,执行失败后车辆在中途,缓存区存储情况怎么修改? } } //窑炉已满,调用车辆起点为提升台,终点为缓存区 @Async("asyncServiceExecutor") public void asynRunTaskToWarehouse(Long currTaskId,Long vehicleId){ CurrTask currTask = currTaskServiceBiz.getById(currTaskId); - Location location = locationServiceBiz.list(new QueryWrapper() - .eq(Location.STATUS, 1) - .eq(Location.VALID, 1)).get(0); + Location location = locationServiceBiz.getById(currTask.getLocationId()); + VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); + Integer otherNowPoint=0; + if (vehicleId==1){ + // TODO: 2022/2/26 获取RGV2当前位置 + otherNowPoint=1; + }else { + //获取RGV1当前位置 + otherNowPoint=2; + } + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + while (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + } + PointInfo pointOfLocation = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask=new RunTask(); setCommonField(runTask); @@ -86,13 +265,9 @@ public class AsynRunTaskService extends BaseService { runTask.setVehicleId(vehicleId); runTask.setBeginTime(LocalDateTime.now()); runTask.setStartPosition(currTask.getStartPosition()); - // TODO: 2021/12/28 location对应的点位 runTask.setEndPosition(location.getCode()); runTaskServiceBiz.save(runTask); - //更新 location 表对应库位状态为占用 - location.setStatus(1); - location.setUpdateTime(LocalDateTime.now()); - locationServiceBiz.updateById(location); + //添加一条库位详情到in_stock_info表 InStockInfo inStockInfo=new InStockInfo(); inStockInfo.setStatus(1); @@ -106,12 +281,6 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setType(1); setCommonField(inStockInfo); inStockInfoServiceBiz.save(inStockInfo); - //修改currTask的是否缓存,库位id,库位名称 - currTask.setIsCache(1); - currTask.setCacheRunTaskId(runTask.getId()); - currTask.setLocationId(location.getId()); - currTask.setLocationName(location.getLocationNameAlias()); - currTaskServiceBiz.updateById(currTask); // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) if (true){ @@ -128,11 +297,14 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setStatus(2); inStockInfo.setInTime(LocalDateTime.now()); inStockInfoServiceBiz.updateById(inStockInfo); + //更新小车状态 + vehicle.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicle); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); - logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到缓存区过程中失败。"); + logger.info("任务 "+currTask.getTaskCode()+" 车辆从液压台到缓存区过程中失败。"); // TODO: 2021/12/14 websocket推送到前端 } } @@ -140,12 +312,28 @@ public class AsynRunTaskService extends BaseService { @Async("asyncServiceExecutor") public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId){ CurrTask currTask = currTaskServiceBiz.getById(currTaskId); + VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); + Integer otherNowPoint=0; + if (vehicleId==1){ + // TODO: 2022/2/26 获取RGV2当前位置 + otherNowPoint=1; + }else { + //获取RGV1当前位置 + otherNowPoint=2; + } + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + while (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + } // TODO: 2021/12/28 location排序 Location location = locationServiceBiz.list(new QueryWrapper() .eq(Location.STATUS, 1) .eq(Location.VALID, 1)).get(0); currTask.setOutStartPosition(currTask.getTargetPosition()); - // TODO: 2021/12/28 location对应的点位 + // location对应的点位 + //String outTargetPosition = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())).getCode(); currTask.setOutTargetPosition(location.getCode()); currTaskServiceBiz.updateById(currTask); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 @@ -193,6 +381,9 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setStatus(2); inStockInfo.setInTime(LocalDateTime.now()); inStockInfoServiceBiz.updateById(inStockInfo); + //更新小车状态 + vehicle.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicle); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -242,4 +433,409 @@ public class AsynRunTaskService extends BaseService { // TODO: 2021/12/14 websocket推送到前端 } } + //允许进炉信号为true,记录开始加工时的能源消耗数据,再写定时任务记录加工过程的消耗数据,再写一个异步方法,加工任务结束的时候记录一下各项消耗的值 + public void asynStartRecordConsume(Long currTaskId,Long kilnId){ + // TODO: 2022/2/17 + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.EQ_TYPE, 0)); + String nameSpaceNote = nameSpace.getNote(); + switch (kilnInfo.getType()){ + //加工炉 + case 1: + //实际温度 + Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //油槽实际温度 + Double actualOilTemp = readPlc(nameSpaceNote, "ActualOilTemp"); + //油槽设定温度 + Double setUpOilTemp = readPlc(nameSpaceNote,"SetUpOilTemp"); + ParTemValue parTemValue=new ParTemValue(); + parTemValue.setSetTemValue(setUpTemp.floatValue()); + parTemValue.setActTemValue(actualTemp.floatValue()); + parTemValue.setOilTankSetTemValue(setUpOilTemp.floatValue()); + parTemValue.setOilTankActTemValue(actualOilTemp.floatValue()); + parTemValue.setKilnId(kilnId); + parTemValue.setTaskId(currTaskId); + setCommonField(parTemValue); + parTemValueServiceBiz.save(parTemValue); + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue=new ParEleValue(); + parEleValue.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue.setTotalBat(electricalValue.floatValue()); + parEleValue.setKilnId(kilnId); + parEleValue.setTaskId(currTaskId); + setCommonField(parEleValue); + parEleValueServiceBiz.save(parEleValue); + //一号油搅拌转速 + Double oilStirringSpeed1 = readPlc(nameSpaceNote, "OilStirringSpeed1"); + //二号油搅拌转速 + Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2"); + ParRotSpeedValue parRotSpeedValue=new ParRotSpeedValue(); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue()); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue()); + parRotSpeedValue.setKilnId(kilnId); + parRotSpeedValue.setTaskId(currTaskId); + setCommonField(parRotSpeedValue); + parRotSpeedValueServiceBiz.save(parRotSpeedValue); + //氮气 + Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow"); + //甲烷 + Double methanolFlow = readPlc(nameSpaceNote, "MethanolFlow"); + //丙烷 + Double propaneFlow = readPlc(nameSpaceNote, "PropaneFlow"); + //氨气 + Double ammoniaFlow = readPlc(nameSpaceNote, "AmmoniaFlow"); + //实际碳势 + Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定碳势 + Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + ParGasValue parGasValue=new ParGasValue(); + parGasValue.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue.setMethanolFlow(methanolFlow.floatValue()); + parGasValue.setPropaneFlow(propaneFlow.floatValue()); + parGasValue.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue.setKilnId(kilnId); + parGasValue.setTaskId(currTaskId); + setCommonField(parGasValue); + parGasValueServiceBiz.save(parGasValue); + break; + //回火炉 + case 2: + //实际温度 + actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + ParTemValue parTemValue2=new ParTemValue(); + parTemValue2.setSetTemValue(setUpTemp.floatValue()); + parTemValue2.setActTemValue(actualTemp.floatValue()); + parTemValue2.setKilnId(kilnId); + parTemValue2.setTaskId(currTaskId); + setCommonField(parTemValue2); + parTemValueServiceBiz.save(parTemValue2); + //电度值 + electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue2=new ParEleValue(); + parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue2.setTotalBat(electricalValue.floatValue()); + parEleValue2.setKilnId(kilnId); + parEleValue2.setTaskId(currTaskId); + setCommonField(parEleValue2); + parEleValueServiceBiz.save(parEleValue2); + break; + //氮化炉 + case 3: + //实际温度 + actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //炉压 + Double furnacePressure = readPlc(nameSpaceNote, "FurnacePressure"); + //外一区温度 + Double outerZoneITemperature = readPlc(nameSpaceNote, "OuterZoneITemperature"); + //外二区温度 + Double outerZone2Temperature = readPlc(nameSpaceNote, "OuterZone2Temperature"); + ParTemValue parTemValue3=new ParTemValue(); + parTemValue3.setSetTemValue(setUpTemp.floatValue()); + parTemValue3.setActTemValue(actualTemp.floatValue()); + parTemValue3.setOuterZone1Temp(outerZoneITemperature.floatValue()); + parTemValue3.setOuterZone2Temp(outerZone2Temperature.floatValue()); + parTemValue3.setFurnacePressure(furnacePressure.floatValue()); + parTemValue3.setKilnId(kilnId); + parTemValue3.setTaskId(currTaskId); + setCommonField(parTemValue3); + parTemValueServiceBiz.save(parTemValue3); + //电度值 + electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue3=new ParEleValue(); + parEleValue3.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue3.setTotalBat(electricalValue.floatValue()); + parEleValue3.setKilnId(kilnId); + parEleValue3.setTaskId(currTaskId); + setCommonField(parEleValue3); + parEleValueServiceBiz.save(parEleValue3); + //实际氮势 + actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定氮势 + setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + //氢含量 + Double hydrogenContent = readPlc(nameSpaceNote, "HydrogenContent"); + //分解率 + Double decompositionRate = readPlc(nameSpaceNote, "DecompositionRate"); + //氨气量 + ammoniaFlow=readPlc(nameSpaceNote,"AmmoniaFlow"); + //氮气量 + nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow"); + //二氧化碳量 + Double carbonDioxideFlow = readPlc(nameSpaceNote, "CarbonDioxideFlow"); + ParGasValue parGasValue3=new ParGasValue(); + parGasValue3.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue3.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue3.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue3.setHydrogenContent(hydrogenContent.floatValue()); + parGasValue3.setDecompositionRate(decompositionRate.floatValue()); + parGasValue3.setKilnId(kilnId); + parGasValue3.setTaskId(currTaskId); + setCommonField(parGasValue3); + parGasValueServiceBiz.save(parGasValue3); + break; + //清洗炉 + case 4: + //电度值 + electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue4=new ParEleValue(); + parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue4.setTotalBat(electricalValue.floatValue()); + parEleValue4.setKilnId(kilnId); + parEleValue4.setTaskId(currTaskId); + setCommonField(parEleValue4); + parEleValueServiceBiz.save(parEleValue4); + break; + default: + logger.info("任务:"+currTaskId+"开始在"+kilnInfo.getKilnName()+"加工,能源消耗开始统计。"); + } + } + //允许出炉信号为true,记录结束加工时的能源消耗数据 + public void asynEndRecordConsume(Long currTaskId,Long kilnId){ + // TODO: 2022/2/17 + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.EQ_TYPE, 0)); + String nameSpaceNote = nameSpace.getNote(); + switch (kilnInfo.getType()){ + //加工炉 + case 1: + //实际温度 + Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //油槽实际温度 + Double actualOilTemp = readPlc(nameSpaceNote, "ActualOilTemp"); + //油槽设定温度 + Double setUpOilTemp = readPlc(nameSpaceNote,"SetUpOilTemp"); + ParTemValue parTemValue=new ParTemValue(); + parTemValue.setSetTemValue(setUpTemp.floatValue()); + parTemValue.setActTemValue(actualTemp.floatValue()); + parTemValue.setOilTankSetTemValue(setUpOilTemp.floatValue()); + parTemValue.setOilTankActTemValue(actualOilTemp.floatValue()); + parTemValue.setKilnId(kilnId); + parTemValue.setTaskId(currTaskId); + setCommonField(parTemValue); + parTemValueServiceBiz.save(parTemValue); + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue=new ParEleValue(); + parEleValue.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue.setTotalBat(electricalValue.floatValue()); + parEleValue.setKilnId(kilnId); + parEleValue.setTaskId(currTaskId); + setCommonField(parEleValue); + parEleValueServiceBiz.save(parEleValue); + //一号油搅拌转速 + Double oilStirringSpeed1 = readPlc(nameSpaceNote, "OilStirringSpeed1"); + //二号油搅拌转速 + Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2"); + ParRotSpeedValue parRotSpeedValue=new ParRotSpeedValue(); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue()); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue()); + parRotSpeedValue.setKilnId(kilnId); + parRotSpeedValue.setTaskId(currTaskId); + setCommonField(parRotSpeedValue); + parRotSpeedValueServiceBiz.save(parRotSpeedValue); + //氮气 + Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow"); + //甲烷 + Double methanolFlow = readPlc(nameSpaceNote, "MethanolFlow"); + //丙烷 + Double propaneFlow = readPlc(nameSpaceNote, "PropaneFlow"); + //氨气 + Double ammoniaFlow = readPlc(nameSpaceNote, "AmmoniaFlow"); + //实际碳势 + Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定碳势 + Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + ParGasValue parGasValue=new ParGasValue(); + parGasValue.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue.setMethanolFlow(methanolFlow.floatValue()); + parGasValue.setPropaneFlow(propaneFlow.floatValue()); + parGasValue.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue.setKilnId(kilnId); + parGasValue.setTaskId(currTaskId); + setCommonField(parGasValue); + parGasValueServiceBiz.save(parGasValue); + break; + //回火炉 + case 2: + //实际温度 + actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + ParTemValue parTemValue2=new ParTemValue(); + parTemValue2.setSetTemValue(setUpTemp.floatValue()); + parTemValue2.setActTemValue(actualTemp.floatValue()); + parTemValue2.setKilnId(kilnId); + parTemValue2.setTaskId(currTaskId); + setCommonField(parTemValue2); + parTemValueServiceBiz.save(parTemValue2); + //电度值 + electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue2=new ParEleValue(); + parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue2.setTotalBat(electricalValue.floatValue()); + parEleValue2.setKilnId(kilnId); + parEleValue2.setTaskId(currTaskId); + setCommonField(parEleValue2); + parEleValueServiceBiz.save(parEleValue2); + break; + //氮化炉 + case 3: + //实际温度 + actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //炉压 + Double furnacePressure = readPlc(nameSpaceNote, "FurnacePressure"); + //外一区温度 + Double outerZoneITemperature = readPlc(nameSpaceNote, "OuterZoneITemperature"); + //外二区温度 + Double outerZone2Temperature = readPlc(nameSpaceNote, "OuterZone2Temperature"); + ParTemValue parTemValue3=new ParTemValue(); + parTemValue3.setSetTemValue(setUpTemp.floatValue()); + parTemValue3.setActTemValue(actualTemp.floatValue()); + parTemValue3.setOuterZone1Temp(outerZoneITemperature.floatValue()); + parTemValue3.setOuterZone2Temp(outerZone2Temperature.floatValue()); + parTemValue3.setFurnacePressure(furnacePressure.floatValue()); + parTemValue3.setKilnId(kilnId); + parTemValue3.setTaskId(currTaskId); + setCommonField(parTemValue3); + parTemValueServiceBiz.save(parTemValue3); + //电度值 + electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue3=new ParEleValue(); + parEleValue3.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue3.setTotalBat(electricalValue.floatValue()); + parEleValue3.setKilnId(kilnId); + parEleValue3.setTaskId(currTaskId); + setCommonField(parEleValue3); + parEleValueServiceBiz.save(parEleValue3); + //实际氮势 + actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定氮势 + setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + //氢含量 + Double hydrogenContent = readPlc(nameSpaceNote, "HydrogenContent"); + //分解率 + Double decompositionRate = readPlc(nameSpaceNote, "DecompositionRate"); + //氨气量 + ammoniaFlow=readPlc(nameSpaceNote,"AmmoniaFlow"); + //氮气量 + nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow"); + //二氧化碳量 + Double carbonDioxideFlow = readPlc(nameSpaceNote, "CarbonDioxideFlow"); + ParGasValue parGasValue3=new ParGasValue(); + parGasValue3.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue3.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue3.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue3.setHydrogenContent(hydrogenContent.floatValue()); + parGasValue3.setDecompositionRate(decompositionRate.floatValue()); + parGasValue3.setKilnId(kilnId); + parGasValue3.setTaskId(currTaskId); + setCommonField(parGasValue3); + parGasValueServiceBiz.save(parGasValue3); + break; + //清洗炉 + case 4: + //电度值 + electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue4=new ParEleValue(); + parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue4.setTotalBat(electricalValue.floatValue()); + parEleValue4.setKilnId(kilnId); + parEleValue4.setTaskId(currTaskId); + setCommonField(parEleValue4); + parEleValueServiceBiz.save(parEleValue4); + break; + default: + logger.info("任务:"+currTaskId+"开始在"+kilnInfo.getKilnName()+"加工,能源消耗开始统计。"); + } + } + /** + * 获取变量值 + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return 变量值 + */ + private Double readPlc(String nameSpace, String variableName){ + String identifier=nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier); + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("能源消耗统计:获取 "+identifier+" 的值失败"); + } + return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index a3da4b1..9e3c945 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -1,23 +1,38 @@ package com.mt.wms.empty.task; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.vo.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.IOException; import java.time.LocalDateTime; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import static org.bouncycastle.asn1.x500.style.RFC4519Style.l; /** * @Author: liguanghao * @Date: 2021/11/15 21:55 * @Version 1.0 */ +@Component @Transactional public class RunTaskUtils { + private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private CurrTaskServiceBiz currTaskServiceBiz; @Resource @@ -28,6 +43,14 @@ public class RunTaskUtils { private AsynRunTaskService asynRunTaskService; @Resource private VehicleInfoServiceBiz vehicleInfoServiceBiz; + @Resource + private TaskDistanceUtils taskDistanceUtils; + @Resource + private PointInfoServiceBiz pointInfoServiceBiz; + @Resource + private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @Resource + private KilnInfoServiceBiz kilnInfoServiceBiz; /** * 进炉加工 @@ -35,9 +58,39 @@ public class RunTaskUtils { * @return * @throws InterruptedException */ - public R runTaskForInKiln(Integer currTaskId) throws InterruptedException { + public R runTaskForInKiln(Long currTaskId) throws InterruptedException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); - //传入任务id,起始点,若终点是窑炉,获取窑炉状态 + //起点,起点和终点是液压台code、窑炉code、缓存区code + String startPosition = currTask.getStartPosition(); + PointInfo startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, startPosition)); + // 可以根据点位类型判断起点是否为液压台 + Integer startPointType = startPoint.getType(); + if (startPointType==3){ + Map yeya = new HashMap(); + //type=1为 入 + yeya.put("type", 1); + yeya.put("number", startPoint.getCode()); + String yeyaJudgeStatus = JSON.toJSONString(yeya); + //判断起点液压台是否已放货且提升到位 + String yeyaStatus=null; + try { + yeyaStatus = HttpClient.httpPost("http://localhost:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + //taskStatus==3满足条件,其他状态值说明液压台不满足开始任务的条件(无货物或者有货物但是没提升到位) + if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 3){ + return R.failed(startPoint.getName()+"号液压台不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!"); + } + } + //是否有小车在运行 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + if (vehicleInfoList.size()>0){ + //有小车在运行,提示当前有车辆在运行,请稍后 + return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); + } + // TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态 int kilnStatus = 1; //窑炉状态为不可用 @@ -46,25 +99,20 @@ public class RunTaskUtils { } //窑炉可用未满 if (kilnStatus==1){ - //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 - List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() - .eq(VehicleInfo.STATUS, 0) - .eq(VehicleInfo.VALID, 1)); - if (vehicleInfoList.size()>0){ - VehicleInfo vehicleInfo = vehicleInfoList.get(0); - vehicleInfo.setStatus(1); - vehicleInfo.setUpdateTime(LocalDateTime.now()); - vehicleInfoServiceBiz.updateById(vehicleInfo); - }else { - return R.failed("暂无可用车辆!请稍后重试!"); - } + //计算出路径最短的车辆id + Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition()); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); //更改任务状态为执行中 currTask.setStatus(1); currTask.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); //异步调用车辆 - asynRunTaskService.asynRunTask(currTask.getId(),vehicleInfoList.get(0).getId()); - return R.ok("操作成功"); + asynRunTaskService.asynRunTask(currTask.getId(),vehicleId); + return R.ok("操作成功,任务已开始执行。"); } //窑炉已满 if (kilnStatus==2){ @@ -74,26 +122,32 @@ public class RunTaskUtils { .eq(Location.VALID, 1)); //缓存区未满 if (count >0) { - //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 - List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() - .eq(VehicleInfo.STATUS, 0) - .eq(VehicleInfo.VALID, 1)); - if (vehicleInfoList.size()>0){ - VehicleInfo vehicleInfo = vehicleInfoList.get(0); - vehicleInfo.setStatus(1); - vehicleInfo.setUpdateTime(LocalDateTime.now()); - vehicleInfoServiceBiz.updateById(vehicleInfo); - }else { - return R.failed("暂无可用车辆!请稍后重试!"); - } + //分配一个缓存区库位 + Location location = locationServiceBiz.list(new QueryWrapper() + .eq(Location.STATUS, 1) + .eq(Location.VALID, 1)).get(0); + //更新 location 表对应库位状态为占用 + location.setStatus(1); + location.setUpdateTime(LocalDateTime.now()); + locationServiceBiz.updateById(location); + //通过库位code去point_info表中查出该库位对应的点 + PointInfo pointInfo = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())); + //计算出路径最短的车辆id,起点液压台,终点缓存区库位点 + Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), location.getCode()); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + //更改任务为入缓存区 currTask.setIsCache(1); currTask.setCacheSatatus(1); currTask.setUpdateTime(LocalDateTime.now()); + currTask.setLocationId(location.getId()); currTaskServiceBiz.updateById(currTask); - //异步调用车辆 - asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId()); - return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); + asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleId); + return R.ok("操作成功!当前目标窑炉已满,托盘准备加入缓存区待加工队列。"); } return R.failed("当前目标窑炉已满!缓存区已满!请稍后重试!"); } @@ -112,34 +166,87 @@ public class RunTaskUtils { .eq("is_in", 1) .eq("status", 1) .eq("kiln_id", kilnId)); + //查询是否为自动任务 + if (currTask.getIsAuto()==1) { + //查询自动任务的哪一步的设备id是该窑炉 + int firstCount = autoExeTaskServiceBiz.count(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, currTask.getId())); + if (firstCount == 1) { + //当前为自动任务第一步 + AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, currTask.getId())); + //第二部的currTaskId + Long taskId = autoExeTask.getTTaskId(); + CurrTask currTaskTwo = currTaskServiceBiz.getById(taskId); + try { + runTaskForInKiln(taskId); + logger.info("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskTwo); + // TODO: 2022/2/27 websocket推送到页面显示 + return R.ok("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskTwo); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else { + //当前加工步骤不为第一步 + int secondCount = autoExeTaskServiceBiz.count(new QueryWrapper().eq(AutoExeTask.T_TASK_ID, currTask.getId())); + if (secondCount == 2) { + //当前为自动任务第二步 + AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper().eq(AutoExeTask.T_TASK_ID, currTask.getId())); + //该自动任务的工艺类型为2,还有第三步 + if (autoExeTask.getProcessFlowType()==2){ + Long thTaskId = autoExeTask.getThTaskId(); + CurrTask currTaskThree = currTaskServiceBiz.getById(thTaskId); + try { + runTaskForInKiln(thTaskId); + logger.info("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskThree); + // TODO: 2022/2/27 websocket推送到页面显示 + return R.ok("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskThree); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + } + + } + } //查询缓存区库位是否已满 int count = locationServiceBiz.count(new QueryWrapper() .eq(Location.STATUS, 0) .eq(Location.VALID, 1)); //缓存区未满 if (count >0) { - //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 - List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() - .eq(VehicleInfo.STATUS, 0) - .eq(VehicleInfo.VALID, 1)); + List locationList = locationServiceBiz.list(new QueryWrapper() + .eq(Location.STATUS, 0) + .eq(Location.VALID, 1)); + //是否有小车在运行 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); if (vehicleInfoList.size()>0){ - VehicleInfo vehicleInfo = vehicleInfoList.get(0); - vehicleInfo.setStatus(1); - vehicleInfo.setUpdateTime(LocalDateTime.now()); - vehicleInfoServiceBiz.updateById(vehicleInfo); - }else { - return R.failed("暂无可用车辆!请稍后重试!"); + //有小车在运行,提示当前有车辆在运行,请稍后 + return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); } + //计算出路径最短的车辆id + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + //窑炉为起点 + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, kilnInfo.getCode())).getCode(); + //缓存区为终点 + Location location = locationList.get(0); + Long targetPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())).getCode(); + Long vehicleId = taskDistanceUtils.chooseVehicle(kilnInfo.getCode(), location.getCode()); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + //修改任务状态 currTask.setIsOut(0); currTask.setTaskType(2); currTask.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); - - //异步调用车辆 + // TODO: 2022/2/16 异步调用车辆 asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId()); return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); }else { return R.ok("当前缓存区已满,无法从加工炉出炉到缓存区。"); } } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 8e3abd3..8799f2b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -1,47 +1,455 @@ package com.mt.wms.empty.task; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.dal.entity.*; +import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.utils.CodeGeneratorHelper; +import com.mt.wms.core.utils.HttpClient; +import com.mt.wms.core.vo.R; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; +import javax.annotation.Resource; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @Author: liguanghao * @Date: 2021/12/13 19:54 * @Version 1.0 */ -public class ScheduledTask { +public class ScheduledTask extends BaseService { + + private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class); + + @Resource + private KilnInfoServiceBiz kilnInfoServiceBiz; + @Resource + private VehicleInfoServiceBiz vehicleInfoServiceBiz; + @Resource + private InStockInfoServiceBiz inStockInfoServiceBiz; + @Resource + private TaskDistanceUtils taskDistanceUtils; + @Resource + private LocationServiceBiz locationServiceBiz; + @Resource + private CurrTaskServiceBiz currTaskServiceBiz; + @Resource + private AsynRunTaskService asynRunTaskService; + @Resource + private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz; + @Resource + private AlarmInfoServiceBiz alarmInfoServiceBiz; + @Resource + private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; + @Resource + private ParGasValueServiceBiz parGasValueServiceBiz; + @Resource + private ParTemValueServiceBiz parTemValueServiceBiz; + @Resource + private ParEleValueServiceBiz parEleValueServiceBiz; + @Resource + private PointInfoServiceBiz pointInfoServiceBiz; + @Resource + private RunTaskUtils runTaskUtils; /** * 查询加工完成的窑炉 */ @Scheduled public void taskForStockToKiln(){ - //遍历currTask为进行中且is_in为正在加工的窑炉状态,若加工完毕,调用runTaskForOutKiln + //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); + if (vehicleInfoList.size()==2){ + //遍历currTask为进行中且is_in为正在加工的窑炉状态,若加工完毕,调用runTaskForOutKiln + List currTaskList = currTaskServiceBiz.list(new QueryWrapper() + .eq(CurrTask.STATUS, 1) + .eq(CurrTask.IS_IN, 1)); + for (CurrTask currTask :currTaskList + ) { + Long kilnId = currTask.getKilnId(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + PlcNameSpace plcNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.TYPE, 0) + .eq(PlcNameSpace.EQ_ID,kilnId)); + //通过允许出炉信号来判定是否加工完成 + String result = readPlcToString(plcNameSpace.getName(), "AllowOut"); + Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (resultBoolean){ + //调用RunTaskUtils.runTaskForOutKiln + runTaskUtils.runTaskForOutKiln(kilnId); + break; + } + } + } } - //每个小时的0分和30分执行 - @Scheduled(cron = "0 0/30 * * * ?") - //获取全部窑炉每半小时电能消耗数据,计算,存储 - public void getAllEleValue(){ - // TODO: 2021/12/27 - // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id - // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + + //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。 + public void getFastValue(){ + //加工炉列表 + List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); + for (KilnInfo kilnInfo:kilnInfoList + ) { + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) + .eq(PlcNameSpace.TYPE,1)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "Working"); + Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + //该炉子在工作中 + if (resultBoolean){ + Long kilnId = kilnInfo.getId(); + String identificationNumber = readPlcToString(nameSpaceNote, "Identification number"); + Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); + //加工炉 + if (kilnInfo.getType()==1){ + //一号油搅拌转速 + Double oilStirringSpeed1 = readPlc(nameSpaceNote, "OilStirringSpeed1"); + //二号油搅拌转速 + Double oilStirringSpeed2 = readPlc(nameSpaceNote, "OilStirringSpeed2"); + ParRotSpeedValue parRotSpeedValue=new ParRotSpeedValue(); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed1.floatValue()); + parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue()); + parRotSpeedValue.setKilnId(kilnId); + parRotSpeedValue.setTaskId(currTaskId); + setCommonField(parRotSpeedValue); + parRotSpeedValueServiceBiz.save(parRotSpeedValue); + //氮气 + Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow"); + //甲烷 + Double methanolFlow = readPlc(nameSpaceNote, "MethanolFlow"); + //丙烷 + Double propaneFlow = readPlc(nameSpaceNote, "PropaneFlow"); + //氨气 + Double ammoniaFlow = readPlc(nameSpaceNote, "AmmoniaFlow"); + //实际碳势 + Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定碳势 + Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + ParGasValue parGasValue=new ParGasValue(); + parGasValue.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue.setMethanolFlow(methanolFlow.floatValue()); + parGasValue.setPropaneFlow(propaneFlow.floatValue()); + parGasValue.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue.setKilnId(kilnId); + parGasValue.setTaskId(currTaskId); + setCommonField(parGasValue); + parGasValueServiceBiz.save(parGasValue); + } + //氮化炉 + if (kilnInfo.getType()==3){ + //实际氮势 + Double actualCarbon = readPlc(nameSpaceNote, "ActualCarbon"); + //设定氮势 + Double setupCarbon = readPlc(nameSpaceNote, "SetupCarbon"); + //氢含量 + Double hydrogenContent = readPlc(nameSpaceNote, "HydrogenContent"); + //分解率 + Double decompositionRate = readPlc(nameSpaceNote, "DecompositionRate"); + //氨气量 + Double ammoniaFlow=readPlc(nameSpaceNote,"AmmoniaFlow"); + //氮气量 + Double nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow"); + //二氧化碳量 + Double carbonDioxideFlow = readPlc(nameSpaceNote, "CarbonDioxideFlow"); + ParGasValue parGasValue3=new ParGasValue(); + parGasValue3.setNitFlowValue(nitrogenFlow.floatValue()); + parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue()); + parGasValue3.setActualNitPotValue(actualCarbon.floatValue()); + parGasValue3.setSetNitPotValue(setupCarbon.floatValue()); + parGasValue3.setHydrogenContent(hydrogenContent.floatValue()); + parGasValue3.setDecompositionRate(decompositionRate.floatValue()); + parGasValue3.setKilnId(kilnId); + parGasValue3.setTaskId(currTaskId); + setCommonField(parGasValue3); + parGasValueServiceBiz.save(parGasValue3); + } + } + } + } + //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。 + public void getSlowValue(){ + List kilnInfoList = kilnInfoServiceBiz.list(); + for (KilnInfo kilnInfo:kilnInfoList + ) { + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) + .eq(PlcNameSpace.TYPE,1)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "Working"); + Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (resultBoolean){ + Long kilnId = kilnInfo.getId(); + String identificationNumber = readPlcToString(nameSpaceNote, "Identification number"); + Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); + //加工炉 + if (kilnInfo.getType()==1){ + //实际温度 + Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //油槽实际温度 + Double actualOilTemp = readPlc(nameSpaceNote, "ActualOilTemp"); + //油槽设定温度 + Double setUpOilTemp = readPlc(nameSpaceNote,"SetUpOilTemp"); + ParTemValue parTemValue=new ParTemValue(); + parTemValue.setSetTemValue(setUpTemp.floatValue()); + parTemValue.setActTemValue(actualTemp.floatValue()); + parTemValue.setOilTankSetTemValue(setUpOilTemp.floatValue()); + parTemValue.setOilTankActTemValue(actualOilTemp.floatValue()); + parTemValue.setKilnId(kilnId); + parTemValue.setTaskId(currTaskId); + setCommonField(parTemValue); + parTemValueServiceBiz.save(parTemValue); + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue=new ParEleValue(); + parEleValue.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue.setTotalBat(electricalValue.floatValue()); + parEleValue.setKilnId(kilnId); + parEleValue.setTaskId(currTaskId); + setCommonField(parEleValue); + parEleValueServiceBiz.save(parEleValue); + } + //回火炉 + if (kilnInfo.getType()==2){ + //实际温度 + Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + ParTemValue parTemValue2=new ParTemValue(); + parTemValue2.setSetTemValue(setUpTemp.floatValue()); + parTemValue2.setActTemValue(actualTemp.floatValue()); + parTemValue2.setKilnId(kilnId); + parTemValue2.setTaskId(currTaskId); + setCommonField(parTemValue2); + parTemValueServiceBiz.save(parTemValue2); + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue2=new ParEleValue(); + parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue2.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue2.setTotalBat(electricalValue.floatValue()); + parEleValue2.setKilnId(kilnId); + parEleValue2.setTaskId(currTaskId); + setCommonField(parEleValue2); + parEleValueServiceBiz.save(parEleValue2); + } + //氮化炉 + if (kilnInfo.getType()==3){ + //实际温度 + Double actualTemp =readPlc(nameSpaceNote,"ActualTemp"); + //设定温度 + Double setUpTemp = readPlc(nameSpaceNote,"SetUpTemp"); + //炉压 + Double furnacePressure = readPlc(nameSpaceNote, "FurnacePressure"); + //外一区温度 + Double outerZoneITemperature = readPlc(nameSpaceNote, "OuterZoneITemperature"); + //外二区温度 + Double outerZone2Temperature = readPlc(nameSpaceNote, "OuterZone2Temperature"); + ParTemValue parTemValue3=new ParTemValue(); + parTemValue3.setSetTemValue(setUpTemp.floatValue()); + parTemValue3.setActTemValue(actualTemp.floatValue()); + parTemValue3.setOuterZone1Temp(outerZoneITemperature.floatValue()); + parTemValue3.setOuterZone2Temp(outerZone2Temperature.floatValue()); + parTemValue3.setFurnacePressure(furnacePressure.floatValue()); + parTemValue3.setKilnId(kilnId); + parTemValue3.setTaskId(currTaskId); + setCommonField(parTemValue3); + parTemValueServiceBiz.save(parTemValue3); + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue3=new ParEleValue(); + parEleValue3.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue3.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue3.setTotalBat(electricalValue.floatValue()); + parEleValue3.setKilnId(kilnId); + parEleValue3.setTaskId(currTaskId); + setCommonField(parEleValue3); + parEleValueServiceBiz.save(parEleValue3); + } + //清洗炉 + if (kilnInfo.getType()==4){ + //电度值 + Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); + //A向电压 + Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + ParEleValue parEleValue4=new ParEleValue(); + parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue()); + parEleValue4.setAVoltagevValue(phaseCVoltage.floatValue()); + parEleValue4.setTotalBat(electricalValue.floatValue()); + parEleValue4.setKilnId(kilnId); + parEleValue4.setTaskId(currTaskId); + setCommonField(parEleValue4); + parEleValueServiceBiz.save(parEleValue4); + } + } + } } - //每日23:55执行 - @Scheduled(cron = "0 55 23 * * ?") - //获取全部窑炉每天电能消耗数据,计算,存储 - public void getAllEleValueForDay(){ - // TODO: 2021/12/27 - // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id - // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, + //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 + public void runTaskForEmptyKiln(){ + List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() + .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); + //存在空闲窑炉 + if (kilnInfoList.size()!=0){ + //缓存去是否有目标位置为窑炉的待加工任务 + KilnInfo kilnInfo = kilnInfoList.get(0); + List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper() + .eq(InStockInfo.TYPE, 1) + .eq(InStockInfo.KILN_ID, kilnInfo.getId()) + .orderByAsc(InStockInfo.IN_TIME)); + if (inStockInfoList.size()>0){ + InStockInfo inStockInfo = inStockInfoList.get(0); + CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId()); + Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); + //是否有小车在运行 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + //两辆车同时空闲(其中一辆车在运行时,不能调度另一辆车,防止运行中路线冲突) + if (vehicleInfoList.size()==0){ + //计算出路径最短的车辆id + Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode()); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(),vehicleId); + } + } + + } } - //每月最后一日23:55执行 - @Scheduled(cron = "0 55 23 L * ?") - //获取全部窑炉每天电能消耗数据,计算,存储 - public void getAllEleValueForMonth(){ - // TODO: 2021/12/27 - // 获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id - // 获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0 + //遍历正在工作炉子的报警变量,记录报警 + public void listenKilnAlarm(){ + List kilnInfoList = kilnInfoServiceBiz.list(); + for (KilnInfo kilnInfo:kilnInfoList + ) { + // TODO: 2022/2/28 判断炉子是否在工作状态 + if (true){ + PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())); + //命名空间前缀 + String nameSpace = kilnNameSpace.getNote(); + //炉子的报警变量 + List alarmNameList = plcNameSpaceServiceBiz.list(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.TYPE, 1) + .eq(PlcNameSpace.EQ_ID,kilnInfo.getId()));; + for (PlcNameSpace plcNameSpace:alarmNameList + ) { + String name = plcNameSpace.getName(); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",nameSpace.concat(name)); + String jsonString = JSON.toJSONString(json); + try { + String result = HttpClient.httpPost("http://localhost:8009/opcua/read", jsonString); + Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + //报警状态为true + if (resultBoolean){ + //任务状态为执行中且正在炉子中加工的任务 + CurrTask currTask = currTaskServiceBiz.getOne(new QueryWrapper() + .eq(CurrTask.KILN_ID, kilnInfo.getId()) + .eq(CurrTask.IS_IN, 1) + .eq(CurrTask.STATUS, 1)); + AlarmInfo alarmInfo=new AlarmInfo(); + alarmInfo.setEquipmentId(currTask.getKilnId()); + alarmInfo.setEquipmentName(currTask.getKilnName()); + alarmInfo.setType(0); + alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode()); + alarmInfo.setAlarmInfo(plcNameSpace.getNote()); + alarmInfo.setTaskCode(currTask.getTaskCode()); + alarmInfo.setCreateTime(LocalDateTime.now()); + alarmInfoServiceBiz.save(alarmInfo); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + /** + * 获取变量值 + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return result字符串 + */ + private String readPlcToString(String nameSpace, String variableName){ + String identifier=nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier); + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("readPLC: "+identifier+" 的值失败"); + } + return result; + } + /** + * 获取变量值 + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return 变量值 + */ + private Double readPlc(String nameSpace, String variableName){ + String identifier=nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier); + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("能源消耗统计:获取 "+identifier+" 的值失败"); + } + return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index daa4b64..eda5cf4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -1,5 +1,12 @@ package com.mt.wms.empty.task; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.dal.entity.PointInfo; +import com.mt.wms.core.dal.service.PointInfoServiceBiz; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + import java.util.List; /** @@ -7,27 +14,85 @@ import java.util.List; * @Date: 2021/12/1 16:56 * @Version 1.0 */ +@Component public class TaskDistanceUtils { + + @Autowired + private PointInfoServiceBiz pointInfoServiceBiz; /** - *计算各个空闲小车执行此任务的路径长度,传入任务起终点,返回一个小车ID + * 计算各个空闲小车执行此任务的路径长度,传入任务起终点,返回一个小车ID + * @param startPoint 起点 + * @param endPoint 终点 + * @return 路径最短的小车id */ - public static Long chooseVehicle(String startPoint,String endPoint){ + public Long chooseVehicle(String startPoint,String endPoint){ + Integer start = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getId(); + Integer end = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getId(); + //获取点位list + List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); //计算任务起点到终点的距离 - + List pointInfoListForTask = pointInfoList.subList(start - 1, end - 1); + Double taskDistance=0D; + for (PointInfo pointInfo:pointInfoListForTask + ) { + taskDistance=taskDistance+pointInfo.getDistance(); + } //计算空闲小车当前位置到起点的距离 - + // TODO: 2022/2/19 两辆小车都空闲,获取出当前位置 + Integer vehicle1=0; + Integer vehicle2=39; + List pointInfoListForVehicle1 = pointInfoList.subList((vehicle1vehicle1)?end:vehicle1 - 1); + List pointInfoListForVehicle2 = pointInfoList.subList((vehicle2vehicle2)?end:vehicle2 - 1); //计算得出总距离最短的小车 - - return null; + Double vehicle1Distance=0D; + for (PointInfo pointInfo:pointInfoListForVehicle1 + ) { + vehicle1Distance=vehicle1Distance+pointInfo.getDistance(); + } + Double vehicle2Distance=0D; + for (PointInfo pointInfo:pointInfoListForVehicle2 + ) { + vehicle2Distance=vehicle2Distance+pointInfo.getDistance(); + } + return (vehicle1Distance< vehicle2Distance)?1L:2L; } /** - * 计算正在执行任务的小车本次任务的剩余路径经过的点位集合 + * 计算执行任务的小车本次任务的剩余路径经过的点位集合 + * @param vehicle 小车id + * @param startPoint 起点 + * @param endPoint 终点 + * @return 点位集合 */ - public static List getPointList(){ - //获取小车当前位置 - + public List getPointList(Long vehicle,String startPoint,String endPoint){ + Integer start = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getId(); + Integer end = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getId(); + //获取点位list + List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); + // TODO: 2022/2/19 获取小车当前位置 + Integer nowPoint=3; //计算小车当前位置到任务起点-任务起点到任务终点的路径点集合 + //小车当前位置、起点、终点,找出最大最小值 + int min=(((nowPointstart)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end; + return pointInfoList.subList(min, max); + } - return null; + //判断小车是否冲突,传入选定小车的id,任务起终点,另一小车位置。 + public Boolean conflictForVehicle(Long vehicle,String startPoint,String endPoint,Integer otherNowPoint){ + Integer start = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getId(); + Integer end = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getId(); + //获取点位list + List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); + // TODO: 2022/2/19 获取小车当前位置 + Integer nowPoint=3; + //计算小车当前位置到任务起点-任务起点到任务终点的路径点集合 + //小车当前位置、起点、终点,找出最大最小值 + int min=(((nowPointstart)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end; + if (otherNowPoint>=min&&otherNowPoint<=max){ + return true; + }else { + return false; + } } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/VehicleCollisionUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/VehicleCollisionUtils.java index b67f758..7cfdf12 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/VehicleCollisionUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/VehicleCollisionUtils.java @@ -1,14 +1,17 @@ package com.mt.wms.empty.task; +import com.mt.wms.core.dal.service.PointInfoServiceBiz; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + /** * @Author: liguanghao * @Date: 2021/12/1 16:38 * @Version 1.0 */ -//计算车辆路径是否冲突的方法,若只有一辆车空闲,计算是否冲突, -// 若两辆车都空闲且路径冲突,离起点近的那辆车计算避让出起点的距离,离终点近的那辆车计算出避让出终点的距离,取小 +@Component public class VehicleCollisionUtils { - //获取当前车辆执行任务的路径,与其他正在执行任务的车辆路径对比 - //根据点坐标的最大最小值确定任务需要经过的点的集合,再根据车辆自身大小加上安全距离包含的点位 - //比较两个集合是否有相同元素 + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AutoTaskVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AutoTaskVo.java new file mode 100644 index 0000000..ecc3897 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AutoTaskVo.java @@ -0,0 +1,236 @@ +package com.mt.wms.empty.vo; + +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * @Author: liguanghao + * @Date: 2022/3/3 22:56 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "自动任务视图对象", description = "用于查询自动任务信息") +public class AutoTaskVo extends BaseVo implements PageVo.ConvertVo{ + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", example = "1") + private Long id; + /** + * 添加时间 + */ + @ApiModelProperty(value = "添加时间", example = "0") + private LocalDateTime createTime; + /** + * 编码 + */ + @ApiModelProperty(value = "编码",example = "0") + private String interCode; + /** + * 工艺类型,1表示第一种工艺流程,2表示第二种工艺流程 + */ + @ApiModelProperty(value = "工艺类型,1表示第一种工艺流程,2表示第二种工艺流程",example = "0") + private Integer processFlowType; + /** + * 状态,0:新增,1:执行中,2完成 + */ + @ApiModelProperty(value = "状态,0:新增,1:执行中,2完成",example = "0") + private Integer status; + + /** + * 执行任务ID,关联任务表:t_curr_task + */ + @ApiModelProperty(value = "执行任务ID,关联任务表:t_curr_task",example = "0") + private Long fTaskId; + + /** + * 任务编码,子任务编码对应任务表t_curr_task中task_code编码 + */ + @ApiModelProperty(value = "任务编码,子任务编码对应任务表t_curr_task中task_code编码",example = "0") + private String fDetTaskCode; + + /** + * 设备类型ID,关联设备类型表:t_equipment_type + */ + @ApiModelProperty(value = "设备类型ID,关联设备类型表:t_equipment_type",example = "0") + private Long fEquipmentTypeId; + + /** + * 设备ID,关联设备表:t_kiln_info + */ + @ApiModelProperty(value = "设备ID,关联设备表:t_kiln_info",example = "0") + private Long fEquipmentId; + + /** + * 设备名称(炉子名称) + */ + @ApiModelProperty(value = "设备名称(炉子名称)",example = "0") + private String fEquipmentName; + + /** + * 工艺号ID,关联工艺号表:t_craft_info + */ + @ApiModelProperty(value = "工艺号ID,关联工艺号表:t_craft_info",example = "0") + private Long fCraftCodeId; + + /** + * 工艺号对应PLC值 + */ + @ApiModelProperty(value = "工艺号对应PLC值",example = "0") + private Integer fPlcValue; + + /** + * 进炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "进炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer fInTranStatus; + + /** + * 加工状态,0:加工开始,1:加工中,2:加工完成 + */ + @ApiModelProperty(value = "加工状态,0:加工开始,1:加工中,2:加工完成",example = "0") + private Integer fProStatus; + + /** + * 出炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "出炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer fOutTranStatus; + + /** + * 执行任务ID,关联任务表:t_curr_task + */ + @ApiModelProperty(value = "执行任务ID,关联任务表:t_curr_task",example = "0") + private Long tTaskId; + + /** + * 任务编码,子任务编码对应任务表t_curr_task中task_code编码 + */ + @ApiModelProperty(value = "任务编码,子任务编码对应任务表t_curr_task中task_code编码",example = "0") + private String tDetTaskCode; + + /** + * 设备类型ID,关联设备类型表:t_equipment_type + */ + @ApiModelProperty(value = "设备类型ID,关联设备类型表:t_equipment_type",example = "0") + private Long tEquipmentTypeId; + + /** + * 设备名称 + */ + @ApiModelProperty(value = "设备名称",example = "0") + private String tEquipmentName; + + /** + * 设备ID,关联设备表:t_kiln_info + */ + @ApiModelProperty(value = "设备ID,关联设备表:t_kiln_info",example = "0") + private Long tEquipmentId; + + /** + * 工艺号ID,关联工艺号表:t_craft_info + */ + @ApiModelProperty(value = "工艺号ID,关联工艺号表:t_craft_info",example = "0") + private Long tCraftCodeId; + + /** + * 工艺号对应PLC值 + */ + @ApiModelProperty(value = "工艺号对应PLC值",example = "0") + private Integer tPlcValue; + + /** + * 进炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "进炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer tInTranStatus; + + /** + * 加工状态,0:加工开始,1:加工中,2:加工完成 + */ + @ApiModelProperty(value = "加工状态,0:加工开始,1:加工中,2:加工完成",example = "0") + private Integer tProStatus; + + /** + * 出炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "出炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer tOutTranStatus; + + /** + * 执行任务ID,关联任务表:t_curr_task + */ + @ApiModelProperty(value = "执行任务ID,关联任务表:t_curr_task",example = "0") + private Long thTaskId; + + /** + * 任务编码,子任务编码对应任务表t_curr_task中task_code编码 + */ + @ApiModelProperty(value = "任务编码,子任务编码对应任务表t_curr_task中task_code编码",example = "0") + private String thDetTaskCode; + + /** + * 设备类型ID,关联设备类型表:t_equipment_type + */ + @ApiModelProperty(value = "设备类型ID,关联设备类型表:t_equipment_type",example = "0") + private Long thEquipmentTypeId; + + /** + * 设备名称 + */ + @ApiModelProperty(value = "设备名称",example = "0") + private String thEquipmentName; + + /** + * 设备ID,关联设备表:t_kiln_info + */ + @ApiModelProperty(value = "设备ID,关联设备表:t_kiln_info",example = "0") + private Long thEquipmentId; + + /** + * 工艺号ID,关联工艺号表:t_craft_info + */ + @ApiModelProperty(value = "工艺号ID,关联工艺号表:t_craft_info",example = "0") + private Long thCraftCodeId; + + /** + * 工艺号对应PLC值 + */ + @ApiModelProperty(value = "工艺号对应PLC值",example = "0") + private Integer thPlcValue; + + /** + * 进炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "进炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer thInTranStatus; + + /** + * 加工状态,0:加工开始,1:加工中,2:加工完成 + */ + @ApiModelProperty(value = "加工状态,0:加工开始,1:加工中,2:加工完成",example = "0") + private Integer thProStatus; + + /** + * 出炉运输状态,0:开始,1:运输中,2:运输完成 + */ + @ApiModelProperty(value = "出炉运输状态,0:开始,1:运输中,2:运输完成",example = "0") + private Integer thOutTranStatus; + + /** + * 备注 + */ + @ApiModelProperty(value = "备注",example = "0") + private String content; +} diff --git a/6.program/wms-gateway/pom.xml b/6.program/wms-gateway/pom.xml index 88beb0f..6198718 100644 --- a/6.program/wms-gateway/pom.xml +++ b/6.program/wms-gateway/pom.xml @@ -60,6 +60,11 @@ knife4j-spring-ui 2.0.8 + + org.yaml + snakeyaml + + From ee05bbf7bba7fd7cb90b9155f4d67f2b2cd18006 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Fri, 4 Mar 2022 17:08:09 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E8=83=BD=E6=BA=90=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mt/wms/basic/params/KilnInfoParam.java | 6 + .../java/com/mt/wms/basic/vo/KilnInfoVo.java | 6 + .../mt/wms/core/dal/entity/AutoExeTask.java | 4 +- .../core/dal/mapper/AutoExeTaskMapper.java | 2 +- .../dal/service/AutoExeTaskServiceBiz.java | 2 +- .../impl/AutoExeTaskServiceBizImpl.java | 2 +- .../empty/controller/AutoTaskController.java | 2 + .../empty/controller/CurrTaskController.java | 2 +- .../empty/controller/EnergyController.java | 246 ++++++++++++++++-- .../wms/empty/params/AutoCurrTaskParam.java | 2 +- .../wms/empty/params/ElectricQueryParam.java | 4 +- .../java/com/mt/wms/empty/vo/AlarmInfoVo.java | 5 + .../com/mt/wms/empty/vo/ConsumeDataVo.java | 46 ++++ 13 files changed, 304 insertions(+), 25 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/ConsumeDataVo.java diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/KilnInfoParam.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/KilnInfoParam.java index 335af70..fe4dc51 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/KilnInfoParam.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/params/KilnInfoParam.java @@ -49,6 +49,12 @@ public class KilnInfoParam extends BaseParam { @ApiModelProperty(value = "缩写(别名)", example = "1") @NotNull(message = "别名不能为空") private String kilnAlias; + /** + * 设备类型,存储数据字典编码,修改为1:加工炉,2:回火炉,3:氮化炉,4:清洗炉 + */ + @ApiModelProperty(value = "设备类型,存储数据字典编码,修改为1:加工炉,2:回火炉,3:氮化炉,4:清洗炉", example = "1") + @NotNull(message = "设备类型不能为空") + private Integer type; /** diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/KilnInfoVo.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/KilnInfoVo.java index 6ef0593..9dddcd2 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/KilnInfoVo.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/KilnInfoVo.java @@ -32,6 +32,12 @@ public class KilnInfoVo extends BaseVo implements PageVo.ConvertVo { @ApiModelProperty(value = "编码", example = "1") private String code; + /** + * 类型,存储数据字典编码,修改为1:加工炉,2:回火炉,3:氮化炉,4:清洗炉 + */ + @ApiModelProperty(value = "类型,存储数据字典编码,修改为1:加工炉,2:回火炉,3:氮化炉,4:清洗炉", example = "1") + private Integer type; + /** * 名称 */ diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java index d9b3a9e..defb256 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/AutoExeTask.java @@ -19,7 +19,7 @@ import lombok.experimental.Accessors; *

* * @author mt - * @since 2022-03-03 + * @since 2022-03-04 */ @Data @EqualsAndHashCode(callSuper = false) @@ -46,7 +46,7 @@ public class AutoExeTask extends Model { private LocalDateTime createTime; /** - * 状态,0:新增,1:执行中,2完成 + * 状态,0:新增,1:执行中,2完成,3 终止 */ @TableField("status") private Integer status; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java index 5770058..d50d831 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/mapper/AutoExeTaskMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; *

* * @author mt - * @since 2022-03-03 + * @since 2022-03-04 */ public interface AutoExeTaskMapper extends BaseMapper { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java index b8c8da7..9dd6dc8 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/AutoExeTaskServiceBiz.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService; *

* * @author mt - * @since 2022-03-03 + * @since 2022-03-04 */ public interface AutoExeTaskServiceBiz extends IService { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java index e6072f0..58bc2e4 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/service/impl/AutoExeTaskServiceBizImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; *

* * @author mt - * @since 2022-03-03 + * @since 2022-03-04 */ @Service public class AutoExeTaskServiceBizImpl extends ServiceImpl implements AutoExeTaskServiceBiz { diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java index e566688..108a4dc 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/AutoTaskController.java @@ -48,6 +48,8 @@ public class AutoTaskController extends BaseController { return autoTaskService.page(autoTaskQueryParam); } + @PostMapping(value = "stop") + @ApiOperation(value = "终止自动任务") private R stop(@Validated @RequestBody IdParam idParam){ return autoTaskService.stop(idParam); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index a55d2de..8653857 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -138,7 +138,7 @@ public class CurrTaskController extends BaseController { @PostMapping(value = "createAutoTask") @ApiOperation(value = "订单加工-创建多个个分步骤加工任务至任务队列") public R createAutoTask(@Validated @RequestBody AutoCurrTaskParam autoCurrTaskParam){ - List detParams = autoCurrTaskParam.getDetParams(); + List detParams = autoCurrTaskParam.getTaskCreateParamList(); //自动任务循环添加多条currTask AutoExeTask autoExeTask=new AutoExeTask(); for (TaskCreateParam param:detParams diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index ad1145e..17af2f4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -5,16 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.gson.JsonObject; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; -import com.mt.wms.core.dal.entity.ParEleValue; -import com.mt.wms.core.dal.entity.ParGasValue; -import com.mt.wms.core.dal.entity.ParRotSpeedValue; -import com.mt.wms.core.dal.entity.ParTemValue; -import com.mt.wms.core.dal.service.ParEleValueServiceBiz; -import com.mt.wms.core.dal.service.ParGasValueServiceBiz; -import com.mt.wms.core.dal.service.ParRotSpeedValueServiceBiz; -import com.mt.wms.core.dal.service.ParTemValueServiceBiz; +import com.mt.wms.core.dal.entity.*; +import com.mt.wms.core.dal.service.*; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.ElectricQueryParam; +import com.mt.wms.empty.vo.ConsumeDataVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -27,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.PostConstruct; +import javax.annotation.Resource; import javax.validation.groups.Default; import java.time.DayOfWeek; import java.time.LocalDate; @@ -34,9 +30,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @Author: liguanghao @@ -81,6 +75,8 @@ public class EnergyController extends BaseController { private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; @Autowired private ParTemValueServiceBiz parTemValueServiceBiz; + @Autowired + private KilnInfoServiceBiz kilnInfoServiceBiz; @PostMapping(value = "eletric") @ApiOperation(value = "根据窑炉id获取消耗情况") @@ -217,28 +213,246 @@ public class EnergyController extends BaseController { @PostMapping(value = "energyList") @ApiOperation(value = "根据加工炉id获取能源消耗情况") public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(electricQueryParam.getKilnId()); + Integer kilnType = kilnInfo.getType(); //传入任务号,窑炉号,查询消耗数据,返回json字符串 + JSONObject jsonObject=new JSONObject(); + ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build(); //电能消耗 List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + if (parEleValueList.size()>0){ + List eleList=new ArrayList(); + //电能消耗 + List eleConsume=new ArrayList<>(); + //A向电压 + List aVolConsume=new ArrayList<>(); + //B向电压 + List bVolConsume=new ArrayList<>(); + //C向电压 + List cVolConsume=new ArrayList<>(); + for (ParEleValue parEleValue:parEleValueList + ) { + consumeDataVo.setCreateTime(parEleValue.getCreateTime()); + consumeDataVo.setValue(parEleValue.getTotalBat()); + consumeDataVo.setName("耗电量"); + consumeDataVo.setUnit("KW"); + eleConsume.add(consumeDataVo); + consumeDataVo.setValue(parEleValue.getAVoltagevValue()); + consumeDataVo.setName("A向电压"); + consumeDataVo.setUnit("V"); + aVolConsume.add(consumeDataVo); + consumeDataVo.setValue(parEleValue.getBVoltagevValue()); + consumeDataVo.setName("B向电压"); + consumeDataVo.setUnit("V"); + bVolConsume.add(consumeDataVo); + consumeDataVo.setValue(parEleValue.getCVoltagevValue()); + consumeDataVo.setName("C向电压"); + consumeDataVo.setUnit("V"); + cVolConsume.add(consumeDataVo); + } + eleList.add(eleConsume); + eleList.add(aVolConsume); + eleList.add(bVolConsume); + eleList.add(cVolConsume); + jsonObject.put("ele",eleList); + } //氮气、甲醇、丙烷、氨气消耗量 List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + if (parGasValueList.size()>0){ + if (kilnType==1){ + List gasList=new ArrayList(); + //氮气 + List nitConsume=new ArrayList<>(); + //甲醇 + List metConsume=new ArrayList<>(); + //丙烷 + List propaneConsume=new ArrayList<>(); + //氨气 + List ammoniaConsume=new ArrayList<>(); + for (ParGasValue parGasValue:parGasValueList + ) { + consumeDataVo.setCreateTime(parGasValue.getCreateTime()); + consumeDataVo.setValue(parGasValue.getNitFlowValue()); + consumeDataVo.setName("氮气"); + consumeDataVo.setUnit("m³"); + nitConsume.add(consumeDataVo); + consumeDataVo.setValue(parGasValue.getMethanolFlow()); + consumeDataVo.setName("甲醇"); + consumeDataVo.setUnit("m³"); + metConsume.add(consumeDataVo); + consumeDataVo.setValue(parGasValue.getPropaneFlow()); + consumeDataVo.setName("丙烷"); + consumeDataVo.setUnit("m³"); + propaneConsume.add(consumeDataVo); + consumeDataVo.setValue(parGasValue.getAmmoniaFlowValue()); + consumeDataVo.setName("氨气"); + consumeDataVo.setUnit("m³"); + ammoniaConsume.add(consumeDataVo); + } + gasList.add(nitConsume); + gasList.add(metConsume); + gasList.add(propaneConsume); + gasList.add(ammoniaConsume); + jsonObject.put("gas",gasList); + } + if (kilnType==3){ + List gasList=new ArrayList(); + //氮气 + List nitConsume=new ArrayList<>(); + //二氧化碳 + List carbonConsume=new ArrayList<>(); + //氨气 + List ammoniaConsume=new ArrayList<>(); + for (ParGasValue parGasValue:parGasValueList + ) { + consumeDataVo.setCreateTime(parGasValue.getCreateTime()); + consumeDataVo.setValue(parGasValue.getNitFlowValue()); + consumeDataVo.setName("氮气"); + consumeDataVo.setUnit("m³"); + nitConsume.add(consumeDataVo); + consumeDataVo.setValue(parGasValue.getCarDioxideFlowValue()); + consumeDataVo.setName("二氧化碳"); + consumeDataVo.setUnit("m³"); + carbonConsume.add(consumeDataVo); + consumeDataVo.setValue(parGasValue.getAmmoniaFlowValue()); + consumeDataVo.setName("氨气"); + consumeDataVo.setUnit("m³"); + ammoniaConsume.add(consumeDataVo); + } + gasList.add(nitConsume); + gasList.add(carbonConsume); + gasList.add(ammoniaConsume); + jsonObject.put("gas",gasList); + } + } //油搅拌转速趋势 List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); + if (parRotSpeedValueList.size()>0){ + if (kilnType==1){ + List rotList=new ArrayList(); + List rot1Consume=new ArrayList<>(); + List rot2Consume=new ArrayList<>(); + for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList + ) { + consumeDataVo.setCreateTime(parRotSpeedValue.getCreateTime()); + consumeDataVo.setValue(parRotSpeedValue.getOilStiSpeedAValue()); + consumeDataVo.setName("1号油搅拌转速"); + consumeDataVo.setUnit("转/min"); + rot1Consume.add(consumeDataVo); + consumeDataVo.setValue(parRotSpeedValue.getOilStiSpeedBValue()); + consumeDataVo.setName("2号油搅拌转速"); + consumeDataVo.setUnit("转/min"); + rot2Consume.add(consumeDataVo); + } + rotList.add(rot1Consume); + rotList.add(rot2Consume); + jsonObject.put("rot",rotList); + } + } //温度趋势(实际温度、设定温度) List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); - JSONObject jsonObject=new JSONObject(); - jsonObject.put("ele",parEleValueList); - jsonObject.put("gas",parGasValueList); - jsonObject.put("rot",parRotSpeedValueList); - jsonObject.put("tem",parTemValueList); + if (parTemValueList.size()>0){ + if (kilnType==1){ + List tempList=new ArrayList(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List actualOilTempConsume=new ArrayList<>(); + List setupOilTempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("实际温度"); + consumeDataVo.setValue(parTemValue.getActTemValue()); + consumeDataVo.setUnit("℃"); + actualTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("设定温度"); + consumeDataVo.setValue(parTemValue.getSetTemValue()); + consumeDataVo.setUnit("℃"); + setupTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("油槽实际温度"); + consumeDataVo.setValue(parTemValue.getOilTankActTemValue()); + consumeDataVo.setUnit("℃"); + actualOilTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("油槽设定温度"); + consumeDataVo.setValue(parTemValue.getOilTankSetTemValue()); + consumeDataVo.setUnit("℃"); + setupOilTempConsume.add(consumeDataVo); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + tempList.add(actualOilTempConsume); + tempList.add(setupOilTempConsume); + jsonObject.put("temp",tempList); + } + if (kilnType==2){ + List tempList=new ArrayList(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("实际温度"); + consumeDataVo.setValue(parTemValue.getActTemValue()); + consumeDataVo.setUnit("℃"); + actualTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("设定温度"); + consumeDataVo.setValue(parTemValue.getSetTemValue()); + consumeDataVo.setUnit("℃"); + setupTempConsume.add(consumeDataVo); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + jsonObject.put("temp",tempList); + } + if (kilnType==3){ + + List tempList=new ArrayList(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List outerZone1TempConsume=new ArrayList<>(); + List outerZone2TempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("实际温度"); + consumeDataVo.setValue(parTemValue.getActTemValue()); + consumeDataVo.setUnit("℃"); + actualTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("设定温度"); + consumeDataVo.setValue(parTemValue.getSetTemValue()); + consumeDataVo.setUnit("℃"); + setupTempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("外一区温度"); + consumeDataVo.setValue(parTemValue.getOuterZone1Temp()); + consumeDataVo.setUnit("℃"); + outerZone1TempConsume.add(consumeDataVo); + consumeDataVo.setCreateTime(parTemValue.getCreateTime()); + consumeDataVo.setName("外二区温度"); + consumeDataVo.setValue(parTemValue.getOuterZone2Temp()); + consumeDataVo.setUnit("℃"); + outerZone2TempConsume.add(consumeDataVo); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + tempList.add(outerZone1TempConsume); + tempList.add(outerZone2TempConsume); + jsonObject.put("temp",tempList); + } + } return R.ok(jsonObject.toJSONString()); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java index 6d719de..6af2a56 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/AutoCurrTaskParam.java @@ -20,5 +20,5 @@ import java.util.List; @ApiModel(value = "自动currTask参数", description = "自动currTask参数") public class AutoCurrTaskParam extends BaseParam { @ApiModelProperty(value = "详细信息", required = true) - private List detParams; + private List taskCreateParamList; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java index 6df70ba..add339f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java @@ -29,9 +29,9 @@ public class ElectricQueryParam extends BaseParam { private Long taskId; - @ApiModelProperty(value = "时间节点", required = true) + @ApiModelProperty(value = "时间节点", required = false) private LocalDateTime time; - @ApiModelProperty(value = "时间类型:1 天,2 周,3 月,4 年", required = true) + @ApiModelProperty(value = "时间类型:1 天,2 周,3 月,4 年", required = false) private Integer dateType; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AlarmInfoVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AlarmInfoVo.java index ad4f5af..06a7d20 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AlarmInfoVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/AlarmInfoVo.java @@ -39,6 +39,11 @@ public class AlarmInfoVo extends BaseVo implements PageVo.ConvertVo{ */ @ApiModelProperty(value = "设备名称",example = "0") private String equipmentName; + /** + * currtask任务code + */ + @ApiModelProperty(value = "currtask任务code",example = "0") + private String taskCode; /** * 报警类型 */ diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/ConsumeDataVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/ConsumeDataVo.java new file mode 100644 index 0000000..ebabdcd --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/ConsumeDataVo.java @@ -0,0 +1,46 @@ +package com.mt.wms.empty.vo; + +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * @Author: liguanghao + * @Date: 2022/3/4 10:47 + * @Version 1.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "消耗数据视图对象", description = "用于查询消耗数据") +public class ConsumeDataVo extends BaseVo implements PageVo.ConvertVo{ + /** + * 时间 + */ + @ApiModelProperty(value = "时间", example = "0") + private LocalDateTime createTime; + /** + * 消耗值 + */ + @ApiModelProperty(value = "消耗值",example = "0.0") + private Float value; + /** + * 单位 + */ + @ApiModelProperty(value = "单位",example = "0.0") + private String unit; + + /** + * 名称 + */ + @ApiModelProperty(value = "名称",example = "0.0") + private String name; +} From 211c0172783e5ec90782bcc22c4f2532471d2a2e Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 5 Mar 2022 14:53:29 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AutoTaskServiceImpl.java | 28 ++- .../mt/wms/empty/task/AsynRunTaskService.java | 237 ++++++++++++++++-- .../com/mt/wms/empty/task/RunTaskUtils.java | 42 +++- .../mt/wms/empty/task/TaskDistanceUtils.java | 10 + .../mt/wms/empty/vo/CurrTaskMainQueryVo.java | 6 + 5 files changed, 290 insertions(+), 33 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java index db85c4a..614f2a8 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/AutoTaskServiceImpl.java @@ -6,18 +6,24 @@ import com.mt.wms.core.api.Assert; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.AutoExeTask; import com.mt.wms.core.dal.entity.AutoExeTaskHis; +import com.mt.wms.core.dal.entity.CurrTask; import com.mt.wms.core.dal.service.AutoExeTaskHisServiceBiz; import com.mt.wms.core.dal.service.AutoExeTaskServiceBiz; +import com.mt.wms.core.dal.service.CurrTaskServiceBiz; import com.mt.wms.core.errorcode.ApiErrorCode; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.vo.IdVo; import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.controller.ApmsController; import com.mt.wms.empty.params.AutoTaskParam; import com.mt.wms.empty.params.AutoTaskQueryParam; import com.mt.wms.empty.service.AutoTaskService; +import com.mt.wms.empty.vo.ApmsEndProcessVo; import com.mt.wms.empty.vo.AutoTaskVo; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,10 +39,16 @@ import java.util.List; @Service @Transactional public class AutoTaskServiceImpl extends BaseService implements AutoTaskService { + + private final static Logger logger = LoggerFactory.getLogger(AutoTaskServiceImpl.class); @Resource private AutoExeTaskServiceBiz autoExeTaskServiceBiz; @Resource private AutoExeTaskHisServiceBiz autoExeTaskHisServiceBiz; + @Resource + private CurrTaskServiceBiz currTaskServiceBiz; + @Resource + private ApmsController apmsController; @Override public R get(IdParam idParam) { Assert.notNull(ApiErrorCode.INVALID_PARAMETER,idParam.getId()); @@ -55,12 +67,14 @@ public class AutoTaskServiceImpl extends BaseService implements AutoTaskService public R> page(AutoTaskQueryParam autoTaskQueryParam) { QueryWrapper wrapper=new QueryWrapper<>(); wrapper.eq((autoTaskQueryParam.getStatus()!=null&&("").equals(autoTaskQueryParam.getStatus())),AutoExeTask.STATUS,autoTaskQueryParam.getStatus()); + wrapper.in(AutoExeTask.STATUS,0,1); Page page = autoExeTaskServiceBiz.page(new Page<>(autoTaskQueryParam.getCurrent(), autoTaskQueryParam.getSize()), wrapper); return successful(new PageVo<>(page,AutoTaskVo.class)); } @Override public R stop(IdParam idParam) { + AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(idParam.getId()); //状态置为终止 autoExeTask.setStatus(3); @@ -71,7 +85,19 @@ public class AutoTaskServiceImpl extends BaseService implements AutoTaskService autoExeTaskHisServiceBiz.save(autoExeTaskHis); //释放后续步骤 // TODO: 2022/3/3 + //删除对应的几条currtask(未执行的),通知apms生产单作废 + List currTaskList = currTaskServiceBiz.list(new QueryWrapper() + .eq(CurrTask.AUTO_EXE_TASK_ID, autoExeTask.getId()).eq(CurrTask.STATUS,0)); + for (CurrTask currTask:currTaskList + ) { + R apmsEndProcessVoR = apmsController.deleteBySheetNo(currTask.getSheetNo()); + if (!apmsEndProcessVoR.getData().getSuccess()){ + logger.info("Apms作废生产单接口错误"); + return R.failed("Apms作废生产单接口错误"); + } + currTaskServiceBiz.removeById(currTask); + } autoExeTaskServiceBiz.removeById(autoExeTask); - return null; + return successful(IdVo.builder().id(idParam.getId()).build()); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 6837aa3..61b4db4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -73,7 +73,7 @@ public class AsynRunTaskService extends BaseService { otherNowPoint=1; //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); - while (conflictBoolean){ + if (conflictBoolean){ //若冲突 // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 Map json = new HashMap(); @@ -87,6 +87,8 @@ public class AsynRunTaskService extends BaseService { } catch (IOException e) { e.printStackTrace(); logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; } } }else { @@ -94,7 +96,7 @@ public class AsynRunTaskService extends BaseService { otherNowPoint=2; //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); - while (conflictBoolean){ + if (conflictBoolean){ //若冲突 // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 Map json = new HashMap(); @@ -107,6 +109,8 @@ public class AsynRunTaskService extends BaseService { } catch (IOException e) { e.printStackTrace(); logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; } } } @@ -182,16 +186,55 @@ public class AsynRunTaskService extends BaseService { if (vehicleId==1){ // TODO: 2022/2/26 获取RGV2当前位置 otherNowPoint=1; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + //type=1为 入 + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 39); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } }else { //获取RGV1当前位置 otherNowPoint=2; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 1); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } } - //两辆小车是否冲突 +/* //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), currTask.getTargetPosition(), otherNowPoint); - while (conflictBoolean){ + if (conflictBoolean){ //若冲突 // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - } + }*/ //新建一条执行任务的关系表存放任务执行信息 RunTask runTask=new RunTask(); @@ -208,9 +251,33 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setStatus(1); inStockInfoServiceBiz.updateById(inStockInfo); // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果 - + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); + Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); + Map json = new HashMap(); + // taskType 1 搬运 + json.put("taskType", 1); + json.put("sendRow", endPoint); + json.put("pickRow",startPoint); + json.put("taskNo",currTaskId); + json.put("ideNumber",1); + json.put("processNumber",currTask.getPlcValue()); + String taskJson = JSON.toJSONString(json); + String result =null; + try { + if (vehicleId==1){ + result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + } + if (vehicleId==2){ + result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + JSONObject jsonObject = JSON.parseObject(result); + int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); //执行成功,托盘进炉 - if (true){ + if (status==1){ //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setEndTime(LocalDateTime.now()); @@ -246,15 +313,48 @@ public class AsynRunTaskService extends BaseService { if (vehicleId==1){ // TODO: 2022/2/26 获取RGV2当前位置 otherNowPoint=1; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + //type=1为 入 + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 39); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } }else { //获取RGV1当前位置 otherNowPoint=2; - } - //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); - while (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 1); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } } PointInfo pointOfLocation = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 @@ -282,8 +382,32 @@ public class AsynRunTaskService extends BaseService { setCommonField(inStockInfo); inStockInfoServiceBiz.save(inStockInfo); // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) - - if (true){ + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); + Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); + Map json = new HashMap(); + // taskType 1 搬运 + json.put("taskType", 1); + json.put("sendRow", endPoint); + json.put("pickRow",startPoint); + json.put("taskNo",currTaskId); + json.put("ideNumber",1); + json.put("processNumber",currTask.getPlcValue()); + String taskJson = JSON.toJSONString(json); + String result =null; + try { + if (vehicleId==1){ + result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + } + if (vehicleId==2){ + result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + JSONObject jsonObject = JSON.parseObject(result); + int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + if (status==1){ //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); @@ -317,15 +441,48 @@ public class AsynRunTaskService extends BaseService { if (vehicleId==1){ // TODO: 2022/2/26 获取RGV2当前位置 otherNowPoint=1; + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + //type=1为 入 + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 39); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } }else { //获取RGV1当前位置 otherNowPoint=2; - } - //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); - while (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + if (conflictBoolean){ + //若冲突 + // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", 1); + String taskJson = JSON.toJSONString(json); + try { + HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + //wocket推送到页面 + return; + } + } } // TODO: 2021/12/28 location排序 Location location = locationServiceBiz.list(new QueryWrapper() @@ -366,7 +523,32 @@ public class AsynRunTaskService extends BaseService { setCommonField(inStockInfo); inStockInfoServiceBiz.save(inStockInfo); // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) - if (true){ + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); + Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); + Map json = new HashMap(); + // taskType 1 搬运 + json.put("taskType", 1); + json.put("sendRow", endPoint); + json.put("pickRow",startPoint); + json.put("taskNo",currTaskId); + json.put("ideNumber",1); + json.put("processNumber",currTask.getPlcValue()); + String taskJson = JSON.toJSONString(json); + String result =null; + try { + if (vehicleId==1){ + result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + } + if (vehicleId==2){ + result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + JSONObject jsonObject = JSON.parseObject(result); + int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + if (status==1){ //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); @@ -394,9 +576,14 @@ public class AsynRunTaskService extends BaseService { } //出库。起点为缓存区库位,终点为提升台 @Async("asyncServiceExecutor") - public void asynRunOutStock(Long runTaskId,Long locationId){ - //修改调度任务状态 - RunTask runTask = runTaskServiceBiz.getById(runTaskId); + public void asynRunOutStock(Long locationId){ + RunTask runTask=new RunTask(); + setCommonField(runTask); + //runTask.setVehicleId(vehicleId); + runTask.setBeginTime(LocalDateTime.now()); + //runTask.setStartPosition(currTask.getOutStartPosition()); + //runTask.setEndPosition(currTask.getOutTargetPosition()); + runTaskServiceBiz.save(runTask); //修改缓存区状态 InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper() .eq("location_id", locationId)); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index 9e3c945..c58bd88 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -51,6 +51,8 @@ public class RunTaskUtils { private AutoExeTaskServiceBiz autoExeTaskServiceBiz; @Resource private KilnInfoServiceBiz kilnInfoServiceBiz; + @Resource + private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz; /** * 进炉加工 @@ -58,7 +60,7 @@ public class RunTaskUtils { * @return * @throws InterruptedException */ - public R runTaskForInKiln(Long currTaskId) throws InterruptedException { + public R runTaskForInKiln(Long currTaskId) throws InterruptedException{ CurrTask currTask = currTaskServiceBiz.getById(currTaskId); //起点,起点和终点是液压台code、窑炉code、缓存区code String startPosition = currTask.getStartPosition(); @@ -90,15 +92,19 @@ public class RunTaskUtils { //有小车在运行,提示当前有车辆在运行,请稍后 return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); } - // TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态 - int kilnStatus = 1; - + // TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态,能放两坨货的窑炉怎么判定状态? + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId()); + String kilnNamePlace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())).getName(); + String result = readPlcToString(kilnNamePlace, "AllowIn"); + Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); //窑炉状态为不可用 - if (kilnStatus == 0) { + if (kilnInfo.getStatus() == 1) { return R.failed("目标窑炉不可用!"); } //窑炉可用未满 - if (kilnStatus==1){ + if (resultBoolean){ //计算出路径最短的车辆id Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition()); //占用车辆 @@ -115,7 +121,7 @@ public class RunTaskUtils { return R.ok("操作成功,任务已开始执行。"); } //窑炉已满 - if (kilnStatus==2){ + if (resultBoolean){ //查询缓存区库位是否已满 int count = locationServiceBiz.count(new QueryWrapper() .eq(Location.STATUS, 0) @@ -249,4 +255,26 @@ public class RunTaskUtils { } } + /** + * 获取变量值 + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return result字符串 + */ + private String readPlcToString(String nameSpace, String variableName){ + String identifier=nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier); + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("readPLC: "+identifier+" 的值失败"); + } + return result; + } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index eda5cf4..4c03438 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -89,9 +89,19 @@ public class TaskDistanceUtils { //小车当前位置、起点、终点,找出最大最小值 int min=(((nowPointstart)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end; + //另一辆小车在在小车路径上比如冲突,不在小车路径上时判定一下安全距离(4米) if (otherNowPoint>=min&&otherNowPoint<=max){ return true; }else { + Double maxDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, max)).getDistance(); + Double minDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, min)).getDistance(); + Double otherVehicleDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, otherNowPoint)).getDistance(); + if (Math.abs(otherVehicleDistance-maxDistance)<4){ + return true; + } + if (Math.abs(otherVehicleDistance-minDistance)<4){ + return true; + } return false; } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskMainQueryVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskMainQueryVo.java index 80043c1..27f1dc5 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskMainQueryVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskMainQueryVo.java @@ -56,6 +56,12 @@ public class CurrTaskMainQueryVo extends BaseVo implements PageVo.ConvertVo { */ @ApiModelProperty("任务类型") private Integer taskType; + + /** + * 是否自动执行: 0手动,1自动,如果是自动任务这里要监控进出和到缓存区的调度任务 + */ + @ApiModelProperty("是否自动执行:手动,1自动") + private Integer is_auto; /** * 开始位置 */ From bb957ab4eab394524f84b491230669ac73ebf2e3 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 5 Mar 2022 16:09:42 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=83=BD=E6=BA=90?= =?UTF-8?q?=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mt/wms/empty/controller/EnergyController.java | 7 ++++++- .../java/com/mt/wms/empty/params/ElectricQueryParam.java | 2 +- .../com/mt/wms/empty/service/impl/OutStockServiceImpl.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 17af2f4..6c9d336 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -77,6 +77,8 @@ public class EnergyController extends BaseController { private ParTemValueServiceBiz parTemValueServiceBiz; @Autowired private KilnInfoServiceBiz kilnInfoServiceBiz; + @Autowired + private CurrTaskServiceBiz currTaskServiceBiz; @PostMapping(value = "eletric") @ApiOperation(value = "根据窑炉id获取消耗情况") @@ -213,7 +215,10 @@ public class EnergyController extends BaseController { @PostMapping(value = "energyList") @ApiOperation(value = "根据加工炉id获取能源消耗情况") public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ - KilnInfo kilnInfo = kilnInfoServiceBiz.getById(electricQueryParam.getKilnId()); + electricQueryParam.getTaskId(); + CurrTask currTask = currTaskServiceBiz.getById(electricQueryParam.getTaskId()); + Long kilnId = currTask.getKilnId(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); Integer kilnType = kilnInfo.getType(); //传入任务号,窑炉号,查询消耗数据,返回json字符串 JSONObject jsonObject=new JSONObject(); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java index add339f..4287fb9 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java @@ -22,7 +22,7 @@ public class ElectricQueryParam extends BaseParam { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "窑炉id", required = true) + @ApiModelProperty(value = "窑炉id", required = false) private Long kilnId; @ApiModelProperty(value = "任务id", required = true) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java index ce7a873..f5803f6 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java @@ -71,7 +71,7 @@ public class OutStockServiceImpl extends BaseService implements OutStockService setCommonField(runTask); runTaskServiceBiz.save(runTask); //异步调用车辆 - asynRunTaskService.asynRunOutStock(runTask.getId(),locationId); + asynRunTaskService.asynRunOutStock(locationId); //修改库位状态 InStockInfo inStockInfo = inStockInfoServiceBiz .getOne(new QueryWrapper().eq("Location_id", locationId)); From edd0f8c77bbd3e25f74ff4020b8b6a27c8db4c86 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 5 Mar 2022 18:21:13 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=83=BD=E6=BA=90?= =?UTF-8?q?=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../empty/controller/CurrTaskController.java | 4 +- .../empty/controller/EnergyController.java | 300 ++++++++++-------- .../com/mt/wms/empty/vo/CurrTaskQueryVo.java | 5 + 3 files changed, 174 insertions(+), 135 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 8653857..2fb07c4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -269,8 +269,8 @@ public class CurrTaskController extends BaseController { } @PostMapping(value = "runTask") @ApiOperation(value = "执行任务") - public R runTask(@Validated @RequestBody Long taskId) { + public R runTask(@Validated @RequestBody IdParam param) { //点击执行按钮会判断当前任务是否为自动任务,如果是自动任务会去自动任务查一下该自动任务的上一步是否已完成(仅非一步时) - return currTaskService.runTask(taskId); + return currTaskService.runTask(param.getId()); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 6c9d336..a4cccea 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -223,39 +223,48 @@ public class EnergyController extends BaseController { //传入任务号,窑炉号,查询消耗数据,返回json字符串 JSONObject jsonObject=new JSONObject(); ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build(); + + Map map=new HashMap(); //电能消耗 List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.KILN_ID, kilnId) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parEleValueList.size()>0){ List eleList=new ArrayList(); //电能消耗 - List eleConsume=new ArrayList<>(); + List eleConsume=new ArrayList<>(); //A向电压 - List aVolConsume=new ArrayList<>(); + List aVolConsume=new ArrayList<>(); //B向电压 - List bVolConsume=new ArrayList<>(); + List bVolConsume=new ArrayList<>(); //C向电压 - List cVolConsume=new ArrayList<>(); + List cVolConsume=new ArrayList<>(); for (ParEleValue parEleValue:parEleValueList ) { - consumeDataVo.setCreateTime(parEleValue.getCreateTime()); - consumeDataVo.setValue(parEleValue.getTotalBat()); - consumeDataVo.setName("耗电量"); - consumeDataVo.setUnit("KW"); - eleConsume.add(consumeDataVo); - consumeDataVo.setValue(parEleValue.getAVoltagevValue()); - consumeDataVo.setName("A向电压"); - consumeDataVo.setUnit("V"); - aVolConsume.add(consumeDataVo); - consumeDataVo.setValue(parEleValue.getBVoltagevValue()); - consumeDataVo.setName("B向电压"); - consumeDataVo.setUnit("V"); - bVolConsume.add(consumeDataVo); - consumeDataVo.setValue(parEleValue.getCVoltagevValue()); - consumeDataVo.setName("C向电压"); - consumeDataVo.setUnit("V"); - cVolConsume.add(consumeDataVo); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getTotalBat()); + map.put("name","耗电量"); + map.put("unit","KW"); + eleConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getAVoltagevValue()); + map.put("name","A向电压"); + map.put("unit","V"); + aVolConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getBVoltagevValue()); + map.put("name","B向电压"); + map.put("unit","V"); + bVolConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getCVoltagevValue()); + map.put("name","C向电压"); + map.put("unit","V"); + cVolConsume.add(JSONObject.toJSON(map)); + map.clear(); } eleList.add(eleConsume); eleList.add(aVolConsume); @@ -265,38 +274,45 @@ public class EnergyController extends BaseController { } //氮气、甲醇、丙烷、氨气消耗量 List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.KILN_ID, kilnId) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parGasValueList.size()>0){ if (kilnType==1){ List gasList=new ArrayList(); //氮气 - List nitConsume=new ArrayList<>(); + List nitConsume=new ArrayList<>(); //甲醇 - List metConsume=new ArrayList<>(); + List metConsume=new ArrayList<>(); //丙烷 - List propaneConsume=new ArrayList<>(); + List propaneConsume=new ArrayList<>(); //氨气 - List ammoniaConsume=new ArrayList<>(); + List ammoniaConsume=new ArrayList<>(); for (ParGasValue parGasValue:parGasValueList ) { - consumeDataVo.setCreateTime(parGasValue.getCreateTime()); - consumeDataVo.setValue(parGasValue.getNitFlowValue()); - consumeDataVo.setName("氮气"); - consumeDataVo.setUnit("m³"); - nitConsume.add(consumeDataVo); - consumeDataVo.setValue(parGasValue.getMethanolFlow()); - consumeDataVo.setName("甲醇"); - consumeDataVo.setUnit("m³"); - metConsume.add(consumeDataVo); - consumeDataVo.setValue(parGasValue.getPropaneFlow()); - consumeDataVo.setName("丙烷"); - consumeDataVo.setUnit("m³"); - propaneConsume.add(consumeDataVo); - consumeDataVo.setValue(parGasValue.getAmmoniaFlowValue()); - consumeDataVo.setName("氨气"); - consumeDataVo.setUnit("m³"); - ammoniaConsume.add(consumeDataVo); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getNitFlowValue()); + map.put("name","氮气"); + map.put("unit","m³"); + nitConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getMethanolFlow()); + map.put("name","甲醇"); + map.put("unit","m³"); + metConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getPropaneFlow()); + map.put("name","丙烷"); + map.put("unit","m³"); + propaneConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getAmmoniaFlowValue()); + map.put("name","氨气"); + map.put("unit","m³"); + ammoniaConsume.add(JSONObject.toJSON(map)); + map.clear(); } gasList.add(nitConsume); gasList.add(metConsume); @@ -307,26 +323,31 @@ public class EnergyController extends BaseController { if (kilnType==3){ List gasList=new ArrayList(); //氮气 - List nitConsume=new ArrayList<>(); + List nitConsume=new ArrayList<>(); //二氧化碳 - List carbonConsume=new ArrayList<>(); + List carbonConsume=new ArrayList<>(); //氨气 - List ammoniaConsume=new ArrayList<>(); + List ammoniaConsume=new ArrayList<>(); for (ParGasValue parGasValue:parGasValueList ) { - consumeDataVo.setCreateTime(parGasValue.getCreateTime()); - consumeDataVo.setValue(parGasValue.getNitFlowValue()); - consumeDataVo.setName("氮气"); - consumeDataVo.setUnit("m³"); - nitConsume.add(consumeDataVo); - consumeDataVo.setValue(parGasValue.getCarDioxideFlowValue()); - consumeDataVo.setName("二氧化碳"); - consumeDataVo.setUnit("m³"); - carbonConsume.add(consumeDataVo); - consumeDataVo.setValue(parGasValue.getAmmoniaFlowValue()); - consumeDataVo.setName("氨气"); - consumeDataVo.setUnit("m³"); - ammoniaConsume.add(consumeDataVo); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getNitFlowValue()); + map.put("name","氮气"); + map.put("unit","m³"); + nitConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getCarDioxideFlowValue()); + map.put("name","二氧化碳"); + map.put("unit","m³"); + carbonConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",parGasValue.getAmmoniaFlowValue()); + map.put("name","氨气"); + map.put("unit","m³"); + ammoniaConsume.add(JSONObject.toJSON(map)); + map.clear(); } gasList.add(nitConsume); gasList.add(carbonConsume); @@ -336,24 +357,27 @@ public class EnergyController extends BaseController { } //油搅拌转速趋势 List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.KILN_ID, kilnId) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parRotSpeedValueList.size()>0){ if (kilnType==1){ List rotList=new ArrayList(); - List rot1Consume=new ArrayList<>(); - List rot2Consume=new ArrayList<>(); + List rot1Consume=new ArrayList<>(); + List rot2Consume=new ArrayList<>(); for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList ) { - consumeDataVo.setCreateTime(parRotSpeedValue.getCreateTime()); - consumeDataVo.setValue(parRotSpeedValue.getOilStiSpeedAValue()); - consumeDataVo.setName("1号油搅拌转速"); - consumeDataVo.setUnit("转/min"); - rot1Consume.add(consumeDataVo); - consumeDataVo.setValue(parRotSpeedValue.getOilStiSpeedBValue()); - consumeDataVo.setName("2号油搅拌转速"); - consumeDataVo.setUnit("转/min"); - rot2Consume.add(consumeDataVo); + map.put("time",parRotSpeedValue.getCreateTime()); + map.put("value",parRotSpeedValue.getOilStiSpeedAValue()); + map.put("name","1号油搅拌转速"); + map.put("unit","转/min"); + rot1Consume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parRotSpeedValue.getCreateTime()); + map.put("value",parRotSpeedValue.getOilStiSpeedBValue()); + map.put("name","2号油搅拌转速"); + map.put("unit","转/min"); + rot2Consume.add(JSONObject.toJSON(map)); + map.clear(); } rotList.add(rot1Consume); rotList.add(rot2Consume); @@ -362,37 +386,41 @@ public class EnergyController extends BaseController { } //温度趋势(实际温度、设定温度) List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, electricQueryParam.getKilnId()) + .eq(ParEleValue.KILN_ID, kilnId) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parTemValueList.size()>0){ if (kilnType==1){ List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List actualOilTempConsume=new ArrayList<>(); - List setupOilTempConsume=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List actualOilTempConsume=new ArrayList<>(); + List setupOilTempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("实际温度"); - consumeDataVo.setValue(parTemValue.getActTemValue()); - consumeDataVo.setUnit("℃"); - actualTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("设定温度"); - consumeDataVo.setValue(parTemValue.getSetTemValue()); - consumeDataVo.setUnit("℃"); - setupTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("油槽实际温度"); - consumeDataVo.setValue(parTemValue.getOilTankActTemValue()); - consumeDataVo.setUnit("℃"); - actualOilTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("油槽设定温度"); - consumeDataVo.setValue(parTemValue.getOilTankSetTemValue()); - consumeDataVo.setUnit("℃"); - setupOilTempConsume.add(consumeDataVo); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOilTankActTemValue()); + map.put("name","油槽实际温度"); + map.put("unit","℃"); + actualOilTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOilTankSetTemValue()); + map.put("name","油槽设定温度"); + map.put("unit","℃"); + setupOilTempConsume.add(JSONObject.toJSON(map)); + map.clear(); } tempList.add(actualTempConsume); tempList.add(setupTempConsume); @@ -402,20 +430,22 @@ public class EnergyController extends BaseController { } if (kilnType==2){ List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("实际温度"); - consumeDataVo.setValue(parTemValue.getActTemValue()); - consumeDataVo.setUnit("℃"); - actualTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("设定温度"); - consumeDataVo.setValue(parTemValue.getSetTemValue()); - consumeDataVo.setUnit("℃"); - setupTempConsume.add(consumeDataVo); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); } tempList.add(actualTempConsume); tempList.add(setupTempConsume); @@ -424,32 +454,36 @@ public class EnergyController extends BaseController { if (kilnType==3){ List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List outerZone1TempConsume=new ArrayList<>(); - List outerZone2TempConsume=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List outerZone1TempConsume=new ArrayList<>(); + List outerZone2TempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("实际温度"); - consumeDataVo.setValue(parTemValue.getActTemValue()); - consumeDataVo.setUnit("℃"); - actualTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("设定温度"); - consumeDataVo.setValue(parTemValue.getSetTemValue()); - consumeDataVo.setUnit("℃"); - setupTempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("外一区温度"); - consumeDataVo.setValue(parTemValue.getOuterZone1Temp()); - consumeDataVo.setUnit("℃"); - outerZone1TempConsume.add(consumeDataVo); - consumeDataVo.setCreateTime(parTemValue.getCreateTime()); - consumeDataVo.setName("外二区温度"); - consumeDataVo.setValue(parTemValue.getOuterZone2Temp()); - consumeDataVo.setUnit("℃"); - outerZone2TempConsume.add(consumeDataVo); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOuterZone1Temp()); + map.put("name","外一区温度"); + map.put("unit","℃"); + outerZone1TempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOuterZone2Temp()); + map.put("name","外二区温度"); + map.put("unit","℃"); + outerZone2TempConsume.add(JSONObject.toJSON(map)); + map.clear(); } tempList.add(actualTempConsume); tempList.add(setupTempConsume); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskQueryVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskQueryVo.java index 94b3c15..3f2529c 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskQueryVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskQueryVo.java @@ -51,6 +51,11 @@ public class CurrTaskQueryVo extends BaseVo implements PageVo.ConvertVo { */ @ApiModelProperty("任务类型") private Integer taskType; + /** + * 是否自动执行: 0手动,1自动,如果是自动任务这里要监控进出和到缓存区的调度任务 + */ + @ApiModelProperty("是否自动执行:手动,1自动") + private Integer is_auto; /** * 开始加工时间 */ From de098ec968070df277a8f0bd3ef9a8abb8aef71a Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Fri, 18 Mar 2022 11:14:47 +0800 Subject: [PATCH 07/19] =?UTF-8?q?todo=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mt/wms/basic/vo/LocationInfoVo.java | 2 +- 6.program/wms-empty/pom.xml | 7 + .../empty/controller/CurrTaskController.java | 2 +- .../empty/controller/OutStockController.java | 3 +- .../mt/wms/empty/params/OutStockParam.java | 6 +- .../mt/wms/empty/service/CurrTaskService.java | 4 +- .../mt/wms/empty/service/OutStockService.java | 4 +- .../service/impl/CurrTaskServiceImpl.java | 7 +- .../mt/wms/empty/task/AsynRunTaskService.java | 507 +++++++++--------- .../com/mt/wms/empty/task/RunTaskUtils.java | 74 ++- .../com/mt/wms/empty/task/ScheduledTask.java | 23 +- .../mt/wms/empty/task/TaskDistanceUtils.java | 90 ++-- .../mt/wms/empty/websocket/MessageModule.java | 42 ++ .../wms/empty/websocket/WebSocketConfig.java | 14 + .../wms/empty/websocket/WebSocketServer.java | 178 ++++++ 15 files changed, 613 insertions(+), 350 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/MessageModule.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketConfig.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/LocationInfoVo.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/LocationInfoVo.java index 0885ef7..2506f6d 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/LocationInfoVo.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/vo/LocationInfoVo.java @@ -48,7 +48,7 @@ public class LocationInfoVo extends BaseVo implements PageVo.ConvertVo { * 状态 */ @ApiModelProperty(value = "状态:0空闲,1使用,2不可用", example = "1") - private String status; + private Integer status; /** * 缓存区 diff --git a/6.program/wms-empty/pom.xml b/6.program/wms-empty/pom.xml index 2846fbf..21aa245 100644 --- a/6.program/wms-empty/pom.xml +++ b/6.program/wms-empty/pom.xml @@ -25,6 +25,13 @@ hutool-all 5.5.7 + + + org.springframework.boot + spring-boot-starter-websocket + 2.5.4 + + \ No newline at end of file diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 2fb07c4..7816473 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -269,7 +269,7 @@ public class CurrTaskController extends BaseController { } @PostMapping(value = "runTask") @ApiOperation(value = "执行任务") - public R runTask(@Validated @RequestBody IdParam param) { + public R runTask(@Validated @RequestBody IdParam param) throws InterruptedException, IOException { //点击执行按钮会判断当前任务是否为自动任务,如果是自动任务会去自动任务查一下该自动任务的上一步是否已完成(仅非一步时) return currTaskService.runTask(param.getId()); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OutStockController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OutStockController.java index 8bf1074..c7d14df 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OutStockController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/OutStockController.java @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.validation.groups.Default; +import java.io.IOException; import java.util.List; /** @@ -51,7 +52,7 @@ public class OutStockController extends BaseController { } @PostMapping(value = "runOutTask") @ApiOperation(value = "执行出库操作") - private R runOutTask(@Validated({PageGroup.class, Default.class}) @RequestBody OutStockParam outStockParam) { + private R runOutTask(@Validated({PageGroup.class, Default.class}) @RequestBody OutStockParam outStockParam) throws IOException { return outStockService.outTask(outStockParam); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OutStockParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OutStockParam.java index b00a804..a24ec9c 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OutStockParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OutStockParam.java @@ -32,7 +32,7 @@ public class OutStockParam extends BaseParam { /** * 提升台 */ - @ApiModelProperty(value = "提升台",required = true, example = "1") - @NotNull(message = "提升台不能为空") - private Integer code; + @ApiModelProperty(value = "液压台code",required = true, example = "1") + @NotNull(message = "液压台code不能为空") + private String code; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java index 41ac197..7529aea 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java @@ -13,6 +13,8 @@ import com.mt.wms.empty.vo.CurrTaskMainQueryVo; import com.mt.wms.empty.vo.CurrTaskQueryVo; import com.mt.wms.empty.vo.CurrTaskVo; +import java.io.IOException; + /** * 拆分任务相关服务 * @@ -87,7 +89,7 @@ public interface CurrTaskService { /** * 执行任务 */ - R runTask(Long taskId); + R runTask(Long taskId) throws InterruptedException, IOException; R createAutoTask(AutoCurrTaskParam autoCurrTaskParam); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OutStockService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OutStockService.java index ecd71b3..5e33723 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OutStockService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/OutStockService.java @@ -4,6 +4,8 @@ import com.mt.wms.core.vo.PageVo; import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.OutStockParam; +import java.io.IOException; + /** * @Author: liguanghao * @Date: 2021/12/17 8:53 @@ -15,5 +17,5 @@ public interface OutStockService { * * @param outStockParam xx查询参数 */ - R outTask(OutStockParam outStockParam); + R outTask(OutStockParam outStockParam) throws IOException; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index cffaa9d..360cae0 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -24,6 +24,7 @@ import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; import com.mt.wms.empty.service.TaskDetHisService; import com.mt.wms.empty.service.TaskHisService; +import com.mt.wms.empty.task.RunTaskUtils; import com.mt.wms.empty.task.TaskDistanceUtils; import com.mt.wms.empty.vo.ApmsEndProcessVo; import com.mt.wms.empty.vo.CurrTaskMainQueryVo; @@ -74,6 +75,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService VehicleInfoServiceBiz vehicleInfoServiceBiz; @Autowired TaskDistanceUtils taskDistanceUtils; + @Autowired + RunTaskUtils runTaskUtils; @Override public CurrTaskVo getCurrTask(IdParam idParam) { @@ -197,9 +200,9 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService } @Override - public R runTask(Long taskId) { + public R runTask(Long taskId) throws InterruptedException, IOException { CurrTask currTask = currTaskServiceBiz.getById(taskId); - return null; + return runTaskUtils.runTaskForInKiln(taskId); } @Override diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 61b4db4..79da967 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -8,6 +8,9 @@ import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.IDGenerator; +import com.mt.wms.empty.websocket.WebSocketServer; +import io.swagger.models.auth.In; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -18,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; import java.util.HashMap; @@ -62,59 +66,42 @@ public class AsynRunTaskService extends BaseService { private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; @Resource private ParGasValueServiceBiz parGasValueServiceBiz; + @Resource + private WebSocketServer webSocketServer; //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉 @Async("asyncServiceExecutor") - public void asynRunTask(Long currTaskId,Long vehicleId){ + public void asynRunTask(Long currTaskId,Long vehicleId) throws IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); - Integer otherNowPoint=0; if (vehicleId==1){ - // TODO: 2022/2/26 获取RGV2当前位置 - otherNowPoint=1; + //获取RGV2当前位置 + Double rgv2CurrPosition = RGVCurrPosition(2); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - //type=1为 入 - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 39); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(2, currTaskId, 39); + if (status!=1){ + logger.info("===执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行成功==="); } }else { //获取RGV1当前位置 - otherNowPoint=2; + Double rgv1CurrPosition = RGVCurrPosition(1); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 1); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(1, currTaskId, 1); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行成功==="); } } - //新建一条执行任务的关系表存放任务执行信息 RunTask runTask=new RunTask(); runTask.setTaskId(currTask.getId()); @@ -125,34 +112,13 @@ public class AsynRunTaskService extends BaseService { setCommonField(runTask); runTask.setBeginTime(LocalDateTime.now()); runTaskServiceBiz.save(runTask); - // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果 + //调用车辆填入起终点,得到车辆执行结果 Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); - Map json = new HashMap(); - // taskType 1 搬运 - json.put("taskType", 1); - json.put("sendRow", endPoint); - json.put("pickRow",startPoint); - json.put("taskNo",currTaskId); - json.put("ideNumber",1); - json.put("processNumber",currTask.getPlcValue()); - String taskJson = JSON.toJSONString(json); - String result =null; - try { - if (vehicleId==1){ - result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); - } - if (vehicleId==2){ - result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); - } - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - } - JSONObject jsonObject = JSON.parseObject(result); - int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); //执行成功,托盘进炉 if (status==1){ + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setEndTime(LocalDateTime.now()); @@ -170,78 +136,54 @@ public class AsynRunTaskService extends BaseService { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); - logger.info("任务 "+currTask.getTaskCode()+" 车辆从液压台台到窑炉过程中失败。"); + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + logger.info("任务 "+currTask.getTaskCode()+" 车辆从液压台台到加工炉过程中失败。"); // TODO: 2021/12/14 websocket推送到前端,小车管理界面添加一个重置小车状态的接口。 + webSocketServer.sendtoAll("任务 "+currTask.getTaskCode()+" 车辆从液压台台到加工炉过程中失败。"); } } - // TODO: 2022/2/26 修改下面的 方法加上小车操作如上 //窑炉可用未满的情况下,调用车辆起点为缓存区终点为窑炉 - public void asynRunTaskForStockToKiln(Long stockInfokId,Long vehicleId){ + public void asynRunTaskForStockToKiln(Long stockInfokId,Long vehicleId) throws IOException { InStockInfo inStockInfo = inStockInfoServiceBiz.getById(stockInfokId); Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); Long currTaskId = inStockInfo.getTaskId(); CurrTask currTask = currTaskServiceBiz.getById(currTaskId); - Integer otherNowPoint=0; if (vehicleId==1){ - // TODO: 2022/2/26 获取RGV2当前位置 - otherNowPoint=1; + //获取RGV2当前位置 + Double rgv2CurrPosition = RGVCurrPosition(2); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(),currTask.getTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - //type=1为 入 - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 39); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(2, currTaskId, 39); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行成功==="); } }else { //获取RGV1当前位置 - otherNowPoint=2; + Double rgv1CurrPosition = RGVCurrPosition(1); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId,location.getCode(),currTask.getTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 1); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(1, currTaskId, 1); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行成功==="); } } -/* //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), currTask.getTargetPosition(), otherNowPoint); - if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - }*/ - //新建一条执行任务的关系表存放任务执行信息 RunTask runTask=new RunTask(); runTask.setTaskId(currTask.getId()); runTask.setTaskCode(currTask.getTaskCode()); runTask.setVehicleId(vehicleId); - // TODO: 2022/2/16 起点为库位 + // 起点为库位 runTask.setStartPosition(location.getCode()); runTask.setEndPosition(currTask.getTargetPosition()); setCommonField(runTask); @@ -250,34 +192,13 @@ public class AsynRunTaskService extends BaseService { //修改缓存区存储情况表状态 inStockInfo.setStatus(1); inStockInfoServiceBiz.updateById(inStockInfo); - // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果 + // 调用车辆填入起终点,得到车辆执行结果 Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); - Map json = new HashMap(); - // taskType 1 搬运 - json.put("taskType", 1); - json.put("sendRow", endPoint); - json.put("pickRow",startPoint); - json.put("taskNo",currTaskId); - json.put("ideNumber",1); - json.put("processNumber",currTask.getPlcValue()); - String taskJson = JSON.toJSONString(json); - String result =null; - try { - if (vehicleId==1){ - result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); - } - if (vehicleId==2){ - result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); - } - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - } - JSONObject jsonObject = JSON.parseObject(result); - int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); //执行成功,托盘进炉 if (status==1){ + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setEndTime(LocalDateTime.now()); @@ -299,64 +220,48 @@ public class AsynRunTaskService extends BaseService { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); - logger.info("任务 "+currTask.getTaskCode()+" 车辆从提升平台到窑炉过程中失败。"); + logger.info("任务 "+currTask.getTaskCode()+" 车辆从缓存区到加工炉过程中失败。"); + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + // TODO: 2021/12/14 websocket推送到前端,小车管理界面添加一个重置小车状态的接口。 // TODO: 2021/12/14 websocket推送到前端,执行失败后车辆在中途,缓存区存储情况怎么修改? + webSocketServer.sendtoAll("任务 "+currTask.getTaskCode()+" 车辆从缓存区到加工炉过程中失败。"); } } //窑炉已满,调用车辆起点为提升台,终点为缓存区 @Async("asyncServiceExecutor") - public void asynRunTaskToWarehouse(Long currTaskId,Long vehicleId){ + public void asynRunTaskToWarehouse(Long currTaskId,Long vehicleId) throws IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); Location location = locationServiceBiz.getById(currTask.getLocationId()); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); - Integer otherNowPoint=0; if (vehicleId==1){ - // TODO: 2022/2/26 获取RGV2当前位置 - otherNowPoint=1; + //获取RGV2当前位置 + Double rgv2CurrPosition = RGVCurrPosition(2); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv2CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - //type=1为 入 - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 39); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(2, currTaskId, 39); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行成功==="); } }else { //获取RGV1当前位置 - otherNowPoint=2; + Double rgv1CurrPosition = RGVCurrPosition(1); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv1CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 1); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(1, currTaskId, 1); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行成功==="); } } - PointInfo pointOfLocation = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask=new RunTask(); setCommonField(runTask); @@ -381,33 +286,12 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setType(1); setCommonField(inStockInfo); inStockInfoServiceBiz.save(inStockInfo); - // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) + // 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); - Map json = new HashMap(); - // taskType 1 搬运 - json.put("taskType", 1); - json.put("sendRow", endPoint); - json.put("pickRow",startPoint); - json.put("taskNo",currTaskId); - json.put("ideNumber",1); - json.put("processNumber",currTask.getPlcValue()); - String taskJson = JSON.toJSONString(json); - String result =null; - try { - if (vehicleId==1){ - result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); - } - if (vehicleId==2){ - result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); - } - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - } - JSONObject jsonObject = JSON.parseObject(result); - int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); if (status==1){ + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); @@ -429,70 +313,46 @@ public class AsynRunTaskService extends BaseService { runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); logger.info("任务 "+currTask.getTaskCode()+" 车辆从液压台到缓存区过程中失败。"); - // TODO: 2021/12/14 websocket推送到前端 + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + webSocketServer.sendtoAll("任务 "+currTask.getTaskCode()+" 车辆从液压台到缓存区过程中失败。"); } } //窑炉加工完成,调用车辆入库到缓存区 @Async("asyncServiceExecutor") - public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId){ + public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId) throws IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); - Integer otherNowPoint=0; if (vehicleId==1){ - // TODO: 2022/2/26 获取RGV2当前位置 - otherNowPoint=1; + //获取RGV2当前位置 + Double rgv2CurrPosition = RGVCurrPosition(2); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - //type=1为 入 - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 39); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(2, currTaskId, 39); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); + // 2022/3/6 websocket通知页面 + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行成功==="); } }else { //获取RGV1当前位置 - otherNowPoint=2; + Double rgv1CurrPosition = RGVCurrPosition(1); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), otherNowPoint); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - //若冲突 - // TODO: 2022/2/26 执行小车移位任务。移位任务完成后再判断是否冲突,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); - // taskType 4 单移动 - json.put("taskType", 4); - json.put("sendRow", 1); - String taskJson = JSON.toJSONString(json); - try { - HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - //wocket推送到页面 + Integer status = moveRgv(1, currTaskId, 1); + if (status!=1){ + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); + // 2022/3/6 websocket通知页面 + webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); return; } + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行成功==="); } } - // TODO: 2021/12/28 location排序 - Location location = locationServiceBiz.list(new QueryWrapper() - .eq(Location.STATUS, 1) - .eq(Location.VALID, 1)).get(0); - currTask.setOutStartPosition(currTask.getTargetPosition()); - // location对应的点位 - //String outTargetPosition = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())).getCode(); - currTask.setOutTargetPosition(location.getCode()); - currTaskServiceBiz.updateById(currTask); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask=new RunTask(); setCommonField(runTask); @@ -504,6 +364,7 @@ public class AsynRunTaskService extends BaseService { runTask.setEndPosition(currTask.getOutTargetPosition()); runTaskServiceBiz.save(runTask); //更新 location 表对应库位状态为占用 + Location location = locationServiceBiz.getOne(new QueryWrapper().eq(Location.CODE, currTask.getOutTargetPosition())); location.setStatus(1); location.setUpdateTime(LocalDateTime.now()); locationServiceBiz.updateById(location); @@ -522,33 +383,12 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setType(0); setCommonField(inStockInfo); inStockInfoServiceBiz.save(inStockInfo); - // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) + // 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号 Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); - Map json = new HashMap(); - // taskType 1 搬运 - json.put("taskType", 1); - json.put("sendRow", endPoint); - json.put("pickRow",startPoint); - json.put("taskNo",currTaskId); - json.put("ideNumber",1); - json.put("processNumber",currTask.getPlcValue()); - String taskJson = JSON.toJSONString(json); - String result =null; - try { - if (vehicleId==1){ - result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); - } - if (vehicleId==2){ - result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); - } - } catch (IOException e) { - e.printStackTrace(); - logger.error(new Date() + "WCS接口超时未响应!"); - } - JSONObject jsonObject = JSON.parseObject(result); - int status = Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); if (status==1){ + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); @@ -571,28 +411,65 @@ public class AsynRunTaskService extends BaseService { runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); logger.info("任务 "+currTask.getTaskCode()+" 车辆从窑炉到缓存区过程中失败。"); - // TODO: 2021/12/14 websocket推送到前端 + logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + // 2021/12/14 websocket推送到前端 + webSocketServer.sendtoAll("任务 "+currTask.getTaskCode()+" 车辆从窑炉到缓存区过程中失败。"); } } //出库。起点为缓存区库位,终点为提升台 @Async("asyncServiceExecutor") - public void asynRunOutStock(Long locationId){ + public void asynRunOutStock(Long locationId,String yeyaTaiCode,Long vehicleId) throws IOException { + Location location = locationServiceBiz.getById(locationId); + if (vehicleId==1){ + //获取RGV2当前位置 + Double rgv2CurrPosition = RGVCurrPosition(2); + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition); + if (conflictBoolean){ + Integer status = moveRgv(2, 1L, 39); + if (status!=1){ + logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); + // 2022/3/6 websocket通知页面 + webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); + return; + } + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行成功==="); + } + }else { + //获取RGV1当前位置 + Double rgv1CurrPosition = RGVCurrPosition(1); + //两辆小车是否冲突 + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition); + if (conflictBoolean){ + Integer status = moveRgv(1, 1L, 1); + if (status!=1){ + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); + // 2022/3/6 websocket通知页面 + webSocketServer.sendtoAll(LocalDateTime.now()+"执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); + return; + } + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行成功==="); + } + } RunTask runTask=new RunTask(); setCommonField(runTask); - //runTask.setVehicleId(vehicleId); + runTask.setVehicleId(vehicleId); runTask.setBeginTime(LocalDateTime.now()); - //runTask.setStartPosition(currTask.getOutStartPosition()); - //runTask.setEndPosition(currTask.getOutTargetPosition()); + runTask.setStartPosition(location.getCode()); + runTask.setEndPosition(yeyaTaiCode); runTaskServiceBiz.save(runTask); //修改缓存区状态 InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper() .eq("location_id", locationId)); - inStockInfo.setStatus(1); + inStockInfo.setStatus(0); inStockInfoServiceBiz.updateById(inStockInfo); - // TODO: 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) - - if (true){ + // 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号(出库任务,任务号为0) + Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); + Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); + Integer status = sendTaskToRgv(vehicleId, 0L, startPoint, endPoint, 0); + if (status==1){ + logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); @@ -608,7 +485,6 @@ public class AsynRunTaskService extends BaseService { inStockInfoHisServiceBiz.save(inStockInfoHis); inStockInfoServiceBiz.removeById(inStockInfo.getId()); //更新库位状态 - Location location = locationServiceBiz.getById(locationId); location.setStatus(0); locationServiceBiz.updateById(location); @@ -617,7 +493,9 @@ public class AsynRunTaskService extends BaseService { runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); logger.info("任务 "+runTask.getTaskCode()+" 车辆从缓存区到提升平台过程中失败。"); - // TODO: 2021/12/14 websocket推送到前端 + logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + // 2021/12/14 websocket推送到前端 + webSocketServer.sendtoAll("出库任务车辆从缓存区到提升平台过程中失败。"); } } //允许进炉信号为true,记录开始加工时的能源消耗数据,再写定时任务记录加工过程的消耗数据,再写一个异步方法,加工任务结束的时候记录一下各项消耗的值 @@ -1025,4 +903,101 @@ public class AsynRunTaskService extends BaseService { } return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); } + + /** + * RGV1的当前位置 + * id 小车表示 + * @return 小车位置值(距离原点的值) + */ + private Double RGVCurrPosition(Integer id){ + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + if (id==1){ + json.put("identifier","S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.CurrentPosition"); + } + if (id==2){ + json.put("identifier","S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.CurrentPosition"); + } + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取RGV1的当前位置失败"); + } + return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + } + + /** + * 移动RGV + * @param vehicleId 车辆id + * @param currTaskId 任务id + * @param sendRow 终点 + * @return json字符串 + */ + private Integer moveRgv(Integer vehicleId,Long currTaskId,Integer sendRow){ + //若冲突 + // 执行小车移位任务,移位任务可以直接让小车移位到两端 + Map json = new HashMap(); + //type=1为 入 + // taskType 4 单移动 + json.put("taskType", 4); + json.put("sendRow", sendRow); + String taskJson = JSON.toJSONString(json); + logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,即将执行车辆位移任务,车辆"+vehicleId+"移动到点位"+sendRow+"==="); + String result =null; + try { + if (vehicleId==1){ + result=HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + }else { + result=HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + } + + JSONObject jsonObject = JSON.parseObject(result); + return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + return -1; + } + } + + /** + * 发送搬运任务到RGV + * @param vehicleId RGV + * @param currTaskId 任务id + * @param startPoint 起点 + * @param endPoint 终点 + * @param processNumber 工艺好 + * @return status状态码 + */ + private Integer sendTaskToRgv(Long vehicleId,Long currTaskId,Long startPoint,Long endPoint,Integer processNumber){ + Map json = new HashMap(); + // taskType 1 搬运 + json.put("taskType", 1); + json.put("sendRow", endPoint); + json.put("pickRow",startPoint); + json.put("taskNo",currTaskId); + json.put("ideNumber",1); + json.put("processNumber",processNumber); + String taskJson = JSON.toJSONString(json); + String result =null; + logger.info("===执行任务:"+currTaskId+" ,即将执行车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"==="); + try { + if (vehicleId==1){ + result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + } + if (vehicleId==2){ + result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(new Date() + "WCS接口超时未响应!"); + } + JSONObject jsonObject = JSON.parseObject(result); + return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); + } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index c58bd88..af42c28 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -7,6 +7,7 @@ import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.websocket.WebSocketServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +37,6 @@ public class RunTaskUtils { @Resource private CurrTaskServiceBiz currTaskServiceBiz; @Resource - private RunTaskServiceBiz runTaskServiceBiz; - @Resource private LocationServiceBiz locationServiceBiz; @Resource private AsynRunTaskService asynRunTaskService; @@ -53,14 +52,16 @@ public class RunTaskUtils { private KilnInfoServiceBiz kilnInfoServiceBiz; @Resource private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz; + @Resource + private WebSocketServer webSocketServer; /** * 进炉加工 - * @param currTaskId - * @return + * @param currTaskId 任务id + * @return R * @throws InterruptedException */ - public R runTaskForInKiln(Long currTaskId) throws InterruptedException{ + public R runTaskForInKiln(Long currTaskId) throws InterruptedException, IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); //起点,起点和终点是液压台code、窑炉code、缓存区code String startPosition = currTask.getStartPosition(); @@ -92,7 +93,7 @@ public class RunTaskUtils { //有小车在运行,提示当前有车辆在运行,请稍后 return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); } - // TODO: 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态,能放两坨货的窑炉怎么判定状态? + // 2022/2/27 传入任务id,起始点,若终点是窑炉,获取窑炉状态,能放两坨货的窑炉怎么判定状态?(AllowIn) KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId()); String kilnNamePlace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() .eq(PlcNameSpace.EQ_TYPE, 0) @@ -119,9 +120,8 @@ public class RunTaskUtils { //异步调用车辆 asynRunTaskService.asynRunTask(currTask.getId(),vehicleId); return R.ok("操作成功,任务已开始执行。"); - } - //窑炉已满 - if (resultBoolean){ + } else { + //窑炉已满 //查询缓存区库位是否已满 int count = locationServiceBiz.count(new QueryWrapper() .eq(Location.STATUS, 0) @@ -157,16 +157,15 @@ public class RunTaskUtils { } return R.failed("当前目标窑炉已满!缓存区已满!请稍后重试!"); } - return null; } /** * 加工完成、出炉。传入窑炉id,查询正在该窑炉加工的currTask,查询是否有空闲车辆,有, * (查询是否为自动任务,是,查询下一步的窑炉是否空闲,是,调车去下一窑炉加工,否,暂存缓存区) - * 呼叫车辆暂存缓存区,车辆调度任务结束后,(结束后再查询缓存区队列避免车辆路线冲突)查询该窑炉的缓存区队列,开始下一托盘货物调度进窑炉 - * @return + * 呼叫车辆暂存缓存区,车辆调度任务结束后,(结束后再查询缓R存区队列避免车辆路线冲突)查询该窑炉的缓存区队列,开始下一托盘货物调度进窑炉 + * @return R */ - public R runTaskForOutKiln(Long kilnId){ + public R runTaskForOutKiln(Long kilnId) throws IOException { //查询正在该窑炉加工的currTask CurrTask currTask = currTaskServiceBiz.getOne(new QueryWrapper() .eq("is_in", 1) @@ -183,10 +182,10 @@ public class RunTaskUtils { Long taskId = autoExeTask.getTTaskId(); CurrTask currTaskTwo = currTaskServiceBiz.getById(taskId); try { - runTaskForInKiln(taskId); logger.info("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskTwo); - // TODO: 2022/2/27 websocket推送到页面显示 - return R.ok("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskTwo); + // 2022/2/27 websocket推送到页面显示 + webSocketServer.sendtoAll("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskTwo); + return runTaskForInKiln(taskId); } catch (InterruptedException e) { e.printStackTrace(); } @@ -201,10 +200,10 @@ public class RunTaskUtils { Long thTaskId = autoExeTask.getThTaskId(); CurrTask currTaskThree = currTaskServiceBiz.getById(thTaskId); try { - runTaskForInKiln(thTaskId); - logger.info("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskThree); - // TODO: 2022/2/27 websocket推送到页面显示 - return R.ok("自动任务第一步:"+currTask.getTaskCode()+"已执行完成。开始执行第二步任务:"+currTaskThree); + logger.info("自动任务第二步:"+currTask.getTaskCode()+"已执行完成。开始执行第三步任务:"+currTaskThree); + // 2022/2/27 websocket推送到页面显示 + webSocketServer.sendtoAll("自动任务第二步:"+currTask.getTaskCode()+"已执行完成。开始执行第三步任务:"+currTaskThree); + return runTaskForInKiln(thTaskId); } catch (InterruptedException e) { e.printStackTrace(); } @@ -231,11 +230,8 @@ public class RunTaskUtils { } //计算出路径最短的车辆id KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); - //窑炉为起点 - Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, kilnInfo.getCode())).getCode(); - //缓存区为终点 + //窑炉为起点,缓存区为终点 Location location = locationList.get(0); - Long targetPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())).getCode(); Long vehicleId = taskDistanceUtils.chooseVehicle(kilnInfo.getCode(), location.getCode()); //占用车辆 VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); @@ -246,8 +242,10 @@ public class RunTaskUtils { currTask.setIsOut(0); currTask.setTaskType(2); currTask.setUpdateTime(LocalDateTime.now()); + currTask.setOutStartPosition(kilnInfo.getCode()); + currTask.setOutTargetPosition(location.getCode()); currTaskServiceBiz.updateById(currTask); - // TODO: 2022/2/16 异步调用车辆 + // 2022/2/16 异步调用车辆 asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId()); return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); }else { @@ -255,6 +253,32 @@ public class RunTaskUtils { } } + /** + * 从缓存区出库 + * @param locationId 库位id + * @param yeyaTaiCode 液压台code + * @return R + */ + public R runTaskForOut(Long locationId,String yeyaTaiCode) throws IOException { + Location location = locationServiceBiz.getById(locationId); + //是否有小车在运行 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + if (vehicleInfoList.size()>0){ + //有小车在运行,提示当前有车辆在运行,请稍后 + return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); + } + //计算出路径最短的车辆id + Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), yeyaTaiCode); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + //异步调用车辆 + asynRunTaskService.asynRunOutStock(locationId,yeyaTaiCode,vehicleInfo.getId()); + return R.ok("操作成功,任务已开始执行。"); + } + /** * 获取变量值 * @param nameSpace nameSpace前缀 diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 8799f2b..3f382bf 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -66,14 +66,16 @@ public class ScheduledTask extends BaseService { * 查询加工完成的窑炉 */ @Scheduled - public void taskForStockToKiln(){ + public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); if (vehicleInfoList.size()==2){ //遍历currTask为进行中且is_in为正在加工的窑炉状态,若加工完毕,调用runTaskForOutKiln + // 2022/3/6 有两托的判定哪一托好了(通过开始加工时间顺序排列) List currTaskList = currTaskServiceBiz.list(new QueryWrapper() .eq(CurrTask.STATUS, 1) - .eq(CurrTask.IS_IN, 1)); + .eq(CurrTask.IS_IN, 1) + .orderByAsc(CurrTask.BEGIN_TIME)); for (CurrTask currTask :currTaskList ) { Long kilnId = currTask.getKilnId(); @@ -323,7 +325,7 @@ public class ScheduledTask extends BaseService { //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - public void runTaskForEmptyKiln(){ + public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); //存在空闲窑炉 @@ -361,11 +363,14 @@ public class ScheduledTask extends BaseService { List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList ) { - // TODO: 2022/2/28 判断炉子是否在工作状态 - if (true){ - PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() - .eq(PlcNameSpace.EQ_TYPE, 0) - .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())); + PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnInfo.getId())); + //判断炉子是否在工作状态 + String working = readPlcToString(kilnNameSpace.getName(), "Working"); + JSONObject jsonObject = JSON.parseObject(working); + Boolean aBoolean = Boolean.valueOf(String.valueOf(jsonObject.get("msg"))); + if (aBoolean){ //命名空间前缀 String nameSpace = kilnNameSpace.getNote(); //炉子的报警变量 @@ -396,7 +401,7 @@ public class ScheduledTask extends BaseService { alarmInfo.setEquipmentName(currTask.getKilnName()); alarmInfo.setType(0); alarmInfo.setAlarmCode(CodeGeneratorHelper.getAlarmCode()); - alarmInfo.setAlarmInfo(plcNameSpace.getNote()); + alarmInfo.setAlarmInfo(plcNameSpace.getEqName()+":"+plcNameSpace.getNote()); alarmInfo.setTaskCode(currTask.getTaskCode()); alarmInfo.setCreateTime(LocalDateTime.now()); alarmInfoServiceBiz.save(alarmInfo); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index 4c03438..e2ed9e5 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -1,13 +1,21 @@ package com.mt.wms.empty.task; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.dal.entity.PointInfo; import com.mt.wms.core.dal.service.PointInfoServiceBiz; +import com.mt.wms.core.utils.HttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @Author: liguanghao @@ -17,6 +25,8 @@ import java.util.List; @Component public class TaskDistanceUtils { + private final static Logger logger = LoggerFactory.getLogger(TaskDistanceUtils.class); + @Autowired private PointInfoServiceBiz pointInfoServiceBiz; /** @@ -26,34 +36,13 @@ public class TaskDistanceUtils { * @return 路径最短的小车id */ public Long chooseVehicle(String startPoint,String endPoint){ - Integer start = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getId(); - Integer end = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getId(); - //获取点位list - List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); - //计算任务起点到终点的距离 - List pointInfoListForTask = pointInfoList.subList(start - 1, end - 1); - Double taskDistance=0D; - for (PointInfo pointInfo:pointInfoListForTask - ) { - taskDistance=taskDistance+pointInfo.getDistance(); - } + Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getDistance(); + // 2022/2/19 两辆小车都空闲,获取出当前位置 + Double rgv1CurrPosition = RGVCurrPosition(1L); + Double rgv2CurrPosition = RGVCurrPosition(2L); //计算空闲小车当前位置到起点的距离 - // TODO: 2022/2/19 两辆小车都空闲,获取出当前位置 - Integer vehicle1=0; - Integer vehicle2=39; - List pointInfoListForVehicle1 = pointInfoList.subList((vehicle1vehicle1)?end:vehicle1 - 1); - List pointInfoListForVehicle2 = pointInfoList.subList((vehicle2vehicle2)?end:vehicle2 - 1); - //计算得出总距离最短的小车 - Double vehicle1Distance=0D; - for (PointInfo pointInfo:pointInfoListForVehicle1 - ) { - vehicle1Distance=vehicle1Distance+pointInfo.getDistance(); - } - Double vehicle2Distance=0D; - for (PointInfo pointInfo:pointInfoListForVehicle2 - ) { - vehicle2Distance=vehicle2Distance+pointInfo.getDistance(); - } + Double vehicle1Distance = Math.abs(startDistance - rgv1CurrPosition); + Double vehicle2Distance = Math.abs(startDistance - rgv2CurrPosition); return (vehicle1Distance< vehicle2Distance)?1L:2L; } /** @@ -78,31 +67,52 @@ public class TaskDistanceUtils { } //判断小车是否冲突,传入选定小车的id,任务起终点,另一小车位置。 - public Boolean conflictForVehicle(Long vehicle,String startPoint,String endPoint,Integer otherNowPoint){ - Integer start = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getId(); - Integer end = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getId(); + public Boolean conflictForVehicle(Long vehicleId,String startPoint,String endPoint,Double otherNowPosition){ + Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getDistance(); + Double endDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getDistance(); //获取点位list List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); - // TODO: 2022/2/19 获取小车当前位置 - Integer nowPoint=3; + // 2022/2/19 获取小车当前位置 + Double rgvCurrPosition = RGVCurrPosition(vehicleId); //计算小车当前位置到任务起点-任务起点到任务终点的路径点集合 //小车当前位置、起点、终点,找出最大最小值 - int min=(((nowPointstart)?nowPoint:start)>end)?((nowPoint>start)?nowPoint:start):end; + Double minDistance=(((rgvCurrPositionstartDistance)?rgvCurrPosition:startDistance)>endDistance)?((rgvCurrPosition>startDistance)?rgvCurrPosition:startDistance):endDistance; //另一辆小车在在小车路径上比如冲突,不在小车路径上时判定一下安全距离(4米) - if (otherNowPoint>=min&&otherNowPoint<=max){ + if (otherNowPosition>=minDistance&&otherNowPosition<=maxDistance){ return true; }else { - Double maxDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, max)).getDistance(); - Double minDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, min)).getDistance(); - Double otherVehicleDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, otherNowPoint)).getDistance(); - if (Math.abs(otherVehicleDistance-maxDistance)<4){ + if (Math.abs(otherNowPosition-maxDistance)<4){ return true; } - if (Math.abs(otherVehicleDistance-minDistance)<4){ + if (Math.abs(otherNowPosition-minDistance)<4){ return true; } return false; } } + /** + * RGV1的当前位置 + * id 小车表示 + * @return 小车位置值(距离原点的值) + */ + private Double RGVCurrPosition(Long id){ + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + if (id==1){ + json.put("identifier","S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.CurrentPosition"); + } + if (id==2){ + json.put("identifier","S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.CurrentPosition"); + } + String result = null; + try { + result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取RGV的当前位置失败"); + } + return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/MessageModule.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/MessageModule.java new file mode 100644 index 0000000..6f7e9d8 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/MessageModule.java @@ -0,0 +1,42 @@ +package com.mt.wms.empty.websocket; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * @Author: liguanghao + * @Date: 2021/11/4 18:42 + * @Version 1.0 + */ +@Component +public class MessageModule { + @Autowired + private WebSocketServer webSocketServer; + public boolean sendMessageToAll(String message) throws IOException { + try { + String msg = message+"|0"; + webSocketServer.onMessage(msg,null); + }catch (Exception e){ + e.printStackTrace(); + } + return true; + } + + public boolean sendMessageToSomeone(String message,String userId){ + /*String msg =message+"|"+userId; + try { + WebSocketServer webSocketServer1 = webSocketServer.getWebSocketSessions().get(userId); + if(webSocketServer1!=null){ + Session session1 = webSocketServer1.getSession(); + webSocketServer.onMessage(msg,session1); + }else { + return false; + } + }catch (RRException e){ + throw new RRException("websocket出现异常"); + }*/ + return true; + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketConfig.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketConfig.java new file mode 100644 index 0000000..0b689c2 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketConfig.java @@ -0,0 +1,14 @@ +package com.mt.wms.empty.websocket; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +@Configuration +public class WebSocketConfig { + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } + +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java new file mode 100644 index 0000000..a76cac4 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java @@ -0,0 +1,178 @@ +package com.mt.wms.empty.websocket; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.websocket.*; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 注意: + * 1.如果多个客户端来 连接 websocket,,那么 不要相同id。。如果是相同id只能发送一个。所以前端连接的id 号要由后台给出 getUniqeId() 这个方法 + * */ +//访问服务端的url地址 +@Component +@ServerEndpoint(value = "/qj/websocket/{id}") +public class WebSocketServer { + private static int onlineCount = 0; + private static ConcurrentHashMap webSocketSet = new ConcurrentHashMap<>(); + + + //前端的id 右后端给他 + public synchronized String getUniqeId(){ + return UUID.randomUUID().toString()+System.currentTimeMillis(); + } + + //与某个客户端的连接会话,需要通过它来给客户端发送数据 + private Session session; + private static Logger log = LogManager.getLogger(WebSocketServer.class); + private String id = ""; + + public Integer getCurrentNum(){ + return webSocketSet.size(); + } + + /** + * 连接建立成功调用的方法*/ + @OnOpen + public void onOpen(@PathParam(value = "id") String id, Session session) { + this.session = session; + this.id = id;//接收到发送消息的人员编号 + webSocketSet.put(id, this); //加入set中 + addOnlineCount(); //在线数加1 + //log.info("用户"+id+"加入!当前在线人数为" + getOnlineCount()); + try { + sendMessage("连接成功"); + + } catch (IOException e) { + log.error("websocket IO异常"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 连接关闭调用的方法 + */ + /*@OnClose + public void onClose() { + + webSocketSet.remove(this); //从set中删除 + subOnlineCount(); //在线数减1 + log.info("有一连接关闭!当前在线人数为" + getOnlineCount()); + }*/ + + // 关闭连接触发事件 + @OnClose + public void onClose(Session session, CloseReason closeReason) { + String[] uris = session.getRequestURI().toString().split("/"); + webSocketSet.remove(uris[uris.length-1]); + subOnlineCount(); + //log.info("有一连接关闭!当前在线人数为" + getOnlineCount()); + } + + /** + * 收到客户端消息后调用的方法 + * + * @param message 客户端发送过来的消息 + * */ + @OnMessage + public void onMessage(String message, Session session) throws Exception { + log.info("来自客户端的消息:" + message); + //可以自己约定字符串内容,比如 内容|0 表示信息群发,内容|X 表示信息发给id为X的用户 + String sendMessage = message; + String sendUserId = "0"; + if(sendMessage.equals("1")){ + } + + } +/* @OnMessage + public void onMessage(String message, Session session) { + log.info("来自客户端的消息:" + message); + //可以自己约定字符串内容,比如 内容|0 表示信息群发,内容|X 表示信息发给id为X的用户 + String sendMessage = message.split("[|]")[0]; + String sendUserId = message.split("[|]")[1]; + try { + if(sendUserId.equals("0")){ + sendtoAll(sendMessage); + } + else{ + sendtoUser(sendMessage,sendUserId); + } + } catch (IOException e) { + e.printStackTrace(); + } + + }*/ + + /** + * + * @param session + * @param error + */ + @OnError + public void onError(Session session, Throwable error) { + log.error("发生错误"); + error.printStackTrace(); + } + + + public void sendMessage(String message) throws IOException { + this.session.getBasicRemote().sendText(message); + } + + /** + * 发送信息给指定ID用户,如果用户不在线则返回不在线信息给自己 + * @param message + * @param sendUserId + * @throws IOException + */ + public void sendtoUser(String message,String sendUserId) throws IOException { + if (webSocketSet.get(sendUserId) != null) { + if(!id.equals(sendUserId)){ + webSocketSet.get(sendUserId).sendMessage( "用户" + id + "发来消息:" + "
" + message); + } + else{ + webSocketSet.get(sendUserId).sendMessage(message); + } + } else { + //如果用户不在线则返回不在线信息给自己 + sendtoUser("当前用户不在线",id); + } + } + + /** + * 发送信息给所有人 + * @param message + * @throws IOException + */ + public void sendtoAll(String message) throws IOException { + for (String key : webSocketSet.keySet()) { + try { + webSocketSet.get(key).sendMessage(message); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + + public static synchronized int getOnlineCount() { + return onlineCount; + } + + public static synchronized void addOnlineCount() { + WebSocketServer.onlineCount++; + } + + public static synchronized void subOnlineCount() { + WebSocketServer.onlineCount--; + } +} + From 2104ddc7fcc8b724816b050b5679a55a0e01ec92 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 19 Mar 2022 11:24:21 +0800 Subject: [PATCH 08/19] =?UTF-8?q?todo=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OutStockServiceImpl.java | 40 ++++--------------- .../wms/empty/websocket/WebSocketServer.java | 2 +- .../src/main/resources/config/application.yml | 1 + 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java index f5803f6..b830f57 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OutStockServiceImpl.java @@ -15,12 +15,14 @@ import com.mt.wms.core.vo.R; import com.mt.wms.empty.params.OutStockParam; import com.mt.wms.empty.service.OutStockService; import com.mt.wms.empty.task.AsynRunTaskService; +import com.mt.wms.empty.task.RunTaskUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.validation.constraints.NotNull; +import java.io.IOException; import java.time.LocalDateTime; import java.util.List; @@ -41,42 +43,16 @@ public class OutStockServiceImpl extends BaseService implements OutStockService private InStockInfoServiceBiz inStockInfoServiceBiz; @Resource private RunTaskServiceBiz runTaskServiceBiz; + @Resource + private RunTaskUtils runTaskUtils; @Override - public R outTask(OutStockParam outStockParam) { - // TODO: 2021/12/17 出库 + public R outTask(OutStockParam outStockParam) throws IOException { + // 2021/12/17 出库 Long locationId = outStockParam.getLocaltionId(); //提升台 - Integer code = outStockParam.getCode(); - //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆 - List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() - .eq(VehicleInfo.STATUS, 0) - .eq(VehicleInfo.VALID, 1)); - if (vehicleInfoList.size()>0){ - VehicleInfo vehicleInfo = vehicleInfoList.get(0); - vehicleInfo.setStatus(1); - vehicleInfo.setUpdateTime(LocalDateTime.now()); - vehicleInfoServiceBiz.updateById(vehicleInfo); - }else { - return R.failed("暂无可用车辆!请稍后重试!"); - } - //生成调度任务 - RunTask runTask=new RunTask(); - runTask.setBeginTime(LocalDateTime.now()); - runTask.setVehicleId(vehicleInfoList.get(0).getId()); - // TODO: 2021/12/22 库位id对应的位置 ,提升平台对应的位置 - runTask.setStartPosition("库位位置"); - runTask.setEndPosition("提升台位置"); - setCommonField(runTask); - runTaskServiceBiz.save(runTask); - //异步调用车辆 - asynRunTaskService.asynRunOutStock(locationId); - //修改库位状态 - InStockInfo inStockInfo = inStockInfoServiceBiz - .getOne(new QueryWrapper().eq("Location_id", locationId)); - inStockInfo.setStatus(1); - inStockInfoServiceBiz.updateById(inStockInfo); - return R.ok("操作成功"); + String code = outStockParam.getCode(); + return runTaskUtils.runTaskForOut(locationId,code); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java index a76cac4..181d097 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java @@ -46,7 +46,7 @@ public class WebSocketServer { this.id = id;//接收到发送消息的人员编号 webSocketSet.put(id, this); //加入set中 addOnlineCount(); //在线数加1 - //log.info("用户"+id+"加入!当前在线人数为" + getOnlineCount()); + log.info("用户"+id+"加入!当前在线人数为" + getOnlineCount()); try { sendMessage("连接成功"); diff --git a/6.program/wms-gateway/src/main/resources/config/application.yml b/6.program/wms-gateway/src/main/resources/config/application.yml index 9348986..6600ba6 100644 --- a/6.program/wms-gateway/src/main/resources/config/application.yml +++ b/6.program/wms-gateway/src/main/resources/config/application.yml @@ -89,6 +89,7 @@ wms: - /*/wechatLogin - /*/mobileLogin - /apms + - /qj/websocket/* #公共配置 common: From c1ce765634d1de1fae0d97cf25cd23b31f3ce1cc Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sat, 19 Mar 2022 22:40:38 +0800 Subject: [PATCH 09/19] =?UTF-8?q?websocket=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mt/wms/empty/task/ScheduledTask.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 3f382bf..b1d08fd 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -9,6 +9,7 @@ import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.CodeGeneratorHelper; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.websocket.WebSocketServer; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,6 +62,13 @@ public class ScheduledTask extends BaseService { private PointInfoServiceBiz pointInfoServiceBiz; @Resource private RunTaskUtils runTaskUtils; + @Resource + private WebSocketServer webSocketServer; + + @Scheduled(fixedDelay = 5000) + public void testWebsocket() throws IOException { + webSocketServer.sendtoAll(LocalDateTime.now()+"测试"); + } /** * 查询加工完成的窑炉 From c8119c5bd00e9a8d53bee909f10bd0d8479f3ecf Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sun, 20 Mar 2022 00:12:04 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/controller/VehicleController.java | 14 +++++++ .../com/mt/wms/empty/task/ScheduledTask.java | 38 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java index 45b4f93..c5e91a2 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java @@ -1,11 +1,14 @@ package com.mt.wms.basic.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.basic.params.VehicleParam; import com.mt.wms.basic.params.VehicleQueryParam; import com.mt.wms.basic.service.VehicleService; import com.mt.wms.basic.vo.VehicleVo; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.VehicleInfo; +import com.mt.wms.core.dal.service.VehicleInfoServiceBiz; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.utils.IDGenerator; import com.mt.wms.core.validator.groups.AddGroup; @@ -40,6 +43,8 @@ public class VehicleController extends BaseController { @Autowired private VehicleService vehicleService; + @Autowired + private VehicleInfoServiceBiz vehicleInfoServiceBiz; @PostMapping(value = "get") @ApiOperation(value = "获取车辆信息") private R get(@Validated @RequestBody IdParam idParam) { @@ -82,4 +87,13 @@ public class VehicleController extends BaseController { return successful(IDGenerator.gen("CL", "yyyyMMddHHmm", 2, "VEHICLE_CODE")); } + private R reset(){ + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + for (VehicleInfo vehicleInfo:vehicleInfoList + ) { + vehicleInfo.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicleInfo); + } + return successful("操作成功,车辆状态已重置为空闲!"); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index b1d08fd..647477a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -423,6 +423,15 @@ public class ScheduledTask extends BaseService { } + //监听车辆是否在线 + public void listenVehicleOnline() throws IOException { + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() + .eq(VehicleInfo.STATUS, 2)); + for (VehicleInfo vehicleInfo:vehicleInfoList + ) { + + } + } /** * 获取变量值 * @param nameSpace nameSpace前缀 @@ -465,4 +474,33 @@ public class ScheduledTask extends BaseService { } return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); } + + private Boolean rgvOnline(Long vehicleId) throws IOException { + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + // TODO: 2022/3/19 小车的命名空间 + String identifier=null; + if (vehicleId==1){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; + } + if (vehicleId==2){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; + } + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier+"Online"); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取小车1当前是否在线失败"); + } + Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (!aBoolean){ + webSocketServer.sendtoAll(vehicleInfo.getVehicleName()+"当前不在线,请人工确认车辆状态,如不能恢复未在线状态,请尽快手动移动车辆到轨道尽头,以避免车辆阻碍任务执行!"); + return false; + } + return true; + } } From 186a28bffc66fb485611a5455fb5a4dfe2617387 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sun, 20 Mar 2022 21:41:49 +0800 Subject: [PATCH 11/19] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 6.program/pom.xml | 12 +- .../basic/controller/VehicleController.java | 2 + .../com/mt/wms/core/utils/HttpClient.java | 4 +- .../empty/controller/EnergyController.java | 122 ++++++---- .../service/impl/StockInfoServiceImpl.java | 2 +- .../mt/wms/empty/task/AsynRunTaskService.java | 48 ++-- .../com/mt/wms/empty/task/RunTaskUtils.java | 119 +++++++++- .../com/mt/wms/empty/task/ScheduledTask.java | 158 ++++++------- .../mt/wms/empty/task/TaskDistanceUtils.java | 82 ++++++- .../src/main/resources/config/application.yml | 10 +- .../src/main/resources/logback.xml | 214 +++++++++++++++++- 11 files changed, 602 insertions(+), 171 deletions(-) diff --git a/6.program/pom.xml b/6.program/pom.xml index 6b6c260..1f7fa6f 100644 --- a/6.program/pom.xml +++ b/6.program/pom.xml @@ -45,11 +45,11 @@ guest guest - redis.picaiba.com:6380 + jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false @@ -98,11 +98,11 @@ wms wms - redis.picaiba.com:6380 + jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false @@ -149,11 +149,11 @@ wms wms - 127.0.0.1:6379 + jdbc:p6spy:mysql://localhost:3306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java index c5e91a2..ef35e72 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java @@ -87,6 +87,8 @@ public class VehicleController extends BaseController { return successful(IDGenerator.gen("CL", "yyyyMMddHHmm", 2, "VEHICLE_CODE")); } + @PostMapping(value = "resetStatus") + @ApiOperation(value = "重置车辆状态") private R reset(){ List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); for (VehicleInfo vehicleInfo:vehicleInfoList diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java index ed1b953..dcb93ab 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java @@ -49,8 +49,8 @@ public class HttpClient { public static String httpPost(String url, String json) throws IOException { //OkHttpClient httpClient = new OkHttpClient(); OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(300L, TimeUnit.SECONDS) - .writeTimeout(300, TimeUnit.SECONDS) - .readTimeout(300, TimeUnit.SECONDS) + .writeTimeout(60*30, TimeUnit.SECONDS) + .readTimeout(60*30, TimeUnit.SECONDS) .build(); RequestBody requestBody = RequestBody.create(JSON, json); Request request = new Request.Builder() diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index a4cccea..a4f6259 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.validation.groups.Default; +import java.math.BigDecimal; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalDateTime; @@ -79,6 +80,8 @@ public class EnergyController extends BaseController { private KilnInfoServiceBiz kilnInfoServiceBiz; @Autowired private CurrTaskServiceBiz currTaskServiceBiz; + @Autowired + private TaskHisServiceBiz taskHisServiceBiz; @PostMapping(value = "eletric") @ApiOperation(value = "根据窑炉id获取消耗情况") @@ -215,8 +218,7 @@ public class EnergyController extends BaseController { @PostMapping(value = "energyList") @ApiOperation(value = "根据加工炉id获取能源消耗情况") public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ - electricQueryParam.getTaskId(); - CurrTask currTask = currTaskServiceBiz.getById(electricQueryParam.getTaskId()); + TaskHis currTask = taskHisServiceBiz.getById(electricQueryParam.getTaskId()); Long kilnId = currTask.getKilnId(); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); Integer kilnType = kilnInfo.getType(); @@ -224,25 +226,33 @@ public class EnergyController extends BaseController { JSONObject jsonObject=new JSONObject(); ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build(); - Map map=new HashMap(); + Map map=new HashMap<>(); //电能消耗 List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() .eq(ParEleValue.KILN_ID, kilnId) .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parEleValueList.size()>0){ - List eleList=new ArrayList(); + List eleList=new ArrayList<>(); //电能消耗 - List eleConsume=new ArrayList<>(); + List eleConsume=new ArrayList<>(); //A向电压 - List aVolConsume=new ArrayList<>(); + List aVolConsume=new ArrayList<>(); //B向电压 - List bVolConsume=new ArrayList<>(); + List bVolConsume=new ArrayList<>(); //C向电压 - List cVolConsume=new ArrayList<>(); + List cVolConsume=new ArrayList<>(); + Float talBat=0F; + int i=0; for (ParEleValue parEleValue:parEleValueList ) { + //首位置为0 + if (i==0){ + talBat=parEleValue.getTotalBat(); + } + + i++; map.put("time",parEleValue.getCreateTime()); - map.put("value",parEleValue.getTotalBat()); + map.put("value",floatSubtract(parEleValue.getTotalBat(),talBat)); map.put("name","耗电量"); map.put("unit","KW"); eleConsume.add(JSONObject.toJSON(map)); @@ -278,37 +288,50 @@ public class EnergyController extends BaseController { .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parGasValueList.size()>0){ if (kilnType==1){ - List gasList=new ArrayList(); + List gasList=new ArrayList<>(); //氮气 - List nitConsume=new ArrayList<>(); + List nitConsume=new ArrayList<>(); + Float nit=0F; //甲醇 - List metConsume=new ArrayList<>(); + List metConsume=new ArrayList<>(); + Float met=0F; //丙烷 - List propaneConsume=new ArrayList<>(); + List propaneConsume=new ArrayList<>(); + Float propane=0F; //氨气 - List ammoniaConsume=new ArrayList<>(); + List ammoniaConsume=new ArrayList<>(); + Float ammonia=0F; + int i=0; for (ParGasValue parGasValue:parGasValueList ) { + //累计值的量首位置为0 + if (i==0){ + nit=parGasValue.getNitFlowValue(); + met=parGasValue.getMethanolFlow(); + propane=parGasValue.getPropaneFlow(); + ammonia=parGasValue.getAmmoniaFlowValue(); + } + i++; map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getNitFlowValue()); + map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); map.put("name","氮气"); map.put("unit","m³"); nitConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getMethanolFlow()); + map.put("value",floatSubtract(parGasValue.getMethanolFlow(),met)); map.put("name","甲醇"); map.put("unit","m³"); metConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getPropaneFlow()); + map.put("value",floatSubtract(parGasValue.getPropaneFlow(),propane)); map.put("name","丙烷"); map.put("unit","m³"); propaneConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getAmmoniaFlowValue()); + map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); map.put("name","氨气"); map.put("unit","m³"); ammoniaConsume.add(JSONObject.toJSON(map)); @@ -321,29 +344,40 @@ public class EnergyController extends BaseController { jsonObject.put("gas",gasList); } if (kilnType==3){ - List gasList=new ArrayList(); + List gasList=new ArrayList<>(); //氮气 - List nitConsume=new ArrayList<>(); + List nitConsume=new ArrayList<>(); + Float nit=0F; //二氧化碳 - List carbonConsume=new ArrayList<>(); + List carbonConsume=new ArrayList<>(); + Float carbon=0F; //氨气 - List ammoniaConsume=new ArrayList<>(); + List ammoniaConsume=new ArrayList<>(); + Float ammonia=0F; + int i=0; for (ParGasValue parGasValue:parGasValueList ) { + //累计值的量首位置为0 + if (i==0){ + nit=parGasValue.getNitFlowValue(); + carbon=parGasValue.getCarDioxideFlowValue(); + ammonia=parGasValue.getAmmoniaFlowValue(); + } + i++; map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getNitFlowValue()); + map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); map.put("name","氮气"); map.put("unit","m³"); nitConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getCarDioxideFlowValue()); + map.put("value",floatSubtract(parGasValue.getCarDioxideFlowValue(),carbon)); map.put("name","二氧化碳"); map.put("unit","m³"); carbonConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parGasValue.getCreateTime()); - map.put("value",parGasValue.getAmmoniaFlowValue()); + map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); map.put("name","氨气"); map.put("unit","m³"); ammoniaConsume.add(JSONObject.toJSON(map)); @@ -361,9 +395,9 @@ public class EnergyController extends BaseController { .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parRotSpeedValueList.size()>0){ if (kilnType==1){ - List rotList=new ArrayList(); - List rot1Consume=new ArrayList<>(); - List rot2Consume=new ArrayList<>(); + List rotList=new ArrayList<>(); + List rot1Consume=new ArrayList<>(); + List rot2Consume=new ArrayList<>(); for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList ) { map.put("time",parRotSpeedValue.getCreateTime()); @@ -390,11 +424,11 @@ public class EnergyController extends BaseController { .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); if (parTemValueList.size()>0){ if (kilnType==1){ - List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List actualOilTempConsume=new ArrayList<>(); - List setupOilTempConsume=new ArrayList<>(); + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List actualOilTempConsume=new ArrayList<>(); + List setupOilTempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { map.put("time",parTemValue.getCreateTime()); @@ -429,9 +463,9 @@ public class EnergyController extends BaseController { jsonObject.put("temp",tempList); } if (kilnType==2){ - List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { map.put("time",parTemValue.getCreateTime()); @@ -453,11 +487,11 @@ public class EnergyController extends BaseController { } if (kilnType==3){ - List tempList=new ArrayList(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List outerZone1TempConsume=new ArrayList<>(); - List outerZone2TempConsume=new ArrayList<>(); + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List outerZone1TempConsume=new ArrayList<>(); + List outerZone2TempConsume=new ArrayList<>(); for (ParTemValue parTemValue:parTemValueList ) { map.put("time",parTemValue.getCreateTime()); @@ -479,6 +513,7 @@ public class EnergyController extends BaseController { outerZone1TempConsume.add(JSONObject.toJSON(map)); map.clear(); map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOuterZone2Temp()); map.put("name","外二区温度"); map.put("unit","℃"); @@ -494,5 +529,10 @@ public class EnergyController extends BaseController { } return R.ok(jsonObject.toJSONString()); } + private Float floatSubtract(Float a,Float b){ + BigDecimal a1 = new BigDecimal(Float.toString(a)); + BigDecimal b1 = new BigDecimal(Float.toString(b)); + return a1.subtract(b1).floatValue(); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java index d06772e..f819ca0 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/StockInfoServiceImpl.java @@ -42,7 +42,7 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic private OrderInfoServiceBiz orderInfoServiceBiz; @Override public R> get(IdParam idParam) { - Long taskId = inStockInfoServiceBiz.getById(idParam).getTaskId(); + Long taskId = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.LOCATION_ID,idParam.getId())).getTaskId(); List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq("curr_task_id", taskId)); List currTaskDetVoList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 79da967..733b89d 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -109,7 +109,6 @@ public class AsynRunTaskService extends BaseService { runTask.setVehicleId(vehicleId); runTask.setStartPosition(currTask.getStartPosition()); runTask.setEndPosition(currTask.getTargetPosition()); - setCommonField(runTask); runTask.setBeginTime(LocalDateTime.now()); runTaskServiceBiz.save(runTask); //调用车辆填入起终点,得到车辆执行结果 @@ -149,6 +148,7 @@ public class AsynRunTaskService extends BaseService { Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); Long currTaskId = inStockInfo.getTaskId(); CurrTask currTask = currTaskServiceBiz.getById(currTaskId); + VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); if (vehicleId==1){ //获取RGV2当前位置 Double rgv2CurrPosition = RGVCurrPosition(2); @@ -186,7 +186,6 @@ public class AsynRunTaskService extends BaseService { // 起点为库位 runTask.setStartPosition(location.getCode()); runTask.setEndPosition(currTask.getTargetPosition()); - setCommonField(runTask); runTask.setBeginTime(LocalDateTime.now()); runTaskServiceBiz.save(runTask); //修改缓存区存储情况表状态 @@ -216,6 +215,9 @@ public class AsynRunTaskService extends BaseService { currTask.setRunTaskId(runTask.getId()); currTask.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); + //更新小车状态 + vehicle.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicle); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -264,7 +266,6 @@ public class AsynRunTaskService extends BaseService { } //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask=new RunTask(); - setCommonField(runTask); runTask.setTaskId(currTask.getId()); runTask.setTaskCode(currTask.getTaskCode()); runTask.setVehicleId(vehicleId); @@ -284,7 +285,7 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setLocationId(location.getId()); inStockInfo.setLocationName(location.getLocationNameAlias()); inStockInfo.setType(1); - setCommonField(inStockInfo); + inStockInfo.setCreateTime(LocalDateTime.now()); inStockInfoServiceBiz.save(inStockInfo); // 调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认) Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); @@ -299,6 +300,7 @@ public class AsynRunTaskService extends BaseService { runTaskServiceBiz.updateById(runTask); //更新currTask表 currTask.setCacheSatatus(2); + currTask.setStatus(3); currTask.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); //更新in_stock_info表 @@ -355,7 +357,6 @@ public class AsynRunTaskService extends BaseService { } //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask=new RunTask(); - setCommonField(runTask); runTask.setTaskId(currTask.getId()); runTask.setTaskCode(currTask.getTaskCode()); runTask.setVehicleId(vehicleId); @@ -380,8 +381,7 @@ public class AsynRunTaskService extends BaseService { inStockInfo.setKilnName(currTask.getKilnName()); inStockInfo.setLocationId(location.getId()); inStockInfo.setLocationName(location.getLocationNameAlias()); - inStockInfo.setType(0); - setCommonField(inStockInfo); + inStockInfo.setCreateTime(LocalDateTime.now()); inStockInfoServiceBiz.save(inStockInfo); // 2021/12/14 调用车辆填入起终点,得到车辆执行结果,填入任务号 Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); @@ -426,7 +426,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, 1L, 39); + Integer status = moveRgv(2, 1L, 1); if (status!=1){ logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); // 2022/3/6 websocket通知页面 @@ -441,7 +441,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, 1L, 1); + Integer status = moveRgv(1, 1L, 12); if (status!=1){ logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); // 2022/3/6 websocket通知页面 @@ -452,7 +452,7 @@ public class AsynRunTaskService extends BaseService { } } RunTask runTask=new RunTask(); - setCommonField(runTask); + // setCommonField(runTask); runTask.setVehicleId(vehicleId); runTask.setBeginTime(LocalDateTime.now()); runTask.setStartPosition(location.getCode()); @@ -470,7 +470,7 @@ public class AsynRunTaskService extends BaseService { Integer status = sendTaskToRgv(vehicleId, 0L, startPoint, endPoint, 0); if (status==1){ logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); - //更新关系表状态为完成 + //更新调度任务表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); runTask.setStatus(2); runTask.setEndTime(LocalDateTime.now()); @@ -487,13 +487,17 @@ public class AsynRunTaskService extends BaseService { //更新库位状态 location.setStatus(0); locationServiceBiz.updateById(location); - + //更新车辆状态 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicleInfo); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); runTaskServiceBiz.updateById(runTask); logger.info("任务 "+runTask.getTaskCode()+" 车辆从缓存区到提升平台过程中失败。"); logger.info("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); + System.out.println("===执行任务出库任务,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行失败==="); // 2021/12/14 websocket推送到前端 webSocketServer.sendtoAll("出库任务车辆从缓存区到提升平台过程中失败。"); } @@ -896,7 +900,7 @@ public class AsynRunTaskService extends BaseService { json.put("identifier",identifier); String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("能源消耗统计:获取 "+identifier+" 的值失败"); @@ -921,12 +925,13 @@ public class AsynRunTaskService extends BaseService { } String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("获取RGV1的当前位置失败"); } - return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + Double value = Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + return value*0.0001; } /** @@ -942,16 +947,21 @@ public class AsynRunTaskService extends BaseService { Map json = new HashMap(); //type=1为 入 // taskType 4 单移动 + json.put("taskType", 4); json.put("sendRow", sendRow); + json.put("pickRow",0); + json.put("taskNo",1); + json.put("ideNumber",1); + json.put("processNumber",1); String taskJson = JSON.toJSONString(json); logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,即将执行车辆位移任务,车辆"+vehicleId+"移动到点位"+sendRow+"==="); String result =null; try { if (vehicleId==1){ - result=HttpClient.httpPost("http://localhost:8009/rgv2/sendTask",taskJson); + result=HttpClient.httpPost("http://192.168.6.51:8009/rgv1/sendTask",taskJson); }else { - result=HttpClient.httpPost("http://localhost:8009/rgv1/sendTask",taskJson); + result=HttpClient.httpPost("http://192.168.6.51:8009/rgv2/sendTask",taskJson); } JSONObject jsonObject = JSON.parseObject(result); @@ -987,10 +997,10 @@ public class AsynRunTaskService extends BaseService { logger.info("===执行任务:"+currTaskId+" ,即将执行车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"==="); try { if (vehicleId==1){ - result = HttpClient.httpPost("http://localhost:8009/rgv1/sendTask", taskJson); + result = HttpClient.httpPost("http://192.168.6.51:8009/rgv1/sendTask", taskJson); } if (vehicleId==2){ - result = HttpClient.httpPost("http://localhost:8009/rgv2/sendTask", taskJson); + result = HttpClient.httpPost("http://192.168.6.51:8009/rgv2/sendTask", taskJson); } } catch (IOException e) { e.printStackTrace(); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index af42c28..e912a2f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -66,18 +66,23 @@ public class RunTaskUtils { //起点,起点和终点是液压台code、窑炉code、缓存区code String startPosition = currTask.getStartPosition(); PointInfo startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, startPosition)); - // 可以根据点位类型判断起点是否为液压台 + // 可以根据点位类型判断起点是否为液压台(2是液压台) Integer startPointType = startPoint.getType(); - if (startPointType==3){ + if (startPointType==2){ Map yeya = new HashMap(); //type=1为 入 yeya.put("type", 1); - yeya.put("number", startPoint.getCode()); + if ("YYT003".equals(startPoint.getNote())){ + yeya.put("number", 2); + } + if ("YYT004".equals(startPoint.getNote())){ + yeya.put("number", 1); + } String yeyaJudgeStatus = JSON.toJSONString(yeya); //判断起点液压台是否已放货且提升到位 String yeyaStatus=null; try { - yeyaStatus = HttpClient.httpPost("http://localhost:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus); + yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus); } catch (IOException e) { e.printStackTrace(); logger.error(new Date() + "WCS接口超时未响应!"); @@ -108,6 +113,9 @@ public class RunTaskUtils { if (resultBoolean){ //计算出路径最短的车辆id Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition()); + if (vehicleId==0){ + return R.failed("两辆车都不在线,请检查后重试!"); + } //占用车辆 VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); vehicleInfo.setStatus(1); @@ -130,7 +138,7 @@ public class RunTaskUtils { if (count >0) { //分配一个缓存区库位 Location location = locationServiceBiz.list(new QueryWrapper() - .eq(Location.STATUS, 1) + .eq(Location.STATUS, 0) .eq(Location.VALID, 1)).get(0); //更新 location 表对应库位状态为占用 location.setStatus(1); @@ -140,6 +148,9 @@ public class RunTaskUtils { PointInfo pointInfo = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, location.getCode())); //计算出路径最短的车辆id,起点液压台,终点缓存区库位点 Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), location.getCode()); + if (vehicleId==0){ + return R.failed("两辆车都不在线,请检查后重试!"); + } //占用车辆 VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); vehicleInfo.setStatus(1); @@ -233,6 +244,9 @@ public class RunTaskUtils { //窑炉为起点,缓存区为终点 Location location = locationList.get(0); Long vehicleId = taskDistanceUtils.chooseVehicle(kilnInfo.getCode(), location.getCode()); + if (vehicleId==0){ + return R.failed("两辆车都不在线,请检查后重试!"); + } //占用车辆 VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); vehicleInfo.setStatus(1); @@ -267,8 +281,17 @@ public class RunTaskUtils { //有小车在运行,提示当前有车辆在运行,请稍后 return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!"); } + Boolean platFormStatus = platFormStatus(yeyaTaiCode); + if (!platFormStatus){ + // TODO: 2022/3/19 delete + System.out.println("当前选定的液压台为在线或未提升到位,请检查后重试!"); + return R.failed("当前选定的液压台为在线或未提升到位,请检查后重试!"); + } //计算出路径最短的车辆id Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), yeyaTaiCode); + if (vehicleId==0){ + return R.failed("两辆车都不在线,请检查后重试!"); + } //占用车辆 VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); vehicleInfo.setStatus(1); @@ -276,6 +299,8 @@ public class RunTaskUtils { vehicleInfoServiceBiz.updateById(vehicleInfo); //异步调用车辆 asynRunTaskService.asynRunOutStock(locationId,yeyaTaiCode,vehicleInfo.getId()); + // TODO: 2022/3/19 + System.out.println("操作成功,任务已开始执行。"); return R.ok("操作成功,任务已开始执行。"); } @@ -293,7 +318,7 @@ public class RunTaskUtils { json.put("identifier",identifier); String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("readPLC: "+identifier+" 的值失败"); @@ -301,4 +326,86 @@ public class RunTaskUtils { return result; } + /** + * 判断液压台是否准备好放货 + * @param platFormCode 液压台编码 + * @return 是/否 + */ + private Boolean platFormStatus(String platFormCode){ + String identifier=null; + if ("YYT001".equals(platFormCode)){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier+"Online"); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取液压台1当前是否在线失败"); + } + Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (aBoolean){ + Map statusJson = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier+"TaskState"); + String statusResult = null; + try { + statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取液压台1当前状态失败"); + } + Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString()); + if (status==1){ + return true; + }else { + return false; + } + }else { + return false; + } + } + if ("YYT002".equals(platFormCode)){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS."; + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier+"Online"); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取液压台2当前是否在线失败"); + } + Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (aBoolean){ + Map statusJson = new HashMap(); + statusJson.put("nameSpace", 6); + statusJson.put("plcName", "plc1"); + statusJson.put("identifier",identifier+"TaskState"); + String statusResult = null; + try { + statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取液压台2当前状态失败"); + } + Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString()); + if (status==1){ + return true; + }else { + return false; + } + }else { + return false; + } + } + return false; + } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 647477a..1957f24 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -15,6 +15,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.io.IOException; @@ -28,6 +29,7 @@ import java.util.Map; * @Date: 2021/12/13 19:54 * @Version 1.0 */ +@Component public class ScheduledTask extends BaseService { private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class); @@ -65,7 +67,6 @@ public class ScheduledTask extends BaseService { @Resource private WebSocketServer webSocketServer; - @Scheduled(fixedDelay = 5000) public void testWebsocket() throws IOException { webSocketServer.sendtoAll(LocalDateTime.now()+"测试"); } @@ -73,7 +74,6 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的窑炉 */ - @Scheduled public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -105,23 +105,24 @@ public class ScheduledTask extends BaseService { } - //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。 + //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 + //@Scheduled(fixedDelay = 1000*30) public void getFastValue(){ //加工炉列表 List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); for (KilnInfo kilnInfo:kilnInfoList ) { PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() - .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) - .eq(PlcNameSpace.TYPE,1)); + .eq(PlcNameSpace.TYPE,0)); String nameSpaceNote = nameSpace.getName(); String result = readPlcToString(nameSpaceNote, "Working"); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); //该炉子在工作中 if (resultBoolean){ Long kilnId = kilnInfo.getId(); - String identificationNumber = readPlcToString(nameSpaceNote, "Identification number"); + String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); //加工炉 if (kilnInfo.getType()==1){ @@ -134,7 +135,7 @@ public class ScheduledTask extends BaseService { parRotSpeedValue.setOilStiSpeedAValue(oilStirringSpeed2.floatValue()); parRotSpeedValue.setKilnId(kilnId); parRotSpeedValue.setTaskId(currTaskId); - setCommonField(parRotSpeedValue); + parRotSpeedValue.setCreateTime(LocalDateTime.now()); parRotSpeedValueServiceBiz.save(parRotSpeedValue); //氮气 Double nitrogenFlow = readPlc(nameSpaceNote, "NitrogenFlow"); @@ -157,7 +158,7 @@ public class ScheduledTask extends BaseService { parGasValue.setSetNitPotValue(setupCarbon.floatValue()); parGasValue.setKilnId(kilnId); parGasValue.setTaskId(currTaskId); - setCommonField(parGasValue); + parGasValue.setCreateTime(LocalDateTime.now()); parGasValueServiceBiz.save(parGasValue); } //氮化炉 @@ -175,7 +176,7 @@ public class ScheduledTask extends BaseService { //氮气量 Double nitrogenFlow=readPlc(nameSpaceNote,"NitrogenFlow"); //二氧化碳量 - Double carbonDioxideFlow = readPlc(nameSpaceNote, "CarbonDioxideFlow"); + Double carbonDioxideFlow = readPlc(nameSpaceNote, "CO2Flow"); ParGasValue parGasValue3=new ParGasValue(); parGasValue3.setNitFlowValue(nitrogenFlow.floatValue()); parGasValue3.setAmmoniaFlowValue(ammoniaFlow.floatValue()); @@ -185,27 +186,29 @@ public class ScheduledTask extends BaseService { parGasValue3.setDecompositionRate(decompositionRate.floatValue()); parGasValue3.setKilnId(kilnId); parGasValue3.setTaskId(currTaskId); - setCommonField(parGasValue3); + parGasValue3.setCreateTime(LocalDateTime.now()); parGasValueServiceBiz.save(parGasValue3); } } } } - //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。 + //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 + //@Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ + System.out.println("开始采集数据"); List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList ) { PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() - .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.EQ_ID, kilnInfo.getId()) - .eq(PlcNameSpace.TYPE,1)); + .eq(PlcNameSpace.TYPE,0)); String nameSpaceNote = nameSpace.getName(); String result = readPlcToString(nameSpaceNote, "Working"); Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); if (resultBoolean){ Long kilnId = kilnInfo.getId(); - String identificationNumber = readPlcToString(nameSpaceNote, "Identification number"); + String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); //加工炉 if (kilnInfo.getType()==1){ @@ -224,7 +227,7 @@ public class ScheduledTask extends BaseService { parTemValue.setOilTankActTemValue(actualOilTemp.floatValue()); parTemValue.setKilnId(kilnId); parTemValue.setTaskId(currTaskId); - setCommonField(parTemValue); + parTemValue.setCreateTime(LocalDateTime.now()); parTemValueServiceBiz.save(parTemValue); //电度值 Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); @@ -239,7 +242,7 @@ public class ScheduledTask extends BaseService { parEleValue.setTotalBat(electricalValue.floatValue()); parEleValue.setKilnId(kilnId); parEleValue.setTaskId(currTaskId); - setCommonField(parEleValue); + parEleValue.setCreateTime(LocalDateTime.now()); parEleValueServiceBiz.save(parEleValue); } //回火炉 @@ -253,14 +256,14 @@ public class ScheduledTask extends BaseService { parTemValue2.setActTemValue(actualTemp.floatValue()); parTemValue2.setKilnId(kilnId); parTemValue2.setTaskId(currTaskId); - setCommonField(parTemValue2); + parTemValue2.setCreateTime(LocalDateTime.now()); parTemValueServiceBiz.save(parTemValue2); //电度值 Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); //A向电压 - Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); - Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); - Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage"); ParEleValue parEleValue2=new ParEleValue(); parEleValue2.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue2.setAVoltagevValue(phaseBVoltage.floatValue()); @@ -268,7 +271,7 @@ public class ScheduledTask extends BaseService { parEleValue2.setTotalBat(electricalValue.floatValue()); parEleValue2.setKilnId(kilnId); parEleValue2.setTaskId(currTaskId); - setCommonField(parEleValue2); + parEleValue2.setCreateTime(LocalDateTime.now()); parEleValueServiceBiz.save(parEleValue2); } //氮化炉 @@ -291,7 +294,7 @@ public class ScheduledTask extends BaseService { parTemValue3.setFurnacePressure(furnacePressure.floatValue()); parTemValue3.setKilnId(kilnId); parTemValue3.setTaskId(currTaskId); - setCommonField(parTemValue3); + parTemValue3.setCreateTime(LocalDateTime.now()); parTemValueServiceBiz.save(parTemValue3); //电度值 Double electricalValue = readPlc(nameSpaceNote,"ElectricalValue"); @@ -306,7 +309,7 @@ public class ScheduledTask extends BaseService { parEleValue3.setTotalBat(electricalValue.floatValue()); parEleValue3.setKilnId(kilnId); parEleValue3.setTaskId(currTaskId); - setCommonField(parEleValue3); + parEleValue3.setCreateTime(LocalDateTime.now()); parEleValueServiceBiz.save(parEleValue3); } //清洗炉 @@ -314,9 +317,9 @@ public class ScheduledTask extends BaseService { //电度值 Double electricalValue = readPlc(nameSpaceNote,"TotalElectricity"); //A向电压 - Double phaseAVoltage = readPlc(nameSpaceNote,"PhaseAVoltage"); - Double phaseBVoltage = readPlc(nameSpaceNote, "PhaseBVoltage"); - Double phaseCVoltage = readPlc(nameSpaceNote, "PhaseCVoltage"); + Double phaseAVoltage = readPlc(nameSpaceNote,"AVoltage"); + Double phaseBVoltage = readPlc(nameSpaceNote, "BVoltage"); + Double phaseCVoltage = readPlc(nameSpaceNote, "CVoltage"); ParEleValue parEleValue4=new ParEleValue(); parEleValue4.setAVoltagevValue(phaseAVoltage.floatValue()); parEleValue4.setAVoltagevValue(phaseBVoltage.floatValue()); @@ -324,42 +327,56 @@ public class ScheduledTask extends BaseService { parEleValue4.setTotalBat(electricalValue.floatValue()); parEleValue4.setKilnId(kilnId); parEleValue4.setTaskId(currTaskId); - setCommonField(parEleValue4); + parEleValue4.setCreateTime(LocalDateTime.now()); parEleValueServiceBiz.save(parEleValue4); } } } + System.out.println("采集完成"); } //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 + //@Scheduled(fixedDelay = 1000*10) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); + // 呼叫车辆运送货物给炉子 //存在空闲窑炉 - if (kilnInfoList.size()!=0){ - //缓存去是否有目标位置为窑炉的待加工任务 - KilnInfo kilnInfo = kilnInfoList.get(0); - List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper() - .eq(InStockInfo.TYPE, 1) - .eq(InStockInfo.KILN_ID, kilnInfo.getId()) - .orderByAsc(InStockInfo.IN_TIME)); - if (inStockInfoList.size()>0){ - InStockInfo inStockInfo = inStockInfoList.get(0); - CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId()); - Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); - //是否有小车在运行 - List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); - //两辆车同时空闲(其中一辆车在运行时,不能调度另一辆车,防止运行中路线冲突) - if (vehicleInfoList.size()==0){ - //计算出路径最短的车辆id - Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode()); - //占用车辆 - VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); - vehicleInfo.setStatus(1); - vehicleInfo.setUpdateTime(LocalDateTime.now()); - vehicleInfoServiceBiz.updateById(vehicleInfo); - asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(),vehicleId); + if (kilnInfoList.size()!=0) { + for (KilnInfo kilnInfo:kilnInfoList + ) { + //查询是否有车辆正在执行任务,如果有,等。(根据车辆是否正在运行可以避免出现前一个任务获取还没进去炉子,炉子状态依然为allowIn,从而继续发送任务的情况) + List vehicleInfos = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + if (vehicleInfos.size()>0){ + return; + } + //查询炉子是否allowIn + Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId()); + if (kilnAllowIn){ + //缓存去是否有目标位置为窑炉的待加工任务 + List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper() + .eq(InStockInfo.TYPE, 1) + .eq(InStockInfo.KILN_ID, kilnInfo.getId()) + .orderByAsc(InStockInfo.IN_TIME)); + if (inStockInfoList.size() > 0) { + InStockInfo inStockInfo = inStockInfoList.get(0); + CurrTask currTask = currTaskServiceBiz.getById(inStockInfo.getTaskId()); + Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); + //是否有小车在运行 + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + //两辆车同时空闲(其中一辆车在运行时,不能调度另一辆车,防止运行中路线冲突) + if (vehicleInfoList.size() == 0) { + //计算出路径最短的车辆id + Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), kilnInfo.getCode()); + //占用车辆 + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + vehicleInfo.setStatus(1); + vehicleInfo.setUpdateTime(LocalDateTime.now()); + vehicleInfoServiceBiz.updateById(vehicleInfo); + asynRunTaskService.asynRunTaskForStockToKiln(inStockInfo.getId(), vehicleId); + } + } } } @@ -446,11 +463,12 @@ public class ScheduledTask extends BaseService { json.put("identifier",identifier); String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("readPLC: "+identifier+" 的值失败"); } + return result; } /** @@ -467,7 +485,7 @@ public class ScheduledTask extends BaseService { json.put("identifier",identifier); String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("能源消耗统计:获取 "+identifier+" 的值失败"); @@ -475,32 +493,14 @@ public class ScheduledTask extends BaseService { return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); } - private Boolean rgvOnline(Long vehicleId) throws IOException { - VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); - // TODO: 2022/3/19 小车的命名空间 - String identifier=null; - if (vehicleId==1){ - identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; - } - if (vehicleId==2){ - identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; - } - Map json = new HashMap(); - json.put("nameSpace", 6); - json.put("plcName", "plc1"); - json.put("identifier",identifier+"Online"); - String result = null; - try { - result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); - } catch (IOException e) { - e.printStackTrace(); - logger.info("获取小车1当前是否在线失败"); - } - Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); - if (!aBoolean){ - webSocketServer.sendtoAll(vehicleInfo.getVehicleName()+"当前不在线,请人工确认车辆状态,如不能恢复未在线状态,请尽快手动移动车辆到轨道尽头,以避免车辆阻碍任务执行!"); - return false; - } - return true; + private Boolean kilnAllowIn(Long kilnId){ + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.TYPE,0)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "AllowIn"); + return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); } + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index e2ed9e5..6a507c8 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.dal.entity.PointInfo; +import com.mt.wms.core.dal.entity.VehicleInfo; import com.mt.wms.core.dal.service.PointInfoServiceBiz; import com.mt.wms.core.utils.HttpClient; import org.slf4j.Logger; @@ -35,15 +36,47 @@ public class TaskDistanceUtils { * @param endPoint 终点 * @return 路径最短的小车id */ - public Long chooseVehicle(String startPoint,String endPoint){ - Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getDistance(); + public Long chooseVehicle(String startPoint,String endPoint) throws IOException { + //车辆是否在线,若不在线,返回在线的那一辆,都不在线返回0 + if (!rgvOnline(1L)){ + + //液压台4 和 1号回火炉只能调用车辆1 + if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){ + return 0L; + } + if (!rgvOnline(2L)){ + return 0L; + } + return 2L; + } + if (!rgvOnline(2L)){ + + //3-4号回火炉只能调用车辆2 + if ("BMC3".equals(startPoint)||"BMC3".equals(endPoint)||"BMC4".equals(startPoint)||"BMC4".equals(endPoint)){ + return 0L; + } + if (!rgvOnline(1L)){ + return 0L; + } + return 1L; + } + //3-4号回火炉只能调用车辆2 + if ("BMC3".equals(startPoint)||"BMC3".equals(endPoint)||"BMC4".equals(startPoint)||"BMC4".equals(endPoint)){ + return 2L; + } + //液压台4 和 1号回火炉只能调用车辆1 + if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){ + return 1L; + } + Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, startPoint)).getDistance(); // 2022/2/19 两辆小车都空闲,获取出当前位置 Double rgv1CurrPosition = RGVCurrPosition(1L); Double rgv2CurrPosition = RGVCurrPosition(2L); //计算空闲小车当前位置到起点的距离 Double vehicle1Distance = Math.abs(startDistance - rgv1CurrPosition); Double vehicle2Distance = Math.abs(startDistance - rgv2CurrPosition); - return (vehicle1Distance< vehicle2Distance)?1L:2L; + return (vehicle1Distance < vehicle2Distance) ? 1L : 2L; + } /** * 计算执行任务的小车本次任务的剩余路径经过的点位集合 @@ -67,9 +100,12 @@ public class TaskDistanceUtils { } //判断小车是否冲突,传入选定小车的id,任务起终点,另一小车位置。 - public Boolean conflictForVehicle(Long vehicleId,String startPoint,String endPoint,Double otherNowPosition){ - Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, startPoint)).getDistance(); - Double endDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.CODE, endPoint)).getDistance(); + public Boolean conflictForVehicle(Long vehicleId,String startPoint,String endPoint,Double otherNowPosition) throws IOException { + if (!rgvOnline(1L)||!rgvOnline(2L)){ + return false; + } + Double startDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, startPoint)).getDistance(); + Double endDistance = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, endPoint)).getDistance(); //获取点位list List pointInfoList = pointInfoServiceBiz.list(new QueryWrapper().orderByAsc(PointInfo.ID)); // 2022/2/19 获取小车当前位置 @@ -108,11 +144,41 @@ public class TaskDistanceUtils { } String result = null; try { - result = HttpClient.httpPost("http://localhost:8009/opcua/read", JSON.toJSONString(json)); + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); } catch (IOException e) { e.printStackTrace(); logger.info("获取RGV的当前位置失败"); } - return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + Double value = Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + return value*0.0001; + } + + /** + * 车辆是否在线 + * @param vehicleId 车辆id + * @return true/false + * @throws IOException plc访问失败 + */ + private Boolean rgvOnline(Long vehicleId) throws IOException { + String identifier=null; + if (vehicleId==1){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online"; + } + if (vehicleId==2){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online"; + } + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取车辆"+vehicleId+"当前是否在线失败"); + } + Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + return online; } } diff --git a/6.program/wms-gateway/src/main/resources/config/application.yml b/6.program/wms-gateway/src/main/resources/config/application.yml index 6600ba6..98a807b 100644 --- a/6.program/wms-gateway/src/main/resources/config/application.yml +++ b/6.program/wms-gateway/src/main/resources/config/application.yml @@ -13,14 +13,14 @@ spring: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 default-property-inclusion: non_null - redis: + #redis: # cluster: # nodes: # - localhost:6379 - host: @spring.redis.host@ - port: @spring.redis.port@ - password: @spring.redis.password@ - database: @spring.redis.database@ + #host: @spring.redis.host@ + #port: @spring.redis.port@ + #password: @spring.redis.password@ + #database: @spring.redis.database@ #开发工具 devtools: diff --git a/6.program/wms-gateway/src/main/resources/logback.xml b/6.program/wms-gateway/src/main/resources/logback.xml index 5eba3ff..57a4b75 100644 --- a/6.program/wms-gateway/src/main/resources/logback.xml +++ b/6.program/wms-gateway/src/main/resources/logback.xml @@ -1,6 +1,212 @@ - - - - + + + + + + logback-spring + + + + + + + + + + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${logging.pathwork}/debug/work-log-debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${logging.pathwork}/work-log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + 999 + 200GB + + + + + + + debug + ACCEPT + DENY + + + + + + + + ${logging.pathwork}/info/work-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${logging.pathwork}/work-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + + + + ${logging.pathwork}/warn/work-log-warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + + + + + + + + + + ${logging.pathwork}/work-log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + 999 + 200GB + + + + warn + ACCEPT + DENY + + + + + + + + ${logging.pathwork}/error/work-log-error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + + + + + + + + + + ${logging.pathwork}/work-log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + 999 + 200GB + + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 4531db10da39e27346cf454c36ba24d417916d08 Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Wed, 23 Mar 2022 09:36:54 +0800 Subject: [PATCH 12/19] 2.23 --- 6.program/pom.xml | 4 +-- .../mt/wms/empty/task/AsynRunTaskService.java | 32 +++++++++++-------- .../com/mt/wms/empty/task/RunTaskUtils.java | 8 ++--- .../com/mt/wms/empty/task/ScheduledTask.java | 4 +-- .../mt/wms/empty/task/TaskDistanceUtils.java | 2 +- .../wms/empty/websocket/WebSocketServer.java | 2 +- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/6.program/pom.xml b/6.program/pom.xml index 1f7fa6f..712e735 100644 --- a/6.program/pom.xml +++ b/6.program/pom.xml @@ -51,10 +51,10 @@ 5--> - jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + jdbc:p6spy:mysql://192.168.6.51:30306/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false root - 1qaz@WSX3edc$RFV + ABC.10086 smtp.mxhichina.com diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 733b89d..99ea8b8 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -79,7 +79,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, currTaskId, 39); + Integer status = moveRgv(2, currTaskId, 2,0); if (status!=1){ logger.info("===执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); @@ -93,7 +93,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, currTaskId, 1); + Integer status = moveRgv(1, currTaskId, 12,0); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); @@ -155,7 +155,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(),currTask.getTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, currTaskId, 39); + Integer status = moveRgv(2, currTaskId, 2,0); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); @@ -169,7 +169,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId,location.getCode(),currTask.getTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, currTaskId, 1); + Integer status = moveRgv(1, currTaskId, 12,0); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); @@ -210,10 +210,14 @@ public class AsynRunTaskService extends BaseService { BeanUtils.copyProperties(inStockInfo,inStockInfoHis); inStockInfoHisServiceBiz.save(inStockInfoHis); inStockInfoServiceBiz.removeById(inStockInfo); + //更改库位状态 + location.setStatus(0); + locationServiceBiz.updateById(location); //更新currTask表状态 currTask.setIsIn(1); currTask.setRunTaskId(runTask.getId()); currTask.setUpdateTime(LocalDateTime.now()); + currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); //更新小车状态 vehicle.setStatus(0); @@ -241,7 +245,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, currTaskId, 39); + Integer status = moveRgv(2, currTaskId, 2,0); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败"); @@ -255,7 +259,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), location.getCode(), rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, currTaskId, 1); + Integer status = moveRgv(1, currTaskId, 12,0); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now()+"执行任务:"+currTask.getTaskCode()+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败"); @@ -330,7 +334,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, currTaskId, 39); + Integer status = moveRgv(2, currTaskId, 2,currTask.getPlcValue()); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); // 2022/3/6 websocket通知页面 @@ -345,7 +349,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getOutStartPosition(), currTask.getOutTargetPosition(), rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, currTaskId, 1); + Integer status = moveRgv(1, currTaskId, 12,currTask.getPlcValue()); if (status!=1){ logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); // 2022/3/6 websocket通知页面 @@ -426,7 +430,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(2, 1L, 1); + Integer status = moveRgv(2, 1L, 2,0); if (status!=1){ logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位39,执行失败==="); // 2022/3/6 websocket通知页面 @@ -441,7 +445,7 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv1CurrPosition); if (conflictBoolean){ - Integer status = moveRgv(1, 1L, 12); + Integer status = moveRgv(1, 1L, 12,0); if (status!=1){ logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆"+vehicleId+"移动到点位1,执行失败==="); // 2022/3/6 websocket通知页面 @@ -941,10 +945,10 @@ public class AsynRunTaskService extends BaseService { * @param sendRow 终点 * @return json字符串 */ - private Integer moveRgv(Integer vehicleId,Long currTaskId,Integer sendRow){ + private Integer moveRgv(Integer vehicleId,Long currTaskId,Integer sendRow,Integer processNumber){ //若冲突 // 执行小车移位任务,移位任务可以直接让小车移位到两端 - Map json = new HashMap(); + Map json = new HashMap(); //type=1为 入 // taskType 4 单移动 @@ -952,8 +956,8 @@ public class AsynRunTaskService extends BaseService { json.put("sendRow", sendRow); json.put("pickRow",0); json.put("taskNo",1); - json.put("ideNumber",1); - json.put("processNumber",1); + json.put("ideNumber",currTaskId); + json.put("processNumber",processNumber); String taskJson = JSON.toJSONString(json); logger.info("===执行任务:"+currTaskId+" 时车辆位置冲突,即将执行车辆位移任务,车辆"+vehicleId+"移动到点位"+sendRow+"==="); String result =null; diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index e912a2f..fc5cd7b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -232,7 +232,7 @@ public class RunTaskUtils { if (count >0) { List locationList = locationServiceBiz.list(new QueryWrapper() .eq(Location.STATUS, 0) - .eq(Location.VALID, 1)); + .eq(Location.VALID, 1).orderByDesc(Location.ID)); //是否有小车在运行 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); if (vehicleInfoList.size()>0){ @@ -349,9 +349,9 @@ public class RunTaskUtils { Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); if (aBoolean){ Map statusJson = new HashMap(); - json.put("nameSpace", 6); - json.put("plcName", "plc1"); - json.put("identifier",identifier+"TaskState"); + statusJson.put("nameSpace", 6); + statusJson.put("plcName", "plc1"); + statusJson.put("identifier",identifier+"TaskState"); String statusResult = null; try { statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson)); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 1957f24..d00a586 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -337,7 +337,7 @@ public class ScheduledTask extends BaseService { //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - //@Scheduled(fixedDelay = 1000*10) + //@Scheduled(fixedDelay = 1000*30) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); @@ -409,7 +409,7 @@ public class ScheduledTask extends BaseService { Map json = new HashMap(); json.put("nameSpace", 6); json.put("plcName", "plc1"); - json.put("identifier",nameSpace.concat(name)); + json.put("identifier",nameSpace+name); String jsonString = JSON.toJSONString(json); try { String result = HttpClient.httpPost("http://localhost:8009/opcua/read", jsonString); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index 6a507c8..2b20860 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -41,7 +41,7 @@ public class TaskDistanceUtils { if (!rgvOnline(1L)){ //液压台4 和 1号回火炉只能调用车辆1 - if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){ + if ("BMC1".equals(startPoint)||"BMC1".equals(endPoint)||"BMC2".equals(startPoint)||"BMC2".equals(endPoint)||"YYT004".equals(startPoint)||"YYT004".equals(endPoint)){ return 0L; } if (!rgvOnline(2L)){ diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java index 181d097..4d43ee4 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java @@ -84,7 +84,7 @@ public class WebSocketServer { * */ @OnMessage public void onMessage(String message, Session session) throws Exception { - log.info("来自客户端的消息:" + message); + //log.info("来自客户端的消息:" + message); //可以自己约定字符串内容,比如 内容|0 表示信息群发,内容|X 表示信息发给id为X的用户 String sendMessage = message; String sendUserId = "0"; From 0dd56c1e8bea3aef915847e232c15876e694b987 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Fri, 17 Jun 2022 08:48:04 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mt/wms/empty/task/ScheduledTask.java | 57 +++++++++++++++- .../com/mt/wms/empty/vo/NowCurrTaskDetVo.java | 68 +++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index d00a586..2ace784 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -6,9 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.utils.BeanUtils; import com.mt.wms.core.utils.CodeGeneratorHelper; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.vo.CurrTaskDetVo; +import com.mt.wms.empty.vo.NowCurrTaskDetVo; import com.mt.wms.empty.websocket.WebSocketServer; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -66,11 +69,52 @@ public class ScheduledTask extends BaseService { private RunTaskUtils runTaskUtils; @Resource private WebSocketServer webSocketServer; + @Resource + private CurrTaskDetServiceBiz currTaskDetServiceBiz; + @Resource + private OrderInfoServiceBiz orderInfoServiceBiz; public void testWebsocket() throws IOException { webSocketServer.sendtoAll(LocalDateTime.now()+"测试"); } + /** + * 正在加工的加工任务详情 + */ + public void screen() throws IOException { + //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 + List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); + List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); + for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList + ) { + Long kilnId = nowCurrTask.getKilnId(); + Boolean kilnWorking = kilnWorking(kilnId); + //查询对应炉号是否Working + if (kilnWorking){ + String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId)).getName(); + //设定时间 + // TODO: 2022/4/11 PLC变量名称设定时间和剩余时间统一命名 + Integer setupTime = Integer.parseInt(readPlcToString(nameSpace, "SetupTime")); + //剩余时间 + Integer remainingTime = Integer.parseInt(readPlcToString(nameSpace, "RemainingTime")); + nowCurrTask.setSetupTime(setupTime); + nowCurrTask.setRemainingTime(remainingTime); + //标识卡详情 + List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); + List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); + for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList + ) { + String customerName = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.ORDER_NO, currTaskDetVo.getOrderNo())).getCustomerName(); + currTaskDetVo.setCustomer(customerName); + } + nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); + } + } + webSocketServer.sendtoAll(JSONObject.toJSONString(nowCurrTaskDetVoList)); + } /** * 查询加工完成的窑炉 */ @@ -104,7 +148,6 @@ public class ScheduledTask extends BaseService { } } - //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 //@Scheduled(fixedDelay = 1000*30) public void getFastValue(){ @@ -192,6 +235,7 @@ public class ScheduledTask extends BaseService { } } } + //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 //@Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ @@ -503,4 +547,15 @@ public class ScheduledTask extends BaseService { return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); } + private Boolean kilnWorking(Long kilnId){ + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.TYPE,0)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "Working"); + return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + } + + } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java new file mode 100644 index 0000000..ffcdba0 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java @@ -0,0 +1,68 @@ +package com.mt.wms.empty.vo; + +import com.mt.wms.core.base.BaseVo; +import com.mt.wms.core.vo.PageVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * @Author: LGH + * @Date: 2022/4/12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "当前正在加工炉任务详情视图对象", description = "用于查询当前正在加工炉任务详情") +public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{ + /** + * 主键,自增 + */ + @ApiModelProperty(value = "主键", example = "1") + private Long id; + /** + * currtask任务code + */ + @ApiModelProperty(value = "currtask任务code",example = "0") + private String taskCode; + + /** + * 炉子id + */ + @ApiModelProperty(value = "炉子id",example = "0") + private Long kilnId; + /** + * 炉子code + */ + @ApiModelProperty(value = "炉子code",example = "0") + private String kilnCode; + /** + * 工艺plc值 + */ + @ApiModelProperty(value = "工艺plc值",example = "0") + private Integer plcValue; + + /** + * 工艺设定时间 + */ + @ApiModelProperty(value = "工艺设定时间",example = "0") + private Integer setupTime; + + /** + * 工艺剩余时间 + */ + @ApiModelProperty(value = "工艺剩余时间",example = "0") + private Integer remainingTime; + + /** + * 标识卡list + */ + @ApiModelProperty(value = "标识卡list",example = "0") + private List currTaskDetVoList; +} From 14b05bae7ed8f20e80695a8defdfca12447e7de3 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 6 Jul 2022 10:12:25 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 6.program/pom.xml | 24 ++++-- .../service/impl/CraftInfoServiceImpl.java | 2 +- .../service/impl/CurrTaskServiceImpl.java | 14 +++- .../service/impl/OrderInfoServiceImpl.java | 2 +- .../mt/wms/empty/task/AsynRunTaskService.java | 5 ++ .../com/mt/wms/empty/task/RunTaskUtils.java | 2 +- .../com/mt/wms/empty/task/ScheduledTask.java | 74 ++++++++++++++++--- .../com/mt/wms/empty/vo/NowCurrTaskDetVo.java | 5 ++ .../wms/empty/websocket/WebSocketServer.java | 17 +++-- 9 files changed, 114 insertions(+), 31 deletions(-) diff --git a/6.program/pom.xml b/6.program/pom.xml index 712e735..ef5d67e 100644 --- a/6.program/pom.xml +++ b/6.program/pom.xml @@ -24,7 +24,7 @@ pom 1.0 - wms + wms-qj wms https://wms.picaiba.com @@ -51,10 +51,12 @@ 5--> - jdbc:p6spy:mysql://192.168.6.51:30306/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + + jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false root - ABC.10086 + + 1qaz@WSX3edc$RFV smtp.mxhichina.com @@ -98,11 +100,11 @@ wms wms - + 10 jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false @@ -149,11 +151,11 @@ wms wms - + 10 jdbc:p6spy:mysql://localhost:3306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false @@ -422,6 +424,14 @@ true + + org.apache.maven.plugins + maven-resources-plugin + + @ + false + + diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java index 34fb50b..048c210 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java @@ -63,7 +63,7 @@ public class CraftInfoServiceImpl extends BaseService implements CraftInfoServic public R> page(CraftInfoQueryParam craftInfoQueryParam) { QueryWrapper wrapper=new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(craftInfoQueryParam.getCraftCode()),CraftInfo.CRAFT_CODE,craftInfoQueryParam.getCraftCode()) - .orderByDesc(CraftInfo.CREATE_TIME); + .orderByAsc(CraftInfo.CREATE_TIME); Page page = craftInfoServiceBiz.page(new Page<>(craftInfoQueryParam.getCurrent(), craftInfoQueryParam.getSize()), wrapper); return successful(new PageVo<>(page,CraftInfoVo.class)); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index 360cae0..5170b4a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -20,10 +20,7 @@ import com.mt.wms.empty.enums.TaskTypeEnum; import com.mt.wms.empty.params.AutoCurrTaskParam; import com.mt.wms.empty.params.CurrTaskQueryParam; import com.mt.wms.empty.params.TaskCreateParam; -import com.mt.wms.empty.service.CurrTaskDetService; -import com.mt.wms.empty.service.CurrTaskService; -import com.mt.wms.empty.service.TaskDetHisService; -import com.mt.wms.empty.service.TaskHisService; +import com.mt.wms.empty.service.*; import com.mt.wms.empty.task.RunTaskUtils; import com.mt.wms.empty.task.TaskDistanceUtils; import com.mt.wms.empty.vo.ApmsEndProcessVo; @@ -77,6 +74,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService TaskDistanceUtils taskDistanceUtils; @Autowired RunTaskUtils runTaskUtils; + @Autowired + AutoExeTaskServiceBiz autoExeTaskServiceBiz; @Override public CurrTaskVo getCurrTask(IdParam idParam) { @@ -202,6 +201,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Override public R runTask(Long taskId) throws InterruptedException, IOException { CurrTask currTask = currTaskServiceBiz.getById(taskId); + //是否为自动任务 + if (currTask.getIsAuto()==1){ + List exeTaskList = autoExeTaskServiceBiz.list(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, taskId)); + if (exeTaskList.size()==0){ + return R.failed("该任务为多步骤加工任务且该步骤不是第一步,请选择第一步骤任务执行!"); + } + } return runTaskUtils.runTaskForInKiln(taskId); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java index 823c40e..e11109b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java @@ -176,7 +176,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic CurrTaskVo currTask = currTaskService.getCurrTask(IdParam.builder().id(orderInfo.getCurrTaskId()).build()); orderInfo.setABeginTime(currTask.getABeginTime()); orderInfo.setAEndTime(currTask.getAEndTime()); - orderInfo.setTaskType(currTask.getTaskType()); + orderInfo.setTaskType(currTask.getProcessType()); orderInfo.setStatus(currTask.getStatus()); orderInfo.setKilnId(currTask.getKilnId()); orderInfo.setStartPosition(currTask.getStartPosition()); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 99ea8b8..dccbecb 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -117,6 +117,8 @@ public class AsynRunTaskService extends BaseService { Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); //执行成功,托盘进炉 if (status==1){ + //开始记录能源消耗 + asynStartRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); @@ -197,6 +199,7 @@ public class AsynRunTaskService extends BaseService { Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); //执行成功,托盘进炉 if (status==1){ + asynStartRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); @@ -392,6 +395,8 @@ public class AsynRunTaskService extends BaseService { Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); if (status==1){ + //加工完成,记录结束时能源消耗 + asynEndRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index fc5cd7b..d60dec5 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -260,7 +260,7 @@ public class RunTaskUtils { currTask.setOutTargetPosition(location.getCode()); currTaskServiceBiz.updateById(currTask); // 2022/2/16 异步调用车辆 - asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId()); + asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleId); return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。"); }else { return R.ok("当前缓存区已满,无法从加工炉出炉到缓存区。"); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 2ace784..73b4357 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -35,7 +35,7 @@ import java.util.Map; @Component public class ScheduledTask extends BaseService { - private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class); + private final static Logger logger = LoggerFactory.getLogger(ScheduledTask.class); @Resource private KilnInfoServiceBiz kilnInfoServiceBiz; @@ -74,13 +74,52 @@ public class ScheduledTask extends BaseService { @Resource private OrderInfoServiceBiz orderInfoServiceBiz; + @Test + public void test() throws IOException { + } + @Scheduled(fixedDelay = 1000*60) public void testWebsocket() throws IOException { - webSocketServer.sendtoAll(LocalDateTime.now()+"测试"); + //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 + List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); + List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); + for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList + ) { + Long kilnId = nowCurrTask.getKilnId(); + Boolean kilnWorking = true; + //查询对应炉号是否Working + if (kilnWorking){ + String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId)).getName(); + //设定时间 + // TODO: 2022/4/11 PLC变量名称设定时间和剩余时间统一命名 + Integer setupTime = 300; + //剩余时间 + Integer remainingTime = 122; + nowCurrTask.setSetupTime(setupTime); + nowCurrTask.setRemainingTime(remainingTime); + int completeness =(int) (((float)remainingTime/(float)setupTime )*100); + nowCurrTask.setCompleteness(completeness); + //标识卡详情 + List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); + List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); + for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList + ) { + String customerName = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.ORDER_NO, currTaskDetVo.getOrderNo())).getCustomerName(); + currTaskDetVo.setCustomer(customerName); + } + nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); + } + } + System.out.println(JSON.toJSONString(nowCurrTaskDetVoList)); + webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2"); } /** * 正在加工的加工任务详情 */ + //@Scheduled(fixedDelay = 1000*60) public void screen() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); @@ -95,13 +134,27 @@ public class ScheduledTask extends BaseService { .eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.TYPE, 0) .eq(PlcNameSpace.EQ_ID, kilnId)).getName(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + nowCurrTask.setKilnCode(kilnInfo.getCode()); //设定时间 - // TODO: 2022/4/11 PLC变量名称设定时间和剩余时间统一命名 - Integer setupTime = Integer.parseInt(readPlcToString(nameSpace, "SetupTime")); + Integer setupTime =1; //剩余时间 - Integer remainingTime = Integer.parseInt(readPlcToString(nameSpace, "RemainingTime")); + Integer remainingTime=0; + if (kilnInfo.getType()!=4){ + remainingTime = Integer.parseInt(readPlcToString(nameSpace, "ProgramTimeRemain")); + } + if(kilnInfo.getType()==1||kilnInfo.getType()==3){ + //运行时间 + Integer runTime = Integer.parseInt(readPlcToString(nameSpace, "ProgramRunTime")); + setupTime=runTime+remainingTime; + } + if (kilnInfo.getType()==2){ + setupTime=Integer.parseInt(readPlcToString(nameSpace, "SetTime")); + } nowCurrTask.setSetupTime(setupTime); nowCurrTask.setRemainingTime(remainingTime); + int completeness =(int) (((float)remainingTime/(float)setupTime )*100); + nowCurrTask.setCompleteness(completeness); //标识卡详情 List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); @@ -118,6 +171,7 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的窑炉 */ + //@Scheduled(fixedDelay = 1000*60*3) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -141,6 +195,7 @@ public class ScheduledTask extends BaseService { Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); if (resultBoolean){ //调用RunTaskUtils.runTaskForOutKiln + logger.info(kilnInfo.getCode()+kilnInfo.getKilnAlias()+"识别到允许出炉信号,进入出库程序!"); runTaskUtils.runTaskForOutKiln(kilnId); break; } @@ -381,7 +436,7 @@ public class ScheduledTask extends BaseService { //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - //@Scheduled(fixedDelay = 1000*30) + //@Scheduled(fixedDelay = 1000*60) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); @@ -398,7 +453,7 @@ public class ScheduledTask extends BaseService { //查询炉子是否allowIn Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId()); if (kilnAllowIn){ - //缓存去是否有目标位置为窑炉的待加工任务 + //缓存区是否有目标位置为窑炉的待加工任务 List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper() .eq(InStockInfo.TYPE, 1) .eq(InStockInfo.KILN_ID, kilnInfo.getId()) @@ -428,6 +483,7 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 + //@Scheduled(fixedDelay = 1000*30) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList @@ -484,10 +540,10 @@ public class ScheduledTask extends BaseService { } - //监听车辆是否在线 + //监听车辆是否在线(暂时不用) public void listenVehicleOnline() throws IOException { List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() - .eq(VehicleInfo.STATUS, 2)); + .eq(VehicleInfo.STATUS, 0)); for (VehicleInfo vehicleInfo:vehicleInfoList ) { diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java index ffcdba0..b0538bf 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java @@ -59,6 +59,11 @@ public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{ */ @ApiModelProperty(value = "工艺剩余时间",example = "0") private Integer remainingTime; + /** + * 工艺进度 + */ + @ApiModelProperty(value = "工艺进度",example = "0") + private Integer completeness; /** * 标识卡list diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java index 4d43ee4..8a60bdd 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java @@ -26,13 +26,14 @@ public class WebSocketServer { //前端的id 右后端给他 public synchronized String getUniqeId(){ - return UUID.randomUUID().toString()+System.currentTimeMillis(); + //return UUID.randomUUID().toString()+System.currentTimeMillis(); + return id; } //与某个客户端的连接会话,需要通过它来给客户端发送数据 private Session session; private static Logger log = LogManager.getLogger(WebSocketServer.class); - private String id = ""; + private String id = getUniqeId(); public Integer getCurrentNum(){ return webSocketSet.size(); @@ -135,15 +136,15 @@ public class WebSocketServer { */ public void sendtoUser(String message,String sendUserId) throws IOException { if (webSocketSet.get(sendUserId) != null) { - if(!id.equals(sendUserId)){ - webSocketSet.get(sendUserId).sendMessage( "用户" + id + "发来消息:" + "
" + message); - } - else{ + //if(!id.equals(sendUserId)){ + //webSocketSet.get(sendUserId).sendMessage( "用户" + id + "发来消息:" + "
" + message); + // } + //else{ webSocketSet.get(sendUserId).sendMessage(message); - } + //} } else { //如果用户不在线则返回不在线信息给自己 - sendtoUser("当前用户不在线",id); + //sendtoUser("当前用户不在线",id); } } From b107cd2446455c9b3363a7cdea2fe181f92741a7 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 6 Jul 2022 18:35:14 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E4=B8=8A=E6=8A=A5apms=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E5=8D=95=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CheckResultController.java | 37 +++++++++ .../params/ApmsCheckRusultQueryParam.java | 24 ++++++ .../service/impl/OrderInfoServiceImpl.java | 6 +- .../mt/wms/empty/task/AsynRunTaskService.java | 78 ++++++++++++++++++- .../com/mt/wms/empty/task/ScheduledTask.java | 20 +++-- 5 files changed, 152 insertions(+), 13 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java new file mode 100644 index 0000000..00d9a4d --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java @@ -0,0 +1,37 @@ +package com.mt.wms.empty.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.ApmsCheckResult; +import com.mt.wms.core.dal.service.ApmsCheckResultServiceBiz; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.ApmsCheckRusultQueryParam; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author: LGH + * @Date: 2022/7/6 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "checkResult") +@Slf4j +@Api(value = "检验结果相关接口", tags = "检验结果相关接口", hidden = false) +public class CheckResultController extends BaseController { + + @Resource + private ApmsCheckResultServiceBiz apmsCheckResultServiceBiz; + + public R checkResult(ApmsCheckRusultQueryParam apmsCheckRusultQueryParam){ + ApmsCheckResult apmsCheckResult = apmsCheckResultServiceBiz.getOne(new QueryWrapper() + .eq(ApmsCheckResult.SHEET_NO, apmsCheckRusultQueryParam.getSheetNo()) + .eq(ApmsCheckResult.IDEN_CARD_NUM, apmsCheckRusultQueryParam.getIdenCardNum())); + return successful(apmsCheckResult); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java new file mode 100644 index 0000000..173dcb9 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java @@ -0,0 +1,24 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: LGH + * @Date: 2022/7/6 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "检验结果查询参数", description = "检验结果查询参数") +public class ApmsCheckRusultQueryParam extends BasePageParam { + @ApiModelProperty(value = "生产单号", required = true) + private String sheetNo; + + @ApiModelProperty(value = "标识卡号", required = true) + private String idenCardNum; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java index e11109b..323444b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java @@ -181,16 +181,16 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic orderInfo.setKilnId(currTask.getKilnId()); orderInfo.setStartPosition(currTask.getStartPosition()); orderInfo.setTargetPosition(currTask.getTargetPosition()); - orderInfo.setVehicleId(currTask.getVehicleId()); + //orderInfo.setVehicleId(currTask.getVehicleId()); //获取窑炉和车辆的名称信息 if (orderInfo.getKilnId() != null) { orderInfo.setKilnName(collect2.get(orderInfo.getKilnId()).get(0).getKilnName()); } - if (orderInfo.getVehicleId() != null) +/* if (orderInfo.getVehicleId() != null) { orderInfo.setVehicleName(collect.get(orderInfo.getVehicleId()).get(0).getVehicleName()); - } + }*/ } ); return successful(currOrderCurrTask); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index dccbecb..e56ef19 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -8,6 +8,14 @@ import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.IDGenerator; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.controller.ApmsController; +import com.mt.wms.empty.params.ApmsEndProcess; +import com.mt.wms.empty.params.ApmsFinishProcessSheet; +import com.mt.wms.empty.params.ApmsStartProcess; +import com.mt.wms.empty.params.FinishItem; +import com.mt.wms.empty.vo.ApmsEndProcessVo; +import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo; import com.mt.wms.empty.websocket.WebSocketServer; import io.swagger.models.auth.In; import org.junit.jupiter.api.Test; @@ -21,11 +29,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -68,6 +75,12 @@ public class AsynRunTaskService extends BaseService { private ParGasValueServiceBiz parGasValueServiceBiz; @Resource private WebSocketServer webSocketServer; + @Resource + private ApmsController apmsController; + @Resource + private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @Resource + private CurrTaskDetServiceBiz currTaskDetServiceBiz; //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉 @Async("asyncServiceExecutor") public void asynRunTask(Long currTaskId,Long vehicleId) throws IOException { @@ -133,6 +146,9 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms加工单开始 + //apmsStartProcess(currTask); + }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -225,6 +241,8 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms生产单开始加工 + //apmsStartProcess(currTask); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -415,6 +433,48 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms加工完成 +/* ApmsEndProcess apmsEndProcess=new ApmsEndProcess(); + apmsEndProcess.setEndTime(LocalDateTime.now().toString()); + apmsEndProcess.setEndUser("QJJP03"); + apmsEndProcess.setSheetNo(currTask.getSheetNo()); + R apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess); + if (apmsEndProcessVoR.getCode()!=0){ + logger.info("任务:"+currTaskId+" 生产单号:"+currTask.getSheetNo()+"上报apm完成处理生产单失败!"); + } + if (currTask.getIsAuto()==1){ + //两步且是第二步 + List twoSpet = autoExeTaskServiceBiz.list(new QueryWrapper() + .eq(AutoExeTask.PROCESS_FLOW_TYPE, 1) + .eq(AutoExeTask.T_TASK_ID, currTaskId)); + //三步且是第三步 + List threeSpet = autoExeTaskServiceBiz.list(new QueryWrapper() + .eq(AutoExeTask.PROCESS_FLOW_TYPE, 2) + .eq(AutoExeTask.TH_TASK_ID, currTaskId)); + if (!(threeSpet.size()!=0||twoSpet.size()!=0)){ + return; + } + } + ApmsFinishProcessSheet apmsFinishProcessSheet=new ApmsFinishProcessSheet(); + apmsFinishProcessSheet.setSheetNo(currTask.getSheetNo()); + apmsFinishProcessSheet.setEndTime(LocalDateTime.now().toString()); + apmsFinishProcessSheet.setEndUser("QJJP03"); + List finishItems=new ArrayList<>(); + List currTaskDets = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTaskId)); + for (CurrTaskDet currTaskDet:currTaskDets + ) { + FinishItem finishItem=new FinishItem(); + BigDecimal bigDecimal = new BigDecimal(currTaskDet.getWeight()); + finishItem.setFinishWeight(bigDecimal.doubleValue()); + finishItem.setFinishQuantity(Math.round(currTaskDet.getQuantity())); + finishItem.setItemCode(currTaskDet.getIdenCardNum()); + finishItems.add(finishItem); + } + apmsFinishProcessSheet.setItems(finishItems); + R apmsFinishProcessSheetVoR = apmsController.finishProcessSheet(apmsFinishProcessSheet); + if (apmsFinishProcessSheetVoR.getCode()!=0){ + logger.info("任务:"+currTask.getTaskCode()+"完成后上报apms完成生产单失败!"); + }*/ }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -1019,4 +1079,16 @@ public class AsynRunTaskService extends BaseService { return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); } + private void apmsStartProcess(CurrTask currTask) { + ApmsStartProcess apmsStartProcess = new ApmsStartProcess(); + apmsStartProcess.setStartTime(LocalDateTime.now().toString()); + apmsStartProcess.setStartUser("QJJP03"); + apmsStartProcess.setSheetNo(currTask.getSheetNo()); + apmsStartProcess.setTechName(currTask.getCraftCodeId().toString()); + apmsStartProcess.setStoveCode(kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode()); + R apmsStartProcessR = apmsController.startProcess(apmsStartProcess); + if (apmsStartProcessR.getCode() != 0) { + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败"); + } + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 73b4357..ddd57a7 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -81,6 +81,9 @@ public class ScheduledTask extends BaseService { public void testWebsocket() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); + if (currTaskList.size()==0){ + return; + } List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList ) { @@ -119,10 +122,13 @@ public class ScheduledTask extends BaseService { /** * 正在加工的加工任务详情 */ - //@Scheduled(fixedDelay = 1000*60) + @Scheduled(fixedDelay = 1000*60) public void screen() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); + if (currTaskList.size()==0){ + return; + } List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList ) { @@ -166,12 +172,12 @@ public class ScheduledTask extends BaseService { nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); } } - webSocketServer.sendtoAll(JSONObject.toJSONString(nowCurrTaskDetVoList)); + webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2"); } /** * 查询加工完成的窑炉 */ - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*3) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -204,7 +210,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 - //@Scheduled(fixedDelay = 1000*30) + @Scheduled(fixedDelay = 1000*30) public void getFastValue(){ //加工炉列表 List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); @@ -292,7 +298,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ System.out.println("开始采集数据"); List kilnInfoList = kilnInfoServiceBiz.list(); @@ -436,7 +442,7 @@ public class ScheduledTask extends BaseService { //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - //@Scheduled(fixedDelay = 1000*60) + @Scheduled(fixedDelay = 1000*60) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); @@ -483,7 +489,7 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 - //@Scheduled(fixedDelay = 1000*30) + @Scheduled(fixedDelay = 1000*30) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList From cf1c8eeb5e74288d171010680dd4a05444083ea8 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 6 Jul 2022 22:07:43 +0800 Subject: [PATCH 16/19] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mt/wms/empty/task/ScheduledTask.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index ddd57a7..bce6aba 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -104,6 +104,7 @@ public class ScheduledTask extends BaseService { nowCurrTask.setRemainingTime(remainingTime); int completeness =(int) (((float)remainingTime/(float)setupTime )*100); nowCurrTask.setCompleteness(completeness); + nowCurrTask.setKilnCode("BMA1"); //标识卡详情 List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); @@ -122,7 +123,7 @@ public class ScheduledTask extends BaseService { /** * 正在加工的加工任务详情 */ - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void screen() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); @@ -161,6 +162,7 @@ public class ScheduledTask extends BaseService { nowCurrTask.setRemainingTime(remainingTime); int completeness =(int) (((float)remainingTime/(float)setupTime )*100); nowCurrTask.setCompleteness(completeness); + nowCurrTask.setKilnCode(kilnInfo.getCode()); //标识卡详情 List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); @@ -177,7 +179,7 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的窑炉 */ - @Scheduled(fixedDelay = 1000*60*3) + //@Scheduled(fixedDelay = 1000*60*3) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -210,7 +212,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 - @Scheduled(fixedDelay = 1000*30) + //@Scheduled(fixedDelay = 1000*30) public void getFastValue(){ //加工炉列表 List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); @@ -298,7 +300,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 - @Scheduled(fixedDelay = 1000*60*3) + //@Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ System.out.println("开始采集数据"); List kilnInfoList = kilnInfoServiceBiz.list(); @@ -442,7 +444,7 @@ public class ScheduledTask extends BaseService { //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0)); @@ -489,7 +491,7 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 - @Scheduled(fixedDelay = 1000*30) + //@Scheduled(fixedDelay = 1000*30) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList From b2319f2a51f07b6744f2f7ef31f50646b2a1fb68 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 6 Jul 2022 22:44:08 +0800 Subject: [PATCH 17/19] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 6.program/pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/6.program/pom.xml b/6.program/pom.xml index ef5d67e..e5a34d4 100644 --- a/6.program/pom.xml +++ b/6.program/pom.xml @@ -51,9 +51,10 @@ 5--> - + + jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false - + root 1qaz@WSX3edc$RFV From 0c67641710686a7738769561c05c5f6712ab3264 Mon Sep 17 00:00:00 2001 From: lgh Date: Thu, 7 Jul 2022 15:22:46 +0800 Subject: [PATCH 18/19] update --- .../main/java/com/mt/wms/core/utils/HttpClient.java | 2 +- .../com/mt/wms/empty/task/AsynRunTaskService.java | 13 ++++++++----- .../java/com/mt/wms/empty/task/ScheduledTask.java | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java index dcb93ab..006cafe 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/HttpClient.java @@ -48,7 +48,7 @@ public class HttpClient { public static String httpPost(String url, String json) throws IOException { //OkHttpClient httpClient = new OkHttpClient(); - OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(300L, TimeUnit.SECONDS) + OkHttpClient httpClient = new OkHttpClient().newBuilder().connectTimeout(300L, TimeUnit.MINUTES) .writeTimeout(60*30, TimeUnit.SECONDS) .readTimeout(60*30, TimeUnit.SECONDS) .build(); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index e56ef19..9e19563 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -128,10 +128,11 @@ public class AsynRunTaskService extends BaseService { Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); + logger.info(String.valueOf(status)); //执行成功,托盘进炉 if (status==1){ - //开始记录能源消耗 - asynStartRecordConsume(currTaskId,currTask.getKilnId()); + // TODO: 2022/7/7 开始记录能源消耗 + //asynStartRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); @@ -215,7 +216,8 @@ public class AsynRunTaskService extends BaseService { Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); //执行成功,托盘进炉 if (status==1){ - asynStartRecordConsume(currTaskId,currTask.getKilnId()); + // TODO: 2022/7/7 + //asynStartRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); @@ -413,8 +415,9 @@ public class AsynRunTaskService extends BaseService { Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue()); if (status==1){ - //加工完成,记录结束时能源消耗 - asynEndRecordConsume(currTaskId,currTask.getKilnId()); + + // TODO: 2022/7/7 加工完成,记录结束时能源消耗 + //asynEndRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新关系表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index bce6aba..573a980 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -77,7 +77,7 @@ public class ScheduledTask extends BaseService { @Test public void test() throws IOException { } - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void testWebsocket() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); @@ -179,7 +179,7 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的窑炉 */ - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*2) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -195,7 +195,7 @@ public class ScheduledTask extends BaseService { Long kilnId = currTask.getKilnId(); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); PlcNameSpace plcNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() - .eq(PlcNameSpace.EQ_TYPE, 1) + .eq(PlcNameSpace.EQ_TYPE, 0) .eq(PlcNameSpace.TYPE, 0) .eq(PlcNameSpace.EQ_ID,kilnId)); //通过允许出炉信号来判定是否加工完成 From 9cc6ef98f92350a35d40d3227611afe2132530b0 Mon Sep 17 00:00:00 2001 From: lgh Date: Thu, 7 Jul 2022 23:50:43 +0800 Subject: [PATCH 19/19] =?UTF-8?q?apms=E7=9A=84ip=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E5=8F=B7=E4=BF=AE=E6=94=B9=20=E8=83=BD=E6=BA=90=E6=B6=88?= =?UTF-8?q?=E8=80=97=E7=BB=9F=E8=AE=A1=E4=BC=98=E5=8C=96=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=94=9F=E4=BA=A7=E5=8D=95=E7=94=A8=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=8F=B7=EF=BC=88=E5=89=8D=E7=AB=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=90=8E=E8=A6=81=E6=94=B9=E5=9B=9E=EF=BC=89=20?= =?UTF-8?q?=E5=A4=9A=E6=AD=A5=E9=AA=A4=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/empty/controller/ApmsController.java | 2 +- .../empty/controller/CurrTaskController.java | 2 +- .../service/impl/CurrTaskServiceImpl.java | 4 ++- .../mt/wms/empty/task/AsynRunTaskService.java | 2 +- .../com/mt/wms/empty/task/RunTaskUtils.java | 2 +- .../com/mt/wms/empty/task/ScheduledTask.java | 26 ++++++++++++++----- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java index d63a6a3..9f66f0f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java @@ -50,7 +50,7 @@ public class ApmsController extends BaseController { // static String Token = "eyJhbGciOiJIUzI1NiJ9.eyJkYXRlIjozMTkyNzU4NDk4ODA3LCJwbGF0Rm9ybUlkIjoyLCJhcGlLZXkiOiI3ZWU4ZjU5YmJhZWFlMjdlIiwiZXhwIjozMTkyNzU4NDk4LCJpYXQiOjE2Mzc1NTg0OTh9.RH3MRQr1dCBYW996-WXN69eXu1ZFblAQHfhZHNbTmCg"; static String Token = ""; static LocalDateTime TokenExpireTime = LocalDateTime.now(); - static String ApiAddress = "http://59.110.171.25:9010"; + static String ApiAddress = "http://192.168.1.109:80"; @PostMapping(value = "apmsPostOrder") @ApiOperation(value = "WMS接收APMS推送订单信息") diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 7816473..0333254 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -233,7 +233,7 @@ public class CurrTaskController extends BaseController { currTaskById.setSheetNo(sheetNo); currTaskService.updateCurrTaskById(currTaskById); //生成详细任务中的检验结果数据在apms推送生产单结果时创建 - return successful("创建成功,任务添加至等待执行队列。"); + //return successful("创建成功,任务添加至等待执行队列。"); } else diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index 5170b4a..1eb3b1b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -102,10 +102,12 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService BeanUtils.copyProperties(param, currTask); currTask.setTaskType(TaskTypeEnum.WTK.getValue()); //根据工艺号查询工艺id以及工艺plc值 - CraftInfo one = craftInfoServiceBiz.getOne(new QueryWrapper().eq(CraftInfo.CREATOR_ID, param.getCraftCode())); + // TODO: 2022/7/7 工艺号临时 + CraftInfo one = craftInfoServiceBiz.getOne(new QueryWrapper().eq(CraftInfo.CRAFT_CODE, 1)); currTask.setCraftCodeId(one.getId()); currTask.setPlcValue(one.getPlcValue()); currTask.setInterCode(IDGenerator.gen("RW", IDGenerator.PATTERN_YYYYMMDDHHMM, 2, "TASK_CODE")); + currTask.setTaskCode(IDGenerator.gen("RW", IDGenerator.PATTERN_YYYYMMDDHHMM, 2, "TASK_CODE")); setCommonField(currTask); currTaskServiceBiz.save(currTask); return successful(IdVo.builder().id(currTask.getId()).build()); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 9e19563..d1808a3 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -132,7 +132,7 @@ public class AsynRunTaskService extends BaseService { //执行成功,托盘进炉 if (status==1){ // TODO: 2022/7/7 开始记录能源消耗 - //asynStartRecordConsume(currTaskId,currTask.getKilnId()); + asynStartRecordConsume(currTaskId,currTask.getKilnId()); logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功==="); //更新调度表状态为完成 runTask.setUpdateTime(LocalDateTime.now()); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java index d60dec5..fe397e7 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java @@ -203,7 +203,7 @@ public class RunTaskUtils { } else { //当前加工步骤不为第一步 int secondCount = autoExeTaskServiceBiz.count(new QueryWrapper().eq(AutoExeTask.T_TASK_ID, currTask.getId())); - if (secondCount == 2) { + if (secondCount == 1) { //当前为自动任务第二步 AutoExeTask autoExeTask = autoExeTaskServiceBiz.getOne(new QueryWrapper().eq(AutoExeTask.T_TASK_ID, currTask.getId())); //该自动任务的工艺类型为2,还有第三步 diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 573a980..e5870b3 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -179,7 +179,7 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的窑炉 */ - @Scheduled(fixedDelay = 1000*60*2) + //@Scheduled(fixedDelay = 1000*60*2) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -212,8 +212,9 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 - //@Scheduled(fixedDelay = 1000*30) + @Scheduled(fixedDelay = 1000*30) public void getFastValue(){ + logger.info("==采集高频能耗数据开始=="); //加工炉列表 List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); for (KilnInfo kilnInfo:kilnInfoList @@ -230,6 +231,10 @@ public class ScheduledTask extends BaseService { Long kilnId = kilnInfo.getId(); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); + if (currTaskId==0){ + logger.info("==当前加工的为手动加工任务,不记录能耗=="); + continue; + } //加工炉 if (kilnInfo.getType()==1){ //一号油搅拌转速 @@ -295,14 +300,16 @@ public class ScheduledTask extends BaseService { parGasValue3.setCreateTime(LocalDateTime.now()); parGasValueServiceBiz.save(parGasValue3); } + } } + logger.info("==采集高频能耗数据结束=="); } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ - System.out.println("开始采集数据"); + logger.info("==开始采集低频数据=="); List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList ) { @@ -317,6 +324,10 @@ public class ScheduledTask extends BaseService { Long kilnId = kilnInfo.getId(); String identificationNumber = readPlcToString(nameSpaceNote, "DischargeIdentNumber"); Long currTaskId = Long.valueOf(JSONObject.parseObject(identificationNumber).get("result").toString()); + if (currTaskId==0){ + logger.info("==当前加工的为手动加工任务,不记录能耗=="); + continue; + } //加工炉 if (kilnInfo.getType()==1){ //实际温度 @@ -439,7 +450,7 @@ public class ScheduledTask extends BaseService { } } } - System.out.println("采集完成"); + logger.info("==结束采集低频数据=="); } //遍历窑炉,空窑炉查询缓存区是否有等待加工的任务, @@ -491,9 +502,10 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 - //@Scheduled(fixedDelay = 1000*30) + @Scheduled(fixedDelay = 1000*60) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); + logger.info("==开始查询炉子是否有报警=="); for (KilnInfo kilnInfo:kilnInfoList ) { PlcNameSpace kilnNameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() @@ -545,7 +557,7 @@ public class ScheduledTask extends BaseService { } } } - + logger.info("==结束查询炉子是否有报警=="); } //监听车辆是否在线(暂时不用)