Commit 0de5a647 by 宋祥

1.工具类增加,批量新增

parent 99e0b22f
......@@ -12,7 +12,9 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -57,7 +59,38 @@ public class DaoUtils {
}
DaoBase.getInstance().insert(sql, obj);
}
/**
* insertBatch method.
*
* @param sql
* @param rows
*/
public static void batchInsert(String sql, List rows) {
// 创建人部门
List<String> orgIds = UserSessionUtils.getOrgId();
AssertUtils.isEmpty(orgIds, "当前用户未绑定部门,无法操作数据,请联系管理员!");
String depCode = orgIds.get(0);
for (Object row : rows) {
if (row instanceof DaoEPBase) {
DaoEPBase daoEPBase = (DaoEPBase) row;
try {
BeanUtils.setProperty(daoEPBase, "depCode", depCode);
} catch (Exception e) {
log.warn("写入创建人部门编码失败", e);
}
setCreator(daoEPBase);
} else if (row instanceof Map) {
Map map = (Map) row;
map.put("depCode", depCode);
setCreator(map);
}
}
Map paramMap = new HashMap();
paramMap.put("rows", rows);
DaoBase.getInstance().insert(sql, paramMap);
}
/**
* update method.
*
......@@ -106,7 +139,7 @@ public class DaoUtils {
});
return DaoBase.getInstance().insertBatch(sql, parameters);
}
/**
* 创建人工号 创建人姓名 创建人岗号 创建时刻
*
......
......@@ -124,11 +124,12 @@ public class ServiceXS3201B extends ServiceEPBase {
dbMainAuth.put("subjectId", groupId);
dbMainAuth.put("recCreator", UserSessionUtils.getLoginName());
dbMainAuth.put("recCreateTime", DateUtils.shortDateTime());
dbMainAuth.put("archiveFlag", 0);
dbMainAuth.put("sortIndex", 0);
return dbMainAuth;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(filterAuths)) {
DaoUtils.insertBatch("XS07.insert", filterAuths);
DaoUtils.batchInsert("XS07.batchInsert", filterAuths);
}
}
}
......
......@@ -30,6 +30,18 @@
)
</insert>
<insert id="batchInsert">
INSERT INTO ${platSchema}.XS_AUTHORIZATION (
SUBJECT_ID, SUBJECT_TYPE, OBJECT_ID, OBJECT_TYPE, OPERATION_TYPE, REC_CREATOR,
REC_CREATE_TIME, ARCHIVE_FLAG, SORT_INDEX
) VALUES
<iterate open="(" conjunction="), (" close=")" property="rows">
#rows[].subjectId#, #rows[].subjectType#, #rows[].objectId#, #rows[].objectType#,
#rows[].operationType#, #rows[].recCreator#, #rows[].recCreateTime#,
#rows[].archiveFlag#, #rows[].sortIndex#
</iterate>
</insert>
<select id="authorizationExists" resultClass="java.util.HashMap">
SELECT * FROM ${platSchema}.XS_AUTHORIZATION
WHERE 1=1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment