-- 2023/08/07 日志管理表字段更改
ALTER TABLE `sys_log` ADD COLUMN `user_id` bigint(0) NOT NULL COMMENT '用户id' AFTER `id`;

ALTER TABLE `sys_log` ADD COLUMN `user_name` varchar(100) NULL DEFAULT NULL COMMENT '用户名称' AFTER `user_id`;

ALTER TABLE `sys_log` ADD COLUMN `url` varchar(64) NULL DEFAULT NULL COMMENT '请求的url' AFTER `content`;

ALTER TABLE `sys_log` ADD COLUMN `args` mediumtext NULL COMMENT '请求的参数' AFTER `url`;

ALTER TABLE `sys_log` ADD COLUMN `run_time` bigint(0) NULL DEFAULT NULL COMMENT '请求的响应时间' AFTER `create_time`;

ALTER TABLE `sys_log` ADD COLUMN `run_status` varchar(64) NULL DEFAULT NULL COMMENT '请求的结果' AFTER `run_time`;

-- 2023/08/10 更改表名
ALTER TABLE t_b_service_region_deatil RENAME TO t_b_service_region_detail;

-- 2023/08/11
-- 服务单元管理权限
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2000', '服务单元管理-编辑', '/api/service/service/unit/edit', 'URL', '54', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2001', '服务单元管理-分页查询', '/api/service/service/unit/page', 'URL', '54', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2002', '服务单元管理-发布', '/api/service/service/unit/publish', 'URL', '54', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2003', '服务单元管理-关闭', '/api/service/service/unit/cloze', 'URL', '54', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2004', '服务单元管理-重启', '/api/service/service/unit/restart', 'URL', '54', '5', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2005', '服务单元管理-作废', '/api/service/service/unit/cancel', 'URL', '54', '6', 'AUTH', '1', '1', '0');
-- 服务范围管理权限
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2006', '服务范围管理-分页查询', '/api/service/service/scope/page', 'URL', '55', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2007', '服务范围管理-派单小计', '/api/service/service/scope/subTotal', 'URL', '55', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2008', '服务范围管理-新增服务范围-未绑定派单分页查询', '/api/service/service/scope/unbind/page', 'URL', '55', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2009', '服务范围管理-批量划定派单和服务单元关系', '/api/service/service/scope/bind_batch', 'URL', '55', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2010', '服务范围管理-移出', '/api/service/service/scope/unbind', 'URL', '55', '5', 'AUTH', '1', '1', '0');
-- 服务区域规划权限
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2011', '服务区域规划-分页查询', '/api/service/service/region/page', 'URL', '56', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2012', '服务区域规划-编辑', '/api/service/service/region/edit', 'URL', '56', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2013', '服务区域规划-删除', '/api/service/service/region/remove', 'URL', '56', '3', 'AUTH', '1', '1', '0');
-- 服务单元管理的元素绑定
UPDATE sys_privilege SET related = '2001' WHERE (id = '218');
UPDATE sys_privilege SET related = '2001' WHERE (id = '219');
UPDATE sys_privilege SET related = '2000' WHERE (id = '220');
UPDATE sys_privilege SET related = '2001' WHERE (id = '221');
UPDATE sys_privilege SET related = '2000' WHERE (id = '222');
UPDATE sys_privilege SET related = '2005' WHERE (id = '223');
UPDATE sys_privilege SET related = '2002' WHERE (id = '225');
UPDATE sys_privilege SET related = '2004' WHERE (id = '226');
UPDATE sys_privilege SET related = '2003' WHERE (id = '227');
-- 服务范围管理的元素绑定
UPDATE sys_privilege SET name = '新增服务范围', related = '2008,2009' WHERE (id = '230');
UPDATE sys_privilege SET related = '2006' WHERE (id = '228');
UPDATE sys_privilege SET related = '2006' WHERE (id = '229');
UPDATE sys_privilege SET related = '2006' WHERE (id = '231');
UPDATE sys_privilege SET related = '2010' WHERE (id = '232');
-- 服务区域规划的元素绑定
UPDATE sys_privilege SET related = '2011' WHERE (id = '233');
UPDATE sys_privilege SET related = '2011' WHERE (id = '234');
UPDATE sys_privilege SET related = '2011' WHERE (id = '236');
UPDATE sys_privilege SET related = '2013' WHERE (id = '238');
UPDATE sys_privilege SET related = '2012' WHERE (id = '235');
UPDATE sys_privilege SET related = '2012' WHERE (id = '237');

-- 2023/08/13
ALTER TABLE `t_b_crm`
    CHANGE COLUMN `service_id` `service_id` BIGINT NULL COMMENT '服务单元id' ;

-- 日志管理权限
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2014', '日志管理-查询', '/api/sys/log/page', 'URL', '10', '1', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2014' WHERE (id = '108');
UPDATE sys_privilege SET related = '2014' WHERE (id = '109');
UPDATE sys_privilege SET related = '2014' WHERE (id = '110');

-- 2023/08/16
ALTER TABLE `t_b_user_archives_allocation`
    CHANGE COLUMN `crm_no` `crm_no` VARCHAR(100) NOT NULL COMMENT 'crm单号' ;

-- 2023/08/17
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('2015', '公共接口-查询服务单元列表', '/api/admin/common/query_service_unit', 'URL', '64', '25', 'SYS', '1', '1', '0');
ALTER TABLE `t_b_user_archives_allocation`
    CHANGE COLUMN `region_user_id` `region_user_id` BIGINT NULL COMMENT '区域协调人id' ;

-- 2023/08/18
ALTER TABLE t_b_crm
    ADD COLUMN region_coordinator_id BIGINT NULL COMMENT '区域协调人id' AFTER lead_id;
ALTER TABLE t_b_user_archives
    ADD COLUMN status VARCHAR(20) NOT NULL COMMENT '人力资源状态（FREE(\"空闲\"),NON_EXECUTION_SOP(\"未执行SOP\"),EXECUTION_SOP(\"执行SOP\");）' AFTER base_photo_path;
ALTER TABLE t_b_user_archives_allocation
    ADD COLUMN archives_id BIGINT NOT NULL COMMENT '人员档案id' AFTER role_id;

-- 2023/08/21
DELETE FROM sys_privilege WHERE (id = '70');
DELETE FROM sys_privilege WHERE (id = '71');

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2016', '人员档案管理-分页查询', '/api/admin/user/archives/page', 'URL', '33', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2017', '人员档案管理-小计', '/api/admin/user/archives/sub_total', 'URL', '33', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2018', '人员档案管理-编辑', '/api/admin/user/archives/edit', 'URL', '33', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2019', '人员档案管理-导入', '/api/admin/user/archives/import', 'URL', '33', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2020', '人员档案管理-导出', '/api/admin/user/archives/export', 'URL', '33', '5', 'AUTH', '1', '1', '0');

UPDATE sys_privilege SET related = '2016,2017' WHERE (id = '153');
UPDATE sys_privilege SET related = '2018' WHERE (id = '154');
UPDATE sys_privilege SET related = '2019' WHERE (id = '155');
UPDATE sys_privilege SET related = '2016,2017' WHERE (id = '156');
UPDATE sys_privilege SET related = '2016,2017' WHERE (id = '157');
UPDATE sys_privilege SET related = '2020' WHERE (id = '158');
UPDATE sys_privilege SET related = '2018' WHERE (id = '160');

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2021', '人员调配管理-分页查询', '/api/admin/user/archives/allocation/page', 'URL', '34', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2022', '人员调配管理-小计查询', '/api/admin/user/archives/allocation/sub_total', 'URL', '34', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2023', '人员调配管理-根据派单号查询派单分配信息', '/api/admin/user/archives/allocation/detail_by_crm_no', 'URL', '34', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2024', '人员调配管理-调配', '/api/admin/user/archives/allocation/edit', 'URL', '34', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2025', '人员调配管理—自动调配', '/api/admin/user/archives/allocation/auto_edit', 'URL', '34', '5', 'AUTH', '1', '1', '0');

UPDATE sys_privilege SET related = '2021,2022,2023' WHERE (id = '161');
UPDATE sys_privilege SET related = '2021,2022' WHERE (id = '162');
UPDATE sys_privilege SET related = '2021,2022' WHERE (id = '163');
UPDATE sys_privilege SET related = '2024' WHERE (id = '164');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('2026', '批量调配', 'AllocateBatch', 'BUTTON', '34', '4', 'AUTH', '2025', '1', '0', '1');

ALTER TABLE t_b_user_archives
    CHANGE COLUMN base_photo_path base_photo_path VARCHAR(500) NULL COMMENT '底照保存地址' ;

INSERT INTO sequence (name, current_value, increment) VALUES ('userArchivesCode', '0', '1');

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2027', '人员档案管理-生成编号', '/api/admin/user/archives/create_code', 'URL', '33', '6', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2018,2027' WHERE (id = '154');

UPDATE sys_privilege SET parent_id = '64', sequence = '27', property = 'SYS' WHERE (id = '267');

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2028', '人员调配管理-发布', '/api/admin/user/archives/allocation/publish', 'URL', '34', '6', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2029', '人员调配管理-撤销发布', '/api/admin/user/archives/allocation/un_publish', 'URL', '34', '7', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2028' WHERE (id = '165');
UPDATE sys_privilege SET related = '2029' WHERE (id = '166');

-- 2023/08/23
ALTER TABLE `t_b_device_in_out`
    ADD COLUMN `usage_type` VARCHAR(45) NULL COMMENT '用途类型（项目、其他）' AFTER `address`;

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2030', '人员调配管理-查询空闲工程师', '/api/admin/user/archives/allocation/free_engineer', 'URL', '34', '8', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2031', '人员调配管理-查询空闲区域协调人', '/api/admin/user/archives/allocation/free_coordinator', 'URL', '34', '9', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2024,2030,2031' WHERE (id = '164');

ALTER TABLE t_b_device_in_out
    ADD COLUMN base_photo_path VARCHAR(500) NULL COMMENT '快递单拍照' AFTER usage_type;

ALTER TABLE t_b_device_in_out
    ADD COLUMN status VARCHAR(20) NOT NULL COMMENT '状态，NORMAL：正常，BREAK_DOWN：故障' AFTER address;

ALTER TABLE t_b_device_in_out
    ADD COLUMN location VARCHAR(100) NULL COMMENT '当前所在地' AFTER supplier_name;

-- 2023/08/25
CREATE TABLE `t_b_ding_submit` (
                                   `id` bigint NOT NULL COMMENT '主键',
                                   `service_id` bigint NOT NULL COMMENT '服务单元id',
                                   `sop_no` varchar(100) NOT NULL COMMENT 'sop单号',
                                   `crm_no` varchar(100) NOT NULL COMMENT 'crm单号',
                                   `user_archives_id` bigint NOT NULL COMMENT '人员档案id',
                                   `approach_time` bigint NOT NULL COMMENT '进场时间',
                                   `departure_time` bigint NOT NULL COMMENT '出场时间',
                                   `role_type` varchar(20) NOT NULL COMMENT '项目角色类型',
                                   `actual_days` int DEFAULT NULL COMMENT '实际出勤（天）',
                                   `weekdays` int DEFAULT NULL COMMENT '工作日（天）',
                                   `weekends` int DEFAULT NULL COMMENT '周末（天）',
                                   `legal_holidays` int DEFAULT NULL COMMENT '法定节假日（天）',
                                   `work_hours` decimal(8,2) DEFAULT NULL COMMENT '累计工时（小时）',
                                   `violation_days` decimal(8,2) DEFAULT NULL COMMENT '违规工时',
                                   `submit_user_id` bigint NOT NULL COMMENT '提交人id',
                                   `submit_time` bigint NOT NULL COMMENT '提交时间',
                                   `submit_status` varchar(20) NOT NULL COMMENT '提交状态',
                                   `create_id` bigint DEFAULT NULL COMMENT '创建人id',
                                   `create_time` bigint DEFAULT NULL COMMENT '创建时间',
                                   `update_id` bigint DEFAULT NULL COMMENT '更新人id',
                                   `update_time` bigint DEFAULT NULL COMMENT '更新时间',
                                   PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='考勤提交审核表';

ALTER TABLE t_b_ding
    ADD COLUMN user_archives_id BIGINT NOT NULL COMMENT '人员档案id' AFTER user_id,
    ADD COLUMN role_type VARCHAR(20) NOT NULL COMMENT '项目角色' AFTER user_archives_id;

-- 2023/08/28
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2032', 'sop管理 - 设备出入库登记查询', '/api/admin/device/in/out/sop_page', 'URL', '43', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2033', '查询可出库的设备信息', '/api/admin/device/in/out/can_out_info', 'URL', '43', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2034', '查询可入库的设备信息', '/api/admin/device/in/out/can_in_info', 'URL', '43', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2035', '设备出入库提交', '/api/admin/device/in/out/submit', 'URL', '43', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2036', '资源保障-设备保障-出入库登记查询', '/api/admin/device/in/out/source_page', 'URL', '37', '1', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2032' WHERE (id = '188');
UPDATE sys_privilege SET related = '2032' WHERE (id = '189');
UPDATE sys_privilege SET related = '2032' WHERE (id = '192');
UPDATE sys_privilege SET related = '2033,2034,2035' WHERE (id = '190');
UPDATE sys_privilege SET related = '2036' WHERE (id = '167');
UPDATE sys_privilege SET related = '2036' WHERE (id = '168');
UPDATE sys_privilege SET related = '2036' WHERE (id = '169');

ALTER TABLE t_b_device_in_out
    CHANGE COLUMN service_id service_id BIGINT NULL COMMENT '服务单元id' ;

-- 2023-08-30
ALTER TABLE t_b_ding
    ADD COLUMN sign_in_address VARCHAR(100) NULL COMMENT '签到地址' AFTER sign_in_time,
    ADD COLUMN sign_out_address VARCHAR(100) NULL COMMENT '签退地址' AFTER sign_out_time;


INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2037', '考勤提交-分页查询', '/api/admin/tb/ding/submit/page', 'URL', '28', '1', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2038', '考勤提交-小计', '/api/admin/tb/ding/submit/sub_total', 'URL', '28', '2', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2039', '考勤提交-批量提交', '/api/admin/tb/ding/submit/submit_batch', 'URL', '28', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2040', '考勤提交-考勤撤回', '/api/admin/tb/ding/submit/apply_withdram', 'URL', '28', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2041', '考勤提交-取消撤回', '/api/admin/tb/ding/submit/cancel_withdraw', 'URL', '28', '5', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2042', '考勤提交-批量导出', '/api/admin/tb/ding/submit/export', 'URL', '28', '6', 'AUTH', '1', '1', '0');

UPDATE sys_privilege SET related = '2037,2038' WHERE (id = '141');
UPDATE sys_privilege SET related = '2039' WHERE (id = '142');
UPDATE sys_privilege SET related = '2037,2038' WHERE (id = '143');
UPDATE sys_privilege SET related = '2037,2038' WHERE (id = '144');
UPDATE sys_privilege SET related = '2042' WHERE (id = '145');
UPDATE sys_privilege SET related = '2039' WHERE (id = '146');
UPDATE sys_privilege SET related = '2040,2041' WHERE (id = '147');

