稻花香仓库初始化
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua;
|
||||
|
||||
import com.seeyon.apps.common.plugin.api.APluginInfoApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.constants.HsDataSyncConstants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataPluginApi extends APluginInfoApi {
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return HsDataSyncConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateUser() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigVo getDefaultConfig() {
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
for (HsDataSyncConstants value : HsDataSyncConstants.values()) {
|
||||
if(value != HsDataSyncConstants.plugin) {
|
||||
configVo.getDevParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getProdParams().put(value.name(), value.getDefaultValue());
|
||||
configVo.getParamMap().put(value.name(), value.getDescription());
|
||||
}
|
||||
}
|
||||
return configVo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerCustomEvent(Map eventAndNodes) {
|
||||
// 如果每个模板不一样 可以采用templatemanager去读取编码配置
|
||||
eventAndNodes.put("hsdata", "历史数据推送");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.constants;
|
||||
|
||||
public enum HsDataSyncConstants {
|
||||
|
||||
// 如果有其他参数 这里去新增 todo
|
||||
plugin("chushihua","插件ID"),
|
||||
temp("hsdata_", "模板前缀"),
|
||||
lastUpdate("2000-01-01 00:00:00", "最后更新时间"),
|
||||
url("", "接口地址");
|
||||
|
||||
HsDataSyncConstants(String defaultValue, String description) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String defaultValue;
|
||||
private String description;
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static String getPluginId() {
|
||||
return plugin.defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.quartz;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.common.workflow.util.FormDataBeanUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.constants.HsDataSyncConstants;
|
||||
import com.seeyon.apps.daohuaxiangSys.chushihua.vo.HsDataVo;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.FanWeiNewUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.InterfaceListUtil;
|
||||
import com.seeyon.apps.daohuaxiangSys.jkts.util.PropKit;
|
||||
import com.seeyon.apps.ext.quartz.AbstractQuartzTask;
|
||||
import com.seeyon.apps.ext.workflow.manager.CstWorkFlowTemplateManager;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
|
||||
import com.seeyon.cap4.form.api.FormApi4Cap4;
|
||||
import com.seeyon.cap4.form.bean.FormBean;
|
||||
import com.seeyon.cap4.form.bean.FormDataMasterBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import com.seeyon.ctp.common.SystemEnvironment;
|
||||
import com.seeyon.ctp.common.filemanager.manager.AttachmentManager;
|
||||
import com.seeyon.ctp.common.po.filemanager.Attachment;
|
||||
import com.seeyon.ctp.common.template.manager.TemplateManager;
|
||||
import com.seeyon.ctp.organization.bo.V3xOrgMember;
|
||||
import com.seeyon.ctp.organization.manager.OrgManager;
|
||||
import com.seeyon.ctp.util.JDBCAgent;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.songjian.utils.json.JSONArray;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
* 定时同步历史数据
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataSyncQuartz extends AbstractQuartzTask {
|
||||
|
||||
private static final Log log = LogFactory.getLog(HsDataSyncQuartz.class);
|
||||
|
||||
|
||||
@Inject
|
||||
private ICstConfigApi cstConfigApi;
|
||||
@Inject
|
||||
private TemplateManager templateManager;
|
||||
@Inject
|
||||
private FormApi4Cap4 formApi4Cap4;
|
||||
@Inject
|
||||
private CstWorkFlowTemplateManager cstWorkFlowTemplateManager;
|
||||
|
||||
private AttachmentManager attachmentManager;
|
||||
|
||||
public void setAttachmentManager(AttachmentManager attachmentManager) {
|
||||
this.attachmentManager = attachmentManager;
|
||||
}
|
||||
|
||||
public AttachmentManager getAttachmentManagery() {
|
||||
if (attachmentManager == null) {
|
||||
attachmentManager = (AttachmentManager) AppContext.getBean("attachmentManager");
|
||||
}
|
||||
return attachmentManager;
|
||||
}
|
||||
|
||||
private OrgManager orgManager;
|
||||
|
||||
public OrgManager getOrgManager() {
|
||||
if (this.orgManager == null) {
|
||||
this.orgManager = ((OrgManager) AppContext.getBean("orgManager"));
|
||||
}
|
||||
return orgManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String taskRun(String tempCode) throws Exception {
|
||||
System.out.println("进入同步方法");
|
||||
final Map<String, Object> regist = FanWeiNewUtil.Regist(PropKit.getProp(PropKit.NEWADDRESS));
|
||||
System.out.println(regist);
|
||||
System.out.println("spk:" + regist.get("spk"));
|
||||
// return null;
|
||||
|
||||
//模板id
|
||||
Object templeteId = null;
|
||||
// 查询满足条件的id
|
||||
String sql = "select id from ctp_template where TEMPLETE_NUMBER = ? ";
|
||||
System.out.println(sql+tempCode);
|
||||
try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(tempCode);
|
||||
agent.execute(sql, params);
|
||||
List<Map<String, Object>> list = agent.resultSetToList();
|
||||
System.out.println(list.size());
|
||||
templeteId = list.get(0).get("id");
|
||||
System.out.println(templeteId);
|
||||
} catch (Exception e) {
|
||||
log.error("获取模板id失败:", e);
|
||||
}
|
||||
ceshi(Long.parseLong(templeteId.toString()), tempCode);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
* 调用第三方接口推送数据
|
||||
* null 表示成功 其他为失败信息
|
||||
* </pre>
|
||||
* @param request
|
||||
* @return: java.lang.String
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
**/
|
||||
private String push(String request, ConfigVo configVo) {
|
||||
// todo 获取配置信息 调用接口
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ceshi(Long tempId, String tempCode) throws IOException {
|
||||
System.out.println("进入ceshi方法");
|
||||
List<Map> datas = new ArrayList();
|
||||
Map<Long, FormBean> formBeanMap = new HashMap<>();
|
||||
|
||||
String dataSql = PropKit.getProp(PropKit.DATASQL);
|
||||
try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
List<Object> params = new ArrayList<>();
|
||||
params.add(tempId);
|
||||
agent.execute(dataSql, params);
|
||||
// 获取到所有的流程数据
|
||||
List<Map<String, Object>> list = agent.resultSetToList();
|
||||
if(null != list) {
|
||||
List<HsDataVo> hsData = list.stream().map(HsDataVo::new).collect(Collectors.toList());
|
||||
for (int i = 0; i < hsData.size(); i++) {
|
||||
Map data = new HashMap();
|
||||
HsDataVo hsDatum = hsData.get(i);
|
||||
FormBean formBean = formBeanMap.get(hsDatum.getFormId());
|
||||
if (null == formBean) {
|
||||
formBean = formApi4Cap4.getForm(hsDatum.getFormId());
|
||||
formBeanMap.put(hsDatum.getFormId(), formBean);
|
||||
}
|
||||
FormDataMasterBean masterBean = formApi4Cap4.getDataMasterBeanById(hsDatum.getMasterId(), formBean, null);
|
||||
// 转换数据
|
||||
FormDataVo formDataVo = FormDataBeanUtil.trans2FormDataVo(HsDataSyncConstants.getPluginId(), hsDatum.getFormId(),
|
||||
hsDatum.getSummaryId(), formBean, masterBean);
|
||||
String name = "";
|
||||
if ("formmain_9291".equals(tempCode)) {
|
||||
name = formDataVo.getFieldData("客户名称文本").getStringValue();
|
||||
} else {
|
||||
String userName = formDataVo.getFieldData("客户名称").getStringValue();
|
||||
System.out.println("userName:" + userName);
|
||||
V3xOrgMember member = getOrgManager().getMemberByLoginName(userName);
|
||||
name = member.getName();
|
||||
}
|
||||
System.out.println("判断名称是否为指定名称"+name);
|
||||
if(!("宜昌高新区盛世禾百货商行".equals(name)||"宜昌市西陵区高东云食品经营部".equals(name)||"宜昌市猇亭区明喜副食店".equals(name)||
|
||||
"湖北省馫昊商贸有限责任公司".equals(name)||"湖北省馫昊商贸有限责任公司".equals(name)||"宜昌梦泽涵商贸有限公司 ".equals(name))){
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("致远客户名称:" + name);
|
||||
Map userIdAndDeptId = getUserIdAndDeptId(name);
|
||||
System.out.println("人员信息:" + userIdAndDeptId.toString());
|
||||
data.put("khmc", userIdAndDeptId.get("userid"));
|
||||
data.put("fgs", userIdAndDeptId.get("deptid"));
|
||||
data.put("bt", formBean.getFormName());
|
||||
data.put("dh", formDataVo.getFieldData("流水号").getStringValue());
|
||||
data.put("sqrq", formDataVo.getFieldData("填表日期").getStringValue());
|
||||
data.put("trje", formDataVo.getFieldData("投入金额").getStringValue());
|
||||
data.put("bayj", formDataVo.getFieldData("备案意见").getStringValue());
|
||||
data.put("bajs", formDataVo.getFieldData("备案简述").getStringValue());
|
||||
data.put("ssschxsgs", formDataVo.getFieldData("分公司").getStringValue());
|
||||
data.put("jbr", formDataVo.getFieldData("经办人").getStringValue());
|
||||
data.put("lcbt", formBean.getFormName());
|
||||
|
||||
String pathId = formDataVo.getFieldData("上传附件").getStringValue();
|
||||
//附件
|
||||
JSONArray faths = null;
|
||||
if (pathId == null || "".equals(pathId)) {
|
||||
faths = new JSONArray();
|
||||
} else {
|
||||
faths = getPathUrl(pathId);
|
||||
}
|
||||
Map parm = FanWeiNewUtil.createWF2(data, faths);
|
||||
//调用新建接口
|
||||
String userId = null;
|
||||
Object userid = userIdAndDeptId.get("userid");
|
||||
if (userid == null || "".equals(userid)) {
|
||||
userId = "";
|
||||
} else {
|
||||
userId = userid.toString();
|
||||
}
|
||||
String s = FanWeiNewUtil.PostRestful(parm, userId);
|
||||
//String s = FanWeiUtil.PostRestful(parm, userId);
|
||||
System.out.println("新建推送结果" + s);
|
||||
JSONObject returnMsg = JSON.parseObject(s);
|
||||
Object code = returnMsg.get("code");
|
||||
if ("SUCCESS".equals(code.toString())) {
|
||||
System.out.println("同步成功!");
|
||||
}else {
|
||||
System.out.println("同步失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("同步失败:" + tempId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取userid和deptid
|
||||
* @param userName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Map getUserIdAndDeptId(String userName) throws Exception {
|
||||
// 新平台指定对应关系
|
||||
Map datas = new HashMap();
|
||||
if("宜昌梦泽涵商贸有限公司".equals(userName)){
|
||||
datas.put("userid", "51");
|
||||
datas.put("deptid", "1545");
|
||||
}else if ("伍家岗区源玥酒水商行".equals(userName)){
|
||||
datas.put("userid", "50");
|
||||
datas.put("deptid", "1553");
|
||||
}else if ("湖北省馫昊商贸有限责任公司".equals(userName)){
|
||||
datas.put("userid", "49");
|
||||
datas.put("deptid", "1555");
|
||||
}else if ("宜昌市猇亭区明喜副食店".equals(userName)){
|
||||
datas.put("userid", "48");
|
||||
datas.put("deptid", "1537");
|
||||
}else if ("宜昌市西陵区高东云食品经营部".equals(userName)){
|
||||
datas.put("userid", "47");
|
||||
datas.put("deptid", "1530");
|
||||
}else if ("宜昌高新区盛世禾百货商行".equals(userName)){
|
||||
datas.put("userid", "46");
|
||||
datas.put("deptid", "1529");
|
||||
}
|
||||
// Map datas = new HashMap();
|
||||
// String sql = PropKit.getProp(PropKit.SQL);
|
||||
// try(JDBCAgent agent = new JDBCAgent(true, false)) {
|
||||
// List<Object> params = new ArrayList<>();
|
||||
// params.add(userName);
|
||||
// agent.execute(sql, params);
|
||||
// List<Map<String, Object>> list = agent.resultSetToList();
|
||||
// Map<String, Object> map = list.get(0);
|
||||
// datas.put("userid", map.get("id"));
|
||||
// datas.put("deptid", map.get("departmentid"));
|
||||
// } catch (Exception e) {
|
||||
// log.error("获取模板id失败:", e);
|
||||
// }
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件路径
|
||||
* @param pathId
|
||||
* @return
|
||||
*/
|
||||
public JSONArray getPathUrl(String pathId) throws IOException {
|
||||
InterfaceListUtil interfaceListUtil = new InterfaceListUtil();
|
||||
String oatoken = interfaceListUtil.getToken(PropKit.getProp(PropKit.LOGINNAME));
|
||||
long aLong = Long.parseLong(pathId);
|
||||
final List<Long> attachmentIds = attachmentManager.getBySubReference(aLong);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 0 ; i < attachmentIds.size();i++) {
|
||||
Attachment attachment = attachmentManager.getAttachmentByFileURL(attachmentIds.get(i));
|
||||
Long fileUrl = attachment.getFileUrl();
|
||||
String filename = attachment.getFilename();
|
||||
String fileType = filename.substring(filename.lastIndexOf(".")+1);
|
||||
String oaFileName = filename.substring(0,filename.lastIndexOf("."));
|
||||
//调用接口下载文件,文件存放在指定的路径下
|
||||
String dowUrl = PropKit.getProp(PropKit.DOWURL)+"/"+fileUrl+"?fileName="+fileType+"&token="+oatoken;
|
||||
String str = SystemEnvironment.getApplicationFolder();
|
||||
String dowPath = str+"/dhxfile/"+filename;
|
||||
String download = interfaceListUtil.download(dowUrl, dowPath);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", filename);
|
||||
jsonObject.put("type", fileType);
|
||||
jsonObject.put("url", PropKit.getProp(PropKit.JYNCFILE)+"/"+filename);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.seeyon.apps.daohuaxiangSys.chushihua.vo;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: FanGaowei
|
||||
* @Date: 2023/12/8
|
||||
*/
|
||||
public class HsDataVo {
|
||||
|
||||
|
||||
private Long summaryId;
|
||||
private Long formId;
|
||||
private Long masterId;
|
||||
|
||||
public HsDataVo(Map<String, Object> row) {
|
||||
this.summaryId = Convert.toLong(row.get("id"));
|
||||
this.masterId = Convert.toLong(row.get("form_recordid"));
|
||||
this.formId = Convert.toLong(row.get("form_appid"));
|
||||
}
|
||||
|
||||
public Long getSummaryId() {
|
||||
return summaryId;
|
||||
}
|
||||
|
||||
public HsDataVo setSummaryId(Long summaryId) {
|
||||
this.summaryId = summaryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getFormId() {
|
||||
return formId;
|
||||
}
|
||||
|
||||
public HsDataVo setFormId(Long formId) {
|
||||
this.formId = formId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getMasterId() {
|
||||
return masterId;
|
||||
}
|
||||
|
||||
public HsDataVo setMasterId(Long masterId) {
|
||||
this.masterId = masterId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user