项目初始化创建
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua;
|
||||
|
||||
import com.seeyon.apps.common.plugin.api.APluginInfoApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.constants.HsDataSyncConstants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataPluginApi extends APluginInfoApi {
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return HsDataSyncConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateUser() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigVo getDefaultConfig() {
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
for (HsDataSyncConstants value : HsDataSyncConstants.values()) {
|
||||
if(value != HsDataSyncConstants.plugin) {
|
||||
configVo.getDevParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getProdParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getParamMap().put(value.name(), value.getDescription());
|
||||
}
|
||||
}
|
||||
return configVo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerCustomEvent(Map eventAndNodes) {
|
||||
// 如果每个模板不一样 可以采用templatemanager去读取编码配置
|
||||
eventAndNodes.put("hsdata", "历史数据推送");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.constants;
|
||||
|
||||
public enum HsDataSyncConstants {
|
||||
|
||||
// 如果有其他参数 这里去新增 todo
|
||||
plugin("chushihua","插件ID"),
|
||||
temp("hsdata_", "模板前缀"),
|
||||
lastUpdate("2000-01-01 00:00:00", "最后更新时间"),
|
||||
url("", "接口地址");
|
||||
|
||||
HsDataSyncConstants(String defaultValue, String description) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String defaultValue;
|
||||
private String description;
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static String getPluginId() {
|
||||
return plugin.defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.quartz;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.common.util.StringKit;
|
||||
import com.seeyon.apps.common.workflow.constants.WorkFlowType;
|
||||
import com.seeyon.apps.common.workflow.parser.FormParseFactory;
|
||||
import com.seeyon.apps.common.workflow.util.FormDataBeanUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.constants.HsDataSyncConstants;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.vo.HsDataVo;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiNewUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.InterfaceListUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.PropKit;
|
||||
import com.seeyon.apps.ext.po.CstWorkFlowRequestTemplate;
|
||||
import com.seeyon.apps.ext.quartz.AbstractQuartzTask;
|
||||
import com.seeyon.apps.ext.workflow.manager.CstWorkFlowTemplateManager;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
|
||||
import com.seeyon.cap4.form.api.FormApi4Cap4;
|
||||
import com.seeyon.cap4.form.bean.FormBean;
|
||||
import com.seeyon.cap4.form.bean.FormDataMasterBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.SystemEnvironment;
|
||||
import com.seeyon.ctp.common.exceptions.BusinessException;
|
||||
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
||||
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
||||
import com.seeyon.ctp.common.po.template.CtpTemplate;
|
||||
import com.seeyon.ctp.common.template.manager.TemplateManager;
|
||||
import com.seeyon.ctp.organization.bo.V3xOrgMember;
|
||||
import com.seeyon.ctp.organization.manager.OrgManager;
|
||||
import com.seeyon.ctp.organization.manager.OrgManagerDirect;
|
||||
import com.seeyon.ctp.util.DateUtil;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import com.seeyon.ctp.util.Strings;
|
||||
import com.seeyon.ctp.util.json.JSONUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
* 定时同步历史数据
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataSyncQuartz extends AbstractQuartzTask {
|
||||
|
||||
private static final Log log = LogFactory.getLog(HsDataSyncQuartz.class);
|
||||
|
||||
|
||||
@Inject
|
||||
private ICstConfigApi cstConfigApi;
|
||||
@Inject
|
||||
private TemplateManager templateManager;
|
||||
@Inject
|
||||
private FormApi4Cap4 formApi4Cap4;
|
||||
@Inject
|
||||
private CstWorkFlowTemplateManager cstWorkFlowTemplateManager;
|
||||
|
||||
private AttachmentManager attachmentManager;
|
||||
|
||||
public void setAttachmentManager(AttachmentManager attachmentManager) {
|
||||
this.attachmentManager = attachmentManager;
|
||||
}
|
||||
|
||||
public AttachmentManager getAttachmentManagery() {
|
||||
if (attachmentManager == null) {
|
||||
attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
||||
}
|
||||
return attachmentManager;
|
||||
}
|
||||
|
||||
private OrgManager orgManager;
|
||||
|
||||
public OrgManager getOrgManager() {
|
||||
if (this.orgManager == null) {
|
||||
this.orgManager = ((OrgManager) AppContext.getBean("orgManager"));
|
||||
}
|
||||
return orgManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String taskRun(String tempCode) throws Exception {
|
||||
System.out.println("进入同步方法");
|
||||
final Map<String, Object> regist = FanWeiNewUtil.Regist(PropKit.getProp(PropKit.NEWADDRESS));
|
||||
System.out.println(regist);
|
||||
System.out.println("spk:" + regist.get("spk"));
|
||||
// return null;
|
||||
|
||||
//模板id
|
||||
Object templeteId = null;
|
||||
// 查询满足条件的id
|
||||
String sql = "select id from ctp_template where TEMPLETE_NUMBER = ? ";
|
||||
System.out.println(sql+tempCode);
|
||||
try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(tempCode);
|
||||
agent.execute(sql, params);
|
||||
List<Map<String, Object>> list = agent.resultSetToList();
|
||||
System.out.println(list.size());
|
||||
templeteId = list.get(0).get("id");
|
||||
System.out.println(templeteId);
|
||||
} catch (Exception e) {
|
||||
log.error("获取模板id失败:", e);
|
||||
}
|
||||
ceshi(Long.parseLong(templeteId.toString()), tempCode);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
* 调用第三方接口推送数据
|
||||
* null 表示成功 其他为失败信息
|
||||
* </pre>
|
||||
* @param request
|
||||
* @return: java.lang.String
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
**/
|
||||
private String push(String request, ConfigVo configVo) {
|
||||
// todo 获取配置信息 调用接口
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ceshi(Long tempId, String tempCode) throws IOException {
|
||||
System.out.println("进入ceshi方法");
|
||||
List<Map> datas = new ArrayList();
|
||||
Map<Long, FormBean> formBeanMap = new HashMap<>();
|
||||
|
||||
String dataSql = PropKit.getProp(PropKit.DATASQL);
|
||||
try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(tempId);
|
||||
agent.execute(dataSql, params);
|
||||
// 获取到所有的流程数据
|
||||
List<Map<String, Object>> list = agent.resultSetToList();
|
||||
if(null != list) {
|
||||
List<HsDataVo> hsData = list.stream().map(HsDataVo::new).collect(Collectors.toList());
|
||||
for (int i = 0; i < hsData.size(); i++) {
|
||||
Map data = new HashMap();
|
||||
HsDataVo hsDatum = hsData.get(i);
|
||||
FormBean formBean = formBeanMap.get(hsDatum.getFormId());
|
||||
if (null == formBean) {
|
||||
formBean = formApi4Cap4.getForm(hsDatum.getFormId());
|
||||
formBeanMap.put(hsDatum.getFormId(), formBean);
|
||||
}
|
||||
FormDataMasterBean masterBean = formApi4Cap4.getDataMasterBeanById(hsDatum.getMasterId(), formBean, null);
|
||||
// 转换数据
|
||||
FormDataVo formDataVo = FormDataBeanUtil.trans2FormDataVo(HsDataSyncConstants.getPluginId(), hsDatum.getFormId(),
|
||||
hsDatum.getSummaryId(), formBean, masterBean);
|
||||
String name = "";
|
||||
if ("formmain_9291".equals(tempCode)) {
|
||||
name = formDataVo.getFieldData("客户名称文本").getStringValue();
|
||||
} else {
|
||||
String userName = formDataVo.getFieldData("客户名称").getStringValue();
|
||||
System.out.println("userName:" + userName);
|
||||
V3xOrgMember member = getOrgManager().getMemberByLoginName(userName);
|
||||
name = member.getName();
|
||||
}
|
||||
System.out.println("判断名称是否为指定名称"+name);
|
||||
if(!("宜昌高新区盛世禾百货商行".equals(name)||"宜昌市西陵区高东云食品经营部".equals(name)||"宜昌市猇亭区明喜副食店".equals(name)||
|
||||
"湖北省馫昊商贸有限责任公司".equals(name)||"湖北省馫昊商贸有限责任公司".equals(name)||"宜昌梦泽涵商贸有限公司 ".equals(name))){
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("致远客户名称:" + name);
|
||||
Map userIdAndDeptId = getUserIdAndDeptId(name);
|
||||
System.out.println("人员信息:" + userIdAndDeptId.toString());
|
||||
data.put("khmc", userIdAndDeptId.get("userid"));
|
||||
data.put("fgs", userIdAndDeptId.get("deptid"));
|
||||
data.put("bt", formBean.getFormName());
|
||||
data.put("dh", formDataVo.getFieldData("流水号").getStringValue());
|
||||
data.put("sqrq", formDataVo.getFieldData("填表日期").getStringValue());
|
||||
data.put("trje", formDataVo.getFieldData("投入金额").getStringValue());
|
||||
data.put("bayj", formDataVo.getFieldData("备案意见").getStringValue());
|
||||
data.put("bajs", formDataVo.getFieldData("备案简述").getStringValue());
|
||||
data.put("ssschxsgs", formDataVo.getFieldData("分公司").getStringValue());
|
||||
data.put("jbr", formDataVo.getFieldData("经办人").getStringValue());
|
||||
data.put("lcbt", formBean.getFormName());
|
||||
|
||||
String pathId = formDataVo.getFieldData("上传附件").getStringValue();
|
||||
//附件
|
||||
JSONArray faths = null;
|
||||
if (pathId == null || "".equals(pathId)) {
|
||||
faths = new JSONArray();
|
||||
} else {
|
||||
faths = getPathUrl(pathId);
|
||||
}
|
||||
Map parm = FanWeiNewUtil.createWF2(data, faths);
|
||||
//调用新建接口
|
||||
String userId = null;
|
||||
Object userid = userIdAndDeptId.get("userid");
|
||||
if (userid == null || "".equals(userid)) {
|
||||
userId = "";
|
||||
} else {
|
||||
userId = userid.toString();
|
||||
}
|
||||
String s = FanWeiNewUtil.PostRestful(parm, userId);
|
||||
//String s = FanWeiUtil.PostRestful(parm, userId);
|
||||
System.out.println("新建推送结果" + s);
|
||||
JSONObject returnMsg = JSON.parseObject(s);
|
||||
Object code = returnMsg.get("code");
|
||||
if ("SUCCESS".equals(code.toString())) {
|
||||
System.out.println("同步成功!");
|
||||
}else {
|
||||
System.out.println("同步失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步失败:" + tempId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取userid和deptid
|
||||
* @param userName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map getUserIdAndDeptId(String userName) throws Exception {
|
||||
// 新平台指定对应关系
|
||||
Map datas = new HashMap();
|
||||
if("宜昌梦泽涵商贸有限公司".equals(userName)){
|
||||
datas.put("userid", "51");
|
||||
datas.put("deptid", "1545");
|
||||
}else if ("伍家岗区源玥酒水商行".equals(userName)){
|
||||
datas.put("userid", "50");
|
||||
datas.put("deptid", "1553");
|
||||
}else if ("湖北省馫昊商贸有限责任公司".equals(userName)){
|
||||
datas.put("userid", "49");
|
||||
datas.put("deptid", "1555");
|
||||
}else if ("宜昌市猇亭区明喜副食店".equals(userName)){
|
||||
datas.put("userid", "48");
|
||||
datas.put("deptid", "1537");
|
||||
}else if ("宜昌市西陵区高东云食品经营部".equals(userName)){
|
||||
datas.put("userid", "47");
|
||||
datas.put("deptid", "1530");
|
||||
}else if ("宜昌高新区盛世禾百货商行".equals(userName)){
|
||||
datas.put("userid", "46");
|
||||
datas.put("deptid", "1529");
|
||||
}
|
||||
// Map datas = new HashMap();
|
||||
// String sql = PropKit.getProp(PropKit.SQL);
|
||||
// try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
// List<Object> params = new ArrayList<>();
|
||||
// params.add(userName);
|
||||
// agent.execute(sql, params);
|
||||
// List<Map<String, Object>> list = agent.resultSetToList();
|
||||
// Map<String, Object> map = list.get(0);
|
||||
// datas.put("userid", map.get("id"));
|
||||
// datas.put("deptid", map.get("departmentid"));
|
||||
// } catch (Exception e) {
|
||||
// log.error("获取模板id失败:", e);
|
||||
// }
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件路径
|
||||
* @param pathId
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getPathUrl(String pathId) throws IOException {
|
||||
InterfaceListUtil interfaceListUtil = new InterfaceListUtil();
|
||||
String oatoken = interfaceListUtil.getToken(PropKit.getProp(PropKit.LOGINNAME));
|
||||
long aLong = Long.parseLong(pathId);
|
||||
final List<Long> attachmentIds = attachmentManager.getBySubReference(aLong);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 0 ; i < attachmentIds.size();i++) {
|
||||
Attachment attachment = attachmentManager.getAttachmentByFileURL(attachmentIds.get(i));
|
||||
Long fileUrl = attachment.getFileUrl();
|
||||
String filename = attachment.getFilename();
|
||||
String fileType = filename.substring(filename.lastIndexOf(".")+1);
|
||||
String oaFileName = filename.substring(0,filename.lastIndexOf("."));
|
||||
//调用接口下载文件,文件存放在指定的路径下
|
||||
String dowUrl = PropKit.getProp(PropKit.DOWURL)+"/"+fileUrl+"?fileName="+fileType+"&token="+oatoken;
|
||||
String str = SystemEnvironment.getApplicationFolder();
|
||||
String dowPath = str+"/dhxfile/"+filename;
|
||||
String download = interfaceListUtil.download(dowUrl, dowPath);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", filename);
|
||||
jsonObject.put("type", fileType);
|
||||
jsonObject.put("url", PropKit.getProp(PropKit.JYNCFILE)+"/"+filename);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.vo;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataVo {
|
||||
|
||||
|
||||
private Long summaryId;
|
||||
private Long formId;
|
||||
private Long masterId;
|
||||
|
||||
public HsDataVo(Map<String, Object> row) {
|
||||
this.summaryId = Convert.toLong(row.get("id"));
|
||||
this.masterId = Convert.toLong(row.get("form_recordid"));
|
||||
this.formId = Convert.toLong(row.get("form_appid"));
|
||||
}
|
||||
|
||||
public Long getSummaryId() {
|
||||
return summaryId;
|
||||
}
|
||||
|
||||
public HsDataVo setSummaryId(Long summaryId) {
|
||||
this.summaryId = summaryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getFormId() {
|
||||
return formId;
|
||||
}
|
||||
|
||||
public HsDataVo setFormId(Long formId) {
|
||||
this.formId = formId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getMasterId() {
|
||||
return masterId;
|
||||
}
|
||||
|
||||
public HsDataVo setMasterId(Long masterId) {
|
||||
this.masterId = masterId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
41
src/com/seeyon/apps/daohuaxiangSys/jkts/TongYongPlugin.java
Normal file
41
src/com/seeyon/apps/daohuaxiangSys/jkts/TongYongPlugin.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts;
|
||||
|
||||
import com.seeyon.apps.common.plugin.api.APluginInfoApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.constants.DaohuaxiangConstants;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/10/25
|
||||
*/
|
||||
public class TongYongPlugin extends APluginInfoApi {
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return DaohuaxiangConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateUser() {
|
||||
return "稻花香";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigVo getDefaultConfig() {
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
for (DaohuaxiangConstants value : DaohuaxiangConstants.values()) {
|
||||
if(value != DaohuaxiangConstants.plugin) {
|
||||
configVo.getDevParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getProdParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getParamMap().put(value.name(), value.getDescription());
|
||||
}
|
||||
}
|
||||
return configVo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.constants;
|
||||
|
||||
|
||||
public enum DaohuaxiangConstants {
|
||||
|
||||
plugin("daohuaxiang", "插件ID"),
|
||||
url("http://localhost", "接口地址");
|
||||
|
||||
DaohuaxiangConstants(String defaultValue, String description) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String defaultValue;
|
||||
private String description;
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static String getPluginId() {
|
||||
return plugin.defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.node;
|
||||
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.workflow.constants.WorkFlowType;
|
||||
import com.seeyon.apps.common.workflow.node.ACommonSuperNode;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.constants.DaohuaxiangConstants;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.service.NewTongYongService;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.service.TongYongService;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import com.seeyon.apps.ext.workflow.vo.SuperNodeContext;
|
||||
import com.seeyon.cap4.form.bean.FormDataMasterBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class NewTongYongNode extends ACommonSuperNode {
|
||||
|
||||
private ICstConfigApi cstConfigApi;
|
||||
|
||||
public ICstConfigApi getICstConfigApi() {
|
||||
if (cstConfigApi == null) {
|
||||
cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||
}
|
||||
return cstConfigApi;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
NewTongYongService newTongYongService;
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return DaohuaxiangConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormParse() {
|
||||
return "json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkFlowType[] getTypes() {
|
||||
return new WorkFlowType[] { WorkFlowType.superNode };
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuperNodeContext proceed(String request, FormDataVo formDataVo, FormDataMasterBean formDataMasterBean) throws Exception {
|
||||
// 获取数据
|
||||
SuperNodeContext context = new SuperNodeContext();
|
||||
context.setNeedSave(true);
|
||||
Map<String, Object> map = newTongYongService.sendInter(formDataVo);
|
||||
context.setRequest(map.get("request").toString());
|
||||
context.setResponse(map.get("response").toString());
|
||||
Object code = map.get("code");
|
||||
if ("200".equals(code.toString())) {
|
||||
context.success(map.get("msg").toString(), false);
|
||||
} else {
|
||||
context.back(map.get("msg").toString());
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return "newTongYongNode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeName() {
|
||||
return "新平台通用节点";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.node;
|
||||
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.workflow.constants.WorkFlowType;
|
||||
import com.seeyon.apps.common.workflow.node.ACommonSuperNode;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.constants.DaohuaxiangConstants;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.service.TongYongService;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import com.seeyon.apps.ext.workflow.vo.SuperNodeContext;
|
||||
import com.seeyon.cap4.form.bean.FormDataMasterBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TongYongNode extends ACommonSuperNode {
|
||||
|
||||
private ICstConfigApi cstConfigApi;
|
||||
|
||||
public ICstConfigApi getICstConfigApi() {
|
||||
if (cstConfigApi == null) {
|
||||
cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||
}
|
||||
return cstConfigApi;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
TongYongService tongYongService;
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return DaohuaxiangConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormParse() {
|
||||
return "json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkFlowType[] getTypes() {
|
||||
return new WorkFlowType[] { WorkFlowType.superNode };
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuperNodeContext proceed(String request, FormDataVo formDataVo, FormDataMasterBean formDataMasterBean) throws Exception {
|
||||
// 获取数据
|
||||
SuperNodeContext context = new SuperNodeContext();
|
||||
context.setNeedSave(true);
|
||||
Map<String, Object> map = tongYongService.sendInter(formDataVo);
|
||||
context.setRequest(map.get("request").toString());
|
||||
context.setResponse(map.get("response").toString());
|
||||
Object code = map.get("code");
|
||||
if ("200".equals(code.toString())) {
|
||||
context.success(map.get("msg").toString(), false);
|
||||
} else {
|
||||
context.back(map.get("msg").toString());
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return "tongYongNode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeName() {
|
||||
return "通用节点";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiNewUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.InterfaceListUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.PropKit;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.SystemEnvironment;
|
||||
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
||||
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NewTongYongService {
|
||||
|
||||
|
||||
private AttachmentManager attachmentManager;
|
||||
|
||||
public void setAttachmentManager(AttachmentManager attachmentManager) {
|
||||
this.attachmentManager = attachmentManager;
|
||||
}
|
||||
|
||||
public AttachmentManager getAttachmentManagery() {
|
||||
if (attachmentManager == null) {
|
||||
attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
||||
}
|
||||
return attachmentManager;
|
||||
}
|
||||
|
||||
public Map<String, Object> sendInter(FormDataVo formDataVo) throws Exception {
|
||||
String pathId = formDataVo.getFieldData("上传附件").getStringValue();
|
||||
//附件
|
||||
JSONArray faths = null;
|
||||
if (pathId == null || "".equals(pathId)) {
|
||||
faths = new JSONArray();
|
||||
} else {
|
||||
faths = getPathUrl(pathId);
|
||||
}
|
||||
//封装参数
|
||||
Map parm = FanWeiNewUtil.createWF(formDataVo, faths);
|
||||
//调用新建接口
|
||||
String userid = formDataVo.getFieldData("经办人").getStringValue();
|
||||
String s = FanWeiNewUtil.PostRestful(parm, userid);
|
||||
JSONObject returnMsg = JSON.parseObject(s);
|
||||
Object code = returnMsg.get("code");
|
||||
System.out.println("新建code:" + code);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if ("SUCCESS".equals(code.toString())) {
|
||||
//调用提交接口
|
||||
// Map data = (Map) returnMsg.get("data");
|
||||
// Object requestid = data.get("requestid");
|
||||
// String msg = FanWeiUtil.PostRestfulbyForm(requestid.toString(), userid);
|
||||
// JSONObject tiJiaoReturnMsg = JSON.parseObject(msg);
|
||||
// Object code2 = tiJiaoReturnMsg.get("code");
|
||||
// System.out.println("提交code:" + code2);
|
||||
map.put("code", "200");
|
||||
map.put("msg", "推送成功");
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
} else {
|
||||
// Map data = (Map) returnMsg.get("errMsg");
|
||||
map.put("code", "300");
|
||||
map.put("msg", "新建流程失败!");
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件路径
|
||||
* @param pathId
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getPathUrl(String pathId) throws IOException {
|
||||
InterfaceListUtil interfaceListUtil = new InterfaceListUtil();
|
||||
String oatoken = interfaceListUtil.getToken(PropKit.getProp(PropKit.LOGINNAME));
|
||||
long aLong = Long.parseLong(pathId);
|
||||
final List<Long> attachmentIds = attachmentManager.getBySubReference(aLong);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 0 ; i < attachmentIds.size();i++) {
|
||||
Attachment attachment = attachmentManager.getAttachmentByFileURL(attachmentIds.get(i));
|
||||
Long fileUrl = attachment.getFileUrl();
|
||||
String filename = attachment.getFilename();
|
||||
String fileType = filename.substring(filename.lastIndexOf(".")+1);
|
||||
String oaFileName = filename.substring(0,filename.lastIndexOf("."));
|
||||
//调用接口下载文件,文件存放在指定的路径下
|
||||
String dowUrl = PropKit.getProp(PropKit.DOWURL)+"/"+fileUrl+"?fileName="+fileType+"&token="+oatoken;
|
||||
String str = SystemEnvironment.getApplicationFolder();
|
||||
String dowPath = str+"/dhxfile/"+filename;
|
||||
String download = interfaceListUtil.download(dowUrl, dowPath);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", filename);
|
||||
jsonObject.put("type", fileType);
|
||||
jsonObject.put("url", PropKit.getProp(PropKit.JYNCFILE)+"/"+filename);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiNewUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.InterfaceListUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.PropKit;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import com.seeyon.apps.ext.workflow.vo.SuperNodeContext;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.SystemEnvironment;
|
||||
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
||||
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TongYongService {
|
||||
|
||||
|
||||
private AttachmentManager attachmentManager;
|
||||
|
||||
public void setAttachmentManager(AttachmentManager attachmentManager) {
|
||||
this.attachmentManager = attachmentManager;
|
||||
}
|
||||
|
||||
public AttachmentManager getAttachmentManagery() {
|
||||
if (attachmentManager == null) {
|
||||
attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
||||
}
|
||||
return attachmentManager;
|
||||
}
|
||||
|
||||
public Map<String, Object> sendInter(FormDataVo formDataVo) throws Exception {
|
||||
String pathId = formDataVo.getFieldData("上传附件").getStringValue();
|
||||
//附件
|
||||
JSONArray faths = null;
|
||||
if (pathId == null || "".equals(pathId)) {
|
||||
faths = new JSONArray();
|
||||
} else {
|
||||
faths = getPathUrl(pathId);
|
||||
}
|
||||
//封装参数
|
||||
Map parm = FanWeiUtil.createWF(formDataVo, faths);
|
||||
//调用新建接口
|
||||
String userid = formDataVo.getFieldData("客户id").getStringValue();
|
||||
String s = FanWeiUtil.PostRestful(parm, userid);
|
||||
JSONObject returnMsg = JSON.parseObject(s);
|
||||
Object code = returnMsg.get("code");
|
||||
System.out.println("新建code:" + code);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if ("SUCCESS".equals(code.toString())) {
|
||||
//调用提交接口
|
||||
// Map data = (Map) returnMsg.get("data");
|
||||
// Object requestid = data.get("requestid");
|
||||
// String msg = FanWeiUtil.PostRestfulbyForm(requestid.toString(), userid);
|
||||
// JSONObject tiJiaoReturnMsg = JSON.parseObject(msg);
|
||||
// Object code2 = tiJiaoReturnMsg.get("code");
|
||||
// System.out.println("提交code:" + code2);
|
||||
map.put("code", "200");
|
||||
map.put("msg", "推送成功");
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
} else {
|
||||
// Map data = (Map) returnMsg.get("errMsg");
|
||||
map.put("code", "300");
|
||||
map.put("msg", "新建流程失败!");
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件路径
|
||||
* @param pathId
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getPathUrl(String pathId) throws IOException {
|
||||
InterfaceListUtil interfaceListUtil = new InterfaceListUtil();
|
||||
String oatoken = interfaceListUtil.getToken(PropKit.getProp(PropKit.LOGINNAME));
|
||||
long aLong = Long.parseLong(pathId);
|
||||
final List<Long> attachmentIds = attachmentManager.getBySubReference(aLong);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 0 ; i < attachmentIds.size();i++) {
|
||||
Attachment attachment = attachmentManager.getAttachmentByFileURL(attachmentIds.get(i));
|
||||
Long fileUrl = attachment.getFileUrl();
|
||||
String filename = attachment.getFilename();
|
||||
String fileType = filename.substring(filename.lastIndexOf(".")+1);
|
||||
String oaFileName = filename.substring(0,filename.lastIndexOf("."));
|
||||
//调用接口下载文件,文件存放在指定的路径下
|
||||
String dowUrl = PropKit.getProp(PropKit.DOWURL)+"/"+fileUrl+"?fileName="+fileType+"&token="+oatoken;
|
||||
String str = SystemEnvironment.getApplicationFolder();
|
||||
String dowPath = str+"/dhxfile/"+filename;
|
||||
String download = interfaceListUtil.download(dowUrl, dowPath);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", filename);
|
||||
jsonObject.put("type", fileType);
|
||||
jsonObject.put("url", PropKit.getProp(PropKit.JYNCFILE)+"/"+filename);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import com.seeyon.ctp.common.SystemEnvironment;
|
||||
|
||||
/**
|
||||
* Description
|
||||
* <pre>获取A8产品下面的文件夹路径</pre>
|
||||
* Copyright(c) Beijing Seeyon Software Co.,LTD
|
||||
*/
|
||||
public class A8FolderKit {
|
||||
|
||||
private static String SH_PROP = "";
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* <pre>获取到A8的安装应用目录 seeyon</pre>
|
||||
* @return
|
||||
*/
|
||||
public static String getPropFile() {
|
||||
if("".equals(SH_PROP)) {
|
||||
SH_PROP = SystemEnvironment.getApplicationFolder() + "/WEB-INF/cfgHome/plugin/daohuaxiang/jyncfile.properties";
|
||||
}
|
||||
return SH_PROP;
|
||||
}
|
||||
|
||||
}
|
||||
110
src/com/seeyon/apps/daohuaxiangSys/jkts/util/BaseUtil.java
Normal file
110
src/com/seeyon/apps/daohuaxiangSys/jkts/util/BaseUtil.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
|
||||
/**
|
||||
* sql执行工具类
|
||||
* 2021-06-08
|
||||
* @author huangzhengguo
|
||||
*
|
||||
*/
|
||||
public class BaseUtil {
|
||||
|
||||
|
||||
PreparedStatement ps = null;
|
||||
ResultSet res = null;
|
||||
Connection conn =null;
|
||||
/**
|
||||
* sql查询工具
|
||||
* @param sql sql语句
|
||||
* @param params sql参数
|
||||
* @return 结果集
|
||||
*/
|
||||
public ResultSet executeQuery(String sql, Object[] params)
|
||||
{
|
||||
conn = JdbcUtil.getConnection();
|
||||
try {
|
||||
ps = conn.prepareStatement(sql);
|
||||
for(int i = 0; i < params.length; i++){
|
||||
ps.setObject(i+1, params[i]);
|
||||
}
|
||||
res = ps.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* sql更新工具
|
||||
* @param sql
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public int executeUpdate(String sql, Object[] params)
|
||||
{
|
||||
int res = 0;
|
||||
conn = JdbcUtil.getConnection();
|
||||
try {
|
||||
ps = conn.prepareStatement(sql);
|
||||
for(int i = 0; i < params.length; i++)
|
||||
{
|
||||
ps.setObject(i+1, params[i]);
|
||||
}
|
||||
res = ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public void close() {
|
||||
release(res,null,conn,ps);
|
||||
}
|
||||
//定义一个释放资源的方法;
|
||||
/*
|
||||
* 定义一个方法: 释放资源: 直接将rs stmt conn 全部释放:
|
||||
*/
|
||||
public static void release(ResultSet rs ,Statement stmt , Connection conn,PreparedStatement ps){
|
||||
if(rs!=null){
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
rs=null;
|
||||
}
|
||||
if(stmt!=null){
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
stmt=null;
|
||||
}
|
||||
if(conn!=null){
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
conn=null;
|
||||
}
|
||||
if(ps!=null){
|
||||
try {
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ps=null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DBConnection {
|
||||
// JDBC 驱动名及数据库 URL
|
||||
static final String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
static final String DB_URL = "jdbc:sqlserver://119.96.243.50:1433;databaseName=U8CLOUD";
|
||||
|
||||
// 数据库的用户名与密码,根据自己的情况修改
|
||||
static final String USER = "sa";
|
||||
static final String PASS = "Sa123456";
|
||||
|
||||
public void conn() {
|
||||
Connection conn = null;
|
||||
|
||||
try {
|
||||
// 注册 JDBC 驱动
|
||||
Class.forName(JDBC_DRIVER);
|
||||
|
||||
// 打开链接
|
||||
System.out.println("连接数据库...");
|
||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
||||
|
||||
|
||||
// 关闭链接
|
||||
conn.close();
|
||||
} catch (SQLException se) {
|
||||
// 处理 JDBC 错误
|
||||
se.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// 处理 Class.forName 错误
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
try {
|
||||
if (conn != null) {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("完成操作");
|
||||
}
|
||||
|
||||
}
|
||||
426
src/com/seeyon/apps/daohuaxiangSys/jkts/util/FanWeiNewUtil.java
Normal file
426
src/com/seeyon/apps/daohuaxiangSys/jkts/util/FanWeiNewUtil.java
Normal file
@@ -0,0 +1,426 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author alexander
|
||||
* @version 1.0
|
||||
* @date 2023/8/25 09:16 星期五
|
||||
*/
|
||||
public class FanWeiNewUtil {
|
||||
/**
|
||||
* 模拟缓存服务
|
||||
*/
|
||||
private static final Map<String,String> SYSTEM_CACHE = new HashMap<>();
|
||||
|
||||
private static String privateKey = "";
|
||||
private static String publicKey = "";
|
||||
|
||||
/**
|
||||
* ecology系统发放的授权许可证(appid)
|
||||
* ce14aaca-fa08-4eb7-9f10-c2294285c4ea
|
||||
*/
|
||||
private static String APPID = "e47a15d2-95f2-4bf6-a546-8076ce445a19";
|
||||
|
||||
|
||||
/**
|
||||
* 第一步:
|
||||
*
|
||||
* 调用ecology注册接口,根据appid进行注册,将返回服务端公钥和Secret信息
|
||||
*/
|
||||
public static Map<String,Object> Regist(String address) throws IOException {
|
||||
|
||||
//调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("cpk","123")
|
||||
.header("loginid",PropKit.getProp(PropKit.LOGINID))
|
||||
.header("pwd",PropKit.getProp(PropKit.PWD))
|
||||
.timeout(2000)
|
||||
.execute().body();
|
||||
|
||||
// 打印ECOLOGY响应信息
|
||||
System.out.println("Regist():"+data);
|
||||
Map<String,Object> datas = JSONUtil.parseObj(data);
|
||||
|
||||
//ECOLOGY返回的系统公钥
|
||||
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String)datas.get("spk")));
|
||||
//ECOLOGY返回的系统密钥
|
||||
SYSTEM_CACHE.put("SERVER_SECRET",StrUtil.nullToEmpty((String)datas.get("secrit")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 第二步:
|
||||
*
|
||||
* 通过第一步中注册系统返回信息进行获取token信息
|
||||
*/
|
||||
public static Map<String,Object> Getoken(String address) throws IOException {
|
||||
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
||||
String secret = PropKit.getProp(PropKit.NEWSECRET);
|
||||
String spk = PropKit.getProp(PropKit.NEWSPK);
|
||||
|
||||
|
||||
// 公钥加密,所以RSA对象私钥为null
|
||||
RSA rsa = new RSA(null,spk);
|
||||
//对秘钥进行加密传输,防止篡改数据
|
||||
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
|
||||
//调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address+ "/api/ec/dev/auth/applytoken")
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("secret",encryptSecret)
|
||||
.header("time","3600")
|
||||
.execute().body();
|
||||
|
||||
System.out.println("Getoken():"+data);
|
||||
Map<String,Object> datas = JSONUtil.parseObj(data);
|
||||
|
||||
//ECOLOGY返回的token
|
||||
// TODO 为Token缓存设置过期时间
|
||||
SYSTEM_CACHE.put("SERVER_TOKEN",StrUtil.nullToEmpty((String)datas.get("token")));
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三步:
|
||||
*
|
||||
* 调用ecology系统的rest接口,请求头部带上token和用户标识认证信息
|
||||
*
|
||||
* @param params 请求参数map,创建流程之类的post接口是以模拟form表单提交的方式,其他get接口以json字符串方式提交
|
||||
*
|
||||
* 注意:ECOLOGY系统所有POST接口调用请求头请设置 "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
|
||||
*/
|
||||
public static String PostRestful(Map params, String userid) throws IOException {
|
||||
|
||||
//ECOLOGY返回的token
|
||||
String token = (String) Getoken(PropKit.getProp(PropKit.NEWADDRESS)).get("token");
|
||||
|
||||
|
||||
//封装请求头参数
|
||||
RSA rsa = new RSA(null, PropKit.getProp(PropKit.NEWSPK));
|
||||
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64(userid,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
||||
|
||||
//调用ECOLOGY系统接口
|
||||
String data = HttpRequest.post(PropKit.getProp(PropKit.NEWADDRESS) + PropKit.getProp(PropKit.TONGYONGAPI))
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("token",token)
|
||||
.header("userid",encryptUserid)
|
||||
// .header("skipsession", "1")
|
||||
.form(params)
|
||||
.execute().body();
|
||||
// Map headermap = new HashMap();
|
||||
// headermap.put("appid",APPID);
|
||||
// headermap.put("token",token);
|
||||
// headermap.put("userid",encryptUserid);
|
||||
// String data = HttpClientUtil.doPostFORM(address + api,headermap,params);
|
||||
System.out.println("PostRestfulby():"+data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static String PostRestfulbyForm(String requestId, String userid) throws IOException {
|
||||
|
||||
//ECOLOGY返回的token
|
||||
String token = (String) Getoken(PropKit.getProp(PropKit.NEWADDRESS)).get("token");
|
||||
|
||||
//封装请求头参数
|
||||
RSA rsa = new RSA(null, PropKit.getProp(PropKit.NEWSPK));
|
||||
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64(userid,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
||||
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("requestId", requestId);//流程ID
|
||||
|
||||
//调用ECOLOGY系统接口
|
||||
String data = HttpRequest.post(PropKit.getProp(PropKit.ADDRESS) + "/api/workflow/paService/submitRequest")
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("token",token)
|
||||
.header("userid",encryptUserid)
|
||||
// .header("skipsession", "1")
|
||||
.form(m)
|
||||
.execute().body();
|
||||
// Map headermap = new HashMap();
|
||||
// headermap.put("appid",APPID);
|
||||
// headermap.put("token",token);
|
||||
// headermap.put("userid",encryptUserid);
|
||||
// String data = HttpClientUtil.doPostFORM(address + api,headermap,params);
|
||||
System.out.println("PostRestfulbyForm():"+data);
|
||||
return data;
|
||||
}
|
||||
|
||||
// public static void getSub(){
|
||||
// String returnSTR = PostRestful("http://110.10.2.39","/api/hrm/resful/getHrmUserInfoWithPage",null,"1");
|
||||
// System.out.println(returnSTR);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 消息接口
|
||||
// */
|
||||
// private static void sendMsg(){
|
||||
// PostRestfulbyForm("http://127.0.0.1:8888","/api/ec/dev/message/sendCustomMessageSingle",sendCustomMessageSingle(),"1");
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 创建流程
|
||||
*/
|
||||
public static Map createWF(FormDataVo formDataVo, JSONArray faths) throws NoSuchFieldException, IOException {
|
||||
|
||||
//主表信息
|
||||
List mainlist = new ArrayList();
|
||||
//客户名称
|
||||
Map mainmap1 = new HashMap();
|
||||
mainmap1.put("fieldName","khmc");//OA字段名-出差类型(下拉框)
|
||||
mainmap1.put("fieldValue",formDataVo.getFieldData("客户id").getStringValue());//字段值(下拉框选项值)
|
||||
mainlist.add(mainmap1);
|
||||
|
||||
//标题
|
||||
Map mainmap2 = new HashMap();
|
||||
mainmap2.put("fieldName","bt");//OA字段名-同行人员(多人力资源浏览框)
|
||||
mainmap2.put("fieldValue",formDataVo.getFieldData("表头").getStringValue());//字段值(OA人员ID,多个以英文逗号分隔)
|
||||
mainlist.add(mainmap2);
|
||||
|
||||
//单号
|
||||
Map mainmap3 = new HashMap();
|
||||
mainmap3.put("fieldName","dh");
|
||||
mainmap3.put("fieldValue",formDataVo.getFieldData("流水号").getStringValue());
|
||||
mainlist.add(mainmap3);
|
||||
|
||||
//申请日期
|
||||
Map mainmap4 = new HashMap();
|
||||
mainmap4.put("fieldName","sqrq");
|
||||
mainmap4.put("fieldValue",formDataVo.getFieldData("填表日期").getStringValue());
|
||||
mainlist.add(mainmap4);
|
||||
|
||||
//投入金额
|
||||
Map mainmap5 = new HashMap();
|
||||
mainmap5.put("fieldName","trje");
|
||||
mainmap5.put("fieldValue",formDataVo.getFieldData("投入金额").getStringValue());
|
||||
mainlist.add(mainmap5);
|
||||
|
||||
//备案意见
|
||||
Map mainmap6 = new HashMap();
|
||||
mainmap6.put("fieldName","bayj");
|
||||
mainmap6.put("fieldValue",formDataVo.getFieldData("备案意见").getStringValue());
|
||||
mainlist.add(mainmap6);
|
||||
|
||||
//备案简述
|
||||
Map mainmap9 = new HashMap();
|
||||
mainmap9.put("fieldName","bajs");
|
||||
mainmap9.put("fieldValue",formDataVo.getFieldData("备案简述").getStringValue());
|
||||
mainlist.add(mainmap9);
|
||||
|
||||
//分公司
|
||||
Map mainmap8 = new HashMap();
|
||||
mainmap8.put("fieldName","ssschxsgs");
|
||||
mainmap8.put("fieldValue",formDataVo.getFieldData("分公司").getStringValue());
|
||||
mainlist.add(mainmap8);
|
||||
|
||||
//经办人
|
||||
Map mainmap10 = new HashMap();
|
||||
mainmap10.put("fieldName","jbr");
|
||||
mainmap10.put("fieldValue",formDataVo.getFieldData("经办人").getStringValue());
|
||||
mainlist.add(mainmap10);
|
||||
|
||||
//备案类型
|
||||
Map mainmap11 = new HashMap();
|
||||
mainmap11.put("fieldName","balx");
|
||||
mainmap11.put("fieldValue","0");
|
||||
mainlist.add(mainmap11);
|
||||
|
||||
//附件
|
||||
if(faths.size() > 0) {
|
||||
Map mainmap7 = new HashMap();
|
||||
mainmap7.put("fieldName","banr");
|
||||
List fujianValue = new ArrayList();
|
||||
for (int i = 0; i < faths.size(); i++) {
|
||||
Map fath = (Map) faths.get(i);
|
||||
Map fujianMap = new HashMap();
|
||||
fujianMap.put("filePath", fath.get("url"));
|
||||
fujianMap.put("fileName", fath.get("name"));
|
||||
fujianValue.add(fujianMap);
|
||||
}
|
||||
|
||||
mainmap7.put("fieldValue",fujianValue);
|
||||
mainlist.add(mainmap7);
|
||||
}
|
||||
|
||||
//接口主参数
|
||||
Map m = new LinkedHashMap();
|
||||
//流程ID
|
||||
m.put("workflowId",PropKit.getProp(PropKit.NEWWORKFLOWID));
|
||||
//流程标题
|
||||
m.put("requestName",formDataVo.getColSummary().getSubject());
|
||||
//主表
|
||||
m.put("mainData",JSONUtil.toJsonStr(mainlist));
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建流程
|
||||
*/
|
||||
public static Map createWF2(Map data, JSONArray faths) throws NoSuchFieldException, IOException {
|
||||
|
||||
//主表信息
|
||||
List mainlist = new ArrayList();
|
||||
|
||||
//客户名称
|
||||
Map mainmap1 = new HashMap();
|
||||
mainmap1.put("fieldName","khmc");//OA字段名-出差类型(下拉框)
|
||||
mainmap1.put("fieldValue",data.get("khmc"));//字段值(下拉框选项值)
|
||||
mainlist.add(mainmap1);
|
||||
|
||||
//标题
|
||||
Map mainmap2 = new HashMap();
|
||||
mainmap2.put("fieldName","bt");//OA字段名-同行人员(多人力资源浏览框)
|
||||
mainmap2.put("fieldValue",data.get("bt"));//字段值(OA人员ID,多个以英文逗号分隔)
|
||||
mainlist.add(mainmap2);
|
||||
|
||||
//单号
|
||||
Map mainmap3 = new HashMap();
|
||||
mainmap3.put("fieldName","dh");
|
||||
mainmap3.put("fieldValue",data.get("dh"));
|
||||
mainlist.add(mainmap3);
|
||||
|
||||
//申请日期
|
||||
Map mainmap4 = new HashMap();
|
||||
mainmap4.put("fieldName","sqrq");
|
||||
mainmap4.put("fieldValue",data.get("sqrq"));
|
||||
mainlist.add(mainmap4);
|
||||
|
||||
//投入金额
|
||||
Map mainmap5 = new HashMap();
|
||||
mainmap5.put("fieldName","trje");
|
||||
mainmap5.put("fieldValue",data.get("trje"));
|
||||
mainlist.add(mainmap5);
|
||||
|
||||
//备案意见
|
||||
Map mainmap6 = new HashMap();
|
||||
mainmap6.put("fieldName","bayj");
|
||||
mainmap6.put("fieldValue",data.get("bayj"));
|
||||
mainlist.add(mainmap6);
|
||||
|
||||
//备案简述
|
||||
Map mainmap9 = new HashMap();
|
||||
mainmap9.put("fieldName","bajs");
|
||||
mainmap9.put("fieldValue",data.get("bajs"));
|
||||
mainlist.add(mainmap9);
|
||||
|
||||
//分公司
|
||||
Map mainmap8 = new HashMap();
|
||||
mainmap8.put("fieldName","ssschxsgs");
|
||||
mainmap8.put("fieldValue",data.get("ssschxsgs"));
|
||||
mainlist.add(mainmap8);
|
||||
|
||||
//经办人
|
||||
Map mainmap10 = new HashMap();
|
||||
mainmap10.put("fieldName","jbr");
|
||||
mainmap10.put("fieldValue",data.get("jbr"));
|
||||
mainlist.add(mainmap10);
|
||||
|
||||
|
||||
|
||||
//附件
|
||||
if(faths.size() > 0) {
|
||||
Map mainmap7 = new HashMap();
|
||||
mainmap7.put("fieldName","banr");
|
||||
List fujianValue = new ArrayList();
|
||||
for (int i = 0; i < faths.size(); i++) {
|
||||
Map fath = (Map) faths.get(i);
|
||||
Map fujianMap = new HashMap();
|
||||
fujianMap.put("filePath", fath.get("url"));
|
||||
fujianMap.put("fileName", fath.get("name"));
|
||||
fujianValue.add(fujianMap);
|
||||
}
|
||||
|
||||
mainmap7.put("fieldValue",fujianValue);
|
||||
mainlist.add(mainmap7);
|
||||
}
|
||||
|
||||
//接口主参数
|
||||
Map m = new LinkedHashMap();
|
||||
//流程ID
|
||||
m.put("workflowId",PropKit.getProp(PropKit.NEWWORKFLOWID));
|
||||
//流程标题
|
||||
m.put("requestName",data.get("lcbt"));
|
||||
//主表
|
||||
m.put("mainData",JSONUtil.toJsonStr(mainlist));
|
||||
|
||||
System.out.println("m:"+m);
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息,参数封装
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> sendCustomMessageSingle() {
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
// map.put("code", "1149"); // 消息来源,新建消息来源获取code 请查看文档第四大点补充
|
||||
map.put("code", "1207"); // 消息来源,新建消息来源获取code 请查看文档第四大点补充
|
||||
map.put("userIdList", "1"); // userIdList参数 userIdList 接收人OA系统id / loginIdList 接收人登录名 / workCodeList 接收人编号 / lastNameList 接收人姓名(任选一个填入即可,以逗号分隔)
|
||||
// map.put("loginIdList","zhangsan,wangwu" ); //接收人登录名
|
||||
// map.put("workCodeList","WS01640,WS01641" ); //接收人编号
|
||||
// map.put("lastNameList","张三,王五" ); //接收人姓名
|
||||
map.put("creater", "1"); //creater的值 创建人OA系统id / 创建人登录名 / 创建人编号 / 创建人姓名(对应接收人所传入的形式)
|
||||
// map.put("creater","zhangsan");
|
||||
// map.put("creater","WS01640");
|
||||
// map.put("creater","张三");
|
||||
map.put("title", "接口创建的消息");
|
||||
map.put("context", "接口创建的消息,看下内容是否进来了");
|
||||
String linkUrl = "http://118.190.132.210:9999/custom_renfu.html?param=corp=ding58007d3a66cc643bacaaa37764f94726--flag=study_project" +
|
||||
"--projectId=1826492840843284480--ticket=2u+cX2Bl4KPQ89QwNOG0VC/YmAv" +
|
||||
"/Sa5pu92FXTgUfGDZlhmqdVyNLtJVcZv3Pe7teWbqGAJhufN8Y4tpIW6c1Q==";
|
||||
map.put("linkUrl", linkUrl);
|
||||
map.put("linkMobileUrl", "http://www.baidu.com");
|
||||
|
||||
// map.put("targetId","559|id22"); //消息来源code +“|”+业务id 消息需要打上已处理标记
|
||||
// map.put("bizState","0"); //0 表示消息初始状态是待处理 消息需要打上已处理标记
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String getAPPID() {
|
||||
return APPID;
|
||||
}
|
||||
|
||||
public static void setAPPID(String APPID) {
|
||||
FanWeiNewUtil.APPID = APPID;
|
||||
}
|
||||
|
||||
public static String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public static void setPrivateKey(String privateKey) {
|
||||
FanWeiNewUtil.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public static String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public static void setPublicKey(String publicKey) {
|
||||
FanWeiNewUtil.publicKey = publicKey;
|
||||
}
|
||||
}
|
||||
415
src/com/seeyon/apps/daohuaxiangSys/jkts/util/FanWeiUtil.java
Normal file
415
src/com/seeyon/apps/daohuaxiangSys/jkts/util/FanWeiUtil.java
Normal file
@@ -0,0 +1,415 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author alexander
|
||||
* @version 1.0
|
||||
* @date 2023/8/25 09:16 星期五
|
||||
*/
|
||||
public class FanWeiUtil {
|
||||
/**
|
||||
* 模拟缓存服务
|
||||
*/
|
||||
private static final Map<String,String> SYSTEM_CACHE = new HashMap<>();
|
||||
|
||||
private static String privateKey = "";
|
||||
private static String publicKey = "";
|
||||
|
||||
/**
|
||||
* ecology系统发放的授权许可证(appid)
|
||||
* ce14aaca-fa08-4eb7-9f10-c2294285c4ea
|
||||
*/
|
||||
private static String APPID = "e47a15d2-95f2-4bf6-a546-8076ce445a19";
|
||||
|
||||
|
||||
/**
|
||||
* 第一步:
|
||||
*
|
||||
* 调用ecology注册接口,根据appid进行注册,将返回服务端公钥和Secret信息
|
||||
*/
|
||||
public static Map<String,Object> Regist(String address){
|
||||
|
||||
//获取当前系统RSA加密的公钥
|
||||
RSA rsa = new RSA();
|
||||
if(publicKey.equals("")) {
|
||||
publicKey = rsa.getPublicKeyBase64();
|
||||
}
|
||||
if(privateKey.equals("")) {
|
||||
privateKey = rsa.getPrivateKeyBase64();
|
||||
}
|
||||
|
||||
System.out.println("publicKey:"+publicKey+" privateKey:"+privateKey);
|
||||
// 客户端RSA私钥
|
||||
SYSTEM_CACHE.put("LOCAL_PRIVATE_KEY",privateKey);
|
||||
// 客户端RSA公钥
|
||||
SYSTEM_CACHE.put("LOCAL_PUBLIC_KEY",publicKey);
|
||||
|
||||
//调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address + "/api/ec/dev/auth/regist")
|
||||
.header("appid",APPID)
|
||||
.header("cpk",publicKey)
|
||||
.timeout(2000)
|
||||
.execute().body();
|
||||
|
||||
// 打印ECOLOGY响应信息
|
||||
System.out.println("Regist():"+data);
|
||||
Map<String,Object> datas = JSONUtil.parseObj(data);
|
||||
|
||||
//ECOLOGY返回的系统公钥
|
||||
SYSTEM_CACHE.put("SERVER_PUBLIC_KEY", StrUtil.nullToEmpty((String)datas.get("spk")));
|
||||
//ECOLOGY返回的系统密钥
|
||||
SYSTEM_CACHE.put("SERVER_SECRET",StrUtil.nullToEmpty((String)datas.get("secrit")));
|
||||
return datas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 第二步:
|
||||
*
|
||||
* 通过第一步中注册系统返回信息进行获取token信息
|
||||
*/
|
||||
public static Map<String,Object> Getoken(String address) throws IOException {
|
||||
// 从系统缓存或者数据库中获取ECOLOGY系统公钥和Secret信息
|
||||
String secret = PropKit.getProp(PropKit.SECRET);
|
||||
String spk = PropKit.getProp(PropKit.SPK);
|
||||
|
||||
|
||||
// 公钥加密,所以RSA对象私钥为null
|
||||
RSA rsa = new RSA(null,spk);
|
||||
//对秘钥进行加密传输,防止篡改数据
|
||||
String encryptSecret = rsa.encryptBase64(secret, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
|
||||
|
||||
//调用ECOLOGY系统接口进行注册
|
||||
String data = HttpRequest.post(address+ "/api/ec/dev/auth/applytoken")
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("secret",encryptSecret)
|
||||
.header("time","3600")
|
||||
.execute().body();
|
||||
|
||||
System.out.println("Getoken():"+data);
|
||||
Map<String,Object> datas = JSONUtil.parseObj(data);
|
||||
|
||||
//ECOLOGY返回的token
|
||||
// TODO 为Token缓存设置过期时间
|
||||
SYSTEM_CACHE.put("SERVER_TOKEN",StrUtil.nullToEmpty((String)datas.get("token")));
|
||||
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三步:
|
||||
*
|
||||
* 调用ecology系统的rest接口,请求头部带上token和用户标识认证信息
|
||||
*
|
||||
* @param params 请求参数map,创建流程之类的post接口是以模拟form表单提交的方式,其他get接口以json字符串方式提交
|
||||
*
|
||||
* 注意:ECOLOGY系统所有POST接口调用请求头请设置 "Content-Type","application/x-www-form-urlencoded; charset=utf-8"
|
||||
*/
|
||||
public static String PostRestful(Map params, String userid) throws IOException {
|
||||
|
||||
//ECOLOGY返回的token
|
||||
String token = (String) Getoken(PropKit.getProp(PropKit.ADDRESS)).get("token");
|
||||
|
||||
|
||||
//封装请求头参数
|
||||
RSA rsa = new RSA(null, PropKit.getProp(PropKit.SPK));
|
||||
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64(userid,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
||||
|
||||
//调用ECOLOGY系统接口
|
||||
String data = HttpRequest.post(PropKit.getProp(PropKit.ADDRESS) + PropKit.getProp(PropKit.TONGYONGAPI))
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("token",token)
|
||||
.header("userid",encryptUserid)
|
||||
// .header("skipsession", "1")
|
||||
.form(params)
|
||||
.execute().body();
|
||||
// Map headermap = new HashMap();
|
||||
// headermap.put("appid",APPID);
|
||||
// headermap.put("token",token);
|
||||
// headermap.put("userid",encryptUserid);
|
||||
// String data = HttpClientUtil.doPostFORM(address + api,headermap,params);
|
||||
System.out.println("PostRestfulby():"+data);
|
||||
return data;
|
||||
}
|
||||
public static String PostRestfulbyForm(String requestId, String userid) throws IOException {
|
||||
|
||||
//ECOLOGY返回的token
|
||||
String token = (String) Getoken(PropKit.getProp(PropKit.ADDRESS)).get("token");
|
||||
|
||||
//封装请求头参数
|
||||
RSA rsa = new RSA(null, PropKit.getProp(PropKit.SPK));
|
||||
//对用户信息进行加密传输,暂仅支持传输OA用户ID
|
||||
String encryptUserid = rsa.encryptBase64(userid,CharsetUtil.CHARSET_UTF_8,KeyType.PublicKey);
|
||||
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("requestId", requestId);//流程ID
|
||||
|
||||
//调用ECOLOGY系统接口
|
||||
String data = HttpRequest.post(PropKit.getProp(PropKit.ADDRESS) + "/api/workflow/paService/submitRequest")
|
||||
.header("appid",PropKit.getProp(PropKit.APPID))
|
||||
.header("token",token)
|
||||
.header("userid",encryptUserid)
|
||||
// .header("skipsession", "1")
|
||||
.form(m)
|
||||
.execute().body();
|
||||
// Map headermap = new HashMap();
|
||||
// headermap.put("appid",APPID);
|
||||
// headermap.put("token",token);
|
||||
// headermap.put("userid",encryptUserid);
|
||||
// String data = HttpClientUtil.doPostFORM(address + api,headermap,params);
|
||||
System.out.println("PostRestfulbyForm():"+data);
|
||||
return data;
|
||||
}
|
||||
|
||||
// public static void getSub(){
|
||||
// String returnSTR = PostRestful("http://110.10.2.39","/api/hrm/resful/getHrmUserInfoWithPage",null,"1");
|
||||
// System.out.println(returnSTR);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 消息接口
|
||||
// */
|
||||
// private static void sendMsg(){
|
||||
// PostRestfulbyForm("http://127.0.0.1:8888","/api/ec/dev/message/sendCustomMessageSingle",sendCustomMessageSingle(),"1");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 创建流程
|
||||
*/
|
||||
public static Map createWF(FormDataVo formDataVo, JSONArray faths) throws NoSuchFieldException, IOException {
|
||||
|
||||
//主表信息
|
||||
List mainlist = new ArrayList();
|
||||
//客户名称
|
||||
Map mainmap1 = new HashMap();
|
||||
mainmap1.put("fieldName","khmc");//OA字段名-出差类型(下拉框)
|
||||
mainmap1.put("fieldValue",formDataVo.getFieldData("客户id").getStringValue());//字段值(下拉框选项值)
|
||||
mainlist.add(mainmap1);
|
||||
|
||||
//标题
|
||||
Map mainmap2 = new HashMap();
|
||||
mainmap2.put("fieldName","bt");//OA字段名-同行人员(多人力资源浏览框)
|
||||
mainmap2.put("fieldValue",formDataVo.getFieldData("表头").getStringValue());//字段值(OA人员ID,多个以英文逗号分隔)
|
||||
mainlist.add(mainmap2);
|
||||
|
||||
//单号
|
||||
Map mainmap3 = new HashMap();
|
||||
mainmap3.put("fieldName","dh");
|
||||
mainmap3.put("fieldValue",formDataVo.getFieldData("流水号").getStringValue());
|
||||
mainlist.add(mainmap3);
|
||||
|
||||
//申请日期
|
||||
Map mainmap4 = new HashMap();
|
||||
mainmap4.put("fieldName","sqrq");
|
||||
mainmap4.put("fieldValue",formDataVo.getFieldData("填表日期").getStringValue());
|
||||
mainlist.add(mainmap4);
|
||||
|
||||
//投入金额
|
||||
Map mainmap5 = new HashMap();
|
||||
mainmap5.put("fieldName","trje");
|
||||
mainmap5.put("fieldValue",formDataVo.getFieldData("投入金额").getStringValue());
|
||||
mainlist.add(mainmap5);
|
||||
|
||||
//备案意见
|
||||
Map mainmap6 = new HashMap();
|
||||
mainmap6.put("fieldName","bayj");
|
||||
mainmap6.put("fieldValue",formDataVo.getFieldData("备案意见").getStringValue());
|
||||
mainlist.add(mainmap6);
|
||||
|
||||
//分公司
|
||||
Map mainmap8 = new HashMap();
|
||||
mainmap8.put("fieldName","fgs");
|
||||
mainmap8.put("fieldValue",formDataVo.getFieldData("分公司").getStringValue());
|
||||
mainlist.add(mainmap8);
|
||||
|
||||
//备案简述
|
||||
Map mainmap11 = new HashMap();
|
||||
mainmap11.put("fieldName","bajs");
|
||||
mainmap11.put("fieldValue",formDataVo.getFieldData("备案简述").getStringValue());
|
||||
mainlist.add(mainmap11);
|
||||
|
||||
//备案类型
|
||||
Map mainmap12 = new HashMap();
|
||||
mainmap12.put("fieldName","balx");
|
||||
mainmap12.put("fieldValue","0");
|
||||
mainlist.add(mainmap12);
|
||||
|
||||
//附件
|
||||
if(faths.size() > 0) {
|
||||
Map mainmap7 = new HashMap();
|
||||
mainmap7.put("fieldName","banr");
|
||||
List fujianValue = new ArrayList();
|
||||
for (int i = 0; i < faths.size(); i++) {
|
||||
Map fath = (Map) faths.get(i);
|
||||
Map fujianMap = new HashMap();
|
||||
fujianMap.put("filePath", fath.get("url"));
|
||||
fujianMap.put("fileName", fath.get("name"));
|
||||
fujianValue.add(fujianMap);
|
||||
}
|
||||
|
||||
mainmap7.put("fieldValue",fujianValue);
|
||||
mainlist.add(mainmap7);
|
||||
}
|
||||
|
||||
//接口主参数
|
||||
Map m = new LinkedHashMap();
|
||||
//流程ID
|
||||
m.put("workflowId",PropKit.getProp(PropKit.WORKFLOWID));
|
||||
//流程标题
|
||||
m.put("requestName",formDataVo.getColSummary().getSubject());
|
||||
//主表
|
||||
m.put("mainData",JSONUtil.toJsonStr(mainlist));
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建流程
|
||||
*/
|
||||
public static Map createWF2(Map data, JSONArray faths) throws NoSuchFieldException, IOException {
|
||||
|
||||
//主表信息
|
||||
List mainlist = new ArrayList();
|
||||
//客户名称
|
||||
Map mainmap1 = new HashMap();
|
||||
mainmap1.put("fieldName","khmc");//OA字段名-出差类型(下拉框)
|
||||
mainmap1.put("fieldValue",data.get("khmc"));//字段值(下拉框选项值)
|
||||
mainlist.add(mainmap1);
|
||||
|
||||
//标题
|
||||
Map mainmap2 = new HashMap();
|
||||
mainmap2.put("fieldName","bt");//OA字段名-同行人员(多人力资源浏览框)
|
||||
mainmap2.put("fieldValue",data.get("bt"));//字段值(OA人员ID,多个以英文逗号分隔)
|
||||
mainlist.add(mainmap2);
|
||||
|
||||
//单号
|
||||
Map mainmap3 = new HashMap();
|
||||
mainmap3.put("fieldName","dh");
|
||||
mainmap3.put("fieldValue",data.get("dh"));
|
||||
mainlist.add(mainmap3);
|
||||
|
||||
//申请日期
|
||||
Map mainmap4 = new HashMap();
|
||||
mainmap4.put("fieldName","sqrq");
|
||||
mainmap4.put("fieldValue",data.get("sqrq"));
|
||||
mainlist.add(mainmap4);
|
||||
|
||||
//投入金额
|
||||
Map mainmap5 = new HashMap();
|
||||
mainmap5.put("fieldName","trje");
|
||||
mainmap5.put("fieldValue",data.get("trje"));
|
||||
mainlist.add(mainmap5);
|
||||
|
||||
//备案意见
|
||||
Map mainmap6 = new HashMap();
|
||||
mainmap6.put("fieldName","bayj");
|
||||
mainmap6.put("fieldValue",data.get("bayj"));
|
||||
mainlist.add(mainmap6);
|
||||
|
||||
//分公司
|
||||
Map mainmap8 = new HashMap();
|
||||
mainmap8.put("fieldName","fgs");
|
||||
mainmap8.put("fieldValue",data.get("fgs"));
|
||||
mainlist.add(mainmap8);
|
||||
|
||||
//附件
|
||||
if(faths.size() > 0) {
|
||||
Map mainmap7 = new HashMap();
|
||||
mainmap7.put("fieldName","banr");
|
||||
List fujianValue = new ArrayList();
|
||||
for (int i = 0; i < faths.size(); i++) {
|
||||
Map fath = (Map) faths.get(i);
|
||||
Map fujianMap = new HashMap();
|
||||
fujianMap.put("filePath", fath.get("url"));
|
||||
fujianMap.put("fileName", fath.get("name"));
|
||||
fujianValue.add(fujianMap);
|
||||
}
|
||||
|
||||
mainmap7.put("fieldValue",fujianValue);
|
||||
mainlist.add(mainmap7);
|
||||
}
|
||||
|
||||
//接口主参数
|
||||
Map m = new LinkedHashMap();
|
||||
//流程ID
|
||||
m.put("workflowId",PropKit.getProp(PropKit.WORKFLOWID));
|
||||
//流程标题
|
||||
m.put("requestName",data.get("lcbt"));
|
||||
//主表
|
||||
m.put("mainData",JSONUtil.toJsonStr(mainlist));
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息,参数封装
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> sendCustomMessageSingle() {
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
// map.put("code", "1149"); // 消息来源,新建消息来源获取code 请查看文档第四大点补充
|
||||
map.put("code", "1207"); // 消息来源,新建消息来源获取code 请查看文档第四大点补充
|
||||
map.put("userIdList", "1"); // userIdList参数 userIdList 接收人OA系统id / loginIdList 接收人登录名 / workCodeList 接收人编号 / lastNameList 接收人姓名(任选一个填入即可,以逗号分隔)
|
||||
// map.put("loginIdList","zhangsan,wangwu" ); //接收人登录名
|
||||
// map.put("workCodeList","WS01640,WS01641" ); //接收人编号
|
||||
// map.put("lastNameList","张三,王五" ); //接收人姓名
|
||||
map.put("creater", "1"); //creater的值 创建人OA系统id / 创建人登录名 / 创建人编号 / 创建人姓名(对应接收人所传入的形式)
|
||||
// map.put("creater","zhangsan");
|
||||
// map.put("creater","WS01640");
|
||||
// map.put("creater","张三");
|
||||
map.put("title", "接口创建的消息");
|
||||
map.put("context", "接口创建的消息,看下内容是否进来了");
|
||||
String linkUrl = "http://118.190.132.210:9999/custom_renfu.html?param=corp=ding58007d3a66cc643bacaaa37764f94726--flag=study_project" +
|
||||
"--projectId=1826492840843284480--ticket=2u+cX2Bl4KPQ89QwNOG0VC/YmAv" +
|
||||
"/Sa5pu92FXTgUfGDZlhmqdVyNLtJVcZv3Pe7teWbqGAJhufN8Y4tpIW6c1Q==";
|
||||
map.put("linkUrl", linkUrl);
|
||||
map.put("linkMobileUrl", "http://www.baidu.com");
|
||||
|
||||
// map.put("targetId","559|id22"); //消息来源code +“|”+业务id 消息需要打上已处理标记
|
||||
// map.put("bizState","0"); //0 表示消息初始状态是待处理 消息需要打上已处理标记
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String getAPPID() {
|
||||
return APPID;
|
||||
}
|
||||
|
||||
public static void setAPPID(String APPID) {
|
||||
FanWeiUtil.APPID = APPID;
|
||||
}
|
||||
|
||||
public static String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public static void setPrivateKey(String privateKey) {
|
||||
FanWeiUtil.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public static String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public static void setPublicKey(String publicKey) {
|
||||
FanWeiUtil.publicKey = publicKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 接口调用工具类
|
||||
* 2021-06-08
|
||||
* @author huangzhengguo
|
||||
*
|
||||
*/
|
||||
public class InterfaceListUtil {
|
||||
|
||||
/**
|
||||
* 获取一个token
|
||||
*
|
||||
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public String getToken(String loginName) throws FileNotFoundException, IOException {
|
||||
String address = "";
|
||||
String token = "";
|
||||
if("".equals(loginName)) {
|
||||
address = PropKit.getProp(PropKit.OATOKENURL)+"/"+PropKit.getProp(PropKit.RESTNAME)+"/"+PropKit.getProp(PropKit.RESTPASSWORD);
|
||||
}else {
|
||||
address = PropKit.getProp(PropKit.OATOKENURL)+"/"+PropKit.getProp(PropKit.RESTNAME)+"/"+PropKit.getProp(PropKit.RESTPASSWORD)+"?loginName="+loginName;
|
||||
}
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(address).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
String result = response.toString();
|
||||
if(result.contains("{")) {
|
||||
JSONObject jsObj = JSONObject.parseObject(result);
|
||||
System.out.println(jsObj);
|
||||
token = jsObj.get("id").toString();
|
||||
}else {
|
||||
token = result;
|
||||
}
|
||||
System.out.println(token);
|
||||
} else {
|
||||
System.out.println("GET request not worked");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用get接口
|
||||
*
|
||||
* @param par 拼接在url中的参数
|
||||
* @param strUrl 需要调用的url对应的配置文件的key
|
||||
* @return
|
||||
*/
|
||||
public String doGet(String par, String strUrl, String token) {
|
||||
String address = MessageFormat.format(getProperties(strUrl), par + "?token=") + token;
|
||||
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
String result = "";
|
||||
HttpGet get = new HttpGet(address);
|
||||
try {
|
||||
HttpResponse res = client.execute(get);
|
||||
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
result = EntityUtils.toString(res.getEntity());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// JSONObject jsObj = JSONObject.parseObject(result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用post接口
|
||||
*
|
||||
* @param str 调用接口传递的参数json
|
||||
* @param urlStr 需要调用的url对应的参数文件中的编码
|
||||
* @return
|
||||
*/
|
||||
public JSONObject doPost(String str, String urlStr,String token) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
BufferedReader br = null;
|
||||
String result = null;
|
||||
try {
|
||||
// String token = getToken(getProperties("restUserName"), getProperties("restPassword"));
|
||||
URL url = new URL(getProperties(urlStr) + "?token=" + token);
|
||||
// 通过远程url连接对象打开连接
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置连接请求方式
|
||||
connection.setRequestMethod("POST");
|
||||
// 设置连接主机服务器超时时间:15000毫秒
|
||||
connection.setConnectTimeout(15000);
|
||||
// 设置读取主机服务器返回数据超时时间:60000毫秒
|
||||
connection.setReadTimeout(60000);
|
||||
|
||||
// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
|
||||
connection.setDoOutput(true);
|
||||
// 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无
|
||||
connection.setDoInput(true);
|
||||
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
// 通过连接对象获取一个输出流
|
||||
os = connection.getOutputStream();
|
||||
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
|
||||
if (!("".equals(str) || str == null)) {
|
||||
os.write(str.getBytes("UTF-8"));
|
||||
}
|
||||
// 连接对象获取一个输入流,向远程读取
|
||||
if (connection.getResponseCode() == 200) {
|
||||
|
||||
is = connection.getInputStream();
|
||||
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
|
||||
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
|
||||
StringBuffer sbf = new StringBuffer();
|
||||
String temp = null;
|
||||
// 循环遍历一行一行读取数据
|
||||
while ((temp = br.readLine()) != null) {
|
||||
sbf.append(temp);
|
||||
sbf.append("\r\n");
|
||||
}
|
||||
result = sbf.toString();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
if (null != br) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != os) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != is) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 断开与远程地址url的连接
|
||||
connection.disconnect();
|
||||
}
|
||||
JSONObject json = JSONObject.parseObject(result);
|
||||
return json;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定参数文件的值(pa.properties)
|
||||
*
|
||||
* @param str 参数文件中的key
|
||||
* @return
|
||||
*/
|
||||
public String getProperties(String str) {
|
||||
Properties properties = null;
|
||||
try {
|
||||
properties = PropertiesLoaderUtils.loadAllProperties("pa.properties");
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return (String) properties.get(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用Soap接口 对接平台使用
|
||||
* @param action 平台接口中的方法参数名称
|
||||
* @param xml 传递平台的XML数据参数
|
||||
* @return 返回调取soap接口后接口的返回值(未处理)
|
||||
* @throws HttpException
|
||||
* @throws IOException
|
||||
*/
|
||||
public String doSoap(String action, String xml,String id) throws HttpException, IOException {
|
||||
String wsdl = "";
|
||||
if("createDepartment".equals(action)||"updateDepartment".equals(action)) {
|
||||
wsdl = getProperties("DeptWsdl");
|
||||
}else if("createPractitioner".equals(action)||"updatePractitioner".equals(action)) {
|
||||
wsdl = getProperties("MemberWsdl");
|
||||
}
|
||||
System.out.println("wsdl:"+wsdl);
|
||||
int timeout = 10000;
|
||||
|
||||
// 构造soap请求信息
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
sb.append(
|
||||
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:urn=\"urn:hl7-org:v3\">");
|
||||
sb.append("<soap:Header/>");
|
||||
sb.append("<soap:Body>");
|
||||
sb.append(" <urn:HIPMessageServer>");
|
||||
sb.append("<urn:action>" + action + "</urn:action><urn:message>" + xml + "</urn:message>");
|
||||
sb.append("</urn:HIPMessageServer>");
|
||||
sb.append("</soap:Body>");
|
||||
sb.append("</soap:Envelope>");
|
||||
|
||||
// HttpClient发送SOAP请求
|
||||
// System.out.println("HttpClient 发送SOAP请求");
|
||||
HttpClient client = new HttpClient();
|
||||
PostMethod postMethod = new PostMethod(wsdl);
|
||||
Header header = new Header();
|
||||
// 设置连接超时
|
||||
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
|
||||
// 设置读取时间超时
|
||||
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
|
||||
// 然后把Soap请求数据添加到PostMethod中
|
||||
RequestEntity requestEntity = null;
|
||||
try {
|
||||
requestEntity = new StringRequestEntity(sb.toString(), "text/xml", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 设置请求头部,否则可能会报 “no SOAPAction header” 的错误
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date businessTime = new Date();
|
||||
Date operationTime = new Date();
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Date root = new Date();
|
||||
String rootId = sdf1.format(root);
|
||||
postMethod.setRequestHeader("SOAPAction", "");
|
||||
postMethod.setRequestHeader("Content-Type", "application/fhir+json");
|
||||
postMethod.setRequestHeader("rootId", rootId);
|
||||
postMethod.setRequestHeader("token", id);
|
||||
postMethod.setRequestHeader("domain", "OA");
|
||||
postMethod.setRequestHeader("businessTime", sdf.format(businessTime));
|
||||
postMethod.setRequestHeader("key", "806c1571-35de-41a2-b3c9-06ae5474d43a");
|
||||
postMethod.setRequestHeader("operationTime", sdf.format(operationTime));
|
||||
// 设置请求体
|
||||
postMethod.setRequestEntity(requestEntity);
|
||||
int status = client.executeMethod(postMethod);
|
||||
// 打印请求状态码
|
||||
// System.out.println("status:" + status);
|
||||
// 获取响应体输入流
|
||||
InputStream is = postMethod.getResponseBodyAsStream();
|
||||
// 获取请求结果字符串
|
||||
byte[] bytes = new byte[is.available()];
|
||||
is.read(bytes);
|
||||
String result = new String(bytes);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件到指定目录
|
||||
* @param dowUrl:http地址
|
||||
* @param dowPath:指定目录
|
||||
* */
|
||||
public String download(String dowUrl, String dowPath){
|
||||
try {
|
||||
// log.info("下载地址是:"+dowUrl+",存储地址是:"+dowPath);
|
||||
URL url = new URL(dowUrl);
|
||||
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;// http的连接类
|
||||
|
||||
//String contentType = httpURLConnection.getContentType();//请求类型,可用来过滤请求,
|
||||
|
||||
httpURLConnection.setConnectTimeout(1000*5);//设置超时
|
||||
|
||||
httpURLConnection.setRequestMethod("GET");//设置请求方式,默认是GET
|
||||
|
||||
httpURLConnection.setRequestProperty("Charset", "UTF-8");// 设置字符编码
|
||||
|
||||
httpURLConnection.connect();// 打开连接
|
||||
|
||||
BufferedInputStream bin = new BufferedInputStream(httpURLConnection.getInputStream());
|
||||
|
||||
String path = dowPath;// 指定存放位置
|
||||
File filed = new File(path);
|
||||
|
||||
OutputStream out = new FileOutputStream(filed);
|
||||
int size = 0;
|
||||
|
||||
byte[] b = new byte[2048];
|
||||
//把输入流的文件读取到字节数据b中,然后输出到指定目录的文件
|
||||
while ((size = bin.read(b)) != -1) {
|
||||
out.write(b, 0, size);
|
||||
}
|
||||
// 关闭资源
|
||||
bin.close();
|
||||
out.close();
|
||||
return "200";
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return "500";
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return "400";
|
||||
}
|
||||
}
|
||||
}
|
||||
82
src/com/seeyon/apps/daohuaxiangSys/jkts/util/JdbcUtil.java
Normal file
82
src/com/seeyon/apps/daohuaxiangSys/jkts/util/JdbcUtil.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
|
||||
/**
|
||||
* jdbc工具类
|
||||
* 2021-06-08
|
||||
* @author huangzhengguo
|
||||
*
|
||||
*/
|
||||
public class JdbcUtil {
|
||||
private static String url;
|
||||
private static String user;
|
||||
private static String password;
|
||||
|
||||
static {
|
||||
// 使用properties加载属性文件
|
||||
//Properties prop = new Properties();
|
||||
//String ip = GetIP.getIp();
|
||||
try {
|
||||
//InputStream is = JdbcUtil.class.getClassLoader().getResourceAsStream("pa.properties");
|
||||
//prop.load(is);
|
||||
// 注册驱动(获取属性文件中的数据)
|
||||
String driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
Class.forName(driverClassName);
|
||||
// 获取属性文件中的url,username,password
|
||||
//System.out.println("ip:" + ip);
|
||||
url = "jdbc:sqlserver://192.168.0.250:1433;databaseName=U8CLOUD";
|
||||
user = "sa";
|
||||
password = "Sa123456";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取数据库连接
|
||||
public static Connection getConnection() {
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
public static void close(Connection conn, Statement stat, ResultSet rs) {
|
||||
close(conn, stat);
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
public static void close(Connection conn, Statement stat) {
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (stat != null) {
|
||||
try {
|
||||
stat.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
137
src/com/seeyon/apps/daohuaxiangSys/jkts/util/PropKit.java
Normal file
137
src/com/seeyon/apps/daohuaxiangSys/jkts/util/PropKit.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.jkts.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 读取参数
|
||||
*/
|
||||
|
||||
public class PropKit {
|
||||
|
||||
private static long lastModify;
|
||||
|
||||
private static ConcurrentHashMap<String, String> props;
|
||||
|
||||
public static final String PROFILE = "profile";
|
||||
|
||||
public static final String PAYBILLFILEURL = "paybillFileUrl";
|
||||
public static final String GENERALBILLURL = "generalbillUrl";
|
||||
public static final String TRANSFORMURL = "transformUrl";
|
||||
public static final String XCFZCANCELURL = "xcfzCancelUrl";
|
||||
public static final String SBFZCANCELURL = "sbfzCancelUrl";
|
||||
public static final String OATOKENURL = "oaTokenUrl";
|
||||
public static final String DOWURL = "dowUrl";
|
||||
public static final String JYNCFILE = "jyncFile";
|
||||
public static final String RESTNAME = "restname";
|
||||
public static final String RESTPASSWORD = "restpassword";
|
||||
public static final String ADDRESS = "address";
|
||||
public static final String TONGYONGAPI = "tongyongApi";
|
||||
public static final String APPID = "appid";
|
||||
public static final String SPK = "spk";
|
||||
public static final String WORKFLOWID = "workflowId";
|
||||
public static final String LOGINNAME = "loginName";
|
||||
public static final String SECRET = "secret";
|
||||
public static final String SQL = "sql";
|
||||
public static final String DATASQL = "dataSql";
|
||||
public static final String NEWADDRESS = "newAddress";
|
||||
public static final String NEWSPK = "newSpk";
|
||||
public static final String NEWSECRET = "newSecret";
|
||||
public static final String NEWWORKFLOWID = "newWorkflowId";
|
||||
public static final String LOGINID = "loginid";
|
||||
public static final String PWD = "pwd";
|
||||
|
||||
public static final String PROD_PAYBILLFILEURL = "prod.paybillFileUrl";
|
||||
public static final String PROD_GENERALBILLURL = "prod.generalbillUrl";
|
||||
public static final String PROD_TRANSFORMURL = "prod.transformUrl";
|
||||
public static final String PROD_XCFZCANCELURL = "prod.xcfzCancelUrl";
|
||||
public static final String PROD_SBFZCANCELURL = "prod.sbfzCancelUrl";
|
||||
public static final String PROD_OATOKENURL = "prod.oaTokenUrl";
|
||||
public static final String PROD_DOWURL = "prod.dowUrl";
|
||||
public static final String PROD_JYNCFILE = "prod.jyncFile";
|
||||
public static final String PROD_RESTNAME = "prod.restname";
|
||||
public static final String PROD_RESTPASSWORD = "prod.restpassword";
|
||||
public static final String PROD_ADDRESS = "prod.address";
|
||||
public static final String PROD_TONGYONGAPI = "prod.tongyongApi";
|
||||
public static final String PROD_APPID = "prod.appid";
|
||||
public static final String PROD_SPK = "prod.spk";
|
||||
public static final String PROD_WORKFLOWID = "prod.workflowId";
|
||||
public static final String PROD_LOGINNAME = "prod.loginName";
|
||||
public static final String PROD_SECRET = "prod.secret";
|
||||
public static final String PROD_SQL = "prod.sql";
|
||||
public static final String PROD_DATASQL = "prod.dataSql";
|
||||
public static final String PROD_NEWADDRESS = "prod.newAddress";
|
||||
public static final String PROD_NEWSPK = "prod.newSpk";
|
||||
public static final String PROD_NEWSECRET = "prod.newSecret";
|
||||
public static final String PROD_NEWWORKFLOWID = "prod.newWorkflowId";
|
||||
public static final String PROD_LOGINID = "prod.loginid";
|
||||
public static final String PROD_PWD = "prod.pwd";
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public static String getProp(String key) throws FileNotFoundException, IOException {
|
||||
File f = new File(A8FolderKit.getPropFile());
|
||||
if(null == props) {
|
||||
props = new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
if(f.lastModified() != lastModify) {
|
||||
/**
|
||||
* huangzhengguo
|
||||
* 2022-10-18
|
||||
*/
|
||||
Properties prop = new Properties();
|
||||
prop.load(new FileInputStream(f));
|
||||
// Properties prop = PropertiesUtil.getFromFile((CtpLocalFile) f);
|
||||
/**
|
||||
* end
|
||||
*/
|
||||
String profile = prop.getProperty(PROFILE);
|
||||
if("prod".equals(profile)) {
|
||||
props.put(PAYBILLFILEURL, prop.getProperty(PROD_PAYBILLFILEURL));
|
||||
props.put(GENERALBILLURL, prop.getProperty(PROD_GENERALBILLURL));
|
||||
props.put(TRANSFORMURL, prop.getProperty(PROD_TRANSFORMURL));
|
||||
props.put(XCFZCANCELURL, prop.getProperty(PROD_XCFZCANCELURL));
|
||||
props.put(OATOKENURL, prop.getProperty(PROD_OATOKENURL));
|
||||
props.put(DOWURL, prop.getProperty(PROD_DOWURL));
|
||||
props.put(JYNCFILE, prop.getProperty(PROD_JYNCFILE));
|
||||
props.put(RESTNAME, prop.getProperty(PROD_RESTNAME));
|
||||
props.put(RESTPASSWORD, prop.getProperty(PROD_RESTPASSWORD));
|
||||
props.put(SBFZCANCELURL, prop.getProperty(PROD_SBFZCANCELURL));
|
||||
props.put(ADDRESS, prop.getProperty(PROD_ADDRESS));
|
||||
props.put(TONGYONGAPI, prop.getProperty(PROD_TONGYONGAPI));
|
||||
props.put(APPID, prop.getProperty(PROD_APPID));
|
||||
props.put(SPK, prop.getProperty(PROD_SPK));
|
||||
props.put(WORKFLOWID, prop.getProperty(PROD_WORKFLOWID));
|
||||
props.put(LOGINNAME, prop.getProperty(PROD_LOGINNAME));
|
||||
props.put(SECRET, prop.getProperty(PROD_SECRET));
|
||||
props.put(SQL, prop.getProperty(PROD_SQL));
|
||||
props.put(DATASQL, prop.getProperty(PROD_DATASQL));
|
||||
props.put(NEWADDRESS, prop.getProperty(PROD_NEWADDRESS));
|
||||
props.put(NEWSPK, prop.getProperty(PROD_NEWSPK));
|
||||
props.put(NEWSECRET, prop.getProperty(PROD_NEWSECRET));
|
||||
props.put(NEWWORKFLOWID, prop.getProperty(PROD_NEWWORKFLOWID));
|
||||
props.put(LOGINID, prop.getProperty(PROD_LOGINID));
|
||||
props.put(PWD, prop.getProperty(PROD_PWD));
|
||||
} else {
|
||||
props.put(PAYBILLFILEURL, prop.getProperty(PROD_PAYBILLFILEURL));
|
||||
props.put(GENERALBILLURL, prop.getProperty(PROD_GENERALBILLURL));
|
||||
props.put(TRANSFORMURL, prop.getProperty(PROD_TRANSFORMURL));
|
||||
props.put(XCFZCANCELURL, prop.getProperty(PROD_XCFZCANCELURL));
|
||||
props.put(OATOKENURL, prop.getProperty(PROD_OATOKENURL));
|
||||
props.put(DOWURL, prop.getProperty(PROD_DOWURL));
|
||||
props.put(JYNCFILE, prop.getProperty(PROD_JYNCFILE));
|
||||
props.put(RESTNAME, prop.getProperty(PROD_RESTNAME));
|
||||
props.put(RESTPASSWORD, prop.getProperty(PROD_RESTPASSWORD));
|
||||
}
|
||||
}
|
||||
return props.get(key);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user