#   字段新增   （表名，字段名，字段类型，修改方式（1：新增，2：修改，3：删除）

CREATE TABLE IF NOT EXISTS `device_inspect_task`
(
    `id`            int                                                           NOT NULL AUTO_INCREMENT,
    `orderId`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '任务单号',
    `planOrderIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检计划单号（外键）',
    `deptCode`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '部门',
    `invCode`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '仓库',
    `code`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资产编码',
    `status`        int                                                           NULL DEFAULT NULL COMMENT '状态',
    `type`          int                                                           NULL DEFAULT NULL COMMENT '类型',
    `inspectUser`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检人',
    `remindTime`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '提醒时间',
    `remark`        varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检备注',
    `strartTime`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '任务开始时间',
    `endTime`       datetime(0)                                                   NULL DEFAULT NULL COMMENT '任务结束时间',
    `createTime`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `updateTime`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `expectedTime`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '预期结束时间',
    `repairType`    int                                                           NULL DEFAULT NULL COMMENT '报修类型',
    `level`         int                                                           NULL DEFAULT NULL COMMENT '紧急程度',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_inspect_task_detail
-- ----------------------------
CREATE TABLE IF NOT EXISTS `device_inspect_task_detail`
(
    `id`             int                                                           NOT NULL AUTO_INCREMENT,
    `projectCode`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检项目编码',
    `projectContent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检内容',
    `status`         int                                                           NULL DEFAULT NULL COMMENT '状态（1：未开始；2：已检查；3：异常；4：不巡检',
    `result`         varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检结果备注',
    `inspectImage`   varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检图片',
    `inspectUser`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检人',
    `updateTime`     datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `taskOrderIdFk`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '巡检任务ID外键',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for device_project_set
-- ----------------------------
CREATE TABLE IF NOT EXISTS `device_project_set`
(
    `id`         int                                                           NOT NULL AUTO_INCREMENT,
    `code`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目编号',
    `content`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目内容',
    `type`       int                                                           NULL DEFAULT NULL COMMENT '项目类型：1：巡检；2：养护',
    `remak`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `udpateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    `updateUser` varchar(0) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NULL DEFAULT NULL COMMENT '更新人',
    `createUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
    `createTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


CALL Pro_Temp_ColumnWork('device_repair_order', 'repairType', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'urgencyType', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'planTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'uploadImage', 'text', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'repariName', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'reparistartTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'repariEndTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'repariRemark', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('device_repair_order', 'repariImage', 'text', 1);

CALL Pro_Temp_ColumnWork('device_inspect_plan', 'startTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'endTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'frequency', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'frequencyUnit', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'planStatus', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'inspectUser', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'lastTime', 'datetime', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'nextTime', 'datetime', 1);
INSERT ignore INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`,
                                      `paramType`, `paramExplain`, `updateTime`)
VALUES (2088, 0, '是否只校验批次号', 'only_vail_batch', '0', 0, 0, '是否只校验批次号(0：否；1：是)', NULL);

CALL Pro_Temp_ColumnWork('device_inspect_task', 'repairType', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('device_inspect_task', 'level', 'tinyint', 1);


CALL Pro_Temp_ColumnWork('io_order', 'preInSelected', 'tinyint', 1);

#
# 	update  io_order set preInSelected = 1  WHERE io_order.billNo in (select checkPreInOrders from (select checkPreInOrders from  io_order  WHERE checkPreInOrders is not null GROUP BY checkPreInOrders) a) ;


CREATE TABLE IF NOT EXISTS `sync_edit_log`
(
    `id`         int                                                            NOT NULL AUTO_INCREMENT,
    `recordCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '日志记录号',
    `operType`   tinyint                                                        NULL DEFAULT NULL COMMENT '操作类型（1:增；2:删，3:改，4:查)',
    `dataType`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '操作数据类型',
    `url`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '接口地址',
    `param`      varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请求参数',
    `jsonResult` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '请求结果',
    `directType` tinyint                                                        NULL DEFAULT NULL COMMENT '1:本地操作；2：对方操作',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '备注说明',
    `operUser`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '操作人',
    `updateTime` datetime(0)                                                    NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;


CREATE TABLE IF NOT EXISTS `sync_edit_type`
(
    `id`     int                                                           NOT NULL AUTO_INCREMENT,
    `code`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作类型',
    `name`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作类型名称',
    `remark` 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
  ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


CREATE TABLE IF NOT EXISTS `device_repair_order_detail`
(
    `id`         bigint(0)                                                     NOT NULL,
    `orderIdFk`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
    `code`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目编号',
    `content`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目内容',
    `type`       int(0)                                                        NULL DEFAULT NULL COMMENT '项目类型：1：巡检；2：养护',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `updateUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
    `updateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;


CREATE TABLE IF NOT EXISTS `device_inspect_plan_delect`
(
    `id`         bigint(0)                                                     NOT NULL,
    `orderIdFk`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
    `code`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目编号',
    `content`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '项目内容',
    `type`       int(0)                                                        NULL DEFAULT NULL COMMENT '项目类型：1：巡检；2：养护',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `updateUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
    `updateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;



CALL Pro_Temp_ColumnWork('device_inspect_task', 'id', 'bigint', 2);
CALL Pro_Temp_ColumnWork('device_inspect_task_detail', 'id', 'bigint', 2);
CALL Pro_Temp_ColumnWork('sync_data_set', 'deviceTask', 'tinyint', 1);


# INSERT ignore INTO `auth_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query_param`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2000, '我的申购单 ', 1674, 2, 'purchase/purApply/pureApplyMySearch', 'purchase/purApply/pureApplyMySearch', NULL, 1, 0, 'C', '0', '0', NULL, NULL, '超级用户', '2023-07-20 17:08:38', NULL, NULL, NULL);
# INSERT ignore INTO `udi_wms_wmd`.`auth_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query_param`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2001, '我的领用单', 1685, 1, 'inout/receive/receiveMySearch', 'inout/receive/receiveMySearch', NULL, 1, 0, 'C', '0', '0', NULL, NULL, '超级用户', '2023-08-14 10:35:30', NULL, NULL, NULL);
#

INSERT ignore INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`,
                                      `paramType`, `paramExplain`, `updateTime`)
VALUES (20068, 0, '设备领用是否选取耗材字段', 'device_product', '0', 1, 0, '0：否；1：是', NULL);
INSERT ignore INTO `sys_pdf_template_relevance_label` (`id`, `templateId`, `customerId`, `adminId`, `moduleId`,
                                                       `localAction`, `remark1`, `remark2`, `remark3`, `printType`,
                                                       `modelKey`, `updateTime`)
VALUES (5, 3, 110, 0, 9, '设备打印', NULL, NULL, NULL, NULL, 'lable', '2023-06-25 15:18:37');



CREATE TABLE IF NOT EXISTS `device_asset_cert`
(
    `id`         bigint                                                        NOT NULL,
    `devCodeFk`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备资产编码外键',
    `name`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书名称',
    `code`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书编码',
    `filePath`   text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci         NULL COMMENT '文件路径',
    `vailDate`   datetime(0)                                                   NULL DEFAULT NULL COMMENT '生效期',
    `expireDate` datetime(0)                                                   NULL DEFAULT NULL COMMENT '失效期',
    `status`     tinyint                                                       NULL DEFAULT NULL COMMENT '证书状态',
    `type`       tinyint                                                       NULL DEFAULT NULL COMMENT '证书类型（1：资质证书；2：技术材料）',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注说明',
    `createUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
    `createTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `updateUser` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新人',
    `updateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of device_asset_cert
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;


CREATE TABLE IF NOT EXISTS `device_asset_user`
(
    `id`         bigint                                                        NOT NULL COMMENT '雪花ID',
    `devCodeFk`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备资产编码',
    `userName`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '相关人员名称',
    `contact1`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系方式1',
    `contact2`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系方式2',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注说明',
    `createUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
    `createTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `updateUser` varchar(0) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci   NULL DEFAULT NULL COMMENT '更新人',
    `updateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;


CREATE TABLE IF NOT EXISTS `device_asset_usage`
(
    `id`         bigint                                                        NOT NULL COMMENT '雪花ID',
    `code`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '使用记录号',
    `user`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '使用人',
    `startTime`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '开始时间',
    `endTime`    datetime(0)                                                   NULL DEFAULT NULL COMMENT '结束时间',
    `remark`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `createUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
    `createTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建时间',
    `updateUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
    `updateTime` datetime(0)                                                   NULL DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;


CALL Pro_Temp_ColumnWork('dept_device_detail', 'curUser', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('dept_device_detail', 'location', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('dept_device_detail', 'detailLocation', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('dept_device_detail', 'nameCode', 'varchar(255)', 1);

CALL Pro_Temp_ColumnWork('device_inspect_plan', 'executeCount', 'int', 1);
CALL Pro_Temp_ColumnWork('device_inspect_plan', 'useFrequency', 'int', 1);

