|
|
@ -1,11 +1,18 @@
|
|
|
|
package com.engine.mzg.conn;
|
|
|
|
package com.engine.mzg.conn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.mzg.entity.SyncTableField;
|
|
|
|
|
|
|
|
import com.engine.mzg.exception.CustomizeRunTimeException;
|
|
|
|
import com.engine.mzg.util.RecruitUtil;
|
|
|
|
import com.engine.mzg.util.RecruitUtil;
|
|
|
|
import com.weaver.formmodel.data.model.Formfield;
|
|
|
|
import com.weaver.formmodel.data.model.Formfield;
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
|
|
|
import weaver.formmode.IgnoreCaseHashMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author:dxfeng
|
|
|
|
* @author:dxfeng
|
|
|
@ -39,11 +46,11 @@ public class RecruitCommon {
|
|
|
|
public static String getSettingValue(String key, Map<String, Formfield> fieldMap, Map<String, Object> paramsData) {
|
|
|
|
public static String getSettingValue(String key, Map<String, Formfield> fieldMap, Map<String, Object> paramsData) {
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
rs.executeQuery("select pzz from uf_recruit_setting where pzx = ? ", key);
|
|
|
|
rs.executeQuery("select pzz from uf_recruit_setting where pzx = ? ", key);
|
|
|
|
String content= "";
|
|
|
|
String content = "";
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
|
content = rs.getString("pzz");
|
|
|
|
content = rs.getString("pzz");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(content)){
|
|
|
|
if (StringUtils.isNotBlank(content)) {
|
|
|
|
content = RecruitUtil.getMsgReplaceStr(content, fieldMap, paramsData);
|
|
|
|
content = RecruitUtil.getMsgReplaceStr(content, fieldMap, paramsData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return content;
|
|
|
|
return content;
|
|
|
@ -99,5 +106,122 @@ public class RecruitCommon {
|
|
|
|
return cancelReason;
|
|
|
|
return cancelReason;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String insertTablesData(String targetTable, String sourceTable, String sourceId, String relatedField, int creator) {
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
String mainId = "";
|
|
|
|
|
|
|
|
rs.executeQuery("select * from uf_recruit_table where target_table = ? and source_table =? ", targetTable, sourceTable);
|
|
|
|
|
|
|
|
String mainTableId = "";
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
mainTableId = rs.getString("id");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(mainTableId)) {
|
|
|
|
|
|
|
|
// 查询配置的字段,更新或者插入数据
|
|
|
|
|
|
|
|
List<SyncTableField> fields = getSyncTableFields(mainTableId);
|
|
|
|
|
|
|
|
rs.executeQuery("select * from " + sourceTable + " where id = ? ", sourceId);
|
|
|
|
|
|
|
|
IgnoreCaseHashMap<String, String> buildDataMap = new IgnoreCaseHashMap<>();
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
for (SyncTableField field : fields) {
|
|
|
|
|
|
|
|
String value = RecruitUtil.parseBlankToNull(rs.getString(field.getSourceField()));
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(value)) {
|
|
|
|
|
|
|
|
buildDataMap.put(field.getTargetField(), value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 新增
|
|
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
|
|
|
buildDataMap.put("modeuuid", uuid);
|
|
|
|
|
|
|
|
int formModeId = RecruitCommon.getModeIdByTableName(targetTable);
|
|
|
|
|
|
|
|
buildDataMap.put("formmodeid", formModeId);
|
|
|
|
|
|
|
|
// 构建建模表基本数据
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(relatedField)) {
|
|
|
|
|
|
|
|
// 设置关联字段
|
|
|
|
|
|
|
|
buildDataMap.put(relatedField, sourceId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RecruitRecordSet.buildModeInsertFields(buildDataMap, creator);
|
|
|
|
|
|
|
|
RecruitRecordSet.insertData(buildDataMap, targetTable);
|
|
|
|
|
|
|
|
mainId = String.valueOf(RecruitRecordSet.refreshRight(uuid, targetTable, formModeId, creator));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mainId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void updateTablesData(String targetTable, String sourceTable, String sourceId, String targetId, String relatedField, int creator) {
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select * from uf_recruit_table where target_table = ? and source_table =? ", targetTable, sourceTable);
|
|
|
|
|
|
|
|
String mainTableId = "";
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
mainTableId = rs.getString("id");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(mainTableId)) {
|
|
|
|
|
|
|
|
// 查询配置的字段,更新或者插入数据
|
|
|
|
|
|
|
|
List<SyncTableField> fields = getSyncTableFields(mainTableId);
|
|
|
|
|
|
|
|
rs.executeQuery("select * from " + sourceTable + " where id = ? ", sourceId);
|
|
|
|
|
|
|
|
IgnoreCaseHashMap<String, String> buildDataMap = new IgnoreCaseHashMap<>();
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
for (SyncTableField field : fields) {
|
|
|
|
|
|
|
|
String value = RecruitUtil.parseBlankToNull(rs.getString(field.getSourceField()));
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(value)) {
|
|
|
|
|
|
|
|
buildDataMap.put(field.getTargetField(), value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(relatedField)) {
|
|
|
|
|
|
|
|
// 设置关联字段
|
|
|
|
|
|
|
|
buildDataMap.put(relatedField, sourceId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 更新
|
|
|
|
|
|
|
|
buildDataMap.put("id", targetId);
|
|
|
|
|
|
|
|
RecruitRecordSet.buildModeUpdateFields(buildDataMap, creator);
|
|
|
|
|
|
|
|
RecruitRecordSet.updateDataById(buildDataMap, targetTable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void syncDetailTablesData(String targetTable, String sourceTable, String sourceId, RecordSet rs, String mainId) {
|
|
|
|
|
|
|
|
IgnoreCaseHashMap<String, String> buildDataMap;
|
|
|
|
|
|
|
|
String mainTableId;
|
|
|
|
|
|
|
|
rs.executeQuery("select * from uf_recruit_table where source_table like '" + sourceTable + "_dt%' and target_table like '" + targetTable + "_dt%' ");
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
mainTableId = rs.getString("id");
|
|
|
|
|
|
|
|
String sourceDetailTable = rs.getString("source_table");
|
|
|
|
|
|
|
|
String targetDetailTable = rs.getString("target_table");
|
|
|
|
|
|
|
|
List<SyncTableField> syncTableFields = getSyncTableFields(mainTableId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 删除明细表数据
|
|
|
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
|
|
|
recordSet.executeUpdate(" delete from " + targetDetailTable + " where mainid = ?", mainId);
|
|
|
|
|
|
|
|
recordSet.executeQuery("select * from " + sourceDetailTable + " where mainid = ? ", sourceId);
|
|
|
|
|
|
|
|
while (recordSet.next()) {
|
|
|
|
|
|
|
|
buildDataMap = new IgnoreCaseHashMap<>();
|
|
|
|
|
|
|
|
buildDataMap.put("mainid", mainId);
|
|
|
|
|
|
|
|
for (SyncTableField field : syncTableFields) {
|
|
|
|
|
|
|
|
String value = RecruitUtil.parseBlankToNull(recordSet.getString(field.getSourceField()));
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(value)) {
|
|
|
|
|
|
|
|
buildDataMap.put(field.getTargetField(), value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RecruitRecordSet.insertData(buildDataMap, targetDetailTable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取配置的需要同步的字段集合
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mainTableId
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static List<SyncTableField> getSyncTableFields(String mainTableId) {
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
rs.executeQuery("select * from uf_recruit_table_dt1 where mainid = ? ", mainTableId);
|
|
|
|
|
|
|
|
List<SyncTableField> fields = new ArrayList<>();
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
fields.add(SyncTableField.builder().sourceField(rs.getString("source_field")).targetField(rs.getString("target_field")).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fields)) {
|
|
|
|
|
|
|
|
throw new CustomizeRunTimeException("数据同步配置异常,请检查配置");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fields;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|