diff --git a/JSD-9435-需求确认书V1.0.docx b/JSD-9435-需求确认书V1.0.docx new file mode 100644 index 0000000..fcec979 Binary files /dev/null and b/JSD-9435-需求确认书V1.0.docx differ diff --git a/README.md b/README.md index 1086f9d..7c591fe 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # open-JSD-9435 -JSD-9435 OA推送 \ No newline at end of file +JSD-9435 OA推送\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 \ No newline at end of file diff --git a/lib/axis-1.4.jar b/lib/axis-1.4.jar new file mode 100644 index 0000000..20b09a5 Binary files /dev/null and b/lib/axis-1.4.jar differ diff --git a/lib/axis-jaxrpc-1.4.jar b/lib/axis-jaxrpc-1.4.jar new file mode 100644 index 0000000..a2c13d9 Binary files /dev/null and b/lib/axis-jaxrpc-1.4.jar differ diff --git a/lib/axis-saaj-1.4.jar b/lib/axis-saaj-1.4.jar new file mode 100644 index 0000000..4ea696e Binary files /dev/null and b/lib/axis-saaj-1.4.jar differ diff --git a/lib/commons-discovery-0.2.jar b/lib/commons-discovery-0.2.jar new file mode 100644 index 0000000..b885548 Binary files /dev/null and b/lib/commons-discovery-0.2.jar differ diff --git a/lib/fastjson-1.2.4.jar b/lib/fastjson-1.2.4.jar new file mode 100644 index 0000000..a857260 Binary files /dev/null and b/lib/fastjson-1.2.4.jar differ diff --git a/lib/sqljdbc4.jar b/lib/sqljdbc4.jar new file mode 100644 index 0000000..b26b1ec Binary files /dev/null and b/lib/sqljdbc4.jar differ diff --git a/lib/wsdl4j-1.4.jar b/lib/wsdl4j-1.4.jar new file mode 100644 index 0000000..49cc2c6 Binary files /dev/null and b/lib/wsdl4j-1.4.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..a19cdb8 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,24 @@ + + com.eco.plugin.xxxx.webservicets + + yes + 1.0.14 + 10.0 + 2018-07-31 + fr.open + + + com.eco.plugin.xxxx.webservicets + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/bean/EmployFLOW.java b/src/main/java/com/eco/plugin/xxxx/webservicets/bean/EmployFLOW.java new file mode 100644 index 0000000..6d4f2cd --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/bean/EmployFLOW.java @@ -0,0 +1,184 @@ +package com.eco.plugin.xxxx.webservicets.bean; + +public class EmployFLOW { + private String FlowId; + private String FlowType; + private String Submitdate; + private String SubmitUser; + private String FlowNode1; + private String FlowNode2; + private String CompanyId; + private String BYZD2; + private String FlowName; + private String Type; + private String Grade; + private String FlowNode3; + private String DATATYPE; //报表类型 + private String SBNF; //上报年份 + private String SBLX; //上报类型 + private String bt; + private String nd ; + private String year ; + private String nf; + private String role; + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getBt() { + return bt; + } + + public void setBt(String bt) { + this.bt = bt; + } + + public String getNd() { + return nd; + } + + public void setNd(String nd) { + this.nd = nd; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getNf() { + return nf; + } + + public void setNf(String nf) { + this.nf = nf; + } + + public String getSBNF() { + return SBNF; + } + + public void setSBNF(String SBNF) { + this.SBNF = SBNF; + } + + public String getSBLX() { + return SBLX; + } + + public void setSBLX(String SBLX) { + this.SBLX = SBLX; + } + + public String getFlowId() { + return FlowId; + } + + public void setFlowId(String flowId) { + FlowId = flowId; + } + + public String getFlowType() { + return FlowType; + } + + public void setFlowType(String flowType) { + FlowType = flowType; + } + + public String getSubmitdate() { + return Submitdate; + } + + public void setSubmitdate(String submitdate) { + Submitdate = submitdate; + } + + public String getSubmitUser() { + return SubmitUser; + } + + public void setSubmitUser(String submitUser) { + SubmitUser = submitUser; + } + + public String getFlowNode1() { + return FlowNode1; + } + + public void setFlowNode1(String flowNode1) { + FlowNode1 = flowNode1; + } + + public String getFlowNode2() { + return FlowNode2; + } + + public void setFlowNode2(String flowNode2) { + FlowNode2 = flowNode2; + } + + public String getCompanyId() { + return CompanyId; + } + + public void setCompanyId(String companyId) { + CompanyId = companyId; + } + + public String getBYZD2() { + return BYZD2; + } + + public void setBYZD2(String BYZD2) { + this.BYZD2 = BYZD2; + } + + public String getFlowName() { + return FlowName; + } + + public void setFlowName(String flowName) { + FlowName = flowName; + } + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public String getGrade() { + return Grade; + } + + public void setGrade(String grade) { + Grade = grade; + } + + public String getFlowNode3() { + return FlowNode3; + } + + public void setFlowNode3(String flowNode3) { + FlowNode3 = flowNode3; + } + + public String getDATATYPE() { + return DATATYPE; + } + + public void setDATATYPE(String DATATYPE) { + this.DATATYPE = DATATYPE; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/config/InitializeMonitor.java b/src/main/java/com/eco/plugin/xxxx/webservicets/config/InitializeMonitor.java new file mode 100644 index 0000000..c291926 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/config/InitializeMonitor.java @@ -0,0 +1,33 @@ +package com.eco.plugin.xxxx.webservicets.config; + +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.DSDDMsgFormula; +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.TsBean; +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.TsEntity; +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.TsHandler; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; +import com.fr.schedule.extension.report.job.output.formula.FormulaBox; +import com.fr.schedule.feature.ScheduleOutputActionEntityRegister; +import com.fr.schedule.feature.output.OutputActionHandler; + +/** + * @author fr.open + * @version 10.0 + * Created by fr.open on 2021-12-03 + */ +public class InitializeMonitor extends AbstractPluginLifecycleMonitor { + @Override + public void afterRun(PluginContext pluginContext) { + OutputActionHandler.registerHandler(new TsHandler(), TsBean.class.getName()); + ScheduleOutputActionEntityRegister.getInstance().addClass(TsEntity.class); + FormulaBox.KEY.register(new DSDDMsgFormula()); + + WinkSimpleConfig.getInstance(); + } + + @Override + public void beforeStop(PluginContext pluginContext) { + OutputActionHandler.removeOutputHandler(TsBean.class.getName()); + ScheduleOutputActionEntityRegister.getInstance().removeClass(TsEntity.class); + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/config/WinkSimpleConfig.java b/src/main/java/com/eco/plugin/xxxx/webservicets/config/WinkSimpleConfig.java new file mode 100644 index 0000000..2dc9654 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/config/WinkSimpleConfig.java @@ -0,0 +1,178 @@ +package com.eco.plugin.xxxx.webservicets.config; + +import com.fr.config.*; +import com.fr.config.holder.Conf; +import com.fr.config.holder.factory.Holders; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; + +@Visualization(category = "代办配置") +@EnableMetrics +public class WinkSimpleConfig extends DefaultConfiguration { + + private static volatile WinkSimpleConfig config = null; + + @Focus(id="com.eco.plugin.xxxx.webservicets.config", text = "单点登录配置", source = Original.PLUGIN) + public static WinkSimpleConfig getInstance() { + if (config == null) { + config = ConfigContext.getConfigInstance(WinkSimpleConfig.class); + } + return config; + } + + @Identifier(value = "tempname", name = "模板名称", description = "模板名称", status = Status.SHOW) + private Conf tempname = Holders.simple(""); + + @Identifier(value = "tburl", name = "填报地址", description = "填报地址", status = Status.SHOW) + private Conf tburl = Holders.simple(""); + + @Identifier(value = "shurl", name = "审核地址", description = "审核地址", status = Status.SHOW) + private Conf shurl = Holders.simple(""); + + @Identifier(value = "userWsdlUrl", name = "userWsdlUrl", description = "userWsdlUrl", status = Status.SHOW) + private Conf userWsdlUrl = Holders.simple(""); + + @Identifier(value = "userNamespace", name = "userNamespace", description = "userNamespace", status = Status.SHOW) + private Conf userNamespace = Holders.simple(""); + + @Identifier(value = "userMethod", name = "userMethod", description = "userMethod", status = Status.SHOW) + private Conf userMethod = Holders.simple(""); + + @Identifier(value = "userKey", name = "userKey", description = "userKey", status = Status.SHOW) + private Conf userKey = Holders.simple(""); + + @Identifier(value = "loginWsdlUrl", name = "loginWsdlUrl", description = "loginWsdlUrl", status = Status.SHOW) + private Conf loginWsdlUrl = Holders.simple(""); + + @Identifier(value = "loginNamespace", name = "loginNamespace", description = "loginNamespace", status = Status.SHOW) + private Conf loginNamespace = Holders.simple(""); + + @Identifier(value = "loginMethod", name = "loginMethod", description = "loginMethod", status = Status.SHOW) + private Conf loginMethod = Holders.simple(""); + + @Identifier(value = "OAWsdlUrl", name = "OAWsdlUrl", description = "OAWsdlUrl", status = Status.SHOW) + private Conf OAWsdlUrl = Holders.simple(""); + + @Identifier(value = "OANamespace", name = "OANamespace", description = "OANamespace", status = Status.SHOW) + private Conf OANamespace = Holders.simple(""); + + @Identifier(value = "OAMethod", name = "OAMethod", description = "OAMethod", status = Status.SHOW) + private Conf OAMethod = Holders.simple(""); + + public String getTempname() { + return tempname.get(); + } + + public void setTempname(String url) { + this.tempname.set(url); + } + + public String getTburl() { + return tburl.get(); + } + + public void setTburl(String url) { + this.tburl.set(url); + } + + public String getShurl() { + return shurl.get(); + } + + public void setShurl(String url) { + this.shurl.set(url); + } + + public String getUserWsdlUrl() { + return userWsdlUrl.get(); + } + + public void setUserWsdlUrl(String url) { + this.userWsdlUrl.set(url); + } + + public String getUserNamespace() { + return userNamespace.get(); + } + + public void setUserNamespace(String url) { + this.userNamespace.set(url); + } + + public String getUserMethod() { + return userMethod.get(); + } + + public void setUserMethod(String url) { + this.userMethod.set(url); + } + + public String getUserKey() { + return userKey.get(); + } + + public void setUserKey(String url) { + this.userKey.set(url); + } + + public String getLoginWsdlUrl() { + return loginWsdlUrl.get(); + } + + public void setLoginWsdlUrl(String url) { + this.loginWsdlUrl.set(url); + } + + public String getLoginNamespace() { + return loginNamespace.get(); + } + + public void setLoginNamespace(String url) { + this.loginNamespace.set(url); + } + + public String getLoginMethod() { + return loginMethod.get(); + } + + public void setLoginMethod(String url) { + this.loginMethod.set(url); + } + + public String getOAWsdlUrl() { + return OAWsdlUrl.get(); + } + + public void setOAWsdlUrl(String url) { + this.OAWsdlUrl.set(url); + } + + public String getOANamespace() { + return OANamespace.get(); + } + + public void setOANamespace(String url) { + this.OANamespace.set(url); + } + + public String getOAMethod() { + return OAMethod.get(); + } + + public void setOAMethod(String url) { + this.OAMethod.set(url); + } + + @Override + public Object clone() throws CloneNotSupportedException { + WinkSimpleConfig cloned = (WinkSimpleConfig) super.clone(); +// cloned.text = (Conf) text.clone(); +// cloned.count = (Conf) count.clone(); +// cloned.price = (Conf) price.clone(); +// cloned.time = (Conf) time.clone(); +// cloned.student = (Conf) student.clone(); + return cloned; + } + +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/DBAccessProvider.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/DBAccessProvider.java new file mode 100644 index 0000000..a8c14c2 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/DBAccessProvider.java @@ -0,0 +1,38 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.db; + +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.TsEntity; +import com.fr.decision.plugin.db.AbstractDecisionDBAccessProvider; +import com.fr.stable.db.accessor.DBAccessor; +import com.fr.stable.db.dao.BaseDAO; +import com.fr.stable.db.dao.DAOProvider; + +public class DBAccessProvider extends AbstractDecisionDBAccessProvider { + private static DBAccessor dbAccessor = null; + + public static DBAccessor getDbAccessor(){ + return dbAccessor; + } + + + @Override + public DAOProvider[] registerDAO() { + return new DAOProvider[]{ + new DAOProvider() { + @Override + public Class getEntityClass() { + return TsEntity.class; + } + + @Override + public Class getDAOClass() { + return Dao.class; + } + } + }; + } + + @Override + public void onDBAvailable(DBAccessor dbAccessor) { + this.dbAccessor = dbAccessor; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/Dao.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/Dao.java new file mode 100644 index 0000000..1618f4c --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/db/Dao.java @@ -0,0 +1,14 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.db; + +import com.eco.plugin.xxxx.webservicets.dsdd.dsdd.TsEntity; +import com.fr.stable.db.dao.BaseDAO; +import com.fr.stable.db.session.DAOSession; + +/** + * Created by fr.open on 2021-12-03. + */ +public class Dao extends BaseDAO { + public Dao(DAOSession daoSession) { + super(daoSession); + } +} \ No newline at end of file diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/DSDDMsgFormula.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/DSDDMsgFormula.java new file mode 100644 index 0000000..4c4325a --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/DSDDMsgFormula.java @@ -0,0 +1,21 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.dsdd; + +import com.fr.main.workbook.ResultWorkBook; +import com.fr.schedule.extension.report.provider.impl.AbstractReportOutputFormulaProvider; + +import java.util.List; +import java.util.Map; + +public class DSDDMsgFormula extends AbstractReportOutputFormulaProvider { + public DSDDMsgFormula() { + } + + public void dealWithFormulaParam(TsBean syncBean, ResultWorkBook resultWorkBook, List> param) throws Exception { +// syncBean.setTitle(ScheduleParameterUtils.dealWithParameter(syncBean.getTitle(), (Map)param.get(0), resultWorkBook)); + } + + public String getActionClassName() { + return TsBean.class.getName(); + } +} + diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsBean.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsBean.java new file mode 100644 index 0000000..b171cbd --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsBean.java @@ -0,0 +1,93 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.dsdd; + +import com.fr.schedule.base.bean.output.BaseOutputAction; +import com.fr.schedule.base.entity.AbstractScheduleEntity; +import com.fr.schedule.base.type.RunType; +import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; + +@JsonSubTypes.Type(value = TsBean.class, name = "TsBean") +public class TsBean extends BaseOutputAction { + private static final long serialVersionUID = 8245931480823179622L; +// private String content = null; + + //报表类型 + private String type = null; + //数据集名称 + private String serverdata = null; + + public TsBean(){ + super(); + } + + //是否受不同用户生成不同附件影响 + @Override + public boolean willExecuteByUser() { + return false; + } + + @Override + public RunType runType() { + return RunType.SEND_EMAIL; + } + + //这里直接关联第一步的entity类 + @Override + public Class outputActionEntityClass() { + return TsEntity.class; + } + + public TsBean id(String id){ + setId(id); + return this; + } + +// public String getContent() { +// return content; +// } +// +// public void setContent(String content) { +// this.content = content; +// } +// +// public TsBean content(String content){ +// setContent(content); +// return this; +// } + + public String getType() { + return type; + } + + public void setType(String title) { + this.type = title; + } + + public TsBean type(String title){ + setType(title); + return this; + } + + public String getServerdata() { + return serverdata; + } + + public void setServerdata(String type) { + this.serverdata = type; + } + + public TsBean serverdata(String type){ + setServerdata(type); + return this; + } + + //转换成entity对象,用于数据库存储,注意属性不要漏了 + @Override + public TsEntity createOutputActionEntity() { + return new TsEntity() + .id(this.getId()) +// .content(this.getContent()) + .serverdata(this.getServerdata()) + .type(this.getType()) + ; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsEntity.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsEntity.java new file mode 100644 index 0000000..ac7f1be --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsEntity.java @@ -0,0 +1,82 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.dsdd; + +import com.fr.schedule.base.entity.AbstractScheduleEntity; +import com.fr.stable.db.entity.TableAssociation; +import com.fr.third.javax.persistence.Column; +import com.fr.third.javax.persistence.Entity; +import com.fr.third.javax.persistence.Table; + +@Entity +@Table(name = "fine_output_wink_message") //表名 +@TableAssociation(associated = true) +public class TsEntity extends AbstractScheduleEntity{ + public TsEntity(){} + + @Column(name = "type") + private String type = null; + + @Column(name = "content") + private String serverdata = null; +// +// @Column(name = "msgtype") +// private String msgtype = null; + + public TsEntity id(String id) { + setId(id); + return this; + } + +// public String getContent() { +// return content; +// } +// +// public void setContent(String content) { +// this.content = content; +// } +// +// public TsEntity content(String content){ +// setContent(content); +// return this; +// } + + public String getType() { + return type; + } + + public void setType(String title) { + this.type = title; + } + + public TsEntity type(String title){ + setType(title); + return this; + } + + public String getServerdata() { + return serverdata; + } + + public void setServerdata(String type) { + this.serverdata = type; + } + + public TsEntity serverdata(String content){ + setServerdata(content); + return this; + } + + + + //转换成bean对象 + @Override + public TsBean createBean() { + return new TsBean() + .id(this.getId()) + .serverdata(this.getServerdata()) + .type(this.getType()) +// .content(this.getContent()) +// .msgtype(this.getMsgtype()) +// .title(this.getTitle()) + ; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsHandler.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsHandler.java new file mode 100644 index 0000000..5b0cb3f --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/dsdd/TsHandler.java @@ -0,0 +1,140 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.dsdd; + +import com.eco.plugin.xxxx.webservicets.utils.FRUtils; +import com.eco.plugin.xxxx.webservicets.utils.WebServiceUtil; +import com.fr.base.TableData; +import com.fr.general.data.DataModel; +import com.fr.general.data.TableDataException; +import com.fr.schedule.base.bean.ScheduleTask; +import com.fr.schedule.base.controller.ScheduleTaskController; +import com.fr.schedule.feature.ScheduleContext; +import com.fr.schedule.feature.output.OutputActionHandler; +import com.fr.script.Calculator; +import com.fr.stable.query.QueryFactory; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Map; + +public class TsHandler extends OutputActionHandler{ + @Override + public void doAction(TsBean tsBean, Map map) throws TableDataException { + String type = tsBean.getType(); + String servername = tsBean.getServerdata(); + + FRUtils.FRLogInfo("type:"+type+";servername:"+servername); + + Map config = WebServiceUtil.getConfig(type); + + FRUtils.FRLogInfo("config:"+config.toString()); + + TableData userInfo = FRUtils.getTableData(servername); + DataModel userInfoDM = userInfo.createDataModel(Calculator.createCalculator()); + + int fridindex = userInfoDM.getColumnIndex("FlowId"); + int receiverindex = userInfoDM.getColumnIndex("FlowNode1"); + int flowNode2Index = userInfoDM.getColumnIndex("FlowNode2"); + int FlowNameindex = userInfoDM.getColumnIndex("FlowName"); + + int btindex = userInfoDM.getColumnIndex("bt"); + int ndindex = userInfoDM.getColumnIndex("nd"); + int yearindex = userInfoDM.getColumnIndex("year"); + int nfindex = userInfoDM.getColumnIndex("nf"); + int usernameindex = userInfoDM.getColumnIndex("fine_username"); + + + String name = config.get("name"); + String tburl = config.get("tburl"); + + int rowcount = userInfoDM.getRowCount(); + + for(int i=0;i map){ + + String taskName = String.valueOf(map.get("taskName")); + + ScheduleTask scheduleTask = getTask(taskName); + + int showType = scheduleTask.getShowType(); + String templateName = scheduleTask.getTemplatePath(); + try { + templateName = URLEncoder.encode(templateName,"utf-8"); + } catch (UnsupportedEncodingException e) { + FRUtils.FRLogInfo("编码模板名称异常:"+e.getMessage()); + return ""; + } + + if(1 == showType){ + templateName+="&op=write"; + } + else if(2 == showType){ + templateName += "&op=view"; + } + else if(3 == showType){ + templateName += "&op=write_plus"; + } + + return tsBean.getResultURL()+"/view/report?viewlet="+templateName; + } + + /** + * 获取用户组信息 + * @param map + * @return + */ + private static String[] getUserGroup(Map map){ + String taskName = String.valueOf(map.get("taskName")); + ScheduleTask scheduleTask = getTask(taskName); + + return scheduleTask.getUserGroup().createUserNameArray(); + } + +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/webresource/DsddWebResourceProvider.java b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/webresource/DsddWebResourceProvider.java new file mode 100644 index 0000000..85ed33a --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/dsdd/webresource/DsddWebResourceProvider.java @@ -0,0 +1,35 @@ +package com.eco.plugin.xxxx.webservicets.dsdd.webresource; + +import com.fr.decision.fun.impl.AbstractWebResourceProvider; +import com.fr.decision.web.MainComponent; +import com.fr.web.struct.Atom; +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + +/** + * + */ +public class DsddWebResourceProvider extends AbstractWebResourceProvider { + @Override + public Atom attach() { + return MainComponent.KEY; + } + + @Override + public Atom client() { + return new Component() { + @Override + public ScriptPath script(RequestClient requestClient) { + return ScriptPath.build("/com/eco/plugin/xxxx/webservicets/js/dsdd.js"); + } + + @Override + public StylePath style(RequestClient requestClient) { + return StylePath.EMPTY; +// return StylePath.build("/com/fr/plugin/jdfSSO/css/icon.css"); + } + }; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/handler/ExtendAttrHandlerProvider.java b/src/main/java/com/eco/plugin/xxxx/webservicets/handler/ExtendAttrHandlerProvider.java new file mode 100644 index 0000000..75260c9 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/handler/ExtendAttrHandlerProvider.java @@ -0,0 +1,13 @@ +package com.eco.plugin.xxxx.webservicets.handler; + +import com.fr.decision.fun.HttpHandler; +import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; + +public class ExtendAttrHandlerProvider extends AbstractHttpHandlerProvider { + @Override + public HttpHandler[] registerHandlers() { + return new HttpHandler[]{ + new FlowHandler(), + }; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/handler/FlowHandler.java b/src/main/java/com/eco/plugin/xxxx/webservicets/handler/FlowHandler.java new file mode 100644 index 0000000..05a0295 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/handler/FlowHandler.java @@ -0,0 +1,166 @@ +package com.eco.plugin.xxxx.webservicets.handler; + +import com.eco.plugin.xxxx.webservicets.bean.EmployFLOW; +import com.eco.plugin.xxxx.webservicets.utils.FRUtils; +import com.eco.plugin.xxxx.webservicets.utils.ResponseUtils; +import com.eco.plugin.xxxx.webservicets.utils.WebServiceUtil; +import com.fr.base.TableData; +import com.fr.decision.fun.impl.BaseHttpHandler; +import com.fr.general.data.DataModel; +import com.fr.general.data.TableDataException; +import com.fr.script.Calculator; +import com.fr.third.springframework.web.bind.annotation.RequestMethod; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; + +public class FlowHandler extends BaseHttpHandler { + public FlowHandler() { + } + + @Override + public RequestMethod getMethod() { + return RequestMethod.GET; + } + + @Override + public String getPath() { + return "/operateFlow"; + } + + @Override + public boolean isPublic() { + return true; + } + + @Override + public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { + + String operation = req.getParameter("operation"); + String url = req.getParameter("url"); + String type = req.getParameter("type"); + String servername = req.getParameter("serverdataname"); + + Map paramMap = this.getParamMap(url); + String flowId = paramMap.get("flowId"); + String sysId = flowId+type; + String approveId = flowId+type+"sh"; + + EmployFLOW ef = getEmployFlowByFlowId(flowId,servername); + + String node1 = ef.getFlowNode1(); + String node2 = ef.getFlowNode2(); + + String publicParam = "&flowId="+flowId+"&node1="+node1+"&node2="+node2; + + Map config = WebServiceUtil.getConfig(type); + + String workFlowName = config.get("name"); + String pcUrl = config.get("tburl") +publicParam;; + String shUrl = config.get("shurl") +publicParam;; + + workFlowName = ef.getFlowName() + workFlowName; + + + if(operation==null || operation.isEmpty()){ + ResponseUtils.failedResponse(res,"operation不能为空"); + return ; + } + + + if(sysId == null || sysId.isEmpty() || node1==null || node1.isEmpty()|| flowId==null || flowId.isEmpty()){ + ResponseUtils.failedResponse(res,"sysId,node1,flowId不能为空"); + return ; + } + + if("1".equals(operation)){ + endFlow(sysId,node1,workFlowName); + + shUrl+="&SBNF="+ef.getSBNF()+"&SBLX="+ef.getSBLX()+"&bt="+ URLEncoder.encode(ef.getBt())+"&nd="+ef.getNd()+"&year="+ef.getYear()+"&nf="+ef.getNf()+"&projectid="+flowId+"&fine_role="+ef.getRole(); + startFlow(approveId,node2,workFlowName+"审核",shUrl); + + FRUtils.FRLogInfo("完成填报,sysId:"+sysId+";approveId="+approveId); + }else if("2".equals(operation)){ + endFlow(approveId,node2,workFlowName+"退回"); + + startFlow(sysId,node1,workFlowName+"被退回",pcUrl+"&sysId="+sysId); + + FRUtils.FRLogInfo("退回:sysId->"+sysId+";approveId->"+approveId); + + }else{ + endFlow(approveId,node2,workFlowName+"结束"); + } + } + + private void startFlow(String approvId,String aprrovName,String workFlowName,String redirectUrl){ + WebServiceUtil.flowOperater("0",approvId,redirectUrl,workFlowName,"待办",aprrovName); + } + + private void endFlow(String sysId,String userName,String workFLowName){ + WebServiceUtil.flowOperater("2",sysId,"",workFLowName,"完成",userName); + } + + private Map getParamMap(String url){ + Map resultMap = new HashMap(); + String[] urls = url.split("\\?"); + String[] param = urls[1].split("&"); + + for(String item : param){ + String[] paramItem = item.split("="); + resultMap.put(paramItem[0],paramItem[1]); + } + + return resultMap; + } + + private EmployFLOW getEmployFlowByFlowId(String flowId, String servername) throws TableDataException { + TableData tableData = FRUtils.getTableData(servername); + DataModel userInfoDM = tableData.createDataModel(Calculator.createCalculator()); + + int flowIdindex = userInfoDM.getColumnIndex("FlowId"); + int flowNode1index = userInfoDM.getColumnIndex("FlowNode1"); + int flowNode2index = userInfoDM.getColumnIndex("FlowNode2"); + int flowNameindex = userInfoDM.getColumnIndex("FlowName"); + int SBLXindex = userInfoDM.getColumnIndex("SBLX"); + int SBNFindex = userInfoDM.getColumnIndex("SBNF"); + + int btindex = userInfoDM.getColumnIndex("bt"); + int ndindex = userInfoDM.getColumnIndex("nd"); + int yearindex = userInfoDM.getColumnIndex("year"); + int nfindex = userInfoDM.getColumnIndex("nf"); + int roleIndex = userInfoDM.getColumnIndex("fine_role"); + + EmployFLOW ef = new EmployFLOW(); + + for(int i =0;i getDateList(String date,int length){ + List dateList = new ArrayList(); + String format = "yyyy-MM-dd"; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //获取length天后的日期 + + String targetDate = getAfterDateStr(Calendar.DATE,date,length,format); + + Date start = null; + Date end = null; + + if(length >= 0) { + start = strToDate(date,format); + end = strToDate(targetDate,format); + }else { + start = strToDate(targetDate,format); + end = strToDate(date,format); + } + + Calendar calBegin = Calendar.getInstance(); + calBegin.setTime(start); + Calendar calEnd = Calendar.getInstance(); + calEnd.setTime(end); + + while (end.after(calBegin.getTime())) { + calBegin.add(Calendar.DATE, 1); + String dayStr = sdf.format(calBegin.getTime()); + dateList.add(dayStr); + } + + return dateList; + } + + /** + * 比较startDate是否在endDate之前 + * @param startDate + * @param endDate + * @param format + * @return 0 两个日期相等 <0 开始日期在结束日期之前 >0 开始日期在结束日期之后 + */ + public static int comparisonDate(String startDate,String endDate,String format) { + Date start = strToDate(startDate,format); + Date end = strToDate(endDate,format); + + return start.compareTo(end); + } + + //获取当前日期年、月、日、时、分、秒 + public static int getCount(int type){ + Calendar calendar = Calendar.getInstance(); + + return calendar.get(type); + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/utils/FRUtils.java b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/FRUtils.java new file mode 100644 index 0000000..a200d82 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/FRUtils.java @@ -0,0 +1,256 @@ +package com.eco.plugin.xxxx.webservicets.utils; + +import com.fr.base.ServerConfig; +import com.fr.base.TableData; +import com.fr.decision.authority.AuthorityContext; +import com.fr.decision.authority.data.User; +import com.fr.decision.webservice.login.LogInOutResultInfo; +import com.fr.decision.webservice.utils.DecisionServiceConstants; +import com.fr.decision.webservice.v10.login.LoginService; +import com.fr.decision.webservice.v10.login.event.LogInOutEvent; +import com.fr.decision.webservice.v10.user.UserService; +import com.fr.event.EventDispatcher; +import com.fr.file.TableDataConfig; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.stable.query.QueryFactory; +import com.fr.stable.query.restriction.RestrictionFactory; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.util.List; + +public class FRUtils { + /** + * 判断用户是否存在 + * @param userName + * @return + */ + public static boolean isUserExist(String userName){ + if (StringUtils.isEmpty(userName)) { + return false; + } else { + try { + List var1 = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName))); + return var1 != null && !var1.isEmpty(); + } catch (Exception var2) { + FineLoggerFactory.getLogger().error(var2.getMessage()); + return false; + } + } + } + + /** + * 判断是否登录FR + * @param req + * @return + */ + public static boolean isLogin(HttpServletRequest req){ + return LoginService.getInstance().isLogged(req); + } + + /** + * 帆软登录 + * @param httpServletRequest + * @param httpServletResponse + * @param userName + * @param url + */ + public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){ + + FineLoggerFactory.getLogger().info("FRLOG:用户名:"+userName); + FineLoggerFactory.getLogger().info("FRLOG:跳转链接:"+url); + + + //判断用户名是否为空 + if(!Utils.isNullStr(userName)){ + if(isUserExist(userName)){ + String FRToken = ""; + + try { + //HttpSession session = httpServletRequest.getSession(true); + + FRToken = LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName); + + //httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,FRToken); + + //session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, FRToken); + EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true)); + FineLoggerFactory.getLogger().info("FRLOG:登陆成功!"); + + if(!Utils.isNullStr(url)){ + httpServletResponse.sendRedirect(url); + } + } catch (Exception e) { + ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!"); + FineLoggerFactory.getLogger().info("FRLOG:登录异常,请联系管理员!"); + FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage()); + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"用户在报表系统中不存在!"); + FineLoggerFactory.getLogger().info("FRLOG:用户在报表系统中不存在!"); + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!"); + FineLoggerFactory.getLogger().info("FRLOG:用户名不能为空!"); + } + } + + /** + * 帆软登录 + * @param httpServletRequest + * @param httpServletResponse + * @param token + * @param url + */ + public static void loginByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token,String url){ + + FineLoggerFactory.getLogger().info("FRLOG:token:"+token); + FineLoggerFactory.getLogger().info("FRLOG:跳转链接:"+url); + + + //判断用户名是否为空 + if(!Utils.isNullStr(token)){ + writeToken2Cookie(httpServletResponse,token,-1); + + HttpSession session = httpServletRequest.getSession(true); + + httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,token); + + session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token); + + if(!Utils.isNullStr(url)){ + try { + httpServletResponse.sendRedirect(url); + } catch (IOException e) { + ResponseUtils.failedResponse(httpServletResponse,"跳转异常!"); + FineLoggerFactory.getLogger().info("FRLOG:跳转异常!"); + } + } + }else{ + ResponseUtils.failedResponse(httpServletResponse,"token不能为空!"); + FineLoggerFactory.getLogger().info("FRLOG:token不能为空!"); + } + } + + /** + * 获取token + * @param httpServletRequest + * @param httpServletResponse + * @param username + * @return + */ + public static String getToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String username){ + String token = ""; + try { + token = LoginService.getInstance().login(httpServletRequest, httpServletResponse, username); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("FRLOG:获取token失败"+e.getMessage()); + } + + return token; + } + + private static void writeToken2Cookie(HttpServletResponse var1, String var2, int var3) { + try { + if (StringUtils.isNotEmpty(var2)) { + Cookie var4 = new Cookie("fine_auth_token", var2); + long var5 = var3 == -2 ? 1209600000L : (long)var3; + var4.setMaxAge((int)var5); + var4.setPath(ServerConfig.getInstance().getCookiePath()); + var1.addCookie(var4); + Cookie var7 = new Cookie("fine_remember_login", String.valueOf(var3 == -2 ? -2 : -1)); + var7.setMaxAge((int)var5); + var7.setPath(ServerConfig.getInstance().getCookiePath()); + var1.addCookie(var7); + } else { + FineLoggerFactory.getLogger().error("empty token cannot save."); + } + } catch (Exception var8) { + FineLoggerFactory.getLogger().error(var8.getMessage(), var8); + } + + } + + /** + * + * @param httpServletRequest + * @param httpServletResponse + */ + public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) + { + if(!isLogin(httpServletRequest)){ + return ; + } + + try { + LoginService.getInstance().logout(httpServletRequest,httpServletResponse); + } catch (Exception e) { + ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!"); + FineLoggerFactory.getLogger().info("FRLOG:登出异常,请联系管理员!"); + FineLoggerFactory.getLogger().info("FRLOGException:"+e.getMessage()); + } + } + + /** + * 打印FR日志 + * @param message + */ + public static void FRLogInfo(String message){ + FineLoggerFactory.getLogger().info("FRLOG:"+message); + } + + /** + * 打印FR日志-error + * @param message + */ + public static void FRLogError(String message){ + FineLoggerFactory.getLogger().error("FRLOG:"+message); + } + + + /** + * 根据用户名获取用户信息 + * @param userName + * @return + */ + public static User getFRUserByUserName(String userName){ + try { + return UserService.getInstance().getUserByUserName(userName); + } catch (Exception e) { + FRLogInfo("获取用户信息异常:"+e.getMessage()); + } + + return null; + } + + /** + * 解密FR密码 + * @param password + * @return + */ +// public static String decryptFRPsd(String password){ +// FRLogInfo("解密密码:"+password); +// return TransmissionTool.decrypt(password); +// } + + /** + * 获取带参数的访问链接 + * @return + */ + public static String getAllUrl(HttpServletRequest httpServletRequest){ + return WebUtils.getOriginalURL(httpServletRequest); + } + + public static TableData getTableData(String serverDataSetName){ + TableData userInfo = TableDataConfig.getInstance().getTableData(serverDataSetName); + +// DataModel userInfoDM = userInfo.createDataModel(Calculator.createCalculator()); +// userInfoDM.get + return userInfo; + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/utils/ResponseUtils.java b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/ResponseUtils.java new file mode 100644 index 0000000..c684ad0 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/ResponseUtils.java @@ -0,0 +1,94 @@ +package com.eco.plugin.xxxx.webservicets.utils; + +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +public class ResponseUtils { + private static final int SUCCESS = 200; + private static final int FAILED = -1; + + public static void successResponse(HttpServletResponse res, String body) { + response(res, body, SUCCESS); + } + + public static void failedResponse(HttpServletResponse res, String body) { + response(res, body, FAILED); + } + + private static void response(HttpServletResponse res, String body, int code) { + JSONObject object = new JSONObject(); + PrintWriter pw; + try { + object.put("code", code); + object.put("data", body); + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + return; + } + res.setContentType("application/json;charset=utf-8"); + String result = object.toString(); + pw.println(result); + pw.flush(); + pw.close(); + } + + public static void response(HttpServletResponse res,JSONObject json){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + return; + } + res.setContentType("application/json;charset=utf-8"); + String result = json.toString(); + pw.println(result); + pw.flush(); + pw.close(); + } + + public static void responseXml(HttpServletResponse res,String xml){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + return; + } + res.setContentType("text/xml;charset=utf-8"); + pw.println(xml); + pw.flush(); + pw.close(); + } + + public static void setCSRFHeader(HttpServletResponse httpServletResponse){ + httpServletResponse.setHeader("Access-Control-Allow-Origin", "*"); + httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH"); + httpServletResponse.setHeader("Access-Control-Max-Age", "36000"); + httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization"); + } + + public static void responseJsonp(HttpServletRequest req, HttpServletResponse res, JSONObject json){ + PrintWriter pw; + try { + pw = WebUtils.createPrintWriter(res); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + return; + } + res.setContentType("text/javascript;charset=utf-8;charset=utf-8"); + String result = json.toString(); + + String jsonp=req.getParameter("callback"); + + pw.println(jsonp+"("+result+")"); + pw.flush(); + pw.close(); + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/utils/Utils.java b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/Utils.java new file mode 100644 index 0000000..4f3f3c1 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/Utils.java @@ -0,0 +1,226 @@ +package com.eco.plugin.xxxx.webservicets.utils; + +import com.fr.base.TemplateUtils; +import com.fr.data.NetworkHelper; +import com.fr.io.utils.ResourceIOUtils; +import com.fr.json.JSONObject; +import com.fr.stable.CodeUtils; +import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.InputStream; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Utils { + + /** + * 判断字符串是否为空 + * @param str + * @return true 空字符串 false 非空字符串 + */ + public static boolean isNullStr(String str){ + return !(str != null && !str.isEmpty() && !"null".equals(str)); + } + + /** + * 判断字符串是否非空 + * @param str + * @return + */ + public static boolean isNotNullStr(String str){ + return !isNullStr(str); + } + + /** + * MD5加密 + * @param str + * @return + */ + public static String getMd5Str(String str) + { + return DigestUtils.md5Hex(str); + } + + /** + * 帆软shaEncode加密 + */ + + public static String shaEncode(String str){ + return CodeUtils.sha256Encode(str); + } + + /** + * 获取uuid + */ + public static String uuid(){ + return UUID.randomUUID().toString(); + } + + /** + * 替换空字符串 + * @param str + * @param replace + * @return + */ + public static String replaceNullStr(String str,String replace){ + if(isNullStr(str)){ + return replace; + } + + return str; + } + + /** + * 获取请求体 + * @param req + * @return + */ + public static JSONObject getRequestBody(HttpServletRequest req){ + StringBuffer sb = new StringBuffer(); + String line = null; + try { + BufferedReader reader = req.getReader(); + while ((line = reader.readLine()) != null) + sb.append(line); + } catch (Exception e) { + FRUtils.FRLogInfo("getRequestBody:exception:"+e.getMessage()); + } + //将空格和换行符替换掉避免使用反序列化工具解析对象时失败 + String jsonString = sb.toString().replaceAll("\\s","").replaceAll("\n",""); + + JSONObject json = new JSONObject(jsonString); + + return json; + } + + /** + * 获取ip + * @return + */ + public static String getIp(HttpServletRequest req){ + String realIp = req.getHeader("X-Real-IP"); + String fw = req.getHeader("X-Forwarded-For"); + if (StringUtils.isNotEmpty(fw) && !"unKnown".equalsIgnoreCase(fw)) { + int var3 = fw.indexOf(","); + return var3 != -1 ? fw.substring(0, var3) : fw; + } else { + fw = realIp; + if (StringUtils.isNotEmpty(realIp) && !"unKnown".equalsIgnoreCase(realIp)) { + return realIp; + } else { + if (StringUtils.isBlank(realIp) || "unknown".equalsIgnoreCase(realIp)) { + fw = req.getHeader("Proxy-Client-IP"); + } + + if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { + fw = req.getHeader("WL-Proxy-Client-IP"); + } + + if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { + fw = req.getHeader("HTTP_CLIENT_IP"); + } + + if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { + fw = req.getHeader("HTTP_X_FORWARDED_FOR"); + } + + if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { + fw = req.getRemoteAddr(); + } + + return fw; + } + } + } + + /** + * 根据key获取cookie + * @param req + * @return + */ + public static String getCookieByKey(HttpServletRequest req,String key){ + Cookie[] cookies = req.getCookies(); + String cookie = ""; + + if(cookies == null || cookies.length <=0){ + return ""; + } + + for(int i = 0; i < cookies.length; i++) { + Cookie item = cookies[i]; + if (item.getName().equalsIgnoreCase(key)) { + cookie = item.getValue(); + } + } + + FRUtils.FRLogInfo("cookie:"+cookie); + + return cookie; + } + + /** + * 判断是否是手机端的链接 + * @param req + * @return + */ + public static boolean isMobile(HttpServletRequest req) { + String[] mobileArray = {"iPhone", "iPad", "android", "windows phone", "xiaomi"}; + String userAgent = req.getHeader("user-agent"); + if (userAgent != null && userAgent.toUpperCase().contains("MOBILE")) { + for(String mobile : mobileArray) { + if(userAgent.toUpperCase().contains(mobile.toUpperCase())) { + return true; + } + } + } + return NetworkHelper.getDevice(req).isMobile(); + } + + /** + * 只编码中文 + * @param url + * @return + */ + public static String encodeCH(String url ){ + Matcher matcher = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(url); + + while(matcher.find()){ + String chn = matcher.group(); + url = url.replaceAll(chn, URLEncoder.encode(chn)); + } + + return url; + } + + /** + * 获取web-inf文件夹下的文件 + * filename /resources/ip4enc.properties + */ + public static InputStream getResourcesFile(String filename){ + return ResourceIOUtils.read(filename); + } + + public static void toErrorPage(HttpServletResponse res,String path,Map parameterMap){ + if(parameterMap == null){ + parameterMap = new HashMap(); + } + + try { + String macPage = TemplateUtils.renderTemplate(path, parameterMap); + WebUtils.printAsString(res, macPage); + }catch (Exception e){ + FRUtils.FRLogError("跳转页面异常"); + } + + } +} diff --git a/src/main/java/com/eco/plugin/xxxx/webservicets/utils/WebServiceUtil.java b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/WebServiceUtil.java new file mode 100644 index 0000000..2a19210 --- /dev/null +++ b/src/main/java/com/eco/plugin/xxxx/webservicets/utils/WebServiceUtil.java @@ -0,0 +1,206 @@ +package com.eco.plugin.xxxx.webservicets.utils; + +import com.eco.plugin.xxxx.webservicets.config.WinkSimpleConfig; +import org.apache.axis.client.Call; +import org.apache.axis.client.Service; +import org.w3c.dom.NodeList; +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import javax.xml.rpc.encoding.XMLType; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + + +public class WebServiceUtil { + + /** + * 根据用户名获取用户Id + * + * @param userName + * @return + */ + public static String getUserId(String userName) { + WinkSimpleConfig psc =WinkSimpleConfig.getInstance(); + + String userKey = psc.getUserKey(); + String userNamespace = psc.getUserNamespace(); + String userMethod = psc.getUserMethod(); + String userWsdlUrl = psc.getUserWsdlUrl(); + + String userId = ""; + + Service service = new Service(); + Call call; + try { + Object[] object = new Object[2]; + + object[0] = userName; + object[1] = userKey; + call = (Call) service.createCall(); + QName opAddEntry = new QName(userNamespace, userMethod); //设置命名空间和需要调用的方法名 + call.setTargetEndpointAddress(userWsdlUrl); //设置请求路径 + call.setOperationName(userMethod); //调用的方法名 + call.setTimeout(Integer.valueOf(2000)); //设置请求超时 + call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 + call.addParameter("Uid", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("key", XMLType.XSD_STRING, ParameterMode.IN); + + userId = (String) call.invoke(opAddEntry, object); + + if("-1".equals(userId)){ + userId=""; + } + } catch (Exception e) { + FRUtils.FRLogError("getUserId exception->"+e.getMessage()); + } + + return userId; + } + + //验证token + public static boolean validate(String token, String userId) { + WinkSimpleConfig psc =WinkSimpleConfig.getInstance(); + + boolean flag = false; + String loginWsdlUrl=psc.getLoginWsdlUrl(); + String loginNamespace=psc.getLoginNamespace(); + String loginMethod=psc.getLoginMethod(); + + Service service = new Service(); + Call call; + try { + Object[] object = new Object[2]; + + object[0] = token; + object[1] = userId; + call = (Call) service.createCall(); + QName opAddEntry = new QName(loginNamespace, loginMethod); //设置命名空间和需要调用的方法名 + call.setTargetEndpointAddress(loginWsdlUrl); //设置请求路径 + call.setOperationName(loginMethod); //调用的方法名 + call.setTimeout(Integer.valueOf(2000)); //设置请求超时 + call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 + call.addParameter("Token", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("User", XMLType.XSD_STRING, ParameterMode.IN); + + String result = (String) call.invoke(opAddEntry, object); + + NodeList nodeList = XMLUtils.xmlTONodeList(result); + String returnCode = XMLUtils.getValueByNodeName(nodeList,"returnCode"); + + if("0".equals(returnCode)){ + flag=true; + } + } catch (Exception e) { + FRUtils.FRLogError("validate exception ->"+e.getMessage()); + } + + return flag; + } + + /** + * 流程操作 + * + * @param operater 1、发起填报待办 2、完成填报待办 3、发起审核待办 4、完结审核待办 + * @param flowid 流程id + * @param pcUrl 审核url + * @param workFLowName 流程名称 + * @param nodeName 节点名称 + * @param receiver 流程接收人 + * @return + */ + public static void flowOperater(String operater,String flowid,String pcUrl,String workFLowName,String nodeName,String receiver) { + WinkSimpleConfig psc =WinkSimpleConfig.getInstance(); + + String OANamespace =psc.getOANamespace(); + String OAMethod = psc.getOAMethod(); + String OAWsdlUrl = psc.getOAWsdlUrl(); + + String receivedatetime = DateUtilSelf.DateToString(new Date(),"yyyy-MM-dd HH:mm:ss"); + + Service service = new Service(); + Call call; + String result = ""; + + try { + Object[] object = new Object[1]; + object[0] = "{\n" + + "\t\"syscode\":\"BI\",\n" + + "\t\"flowid\":\""+ flowid +"\",\n" + + "\t\"requestname\":\"" + workFLowName + "\",\n" + + "\t\"workflowname\":\"" + workFLowName + "\",\n" + + "\t\"nodename\":\"" + nodeName + "\",\n" + + "\t\"pcurl\":\""+ pcUrl +"\",\n" + + "\t\"appurl\":\"\",\n" + + "\t\"creator\":\"admin\",\n" + + "\t\"createdatetime\":\"" + receivedatetime + "\",\n" + + "\t\"receiver\":\""+ receiver +"\",\n" + + "\t\"receivedatetime\":\""+ receivedatetime +"\",\n" + + "\t\"isremark\":\""+ operater +"\",\n" + + "\t\"viewtype\":\"0\",\n" + + "\t\"receivets\":\"\"\n" + + "}";//Object是用来存储方法的参数 + //{"errCode":0,"data":"{\"message\":\"流程数据【测试流程001】自动更新办结成功\",\"dataType\":\"WfData\",\"operResult\":\"1\",\"syscode\":\"BI\",\"operType\":\"AutoEdit\"}"} + + call = (Call) service.createCall(); + QName opAddEntry = new QName(OANamespace, OAMethod); //设置命名空间和需要调用的方法名 + call.setTargetEndpointAddress(OAWsdlUrl); //设置请求路径 + call.setOperationName(OAMethod); //调用的方法名 + call.setTimeout(Integer.valueOf(2000)); //设置请求超时 + call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型 + call.addParameter("dataMap", XMLType.SOAP_ARRAY, ParameterMode.IN); + + result = (String) call.invoke(opAddEntry, object); + FRUtils.FRLogInfo("flowOperater result ->"+result); + } catch (Exception e) { + FRUtils.FRLogError("flowOperater exception ->"+e.getMessage()); + } + } + + public static Map getConfig(String type){ + WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); + String tburl = psc.getTburl(); + String shurl = psc.getShurl(); + String tempname = psc.getTempname(); + + Map map = new HashMap(); + map.put("name",getValue(tempname,type)); + map.put("tburl",getValue(tburl,type)); + map.put("shurl",getValue(shurl,type)); + + return map; + } + + public static void main(String[] args) { + String tburl = "pttx,http://bi.ibtcloud.cn/decision/view/report?viewlet=Buletown_INFO%252F%25E5%25B9%25B3%25E5%258F%25B0%25E4%25BF%25A1%25E6%2581%25AF_%25E7%25A1%25AE%25E8%25AE%25A4.cpt&ref_t=design&op=write&ref_c=ecc6e216-cf3f-4421-bad5-b652cc8f781b"; + String type = "pttx"; + System.out.println(getValue(tburl,type)); + + } + + + /** + * 根据key获取值 + * @param url + * @param type + * @return + */ + private static String getValue(String url,String type){ + String result = ""; + String[] keyvalue = url.split(";"); + + for(int i=0;i 0) ? (r.push(t), BI.each(i, function (e, t) { + var i = t.actionName; + r.push(i), + o[i] = t + }), s = BI.concat(s, BI.difference(l[t].actions, r))) : (r.push(t), o[t] = i), a.push(l[t].runType)) + }); + var t = BI.filter(i, function (e, t) { + return c.store.isDefaultByRunType(t, a) || c.store.isDefaultValueItem(t, r, s) + }); + return { + scheduleOutput: BI.extend({}, this.model.currTask.scheduleOutput, { + outputActionList: BI.map(o, function (e, t) { + return delete t.runType, + BI.extend({ + resultURL: window.location.protocol + "//" + window.location.host + Dec.fineServletURL + }, t) + }).concat(t) + }) + } + }, + _cardCreator: function (i) { + var t = this, + e = BI.find(this.model.handlingItems, function (e, t) { + return t.value === i + }); + return e && BI.isKey(e.cardType) ? { + type: e.cardType, + value: this.store.findActionValue(e, BI.deepClone(this.model.outputActionList)), + ref: function (e) { + t[i + "Pane"] = e + } + } + : { + type: "bi.label", + text: i + } + }, + _createLeftItems: function (e) { + var n = this; + return BI.map(e, function (e, t) { + var i = n.model.handlingItems[t].text; + return { + type: "dec.schedule.task.file.handling.item", + text: i, + value: t, + listeners: [{ + eventName: "EVENT_DELETE", + action: function () { + n.store.deleteAction(t, i) + } + } + ] + } + }) + } +}); + +BI.shortcut("dec.schedule.task.handling", e) \ No newline at end of file