# KPI综合管理系统 ```Project |—— api └── version1 └── empower |—— apirouter |—— initialization └── database └── nosql └── app └── route |identification |—— config └── configDatabase └── configNosql └── configAapp └── configJson |—— models |—— overall |—— middleware ``` ## Hr 文件结构说明 | 文件夹 | 说明 | 描述| |--------- |------ |-----| | `api` | api相关业务 | api业务实现 | | `--version1` | 业务版本文件夹 | 版本界定 | | `--empower` |OAuth 2.0 授权 |授权Token| | `apirouter` | 路由器 | 业务路由设定 | | `initialization` | 初始化相关业务 | 系统初始化方面的实现 | | `--database` | 数据库业务 | 数据库业务初始化实现 | | `--nosql` | nosql数据库业务 | nosql业务初始化实现(例:Redis) | | `--app` | app数据库业务 | app业务初始化实现 | | `--route` | 路由初始化 | 路由初始化 | | `identification` | 授权验证器 | 授权验证器 | | `config` | 系统配置相关业务 | 系统系统配置方面的实现 | | `--configDatabase` | 数据库业务 | 数据库业务系统配置实现 | | `--configNosql` | nosql数据库业务 | nosql业务系统配置实现(例:Redis) | | `--configAapp` | app系统业务 | app业务系统配置实现 | | `--configJson` | app JSON业务 | app业务系统配置实现 | | `models` | 数据模型 | 数据库方面的配置 | | `overall` | 全局对象 | 全局对象| | `middleware` | 中间件 | 中间件 | ## 加密规则 ``` 1、分解步骤 one = md5(CodeString)+md5(AppKey) two = md5(one)+AppKey therr = md5(two) 2、合并 md5(md5(md5(CodeString)+md5(AppKey))+AppKey) ``` ## 企业微信按钮key定义 KPI_post_OrderId_1_1 或 KPI_post_OrderId_2_1 |系统 |类别 |审批流ID|操作|步进器| |---------|---------|---------|---------|---------| | KPI | post | OrderId | 1:批准;2:驳回 | 当前步进位 | | KPI | department | OrderId | 1:批准;2:驳回 | 当前步进位 | ## 开发日志 ``` Time:2022-08-10 绩效考核数据库添加数据表 CREATE TABLE `depart_dime_post_weight` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `orgid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '行政组织', `postid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位', `dimension` bigint(20) NOT NULL COMMENT '维度', `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', `weight` bigint(6) unsigned NOT NULL DEFAULT '0' COMMENT '权重', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1:定性考核;2:定量考核', `hierarchy` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1:维度;2:指标', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM AUTO_INCREMENT=424 DEFAULT CHARSET=utf8mb4 COMMENT='岗位考核指标权重'; 添加 model 文件 路径 models->modelskpi depart_dime_post_weight.go ``` ``` Time:2022-08-10 绩效考核数据库添加<指标、栏目、细则关联部门>数据表 CREATE TABLE `target_department` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `target_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标ID', `target_sun_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '子目标', `target_bylaws` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型(1:指标;2:子目标)', `department_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '部门ID', `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位ID', `report_person` longtext COMMENT '上报人', `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用;3:删除)', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '写入时间', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='指标、栏目、细则关联部门'; 添加 model 文件 路径 models->modelskpi target_department.go ``` ``` Time:2022-08-12 指标部门、岗位上报人对照表 CREATE TABLE `target_report` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `target_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标ID', `target_sun_id` bigint(20) unsigned NOT NULL COMMENT '子目标', `target_bylaws` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', `department_id` bigint(20) unsigned DEFAULT '0' COMMENT '部门ID', `post_id` bigint(20) unsigned DEFAULT '0' COMMENT '岗位ID', `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型(1:公司级;2:部门级)', `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用;3:删除)', `man_key` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '提报人ID', `time` bigint(20) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='指标、子栏目、细则部门、岗位上报人对照表'; ``` ``` Time:2022-08-16 创建子栏目关联指标视图 son_target_father select `qt`.`q_id` AS `q_id`,`qt`.`q_title` AS `q_title`,`qt`.`q_parent_id` AS `q_parent_id`,`qt`.`q_state` AS `q_state`,`qt`.`q_time` AS `q_time`,`qt`.`q_depart` AS `q_depart`,`et`.`et_title` AS `et_title`,`et`.`et_type` AS `et_type`,`et`.`et_dimension` AS `et_dimension`,`et`.`et_key` AS `et_key`,`et`.`et_unit` AS `et_unit`,`et`.`et_cycle` AS `et_cycle`,`et`.`et_cycleattr` AS `et_cycleattr`,`et`.`et_scoring_method` AS `et_scoring_method` from (`qualitative_target` `qt` left join `evaluationtarget` `et` on((`qt`.`q_parent_id` = `et`.`et_id`))) ``` 创建用户与职务、岗位关联视图 user_post_duties (HR数据库) ``` select `pc`.`mobilephone` AS `mobilephone`,`pc`.`gender` AS `gender`,`ps`.`name` AS `postname`,`ps`.`person_in_charge` AS `leading_cadre`,`ps`.`superior` AS `post_superior`,`ps`.`menu_permit` AS `menu_permit`,`ps`.`button_permit` AS `button_permit`,`pd`.`name` AS `duties_name`,`pa`.`id` AS `id`,`pa`.`number` AS `number`,`pa`.`name` AS `name`,`pa`.`icon` AS `icon`,`pa`.`company` AS `company`,`pa`.`maindeparment` AS `maindeparment`,`pa`.`admin_org` AS `admin_org`,`pa`.`position` AS `position`,`pa`.`job_id` AS `job_id`,`pa`.`job_leve` AS `job_leve`,`pa`.`wechat` AS `wechat`,`pa`.`work_wechat` AS `work_wechat`,`pa`.`is_admin` AS `is_admin`,`pa`.`key` AS `key`,`pa`.`role` AS `role`,`pa`.`password` AS `password`,`pa`.`sun_main_deparment` AS `sun_main_deparment`,`pa`.`teamid` AS `teamid` from (((`person_archives` `pa` join `personnel_content` `pc` on((`pa`.`key` = `pc`.`key`))) join `position` `ps` on((`pa`.`position` = `ps`.`id`))) join `duties` `pd` on((`pa`.`job_id` = `pd`.`id`))) ``` Time:2022-08-16
埋坑(1) 待以后编写相应模块 PS:该问题解决后删除此记录
``` F:\goobject\src\key_performance_indicators\api\version1\departmentseting\departmentpc\qualitativekpi.go 函数 DelSonTarget 文件 第 1138 行 预留判断该指标是否在使用中 ``` Time:2022-08-24
数据库增加考核项目与提报人关联视图
``` select `qes`.`id` AS `id`,`qes`.`version_number` AS `version_number`,`qes`.`company_id` AS `company_id`,`qes`.`department_id` AS `department_id`,`qes`.`org_id` AS `org_id`,`qes`.`post_id` AS `post_id`,`qes`.`title` AS `title`,`qes`.`dimension_id` AS `dimension_id`,`qes`.`target_id` AS `target_id`,`qes`.`son_target_id` AS `son_target_id`,`qes`.`details_id` AS `details_id`,`qes`.`attribute` AS `attribute`,`qes`.`min_score` AS `min_score`,`qes`.`max_score` AS `max_score`,`qes`.`scoring_method` AS `scoring_method`,`qes`.`state` AS `state`,`qes`.`addtime` AS `addtime`,`qes`.`eitetime` AS `eitetime`,`qes`.`censor_type` AS `censor_type`,`qes`.`source` AS `source`,`qes`.`run_state` AS `run_state`,`tr`.`type` AS `tr_type`,`tr`.`man_key` AS `man_key`,`tr`.`man_department` AS `man_department`,`tr`.`class` AS `tr_class`,`tr`.`type_level` AS `tr_level` from (`qualitative_evaluation_scheme` `qes` join `target_report` `tr` on(((`qes`.`dimension_id` = `tr`.`dimension_id`) and (`qes`.`target_id` = `tr`.`target_id`) and (`qes`.`son_target_id` = `tr`.`target_sun_id`) and (`qes`.`details_id` = `tr`.`target_bylaws`) and (`qes`.`post_id` = `tr`.`post_id`) and (`qes`.`org_id` = `tr`.`department_id`)))) ``` Time:2022-08-29
数据库增加 岗位审批工作流 数据表
``` CREATE TABLE `post_workflow_orders` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '审批单ID', `step` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '当前执行到第几步', `next_step` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '下一步执行哪个步骤', `work_flow` longtext COMMENT '工作流(审批json字符串)', `company_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '公司', `department_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '部门', `org_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '行政组织', `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位', `class` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '属性1、定性;2、定量', `dimension` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '维度', `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', `son_target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标子栏目', `detailed` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', `executor` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人', `executor_department` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人部门', `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '流程状态 1:草稿;2:驳回;3:审批中;4:归档;5:废弃;6:删除', `start_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程开始时间', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', `enclosure_format` longtext COMMENT '附件', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='岗位审批工作流'; ``` Time:2022-08-29
数据库增加 定性考核流水 数据表
``` CREATE TABLE `post_nature_flow` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '审批单ID同时也是订单ID', `add_or_decrease` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '增加或减少(1:增加;2:减少)', `score` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '分值(*100保存)', `money` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '钱(扣款或奖励)*100保存', `reason` text COMMENT '这样操作的原因', `sheme_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '方案ID', `sheme_version` varchar(255) NOT NULL DEFAULT '' COMMENT '方案版本', `dimension` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '维度', `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', `son_target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标子栏目', `detailed` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标细则', `year` int(7) unsigned NOT NULL DEFAULT '0' COMMENT '年', `quarter` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '季度', `month` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '月', `week` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '周', `person_liable` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '责任人', `company_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '公司', `department_id` bigint(20) NOT NULL COMMENT '部门', `org_id` bigint(20) NOT NULL COMMENT '行政组织', `post_id` bigint(20) NOT NULL COMMENT '岗位', `executor` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人', `executor_department` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人部门', `rectification` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否需要整改 1、需要整改;2:无需整改', `correction_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '整改期限', `happen_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '发生时间', `happen_count` int(7) unsigned NOT NULL DEFAULT '1' COMMENT '发生次数', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='定性考核流水'; ``` Time:2022-08-29
数据库增加 岗位定量考核流水 数据表
``` CREATE TABLE `post_metering_flow` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '审批单ID同时也是订单ID', `sheme_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '方案ID', `sheme_version` varchar(255) NOT NULL DEFAULT '' COMMENT '方案版本号', `dimension` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '维度', `target` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '指标', `score` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '实际值', `reason` text COMMENT '这样操作的原因', `year` int(7) unsigned NOT NULL DEFAULT '0' COMMENT '年', `quarter` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '季度', `month` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '月', `week` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '周', `person_liable` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '责任人', `company_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '公司', `department_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '部门', `org_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '行政组织', `post_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '岗位', `executor` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人', `executor_department` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '执行人部门', `happen_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '发生时间', `baseline` text COMMENT '基准线', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='岗位定量考核流水'; ``` Time:2022-09-04
增加权限配置管理相关模块
## database.yaml添加权限数据库配置 ``` 1、文件地址:config\configDatabase\database.yaml 2、系统权限配置数据库 systemPermission: url_path: '127.0.0.1' #数据库地址 port: 3306 #数据库端口 charset: 'utf8mb4' #数据库编码方式 parseTime: 'True' #是否自动转换时间 loc: 'Local' #时区 name: 'system_permission' #数据库名称 username: 'root' #数据库用户民 password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量 max_open_conns: 1500 #最大打开数量 gorm_log: true #是否开启gorm日志 ``` ## 增加系统权限系统参数 1、config\configDatabase\database.go SystemPermission MasterMysqlSetUp `mapstructure:"systempermission" json:"systempermission" yaml:"systempermission"` //系统权限配置数据库 2、overall\appConfig.go CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 3、initialization\databaseinit\mysql.go ``` //系统权限配置数据库 overall.CONSTANT_DB_System_Permission = sqlConfig.SystemPermission.OpenSql() if overall.CONSTANT_DB_System_Permission == nil { fmt.Printf("%v数据库开启失败!\n", sqlConfig.SystemPermission.Name) } else { fmt.Printf("%v数据库开启成功!\n", sqlConfig.SystemPermission.Name) } ``` ## 增加仓储系统参数 1、config\configDatabase\database.go Storage MasterMysqlSetUp `mapstructure:"storage" json:"storage" yaml:"storage"` //仓储系统数据库 2、overall\appConfig.go CONSTANT_DB_Storage *gorm.DB //仓储系统数据库 3、initialization\databaseinit\mysql.go ``` //仓储系统 overall.CONSTANT_DB_Storage = sqlConfig.Storage.OpenSql() if overall.CONSTANT_DB_Storage == nil { fmt.Printf("%v数据库开启失败!\n", sqlConfig.Storage.Name) } else { fmt.Printf("%v数据库开启成功!\n", sqlConfig.Storage.Name) } ``` Time:2022-09-07
数据库增加 应用系统 数据表
``` CREATE TABLE `appsystem` ( `id` bigint(20) unsigned NOT NULL, `title` varchar(255) DEFAULT '' COMMENT '系统名称', `coder` varchar(255) NOT NULL DEFAULT '' COMMENT '识别符', `state` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用;2:禁用:3:删除)', `time` bigint(20) unsigned NOT NULL DEFAULT '0', `sort` int(5) unsigned NOT NULL DEFAULT '50' COMMENT '排序', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='应用系统'; ``` Time:2022-10-05
数据库增加 审批记录 数据表
``` CREATE TABLE `open_approval_change_log` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `type` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '类型(1:部门;2:岗位)', `title` varchar(255) DEFAULT '' COMMENT '节点名称', `operator` varchar(255) NOT NULL DEFAULT '' COMMENT '操作人', `orderid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID', `operatortime` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间', `step` int(5) unsigned NOT NULL DEFAULT '1' COMMENT '操作第几步', `operatortype` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '操作状态', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='审批记录'; ``` Time:2022-10-05
数据库增加 当前节点是否可操作 数据表
``` CREATE TABLE `operator_is_true` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `orderid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID', `step` int(5) unsigned NOT NULL DEFAULT '1' COMMENT '审批到第几步', `state` int(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:1:可操作;2:不可操作', `time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '时间', `msgid` varchar(255) DEFAULT '' COMMENT '消息id,用于撤回应用消息', `response_code` varchar(255) DEFAULT '' COMMENT '仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,24小时内有效,且只能使用一次', `stepper` int(5) unsigned NOT NULL DEFAULT '1' COMMENT '步进器', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='当前节点是否可操作'; ```