ht
qijirenjian 1 month ago
commit b492390d67

@ -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,61 @@
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 cn.hutool.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 = "976355735283761152";
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("AZJ03").toString());
}
}
}
log.info("Showhl_controller execute result : " + result);
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 = "976355735283761152";
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);
}
}
}

@ -34,13 +34,13 @@ public class DataOperateUtil {
private DataSetService dataSetService;
public List<Long> getDetailFormId(String workflowId) {
log.error("getDetailFormId start : " + workflowId );
log.info("getDetailFormId start : " + workflowId );
List<Long> formIdList = new ArrayList();
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-basic-schedule-service";
try {
String sql = "select form_id from ecology10.dbo.form_table where form_id in (select id from ecology10.dbo.sub_form where form_id in (select relatekey from ecology10.dbo.wfp_relateform where workflowid = '"+workflowId+"'))";
log.info("getConfig sql-->" + sql);
log.info("getDetailFormId sql-->" + sql);
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
// log.info("getConfig datas-->" + datas);
if(String.valueOf(datas.get("status")).equals("OK")){
@ -52,27 +52,28 @@ public class DataOperateUtil {
}
return formIdList;
}else {
log.error("getConfig status-->"+ datas.get("status"));
log.error("getDetailFormId status-->"+ datas.get("status"));
return formIdList;
}
}catch (Exception e){
log.error("getConfig e--> ",e);
log.error("getDetailFormId e--> ",e);
return formIdList;
}
}
public String getConfig(String key,String tenantKey){
int tenantId = getTenantId(tenantKey);
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-basic-schedule-service";
String groupId = "weaver-ebuilder-form-service";
try {
String sql = "select configvalue from ecology10.dbo.uf_config where configkey = '" + key + "' and zhkey = '"+tenantKey+"'";
String sql = "select configvalue from ecology10.dbo.uf_config where configkey = '" + key + "' and zhkey = '"+tenantId+"'";
log.info("getConfig sql-->" + sql);
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
// log.info("getConfig datas-->" + datas);
log.info("getConfig datas-->" + datas);
if(String.valueOf(datas.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
Map<String, Object> map = records.get(0);
return map.get("config_value").toString();
return map.get("configvalue").toString();
}else {
log.error("getConfig status-->"+ datas.get("status"));
return "";
@ -91,7 +92,7 @@ public class DataOperateUtil {
executeSqlEntity.setSourceType(SourceType.valueOf(sourceType));
// log.info("executeForQuery executeSqlEntity-->"+executeSqlEntity.getSql()+"-->"+executeSqlEntity.getGroupId()+"-->"+executeSqlEntity.getSourceType());
Map<String, Object> datas = dataSetService.executeSql(executeSqlEntity);
// log.info("executeForQuery datas-->" + datas);
log.info("executeForQuery datas-->" + datas);
TenantRpcContext.removeTargetTenantKey();
return datas;
}
@ -101,6 +102,7 @@ public class DataOperateUtil {
* @return
*/
public static JSONObject getFromDataByDataDetails(List<FormDataDuty> formDataDutyList) {
log.error("getFromDataByDataDetails start");
JSONObject formData = new JSONObject();
formData.put("module","workflow");
@ -172,6 +174,14 @@ public class DataOperateUtil {
return formData;
}
private int getTenantId(String tenantKey){
if (tenantKey == "temkc46eme"){
return 0;
}else {
return 0;
}
}
public static String null2String(String s){
return s == null ? "" : s;
}

@ -52,7 +52,8 @@ public class InterInfoAchieveUtil {
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String params = "app_key="+app_key+"&app_secret="+app_secret+"&grant_type="+grant_type+"&code="+code;
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address",tenantKey)) + "/papi/openapi/oauth2/access_token";
// log.info("getToken params-->" + params);
log.info("getToken url--"+url);
log.info("getToken params-->" + params);
RequestBody body = RequestBody.create(mediaType, params);
Request request = new Request.Builder()
.url(url)
@ -63,4 +64,5 @@ public class InterInfoAchieveUtil {
return response.body().string();
}
}

@ -30,62 +30,61 @@ public class DoCreateWorkflowService {
@Autowired
private InterInfoAchieveUtil interInfoAchieveUtil;
public String doCreateWorkflowRequest(String creator,String tenantKey,String workflowId,String mainTable,String[] detailTables) throws IOException {
public String doCreateWorkflowRequest(String creator,String tenantKey,String workflowId,String mainTable,String detailArray) throws IOException {
log.info("DoCreateWorkflowService start");
List<Long> detailFormId = dataOperateUtil.getDetailFormId(workflowId);
JSONObject param = new JSONObject();
param.put("userid", Long.valueOf(creator));
param.put("workflowId", Long.valueOf(workflowId));
log.info("主表数据:" + mainTable);
//主表数据 json {"sqr":"sqr1","date":"date1","hrm:zrr":"zrr1"}
//字段名前面加 hrm:表示是人力资源字段
if (mainTable == null || mainTable.equals("")) {
return "主表数据不能为空";
}
try {
List<Long> detailFormId = dataOperateUtil.getDetailFormId(workflowId);
JSONObject param = new JSONObject();
param.put("userid", Long.valueOf(creator));
param.put("workflowId", Long.valueOf(workflowId));
log.info("主表数据:" + mainTable);
//主表数据 json {"sqr":"sqr1","date":"date1","hrm:zrr":"zrr1"}
//字段名前面加 hrm:表示是人力资源字段
if (mainTable == null || mainTable.equals("")) {
return "主表数据不能为空";
}
JSONObject jsonObject = JSONObject.parseObject(mainTable);
Map<String, Object> mainMap = jsonObject.toJavaObject(Map.class);
log.error("主表集合:" + mainMap);
List<FormDataDuty> formDataDutyList = new ArrayList();
// 输出 Map 的内容
for (Map.Entry<String, Object> entry : mainMap.entrySet()) {
FormDataDuty formDataDuty = FormDataDuty.builder().build();
String key = entry.getKey();
Object value = entry.getValue();
formDataDuty.setFieldType(1);
formDataDuty.setDataKey(key);
formDataDuty.setContent(String.valueOf(value));
formDataDutyList.add(formDataDuty);
}
if(detailTables==null){
JSONObject jsonObject = JSONObject.parseObject(mainTable);
Map<String, Object> mainMap = jsonObject.toJavaObject(Map.class);
log.info("主表集合:" + mainMap);
List<FormDataDuty> formDataDutyList = new ArrayList();
// 输出 Map 的内容
for (Map.Entry<String, Object> entry : mainMap.entrySet()) {
FormDataDuty formDataDuty = FormDataDuty.builder().build();
String key = entry.getKey();
Object value = entry.getValue();
formDataDuty.setFieldType(1);
formDataDuty.setDataKey(key);
formDataDuty.setContent(String.valueOf(value));
formDataDutyList.add(formDataDuty);
}
}else{
// log.error("处理明细数据");
if(detailTables.length>0){
log.info("detailArray--",detailArray);
JSONArray detailTables = JSONArray.parseArray(detailArray);
if(detailTables.size()>0){
// 遍历外部 JSONArray
for (int i = 0; i < detailTables.length; i++) {
JSONArray innerArray = JSONArray.parseArray(detailTables[i]); // 获取内部的 JSONArray
log.error("innerArray:"+innerArray);
for (int i = 0; i < detailTables.size(); i++) {
log.info("detailTables--"+detailTables.get(i));
JSONObject detailInfo = JSONObject.parseObject(detailTables.get(i).toString()); // 获取内部的 JSONArray
log.info("detailInfo:"+detailInfo);
if(innerArray.size()>0){
//判断明细表id是否存在
if (detailFormId.size() < i+1) {
log.error("明细表"+(i+1)+"form_id未找到或不存在");
return "明细表"+(i+1)+"form_id未找到或不存在";
}
Long subFormId = detailFormId.get(i);
log.error("明细表"+(i+1)+"form_id"+subFormId);
log.info("index:"+detailInfo.get("index"));
log.info("detailFormId:"+detailFormId);
Long subFormId = detailFormId.get(Integer.parseInt(detailInfo.get("index").toString())-1);
log.info("明细表"+(i+1)+"form_id"+subFormId);
JSONArray innerArray = detailInfo.getJSONArray("data");
if(innerArray.size()>0){
// 遍历内部 JSONArray
for (int j = 0; j < innerArray.size(); j++) {
com.alibaba.fastjson.JSONObject jsonDetail = innerArray.getJSONObject(j);
JSONObject jsonDetail = innerArray.getJSONObject(j);
// 遍历 JSONObject 的键值对
for (String key : jsonDetail.keySet()) {
FormDataDuty formDataDuty = FormDataDuty.builder().build();
String value = jsonDetail.getString(key);
if (!"".equals(key)) {
// log.error("明细表普通字段值:"+value);
// log.info("明细表普通字段值:"+value);
if(StringUtils.isNotEmpty(value)){
formDataDuty.setDataKey(key);
formDataDuty.setDataIndex((long) (j + 1));
@ -93,7 +92,7 @@ public class DoCreateWorkflowService {
//目前写死 后续在找方法
formDataDuty.setSubFormId(subFormId);
}else{
// log.error("明细表普通字段值为空");
// log.info("明细表普通字段值为空");
}
formDataDutyList.add(formDataDuty);
}
@ -105,44 +104,50 @@ public class DoCreateWorkflowService {
}
log.error("formDataDutyList数据"+formDataDutyList.size()+"-"+formDataDutyList);
log.info("formDataDutyList数据"+formDataDutyList.size()+"-"+formDataDutyList);
}
}
if(CollectionUtils.isNotEmpty(formDataDutyList)) {
JSONObject fromDataByDataDetails = dataOperateUtil.getFromDataByDataDetails(formDataDutyList);
param.put("formData", fromDataByDataDetails);
}
String code = interInfoAchieveUtil.getCode(tenantKey);
String token = interInfoAchieveUtil.getToken(code,tenantKey);
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address",tenantKey)) + "/api/workflow/core/paService/v1/doCreateRequest?access_token=" + token;
log.error("url : " + url);
JSONObject otherParams =new JSONObject();
otherParams.put("isnextflow",1);
param.put("otherParams",otherParams);
log.error("表单json:"+param.toJSONString());
// 远程调用创建流程。
String response = HttpUtil.post(url, param.toJSONString());
log.error("自动创建流程结果:"+response);
JSONObject responseObj = JSONObject.parseObject(response);
Object message = responseObj.get("message");
JSONObject messageObj = JSONObject.parseObject(message.toString());
String errcode = messageObj.get("errcode").toString();
log.error("errcode"+errcode);
if(StringUtils.isNotEmpty(errcode)){
if(messageObj.get("errcode").toString().equals("0")){
log.error("requestId"+messageObj.get("requestId").toString());
return Optional.ofNullable(messageObj.get("requestId")).map(Object::toString).orElse("");
if(CollectionUtils.isNotEmpty(formDataDutyList)) {
JSONObject fromDataByDataDetails = dataOperateUtil.getFromDataByDataDetails(formDataDutyList);
log.info("formDataDutyList数据"+fromDataByDataDetails);
param.put("formData", fromDataByDataDetails);
}
String code = JSONObject.parseObject(interInfoAchieveUtil.getCode(tenantKey)).getString("code");
String token = JSONObject.parseObject(interInfoAchieveUtil.getToken(code,tenantKey)).getString("accessToken");
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address",tenantKey)) + "/papi/openapi/api/workflow/core/paService/v1/doCreateRequest?access_token=" + token;
log.info("url : " + url);
JSONObject otherParams =new JSONObject();
otherParams.put("isnextflow",1);
param.put("otherParams",otherParams);
log.info("表单json:"+param.toJSONString());
// 远程调用创建流程。
String response = HttpUtil.post(url, param.toJSONString());
log.info("自动创建流程结果:"+response);
JSONObject responseObj = JSONObject.parseObject(response);
Object message = responseObj.get("message");
JSONObject messageObj = JSONObject.parseObject(message.toString());
String errcode = messageObj.get("errcode").toString();
log.info("errcode"+errcode);
if(StringUtils.isNotEmpty(errcode)){
if(messageObj.get("errcode").toString().equals("0")){
log.info("requestId"+messageObj.get("requestId").toString());
return Optional.ofNullable(messageObj.get("requestId")).map(Object::toString).orElse("");
}else{
log.info("errmsg"+messageObj.get("errmsg").toString());
return messageObj.get("errmsg").toString();
}
}else{
log.error("errmsg"+messageObj.get("errmsg").toString());
return messageObj.get("errmsg").toString();
return "调用泛微流程创建接口失败";
}
}else{
return "调用泛微流程创建接口失败";
}catch (Exception e){
log.info("接口调用失败-",e);
return "接口调用失败--"+e;
}
}
}

@ -0,0 +1,100 @@
package com.weaver.secondev.action.approval;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.secondev.util.DataOperateUtil;
import com.weaver.secondev.util.ThirdInfoUtil;
import com.weaver.verupgrade.interfaces.workflow.action.Action;
import com.weaver.verupgrade.soa.workflow.request.RequestInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-06-04
* @Description:
*/
@Slf4j
@Service("workflow_action_PayApplicationApprovalAction")
public class PayApplicationApprovalAction implements EsbServerlessRpcRemoteInterface {
@Autowired
private RequestInfo requestInfoTemp;
@Autowired
private DataOperateUtil dataOperateUtil;
@Autowired
private ThirdInfoUtil thirdInfoUtil;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
log.info("PayApplicationApprovalAction execute start");
log.info("PayApplicationApprovalAction execute params : " + params);
try {
Map<String, Object> weaverResultMap = new HashMap<>();
Long requestIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("requestid", -1)));
Long userIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("userid", -1)));
String status = String.valueOf(params.getOrDefault("status", ""));
RequestInfo requestinfo = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
String tableName = requestinfo.getRequestManager().getBillTableName();
String formDataId = dataOperateUtil.getFormDataId(String.valueOf(requestIdTemp));
String sql = "select pk,billtype from " + tableName + " where form_data_id = " + formDataId;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-workflow-report-serviceworkflowreport";
Map<String, Object> datas = dataOperateUtil.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);
String billType = map.get("billtype").toString();
String pk = map.get("pk").toString();
String usercode = dataOperateUtil.getConfig("third_usercode");
JSONObject jsonObject = new JSONObject();
jsonObject.put("pk", pk);
jsonObject.put("usercode", usercode);
jsonObject.put("billtype", billType);
String url = "";
if ("1".equals(status)){
url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/uapbd/approveoaapi/Approve";
}else {
url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/uapbd/approveoaapi/UnApprove";
}
JSONObject tokenInfo = thirdInfoUtil.getToken();
if (tokenInfo.get("success").equals("true")){
JSONObject data = tokenInfo.getJSONObject("data");
String token = data.getString("access_token");
Boolean result = thirdInfoUtil.transferStatusInfo(url, token, jsonObject);
log.info("PayApplicationApprovalAction execute result : " + result);
if (result){
return WeaResult.success(thirdInfoUtil.getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, requestinfo.getRequestManager()));
}else {
log.info("PayApplicationApprovalAction execute error--推送失败");
return WeaResult.fail("PayApplicationApprovalAction execute error--推送失败");
}
}else {
log.info("PayApplicationApprovalAction execute error--token调用失败");
return WeaResult.fail("PayApplicationApprovalAction execute error--token调用失败");
}
}else {
log.info("PayApplicationApprovalAction execute error--查询不到数据");
return WeaResult.fail("PayApplicationApprovalAction execute error--查询不到数据");
}
}else {
log.info("PayApplicationApprovalAction execute error--查询失败");
return WeaResult.fail("PayApplicationApprovalAction execute error--查询失败");
}
} catch (Exception e) {
log.error("PaymentApplyAction execute error", e);
return WeaResult.fail("PayApplicationApprovalAction execute error", e);
}
}
}

@ -0,0 +1,100 @@
package com.weaver.secondev.action.approval;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.secondev.util.DataOperateUtil;
import com.weaver.secondev.util.ThirdInfoUtil;
import com.weaver.verupgrade.interfaces.workflow.action.Action;
import lombok.extern.slf4j.Slf4j;
import com.weaver.verupgrade.soa.workflow.request.RequestInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-06-03
* @Description:
*/
@Slf4j
@Service("workflow_action_ReimbursementApprovalAction")
public class ReimbursementApprovalAction implements EsbServerlessRpcRemoteInterface {
@Autowired
private RequestInfo requestInfoTemp;
@Autowired
private DataOperateUtil dataOperateUtil;
@Autowired
private ThirdInfoUtil thirdInfoUtil;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
log.error("ReimbursementApprovalAction execute start");
log.error("ReimbursementApprovalAction execute params : " + params);
try {
Map<String, Object> weaverResultMap = new HashMap<>();
Long requestIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("requestid", -1)));
Long userIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("userid", -1)));
String status = String.valueOf(params.getOrDefault("status", ""));
RequestInfo requestinfo = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
String tableName = requestinfo.getRequestManager().getBillTableName();
String formDataId = dataOperateUtil.getFormDataId(String.valueOf(requestIdTemp));
String sql = "select pk,billtype from " + tableName + " where form_data_id = " + formDataId;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-workflow-report-serviceworkflowreport";
Map<String, Object> datas = dataOperateUtil.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);
String pk = String.valueOf(map.get("pk"));
String billtype = String.valueOf(map.get("billtype"));
String usercode = dataOperateUtil.getConfig("third_usercode");
JSONObject jsonObject = new JSONObject();
jsonObject.put("pk", pk);
jsonObject.put("usercode", usercode);
jsonObject.put("billtype", billtype);
String url = "";
if ("1".equals(status)){
url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/arap/payablebill/commit";
}else {
url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/arap/payablebill/uncommit";
}
JSONObject tokenInfo = thirdInfoUtil.getToken();
if (tokenInfo.get("success").equals("true")){
JSONObject data = tokenInfo.getJSONObject("data");
String token = data.getString("access_token");
Boolean result = thirdInfoUtil.transferStatusInfo(url, token, jsonObject);
log.info("ReimbursementApprovalAction execute result : " + result);
if (result){
return WeaResult.success(thirdInfoUtil.getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, requestinfo.getRequestManager()));
}else {
log.info("ReimbursementApprovalAction execute error--推送失败");
return WeaResult.fail("ReimbursementApprovalAction execute error--推送失败");
}
}else {
log.info("ReimbursementApprovalAction execute error--token调用失败");
return WeaResult.fail("ReimbursementApprovalAction execute error--token调用失败");
}
}else {
log.info("ReimbursementApprovalAction execute error--查询不到数据");
return WeaResult.fail("ReimbursementApprovalAction execute error--查询不到数据");
}
}else {
log.info("ReimbursementApprovalAction execute error--查询失败");
return WeaResult.fail("ReimbursementApprovalAction execute error--查询失败");
}
} catch (Exception e) {
log.error("ReimbursementApprovalAction execute error", e);
return WeaResult.fail("ReimbursementApprovalAction execute error", e);
}
}
}

@ -0,0 +1,164 @@
package com.weaver.secondev.action.info;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.file.ud.api.FileDownloadService;
import com.weaver.secondev.util.DataOperateUtil;
import com.weaver.secondev.util.ThirdInfoUtil;
import com.weaver.verupgrade.interfaces.workflow.action.Action;
import com.weaver.verupgrade.soa.workflow.request.RequestInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-06-11
* @Description:
*/
@Slf4j
@Service("workflow_action_PurchaseRequisitionInfoAction")
public class PurchaseRequisitionInfoAction implements EsbServerlessRpcRemoteInterface {
@Autowired
private RequestInfo requestInfoTemp;
@Autowired
private DataOperateUtil dataOperateUtil;
@Autowired
private ThirdInfoUtil thirdInfoUtil;
@Autowired
private FileDownloadService fileDownloadService;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
log.info("PurchaseRequisitionInfoAction execute start");
log.info("PurchaseRequisitionInfoAction execute params : " + params);
try {
Map<String, Object> weaverResultMap = new HashMap<>();
Long requestIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("requestid", -1)));
Long userIdTemp = Long.parseLong(String.valueOf(params.getOrDefault("userid", -1)));
RequestInfo requestinfo = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
String tableName = requestinfo.getRequestManager().getBillTableName();
String wokflowId = requestinfo.getWorkflowid();
String formDataId = dataOperateUtil.getFormDataId(String.valueOf(requestIdTemp));
String sql = "select * from " + tableName + " where formdataid = " + formDataId;
log.error("ReimbursementInfoAction execute sql : " + sql);
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-workflow-report-serviceworkflowreport";
Map<String, Object> datas = dataOperateUtil.executeForQuery(sourceType, groupId, sql);
JSONObject responseJson = new JSONObject();
if(String.valueOf(datas.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
if (records.size()>0){
JSONObject po_praybill = new JSONObject();
String ccurrencyid = "CNY";
String pk_org = dataOperateUtil.null2String(records.get(0).get("pk_org"));
String pk_org_v = dataOperateUtil.null2String(records.get(0).get("pk_org_v"));
String dbilldate = dataOperateUtil.null2String(records.get(0).get("dbilldate"));
String ctrantypeid = "D1";
String pk_planpsn = dataOperateUtil.getJobNum(dataOperateUtil.null2String(records.get(0).get("pk_planpsn"))).toString();
String pk_plandept = dataOperateUtil.getDepartmentCode(dataOperateUtil.null2String(records.get(0).get("pk_plandept"))).toString();
String fbillstatus = dataOperateUtil.null2String(records.get(0).get("fbillstatus"));
String vmemo = dataOperateUtil.null2String(records.get(0).get("vmemo"));
String billmaker = dataOperateUtil.getJobNum(dataOperateUtil.null2String(records.get(0).get("billmaker"))).toString();
String dmakedate = dataOperateUtil.null2String(records.get(0).get("dmakedate"));
po_praybill.put("ccurrencyid", ccurrencyid);
po_praybill.put("pk_org", pk_org);
po_praybill.put("pk_org_v", pk_org_v);
po_praybill.put("dbilldate", dbilldate);
po_praybill.put("ctrantypeid", ctrantypeid);
po_praybill.put("pk_planpsn", pk_planpsn);
po_praybill.put("pk_plandept", pk_plandept);
po_praybill.put("fbillstatus", fbillstatus);
po_praybill.put("vmemo", vmemo);
po_praybill.put("billmaker", billmaker);
po_praybill.put("dmakedate", dmakedate);
responseJson.put("po_praybill", po_praybill);
}else {
log.error("ReimbursementInfoAction execute error", "主表查询不到数据");
return WeaResult.fail("ReimbursementInfoAction execute error--主表查询不到数据");
}
}else {
log.error("ReimbursementInfoAction execute error", "主表数据查询失败");
return WeaResult.fail("ReimbursementInfoAction execute error--主表数据查询失败");
}
List<String> detailTableNameList = dataOperateUtil.getDetailTableName(wokflowId);
String detailTableName = detailTableNameList.get(0);
String detailTableSql = "select * from " + detailTableName + " where form_data_id = " + formDataId;
log.error("ReimbursementInfoAction execute sql : " + detailTableSql);
Map<String, Object> detailDatas = dataOperateUtil.executeForQuery(sourceType, groupId, detailTableSql);
JSONArray po_praybill_b = new JSONArray();
if(String.valueOf(detailDatas.get("status")).equals("OK")) {
List<Map<String, Object>> detailRecords = (List<Map<String, Object>>) detailDatas.get("records");
if (detailRecords.size() > 0) {
for (int i = 0; i < detailRecords.size(); i++) {
JSONObject detailJson = new JSONObject();
Map<String, Object> detailMap = detailRecords.get(i);
String pk_material = dataOperateUtil.null2String(detailMap.get("pk_material"));
String castunitid = dataOperateUtil.null2String(detailMap.get("castunitid"));;
String nastnum = dataOperateUtil.null2String(detailMap.get("nastnum"));
String vchangerate = dataOperateUtil.null2String(detailMap.get("vchangerate"));
String cunitid = dataOperateUtil.null2String(detailMap.get("cunitid"));
String nnum = dataOperateUtil.null2String(detailMap.get("nnum"));
String dreqdate = dataOperateUtil.null2String(detailMap.get("dreqdate"));
String dsuggestdate = dataOperateUtil.null2String(detailMap.get("dsuggestdate"));
String pk_employee = dataOperateUtil.getJobNum(dataOperateUtil.null2String(detailMap.get("pk_employee"))).toString();
String pk_suggestsupplier = dataOperateUtil.null2String(detailMap.get("pk_suggestsupplier"));
String pk_purchaseorg = dataOperateUtil.null2String(detailMap.get("pk_purchaseorg"));
detailJson.put("pk_material", pk_material);
detailJson.put("castunitid", castunitid);
detailJson.put("nastnum", nastnum);
detailJson.put("vchangerate", vchangerate);
detailJson.put("cunitid", cunitid);
detailJson.put("nnum", nnum);
detailJson.put("dreqdate", dreqdate);
detailJson.put("dsuggestdate", dsuggestdate);
detailJson.put("pk_employee", pk_employee);
detailJson.put("pk_suggestsupplier", pk_suggestsupplier);
detailJson.put("pk_purchaseorg", pk_purchaseorg);
po_praybill_b.add(detailJson);
}
responseJson.put("po_praybill_b", po_praybill_b);
String url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/nccloud/api/pu/praybillext/add";
JSONObject tokenInfo = thirdInfoUtil.getToken();
if (tokenInfo.get("success").equals("true")){
JSONObject data = tokenInfo.getJSONObject("data");
String token = data.getString("access_token");
JSONObject request = thirdInfoUtil.transferInfo(url, token, responseJson);
String success = request.get("success").toString();
if ("true".equals(success)){
return WeaResult.success(thirdInfoUtil.getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, requestinfo.getRequestManager()));
}else {
log.info("PurchaseRequisitionInfoAction execute error--推送失败");
return WeaResult.fail("PurchaseRequisitionInfoAction execute error--推送失败");
}
}else {
log.info("PurchaseRequisitionInfoAction execute error--token调用失败");
return WeaResult.fail("PurchaseRequisitionInfoAction execute error--token调用失败");
}
}else {
log.info("PurchaseRequisitionInfoAction execute error--查询不到数据");
return WeaResult.fail("PurchaseRequisitionInfoAction execute error--查询不到数据");
}
}else {
log.info("PurchaseRequisitionInfoAction execute error--查询失败");
return WeaResult.fail("PurchaseRequisitionInfoAction execute error--查询失败");
}
} catch (Exception e) {
log.error("PurchaseRequisitionInfoAction execute error", e);
return WeaResult.fail("PurchaseRequisitionInfoAction execute error", e);
}
}
}

