2023-10-19 18:13:58 +08:00
|
|
|
package com.engine.recruit.conn;
|
|
|
|
|
|
2023-10-24 17:41:46 +08:00
|
|
|
import com.engine.recruit.exception.CustomizeRunTimeException;
|
2023-10-19 18:13:58 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-10-20 09:46:18 +08:00
|
|
|
import weaver.common.DateUtil;
|
2023-10-19 18:13:58 +08:00
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil;
|
2023-10-24 15:26:07 +08:00
|
|
|
import weaver.formmode.setup.ModeRightInfo;
|
|
|
|
|
import weaver.general.Util;
|
2023-10-19 18:13:58 +08:00
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author:dxfeng
|
|
|
|
|
* @createTime: 2023/10/19
|
|
|
|
|
* @version: 1.0
|
|
|
|
|
*/
|
|
|
|
|
public class RecruitRecordSet {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取单个记录映射
|
|
|
|
|
*
|
|
|
|
|
* @param rs RecordSet
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static Map<String, Object> getSingleRecordMap(RecordSet rs) {
|
|
|
|
|
Map<String, Object> dataMap = new RecruitDataMap<>();
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
String[] columnNames = rs.getColumnName();
|
|
|
|
|
for (String columnName : columnNames) {
|
|
|
|
|
dataMap.put(columnName.toLowerCase(), RecruitModeUtil.parseBlankToNull(rs.getString(columnName)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return dataMap;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-27 09:27:47 +08:00
|
|
|
public static List<Map<String, Object>> getRecordMapList(RecordSet rs) {
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String[] columnNames = rs.getColumnName();
|
|
|
|
|
Map<String, Object> dataMap = new RecruitDataMap<>();
|
|
|
|
|
for (String columnName : columnNames) {
|
|
|
|
|
dataMap.put(columnName.toLowerCase(), RecruitModeUtil.parseBlankToNull(rs.getString(columnName)));
|
|
|
|
|
}
|
|
|
|
|
list.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 18:13:58 +08:00
|
|
|
/**
|
|
|
|
|
* 插入数据
|
|
|
|
|
*
|
|
|
|
|
* @param dataMap 数据集合
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
*/
|
|
|
|
|
public static void insertData(Map<String, Object> dataMap, String tableName) {
|
|
|
|
|
List<String> fieldList = new ArrayList<>();
|
|
|
|
|
List<Object> dataList = new ArrayList<>();
|
|
|
|
|
List<String> paramList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
dataMap.forEach((key, value) -> {
|
|
|
|
|
fieldList.add(key);
|
|
|
|
|
dataList.add(value);
|
|
|
|
|
paramList.add("?");
|
|
|
|
|
});
|
|
|
|
|
String insertSql = " insert into " + tableName + "(" + StringUtils.join(fieldList, ",") + ") values (" + StringUtils.join(paramList, ",") + ")";
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeUpdate(insertSql, dataList);
|
2023-10-24 17:41:46 +08:00
|
|
|
if (StringUtils.isNotBlank(rs.getExceptionMsg())) {
|
|
|
|
|
throw new CustomizeRunTimeException(rs.getExceptionMsg());
|
|
|
|
|
}
|
2023-10-19 18:13:58 +08:00
|
|
|
}
|
|
|
|
|
|
2023-10-27 09:27:47 +08:00
|
|
|
/**
|
|
|
|
|
* 根据ID更新数据
|
|
|
|
|
*
|
|
|
|
|
* @param dataMap
|
|
|
|
|
* @param tableName
|
|
|
|
|
*/
|
|
|
|
|
public static void updateDataById(Map<String, Object> dataMap, String tableName) {
|
|
|
|
|
List<String> fieldList = new ArrayList<>();
|
|
|
|
|
List<Object> dataList = new ArrayList<>();
|
|
|
|
|
List<String> paramList = new ArrayList<>();
|
|
|
|
|
String id = Util.null2String(dataMap.get("id"));
|
|
|
|
|
dataMap.remove("id");
|
|
|
|
|
|
|
|
|
|
dataMap.forEach((key, value) -> {
|
|
|
|
|
fieldList.add(key + " = ? ");
|
|
|
|
|
dataList.add(value);
|
|
|
|
|
paramList.add("?");
|
|
|
|
|
});
|
|
|
|
|
dataList.add(id);
|
|
|
|
|
String updateSql = "update " + tableName + " set " + StringUtils.join(fieldList, ",") + " where id = ? ";
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeUpdate(updateSql, dataList);
|
|
|
|
|
if (StringUtils.isNotBlank(rs.getExceptionMsg())) {
|
|
|
|
|
throw new CustomizeRunTimeException(rs.getExceptionMsg());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-20 09:46:18 +08:00
|
|
|
/**
|
|
|
|
|
* 构建建模表基本数据
|
|
|
|
|
*
|
|
|
|
|
* @param mainDataMap 参数集合
|
|
|
|
|
*/
|
2023-10-27 09:27:47 +08:00
|
|
|
public static void buildModeBaseFields(Map<String, Object> mainDataMap, int userId) {
|
2023-10-20 09:46:18 +08:00
|
|
|
String dateTime = DateUtil.getFullDate();
|
|
|
|
|
String[] dateSplit = dateTime.split(" ");
|
|
|
|
|
mainDataMap.put("modedatacreater", userId);
|
|
|
|
|
mainDataMap.put("modedatacreatedate", dateSplit[0]);
|
|
|
|
|
mainDataMap.put("modedatacreatetime", dateSplit[1]);
|
|
|
|
|
mainDataMap.put("modedatamodifier", userId);
|
|
|
|
|
mainDataMap.put("modedatamodifydatetime", dateTime);
|
|
|
|
|
mainDataMap.put("modedatacreatertype", "0");
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-24 15:26:07 +08:00
|
|
|
/**
|
|
|
|
|
* 建模表数据权限重构
|
|
|
|
|
*
|
|
|
|
|
* @param uuid
|
|
|
|
|
* @param modeTable
|
|
|
|
|
* @param formModeId
|
|
|
|
|
*/
|
|
|
|
|
public static int refreshRight(String uuid, String modeTable, int formModeId) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery("select id from " + modeTable + " where modeuuid='" + uuid + "'");
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
//建模数据的id
|
|
|
|
|
int bid = Util.getIntValue(rs.getString("id"));
|
|
|
|
|
ModeRightInfo modeRightInfo = new ModeRightInfo();
|
|
|
|
|
modeRightInfo.setNewRight(true);
|
|
|
|
|
//新建的时候添加共享
|
|
|
|
|
modeRightInfo.editModeDataShare(1, formModeId, bid);
|
|
|
|
|
return bid;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 18:13:58 +08:00
|
|
|
}
|