提交
This commit is contained in:
1 parent
ffc89d9b57
commit
c2cba3e668
53 files changed
+11794
-6264
No files matched your search
@@ -0,0 +1,24 @@
|
||||
-- pl_personnel 增加人员归属:self-山峡 carrier-非山峡
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'pl_personnel'
|
||||
AND COLUMN_NAME = 'personnel_affiliation'
|
||||
);
|
||||
|
||||
SET @ddl := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE `pl_personnel`
|
||||
ADD COLUMN `personnel_affiliation` varchar(20) NOT NULL DEFAULT ''self''
|
||||
COMMENT ''人员归属 self-山峡 carrier-非山峡''
|
||||
AFTER `personnel_type`',
|
||||
'SELECT ''personnel_affiliation already exists'' AS msg'
|
||||
);
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
UPDATE `pl_personnel`
|
||||
SET `personnel_affiliation` = 'self'
|
||||
WHERE `personnel_affiliation` IS NULL OR `personnel_affiliation` = '';
|
||||
@@ -0,0 +1,52 @@
|
||||
-- pl_personnel 增加人员类型;历史数据按车辆关联推断
|
||||
-- 可重复执行(列已存在则跳过加列,UPDATE 可重复跑)
|
||||
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'pl_personnel'
|
||||
AND COLUMN_NAME = 'personnel_type'
|
||||
);
|
||||
|
||||
SET @ddl := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE `pl_personnel`
|
||||
ADD COLUMN `personnel_type` varchar(20) NOT NULL DEFAULT ''both''
|
||||
COMMENT ''人员类型 driver-驾驶员 escort-押运员 both-驾驶员兼押运员''
|
||||
AFTER `id_card_no`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 仅有 driver 关联
|
||||
UPDATE pl_personnel p
|
||||
SET p.personnel_type = 'driver'
|
||||
WHERE p.del_flag = 0
|
||||
AND (p.personnel_type IS NULL OR p.personnel_type = '' OR p.personnel_type = 'both')
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM pl_vehicle_personnel vp
|
||||
WHERE vp.personnel_id = p.id AND vp.del_flag = 0 AND vp.role = 'driver'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM pl_vehicle_personnel vp
|
||||
WHERE vp.personnel_id = p.id AND vp.del_flag = 0 AND vp.role = 'escort'
|
||||
);
|
||||
|
||||
-- 仅有 escort 关联
|
||||
UPDATE pl_personnel p
|
||||
SET p.personnel_type = 'escort'
|
||||
WHERE p.del_flag = 0
|
||||
AND (p.personnel_type IS NULL OR p.personnel_type = '' OR p.personnel_type = 'both')
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM pl_vehicle_personnel vp
|
||||
WHERE vp.personnel_id = p.id AND vp.del_flag = 0 AND vp.role = 'escort'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM pl_vehicle_personnel vp
|
||||
WHERE vp.personnel_id = p.id AND vp.del_flag = 0 AND vp.role = 'driver'
|
||||
);
|
||||
|
||||
-- 同时有 driver + escort 或无关联保持 both(默认)
|
||||
@@ -81,6 +81,8 @@ CREATE TABLE `pl_personnel` (
|
||||
`phone_no` varchar(32) DEFAULT NULL COMMENT '手机号(非必填)',
|
||||
`age` int(11) DEFAULT NULL COMMENT '年龄',
|
||||
`id_card_no` varchar(32) DEFAULT NULL COMMENT '身份证号',
|
||||
`personnel_type` varchar(20) NOT NULL DEFAULT 'both' COMMENT '人员类型 driver-驾驶员 escort-押运员 both-驾驶员兼押运员',
|
||||
`personnel_affiliation` varchar(20) NOT NULL DEFAULT 'self' COMMENT '人员归属 self-山峡 carrier-非山峡',
|
||||
`status` char(1) NOT NULL DEFAULT '1' COMMENT '状态 1-在职 0-停用',
|
||||
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
|
||||
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
|
||||
|
||||
@@ -2752,6 +2752,7 @@ CREATE TABLE `pl_personnel` (
|
||||
`phone_no` varchar(32) DEFAULT NULL COMMENT '手机号(非必填)',
|
||||
`age` int(11) DEFAULT NULL COMMENT '年龄',
|
||||
`id_card_no` varchar(32) DEFAULT NULL COMMENT '身份证号',
|
||||
`personnel_type` varchar(20) NOT NULL DEFAULT 'both' COMMENT '人员类型 driver-驾驶员 escort-押运员 both-驾驶员兼押运员',
|
||||
`status` char(1) NOT NULL DEFAULT '1' COMMENT '状态 1-在职 0-停用',
|
||||
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
|
||||
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
|
||||
@@ -2772,10 +2773,10 @@ CREATE TABLE `pl_personnel` (
|
||||
-- Records of pl_personnel
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('3C13B995C2B149E8AA50222609D030A1', '里斯', '13099922123', 32, '123123', '1', 'shanxia2.0', NULL, '123123', 'd3000000000000000000000000000001', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-20 07:45:10', 'd3000000000000000000000000000001', '2026-06-20 07:55:22', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('4B753C6E5CE446AB9208C449A76BEA0C', '张三', '13900022112', 35, '340829181823123123123', '1', 'shanxia2.0', NULL, '备注', 'd3000000000000000000000000000001', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-19 22:56:38', 'd3000000000000000000000000000001', '2026-06-20 07:44:42', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('9AB6B5474343428C80C24503EB7771DC', '刘道银', '130023312', 32, '34082219912312', '1', 'shanxia2.0', NULL, '司机', 'BFB4CBEAB7054F48BDE82B55A985798C', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-28 14:57:39', 'd3000000000000000000000000000001', '2026-06-28 16:11:58', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('BD11DEEA3C1E4C8EA75CDF18A6EED21F', '吴春生', '1390001231', 32, '340822121323', '1', 'shanxia2.0', NULL, '押运员', 'BFB4CBEAB7054F48BDE82B55A985798C', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-28 14:56:57', 'd3000000000000000000000000000001', '2026-06-28 16:11:58', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `personnel_type`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('3C13B995C2B149E8AA50222609D030A1', '里斯', '13099922123', 32, '123123', 'both', '1', 'shanxia2.0', NULL, '123123', 'd3000000000000000000000000000001', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-20 07:45:10', 'd3000000000000000000000000000001', '2026-06-20 07:55:22', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `personnel_type`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('4B753C6E5CE446AB9208C449A76BEA0C', '张三', '13900022112', 35, '340829181823123123123', 'both', '1', 'shanxia2.0', NULL, '备注', 'd3000000000000000000000000000001', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-19 22:56:38', 'd3000000000000000000000000000001', '2026-06-20 07:44:42', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `personnel_type`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('9AB6B5474343428C80C24503EB7771DC', '刘道银', '130023312', 32, '34082219912312', 'driver', '1', 'shanxia2.0', NULL, '司机', 'BFB4CBEAB7054F48BDE82B55A985798C', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-28 14:57:39', 'd3000000000000000000000000000001', '2026-06-28 16:11:58', 0);
|
||||
INSERT INTO `pl_personnel` (`id`, `personnel_name`, `phone_no`, `age`, `id_card_no`, `personnel_type`, `status`, `tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`) VALUES ('BD11DEEA3C1E4C8EA75CDF18A6EED21F', '吴春生', '1390001231', 32, '340822121323', 'escort', '1', 'shanxia2.0', NULL, '押运员', 'BFB4CBEAB7054F48BDE82B55A985798C', 'b13c2be2-4e71-11f1-9f47-00163e3bdd96', '2026-06-28 14:56:57', 'd3000000000000000000000000000001', '2026-06-28 16:11:58', 0);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
Reference in new issue
Block a user