Merge remote-tracking branch 'origin/ht' into ht
commit
57600085bc
@ -0,0 +1,92 @@
|
|||||||
|
package com.weaver.seconddev.interfaces.workflow.controller;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.weaver.common.base.entity.result.WeaResult;
|
||||||
|
import com.weaver.ebuilder.common.util.TenantContext;
|
||||||
|
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||||
|
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||||
|
import com.weaver.ebuilder.datasource.api.service.DataSetService;
|
||||||
|
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
|
||||||
|
import com.weaver.teams.api.tenant.Tenant;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: calyrex
|
||||||
|
* @CreateTime: 2025-02-20
|
||||||
|
* @Description: 需求变更已废弃
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping({"/papi/secondev/workflow/controller" })
|
||||||
|
public class CheckCarNumber_controller {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DataSetService dataSetService;
|
||||||
|
@RequestMapping("/CheckCarNumber")
|
||||||
|
public WeaResult<JSONObject> run(@RequestParam Map<String,Object> params) {
|
||||||
|
log.error("CheckCarNumber_controller execute start");
|
||||||
|
log.error("CheckCarNumber_controller execute params : " + params);
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
String applicant = null2String(params.get("applicant"));
|
||||||
|
String flag = "0";
|
||||||
|
String sql = "";
|
||||||
|
String sourceType = null2String(SourceType.LOGIC);
|
||||||
|
String groupId = "weaver-hr-service";
|
||||||
|
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
|
||||||
|
if(String.valueOf(datas.get("status")).equals("OK")){
|
||||||
|
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
|
||||||
|
if (records.size()>0){
|
||||||
|
Map<String, Object> map = records.get(0);
|
||||||
|
json.put("flag",map.get("num"));
|
||||||
|
return WeaResult.success(json);
|
||||||
|
}else {
|
||||||
|
log.error("getCustomId 相关字段未找到");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
log.error("getUserId status-->"+ datas.get("status"));
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("CheckCarNumber_controller execute error : " , e);
|
||||||
|
return WeaResult.fail(500, "getgsjc_controller execute error", e);
|
||||||
|
}
|
||||||
|
return WeaResult.success(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql) {
|
||||||
|
// log.error("executeForQuery sourceType-->" + sourceType + ",groupId-->" + groupId + ",sql-->" + sql);
|
||||||
|
final Tenant currentTenant = TenantContext.getCurrentTenant();
|
||||||
|
TenantRpcContext.setTargetTenantKey(String.valueOf(currentTenant));
|
||||||
|
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||||
|
executeSqlEntity.setSql(cn.hutool.core.codec.Base64.encode(sql));
|
||||||
|
executeSqlEntity.setGroupId(groupId); //groupid,可以访问 E10地址/api/datasource/ds/group?sourceType=LOGIC 获取
|
||||||
|
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
|
||||||
|
// log.error("executeForQuery executeSqlEntity-->"+executeSqlEntity.getSql()+"-->"+executeSqlEntity.getGroupId()+"-->"+executeSqlEntity.getSourceType());
|
||||||
|
Map<String, Object> datas = dataSetService.executeSql(executeSqlEntity);
|
||||||
|
log.error("executeForQuery datas-->" + datas);
|
||||||
|
TenantRpcContext.removeTargetTenantKey();
|
||||||
|
return datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(String s){
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(Object o){
|
||||||
|
return o == null ? "" : o.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String null2String(String s1,String s2){
|
||||||
|
return s1 == null ? (s2 == null ? "" : s2) : s1;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue