

###权限
INSERT INTO `module` (`id`, `code`, `name`, `url`, `seq`, `index`, `shortcut`, `class`, `action`, `active`, `create_time`, `update_time`, `update_by`, `moduletype`, `p_id`)
VALUES ('190', 'supInsManagement', '监督检查情况管理', '', '1', '\0', '\0', '', '', '', now(), now(), 'system', '1', '122'),
('191', 'companyInspectionList', '保安服务公司监督检查', '', '1', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('192', 'companyAwardList', '保安服务公司表彰奖励', '', '2', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('193', 'companyPunishList', '保安服务公司违法违规处罚', '', '3', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('194', 'companyComplaintList', '保安服务公司投诉信息', '', '4', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),

('195', 'conCompanyInspectionList', '自招保安员单位监督检查', '', '5', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('196', 'conCompanyAwardList', '自招保安员单位表彰奖励', '', '6', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('197', 'conCompanyPunishList', '自招保安员单位违法违规处罚', '', '7', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('198', 'conCompanyComplaintList', '自招保安员单位投诉信息', '', '8', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),

('199', 'trainCompanyInspectionList', '保安培训单位监督检查', '', '9', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('200', 'trainCompanyAwardList', '保安培训单位表彰奖励', '', '10', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('201', 'trainCompanyPunishList', '保安培训单位违法违规处罚', '', '11', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('202', 'trainCompanyComplaintList', '保安培训单位投诉信息', '', '12', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),

('203', 'personAwardList', '保安员表彰奖励', '', '13', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('204', 'personPunishList', '保安员违法违规处罚', '', '14', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190'),
('205', 'personComplaintList', '保安员投诉信息', '', '15', '\0', '\0', '', '', '', now(), now(), 'system', '1', '190');


INSERT INTO `operation` (`code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`)
SELECT 'query', '查询', id, '', now(), now(), 'system'
FROM module WHERE P_ID=190;


INSERT INTO `operation` (`code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`)
SELECT 'add', '新增', id, '', now(), now(), 'system'
FROM module WHERE P_ID=190;


INSERT INTO `operation` (`code`, `name`, `module_id`, `active`, `create_time`, `update_time`, `update_by`)
SELECT 'edit', '修改', id, '', now(), now(), 'system'
FROM module WHERE P_ID=190;

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,module m
where pr.active=true
and p.active=TRUE
and o.active=TRUE
and pr.orgid=p.id
and o.module_id=m.id
and m.p_id=190;

##外网权限删除
DELETE from permission where id in (
select t.id from (select p.id from module m, config c,permission p where (m.p_id = 190 or m.id=190)
AND c.active = TRUE
AND c.`key` = 'police'
AND c.`value` = '0'
and p.module_id=m.id)t
);


##外网权限删除
DELETE from operation where id in (
select t.id from (
select p.id from module m, config c,operation p where (m.p_id = 190 or m.id=190)
AND c.active = TRUE
AND c.`key` = 'police'
AND c.`value` = '0'
and p.module_id=m.id)t
);

##外网权限删除
delete FROM module where id in (
select t.id from (
select m.id from module m, config c WHERE (m.p_id = 190 or m.id=190)
AND c.active = TRUE
AND c.`key` = 'police'
AND c.`value` = '0')t
);