feat: 企业信息管理
parent
bd629f7e63
commit
4d4d94f7d7
205
docs/init-v2.sql
205
docs/init-v2.sql
|
|
@ -12,7 +12,7 @@ USE `jjb_saas_safety_eval`;
|
|||
-- 作用: 机构基本信息及认证状态(填写信息/审核中/通过)
|
||||
-- ------------------------------------------------------------
|
||||
create table org_info (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
unit_name varchar(200) not null comment '生产经营单位名称',
|
||||
credit_code varchar(18) not null comment '统一社会信用代码',
|
||||
safety_industry_category_code varchar(32) default null comment '安全生产监管行业类别编码',
|
||||
|
|
@ -70,7 +70,7 @@ create table org_info (
|
|||
-- 关联: org_id -> org_info.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_qualification (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
license_type_code varchar(32) default null comment '证照类型编码',
|
||||
license_type_name varchar(50) default null comment '证照类型名称',
|
||||
|
|
@ -104,11 +104,12 @@ create table org_qualification (
|
|||
-- 关联: org_id -> org_info.id; parent_id 自关联
|
||||
-- ------------------------------------------------------------
|
||||
create table org_department (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
parent_id bigint default 0 comment '上级部门id,0为根',
|
||||
dept_name varchar(100) not null comment '部门名称',
|
||||
manager_name varchar(50) default null comment '负责人',
|
||||
manager_name varchar(50) default null comment '负责人姓名',
|
||||
manager_account varchar(50) default null comment '负责人账号',
|
||||
dept_level_code varchar(32) default null comment '部门级别编码',
|
||||
dept_level_name varchar(50) default null comment '部门级别名称',
|
||||
delete_enum varchar(32) default null comment '删除标识true false',
|
||||
|
|
@ -133,7 +134,7 @@ create table org_department (
|
|||
-- 关联: org_id -> org_info.id; dept_id -> org_department.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_position (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
dept_id bigint not null comment '部门id',
|
||||
position_name varchar(100) not null comment '岗位名称',
|
||||
|
|
@ -160,7 +161,7 @@ create table org_position (
|
|||
-- 关联: org_id -> org_info.id; dept_id -> org_department.id; post_id -> org_position.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_personnel (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
dept_id bigint default null comment '部门id',
|
||||
post_id bigint default null comment '岗位id',
|
||||
|
|
@ -193,7 +194,8 @@ create table org_personnel (
|
|||
key idx_org_personnel_org_id (org_id),
|
||||
key idx_org_personnel_dept_id (dept_id),
|
||||
key idx_org_personnel_post_id (post_id),
|
||||
key idx_org_personnel_account (account)
|
||||
key idx_org_personnel_account (account),
|
||||
unique key uk_org_personnel_org_account (org_id, account)
|
||||
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='人员信息表';
|
||||
|
||||
-- ------------------------------------------------------------
|
||||
|
|
@ -202,7 +204,7 @@ create table org_personnel (
|
|||
-- 关联: personnel_id -> org_personnel.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_personnel_cert (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
personnel_id bigint not null comment '人员id',
|
||||
cert_name varchar(200) default null comment '证照名称',
|
||||
|
|
@ -240,7 +242,7 @@ create table org_personnel_cert (
|
|||
-- 关联: personnel_id -> org_personnel.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_personnel_change (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
personnel_id bigint not null comment '人员id',
|
||||
change_item varchar(200) not null comment '变更事项',
|
||||
|
|
@ -268,7 +270,7 @@ create table org_personnel_change (
|
|||
-- 关联: personnel_id -> org_personnel.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_resign_apply (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
personnel_id bigint not null comment '人员id',
|
||||
applicant_name varchar(50) not null comment '申请人',
|
||||
|
|
@ -302,7 +304,7 @@ create table org_resign_apply (
|
|||
-- 关联: org_id -> org_info.id
|
||||
-- ------------------------------------------------------------
|
||||
create table org_equipment (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
device_name varchar(200) not null comment '设备名称',
|
||||
device_model varchar(100) default null comment '设备型号',
|
||||
|
|
@ -342,7 +344,7 @@ create table org_equipment (
|
|||
-- 关联: org_id -> org_info.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
filing_territory_code varchar(32) default null comment '备案属地编码',
|
||||
filing_territory_name varchar(100) default null comment '备案属地名称',
|
||||
|
|
@ -392,7 +394,7 @@ create table qual_filing (
|
|||
-- 关联: filing_id -> qual_filing.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_material (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
filing_id bigint not null comment '备案申请id',
|
||||
material_content varchar(500) not null comment '材料内容',
|
||||
material_format varchar(20) default null comment '材料格式',
|
||||
|
|
@ -420,7 +422,7 @@ create table qual_filing_material (
|
|||
-- 关联: filing_id -> qual_filing.id (1:1)
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_commitment (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
filing_id bigint not null comment '备案申请id',
|
||||
commitment_content text default null comment '承诺内容',
|
||||
legal_rep_signature_url varchar(500) default null comment '法定代表人签名图片地址',
|
||||
|
|
@ -447,7 +449,7 @@ create table qual_filing_commitment (
|
|||
-- 关联: filing_id -> qual_filing.id; source_personnel_id -> org_personnel.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_personnel (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
filing_id bigint not null comment '备案申请id',
|
||||
source_personnel_id bigint default null comment '来源人员id',
|
||||
person_name varchar(50) not null comment '人员姓名',
|
||||
|
|
@ -495,7 +497,7 @@ create table qual_filing_personnel (
|
|||
-- 关联: filing_personnel_id -> qual_filing_personnel.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_personnel_cert (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
filing_id bigint not null comment '备案申请id',
|
||||
filing_personnel_id bigint not null comment '备案人员id',
|
||||
cert_name varchar(200) default null comment '证照名称',
|
||||
|
|
@ -534,7 +536,7 @@ create table qual_filing_personnel_cert (
|
|||
-- 关联: filing_id -> qual_filing.id; source_equipment_id -> org_equipment.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_equipment (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
filing_id bigint not null comment '备案申请id',
|
||||
source_equipment_id bigint default null comment '来源装备id',
|
||||
device_name varchar(200) not null comment '设备名称',
|
||||
|
|
@ -575,7 +577,7 @@ create table qual_filing_equipment (
|
|||
-- 关联: origin_filing_id -> qual_filing.id; org_id -> org_info.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_change (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
org_id bigint not null comment '机构id',
|
||||
origin_filing_id bigint not null comment '原备案申请id',
|
||||
change_count int default 0 comment '变更次数',
|
||||
|
|
@ -624,7 +626,7 @@ create table qual_filing_change (
|
|||
-- 关联: change_id -> qual_filing_change.id
|
||||
-- ------------------------------------------------------------
|
||||
create table qual_filing_change_detail (
|
||||
id bigint not null auto_increment comment '主键',
|
||||
id bigint not null comment '主键',
|
||||
change_id bigint not null comment '备案变更id',
|
||||
change_field varchar(100) not null comment '变更字段',
|
||||
change_content varchar(1000) not null comment '变更内容',
|
||||
|
|
@ -643,3 +645,168 @@ create table qual_filing_change_detail (
|
|||
primary key (id),
|
||||
key idx_qual_filing_change_detail_change_id (change_id)
|
||||
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='备案变更明细表';
|
||||
|
||||
-- ============================================================
|
||||
-- 企业信息管理模块 - 联调测试数据(手动执行)
|
||||
-- 执行前会清理本机构 org_id=1 下的旧联调数据,避免脏数据干扰
|
||||
-- ============================================================
|
||||
|
||||
SET @tenant_id = 1001;
|
||||
SET @org_id = 1;
|
||||
SET @now = NOW();
|
||||
|
||||
DELETE FROM org_personnel_change WHERE org_id = @org_id;
|
||||
DELETE FROM org_personnel_cert WHERE org_id = @org_id;
|
||||
DELETE FROM org_resign_apply WHERE org_id = @org_id;
|
||||
DELETE FROM org_personnel WHERE org_id = @org_id;
|
||||
DELETE FROM org_equipment WHERE org_id = @org_id;
|
||||
DELETE FROM org_qualification WHERE org_id = @org_id;
|
||||
DELETE FROM org_position WHERE org_id = @org_id;
|
||||
DELETE FROM org_department WHERE org_id = @org_id;
|
||||
DELETE FROM org_info WHERE id = @org_id;
|
||||
|
||||
-- ── 1. 机构信息 ──
|
||||
INSERT INTO org_info (
|
||||
id, unit_name, credit_code, safety_industry_category_name, district_name, town_street,
|
||||
village_community, longitude, latitude, register_address, business_address,
|
||||
ownership_type_name, legal_representative, legal_representative_phone,
|
||||
principal_name, principal_phone, safety_dept_manager, safety_dept_manager_phone,
|
||||
safety_deputy_phone, production_date, business_status_name, info_disclosure_url,
|
||||
workplace_area, archive_room_area, fulltime_evaluator_count, registered_engineer_count,
|
||||
economy_industry_code, auth_status_code, auth_status_name,
|
||||
delete_enum, tenant_id, org_id, create_time, update_time
|
||||
) VALUES (
|
||||
@org_id, '秦皇岛示例安全评价有限公司', '91130300MA0XXXXXX1', '安全评价', '海港区', '白塔岭街道',
|
||||
'文府里社区', 119.586000, 39.942000,
|
||||
'河北省秦皇岛市海港区示例路88号', '河北省秦皇岛市海港区示例路88号',
|
||||
'民营企业', '张三', '0335-88880001', '李四', '13800138001', '王五', '13800138002',
|
||||
'13800138003', '2018-06-01', '正常经营', 'https://example.com/disclosure',
|
||||
1200.00, 80.00, 12, 5, 'M7491', 3, '通过',
|
||||
'false', @tenant_id, @org_id, @now, @now
|
||||
);
|
||||
|
||||
-- ── 2. 部门(含负责人账号,便于下拉回显) ──
|
||||
INSERT INTO org_department (id, org_id, parent_id, dept_name, manager_name, manager_account, dept_level_name, delete_enum, tenant_id, create_time, update_time) VALUES
|
||||
(101, @org_id, 0, '综合管理部', '冯行政', '13800138014', '一级', 'false', @tenant_id, @now, @now),
|
||||
(102, @org_id, 0, '评价一部', '陈评价', '13800138010', '一级', 'false', @tenant_id, @now, @now),
|
||||
(103, @org_id, 0, '评价二部', '郑专项', '13800138013', '一级', 'false', @tenant_id, @now, @now),
|
||||
(104, @org_id, 0, '技术质量部', '吴质量', '13800138012', '一级', 'false', @tenant_id, @now, @now),
|
||||
(105, @org_id, 0, '市场开发部', '褚采样', '13800138015', '一级', 'false', @tenant_id, @now, @now),
|
||||
(106, @org_id, 101, '行政组', '冯行政', '13800138014', '二级', 'false', @tenant_id, @now, @now),
|
||||
(107, @org_id, 101, '人事组', '冯行政', '13800138014', '二级', 'false', @tenant_id, @now, @now),
|
||||
(108, @org_id, 102, '现场评价一组', '林项目', '13800138011', '二级', 'false', @tenant_id, @now, @now),
|
||||
(109, @org_id, 102, '现场评价二组', '陈评价', '13800138010', '二级', 'false', @tenant_id, @now, @now),
|
||||
(110, @org_id, 102, '报告编制组', '林项目', '13800138011', '二级', 'false', @tenant_id, @now, @now),
|
||||
(111, @org_id, 103, '专项评价组', '郑专项', '13800138013', '二级', 'false', @tenant_id, @now, @now),
|
||||
(112, @org_id, 103, '综合评价组', '郑专项', '13800138013', '二级', 'false', @tenant_id, @now, @now),
|
||||
(113, @org_id, 104, '质检组', '吴质量', '13800138012', '二级', 'false', @tenant_id, @now, @now),
|
||||
(114, @org_id, 104, '档案管理组', '吴质量', '13800138012', '二级', 'false', @tenant_id, @now, @now),
|
||||
(115, @org_id, 104, '设备管理组', '吴质量', '13800138012', '二级', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 3. 岗位(24条) ──
|
||||
INSERT INTO org_position (id, org_id, dept_id, position_name, duty_desc, delete_enum, tenant_id, create_time, update_time) VALUES
|
||||
(201, @org_id, 101, '部门经理', '负责综合管理部全面工作', 'false', @tenant_id, @now, @now),
|
||||
(202, @org_id, 106, '行政专员', '负责日常行政事务', 'false', @tenant_id, @now, @now),
|
||||
(203, @org_id, 107, '人事专员', '负责招聘与员工关系', 'false', @tenant_id, @now, @now),
|
||||
(204, @org_id, 102, '部门经理', '负责评价一部项目管理', 'false', @tenant_id, @now, @now),
|
||||
(205, @org_id, 108, '评价师', '负责现场安全评价', 'false', @tenant_id, @now, @now),
|
||||
(206, @org_id, 108, '项目负责人', '负责评价项目统筹', 'false', @tenant_id, @now, @now),
|
||||
(207, @org_id, 109, '评价师', '负责现场安全评价', 'false', @tenant_id, @now, @now),
|
||||
(208, @org_id, 109, '助理评价师', '协助现场评价工作', 'false', @tenant_id, @now, @now),
|
||||
(209, @org_id, 110, '报告编制员', '负责评价报告编制', 'false', @tenant_id, @now, @now),
|
||||
(210, @org_id, 110, '报告审核员', '负责报告质量审核', 'false', @tenant_id, @now, @now),
|
||||
(211, @org_id, 103, '部门经理', '负责评价二部全面工作', 'false', @tenant_id, @now, @now),
|
||||
(212, @org_id, 111, '专项评价师', '负责专项安全评价', 'false', @tenant_id, @now, @now),
|
||||
(213, @org_id, 112, '综合评价师', '负责综合安全评价', 'false', @tenant_id, @now, @now),
|
||||
(214, @org_id, 104, '质量管理员', '负责质量体系运行', 'false', @tenant_id, @now, @now),
|
||||
(215, @org_id, 113, '质检工程师', '负责报告与过程质检', 'false', @tenant_id, @now, @now),
|
||||
(216, @org_id, 114, '档案管理员', '负责档案归档与保管', 'false', @tenant_id, @now, @now),
|
||||
(217, @org_id, 115, '设备管理员', '负责仪器设备管理', 'false', @tenant_id, @now, @now),
|
||||
(218, @org_id, 105, '市场经理', '负责市场开拓', 'false', @tenant_id, @now, @now),
|
||||
(219, @org_id, 105, '客户经理', '负责客户关系维护', 'false', @tenant_id, @now, @now),
|
||||
(220, @org_id, 102, '技术负责人', '负责评价技术把关', 'false', @tenant_id, @now, @now),
|
||||
(221, @org_id, 103, '技术负责人', '负责评价技术把关', 'false', @tenant_id, @now, @now),
|
||||
(222, @org_id, 108, '采样员', '负责现场样品采集', 'false', @tenant_id, @now, @now),
|
||||
(223, @org_id, 109, '采样员', '负责现场样品采集', 'false', @tenant_id, @now, @now),
|
||||
(224, @org_id, 110, '资料员', '负责项目资料整理', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 4. 机构资质证书 ──
|
||||
INSERT INTO org_qualification (
|
||||
id, org_id, license_type_name, cert_name, cert_no, issue_date, issue_org,
|
||||
valid_start_date, valid_end_date, enable_flag, delete_enum, tenant_id, create_time, update_time
|
||||
) VALUES
|
||||
(301, @org_id, '安全评价机构资质证书', '安全评价机构资质证书(甲级)', 'AQPJ-2024-001', '2024-01-15', '河北省应急管理厅', '2024-01-15', '2027-01-14', 1, 'false', @tenant_id, @now, @now),
|
||||
(302, @org_id, '营业执照', '营业执照', '91130300MA0XXXXXX1', '2018-06-01', '秦皇岛市行政审批局', '2018-06-01', '2099-12-31', 1, 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 5. 人员信息 ──
|
||||
INSERT INTO org_personnel (
|
||||
id, org_id, dept_id, post_id, user_name, account, gender_code, gender_name,
|
||||
birth_date, id_card_no, current_address, office_address, education_name,
|
||||
graduate_school, major, employment_status_code, employment_status_name,
|
||||
delete_enum, tenant_id, create_time, update_time
|
||||
) VALUES
|
||||
(401, @org_id, 102, 205, '陈评价', '13800138010', 1, '男', '1985-03-15', '130302198503151234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '本科', '华北理工大学', '安全工程', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(402, @org_id, 102, 206, '林项目', '13800138011', 1, '男', '1988-07-22', '130302198807221234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '硕士', '中国矿业大学', '安全科学与工程', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(403, @org_id, 104, 215, '吴质量', '13800138012', 2, '女', '1990-11-08', '130302199011081234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '本科', '河北工程大学', '安全工程', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(404, @org_id, 103, 212, '郑专项', '13800138013', 1, '男', '1987-01-30', '130302198701301234', '秦皇岛市开发区', '秦皇岛市海港区示例路88号', '本科', '东北大学', '安全工程', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(405, @org_id, 101, 202, '冯行政', '13800138014', 2, '女', '1992-05-18', '130302199205181234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '大专', '秦皇岛职业技术学院', '行政管理', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(406, @org_id, 108, 222, '褚采样', '13800138015', 1, '男', '1995-09-03', '130302199509031234', '秦皇岛市北戴河区', '秦皇岛市海港区示例路88号', '本科', '河北科技大学', '应用化学', 1, '在职', 'false', @tenant_id, @now, @now),
|
||||
(407, @org_id, 101, 201, '钱离职', '13800138016', 1, '男', '1980-01-01', '130302198001011234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '本科', '燕山大学', '安全工程', 2, '离职', 'false', @tenant_id, @now, @now),
|
||||
(408, @org_id, 102, 205, '孙离职', '13800138017', 2, '女', '1986-06-12', '130302198606121234', '秦皇岛市海港区', '秦皇岛市海港区示例路88号', '本科', '河北工业大学', '安全工程', 2, '离职', 'false', @tenant_id, @now, @now),
|
||||
(409, @org_id, 103, 212, '周离职', '13800138018', 1, '男', '1984-09-20', '130302198409201234', '秦皇岛市开发区', '秦皇岛市海港区示例路88号', '硕士', '天津大学', '安全科学与工程', 2, '离职', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 6. 人员证书 ──
|
||||
INSERT INTO org_personnel_cert (
|
||||
id, org_id, personnel_id, cert_name, cert_category_name, operation_category_name,
|
||||
cert_no, issue_org, valid_start_date, valid_end_date, delete_enum, tenant_id, create_time, update_time
|
||||
) VALUES
|
||||
(501, @org_id, 401, '注册安全工程师证', '注册安全工程师', '金属非金属矿山', 'ZCAQ-2019-001', '应急管理部', '2019-06-01', '2025-06-01', 'false', @tenant_id, @now, @now),
|
||||
(502, @org_id, 402, '安全评价师证(一级)', '安全评价师', '安全评价', 'AQPJS-2020-002', '中国安全生产协会', '2020-03-01', '2026-03-01', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 7. 人员变更记录(原型:3/2/6 条变更) ──
|
||||
INSERT INTO org_personnel_change (id, org_id, personnel_id, change_item, change_time, operator_name, delete_enum, tenant_id, create_time, update_time) VALUES
|
||||
(601, @org_id, 407, '修改联系电话', DATE_SUB(@now, INTERVAL 30 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(602, @org_id, 407, '调整所属岗位', DATE_SUB(@now, INTERVAL 20 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(603, @org_id, 407, '更新学历信息', DATE_SUB(@now, INTERVAL 10 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(604, @org_id, 408, '修改办公地址', DATE_SUB(@now, INTERVAL 25 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(605, @org_id, 408, '调整部门', DATE_SUB(@now, INTERVAL 12 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(606, @org_id, 409, '修改姓名', DATE_SUB(@now, INTERVAL 40 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(607, @org_id, 409, '修改账号', DATE_SUB(@now, INTERVAL 35 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(608, @org_id, 409, '修改性别', DATE_SUB(@now, INTERVAL 30 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(609, @org_id, 409, '修改出生日期', DATE_SUB(@now, INTERVAL 25 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(610, @org_id, 409, '修改身份证号', DATE_SUB(@now, INTERVAL 20 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(611, @org_id, 409, '修改现住地址', DATE_SUB(@now, INTERVAL 15 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(612, @org_id, 401, '修改联系电话', DATE_SUB(@now, INTERVAL 7 DAY), '管理员', 'false', @tenant_id, @now, @now),
|
||||
(613, @org_id, 403, '修改办公地址', DATE_SUB(@now, INTERVAL 5 DAY), '管理员', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 8. 离职申请(原型:未审核/已审核/未审核) ──
|
||||
INSERT INTO org_resign_apply (
|
||||
id, org_id, personnel_id, applicant_name, apply_time, resign_reason,
|
||||
expected_resign_date, audit_status_code, audit_status_name, delete_enum, tenant_id, create_time, update_time
|
||||
) VALUES
|
||||
(701, @org_id, 407, '钱离职', DATE_SUB(@now, INTERVAL 5 DAY), '个人原因申请离职', DATE_ADD(CURDATE(), INTERVAL 30 DAY), 0, '未审核', 'false', @tenant_id, @now, @now),
|
||||
(702, @org_id, 408, '孙离职', DATE_SUB(@now, INTERVAL 60 DAY), '家庭原因', DATE_SUB(CURDATE(), INTERVAL 30 DAY), 1, '已审核', 'false', @tenant_id, @now, @now),
|
||||
(703, @org_id, 409, '周离职', DATE_SUB(@now, INTERVAL 3 DAY), '工作调动', DATE_ADD(CURDATE(), INTERVAL 15 DAY), 0, '未审核', 'false', @tenant_id, @now, @now),
|
||||
(704, @org_id, 403, '吴质量', DATE_SUB(@now, INTERVAL 8 DAY), '个人发展', DATE_ADD(CURDATE(), INTERVAL 20 DAY), 0, '未审核', 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ── 9. 装备信息 ──
|
||||
INSERT INTO org_equipment (
|
||||
id, org_id, device_name, device_model, instrument_type_code, instrument_type_name,
|
||||
device_type_code, device_type_name,
|
||||
manufacturer, flow_desc, min_flow, max_flow, calibration_unit, calibration_init_value,
|
||||
field_calibration_type_name, dual_channel_flag, enable_flag, delete_enum, tenant_id, create_time, update_time
|
||||
) VALUES
|
||||
(801, @org_id, '四合一气体检测仪', 'PGM-6208', '检测仪器', '检测仪器', '便携式', '便携式', '英国ION Science', '0-100%LEL', 0.0000, 100.0000, '市计量院', '0', '定期校验', 2, 1, 'false', @tenant_id, @now, @now),
|
||||
(802, @org_id, '激光粉尘仪', 'LD-5K', '检测仪器', '检测仪器', '便携式', '便携式', '青岛众瑞', '0-10mg/m3', 0.0000, 10.0000, '市计量院', '0', '定期校验', 2, 1, 'false', @tenant_id, @now, @now),
|
||||
(803, @org_id, '声级计', 'AWA5688', '检测仪器', '检测仪器', '便携式', '便携式', '杭州爱华', '30-130dB', 0.0000, 130.0000, '市计量院', '0', '定期校验', 2, 1, 'false', @tenant_id, @now, @now),
|
||||
(804, @org_id, '万用表', 'Fluke87V', '电工仪器', '电工仪器', '手持式', '手持式', 'Fluke', '-', 0.0000, 0.0000, '市计量院', '0', '定期校验', 2, 1, 'false', @tenant_id, @now, @now),
|
||||
(805, @org_id, '风速仪', 'Testo410-2','检测仪器','检测仪器', '便携式', '便携式', '德图Testo', '0.4-20m/s', 0.4000, 20.0000, '市计量院', '0', '定期校验', 2, 1, 'false', @tenant_id, @now, @now);
|
||||
|
||||
-- ============================================================
|
||||
-- 增量升级脚本(已有库按需执行)
|
||||
-- ============================================================
|
||||
-- ALTER TABLE org_department ADD COLUMN manager_account varchar(50) DEFAULT NULL COMMENT '负责人账号' AFTER manager_name;
|
||||
-- ALTER TABLE org_personnel ADD UNIQUE KEY uk_org_personnel_org_account (org_id, account);
|
||||
-- UPDATE org_equipment SET instrument_type_code = instrument_type_name, device_type_code = device_type_name WHERE instrument_type_code IS NULL OR device_type_code IS NULL;
|
||||
-- UPDATE org_resign_apply SET audit_status_code = 0, audit_status_name = '未审核', reject_reason = NULL WHERE id = 701;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package org.qinan.safetyeval.adapter.config;
|
||||
|
||||
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 本地联调:为免鉴权的企业信息接口注入默认用户上下文,供 MyMetaObjectHandler 填充 org_id / tenant_id。
|
||||
*/
|
||||
@Configuration
|
||||
@Profile("local")
|
||||
public class LocalDevUserContextConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value("${safety-eval.public-api.system-user-id:1}")
|
||||
private Long systemUserId;
|
||||
|
||||
@Value("${safety-eval.public-api.system-user-name:local-dev}")
|
||||
private String systemUserName;
|
||||
|
||||
@Value("${safety-eval.public-api.tenant-id:1001}")
|
||||
private Long tenantId;
|
||||
|
||||
@Value("${safety-eval.public-api.org-id:1}")
|
||||
private Long orgId;
|
||||
|
||||
private static final String[] LOCAL_DEV_PATHS = {
|
||||
"/org-info/**",
|
||||
"/org-department/**",
|
||||
"/org-position/**",
|
||||
"/org-qualification/**",
|
||||
"/org-personnel/**",
|
||||
"/org-personnel-cert/**",
|
||||
"/org-personnel-change/**",
|
||||
"/org-resign-apply/**",
|
||||
"/org-equipment/**",
|
||||
};
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new HandlerInterceptor() {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
ThreadLocalUserInfoAdapter.set(systemUserId, systemUserName, tenantId, orgId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception exception) {
|
||||
ThreadLocalUserInfoAdapter.clear();
|
||||
}
|
||||
}).addPathPatterns(LOCAL_DEV_PATHS);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ import org.qinan.safetyeval.client.co.OrgDepartmentCO;
|
|||
import org.qinan.safetyeval.client.dto.OrgDepartmentAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgDepartmentModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgDepartmentPageQuery;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,4 +56,10 @@ public class OrgPersonnelController {
|
|||
public PageResponse<OrgPersonnelCO> page(@Validated OrgPersonnelPageQuery query) {
|
||||
return orgPersonnelApi.page(query);
|
||||
}
|
||||
|
||||
@ApiOperation("重置人员密码")
|
||||
@PostMapping("/reset-password")
|
||||
public SingleResponse<Void> resetPassword(@RequestParam Long id) {
|
||||
return orgPersonnelApi.resetPassword(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
|
|||
entity.setParentId(cmd.getParentId());
|
||||
entity.setDeptName(cmd.getDeptName());
|
||||
entity.setManagerName(cmd.getManagerName());
|
||||
entity.setManagerAccount(cmd.getManagerAccount());
|
||||
entity.setDeptLevelCode(cmd.getDeptLevelCode());
|
||||
entity.setDeptLevelName(cmd.getDeptLevelName());
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
|
|||
entity.setParentId(cmd.getParentId());
|
||||
entity.setDeptName(cmd.getDeptName());
|
||||
entity.setManagerName(cmd.getManagerName());
|
||||
entity.setManagerAccount(cmd.getManagerAccount());
|
||||
entity.setDeptLevelCode(cmd.getDeptLevelCode());
|
||||
entity.setDeptLevelName(cmd.getDeptLevelName());
|
||||
|
||||
|
|
@ -93,6 +95,7 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
|
|||
co.setParentId(entity.getParentId());
|
||||
co.setDeptName(entity.getDeptName());
|
||||
co.setManagerName(entity.getManagerName());
|
||||
co.setManagerAccount(entity.getManagerAccount());
|
||||
co.setDeptLevelCode(entity.getDeptLevelCode());
|
||||
co.setDeptLevelName(entity.getDeptLevelName());
|
||||
co.setTenantId(entity.getTenantId());
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ public class OrgEquipmentExecutor implements OrgEquipmentApi {
|
|||
domainQuery.setPageSize(query.getSize());
|
||||
domainQuery.setOrgId(query.getOrgId());
|
||||
domainQuery.setDeviceName(query.getDeviceName());
|
||||
domainQuery.setInstrumentTypeCode(query.getInstrumentTypeCode());
|
||||
domainQuery.setDeviceTypeCode(query.getDeviceTypeCode());
|
||||
domainQuery.setInstrumentType(query.getInstrumentType());
|
||||
domainQuery.setDeviceType(query.getDeviceType());
|
||||
domainQuery.setEnableFlag(query.getEnableFlag());
|
||||
|
||||
PageResult<OrgEquipmentEntity> pageResult = orgEquipmentDomainService.page(domainQuery);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
|
|||
entity.setValidEndDate(cmd.getValidEndDate());
|
||||
entity.setReviewDate(cmd.getReviewDate());
|
||||
entity.setCertAttachmentUrl(cmd.getCertAttachmentUrl());
|
||||
entity.setPersonnelId(cmd.getPersonnelId());
|
||||
|
||||
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.add(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
@ -71,6 +72,7 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
|
|||
entity.setValidEndDate(cmd.getValidEndDate());
|
||||
entity.setReviewDate(cmd.getReviewDate());
|
||||
entity.setCertAttachmentUrl(cmd.getCertAttachmentUrl());
|
||||
entity.setPersonnelId(cmd.getPersonnelId());
|
||||
|
||||
OrgPersonnelCertEntity result = orgPersonnelCertDomainService.modify(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
|
|||
|
|
@ -1,24 +1,30 @@
|
|||
package org.qinan.safetyeval.app.executor;
|
||||
|
||||
import org.qinan.safetyeval.app.support.OrgPersonnelChangeRecorder;
|
||||
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
|
||||
import org.qinan.safetyeval.client.api.OrgPersonnelApi;
|
||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.co.OrgPersonnelCO;
|
||||
import org.qinan.safetyeval.client.dto.OrgPersonnelAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPersonnelModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPersonnelPageQuery;
|
||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgResignApplyGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgPersonnelQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.domain.service.OrgPersonnelDomainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员信息执行器(App层)
|
||||
*
|
||||
* @author safety-eval
|
||||
*/
|
||||
@Service
|
||||
public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
||||
|
|
@ -27,55 +33,43 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
@Autowired(required = false)
|
||||
private OrgPersonnelDomainService orgPersonnelDomainService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgPersonnelViewEnricher orgPersonnelViewEnricher;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgPersonnelChangeRecorder orgPersonnelChangeRecorder;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgResignApplyGateway orgResignApplyGateway;
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgPersonnelCO> add(OrgPersonnelAddCmd cmd) {
|
||||
OrgPersonnelEntity entity = new OrgPersonnelEntity();
|
||||
entity.setUserName(cmd.getUserName());
|
||||
entity.setAccount(cmd.getAccount());
|
||||
entity.setGenderCode(cmd.getGenderCode());
|
||||
entity.setGenderName(cmd.getGenderName());
|
||||
entity.setBirthDate(cmd.getBirthDate());
|
||||
entity.setIdCardNo(cmd.getIdCardNo());
|
||||
entity.setCurrentAddress(cmd.getCurrentAddress());
|
||||
entity.setOfficeAddress(cmd.getOfficeAddress());
|
||||
entity.setEducationCode(cmd.getEducationCode());
|
||||
entity.setEducationName(cmd.getEducationName());
|
||||
entity.setGraduateSchool(cmd.getGraduateSchool());
|
||||
entity.setMajor(cmd.getMajor());
|
||||
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
|
||||
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
|
||||
|
||||
OrgPersonnelEntity entity = toEntity(cmd);
|
||||
OrgPersonnelEntity result = orgPersonnelDomainService.add(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
OrgPersonnelCO co = toCO(result);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgPersonnelCO> get(Long id) {
|
||||
OrgPersonnelEntity entity = orgPersonnelDomainService.get(id);
|
||||
return SingleResponse.success(toCO(entity));
|
||||
OrgPersonnelCO co = toCO(entity);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SingleResponse<OrgPersonnelCO> modify(OrgPersonnelModifyCmd cmd) {
|
||||
OrgPersonnelEntity entity = new OrgPersonnelEntity();
|
||||
OrgPersonnelEntity existing = orgPersonnelDomainService.get(cmd.getId());
|
||||
OrgPersonnelEntity entity = toEntity(cmd);
|
||||
entity.setId(cmd.getId());
|
||||
entity.setUserName(cmd.getUserName());
|
||||
entity.setAccount(cmd.getAccount());
|
||||
entity.setGenderCode(cmd.getGenderCode());
|
||||
entity.setGenderName(cmd.getGenderName());
|
||||
entity.setBirthDate(cmd.getBirthDate());
|
||||
entity.setIdCardNo(cmd.getIdCardNo());
|
||||
entity.setCurrentAddress(cmd.getCurrentAddress());
|
||||
entity.setOfficeAddress(cmd.getOfficeAddress());
|
||||
entity.setEducationCode(cmd.getEducationCode());
|
||||
entity.setEducationName(cmd.getEducationName());
|
||||
entity.setGraduateSchool(cmd.getGraduateSchool());
|
||||
entity.setMajor(cmd.getMajor());
|
||||
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
|
||||
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
|
||||
|
||||
OrgPersonnelEntity result = orgPersonnelDomainService.modify(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
orgPersonnelChangeRecorder.recordChanges(existing, result);
|
||||
OrgPersonnelCO co = toCO(result);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -84,6 +78,16 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
return SingleResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<Void> resetPassword(Long id) {
|
||||
OrgPersonnelEntity entity = orgPersonnelDomainService.get(id);
|
||||
if (entity == null) {
|
||||
throw new BizException(ErrorCode.ORG_PERSONNEL_NOT_FOUND);
|
||||
}
|
||||
// 联调阶段:密码重置占位,后续对接统一用户中心
|
||||
return SingleResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResponse<OrgPersonnelCO> page(OrgPersonnelPageQuery query) {
|
||||
OrgPersonnelQuery domainQuery = new OrgPersonnelQuery();
|
||||
|
|
@ -94,14 +98,71 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
domainQuery.setPostId(query.getPostId());
|
||||
domainQuery.setUserName(query.getUserName());
|
||||
domainQuery.setAccount(query.getAccount());
|
||||
domainQuery.setEmploymentStatusCode(query.getEmploymentStatusCode());
|
||||
if (query.getResignAuditStatus() != null && orgResignApplyGateway != null) {
|
||||
domainQuery.setPersonnelIds(orgResignApplyGateway.listPersonnelIdsByAuditStatus(
|
||||
query.getResignAuditStatus(), query.getOrgId()));
|
||||
}
|
||||
|
||||
PageResult<OrgPersonnelEntity> pageResult = orgPersonnelDomainService.page(domainQuery);
|
||||
|
||||
return PageResponse.of(
|
||||
pageResult.getRecords().stream()
|
||||
.map(this::toCO)
|
||||
.collect(java.util.stream.Collectors.toList()),
|
||||
pageResult.getTotal());
|
||||
List<OrgPersonnelCO> records = pageResult.getRecords().stream()
|
||||
.map(entity -> {
|
||||
OrgPersonnelCO co = toCO(entity);
|
||||
enrich(co);
|
||||
return co;
|
||||
})
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
|
||||
return PageResponse.of(records, pageResult.getTotal());
|
||||
}
|
||||
|
||||
private void enrich(OrgPersonnelCO co) {
|
||||
if (orgPersonnelViewEnricher != null) {
|
||||
orgPersonnelViewEnricher.enrichPersonnel(co);
|
||||
}
|
||||
}
|
||||
|
||||
private OrgPersonnelEntity toEntity(OrgPersonnelAddCmd cmd) {
|
||||
OrgPersonnelEntity entity = new OrgPersonnelEntity();
|
||||
entity.setUserName(cmd.getUserName());
|
||||
entity.setAccount(cmd.getAccount());
|
||||
entity.setGenderCode(cmd.getGenderCode());
|
||||
entity.setGenderName(cmd.getGenderName());
|
||||
entity.setBirthDate(cmd.getBirthDate());
|
||||
entity.setIdCardNo(cmd.getIdCardNo());
|
||||
entity.setCurrentAddress(cmd.getCurrentAddress());
|
||||
entity.setOfficeAddress(cmd.getOfficeAddress());
|
||||
entity.setEducationCode(cmd.getEducationCode());
|
||||
entity.setEducationName(cmd.getEducationName());
|
||||
entity.setGraduateSchool(cmd.getGraduateSchool());
|
||||
entity.setMajor(cmd.getMajor());
|
||||
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
|
||||
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
|
||||
entity.setDeptId(cmd.getDeptId());
|
||||
entity.setPostId(cmd.getPostId());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private OrgPersonnelEntity toEntity(OrgPersonnelModifyCmd cmd) {
|
||||
OrgPersonnelEntity entity = new OrgPersonnelEntity();
|
||||
entity.setUserName(cmd.getUserName());
|
||||
entity.setAccount(cmd.getAccount());
|
||||
entity.setGenderCode(cmd.getGenderCode());
|
||||
entity.setGenderName(cmd.getGenderName());
|
||||
entity.setBirthDate(cmd.getBirthDate());
|
||||
entity.setIdCardNo(cmd.getIdCardNo());
|
||||
entity.setCurrentAddress(cmd.getCurrentAddress());
|
||||
entity.setOfficeAddress(cmd.getOfficeAddress());
|
||||
entity.setEducationCode(cmd.getEducationCode());
|
||||
entity.setEducationName(cmd.getEducationName());
|
||||
entity.setGraduateSchool(cmd.getGraduateSchool());
|
||||
entity.setMajor(cmd.getMajor());
|
||||
entity.setEmploymentStatusCode(cmd.getEmploymentStatusCode());
|
||||
entity.setEmploymentStatusName(cmd.getEmploymentStatusName());
|
||||
entity.setDeptId(cmd.getDeptId());
|
||||
entity.setPostId(cmd.getPostId());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private OrgPersonnelCO toCO(OrgPersonnelEntity entity) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
OrgPositionEntity entity = new OrgPositionEntity();
|
||||
entity.setPositionName(cmd.getPositionName());
|
||||
entity.setDutyDesc(cmd.getDutyDesc());
|
||||
entity.setDeptId(cmd.getDeptId());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
|
||||
OrgPositionEntity result = orgPositionDomainService.add(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
@ -49,6 +51,8 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
entity.setId(cmd.getId());
|
||||
entity.setPositionName(cmd.getPositionName());
|
||||
entity.setDutyDesc(cmd.getDutyDesc());
|
||||
entity.setDeptId(cmd.getDeptId());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
|
||||
OrgPositionEntity result = orgPositionDomainService.modify(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
@ -87,6 +91,7 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
co.setDeptId(entity.getDeptId());
|
||||
co.setPositionName(entity.getPositionName());
|
||||
co.setDutyDesc(entity.getDutyDesc());
|
||||
co.setRemark(entity.getRemark());
|
||||
co.setTenantId(entity.getTenantId());
|
||||
return co;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public class OrgQualificationExecutor implements OrgQualificationApi {
|
|||
entity.setValidEndDate(cmd.getValidEndDate());
|
||||
entity.setCertImageUrl(cmd.getCertImageUrl());
|
||||
entity.setEnableFlag(cmd.getEnableFlag());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
|
||||
OrgQualificationEntity result = orgQualificationDomainService.add(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
@ -65,6 +66,7 @@ public class OrgQualificationExecutor implements OrgQualificationApi {
|
|||
entity.setValidEndDate(cmd.getValidEndDate());
|
||||
entity.setCertImageUrl(cmd.getCertImageUrl());
|
||||
entity.setEnableFlag(cmd.getEnableFlag());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
|
||||
OrgQualificationEntity result = orgQualificationDomainService.modify(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
|
|
@ -111,6 +113,7 @@ public class OrgQualificationExecutor implements OrgQualificationApi {
|
|||
co.setValidEndDate(entity.getValidEndDate());
|
||||
co.setCertImageUrl(entity.getCertImageUrl());
|
||||
co.setEnableFlag(entity.getEnableFlag());
|
||||
co.setRemark(entity.getRemark());
|
||||
co.setTenantId(entity.getTenantId());
|
||||
return co;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,16 @@ import org.qinan.safetyeval.client.dto.OrgResignApplyAddCmd;
|
|||
import org.qinan.safetyeval.client.dto.OrgResignApplyModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgResignApplyPageQuery;
|
||||
import org.qinan.safetyeval.domain.entity.OrgResignApplyEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgResignApplyQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.domain.service.OrgResignApplyDomainService;
|
||||
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 人员离职申请执行器(App层)
|
||||
|
|
@ -27,6 +31,12 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
|
|||
@Autowired(required = false)
|
||||
private OrgResignApplyDomainService orgResignApplyDomainService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgPersonnelViewEnricher orgPersonnelViewEnricher;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgPersonnelGateway orgPersonnelGateway;
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgResignApplyCO> add(OrgResignApplyAddCmd cmd) {
|
||||
OrgResignApplyEntity entity = new OrgResignApplyEntity();
|
||||
|
|
@ -35,18 +45,24 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
|
|||
entity.setResignReason(cmd.getResignReason());
|
||||
entity.setExpectedResignDate(cmd.getExpectedResignDate());
|
||||
entity.setReportFileUrl(cmd.getReportFileUrl());
|
||||
entity.setAuditStatusCode(cmd.getAuditStatusCode());
|
||||
entity.setAuditStatusName(cmd.getAuditStatusName());
|
||||
entity.setAuditStatusCode(cmd.getAuditStatusCode() != null ? cmd.getAuditStatusCode() : 0);
|
||||
entity.setAuditStatusName(cmd.getAuditStatusName() != null ? cmd.getAuditStatusName() : "未审核");
|
||||
entity.setRejectReason(cmd.getRejectReason());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
entity.setPersonnelId(resolvePersonnelId(cmd.getPersonnelId(), cmd.getApplicantName()));
|
||||
|
||||
OrgResignApplyEntity result = orgResignApplyDomainService.add(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
OrgResignApplyCO co = toCO(result);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgResignApplyCO> get(Long id) {
|
||||
OrgResignApplyEntity entity = orgResignApplyDomainService.get(id);
|
||||
return SingleResponse.success(toCO(entity));
|
||||
OrgResignApplyCO co = toCO(entity);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -61,9 +77,18 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
|
|||
entity.setAuditStatusCode(cmd.getAuditStatusCode());
|
||||
entity.setAuditStatusName(cmd.getAuditStatusName());
|
||||
entity.setRejectReason(cmd.getRejectReason());
|
||||
entity.setRemark(cmd.getRemark());
|
||||
entity.setPersonnelId(cmd.getPersonnelId());
|
||||
|
||||
if (entity.getAuditStatusCode() != null && entity.getAuditStatusName() == null) {
|
||||
entity.setAuditStatusName(resolveAuditStatusName(entity.getAuditStatusCode()));
|
||||
}
|
||||
|
||||
OrgResignApplyEntity result = orgResignApplyDomainService.modify(entity);
|
||||
return SingleResponse.success(toCO(result));
|
||||
syncPersonnelEmploymentAfterAudit(result);
|
||||
OrgResignApplyCO co = toCO(result);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -80,16 +105,70 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
|
|||
domainQuery.setOrgId(query.getOrgId());
|
||||
domainQuery.setPersonnelId(query.getPersonnelId());
|
||||
domainQuery.setAuditStatusCode(query.getAuditStatusCode());
|
||||
domainQuery.setApplicantName(query.getApplicantName());
|
||||
|
||||
PageResult<OrgResignApplyEntity> pageResult = orgResignApplyDomainService.page(domainQuery);
|
||||
|
||||
return PageResponse.of(
|
||||
pageResult.getRecords().stream()
|
||||
.map(this::toCO)
|
||||
.map(entity -> {
|
||||
OrgResignApplyCO co = toCO(entity);
|
||||
enrich(co);
|
||||
return co;
|
||||
})
|
||||
.collect(java.util.stream.Collectors.toList()),
|
||||
pageResult.getTotal());
|
||||
}
|
||||
|
||||
private void enrich(OrgResignApplyCO co) {
|
||||
if (orgPersonnelViewEnricher != null) {
|
||||
orgPersonnelViewEnricher.enrichResignApply(co);
|
||||
}
|
||||
}
|
||||
|
||||
private Long resolvePersonnelId(Long personnelId, String applicantName) {
|
||||
if (personnelId != null) {
|
||||
return personnelId;
|
||||
}
|
||||
if (orgPersonnelGateway == null || !StringUtils.hasText(applicantName)) {
|
||||
return null;
|
||||
}
|
||||
OrgPersonnelEntity personnel = orgPersonnelGateway.findByUserName(applicantName);
|
||||
if (personnel == null) {
|
||||
personnel = orgPersonnelGateway.getByAccount(applicantName);
|
||||
}
|
||||
return personnel != null ? personnel.getId() : null;
|
||||
}
|
||||
|
||||
private void syncPersonnelEmploymentAfterAudit(OrgResignApplyEntity result) {
|
||||
if (result == null || result.getPersonnelId() == null || orgPersonnelGateway == null) {
|
||||
return;
|
||||
}
|
||||
if (result.getAuditStatusCode() == null || result.getAuditStatusCode() != 1) {
|
||||
return;
|
||||
}
|
||||
OrgPersonnelEntity personnel = orgPersonnelGateway.get(result.getPersonnelId());
|
||||
if (personnel == null) {
|
||||
return;
|
||||
}
|
||||
personnel.setEmploymentStatusCode(2);
|
||||
personnel.setEmploymentStatusName("离职");
|
||||
orgPersonnelGateway.modify(personnel);
|
||||
}
|
||||
|
||||
private String resolveAuditStatusName(Integer auditStatusCode) {
|
||||
if (auditStatusCode == null) {
|
||||
return "未审核";
|
||||
}
|
||||
if (auditStatusCode == 1) {
|
||||
return "已审核";
|
||||
}
|
||||
if (auditStatusCode == 2) {
|
||||
return "已退回";
|
||||
}
|
||||
return "未审核";
|
||||
}
|
||||
|
||||
private OrgResignApplyCO toCO(OrgResignApplyEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
|
|
@ -105,6 +184,7 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
|
|||
co.setAuditStatusCode(entity.getAuditStatusCode());
|
||||
co.setAuditStatusName(entity.getAuditStatusName());
|
||||
co.setRejectReason(entity.getRejectReason());
|
||||
co.setRemark(entity.getRemark());
|
||||
co.setTenantId(entity.getTenantId());
|
||||
return co;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
package org.qinan.safetyeval.app.support;
|
||||
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelChangeEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelChangeGateway;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 人员信息修改时自动写入变更记录。
|
||||
*/
|
||||
@Component
|
||||
public class OrgPersonnelChangeRecorder {
|
||||
|
||||
@Resource
|
||||
private OrgPersonnelChangeGateway orgPersonnelChangeGateway;
|
||||
|
||||
public void recordChanges(OrgPersonnelEntity before, OrgPersonnelEntity after) {
|
||||
if (before == null || after == null || after.getId() == null) {
|
||||
return;
|
||||
}
|
||||
List<String> items = new ArrayList<>();
|
||||
if (!Objects.equals(before.getUserName(), after.getUserName())) {
|
||||
items.add("姓名");
|
||||
}
|
||||
if (!Objects.equals(before.getAccount(), after.getAccount())) {
|
||||
items.add("账号");
|
||||
}
|
||||
if (!Objects.equals(before.getDeptId(), after.getDeptId())) {
|
||||
items.add("部门");
|
||||
}
|
||||
if (!Objects.equals(before.getPostId(), after.getPostId())) {
|
||||
items.add("岗位");
|
||||
}
|
||||
if (!Objects.equals(before.getGenderCode(), after.getGenderCode())) {
|
||||
items.add("性别");
|
||||
}
|
||||
if (!Objects.equals(before.getBirthDate(), after.getBirthDate())) {
|
||||
items.add("出生日期");
|
||||
}
|
||||
if (!Objects.equals(before.getIdCardNo(), after.getIdCardNo())) {
|
||||
items.add("身份证号");
|
||||
}
|
||||
if (!Objects.equals(before.getCurrentAddress(), after.getCurrentAddress())) {
|
||||
items.add("现住地址");
|
||||
}
|
||||
if (!Objects.equals(before.getOfficeAddress(), after.getOfficeAddress())) {
|
||||
items.add("办公地址");
|
||||
}
|
||||
if (!Objects.equals(before.getEducationName(), after.getEducationName())) {
|
||||
items.add("学历");
|
||||
}
|
||||
if (!Objects.equals(before.getGraduateSchool(), after.getGraduateSchool())) {
|
||||
items.add("毕业院校");
|
||||
}
|
||||
if (!Objects.equals(before.getMajor(), after.getMajor())) {
|
||||
items.add("专业");
|
||||
}
|
||||
if (!Objects.equals(before.getEmploymentStatusCode(), after.getEmploymentStatusCode())) {
|
||||
items.add("就职状态");
|
||||
}
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String operator = StringUtils.hasText(AuthUserContextAdapter.getCurrentUserName()) ? AuthUserContextAdapter.getCurrentUserName() : "系统";
|
||||
for (String item : items) {
|
||||
OrgPersonnelChangeEntity change = new OrgPersonnelChangeEntity();
|
||||
change.setPersonnelId(after.getId());
|
||||
change.setChangeItem(item);
|
||||
change.setChangeTime(now);
|
||||
change.setOperatorName(operator);
|
||||
orgPersonnelChangeGateway.save(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package org.qinan.safetyeval.app.support;
|
||||
|
||||
import org.qinan.safetyeval.client.co.OrgPersonnelCO;
|
||||
import org.qinan.safetyeval.client.co.OrgResignApplyCO;
|
||||
import org.qinan.safetyeval.domain.entity.OrgDepartmentEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelChangeEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPositionEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgResignApplyEntity;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgDepartmentGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelCertGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelChangeGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPositionGateway;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgResignApplyGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgPersonnelCertQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 人员/离职列表展示字段组装(部门名、岗位名、证书名、账号等)。
|
||||
*/
|
||||
@Component
|
||||
public class OrgPersonnelViewEnricher {
|
||||
|
||||
@Resource
|
||||
private OrgDepartmentGateway orgDepartmentGateway;
|
||||
|
||||
@Resource
|
||||
private OrgPositionGateway orgPositionGateway;
|
||||
|
||||
@Resource
|
||||
private OrgPersonnelCertGateway orgPersonnelCertGateway;
|
||||
|
||||
@Resource
|
||||
private OrgPersonnelGateway orgPersonnelGateway;
|
||||
|
||||
@Resource
|
||||
private OrgPersonnelChangeGateway orgPersonnelChangeGateway;
|
||||
|
||||
@Resource
|
||||
private OrgResignApplyGateway orgResignApplyGateway;
|
||||
|
||||
public void enrichPersonnel(OrgPersonnelCO co) {
|
||||
if (co == null) {
|
||||
return;
|
||||
}
|
||||
if (co.getDeptId() != null) {
|
||||
OrgDepartmentEntity dept = orgDepartmentGateway.get(co.getDeptId());
|
||||
if (dept != null) {
|
||||
co.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
if (co.getPostId() != null) {
|
||||
OrgPositionEntity position = orgPositionGateway.get(co.getPostId());
|
||||
if (position != null) {
|
||||
co.setPostName(position.getPositionName());
|
||||
}
|
||||
}
|
||||
if (co.getId() != null) {
|
||||
OrgPersonnelCertQuery certQuery = new OrgPersonnelCertQuery();
|
||||
certQuery.setPersonnelId(co.getId());
|
||||
certQuery.setPageNum(1L);
|
||||
certQuery.setPageSize(200L);
|
||||
PageResult<OrgPersonnelCertEntity> certPage = orgPersonnelCertGateway.page(certQuery);
|
||||
String certNames = certPage.getRecords().stream()
|
||||
.map(OrgPersonnelCertEntity::getCertName)
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.joining("、"));
|
||||
co.setCertNames(certNames);
|
||||
|
||||
enrichChangeSummary(co);
|
||||
}
|
||||
if (co.getEmploymentStatusCode() == null) {
|
||||
co.setEmploymentStatusCode(1);
|
||||
co.setEmploymentStatusName("在职");
|
||||
}
|
||||
}
|
||||
|
||||
private void enrichChangeSummary(OrgPersonnelCO co) {
|
||||
List<OrgPersonnelChangeEntity> changes = orgPersonnelChangeGateway.listByPersonnelId(co.getId());
|
||||
co.setChangeCount(changes != null ? changes.size() : 0);
|
||||
|
||||
List<OrgResignApplyEntity> applies = orgResignApplyGateway.listByPersonnelId(co.getId());
|
||||
if (applies == null || applies.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
OrgResignApplyEntity displayApply = applies.stream()
|
||||
.filter(item -> item.getAuditStatusCode() != null && item.getAuditStatusCode() == 0)
|
||||
.findFirst()
|
||||
.orElse(applies.get(0));
|
||||
co.setResignApplyId(displayApply.getId());
|
||||
co.setResignAuditStatus(displayApply.getAuditStatusCode() != null ? displayApply.getAuditStatusCode() : 0);
|
||||
}
|
||||
|
||||
public void enrichResignApply(OrgResignApplyCO co) {
|
||||
if (co == null) {
|
||||
return;
|
||||
}
|
||||
if (co.getAuditStatusCode() == null) {
|
||||
co.setAuditStatusCode(0);
|
||||
co.setAuditStatusName("未审核");
|
||||
}
|
||||
if (co.getPersonnelId() == null) {
|
||||
return;
|
||||
}
|
||||
OrgPersonnelEntity personnel = orgPersonnelGateway.get(co.getPersonnelId());
|
||||
if (personnel == null) {
|
||||
return;
|
||||
}
|
||||
co.setAccount(personnel.getAccount());
|
||||
if (personnel.getDeptId() != null) {
|
||||
OrgDepartmentEntity dept = orgDepartmentGateway.get(personnel.getDeptId());
|
||||
if (dept != null) {
|
||||
co.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,4 +23,6 @@ public interface OrgPersonnelApi {
|
|||
SingleResponse<Void> delete(Long id);
|
||||
|
||||
PageResponse<OrgPersonnelCO> page(OrgPersonnelPageQuery query);
|
||||
|
||||
SingleResponse<Void> resetPassword(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ public class OrgDepartmentCO {
|
|||
/** managerName */
|
||||
private String managerName;
|
||||
|
||||
/** managerAccount */
|
||||
private String managerAccount;
|
||||
|
||||
/** deptLevelCode */
|
||||
private String deptLevelCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,24 @@ public class OrgPersonnelCO {
|
|||
/** employmentStatusName */
|
||||
private String employmentStatusName;
|
||||
|
||||
/** 部门名称(列表展示,非持久化) */
|
||||
private String deptName;
|
||||
|
||||
/** 岗位名称(列表展示,非持久化) */
|
||||
private String postName;
|
||||
|
||||
/** 证书名称汇总(列表展示,非持久化) */
|
||||
private String certNames;
|
||||
|
||||
/** 信息变更次数(列表展示,非持久化) */
|
||||
private Integer changeCount;
|
||||
|
||||
/** 离职申请ID(列表展示,非持久化) */
|
||||
private Long resignApplyId;
|
||||
|
||||
/** 离职申请审核状态(列表展示,非持久化) */
|
||||
private Integer resignAuditStatus;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ public class OrgPositionCO {
|
|||
/** dutyDesc */
|
||||
private String dutyDesc;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ public class OrgQualificationCO {
|
|||
/** enableFlag */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,15 @@ public class OrgResignApplyCO {
|
|||
/** rejectReason */
|
||||
private String rejectReason;
|
||||
|
||||
/** 申请备注 */
|
||||
private String remark;
|
||||
|
||||
/** 人员账号(列表展示,非持久化) */
|
||||
private String account;
|
||||
|
||||
/** 部门名称(列表展示,非持久化) */
|
||||
private String deptName;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ public class OrgDepartmentAddCmd {
|
|||
/** managerName */
|
||||
private String managerName;
|
||||
|
||||
/** managerAccount */
|
||||
private String managerAccount;
|
||||
|
||||
/** deptLevelCode */
|
||||
private String deptLevelCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ public class OrgDepartmentModifyCmd {
|
|||
/** managerName */
|
||||
private String managerName;
|
||||
|
||||
/** managerAccount */
|
||||
private String managerAccount;
|
||||
|
||||
/** deptLevelCode */
|
||||
private String deptLevelCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ public class OrgEquipmentPageQuery extends BasePageQuery {
|
|||
/** 设备名称 */
|
||||
private String deviceName;
|
||||
|
||||
/** 仪器类型编码 */
|
||||
private Long instrumentTypeCode;
|
||||
/** 仪器类型(模糊匹配名称或编码) */
|
||||
private String instrumentType;
|
||||
|
||||
/** 设备类型编码 */
|
||||
private Long deviceTypeCode;
|
||||
/** 设备类型(模糊匹配名称或编码) */
|
||||
private String deviceType;
|
||||
|
||||
/** 设备状态 */
|
||||
private Long enableFlag;
|
||||
|
|
|
|||
|
|
@ -52,4 +52,10 @@ public class OrgPersonnelAddCmd {
|
|||
|
||||
/** employmentStatusName */
|
||||
private String employmentStatusName;
|
||||
|
||||
/** deptId */
|
||||
private Long deptId;
|
||||
|
||||
/** postId */
|
||||
private Long postId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,4 +49,7 @@ public class OrgPersonnelCertAddCmd {
|
|||
|
||||
/** certAttachmentUrl */
|
||||
private String certAttachmentUrl;
|
||||
|
||||
/** personnelId */
|
||||
private Long personnelId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ public class OrgPersonnelCertModifyCmd {
|
|||
/** certAttachmentUrl */
|
||||
private String certAttachmentUrl;
|
||||
|
||||
/** personnelId */
|
||||
private Long personnelId;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@ public class OrgPersonnelModifyCmd {
|
|||
/** employmentStatusName */
|
||||
private String employmentStatusName;
|
||||
|
||||
/** deptId */
|
||||
private Long deptId;
|
||||
|
||||
/** postId */
|
||||
private Long postId;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ public class OrgPersonnelPageQuery extends BasePageQuery {
|
|||
/** 姓名 */
|
||||
private String userName;
|
||||
|
||||
/** 账号 */
|
||||
/** 账号(模糊) */
|
||||
private String account;
|
||||
|
||||
/** 就职状态编码 */
|
||||
private Integer employmentStatusCode;
|
||||
|
||||
/** 离职申请审核状态(0未审核 1已审核 2已退回) */
|
||||
private Integer resignAuditStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,10 @@ public class OrgPositionAddCmd {
|
|||
|
||||
/** dutyDesc */
|
||||
private String dutyDesc;
|
||||
|
||||
/** deptId */
|
||||
private Long deptId;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ public class OrgPositionModifyCmd {
|
|||
/** dutyDesc */
|
||||
private String dutyDesc;
|
||||
|
||||
/** deptId */
|
||||
private Long deptId;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,7 @@ public class OrgQualificationAddCmd {
|
|||
|
||||
/** enableFlag */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ public class OrgQualificationModifyCmd {
|
|||
/** enableFlag */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,10 @@ public class OrgResignApplyAddCmd {
|
|||
|
||||
/** rejectReason */
|
||||
private String rejectReason;
|
||||
|
||||
/** personnelId */
|
||||
private Long personnelId;
|
||||
|
||||
/** 申请备注 */
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ public class OrgResignApplyModifyCmd {
|
|||
/** rejectReason */
|
||||
private String rejectReason;
|
||||
|
||||
/** 申请备注 */
|
||||
private String remark;
|
||||
|
||||
/** personnelId */
|
||||
private Long personnelId;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,5 +19,8 @@ public class OrgResignApplyPageQuery extends BasePageQuery {
|
|||
private Long personnelId;
|
||||
|
||||
/** 审核状态 */
|
||||
private Long auditStatusCode;
|
||||
private Integer auditStatusCode;
|
||||
|
||||
/** 申请人姓名(模糊) */
|
||||
private String applicantName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,12 @@ public class OrgDepartmentEntity {
|
|||
/** 部门名称 */
|
||||
private String deptName;
|
||||
|
||||
/** 负责人 */
|
||||
/** 负责人姓名 */
|
||||
private String managerName;
|
||||
|
||||
/** 负责人账号 */
|
||||
private String managerAccount;
|
||||
|
||||
/** 部门级别编码 */
|
||||
private String deptLevelCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ public class OrgPositionEntity {
|
|||
/** 岗位职责 */
|
||||
private String dutyDesc;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public class OrgQualificationEntity {
|
|||
/** 启用标识(1启用2禁用) */
|
||||
private Integer enableFlag;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public class OrgResignApplyEntity {
|
|||
/** 退回原因 */
|
||||
private String rejectReason;
|
||||
|
||||
/** 申请备注 */
|
||||
private String remark;
|
||||
|
||||
/** 租户ID */
|
||||
private Long tenantId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public enum ErrorCode {
|
|||
|
||||
// ---- 人员信息 ----
|
||||
ORG_PERSONNEL_NOT_FOUND("01-05-001", "人员信息不存在"),
|
||||
ORG_PERSONNEL_ACCOUNT_EXISTS("01-05-002", "账号已存在"),
|
||||
|
||||
// ---- 人员证书 ----
|
||||
ORG_PERSONNEL_CERT_NOT_FOUND("01-06-001", "人员证书不存在"),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ public interface OrgPersonnelGateway {
|
|||
|
||||
OrgPersonnelEntity getByAccount(String account);
|
||||
|
||||
OrgPersonnelEntity findByUserName(String userName);
|
||||
|
||||
OrgPersonnelEntity modify(OrgPersonnelEntity entity);
|
||||
|
||||
void delete(Long id);
|
||||
|
|
|
|||
|
|
@ -20,4 +20,14 @@ public interface OrgResignApplyGateway {
|
|||
void delete(Long id);
|
||||
|
||||
PageResult<OrgResignApplyEntity> page(OrgResignApplyQuery query);
|
||||
|
||||
/**
|
||||
* 按人员查询离职申请,按申请时间倒序。
|
||||
*/
|
||||
java.util.List<OrgResignApplyEntity> listByPersonnelId(Long personnelId);
|
||||
|
||||
/**
|
||||
* 查询指定审核状态下有离职申请的人员 ID 列表。
|
||||
*/
|
||||
java.util.List<Long> listPersonnelIdsByAuditStatus(Integer auditStatusCode, Long orgId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ public class OrgEquipmentQuery {
|
|||
/** 设备名称 */
|
||||
private String deviceName;
|
||||
|
||||
/** 仪器类型编码 */
|
||||
private Long instrumentTypeCode;
|
||||
/** 仪器类型(模糊匹配名称或编码) */
|
||||
private String instrumentType;
|
||||
|
||||
/** 设备类型编码 */
|
||||
private Long deviceTypeCode;
|
||||
/** 设备类型(模糊匹配名称或编码) */
|
||||
private String deviceType;
|
||||
|
||||
/** 设备状态 */
|
||||
private Long enableFlag;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,15 @@ public class OrgPersonnelQuery {
|
|||
/** 姓名 */
|
||||
private String userName;
|
||||
|
||||
/** 账号 */
|
||||
/** 账号(模糊) */
|
||||
private String account;
|
||||
|
||||
/** 就职状态编码 */
|
||||
private Integer employmentStatusCode;
|
||||
|
||||
/** 离职申请审核状态 */
|
||||
private Integer resignAuditStatus;
|
||||
|
||||
/** 人员 ID 列表(离职审核状态筛选) */
|
||||
private java.util.List<Long> personnelIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,8 @@ public class OrgResignApplyQuery {
|
|||
private Long personnelId;
|
||||
|
||||
/** 审核状态 */
|
||||
private Long auditStatusCode;
|
||||
private Integer auditStatusCode;
|
||||
|
||||
/** 申请人姓名(模糊) */
|
||||
private String applicantName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import org.qinan.safetyeval.domain.exception.ErrorCode;
|
|||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgPersonnelQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 人员信息领域服务
|
||||
*
|
||||
* @author safety-eval
|
||||
*/
|
||||
@Service
|
||||
public class OrgPersonnelDomainService {
|
||||
|
|
@ -22,6 +21,11 @@ public class OrgPersonnelDomainService {
|
|||
private OrgPersonnelGateway orgPersonnelGateway;
|
||||
|
||||
public OrgPersonnelEntity add(OrgPersonnelEntity entity) {
|
||||
assertAccountUnique(entity.getAccount(), null);
|
||||
if (entity.getEmploymentStatusCode() == null) {
|
||||
entity.setEmploymentStatusCode(1);
|
||||
entity.setEmploymentStatusName("在职");
|
||||
}
|
||||
return orgPersonnelGateway.save(entity);
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +38,54 @@ public class OrgPersonnelDomainService {
|
|||
if (existing == null) {
|
||||
throw new BizException(ErrorCode.ORG_PERSONNEL_NOT_FOUND);
|
||||
}
|
||||
return orgPersonnelGateway.modify(entity);
|
||||
assertAccountUnique(entity.getAccount(), entity.getId());
|
||||
mergeForModify(existing, entity);
|
||||
return orgPersonnelGateway.modify(existing);
|
||||
}
|
||||
|
||||
private void mergeForModify(OrgPersonnelEntity target, OrgPersonnelEntity patch) {
|
||||
if (StringUtils.hasText(patch.getUserName())) {
|
||||
target.setUserName(patch.getUserName());
|
||||
}
|
||||
if (StringUtils.hasText(patch.getAccount())) {
|
||||
target.setAccount(patch.getAccount());
|
||||
}
|
||||
if (patch.getGenderCode() != null) {
|
||||
target.setGenderCode(patch.getGenderCode());
|
||||
target.setGenderName(patch.getGenderName());
|
||||
}
|
||||
if (patch.getBirthDate() != null) {
|
||||
target.setBirthDate(patch.getBirthDate());
|
||||
}
|
||||
if (patch.getIdCardNo() != null) {
|
||||
target.setIdCardNo(patch.getIdCardNo());
|
||||
}
|
||||
if (patch.getCurrentAddress() != null) {
|
||||
target.setCurrentAddress(patch.getCurrentAddress());
|
||||
}
|
||||
if (patch.getOfficeAddress() != null) {
|
||||
target.setOfficeAddress(patch.getOfficeAddress());
|
||||
}
|
||||
if (patch.getEducationCode() != null) {
|
||||
target.setEducationCode(patch.getEducationCode());
|
||||
target.setEducationName(patch.getEducationName());
|
||||
}
|
||||
if (patch.getGraduateSchool() != null) {
|
||||
target.setGraduateSchool(patch.getGraduateSchool());
|
||||
}
|
||||
if (patch.getMajor() != null) {
|
||||
target.setMajor(patch.getMajor());
|
||||
}
|
||||
if (patch.getEmploymentStatusCode() != null) {
|
||||
target.setEmploymentStatusCode(patch.getEmploymentStatusCode());
|
||||
target.setEmploymentStatusName(patch.getEmploymentStatusName());
|
||||
}
|
||||
if (patch.getDeptId() != null) {
|
||||
target.setDeptId(patch.getDeptId());
|
||||
}
|
||||
if (patch.getPostId() != null) {
|
||||
target.setPostId(patch.getPostId());
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Long id) {
|
||||
|
|
@ -48,4 +99,14 @@ public class OrgPersonnelDomainService {
|
|||
public PageResult<OrgPersonnelEntity> page(OrgPersonnelQuery query) {
|
||||
return orgPersonnelGateway.page(query);
|
||||
}
|
||||
|
||||
private void assertAccountUnique(String account, Long excludeId) {
|
||||
if (!StringUtils.hasText(account)) {
|
||||
return;
|
||||
}
|
||||
OrgPersonnelEntity found = orgPersonnelGateway.getByAccount(account);
|
||||
if (found != null && (excludeId == null || !found.getId().equals(excludeId))) {
|
||||
throw new BizException(ErrorCode.ORG_PERSONNEL_ACCOUNT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package org.qinan.safetyeval.infrastructure.adapter.auth;
|
||||
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
|
||||
/**
|
||||
* AuthContext 全局适配:统一从 {@link AuthContext#getCurrentUser()} 解析用户信息。
|
||||
* <p>
|
||||
* 业务代码通过静态方法获取用户上下文,避免 SSOUser 字段调整导致大面积改动。
|
||||
* </p>
|
||||
*/
|
||||
public final class AuthUserContextAdapter {
|
||||
|
||||
private AuthUserContextAdapter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户;未登录返回 null。
|
||||
*/
|
||||
public static AuthUserInfo getCurrentUser() {
|
||||
return AuthUserInfo.from(AuthContext.getCurrentUser());
|
||||
}
|
||||
|
||||
public static Long getCurrentUserId() {
|
||||
AuthUserInfo user = getCurrentUser();
|
||||
return user == null ? null : user.getUserId();
|
||||
}
|
||||
|
||||
public static String getCurrentUserName() {
|
||||
AuthUserInfo user = getCurrentUser();
|
||||
return user == null ? null : user.getUserName();
|
||||
}
|
||||
|
||||
public static Long getCurrentTenantId() {
|
||||
AuthUserInfo user = getCurrentUser();
|
||||
return user == null ? null : user.getTenantId();
|
||||
}
|
||||
|
||||
public static Long getCurrentOrgId() {
|
||||
AuthUserInfo user = getCurrentUser();
|
||||
return user == null ? null : user.getOrgId();
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn() {
|
||||
return getCurrentUser() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 透传原始 SSOUser,仅在适配类内部扩展字段时使用。
|
||||
*/
|
||||
static SSOUser getRawUser() {
|
||||
return AuthContext.getCurrentUser();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package org.qinan.safetyeval.infrastructure.adapter.auth;
|
||||
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import lombok.Builder;
|
||||
import lombok.Value;
|
||||
|
||||
/**
|
||||
* 稳定的登录用户视图,屏蔽 SSOUser 字段变更对业务代码的影响。
|
||||
*/
|
||||
@Value
|
||||
@Builder
|
||||
public class AuthUserInfo {
|
||||
|
||||
Long userId;
|
||||
String userName;
|
||||
Long tenantId;
|
||||
Long orgId;
|
||||
|
||||
public static AuthUserInfo from(SSOUser user) {
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
return AuthUserInfo.builder()
|
||||
.userId(user.getUserId())
|
||||
.userName(user.getName())
|
||||
.tenantId(user.getTenantId())
|
||||
.orgId(user.getOrgId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,9 @@ public class OrgDepartmentDO {
|
|||
/** 负责人 */
|
||||
private String managerName;
|
||||
|
||||
/** 负责人账号 */
|
||||
private String managerAccount;
|
||||
|
||||
/** 部门级别编码 */
|
||||
private String deptLevelCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgDepartmentQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgDepartmentDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgDepartmentMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgDepartmentGatewayImpl implements OrgDepartmentGateway {
|
|||
@Resource
|
||||
private OrgDepartmentMapper orgDepartmentMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgDepartmentEntity save(OrgDepartmentEntity entity) {
|
||||
OrgDepartmentDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgDepartmentMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -80,9 +86,11 @@ public class OrgDepartmentGatewayImpl implements OrgDepartmentGateway {
|
|||
|
||||
private OrgDepartmentDO toDO(OrgDepartmentEntity entity) {
|
||||
OrgDepartmentDO dataObject = new OrgDepartmentDO();
|
||||
dataObject.setParentId(entity.getParentId());
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setParentId(entity.getParentId() != null ? entity.getParentId() : 0L);
|
||||
dataObject.setDeptName(entity.getDeptName());
|
||||
dataObject.setManagerName(entity.getManagerName());
|
||||
dataObject.setManagerAccount(entity.getManagerAccount());
|
||||
dataObject.setDeptLevelCode(entity.getDeptLevelCode());
|
||||
dataObject.setDeptLevelName(entity.getDeptLevelName());
|
||||
dataObject.setTenantId(entity.getTenantId());
|
||||
|
|
@ -98,6 +106,7 @@ public class OrgDepartmentGatewayImpl implements OrgDepartmentGateway {
|
|||
entity.setParentId(dataObject.getParentId());
|
||||
entity.setDeptName(dataObject.getDeptName());
|
||||
entity.setManagerName(dataObject.getManagerName());
|
||||
entity.setManagerAccount(dataObject.getManagerAccount());
|
||||
entity.setDeptLevelCode(dataObject.getDeptLevelCode());
|
||||
entity.setDeptLevelName(dataObject.getDeptLevelName());
|
||||
entity.setTenantId(dataObject.getTenantId());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgEquipmentQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgEquipmentDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgEquipmentMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgEquipmentGatewayImpl implements OrgEquipmentGateway {
|
|||
@Resource
|
||||
private OrgEquipmentMapper orgEquipmentMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgEquipmentEntity save(OrgEquipmentEntity entity) {
|
||||
OrgEquipmentDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgEquipmentMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -64,11 +70,13 @@ public class OrgEquipmentGatewayImpl implements OrgEquipmentGateway {
|
|||
if (StringUtils.hasText(query.getDeviceName())) {
|
||||
wrapper.like(OrgEquipmentDO::getDeviceName, query.getDeviceName());
|
||||
}
|
||||
if (query.getInstrumentTypeCode() != null) {
|
||||
wrapper.eq(OrgEquipmentDO::getInstrumentTypeCode, query.getInstrumentTypeCode());
|
||||
if (StringUtils.hasText(query.getInstrumentType())) {
|
||||
wrapper.and(w -> w.like(OrgEquipmentDO::getInstrumentTypeName, query.getInstrumentType())
|
||||
.or().like(OrgEquipmentDO::getInstrumentTypeCode, query.getInstrumentType()));
|
||||
}
|
||||
if (query.getDeviceTypeCode() != null) {
|
||||
wrapper.eq(OrgEquipmentDO::getDeviceTypeCode, query.getDeviceTypeCode());
|
||||
if (StringUtils.hasText(query.getDeviceType())) {
|
||||
wrapper.and(w -> w.like(OrgEquipmentDO::getDeviceTypeName, query.getDeviceType())
|
||||
.or().like(OrgEquipmentDO::getDeviceTypeCode, query.getDeviceType()));
|
||||
}
|
||||
if (query.getEnableFlag() != null) {
|
||||
wrapper.eq(OrgEquipmentDO::getEnableFlag, query.getEnableFlag());
|
||||
|
|
@ -86,6 +94,7 @@ public class OrgEquipmentGatewayImpl implements OrgEquipmentGateway {
|
|||
|
||||
private OrgEquipmentDO toDO(OrgEquipmentEntity entity) {
|
||||
OrgEquipmentDO dataObject = new OrgEquipmentDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setDeviceName(entity.getDeviceName());
|
||||
dataObject.setDeviceModel(entity.getDeviceModel());
|
||||
dataObject.setInstrumentTypeCode(entity.getInstrumentTypeCode());
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
|||
import org.qinan.safetyeval.domain.gateway.OrgInfoGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgInfoDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgInfoMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -30,6 +32,7 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
|||
@Override
|
||||
public OrgInfoEntity save(OrgInfoEntity entity) {
|
||||
OrgInfoDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgInfoMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgPersonnelCertQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelCertDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelCertMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
|||
@Resource
|
||||
private OrgPersonnelCertMapper orgPersonnelCertMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgPersonnelCertEntity save(OrgPersonnelCertEntity entity) {
|
||||
OrgPersonnelCertDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgPersonnelCertMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -100,6 +106,7 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
|
|||
|
||||
private OrgPersonnelCertDO toDO(OrgPersonnelCertEntity entity) {
|
||||
OrgPersonnelCertDO dataObject = new OrgPersonnelCertDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setPersonnelId(entity.getPersonnelId());
|
||||
dataObject.setCertName(entity.getCertName());
|
||||
dataObject.setCertTypeCode(entity.getCertTypeCode());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgPersonnelChangeQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelChangeDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelChangeMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgPersonnelChangeGatewayImpl implements OrgPersonnelChangeGateway
|
|||
@Resource
|
||||
private OrgPersonnelChangeMapper orgPersonnelChangeMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgPersonnelChangeEntity save(OrgPersonnelChangeEntity entity) {
|
||||
OrgPersonnelChangeDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgPersonnelChangeMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -88,6 +94,7 @@ public class OrgPersonnelChangeGatewayImpl implements OrgPersonnelChangeGateway
|
|||
|
||||
private OrgPersonnelChangeDO toDO(OrgPersonnelChangeEntity entity) {
|
||||
OrgPersonnelChangeDO dataObject = new OrgPersonnelChangeDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setPersonnelId(entity.getPersonnelId());
|
||||
dataObject.setChangeItem(entity.getChangeItem());
|
||||
dataObject.setChangeTime(entity.getChangeTime());
|
||||
|
|
@ -102,6 +109,7 @@ public class OrgPersonnelChangeGatewayImpl implements OrgPersonnelChangeGateway
|
|||
}
|
||||
OrgPersonnelChangeEntity entity = new OrgPersonnelChangeEntity();
|
||||
entity.setId(dataObject.getId());
|
||||
entity.setOrgId(dataObject.getOrgId());
|
||||
entity.setPersonnelId(dataObject.getPersonnelId());
|
||||
entity.setChangeItem(dataObject.getChangeItem());
|
||||
entity.setChangeTime(dataObject.getChangeTime());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgPersonnelQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
|
|||
@Resource
|
||||
private OrgPersonnelMapper orgPersonnelMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgPersonnelEntity save(OrgPersonnelEntity entity) {
|
||||
OrgPersonnelDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgPersonnelMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -40,11 +46,28 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
|
|||
OrgPersonnelDO dataObject = orgPersonnelMapper.selectById(id);
|
||||
return toEntity(dataObject);
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public OrgPersonnelEntity getByAccount(String account) {
|
||||
LambdaQueryWrapper<OrgPersonnelDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrgPersonnelDO::getAccount, account);
|
||||
wrapper.eq(OrgPersonnelDO::getDeleteEnum, "false");
|
||||
Long orgId = orgContextResolver.resolveOrgId(null);
|
||||
if (orgId != null) {
|
||||
wrapper.eq(OrgPersonnelDO::getOrgId, orgId);
|
||||
}
|
||||
OrgPersonnelDO dataObject = orgPersonnelMapper.selectOne(wrapper);
|
||||
return toEntity(dataObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgPersonnelEntity findByUserName(String userName) {
|
||||
if (!StringUtils.hasText(userName)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<OrgPersonnelDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrgPersonnelDO::getUserName, userName);
|
||||
wrapper.eq(OrgPersonnelDO::getDeleteEnum, "false");
|
||||
wrapper.last("LIMIT 1");
|
||||
OrgPersonnelDO dataObject = orgPersonnelMapper.selectOne(wrapper);
|
||||
return toEntity(dataObject);
|
||||
}
|
||||
|
|
@ -79,7 +102,18 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
|
|||
wrapper.like(OrgPersonnelDO::getUserName, query.getUserName());
|
||||
}
|
||||
if (StringUtils.hasText(query.getAccount())) {
|
||||
wrapper.eq(OrgPersonnelDO::getAccount, query.getAccount());
|
||||
wrapper.like(OrgPersonnelDO::getAccount, query.getAccount());
|
||||
}
|
||||
if (query.getEmploymentStatusCode() != null) {
|
||||
wrapper.eq(OrgPersonnelDO::getEmploymentStatusCode, query.getEmploymentStatusCode());
|
||||
}
|
||||
if (query.getPersonnelIds() != null) {
|
||||
if (query.getPersonnelIds().isEmpty()) {
|
||||
wrapper.eq(OrgPersonnelDO::getId, -1L);
|
||||
}
|
||||
else {
|
||||
wrapper.in(OrgPersonnelDO::getId, query.getPersonnelIds());
|
||||
}
|
||||
}
|
||||
|
||||
Page<OrgPersonnelDO> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
|
|
@ -94,6 +128,7 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
|
|||
|
||||
private OrgPersonnelDO toDO(OrgPersonnelEntity entity) {
|
||||
OrgPersonnelDO dataObject = new OrgPersonnelDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setDeptId(entity.getDeptId());
|
||||
dataObject.setPostId(entity.getPostId());
|
||||
dataObject.setUserName(entity.getUserName());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgPositionQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgPositionDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPositionMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
@Resource
|
||||
private OrgPositionMapper orgPositionMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgPositionEntity save(OrgPositionEntity entity) {
|
||||
OrgPositionDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgPositionMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -80,9 +86,11 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
|
||||
private OrgPositionDO toDO(OrgPositionEntity entity) {
|
||||
OrgPositionDO dataObject = new OrgPositionDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setDeptId(entity.getDeptId());
|
||||
dataObject.setPositionName(entity.getPositionName());
|
||||
dataObject.setDutyDesc(entity.getDutyDesc());
|
||||
dataObject.setRemarks(entity.getRemark());
|
||||
dataObject.setTenantId(entity.getTenantId());
|
||||
return dataObject;
|
||||
}
|
||||
|
|
@ -96,6 +104,7 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
entity.setDeptId(dataObject.getDeptId());
|
||||
entity.setPositionName(dataObject.getPositionName());
|
||||
entity.setDutyDesc(dataObject.getDutyDesc());
|
||||
entity.setRemark(dataObject.getRemarks());
|
||||
entity.setTenantId(dataObject.getTenantId());
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.qinan.safetyeval.domain.query.OrgQualificationQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgQualificationDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgQualificationMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
|
@ -27,9 +29,13 @@ public class OrgQualificationGatewayImpl implements OrgQualificationGateway {
|
|||
@Resource
|
||||
private OrgQualificationMapper orgQualificationMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgQualificationEntity save(OrgQualificationEntity entity) {
|
||||
OrgQualificationDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgQualificationMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -91,6 +97,7 @@ public class OrgQualificationGatewayImpl implements OrgQualificationGateway {
|
|||
|
||||
private OrgQualificationDO toDO(OrgQualificationEntity entity) {
|
||||
OrgQualificationDO dataObject = new OrgQualificationDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setLicenseTypeCode(entity.getLicenseTypeCode());
|
||||
dataObject.setLicenseTypeName(entity.getLicenseTypeName());
|
||||
dataObject.setCertName(entity.getCertName());
|
||||
|
|
@ -101,6 +108,7 @@ public class OrgQualificationGatewayImpl implements OrgQualificationGateway {
|
|||
dataObject.setValidEndDate(entity.getValidEndDate());
|
||||
dataObject.setCertImageUrl(entity.getCertImageUrl());
|
||||
dataObject.setEnableFlag(entity.getEnableFlag());
|
||||
dataObject.setRemarks(entity.getRemark());
|
||||
dataObject.setTenantId(entity.getTenantId());
|
||||
return dataObject;
|
||||
}
|
||||
|
|
@ -121,6 +129,7 @@ public class OrgQualificationGatewayImpl implements OrgQualificationGateway {
|
|||
entity.setValidEndDate(dataObject.getValidEndDate());
|
||||
entity.setCertImageUrl(dataObject.getCertImageUrl());
|
||||
entity.setEnableFlag(dataObject.getEnableFlag());
|
||||
entity.setRemark(dataObject.getRemarks());
|
||||
entity.setTenantId(dataObject.getTenantId());
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,15 @@ import org.qinan.safetyeval.domain.query.OrgResignApplyQuery;
|
|||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.OrgResignApplyDO;
|
||||
import org.qinan.safetyeval.infrastructure.mapper.OrgResignApplyMapper;
|
||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||
import org.qinan.safetyeval.infrastructure.support.OrgContextResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -27,9 +31,13 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
|
|||
@Resource
|
||||
private OrgResignApplyMapper orgResignApplyMapper;
|
||||
|
||||
@Resource
|
||||
private OrgContextResolver orgContextResolver;
|
||||
|
||||
@Override
|
||||
public OrgResignApplyEntity save(OrgResignApplyEntity entity) {
|
||||
OrgResignApplyDO dataObject = toDO(entity);
|
||||
InsertFieldDefaults.apply(dataObject);
|
||||
orgResignApplyMapper.insert(dataObject);
|
||||
entity.setId(dataObject.getId());
|
||||
return entity;
|
||||
|
|
@ -67,6 +75,9 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
|
|||
if (query.getAuditStatusCode() != null) {
|
||||
wrapper.eq(OrgResignApplyDO::getAuditStatusCode, query.getAuditStatusCode());
|
||||
}
|
||||
if (StringUtils.hasText(query.getApplicantName())) {
|
||||
wrapper.like(OrgResignApplyDO::getApplicantName, query.getApplicantName());
|
||||
}
|
||||
|
||||
Page<OrgResignApplyDO> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
IPage<OrgResignApplyDO> result = orgResignApplyMapper.selectPage(page, wrapper);
|
||||
|
|
@ -78,8 +89,44 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
|
|||
return PageResult.of(entities, result.getTotal(), result.getCurrent(), result.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgResignApplyEntity> listByPersonnelId(Long personnelId) {
|
||||
if (personnelId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
LambdaQueryWrapper<OrgResignApplyDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrgResignApplyDO::getPersonnelId, personnelId);
|
||||
wrapper.eq(OrgResignApplyDO::getDeleteEnum, "false");
|
||||
wrapper.orderByDesc(OrgResignApplyDO::getApplyTime);
|
||||
wrapper.orderByDesc(OrgResignApplyDO::getId);
|
||||
return orgResignApplyMapper.selectList(wrapper).stream()
|
||||
.map(this::toEntity)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listPersonnelIdsByAuditStatus(Integer auditStatusCode, Long orgId) {
|
||||
if (auditStatusCode == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Long resolvedOrgId = orgContextResolver.resolveOrgId(orgId);
|
||||
LambdaQueryWrapper<OrgResignApplyDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrgResignApplyDO::getDeleteEnum, "false");
|
||||
wrapper.eq(OrgResignApplyDO::getAuditStatusCode, auditStatusCode);
|
||||
if (resolvedOrgId != null) {
|
||||
wrapper.eq(OrgResignApplyDO::getOrgId, resolvedOrgId);
|
||||
}
|
||||
wrapper.select(OrgResignApplyDO::getPersonnelId);
|
||||
return orgResignApplyMapper.selectList(wrapper).stream()
|
||||
.map(OrgResignApplyDO::getPersonnelId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private OrgResignApplyDO toDO(OrgResignApplyEntity entity) {
|
||||
OrgResignApplyDO dataObject = new OrgResignApplyDO();
|
||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||
dataObject.setPersonnelId(entity.getPersonnelId());
|
||||
dataObject.setApplicantName(entity.getApplicantName());
|
||||
dataObject.setApplyTime(entity.getApplyTime());
|
||||
|
|
@ -89,6 +136,7 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
|
|||
dataObject.setAuditStatusCode(entity.getAuditStatusCode());
|
||||
dataObject.setAuditStatusName(entity.getAuditStatusName());
|
||||
dataObject.setRejectReason(entity.getRejectReason());
|
||||
dataObject.setRemarks(entity.getRemark());
|
||||
dataObject.setTenantId(entity.getTenantId());
|
||||
return dataObject;
|
||||
}
|
||||
|
|
@ -108,6 +156,7 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
|
|||
entity.setAuditStatusCode(dataObject.getAuditStatusCode());
|
||||
entity.setAuditStatusName(dataObject.getAuditStatusName());
|
||||
entity.setRejectReason(dataObject.getRejectReason());
|
||||
entity.setRemark(dataObject.getRemarks());
|
||||
entity.setTenantId(dataObject.getTenantId());
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.qinan.safetyeval.infrastructure.handler;
|
|||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.qinan.safetyeval.domain.adapter.UserInfoAdapter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -27,6 +28,19 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||
@Resource
|
||||
private UserInfoAdapter userInfoAdapter;
|
||||
|
||||
/** 无登录上下文时的回退值(local 联调配置 org-id=1;生产默认 0 不生效) */
|
||||
@Value("${safety-eval.public-api.org-id:0}")
|
||||
private Long fallbackOrgId;
|
||||
|
||||
@Value("${safety-eval.public-api.tenant-id:0}")
|
||||
private Long fallbackTenantId;
|
||||
|
||||
@Value("${safety-eval.public-api.system-user-id:0}")
|
||||
private Long fallbackUserId;
|
||||
|
||||
@Value("${safety-eval.public-api.system-user-name:system}")
|
||||
private String fallbackUserName;
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
|
@ -35,6 +49,19 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||
Long tenantId = userInfoAdapter.getCurrentTenantId();
|
||||
Long orgId = userInfoAdapter.getCurrentOrgId();
|
||||
|
||||
if (userId == null && fallbackUserId != null && fallbackUserId > 0) {
|
||||
userId = fallbackUserId;
|
||||
}
|
||||
if (userName == null && fallbackUserName != null) {
|
||||
userName = fallbackUserName;
|
||||
}
|
||||
if (tenantId == null && fallbackTenantId != null && fallbackTenantId > 0) {
|
||||
tenantId = fallbackTenantId;
|
||||
}
|
||||
if (orgId == null && fallbackOrgId != null && fallbackOrgId > 0) {
|
||||
orgId = fallbackOrgId;
|
||||
}
|
||||
|
||||
// 严格填充:仅当字段值为 null 时填充,优先级最低
|
||||
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, now);
|
||||
this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, now);
|
||||
|
|
@ -64,6 +91,12 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|||
LocalDateTime now = LocalDateTime.now();
|
||||
Long userId = userInfoAdapter.getCurrentUserId();
|
||||
String userName = userInfoAdapter.getCurrentUserName();
|
||||
if (userId == null && fallbackUserId != null && fallbackUserId > 0) {
|
||||
userId = fallbackUserId;
|
||||
}
|
||||
if (userName == null && fallbackUserName != null) {
|
||||
userName = fallbackUserName;
|
||||
}
|
||||
|
||||
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, now);
|
||||
if (userId != null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package org.qinan.safetyeval.infrastructure.support;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* insert 前补齐 GBS 默认字段,避免逻辑删除字段为 null 导致 selectById 查不到。
|
||||
*/
|
||||
public final class InsertFieldDefaults {
|
||||
|
||||
private static final String DELETE_NOT_DELETED = "false";
|
||||
private static final String DEFAULT_ENV = "prod";
|
||||
|
||||
private InsertFieldDefaults() {
|
||||
}
|
||||
|
||||
public static void apply(Object dataObject) {
|
||||
if (dataObject == null) {
|
||||
return;
|
||||
}
|
||||
setIfNull(dataObject, "deleteEnum", DELETE_NOT_DELETED);
|
||||
setIfNull(dataObject, "env", DEFAULT_ENV);
|
||||
setIfNull(dataObject, "version", 0);
|
||||
}
|
||||
|
||||
private static void setIfNull(Object target, String property, Object value) {
|
||||
try {
|
||||
String getterName = "get" + Character.toUpperCase(property.charAt(0)) + property.substring(1);
|
||||
Method getter = target.getClass().getMethod(getterName);
|
||||
if (getter.invoke(target) != null) {
|
||||
return;
|
||||
}
|
||||
String setterName = "set" + Character.toUpperCase(property.charAt(0)) + property.substring(1);
|
||||
Method setter = target.getClass().getMethod(setterName, value.getClass());
|
||||
setter.invoke(target, value);
|
||||
}
|
||||
catch (ReflectiveOperationException ignored) {
|
||||
// 非 GBS 标准 DO 忽略
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package org.qinan.safetyeval.infrastructure.support;
|
||||
|
||||
import org.qinan.safetyeval.domain.adapter.UserInfoAdapter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 解析写入时的 orgId:优先实体值 → 登录上下文 → 配置回退(local 联调 org-id=1)。
|
||||
*/
|
||||
@Component
|
||||
public class OrgContextResolver {
|
||||
|
||||
@Resource
|
||||
private UserInfoAdapter userInfoAdapter;
|
||||
|
||||
@Value("${safety-eval.public-api.org-id:0}")
|
||||
private Long fallbackOrgId;
|
||||
|
||||
public Long resolveOrgId(Long entityOrgId) {
|
||||
if (entityOrgId != null) {
|
||||
return entityOrgId;
|
||||
}
|
||||
Long orgId = userInfoAdapter.getCurrentOrgId();
|
||||
if (orgId != null) {
|
||||
return orgId;
|
||||
}
|
||||
if (fallbackOrgId != null && fallbackOrgId > 0) {
|
||||
return fallbackOrgId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
<result column="parent_id" property="parentId"/>
|
||||
<result column="dept_name" property="deptName"/>
|
||||
<result column="manager_name" property="managerName"/>
|
||||
<result column="manager_account" property="managerAccount"/>
|
||||
<result column="dept_level_code" property="deptLevelCode"/>
|
||||
<result column="dept_level_name" property="deptLevelName"/>
|
||||
<result column="delete_enum" property="deleteEnum"/>
|
||||
|
|
@ -26,7 +27,7 @@
|
|||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
`id`, `org_id`, `parent_id`, `dept_name`, `manager_name`, `dept_level_code`, `dept_level_name`, `delete_enum`, `remarks`, `create_name`, `update_name`, `tenant_id`, `version`, `create_time`, `update_time`, `create_id`, `update_id`, `env`
|
||||
`id`, `org_id`, `parent_id`, `dept_name`, `manager_name`, `manager_account`, `dept_level_code`, `dept_level_name`, `delete_enum`, `remarks`, `create_name`, `update_name`, `tenant_id`, `version`, `create_time`, `update_time`, `create_id`, `update_id`, `env`
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package org.qinan.safetyeval.start.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* 本地联调跨域配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WebCorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedOriginPattern("*");
|
||||
config.addAllowedHeader("*");
|
||||
config.addAllowedMethod("*");
|
||||
config.setAllowCredentials(true);
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
|
|
@ -54,3 +54,33 @@ mybatis-plus:
|
|||
logging:
|
||||
level:
|
||||
org.qinan.safetyeval: debug
|
||||
|
||||
# 本地联调:企业信息管理接口免鉴权(覆盖 application.yml 中 security 配置)
|
||||
safety-eval:
|
||||
security:
|
||||
permit-all-paths:
|
||||
- /v2/api-docs
|
||||
- /v3/api-docs
|
||||
permit-all-prefixes:
|
||||
- /swagger-ui
|
||||
- /swagger-resources
|
||||
- /webjars
|
||||
- /public/org-personnel
|
||||
- /test
|
||||
- /tmp
|
||||
- /mock
|
||||
- /org-info
|
||||
- /org-department
|
||||
- /org-position
|
||||
- /org-qualification
|
||||
- /org-personnel
|
||||
- /org-personnel-cert
|
||||
- /org-personnel-change
|
||||
- /org-resign-apply
|
||||
- /org-equipment
|
||||
# 本地联调默认用户上下文(与 init-v2.sql 测试数据 @org_id=1 @tenant_id=1001 一致)
|
||||
public-api:
|
||||
system-user-id: 1
|
||||
system-user-name: local-dev
|
||||
tenant-id: 1001
|
||||
org-id: 1
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ mybatis-plus:
|
|||
mapper-locations: classpath*:mapper/**/*.xml
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: assign_id
|
||||
logic-delete-field: deleteEnum
|
||||
logic-delete-value: "true"
|
||||
logic-not-delete-value: "false"
|
||||
|
|
|
|||
Loading…
Reference in New Issue