

delete from module where `code`='certificatePrintLogManager' and id=302;
delete from operation where module_id=302;

delete from module where `code`='companyOutTimePerson' and id=180;
delete from operation where module_id=180;

delete from module where `code`='companyPerson' and id=179;
delete from operation where module_id=179;

UPDATE `module` SET `active`=FALSE WHERE (`id`='65');

delete FROM module where id=215;
delete FROM operation where id=427 and `code`='uploadImg';
update operation set module_id=206 where module_id=215;

delete from `module` where `code`='PermitRecordManager';
INSERT INTO `module` (`id`, `native_code`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('319', '11', 'PermitRecordManager', '许可备案管理', '', '6', '\0', '\0', '', '', '', now(), now(), 'system', '1', '122');

delete from `module` where `code`='equipmentCarManager';
INSERT INTO `module` (`id`, `native_code`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('320', '11', 'equipmentCarManager', '设备车辆管理', '', '6', '\0', '\0', '', '', '', now(), now(), 'system', '1', '142');


UPDATE `module` SET `p_id`='320' WHERE `id` in (315,314,316);

update module set active=FALSE,seq=60 where `code`='dataCount' AND moduletype = 1;
update module set active=FALSE,seq=80 where `code`='proposal' AND moduletype = 1;
update module set active=FALSE,seq=80 where `code`='complaintInfo' AND moduletype = 1;

-- 首页
update module set seq=1 where `code`='homePage' AND moduletype = 1;
-- 综合态势大屏
-- 待办事项
update module set seq=2,active=true where `code`='needToDo' AND moduletype = 1;
-- 预警
update module set seq=3 where `code`='ContrastWarning' AND moduletype = 1;
-- 保安员资格证管理
update module set seq=4 where `code`='SecurityPersonCertificatManagement' AND moduletype = 1;
-- 保安员等级证考试报名
update module set seq=5,p_id=122 where `code`='personGradeManager' AND moduletype = 1;
-- 许可备案管理
update module set seq=6 where `code`='PermitRecordManager' AND moduletype = 1;
-- 许可管理
update module set seq=1,p_id=319 where `code`='permit' AND moduletype = 1;
-- 备案管理
update module set seq=2,p_id=319 where `code`='keepOnRecord' AND moduletype = 1;
-- 变更管理
update module set seq=3,p_id=319 where `code`='change' AND moduletype = 1;
-- 监督检查情况管理
update module set seq=7 where `code`='supInsManagement' AND moduletype = 1;
-- 行业信息
update module set seq=8 where `code`='industry' AND moduletype = 1;
-- 会议管理
-- 工作部署
update module set seq=10,`name`='工作部署' where `code`='news' AND moduletype = 1;
update module set `name`='企业消息通知' where `code`='newNotify' AND moduletype = 1;
-- 旧系统数据查询
-- 系统管理
update module set seq=11 where `code`='systemConfig' AND moduletype = 1;
-- 超管配置


update module set p_id=210 where `name`='劳动合同' and moduletype=1;
update module set p_id=175 where `name`='问题人员' and moduletype=1;


UPDATE `operation` SET `active`=FALSE WHERE (`id`='218')AND `code`='personCertificate';
UPDATE `operation` SET `active`=FALSE WHERE (`id`='221')AND `code`='personCertificateStatistics';


UPDATE `module` SET `seq`='10' WHERE `id`=178;
UPDATE `module` SET `seq`='30' WHERE (`id`='184');
UPDATE `module` SET `seq`='40' WHERE (`id`='187');
UPDATE `module` SET `seq`='50' WHERE (`id`='208');
UPDATE `module` SET `seq`='60' WHERE (`id`='210');
UPDATE `module` SET `seq`='70' WHERE (`id`='320');
UPDATE `module` SET `seq`='80' WHERE (`id`='64');
UPDATE `module` SET `seq`='90' WHERE (`id`='112');
UPDATE `module` SET `seq`='100' WHERE (`id`='146');
UPDATE `module` SET `seq`='110' WHERE (`id`='206');
UPDATE `module` SET `seq`='120' WHERE (`id`='207');

UPDATE `module` SET `p_id`='313' WHERE (`id`='311');
UPDATE `module` SET `p_id`='313' WHERE (`id`='312');
UPDATE `module` SET active=FALSE WHERE (`id`='318');
UPDATE `module` SET `p_id`='166' WHERE (`id`='317');
UPDATE `module` SET `p_id`='177' WHERE (`id`='301');
UPDATE `module` SET `p_id`='175' WHERE (`id`='176');

UPDATE `module` SET `seq`='20' WHERE (`id`='311');
UPDATE `module` SET `seq`='20' WHERE (`id`='134');
UPDATE `module` SET `seq`='30' WHERE (`id`='135');
UPDATE `module` SET `seq`='40' WHERE (`id`='301');
UPDATE `module` SET `seq`='30' WHERE (`id`='400');

UPDATE `module` SET `seq`='10' WHERE (`id`='75');
UPDATE `module` SET `seq`='20' WHERE (`id`='77');
UPDATE `module` SET `seq`='30' WHERE (`id`='76');

UPDATE `module` SET `seq`='10' WHERE (`id`='165');
UPDATE `module` SET `seq`='20' WHERE (`id`='317');

UPDATE `module` SET `seq`='10' WHERE (`id`='111');
UPDATE `module` SET `seq`='20' WHERE (`id`='176');
UPDATE `module` SET `seq`='10' WHERE (`id`='312');

UPDATE `module` SET `name`='预警' WHERE (`id`='175');



delete from `module` where `code`='professionalLevelManager';
INSERT INTO `module` (`id`, `native_code`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('321', '11', 'professionalLevelManager', '保安员职业技能等级管理', '', '5', '\0', '\0', '', '', '', now(), now(), 'system', '1', '122');

delete from `module` where `code`='fiveLevelManager';
INSERT INTO `module` (`id`, `native_code`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('322', '11', 'fiveLevelManager', '五级保安员等级考试管理', '', '5', '\0', '\0', '', '', '', now(), now(), 'system', '1', '321');

UPDATE `module` SET `name`='五级保安员报名信息', `p_id`='322' WHERE (`id`='313');
UPDATE `module` SET `name`='五级保安员实习信息',`p_id`='322',active=false WHERE (`id`='311');
UPDATE `module` SET `name`='班级信息管理',`p_id`='322' WHERE (`id`='312');

UPDATE `module` SET `p_id`='321' WHERE (`id`='146');

-- INSERT INTO `operation` (`native_code`, `code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`) VALUES ('11', 'toQueryPage', '进入查询页面', '313', '', now(), now(), 'system');
-- INSERT INTO `operation` (`native_code`, `code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`) VALUES ('11', 'query', '查询', '313', '', now(), now(), 'system');
-- INSERT INTO `operation` (`native_code`, `code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`) VALUES ('11', 'export', '导出', '313', '', now(), now(), 'system');
-- INSERT INTO `operation` (`native_code`, `code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`) VALUES ('11', 'view', '查看', '313', '', now(), now(), 'system');



UPDATE `module` SET `seq`='10' WHERE (`id`='114');
UPDATE `module` SET `seq`='20' WHERE (`id`='130');
UPDATE `module` SET `seq`='30' WHERE (`id`='67');
UPDATE `module` SET `seq`='40' WHERE (`id`='131');


UPDATE `module` SET `seq`='10' WHERE (`id`='68');
UPDATE `module` SET `seq`='20' WHERE (`id`='70');
UPDATE `module` SET `seq`='30' WHERE (`id`='69');
UPDATE `module` SET `seq`='40' WHERE (`id`='74');

UPDATE `module` SET `seq`='10' WHERE (`id`='71');
UPDATE `module` SET `seq`='20' WHERE (`id`='140');
UPDATE `module` SET `seq`='30' WHERE (`id`='141');

UPDATE `module` SET `active`=FALSE WHERE (`id`='183');
UPDATE `module` SET `active`=FALSE WHERE (`id`='186');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='183');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='186');


UPDATE `module` SET `active`=FALSE WHERE (`id`='182');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='182');
UPDATE `module` SET `active`=FALSE WHERE (`id`='185');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='185');


delete from `module` where `code`='supInsComManagement';
delete from `module` where `code`='supInsTrainComManagement';
delete from `module` where `code`='supInsConComManagement';
delete from `module` where `code`='supInsPerManagement';
INSERT INTO `module` (`id`, `native_code`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('323', '11', 'supInsComManagement', '保安服务公司监督检查', '', '10', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
 ('324', '11', 'supInsTrainComManagement', '保安培训单位监督检查', '', '20', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
 ('325', '11', 'supInsConComManagement', '自招保安员单位监督检查', '', '30', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
 ('326', '11', 'supInsPerManagement', '保安员监督检查', '', '40', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190');

update module set p_id=323 where id in ('191','192','193','194');
update module set p_id=324 where id in ('199','200','201','202');
update module set p_id=325 where id in ('195','196','197','198');
update module set p_id=326 where id in ('203','204','205');
update module set seq=50 where id =400;

UPDATE `module` SET `name`='劳动/劳务合同' WHERE (`id`='212');
UPDATE `module` SET `active`=FALSE WHERE (`id`='213');
UPDATE `module` SET `active`=FALSE WHERE (`id`='214');

UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='213');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='214');


UPDATE `operation` SET `name`='处理' WHERE `code`='dispose' and module_id=111;
UPDATE `operation` SET `name`='审批' WHERE `code`='saveAppealApproval' and module_id=312;

UPDATE `module` SET `active`=FALSE WHERE (`id`='188');
UPDATE `operation` SET `active`=FALSE WHERE (`module_id`='188');
UPDATE `module` SET `name`='保安员信息' WHERE (`id`='110');

UPDATE `operation` SET `name`='搜索' WHERE `code`='search' and module_id=119;

update police_role set orgid=2000 where id=1001;


INSERT INTO `police_role` ( id,`active`, `create_time`, `update_time`, `update_by`, `creater`, `createrorg`, `rolename`, `roledesc`, `oprole`, `datarole`, `orgname`, `orgid`, `usernum`, `authtype`, `roletype`, `policeRoleType`, `updateflag`)
VALUES (1045,'', now(), now(), 'bj_super', '系统超级管理员', '北京市', '保安总公司', NULL, NULL, NULL, '保安总公司', '1000', '1', NULL, NULL, NULL, '\0');

update `user_role` set roleid=1045 where USERID =2 and roleid=601;

DELETE from permission where module_id in (311,312,313,146);

INSERT INTO`permission` (`role_id`, `module_id`, `operation_id`, `roletype`)
select pr.id,o.module_id,o.id,'2' from police_role pr,police p,operation o
where pr.active=true
and p.active=TRUE
and o.active=TRUE
and pr.orgid=p.id
and o.module_id not in (311,312,313,146)
and not EXISTS(
select 1 from permission pm where roletype =2 and pm.role_id = pr.id and pm.module_id=o.module_id and pm.operation_id=o.id
);

INSERT INTO`permission` (`role_id`, `module_id`, `operation_id`, `roletype`)
select pr.id,o.module_id,o.id,'2' from police_role pr,police p,operation o
where pr.active=true
and p.active=TRUE
and o.active=TRUE
and pr.orgid=p.id
and o.module_id in (311,312,313,146)
and p.id=1
and not EXISTS(
select 1 from permission pm where roletype =2 and pm.role_id = pr.id and pm.module_id=o.module_id and pm.operation_id=o.id
);

update user_role t1,police_role t2,`user` t3
set t1.active=FALSE
where t1.active=true and t2.active=TRUE and t3.active=TRUE and t3.platform=1
and t1.roleid=t2.id and t1.USERID=t3.id and t2.orgid != t3.orgid;


UPDATE `module` SET `name`='枪支信息管理' WHERE (`id`='314');
UPDATE `module` SET `name`='车辆信息管理' WHERE (`id`='315');
UPDATE `module` SET `name`='监督检查管理' WHERE (`id`='190');
UPDATE `module` SET `name`='行业信息管理' WHERE (`id`='142');