@ -0,0 +1,228 @@
package com.weaver.secondev.action.info;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.ebuilder.datasource.api.enums.SourceType;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.eteams.file.client.file.FileData;
import com.weaver.file.ud.api.FileDownloadService;
import com.weaver.secondev.util.DataOperateUtil;
import com.weaver.secondev.util.ThirdInfoUtil;
import com.weaver.verupgrade.file.ImageFileManager;
import com.weaver.verupgrade.interfaces.workflow.action.Action;
import com.weaver.verupgrade.soa.workflow.request.RequestInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-06-03
* @Description:
*/
@Slf4j
@Service("workflow_action_ReimbursementInfoAction")
public class ReimbursementInfoAction implements EsbServerlessRpcRemoteInterface {
@Autowired
private RequestInfo requestInfoTemp;
@Autowired
private DataOperateUtil dataOperateUtil;
@Autowired
private ThirdInfoUtil thirdInfoUtil;
@Autowired
private FileDownloadService fileDownloadService;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> requestInfoMap) {
log.error("ReimbursementInfoAction execute start");
log.error("ReimbursementInfoAction execute params : " + requestInfoMap);
try {
Map<String, Object> weaverResultMap = new HashMap<>();
Long requestIdTemp = Long.parseLong(String.valueOf(requestInfoMap.getOrDefault("requestid", -1)));
Long userIdTemp = Long.parseLong(String.valueOf(requestInfoMap.getOrDefault("userid", -1)));
RequestInfo requestinfo = requestInfoTemp.getRequestInfo(requestIdTemp, userIdTemp);
String wokflowId = requestinfo.getWorkflowid();
String tableName = requestinfo.getRequestManager().getBillTableName();
String formDataId = dataOperateUtil.getFormDataId(String.valueOf(requestIdTemp));
String sql = "select * from " + tableName + " where form_data_id = " + formDataId;
log.error("ReimbursementInfoAction execute sql : " + sql);
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-workflow-report-serviceworkflowreport";
Map<String, Object> datas = dataOperateUtil.executeForQuery(sourceType, groupId, sql);
JSONObject responseJson = new JSONObject();
String xgfj = "";
if(String.valueOf(datas.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
if (records.size()>0){
String pk_org_v = dataOperateUtil.null2String(records.get(0).get("pk_org_v"));
String pk_org = dataOperateUtil.null2String(records.get(0).get("pk_org"));
String billdate = dataOperateUtil.null2String(records.get(0).get("billdate"));
String busidate = dataOperateUtil.null2String(records.get(0).get("busidate"));
String objtype = "3";
String pk_tradetypeid = "D1";
String pk_busitype = "AP01";
String scomment = dataOperateUtil.null2String(records.get(0).get("scomment"));
String billmaker = dataOperateUtil.null2String(records.get(0).get("billmaker"));
String def21 = wokflowId;
String def22 = String.valueOf(requestIdTemp);
String pu_org = dataOperateUtil.getDepartmentCode(dataOperateUtil.null2String(records.get(0).get("pu_org"))).toString();
String pu_deptid_v = dataOperateUtil.getDepartmentCode(dataOperateUtil.null2String(records.get(0).get("pu_deptid_v"))).toString();
//报销人待确认
String pk_psndoc = dataOperateUtil.getJobNum(dataOperateUtil.null2String(records.get(0).get("pk_psndoc"))).toString();
String pk_currtype = "CNY";
String local_money = dataOperateUtil.null2String(records.get(0).get("local_money"));
String grouprate = dataOperateUtil.null2String(records.get(0).get("grouprate"));
String grouplocal = dataOperateUtil.null2String(records.get(0).get("grouplocal"));
String globalrate = dataOperateUtil.null2String(records.get(0).get("globalrate"));
String globallocal = dataOperateUtil.null2String(records.get(0).get("globallocal"));
String rate = dataOperateUtil.null2String(records.get(0).get("rate"));
String money = dataOperateUtil.null2String(records.get(0).get("money"));
xgfj = dataOperateUtil.null2String(records.get(0).get("xgfj"));
responseJson.put("pk_org_v", pk_org_v);
responseJson.put("pk_org", pk_org);
responseJson.put("billdate", billdate);
responseJson.put("busidate", busidate);
responseJson.put("objtype", objtype);
responseJson.put("pk_tradetypeid", pk_tradetypeid);
responseJson.put("pk_busitype", pk_busitype);
responseJson.put("scomment", scomment);
responseJson.put("billmaker", billmaker);
responseJson.put("def21", def21);
responseJson.put("def22", def22);
responseJson.put("pu_org", pu_org);
responseJson.put("pu_deptid_v", pu_deptid_v);
responseJson.put("pk_psndoc", pk_psndoc);
responseJson.put("pk_currtype", pk_currtype);
responseJson.put("local_money", local_money);
responseJson.put("grouprate", grouprate);
responseJson.put("grouplocal", grouplocal);
responseJson.put("globalrate", globalrate);
responseJson.put("globallocal", globallocal);
responseJson.put("rate", rate);
responseJson.put("money", money);
}else {
log.error("ReimbursementInfoAction execute error", "主表查询不到数据");
return WeaResult.fail("ReimbursementInfoAction execute error--主表查询不到数据");
}
}else {
log.error("ReimbursementInfoAction execute error", "主表数据查询失败");
return WeaResult.fail("ReimbursementInfoAction execute error--主表数据查询失败");
}
List<String> detailTableNameList = dataOperateUtil.getDetailTableName(wokflowId);
String detailTableName = detailTableNameList.get(0);
String detailTableSql = "select * from " + detailTableName + " where form_data_id = " + formDataId;
log.error("ReimbursementInfoAction execute sql : " + detailTableSql);
Map<String, Object> detailDatas = dataOperateUtil.executeForQuery(sourceType, groupId, detailTableSql);
if(String.valueOf(detailDatas.get("status")).equals("OK")){
List<Map<String,Object>> detailRecords = (List<Map<String,Object>>)detailDatas.get("records");
if (detailRecords.size()>0){
JSONArray items = new JSONArray();
for (int i = 0; i < detailRecords.size(); i++) {
JSONObject detailJson = new JSONObject();
Map<String, Object> detailMap = detailRecords.get(i);
String project = dataOperateUtil.null2String(detailMap.get("project"));
String objtype = dataOperateUtil.null2String(detailMap.get("objtype"));
String pk_deptid_v = dataOperateUtil.getDepartmentCode(dataOperateUtil.null2String(detailMap.get("pk_deptid_v"))).toString();
String pk_psndoc = dataOperateUtil.getJobNum(dataOperateUtil.null2String(detailMap.get("pk_psndoc"))).toString();
String pk_subjcode = dataOperateUtil.null2String(detailMap.get("pk_subjcode"));
String pk_currtype = "CNY";
String rate = "1";
String def21 = dataOperateUtil.null2String(detailMap.get("def21"));
String def22 = dataOperateUtil.null2String(detailMap.get("def22"));
String money_cr = dataOperateUtil.null2String(detailMap.get("money_cr"));
String local_money_cr = dataOperateUtil.null2String(detailMap.get("local_money_cr"));
String axcodeid = dataOperateUtil.null2String(detailMap.get("axcodeid"));
String taxrate = dataOperateUtil.null2String(detailMap.get("taxrate"));
String local_tax_cr = dataOperateUtil.null2String(detailMap.get("local_tax_cr"));
String notax_cr = dataOperateUtil.null2String(detailMap.get("notax_cr"));
String local_notax_cr = dataOperateUtil.null2String(detailMap.get("local_notax_cr"));
String recaccount = dataOperateUtil.null2String(detailMap.get("recaccount"));
String grouprate = dataOperateUtil.null2String(detailMap.get("grouprate"));
String groupcrebit = dataOperateUtil.null2String(detailMap.get("groupcrebit"));
String globalrate = dataOperateUtil.null2String(detailMap.get("globalrate"));
String globalcrebit = dataOperateUtil.null2String(detailMap.get("globalcrebit"));
String quantity_cr = "1";
String price = dataOperateUtil.null2String(detailMap.get("price"));
String taxcodeid = dataOperateUtil.null2String(detailMap.get("taxcodeid"));
detailJson.put("project", project);
detailJson.put("objtype", objtype);
detailJson.put("pk_deptid_v", pk_deptid_v);
detailJson.put("pk_psndoc", pk_psndoc);
detailJson.put("pk_subjcode", pk_subjcode);
detailJson.put("pk_currtype", pk_currtype);
detailJson.put("rate", rate);
detailJson.put("def21", def21);
detailJson.put("def22", def22);
detailJson.put("money_cr", money_cr);
detailJson.put("local_money_cr", local_money_cr);
detailJson.put("axcodeid", axcodeid);
detailJson.put("taxrate", taxrate);
detailJson.put("local_tax_cr", local_tax_cr);
detailJson.put("notax_cr", notax_cr);
detailJson.put("local_notax_cr", local_notax_cr);
detailJson.put("recaccount", recaccount);
detailJson.put("grouprate", grouprate);
detailJson.put("groupcrebit", groupcrebit);
detailJson.put("globalrate", globalrate);
detailJson.put("globalcrebit", globalcrebit);
detailJson.put("quantity_cr", quantity_cr);
detailJson.put("price", price);
detailJson.put("taxcodeid", taxcodeid);
items.add(detailJson);
}
responseJson.put("items", items);
String url = dataOperateUtil.getConfig("ip_address") + "/nccloud/api/arap/payablebill/insert";
JSONObject tokenInfo = thirdInfoUtil.getToken();
if (tokenInfo.get("success").equals("true")){
JSONObject data = tokenInfo.getJSONObject("data");
String token = data.getString("access_token");
JSONObject request = thirdInfoUtil.transferInfo(url, token, responseJson);
String success = request.get("success").toString();
if ("true".equals(success)){
JSONObject data1 = request.getJSONObject("data");
String pk_bill = data1.getString("pk_bill");
List<String> xgfjList = Arrays.asList(xgfj.split(","));
for (String fileId : xgfjList) {
FileData fileData = fileDownloadService.downloadFileLazy(Long.valueOf(fileId));
InputStream inputStream = fileData.getInputStream();
String fileName = dataOperateUtil.getFileName(fileId);
Boolean isUpdate = thirdInfoUtil.updateFile(pk_bill, fileName, inputStream);
if (!isUpdate){
log.info("updateFile error:上传附件失败");
return WeaResult.fail("上传附件失败");
}
}
}else {
log.info("transferInfo error:{}", request);
return WeaResult.fail("推送表单数据失败");
}
}
return WeaResult.success(thirdInfoUtil.getResultMapForAction(weaverResultMap, "result", Action.SUCCESS, requestinfo.getRequestManager()));
}else {
log.info("getToken error:明细表为空" );
return WeaResult.fail("明细表为空");
}
}else {
log.info("getToken error:查询数据失败");
return WeaResult.fail("查询数据失败");
}
} catch (Exception e) {
log.error("ReimbursementInfoAction execute error", e);
return WeaResult.fail("ReimbursementInfoAction execute error", e);
}
}
}

@ -0,0 +1,164 @@
package com.weaver.secondev.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-04-25
* @Description:
*/
@Component
@Slf4j
public class DataOperateUtil {
@Autowired
private DataSetService dataSetService;
public List<String> getDetailTableName(String workflowId) {
log.info("getDetailFormId start : " + workflowId );
List<String> tableNameList = new ArrayList();
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-basic-schedule-service";
try {
String sql = "select table_name from ecology10.dbo.form_table where form_id in (select id from ecology10.dbo.sub_form where form_id in (select relatekey from ecology10.dbo.wfp_relateform where workflowid = '"+workflowId+"'))";
log.info("getDetailFormId sql-->" + sql);
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
// log.info("getConfig datas-->" + datas);
if(String.valueOf(datas.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
for (int i = 0; i < records.size(); i++) {
Map<String, Object> map = records.get(i);
String table_name = map.get("table_name").toString();
tableNameList.add(table_name);
}
return tableNameList;
}else {
log.error("getDetailFormId status-->"+ datas.get("status"));
return tableNameList;
}
}catch (Exception e){
log.error("getDetailFormId e--> ",e);
return tableNameList;
}
}
public String getDepartmentCode(String departmentId){
String sql = "select code from eteams.dbo.department where id = " + departmentId;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-hrm-service";
Map<String, Object> stringObjectMap = executeForQuery(sourceType, groupId, sql);
if(String.valueOf(stringObjectMap.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)stringObjectMap.get("records");
Map<String, Object> map = records.get(0);
return map.get("code").toString();
}else {
log.error("getDepartmentCode status-->"+ stringObjectMap.get("status"));
return "";
}
}
public String getJobNum(String jobId){
String sql = "select job_num from eteams.dbo.job where id = " + jobId;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-hrm-service";
Map<String, Object> stringObjectMap = executeForQuery(sourceType, groupId, sql);
if(String.valueOf(stringObjectMap.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)stringObjectMap.get("records");
Map<String, Object> map = records.get(0);
return map.get("job_num").toString();
}else {
log.error("getJobNum status-->"+ stringObjectMap.get("status"));
return "";
}
}
public String getFileName(String fileId){
String sql = " select name from fileobj where id = " + fileId;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-file-service";
Map<String, Object> stringObjectMap = executeForQuery(sourceType, groupId, sql);
if(String.valueOf(stringObjectMap.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)stringObjectMap.get("records");
Map<String, Object> map = records.get(0);
return map.get("name").toString();
}else {
log.error("getFileName status-->"+ stringObjectMap.get("status"));
return "";
}
}
public String getFormDataId(String requestid){
String sql = " select dataid from wfc_form_data where requestid = " + requestid;
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-workflow-report-serviceworkflowreport";
Map<String, Object> stringObjectMap = executeForQuery(sourceType, groupId, sql);
if(String.valueOf(stringObjectMap.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)stringObjectMap.get("records");
Map<String, Object> map = records.get(0);
return map.get("dataid").toString();
}else {
log.error("getFormDataId status-->"+ stringObjectMap.get("status"));
return "";
}
}
public String getConfig(String key){
String sourceType = String.valueOf(SourceType.LOGIC);
String groupId = "weaver-basic-schedule-service";
try {
String sql = "select config_value from ecology10.dbo.uf_config where config_key = '" + key + "'";
// log.info("getConfig sql-->" + sql);
Map<String, Object> datas = executeForQuery(sourceType, groupId, sql);
// log.info("getConfig datas-->" + datas);
if(String.valueOf(datas.get("status")).equals("OK")){
List<Map<String,Object>> records = (List<Map<String,Object>>)datas.get("records");
Map<String, Object> map = records.get(0);
return map.get("config_value").toString();
}else {
log.info("getConfig status-->"+ datas.get("status"));
return "";
}
}catch (Exception e){
log.info("getConfig e--> ",e);
return "";
}
}
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql) {
// log.info("executeForQuery sourceType-->" + sourceType + ",groupId-->" + groupId + ",sql-->" + sql);
TenantRpcContext.setTargetTenantKey("temkc46eme");
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.info("executeForQuery executeSqlEntity-->"+executeSqlEntity.getSql()+"-->"+executeSqlEntity.getGroupId()+"-->"+executeSqlEntity.getSourceType());
Map<String, Object> datas = dataSetService.executeSql(executeSqlEntity);
log.info("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,119 @@
package com.weaver.secondev.util;
import com.alibaba.fastjson.JSONObject;
import cn.hutool.http.HttpRequest;
import com.weaver.verupgrade.workflow.request.RequestManager;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
/**
* @Author: calyrex
* @CreateTime: 2025-06-03
* @Description:
*/
@Component
@Slf4j
public class ThirdInfoUtil {
@Autowired
private DataOperateUtil dataOperateUtil;
public JSONObject getToken(){
String ipAddress = dataOperateUtil.getConfig("ip_address");
String bizCenter = dataOperateUtil.getConfig("biz_center");
String grantType = dataOperateUtil.getConfig("grant_type");
String clientId = dataOperateUtil.getConfig("client_id");
String clientSecret = dataOperateUtil.getConfig("client_secret");
String signature = dataOperateUtil.getConfig("signature");
String url = ipAddress + "/nccloud/opm/accesstoken?grant_type=" + grantType + "&client_id=" + clientId + "&client_secret=" + clientSecret + "&signature=" + signature + "&biz_center=" + bizCenter;
String body = HttpRequest.post(url)
.header("Content-Type", "application/x-www-form-urlencoded")
.execute().body();
JSONObject result = JSONObject.parseObject(body);
return result;
}
public Boolean transferStatusInfo(String url, String token, JSONObject body){
String request = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("client_id", dataOperateUtil.getConfig("client_id"))
.header("signature", dataOperateUtil.getConfig("signature"))
.header("access_token", token)
.header("ucg_flag", "Y")
.header("repeat_check", "y")
.body(String.valueOf(body))
.execute().body();
log.info("transferInfo request:{}", request);
boolean result = Boolean.parseBoolean(JSONObject.parseObject(request).get("success").toString());
return result;
}
public JSONObject transferInfo(String url, String token, JSONObject body){
String request = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("client_id", dataOperateUtil.getConfig("client_id"))
.header("signature", dataOperateUtil.getConfig("signature"))
.header("access_token", token)
.header("ucg_flag", "Y")
.header("repeat_check", "y")
.body(String.valueOf(body))
.execute().body();
log.info("transferInfo request:{}", request);
return JSONObject.parseObject(request);
}
public Boolean updateFile(String parentPath,String imageFileName, InputStream inputStream) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
String url = dataOperateUtil.null2String(dataOperateUtil.getConfig("oa_address")) + "/service/FileUpLoad";
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file1",imageFileName,
// RequestBody.create(MediaType.parse("application/octet-stream"), new File("D:\\works\\fwsz\\管委会\\test.pdf")))
RequestBody.create(MediaType.parse("application/octet-stream"), toByteArray(inputStream)))
.build();
Request request = new Request.Builder()
.url(url)
.header("operType","upload")
.header("dsName",dataOperateUtil.getConfig("dsName"))
.header("parentPath",parentPath)
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
String string = response.body().string();
JSONObject result = JSONObject.parseObject(string);
return result.getBoolean("success");
}
public Map<String, Object> getResultMapForAction(Map<String, Object> map, String key, Object value, RequestManager requestManager) {
if (key != null && !key.isEmpty()) {
map.put(key, value);
}
String msgContent = requestManager.getMessagecontent();
if (msgContent != null && !msgContent.isEmpty()) {
map.put("msgContent", msgContent);
}
String msgId = requestManager.getMessageid();
if (msgId != null && !msgId.isEmpty()) {
map.put("msgId", msgId);
}
return map;
}
public static byte[] toByteArray(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024*4];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
return output.toByteArray();
}
}
Loading…
Cancel
Save