| | |
| | | |
| | | logging: |
| | | file: |
| | | name: @log.path@/logs/${spring.application.name}.log # 日志文件名,全路径 |
| | | name: @log.path@/iailab-gateway/log/${spring.application.name}.log # 日志文件名,全路径 |
| | | |
| | | knife4j: |
| | | # 聚合 Swagger 文档,参考 https://doc.xiaominfo.com/docs/action/springcloud-gateway 文档 |
| | |
| | | .collect(Collectors.joining("\n")); |
| | | } |
| | | |
| | | /** |
| | | * 判断字符串是不是数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean isNumeric(String str) { |
| | | return str.matches("-?\\d+(\\.\\d+)?"); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.number.NumberUtils; |
| | | import com.iailab.framework.datapermission.core.annotation.DataPermission; |
| | | import com.iailab.module.bpm.controller.admin.task.vo.task.*; |
| | | import com.iailab.module.bpm.convert.task.BpmTaskConvert; |
| | | import com.iailab.module.bpm.dal.dataobject.definition.BpmFormDO; |
| | |
| | | @GetMapping("todo-page") |
| | | @Operation(summary = "获取 Todo 待办任务分页") |
| | | @PreAuthorize("@ss.hasPermission('bpm:task:query')") |
| | | @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 |
| | | public CommonResult<PageResult<BpmTaskRespVO>> getTaskTodoPage(@Valid BpmTaskPageReqVO pageVO) { |
| | | PageResult<Task> pageResult = taskService.getTaskTodoPage(getLoginUserId(), pageVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | |
| | | // 拼接数据 |
| | | Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap( |
| | | convertSet(pageResult.getList(), Task::getProcessInstanceId)); |
| | | // TODO 此处有bug |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); |
| | | return success(BpmTaskConvert.INSTANCE.buildTodoTaskPage(pageResult, processInstanceMap, userMap)); |
| | | PageResult<BpmTaskRespVO> bpmTaskRespVOPageResult = BpmTaskConvert.INSTANCE.buildTodoTaskPage(pageResult, processInstanceMap, userMap); |
| | | return success(bpmTaskRespVOPageResult); |
| | | } |
| | | |
| | | @GetMapping("done-page") |
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.iailab.framework.common.util.number.NumberUtils; |
| | | import com.iailab.framework.datapermission.core.annotation.DataPermission; |
| | | import com.iailab.module.bpm.enums.definition.BpmBoundaryEventType; |
| | | import com.iailab.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| | | import com.iailab.module.bpm.framework.flowable.core.util.BpmnModelUtils; |
| | |
| | | package com.iailab.module.bpm.framework.flowable.core.listener.demo.exection; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.flowable.bpmn.model.FieldExtension; |
| | | import org.flowable.engine.delegate.DelegateExecution; |
| | | import org.flowable.engine.delegate.JavaDelegate; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 类型为 class 的 ExecutionListener 监听器示例 |
| | |
| | | |
| | | @Override |
| | | public void execute(DelegateExecution execution) { |
| | | log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), |
| | | log.info("[execute][execution({}) 执行监听器(类)被调用!变量有:{}]", execution.getId(), |
| | | execution.getCurrentFlowableListener().getFieldExtensions()); |
| | | List<FieldExtension> fieldExtensions = execution.getCurrentFlowableListener().getFieldExtensions(); |
| | | if(ObjectUtils.isNotEmpty(fieldExtensions)) { |
| | | fieldExtensions.stream().forEach(fieldExtension -> { |
| | | System.out.println(fieldExtension.getFieldName()); |
| | | System.out.println(fieldExtension.getExpression()); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.iailab.module.bpm.framework.flowable.core.listener.demo.exection; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.flowable.bpmn.model.FieldExtension; |
| | | import org.flowable.engine.delegate.DelegateExecution; |
| | | import org.flowable.engine.delegate.JavaDelegate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 类型为 delegateExpression 的 ExecutionListener 监听器示例 |
| | |
| | | |
| | | @Override |
| | | public void execute(DelegateExecution execution) { |
| | | log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), |
| | | log.info("[execute][execution({}) 执行监听器(委托表达式被调用)!变量有:{}]", execution.getId(), |
| | | execution.getCurrentFlowableListener().getFieldExtensions()); |
| | | List<FieldExtension> fieldExtensions = execution.getCurrentFlowableListener().getFieldExtensions(); |
| | | if(ObjectUtils.isNotEmpty(fieldExtensions)) { |
| | | fieldExtensions.stream().forEach(fieldExtension -> { |
| | | System.out.println(fieldExtension.getFieldName()); |
| | | System.out.println(fieldExtension.getStringValue()); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.iailab.module.bpm.framework.flowable.core.listener.demo.exection; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.flowable.bpmn.model.FieldExtension; |
| | | import org.flowable.engine.delegate.DelegateExecution; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 类型为 expression 的 ExecutionListener 监听器示例 |
| | |
| | | public class DemoSpringExpressionExecutionListener { |
| | | |
| | | public void execute(DelegateExecution execution) { |
| | | log.info("[execute][execution({}) 被调用!变量有:{}]", execution.getId(), |
| | | log.info("[execute][execution({}) 执行监听器(spring表达式)被调用!变量有:{}]", execution.getId(), |
| | | execution.getCurrentFlowableListener().getFieldExtensions()); |
| | | List<FieldExtension> fieldExtensions = execution.getCurrentFlowableListener().getFieldExtensions(); |
| | | if(ObjectUtils.isNotEmpty(fieldExtensions)) { |
| | | fieldExtensions.stream().forEach(fieldExtension -> { |
| | | System.out.println(fieldExtension.getFieldName()); |
| | | System.out.println(fieldExtension.getExpression()); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void notify(DelegateTask delegateTask) { |
| | | log.info("[execute][task({}) 被调用]", delegateTask.getId()); |
| | | log.info("[execute][task({}) 任务监听器(类)被调用]", delegateTask.getId()); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.flowable.task.service.delegate.DelegateTask; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 类型为 delegateExpression 的 TaskListener 监听器示例 |
| | | * |
| | |
| | | |
| | | @Override |
| | | public void notify(DelegateTask delegateTask) { |
| | | log.info("[execute][task({}) 被调用]", delegateTask.getId()); |
| | | log.info("[execute][task({}) 任务监听器(委托表达式)被调用]", delegateTask.getId()); |
| | | Map<String, Object> variables = delegateTask.getVariables(); |
| | | System.out.println(variables.toString());; |
| | | } |
| | | |
| | | } |
| | |
| | | public class DemoSpringExpressionTaskListener { |
| | | |
| | | public void notify(DelegateTask delegateTask) { |
| | | log.info("[execute][task({}) 被调用]", delegateTask.getId()); |
| | | log.info("[execute][task({}) 任务监听器(spring表达式)被调用]", delegateTask.getId()); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.iailab.framework.common.util.number.NumberUtils; |
| | | import com.iailab.framework.common.util.object.ObjectUtils; |
| | | import com.iailab.framework.common.util.object.PageUtils; |
| | | import com.iailab.framework.datapermission.core.annotation.DataPermission; |
| | | import com.iailab.framework.web.core.util.WebFrameworkUtils; |
| | | import com.iailab.module.bpm.controller.admin.task.vo.task.*; |
| | | import com.iailab.module.bpm.convert.task.BpmTaskConvert; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData(); |
| | | messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<ApiPlanItemDTO> getInfoByIds(Set<String> planIds) { |
| | | if (CollectionUtils.isEmpty(planIds)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<PlanItemEntity> plans = planItemService.getInfoByIds(planIds); |
| | | return ConvertUtils.sourceToTarget(plans,ApiPlanItemDTO.class); |
| | | } |
| | |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.channel.kio.collector.KingIOCollector; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueBoolPOJO; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; |
| | | import com.iailab.module.data.point.collection.handler.CalculateHandle; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.Duration; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | @Autowired |
| | | private DaPointCollectStatusService daPointCollectStatusService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public static final String PV = "point_value:"; |
| | | |
| | | public static final long offset = 60 * 3L; |
| | | |
| | | /** |
| | | * 采集 |
| | | * |
| | |
| | | List<DaPointDTO> pointCumulateList = daPointService.getCumulatePoint(minfreq); |
| | | pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList)); |
| | | |
| | | log.info("存入数据库"); |
| | | log.info("存入时序库"); |
| | | influxDBService.asyncWritePointValues(pointValues); |
| | | |
| | | log.info("存入缓存"); |
| | | for (InfluxPointValuePOJO pointValue : pointValues) { |
| | | if (pointValue instanceof InfluxPointValueSimPOJO) { |
| | | InfluxPointValueSimPOJO simPOJO = (InfluxPointValueSimPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + simPOJO.getPoint(), simPOJO.getValue().doubleValue(), offset, TimeUnit.SECONDS); |
| | | } else if (pointValue instanceof InfluxPointValueDigPOJO) { |
| | | InfluxPointValueDigPOJO digPOJO = (InfluxPointValueDigPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + digPOJO.getPoint(), digPOJO.getValue().intValue(), offset, TimeUnit.SECONDS); |
| | | } else if (pointValue instanceof InfluxPointValueBoolPOJO) { |
| | | InfluxPointValueBoolPOJO boolPOJO = (InfluxPointValueBoolPOJO) pointValue; |
| | | redisTemplate.opsForValue().set(PV + boolPOJO.getPoint(), boolPOJO.getValue().booleanValue(), offset, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | log.info("更新采集状态"); |
| | | daPointCollectStatusService.recordStatusList(pointValues, collectTime); |
| | | log.info("采集完成"); |
| | |
| | | package com.iailab.module.data.point.collection.handler; |
| | | |
| | | import com.iailab.framework.common.util.string.StrUtils; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.DataTypeEnum; |
| | | import com.iailab.module.data.common.enums.JsErrorCode; |
| | | import com.iailab.module.data.common.utils.JavaScriptHandler; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private JavaScriptHandler javaScriptHandler; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public static final String regex = "[+\\-\\*/()\\&\\|\\>\\<]"; |
| | | |
| | |
| | | String result = javaScriptHandler.eval(expression); |
| | | log.info("result=" + result); |
| | | if (result == null) { |
| | | return null; |
| | | return CommonConstant.BAD_VALUE; |
| | | } else if (result.contains(JsErrorCode.Infinity.name()) || |
| | | result.contains(JsErrorCode.NaN.name())) { |
| | | log.info("计算异常,使用默认值"); |
| | |
| | | if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { |
| | | return new BigDecimal(result).intValue(); |
| | | } else if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { |
| | | return new BigDecimal(result).setScale(10, BigDecimal.ROUND_UP).doubleValue(); |
| | | return new BigDecimal(result).setScale(4, BigDecimal.ROUND_UP).doubleValue(); |
| | | } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { |
| | | return Boolean.parseBoolean(result); |
| | | } |
| | |
| | | return data; |
| | | } |
| | | pointMathList.forEach(item -> { |
| | | data.put(item.getPointNo(), singleCompute(item)); |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | if (redisTemplate.hasKey(PointCollector.PV + item.getPointNo())) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |
| | | return data; |
| | | } |
| | | |
| | | private Object singleCompute(DaPointDTO dto) { |
| | | String result = CommonConstant.BAD_VALUE.toString(); |
| | | Map<String, Object> dataMap = new HashMap<>(); |
| | | String expression = dto.getExpression(); |
| | | String[] arr = expression.split(regex); |
| | |
| | | pointNos.add(s); |
| | | dataMap.putAll(measureHandle.getCurrent(pointNos)); |
| | | dataMap.putAll(constantHandle.getCurrent(pointNos)); |
| | | expression = expression.replace(s, dataMap.get(s).toString()); |
| | | String valueStr = dataMap.get(s).toString(); |
| | | if (StrUtils.isNumeric(valueStr) && new BigDecimal(valueStr).compareTo(CommonConstant.BAD_VALUE) == 0) { |
| | | log.info("BAD_VALUE:" + s); |
| | | } |
| | | if (StrUtils.isNumeric(valueStr) && new BigDecimal(valueStr).compareTo(BigDecimal.ZERO) < 0) { |
| | | valueStr = "(" + valueStr + ")"; |
| | | } |
| | | expression = expression.replace(s, valueStr); |
| | | } |
| | | expression = expression.replace("&", "&&"); |
| | | expression = expression.replace("|", "||"); |
| | | expression = expression.replace("False", "false"); |
| | | expression = expression.replace("True", "true"); |
| | | log.info("PointNo=" + dto.getPointNo() + ";expression=" + expression); |
| | | String result = javaScriptHandler.eval(expression); |
| | | result = javaScriptHandler.eval(expression); |
| | | log.info("result=" + result); |
| | | if (result == null) { |
| | | return null; |
| | | } else if (result.contains(JsErrorCode.Infinity.name()) || |
| | | result.contains(JsErrorCode.NaN.name())) { |
| | | return CommonConstant.BAD_VALUE; |
| | | } else if (result.contains(JsErrorCode.Infinity.name()) || result.contains(JsErrorCode.NaN.name())) { |
| | | log.info("计算异常,使用默认值"); |
| | | return dto.getDefaultValue() == null ? BigDecimal.ZERO : dto.getDefaultValue(); |
| | | } else { |
| | | if (DataTypeEnum.INT.getCode().equals(dto.getDataType())) { |
| | | return new BigDecimal(result).intValue(); |
| | | } else if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType())) { |
| | | return new BigDecimal(result).setScale(10, BigDecimal.ROUND_UP).doubleValue(); |
| | | return new BigDecimal(result).setScale(2, BigDecimal.ROUND_UP).doubleValue(); |
| | | } else if (DataTypeEnum.BOOLEAN.getCode().equals(dto.getDataType())) { |
| | | return Boolean.parseBoolean(result); |
| | | } |
| | |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos) { |
| | | List<InfluxPointValuePOJO> result = new ArrayList<>(); |
| | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | pointMathList.forEach(item -> { |
| | | data.put(item.getPointNo(), singleCompute(item, calendar.getTime())); |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | if (redisTemplate.hasKey(PointCollector.PV + item.getPointNo())) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item, calendar.getTime()); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |
| | | return data; |
| | | } |
| | |
| | | import com.iailab.module.data.channel.kio.collector.KingIOCollector; |
| | | import com.iailab.module.data.channel.modbus.collector.ModBusCollector; |
| | | import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
| | | import com.iailab.module.data.point.common.PointDataTypeEnum; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 测量点处理 |
| | |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { |
| | | log.info("测量点处理开始"); |
| | |
| | | pointMeasureList.forEach( |
| | | item -> { |
| | | try { |
| | | boolean hasKey = redisTemplate.hasKey(PointCollector.PV + item.getPointNo()); |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) { |
| | | if (hasKey) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) { |
| | | value = opcUaCollector.getTagValue(item.getSourceId(), item.getTagNo()); |
| | | } else if (DataSourceType.ModBus.getCode().equals(item.getSourceType())) { |
| | | value = modBusCollector.getTagValue(item.getSourceId(), item.getTagNo()); |
| | |
| | | } else { |
| | | log.info("没有匹配的TagNo=" + item.getTagNo()); |
| | | } |
| | | log.info("没有匹配的TagNo=" + item.getTagNo()); |
| | | log.info("valueStr=" + value.toString()); |
| | | log.info("DataType=" + item.getDataType()); |
| | | log.info("TagNo=" + item.getTagNo() + ",value=" + value.toString()); |
| | | if (!PointDataTypeEnum.BOOLEAN.getCode().equals(item.getDataType())) { |
| | | BigDecimal decValue = new BigDecimal(value.toString()); |
| | | if (PointDataTypeEnum.FLOAT.getCode().equals(item.getDataType())) { |
| | |
| | | } else { |
| | | data.put(item.getPointNo(), value); |
| | | } |
| | | |
| | | if (!hasKey) { |
| | | // 存入缓存 |
| | | toRedis(value, item); |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | |
| | | ); |
| | | return data; |
| | | } |
| | | |
| | | public void toRedis(Object value, DaPointDTO point) { |
| | | if (PointDataTypeEnum.FLOAT.getCode().equals(point.getDataType())) { |
| | | redisTemplate.opsForValue().set(PointCollector.PV + point.getPointNo(), new BigDecimal(value.toString()).intValue(), |
| | | PointCollector.offset, TimeUnit.SECONDS); |
| | | } else if (PointDataTypeEnum.INT.getCode().equals(point.getDataType())) { |
| | | redisTemplate.opsForValue().set(PointCollector.PV + point.getPointNo(), new BigDecimal(value.toString()).doubleValue(), |
| | | PointCollector.offset, TimeUnit.SECONDS); |
| | | } else if (PointDataTypeEnum.BOOLEAN.getCode().equals(point.getDataType())) { |
| | | redisTemplate.opsForValue().set(PointCollector.PV + point.getPointNo(), Boolean.parseBoolean(value.toString()), |
| | | PointCollector.offset, TimeUnit.SECONDS); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | logging: |
| | | file: |
| | | name: @log.path@/logs/${spring.application.name}.log # 日志文件名,全路径 |
| | | name: @log.path@/iailab-data/log/${spring.application.name}.log # 日志文件名,全路径 |
| | | level: |
| | | org: |
| | | springframework: |
| | |
| | | username: @nacos.username@ |
| | | password: @nacos.password@ |
| | | discovery: # 【配置中心】配置项 |
| | | ip: @deploy.server@ |
| | | # ip: @deploy.server@ |
| | | namespace: @profiles.active@ |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
| | | metadata: |
| | |
| | | |
| | | logging: |
| | | file: |
| | | name: D:/DLUT/IailabPlat/webapp/infra/logs/${spring.application.name}.log # 日志文件名,全路径 |
| | | name: @log.path@/iailab-infra/log/${spring.application.name}.log # 日志文件名,全路径 |
| | | |
| | | --- #################### 接口文档配置 #################### |
| | | |
| | |
| | | * @return |
| | | * @throws ModelInvokeException |
| | | */ |
| | | PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName) throws ModelInvokeException; |
| | | PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo) throws ModelInvokeException; |
| | | } |
| | |
| | | throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", |
| | | ModelInvokeException.errorGetModelEntity, itemId)); |
| | | } |
| | | predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName()); |
| | | predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName(),predictItemDto.getItemNo()); |
| | | predictResult.setPredictId(itemId); |
| | | } catch (ModelResultErrorException ex) { |
| | | throw ex; |
| | |
| | | * @throws ModelInvokeException |
| | | */ |
| | | @Override |
| | | public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName) throws ModelInvokeException { |
| | | public synchronized PredictResultVO predictByModel(Date predictTime, MmPredictModelEntity predictModel,String itemName,String itemNo) throws ModelInvokeException { |
| | | PredictResultVO result = new PredictResultVO(); |
| | | if (predictModel == null) { |
| | | throw new ModelInvokeException("modelEntity is null"); |
| | |
| | | param2Values[portLength] = newModelBean.getDataMap().get("models"); |
| | | param2Values[portLength + 1] = settings; |
| | | |
| | | log.info("####################### 预测模型 "+ "【itemId:" + predictModel.getItemid() + ",itemName" + itemName + "】 ##########################"); |
| | | log.info("####################### 预测模型 "+ "【itemId:" + predictModel.getItemid() + ",itemName:" + itemName + ",itemNo:" + itemNo + "】 ##########################"); |
| | | // JSONObject jsonObjNewModelBean = new JSONObject(); |
| | | // jsonObjNewModelBean.put("newModelBean", newModelBean); |
| | | // log.info(String.valueOf(jsonObjNewModelBean)); |
| | |
| | | } |
| | | modelResult = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT); |
| | | //打印结果 |
| | | log.info("预测模型计算完成:modelId=" + modelId + ",modelName" + predictModel.getMethodname()); |
| | | JSONObject jsonObjResult = new JSONObject(); |
| | | jsonObjResult.put("result", modelResult); |
| | | log.info(String.valueOf(jsonObjResult)); |
| | | log.info("预测模型计算完成:modelId=" + modelId + ",modelName=" + predictModel.getMethodname() + ",modelResult=" + String.valueOf(jsonObjResult)); |
| | | |
| | | List<MmItemOutputEntity> itemOutputList = mmItemOutputService.getByItemid(predictModel.getItemid()); |
| | | Map<MmItemOutputEntity, double[]> predictMatrixs = new HashMap<>(); |
| | |
| | | ex.printStackTrace(); |
| | | throw ex; |
| | | } catch (Exception ex) { |
| | | log.error("调用发生异常,异常信息为:{1}", ex); |
| | | // ex.printStackTrace(); |
| | | // log.error("调用发生异常,异常信息为:{0}", ex.getMessage()); |
| | | ex.printStackTrace(); |
| | | throw new ModelInvokeException(ex.getMessage()); |
| | | } |
| | | return result; |
| | |
| | | SampleDataConstructor sampleDataConstructor = sampleFactory.createSampelData(typeA); |
| | | return sampleDataConstructor.prepareSampleData(sampleInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new ModelInvokeException(MessageFormat.format("{0},Name:{1}", |
| | | ModelInvokeException.errorGetModelArithParam, itemName)); |
| | | } |
| | |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.data.enums.TimeGranularitySecEnum; |
| | | import com.iailab.module.model.mcs.pre.enums.PredGranularityEnum; |
| | | import com.iailab.module.model.mdk.common.enums.ModelParamType; |
| | | import com.iailab.module.model.mdk.sample.dto.SampleData; |
| | | import com.iailab.module.model.mdk.sample.dto.SampleInfo; |
| | |
| | | case NORMALITEM: |
| | | case MERGEITEM: |
| | | // 预测值 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | start = startTime.getTime(); |
| | | |
| | | calendar.setTime(endTime); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | endTime = calendar.getTime(); |
| | | end = endTime.getTime(); |
| | | |
| | | oneMin = 60 * 1000L; |
| | | oneMin = PredGranularityEnum.MIN1.getCode() * 1000L; |
| | | start = start - (start % oneMin) + oneMin; |
| | | end = end - (end % oneMin) + oneMin; |
| | | mins = ((end - start) / oneMin); |
| | | break; |
| | | case DATAPOINT: |
| | |
| | | break; |
| | | case NORMALITEM: |
| | | case MERGEITEM: |
| | | dateTime = calendar.getTime(); |
| | | dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60); |
| | | break; |
| | | case IND: |
| | | dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60); |
| | |
| | | |
| | | logging: |
| | | file: |
| | | name: @log.path@/logs/${spring.application.name}.log # 日志文件名,全路径 |
| | | name: @log.path@/iailab-model/log/${spring.application.name}.log # 日志文件名,全路径 |
| | | level: |
| | | org: |
| | | springframework: |
| | |
| | | menu.setParentId(parentMenu.getId()); |
| | | tempChildren.add(parentMenu); |
| | | } else if(menu.getType().equals(MenuTypeEnum.DIR.getType())) { |
| | | // 为应用菜单二级目录前增加“/” |
| | | // 为应用菜单二级目录前增加“/” (不处理外链菜单path) |
| | | if(!menu.getPath().contains("http:") && !menu.getPath().contains("https:")) { |
| | | menu.setPath("/" + menu.getPath()); |
| | | } |
| | |
| | | List<AuthPermissionInfoRespVO.MenuVO> menuVOS = filterList(treeNodeMap.values(), node -> id.equals(node.getParentId())); |
| | | if(type == 0) { |
| | | menuVOS.stream().forEach(menuVO -> { |
| | | menuVO.setPath((parentPath + "/" + menuVO.getPath()).replace("//", "/")); |
| | | // 不处理外链菜单path |
| | | if(!menuVO.getPath().contains("http:") && !menuVO.getPath().contains("https:")) { |
| | | menuVO.setPath((parentPath + "/" + menuVO.getPath()).replace("//", "/")); |
| | | } |
| | | }); |
| | | } |
| | | return menuVOS; |
| | |
| | | |
| | | logging: |
| | | file: |
| | | name: @log.path@/logs/${spring.application.name}.log # 日志文件名,全路径 |
| | | name: @log.path@/iailab-system/log/${spring.application.name}.log # 日志文件名,全路径 |
| | | |
| | | --- #################### 接口文档配置 #################### |
| | | |
| | |
| | | begin-code: 9999 # 这里配置 9999 的原因是,测试方便。 |
| | | end-code: 9999 # 这里配置 9999 的原因是,测试方便。 |
| | | |
| | | debug: false |
| | | debug: true |
| | |
| | | <nacos.metadata.version>1.0.0</nacos.metadata.version> |
| | | <log.path>D:\DLUT\iailab-plat</log.path> |
| | | <logstash.address>127.0.0.1:4560</logstash.address> |
| | | <deploy.server>192.168.56.1</deploy.server> |
| | | <deploy.server>172.16.216.132</deploy.server> |
| | | </properties> |
| | | <activation> |
| | | <!-- 默认环境 --> |
| | |
| | | <nacos.username>nacos</nacos.username> |
| | | <nacos.password>nacos</nacos.password> |
| | | <nacos.metadata.version>1.0.0</nacos.metadata.version> |
| | | <log.path>D:\iailab\logs</log.path> |
| | | <log.path>D:\iailab</log.path> |
| | | <logstash.address>127.0.0.1:4560</logstash.address> |
| | | <deploy.server>10.88.4.131</deploy.server> |
| | | </properties> |