/** 2022-10-20 **/
ALTER TABLE `thr_order`
ADD COLUMN `thirdPartyDate` tinyint(0) NULL DEFAULT NULL COMMENT '判断来源至哪里1：第三方 2：自己创建';




-- //首营管理字段新增与变更

alter table auth_user modify column CustomerId varchar(60);
alter table customer_contact modify column customerId varchar(60);
alter table auth_user modify column CustomerId varchar(60);



alter table company_product_relevance modify column customerId varchar(60);
alter table company_product_relevance modify column enterpriseId varchar(60);
alter table company_product_relevance modify column productId varchar(60);
alter table company_product_relevance modify column registrationId varchar(60);




alter table inv_stockprint_pdf_temp modify column printCodeIdFk varchar(255);
alter table inv_stockprint_pdf_temp modify column stockOrderFk varchar(255);




/*
 Navicat Premium Data Transfer

 Source Server         : mysql
 Source Server Type    : MySQL
 Source Server Version : 80021
 Source Host           : localhost:3306
 Source Schema         : udiwms_ph1

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

 Date: 27/10/2022 14:25:57
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sup_cert
-- ----------------------------
DROP TABLE IF EXISTS `sup_cert`;
CREATE TABLE `sup_cert`  (
                             `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
                             `CustomerId` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '配送企业ID外键',
                             `name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '证书名称',
                             `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书编号',
                             `filePath` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '证书文件路径',
                             `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
                             `createTime` datetime(0) NOT NULL COMMENT '创建时间',
                             `updateTime` datetime(0) NOT NULL COMMENT '更新时间',
                             `vailDate` datetime(0) NULL DEFAULT NULL COMMENT '有效期',
                             `expireDate` datetime(0) NULL DEFAULT NULL COMMENT '失效期',
                             `remark1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                             `type` tinyint NULL DEFAULT NULL COMMENT '证书类型：1:供应商；2.生产企业；3.产品品种',
                             `manufacturerIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产企业ID外键',
                             `productIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品证书ID外键',
                             `auditStatus` tinyint NULL DEFAULT NULL COMMENT '审核状态',
                             `auditComment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核说明',
                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;




DROP TABLE IF EXISTS `sup_cert_set`;
CREATE TABLE `sup_cert_set`  (
                                 `id` int NOT NULL AUTO_INCREMENT,
                                 `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '证书名称',
                                 `need` tinyint NULL DEFAULT NULL COMMENT '是否必选',
                                 `type` tinyint NULL DEFAULT NULL COMMENT '类型：（1.供应商，2.生产企业，3，产品)',
                                 `foreign` tinyint NULL DEFAULT NULL COMMENT '是否进口(1:全部，2：进口，3.国内）',
                                 `cplx` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品类型（器械/实际）',
                                 `hchzsb` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品类别（耗材/设备）',
                                 `flbm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '分类编码',
                                 `imports` tinyint NULL DEFAULT NULL COMMENT '是否进口(1:全部，2：进口，3.国内）',
                                 `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                 `updateTime` datetime(0) NULL DEFAULT NULL,
                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;


-- ----------------------------
-- Table structure for sup_company
-- ----------------------------
DROP TABLE IF EXISTS `sup_company`;
CREATE TABLE `sup_company`  (
                                `customerId` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
                                `companyName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业名称',
                                `bussinessStatus` int NULL DEFAULT NULL COMMENT '企业类型：1.生产企业；2.经营企业；',
                                `creditNum` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '统一社会信用代码',
                                `classes` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `area` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '地址',
                                `detailAddr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '详细地址',
                                `appId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '应用码x',
                                `appSecret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '授权码x',
                                `contacts` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系人',
                                `mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '联系电话',
                                `tel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电话',
                                `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮箱',
                                `areaCode` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `refEntId` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业唯一标识x',
                                `entId` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业IDx',
                                `networkType` int NULL DEFAULT NULL COMMENT '入网标识【0非入网1入网2入驻马上放心】x',
                                `certIdFk` int NULL DEFAULT NULL COMMENT '绑定appkey外键IDx',
                                `parentCompany` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属总部x',
                                `parentIdFk` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属总部Idx',
                                `contactsPapersType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人证件类型：1：身份证',
                                `contactsPapersCode` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人证件号码',
                                `registerStatus` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '登记状态：1：续存（在营，开业，在册），2：吊销，3：注销，4：迁出',
                                `jyxkzh` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '经营许可证号（Ⅲ类）',
                                `jyxkzfzjg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '经营许可证发证机关',
                                `jyxkzyxq` date NULL DEFAULT NULL COMMENT '经营许可证有效期至',
                                `jybapzh` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '经营备案凭证号（Ⅱ类）',
                                `jybabm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '经营备案部门',
                                `fzrq` date NULL DEFAULT NULL COMMENT '发证日期',
                                `suihao` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '税号',
                                `kaihuhang` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户行',
                                `kaihuzhanghao` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '开户账号',
                                `auditStatus` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核状态 0：草稿，4：申请变更，3：允许变更，5：拒绝变更，6：未审核，1：通过，2：不通过',
                                `filePath` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '文件路径',
                                `filePath2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '文件路径',
                                `filePath3` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '文件路径',
                                `filePath4` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '文件路径',
                                `unitIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '往来单位外键',
                                `createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                `createBy` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
                                `updateTime` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                `auditTime` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                                `auditComment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核意见',
                                `editStatus` tinyint NULL DEFAULT NULL COMMENT '保存状态（1.草稿保存，2.已提交保存)',
                                PRIMARY KEY (`customerId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sup_manufacturer
-- ----------------------------
DROP TABLE IF EXISTS `sup_manufacturer`;
CREATE TABLE `sup_manufacturer`  (
                                     `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
                                     `manufacturerId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业ID主键',
                                     `companyName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业名称',
                                     `creditCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '统一社会信用代码',
                                     `companyType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业类型：1：注册人/备案人，2：代理人',
                                     `placeArea` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在地区：省市区',
                                     `placeAreaCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在地区代码',
                                     `placeAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所在地址：详细地址',
                                     `legalPersonName` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人姓名',
                                     `legalPersonPapersType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人证件类型：1：身份证',
                                     `legalPersonPapersCode` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '法人证件号码',
                                     `productionArea` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产地区：省市区',
                                     `productionAreaCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产地区代码',
                                     `productionAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产地址：详细地址',
                                     `registerStatus` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '登记状态：1：续存（在营，开业，在册），2：吊销，3：注销，4：迁出',
                                     `productionLicenceNum` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '医疗器械生产许可证号',
                                     `productionLicenceDate` date NULL DEFAULT NULL COMMENT '医疗器械生产许可证有效期至',
                                     `productionRecordNum` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '医疗器械生产备案凭证号',
                                     `productionRecordSection` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '医疗器械经营备案凭证号\n发证机关/备案部门',
                                     `productionRecordDate` date NULL DEFAULT NULL COMMENT '医疗器械生产备案凭证号发证日期',
                                     `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
                                     `create_date` date NULL DEFAULT NULL COMMENT '创建时间',
                                     `update_date` date NULL DEFAULT NULL COMMENT '更新时间',
                                     `customerId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '往来单位ID主键',
                                     `auditStatus` tinyint NULL DEFAULT NULL COMMENT '审核状态 0：草稿，4：申请变更，3：允许变更，5：拒绝变更，6：未审核，1：通过，2：不通过',
                                     `auditComment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拒绝说明',
                                     PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sup_product
-- ----------------------------
DROP TABLE IF EXISTS `sup_product`;
CREATE TABLE `sup_product`  (
                                `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
                                `productId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品ID',
                                `enterpriseId` bigint UNSIGNED NULL DEFAULT NULL,
                                `recordCode` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案号',
                                `recordProductName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案产品名称',
                                `productManageType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '医疗器械管理类别（Ⅰ类、Ⅱ类、Ⅲ类）',
                                `recordPeopleName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案人名称',
                                `recordPeopleArea` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册人住所地区：省市区',
                                `recordPeopleAreaCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册人住所地区代码',
                                `recordPeopleAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册人住所地址：详细地址',
                                `productType` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '器械类别（器械或诊断试剂）',
                                `productDirectoryCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '器械目录分类编码',
                                `agentName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '代理人名称',
                                `agentArea` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '代理人住所地区：省市区',
                                `agentAreaCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '代理人住所地区代码',
                                `agentAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '代理人住所地址：详细地址',
                                `instructions` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '说明书附件',
                                `productAddress` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产地址',
                                `recordText` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册/备案证电子档案',
                                `placeOrigin` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产地 国产 进口 港澳台',
                                `productionRegion` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产国或地区',
                                `productionCompanyName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产厂商名称',
                                `afterSale` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '售后服务机构',
                                `specification` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规格型号',
                                `structure` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '结构及组成',
                                `scope` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '适用范围',
                                `other` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '其它内容',
                                `filePath` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '注册证/备案凭证电子档 文件地址',
                                `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
                                `create_date` date NULL DEFAULT NULL COMMENT '创建时间',
                                `update_date` date NULL DEFAULT NULL COMMENT '更新时间',
                                `manufacturerIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '生产企业Id',
                                `customerId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '往来单位ID',
                                `auditStatus` tinyint NULL DEFAULT NULL,
                                `auditComment` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `sptm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `ybbm` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `measname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                `cpms` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;



DROP INDEX `uniqueKey` ON inv_prein_product;
alter table inv_prein_product add UNIQUE uniqueKey(`orderIdFk`)


ALTER TABLE `thr_order`
    ADD COLUMN `thirdPartyDate` tinyint(0) NULL DEFAULT NULL COMMENT '判断来源至哪里1：第三方 2：自己创建' AFTER `manufactory`;



ALTER TABLE `sup_cert`
    ADD COLUMN `status` tinyint(0) NULL   DEFAULT NULL   COMMENT '0：启用，1:禁用';

ALTER TABLE `sup_company`
    ADD COLUMN `status` tinyint(0) NULL   DEFAULT NULL   COMMENT '0：启用，1:禁用';

ALTER TABLE `sup_product`
    ADD COLUMN `relIdFk` VARCHAR(64) NULL   DEFAULT NULL   COMMENT '耗材字典关联主键';
ALTER TABLE `sup_product`
    ADD COLUMN `hchzsb` VARCHAR(64) NULL   DEFAULT NULL   COMMENT '耗材或者设备';


alter table company Add column createTime datetime(0) DEFAULT NULL COMMENT '创建时间';
alter table company Add column createBy VARCHAR(64) DEFAULT NULL COMMENT '创建人';
alter table company Add column updateTime datetime(0) DEFAULT NULL COMMENT '更新时间';
alter table company Add column auditTime datetime(0) DEFAULT NULL COMMENT '审核时间';
alter table company Add column auditComment VARCHAR(1024) DEFAULT NULL COMMENT '审核意见';
alter table company Add column editStatus TINYINT NULL DEFAULT NULL COMMENT '保存状态（1.草稿保存，2.已提交保存)';


-- 预验收出库相关功能
alter table io_order Add column preInBillNo varchar(64) DEFAULT NULL COMMENT '预验收入库单号,只有出库时许校验预验收库存才有';
alter table io_order Add column preOutBillNo varchar(64) DEFAULT NULL COMMENT '预验收关联的出库单号,只有预验收入库才有';


alter table inv_prein_product Add column orderIdFk varchar(64) DEFAULT NULL COMMENT '扫码单据外键';
DROP INDEX `uniqueKey` ON inv_prein_product;


alter table sup_cert modify column filePath varchar(255)  null DEFAULT NULL ;

INSERT INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`) VALUES (1070, 0, '配送是否资质校验', 'checkCert', '0', 1, 0, '1:是，0：否');
INSERT INTO `sys_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`) VALUES (1080, 0, '预验收出库是否移除预验收库存', 'clear_prein_inv', '1', 1, 0, '1:是，0：否');


INSERT INTO `spms_za`.`system_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`) VALUES (1070, 0, '配送是否资质校验', 'checkCert', '0', 1, 0, '1:是，0：否');
INSERT INTO `spms_za`.`system_param_config`(`id`, `parentId`, `paramName`, `paramKey`, `paramValue`, `paramStatus`, `paramType`, `paramExplain`) VALUES (1080, 0, '预验收出库是否移除预验收库存', 'clear_prein_inv', '1', 1, 0, '1:是，0：否');

//耗材领用

alter table basic_bustype_change Add column systemDefault tinyint(0) DEFAULT NULL COMMENT '是否系统预设';
alter table thr_order Add column fromSubInvCode VARCHAR(64) DEFAULT NULL COMMENT '往来分库';
alter table thr_order Add column allocateStatus tinyint(0) DEFAULT NULL COMMENT '1:已配货；2：未配货';


DROP TABLE IF EXISTS `basic_bustype_change`;
CREATE TABLE `basic_bustype_change`  (
                                         `id` int NOT NULL AUTO_INCREMENT,
                                         `originAction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原单据类型代码',
                                         `originName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原单据类型名称',
                                         `targetBusAction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '目标业务单据类型',
                                         `targetScAction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '目标扫码单据类型',
                                         `type` tinyint NULL DEFAULT NULL COMMENT '1:领用单据类型；2.产品申购类型；3.采购计划单据类型',
                                         `enable` tinyint NULL DEFAULT NULL COMMENT '0:启用；1:禁用',
                                         `updateTime` datetime(0) NULL DEFAULT NULL,
                                         `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
                                         `systemDefault` tinyint NULL DEFAULT NULL COMMENT '是否系统预设',
                                         PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of basic_bustype_change
-- ----------------------------
INSERT INTO `basic_bustype_change` VALUES (1, 'purplan', '采购计划', 'ST65076733426459', NULL, 3, 0, '2022-11-08 15:36:04', '采购计划审核通过后转采购入库单', 1);



//采购管理相关

DROP TABLE IF EXISTS `pur_apply`;
CREATE TABLE `pur_apply`  (
                              `id` bigint NOT NULL AUTO_INCREMENT,
                              `billNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单据号',
                              `billDate` datetime(0) NULL DEFAULT NULL COMMENT '单据日期',
                              `status` tinyint NULL DEFAULT NULL COMMENT '状态（1.草稿，2.未审核，3.已审核,4.已拒绝）',
                              `billType` tinyint NULL DEFAULT NULL COMMENT '申购类型',
                              `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申购说明',
                              `locStorageCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当前仓库',
                              `invWarehouseCode` 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 '所属部门',
                              `createBy` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
                              `createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                              `auditBy` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核人',
                              `auditTime` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                              `updateTime` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                              `auditRemark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核说明',
                              PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for pur_apply_detail
-- ----------------------------
DROP TABLE IF EXISTS `pur_apply_detail`;
CREATE TABLE `pur_apply_detail`  (
                                     `id` int NOT NULL AUTO_INCREMENT,
                                     `orderIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单外键',
                                     `productId` int NULL DEFAULT NULL COMMENT '产品ID',
                                     `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
                                     `count` int NULL DEFAULT NULL COMMENT '数量',
                                     `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
                                     PRIMARY KEY (`id`) USING BTREE,
                                     UNIQUE INDEX `idFk`(`orderIdFk`, `productId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for pur_plan
-- ----------------------------
DROP TABLE IF EXISTS `pur_plan`;
CREATE TABLE `pur_plan`  (
                             `id` bigint NOT NULL AUTO_INCREMENT,
                             `billNo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单据号',
                             `billDate` datetime(0) NULL DEFAULT NULL COMMENT '单据日期',
                             `status` tinyint NULL DEFAULT NULL COMMENT '状态（1.草稿，2.未审核，3.已审核）',
                             `billType` tinyint NULL DEFAULT NULL COMMENT '申购类型',
                             `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '申购说明',
                             `locStorageCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '当前仓库',
                             `invWarehouseCode` 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 '所属部门',
                             `createBy` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
                             `createTime` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                             `auditBy` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核人',
                             `auditTime` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                             `auditRemark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '审核说明',
                             `updateTime` datetime(0) NULL DEFAULT NULL,
                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for pur_plan_detail
-- ----------------------------
DROP TABLE IF EXISTS `pur_plan_detail`;
CREATE TABLE `pur_plan_detail`  (
                                    `id` int NOT NULL AUTO_INCREMENT,
                                    `orderIdFk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '订单外键',
                                    `productId` int NULL DEFAULT NULL COMMENT '产品ID',
                                    `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
                                    `count` int NULL DEFAULT NULL COMMENT '数量',
                                    `supId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '供应商ID',
                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;



alter table sup_manufacturer Add column createTime datetime(0) DEFAULT NULL COMMENT '创建时间';
alter table sup_manufacturer Add column updateTime datetime(0) DEFAULT NULL COMMENT '更新时间';
alter table sup_product Add column createTime datetime(0) DEFAULT NULL COMMENT '创建时间';
alter table sup_product Add column updateTime datetime(0) DEFAULT NULL COMMENT '更新时间';


alter table sup_manufacturer DROP COLUMN create_date;
alter table sup_manufacturer DROP COLUMN update_date;
alter table sup_product DROP COLUMN create_date;
alter table sup_product DROP COLUMN update_date;



alter table pur_apply Add column targetInv VARCHAR(64) DEFAULT NULL COMMENT '目标仓库';
alter table pur_apply Add column targetSubInv VARCHAR(64) DEFAULT NULL COMMENT '目标分库';


alter table pur_apply modify column billType varchar(60);
alter table pur_plan modify column billType varchar(60);




alter table sup_company add unique index uniquekey(customerId);
alter table sup_manufacturer add unique index uniquekey(manufacturerId,customerId);
alter table sup_product add unique index uniquekey(productId,manufacturerIdFk,customerId);



alter table sync_data_set Add column unCheckCert TINYINT(0) DEFAULT NULL COMMENT '未审核';
alter table sync_data_set Add column checkedCert TINYINT(0) DEFAULT NULL COMMENT '已审核';
alter table sync_data_set Add column companyCert TINYINT(0) DEFAULT NULL COMMENT '企业证书';
alter table sync_data_set Add column manufacturerCert TINYINT(0) DEFAULT NULL COMMENT '生产企业证书';
alter table sync_data_set Add column productCert TINYINT(0) DEFAULT NULL COMMENT '产品证书';


