代码结构

main
Administrator 1 month ago
parent 712e1dc737
commit dcaa9039df

@ -0,0 +1,61 @@
package com.weaver.seconddev.jcl.organization.controller;
import com.weaver.common.authority.annotation.WeaPermission;
import com.weaver.seconddev.jcl.organization.service.EmployeeRelationService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/secondev/jcl/employeeRelation")
public class EmployeeRelationController {
private static final Logger log = LoggerFactory.getLogger(EmployeeRelationController.class);
@Autowired
private EmployeeRelationService employeeRelationService;
/**
*
* @return
*/
@WeaPermission(publicPermission = true)
@Produces(MediaType.APPLICATION_JSON)
@GetMapping("/writeBackRecord")
public Map<String, Object> writeBackRecord(
@RequestParam("yearMonth") String yearMonth){
log.error("writeBackRecord.yearMonth:"+yearMonth);
Map<String, Object> actionMap = new HashMap<>();
try {
//查询干部绩效评定结果
List<Map<String, Object>> leaderPdInfo = employeeRelationService.queryLeaderPdByYear(yearMonth);
log.error("resultCalculAtion.leaderPdInfo:{}", leaderPdInfo);
//循环计算干部总分及等级
if(CollectionUtils.isNotEmpty(leaderPdInfo)){
for (Map<String, Object> map : leaderPdInfo) {
//将得分、等级回写到干部考核备案表
employeeRelationService.updateLeaderDaInfo(map);
}
}
actionMap.put("code","200");
actionMap.put("msg","接口调用成功!");
}catch(Exception e){
log.error("接口调用失败-e:{}",e);
actionMap.put("code","201");
actionMap.put("msg","接口调用失败!");
}
return actionMap;
}
}

@ -0,0 +1,106 @@
package com.weaver.seconddev.jcl.organization.esb;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @use
* @date 2025312
* @author xuxy
*/
@Service("updateEmployeeTransferInfo_jcl")
public class UpdateYgddInfoAction implements EsbServerlessRpcRemoteInterface {
@Autowired
private DatabaseUtils databaseUtils;
private static final Logger log = LoggerFactory.getLogger(UpdateYgddInfoAction.class);
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
Map<String, Object> rs =new HashMap<>();
//查询员工调动信息
List<Map<String, Object>> list = queryYgddInfo();
//遍历判断是否有当天零点的调动生效日期的人员,更新
Map<String, Object> result = updateYgddInfo(list);
log.error("UpdateYgddInfoAction.flowV3:"+result);
rs.put("flowV3",result);
return WeaResult.success(rs);
}
public List<Map<String, Object>> queryYgddInfo() {
String sql=" SELECT * from uf_jcl_rydd where delete_type=0 and TENANT_KEY='t7n9jpeaoa' " ;
log.error("queryYgddInfo.sql:{}",sql);
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
log.error("queryYgddInfo.recordList:{}",recordList);
return recordList;
}
public Map<String, Object> updateYgddInfo(List<Map<String, Object>> list) {
Map<String, Object> rs = new HashMap<>();
for (Map<String, Object> map : list) {
String ddr = String.valueOf(map.get("ddr"));
String ddsxrq = String.valueOf(map.get("ddsxrq"));
String ddhgs = String.valueOf(map.get("ddhgs"));
String ddhbm = String.valueOf(map.get("ddhbm"));
String ddhgw = String.valueOf(map.get("ddhgw"));
String ddhzjsj = String.valueOf(map.get("ddhzjsj"));
//判断调动生效日期是否为当天
if (isToday(ddsxrq)) {
//更新数据到员工基础信息表
String sql = "update eteams.employee set department = '" + ddhbm + "',POSITION = '" + ddhgw + "',SUPERIOR = '" + ddhzjsj + "'" +
" where id = '" + ddr + "' and TENANT_KEY = 't7n9jpeaoa' and delete_type=0 ";
log.error("UpdateYgddInfoAction.sql:{}", sql);
rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
log.error("UpdateYgddInfoAction.rs:{}", rs);
}
}
return rs;
}
public static boolean isToday(String dateStr) {
// 定义日期格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 解析日期字符串
try {
Date inputDate = dateFormat.parse(dateStr);
// 获取当前日期
Calendar calendar = Calendar.getInstance();
Date today = calendar.getTime();
// 重置时间部分,只比较日期部分
calendar.setTime(inputDate);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date truncatedInputDate = calendar.getTime();
calendar.setTime(today);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date truncatedTodayDate = calendar.getTime();
// 比较日期
return truncatedInputDate.equals(truncatedTodayDate);
} catch (ParseException e) {
// 如果解析失败,返回 false
e.printStackTrace();
return false;
}
}
}

@ -0,0 +1,11 @@
package com.weaver.seconddev.jcl.organization.service;
import java.util.List;
import java.util.Map;
public interface EmployeeRelationService {
List<Map<String, Object>> queryLeaderPdByYear(String yearMonth);
void updateLeaderDaInfo(Map<String, Object> map);
}

@ -0,0 +1,43 @@
package com.weaver.seconddev.jcl.organization.service.impl;
import com.weaver.seconddev.jcl.organization.controller.EmployeeRelationController;
import com.weaver.seconddev.jcl.organization.service.EmployeeRelationService;
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
public class EmployeeRelationServiceImpl implements EmployeeRelationService {
private static final Logger log = LoggerFactory.getLogger(EmployeeRelationController.class);
@Autowired
private DatabaseUtils databaseUtils;
@Override
public List<Map<String, Object>> queryLeaderPdByYear(String yearMonth) {
String sql="select a.khny,b.* from uf_gbkhpd a left join uf_gbkhpd_mxb1 b on a.id = b.form_data_id where a.khny = '" + yearMonth + "' and a.IS_DELETE = 0 and a.delete_type = 0 and a.TENANT_KEY = 'tscemvfpqg' " ;
log.error("queryLeaderPdByYear.sql:{}",sql);
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(rs);
log.error("queryLeaderPdByYear.recordList:{}",recordList);
return recordList;
}
@Override
public void updateLeaderDaInfo(Map<String, Object> map) {
String khny = String.valueOf(map.get("khny"));
String xm = String.valueOf(map.get("xm"));
String df = String.valueOf(map.get("df"));
String dj = String.valueOf(map.get("dj"));
log.error("updateLeaderDaInfo.map:{}",map);
String sql="update uf_jcl_gbkhba set ndzhjxkhdf = '" + df + "',ndzhjxkhdj ='" + dj + "' where nd = '" + khny.substring(0, 4) + "' and bkhr = '" + xm + "' ";
log.error("updateLeaderDaInfo.sql:{}",sql);
Map<String, Object> rs = databaseUtils.execute("LOGIC", "weaver-ebuilder-form-service", sql);
log.error("updateEmployeeDjInfo.rs:{}",rs);
}
}

@ -0,0 +1,422 @@
package com.weaver.seconddev.jcl.organization.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Component
public class CommonUtils {
private final static Logger log = LoggerFactory.getLogger(CommonUtils.class);
public static JSONObject toJSON(String data){
if(!StringUtils.isEmpty(data)){
try {
return JSONObject.parseObject(data);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return null;
}
public static Long getJSONLong(JSONObject json,String key){
if(json != null && json.containsKey(key)){
try {
return json.getLong(key);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return null;
}
public static Integer getJSONInteger(JSONObject json,String key){
if(json != null && json.containsKey(key)){
try {
return json.getInteger(key);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return -1;
}
public static String getJSONString(JSONObject json,String key){
if(json != null && json.containsKey(key)){
try {
return null2String(json.getString(key));
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return "";
}
public static JSONObject getJSONObject(JSONObject json,String key){
if(json != null && json.containsKey(key)){
try {
return json.getJSONObject(key);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return null;
}
public static JSONArray getJSONArray(JSONObject json, String key){
if(json != null && json.containsKey(key)){
try {
return json.getJSONArray(key);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return null;
}
public static JSONObject getJSONObject(JSONArray json, int idx){
if(json != null && json.size() > idx){
try {
return json.getJSONObject(idx);
}catch (Throwable t){
log.error(t.getMessage(),t);
}
}
return null;
}
public static String mapToStrData(Map<String, Object> para){
if(para != null) {
return JSONObject.toJSON(para).toString();
}
return "";
}
public static void strToLongList(List<Long> list,String strs){
strToLongList(list,strs,true);
}
public static void strToLongList(List<Long> list,String strs,boolean isDist){
if(list == null){
return;
}
if(StringUtils.isEmpty(strs)){
return;
}
String[] strList = StringUtils.split(strs, ",");
for(String str:strList){
if(StringUtils.isEmpty(str)){
continue;
}
long id = getLongValue(str);
if(id > 0l && (isDist == false || !list.contains(id))){
list.add(id);
}
}
}
public static long getLongValue(Object v){
return getLongValue(null2String(v));
}
public static long getLongValue(String v) {
return getLongValue(v, -1);
}
public static long getLongValue(String v, long def) {
try {
return Long.parseLong(v);
} catch (Exception ex) {
return def;
}
}
public static int getIntValue(Object o){
return getIntValue(null2String(o));
}
public static int getIntValue(String s){
return getIntValue(s,-1);
}
public static int getIntValue(String s, int def){
try {
return NumberUtils.toInt(s);
} catch (Exception ex) {
return def;
}
}
public static String null2String(Object s) {
return s == null ? "" : s.toString();
}
public static String null2String(Object s, String def) {
return s == null ? (def == null ? "" : def) : s.toString();
}
public static String stringReplace(String sou, String s1, String s2) {
//int idx = sou.indexOf(s1);
//if (idx < 0) {
// return sou;
//}
//return sou.substring(0, idx) + s2 + StringReplace(sou.substring(idx + s1.length()), s1, s2);
sou = null2String(sou);
s1 = null2String(s1);
s2 = null2String(s2);
try{
sou = sou.replace(s1, s2);
}catch(Exception e){
//System.out.println(e);//将未知异常打印出来,便于检查错误。
}
return sou;
}
/**
*
*
* @param s
* @return
*/
public static String toScreen(String s) {
char c[] = s.toCharArray();
char ch;
int i = 0;
StringBuffer buf = new StringBuffer();
while (i < c.length) {
ch = c[i++];
if (ch == '\r')
buf.append("");
else if (ch == '\n')
buf.append("");
else
buf.append(ch);
}
return buf.toString();
}
/**
*
*
* @param s
* @return
*/
public static String toExcel(String s) {
if (s == null) return "";
//因本方法会将字符串 &符号转换故先将欧元符号转义符转换为其Unicode码
s = s.replaceAll("&euro;", "\u20AC");
String str = toScreen(s);
str = stringReplace(str, "&ang;", "∠");
str = stringReplace(str, "&phi;", "φ");
str = stringReplace(str, "&quot;", "\"");
str = stringReplace(str, "&nbsp", "%nbsp");
//str=Util.StringReplace(str,"'","");
str = stringReplace(str, "&lt;", "<");
str = stringReplace(str, "&gt;", ">");
str = stringReplace(str, "&dt;&at;", "<br>");
str = stringReplace(str, "&", "&amp;");
str = stringReplace(str, "<br>", "&dt;&at;");
if ("&dt;&at;".equals(str)) {
str = "";
}
//在方法最后,又将欧元符号置换为转义符
str = str.replaceAll("\u20AC", "&euro;");
return str;
}
public static String delHtml(final String inputString) {
String htmlStr = toExcel(inputString); // 含html标签的字符串
String textStr = "";
java.util.regex.Pattern p_script;
java.util.regex.Matcher m_script;
java.util.regex.Pattern p_html;
java.util.regex.Matcher m_html;
try {
String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
String regEx_script = "<[/s]*?script[^>]*?>[/s/S]*?<[/s]*?//[/s]*?script[/s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[/s/S]*?<//script>
p_script = java.util.regex.Pattern.compile(regEx_script, java.util.regex.Pattern.CASE_INSENSITIVE);
m_script = p_script.matcher(htmlStr);
htmlStr = m_script.replaceAll(""); // 过滤script标签
p_html = java.util.regex.Pattern.compile(regEx_html, java.util.regex.Pattern.CASE_INSENSITIVE);
m_html = p_html.matcher(htmlStr);
htmlStr = m_html.replaceAll(""); // 过滤html标签
textStr = htmlStr;
} catch (Exception e) {
System.err.println("Html2Text: " + e.getMessage());
}
return htmlToTxt(textStr).trim();// 返回文本字符串
}
/**
* html
*
* @param input
* @return
*/
public static String htmlToTxt(String input) {
if (input == null || input.trim().equals("")) {
return "";
}
// 去掉所有html元素,
String str = input.replaceAll("<[a-zA-Z]+[1-9]?[^><]*>", "");
return str;
}
//==new=
public static int getIntValue(Object s, int def){
return getIntValue(null2String(s));
}
public static List<Long> strToLongList(String strs){
List<Long> list = new ArrayList<Long>();
strToLongList(list,strs,true);
return list;
}
public static int dateInterval(String fromdate, String todate) {
Calendar fromcalendar = getCalendar(fromdate);
Calendar tocalendar = getCalendar(todate);
if (fromcalendar == null || tocalendar == null)
return 0;
return (int) ((tocalendar.getTimeInMillis() - fromcalendar.getTimeInMillis()) / 3600 / 24 / 1000);
}
/**
* @param datetime - '2004-05-12 12:00:23' '2004-05-12'
* @return null
*/
public static Calendar getCalendar(String datetime) {
int datetimelength = datetime.length() ;
switch(datetimelength) {
case 19 :
return getCalendar(datetime , "yyyy'-'MM'-'dd' 'HH:mm:ss") ;
case 10 :
return getCalendar(datetime , "yyyy'-'MM'-'dd") ;
default :
return null ;
}
}
/**
* @param datetime -
* @param formart -
* @return null
*/
public static Calendar getCalendar(String datetime, String formart) {
SimpleDateFormat SDF = new SimpleDateFormat(formart) ;
Calendar calendar = Calendar.getInstance() ;
try {
calendar.setTime(SDF.parse(datetime)) ;
} catch (ParseException e) {
return null ;
}
return calendar ;
}
/**
* @return yyyy'-'MM'-'dd
*
* yyyy'-'MM'-'dd
*
* 2004-09-07
*/
public static String getCurrentDateString() {
String timestrformart = "yyyy'-'MM'-'dd" ;
SimpleDateFormat SDF = new SimpleDateFormat(timestrformart) ;
Calendar calendar = Calendar.getInstance() ;
return SDF.format(calendar.getTime()) ;
}
public static String getMessage(String msgMode,String key,String val){
key = null2String(key).trim();
val = null2String(val).trim();
msgMode = null2String(msgMode).trim();
if(!"".equals(msgMode) && !"".equals(key)) {
msgMode = msgMode.replaceAll(key, val);
}
return msgMode;
}
public static List<Long> tranStrToLongList(Object idListObj){
List<Long> docIds = new ArrayList<Long>();
if(idListObj != null) {
try {
JSONArray idObjs = JSONArray.parseArray(null2String(idListObj));
for (Object idObj : idObjs) {
long id = getLongValue(idObj);
if (id > 0l) {
docIds.add(id);
}
}
} catch (Exception e) {
log.error("trans error :{}", idListObj);
log.error(e.getMessage(), e);
}
}
return docIds;
}
public static Map<String, Object> requestToMap(HttpServletRequest request) {
Map<String, String[]> properties = request.getParameterMap();//把请求参数封装到Map<String, String[]>中
Map<String, Object> returnMap = new HashMap<String, Object>();
Iterator<Map.Entry<String, String[]>> iter = properties.entrySet().iterator();
String name = "";
String value = "";
while (iter.hasNext()) {
Map.Entry<String, String[]> entry = iter.next();
name = entry.getKey();
Object valueObj = entry.getValue();
if (null == valueObj) {
value = "";
} else if (valueObj instanceof String[]) {
String[] values = (String[]) valueObj;
for (int i = 0; i < values.length; i++) {
value = values[i] + ",";
}
value = value.substring(0, value.length() - 1);
} else {
value = valueObj.toString();
}
returnMap.put(name, value);
}
return returnMap;
}
}

@ -0,0 +1,328 @@
package com.weaver.seconddev.jcl.organization.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
import com.weaver.ebuilder.datasource.api.query.dto.dw.DynamicParamDto;
import com.weaver.ebuilder.datasource.api.query.dto.dw.FieldQuery;
import com.weaver.ebuilder.datasource.api.query.dto.dw.GroupQuery;
import com.weaver.ebuilder.datasource.api.query.dto.dw.TableQuery;
import com.weaver.ebuilder.datasource.api.service.DataSetService;
import com.weaver.ebuilder.datasource.api.service.impl.EbFormDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* DatabaseUtil SQL
*/
@Component
public class DatabaseUtils {
private final static Logger log = LoggerFactory.getLogger(DatabaseUtils.class);
@Autowired
private DataSetService dataSetService;
@Autowired
private EbFormDataService dataService;
/**
* SQL
*
* @param entity SQL
* @return Map
* @throws RuntimeException SQL
*/
public Map<String, Object> executeSql(ExecuteSqlEntity entity) {
Map<String, Object> map = dataSetService.executeSql(entity);
if ("FAIL".equals(com.weaver.seconddev.jcl.organization.util.CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
throw new RuntimeException("sql执行异常");
} else {
return map;
}
}
/**
* SQL
*
* @param entity SQL
* @param pageNo
* @param pageSize
* @return Map
* @throws RuntimeException SQL
*/
public Map<String, Object> executeSql(ExecuteSqlEntity entity, int pageNo, int pageSize) {
entity.setPageNo(pageNo);
entity.setPageSize(pageSize);
Map<String, Object> map = dataSetService.executeForQuery(entity);
if ("FAIL".equals(com.weaver.seconddev.jcl.organization.util.CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT))) {
log.error("sql执行失败=>{}", JSONObject.toJSONString(map));
throw new RuntimeException("sql执行异常");
} else {
return map;
}
}
/**
* SQL
*
* @param sql SQL
* @param groupId ID
* @paramDesc ID select APPLICATION_MARK,APPLICATION_name from eteams.ds_mark_service_relation
* @return SQL
*/
public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
log.error("sql=>{}", sql);
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(SourceType.LOGIC);
executeSqlEntity.setGroupKey("0");
return executeSqlEntity;
}
/**
* SQL Base64
*
* @param sql SQL
* @return
*/
public String base64(String sql) {
return Base64.encode(sql);
}
/**
*
*
* @param map Map
* @return Map
*/
public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
List<Map<String, Object>> entity = new ArrayList();
if ("OK".equals(com.weaver.seconddev.jcl.organization.util.CommonUtils.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && CommonUtils.getIntValue(map.get("count")) > 0) {
entity = (List) map.get("records");
}
return keyToLowerCase((List) entity);
}
public Map<String, Object> getOneDataSource(Map<String, Object> map) {
List<Map<String, Object>> entity = getDataSourceList(map);
return (Map)(CollectionUtil.isNotEmpty(entity) ? (Map)entity.get(0) : new HashMap());
}
/**
* Map
*
* @param orgMapList Map
* @return Map
*/
public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
List<Map<String, Object>> resultList = new ArrayList();
Iterator var2 = orgMapList.iterator();
while (var2.hasNext()) {
Map<String, Object> stringObjectMap = (Map) var2.next();
resultList.add(keyToLowerCase(stringObjectMap));
}
return resultList;
}
/**
* Map
*
* @param orgMap Map
* @return Map
*/
public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
Map<String, Object> resultMap = new HashMap();
if (orgMap != null && !orgMap.isEmpty()) {
Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
Iterator var3 = entrySet.iterator();
while (var3.hasNext()) {
Map.Entry<String, Object> entry = (Map.Entry) var3.next();
String key = (String) entry.getKey();
Object value = entry.getValue();
resultMap.put(key.toLowerCase(), value);
}
return resultMap;
} else {
return resultMap;
}
}
/**
*
*
* @param sourceType sourceType
* ETEAMS :
* FORM: ebuilder
* LOGIC: ()
* EXTERNAL
* @return
*/
public List<Map<String, Object>> getDataGroups(String sourceType, Boolean flag) {
GroupQuery query = new GroupQuery();
query.setSourceType(SourceType.valueOf(sourceType));
query.setShowSqlDataset(flag);
DynamicParamDto dynamicParamDto = new DynamicParamDto();
dynamicParamDto.setUserId(10000L);
dynamicParamDto.setTenantKey("tk");
query.setDynamicParamDto(dynamicParamDto);
return dataSetService.getDataGroups(query);
}
/**
*
*
* @param sourceType
* @param groupId
* @param pageNum
* @param pageSize
* @return
*/
public Map<String, Object> getDataSets(String sourceType, String groupId, Integer pageNum, Integer pageSize) {
TableQuery tableQuery = new TableQuery();
tableQuery.setSourceType(SourceType.valueOf(sourceType));
tableQuery.setGroupId(groupId);
//非必传
//tableQuery.setName(name);
tableQuery.setPageNo(pageNum);
tableQuery.setPageSize(pageSize);
return dataSetService.getDataSetsByPage(tableQuery);
}
/**
*
* sourceType :LOGIC
* sourceId : 8494845523559165780
* groupId : weaver-crm-service
*
* @param
* @return
*/
public List<Map<String, Object>> getFields(String sourceType, String sourceId, String groupId) {
FieldQuery query = new FieldQuery();
query.setSourceType(SourceType.valueOf(sourceType));
query.setSourceId(sourceId);
query.setGroupId(groupId);
return dataSetService.getFields(query);
}
/**
* sql
* sourceType :LOGIC
* groupId : weaver-ebuilder-app-service
* sql : select * from ebda_app limit 10
*
* @param
* @return
*/
public Map<String, Object> execute(String sourceType, String groupId, String sql) {
//执行sql 参数sourceType groupId sql
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
return dataSetService.executeSql(executeSqlEntity);
}
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
//执行sql 参数sourceType groupId sql sqlparam
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
executeSqlEntity.setSql(base64(sql));
executeSqlEntity.setGroupId(groupId);
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
executeSqlEntity.setParams(sqlparam);
return dataSetService.executeSql(executeSqlEntity);
}
public String getMysqlPagedSql(String sql,int pageNo, int pageSize) {
if(pageNo<=0){
pageNo = 1;
}
if(pageSize<=0){
pageSize = 20;
}
int start = (pageNo-1)*pageSize;
int end = pageNo*pageSize;
return new StringBuffer().append(sql).append(
" LIMIT "+start+","+(end-start)).toString();
}
/**
* sql
* @param list
* @return
*/
public List<SqlParamEntity> querySqlParamEntity(List<String> list){
List<SqlParamEntity> sqlparam = new ArrayList<SqlParamEntity>();
for (String str : list){
SqlParamEntity sqlParamEntity = new SqlParamEntity();
sqlParamEntity.setParamType(SqlParamType.VARCHAR);
sqlParamEntity.setValue(str);
sqlparam.add(sqlParamEntity);
}
return sqlparam;
}
/***
*
* @param sourceType
* @param groupId
* @param dataSql
* @param paramList
* @return
*/
public List<Map<String, Object>> getSqlList(String sourceType,String groupId,String dataSql,List<String> paramList){
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
List<Map<String, Object>> recordList = getDataSourceList(result);
return recordList;
}
/***
*
* @param sourceType
* @param groupId
* @param dataSql
* @param paramList
* @return
*/
public Map<String, Object> getSqlMap(String sourceType,String groupId,String dataSql,List<String> paramList){
Map<String, Object> recordMap = new HashMap<>();
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
Map<String, Object> result = executeForQuery(sourceType, groupId, dataSql, sqlParamList);
List<Map<String, Object>> recordList = getDataSourceList(result);
if(recordList.size() > 0){
recordMap = recordList.get(0);
}
return recordMap;
}
}
Loading…
Cancel
Save