webservice

ht
qijirenjian 4 months ago
parent 98d7e80c48
commit 780882a95c

@ -72,7 +72,7 @@ public class HrUtil {
sql = "select * from e10_common.dbo.uf_hrxt_mt where xtbs='" + field3 + "'"; sql = "select * from e10_common.dbo.uf_hrxt_mt where xtbs='" + field3 + "'";
logger_3cf7b2d9.error("sql--" + sql); logger_3cf7b2d9.error("sql--" + sql);
String poolname_9n = CONN_TYPE.workflow.getType(); String poolname_9n = "E10JTZH";
// TODO E10执行sql方法第二参数必须指定源默认使用流程源单体客户无需修改微服务/组合客户需根据查询表所属服务切换源,或使用外部数据源 // TODO E10执行sql方法第二参数必须指定源默认使用流程源单体客户无需修改微服务/组合客户需根据查询表所属服务切换源,或使用外部数据源
rs.executeSql(sql, poolname_9n); rs.executeSql(sql, poolname_9n);
if (rs.next()) { if (rs.next()) {

@ -89,11 +89,14 @@ public class AutoCreateWorkflowService {
return "E10获取流程对应租户失败请假查e10_common.dbo.uf_zhwfid_mt配置信息"; return "E10获取流程对应租户失败请假查e10_common.dbo.uf_zhwfid_mt配置信息";
} }
String zhsjy = zhWfMap.get("zhsjy");
//3.根据工号获取创建人id (租户概念后续增加) //3.根据工号获取创建人id (租户概念后续增加)
String groupId = "weaver-ebuilder-form-service";//不确定 String groupId = "weaver-ebuilder-form-service";//不确定
String sql = "select ID,TENANT_KEY from eteams.employee where status = 'normal' and job_num = '"+creator+"' and tenant_key = '"+createTenantKey+"'"; String sql = "select ID,TENANT_KEY from eteams.employee where status = 'normal' and job_num = '"+creator+"' and tenant_key = '"+createTenantKey+"'";
Map<String,Object> recordMap = new HashMap<>(); Map<String,Object> recordMap = new HashMap<>();
String sourceType = "LOGIC"; // String sourceType = "LOGIC";
String sourceType = zhsjy;
log.error("createWorkflow sql1 :"+sql); log.error("createWorkflow sql1 :"+sql);
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql); Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
@ -159,7 +162,7 @@ public class AutoCreateWorkflowService {
if (!"".equals(key)) { if (!"".equals(key)) {
if(key.contains("hrm:")){ if(key.contains("hrm:")){
//判断人力资源字段工号是否正确 (todo) //判断人力资源字段工号是否正确 (todo)
optionId = getIdByWorkcode(code,createTenantKey); optionId = getIdByWorkcode(code,createTenantKey,zhsjy);
if(optionId == null) { if(optionId == null) {
return "工号为空或不存在"; return "工号为空或不存在";
} }
@ -180,7 +183,7 @@ public class AutoCreateWorkflowService {
if(mainMap.get("hrm:"+str2) != null){ if(mainMap.get("hrm:"+str2) != null){
String hrmResource = (String) mainMap.get("hrm:"+str2); String hrmResource = (String) mainMap.get("hrm:"+str2);
Long id = getIdByWorkcode(hrmResource,createTenantKey); Long id = getIdByWorkcode(hrmResource,createTenantKey,zhsjy);
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(id); SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(id);
optionId = simpleEmployee.getDepartmentId(); optionId = simpleEmployee.getDepartmentId();
if (key.contains("com:")) { if (key.contains("com:")) {
@ -276,7 +279,7 @@ public class AutoCreateWorkflowService {
if (!"".equals(key)) { if (!"".equals(key)) {
if(key.contains("hrm:")){ if(key.contains("hrm:")){
//判断人力资源字段工号是否正确 (todo) //判断人力资源字段工号是否正确 (todo)
optionId = getIdByWorkcode(value,createTenantKey); optionId = getIdByWorkcode(value,createTenantKey,zhsjy);
if(optionId == null) { if(optionId == null) {
return "工号为空或不存在"; return "工号为空或不存在";
} }
@ -299,7 +302,7 @@ public class AutoCreateWorkflowService {
if(mainMap.get("hrm:"+str2) != null){ if(mainMap.get("hrm:"+str2) != null){
String hrmResource = (String) mainMap.get("hrm:"+str2); String hrmResource = (String) mainMap.get("hrm:"+str2);
Long id = getIdByWorkcode(hrmResource,createTenantKey); Long id = getIdByWorkcode(hrmResource,createTenantKey,zhsjy);
SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(id); SimpleEmployee simpleEmployee = hrmCommonUtil.getSimpleEmployee(id);
optionId = simpleEmployee.getDepartmentId(); optionId = simpleEmployee.getDepartmentId();
if (key.contains("com:")) { if (key.contains("com:")) {
@ -405,12 +408,13 @@ public class AutoCreateWorkflowService {
* @param workcode * @param workcode
* @return * @return
*/ */
private Long getIdByWorkcode(String workcode,String createTenantKey) { private Long getIdByWorkcode(String workcode,String createTenantKey , String zhsjy) {
log.error("人员工号:"+workcode); log.error("人员工号:"+workcode);
String groupId = "weaver-ebuilder-form-service"; String groupId = "weaver-ebuilder-form-service";
String sql = "select ID from eteams.dbo.employee where status = 'normal' and job_num = '"+workcode+"' and tenant_key = '"+createTenantKey+"'"; String sql = "select ID from eteams.dbo.employee where status = 'normal' and job_num = '"+workcode+"' and tenant_key = '"+createTenantKey+"'";
Map<String,Object> recordMap = new HashMap<>(); Map<String,Object> recordMap = new HashMap<>();
String sourceType = "LOGIC"; // String sourceType = "LOGIC";
String sourceType = zhsjy;
Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql); Map<String, Object> result = databaseUtils.execute(sourceType, groupId, sql);
List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result); List<Map<String,Object>> recordList = databaseUtils.getDataSourceList(result);
if(CollectionUtils.isNotEmpty(recordList)){ if(CollectionUtils.isNotEmpty(recordList)){

@ -38,7 +38,7 @@ public class WfUtil {
String poolname = CONN_TYPE.ebuilder.getType(); String poolname = CONN_TYPE.ebuilder.getType();
rs.setTenantKey(jtzhTenantKey); rs.setTenantKey(jtzhTenantKey);
//从集团租户 根据传入的wfid获取有效的wfid //从集团租户 根据传入的wfid获取有效的wfid
validWfif = getValidWfid(jtzhTenantKey,currentWfid); validWfif = getValidWfid(jtzhTenantKey,currentWfid,"E10JTZH",jtzhTenantKey);
log.error("getZhWfMap validWfif : " + validWfif ); log.error("getZhWfMap validWfif : " + validWfif );
if("".equals(validWfif)){//如果为空就是其他租户的新流程 if("".equals(validWfif)){//如果为空就是其他租户的新流程
validWfif = currentWfid; validWfif = currentWfid;
@ -64,26 +64,31 @@ public class WfUtil {
String zhbs = getZhbs(workcode,jtzhTenantKey); String zhbs = getZhbs(workcode,jtzhTenantKey);
sszh = getZhbsInfo(zhbs,jtzhTenantKey); sszh = getZhbsInfo(zhbs,jtzhTenantKey);
} }
Map<String,String > zhmap = getZhTenantKey(sszh,jtzhTenantKey);
//log.error(JSON.toJSONString(zhmap));
tenantKey = zhmap.get("zzkey");
String zhsjy = zhmap.get("zhsjy");;
if("0".equals(sszh)){//集团 if("0".equals(sszh)){//集团
workflowid =jtwfid; workflowid =jtwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
}else if("1".equals(sszh)){//光电 }else if("1".equals(sszh)){//光电
workflowid =gdwfid; workflowid =gdwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
}else if("2".equals(sszh)){//华海租户 }else if("2".equals(sszh)){//华海租户
workflowid = hhwfid; workflowid = hhwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
} }
log.error("getZhWfMap workflowid : " + workflowid ); log.error("getZhWfMap workflowid : " + workflowid );
if("".equals(workflowid)){ if("".equals(workflowid)){
workflowid = validWfif; workflowid = validWfif;
tenantKey = jtzhTenantKey; tenantKey = jtzhTenantKey;
zhsjy = "E10JTZH";
} }
validWfif = getValidWfid(tenantKey,workflowid); validWfif = getValidWfid(tenantKey,workflowid,zhsjy,jtzhTenantKey);
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("workflowid",validWfif); map.put("workflowid",validWfif);
map.put("tenantKey",tenantKey); map.put("tenantKey",tenantKey);
map.put("zhsjy",zhsjy);
log.error("map : " + map ); log.error("map : " + map );
return map; return map;
} }
@ -99,7 +104,7 @@ public class WfUtil {
String poolname = CONN_TYPE.ebuilder.getType(); String poolname = CONN_TYPE.ebuilder.getType();
rs.setTenantKey(jtzhTenantKey); rs.setTenantKey(jtzhTenantKey);
//从集团租户 根据传入的wfid获取有效的wfid //从集团租户 根据传入的wfid获取有效的wfid
validWfif = getValidWfid(jtzhTenantKey,currentWfid); validWfif = getValidWfid(jtzhTenantKey,currentWfid,"E10JTZH",jtzhTenantKey);
log.error("getZhWfMapNoUser validWfif : " + validWfif ); log.error("getZhWfMapNoUser validWfif : " + validWfif );
if("".equals(validWfif)){//如果为空就是其他租户的新流程 if("".equals(validWfif)){//如果为空就是其他租户的新流程
validWfif = currentWfid; validWfif = currentWfid;
@ -125,27 +130,32 @@ public class WfUtil {
// String zhbs = getZhbs(workcode,jtzhTenantKey); // String zhbs = getZhbs(workcode,jtzhTenantKey);
// sszh = getZhbsInfo(zhbs,jtzhTenantKey); // sszh = getZhbsInfo(zhbs,jtzhTenantKey);
// } // }
Map<String,String > zhmap = getZhTenantKey(sszh,jtzhTenantKey);
//log.error(JSON.toJSONString(zhmap));
tenantKey = zhmap.get("zzkey");
String zhsjy = zhmap.get("zhsjy");
if("0".equals(sszh)){//集团 if("0".equals(sszh)){//集团
workflowid =jtwfid; workflowid =jtwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
}else if("1".equals(sszh)){//光电 }else if("1".equals(sszh)){//光电
workflowid =gdwfid; workflowid =gdwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
}else if("2".equals(sszh)){//华海租户 }else if("2".equals(sszh)){//华海租户
workflowid = hhwfid; workflowid = hhwfid;
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
} }
log.error("getZhWfMapNoUser workflowid : " + workflowid ); log.error("getZhWfMapNoUser workflowid : " + workflowid );
if("".equals(workflowid)){ if("".equals(workflowid)){
workflowid = validWfif; workflowid = validWfif;
tenantKey = jtzhTenantKey; tenantKey = jtzhTenantKey;
} }
validWfif = getValidWfid(tenantKey,workflowid); validWfif = getValidWfid(tenantKey,workflowid,zhsjy,jtzhTenantKey);
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("workflowid",validWfif); map.put("workflowid",validWfif);
map.put("tenantKey",tenantKey); map.put("tenantKey",tenantKey);
map.put("zhsjy",zhsjy);
log.error("map : " + map ); log.error("map : " + map );
return map; return map;
} }
@ -179,32 +189,39 @@ public class WfUtil {
return sszh; return sszh;
} }
public String getZhTenantKey(String sszh,String jtzhTenantKey){
public Map<String,String> getZhTenantKey(String sszh,String jtzhTenantKey){
String zzkey = ""; String zzkey = "";
RecordSet rs = I18nContextUtil.getBean(RecordSet.class); RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
String poolname = CONN_TYPE.ebuilder.getType(); String poolname = CONN_TYPE.ebuilder.getType();
rs.setTenantKey(jtzhTenantKey); rs.setTenantKey(jtzhTenantKey);
String sql = "select zzkey from e10_common.dbo.uf_tenant_mt where sszh='"+sszh+"' and delete_type ='0'"; String zhsjy = "";
String sql = "select zzkey,zhsjy from e10_common.dbo.uf_tenant_mt where sszh='"+sszh+"' and delete_type ='0'";
rs.executeSql(sql,poolname); rs.executeSql(sql,poolname);
if(rs.next()){ if(rs.next()){
zzkey = Util.null2String(rs.getString("zzkey")); zzkey = Util.null2String(rs.getString("zzkey"));
zhsjy = Util.null2String(rs.getString("zhsjy"));
} }
return zzkey; Map<String,String> map = new HashMap<>();
map.put("zzkey",zzkey);
map.put("zhsjy",zhsjy);
return map;
} }
public String getValidWfid(String tenantKey,String wfid){
public String getValidWfid(String tenantKey,String wfid,String zhsjy,String jtzhTenantKey) {
String workflowid = ""; String workflowid = "";
RecordSet rs = I18nContextUtil.getBean(RecordSet.class); RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
rs.setTenantKey(tenantKey); rs.setTenantKey(jtzhTenantKey);
String sql = "SELECT CASE WHEN status = 1 THEN id ELSE activewfid END AS workflowid FROM e10_core_business.dbo.wfp_base WHERE id like '%"+wfid+"' AND delete_type = 0 AND tenant_key = '"+tenantKey+"'"; String sql = "SELECT CASE WHEN status = 1 THEN id ELSE activewfid END AS workflowid FROM e10_core_business.dbo.wfp_base WHERE id like '%" + wfid + "' AND delete_type = 0 AND tenant_key = '" + tenantKey + "'";
// log.error("oaflowid:"+sql); //log.error("oaflowid:"+sql+" zhsjy:"+zhsjy);
rs.executeSql(sql,CONN_TYPE.workflow.getType()); rs.executeSql(sql, zhsjy);
if(rs.next()){ //log.error(JSON.toJSONString(rs.getExecuteResult()));
if (rs.next()) {
workflowid = Util.null2String(rs.getString("workflowid")); workflowid = Util.null2String(rs.getString("workflowid"));
} }
return workflowid; return workflowid;
} }

Loading…
Cancel
Save