20260914223013
This commit is contained in:
1 parent
549c8bd2eb
commit
63514476d7
60 files changed
+6478
-2004
No files matched your search
@@ -0,0 +1,127 @@
|
||||
/* ============================================================================
|
||||
FMS 新系统业务表建表脚本 — 联系人
|
||||
依据文档:FMS业务表设计.md
|
||||
|
||||
使用说明:
|
||||
1. 执行前先切换到目标数据库(USE [数据库名])。
|
||||
2. 脚本只建表、索引和查询视图,不含初始化数据和迁移数据。
|
||||
3. 不使用外键、CHECK、触发器;关联完整性和业务校验由业务层处理。
|
||||
4. 表已存在时先用「重建」段落删除旧对象,再执行建表段落。
|
||||
============================================================================ */
|
||||
|
||||
SET NOCOUNT ON;
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
重建(仅旧结构需要重建时执行,会删除这些表及其数据)
|
||||
============================================================================ */
|
||||
|
||||
drop view if exists dbo.v_b_contact;
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_contact_type;
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_contact;
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
主表
|
||||
============================================================================ */
|
||||
|
||||
create table dbo.b_contact (
|
||||
b_id bigint not null primary key, -- 主键(雪花)
|
||||
b_ywid varchar(50) not null, -- 业务ID(旧库 b_contact.b_id)
|
||||
b_name_ch nvarchar(50) null, -- 中文名
|
||||
b_name_en nvarchar(50) null, -- 英文名
|
||||
b_sex nvarchar(50) null, -- 性别
|
||||
b_birthday date null, -- 生日
|
||||
b_duty nvarchar(50) null, -- 职务
|
||||
b_departmentname nvarchar(50) null, -- 部门
|
||||
b_phone nvarchar(50) null, -- 电话
|
||||
b_mobilephone nvarchar(50) null, -- 手机
|
||||
b_fax nvarchar(50) null, -- 传真
|
||||
b_email varchar(50) null, -- 邮件
|
||||
b_homephone nvarchar(50) null, -- 家庭电话
|
||||
b_homeaddr nvarchar(255) null, -- 家庭住址
|
||||
b_taste nvarchar(50) null, -- 口味偏好
|
||||
b_habit nvarchar(50) null, -- 习惯
|
||||
b_homesituation nvarchar(50) null, -- 家庭情况
|
||||
b_picture varchar(500) null, -- 照片(文件路径)
|
||||
b_cate_id varchar(50) null, -- 联系人类型(b_contact_type.b_id)
|
||||
b_type1_id varchar(50) null, -- 备用分类
|
||||
b_customer_id bigint null, -- 所属往来单位(b_othercompany.b_id)
|
||||
b_owner_id varchar(50) null, -- 业务员(b_user.b_id)
|
||||
b_isdefault tinyint not null default 0, -- 是否默认联系人(0/1)
|
||||
b_showcolor int null, -- 显示颜色
|
||||
b_htbegindate date null, -- 合同开始日期
|
||||
b_htenddate date null, -- 合同结束日期
|
||||
b_state varchar(50) null, -- 状态
|
||||
b_bz nvarchar(1000) null, -- 备注
|
||||
b_created_by varchar(50) null, -- 创建人
|
||||
b_created_at datetime2 null, -- 创建时间
|
||||
b_updated_by varchar(50) null, -- 最后修改人
|
||||
b_updated_at datetime2 null -- 最后修改时间
|
||||
);
|
||||
GO
|
||||
|
||||
create unique index ux_b_contact_ywid on dbo.b_contact (b_ywid);
|
||||
GO
|
||||
|
||||
create index ix_b_contact_customer on dbo.b_contact (b_customer_id, b_id);
|
||||
GO
|
||||
|
||||
create index ix_b_contact_name on dbo.b_contact (b_name_ch, b_id);
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
联系人类型字典
|
||||
============================================================================ */
|
||||
|
||||
create table dbo.b_contact_type (
|
||||
b_id varchar(50) not null primary key, -- 类型编码
|
||||
b_name nvarchar(50) null, -- 类型名称
|
||||
b_i18n varchar(150) null, -- 多语言资源键
|
||||
b_canuse tinyint not null default 1, -- 是否启用(0/1)
|
||||
b_xh int not null default 0, -- 显示顺序
|
||||
b_bz nvarchar(200) null, -- 备注
|
||||
b_created_by varchar(50) null,
|
||||
b_created_at datetime2 null,
|
||||
b_updated_by varchar(50) null,
|
||||
b_updated_at datetime2 null
|
||||
);
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
查询视图
|
||||
|
||||
用途:作为 s_module.b_view_table 的数据源。列表查询直接 select ... from 该视图,
|
||||
s_field.b_field 必须是视图里真实存在的列。
|
||||
说明:视图只供查询,写库仍走 s_module.b_save_table = b_contact。
|
||||
============================================================================ */
|
||||
|
||||
create or alter view dbo.v_b_contact as
|
||||
select c.b_id, c.b_ywid, c.b_name_ch, c.b_name_en, c.b_sex, c.b_phone,
|
||||
c.b_mobilephone, c.b_fax, c.b_email,
|
||||
c.b_duty, c.b_homephone, c.b_cate_id, c.b_homeaddr, c.b_bz,
|
||||
c.b_departmentname, c.b_picture,
|
||||
c.b_customer_id, c.b_owner_id, c.b_isdefault,
|
||||
c.b_taste, c.b_habit, c.b_homesituation,
|
||||
u.b_name as v_ownername, -- 业务员姓名
|
||||
d.b_name as v_ownerdepartment, -- 业务员所属部门
|
||||
c.b_showcolor,
|
||||
o.b_name as v_customer_name, -- 客户名称
|
||||
c.b_birthday,
|
||||
case when isnull(c.b_name_ch, '') = '' then c.b_name_en
|
||||
when isnull(c.b_name_en, '') = '' then c.b_name_ch
|
||||
else isnull(c.b_name_ch, '') + isnull(c.b_name_en, '') end as b_name,
|
||||
c.b_type1_id,
|
||||
c.b_htbegindate, c.b_htenddate,
|
||||
c.b_created_by, c.b_created_at, c.b_updated_by, c.b_updated_at,
|
||||
c.b_state
|
||||
from dbo.b_contact c
|
||||
left join dbo.b_othercompany o on o.b_id = c.b_customer_id
|
||||
left join dbo.b_user u on u.b_id = c.b_owner_id
|
||||
left join dbo.b_dept d on d.b_id = u.b_dept_id
|
||||
where isnull(o.b_ywid, '') <> 'b_employee';
|
||||
GO
|
||||
@@ -155,7 +155,7 @@ GO
|
||||
============================================================================ */
|
||||
|
||||
create table dbo.b_grade (
|
||||
b_id varchar(50) not null primary key, -- 级别编码
|
||||
b_id bigint not null primary key, -- 主键(雪花)
|
||||
b_name nvarchar(50) null, -- 级别名称
|
||||
b_i18n varchar(150) null, -- 多语言资源键
|
||||
b_canuse tinyint not null default 1, -- 是否启用(0/1)
|
||||
@@ -173,7 +173,7 @@ GO
|
||||
============================================================================ */
|
||||
|
||||
create table dbo.b_from (
|
||||
b_id varchar(50) not null primary key, -- 来源编码
|
||||
b_id bigint not null primary key, -- 主键(雪花)
|
||||
b_name nvarchar(50) null, -- 来源名称
|
||||
b_i18n varchar(150) null, -- 多语言资源键
|
||||
b_canuse tinyint not null default 1, -- 是否启用(0/1)
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/* ============================================================================
|
||||
其他数据(base_otherdata):62 张字典表 + 查询视图
|
||||
|
||||
来源:旧库 b_other_bmfl 登记的 62 张数据表(清单见 fms-api/tools/migration/otherdata-modules.txt)
|
||||
设计见《FMS业务表设计.md》「其他数据」节,要点:
|
||||
1. 主键 b_id 为雪花(bigint),旧编号(001/002 等流水号)不保留;
|
||||
2. 各表统一含 b_i18n / b_canuse / b_xh / b_bz 与审计四字段;
|
||||
3. 视图 v_<表名> 供 s_module.b_view_table 查询,写库走 s_module.b_save_table = 表名;
|
||||
4. b_from / b_grade 的重建与引用转换由迁移工具处理(不在本脚本)——
|
||||
它们已按编码主键建好,需随本次迁移重建为雪花,并转换 b_othercompany 的引用值。
|
||||
|
||||
执行:cd fms-api
|
||||
java -Dstdout.encoding=UTF-8 -cp "tools/migration/mssql-jdbc-13.4.0.jre11.jar" \
|
||||
tools/migration/RunSqlFile.java ../sql/fms_business_otherdata.sql
|
||||
============================================================================ */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
① 标准结构(52 张):b_id / b_name / b_i18n / b_canuse / b_xh / b_bz / 审计
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
declare @std table (t sysname primary key);
|
||||
insert into @std (t) values
|
||||
-- 1.常用
|
||||
('b_goodssource'), ('b_dailyfeetype'), ('b_dailytype'), ('b_ywtype'), ('b_ysfs'),
|
||||
-- 2.系统
|
||||
('b_cargo_damage_status'), ('b_bulkforkliftpersonname'), ('b_bulktype'), ('b_bulkpersonname'),
|
||||
('b_bulkstevedorepersonname'), ('b_charging_method'), ('b_unloading_method'), ('b_sys_b_lessfull'),
|
||||
('b_sys_edittype'), ('b_freightpayment'), ('b_jsfs'), ('b_ivtype'), ('b_sys_sex'), ('b_sys_copies'),
|
||||
('b_cztype'), ('b_sys_level'), ('b_sys_operator'), ('b_blstate'), ('b_sys_state'), ('b_sys_feesf'),
|
||||
('bc_priceList_type'), ('b_sys_yesno'), ('b_ystype'), ('b_billtype'), ('b_bgtype'), ('b_httype'),
|
||||
('b_sys_hdtype'), ('b_progress'), ('b_zxstate'),
|
||||
-- 3.仓库
|
||||
('b_depot'), ('b_depotouttype'), ('b_depotintype'),
|
||||
-- 5.物流
|
||||
('car_daily_feetype'), ('car_jiayou_jsfs'), ('car_jiayou_type'), ('car_jiayou_youliao'),
|
||||
('b_cdtype'), ('b_shfs'), ('b_thfs'), ('b_wangdian'), ('b_ywfrom'), ('b_ywtype_tc'),
|
||||
-- 6.铁运
|
||||
('b_servicetype'), ('b_contype'), ('b_ywtype_ht'),
|
||||
-- 7.空运
|
||||
('b_dcterm'), ('b_ywtype_ky');
|
||||
|
||||
declare @t sysname, @sql nvarchar(max);
|
||||
declare std_cursor cursor local fast_forward for select t from @std order by t;
|
||||
open std_cursor;
|
||||
fetch next from std_cursor into @t;
|
||||
while @@fetch_status = 0
|
||||
begin
|
||||
set @sql = 'drop table if exists dbo.' + @t + ';';
|
||||
exec sp_executesql @sql;
|
||||
set @sql = 'create table dbo.' + @t + ' ('
|
||||
+ 'b_id bigint not null primary key, b_name nvarchar(50) null, b_i18n varchar(150) null, '
|
||||
+ 'b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null, '
|
||||
+ 'b_created_by varchar(50) null, b_created_at datetime2 null, '
|
||||
+ 'b_updated_by varchar(50) null, b_updated_at datetime2 null);';
|
||||
exec sp_executesql @sql;
|
||||
print 'created dbo.' + @t;
|
||||
fetch next from std_cursor into @t;
|
||||
end
|
||||
close std_cursor;
|
||||
deallocate std_cursor;
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
② 差异结构(10 张):标准字段之外还有业务字段,按《FMS业务表设计.md》逐张写出
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
drop table if exists dbo.b_feetype;
|
||||
GO
|
||||
create table dbo.b_feetype (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_name_e nvarchar(50) null, b_default tinyint not null default 0,
|
||||
b_amount decimal(18,2) null, b_tax decimal(18,4) null, b_money_id varchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_oceanline;
|
||||
GO
|
||||
create table dbo.b_oceanline (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_edicode varchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_port;
|
||||
GO
|
||||
create table dbo.b_port (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_name_e nvarchar(50) null, b_country nvarchar(50) null,
|
||||
b_oceanline varchar(50) null, b_edicode varchar(50) null, b_tz tinyint not null default 0,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_money;
|
||||
GO
|
||||
create table dbo.b_money (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_edicode varchar(50) null, b_hl decimal(18,4) null,
|
||||
b_symbol nvarchar(50) null, b_isconvert tinyint not null default 0,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_vessel;
|
||||
GO
|
||||
create table dbo.b_vessel (
|
||||
b_id bigint not null primary key, b_name nvarchar(100) null, b_edicode varchar(50) null, b_voy nvarchar(100) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_con_type;
|
||||
GO
|
||||
create table dbo.b_con_type (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_edicode varchar(50) null, b_type nvarchar(50) null,
|
||||
b_linkcon nvarchar(50) null, b_default tinyint not null default 0,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_city;
|
||||
GO
|
||||
create table dbo.b_city (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_name_e nvarchar(50) null,
|
||||
b_country_name_c nvarchar(50) null, b_country_name_e nvarchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_sys_pricelisttype;
|
||||
GO
|
||||
create table dbo.b_sys_pricelisttype (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_dw_id varchar(50) null, b_dw_name varchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_transway;
|
||||
GO
|
||||
create table dbo.b_transway (
|
||||
b_id bigint not null primary key, b_name nvarchar(100) null, b_edicode varchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
drop table if exists dbo.b_package;
|
||||
GO
|
||||
create table dbo.b_package (
|
||||
b_id bigint not null primary key, b_name nvarchar(50) null, b_edicode varchar(50) null,
|
||||
b_i18n varchar(150) null, b_canuse tinyint not null default 1, b_xh int not null default 0, b_bz nvarchar(200) null,
|
||||
b_created_by varchar(50) null, b_created_at datetime2 null, b_updated_by varchar(50) null, b_updated_at datetime2 null);
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
③ 说明:字典模块直接查表(s_module.b_view_table = 表名),不建 v_ 直通视图。
|
||||
早期版本曾按 v_<表名> 生成过一批直通视图,已随模块编码改为表名一并删除。
|
||||
---------------------------------------------------------------------------- */
|
||||
@@ -0,0 +1,82 @@
|
||||
/* ============================================================================
|
||||
FMS 模块注册脚本 — 联系人(v_b_contact)
|
||||
依据文档:FMS业务表设计.md
|
||||
|
||||
使用说明:
|
||||
1. 先执行 fms_business_contact.sql 建表与视图,再执行本脚本。
|
||||
2. 脚本只写模块元数据(s_module / s_field)并修正菜单路由,不含业务数据。
|
||||
3. 界面配置(s_module_schema 的 view / edit)由 FieldNameSync 从旧库 s_columnLib 同步生成。
|
||||
4. 脚本可重复执行:先清空本模块的 s_field / s_module 行再重建。
|
||||
============================================================================ */
|
||||
|
||||
SET NOCOUNT ON;
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
模块定义
|
||||
============================================================================ */
|
||||
|
||||
delete from dbo.s_field where b_module_id = 'v_b_contact';
|
||||
GO
|
||||
|
||||
delete from dbo.s_module where b_id = 'v_b_contact';
|
||||
GO
|
||||
|
||||
insert into dbo.s_module (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_module_type,
|
||||
b_view_table, b_save_table, b_key_field, b_canuse, b_xh)
|
||||
values ('v_b_contact', 'base', 1, '/base/v_b_contact/', N'联系人', 'module.v_b_contact',
|
||||
'data', 'v_b_contact', 'b_contact', 'b_id', 1, 20);
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
字段定义(b_name 先用字段编码占位,随后由 FieldNameSync 同步旧库中文名)
|
||||
============================================================================ */
|
||||
|
||||
insert into dbo.s_field (b_module_id, b_field, b_name, b_i18n, b_type, b_canuse, b_xh)
|
||||
values ('v_b_contact', 'b_id', 'b_id', null, 'number', 1, 10),
|
||||
('v_b_contact', 'b_ywid', 'b_ywid', null, 'input', 1, 20),
|
||||
('v_b_contact', 'b_name_ch', 'b_name_ch', null, 'input', 1, 30),
|
||||
('v_b_contact', 'b_name_en', 'b_name_en', null, 'input', 1, 40),
|
||||
('v_b_contact', 'b_sex', 'b_sex', null, 'input', 1, 50),
|
||||
('v_b_contact', 'b_phone', 'b_phone', null, 'input', 1, 60),
|
||||
('v_b_contact', 'b_mobilephone', 'b_mobilephone', null, 'input', 1, 70),
|
||||
('v_b_contact', 'b_fax', 'b_fax', null, 'input', 1, 80),
|
||||
('v_b_contact', 'b_email', 'b_email', null, 'input', 1, 90),
|
||||
('v_b_contact', 'b_duty', 'b_duty', null, 'input', 1, 100),
|
||||
('v_b_contact', 'b_homephone', 'b_homephone', null, 'input', 1, 110),
|
||||
('v_b_contact', 'b_cate_id', 'b_cate_id', null, 'input', 1, 120),
|
||||
('v_b_contact', 'b_homeaddr', 'b_homeaddr', null, 'input', 1, 130),
|
||||
('v_b_contact', 'b_bz', 'b_bz', null, 'input', 1, 140),
|
||||
('v_b_contact', 'b_departmentname', 'b_departmentname', null, 'input', 1, 150),
|
||||
('v_b_contact', 'b_picture', 'b_picture', null, 'input', 1, 160),
|
||||
('v_b_contact', 'b_customer_id', 'b_customer_id', null, 'input', 1, 170),
|
||||
('v_b_contact', 'b_owner_id', 'b_owner_id', null, 'input', 1, 180),
|
||||
('v_b_contact', 'b_isdefault', 'b_isdefault', null, 'checkbox', 1, 190),
|
||||
('v_b_contact', 'b_taste', 'b_taste', null, 'input', 1, 200),
|
||||
('v_b_contact', 'b_habit', 'b_habit', null, 'input', 1, 210),
|
||||
('v_b_contact', 'b_homesituation', 'b_homesituation', null, 'input', 1, 220),
|
||||
('v_b_contact', 'v_ownername', 'v_ownername', null, 'input', 1, 230),
|
||||
('v_b_contact', 'v_ownerdepartment', 'v_ownerdepartment', null, 'input', 1, 240),
|
||||
('v_b_contact', 'b_showcolor', 'b_showcolor', null, 'input', 1, 250),
|
||||
('v_b_contact', 'v_customer_name', 'v_customer_name', null, 'input', 1, 260),
|
||||
('v_b_contact', 'b_birthday', 'b_birthday', null, 'date', 1, 270),
|
||||
('v_b_contact', 'b_name', 'b_name', null, 'input', 1, 280),
|
||||
('v_b_contact', 'b_type1_id', 'b_type1_id', null, 'input', 1, 290),
|
||||
('v_b_contact', 'b_htbegindate', 'b_htbegindate', null, 'date', 1, 300),
|
||||
('v_b_contact', 'b_htenddate', 'b_htenddate', null, 'date', 1, 310),
|
||||
('v_b_contact', 'b_created_by', 'b_created_by', null, 'input', 1, 320),
|
||||
('v_b_contact', 'b_created_at', 'b_created_at', null, 'datetime', 1, 330),
|
||||
('v_b_contact', 'b_updated_by', 'b_updated_by', null, 'input', 1, 340),
|
||||
('v_b_contact', 'b_updated_at', 'b_updated_at', null, 'datetime', 1, 350),
|
||||
('v_b_contact', 'b_state', 'b_state', null, 'input', 1, 360);
|
||||
GO
|
||||
|
||||
/* ============================================================================
|
||||
菜单路由修正:联系人菜单原为占位(/dashboard 且路径缺前导斜杠)
|
||||
============================================================================ */
|
||||
|
||||
update dbo.s_menu
|
||||
set b_route = '/base/contact',
|
||||
b_path = '/base/contact/'
|
||||
where b_id = 'contact';
|
||||
GO
|
||||
@@ -0,0 +1,215 @@
|
||||
/* ============================================================================
|
||||
其他数据:模块注册(base_otherdata 根 + 6 个分组 + 64 个数据模块 + 字段定义)
|
||||
|
||||
依据文档:FMS业务表设计.md「其他数据」节
|
||||
前置脚本:fms_business_otherdata.sql(建表 + 视图)
|
||||
说明:
|
||||
1. 三层组织:其他数据(base_otherdata)→ 分组(常用/系统/仓库/物流/铁运/空运,module 类型)
|
||||
→ 数据模块(data);模块编码 = 表名(如 b_money),b_view_table / b_save_table 都指向表;
|
||||
2. b_canuse 沿用旧库 b_other_bmfl 的启用状态(启用 46、停用 16);
|
||||
3. s_field 的字段名先用字段编码占位,重跑本脚本后需执行
|
||||
FieldNameSync --all-otherdata --force 重建字段名与 view/edit 配置;
|
||||
4. b_from / b_grade 也在此注册(表由迁移工具重建为雪花);
|
||||
5. b_othercompany_partner_type(树形分类)不在本脚本注册,由 othercompany 页面维护。
|
||||
============================================================================ */
|
||||
|
||||
SET NOCOUNT ON;
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
1. 清理(脚本可重复执行)
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
delete from dbo.s_field where b_module_id in (select b_id from dbo.s_module where b_path like '/base/base_otherdata/%');
|
||||
GO
|
||||
|
||||
delete from dbo.s_module where b_path like '/base/base_otherdata/%' or b_id = 'base_otherdata';
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
2. 根模块
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
insert into dbo.s_module (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_module_type, b_canuse, b_xh, b_bz)
|
||||
values ('base_otherdata', 'base', 1, '/base/base_otherdata/', N'其他数据', 'module.base_otherdata', 'module', 1, 30,
|
||||
N'原 G3HY「其他数据」的 62 张基础字典 + b_from / b_grade');
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
3. 分组(6 个 module 节点):常用 / 系统 / 仓库 / 物流 / 铁运 / 空运
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
declare @groups table (id varchar(50) primary key, name nvarchar(200) not null, xh int not null);
|
||||
insert into @groups (id, name, xh) values
|
||||
('od_common', N'常用', 10),
|
||||
('od_system', N'系统', 20),
|
||||
('od_depot', N'仓库', 30),
|
||||
('od_logistics', N'物流', 40),
|
||||
('od_rail', N'铁运', 50),
|
||||
('od_air', N'空运', 60);
|
||||
|
||||
insert into dbo.s_module (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_module_type, b_canuse, b_xh)
|
||||
select g.id, 'base_otherdata', 2, '/base/base_otherdata/' + g.id + '/', g.name, 'module.' + g.id, 'module', 1, g.xh
|
||||
from @groups g;
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
4. 数据模块(64 个):id 为 'v_' + 表名(列表统一写法),插入时取表名作为模块编码;
|
||||
分组按 xh 段划分(与列表中的分组顺序一致);b_view_table / b_save_table 都指向表本身
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
declare @mods table (id varchar(50) primary key, name nvarchar(200) not null, canuse tinyint not null, xh int not null);
|
||||
insert into @mods (id, name, canuse, xh) values
|
||||
-- 1.常用
|
||||
('v_b_feetype', N'费用类别', 1, 10),
|
||||
('v_b_oceanline', N'航线', 1, 20),
|
||||
('v_b_goodssource', N'货物来源', 1, 30),
|
||||
('v_b_dailyfeetype', N'日常费用', 1, 40),
|
||||
('v_b_dailytype', N'收支类型', 0, 50),
|
||||
('v_b_ywtype', N'业务类型', 1, 60),
|
||||
('v_b_ysfs', N'运输方式', 1, 70),
|
||||
('v_b_port', N'港口', 1, 80),
|
||||
('v_b_money', N'币种', 1, 90),
|
||||
-- 2.系统
|
||||
('v_b_cargo_damage_status', N'货损状态', 1, 100),
|
||||
('v_b_bulkforkliftpersonname', N'散货铲车人员', 1, 110),
|
||||
('v_b_bulktype', N'散货类型', 1, 120),
|
||||
('v_b_bulkpersonname', N'散货理货人员', 1, 130),
|
||||
('v_b_bulkstevedorepersonname', N'散货装卸人员', 1, 140),
|
||||
('v_b_charging_method', N'收费方式', 1, 150),
|
||||
('v_b_unloading_method', N'卸货方式', 1, 160),
|
||||
('v_b_sys_b_lessfull', N'装箱', 1, 170),
|
||||
('v_b_sys_edittype', N'字段编辑选择', 0, 180),
|
||||
('v_b_vessel', N'船名船次', 1, 190),
|
||||
('v_b_freightpayment', N'运费条款', 1, 200),
|
||||
('v_b_con_type', N'箱型管理', 1, 210),
|
||||
('v_b_jsfs', N'结算方式', 0, 220),
|
||||
('v_b_city', N'城市', 0, 230),
|
||||
('v_b_ivtype', N'发票类型', 1, 240),
|
||||
('v_b_sys_sex', N'性别', 0, 250),
|
||||
('v_b_sys_copies', N'提单份数', 0, 260),
|
||||
('v_b_cztype', N'称重方式', 1, 270),
|
||||
('v_b_sys_level', N'级别', 0, 280),
|
||||
('v_b_sys_operator', N'条件设置操作符', 0, 290),
|
||||
('v_b_blstate', N'提单方式', 0, 300),
|
||||
('v_b_sys_state', N'审核状态', 0, 310),
|
||||
('v_b_sys_feesf', N'费用收付', 0, 320),
|
||||
('v_bc_priceList_type', N'价目表类型', 0, 330),
|
||||
('v_b_sys_yesno', N'是否', 0, 340),
|
||||
('v_b_sys_pricelisttype', N'合作伙伴类型', 0, 350),
|
||||
('v_b_ystype', N'付款类型', 1, 360),
|
||||
('v_b_billtype', N'账单类型', 1, 370),
|
||||
('v_b_bgtype', N'报关方式', 1, 380),
|
||||
('v_b_httype', N'合同类型', 0, 390),
|
||||
('v_b_transway', N'运输条款', 1, 400),
|
||||
('v_b_from', N'客户来源', 1, 410),
|
||||
('v_b_grade', N'客户级别', 1, 420),
|
||||
('v_b_sys_hdtype', N'回单类型', 1, 430),
|
||||
('v_b_package', N'包装单位', 1, 440),
|
||||
('v_b_progress', N'进度情况', 1, 450),
|
||||
('v_b_zxstate', N'执行状态', 0, 460),
|
||||
-- 3.仓库
|
||||
('v_b_depot', N'仓库', 1, 470),
|
||||
('v_b_depotouttype', N'出库类型', 1, 480),
|
||||
('v_b_depotintype', N'入库类型', 1, 490),
|
||||
-- 5.物流
|
||||
('v_car_daily_feetype', N'费用报销-费用类型', 1, 500),
|
||||
('v_car_jiayou_jsfs', N'计算方式', 1, 510),
|
||||
('v_car_jiayou_type', N'加油类型', 1, 520),
|
||||
('v_car_jiayou_youliao', N'燃油种类', 1, 530),
|
||||
('v_b_cdtype', N'派车类型', 1, 540),
|
||||
('v_b_shfs', N'派送方式', 1, 550),
|
||||
('v_b_thfs', N'提货方式', 1, 560),
|
||||
('v_b_wangdian', N'网点', 1, 570),
|
||||
('v_b_ywfrom', N'业务来源', 1, 580),
|
||||
('v_b_ywtype_tc', N'业务类型', 1, 590),
|
||||
-- 6.铁运
|
||||
('v_b_servicetype', N'服务内容', 1, 600),
|
||||
('v_b_contype', N'箱属', 1, 610),
|
||||
('v_b_ywtype_ht', N'业务类型', 1, 620),
|
||||
-- 7.空运
|
||||
('v_b_dcterm', N'订舱条款', 1, 630),
|
||||
('v_b_ywtype_ky', N'业务类型', 1, 640);
|
||||
|
||||
insert into dbo.s_module (b_id, b_parent_id, b_depth, b_path, b_name, b_i18n, b_module_type,
|
||||
b_view_table, b_save_table, b_key_field, b_canuse, b_xh)
|
||||
select t.code, g.id, 3, '/base/base_otherdata/' + g.id + '/' + t.code + '/', m.name, 'module.' + t.code, 'data',
|
||||
t.code, t.code, 'b_id', m.canuse, m.xh
|
||||
from @mods m
|
||||
cross apply (select stuff(m.id, 1, 2, '') as code) t
|
||||
cross apply (select case
|
||||
when m.xh < 100 then 'od_common'
|
||||
when m.xh < 470 then 'od_system'
|
||||
when m.xh < 500 then 'od_depot'
|
||||
when m.xh < 600 then 'od_logistics'
|
||||
when m.xh < 630 then 'od_rail'
|
||||
else 'od_air' end as id) g;
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
5. 字段定义:从各模块 b_save_table 的列生成(审计字段也保留)
|
||||
b_name 先占位,随后由 FieldNameSync 从旧库 s_columnLib 同步中文名
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
insert into dbo.s_field (b_module_id, b_field, b_name, b_i18n, b_type, b_canuse, b_xh)
|
||||
select sm.b_id,
|
||||
c.name,
|
||||
c.name,
|
||||
null,
|
||||
case
|
||||
when ty.name in ('bigint', 'int', 'decimal', 'numeric') then 'number'
|
||||
when ty.name = 'tinyint' then 'checkbox'
|
||||
when ty.name in ('datetime2', 'date', 'datetime') then 'datetime'
|
||||
else 'input'
|
||||
end,
|
||||
1,
|
||||
row_number() over (partition by sm.b_id order by c.column_id) * 10
|
||||
from dbo.s_module sm
|
||||
join sys.columns c on c.object_id = object_id('dbo.' + sm.b_save_table)
|
||||
join sys.types ty on ty.user_type_id = c.user_type_id
|
||||
where sm.b_path like '/base/base_otherdata/%'
|
||||
and sm.b_module_type = 'data';
|
||||
GO
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
6. 字典模块直接查表(b_view_table = 表名),不建 v_ 直通视图;
|
||||
单表无需叠加 join / 计算列时,不加视图,与旧库一致。
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
7. 通用字段中文名:旧库 s_columnLib 没有这些新增字段的记录,FieldNameSync
|
||||
同步不到,这里统一补上(只填占位,不覆盖已同步的名称)
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
update dbo.s_field
|
||||
set b_name = case b_field
|
||||
when 'b_id' then N'系统编号'
|
||||
when 'b_i18n' then N'多语言键'
|
||||
when 'b_canuse' then N'是否启用'
|
||||
when 'b_xh' then N'显示顺序'
|
||||
when 'b_created_by' then N'创建人'
|
||||
when 'b_created_at' then N'创建时间'
|
||||
when 'b_updated_by' then N'更新人'
|
||||
when 'b_updated_at' then N'更新时间'
|
||||
when 'b_edicode' then N'EDI编码'
|
||||
when 'b_name' then N'名称'
|
||||
when 'b_name_e' then N'英文名'
|
||||
when 'b_bz' then N'备注'
|
||||
when 'b_money_id' then N'币种'
|
||||
when 'b_country' then N'国家'
|
||||
when 'b_country_name_c' then N'国家(中文)'
|
||||
when 'b_country_name_e' then N'国家(英文)'
|
||||
when 'b_voy' then N'船次'
|
||||
when 'b_type' then N'类型'
|
||||
when 'b_linkcon' then N'关联箱型'
|
||||
when 'b_dw_id' then N'关联单位字段'
|
||||
when 'b_dw_name' then N'关联单位视图'
|
||||
when 'b_hl' then N'汇率'
|
||||
when 'b_symbol' then N'货币符号'
|
||||
when 'b_isconvert' then N'参与折算'
|
||||
when 'b_tz' then N'标志位'
|
||||
else b_name
|
||||
end
|
||||
where b_name = b_field
|
||||
and b_module_id in (select b_id from dbo.s_module where b_path like '/base/base_otherdata/%');
|
||||
GO
|
||||
Reference in new issue
Block a user