//获取流程模板编号 String templateCode = event.getTemplateCode(); log.info("进入流程结束事件 --> 表单编号为 " + templateCode); FormBean formBean = formApi4Cap4.getFormByFormCode(templateCode); String tableName = formBean.getMasterTableBean().getTableName(); Long masterId = affair.getFormRecordid(); FormDataMasterBean dataMasterBeanById = formApi4Cap4.getDataMasterBeanById(masterId, formBean, null); String allDataJSONString = dataMasterBeanById.getAllDataJSONString(); JSONObject jsonObject = JSONObject.parseObject(allDataJSONString); JSONObject masterJson=new JSONObject(new LinkedHashMap()); JSONObject infoJson=new JSONObject(new LinkedHashMap()); Map<String,Object> maps=(Map<String, Object>) jsonObject.get(tableName); String serialNum = FormCommonUtils.getFieldName(formBean, "流水号"); masterJson.put("serialNum",maps.get(serialNum)); String shipperOrg = FormCommonUtils.getFieldName(formBean, "所属单位"); masterJson.put("shipperOrg",maps.get(shipperOrg)); String DocType = FormCommonUtils.getFieldName(formBean, "单据类型"); masterJson.put("DocType",maps.get(DocType)); System.out.println(masterJson);给这段代码添加注释
时间: 2024-04-25 19:27:26 浏览: 134
```
// 获取流程模板编号
String templateCode = event.getTemplateCode();
log.info("进入流程结束事件 --> 表单编号为 " + templateCode);
// 根据表单编号获取表单信息
FormBean formBean = formApi4Cap4.getFormByFormCode(templateCode);
String tableName = formBean.getMasterTableBean().getTableName();
// 获取流程表单主记录ID,并根据ID获取表单数据
Long masterId = affair.getFormRecordid();
FormDataMasterBean dataMasterBeanById = formApi4Cap4.getDataMasterBeanById(masterId, formBean, null);
String allDataJSONString = dataMasterBeanById.getAllDataJSONString();
JSONObject jsonObject = JSONObject.parseObject(allDataJSONString);
// 根据表名获取表单主记录的JSON对象
JSONObject masterJson = new JSONObject(new LinkedHashMap());
JSONObject infoJson = new JSONObject(new LinkedHashMap());
Map<String,Object> maps = (Map<String, Object>) jsonObject.get(tableName);
// 获取表单中的流水号、所属单位、单据类型等信息,并存入 masterJson 对象中
String serialNum = FormCommonUtils.getFieldName(formBean, "流水号");
masterJson.put("serialNum",maps.get(serialNum));
String shipperOrg = FormCommonUtils.getFieldName(formBean, "所属单位");
masterJson.put("shipperOrg",maps.get(shipperOrg));
String DocType = FormCommonUtils.getFieldName(formBean, "单据类型");
masterJson.put("DocType",maps.get(DocType));
// 输出 masterJson 对象
System.out.println(masterJson);
```
这段代码的作用是从一个表单记录中提取出流水号、所属单位、单据类型等信息,并将其存入 `masterJson` 对象中。具体的注释已经加在代码中了。
阅读全文