| | |
| | | package com.product.administration.service; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.google.common.collect.Sets; |
| | | import com.product.administration.config.SystemCode; |
| | | import com.product.common.collect.SetUtils; |
| | | import com.product.util.SystemParamReplace; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.product.administration.config.CmnConst; |
| | |
| | | BaseDao baseDao; |
| | | |
| | | @Autowired |
| | | private ApplicationContext applicationContext; |
| | | |
| | | @Autowired |
| | | FlowService flowService; |
| | | |
| | | |
| | | |
| | | public BaseDao getBaseDao() { |
| | | return baseDao; |
| | |
| | | |
| | | /** |
| | | * 预警-给定uuid单个预警,通常为定时任务触发 |
| | | * |
| | | * @param uuid |
| | | */ |
| | | public void triggerSingleWarningTask(String uuid) { |
| | |
| | | } |
| | | singleWarningTask(fseWarningConfig); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | SpringMVCContextHolder.getSystemLogger().error(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 特殊预警 |
| | | * 预警数据来源于其它业务(对象方法调用),验证条件来源于其它业务(bean调用) |
| | | * 数据替换依然来源于配置表 |
| | | * |
| | | * @param configUuid |
| | | * @param dtService 预警的业务数据,关联设备数据 |
| | | */ |
| | | public void warningCreate(String configUuid, DataTableEntity dtServiceData, Map<String, String> mapFields) { |
| | | |
| | | FieldSetEntity fseWarningConfig = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_EARLY_WARNING, configUuid, false); |
| | | if (!"1".equals(fseWarningConfig.getString(CmnConst.CONFIG_STATUS))) { |
| | | throw new BaseException(SystemCode.WARN_NO_NORMAL_STATUS_RECORD); |
| | | } |
| | | String mainTableName = fseWarningConfig.getString(CmnConst.SOURCE_TABLE); //主表名 |
| | | |
| | | String warnContent = fseWarningConfig.getString(CmnConst.WARNING_CONTENT_HIDE); //提醒内容 |
| | | String warnMethod = fseWarningConfig.getString(CmnConst.WARNING_METHOD); //预警方式 |
| | | |
| | | String serviceReceiver = fseWarningConfig.getString(CmnConst.BUSINESS_RELATED_PERSON); //业务相关人员(表名.字段名) |
| | | String fixedReceiver = fseWarningConfig.getString(CmnConst.FIXED_RECEIVER); //固定接收人 |
| | | |
| | | //获取发送消息频率 |
| | | Double cronExpression = fseWarningConfig.getDouble("reminder_frequency"); |
| | | |
| | | //发送消息的频率 1.23 小数点前面代表天 小数点后面代表小时 |
| | | double seconds = 0; |
| | | if (cronExpression != null && cronExpression > 0) { |
| | | //将发送消息频率转换为小时 |
| | | double hours = cronExpression * 24; |
| | | //将发送消息频率转换为分钟 |
| | | double minutes = hours * 60; |
| | | //将发送消息频率转换为秒 |
| | | seconds = minutes * 60; |
| | | } |
| | | |
| | | Map<String, String> tableNameAndAlias = new HashMap<>();//相关表名-->表别名,tableName-->tableName1 |
| | | Map<String, String> fieldAndAlias = new HashMap<>(); //相关字段-->字段别名,tableName.fieldName-->tableName1fieldName |
| | | Map<String, String> fieldReference = new HashMap<>(); //组合相关字段的参照,tableName1fieldName-->referenceName |
| | | StringBuilder concatField = new StringBuilder(); //组合相关字段,tableName1.fieldName tableName1fieldName |
| | | //解析业务相关人员 |
| | | if (!StringUtils.isEmpty(serviceReceiver)) { |
| | | parseWarningContent(serviceReceiver, concatField, tableNameAndAlias, fieldAndAlias, fieldReference); |
| | | } |
| | | //解析预警内容 |
| | | if (!StringUtils.isEmpty(warnContent)) { |
| | | parseWarningContent(warnContent, concatField, tableNameAndAlias, fieldAndAlias, fieldReference); |
| | | } |
| | | |
| | | DataTableEntity dtParmFault = null; |
| | | String beanAndMehtod = fseWarningConfig.getString("bean"); |
| | | Object bean = applicationContext.getBean(beanAndMehtod.split("\\.")[0]); |
| | | try { |
| | | Method method = bean.getClass().getMethod(beanAndMehtod.split("\\.")[1], DataTableEntity.class, Map.class); |
| | | dtParmFault = (DataTableEntity)method.invoke(bean, dtServiceData, mapFields); |
| | | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { |
| | | e.printStackTrace(); |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } catch (SecurityException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (!BaseUtil.dataTableIsEmpty(dtParmFault)) { |
| | | // 获取相关设备历史最新预警 |
| | | Object[] limitParam = dtParmFault.getFieldAllValues("unique_key"); |
| | | StringBuilder sqlWarnHistory = new StringBuilder(); |
| | | sqlWarnHistory.append("SELECT e.* \n"); |
| | | sqlWarnHistory.append("FROM product_sys_early_warning_info e \n"); |
| | | sqlWarnHistory.append("JOIN ( \n"); |
| | | sqlWarnHistory.append(" SELECT data_uuid, MAX(early_warning_datetime) AS latest_datetime \n"); |
| | | sqlWarnHistory.append(" FROM product_sys_early_warning_info "); |
| | | sqlWarnHistory.append(" WHERE early_warning_uuid=? and (").append(BaseUtil.buildQuestionMarkFilter("data_uuid", limitParam, true)).append(") \n"); |
| | | sqlWarnHistory.append(" GROUP BY data_uuid \n"); |
| | | sqlWarnHistory.append(") AS latest ON e.data_uuid = latest.data_uuid AND e.early_warning_datetime = latest.latest_datetime"); |
| | | DataTableEntity dtLastWarn = baseDao.listTable(sqlWarnHistory.toString(), new Object[] {configUuid}); |
| | | Map<String, FieldSetEntity> mapLastWarn = new HashMap<>(); |
| | | if (!DataTableEntity.isEmpty(dtLastWarn)) { |
| | | for (int j = 0; j < dtLastWarn.getRows(); j++) { |
| | | FieldSetEntity fse = dtLastWarn.getFieldSetEntity(j); |
| | | mapLastWarn.put(fse.getString("data_uuid"), fse); |
| | | } |
| | | } |
| | | // 遍历预警数据 |
| | | for (int j = 0; j < dtParmFault.getRows(); j++) { |
| | | FieldSetEntity fseParamFault = dtParmFault.getFieldSetEntity(j); |
| | | String deviceUUID = fseParamFault.getString(mapFields.get("device_code_field")); |
| | | String paramType = fseParamFault.getString(mapFields.get("param_type_field")); |
| | | String faultGrade = fseParamFault.getString("fault_grade_uuid"); |
| | | |
| | | // 业务uuid(该数据特指:设备,参数) |
| | | String uniqueKey = fseParamFault.getString("unique_key"); |
| | | |
| | | // 判断是否预警 |
| | | if (mapLastWarn.containsKey(uniqueKey) && !StringUtils.isEmpty(cronExpression)) { |
| | | //如果已经存在预警信息 根据cron表达式判断是否需要再次预警 |
| | | Date lastWarnTime = mapLastWarn.get(uniqueKey).getDate("early_warning_datetime"); |
| | | if (lastWarnTime != null) { |
| | | long time = new Date().getTime() - lastWarnTime.getTime(); |
| | | if (time < seconds * 1000) { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 获取视图数据 |
| | | StringBuilder sqlData = new StringBuilder(); |
| | | sqlData.append("SELECT ").append(concatField.subSequence(1, concatField.length())).append(" \n"); |
| | | sqlData.append("FROM ").append(mainTableName).append(" " + tableNameAndAlias.get(mainTableName)).append(" \n"); |
| | | sqlData.append("WHERE ").append("device_number = ? AND param_config_uuid = ? AND uuid = ?"); |
| | | FieldSetEntity fseService = baseDao.getFieldSetEntityBySQL(sqlData.toString(), |
| | | new Object[] {deviceUUID, paramType, faultGrade}, false); |
| | | |
| | | //信息接收人 |
| | | Set<String> receiverSet = Sets.newTreeSet(); |
| | | |
| | | //装载业务接收人 |
| | | String tempStr; |
| | | if (!StringUtils.isEmpty(serviceReceiver)) { |
| | | String[] splitReceiver = serviceReceiver.replace("{#", "").replace("#}", "").split(","); |
| | | for (int k = 0; k < splitReceiver.length; k++) { |
| | | tempStr = fseService.getString(fieldAndAlias.get(splitReceiver[k])); |
| | | if (!StringUtils.isEmpty(tempStr)) { |
| | | for (String singlePerson : tempStr.split(",")) { |
| | | receiverSet.add(singlePerson); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 若是勾选了直属领导,那么一并添加上 6c 2022年3月22日 09:25:43 |
| | | if ("1".equals(fseWarningConfig.getString(CmnConst.DIRECT_LEADER_FLAG)) && !receiverSet.isEmpty()) { |
| | | StringBuilder directLeaderSql = new StringBuilder(256); |
| | | directLeaderSql.append("SELECT l.user_id,l.show_name,l.direct_leader_code,l.tricode \n"); |
| | | directLeaderSql.append("FROM product_sys_staffs l \n"); |
| | | directLeaderSql.append("INNER JOIN ( \n"); |
| | | directLeaderSql.append(" SELECT user_id,show_name,direct_leader_code,tricode \n"); |
| | | directLeaderSql.append(" FROM product_sys_staffs \n"); |
| | | directLeaderSql.append(" WHERE ").append(BaseUtil.buildQuestionMarkFilter("user_id", receiverSet.size(), true)); |
| | | directLeaderSql.append("\n) p ON l.tricode=p.direct_leader_code"); |
| | | DataTableEntity directLeaderDte = baseDao.listTable(directLeaderSql.toString(), receiverSet.toArray()); |
| | | FieldSetEntity directLeaderFse; |
| | | for (int k = 0; k < directLeaderDte.getRows(); k++) { |
| | | directLeaderFse = directLeaderDte.getFieldSetEntity(k); |
| | | receiverSet.add(directLeaderFse.getString(CmnConst.USER_ID)); |
| | | } |
| | | } |
| | | |
| | | //装载固定接收人 |
| | | if (!StringUtils.isEmpty(fixedReceiver)) { |
| | | String[] splitReceiver = fixedReceiver.split(","); |
| | | for (int k = 0; k < splitReceiver.length; k++) { |
| | | FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?", new Object[]{splitReceiver[k]}, false); |
| | | receiverSet.add(fseStaff.getString(CmnConst.USER_ID)); |
| | | } |
| | | } |
| | | |
| | | //暂时替换提醒内容 |
| | | warnContent = SystemParamReplace.replaceParams(warnContent, fseService); |
| | | String content = getContentByTableSource(fseService, warnContent, fieldReference); |
| | | // content = content.replace("【参数值】", fseParamFault.getString(fseParamFault.getString("target_value_field"))); |
| | | |
| | | String allReceiver = SetUtils.set2String(receiverSet, ","); |
| | | |
| | | //自动生成预警日志信息 |
| | | FieldSetEntity fseWarnLog = new FieldSetEntity(CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO); |
| | | fseWarnLog.setValue(CmnConst.EARLY_WARNING_DATETIME, new Date()); |
| | | fseWarnLog.setValue(CmnConst.EARLY_WARNING_UUID, configUuid); |
| | | fseWarnLog.setValue(CmnConst.DATA_UUID, uniqueKey); |
| | | // fse.setValue(CmnConst.DATA_UUID, serviceId); |
| | | fseWarnLog.setValue(CmnConst.WARNING_CONTENT, content); |
| | | fseWarnLog.setValue(CmnConst.RECEIVER, allReceiver); |
| | | fseWarnLog.setValue(CmnConst.WARNING_METHOD, warnMethod); |
| | | baseDao.add(fseWarnLog); |
| | | |
| | | //发送信息 |
| | | if (!StringUtils.isEmpty(warnMethod)) { |
| | | String[] send_method = warnMethod.split(","); |
| | | for (int k = 0; k < send_method.length; k++) { |
| | | if ("1".equals(send_method[k])) { //系统消息 |
| | | WebsocketMesssageServiceThread.getInstance().appendMessage(allReceiver, content, "预警消息", 1, "31", CmnConst.BUTTON_URL_WARN_MESSAGE_INFO + "?uuid=" + fseWarnLog.getUUID(), CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, fseWarnLog.getUUID(), 1, 0, 0); |
| | | } else if ("2".equals(send_method[k])) { //电子邮件 |
| | | parseMail(content, allReceiver); |
| | | } else if ("3".equals(send_method[k])) { //短信消息 |
| | | parseSMS(content, allReceiver); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 单个预警 |
| | | * |
| | | * @param fseWarningConfig |
| | | */ |
| | | private void singleWarningTask(FieldSetEntity fseWarningConfig) { |
| | |
| | | |
| | | String flowCode = fseWarningConfig.getString(CmnConst.FLOW_CODE); //流程type_code |
| | | String flowParam = fseWarningConfig.getString(CmnConst.FLOW_PARAM); //流程参数转换 |
| | | |
| | | //获取发送消息频率 |
| | | Double cronExpression = fseWarningConfig.getDouble("reminder_frequency"); |
| | | |
| | | //发送消息的频率 1.23 小数点前面代表天 小数点后面代表小时 |
| | | double seconds = 0; |
| | | if (cronExpression != null && cronExpression > 0) { |
| | | |
| | | //将发送消息频率转换为小时 |
| | | double hours = cronExpression * 24; |
| | | //将发送消息频率转换为分钟 |
| | | double minutes = hours * 60; |
| | | //将发送消息频率转换为秒 |
| | | seconds = minutes * 60; |
| | | } |
| | | |
| | | |
| | | Map<String, String> tableNameAndAlias = new HashMap<>(); //相关表名-->表别名,tableName-->tableName1 |
| | | Map<String, String> fieldAndAlias = new HashMap<>(); //相关字段-->字段别名,tableName.fieldName-->tableName1fieldName |
| | |
| | | //查询符合预警的数据 |
| | | DataTableEntity dtService = baseDao.listTable(serviceSQL.toString(), new Object[]{}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtService)) { |
| | | Object[] serviceCollect = dtService.getFieldAllValues(mainTableAlias + "uuid"); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | //查询是否已经存在预警如有相同data_uuid的数据查询出最近的一条根据预警时间字段 early_warning_datetime |
| | | sql.append("SELECT e.* \n"); |
| | | sql.append("FROM product_sys_early_warning_info e \n"); |
| | | sql.append("JOIN ( \n"); |
| | | sql.append(" SELECT data_uuid, MAX(early_warning_datetime) AS latest_datetime \n"); |
| | | sql.append(" FROM product_sys_early_warning_info \n"); |
| | | sql.append(" WHERE early_warning_uuid=? and (").append(BaseUtil.buildQuestionMarkFilter("data_uuid", serviceCollect, true)).append(") \n"); |
| | | sql.append(" GROUP BY data_uuid \n"); |
| | | sql.append(") AS latest ON e.data_uuid = latest.data_uuid AND e.early_warning_datetime = latest.latest_datetime"); |
| | | DataTableEntity dtLastWarn = baseDao.listTable(sql.toString(), new Object[] {fseWarningConfig.getUUID()}); |
| | | |
| | | Map<String, FieldSetEntity> mapListWarn = new HashMap<>(); |
| | | if (!DataTableEntity.isEmpty(dtLastWarn)) { |
| | | for (int j = 0; j < dtLastWarn.getRows(); j++) { |
| | | FieldSetEntity fse = dtLastWarn.getFieldSetEntity(j); |
| | | mapListWarn.put(fse.getString("data_uuid"), fse); |
| | | } |
| | | } |
| | | |
| | | //以data_uuid 进行分组 |
| | | for (int j = 0; j < dtService.getRows(); j++) { |
| | | FieldSetEntity fseService = dtService.getFieldSetEntity(j); |
| | | |
| | | //业务uuid |
| | | String serviceId = fseService.getString(mainTableAlias + "uuid"); |
| | | //预警uuid |
| | | String warnUUID = fseWarningConfig.getUUID(); |
| | | if (mapListWarn.containsKey(serviceId) && !StringUtils.isEmpty(cronExpression)) { |
| | | //如果已经存在预警信息 根据cron表达式判断是否需要再次预警 |
| | | Date preTime = mapListWarn.get(serviceId).getDate("early_warning_datetime"); |
| | | if (preTime != null) { |
| | | long time = new Date().getTime() - preTime.getTime(); |
| | | if (time < seconds * 1000) { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //信息接收人 |
| | | Set<String> receiverSet = Sets.newTreeSet(); |
| | |
| | | |
| | | //装载固定接收人 |
| | | if (!StringUtils.isEmpty(fixedReceiver)) { |
| | | FieldSetEntity fseOrgnaiztion = baseDao.getFieldSetEntity("product_sys_organizational_structure_storage", fixedReceiver, false); |
| | | if (!StringUtils.isEmpty(fseOrgnaiztion.getString("staff_ids"))) { |
| | | String[] splitReceiver = fseOrgnaiztion.getString("staff_ids").split(","); |
| | | // FieldSetEntity fseOrgnaiztion = baseDao.getFieldSetEntity("product_sys_organizational_structure_storage", fixedReceiver, false); |
| | | // if (!StringUtils.isEmpty(fseOrgnaiztion.getString("staff_ids"))) { |
| | | // String[] splitReceiver = fseOrgnaiztion.getString("staff_ids").split(","); |
| | | String[] splitReceiver = fixedReceiver.split(","); |
| | | for (int k = 0; k < splitReceiver.length; k++) { |
| | | FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "staff_id=?", new Object[]{splitReceiver[k]}, false); |
| | | receiverSet.add(fseStaff.getString(CmnConst.USER_ID)); |
| | | // FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "staff_id=?", new Object[]{splitReceiver[k]}, false); |
| | | // receiverSet.add(fseStaff.getString(CmnConst.USER_ID)); |
| | | receiverSet.add(splitReceiver[k]); |
| | | } |
| | | } |
| | | // } |
| | | } |
| | | |
| | | //装载流程相关人 |
| | |
| | | FieldSetEntity fse = new FieldSetEntity(); |
| | | fse.setTableName(CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO); |
| | | fse.setValue(CmnConst.EARLY_WARNING_DATETIME, new Date()); |
| | | fse.setValue(CmnConst.EARLY_WARNING_UUID, warnUUID); |
| | | fse.setValue(CmnConst.EARLY_WARNING_UUID, fseWarningConfig.getUUID()); |
| | | fse.setValue(CmnConst.DATA_UUID, serviceId); |
| | | fse.setValue(CmnConst.WARNING_CONTENT, content); |
| | | fse.setValue(CmnConst.RECEIVER, allReceiver); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据提醒内容中的表属性,进行拼接成标准格式 |
| | | * @param content 预警内容 |
| | | * @param concatField 组合字段 |
| | | * @param tableNameAndAlias 表名及别名 |
| | | * @param fieldAndAlias 字段名及别名 |
| | | * @param fieldReference 字段及参照 |
| | | * 根据提醒内容中的表属性,进行拼接成标准格式 |
| | | * |
| | | * @param content 预警内容 |
| | | * @param concatField 组合字段 |
| | | * @param tableNameAndAlias 表名及别名 |
| | | * @param fieldAndAlias 字段名及别名 |
| | | * @param fieldReference 字段及参照 |
| | | * @return |
| | | */ |
| | | public Object[] parseWarningContent(String warnContent, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String>fieldAndAlias, Map<String, String> fieldReference) { |
| | | public Object[] parseWarningContent(String warnContent, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String> fieldAndAlias, Map<String, String> fieldReference) { |
| | | int s = 0; |
| | | String tableAndField=null; |
| | | String tableAndField = null; |
| | | while (s >= 0) { |
| | | int c = warnContent.indexOf("{#", s); |
| | | if (c == -1) { |
| | | concatField.append(" uuid "); |
| | | concatField.append(", uuid "); |
| | | break; |
| | | } |
| | | int m = warnContent.indexOf("#}", c); |
| | | s = c + 2; |
| | | |
| | | |
| | | //表名.字段名 |
| | | tableAndField=warnContent.substring(s, m); |
| | | |
| | | tableAndField = warnContent.substring(s, m); |
| | | |
| | | //获取表名 |
| | | String relationTable=tableAndField.split("\\.")[0]; |
| | | String relationTable = tableAndField.split("\\.")[0]; |
| | | //表别名 |
| | | String relationTableAlias=relationTable+"1"; |
| | | String relationTableAlias = relationTable + "1"; |
| | | //字段名 |
| | | String fieldName=tableAndField.split("\\.")[1]; |
| | | |
| | | if (tableNameAndAlias.get(relationTable)==null) { |
| | | String fieldName = tableAndField.split("\\.")[1]; |
| | | |
| | | if (tableNameAndAlias.get(relationTable) == null) { |
| | | concatField.append(","); |
| | | concatField.append(relationTableAlias); |
| | | concatField.append(".uuid "); |
| | | concatField.append(relationTableAlias); |
| | | concatField.append("uuid"); |
| | | fieldAndAlias.put(relationTable+".uuid", relationTable+"1uuid"); |
| | | fieldAndAlias.put(relationTable + ".uuid", relationTable + "1uuid"); |
| | | tableNameAndAlias.put(relationTable, relationTableAlias); |
| | | } |
| | | |
| | | |
| | | //生成字段别名-->表名1字段名 |
| | | String tableFieldAlias=tableAndField.replace(".", "1"); |
| | | |
| | | if (fieldAndAlias.get(tableAndField)==null) { |
| | | fieldAndAlias.put(tableAndField,tableFieldAlias); |
| | | String tableFieldAlias = tableAndField.replace(".", "1"); |
| | | |
| | | if (fieldAndAlias.get(tableAndField) == null) { |
| | | fieldAndAlias.put(tableAndField, tableFieldAlias); |
| | | concatField.append(","); |
| | | concatField.append(relationTableAlias+"."+fieldName); |
| | | concatField.append(relationTableAlias + "." + fieldName); |
| | | concatField.append(" "); |
| | | concatField.append(tableFieldAlias); |
| | | fieldReference.put(tableFieldAlias, getReferenceByField(tableAndField)); |
| | | } |
| | | } |
| | | return new Object[]{concatField,tableNameAndAlias,fieldAndAlias,fieldReference}; |
| | | return new Object[]{concatField, tableNameAndAlias, fieldAndAlias, fieldReference}; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据提醒内容中的表属性,进行拼接成标准格式 |
| | | * @param flowParam 预警内容 |
| | | * @param concatField 组合字段 |
| | | * @param tableNameAndAlias 表名及别名 |
| | | * @param fieldAndAlias 字段名及别名 |
| | | * @param fieldReference 字段及参照 |
| | | * 根据提醒内容中的表属性,进行拼接成标准格式 |
| | | * |
| | | * @param flowParam 预警内容 |
| | | * @param concatField 组合字段 |
| | | * @param tableNameAndAlias 表名及别名 |
| | | * @param fieldAndAlias 字段名及别名 |
| | | * @param fieldReference 字段及参照 |
| | | * @return |
| | | */ |
| | | public Object[] parseFlowParam(String flowParam, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String>fieldAndAlias, Map<String, String> fieldReference) { |
| | | |
| | | String[] warnAndFlows=flowParam.split(","); |
| | | public Object[] parseFlowParam(String flowParam, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String> fieldAndAlias, Map<String, String> fieldReference) { |
| | | |
| | | String[] warnAndFlows = flowParam.split(","); |
| | | for (int i = 0; i < warnAndFlows.length; i++) { |
| | | String[] warnAndFlow=warnAndFlows[i].split("="); |
| | | String tableAndField=warnAndFlow[0]; |
| | | |
| | | String[] warnAndFlow = warnAndFlows[i].split("="); |
| | | String tableAndField = warnAndFlow[0]; |
| | | |
| | | //获取表名 |
| | | String relationTable=tableAndField.split("\\.")[0]; |
| | | String relationTable = tableAndField.split("\\.")[0]; |
| | | //表别名 |
| | | String relationTableAlias=relationTable+"1"; |
| | | String relationTableAlias = relationTable + "1"; |
| | | //字段名 |
| | | String fieldName=tableAndField.split("\\.")[1]; |
| | | |
| | | if (tableNameAndAlias.get(relationTable)==null) { |
| | | String fieldName = tableAndField.split("\\.")[1]; |
| | | |
| | | if (tableNameAndAlias.get(relationTable) == null) { |
| | | concatField.append(","); |
| | | concatField.append(relationTableAlias); |
| | | concatField.append(".uuid "); |
| | | concatField.append(relationTableAlias); |
| | | concatField.append("uuid"); |
| | | fieldAndAlias.put(relationTable+".uuid", relationTable+"1uuid"); |
| | | fieldAndAlias.put(relationTable + ".uuid", relationTable + "1uuid"); |
| | | tableNameAndAlias.put(relationTable, relationTableAlias); |
| | | } |
| | | |
| | | |
| | | //生成字段别名-->表名1字段名 |
| | | String tableFieldAlias=tableAndField.replace(".", "1"); |
| | | |
| | | if (fieldAndAlias.get(tableAndField)==null) { |
| | | fieldAndAlias.put(tableAndField,tableFieldAlias); |
| | | String tableFieldAlias = tableAndField.replace(".", "1"); |
| | | |
| | | if (fieldAndAlias.get(tableAndField) == null) { |
| | | fieldAndAlias.put(tableAndField, tableFieldAlias); |
| | | concatField.append(","); |
| | | concatField.append(relationTableAlias+"."+fieldName); |
| | | concatField.append(relationTableAlias + "." + fieldName); |
| | | concatField.append(" "); |
| | | concatField.append(tableFieldAlias); |
| | | fieldReference.put(tableFieldAlias, getReferenceByField(tableAndField)); |
| | | } |
| | | } |
| | | return new Object[]{concatField,tableNameAndAlias,fieldAndAlias,fieldReference}; |
| | | return new Object[]{concatField, tableNameAndAlias, fieldAndAlias, fieldReference}; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据表名和字段的获取对应参照 |
| | | * @param tableAndField 表别名.字段名 |
| | | * 根据表名和字段的获取对应参照 |
| | | * |
| | | * @param tableAndField 表别名.字段名 |
| | | * @return 参照名 |
| | | */ |
| | | public String getReferenceByField(String tableAndField) { |
| | | String [] tableField=tableAndField.replace("1.", ".").split("\\."); |
| | | String tableName=tableField[0]; |
| | | String fieldName=tableField[1]; |
| | | FieldSetEntity fseTableInfo=baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?",new Object[] {tableName}, false); |
| | | FieldSetEntity fseFieldInfo=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_name=?", new Object[] {fseTableInfo.getUUID(),fieldName}, false); |
| | | if (fseFieldInfo==null) { |
| | | String[] tableField = tableAndField.replace("1.", ".").split("\\."); |
| | | String tableName = tableField[0]; |
| | | String fieldName = tableField[1]; |
| | | FieldSetEntity fseTableInfo = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?", new Object[]{tableName}, false); |
| | | FieldSetEntity fseFieldInfo = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_name=?", new Object[]{fseTableInfo.getUUID(), fieldName}, false); |
| | | if (fseFieldInfo == null) { |
| | | throw new BaseException("", "", this.getClass(), ""); |
| | | } |
| | | String fieldType=fseFieldInfo.getString(CmnConst.FIELD_TYPE); |
| | | String fieldType = fseFieldInfo.getString(CmnConst.FIELD_TYPE); |
| | | if (CmnConst.USERID.equals(fieldType)) { |
| | | return CmnConst.USERID; |
| | | }else { |
| | | } else { |
| | | return fseFieldInfo.getString(CmnConst.FIELD_REFERENCE); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成关联SQL |
| | | * 生成关联SQL |
| | | * |
| | | * @param tableNameAndAlias |
| | | * @param subTable 当前表 |
| | | * @param subTable 当前表 |
| | | * @return |
| | | */ |
| | | public String createTableRelation(Map<String,String>tableNameAndAlias, String subTable) { |
| | | public String createTableRelation(Map<String, String> tableNameAndAlias, String subTable) { |
| | | //关联SQL |
| | | StringBuilder relationSql=new StringBuilder(); |
| | | relationSql.append(subTable+" "); |
| | | relationSql.append(subTable+"1"); |
| | | |
| | | StringBuilder relationSql = new StringBuilder(); |
| | | relationSql.append(subTable + " "); |
| | | relationSql.append(subTable + "1"); |
| | | |
| | | //判断是否使用子表 |
| | | if (tableNameAndAlias!=null) { |
| | | if (tableNameAndAlias != null) { |
| | | //根据关联子表生成关联SQL |
| | | for (String mainTableName : tableNameAndAlias.keySet()) { |
| | | //获取外键字段 |
| | | String foreignKey=baseDao.getSubTableRelation(mainTableName, subTable); |
| | | String foreignKey = baseDao.getSubTableRelation(mainTableName, subTable); |
| | | if (!StringUtils.isEmpty(foreignKey)) { |
| | | relationSql.append(" LEFT JOIN "); |
| | | relationSql.append(mainTableName+" "); |
| | | relationSql.append(mainTableName+"1"); |
| | | relationSql.append(mainTableName + " "); |
| | | relationSql.append(mainTableName + "1"); |
| | | relationSql.append(" ON "); |
| | | relationSql.append(mainTableName+"1.uuid="); |
| | | relationSql.append(subTable+"1."+foreignKey); |
| | | relationSql.append(mainTableName + "1.uuid="); |
| | | relationSql.append(subTable + "1." + foreignKey); |
| | | } |
| | | } |
| | | } |
| | | return relationSql.toString(); |
| | | } |
| | | |
| | | |
| | | public String getContentByTableSource(FieldSetEntity fse,String content, Map<String, String> concatFieldReference) { |
| | | if (content.indexOf("{#")==-1) { |
| | | |
| | | |
| | | public String getContentByTableSource(FieldSetEntity fse, String content, Map<String, String> concatFieldReference) { |
| | | if (content.indexOf("{#") == -1) { |
| | | return content; |
| | | } |
| | | content=content.replace(".", "1"); |
| | | content = content.replace(".", "1"); |
| | | return replaceParamText(content, fse, concatFieldReference); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 替换文本参数 |
| | | * |
| | | * |
| | | * @param paramText 原文本 |
| | | * @param fseData 业务数据 |
| | | * @return 新文本 |
| | |
| | | Matcher m = p3.matcher(str); |
| | | while (m.find()) { |
| | | String group = m.group(2); |
| | | String replaceValue= SystemParamReplace.replaceSystemParameter(group); |
| | | if(StringUtils.isEmpty(replaceValue)) { |
| | | String replaceValue = SystemParamReplace.replaceSystemParameter(group); |
| | | if (StringUtils.isEmpty(replaceValue)) { |
| | | continue; |
| | | } |
| | | m.appendReplacement(sb1, replaceValue); |
| | |
| | | if (null != value) { |
| | | if (StringUtils.isEmpty(concatFieldReference.get(group))) { |
| | | m.appendReplacement(sb2, value); |
| | | }else { |
| | | m.appendReplacement(sb2, parseReference(concatFieldReference.get(group),value,fseData)); |
| | | } else { |
| | | m.appendReplacement(sb2, parseReference(concatFieldReference.get(group), value, fseData)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | return sb2.toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 参照替换 |
| | | * 参照替换 |
| | | * |
| | | * @param referenceName |
| | | * @param originValue |
| | | * @param fseData |
| | | * @return |
| | | */ |
| | | public String parseReference(String referenceName, String originValue, FieldSetEntity fseData) { |
| | | if (CmnConst.USERID.equals(referenceName)) { //人员 |
| | | FieldSetEntity fseUser=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[] {originValue}, false); |
| | | if (fseUser==null) { |
| | | if (CmnConst.USERID.equals(referenceName)) { //人员 |
| | | FieldSetEntity fseUser = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[]{originValue}, false); |
| | | if (fseUser == null) { |
| | | throw new BaseException("", "", this.getClass(), ""); |
| | | }else { |
| | | } else { |
| | | return fseUser.getString(CmnConst.USER_NAME); |
| | | } |
| | | }else if (referenceName.indexOf("》")>-1) { //数据字典 |
| | | referenceName.replace("《", "").replace("》", ""); |
| | | FieldSetEntity fseDict=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DICT, "dict_name=? AND dict_value=?", new Object[] {referenceName, originValue}, false); |
| | | if (fseDict==null) { |
| | | } else if (referenceName.indexOf("》") > -1) { //数据字典 |
| | | referenceName = referenceName.replace("《", "").replace("》", ""); |
| | | FieldSetEntity fseDict = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DICT, "dict_name=? AND dict_value=?", new Object[]{referenceName, originValue}, false); |
| | | if (fseDict == null) { |
| | | throw new BaseException("", "", this.getClass(), ""); |
| | | }else { |
| | | } else { |
| | | return fseDict.getString(CmnConst.DICT_LABEL); |
| | | } |
| | | }else { //高级参照 |
| | | FieldSetEntity fsePrompt=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PROMPT, "prompt_name=?", new Object[] {referenceName}, false); |
| | | if (fsePrompt==null) { |
| | | throw new BaseException("", "",this.getClass(),""); |
| | | }else { |
| | | String valueField=fsePrompt.getString("value_field"); |
| | | String viewField=fsePrompt.getString("view_fields"); |
| | | String sourceTable=fsePrompt.getString("source_table"); |
| | | FieldSetEntity fsePromptData=baseDao.getFieldSetEntityByFilter(sourceTable, valueField+"=?", new Object[] {originValue}, false); |
| | | if (fsePromptData!=null) { |
| | | } else { //高级参照 |
| | | FieldSetEntity fsePrompt = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PROMPT, "prompt_name=?", new Object[]{referenceName}, false); |
| | | if (fsePrompt == null) { |
| | | throw new BaseException("", "", this.getClass(), ""); |
| | | } else { |
| | | String valueField = fsePrompt.getString("value_field"); |
| | | String viewField = fsePrompt.getString("view_fields"); |
| | | String sourceTable = fsePrompt.getString("source_table"); |
| | | FieldSetEntity fsePromptData = baseDao.getFieldSetEntityByFilter(sourceTable, valueField + "=?", new Object[]{originValue}, false); |
| | | if (fsePromptData != null) { |
| | | return fsePromptData.getString(viewField); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return originValue; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 解析条件表达式 |
| | | * 解析条件表达式 |
| | | * |
| | | * @param warnCOnditon |
| | | * @param tableNameAndAlias |
| | | * @return |
| | | */ |
| | | public String parseWarnCondition(String warnConditon, Map<String, String> tableNameAndAlias) { |
| | | for (String tableName : tableNameAndAlias.keySet()) { |
| | | if (warnConditon.indexOf(tableName)>-1) { |
| | | warnConditon=warnConditon.replace(tableName, tableNameAndAlias.get(tableName)); |
| | | if (warnConditon.indexOf(tableName) > -1) { |
| | | warnConditon = warnConditon.replace(tableName, tableNameAndAlias.get(tableName)); |
| | | } |
| | | } |
| | | warnConditon=warnConditon.replace("{#", "").replace("#}", ""); |
| | | warnConditon=warnConditon.replace("{%", "").replace("%}", ""); |
| | | warnConditon = warnConditon.replace("{#", "").replace("#}", ""); |
| | | warnConditon = warnConditon.replace("{%", "").replace("%}", ""); |
| | | return warnConditon; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 预警发邮件解析 |
| | | * 预警发邮件解析 |
| | | * |
| | | * @param content |
| | | * @param receiver |
| | | */ |
| | | public void parseMail(String content,String receiver) { |
| | | String[] user_ids=receiver.split(","); |
| | | public void parseMail(String content, String receiver) { |
| | | String[] user_ids = receiver.split(","); |
| | | for (int i = 0; i < user_ids.length; i++) { |
| | | FieldSetEntity fseStaff=baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[] {user_ids[i]}, false); |
| | | if (fseStaff==null) { |
| | | FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[]{user_ids[i]}, false); |
| | | if (fseStaff == null) { |
| | | continue; |
| | | } |
| | | String org_level_uuid=fseStaff.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String userEmail=fseStaff.getString("staff_email"); |
| | | FieldSetEntity fseCompanySmtp=baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[] {org_level_uuid}, false); |
| | | |
| | | FieldSetEntity fseMailInfo=new FieldSetEntity(); |
| | | String org_level_uuid = fseStaff.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String userEmail = fseStaff.getString("staff_email"); |
| | | FieldSetEntity fseCompanySmtp = baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[]{org_level_uuid}, false); |
| | | |
| | | FieldSetEntity fseMailInfo = new FieldSetEntity(); |
| | | fseMailInfo.setTableName(CmnConst.PRODUCT_SYS_MAIL_SEND); |
| | | fseMailInfo.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | fseMailInfo.setValue(CmnConst.ADDRESSEE, userEmail); |
| | | fseMailInfo.setValue(CmnConst.MAIL_TITLE, "预警信息"); |
| | | fseMailInfo.setValue(CmnConst.MAIL_CONTENT, content); |
| | | if (fseCompanySmtp!=null) { |
| | | if (fseCompanySmtp != null) { |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, fseCompanySmtp.getString(CmnConst.SMTP_SERVER_HOST)); |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, fseCompanySmtp.getString(CmnConst.SMTP_SERVER_PORT)); |
| | | fseMailInfo.setValue(CmnConst.SMTP_USERNAME, fseCompanySmtp.getString(CmnConst.SMTP_USERNAME)); |
| | | fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, fseCompanySmtp.getString(CmnConst.SMTP_LICENSE_CODE)); |
| | | }else { |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, Global.getSystemConfig("spring.mail.host","")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, Global.getSystemConfig("spring.mail.port","")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_USERNAME, Global.getSystemConfig("spring.mail.username","")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, Global.getSystemConfig("spring.mail.password","")); |
| | | } else { |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, Global.getSystemConfig("spring.mail.host", "")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, Global.getSystemConfig("spring.mail.port", "")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_USERNAME, Global.getSystemConfig("spring.mail.username", "")); |
| | | fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, Global.getSystemConfig("spring.mail.password", "")); |
| | | } |
| | | fseMailInfo.setValue("send_mode", "smtp"); |
| | | SmtpSendMail.sendMail(fseMailInfo,null); |
| | | SmtpSendMail.sendMail(fseMailInfo, null); |
| | | |
| | | //创建人和创建时间 |
| | | if (SpringMVCContextHolder.getCurrentUser()!=null) { |
| | | if (SpringMVCContextHolder.getCurrentUser() != null) { |
| | | fseMailInfo.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id()); |
| | | } |
| | | fseMailInfo.setValue(CmnConst.CREATED_UTC_DATETIME,new Date()); |
| | | fseMailInfo.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | baseDao.add(fseMailInfo); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 预警发短信解析 |
| | | * 预警发短信解析 |
| | | * |
| | | * @param content |
| | | * @param receiver |
| | | */ |
| | | public void parseSMS(String content,String receiver) { |
| | | String[] user_ids=receiver.split(","); |
| | | public void parseSMS(String content, String receiver) { |
| | | String[] user_ids = receiver.split(","); |
| | | for (int i = 0; i < user_ids.length; i++) { |
| | | FieldSetEntity fseuser=baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?", new Object[] {user_ids[i]}, false); |
| | | FieldSetEntity fseStaff=baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[] {user_ids[i]}, false); |
| | | if (fseStaff==null) { |
| | | FieldSetEntity fseuser = baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?", new Object[]{user_ids[i]}, false); |
| | | FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[]{user_ids[i]}, false); |
| | | if (fseStaff == null) { |
| | | continue; |
| | | } |
| | | String org_level_uuid=fseStaff.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String userPhone=fseuser.getString("user_phone_number"); |
| | | |
| | | FieldSetEntity fseMessageInfo=new FieldSetEntity(); |
| | | String org_level_uuid = fseStaff.getString(CmnConst.ORG_LEVEL_UUID); |
| | | String userPhone = fseuser.getString("user_phone_number"); |
| | | |
| | | FieldSetEntity fseMessageInfo = new FieldSetEntity(); |
| | | fseMessageInfo.setTableName(CmnConst.PRODUCT_SYS_MESSAGE_SEND); |
| | | fseMessageInfo.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid); |
| | | fseMessageInfo.setValue("send_user", "2"); |
| | | fseMessageInfo.setValue("receive_user",userPhone); |
| | | fseMessageInfo.setValue("receive_user", userPhone); |
| | | fseMessageInfo.setValue("content", content); |
| | | |
| | | |
| | | FieldSetEntity fseCompanyMessage=baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[] {org_level_uuid}, false); |
| | | if (fseCompanyMessage!=null) { |
| | | |
| | | |
| | | FieldSetEntity fseCompanyMessage = baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[]{org_level_uuid}, false); |
| | | if (fseCompanyMessage != null) { |
| | | fseMessageInfo.setValue(CmnConst.USER_ACCOUNT, fseCompanyMessage.getString(CmnConst.USER_ACCOUNT)); |
| | | fseMessageInfo.setValue(CmnConst.SECRETKEY, fseCompanyMessage.getString(CmnConst.SECRETKEY)); |
| | | fseMessageInfo.setValue(CmnConst.ECNAME, fseCompanyMessage.getString(CmnConst.ECNAME)); |
| | |
| | | fseMessageInfo.setValue(CmnConst.ADDSERIAL, fseCompanyMessage.getString(CmnConst.ADDSERIAL)); |
| | | fseMessageInfo.setValue(CmnConst.URL, fseCompanyMessage.getString(CmnConst.URL)); |
| | | fseMessageInfo.setValue(CmnConst.TREATY, fseCompanyMessage.getString(CmnConst.TREATY)); |
| | | }else { |
| | | } else { |
| | | fseMessageInfo.setValue(CmnConst.USER_ACCOUNT, "zgctjt"); |
| | | fseMessageInfo.setValue(CmnConst.SECRETKEY, "zgctjt2019"); |
| | | fseMessageInfo.setValue(CmnConst.ECNAME, "自贡市城市建设投资开发集团有限公司"); |
| | |
| | | fseMessageInfo.setValue(CmnConst.TREATY, "HTTP"); |
| | | } |
| | | fseMessageInfo.setValue("send_mode", "smtp"); |
| | | |
| | | |
| | | HttpSmsSendUtil.sendMsg(fseMessageInfo); |
| | | fseMessageInfo.setValue(CmnConst.CREATED_BY, 1); |
| | | fseMessageInfo.setValue(CmnConst.CREATED_UTC_DATETIME,new Date()); |
| | | fseMessageInfo.setValue(CmnConst.CREATED_UTC_DATETIME, new Date()); |
| | | baseDao.add(fseMessageInfo); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 自动发起流程 |
| | | * 自动发起流程 |
| | | * |
| | | * @param flowCode |
| | | * @param flowParam |
| | | * @param fseService |
| | | * @param fieldAndAlias |
| | | */ |
| | | public void autoStartFlow(String warnName,String flowCode, String flowParam, FieldSetEntity fseService, Map<String, String>fieldAndAlias, Integer createdBy) { |
| | | |
| | | if (flowCode==null) { |
| | | return ; |
| | | public void autoStartFlow(String warnName, String flowCode, String flowParam, FieldSetEntity fseService, Map<String, String> fieldAndAlias, Integer createdBy) { |
| | | |
| | | if (flowCode == null) { |
| | | return; |
| | | } |
| | | |
| | | FieldSetEntity fseFlowService=new FieldSetEntity(); |
| | | |
| | | String [] warnAndFlows=flowParam.split(","); |
| | | |
| | | FieldSetEntity fseFlowService = new FieldSetEntity(); |
| | | |
| | | String[] warnAndFlows = flowParam.split(","); |
| | | for (int i = 0; i < warnAndFlows.length; i++) { |
| | | String [] warnAndFlow=warnAndFlows[i].split("="); |
| | | String warnField=warnAndFlow[0]; |
| | | String flowField=warnAndFlow[1]; |
| | | |
| | | String[] warnAndFlow = warnAndFlows[i].split("="); |
| | | String warnField = warnAndFlow[0]; |
| | | String flowField = warnAndFlow[1]; |
| | | |
| | | fseFlowService.setTableName(flowField.split("\\.")[0]); |
| | | fseFlowService.setValue(flowField.split("\\.")[1], fseService.getObject(fieldAndAlias.get(warnField.replace("{#", "").replace("#}", "")))); |
| | | } |
| | | |
| | | |
| | | baseDao.add(fseFlowService); |
| | | |
| | | FieldSetEntity fseFLow=new FieldSetEntity(); |
| | | |
| | | FieldSetEntity fseFLow = new FieldSetEntity(); |
| | | fseFLow.setTableName(fseFlowService.getTableName()); |
| | | fseFLow.setValue("flow_title", warnName); |
| | | fseFLow.setValue("uuid", fseFlowService.getUUID()); |