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

-- ----------------------------
-- Table structure for inv_stock_compare
-- ----------------------------
CREATE TABLE IF NOT EXISTS `inv_stock_compare`
(
    `id`               bigint                                                        NOT NULL,
    `status`           int                                                           NOT NULL COMMENT '状态',
    `thrSysId`         int                                                           NOT NULL COMMENT '第三方系统id',
    `thrSysName`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方系统名称',
    `thirdTableField`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方系统字段名',
    `invCode`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '仓库编码',
    `invName`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '仓库名称',
    `mainAction`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '出入库类型',
    `action`           varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据类型编码',
    `actionName`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据类型名称',
    `compareStartDate` date                                                          NOT NULL COMMENT '筛选开始时间',
    `compareEndDate`   date                                                          NOT NULL COMMENT '筛选结束时间',
    `compareTime`      datetime                                                      NULL     DEFAULT NULL COMMENT '对比时间',
    `siftBatchNo`      bit(1)                                                        NOT NULL DEFAULT b'0' COMMENT '是否区分批次号',
    `remark`           text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci         NULL COMMENT '备注',
    `createTime`       datetime                                                      NOT NULL COMMENT '创建时间',
    `createUser`       bigint                                                        NOT NULL COMMENT '创建人id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存对比表'
  ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for inv_stock_compare_detail
-- ----------------------------
CREATE TABLE IF NOT EXISTS `inv_stock_compare_detail`
(
    `compareId`     bigint                                                        NOT NULL COMMENT '对比id',
    `productId`     bigint                                                        NOT NULL COMMENT '产品id',
    `thrProductId`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方产品编码',
    `nameCode`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'DI',
    `productName`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品名称',
    `cpms`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品描述',
    `ggxh`          varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规格型号',
    `manufactory`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '生产厂家',
    `ylqxzcrbarmc`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '医疗器械注册/备案人名称',
    `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '注册证编号/备案批准编号',
    `mainAction`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '出入库类型',
    `count`         int                                                           NOT NULL COMMENT '对应数量',
    `thrCount`      int                                                           NULL DEFAULT NULL COMMENT '第三方数量',
    `compareCount`  int                                                           NULL DEFAULT NULL COMMENT '对比数量',
    PRIMARY KEY (`compareId`, `productId`, `mainAction`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存对比明细'
  ROW_FORMAT = Dynamic;


CALL Pro_Temp_ColumnWork('io_order', 'confirmUser', 'varchar(255)', 1);


CREATE TABLE IF NOT EXISTS `sys_app_version`
(
    `id`          int                                                           NOT NULL,
    `type`        varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NOT NULL COMMENT '类型：android,pc,',
    `versionName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '版本号',
    `versionCode` int                                                           NULL DEFAULT NULL,
    `appName`     varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci  NULL DEFAULT NULL COMMENT '应用名称',
    `createTime`  datetime(0)                                                   NULL DEFAULT NULL COMMENT '创建日期',
    `downloadUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '下载地址',
    `updateLog`   varchar(600) 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;

INSERT ignore INTO `sys_app_version`(`id`, `type`, `versionName`, `versionCode`, `appName`, `createTime`, `downloadUrl`,
                                     `updateLog`)
VALUES (1, 'udi_wms_new', '3.0.6', 306, 'UDI扫码终端', '2023-10-30 18:42:24', 'http://192.168.1.11:9150/udiwms_new.apk',
        '1.单据审核移除UDI码异常提示；2优化多项功能');



CALL Pro_Temp_ColumnWork('basic_product_category', 'deptCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_product_category', 'invCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'inPreInBack', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'deptNoInvType', 'tinyint', 1);


INSERT ignore INTO sys_param_config(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`,
                                    `paramType`, `paramExplain`, `updateTime`)
VALUES (20088, 0, '单据详情展示方式', 'order_detail_visible', '1', 0, 0, '1:按DI统一排序2：按扫码或录入时间排序', NULL);

CALL Pro_Temp_ColumnWork('io_order_detail_biz', 'sterBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_order_detail_biz', 'sterDate', 'varchar(255)', 1);

CALL Pro_Temp_ColumnWork('io_order_detail_code', 'sterBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_order_detail_code', 'sterDate', 'varchar(255)', 1);

CALL Pro_Temp_ColumnWork('io_order_detail_result', 'sterBatchNo', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('io_order_detail_result', 'sterDate', 'varchar(255)', 1);


UPDATE `auth_menu`
SET `menu_name`   = '耗材字典维护',
    `parent_id`   = 1644,
    `order_num`   = 1,
    `path`        = 'maintain',
    `component`   = 'basic/product/product',
    `query_param` = '{\"vueRouteSource\":1}',
    `is_frame`    = 1,
    `is_cache`    = 0,
    `menu_type`   = 'C',
    `visible`     = '0',
    `status`      = '0',
    `perms`       = 'basic:product:maintain',
    `icon`        = NULL,
    `create_by`   = '超级用户',
    `create_time` = '2023-01-11 17:02:20',
    `update_by`   = NULL,
    `update_time` = NULL,
    `remark`      = NULL
WHERE `menu_id` = 1646;
UPDATE `auth_menu`
SET `menu_name`   = '产品信息导出',
    `parent_id`   = 1616,
    `order_num`   = 2,
    `path`        = 'basic/product/product',
    `component`   = 'basic/product/product',
    `query_param` = '{\"vueRouteSource\":2}',
    `is_frame`    = 1,
    `is_cache`    = 0,
    `menu_type`   = 'C',
    `visible`     = '0',
    `status`      = '0',
    `perms`       = 'thirdSys:product:export',
    `icon`        = '',
    `create_by`   = '超级用户',
    `create_time` = '2022-12-28 11:30:58',
    `update_by`   = NULL,
    `update_time` = NULL,
    `remark`      = NULL
WHERE `menu_id` = 1618;


CREATE TABLE IF NOT EXISTS `thr_product_type`
(
    `id`       int                                                           NOT NULL,
    `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 '类别名称',
    `thirdSys` 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;

CALL Pro_Temp_ColumnWork('basic_udirel', 'uploadFlag', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('basic_udirel', 'uploadMsg', 'varchar(1024)', 1);

CALL Pro_Temp_ColumnWork('thr_products', 'prcitmcode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('thr_products', 'invCode', 'varchar(255)', 1);


CALL Pro_Temp_ColumnWork('basic_sk_prescribe', 'adNum', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item', 'adNum', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item_detail', 'nameCode', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item_detail', 'amount', 'decimal(10, 3)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item_detail', 'adNum', 'varchar(255)', 1);

CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'vailPrescribe', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('basic_bussiness_type', 'inputSick', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('io_order', 'sickerAdNum', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item_detail', 'pId', 'varchar(255)', 2);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe_item_detail', 'updateTime', 'datetime', 1);


CREATE TABLE IF NOT EXISTS `io_stat_detail`
(
    `id`            int                                                           NOT NULL AUTO_INCREMENT,
    `recordKeyFk`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '汇总记录号',
    `relIdFk`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '物资编码主键',
    `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 '批次号',
    `inCount`       int                                                           NULL DEFAULT NULL COMMENT '入库数量',
    `inPrice`       decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '入库价格',
    `inAmount`      decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '入库金额',
    `outCount`      int                                                           NULL DEFAULT NULL COMMENT '出库数量',
    `outPrice`      decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '出库价格',
    `outAmount`     decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '出库金额',
    `balanceCount`  int                                                           NULL DEFAULT NULL COMMENT '结余数量',
    `balancePrice`  decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '结余价格',
    `balanceAmount` decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '结余金额',
    `remark`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
    `updateTime`    datetime(0)                                                   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 '仓库',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  ROW_FORMAT = Dynamic;


CALL Pro_Temp_ColumnWork('io_stat_order', 'startDate', 'datetime', 1);
CALL Pro_Temp_ColumnWork('io_stat_order', 'endDate', 'datetime', 1);
CALL Pro_Temp_ColumnWork('io_stat_order', 'status', 'tinyint', 1);
CALL Pro_Temp_ColumnWork('io_stat_order', 'statType', 'tinyint', 1);

CALL Pro_Temp_ColumnWork('basic_sk_prescribe', 'deptName', 'varchar(255)', 1);
CALL Pro_Temp_ColumnWork('basic_sk_prescribe', 'deptCode', 'varchar(255)', 1);


CREATE TABLE IF NOT EXISTS `io_order_sk_prescribe`
(
    `id`            bigint                                                        NOT NULL AUTO_INCREMENT,
    `pId`           bigint                                                        NOT NULL COMMENT '项目组套外键',
    `sickerCode`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '患者编码',
    `prescribeCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '处方编码',
    `relId`         bigint                                                        NULL DEFAULT NULL COMMENT '耗材产品id',
    `thrName`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '耗材名称',
    `thrCode`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '耗材编码',
    `measureCount`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量数量',
    `measureUnit`   varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
    `category`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类别',
    `frequency`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '频率',
    `count`         int                                                           NULL DEFAULT NULL COMMENT '数量',
    `price`         decimal(16, 4)                                                NULL DEFAULT NULL COMMENT '价格',
    `ggxh`          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 '备注',
    `nameCode`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
    `amount`        decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '总金额',
    `adNum`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '住院号',
    `realCount`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '实际数量',
    `realPrice`     decimal(10, 3)                                                NULL DEFAULT NULL COMMENT '实际价格',
    `orderIdFk`     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;




