calyrex 5.19和信jsp改造
parent
d0550dd643
commit
ba60d73490
@ -0,0 +1,54 @@
|
||||
package com.weaver.seconddev.interfaces.workflow.util;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: calyrex
|
||||
* @CreateTime: 2025-05-19
|
||||
* @Description: 数据操作工具
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DataOperateUtil {
|
||||
|
||||
@Autowired
|
||||
private DataSetService dataSetService;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.weaver.seconddev.controller;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.util.DataOperateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONObject;
|
||||
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-05-19
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping({"/papi/secondev/workflow" })
|
||||
public class Showhl1_controller {
|
||||
|
||||
@Autowired
|
||||
private DataOperateUtil dataOperateUtil;
|
||||
|
||||
|
||||
@RequestMapping("/Showhl1")
|
||||
public WeaResult<JSONObject> execute(@RequestParam Map<String,Object> params) {
|
||||
log.info("Showhl_controller execute start");
|
||||
log.info("Showhl_controller execute params : " + params);
|
||||
String zt = dataOperateUtil.null2String(params.get("zt"));
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Float result = 0.0f;
|
||||
String sql = "";
|
||||
try {
|
||||
sql = "select azj03 from hxjm.azj_file where azj01 = 'USD' and ((year(to_date(azj02, 'yyyy-mm')) = year(sysdate)) and (month(to_date(azj02, 'yyyy-mm')) = month(sysdate)))";
|
||||
String SourceType = "EXTERNAL";
|
||||
String groupId = "Topgp";
|
||||
Map<String, Object> datas = dataOperateUtil.executeForQuery(SourceType, groupId, sql);
|
||||
if (datas != null && datas.size() > 0) {
|
||||
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);
|
||||
result = Float.valueOf(map.get("azk03").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
jsonObject.put("result", result);
|
||||
return WeaResult.success(jsonObject);
|
||||
}catch (Exception e){
|
||||
log.error("Showhl_controller execute error : " , e);
|
||||
return WeaResult.fail(500, "Showhl_controller execute error", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.weaver.seconddev.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.util.DataOperateUtil;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: calyrex
|
||||
* @CreateTime: 2025-05-19
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping({"/papi/secondev/workflow" })
|
||||
public class Showhl_controller {
|
||||
|
||||
@Autowired
|
||||
private DataOperateUtil dataOperateUtil;
|
||||
|
||||
|
||||
@RequestMapping("/Showhl")
|
||||
public WeaResult<JSONObject> execute(@RequestParam Map<String,Object> params) {
|
||||
log.info("Showhl_controller execute start");
|
||||
log.info("Showhl_controller execute params : " + params);
|
||||
String zt = dataOperateUtil.null2String(params.get("zt"));
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Float tz = 0.0f;
|
||||
Float my = 0.0f;
|
||||
Float result = 0.0f;
|
||||
String sql = "";
|
||||
try {
|
||||
sql = "select azk03 from HOXIN.azk_file where azk01='USD' and year(azk02) = year(sysdate) and month(azk02) = month(sysdate) and day(azk02) = day(sysdate)";
|
||||
String SourceType = "EXTERNAL";
|
||||
String groupId = "Topgp";
|
||||
Map<String, Object> datas = dataOperateUtil.executeForQuery(SourceType, groupId, sql);
|
||||
if (datas != null && datas.size() > 0) {
|
||||
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);
|
||||
tz = Float.valueOf(map.get("azk03").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
sql = "select azj03 from hxjm.azj_file where azj01 = 'USD' and ((year(to_date(azj02, 'yyyy-mm')) = year(sysdate)) and (month(to_date(azj02, 'yyyy-mm')) = month(sysdate)))";
|
||||
datas = dataOperateUtil.executeForQuery(SourceType, groupId, sql);
|
||||
if (datas != null && datas.size() > 0) {
|
||||
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);
|
||||
my = Float.valueOf(map.get("azj03").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = tz / my;
|
||||
jsonObject.put("result",result);
|
||||
return WeaResult.success(jsonObject);
|
||||
}catch (Exception e){
|
||||
log.error("Showhl_controller execute error : " , e);
|
||||
return WeaResult.fail(500, "Showhl_controller execute error", e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue