Browse Source

open

master
pioneer 2 years ago
commit
c1d4edf13d
  1. 7
      README.md
  2. BIN
      lib/finekit-10.0.jar
  3. 37
      plugin.xml
  4. 34
      src/main/java/com/fr/plugin/cdia/JSCSSBridge.java
  5. 32
      src/main/java/com/fr/plugin/cdia/JSCSSMainBridge.java
  6. 29
      src/main/java/com/fr/plugin/cdia/LocaleFinder.java
  7. 34
      src/main/java/com/fr/plugin/cdia/PluginMonitor.java
  8. 55
      src/main/java/com/fr/plugin/cdia/ProcessDBAccess.java
  9. 37
      src/main/java/com/fr/plugin/cdia/ProcessHttpHandlerProvider.java
  10. 36
      src/main/java/com/fr/plugin/cdia/ProcessURLAliasProvider.java
  11. 39
      src/main/java/com/fr/plugin/cdia/bean/ProcessAssignBean.java
  12. 75
      src/main/java/com/fr/plugin/cdia/config/CdiaConfig.java
  13. 52
      src/main/java/com/fr/plugin/cdia/dao/ProcessAssignDao.java
  14. 613
      src/main/java/com/fr/plugin/cdia/entity/ProcessAssignEntity.java
  15. 310
      src/main/java/com/fr/plugin/cdia/service/AssignServiceHandler.java
  16. 105
      src/main/java/com/fr/plugin/cdia/service/QueryServiceHandler.java
  17. 39
      src/main/java/com/fr/plugin/cdia/submit/SubmitUIBridge.java
  18. 264
      src/main/java/com/fr/plugin/cdia/submit/job/AddUserSubmitJob.java
  19. 235
      src/main/java/com/fr/plugin/cdia/submit/job/CustomSubmitJob.java
  20. 260
      src/main/java/com/fr/plugin/cdia/submit/job/CustomTotalSubmitJob.java
  21. 106
      src/main/java/com/fr/plugin/cdia/submit/ui/DataSubmitConfigPane.java
  22. 45
      src/main/java/com/fr/plugin/cdia/submit/ui/DataSubmitItems.java
  23. 35
      src/main/java/com/fr/plugin/cdia/web/WebResourceComponent.java
  24. 13
      src/main/resources/com/fr/plugin/cdia/locale/lang.properties
  25. 13
      src/main/resources/com/fr/plugin/cdia/locale/lang_zh_CN.properties
  26. 2
      src/main/resources/com/fr/plugin/cdia/web/cdia.js

7
README.md

@ -0,0 +1,7 @@
# open-JSD-9885
JSD-9885 用户申请流程场景开发\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。

BIN
lib/finekit-10.0.jar

Binary file not shown.

37
plugin.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>com.fr.plugin.cdia.v10</id>
<name><![CDATA[自定义提交数据和用户处理_EK]]></name>
<active>yes</active>
<version>2.3.5</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[自定义提交数据和用户处理]]></description>
<change-notes><![CDATA[
[2022-10-06]JSD-11336管会系统接口调整<br/>
[2022-04-06]JSD-9885插件初始化<br/>
[2022-04-06]支持多人申请、自定义提交支持添加多个用户角色、审批流程回调第三方接口<br/>
OA创建流程、审批意见查询接口国产化。<br/>
自定义提交数据和用户处理。<br/>
]]></change-notes>
<main-package>com.fr.plugin.cdia</main-package>
<prefer-packages>
<prefer-package>com.fanruan.api</prefer-package>
</prefer-packages>
<lifecycle-monitor class="com.fr.plugin.cdia.PluginMonitor"/>
<extra-core>
<LocaleFinder class="com.fr.plugin.cdia.LocaleFinder"/>
<DBAccessProvider class="com.fr.plugin.cdia.ProcessDBAccess"/>
</extra-core>
<extra-decision>
<WebResourceProvider class="com.fr.plugin.cdia.JSCSSBridge"/>
<WebResourceProvider class="com.fr.plugin.cdia.JSCSSMainBridge"/>
<HttpHandlerProvider class="com.fr.plugin.cdia.ProcessHttpHandlerProvider"/>
<URLAliasProvider class="com.fr.plugin.cdia.ProcessURLAliasProvider"/>
</extra-decision>
<extra-designer>
<SubmitProvider class="com.fr.plugin.cdia.submit.SubmitUIBridge"/>
</extra-designer>
<function-recorder class="com.fr.plugin.cdia.web.WebResourceComponent"/>
</plugin>

34
src/main/java/com/fr/plugin/cdia/JSCSSBridge.java

@ -0,0 +1,34 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: JSCSSBridge
* Author:
* Date: 2020/8/31 16:34
*/
package com.fr.plugin.cdia;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.UserComponent;
import com.fr.plugin.cdia.web.WebResourceComponent;
import com.fr.stable.fun.Authorize;
import com.fr.web.struct.Atom;
/**
* <Function Description><br>
* <平台组件定制JSCSSBridge>
*
* @author
* @since 1.0.0
*/
@Authorize(callSignKey = WebResourceComponent.PLUGIN_ID)
public class JSCSSBridge extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return UserComponent.KEY;
}
@Override
public Atom client() {
return WebResourceComponent.KEY;
}
}

32
src/main/java/com/fr/plugin/cdia/JSCSSMainBridge.java

@ -0,0 +1,32 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: JSCSSMainBridge
* Author:
* Date: 2020/9/24 13:36
*/
package com.fr.plugin.cdia;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.cdia.web.WebResourceComponent;
import com.fr.web.struct.Atom;
/**
* <Function Description><br>
* <平台组件定制>
*
* @author
* @since 1.0.0
*/
public class JSCSSMainBridge extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return WebResourceComponent.KEY;
}
}

29
src/main/java/com/fr/plugin/cdia/LocaleFinder.java

@ -0,0 +1,29 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: LocaleFinder
* Author:
* Date: 2020/8/31 22:19
*/
package com.fr.plugin.cdia;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
/**
* <Function Description><br>
* <LocaleFinder>
*
* @author
* @since 1.0.0
*/
public class LocaleFinder extends AbstractLocaleFinder {
@Override
public String find() {
return "com/fr/plugin/cdia/locale/lang";
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

34
src/main/java/com/fr/plugin/cdia/PluginMonitor.java

@ -0,0 +1,34 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: PluginMonitor
* Author:
* Date: 2021/3/30 15:10
*/
package com.fr.plugin.cdia;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.cdia.config.CdiaConfig;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
/**
* <Function Description><br>
* <PluginMonitor>
*
* @author
* @since 1.0.0
*/
public class PluginMonitor extends AbstractPluginLifecycleMonitor {
public PluginMonitor() {
}
@Override
public void afterRun(PluginContext pluginContext) {
CdiaConfig.getInstance();
}
@Override
public void beforeStop(PluginContext pluginContext) {
}
}

55
src/main/java/com/fr/plugin/cdia/ProcessDBAccess.java

@ -0,0 +1,55 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: RoleGroupDBAccess
* Author:
* Date: 2020/6/4 11:48
*/
package com.fr.plugin.cdia;
import com.fr.plugin.db.AbstractDBAccessProvider;
import com.fr.plugin.cdia.dao.ProcessAssignDao;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.stable.db.accessor.DBAccessor;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
/**
* Function Description<br>
* ProcessDBAccess
*
* @author
* @since 1.0.0
*/
public class ProcessDBAccess extends AbstractDBAccessProvider {
private static DBAccessor accessor;
public ProcessDBAccess() {
}
public static DBAccessor getAccessor() {
return accessor;
}
@Override
public DAOProvider[] registerDAO() {
return new DAOProvider[]{
new DAOProvider() {
@Override
public Class getEntityClass() {
return ProcessAssignEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return ProcessAssignDao.class;
}
}
};
}
@Override
public void onDBAvailable(DBAccessor dbAccessor) {
accessor = dbAccessor;
}
}

37
src/main/java/com/fr/plugin/cdia/ProcessHttpHandlerProvider.java

@ -0,0 +1,37 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: ProcessHttpHandlerProvider
* Author:
* Date: 2020/9/11 8:41
*/
package com.fr.plugin.cdia;
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.plugin.cdia.service.AssignServiceHandler;
import com.fr.plugin.cdia.service.QueryServiceHandler;
import com.fr.stable.fun.Authorize;
import static com.fr.plugin.cdia.web.WebResourceComponent.PLUGIN_ID;
/**
* <Function Description><br>
* <ProcessHttpHandlerProvider>
*
* @author
* @since 1.0.0
*/
@Authorize(callSignKey = PLUGIN_ID)
public class ProcessHttpHandlerProvider extends AbstractHttpHandlerProvider {
public ProcessHttpHandlerProvider() {
}
@Override
public BaseHttpHandler[] registerHandlers() {
return new BaseHttpHandler[]{
new AssignServiceHandler(),
new QueryServiceHandler()
};
}
}

36
src/main/java/com/fr/plugin/cdia/ProcessURLAliasProvider.java

@ -0,0 +1,36 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: ProcessURLAliasProvider
* Author:
* Date: 2020/9/11 8:47
*/
package com.fr.plugin.cdia;
import com.fr.decision.fun.impl.AbstractURLAliasProvider;
import com.fr.decision.webservice.url.alias.URLAlias;
import com.fr.decision.webservice.url.alias.URLAliasFactory;
import static com.fr.plugin.cdia.service.AssignServiceHandler.API_ASSIGN_PROCESS;
import static com.fr.plugin.cdia.service.QueryServiceHandler.API_QUERY_PROCESS;
/**
* <Function Description><br>
* <ProcessURLAliasProvider>
*
* @author
* @since 1.0.0
*/
public class ProcessURLAliasProvider extends AbstractURLAliasProvider {
public ProcessURLAliasProvider() {
}
@Override
public URLAlias[] registerAlias() {
return new URLAlias[]{
URLAliasFactory.createPluginAlias(API_ASSIGN_PROCESS, API_ASSIGN_PROCESS, true),
URLAliasFactory.createPluginAlias(API_QUERY_PROCESS, API_QUERY_PROCESS, true)
};
}
}

39
src/main/java/com/fr/plugin/cdia/bean/ProcessAssignBean.java

@ -0,0 +1,39 @@
/*
* Copyright (C), 2018-2022
* Project: starter
* FileName: ProcessAssignBean
* Author: xx
* Date: 2022/4/8 15:46
*/
package com.fr.plugin.cdia.bean;
import com.fr.json.JSONObject;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
/**
* <Function Description><br>
* <ProcessAssignBean>
*
* @author xx
* @since 1.0.0
*/
public class ProcessAssignBean {
private ProcessAssignEntity processAssignEntity;
private JSONObject paramsJSON;
public ProcessAssignEntity getProcessAssignEntity() {
return processAssignEntity;
}
public void setProcessAssignEntity(ProcessAssignEntity processAssignEntity) {
this.processAssignEntity = processAssignEntity;
}
public JSONObject getParamsJSON() {
return paramsJSON;
}
public void setParamsJSON(JSONObject paramsJSON) {
this.paramsJSON = paramsJSON;
}
}

75
src/main/java/com/fr/plugin/cdia/config/CdiaConfig.java

@ -0,0 +1,75 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: CdiaConfig
* Author:
* Date: 2021/3/30 9:38
*/
package com.fr.plugin.cdia.config;
import com.fr.config.*;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
/**
* <Function Description><br>
* <CdiaConfig>
*
* @author
* @since 1.0.0
*/
@Visualization(category = "Plugin-cdia_Group")
public class CdiaConfig extends DefaultConfiguration {
public static final String CREATE_PROCESS_DEFAULT = "http://xx:1000/api/v1/create/saveProcess";
public static final String PROC_FORM_OP_INDEX_DEFAULT = "http://xx:9000/workflowService/api/v1/baseForm/findProcFormOpIndexUrl";
public static final String PROC_NODE_DEFAULT = "http://xx:9000//odpsService/api/v1/formBase/findProcFormOpinion";
public static final String ASSIGN_NMA_AUTH_URL = "http://xx:8001/rms/ws/autoAssignRoleAndDataAuthAndMdReportAuthService";
private static volatile CdiaConfig config = null;
@Identifier(value = "createProcessUrl", name = "Plugin-cdia_Config_CreateProcessUrl", description = "Plugin-cdia_Config_CreateProcessUrl_Description", status = Status.SHOW)
private final Conf<String> createProcessUrl = Holders.simple(CREATE_PROCESS_DEFAULT);
@Identifier(value = "procFormOpIndexUrl", name = "Plugin-cdia_Config_ProcFormOpIndexUrl", description = "Plugin-cdia_Config_ProcFormOpIndexUrl_Description", status = Status.SHOW)
private final Conf<String> procFormOpIndexUrl = Holders.simple(PROC_FORM_OP_INDEX_DEFAULT);
@Identifier(value = "procNodeUrl", name = "Plugin-cdia_Config_ProcNodeUrl", description = "Plugin-cdia_Config_ProcNodeUrl_Description", status = Status.SHOW)
private final Conf<String> procNodeUrl = Holders.simple(PROC_NODE_DEFAULT);
@Identifier(value = "assignNmaAuthUrl", name = "Plugin-cdia_Config_AssignNmaAuthUrl", description = "Plugin-cdia_Config_AssignNmaAuthUrl_Description", status = Status.SHOW)
private final Conf<String> assignNmaAuthUrl = Holders.simple(ASSIGN_NMA_AUTH_URL);
public static CdiaConfig getInstance() {
if (config == null) {
config = ConfigContext.getConfigInstance(CdiaConfig.class);
}
return config;
}
public String getCreateProcessUrl() {
return createProcessUrl.get();
}
public void setCreateProcessUrl(String createProcessUrl) {
this.createProcessUrl.set(createProcessUrl);
}
public String getProcFormOpIndexUrl() {
return procFormOpIndexUrl.get();
}
public void setProcFormOpIndexUrl(String procFormOpIndexUrl) {
this.procFormOpIndexUrl.set(procFormOpIndexUrl);
}
public String getProcNodeUrl() {
return procNodeUrl.get();
}
public void setProcNodeUrl(String procNodeUrl) {
this.procNodeUrl.set(procNodeUrl);
}
public String getAssignNmaAuthUrl() {
return assignNmaAuthUrl.get();
}
public void setAssignNmaAuthUrl(String assignNmaAuthUrl) {
this.assignNmaAuthUrl.set(assignNmaAuthUrl);
}
}

52
src/main/java/com/fr/plugin/cdia/dao/ProcessAssignDao.java

@ -0,0 +1,52 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: ProcessAssignDao
* Author:
* Date: 2020/9/3 21:41
*/
package com.fr.plugin.cdia.dao;
import com.fr.plugin.cdia.ProcessDBAccess;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOContext;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.List;
/**
* <Function Description><br>
* <ProcessAssignDao>
*
* @author
* @since 1.0.0
*/
public class ProcessAssignDao extends BaseDAO<ProcessAssignEntity> {
public ProcessAssignDao(DAOSession daoSession) {
super(daoSession);
}
/**
* 通过流程单号查询流程Entity
*
* @param procInstId
* @return
* @throws Exception
*/
public static List<ProcessAssignEntity> findEntityByProc(final String procInstId) throws Exception {
return ProcessDBAccess.getAccessor().runQueryAction(new DBAction<List<ProcessAssignEntity>>() {
@Override
public List<ProcessAssignEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(ProcessAssignDao.class).find(QueryFactory.create().addRestriction(RestrictionFactory.eq("procInstId", procInstId)));
}
});
}
protected Class<ProcessAssignEntity> getEntityClass() {
return ProcessAssignEntity.class;
}
}

613
src/main/java/com/fr/plugin/cdia/entity/ProcessAssignEntity.java

@ -0,0 +1,613 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: ProcessAssignEntity
* Author:
* Date: 2020/9/3 21:43
*/
package com.fr.plugin.cdia.entity;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
/**
* <Function Description><br>
* <流程申请及审核意见ProcessAssignEntity>
*
* @author
* @since 1.0.0
*/
@Entity
@Table(name = "cmbc_process_assign")
public class ProcessAssignEntity extends BaseEntity {
public static final String DRAF_ID = "DRAF_ID";
public static final String DRAF_NAME = "DRAF_NAME";
public static final String DRAF_DEPT_ID = "DRAF_DEPT_ID";
public static final String DRAF_DEPT_NAME = "DRAF_DEPT_NAME";
public static final String DRAF_DATE = "DRAF_DATE";
public static final String DRAF_TEL = "DRAF_TEL";
public static final String DOC_TITLE = "DOC_TITLE";
public static final String APP_ID = "APP_ID";
public static final String APP_NUMBER = "APP_NUMBER";
public static final String APP_NAME = "APP_NAME";
public static final String APP_OPER_NAME = "APP_OPER_NAME";
public static final String APP_OPER_ID = "APP_OPER_ID";
public static final String APP_DEPT_NAME = "APP_DEPT_NAME";
public static final String APP_TEL = "APP_TEL";
public static final String APP_MAIL = "APP_MAIL";
public static final String APP_TYPE = "APP_TYPE";
public static final String BT_ROLE_NAME = "BT_ROLE_NAME";
public static final String PURPOSE = "PURPOSE";
public static final String YT_ROLE_NAME = "YT_ROLE_NAME";
public static final String TC_ROLE_NAME = "TC_ROLE_NAME";
public static final String PROC_INST_ID = "PROCINSTID";
public static final String SEQUENCE_NO = "SEQUENCE_NO";
public static final String LOAD_TIME = "LOAD_TIME";
public static final String OP_FLAG = "OP_FLAG";
public static final String PROC_END_FLAG = "PROC_END_FLAG";
public static final String PROC_DELETE_FLAG = "PROC_DELETE_FLAG";
public static final String YT_OP = "YT_OP";
public static final String TC_OP = "TC_OP";
public static final String OP_INDEX_URL = "OP_INDEX_URL";
private static final long serialVersionUID = -3562843353984449028L;
// 拟稿人用户ID
@Column(name = "DRAF_ID")
private String drafId = StringUtils.EMPTY;
// 拟稿人姓名
@Column(name = "DRAF_NAME")
private String drafName = StringUtils.EMPTY;
// 拟稿人部门ID
@Column(name = "DRAF_DEPT_ID")
private String drafDeptId = StringUtils.EMPTY;
// 拟稿人部门名称
@Column(name = "DRAF_DEPT_NAME")
private String drafDeptName = StringUtils.EMPTY;
// 拟稿日期
@Column(name = "DRAF_DATE")
private String drafDate = StringUtils.EMPTY;
// 拟稿人电话
@Column(name = "DRAF_TEL")
private String drafTel = StringUtils.EMPTY;
// 表单标题
@Column(name = "DOC_TITLE")
private String docTitle = StringUtils.EMPTY;
// 申请人用户ID
@Column(name = "APP_ID")
private String appId = StringUtils.EMPTY;
// 申请人员工号
@Column(name = "APP_NUMBER")
private String appNumber = StringUtils.EMPTY;
// 申请人姓名
@Column(name = "APP_NAME")
private String appName = StringUtils.EMPTY;
// 申请人所在机构
@Column(name = "APP_OPER_NAME")
private String appOperName = StringUtils.EMPTY;
// 申请人所在机构ID
@Column(name = "APP_OPER_ID")
private String appOperId = StringUtils.EMPTY;
// 申请人部门名称
@Column(name = "APP_DEPT_NAME")
private String appDeptName = StringUtils.EMPTY;
// 申请人电话
@Column(name = "APP_TEL")
private String appTel = StringUtils.EMPTY;
// 申请人邮箱
@Column(name = "APP_MAIL")
private String appMail = StringUtils.EMPTY;
// 申请类型
@Column(name = "APP_TYPE")
private String appType = StringUtils.EMPTY;
// 部门类别(价值云图数据权限(角色名称))
@Column(name = "BT_ROLE_NAME")
private String btRoleName = StringUtils.EMPTY;
// 用途
@Column(name = "PURPOSE")
private String purpose = StringUtils.EMPTY;
// 价值云图数据权限(角色名称)
@Column(name = "YT_ROLE_NAME")
private String ytRoleName = StringUtils.EMPTY;
// 头寸权限(角色名称)
@Column(name = "TC_ROLE_NAME")
private String tcRoleName = StringUtils.EMPTY;
// OA流程编号
@Column(name = "PROCINSTID")
private String procInstId = StringUtils.EMPTY;
// 流水号
@Column(name = "SEQUENCE_NO")
private String sequenceNo = StringUtils.EMPTY;
// timestamp
@Column(name = "LOAD_TIME")
private String loadTime = StringUtils.EMPTY;
// 管理员处理标识
@Column(name = "OP_FLAG")
private int opFlag;
// OA流程结果标志
@Column(name = "PROC_END_FLAG")
private int procEndFlag;
// OA流程删除标志
@Column(name = "PROC_DELETE_FLAG")
private int procDeleteFlag;
// 价值云图审批意见
@Column(name = "YT_OP")
private String ytOp = StringUtils.EMPTY;
// 头寸审批意见
@Column(name = "TC_OP")
private String tcOp = StringUtils.EMPTY;
// 流程url
@Column(name = OP_INDEX_URL)
private String opIndexUrl = StringUtils.EMPTY;
public ProcessAssignEntity() {
}
public void setEntity(String key, String value) {
if (ComparatorUtils.equals(key, DRAF_ID)) {
this.setDrafId(value);
} else if (ComparatorUtils.equals(key, DRAF_NAME)) {
this.setDrafName(value);
} else if (ComparatorUtils.equals(key, DRAF_DEPT_ID)) {
this.setDrafDeptId(value);
} else if (ComparatorUtils.equals(key, DRAF_DEPT_NAME)) {
this.setDrafDeptName(value);
} else if (ComparatorUtils.equals(key, DRAF_DATE)) {
this.setDrafDate(value);
} else if (ComparatorUtils.equals(key, DRAF_TEL)) {
this.setDrafTel(value);
} else if (ComparatorUtils.equals(key, DOC_TITLE)) {
this.setDocTitle(value);
} else if (ComparatorUtils.equals(key, APP_ID)) {
this.setAppId(value);
} else if (ComparatorUtils.equals(key, APP_NUMBER)) {
this.setAppNumber(value);
} else if (ComparatorUtils.equals(key, APP_NAME)) {
this.setAppName(value);
} else if (ComparatorUtils.equals(key, APP_OPER_NAME)) {
this.setAppOperName(value);
} else if (ComparatorUtils.equals(key, APP_OPER_ID)) {
this.setAppOperId(value);
} else if (ComparatorUtils.equals(key, APP_DEPT_NAME)) {
this.setAppDeptName(value);
} else if (ComparatorUtils.equals(key, APP_TEL)) {
this.setAppTel(value);
} else if (ComparatorUtils.equals(key, APP_MAIL)) {
this.setAppMail(value);
} else if (ComparatorUtils.equals(key, APP_TYPE)) {
this.setAppType(value);
} else if (ComparatorUtils.equals(key, BT_ROLE_NAME)) {
this.setBtRoleName(value);
} else if (ComparatorUtils.equals(key, PURPOSE)) {
this.setPurpose(value);
} else if (ComparatorUtils.equals(key, YT_ROLE_NAME)) {
this.setYtRoleName(value);
} else if (ComparatorUtils.equals(key, TC_ROLE_NAME)) {
this.setTcRoleName(value);
} else if (ComparatorUtils.equals(key, PROC_INST_ID)) {
this.setId(value);
this.setProcInstId(value);
} else if (ComparatorUtils.equals(key, SEQUENCE_NO)) {
this.setSequenceNo(value);
}
}
public JSONObject toJSON() {
JSONObject json = JSONObject.create();
json.put(DRAF_ID, this.getDrafId());
json.put(DRAF_NAME, this.getDrafName());
json.put(DRAF_DEPT_ID, this.getDrafDeptId());
json.put(DRAF_DEPT_NAME, this.getDrafDeptName());
json.put(DRAF_DATE, this.getDrafDate());
json.put(DRAF_TEL, this.getDrafTel());
json.put(DOC_TITLE, this.getDocTitle());
json.put(PROC_INST_ID, this.getProcInstId());
json.put(SEQUENCE_NO, this.getSequenceNo());
return json;
}
public JSONObject detail2JSON() {
JSONObject json = JSONObject.create();
json.put(APP_ID, this.getAppId());
json.put(APP_NUMBER, this.getAppNumber());
json.put(APP_NAME, this.getAppName());
json.put(APP_OPER_NAME, this.getAppOperName());
json.put(APP_OPER_ID, this.getAppOperId());
json.put(APP_DEPT_NAME, this.getAppDeptName());
json.put(APP_TEL, this.getAppTel());
json.put(APP_MAIL, this.getAppMail());
json.put(APP_TYPE, this.getAppType());
json.put(BT_ROLE_NAME, this.getBtRoleName());
json.put(PURPOSE, this.getPurpose());
json.put(YT_ROLE_NAME, this.getYtRoleName());
json.put(TC_ROLE_NAME, this.getTcRoleName());
return json;
}
public ProcessAssignEntity id(String id) {
this.setId(id);
return this;
}
public String getDrafId() {
return drafId;
}
public void setDrafId(String drafId) {
this.drafId = drafId;
}
public ProcessAssignEntity drafId(String drafId) {
this.setDrafId(drafId);
return this;
}
public String getDrafName() {
return drafName;
}
public void setDrafName(String drafName) {
this.drafName = drafName;
}
public ProcessAssignEntity drafName(String drafName) {
this.setDrafName(drafName);
return this;
}
public String getDrafDeptId() {
return drafDeptId;
}
public void setDrafDeptId(String drafDeptId) {
this.drafDeptId = drafDeptId;
}
public ProcessAssignEntity drafDeptId(String drafDeptId) {
this.setDrafDeptId(drafDeptId);
return this;
}
public String getDrafDeptName() {
return drafDeptName;
}
public void setDrafDeptName(String drafDeptName) {
this.drafDeptName = drafDeptName;
}
public ProcessAssignEntity drafDeptName(String drafDeptName) {
this.setDrafDeptName(drafDeptName);
return this;
}
public String getDrafDate() {
return drafDate;
}
public void setDrafDate(String drafDate) {
this.drafDate = drafDate;
}
public ProcessAssignEntity drafDate(String drafDate) {
this.setDrafDate(drafDate);
return this;
}
public String getDrafTel() {
return drafTel;
}
public void setDrafTel(String drafTel) {
this.drafTel = drafTel;
}
public ProcessAssignEntity drafTel(String drafTel) {
this.setDrafTel(drafTel);
return this;
}
public String getDocTitle() {
return docTitle;
}
public void setDocTitle(String docTitle) {
this.docTitle = docTitle;
}
public ProcessAssignEntity docTitle(String docTitle) {
this.setDocTitle(docTitle);
return this;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public ProcessAssignEntity appId(String appId) {
this.setAppId(appId);
return this;
}
public String getAppNumber() {
return appNumber;
}
public void setAppNumber(String appNumber) {
this.appNumber = appNumber;
}
public ProcessAssignEntity appNumber(String appNumber) {
this.setAppNumber(appNumber);
return this;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public ProcessAssignEntity appName(String appName) {
this.setAppName(appName);
return this;
}
public String getAppOperName() {
return appOperName;
}
public void setAppOperName(String appOperName) {
this.appOperName = appOperName;
}
public ProcessAssignEntity appOperName(String appOperName) {
this.setAppOperName(appOperName);
return this;
}
public String getAppOperId() {
return appOperId;
}
public void setAppOperId(String appOperId) {
this.appOperId = appOperId;
}
public ProcessAssignEntity appOperId(String appOperId) {
this.setAppOperId(appOperId);
return this;
}
public String getAppDeptName() {
return appDeptName;
}
public void setAppDeptName(String appDeptName) {
this.appDeptName = appDeptName;
}
public ProcessAssignEntity appDeptName(String appDeptName) {
this.setAppDeptName(appDeptName);
return this;
}
public String getAppTel() {
return appTel;
}
public void setAppTel(String appTel) {
this.appTel = appTel;
}
public ProcessAssignEntity appTel(String appTel) {
this.setAppTel(appTel);
return this;
}
public String getAppMail() {
return appMail;
}
public void setAppMail(String appMail) {
this.appMail = appMail;
}
public ProcessAssignEntity appMail(String appMail) {
this.setAppMail(appMail);
return this;
}
public String getAppType() {
return appType;
}
public void setAppType(String appType) {
this.appType = appType;
}
public ProcessAssignEntity appType(String appType) {
this.setAppType(appType);
return this;
}
public String getBtRoleName() {
return btRoleName;
}
public void setBtRoleName(String btRoleName) {
this.btRoleName = btRoleName;
}
public ProcessAssignEntity btRoleName(String btRoleName) {
this.setBtRoleName(btRoleName);
return this;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public ProcessAssignEntity purpose(String purpose) {
this.setPurpose(purpose);
return this;
}
public String getYtRoleName() {
return ytRoleName;
}
public void setYtRoleName(String ytRoleName) {
this.ytRoleName = ytRoleName;
}
public ProcessAssignEntity ytRoleName(String ytRoleName) {
this.setYtRoleName(ytRoleName);
return this;
}
public String getTcRoleName() {
return tcRoleName;
}
public void setTcRoleName(String tcRoleName) {
this.tcRoleName = tcRoleName;
}
public ProcessAssignEntity tcRoleName(String tcRoleName) {
this.setTcRoleName(tcRoleName);
return this;
}
public String getProcInstId() {
return procInstId;
}
public void setProcInstId(String procInstId) {
this.procInstId = procInstId;
}
public ProcessAssignEntity procInstId(String procInstId) {
this.setProcInstId(procInstId);
return this;
}
public String getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(String sequenceNo) {
this.sequenceNo = sequenceNo;
}
public ProcessAssignEntity sequenceNo(String sequenceNo) {
this.setSequenceNo(sequenceNo);
return this;
}
public String getLoadTime() {
return loadTime;
}
public void setLoadTime(String loadTime) {
this.loadTime = loadTime;
}
public ProcessAssignEntity loadTime(String loadTime) {
this.setLoadTime(loadTime);
return this;
}
public int getOpFlag() {
return opFlag;
}
public void setOpFlag(int opFlag) {
this.opFlag = opFlag;
}
public ProcessAssignEntity opFlag(int opFlag) {
this.setOpFlag(opFlag);
return this;
}
public int getProcEndFlag() {
return procEndFlag;
}
public void setProcEndFlag(int procEndFlag) {
this.procEndFlag = procEndFlag;
}
public ProcessAssignEntity procEndFlag(int procEndFlag) {
this.setProcEndFlag(procEndFlag);
return this;
}
public int getProcDeleteFlag() {
return procDeleteFlag;
}
public void setProcDeleteFlag(int procDeleteFlag) {
this.procDeleteFlag = procDeleteFlag;
}
public ProcessAssignEntity procDeleteFlag(int procDeleteFlag) {
this.setProcDeleteFlag(procDeleteFlag);
return this;
}
public String getYtOp() {
return ytOp;
}
public void setYtOp(String ytOp) {
this.ytOp = ytOp;
}
public ProcessAssignEntity ytOp(String ytOp) {
this.setYtOp(ytOp);
return this;
}
public String getTcOp() {
return tcOp;
}
public void setTcOp(String tcOp) {
this.tcOp = tcOp;
}
public ProcessAssignEntity tcOp(String tcOp) {
this.setTcOp(tcOp);
return this;
}
public String getOpIndexUrl() {
return opIndexUrl;
}
public void setOpIndexUrl(String opIndexUrl) {
this.opIndexUrl = opIndexUrl;
}
public ProcessAssignEntity opIndexUrl(String opIndexUrl) {
this.setOpIndexUrl(opIndexUrl);
return this;
}
}

310
src/main/java/com/fr/plugin/cdia/service/AssignServiceHandler.java

@ -0,0 +1,310 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: AssignServiceHandler
* Author:
* Date: 2020/9/11 8:43
*/
package com.fr.plugin.cdia.service;
import com.fanruan.api.decision.user.UserKit;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.net.http.HttpKit;
import com.fanruan.api.util.StringKit;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.data.CustomRole;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.decision.webservice.bean.user.UserBean;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.plugin.cdia.ProcessDBAccess;
import com.fr.plugin.cdia.config.CdiaConfig;
import com.fr.plugin.cdia.dao.ProcessAssignDao;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.plugin.cdia.submit.job.AddUserSubmitJob;
import com.fr.plugin.cdia.submit.job.CustomSubmitJob;
import com.fr.plugin.context.PluginContexts;
import com.fr.stable.StringUtils;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.third.org.apache.http.entity.StringEntity;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <Function Description><br>
* <AssignServiceHandler>
*
* @author
* @since 1.0.0
*/
public class AssignServiceHandler extends BaseHttpHandler {
public static final String API_ASSIGN_PROCESS = "/cdia/assignProcess";
public static final String TC_OP_YES = "同意";
public static final String AUTH_GROUP = "performer";
public static final String USER_WAIT_TO_ASSIGN_NMA_AUTH_LST_HEADER = "<userWaitToAssignNmaAuthLst><userWaitToAssignNmaAuthMap>";
public static final String USER_WAIT_TO_ASSIGN_NMA_AUTH_LST_FOOTER = "</userWaitToAssignNmaAuthMap></userWaitToAssignNmaAuthLst>";
public static final String SOAP_REQUEST_HEADER = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:aut=\"http://services.tesla.com/autoAssignRoleAndDataAuthAndMdReportAuthService\"><soapenv:Header/><soapenv:Body><aut:autoAssignRoleAndDataAuthAndMdReportAuthServiceRequest>";
public static final String SOAP_SERVICE_FOOTER = "</aut:autoAssignRoleAndDataAuthAndMdReportAuthServiceRequest></soapenv:Body></soapenv:Envelope>";
public static final String YT_OP_YES = "[同意]";
public AssignServiceHandler() {
}
@Override
public RequestMethod getMethod() {
return RequestMethod.POST;
}
@Override
public String getPath() {
return API_ASSIGN_PROCESS;
}
@Override
public boolean isPublic() {
return true;
}
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) {
LogKit.error(I18nKit.getLocText("Plugin-cdia_Licence_Expired"));
WebUtils.flushSuccessMessageAutoClose(request, response, createFailResponseJSONObject());
return;
}
try {
JSONObject paramsJSON = getPostParams(request);
String procInstId = paramsJSON.getString("procInstId", StringUtils.EMPTY);
String msgType = paramsJSON.getString("msgType", StringUtils.EMPTY);
String procEndFlag = "0";
String procDeleteFlag = "0";
if (ComparatorUtils.equals(msgType, "delete") || ComparatorUtils.equals(msgType, "break")) {
procDeleteFlag = "1";
} else if (ComparatorUtils.equals(msgType, "commit")) {
procEndFlag = "1";
}
List<ProcessAssignEntity> processAssignEntityList = ProcessAssignDao.findEntityByProc(procInstId);
StringBuilder userWaitToAssignNmaAuthLst = new StringBuilder();
for (ProcessAssignEntity processAssignEntity : processAssignEntityList) {
processAssignEntity.setProcEndFlag(Integer.parseInt(procEndFlag));
processAssignEntity.setProcDeleteFlag(Integer.parseInt(procDeleteFlag));
setProcNodeOpinion(processAssignEntity);
updateEntity(processAssignEntity);
LogKit.info("cdia-AssignServiceHandler-handle-头寸审批意见:{}", processAssignEntity.getTcOp());
if (ComparatorUtils.equals(processAssignEntity.getTcOp(), TC_OP_YES)) {
LogKit.info("cdia-AssignServiceHandler-handle-申请人用户ID:{}", processAssignEntity.getAppId());
LogKit.info("cdia-AssignServiceHandler-handle-头寸权限:{}", processAssignEntity.getTcRoleName());
if (!setUserRole(processAssignEntity.getAppId(), processAssignEntity.getTcRoleName())) {
LogKit.info("cdia-AssignServiceHandler-handle-更新头寸权限失败!");
}
}
LogKit.info("cdia-AssignServiceHandler-handle-YT_OP审批意见:{}", processAssignEntity.getYtOp());
if (processAssignEntity.getYtOp().startsWith(YT_OP_YES)) {
// 产生管会接口数据
assignNmaAuthLst(userWaitToAssignNmaAuthLst, processAssignEntity);
}
}
if (StringKit.isNotBlank(userWaitToAssignNmaAuthLst.toString())) {
sendAssignNmaAuthLst(userWaitToAssignNmaAuthLst);
}
WebUtils.flushSuccessMessageAutoClose(request, response, createSuccessResponseJSONObject());
} catch (Exception e) {
WebUtils.flushSuccessMessageAutoClose(request, response, createFailResponseJSONObject());
LogKit.error(e.getMessage(), e);
}
}
/**
* 发送管会接口
*
* @param userWaitToAssignNmaAuthLst
* @throws IOException
*/
private void sendAssignNmaAuthLst(StringBuilder userWaitToAssignNmaAuthLst) throws IOException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "text/xml;charset=UTF-8");
headers.put("SOAPAction", "autoAssignRoleAndDataAuthAndMdReportAuthService");
String soapXml = SOAP_REQUEST_HEADER +
userWaitToAssignNmaAuthLst.toString() +
SOAP_SERVICE_FOOTER;
LogKit.info("cdia-AssignServiceHandler-sendAssignNmaAuthLst-soapXml:{}, headers:{}", soapXml, headers);
StringEntity stringEntity = new StringEntity(soapXml, "UTF-8");
String response = HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom().url(CdiaConfig.getInstance().getAssignNmaAuthUrl()).post(stringEntity).headers(headers).build());
LogKit.info("cdia-AssignServiceHandler-sendAssignNmaAuthLst-response:{}", response);
}
/**
* 产生管会接口数据
*
* @param userWaitToAssignNmaAuthLst
* @param processAssignEntity
*/
private void assignNmaAuthLst(StringBuilder userWaitToAssignNmaAuthLst, ProcessAssignEntity processAssignEntity) {
userWaitToAssignNmaAuthLst.append(USER_WAIT_TO_ASSIGN_NMA_AUTH_LST_HEADER);
userWaitToAssignNmaAuthLst.append("<empNo>").append(processAssignEntity.getAppNumber()).append("</empNo>");
userWaitToAssignNmaAuthLst.append("<userNm>").append(processAssignEntity.getAppName()).append("</userNm>");
userWaitToAssignNmaAuthLst.append("<oaUserNm>").append(processAssignEntity.getAppId()).append("</oaUserNm>");
userWaitToAssignNmaAuthLst.append("<instNm>").append(processAssignEntity.getAppOperName()).append("</instNm>");
userWaitToAssignNmaAuthLst.append("<deptNm>").append(processAssignEntity.getAppDeptName()).append("</deptNm>");
userWaitToAssignNmaAuthLst.append("<mobile>").append(processAssignEntity.getAppTel()).append("</mobile>");
userWaitToAssignNmaAuthLst.append("<email>").append(processAssignEntity.getAppMail()).append("</email>");
userWaitToAssignNmaAuthLst.append("<userType>").append(processAssignEntity.getAppType()).append("</userType>");
userWaitToAssignNmaAuthLst.append("<purpose>").append(processAssignEntity.getPurpose()).append("</purpose>");
userWaitToAssignNmaAuthLst.append("<authType>").append(processAssignEntity.getBtRoleName()).append("</authType>");
userWaitToAssignNmaAuthLst.append(USER_WAIT_TO_ASSIGN_NMA_AUTH_LST_FOOTER);
}
/**
* 获得提交接口的JSON参数
*
* @param request
* @return
*/
private JSONObject getPostParams(HttpServletRequest request) {
BufferedReader reader = null;
StringBuilder sb = new StringBuilder();
try {
reader = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8"));
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
LogKit.error(e.getMessage(), e);
} finally {
try {
if (null != reader) {
reader.close();
}
} catch (IOException e) {
LogKit.error(e.getMessage(), e);
}
}
if (StringUtils.isEmpty(sb.toString())) {
return JSONObject.EMPTY;
}
LogKit.info("cdia-AssignServiceHandler-getPostParams:{}", sb.toString());
return new JSONObject(sb.toString());
}
/**
* 审批意见查询接口返回审核意见
*
* @param processAssignEntity
*/
private void setProcNodeOpinion(ProcessAssignEntity processAssignEntity) throws Exception {
JSONObject bodyJSON = JSONObject.create();
JSONObject paramObject = JSONObject.create();
paramObject.put("procInstId", processAssignEntity.getProcInstId());
paramObject.put("authGroup", AUTH_GROUP);
paramObject.put("nodeInstId", StringUtils.EMPTY);
bodyJSON.put("paramObject", paramObject);
bodyJSON.put("sysId", CustomSubmitJob.SYS_ID);
bodyJSON.put("userId", processAssignEntity.getDrafId());
LogKit.info("cdia-AssignServiceHandler-setProcNodeOpinion-审批意见查询接口参数:{}", bodyJSON.encode());
String res = CustomSubmitJob.postJSON(CdiaConfig.getInstance().getProcNodeUrl(), bodyJSON);
LogKit.info("cdia-AssignServiceHandler-审批意见查询接口响应:{}", res);
JSONArray opinionMap = (new JSONObject(res)).getJSONObject("resultData").getJSONArray("opinionMap");
String ytOp = StringUtils.EMPTY;
String tcOp = StringUtils.EMPTY;
for (int i = 0; i < opinionMap.size(); i++) {
String fieldCode = opinionMap.getJSONObject(i).getString("fieldCode");
String opinionType = opinionMap.getJSONObject(i).getString("opinionText");
if (ComparatorUtils.equals(fieldCode, "cloudAtlasOption")) {
// 价值云图权限审批意见
ytOp = opinionType;
}
if (ComparatorUtils.equals(fieldCode, "positionOption")) {
// 头寸权限审批意见
tcOp = opinionType;
}
}
processAssignEntity.setYtOp(ytOp);
processAssignEntity.setTcOp(tcOp);
}
/**
* 保存
*
* @param processAssignEntity
* @throws Exception
*/
private void updateEntity(final ProcessAssignEntity processAssignEntity) throws Exception {
ProcessDBAccess.getAccessor().runDMLAction(new DBAction<ProcessAssignEntity>() {
@Override
public ProcessAssignEntity run(DAOContext daoContext) throws Exception {
(daoContext.getDAO(ProcessAssignDao.class)).update(processAssignEntity);
return null;
}
});
}
/**
* @param userName
* @param tcRoleName
* @return
* @throws Exception
*/
private Boolean setUserRole(String userName, final String tcRoleName) throws Exception {
if (StringUtils.isEmpty(tcRoleName) || StringUtils.isEmpty(userName)) {
return false;
}
if (UserKit.existUsername(userName)) {
try {
String roleId = getRoleIDByName(tcRoleName);
String userId = UserService.getInstance().getCurrentUserId(userName);
UserBean userBean = new UserBean();
userBean.setId(userId);
userBean.setRoleIds(new String[]{roleId});
UserService.getInstance().updateUserRoles(AddUserSubmitJob.getAdminUserId(), userBean);
return true;
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
}
}
return false;
}
private String getRoleIDByName(String role) throws Exception {
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("name", role));
CustomRole customRole = AuthorityContext.getInstance().getCustomRoleController().findOne(condition);
if (customRole != null) {
return customRole.getId();
}
return StringKit.EMPTY;
}
private JSONObject createSuccessResponseJSONObject() throws JSONException {
JSONObject result = JSONObject.create();
result.put("errorCode", 0);
result.put("status", "success");
return result;
}
private JSONObject createFailResponseJSONObject() throws JSONException {
JSONObject result = JSONObject.create();
result.put("errorCode", 1);
result.put("status", "fail");
return result;
}
}

105
src/main/java/com/fr/plugin/cdia/service/QueryServiceHandler.java

@ -0,0 +1,105 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: QueryServiceHandler
* Author:
* Date: 2020/9/11 8:51
*/
package com.fr.plugin.cdia.service;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.net.NetworkKit;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.plugin.cdia.dao.ProcessAssignDao;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.plugin.context.PluginContexts;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* <Function Description><br>
* <QueryServiceHandler>
*
* @author
* @since 1.0.0
*/
public class QueryServiceHandler extends BaseHttpHandler {
public static final String API_QUERY_PROCESS = "/cdia/queryProcess";
public QueryServiceHandler() {
}
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return API_QUERY_PROCESS;
}
@Override
public boolean isPublic() {
return true;
}
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) {
LogKit.error(I18nKit.getLocText("Plugin-cdia_Licence_Expired"));
WebUtils.flushSuccessMessageAutoClose(request, response, createFailResponseJSONObject());
return;
}
final String procInstId = NetworkKit.getHTTPRequestParameter(request, "procInstId");
JSONObject data = null;
try {
data = getProcessData(procInstId);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
}
JSONObject result = createFailResponseJSONObject();
if (data != null && data.size() > 0) {
result = createSuccessResponseJSONObject();
result.put("data", data);
}
WebUtils.flushSuccessMessageAutoClose(request, response, result);
}
private JSONObject getProcessData(String procInstId) throws Exception {
List<ProcessAssignEntity> processAssignEntityList = ProcessAssignDao.findEntityByProc(procInstId);
JSONObject processData = JSONObject.create();
JSONArray detail = JSONArray.create();
for (ProcessAssignEntity processAssignEntity : processAssignEntityList) {
if (!processData.has("header")) {
processData.put("header", processAssignEntity.toJSON());
}
detail.add(processAssignEntity.detail2JSON());
}
processData.put("body", detail);
return processData;
}
private JSONObject createSuccessResponseJSONObject() throws JSONException {
JSONObject result = JSONObject.create();
result.put("errorCode", 0);
result.put("status", "success");
return result;
}
private JSONObject createFailResponseJSONObject() throws JSONException {
JSONObject result = JSONObject.create();
result.put("errorCode", 1);
result.put("status", "fail");
return result;
}
}

39
src/main/java/com/fr/plugin/cdia/submit/SubmitUIBridge.java

@ -0,0 +1,39 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: SubmitUIBridge
* Author:
* Date: 2020/8/31 21:50
*/
package com.fr.plugin.cdia.submit;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractSubmitProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.cdia.submit.ui.DataSubmitConfigPane;
/**
* <Function Description><br>
* <SubmitUIBridge>
*
* @author
* @since 1.0.0
*/
public class SubmitUIBridge extends AbstractSubmitProvider {
public static final String KEY = "DataSubmit";
@Override
public BasicBeanPane appearanceForSubmit() {
return new DataSubmitConfigPane();
}
@Override
public String dataForSubmit() {
return Toolkit.i18nText("Plugin-cdia_Submit_Data");
}
@Override
public String keyForSubmit() {
return SubmitUIBridge.KEY;
}
}

264
src/main/java/com/fr/plugin/cdia/submit/job/AddUserSubmitJob.java

@ -0,0 +1,264 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: AddUserSubmitJob
* Author:
* Date: 2020/8/30 15:49
*/
package com.fr.plugin.cdia.submit.job;
import com.fanruan.api.decision.user.UserKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.DefinedSubmitJob;
import com.fr.data.JobValue;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.base.constant.type.operation.ManualOperationType;
import com.fr.decision.authority.data.CustomRole;
import com.fr.decision.authority.data.Department;
import com.fr.decision.authority.data.Post;
import com.fr.decision.privilege.TransmissionTool;
import com.fr.decision.webservice.bean.user.DepartmentPostBean;
import com.fr.decision.webservice.bean.user.RoleBean;
import com.fr.decision.webservice.bean.user.UserBean;
import com.fr.decision.webservice.v10.user.CustomRoleService;
import com.fr.decision.webservice.v10.user.PositionService;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.script.Calculator;
import com.fr.stable.Primitive;
import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <Function Description><br>
* <自定义提交添加用户AddUserSubmitJob>
*
* @author
* @since 1.0.0
*/
public class AddUserSubmitJob extends DefinedSubmitJob {
public static final String SEPARATOR = ",";
/**
* 获取管理员id
*
* @return
* @throws Exception
*/
public static String getAdminUserId() throws Exception {
List<String> adminUserIdList = UserService.getInstance().getAdminUserIdList();
if (adminUserIdList.isEmpty()) {
return "admin";
}
return StringKit.isNotBlank(adminUserIdList.get(0)) ? adminUserIdList.get(0) : "admin";
}
private String roleOperation(String role) throws Exception {
String customRoleId = getCustomRoleIdByName(role);
if (StringKit.isNotBlank(customRoleId)) {
return customRoleId;
}
RoleBean roleBean = new RoleBean(role, "", role, ManualOperationType.KEY.toInteger());
CustomRoleService.getInstance().addCustomRole(getAdminUserId(), roleBean);
return getCustomRoleIdByName(role);
}
private String getCustomRoleIdByName(String roleName) throws Exception {
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("name", roleName));
CustomRole customRole = AuthorityContext.getInstance().getCustomRoleController().findOne(condition);
if (customRole != null) {
return customRole.getId();
}
return StringKit.EMPTY;
}
@Override
public String getJobType() {
return "AddUserSubmitJob";
}
@Override
public void doJob(Calculator calculator) throws Exception {
Map<String, Object> propertyMap = calculator.getAttribute(PROPERTY_VALUE);
if (propertyMap == null) {
return;
}
if (isOperationState(propertyMap)) {
String departmentName = getAttributeByKey(propertyMap, "department");
String roles = getAttributeByKey(propertyMap, "role");
String deptType = getAttributeByKey(propertyMap, "deptType");
String rolesStr = StringKit.EMPTY;
if (StringKit.isNotEmpty(roles)) {
rolesStr = roles;
}
if (StringKit.isNotEmpty(deptType)) {
if (StringKit.isNotEmpty(rolesStr)) {
rolesStr = rolesStr + "," + deptType;
} else {
rolesStr = deptType;
}
}
LogKit.info("cdia-AddUserSubmitJob-doJob-rolesStr", rolesStr);
UserBean userBean = getUserBean(propertyMap);
String departmentPostId = getDepartmentPostId(departmentName);
operation(userBean, rolesStr, departmentPostId);
}
}
/**
* 判断是否提交填报操作
*
* @param propertyMap
* @return
*/
private Boolean isOperationState(Map<String, Object> propertyMap) {
JobValue ce = (JobValue) propertyMap.get("username");
if (ce.getState() == JobValue.State.MODIFIED) {
// 此单元格的值在报表初始化后被修改过
LogKit.info("cdia-AddUserSubmitJob-doJob-State-MODIFIED");
return true;
} else if (ce.getState() == JobValue.State.INSERT) {
// 此单元格是在报表初始化后新增的(例如执行了插入行操作)
LogKit.info("cdia-AddUserSubmitJob-doJob-State-INSERT");
return true;
} else if (ce.getState() == JobValue.State.DELETED) {
// 此单元格所在的记录被执行了删除操作
} else if (ce.getState() == JobValue.State.DEFAULT) {
// 此单元格在报表初始化后没有变化
LogKit.info("cdia-AddUserSubmitJob-doJob-State-DEFAULT");
return true;
}
return false;
}
/**
* 填报属性提取用户信息
*
* @param propertyMap
* @return
*/
private UserBean getUserBean(Map<String, Object> propertyMap) {
String username = getAttributeByKey(propertyMap, "username");
String name = getAttributeByKey(propertyMap, "name");
String mobile = getAttributeByKey(propertyMap, "mobile");
String email = getAttributeByKey(propertyMap, "email");
UserBean userBean = new UserBean();
userBean.setUsername(username);
userBean.setPassword(TransmissionTool.defaultEncrypt(UUID.randomUUID().toString()));
userBean.setRealName(name);
userBean.setMobile(mobile);
userBean.setEmail(email);
return userBean;
}
/**
* 通过属性名获得填报属性值
*
* @param propertyMap
* @param key
* @return
*/
private String getAttributeByKey(Map<String, Object> propertyMap, String key) {
if (!propertyMap.containsKey(key)) {
return StringUtils.EMPTY;
}
Object value = ((JobValue) propertyMap.get(key)).getValue();
if (value instanceof Primitive) {
return StringUtils.EMPTY;
}
return String.valueOf(((JobValue) propertyMap.get(key)).getValue());
}
/**
* 更新用户信息和角色
*
* @param userBean
* @param roles
* @throws Exception
*/
private void operation(UserBean userBean, final String roles, String departmentPostId) throws Exception {
if (UserKit.existUsername(userBean.getUsername())) {
return;
}
if (StringKit.isNotBlank(roles)) {
List<String> roleIds = new ArrayList<>();
String roleId;
for (String role : roles.split(SEPARATOR)) {
if (StringKit.isEmpty(role)) {
continue;
}
roleId = roleOperation(role);
roleIds.add(roleId);
}
userBean.setRoleIds(roleIds.toArray(new String[0]));
}
if (StringKit.isNotBlank(departmentPostId)) {
userBean.setDepartmentPostId(departmentPostId);
}
UserService.getInstance().addUser(userBean);
}
private String getDepartmentPostId(String departmentAndPostName) throws Exception {
String departmentName;
String positionName;
if (departmentAndPostName.contains("-")) {
String[] departmentAndPostArray = departmentAndPostName.split("-");
departmentName = departmentAndPostArray[0];
positionName = departmentAndPostArray[1];
} else {
departmentName = departmentAndPostName;
positionName = StringKit.EMPTY;
}
AuthorityContext authorityContext = AuthorityContext.getInstance();
QueryCondition queryDepartment = QueryFactory.create().addRestriction(RestrictionFactory.eq(Department.COLUMN_NAME, departmentName));
Department department = authorityContext.getDepartmentController().findOne(queryDepartment);
if (department == null) {
return StringKit.EMPTY;
}
String departmentPostId = department.getId();
String positionId = positionSynOperation(positionName, departmentPostId);
if (StringKit.isNotBlank(positionId)) {
departmentPostId = departmentPostId + "@@@" + positionId;
}
return departmentPostId;
}
/**
* 职务同步操作
*
* @param positionName
* @return
* @throws Exception
*/
private String positionSynOperation(String positionName, String departmentId) throws Exception {
if (StringKit.isBlank(positionName)) {
return StringKit.EMPTY;
}
String position = StringKit.isNotBlank(positionName) ? positionName : "职员";
Post post = AuthorityContext.getInstance().getPostController().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("name", position)));
String positionId;
if (post == null) {
positionId = PositionService.getInstance().addPosition(position, position);
} else {
positionId = post.getId();
}
List<DepartmentPostBean> departmentPostBeanList = PositionService.getInstance().getPositionsUnderParentDepartment(getAdminUserId(), departmentId, position);
if (departmentPostBeanList == null || departmentPostBeanList.isEmpty()) {
try {
AuthorityContext.getInstance().getPostController().addPostToDepartment(positionId, departmentId);
} catch (Exception e) {
LogKit.info("cdia-AddUserSubmitJob-positionSynOperation-addPostToDepartmentFailed-position:{}, departmentId:{}", positionId + position, departmentId);
LogKit.error(e.getMessage(), e);
}
}
return positionId;
}
}

235
src/main/java/com/fr/plugin/cdia/submit/job/CustomSubmitJob.java

@ -0,0 +1,235 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: CustomSubmitJob
* Author:
* Date: 2020/8/28 17:01
*/
package com.fr.plugin.cdia.submit.job;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.net.http.HttpKit;
import com.fr.data.DefinedSubmitJob;
import com.fr.data.JobValue;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import com.fr.plugin.cdia.ProcessDBAccess;
import com.fr.plugin.cdia.config.CdiaConfig;
import com.fr.plugin.cdia.dao.ProcessAssignDao;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.script.Calculator;
import com.fr.stable.Primitive;
import com.fr.stable.StringUtils;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.third.org.apache.http.entity.StringEntity;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
/**
* <Function Description><br>
* <CustomSubmitJob>
*
* @author
* @since 1.0.0
*/
public class CustomSubmitJob extends DefinedSubmitJob {
public static final String SYS_ID = "OA";
private static final HashSet<String> paramsSet = new HashSet<String>() {{
add("procDefId");
add("docTitle");
add("userId");
add("deptId");
add("systemCode");
add("equipmentType");
}};
/**
* POST提交JSON
*
* @param url
* @param params
* @return
* @throws Exception
*/
public static String postJSON(String url, JSONObject params) throws Exception {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
StringEntity stringEntity = new StringEntity(params.encode(), "UTF-8");
return HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom()
.url(url).post(stringEntity).headers(headers).build());
}
@Override
public String getJobType() {
return "CustomJob";
}
@Override
public void doJob(Calculator calculator) throws Exception {
Map<String, Object> propertyMap = calculator.getAttribute(PROPERTY_VALUE);
if (propertyMap == null) {
return;
}
if (!isOperationState(propertyMap)) {
return;
}
ProcessAssignEntity processAssignEntity = new ProcessAssignEntity();
JSONObject paramsJSON = JSONObject.create();
getSubmitAttribute(propertyMap, processAssignEntity, paramsJSON);
if (paramsJSON.isEmpty()) {
return;
}
operation(paramsJSON, processAssignEntity);
}
/**
* 提取填报属性值
*
* @param propertyMap 属性值Map
* @param processAssignEntity 流程实体
* @param paramsJSON http接口参数
*/
private void getSubmitAttribute(Map<String, Object> propertyMap, ProcessAssignEntity processAssignEntity, JSONObject paramsJSON) {
for (Entry<String, Object> entry : propertyMap.entrySet()) {
if (entry.getValue() instanceof JobValue) {
JobValue ce = (JobValue) entry.getValue();
if (ce.getValue() instanceof Primitive) {
continue;
}
if (paramsSet.contains(entry.getKey())) {
paramsJSON.put(entry.getKey(), String.valueOf(ce.getValue()));
}
processAssignEntity.setEntity(entry.getKey(), String.valueOf(ce.getValue()));
}
}
}
/**
* 填报属性状态判断
*
* @param propertyMap
* @return
*/
private Boolean isOperationState(Map<String, Object> propertyMap) {
for (Entry<String, Object> entry : propertyMap.entrySet()) {
if (entry.getValue() instanceof JobValue) {
JobValue ce = (JobValue) entry.getValue();
if (ce.getState() == JobValue.State.MODIFIED) {
// 此单元格的值在报表初始化后被修改过
LogKit.info("cdia-CustomSubmitJob-doJob-State-MODIFIED");
return true;
} else if (ce.getState() == JobValue.State.INSERT) {
// 此单元格是在报表初始化后新增的(例如执行了插入行操作)
LogKit.info("cdia-CustomSubmitJob-doJob-State-INSERT");
return true;
} else if (ce.getState() == JobValue.State.DEFAULT) {
// 此单元格在报表初始化后没有变化
LogKit.info("cdia-CustomSubmitJob-doJob-State-DEFAULT");
return true;
}
}
return false;
}
return false;
}
/**
* 保存
*
* @param processAssignEntity
* @throws Exception
*/
private void save(final ProcessAssignEntity processAssignEntity) throws Exception {
ProcessDBAccess.getAccessor().runDMLAction(new DBAction<ProcessAssignEntity>() {
@Override
public ProcessAssignEntity run(DAOContext daoContext) throws Exception {
(daoContext.getDAO(ProcessAssignDao.class)).addOrUpdate(processAssignEntity);
return null;
}
});
}
/**
* 提交属性处理操作
* 1.访问创建流程接口获得流程ID及其他信息
* 2.流程表单保存
* 3.打开浏览器窗口
*
* @param paramsJSON
* @param processAssignEntity
* @throws Exception
*/
private void operation(JSONObject paramsJSON, ProcessAssignEntity processAssignEntity) throws Exception {
JSONObject createProcessBody = saveProcessBody(paramsJSON);
LogKit.info("cdia-CustomSubmitJob-operation-createProcessBody:{}", createProcessBody.encode());
String res = postJSON(CdiaConfig.getInstance().getCreateProcessUrl(), createProcessBody);
LogKit.info("cdia-CustomSubmitJob-operation-response:{}", res);
JSONObject procInstanceJo = new JSONObject(res).getJSONObject("resultData").getJSONObject("procInstance");
String procInstId = procInstanceJo.getString("procInstId");
String sequenceNo = procInstanceJo.getString("sequenceNo");
if (StringUtils.isEmpty(procInstId) || ComparatorUtils.equals(procInstId, "{}")
|| StringUtils.isEmpty(sequenceNo) || ComparatorUtils.equals(sequenceNo, "{}")
) {
return;
}
// 保存数据库
processAssignEntity.setId(procInstId);
processAssignEntity.setProcInstId(procInstId);
processAssignEntity.setSequenceNo(sequenceNo);
processAssignEntity.setLoadTime(String.valueOf(System.currentTimeMillis()));
setOpIndexUrl(processAssignEntity);
save(processAssignEntity);
}
/**
* findProcFormOpIndexUrl接口返回url
*
* @param processAssignEntity
*/
private void setOpIndexUrl(ProcessAssignEntity processAssignEntity) throws Exception {
if (StringUtils.isBlank(processAssignEntity.getSequenceNo())) {
return;
}
Map<String, Object> params = new HashMap<String, Object>();
JSONObject bodyJSON = JSONObject.create();
JSONObject paramObject = JSONObject.create();
paramObject.put("sequenceNo", processAssignEntity.getSequenceNo());
paramObject.put("authFlag", "0");
bodyJSON.put("paramObject", paramObject);
bodyJSON.put("formSysId", StringUtils.EMPTY);
bodyJSON.put("sysId", SYS_ID);
bodyJSON.put("userId", processAssignEntity.getDrafId());
LogKit.info("cdia-CustomSubmitJob-setOpIndexUrl-params:{}", params);
String res = postJSON(CdiaConfig.getInstance().getProcFormOpIndexUrl(), bodyJSON);
LogKit.info("cdia-CustomSubmitJob-setOpIndexUrl-res:{}", res);
String resultData = (new JSONObject(res)).getString("resultData");
if (StringUtils.isNotBlank(resultData)) {
processAssignEntity.setOpIndexUrl(resultData);
}
}
/**
* OA创建流程接口-国产化
*
* @param paramsJSON
* @return
*/
private JSONObject saveProcessBody(JSONObject paramsJSON) {
JSONObject requestBody = JSONObject.create();
JSONObject paramObject = new JSONObject().put("deptId", paramsJSON.getString("deptId"))
.put("docTitle", paramsJSON.getString("docTitle"))
.put("formValue", JSONObject.EMPTY)
.put("procDefId", paramsJSON.getString("procDefId"))
.put("isWait", "0");
requestBody.put("paramObject", paramObject)
.put("sysId", paramsJSON.getString("systemCode"))
.put("formSysId", paramsJSON.getString("equipmentType"))
.put("userId", paramsJSON.getString("userId"));
return requestBody;
}
}

260
src/main/java/com/fr/plugin/cdia/submit/job/CustomTotalSubmitJob.java

@ -0,0 +1,260 @@
/*
* Copyright (C), 2018-2022
* Project: starter
* FileName: CustomTotalSubmitJob
* Author:
* Date: 2022/4/7 23:39
*/
package com.fr.plugin.cdia.submit.job;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.net.http.HttpKit;
import com.fr.base.Parameter;
import com.fr.data.JobValue;
import com.fr.data.TotalSubmitJob;
import com.fr.general.ComparatorUtils;
import com.fr.general.DefaultValues;
import com.fr.general.GeneralContext;
import com.fr.json.JSONObject;
import com.fr.plugin.cdia.ProcessDBAccess;
import com.fr.plugin.cdia.bean.ProcessAssignBean;
import com.fr.plugin.cdia.config.CdiaConfig;
import com.fr.plugin.cdia.dao.ProcessAssignDao;
import com.fr.plugin.cdia.entity.ProcessAssignEntity;
import com.fr.script.Calculator;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.third.org.apache.http.entity.StringEntity;
import java.util.*;
/**
* <Function Description><br>
* <CustomTotalSubmitJob>
*
* @author
* @since 1.0.0
*/
public class CustomTotalSubmitJob extends TotalSubmitJob {
public static final String SYS_ID = "OA";
private static final long serialVersionUID = 8626781409712334459L;
private static final HashSet<String> paramsSet = new HashSet<String>() {{
add("procDefId");
add("docTitle");
add("userId");
add("deptId");
add("systemCode");
add("equipmentType");
}};
/**
* POST提交JSON
*
* @param url
* @param params
* @return
* @throws Exception
*/
public static String postJSON(String url, JSONObject params) throws Exception {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
StringEntity stringEntity = new StringEntity(params.encode(), "UTF-8");
return HttpKit.executeAndParse(com.fanruan.api.net.http.rs.HttpRequest.custom()
.url(url).post(stringEntity).headers(headers).build());
}
@Override
public void doJob(Calculator calculator) throws Exception {
super.doJob(calculator);
}
@Override
public String getJobType() {
return "CustomTotalJob";
}
@Override
protected void doTotalJob(Data data, Calculator calculator) throws Exception {
List<ProcessAssignBean> processAssignBeans = new ArrayList<>();
ProcessAssignBean processAssignBean;
ProcessAssignEntity processAssignEntity;
JSONObject paramsJSON;
boolean isRecordModify;
for (int row = 0; row < data.getRowCount(); row++) {
processAssignBean = new ProcessAssignBean();
processAssignEntity = new ProcessAssignEntity();
paramsJSON = JSONObject.create();
isRecordModify = false;
for (int col = 0; col < data.getColumnCount(); col++) {
Object cellValue = data.getValueAt(row, col);
if (!(cellValue instanceof JobValue)) {
continue;
}
JobValue ce = (JobValue) cellValue;
if (!isRecordModify && isStateStrict(ce)) {
isRecordModify = true;
}
if (paramsSet.contains(data.getColumnName(col))) {
paramsJSON.put(data.getColumnName(col), valueToString(ce.getValue()));
}
processAssignEntity.setEntity(data.getColumnName(col), valueToString(ce.getValue()));
}
if (isRecordModify) {
processAssignBean.setParamsJSON(paramsJSON);
processAssignBean.setProcessAssignEntity(processAssignEntity);
processAssignBeans.add(processAssignBean);
}
}
if (processAssignBeans.isEmpty()) {
return;
}
JSONObject procInstanceJo = JSONObject.EMPTY;
for (ProcessAssignBean processAssign : processAssignBeans) {
if (processAssign.getParamsJSON().isEmpty()) {
continue;
}
if (ComparatorUtils.equals(procInstanceJo, JSONObject.EMPTY)) {
procInstanceJo = getProcInstance(processAssign.getParamsJSON());
}
operation(procInstanceJo, processAssign.getProcessAssignEntity());
}
}
private JSONObject getProcInstance(JSONObject paramsJSON) throws Exception {
JSONObject createProcessBody = saveProcessBody(paramsJSON);
LogKit.info("cdia-CustomTotalSubmitJob-getProcInstance-createProcessBody:{}", createProcessBody.encode());
String res = postJSON(CdiaConfig.getInstance().getCreateProcessUrl(), createProcessBody);
LogKit.info("cdia-CustomTotalSubmitJob-getProcInstance-response:{}", res);
return new JSONObject(res).getJSONObject("resultData").getJSONObject("procInstance");
}
/**
* jobValue to String
*
* @return
*/
private String valueToString(Object value) {
String result;
if (value instanceof Date) {
DefaultValues defaultValues = GeneralContext.getDefaultValues();
result = defaultValues.getDateTimeFormat().format(value);
} else if (value instanceof Parameter) {
result = ((Parameter) value).valueToString();
} else if (value instanceof Double) {
result = StableUtils.doubleToString((Double) value);
} else {
result = String.valueOf(value);
}
return result;
}
/**
* 填报属性状态判断
*
* @param jobValue
* @return
*/
private Boolean isStateStrict(JobValue jobValue) {
if ((jobValue.getState().checkChanged() && !jobValue.getState().checkDeleted())) {
return true;
} else if (jobValue.getState().checkInsert()) {
return true;
} else if (jobValue.getState().checkDeleted()) {
return true;
} else if (jobValue.getState().checkDefault()) {
return true;
}
return false;
}
/**
* 提交属性处理操作
* 1.访问创建流程接口获得流程ID及其他信息
* 2.流程表单保存
* 3.打开浏览器窗口
*
* @param procInstanceJo
* @param processAssignEntity
* @throws Exception
*/
private void operation(JSONObject procInstanceJo, ProcessAssignEntity processAssignEntity) throws Exception {
String procInstId = procInstanceJo.getString("procInstId");
String sequenceNo = procInstanceJo.getString("sequenceNo");
if (StringUtils.isEmpty(procInstId) || ComparatorUtils.equals(procInstId, "{}")
|| StringUtils.isEmpty(sequenceNo) || ComparatorUtils.equals(sequenceNo, "{}")
) {
return;
}
// 保存数据库
processAssignEntity.setId(UUID.randomUUID().toString());
processAssignEntity.setProcInstId(procInstId);
processAssignEntity.setSequenceNo(sequenceNo);
processAssignEntity.setLoadTime(String.valueOf(System.currentTimeMillis()));
setOpIndexUrl(processAssignEntity);
save(processAssignEntity);
}
/**
* findProcFormOpIndexUrl接口返回url
*
* @param processAssignEntity
*/
private void setOpIndexUrl(ProcessAssignEntity processAssignEntity) throws Exception {
if (StringUtils.isBlank(processAssignEntity.getSequenceNo())) {
return;
}
JSONObject bodyJSON = JSONObject.create();
JSONObject paramObject = JSONObject.create();
paramObject.put("sequenceNo", processAssignEntity.getSequenceNo());
paramObject.put("authFlag", "0");
bodyJSON.put("paramObject", paramObject);
bodyJSON.put("formSysId", StringUtils.EMPTY);
bodyJSON.put("sysId", SYS_ID);
bodyJSON.put("userId", processAssignEntity.getDrafId());
LogKit.info("cdia-CustomTotalSubmitJob-setOpIndexUrl-bodyJSON:{}", bodyJSON.encode());
String res = postJSON(CdiaConfig.getInstance().getProcFormOpIndexUrl(), bodyJSON);
LogKit.info("cdia-CustomTotalSubmitJob-setOpIndexUrl-res:{}", res);
String resultData = (new JSONObject(res)).getString("resultData");
if (StringUtils.isNotBlank(resultData)) {
processAssignEntity.setOpIndexUrl(resultData);
}
}
/**
* OA创建流程接口-国产化
*
* @param paramsJSON
* @return
*/
private JSONObject saveProcessBody(JSONObject paramsJSON) {
JSONObject requestBody = JSONObject.create();
JSONObject paramObject = new JSONObject().put("deptId", paramsJSON.getString("deptId"))
.put("docTitle", paramsJSON.getString("docTitle"))
.put("formValue", JSONObject.EMPTY)
.put("procDefId", paramsJSON.getString("procDefId"))
.put("isWait", "0");
requestBody.put("paramObject", paramObject)
.put("sysId", paramsJSON.getString("systemCode"))
.put("formSysId", paramsJSON.getString("equipmentType"))
.put("userId", paramsJSON.getString("userId"));
return requestBody;
}
/**
* 保存
*
* @param processAssignEntity
* @throws Exception
*/
private void save(final ProcessAssignEntity processAssignEntity) throws Exception {
ProcessDBAccess.getAccessor().runDMLAction(new DBAction<ProcessAssignEntity>() {
@Override
public ProcessAssignEntity run(DAOContext daoContext) throws Exception {
(daoContext.getDAO(ProcessAssignDao.class)).addOrUpdate(processAssignEntity);
return null;
}
});
}
}

106
src/main/java/com/fr/plugin/cdia/submit/ui/DataSubmitConfigPane.java

@ -0,0 +1,106 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: DataSubmitConfigPane
* Author:
* Date: 2020/8/31 21:59
*/
package com.fr.plugin.cdia.submit.ui;
import com.fr.data.AbstractClassJob;
import com.fr.data.ClassSubmitJob;
import com.fr.data.SubmitJob;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.gui.frpane.ObjectProperiesPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.util.List;
/**
* <Function Description><br>
* <数据提交配置DataSubmitConfigPane>
*
* @author
* @since 1.0.0
*/
public class DataSubmitConfigPane extends BasicBeanPane {
protected UIComboBox classNameComboBox;
protected ObjectProperiesPane objectProperiesPane;
public DataSubmitConfigPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel classPathPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
this.classNameComboBox = initUIComboBox(DataSubmitItems.LIST_ITEMS);
classPathPane.add(this.classNameComboBox);
classPathPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Class_Name"), null));
this.add(classPathPane, "North");
this.objectProperiesPane = new ObjectProperiesPane();
this.objectProperiesPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Property"), null));
this.add(this.objectProperiesPane, "Center");
UITextArea description = new UITextArea(2, 1);
description.setText(Toolkit.i18nText("Fine-Design_Basic_Extend_Class", new Object[]{"com.fr.data.AbstractSubmitTask"}));
JPanel descriptionPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
descriptionPane.add(description);
descriptionPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Custom_Job_Description"), null));
this.add(descriptionPane, "South");
this.checkAddButtonEnable();
}
public int getLengthOfTextField() {
return 25;
}
protected String title4PopupWindow() {
return "DataSubmitJob";
}
protected Component getWindowAncestor() {
return this;
}
public void populateBean(Object obj) {
if (obj instanceof AbstractClassJob) {
AbstractClassJob job = (AbstractClassJob) obj;
this.classNameComboBox.setSelectedIndex(DataSubmitItems.classNameList.indexOf(job.getClassName()));
this.objectProperiesPane.populateBean(job.getPropertyMap());
this.checkAddButtonEnable();
}
}
public SubmitJob updateBean() {
ClassSubmitJob submitJob = new ClassSubmitJob(DataSubmitItems.classNameList.get(this.classNameComboBox.getSelectedIndex()));
submitJob.setPropertyMap(this.objectProperiesPane.updateBean());
this.checkAddButtonEnable();
return submitJob;
}
public void checkAddButtonEnable() {
this.objectProperiesPane.enableAddButton(true);
}
public void reset() {
this.classNameComboBox.setSelectedIndex(0);
this.checkAddButtonEnable();
}
/**
* 初始化类名下拉框
*
* @param items
* @return
*/
private UIComboBox initUIComboBox(List<Item> items) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
return new UIComboBox(model);
}
}

