/*
 Navicat Premium Data Transfer

 Source Server         : localhost-3333
 Source Server Type    : MySQL
 Source Server Version : 80033
 Source Host           : localhost:3333
 Source Schema         : udi_wms

 Target Server Type    : MySQL
 Target Server Version : 80033
 File Encoding         : 65001

 Date: 18/12/2023 10:42:05
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for device_change_log
-- ----------------------------
DROP TABLE IF EXISTS `device_change_log`;
CREATE TABLE `device_change_log`  (
  `id` bigint NOT NULL COMMENT '日志id',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'add:新增入库，change:变更归属',
  `changeOrderId` bigint NOT NULL COMMENT '变更单号',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作部门',
  `deptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作部门',
  `toDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '目标部门',
  `toDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '目标部门',
  `confirmUser` bigint NOT NULL COMMENT '确认人id',
  `confirmUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '确认人姓名',
  `confirmTime` datetime NOT NULL COMMENT '确认时间',
  `confirmRemark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '确认备注',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '操作人姓名',
  `createUser` bigint NOT NULL COMMENT '操作人id',
  `createTime` datetime NOT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备变更日志表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_change_order
-- ----------------------------
DROP TABLE IF EXISTS `device_change_order`;
CREATE TABLE `device_change_order`  (
  `orderId` bigint NOT NULL COMMENT '编码',
  `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'add:新增入库，change:变更归属',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '1.待目标部门接收 ，2.完成(目标确认接收) ，3.目标部门拒收，4.取消',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建部门',
  `toDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '目标部门',
  `confirmUser` bigint NULL DEFAULT NULL COMMENT '确认人id',
  `confirmUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人姓名',
  `confirmTime` datetime NULL DEFAULT NULL COMMENT '确认时间',
  `confirmRemark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '确认备注',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人',
  `createUser` bigint NULL DEFAULT NULL COMMENT '创建人id',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`orderId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备变更单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_change_order_item
-- ----------------------------
DROP TABLE IF EXISTS `device_change_order_item`;
CREATE TABLE `device_change_order_item`  (
  `orderId` bigint NOT NULL COMMENT '变更单号',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '设备编码',
  `productId` bigint NOT NULL COMMENT '产品id',
  `udi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'UDI码',
  `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'DI码',
  `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `batchNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `serialNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '序列号',
  `productionDate` date NULL DEFAULT NULL COMMENT '生产日期',
  `expireDate` date NULL DEFAULT NULL COMMENT '失效日期',
  `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂家',
  `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案凭证号',
  `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
  `supName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  PRIMARY KEY (`orderId`, `deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备变更单明细' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_check
-- ----------------------------
DROP TABLE IF EXISTS `device_check`;
CREATE TABLE `device_check`  (
  `taskId` bigint NOT NULL COMMENT '巡检任务id',
  `planId` bigint NULL DEFAULT NULL COMMENT '计划id',
  `planName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计划名称',
  `chargeDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '负责部门编码',
  `checkUserId` bigint NULL DEFAULT NULL COMMENT '巡检人id',
  `checkUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检人姓名',
  `checkUserPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检人电话',
  `deviceCount` int NOT NULL COMMENT '设备数量',
  `finishCount` int NOT NULL DEFAULT 0 COMMENT '完成设备数量',
  `exceptionCount` int NOT NULL DEFAULT 0 COMMENT '异常数量',
  `finishTime` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '任务名称',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '任务备注',
  `sysFlag` bit(1) NOT NULL COMMENT '是否系统创建 1/true 是 0/false 否',
  `finishFlag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已完成',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  `createUserId` bigint NULL DEFAULT NULL COMMENT '创建人id',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人姓名',
  PRIMARY KEY (`taskId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检任务表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_check_detail
-- ----------------------------
DROP TABLE IF EXISTS `device_check_detail`;
CREATE TABLE `device_check_detail`  (
  `taskId` bigint NOT NULL COMMENT '任务id',
  `deviceCode` varbinary(255) NOT NULL COMMENT '设备编码',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门编码',
  `deptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门名称',
  `finishFlag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已完成 1/true 0/false',
  `productId` bigint NOT NULL COMMENT '产品id',
  `udi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'UDI码',
  `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'DI码',
  `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `batchNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `serialNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '序列号',
  `productionDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产日期',
  `expireDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '失效日期',
  `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂家',
  `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案凭证号',
  `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
  `supName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `itemCount` int NOT NULL DEFAULT 0 COMMENT '项目数量',
  `exceptionCount` int NOT NULL DEFAULT 0 COMMENT '异常数量',
  `finishCount` int NOT NULL DEFAULT 0 COMMENT '完成项目数量',
  `finishTime` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `repairId` bigint NULL DEFAULT NULL COMMENT '维修单id',
  PRIMARY KEY (`taskId`, `deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检任务明细' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_check_detail_item
-- ----------------------------
DROP TABLE IF EXISTS `device_check_detail_item`;
CREATE TABLE `device_check_detail_item`  (
  `taskId` bigint NOT NULL COMMENT '任务id',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `itemCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `itemName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目名称',
  `itemContent` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `normalFlag` bit(1) NULL DEFAULT NULL COMMENT '正常标识',
  `finishFlag` bit(1) NOT NULL DEFAULT b'0' COMMENT '完成标识',
  `finishTime` datetime NULL DEFAULT NULL COMMENT '完成时间',
  `suggestion` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '巡检建议',
  `checkUserId` bigint NULL DEFAULT NULL COMMENT '巡检人id',
  `checkUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检人姓名',
  `checkDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检部门',
  `checkDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检部门名称',
  PRIMARY KEY (`taskId`, `deviceCode`, `itemCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备巡检项目' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_check_item_dict
-- ----------------------------
DROP TABLE IF EXISTS `device_check_item_dict`;
CREATE TABLE `device_check_item_dict`  (
  `code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目名称',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  `createUserId` bigint NOT NULL COMMENT '创建人id',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人名称',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检项目字典' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_info
-- ----------------------------
DROP TABLE IF EXISTS `device_info`;
CREATE TABLE `device_info`  (
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门编码',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '1.正常，2变更归属中，3.维修申请中  4.维修中  6.销毁/报废',
  `checkLock` bit(1) NOT NULL DEFAULT b'0' COMMENT '巡检锁定',
  `udi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'UDI码',
  `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'DI码',
  `productId` bigint NOT NULL COMMENT '产品id',
  `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `batchNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `serialNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '序列号',
  `productionDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产日期',
  `expireDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '失效日期',
  `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂家',
  `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案凭证号',
  `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
  `supName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `changeCount` int NOT NULL DEFAULT 0 COMMENT '变更次数',
  `repairApplyCount` int NOT NULL DEFAULT 0 COMMENT '报修次数',
  `repairCount` int NOT NULL DEFAULT 0 COMMENT '维修次数',
  `checkCount` int NOT NULL DEFAULT 0 COMMENT '巡检次数',
  `lastChangeOrderId` bigint NOT NULL COMMENT '最后变更单号',
  `lastRepairApplyId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后报修申请单号',
  `lastRepairApplyTime` datetime NULL DEFAULT NULL COMMENT '最后报修时间',
  `lastRepairId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后维修单号',
  `lastRepairUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后维修负责人名称',
  `lastRepairUserPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后维修人联系电话',
  `lastRepairTime` datetime NULL DEFAULT NULL COMMENT '最后维修时间',
  `lastCheckUserId` bigint NULL DEFAULT NULL COMMENT '最后检查/巡检负责人',
  `lastCheckUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后检查/巡检负责人名称',
  `lastCheckPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最后检查/巡检人联系电话',
  `lastCheckTime` datetime NULL DEFAULT NULL COMMENT '最后检查/巡检时间',
  `lastCheckTaskId` bigint NULL DEFAULT NULL COMMENT '最后检查/巡检任务id',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  `createUserId` bigint NOT NULL COMMENT '创建人id',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人名称',
  PRIMARY KEY (`deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_plan
-- ----------------------------
DROP TABLE IF EXISTS `device_plan`;
CREATE TABLE `device_plan`  (
  `planId` bigint NOT NULL COMMENT '计划id',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '计划名称',
  `chargeDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '负责部门',
  `startDate` date NOT NULL COMMENT '开始日期',
  `endDate` date NOT NULL COMMENT '结束日期',
  `frequency` int NOT NULL COMMENT '频率(天)',
  `execCount` int NOT NULL DEFAULT 0 COMMENT '执行次数',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注',
  `createUserId` bigint NOT NULL COMMENT '创建人id',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人名称',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`planId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备巡检计划' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_plan_detail
-- ----------------------------
DROP TABLE IF EXISTS `device_plan_detail`;
CREATE TABLE `device_plan_detail`  (
  `planId` bigint NOT NULL COMMENT '计划id',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编号',
  `productId` bigint NOT NULL COMMENT '产品id',
  PRIMARY KEY (`planId`, `deviceCode`) USING BTREE,
  UNIQUE INDEX `uk_planId_productId`(`planId`, `deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检计划明细' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_plan_detail_item
-- ----------------------------
DROP TABLE IF EXISTS `device_plan_detail_item`;
CREATE TABLE `device_plan_detail_item`  (
  `planId` bigint NOT NULL COMMENT '巡检计划明细id',
  `productId` bigint NOT NULL COMMENT '巡检计划产品id',
  `itemCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目编码',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目名称',
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '项目内容',
  PRIMARY KEY (`planId`, `productId`, `itemCode`) USING BTREE,
  UNIQUE INDEX `uk_planId_deviceCode_itemCode`(`planId`, `itemCode`, `deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '巡检设备的项目' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_repair
-- ----------------------------
DROP TABLE IF EXISTS `device_repair`;
CREATE TABLE `device_repair`  (
  `id` bigint NOT NULL COMMENT '维修id',
  `applyId` bigint NULL DEFAULT NULL COMMENT '维修申请id',
  `checkTaskId` bigint NULL DEFAULT NULL COMMENT '巡检任务单id',
  `finishFlag` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已完成 true/false',
  `description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '问题描述',
  `diagnosisInfo` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '诊断信息',
  `innerFlag` bit(1) NULL DEFAULT NULL COMMENT '是否内部维修',
  `repairUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修人姓名',
  `repairUserPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '维修人联系方式',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备码',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门编码',
  `deptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门名称',
  `productId` bigint NOT NULL COMMENT '产品id',
  `udi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'UDI码',
  `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'DI码',
  `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `batchNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `serialNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '序列号',
  `productionDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产日期',
  `expireDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '失效日期',
  `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂家',
  `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案凭证号',
  `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
  `supName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `createUserId` bigint NOT NULL COMMENT '创建人id',
  `createUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建人姓名',
  `createTime` datetime NOT NULL COMMENT '创建时间',
  `createDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建部门',
  `createDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '创建部门名称',
  `confirmUserId` bigint NULL DEFAULT NULL COMMENT '确认人id',
  `confirmUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人姓名',
  `confirmTime` datetime NULL DEFAULT NULL COMMENT '确认时间',
  `confirmRemark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '确认备注',
  `confirmDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门',
  `confirmDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门名称',
  `confirmPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人联系方式',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备维修单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_repair_apply
-- ----------------------------
DROP TABLE IF EXISTS `device_repair_apply`;
CREATE TABLE `device_repair_apply`  (
  `id` bigint NOT NULL COMMENT '报修单id',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态 待受理，受理中，维修中，完成',
  `applyDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报修部门编码',
  `applyDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报修部门',
  `applyUserId` bigint NOT NULL COMMENT '报修人id',
  `applyUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报修人姓名',
  `applyUserPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '报修人联系方式',
  `applyTime` datetime NOT NULL COMMENT '报修时间',
  `deviceCount` int NOT NULL COMMENT '设备数量',
  `finishCount` int NOT NULL DEFAULT 0 COMMENT '完成数量',
  `confirmDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门',
  `confirmDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门名称',
  `confirmUserId` bigint NULL DEFAULT NULL COMMENT '确认人id',
  `confirmUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人姓名',
  `confirmPhone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人联系方式',
  `confirmTime` datetime NULL DEFAULT NULL COMMENT '确认时间',
  `finishTime` datetime NULL DEFAULT NULL COMMENT '完成时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备报修单' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_repair_apply_detail
-- ----------------------------
DROP TABLE IF EXISTS `device_repair_apply_detail`;
CREATE TABLE `device_repair_apply_detail`  (
  `applyId` bigint NOT NULL COMMENT '报修单id',
  `deviceCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编码',
  `deptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门编码',
  `deptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门名称',
  `description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '问题描述',
  `diagnosisInfo` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '诊断信息',
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '\0' COMMENT '状态  待诊断、待维修、维修中、完成',
  `repairFlag` bit(1) NULL DEFAULT NULL COMMENT '是否需要维修 true/false',
  `repairId` bigint NULL DEFAULT NULL COMMENT '维修单id',
  `productId` bigint NOT NULL COMMENT '产品id',
  `udi` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'UDI码',
  `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'DI码',
  `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
  `batchNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '批次号',
  `serialNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '序列号',
  `productionDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产日期',
  `expireDate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '失效日期',
  `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂家',
  `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案凭证号',
  `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
  `supName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商名称',
  `confirmUserId` bigint NULL DEFAULT NULL COMMENT '确认人id',
  `confirmUserName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认人姓名',
  `confirmTime` datetime NULL DEFAULT NULL COMMENT '确认时间',
  `confirmRemark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '确认备注',
  `confirmDeptCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门',
  `confirmDeptName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '确认部门名称',
  `finishTime` datetime NULL DEFAULT NULL COMMENT '完成时间',
  PRIMARY KEY (`applyId`, `deviceCode`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备报修单明细' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
