| | |
| | | import com.product.org.admin.service.StaffManagerService; |
| | | import com.product.quartz.service.impl.SysJobService; |
| | | import com.product.util.BaseUtil; |
| | | import com.product.util.SystemParamReplace; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | Map<String, String> fieldReference = new HashMap<>(); //组合相关字段的参照,tableName1fieldName-->referenceName |
| | | StringBuilder concatField = new StringBuilder(); //组合相关字段,tableName1.fieldName tableName1fieldName |
| | | earlyWarningServer.parseWarningContent(warnCondition, concatField, tableNameAndAlias, fieldAndAlias, fieldReference); |
| | | // 替换系统参数 |
| | | warnCondition = SystemParamReplace.systemParamsReplace(warnCondition); |
| | | |
| | | //生成主子表关联SQL |
| | | String relationSQL = earlyWarningServer.createTableRelation(tableNameAndAlias, mainTableName); |
| | | |
| | | StringBuilder serviceSQL = new StringBuilder(); |
| | | serviceSQL.append(" SELECT "); |
| | | serviceSQL.append(concatField.subSequence(1, concatField.length())); |
| | | serviceSQL.append(StringUtils.isEmpty(concatField) ? "*" : concatField.subSequence(1, concatField.length())); |
| | | serviceSQL.append(" FROM "); |
| | | serviceSQL.append(relationSQL); |
| | | serviceSQL.append(" WHERE "); |
| | |
| | | } |
| | | return dte; |
| | | } |
| | | |
| | | /** |
| | | * 转发 |
| | | * @param fse |
| | | */ |
| | | @Override |
| | | public void transmit(FieldSetEntity fse) { |
| | | String uuid = fse.getUUID(); |
| | | String messageAccepter = fse.getString("user"); |
| | | FieldSetEntity warnMsgFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, uuid, false); |
| | | String preReceiver = warnMsgFse.getString(CmnConst.RECEIVER); |
| | | Set<String> preReceiverSet = Sets.newHashSet(preReceiver.split(",")); |
| | | if (StringUtils.isEmpty(messageAccepter)) { |
| | | throw new BaseException(SystemCode.WARN_TRANSMIT_USER_IS_NULL); |
| | | } |
| | | Set<String> transmitUserSet = Sets.newHashSet(messageAccepter.split(",")); |
| | | transmitUserSet.forEach(transmitUser -> { |
| | | if (preReceiverSet.contains(transmitUser)) { |
| | | FieldSetEntity transmitUserFse = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[]{transmitUser}, false); |
| | | throw new BaseException(SystemCode.WARN_TRANSMIT_USER_REPEAT.getValue(), String.format("%s:%s", SystemCode.WARN_TRANSMIT_USER_REPEAT.getText(), transmitUserFse.getString(CmnConst.USER_NAME))); |
| | | } |
| | | }); |
| | | // 更新预警信息表 |
| | | warnMsgFse.setValue(CmnConst.RECEIVER, preReceiver + "," + messageAccepter); |
| | | baseDao.saveFieldSetEntity(warnMsgFse); |
| | | |
| | | // 发送消息给转发人 |
| | | SystemUser curUser = SpringMVCContextHolder.getCurrentUser(); |
| | | FieldSetEntity msgFse = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_MESSAGE, "source_table=? and source_uuid=?", new Object[]{CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, uuid}, false); |
| | | String title = String.format("%s向您转发了预警消息《%s》", curUser.getUser_name(), msgFse.getString(CmnConst.TITLE)); |
| | | String content = msgFse.getString("content"); |
| | | WebsocketMesssageServiceThread.getInstance().appendMessage(messageAccepter, content, title, curUser.getUser_id(), |
| | | "31", CmnConst.BUTTON_URL_WARN_MESSAGE_INFO + "?uuid=" + fse.getUUID(), |
| | | CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, fse.getUUID(), curUser.getUser_id(), 0, 0, null); |
| | | } |
| | | } |