webservice
parent
c1f36a7ebf
commit
6ebd067af3
@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
id 'war'
|
||||
}
|
||||
|
||||
description = ""
|
||||
|
||||
//version '1.0.0' // 为子项目设置版本号为 1.0.0
|
||||
|
||||
dependencies {
|
||||
// 子项目私有依赖添加
|
||||
}
|
||||
|
||||
//jar {
|
||||
// archiveBaseName = 'secondev-ht-njwebserivce' // 替换为子项目的实际名称
|
||||
// archiveVersion = version
|
||||
// archiveClassifier = ''
|
||||
// archiveExtension = 'jar'
|
||||
// destinationDirectory = file('build/libs')
|
||||
//}
|
@ -0,0 +1,64 @@
|
||||
package com.weaver.seconddev.njwebservice;
|
||||
|
||||
import com.weaver.seconddev.njwebservice.entity.SubmitWorkflowReq;
|
||||
import com.weaver.seconddev.njwebservice.entity.SubmitWorkflowRes;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* 自动创建流程 webService
|
||||
*/
|
||||
@Service("autoCreateWorkflowEncService")
|
||||
public class AutoCreateWorkflowEncService {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(AutoCreateWorkflowEncService.class);
|
||||
|
||||
@Autowired
|
||||
private AutoCreateWorkflowService autoCreateWorkflowService;
|
||||
|
||||
@Autowired
|
||||
private SubmitWorkflowRes var12;
|
||||
public SubmitWorkflowRes createWorkflow(SubmitWorkflowReq var1) {
|
||||
|
||||
String var2 = var1.getDATAS().getLoginname();
|
||||
String var3 = var1.getDATAS().getPassword();
|
||||
String var4 = var1.getDATAS().getWorkflowId();
|
||||
String var5 = var1.getDATAS().getCreator();
|
||||
String var6 = var1.getDATAS().getRequestLevel();
|
||||
String var7 = var1.getDATAS().getMainTable();
|
||||
String var8 = var1.getDATAS().getDetailTables();
|
||||
String var9 = var1.getSYSID();
|
||||
String var10 = var1.getSENDID();
|
||||
String var11 = var1.getITFID();
|
||||
|
||||
|
||||
var12.setITFID(var11);
|
||||
var12.setSYSID(var9);
|
||||
var12.setSENDID(var10);
|
||||
String var14 = autoCreateWorkflowService.createWorkflow(var2, var3, var4, var5, var6, var7, var8);
|
||||
if (isInteger(var14)) {
|
||||
var12.setISTAT("S");
|
||||
log.error(var5 + "创建流程id为" + var4 + "的流程成功!");
|
||||
} else {
|
||||
var12.setISTAT("F");
|
||||
log.error(var5 + "创建流程id为" + var4 + "的流程失败:" + var14);
|
||||
}
|
||||
|
||||
var12.setMESSAGE(var14);
|
||||
return var12;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isInteger(String var0) {
|
||||
Pattern var1 = Pattern.compile("^\\+?[1-9][0-9]*$");
|
||||
return var1.matcher(var0).matches();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.weaver.seconddev.njwebservice;
|
||||
|
||||
import com.weaver.common.hrm.util.Util;
|
||||
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||
import com.weaver.seconddev.njwebservice.util.DocUtil;
|
||||
import com.weaver.verupgrade.conn.CONN_TYPE;
|
||||
import com.weaver.verupgrade.conn.RecordSet;
|
||||
import com.weaver.verupgrade.workflow.workflow.WorkflowAllComInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("demoService")
|
||||
public class DemoService {
|
||||
private final static Logger log = LoggerFactory.getLogger(DemoService.class);
|
||||
|
||||
private static final String HOST = "http://10.6.23.235:20600/papi/openapi";
|
||||
|
||||
@Autowired
|
||||
private DocUtil docUtil;
|
||||
|
||||
// @Autowired
|
||||
// private DepartmentComInfo departmentComInfo;
|
||||
|
||||
@Autowired
|
||||
private WorkflowAllComInfo workflowAllComInfo;
|
||||
|
||||
|
||||
|
||||
public String demo(String base64){
|
||||
// //实现自定义webservice接口逻辑
|
||||
|
||||
//String tips = SecondUtil.validationParam("OAAdmin", "123456", "100003460000005676", "2022050353");
|
||||
|
||||
//String formId = workflowAllComInfo.getFormId("100003460000005676");
|
||||
|
||||
String workcodeId = "100003460000005676";
|
||||
|
||||
// 获取明细表表名
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.workflow.getType();
|
||||
|
||||
String formSql = "";
|
||||
|
||||
String sql = "SELECT * FROM form_table WHERE \n" +
|
||||
" form_id IN ( SELECT id FROM sub_form WHERE form_id IN ( SELECT form_id FROM e10_core_business.dbo.form_table WHERE table_name = 'formtable_main_3540'))";
|
||||
rs.executeSql(sql,poolname);
|
||||
while (rs.next()){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id", Util.getLongValue(rs.getString("id")));
|
||||
map.put("table_type", Util.getIntValue(rs.getString("table_type")));
|
||||
map.put("form_name", Util.null2String(rs.getString("form_name")));
|
||||
list.add(map);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// String token = "";
|
||||
// try {
|
||||
// token = AccessTokenUtil.getToken();
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
//// log.error("base64:"+base64);
|
||||
////
|
||||
// int base64Length = base64.length();
|
||||
//
|
||||
// // 计算原始文件大小
|
||||
// int originalSize = (base64Length * 3) / 4;
|
||||
//
|
||||
// // 如果 Base64 字符串末尾有填充字符 '=',需要减去对应的字节数
|
||||
// if (base64.endsWith("==")) {
|
||||
// originalSize -= 2; // 每两个 '=' 表示填充了 1 个字节
|
||||
// } else if (base64.endsWith("=")) {
|
||||
// originalSize -= 1; // 每 1 个 '=' 表示填充了 1 个字节
|
||||
// }
|
||||
//
|
||||
////
|
||||
// JSONObject params = new JSONObject();
|
||||
// params.put("userid", 100001700000063120L);
|
||||
// params.put("base64", base64);
|
||||
// params.put("name","测试.png");
|
||||
// params.put("size",String.valueOf(originalSize));
|
||||
// params.put("lastModified",System.currentTimeMillis());
|
||||
////
|
||||
////
|
||||
////
|
||||
// String url = HOST + "/api/file/v2/common/upload/base64?access_token=" + token;
|
||||
// HttpRequest request = HttpRequest.post(url)
|
||||
// .header(Header.CONTENT_TYPE, ContentType.MULTIPART.toString())
|
||||
// .form("userid", 100001700000063120L) // 添加表单字段
|
||||
// .form("base64", base64)
|
||||
// .form("name", "测试.png") // 添加表单字段
|
||||
// .form("size", String.valueOf(originalSize))
|
||||
// .form("lastModified", System.currentTimeMillis());
|
||||
//
|
||||
// // 发送请求并获取响应
|
||||
// HttpResponse response = request.execute();
|
||||
//
|
||||
// // 获取响应状态码
|
||||
// int statusCode = response.getStatus();
|
||||
//
|
||||
// // 获取响应体
|
||||
// String body = response.body();
|
||||
|
||||
// log.error("base64:"+base64);
|
||||
// String docId = docUtil.createdocByBase642("测试.png", base64, "", "100001700000063120", "");
|
||||
|
||||
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
// try {
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
//
|
||||
// // Create the parameters and add the file
|
||||
// MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
||||
// param.add("userid", "811711878160941057");
|
||||
// param.add("name", "测试.png");
|
||||
// param.add("size", String.valueOf(originalSize));
|
||||
// param.add("module", "workflow");
|
||||
// //param.add("access_token", token);
|
||||
// param.add("base64", base64);
|
||||
// // Create the request entity using the parameters and headers
|
||||
// HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(param, headers);
|
||||
// // Send the request
|
||||
// ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
|
||||
// return response.toString();
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/1/6 6:08 PM
|
||||
* @Description: 浏览按钮
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DataOptions {
|
||||
|
||||
|
||||
private Long optionId;
|
||||
|
||||
private Long dataKey;
|
||||
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 选项类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private Boolean matchByName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/1/6 6:08 PM
|
||||
* @Description: 光导物料退库审批流程明细表
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MaterialDetailTablePo {
|
||||
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
private String materialDesc;
|
||||
|
||||
private String departmentId;
|
||||
|
||||
/**
|
||||
* 平均消耗
|
||||
*/
|
||||
private String averageUse;
|
||||
|
||||
/**
|
||||
* 本月累计
|
||||
*/
|
||||
private String sumMonth;
|
||||
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private String inventoryCount;
|
||||
|
||||
/**
|
||||
* 退库数量
|
||||
*/
|
||||
private String outCount;
|
||||
|
||||
|
||||
private String money;
|
||||
|
||||
/**
|
||||
* 成本中心
|
||||
*/
|
||||
private String costCenter;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/1/6 6:08 PM
|
||||
* @Description: 光导物料退库审批流程主表
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MaterialMainTablePo {
|
||||
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 申请单位
|
||||
*/
|
||||
private String applicant;
|
||||
|
||||
private String departmentId;
|
||||
|
||||
/**
|
||||
* 申请日期
|
||||
*/
|
||||
private String applyDate;
|
||||
|
||||
private String sumMoney;
|
||||
|
||||
private String applyNo;
|
||||
|
||||
private String outApplyDate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SubmitWorkflowParam {
|
||||
String loginname;
|
||||
String password;
|
||||
String workflowId;
|
||||
String creator;
|
||||
String requestLevel;
|
||||
String mainTable;
|
||||
String detailTables;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SubmitWorkflowReq {
|
||||
String SENDID = "";
|
||||
String ITFID = "";
|
||||
String SYSID = "";
|
||||
SubmitWorkflowParam DATAS;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.weaver.seconddev.njwebservice.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SubmitWorkflowRes {
|
||||
String SENDID ;
|
||||
String ITFID;
|
||||
String SYSID;
|
||||
String ISTAT;
|
||||
String MESSAGE;
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.weaver.seconddev.njwebservice.util;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||
import com.weaver.common.i18n.tool.util.Util;
|
||||
import com.weaver.verupgrade.conn.CONN_TYPE;
|
||||
import com.weaver.verupgrade.conn.RecordSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/1/7 2:41 PM
|
||||
* @Description: access_token 获取
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class AccessTokenUtil {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(AccessTokenUtil.class);
|
||||
|
||||
private static String CORP_ID = "9d18deb9bbeb98f7a2402808f8bb8ce8";
|
||||
|
||||
//private static String APP_KEY = "179a9854c471d161db69ec9f16c6e1e";
|
||||
private static String APP_KEY = "437dd08a2cd0018bf1242128cab4224c";
|
||||
|
||||
//private static String APP_SECRET = "9aa17e9391d8fdf4be44f78e2a26be30";
|
||||
private static String APP_SECRET = "3e86b82ada2b72fdd3d7929d5623b04f";
|
||||
|
||||
private static String HOST = "http://10.6.23.235:20600/papi/openapi";
|
||||
|
||||
/**
|
||||
* 获取AccessToken
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getToken() throws Exception {
|
||||
|
||||
// 获取code
|
||||
String codeUrl = HOST + "/oauth2/authorize?corpid=" + CORP_ID + "&response_type=code&state=a21";
|
||||
String codeResponse = HttpUtil.get(codeUrl);
|
||||
System.out.println(codeResponse);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(codeResponse);
|
||||
Object errcode = jsonObject.get("errcode");
|
||||
Object code = jsonObject.get("code");
|
||||
log.error("本次获取code值"+code+"==> errcode"+errcode);
|
||||
|
||||
// 根据code 获取token。
|
||||
String tokenUrl = HOST + "/oauth2/access_token";
|
||||
Map<String, Object> tokanParam = new HashMap<>(4);
|
||||
tokanParam.put("app_key", APP_KEY);
|
||||
tokanParam.put("app_secret", APP_SECRET);
|
||||
tokanParam.put("grant_type", "authorization_code");
|
||||
tokanParam.put("code", code);
|
||||
|
||||
String tokenResponse = HttpUtil.post(tokenUrl, tokanParam);
|
||||
log.error("tokenResponse" + tokenResponse);
|
||||
|
||||
JSONObject tokenResponseObj = JSONObject.parseObject(tokenResponse);
|
||||
return Optional.ofNullable(tokenResponseObj.get("accessToken")).map(Object::toString).orElse(new String());
|
||||
}
|
||||
|
||||
|
||||
public static String getAccessToken(String tenantKey) {
|
||||
|
||||
String accesstoken = "";
|
||||
String sql = "select accesstoken from e10_common.dbo.uf_tenant_mt where zzkey='"+tenantKey+"' and delete_type ='0'";
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.ebuilder.getType();
|
||||
rs.setTenantKey(tenantKey);
|
||||
rs.executeSql(sql, poolname);
|
||||
if (rs.next()) {
|
||||
accesstoken = Util.null2String(rs.getString("accesstoken"));
|
||||
}
|
||||
return accesstoken;
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package com.weaver.seconddev.njwebservice.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.weaver.datasource.utils.rest.CommonRestService;
|
||||
import com.weaver.ebuilder.datasource.api.entity.ExecuteSqlEntity;
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SqlParamType;
|
||||
import com.weaver.ebuilder.datasource.api.enums.SourceType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/1/7 2:02 PM
|
||||
* @Description: 数据库操作
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataSetUtil {
|
||||
|
||||
@Autowired
|
||||
private CommonRestService commonRestService;
|
||||
|
||||
public static String base64(String sql) {
|
||||
return Base64.encode(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行服务内部sql:/sapi/secondev/ds/executeSql
|
||||
* sourceType :LOGIC
|
||||
* groupId : weaver-ebuilder-app-service 可以通过group接口获取
|
||||
* sql : select * from ebda_app limit 10
|
||||
* @param sourceType LOGIC: 各模块提供业务数据(逻辑表)
|
||||
* @param groupId
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> executeLogicSql(SourceType sourceType, String groupId, String sql) {
|
||||
//拼接参数
|
||||
Map<String, Object> valueMap = new HashMap<>();
|
||||
valueMap.put("sourceType", sourceType);
|
||||
valueMap.put("groupId", groupId);
|
||||
valueMap.put("sql", base64(sql));
|
||||
|
||||
try {
|
||||
return commonRestService.getForObject("/sapi/secondev/ds/executeSql", valueMap, MediaType.APPLICATION_FORM_URLENCODED, Map.class);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1201基线后支持的聚合执行接口
|
||||
* LOGIC:支持普通sql与预编译sql执行,支持带事务执行
|
||||
* EXTERNAL:支持普通sql与预编译sql执行,不支持带事务执行
|
||||
* @param sourceType 连接类型
|
||||
* @param groupId 连接id
|
||||
* @param sql sql语句
|
||||
* @param sqlParams 预编译sql参数
|
||||
* @param transId 事务id
|
||||
* @param startTrans 是否开启事务
|
||||
* @param commit 是否提交事务
|
||||
* @param rollback 是否回滚事务
|
||||
*/
|
||||
public Map<String, Object> executeSqlWithTrans(SourceType sourceType, String groupId, String sql, List<SqlParamEntity> sqlParams, String transId, Boolean startTrans, Boolean commit, Boolean rollback) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(groupId);
|
||||
executeSqlEntity.setSourceType(sourceType);
|
||||
|
||||
//若通过占位符方式查询外部数据库,需增加此参数
|
||||
//占位符list 的顺序 要与 sql 的?占位符顺序一致
|
||||
if (sqlParams != null && !sqlParams.isEmpty()) {
|
||||
executeSqlEntity.setParams(sqlParams);
|
||||
}
|
||||
//设置事务id
|
||||
if (transId != null && !transId.isEmpty()) {
|
||||
executeSqlEntity.setTransactionId(transId);
|
||||
}
|
||||
//是否开启事务
|
||||
if (startTrans != null && startTrans) {
|
||||
executeSqlEntity.setStartTransaction(true);
|
||||
}
|
||||
//是否提交事务
|
||||
if (commit != null && commit) {
|
||||
executeSqlEntity.setCommitTransaction(true);
|
||||
}
|
||||
//是否回滚事务
|
||||
if (rollback != null && rollback) {
|
||||
executeSqlEntity.setRollbackTransaction(true);
|
||||
}
|
||||
|
||||
//拼接参数
|
||||
Map<String, Object> valueMap = new HashMap<>();
|
||||
valueMap.put("entity", JSONUtil.toJsonStr(executeSqlEntity));
|
||||
|
||||
try {
|
||||
return commonRestService.postForForm("/sapi/secondev/ds/executeSqlAll", Map.class, valueMap);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SqlParamEntity> getSqlParams() {
|
||||
List<SqlParamEntity> sqlParams = new ArrayList<>();
|
||||
|
||||
SqlParamEntity sqlParam1 = new SqlParamEntity();
|
||||
sqlParam1.setParamType(SqlParamType.VARCHAR);
|
||||
sqlParam1.setValue("thsv5s4n2c");
|
||||
sqlParams.add(sqlParam1);
|
||||
|
||||
SqlParamEntity sqlParam2 = new SqlParamEntity();
|
||||
sqlParam2.setParamType(SqlParamType.INTEGER);
|
||||
sqlParam2.setValue("0");
|
||||
sqlParams.add(sqlParam2);
|
||||
|
||||
List<Long> ids = new ArrayList<>();
|
||||
ids.add(1054407582048280585L);
|
||||
ids.add(1054407345976074241L);
|
||||
ids.add(1054406667262189570L);
|
||||
for (Long id : ids) {
|
||||
SqlParamEntity sqlParam3 = new SqlParamEntity();
|
||||
sqlParam3.setParamType(SqlParamType.LONG);
|
||||
sqlParam3.setValue(String.valueOf(id));
|
||||
sqlParams.add(sqlParam3);
|
||||
}
|
||||
|
||||
return sqlParams;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,449 @@
|
||||
package com.weaver.seconddev.njwebservice.util;
|
||||
|
||||
import com.weaver.common.hrm.util.Util;
|
||||
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||
import com.weaver.eteams.file.client.file.FileObj;
|
||||
import com.weaver.eteams.file.client.param.RemoteUploadParam;
|
||||
import com.weaver.file.ud.api.FileUploadService;
|
||||
import com.weaver.teams.domain.EntityType;
|
||||
import com.weaver.verupgrade.conn.CONN_TYPE;
|
||||
import com.weaver.verupgrade.conn.RecordSet;
|
||||
import org.apache.axis.encoding.Base64;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* createby jianyong.tang
|
||||
* createTime
|
||||
* version v1
|
||||
* desc
|
||||
*/
|
||||
@Component
|
||||
public class DocUtil {
|
||||
/**
|
||||
* 16进制字符串获取文档id
|
||||
* @param filename
|
||||
* @param data16
|
||||
* @param seccategory
|
||||
* @param createrid
|
||||
* @return
|
||||
*/
|
||||
private final Logger log = LoggerFactory.getLogger(DocUtil.class);
|
||||
|
||||
public static byte[] hexStringToByteArray(String s) {
|
||||
int len = s.length();
|
||||
byte[] data = new byte[len / 2];
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||
+ Character.digit(s.charAt(i + 1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static String hexStringToString(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
return null;
|
||||
}
|
||||
s = s.replace(" ", "");
|
||||
byte[] baKeyword = new byte[s.length() / 2];
|
||||
for (int i = 0; i < baKeyword.length; i++) {
|
||||
try {
|
||||
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||
// new String();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private FileUploadService fileUploadService;
|
||||
public String createdocByBase642(String filename,String base64Str,String seccategory,String createrid,String tenantKey){
|
||||
String docid = "";
|
||||
try {
|
||||
//DocAccService das = new DocAccService();
|
||||
RemoteUploadParam remoteUploadParam = new RemoteUploadParam(filename, "", EntityType.document.name());
|
||||
FileObj fileObj = fileUploadService.uploadLocalFileWithBase64(toSemiangle(base64Str.replace(" ","").replace("\r","")), Long.valueOf(createrid), "", remoteUploadParam);
|
||||
//long imagefileid = das.getFileByBase64(toSemiangle(base64Str), filename);
|
||||
long imagefileid = ObjectUtils.isEmpty(fileObj) ? -1L : fileObj.getFileid();
|
||||
docid=String.valueOf(imagefileid);
|
||||
// DocSaveService var22 = new DocSaveService();
|
||||
// if(imagefileid>0){
|
||||
// RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
// String poolname = CONN_TYPE.hrm.getType();
|
||||
// rs.setTenantKey(tenantKey);
|
||||
// String departmentId="-1";
|
||||
// String sql="SELECT department FROM eteams.dbo.employee WHERE id = '"+createrid+"' AND delete_type = 0 AND tenant_key = '"+tenantKey+"'";
|
||||
// rs.executeSql(sql, poolname);
|
||||
// User user = new User();
|
||||
// if(rs.next()){
|
||||
// departmentId = Util.null2String(rs.getString("department"));
|
||||
// }
|
||||
// user.setUid(Long.valueOf(createrid));
|
||||
// user.setUserDepartment(Long.valueOf(departmentId));
|
||||
// user.setLanguage(7);
|
||||
// user.setLogintype("1");
|
||||
// user.setLoginip("127.0.0.1");
|
||||
//
|
||||
// log.error("seccategory:"+seccategory+"ten:"+HrmContextUtil.getCurrentTenantKey()+" imagefileid:"+imagefileid+" user:"+user.getUID());
|
||||
// docid=String.valueOf(var22.accForDoc(Long.valueOf(seccategory),imagefileid,user));
|
||||
// }
|
||||
//拿到附件id就可以更新到流程表字段
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("e",e);
|
||||
}
|
||||
return docid;
|
||||
}
|
||||
|
||||
public String toSemiangle(String src) {
|
||||
char[] c = src.toCharArray();
|
||||
for (int index = 0; index < c.length; index++) {
|
||||
if (c[index] == 12288) {// 全角空格
|
||||
c[index] = (char) 32;
|
||||
} else if (c[index] > 65280 && c[index] < 65375) {// 其他全角字符
|
||||
c[index] = (char) (c[index] - 65248);
|
||||
}
|
||||
}
|
||||
return String.valueOf(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Map<String,String> getDocInfo(String docid,String tenantKey) throws Exception {
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.document.getType();
|
||||
rs.setTenantKey(tenantKey);
|
||||
Map<String,String> docmap = new HashMap<>();
|
||||
String uploadBuffer="";//base64字符串
|
||||
String sql = " select c.file_path ,c.file_url ,b.id as imagefileid,b.size ,b.NAME from e10_core_business.dbo.document a,e10_core_business.dbo.fileobj b,e10_core_business.dbo.file_storage_info c where a.id=b.REF_ID and b.URL =c.file_url " +
|
||||
"and a.ID ="+docid+" " +
|
||||
"AND a.delete_type = 0 " +
|
||||
"AND a.tenant_key = '"+tenantKey+"' " +
|
||||
"AND b.delete_type = 0 " +
|
||||
"AND b.tenant_key = '"+tenantKey+"' " +
|
||||
"AND c.delete_type = 0 " +
|
||||
"AND c.tenant_key = '"+tenantKey+"';";
|
||||
rs.executeSql(sql, poolname);
|
||||
if(rs.next()){
|
||||
String imagefileid = Util.null2String(rs.getString("imagefileid"));
|
||||
String filerealpath = Util.null2String(rs.getString("file_path"))+"/"+Util.null2String(rs.getString("file_url"));
|
||||
String iszip ="1";
|
||||
String filesize = Util.null2String(rs.getString("size"));
|
||||
String imagefilename = Util.null2String(rs.getString("NAME"));//文件名
|
||||
InputStream fi = getFile(filerealpath,iszip);
|
||||
docmap.put("imagefileid",imagefileid);
|
||||
docmap.put("filename",imagefilename);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int count = 0;
|
||||
while((count = fi.read(buffer)) >= 0){
|
||||
baos.write(buffer, 0, count);
|
||||
}
|
||||
uploadBuffer = Base64.encode(baos.toByteArray());
|
||||
docmap.put("base64str",uploadBuffer);
|
||||
docmap.put("filesize",filesize);
|
||||
baos.close();
|
||||
//这里就可以封装 文件名和文件内容 传给第三方系统
|
||||
}
|
||||
return docmap;
|
||||
|
||||
}
|
||||
|
||||
public Map<String,String> getDocInfoWf(String fileid,String tenantKey) throws Exception {
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.document.getType();
|
||||
rs.setTenantKey(tenantKey);
|
||||
Map<String,String> docmap = new HashMap<>();
|
||||
String uploadBuffer="";//base64字符串
|
||||
String sql = " select c.file_path ,c.file_url ,b.id as imagefileid,b.size ,b.NAME from e10_core_business.dbo.fileobj b,e10_core_business.dbo.file_storage_info c where b.URL =c.file_url " +
|
||||
"and b.ID ="+fileid+" " +
|
||||
"AND b.delete_type = 0 " +
|
||||
"AND b.tenant_key = '"+tenantKey+"' " +
|
||||
"AND c.delete_type = 0 " +
|
||||
"AND c.tenant_key = '"+tenantKey+"';";
|
||||
rs.executeSql(sql, poolname);
|
||||
if(rs.next()){
|
||||
String imagefileid = Util.null2String(rs.getString("imagefileid"));
|
||||
String filerealpath = Util.null2String(rs.getString("file_path"))+"/"+Util.null2String(rs.getString("file_url"));
|
||||
String iszip ="1";
|
||||
String filesize = Util.null2String(rs.getString("size"));
|
||||
String imagefilename = Util.null2String(rs.getString("NAME"));//文件名
|
||||
InputStream fi = getFile(filerealpath,iszip);
|
||||
docmap.put("imagefileid",imagefileid);
|
||||
docmap.put("filename",imagefilename);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int count = 0;
|
||||
while((count = fi.read(buffer)) >= 0){
|
||||
baos.write(buffer, 0, count);
|
||||
}
|
||||
uploadBuffer = Base64.encode(baos.toByteArray());
|
||||
docmap.put("base64str",uploadBuffer);
|
||||
docmap.put("filesize",filesize);
|
||||
baos.close();
|
||||
//这里就可以封装 文件名和文件内容 传给第三方系统
|
||||
}
|
||||
return docmap;
|
||||
|
||||
}
|
||||
/**
|
||||
* 根据系统文档存放路径 获取文档流
|
||||
* @param filerealpath 文档存放路径
|
||||
* @param iszip 是否压缩包
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private InputStream getFile(String filerealpath, String iszip)
|
||||
throws Exception {
|
||||
ZipInputStream zin = null;
|
||||
InputStream imagefile = null;
|
||||
File thefile = new File(filerealpath);
|
||||
if (iszip.equals("1")) {
|
||||
zin = new ZipInputStream(new FileInputStream(thefile));
|
||||
if (zin.getNextEntry() != null)
|
||||
imagefile = new BufferedInputStream(zin);
|
||||
} else {
|
||||
imagefile = new BufferedInputStream(new FileInputStream(thefile));
|
||||
}
|
||||
return imagefile;
|
||||
}
|
||||
|
||||
public String getShareRyids(String wdid,String tenantKey){
|
||||
StringBuffer ryids = new StringBuffer();
|
||||
if("".equals(wdid)){
|
||||
return "";
|
||||
}
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.document.getType();
|
||||
rs.setTenantKey(tenantKey);
|
||||
RecordSet rs_dt = I18nContextUtil.getBean(RecordSet.class);
|
||||
rs_dt.setTenantKey(tenantKey);
|
||||
String typeids = "";
|
||||
String flag = "";
|
||||
String sql_dt = "";
|
||||
String sql = "select distinct target_type from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"'";
|
||||
rs.executeSql(sql, poolname);
|
||||
while (rs.next()){
|
||||
String type = Util.null2String(rs.getString("target_type"));
|
||||
typeids = typeids + flag +type;
|
||||
flag = ",";
|
||||
}
|
||||
poolname = CONN_TYPE.hrm.getType();
|
||||
typeids = ","+typeids+",";
|
||||
log.error(typeids);
|
||||
flag = "";
|
||||
if(typeids.indexOf(",11,")>=0){//所有人
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type=11";
|
||||
rs.executeSql(sql, CONN_TYPE.document.getType());
|
||||
if(rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
}
|
||||
sql = "select id from eteams.dbo.employee WHERE PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax +" AND delete_type = 0 AND tenant_key = '"+tenantKey+"'";
|
||||
rs.executeSql(sql, poolname);
|
||||
while (rs.next()){
|
||||
ryids.append(flag).append(rs.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
|
||||
}
|
||||
if(typeids.indexOf(",5,")>=0 || typeids.indexOf(",501,")>=0){//分部
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String subcomid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(5,501)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
subcomid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(subcomid)){
|
||||
continue;
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a,eteams.dbo.department b WHERE a.DEPARTMENT =b.id and b.subcompanyid ='"+subcomid+"' and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax +" AND a.delete_type = 0 AND a.tenant_key = '"+tenantKey+"'";
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(typeids.indexOf(",6,")>=0 || typeids.indexOf(",502,")>=0){//分部下级
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String subcomid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(6,502)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
subcomid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(subcomid)){
|
||||
continue;
|
||||
}
|
||||
String comids = "";
|
||||
String flag1 = "";
|
||||
sql_dt = "WITH allsub(id,name,parent) " +
|
||||
"as ( " +
|
||||
"SELECT id,name ,parent FROM eteams.dbo.department where id in("+subcomid+") and type = 'subcompany' AND virtualid = 1 and STATUS =1 AND delete_type = 0 AND tenant_key = '"+tenantKey+"' " +
|
||||
" UNION ALL SELECT a.id,a.name,a.parent FROM eteams.dbo.department a,allsub b where a.parent = b.id and type = 'subcompany' AND virtualid = 1 and STATUS =1 AND delete_type = 0 AND tenant_key = '"+tenantKey+"' " +
|
||||
") select id from allsub";
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
comids = comids + flag1 +rs_dt.getString("id");
|
||||
flag1 = ",";
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a,eteams.dbo.department b WHERE a.DEPARTMENT =b.id and b.subcompanyid in("+comids+") and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax +" AND a.delete_type = 0 AND a.tenant_key = '"+tenantKey+"'";
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(typeids.indexOf(",2,")>=0||typeids.indexOf(",2002,")>=0){//部门
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String deptid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(2,2002)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
deptid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(deptid)){
|
||||
continue;
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a WHERE a.DEPARTMENT ='"+deptid+"' and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax +" AND delete_type = 0 AND tenant_key = '"+tenantKey+"'";
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(typeids.indexOf(",3,")>=0 || typeids.indexOf(",3002,")>=0){//部门含下级
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String deptid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(3,3002)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
deptid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(deptid)){
|
||||
continue;
|
||||
}
|
||||
String deptids = "";
|
||||
String flag1 = "";
|
||||
sql_dt = "WITH allsub(id,name,parent) " +
|
||||
"as ( " +
|
||||
"SELECT id,name ,parent FROM eteams.dbo.department where id in("+deptid+") and type = 'department' AND virtualid = 1 and STATUS =1 AND delete_type = 0 AND tenant_key = '"+tenantKey+"' " +
|
||||
" UNION ALL SELECT a.id,a.name,a.parent FROM eteams.dbo.department a,allsub b where a.parent = b.id and type = 'department' AND virtualid = 1 and STATUS =1 AND delete_type = 0 AND tenant_key = '"+tenantKey+"' " +
|
||||
") select id from allsub";
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
deptids = deptids + flag1 +rs_dt.getString("id");
|
||||
flag1 = ",";
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a WHERE a.DEPARTMENT in("+deptids+") and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax +" AND delete_type = 0 AND tenant_key = '"+tenantKey+"'";
|
||||
log.error(sql_dt);
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(typeids.indexOf(",1,")>=0){//人员
|
||||
String ryid = "";
|
||||
sql = "select target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(1)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
ryid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(ryid)){
|
||||
continue;
|
||||
}
|
||||
ryids.append(flag).append(ryid);
|
||||
flag = ",";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(typeids.indexOf(",10,")>=0){//角色 人员
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String roleid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(10)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
roleid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(roleid)){
|
||||
continue;
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a where id in(SELECT user_id FROM eteams.dbo.auth_user_role WHERE role_id = "+roleid+" AND resource_type = 'RESOURCE' AND delete_type = 0 AND tenant_key = '"+tenantKey+"' ) and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax;
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(typeids.indexOf(",1411,")>=0){//群组
|
||||
String seclevel = "";
|
||||
String seclevelmax = "";
|
||||
String groupid = "";
|
||||
sql = "select target_min_sec_level ,target_max_sec_level,target_id from e10_core_business.dbo.document_ph_doc_s01 where source_id="+wdid+" and delete_type=0 and tenant_key ='"+tenantKey+"' and target_type in(1411)";
|
||||
rs.executeSql(sql,CONN_TYPE.document.getType());
|
||||
while (rs.next()){
|
||||
seclevel = Util.null2String(rs.getString("target_min_sec_level"));
|
||||
seclevelmax = Util.null2String(rs.getString("target_max_sec_level"));
|
||||
groupid = Util.null2String(rs.getString("target_id"));
|
||||
if("".equals(groupid)){
|
||||
continue;
|
||||
}
|
||||
sql_dt = "SELECT a.id FROM eteams.dbo.employee a where id in(SELECT employee FROM eteams.dbo.channel_user_link where channel="+groupid+" and delete_type=0) and PERSONNEL_STATUS <6 and sec_level>="+seclevel+" and sec_level<="+seclevelmax;
|
||||
rs_dt.executeSql(sql_dt,poolname);
|
||||
while (rs_dt.next()){
|
||||
ryids.append(flag).append(rs_dt.getString("id"));
|
||||
flag = ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ryids.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
package com.weaver.seconddev.njwebservice.util;
|
||||
|
||||
import com.weaver.common.hrm.util.Util;
|
||||
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||
import com.weaver.verupgrade.conn.CONN_TYPE;
|
||||
import com.weaver.verupgrade.conn.RecordSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ClassName WfUtil
|
||||
* Author
|
||||
* Date 2025/1/2 8:56
|
||||
* Description WfUtil
|
||||
* Version 1.0
|
||||
*/
|
||||
public class WfUtil {
|
||||
private final Logger log = LoggerFactory.getLogger(WfUtil.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jtzhTenantKey 集团租户TenantKey
|
||||
* @param workcode 流程创建人工号
|
||||
* @param wfid 流程id
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getZhWfMap(String jtzhTenantKey,String workcode,String wfid){
|
||||
log.error("getZhWfMap start : " + wfid );
|
||||
String currentWfid = wfid;//触发过来的wfid
|
||||
String validWfif = "";//有效wfid
|
||||
if(currentWfid.length()<=8){
|
||||
currentWfid = getStrNum(currentWfid,8);
|
||||
}
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.ebuilder.getType();
|
||||
rs.setTenantKey(jtzhTenantKey);
|
||||
//从集团租户 根据传入的wfid获取有效的wfid
|
||||
validWfif = getValidWfid(jtzhTenantKey,currentWfid);
|
||||
log.error("getZhWfMap validWfif : " + validWfif );
|
||||
if("".equals(validWfif)){//如果为空就是其他租户的新流程
|
||||
validWfif = currentWfid;
|
||||
}
|
||||
//根据传入的wfid和获取到的当前有效的wfid 从配置表获取对应租户和对应wfid
|
||||
String sszh = "";//所属租户
|
||||
String jtwfid = "";//集团wfid
|
||||
String gdwfid = "";//光电wfid
|
||||
String hhwfid = "";//华海wfid
|
||||
String workflowid = "";
|
||||
String sql = "select sszh,jtwfid,gdwfid,hhwfid from e10_common.dbo.uf_zhwfid_mt where (cfwfid like '%"+currentWfid+"' or cfwfid like '%"+validWfif+"') and delete_type ='0'";
|
||||
rs.executeSql(sql,poolname);
|
||||
if(rs.next()){
|
||||
sszh = Util.null2String(rs.getString("sszh"));
|
||||
jtwfid = Util.null2String(rs.getString("jtwfid"));
|
||||
gdwfid = Util.null2String(rs.getString("gdwfid"));
|
||||
hhwfid = Util.null2String(rs.getString("hhwfid"));
|
||||
}
|
||||
|
||||
log.error("getZhWfMap sszh : " + sszh );
|
||||
String tenantKey = "";
|
||||
if("3".equals(sszh)){//全租户 判断创建人是哪个租户的 取对应租户的 wfid;
|
||||
String zhbs = getZhbs(workcode,jtzhTenantKey);
|
||||
sszh = getZhbsInfo(zhbs,jtzhTenantKey);
|
||||
}
|
||||
if("0".equals(sszh)){//集团
|
||||
workflowid =jtwfid;
|
||||
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
|
||||
}else if("1".equals(sszh)){//光电
|
||||
workflowid =gdwfid;
|
||||
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
|
||||
}else if("2".equals(sszh)){//华海租户
|
||||
workflowid = hhwfid;
|
||||
tenantKey = getZhTenantKey(sszh,jtzhTenantKey);
|
||||
}
|
||||
log.error("getZhWfMap workflowid : " + workflowid );
|
||||
if("".equals(workflowid)){
|
||||
workflowid = validWfif;
|
||||
tenantKey = jtzhTenantKey;
|
||||
}
|
||||
validWfif = getValidWfid(tenantKey,workflowid);
|
||||
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("workflowid",validWfif);
|
||||
map.put("tenantKey",tenantKey);
|
||||
log.error("map : " + map );
|
||||
return map;
|
||||
}
|
||||
|
||||
public String getZhbs(String workcode,String jtzhTenantKey){
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.hrm.getType();
|
||||
rs.setTenantKey(jtzhTenantKey);
|
||||
String field3 = "";
|
||||
String sql = "select isnull(field3,'') as field3 from eteams.dbo.employee a,eteams.dbo.hrmemployeedefined b where a.formdata =b.FORM_DATA_ID and a.job_num = '"+workcode+"' AND a.delete_type = 0 AND a.tenant_key = '"+jtzhTenantKey+"' AND b.delete_type = 0 AND b.tenant_key = '"+jtzhTenantKey+"'";
|
||||
rs.executeSql(sql,poolname);
|
||||
if(rs.next()){
|
||||
field3 = Util.null2String(rs.getString("field3"));
|
||||
}
|
||||
if("".equals(field3)||"mgl".equals(field3)){
|
||||
field3="HTJT";
|
||||
}
|
||||
return field3;
|
||||
}
|
||||
|
||||
public String getZhbsInfo(String zhbs,String jtzhTenantKey){
|
||||
String sszh = "";
|
||||
Map<String,String> map = new HashMap<>();
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.ebuilder.getType();
|
||||
rs.setTenantKey(jtzhTenantKey);
|
||||
String sql = "select zzkey,sszh from e10_common.dbo.uf_tenant_mt where zhbs='"+zhbs+"' and delete_type ='0'";
|
||||
rs.executeSql(sql,poolname);
|
||||
if(rs.next()){
|
||||
sszh = Util.null2String(rs.getString("sszh"));
|
||||
}
|
||||
return sszh;
|
||||
}
|
||||
|
||||
public String getZhTenantKey(String sszh,String jtzhTenantKey){
|
||||
String zzkey = "";
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.ebuilder.getType();
|
||||
rs.setTenantKey(jtzhTenantKey);
|
||||
String sql = "select zzkey from e10_common.dbo.uf_tenant_mt where sszh='"+sszh+"' and delete_type ='0'";
|
||||
rs.executeSql(sql,poolname);
|
||||
if(rs.next()){
|
||||
zzkey = Util.null2String(rs.getString("zzkey"));
|
||||
}
|
||||
return zzkey;
|
||||
}
|
||||
|
||||
|
||||
public String getValidWfid(String tenantKey,String wfid){
|
||||
String workflowid = "";
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
rs.setTenantKey(tenantKey);
|
||||
String sql = "SELECT CASE WHEN status = 1 THEN id ELSE activewfid END AS workflowid FROM e10_core_business.dbo.wfp_base WHERE id like '%"+wfid+"' AND delete_type = 0 AND tenant_key = '"+tenantKey+"'";
|
||||
// log.error("oaflowid:"+sql);
|
||||
rs.executeSql(sql,CONN_TYPE.workflow.getType());
|
||||
if(rs.next()){
|
||||
workflowid = Util.null2String(rs.getString("workflowid"));
|
||||
}
|
||||
return workflowid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getStrNum(String num,int len){
|
||||
String buff = num;
|
||||
int max = len - buff.length();
|
||||
for(int index = 0; index < max;index++){
|
||||
buff = "0" + buff;
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue