From 4bab5bae71d4d7a1da1fe48720a61297f4b3d954 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 22 Sep 2023 13:38:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=AE=89=E6=8E=92=E7=AC=94?= =?UTF-8?q?=E8=AF=95=E6=8E=A8=E7=AC=94=E8=AF=95=E7=BB=93=E6=9E=9C=EF=BC=88?= =?UTF-8?q?=E5=BB=BA=E6=A8=A1=E6=8E=A8=E5=BB=BA=E6=A8=A1=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BatchAddWrittenResultModeExpand.java | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/weaver/formmode/recruit/written/BatchAddWrittenResultModeExpand.java diff --git a/src/weaver/formmode/recruit/written/BatchAddWrittenResultModeExpand.java b/src/weaver/formmode/recruit/written/BatchAddWrittenResultModeExpand.java new file mode 100644 index 0000000..681f211 --- /dev/null +++ b/src/weaver/formmode/recruit/written/BatchAddWrittenResultModeExpand.java @@ -0,0 +1,148 @@ +package weaver.formmode.recruit.written; + +import org.apache.commons.collections.CollectionUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.soa.workflow.request.*; + +import java.util.*; + +/** + *

聚才林招聘

+ * 批量安排笔试推笔试结果 + * + * @author:dxfeng + * @createTime: 2023/09/21 + * @version: 1.0 + */ +public class BatchAddWrittenResultModeExpand extends AbstractModeExpandJavaCodeNew { + private static final String MODE_TABLE_NAME = "uf_jcl_bs"; + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + try { + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + int formModeId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? )", MODE_TABLE_NAME); + if (rs.next()) { + formModeId = rs.getInt("id"); + } + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + Map mainDataMap = new HashMap<>(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + // 填充建模数据基本信息 + mainDataMap.put("formmodeid", formModeId); + mainDataMap.put("modedatacreater", requestInfo.getCreatorid()); + String dateTime = DateUtil.getFullDate(); + String[] split = dateTime.split(" "); + mainDataMap.put("modedatacreatedate", split[0]); + mainDataMap.put("modedatacreatetime", split[1]); + mainDataMap.put("modedatamodifier", requestInfo.getCreatorid()); + mainDataMap.put("modedatamodifydatetime", dateTime); + mainDataMap.put("modedatacreatertype", "0"); + + mainDataMap.put("bsapid", requestInfo.getRequestid()); + + List> detailMapList = new ArrayList<>(); + DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); + DetailTable detailTable = detailTableInfo.getDetailTable(0); + Row[] rows = detailTable.getRow(); + for (Row row : rows) { + Map detailDataMap = new HashMap<>(mainDataMap); + Cell[] cells = row.getCell(); + for (Cell cell : cells) { + detailDataMap.put(cell.getName(), cell.getValue()); + } + detailMapList.add(detailDataMap); + } + + for (Map detailDataMap : detailMapList) { + List> paramList = new ArrayList<>(); + buildParamList(detailDataMap, paramList); + if (CollectionUtils.isNotEmpty(paramList)) { + String insertSql = "insert into " + MODE_TABLE_NAME + " (modeuuid, modedatacreatertype, formmodeid, modedatacreater, modedatacreatedate, modedatacreatetime, modedatamodifier, modedatamodifydatetime, pcid, ypz, ypzw, bsmc, bssj, bssm, tdsj, bsapid, sjh, yx ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + for (List objects : paramList) { + String uuid = UUID.randomUUID().toString(); + objects.add(0, uuid); + rs.executeUpdate(insertSql, objects); + refreshRight(rs, uuid, formModeId); + } + } + } + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } + + + /** + * 构建批量插入数据集合 + * + * @param map 表单参数 + * @param paramList 待插入数据集合 + */ + private void buildParamList(Map map, List> paramList) { + List param = new ArrayList<>(); + // 填充建模表相关字段 + param.add(map.get("modedatacreatertype")); + param.add(map.get("formmodeid")); + param.add(map.get("modedatacreater")); + param.add(map.get("modedatacreatedate")); + param.add(map.get("modedatacreatetime")); + param.add(map.get("modedatamodifier")); + param.add(map.get("modedatamodifydatetime")); + + // 表单字段 + // 批次ID + param.add(map.get("pcid")); + // 应聘者 + param.add(map.get("ypz")); + // 应聘职位 + param.add(map.get("ypzw")); + //笔试名称 + param.add(map.get("bsmc")); + // 笔试时间 + param.add(map.get("bssj")); + // 笔试说明 + param.add(map.get("bssm")); + param.add(map.get("tdsj")); + param.add(map.get("bsapid")); + param.add(map.get("sjh")); + param.add(map.get("yx")); + paramList.add(param); + } + + /** + * 权限重构 + * + * @param rs RecordSet + * @param uuid UUID + * @param formModeId 建模ID + */ + private void refreshRight(RecordSet rs, String uuid, int formModeId) { + rs.executeQuery("select id from " + MODE_TABLE_NAME + " 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); + } + } + +}