-- 2023-08-31
UPDATE sys_privilege SET url = '/api/admin/tb/ding/submit/apply_withdraw' WHERE (id = '2040');
UPDATE sys_privilege SET related = NULL WHERE (id = '5');

INSERT INTO sequence (name, current_value, increment) VALUES ('deviceInOutCode', '0', '1');
ALTER TABLE t_b_device_in_out
    ADD COLUMN serial_no VARCHAR(20) NOT NULL COMMENT '出入库流水号' AFTER id;

-- 2023-09-04
ALTER TABLE t_b_ding
    ADD COLUMN ding_sop_no VARCHAR(100) NOT NULL COMMENT '实际打卡对应的sop单号' AFTER sop_no,
    CHANGE COLUMN sop_no sop_no VARCHAR(100) NOT NULL COMMENT 'sop单号';

ALTER TABLE t_b_ding
    CHANGE COLUMN face_in_error face_in_pass TINYINT NULL DEFAULT NULL COMMENT '人脸识别是否通过，0：未通过，1：通过' ,
    CHANGE COLUMN face_out_error face_out_pass TINYINT NULL DEFAULT NULL COMMENT '人脸识别是否通过，0：未通过，1：通过' ;

-- 2023-09-06
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2043', '查询项目派单信息', '/api/admin/tb/crm/crm_project_info', 'URL', '64', '32', 'SYS', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2044', '考勤打卡信息', '/api/admin/tb/ding/ding_info', 'URL', '26', '1', 'SYS', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2045', '考勤结果统计', '/api/admin/tb/ding/ding_statistic', 'URL', '26', '2', 'SYS', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2046', '考勤打卡保存', '/api/admin/tb/ding/ding_save', 'URL', '26', '3', 'SYS', '1', '1', '0');
UPDATE sys_privilege SET related = '3017,2044,2045,2046' WHERE (id = '26');

-- 2023-09-07
ALTER TABLE t_b_crm
    ADD COLUMN status VARCHAR(20) NOT NULL COMMENT '派单状态(UN_PUBLISH(\"未发布\"),PUBLISH(\"已发布\"),FINISH(\"已完成\");)' AFTER update_time;

-- 2023-09-08
ALTER TABLE t_b_crm
    CHANGE COLUMN lead_id lead_id BIGINT NULL DEFAULT NULL COMMENT '大区经理id' ;
ALTER TABLE t_b_service_region
    CHANGE COLUMN lead_id lead_id BIGINT NOT NULL COMMENT '大区经理id' ;

-- 2023-09-12
INSERT INTO sys_privilege(id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES (2047, '服务区域规划-查询可选大区经理', '/api/service/service/region/find_leader', 'URL', 56, 4, 'AUTH', NULL, 1, 1, 0);
UPDATE sys_privilege SET related = '2012,2047' WHERE id = 235;
UPDATE sys_privilege SET related = '2012,2047' WHERE id = 237;

-- 用户查询编辑
UPDATE sys_privilege SET related = '283' WHERE (id = '118');
UPDATE sys_privilege SET related = '283' WHERE (id = '120');
UPDATE sys_privilege SET related = '252' WHERE (id = '117');

-- 服务档位配置新增
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('300', '服务档位新增', '/api/sys/level/add', 'URL', '6', '7', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '254,300' WHERE (id = '90');
UPDATE sys_privilege SET parent_id = '64', sequence = '32', property = 'SYS' WHERE (id = '255');

-- 供应商管理
UPDATE sys_privilege SET related = '264,266' WHERE (id = '81');
UPDATE sys_privilege SET related = '268' WHERE (id = '82');
UPDATE sys_privilege SET related = '269,266' WHERE (id = '83');
UPDATE sys_privilege SET related = '265' WHERE (id = '84');

-- 考勤组设置
UPDATE sys_privilege SET related = '281' WHERE (id = '93');
UPDATE sys_privilege SET related = '277' WHERE (id = '94');
UPDATE sys_privilege SET related = '282' WHERE (id = '95');
UPDATE sys_privilege SET related = '278' WHERE (id = '96');
UPDATE sys_privilege SET related = '281' WHERE (id = '97');
UPDATE sys_privilege SET related = '281' WHERE (id = '106');

-- 2023-09-13
-- 服务范围设置
UPDATE sys_privilege SET related = '2006,2007' WHERE (id = '228');
UPDATE sys_privilege SET related = '2006,2007' WHERE (id = '231');

INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('35', 'face.verify.baiduLocalAppId', '百度人脸识别appId', 'test', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('36', 'face.verify.baiduLocalUrlPrefix', '百度人脸识别请求url', 'http://192.168.20.253', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('37', 'baidu.face.compare.url', '百度人脸识别人脸比对接口', '/face-api/v3/face/match', '1', '1', '1');

ALTER TABLE t_b_ding_history
    ADD COLUMN sop_no VARCHAR(20) NULL COMMENT 'sop编号' AFTER ding_id,
    CHANGE COLUMN ding_id ding_id BIGINT NULL COMMENT '考勤id' ;

INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('38', 'baidu.face.compare.score', '百度人脸识别人脸比对阈值', '70', '1', '1', '1');

ALTER TABLE t_b_ding_history
    DROP COLUMN face_out_error,
    DROP COLUMN axis_out_Y,
    DROP COLUMN axis_out_x,
    DROP COLUMN sign_out_time,
    ADD COLUMN face_open TINYINT NULL COMMENT '是否开启人脸识别' AFTER axis_y,
    ADD COLUMN face_photo_path VARCHAR(500) NULL COMMENT '抓拍照片地址' AFTER face_pass,
    ADD COLUMN match_score DECIMAL(8,2) NULL COMMENT '对比分数' AFTER face_photo_path,
    CHANGE COLUMN sign_in_time sign_time BIGINT NULL DEFAULT NULL COMMENT '签到时间' ,
    CHANGE COLUMN axis_in_x axis_x VARCHAR(20) NULL DEFAULT NULL COMMENT '坐标轴X' ,
    CHANGE COLUMN axis_in_y axis_y VARCHAR(20) NULL DEFAULT NULL COMMENT '坐标轴Y' ,
    CHANGE COLUMN face_in_error face_pass TINYINT NULL DEFAULT NULL COMMENT '人脸识别是否通过，0：未通过，1：通过' ;

-- 2023-09-18
INSERT INTO sys_privilege(id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES (2048, '考勤打卡-查询进行中的sop', '/api/admin/tb/ding/ding_find_running_sop', 'URL', 26, 4, 'SYS', NULL, 1, 1, 0);
INSERT INTO sys_privilege(id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES (2049, '考勤打卡-查询所有sop', '/api/admin/tb/ding/ding_find_all_sop', 'URL', 26, 5, 'SYS', NULL, 1, 1, 0);

-- 2023-09-22
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2050', '考勤提交-同意撤回', '/api/admin/tb/ding/submit/agree_withdraw', 'URL', '28', '7', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2050' WHERE (id = '152');

-- 2023-09-25
ALTER TABLE t_b_ding_apply
    ADD COLUMN sop_no VARCHAR(100) NOT NULL COMMENT 'sop编号' AFTER id,
    ADD COLUMN crm_no VARCHAR(100) NOT NULL COMMENT '派单编号' AFTER sop_no;

UPDATE sys_privilege SET property = 'SYS' WHERE (id = '2033');
UPDATE sys_privilege SET property = 'SYS' WHERE (id = '2035');

-- 2023-09-26
ALTER TABLE sys_ding_group
    CHANGE COLUMN sign_in_time sign_in_time VARCHAR(50) NULL COMMENT '签到时段' ,
    CHANGE COLUMN sign_out_time sign_out_time VARCHAR(50) NULL COMMENT '签退时段' ;

ALTER TABLE t_b_user_archives
    ADD COLUMN enable TINYINT(1) NOT NULL DEFAULT 1 COMMENT '是否启用（1启用，0作废）' AFTER status;

INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2051', '人员档案管理-作废', '/api/admin/user/archives/cancel', 'URL', '33', '7', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2051' WHERE (id = '159');

-- 2023-10-10
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('39', 'fxxk.app.id', '纷享销客AppID', 'FSAID_131c93b', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('40', 'fxxk.app.secrete', '纷享销客APPSecret', '5d590b10cca24ce5a51fc716564aac9f', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('41', 'fxxk.permanent.code', '纷享销客永久授权码', '4EFBD3FCF655B4D934C163EA5ECE638D', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('42', 'fxxk.curren.open.user.id', '纷享销客当前操作人OpenUserID', 'FSUID_AE9192D544DCF7924E88E9EA800641C7', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('43', 'fxxk.api.name.crm', '纷享销客项目派单apiName', 'object_zS8me__c', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('44', 'fxxk.api.name.crm.detail', '纷享销客项目派单明细apiName', 'object_bs553__c', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('45', 'fxxk.app.auth.url', '纷享销客应用级授权接口', 'https://open.fxiaoke.com/cgi/corpAccessToken/get/V2', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('46', 'fxxk.user.by.mobile.url', '纷享销客根据手机号查询员工接口', 'https://open.fxiaoke.com/cgi/user/getByMobile', '1', '1', '1');
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('47', 'fxxk.custom.query.url', '纷享销客查询自定义对象接口', 'https://open.fxiaoke.com/cgi/crm/custom/v2/data/query', '1', '1', '1');

-- 2023-10-12
ALTER TABLE t_b_device_in_out
    ADD COLUMN address_arr VARCHAR(100) NULL COMMENT '发往地（回显）' AFTER address;
ALTER TABLE sys_device
    ADD COLUMN location_arr VARCHAR(100) NULL COMMENT '当前所在地（回显）' AFTER location;

-- 2023-10-13
ALTER TABLE t_b_crm
    ADD COLUMN publish_user_id BIGINT NULL COMMENT '发布人id' AFTER status,
    ADD COLUMN publish_time BIGINT NULL COMMENT '发布时间' AFTER publish_user_id;
-- 2023-10-30
ALTER TABLE t_b_service_region
    ADD COLUMN region_name VARCHAR(100) NOT NULL COMMENT '大区名称' AFTER service_id;
ALTER TABLE t_b_service_region
    ADD UNIQUE INDEX service_region_UN (service_id ASC, region_name ASC) VISIBLE;
;
-- 2023-11-08
ALTER TABLE `sys_custom` DROP COLUMN `manager_id`;
-- 2023-11-10
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('2052', '出入库登记查询-查询登记人列表', '/api/admin/device/in/out/registrant_list', 'URL', '64', '33', 'SYS', '1', '1', '0');

-- 2023-11-14
ALTER TABLE t_b_ding_submit
    CHANGE COLUMN approach_time approach_time BIGINT NULL COMMENT '进场时间' ,
    CHANGE COLUMN departure_time departure_time BIGINT NULL COMMENT '出场时间' ;

-- 2023-11-17
ALTER TABLE t_b_crm
    ADD COLUMN region_id BIGINT NULL COMMENT '服务区域规划id' AFTER lead_id,
    ADD COLUMN region_detail_id BIGINT NULL COMMENT '服务区域规划明细id' AFTER region_id;

DELETE FROM sys_privilege WHERE (id = '1033');
UPDATE sys_privilege SET related = '1032,1035,1036,1037,1038' WHERE (id = '51');

-- 2023-11-18
ALTER TABLE t_b_ding
    ADD COLUMN sign_year VARCHAR(20) NOT NULL COMMENT '签到年份' AFTER task_id;

-- 2023-11-23
INSERT INTO sys_privilege (id, name, url, type, sequence, enable, default_auth, front_display) VALUES ('2053', '智能客服', 'aiCustomerManage', 'MENU', '11', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('2054', '智能客服', 'aiCustomerChildManage', 'MENU', '2053', '1', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2055', '软通智能客服单点登录', '/api/sso/rtzf/login', 'URL', '2054', '1', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '2055' WHERE (id = '2054');
UPDATE sys_privilege SET url = '/api/sso/rtzf/login' WHERE (id = '2055');


-- 2023-11-24
ALTER TABLE sys_user
    ADD COLUMN rtzf_sync_status VARCHAR(20) NULL COMMENT '软通智服同步状态' AFTER source;

-- 2023-11-27
-- t_b_ding表和t_b_service_region表测试环境有脏数据
ALTER TABLE t_b_ding
    ADD UNIQUE INDEX t_b_ding_un (sop_no, user_id, sign_year, sign_date);
;
ALTER TABLE t_b_ding_submit
    ADD UNIQUE INDEX t_b_ding_submit_un (sop_no, user_archives_id);
;
ALTER TABLE t_b_product
    ADD UNIQUE INDEX t_b_product_un_code (code);
;
ALTER TABLE t_b_service
    ADD UNIQUE INDEX t_b_service_un_name (name);
;
ALTER TABLE t_b_service_region
    ADD UNIQUE INDEX t_b_service_region_un (service_id, region_name);
;
ALTER TABLE t_b_service_scope
    ADD UNIQUE INDEX t_b_service_scope_un (service_id, crm_no);
;
ALTER TABLE t_b_user_archives
    ADD UNIQUE INDEX t_b_user_archives_un_identity (identity),
    ADD UNIQUE INDEX t_b_user_archives_un_mobile_number (mobile_number);
;
ALTER TABLE t_b_user_archives_allocation
    ADD UNIQUE INDEX t_b_user_archives_allocation_un (crm_no, archives_id);
;
ALTER TABLE t_b_user_archives_supplier
    ADD UNIQUE INDEX t_b_user_archives_supplier_un (user_archives_id, supplier_id);
;

-- 2023-11-28
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('37', 'fxxk.user.query.url', '纷享销客查询人员对象的列表', 'https://open.fxiaoke.com/cgi/crm/v2/data/query', '1', '1', '1');

-- 2023-11-29
ALTER TABLE t_b_device_delivery
    ADD COLUMN delivery_type VARCHAR(20) NOT NULL COMMENT '发货类型（出入库类型）' AFTER express_photo_path,
    ADD COLUMN effect TINYINT NOT NULL COMMENT '有效的可操作的发货记录（当一个设备处于一个发货出入库生命周期时为有效）, 0: 无效，1: 有效' AFTER update_time;

ALTER TABLE t_b_device_delivery
    CHANGE COLUMN device_no serial_no VARCHAR(50) NOT NULL COMMENT '设备序列号' ;

-- 2023-11-29
ALTER TABLE sys_device_brand
    ADD UNIQUE INDEX sys_device_brand_un_brand (brand);
;
ALTER TABLE sys_device_model
    ADD UNIQUE INDEX sys_device_model_un (brand_id, model);
;
ALTER TABLE sys_device
    DROP INDEX sys_device_un_device_code ,
    ADD UNIQUE INDEX sys_device_un_serial_no (serial_no);
;

-- 2023-11-30
ALTER TABLE sys_supplier
    ADD UNIQUE INDEX sys_supplier_un_name (name);
;

ALTER TABLE sys_user
    ADD COLUMN supplier_id BIGINT NULL COMMENT '供应商id' AFTER source;

-- 2023-12-01
update t_b_device_in_out tbdio set device_no = (select serial_no from sys_device sd where tbdio.device_no = sd.device_code);

ALTER TABLE t_b_device_in_out
    CHANGE COLUMN device_no device_serial_no VARCHAR(50) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL COMMENT '设备序列号';

-- 2023-12-02
DELETE FROM sys_privilege WHERE (id = '3067');
UPDATE sys_privilege SET parent_id = '3053' WHERE (id = '3065');
UPDATE sys_privilege SET parent_id = '3053' WHERE (id = '3066');
UPDATE sys_privilege SET name = '设备发货保存接口' WHERE (id = '3065');
UPDATE sys_privilege SET id = '3072' WHERE (id = '3068');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3067', '设备发货列表分页查询', '/api/admin/device/delivery/page', 'URL', '3053', '3', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3068', '设备发货查询单个记录接口', '/api/admin/device/delivery/find/by/id', 'URL', '3053', '4', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3069', '设备发货导入', '/api/admin/device/delivery/import', 'URL', '3053', '5', 'AUTH', '1', '1', '0');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3070', '设备发货导出', '/api/admin/device/delivery/export', 'URL', '3053', '6', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '3067' WHERE (id = '3054');
UPDATE sys_privilege SET related = '3067' WHERE (id = '3055');
UPDATE sys_privilege SET related = '3069' WHERE (id = '3056');
UPDATE sys_privilege SET related = '3070' WHERE (id = '3057');
UPDATE sys_privilege SET related = '3066' WHERE (id = '3058');
UPDATE sys_privilege SET related = '3066' WHERE (id = '3059');
UPDATE sys_privilege SET related = '3066' WHERE (id = '3060');
UPDATE sys_privilege SET related = '3065,3068' WHERE (id = '3061');

-- 2023-12-07
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3071', '设备发货人列表查询', '/api/admin/device/delivery/delivery_user_list', 'URL', '3053', '7', 'AUTH', '1', '1', '0');
UPDATE sys_privilege SET related = '3067,3071' WHERE (id = '3055');
UPDATE sys_privilege SET related = '3067,3071' WHERE (id = '3054');

-- 2023-12-08
INSERT INTO sys_privilege (id, name, url, type, sequence, enable, default_auth, front_display) VALUES ('1100', '数据驾驶舱', 'dataCockpit', 'MENU', '12', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1101', '派单分析', 'crmAnalyse', 'MENU', '1100', '1', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1102', '服务单元分析', 'serviceAnalyse', 'MENU', '1100', '2', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1103', 'SOP预警监控', 'sopAnalyse', 'MENU', '1100', '3', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1104', '项目进度监控', 'sopSchedule', 'MENU', '1100', '4', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1105', '设备保障监控', 'deviceMonitor', 'MENU', '1100', '5', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, enable, default_auth, front_display) VALUES ('1106', '质量分析监控', 'qualityAnalyse', 'MENU', '1100', '6', '1', '0', '1');

-- 派单分析
UPDATE sys_privilege SET parent_id = '1101', sequence = '1', property = 'AUTH' WHERE (id = '1073');
UPDATE sys_privilege SET parent_id = '1101', sequence = '2', property = 'AUTH' WHERE (id = '1074');
UPDATE sys_privilege SET parent_id = '1101', sequence = '3', property = 'AUTH' WHERE (id = '1075');
UPDATE sys_privilege SET parent_id = '1101', sequence = '4', property = 'AUTH' WHERE (id = '1076');
UPDATE sys_privilege SET parent_id = '1101', sequence = '5', property = 'AUTH' WHERE (id = '1077');
UPDATE sys_privilege SET parent_id = '1101', sequence = '6', property = 'AUTH' WHERE (id = '1078');
UPDATE sys_privilege SET parent_id = '1101', sequence = '7', property = 'AUTH' WHERE (id = '1079');
UPDATE sys_privilege SET parent_id = '1101', sequence = '8', property = 'AUTH' WHERE (id = '1080');
UPDATE sys_privilege SET parent_id = '1101', sequence = '9', property = 'AUTH' WHERE (id = '1081');
UPDATE sys_privilege SET parent_id = '1101', sequence = '10', property = 'AUTH' WHERE (id = '1082');
UPDATE sys_privilege SET parent_id = '1101', sequence = '11', property = 'AUTH' WHERE (id = '1099');

-- 服务单元分析
UPDATE sys_privilege SET parent_id = '1102', sequence = '1', property = 'AUTH' WHERE (id = '1062');
UPDATE sys_privilege SET parent_id = '1102', sequence = '2', property = 'AUTH' WHERE (id = '1063');
UPDATE sys_privilege SET parent_id = '1102', sequence = '3', property = 'AUTH' WHERE (id = '1064');
UPDATE sys_privilege SET parent_id = '1102', sequence = '4', property = 'AUTH' WHERE (id = '1065');
UPDATE sys_privilege SET parent_id = '1102', sequence = '5', property = 'AUTH' WHERE (id = '1066');
UPDATE sys_privilege SET parent_id = '1102', sequence = '6', property = 'AUTH' WHERE (id = '1067');
UPDATE sys_privilege SET parent_id = '1102', sequence = '7', property = 'AUTH' WHERE (id = '1068');
UPDATE sys_privilege SET parent_id = '1102', sequence = '8', property = 'AUTH' WHERE (id = '1069');
UPDATE sys_privilege SET parent_id = '1102', sequence = '9', property = 'AUTH' WHERE (id = '1070');
UPDATE sys_privilege SET parent_id = '1102', sequence = '10', property = 'AUTH' WHERE (id = '1071');
UPDATE sys_privilege SET parent_id = '1102', sequence = '11', property = 'AUTH' WHERE (id = '1072');

-- sop预警监控
UPDATE sys_privilege SET parent_id = '1103', sequence = '1', property = 'AUTH' WHERE (id = '1057');
UPDATE sys_privilege SET parent_id = '1103', sequence = '2', property = 'AUTH' WHERE (id = '1058');
UPDATE sys_privilege SET parent_id = '1103', sequence = '3', property = 'AUTH' WHERE (id = '1059');
UPDATE sys_privilege SET parent_id = '1103', sequence = '4', property = 'AUTH' WHERE (id = '1060');
UPDATE sys_privilege SET parent_id = '1103', sequence = '5', property = 'AUTH' WHERE (id = '1061');

-- 项目进度监控
UPDATE sys_privilege SET parent_id = '1104', sequence = '1', property = 'AUTH' WHERE (id = '1094');
UPDATE sys_privilege SET parent_id = '1104', sequence = '2', property = 'AUTH' WHERE (id = '1095');
UPDATE sys_privilege SET parent_id = '1104', sequence = '3', property = 'AUTH' WHERE (id = '1097');

-- 设备保障监控
UPDATE sys_privilege SET parent_id = '1105', sequence = '1', property = 'AUTH' WHERE (id = '1090');
UPDATE sys_privilege SET parent_id = '1105', sequence = '2', property = 'AUTH' WHERE (id = '1091');
UPDATE sys_privilege SET parent_id = '1105', sequence = '3', property = 'AUTH' WHERE (id = '1092');
UPDATE sys_privilege SET parent_id = '1105', sequence = '4', property = 'AUTH' WHERE (id = '1093');

-- 质量分析监控
UPDATE sys_privilege SET parent_id = '1106', sequence = '1', property = 'AUTH' WHERE (id = '1083');
UPDATE sys_privilege SET parent_id = '1106', sequence = '2', property = 'AUTH' WHERE (id = '1084');
UPDATE sys_privilege SET parent_id = '1106', sequence = '3', property = 'AUTH' WHERE (id = '1085');
UPDATE sys_privilege SET parent_id = '1106', sequence = '4', property = 'AUTH' WHERE (id = '1086');
UPDATE sys_privilege SET parent_id = '1106', sequence = '5', property = 'AUTH' WHERE (id = '1087');
UPDATE sys_privilege SET parent_id = '1106', sequence = '6', property = 'AUTH' WHERE (id = '1088');
UPDATE sys_privilege SET parent_id = '1106', sequence = '7', property = 'AUTH' WHERE (id = '1089');

-- 绑定菜单url权限
UPDATE sys_privilege SET related = '1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1099' WHERE (id = '1101');
UPDATE sys_privilege SET related = '1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072' WHERE (id = '1102');
UPDATE sys_privilege SET related = '1057,1058,1059,1060,1061' WHERE (id = '1103');
UPDATE sys_privilege SET related = '1094,1095,1097' WHERE (id = '1104');
UPDATE sys_privilege SET related = '1090,1091,1092,1093' WHERE (id = '1105');
UPDATE sys_privilege SET related = '1083,1084,1085,1086,1087,1088,1089' WHERE (id = '1106');

-- 2023-12-13
INSERT INTO sys_config (id, config_key, config_name, config_value, enable, sort, create_id) VALUES ('38', 'rtzf.oss.login.url', '软通智服单点登录接口', 'https://qmth.echo-isoftstone.com/login', '1', '1', '1');

-- 2023-12-14
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('3076', '批量返还', 'BatchReturn', 'BUTTON', '3053', '5', 'AUTH', '3078,2035', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, related, enable, default_auth, front_display) VALUES ('3077', '返还', 'Return', 'LINK', '3053', '6', 'AUTH', '3078,2035', '1', '0', '1');
INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('3078', '设备发货可返还设备列表查询', '/api/admin/device/delivery/can_return_info', 'URL', '3053', '8', 'AUTH', '1', '1', '0');

UPDATE sys_device
SET
    scan_count = 0
WHERE
    scan_count IS NULL;
ALTER TABLE sys_device
    CHANGE COLUMN scan_count scan_count BIGINT NOT NULL DEFAULT 0 COMMENT '总扫描量' ;