From 65e6736b8cd2c2353a984b92606271b460778791 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 28 Jun 2024 09:57:29 +0800 Subject: [PATCH] =?UTF-8?q?ADD-=E5=88=9D=E5=A7=8B=E5=8C=96=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=A7=86=E5=9B=BESQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/InitRecruitDataServiceImpl.java | 106 +++++++----------- 1 file changed, 42 insertions(+), 64 deletions(-) diff --git a/src/com/engine/recruit/service/impl/InitRecruitDataServiceImpl.java b/src/com/engine/recruit/service/impl/InitRecruitDataServiceImpl.java index 3461f64..932025b 100644 --- a/src/com/engine/recruit/service/impl/InitRecruitDataServiceImpl.java +++ b/src/com/engine/recruit/service/impl/InitRecruitDataServiceImpl.java @@ -4,17 +4,17 @@ import com.engine.core.impl.Service; import com.engine.recruit.conn.ApplicantCommonInfo; import com.engine.recruit.conn.RecruitDataMap; import com.engine.recruit.conn.RecruitRecordSet; -import com.engine.recruit.constant.ModeSearchCodeConstant; -import com.engine.recruit.constant.ModeTreeCodeConstant; import com.engine.recruit.entity.init.po.*; import com.engine.recruit.exception.CustomizeRunTimeException; import com.engine.recruit.service.InitRecruitDataService; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.formmode.recruit.modeexpand.process.StageDataInsert; -import weaver.general.BaseBean; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -27,6 +27,9 @@ public class InitRecruitDataServiceImpl extends Service implements InitRecruitDa public Map checkInitStatus() { RecordSet rs = new RecordSet(); + // 创建视图 + createView(rs); + rs.executeQuery("select id from uf_jcl_zplc"); if (rs.next()) { throw new CustomizeRunTimeException("当前已存在招聘流程数据,无需重复初始化"); @@ -42,11 +45,6 @@ public class InitRecruitDataServiceImpl extends Service implements InitRecruitDa rs.executeUpdate("delete from uf_jcl_zpjdsz_dt1;"); rs.executeUpdate("delete from uf_jcl_zpjdsz_dt2;"); rs.executeUpdate("delete from uf_jcl_lcczan;"); - // 刷新页面菜单 - rs.executeQuery("select * from hp_nonstandard_function_info where num='163' and name ='招聘管理'"); - if (rs.next()) { - refreshMenuUrl(); - } // 插入操作按钮数据, int buttonModeId = ApplicantCommonInfo.getModeIdByTableName("uf_jcl_lcczan"); @@ -68,63 +66,43 @@ public class InitRecruitDataServiceImpl extends Service implements InitRecruitDa /** - * 更新招聘管理相关菜单地址 + * 创建视图:v_zpmc + * + * @param rs */ - private void refreshMenuUrl() { - - List menuSqlList = new ArrayList<>(); - // 招聘需求 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RECRUITMENT_DEMAND_MANAGEMENT) + "' where id = " + 100189); - // 招聘职位 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RECRUITMENT_POSITIONS) + "' where id = " + 100190); - // 应聘者 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.APPLICANTS) + "' where id = " + 100192); - // 部门筛选 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.SCREENING_FEEDBACK) + "' where id = " + 100193); - // 笔试 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.WRITTEN_RESULTS) + "' where id = " + 100194); - // 面试 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.INTERVIEW) + "' where id = " + 100195); - // 薪酬谈判 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.SALARY_NEGOTIATION) + "' where id = " + 100196); - // 背调 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.BACK_TONE) + "' where id = " + 100197); - // offer - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.OFFER) + "' where id = " + 100198); - // 人才库 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.TALENT_POOL) + "' where id = " + 100200); - // 简历库 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RESUME_LIBRARY) + "' where id = " + 100201); - // 工作地点 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.WORK_LOCATION) + "' where id = " + 100203); - // 字段类型名称 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.DATA_DICTIONARY_TYPE_NAME) + "' where id = " + 100205); - // 邮件通知模板 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.EMAIL_NOTIFICATION_TEMPLATE) + "' where id = " + 100206); - // 千里聆邮箱配置 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.QLL_EMAIL_CONFIG) + "' where id = " + 100207); - // 招聘需求 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RECRUITMENT_DEMAND_MANAGEMENT) + "' where id = " + 100209); - // 我的筛选 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.SCREENING_FEEDBACK) + "' where id = " + 100210); - // 我的面试 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.PARTICIPATE_IN_INTERVIEWS) + "' where id = " + 100211); - // 招聘流程 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RECRUITMENT_PROCESS_LIST) + "' where id = " + 100213); - // 招聘阶段 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.RECRUITMENT_STAGE_LIST) + "' where id = " + 100214); - // 操作按钮 - menuSqlList.add("update LeftMenuInfo set fullrouteurl = '/spa/cube/index.html#/main/cube/search?customid=" + getCustomSearchId(ModeSearchCodeConstant.LIST_OF_OPERATION_BUTTONS) + "' where id = " + 100215); - // 入职管理 - menuSqlList.add("update LeftMenuInfo set fullrouteurl= '/spa/cube/index.html#/main/cube/viewCustomPage?id=" + getCustomPageId("入职管理", ModeSearchCodeConstant.ENTRY_MANAGEMENT) + "&noTitleShow=1' where id = " + 100199); - // 数据字典 - menuSqlList.add("update LeftMenuInfo set fullrouteurl= '/spa/cube/index.html#/main/cube/tree?id=" + getCustomTreeId(ModeTreeCodeConstant.DATA_DICTIONARY_TREE) + "&noTitleShow=1' where id = " + 100204); - - RecordSet rs = new RecordSet(); - for (String sql : menuSqlList) { - new BaseBean().writeLog("招聘目录初始化SQL:==" + sql); - rs.executeUpdate(sql); + private void createView(RecordSet rs) { + String dbType = rs.getDBType(); + String sql = ""; + switch (dbType) { + case "oracle": + sql = "CREATE OR REPLACE VIEW v_zpmc AS SELECT a.id, a.zpzwmc, b.cnt, a.zpzwmc || '(' || b.cnt || ')' AS fname FROM uf_jcl_zp_zpzw a INNER JOIN ( SELECT ypzw, COUNT(*) AS cnt FROM uf_jcl_yppc WHERE zt = 1 GROUP BY ypzw ) b ON a.id = b.ypzw"; + break; + case "sqlserver": + sql = "CREATE VIEW v_zpmc AS SELECT a.id, a.zpzwmc, b.cnt, a.zpzwmc + '(' + CAST(b.cnt AS VARCHAR) + ')' AS fname FROM uf_jcl_zp_zpzw a INNER JOIN ( SELECT ypzw, COUNT(*) AS cnt FROM uf_jcl_yppc WHERE zt = 1 GROUP BY ypzw ) b ON a.id = b.ypzw"; + break; + case "mysql": + sql = "create or replace view v_zpmc as select a.id, a.zpzwmc, b.cnt, CONCAT(a.zpzwmc, '(', b.cnt, ')') as fname from uf_jcl_zp_zpzw a inner join ( select ypzw, count(*) cnt from uf_jcl_yppc where zt = 1 group by ypzw) b on a.id = b.ypzw"; + break; + case "postgresql": + sql = "create or replace view v_zpmc as select a.id, a.zpzwmc, b.cnt, CONCAT(a.zpzwmc, '(', b.cnt, ')') as fname from uf_jcl_zp_zpzw a inner join ( select ypzw, count(*) cnt from uf_jcl_yppc where zt = 1 group by ypzw) b on a.id = b.ypzw"; + break; + default: + break; } + if (StringUtils.isBlank(sql)) { + throw new CustomizeRunTimeException("暂未支持当前数据库,DB类型[" + dbType + "]暂不支持);"); + } + + // 执行SQL语句,创建视图 + if ("sqlserver".equals(dbType)) { + rs.executeQuery("SELECT 1 FROM sys.views WHERE name = 'v_zpmc'"); + if (rs.next()) { + // SqlServer,如果视图存在,先删除再创建 + rs.execute("drop view v_zpmc"); + } + } + rs.execute(sql); + } /**