45
src/main/java/com/fr/plugin/cdia/submit/ui/DataSubmitItems.java

@ -0,0 +1,45 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: DataSubmitItems
* Author:
* Date: 2020/9/1 8:47
*/
package com.fr.plugin.cdia.submit.ui;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.cdia.submit.job.AddUserSubmitJob;
import com.fr.plugin.cdia.submit.job.CustomSubmitJob;
import java.util.ArrayList;
import java.util.List;
/**
* <Function Description><br>
* <DataSubmitItems>
*
* @author
* @since 1.0.0
*/
public class DataSubmitItems implements ItemProvider {
public static List<Item> LIST_ITEMS = new ArrayList<Item>() {{
add(new Item(Toolkit.i18nText("Plugin-cdia_ClassName_Apply_Submit"), CustomSubmitJob.class.getName()));
add(new Item(Toolkit.i18nText("Plugin-cdia_ClassName_Add_User_Submit"), AddUserSubmitJob.class.getName()));
}};
public static List<String> classNameList = new ArrayList<String>() {{
add(CustomSubmitJob.class.getName());
add(AddUserSubmitJob.class.getName());
}};
public DataSubmitItems() {
}
@Override
public Item[] getItems() {
return LIST_ITEMS.toArray(new Item[0]);
}
}

35
src/main/java/com/fr/plugin/cdia/web/WebResourceComponent.java

@ -0,0 +1,35 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: WebResourceComponent
* Author:
* Date: 2020/8/31 16:39
*/
package com.fr.plugin.cdia.web;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
/**
* <Function Description><br>
* <WebResourceComponent>
*
* @author
* @since 1.0.0
*/
@EnableMetrics
public class WebResourceComponent extends Component {
public static final String PLUGIN_ID = "com.fr.plugin.cdia.v10";
public static final WebResourceComponent KEY = new WebResourceComponent();
@Override
@Focus(id = PLUGIN_ID, text = "Plugin-cdia", source = Original.PLUGIN)
public ScriptPath script(RequestClient requestClient) {
return ScriptPath.build("/com/fr/plugin/cdia/web/cdia.js");
}
}

13
src/main/resources/com/fr/plugin/cdia/locale/lang.properties

@ -0,0 +1,13 @@
Plugin-cdia_Submit_Data=API Data Submit
Plugin-cdia_ClassName_Apply_Submit=Apply Submit
Plugin-cdia_ClassName_Add_User_Submit=Add User Submit
Plugin-cdia_Group=API Data Submit
Plugin-cdia_Config_CreateProcessUrl=Create Process Url
Plugin-cdia_Config_CreateProcessUrl_Description=Create Process Url
Plugin-cdia_Config_ProcFormOpIndexUrl=ProcFormOpIndexUrl
Plugin-cdia_Config_ProcFormOpIndexUrl_Description=ProcFormOpIndexUrl
Plugin-cdia_Config_ProcNodeUrl=ProcNodeUrl
Plugin-cdia_Config_ProcNodeUrl_Description=ProcNodeUrl
Plugin-cdia_Config_AssignNmaAuthUrl=AssignNmaAuthUrl
Plugin-cdia_Config_AssignNmaAuthUrl_Description=AssignNmaAuthUrl
Plugin-cdia_Licence_Expired=API Data Submit Plugin Licence Expired

13
src/main/resources/com/fr/plugin/cdia/locale/lang_zh_CN.properties

@ -0,0 +1,13 @@
Plugin-cdia_Submit_Data=\u63A5\u53E3\u6570\u636E\u63D0\u4EA4
Plugin-cdia_ClassName_Apply_Submit=\u5EFA\u7ACB\u5BA1\u6838\u63D0\u4EA4
Plugin-cdia_ClassName_Add_User_Submit=\u67E5\u8BE2\u5BA1\u6838\u63D0\u4EA4
Plugin-cdia_Group=\u63A5\u53E3\u6570\u636E\u63D0\u4EA4
Plugin-cdia_Config_CreateProcessUrl=\u521B\u5EFA\u6D41\u7A0BUrl
Plugin-cdia_Config_CreateProcessUrl_Description=\u521B\u5EFA\u6D41\u7A0BUrl
Plugin-cdia_Config_ProcFormOpIndexUrl=\u6D41\u7A0B\u7D22\u5F15url\u67E5\u8BE2\u63A5\u53E3
Plugin-cdia_Config_ProcFormOpIndexUrl_Description=\u6D41\u7A0B\u7D22\u5F15url\u67E5\u8BE2\u63A5\u53E3
Plugin-cdia_Config_ProcNodeUrl=\u5BA1\u6279\u610F\u89C1\u67E5\u8BE2\u63A5\u53E3
Plugin-cdia_Config_ProcNodeUrl_Description=\u5BA1\u6279\u610F\u89C1\u67E5\u8BE2\u63A5\u53E3
Plugin-cdia_Config_AssignNmaAuthUrl=\u7BA1\u4F1A\u63A5\u53E3
Plugin-cdia_Config_AssignNmaAuthUrl_Description=\u7BA1\u4F1A\u63A5\u53E3
Plugin-cdia_Licence_Expired=\u63A5\u53E3\u6570\u636E\u63D0\u4EA4\u63D2\u4EF6\u8BB8\u53EF\u8FC7\u671F

2
src/main/resources/com/fr/plugin/cdia/web/cdia.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save