Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat
已添加13个文件
已删除80个文件
已修改28个文件
| | |
| | | - Path=/admin-api/xmcsms/** |
| | | filters: |
| | | - RewritePath=/admin-api/xmcsms/v3/api-docs, /v3/api-docs |
| | | ## shangangrizhao 服务 |
| | | - id: shangangrizhao-admin-api # 路由的编号 |
| | | uri: grayLb://shangangrizhao-server |
| | | predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组 |
| | | - Path=/admin-api/shangangrizhao/** |
| | | filters: |
| | | - RewritePath=/admin-api/shangangrizhao/v3/api-docs, /v3/api-docs |
| | | x-forwarded: |
| | | prefix-enabled: true # 避免 Swagger 重复带上额外的 /admin-api/system 前缀 |
| | | |
| | |
| | | ErrorCode DATA_SOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_007_000, "数据源配置不存在"); |
| | | ErrorCode DATA_SOURCE_CONFIG_NOT_OK = new ErrorCode(1_001_007_001, "数据源配置不正确,无法进行连接"); |
| | | |
| | | // ========== 资源监控 1-001-008-000 ========== |
| | | ErrorCode MONITOR_DISK_NOT_EXISTS = new ErrorCode(1_001_008_000, "磁盘监控不存在"); |
| | | ErrorCode MONITOR_MEM_NOT_EXISTS = new ErrorCode(1_001_008_001, "内存监控不存在"); |
| | | |
| | | // ========== 学生 1-001-201-000 ========== |
| | | ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在"); |
| | | ErrorCode DEMO02_CATEGORY_NOT_EXISTS = new ErrorCode(1_001_201_001, "示例分类不存在"); |
| | |
| | | @Operation(summary = "获取15分钟内最新预警建议信息") |
| | | List<ScheduleSuggestRespDTO> getLastSuggest(@RequestParam Map<String, Object> params); |
| | | |
| | | @PostMapping(PREFIX + "/predict-item/autoAdjustByCode") |
| | | @Operation(summary = "自动调整") |
| | | Boolean autoAdjustByCode(@RequestBody MmPredictAutoAdjustReqVO reqVO); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.api.mcs.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/9 16:15 |
| | | **/ |
| | | @Data |
| | | public class MmPredictAutoAdjustReqVO { |
| | | |
| | | private String configCode; |
| | | private Long adjustStartTime; |
| | | } |
| | |
| | | @Schema(description = "T+L预测值,L表示预测长度") |
| | | private List<Object[]> preDataL; |
| | | |
| | | @Schema(description = "原始T+L预测值(未经过自动调整)") |
| | | private List<Object[]> preDataLOriginal; |
| | | |
| | | @Schema(description = "当时预测值") |
| | | private List<Object[]> curData; |
| | | |
| | |
| | | |
| | | // 模型输出调整值 |
| | | String OUT_ADJUST_VALUES = "adjustValues"; |
| | | |
| | | String DECIMAL_PLACES = "DECIMAL_PLACES"; |
| | | } |
| | |
| | | |
| | | -- t_st_schedule_record 创建复合索引 |
| | | CREATE INDEX idx_st_schedule_record_scheme_result_time ON t_st_schedule_record (scheme_id, result_code, schedule_time DESC, create_time DESC); |
| | | |
| | | CREATE TABLE `t_mm_predict_auto_adjust_config` ( |
| | | `id` varchar(36) NOT NULL, |
| | | `config_name` varchar(255) DEFAULT NULL COMMENT '配置名称', |
| | | `config_code` varchar(255) DEFAULT NULL COMMENT '配置编码', |
| | | `output_id` varchar(36) DEFAULT NULL COMMENT '预测输出id', |
| | | `point_id` varchar(36) DEFAULT NULL COMMENT '测点id', |
| | | `t` int DEFAULT NULL COMMENT '取值时间范围', |
| | | `trigger_rule` varchar(36) DEFAULT NULL COMMENT '触发规则', |
| | | `trigger_value` double DEFAULT NULL COMMENT '触发值', |
| | | `adjust_direction` tinyint DEFAULT '1' COMMENT '调整方向(1:正向,-1:反向)', |
| | | `adjust_length` int DEFAULT NULL COMMENT '调整长度', |
| | | `adjust_value_rule` varchar(36) DEFAULT NULL COMMENT '调整值计算规则', |
| | | `is_enable` tinyint DEFAULT NULL COMMENT '是否启用(0禁用 1启用)', |
| | | `create_time` datetime DEFAULT NULL, |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='预测结果自动调整配置表'; |
| | |
| | | private StScheduleModelSettingService stScheduleModelSettingService; |
| | | |
| | | @Autowired |
| | | private StAdjustConfigService stAdjustConfigService; |
| | | private MmPredictAutoAdjustConfigService autoAdjustService; |
| | | private int HOUR_MINS = 60; |
| | | |
| | | @Override |
| | |
| | | viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime, reqVO.getPrec())); |
| | | viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | viewDto.setPreDataLOriginal(mmItemResultLastPointService.getData(output.getId(), startTime, endTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND,DataTypeEnum.FLOAT_LAST_BAK)); |
| | | viewDto.setCurData(mmItemResultJsonService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | | // 模拟调整曲线 |
| | | viewDto.setAdjData(stAdjustResultService.getData(output.getId(), predictTime, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); |
| | |
| | | BigDecimal limitL = chartParams.get(CommonConstant.LIMIT_L) == null ? null : new BigDecimal(chartParams.get(CommonConstant.LIMIT_L)); |
| | | int lengthLeft = chartParams.get(CommonConstant.LENGTH_LEFT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_LEFT)).intValue(); |
| | | int lengthRight = chartParams.get(CommonConstant.LENGTH_RIGHT) == null ? predictItem.getPredictLength() : new BigDecimal(chartParams.get(CommonConstant.LENGTH_RIGHT)).intValue(); |
| | | int decimalPlaces = chartParams.get(CommonConstant.DECIMAL_PLACES) == null ? 3 : new BigDecimal(chartParams.get(CommonConstant.DECIMAL_PLACES)).intValue(); |
| | | |
| | | Date[] timeArray = calResultTime(predictItem, reqVO.getStartTime(), reqVO.getEndTime(), lengthLeft, lengthRight); |
| | | Date predictTime = timeArray[0]; |
| | |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | | break; |
| | | case TL: |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime, timeFormat)); |
| | | dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime, timeFormat)); |
| | | dataView.setPreDataN(mmItemResultService.getData(outPut.getId(), predictTime, endTime, timeFormat, decimalPlaces)); |
| | | dataView.setPreDataL(mmItemResultLastPointService.getData(outPut.getId(), startTime, endTime, timeFormat, decimalPlaces)); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | return stScheduleSuggestService.getLastSuggest(params); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean autoAdjustByCode(MmPredictAutoAdjustReqVO reqVO) { |
| | | return autoAdjustService.autoAdjustByCode(reqVO.getConfigCode(),reqVO.getAdjustStartTime()); |
| | | } |
| | | |
| | | private Date[] calResultTime(ItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { |
| | | Date[] result = new Date[3]; |
| | | Date predictTime = predictItem.getLastTime(); |
| | |
| | | |
| | | FLOAT_LAST("float_last"), |
| | | |
| | | FLOAT_LAST_BAK("float_last_bak"), |
| | | |
| | | BOOLEAN("boolean"); |
| | | |
| | | private String code; |
| | |
| | | public enum DataMeasurement { |
| | | t_md_sim_value, |
| | | t_md_last_sim_value, |
| | | t_md_last_bak_sim_value, |
| | | t_md_dig_value, |
| | | t_md_bool_value, |
| | | t_md_str_value, |
| | |
| | | return DataMeasurement.t_md_bool_value.name(); |
| | | } else if (DataTypeEnum.FLOAT_LAST.getCode().equals(type)) { |
| | | return DataMeasurement.t_md_last_sim_value.name(); |
| | | } else if (DataTypeEnum.FLOAT_LAST_BAK.getCode().equals(type)) { |
| | | return DataMeasurement.t_md_last_bak_sim_value.name(); |
| | | } else { |
| | | return DataMeasurement.t_md_str_value.name(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.influxdb.pojo; |
| | | |
| | | import com.influxdb.annotations.Column; |
| | | import com.influxdb.annotations.Measurement; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/1/7 13:43 |
| | | **/ |
| | | @Data |
| | | @Measurement(name = "t_md_last_bak_sim_value") |
| | | public class InfluxModelResultLastBakSimPOJO extends InfluxModelResultPOJO { |
| | | |
| | | @Column |
| | | private Double value; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.controller.admin; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.MmPredictAutoAdjustReqVO; |
| | | import com.iailab.module.model.mcs.pre.entity.MmPredictAutoAdjustConfigEntity; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictAutoAdjustConfigService; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigPageReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigVO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 13:30 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/model/pre/auto-adjust-config") |
| | | public class MmPredictAutoAdjustConfigController { |
| | | |
| | | @Autowired |
| | | private MmPredictAutoAdjustConfigService autoAdjustConfigService; |
| | | |
| | | @Autowired |
| | | private McsApi mcsApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建自动调整配置") |
| | | @PreAuthorize("@ss.hasPermission('pre:auto-adjust-config:create')") |
| | | public CommonResult<Boolean> create(@RequestBody MmPredictAutoAdjustConfigEntity entity) { |
| | | autoAdjustConfigService.create(entity); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "更新自动调整配置") |
| | | @PreAuthorize("@ss.hasPermission('pre:auto-adjust-config:update')") |
| | | public CommonResult<Boolean> update(@RequestBody MmPredictAutoAdjustConfigEntity entity) { |
| | | autoAdjustConfigService.update(entity); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除自动调整配置") |
| | | @PreAuthorize("@ss.hasPermission('pre:auto-adjust-config:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
| | | autoAdjustConfigService.delete(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get/{id}") |
| | | @Operation(summary = "获得自动调整配置") |
| | | @PreAuthorize("@ss.hasPermission('pre:auto-adjust-config:query')") |
| | | public CommonResult<MmPredictAutoAdjustConfigVO> getInfo(@PathVariable("id") String id) { |
| | | MmPredictAutoAdjustConfigEntity entity = autoAdjustConfigService.getInfo(id); |
| | | return success(BeanUtils.toBean(entity, MmPredictAutoAdjustConfigVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得自动调整配置分页") |
| | | @PreAuthorize("@ss.hasPermission('pre:auto-adjust-config:query')") |
| | | public CommonResult<PageResult<MmPredictAutoAdjustConfigVO>> page(MmPredictAutoAdjustConfigPageReqVO params) { |
| | | PageResult<MmPredictAutoAdjustConfigVO> pageResult = autoAdjustConfigService.page(params); |
| | | return success(pageResult); |
| | | } |
| | | |
| | | @PostMapping("/autoAdjustByCode") |
| | | @Operation(summary = "通过configCode自动调整") |
| | | public Boolean autoAdjustByCode(@RequestBody MmPredictAutoAdjustReqVO params) { |
| | | return autoAdjustConfigService.autoAdjustByCode(params.getConfigCode(),params.getAdjustStartTime()); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.mcs.pre.entity.MmPredictAutoAdjustConfigEntity; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmConfigRespVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigPageReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 14:16 |
| | | **/ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface MmPredictAutoAdjustConfigDao extends BaseMapperX<MmPredictAutoAdjustConfigEntity> { |
| | | |
| | | IPage<MmPredictAutoAdjustConfigVO> getPage(IPage<MmPredictAutoAdjustConfigEntity> page, @Param("params") MmPredictAutoAdjustConfigPageReqVO reqVO); |
| | | |
| | | default IPage<MmPredictAutoAdjustConfigVO> selectPage(MmPredictAutoAdjustConfigPageReqVO params) { |
| | | return getPage(getPage(params), params); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 11:59 |
| | | **/ |
| | | @Data |
| | | @TableName("t_mm_predict_auto_adjust_config") |
| | | public class MmPredictAutoAdjustConfigEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 配置名称 |
| | | */ |
| | | private String configName; |
| | | |
| | | /** |
| | | * 配置编码 |
| | | */ |
| | | private String configCode; |
| | | |
| | | /** |
| | | * 预测输出id |
| | | */ |
| | | private String outputId; |
| | | |
| | | /** |
| | | * 测点id |
| | | */ |
| | | private String pointId; |
| | | |
| | | /** |
| | | * 取值时间范围 |
| | | */ |
| | | private Integer t; |
| | | |
| | | /** |
| | | * 触发规则 |
| | | */ |
| | | private String triggerRule; |
| | | |
| | | /** |
| | | * 触发值 |
| | | */ |
| | | private Double triggerValue; |
| | | |
| | | /** |
| | | * 调整方向(1:正向,-1:反向) |
| | | */ |
| | | private Integer adjustDirection; |
| | | |
| | | /** |
| | | * 调整长度 |
| | | */ |
| | | private Integer adjustLength; |
| | | |
| | | /** |
| | | * 调整值计算规则 |
| | | */ |
| | | private String adjustValueRule; |
| | | |
| | | /** |
| | | * 是否启用(0禁用 1启用) |
| | | */ |
| | | private Integer isEnable; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 自动调整 触发规则 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum AutoAdjustTriggerRuleEnum { |
| | | |
| | | // 斜率 |
| | | SLOPE("slope"), |
| | | // 平均差 |
| | | AVERAGE_GAP("average_gap"), |
| | | UNKNOW("unknow"); |
| | | |
| | | |
| | | private final String code; |
| | | |
| | | public static AutoAdjustTriggerRuleEnum fromCode(String code) { |
| | | for (AutoAdjustTriggerRuleEnum unit : values()) { |
| | | if (unit.code.equals(code)) { |
| | | return unit; |
| | | } |
| | | } |
| | | return UNKNOW; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * 自动调整 调整值计算规则 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum AutoAdjustValueRuleEnum { |
| | | |
| | | // 均值差 |
| | | AVERAGE_GAP_VALUE("average_gap_value",(map) -> { |
| | | if (!map.containsKey("startValue") || !map.containsKey("endValue")) { |
| | | return 0.0; |
| | | } |
| | | Double startValue = Double.valueOf(map.get("startValue").toString()); |
| | | Double endValue = Double.valueOf(map.get("endValue").toString()); |
| | | return endValue - startValue; |
| | | }); |
| | | |
| | | |
| | | private final String code; |
| | | private final Function<HashMap<String,Object>, Double> calculator; |
| | | |
| | | public Double calculate(HashMap<String,Object> map) { |
| | | return calculator.apply(map); |
| | | } |
| | | |
| | | public static AutoAdjustValueRuleEnum fromCode(String code) { |
| | | for (AutoAdjustValueRuleEnum unit : values()) { |
| | | if (unit.code.equals(code)) { |
| | | return unit; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Double getAdjustValue(String code,HashMap<String,Object> map) { |
| | | |
| | | AutoAdjustValueRuleEnum rule = AutoAdjustValueRuleEnum.fromCode(code); |
| | | |
| | | if (rule == null) { |
| | | return 0.0; |
| | | } |
| | | return rule.calculate(map); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.model.mcs.pre.service; |
| | | |
| | | import com.iailab.module.model.common.enums.DataTypeEnum; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | public interface MmItemResultLastPointService { |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat, DataTypeEnum dataTypeEnum); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat, int decimalPlaces); |
| | | } |
| | |
| | | List<DataValueVO> getPredictValueLast(String outputid, Date startTime, int mins); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat); |
| | | |
| | | List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat, int decimalPlaces); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service; |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.mcs.pre.entity.MmPredictAutoAdjustConfigEntity; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigPageReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 13:44 |
| | | **/ |
| | | public interface MmPredictAutoAdjustConfigService extends BaseService<MmPredictAutoAdjustConfigEntity> { |
| | | |
| | | PageResult<MmPredictAutoAdjustConfigVO> page(MmPredictAutoAdjustConfigPageReqVO params); |
| | | |
| | | MmPredictAutoAdjustConfigEntity getInfo(String id); |
| | | |
| | | MmPredictAutoAdjustConfigEntity getByCode(String code); |
| | | |
| | | void create(MmPredictAutoAdjustConfigEntity entity); |
| | | |
| | | void update(MmPredictAutoAdjustConfigEntity entity); |
| | | |
| | | void delete(String id); |
| | | |
| | | boolean autoAdjustByCode(String configCode,long adjustStartTime); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat) { |
| | | return getData(outputid,startTime,endTime,timeFormat,null); |
| | | } |
| | | |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat,DataTypeEnum dataTypeEnum) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); |
| | | if (dataTypeEnum == null) { |
| | | dataTypeEnum = DataTypeEnum.FLOAT_LAST; |
| | | } |
| | | pojo.setType(dataTypeEnum.getCode()); |
| | | pojo.setOutPutId(outputid); |
| | | List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime); |
| | | influxModelResultVOS.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat); |
| | | dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(3, BigDecimal.ROUND_HALF_UP); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat, int decimalPlaces) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); |
| | | pojo.setType(DataTypeEnum.FLOAT_LAST.getCode()); |
| | |
| | | influxModelResultVOS.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat); |
| | | dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(3, BigDecimal.ROUND_HALF_UP); |
| | | dataItem[1] = BigDecimal.valueOf(Double.parseDouble(item.getValue().toString())).setScale(decimalPlaces, RoundingMode.HALF_UP); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.model.common.enums.DataTypeEnum; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultLastBakSimPOJO; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultLastSimPOJO; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultSimPOJO; |
| | |
| | | public void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime) { |
| | | List<InfluxModelResultPOJO> importList = new ArrayList<>(); |
| | | List<InfluxModelResultPOJO> lastList = new ArrayList<>(); |
| | | List<InfluxModelResultPOJO> lastBakList = new ArrayList<>(); |
| | | List<MmItemResultJsonEntity> resultJsonList = new ArrayList<>(); |
| | | |
| | | for (Map.Entry<String, List<DataValueVO>> entry : predictValueMap.entrySet()) { |
| | |
| | | pojo.setValue(dataVo.getDataValue()); |
| | | pojo.setTimestamp(dataVo.getDataTime().toInstant()); |
| | | pojo.setOutPutId(entry.getKey()); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | importList.add(pojo); |
| | | } |
| | | |
| | |
| | | pojo.setValue(dataVo.getDataValue()); |
| | | pojo.setTimestamp(dataVo.getDataTime().toInstant()); |
| | | pojo.setOutPutId(entry.getKey()); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | lastList.add(pojo); |
| | | |
| | | InfluxModelResultLastBakSimPOJO bakSimPojo = new InfluxModelResultLastBakSimPOJO(); |
| | | bakSimPojo.setValue(dataVo.getDataValue()); |
| | | bakSimPojo.setTimestamp(dataVo.getDataTime().toInstant()); |
| | | bakSimPojo.setOutPutId(entry.getKey()); |
| | | lastBakList.add(bakSimPojo); |
| | | } |
| | | |
| | | MmItemResultJsonEntity resultJson = new MmItemResultJsonEntity(); |
| | |
| | | // double结果存入influxdb |
| | | influxDBService.asyncWriteModelResults(importList); |
| | | influxDBService.asyncWriteModelResults(lastList); |
| | | // t+l备份 |
| | | influxDBService.asyncWriteModelResults(lastBakList); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<Object[]> getData(String outputid, Date startTime, Date endTime, String timeFormat, int decimalPlaces) { |
| | | List<Object[]> result = new ArrayList<>(); |
| | | InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | pojo.setOutPutId(outputid); |
| | | List<InfluxModelResultVO> influxModelResultVOS = influxDBService.queryModelResults(pojo, startTime, endTime); |
| | | influxModelResultVOS.forEach(item -> { |
| | | Object[] dataItem = new Object[2]; |
| | | dataItem[0] = DateUtils.format(Date.from(item.getTimestamp()), timeFormat); |
| | | dataItem[1] = BigDecimal.valueOf(Double.valueOf(item.getValue().toString())).setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); |
| | | result.add(dataItem); |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.model.common.enums.DataTypeEnum; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultLastSimPOJO; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultPOJO; |
| | | import com.iailab.module.model.influxdb.service.InfluxDBService; |
| | | import com.iailab.module.model.influxdb.vo.InfluxModelResultVO; |
| | | import com.iailab.module.model.mcs.pre.dao.MmPredictAutoAdjustConfigDao; |
| | | import com.iailab.module.model.mcs.pre.entity.MmPredictAutoAdjustConfigEntity; |
| | | import com.iailab.module.model.mcs.pre.enums.AutoAdjustTriggerRuleEnum; |
| | | import com.iailab.module.model.mcs.pre.enums.AutoAdjustValueRuleEnum; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictAutoAdjustConfigService; |
| | | import com.iailab.module.model.mcs.pre.service.MmPredictItemService; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigPageReqVO; |
| | | import com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigVO; |
| | | import com.iailab.module.model.mdk.vo.ItemVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年11月19日 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class MmPredictAutoAdjustConfigServiceImpl extends BaseServiceImpl<MmPredictAutoAdjustConfigDao, MmPredictAutoAdjustConfigEntity> |
| | | implements MmPredictAutoAdjustConfigService { |
| | | |
| | | @Autowired |
| | | private MmPredictItemService mmPredictItemService; |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | @Autowired |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Override |
| | | public PageResult<MmPredictAutoAdjustConfigVO> page(MmPredictAutoAdjustConfigPageReqVO params) { |
| | | IPage<MmPredictAutoAdjustConfigVO> page = baseDao.selectPage(params); |
| | | return new PageResult<>(page.getRecords(), page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public MmPredictAutoAdjustConfigEntity getInfo(String id) { |
| | | return baseDao.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public MmPredictAutoAdjustConfigEntity getByCode(String code) { |
| | | return baseDao.selectOne("config_code",code); |
| | | } |
| | | |
| | | @Override |
| | | public void create(MmPredictAutoAdjustConfigEntity entity) { |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | baseDao.insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(MmPredictAutoAdjustConfigEntity entity) { |
| | | baseDao.updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String id) { |
| | | baseDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public boolean autoAdjustByCode(String configCode,long adjustStartTime) { |
| | | // 查询调整配置 |
| | | MmPredictAutoAdjustConfigEntity configEntity = getByCode(configCode); |
| | | if (configEntity == null) { |
| | | log.info("自动调整失败原因:configEntity为null"); |
| | | return false; |
| | | } |
| | | |
| | | Double adjustValue = 0.0; |
| | | ApiPointValueQueryDTO queryDTO; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(adjustStartTime); |
| | | Date endTime; |
| | | Date startTime; |
| | | List<ApiPointValueDTO> apiPointValueDTOS; |
| | | // 判断是否调整 |
| | | AutoAdjustTriggerRuleEnum triggerRuleEnum = AutoAdjustTriggerRuleEnum.fromCode(configEntity.getTriggerRule()); |
| | | switch (triggerRuleEnum) { |
| | | case SLOPE: |
| | | queryDTO = new ApiPointValueQueryDTO(); |
| | | queryDTO.setPointNo(dataPointApi.getInfoById(configEntity.getPointId()).getPointNo()); |
| | | endTime = calendar.getTime(); |
| | | queryDTO.setEnd(endTime); |
| | | calendar.add(Calendar.MINUTE,-1 * configEntity.getT()); |
| | | startTime = calendar.getTime(); |
| | | queryDTO.setStart(startTime); |
| | | apiPointValueDTOS = dataPointApi.queryPointHistoryValue(queryDTO); |
| | | if (CollectionUtils.isEmpty(apiPointValueDTOS)) { |
| | | log.info("自动调整失败原因:测点数据长度为0"); |
| | | return false; |
| | | } |
| | | apiPointValueDTOS = apiPointValueDTOS.stream().filter(e -> e.getV() != -2).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(apiPointValueDTOS)) { |
| | | log.info("自动调整失败原因:测点数据长度为0"); |
| | | return false; |
| | | } |
| | | Optional<ApiPointValueDTO> startOptional = apiPointValueDTOS.stream().filter(e -> e.getT().equals(startTime)).findFirst(); |
| | | if (!startOptional.isPresent()) { |
| | | log.info("自动调整失败原因:计算斜率startTime时间点测点值为null,startTime:" + startTime); |
| | | return false; |
| | | } |
| | | Optional<ApiPointValueDTO> endOptional = apiPointValueDTOS.stream().filter(e -> e.getT().equals(endTime)).findFirst(); |
| | | if (!endOptional.isPresent()) { |
| | | log.info("自动调整失败原因:计算斜率endTime时间点测点值为null,endTime:" + endTime); |
| | | return false; |
| | | } |
| | | ApiPointValueDTO startPointValue = startOptional.get(); |
| | | ApiPointValueDTO endPointValue = endOptional.get(); |
| | | |
| | | // 计算斜率,有正负之分,代表上升或下降 |
| | | double slope = BigDecimal.valueOf(endPointValue.getV() - startPointValue.getV()).divide(BigDecimal.valueOf(configEntity.getT())).doubleValue(); |
| | | //斜率绝对值大于等于触发值则进行调整 |
| | | if (Double.valueOf(Math.abs(slope)).compareTo(configEntity.getTriggerValue()) >= 0) { |
| | | //计算调整值 |
| | | HashMap<String,Object> map = new HashMap<>(); |
| | | map.put("startValue",startPointValue.getV()); |
| | | map.put("endValue",endPointValue.getV()); |
| | | adjustValue = AutoAdjustValueRuleEnum.getAdjustValue(configEntity.getAdjustValueRule(), map); |
| | | } else { |
| | | log.info("自动调整失败原因:斜率小于调整值,斜率:" + slope); |
| | | return false; |
| | | } |
| | | break; |
| | | case AVERAGE_GAP: |
| | | queryDTO = new ApiPointValueQueryDTO(); |
| | | queryDTO.setPointNo(dataPointApi.getInfoById(configEntity.getPointId()).getPointNo()); |
| | | endTime = calendar.getTime(); |
| | | queryDTO.setEnd(endTime); |
| | | calendar.add(Calendar.MINUTE,-1 * configEntity.getT() * 2 + 1); |
| | | startTime = calendar.getTime(); |
| | | queryDTO.setStart(startTime); |
| | | apiPointValueDTOS = dataPointApi.queryPointHistoryValue(queryDTO); |
| | | if (CollectionUtils.isEmpty(apiPointValueDTOS)) { |
| | | log.info("自动调整失败原因:测点数据长度为0"); |
| | | return false; |
| | | } |
| | | apiPointValueDTOS = apiPointValueDTOS.stream().filter(e -> e.getV() != -2).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(apiPointValueDTOS)) { |
| | | log.info("自动调整失败原因:测点数据长度为0"); |
| | | return false; |
| | | } |
| | | calendar.add(Calendar.MINUTE,configEntity.getT()); |
| | | double startAverage = apiPointValueDTOS.stream().filter(e -> e.getT().before(calendar.getTime())).collect(Collectors.summarizingDouble(ApiPointValueDTO::getV)).getAverage(); |
| | | double endAverage = apiPointValueDTOS.stream().filter(e -> e.getT().compareTo(calendar.getTime()) >= 0).collect(Collectors.summarizingDouble(ApiPointValueDTO::getV)).getAverage(); |
| | | // 计算均值差,大于等于触发值则进行调整 |
| | | if (Double.valueOf(Math.abs(startAverage - endAverage)).compareTo(configEntity.getTriggerValue()) >= 0) { |
| | | //计算调整值 |
| | | HashMap<String,Object> map = new HashMap<>(); |
| | | map.put("startValue",startAverage); |
| | | map.put("endValue",endAverage); |
| | | adjustValue = AutoAdjustValueRuleEnum.getAdjustValue(configEntity.getAdjustValueRule(), map); |
| | | } else { |
| | | log.info("自动调整失败原因:均值差小于调整值,均值差:" + (startAverage - endAverage)); |
| | | return false; |
| | | } |
| | | break; |
| | | default: |
| | | log.info("自动调整失败原因:未知触发规则,triggerRule" + configEntity.getTriggerRule()); |
| | | return false; |
| | | } |
| | | |
| | | // 调整方向 |
| | | adjustValue = adjustValue * configEntity.getAdjustDirection(); |
| | | |
| | | // 获取历史结果 |
| | | ItemVO item = mmPredictItemService.getItemByOutPutId(configEntity.getOutputId()); |
| | | if (item == null) { |
| | | log.info("自动调整失败原因:getItemByOutPutId为null,outputId:" + configEntity.getOutputId()); |
| | | return false; |
| | | } |
| | | Calendar resultCalendar = Calendar.getInstance(); |
| | | resultCalendar.setTimeInMillis(adjustStartTime); |
| | | Date resultStartTime = resultCalendar.getTime(); |
| | | resultCalendar.add(Calendar.SECOND,configEntity.getAdjustLength() * item.getGranularity()); |
| | | Date resultEndTime = resultCalendar.getTime(); |
| | | InfluxModelResultPOJO pojo = new InfluxModelResultPOJO(); |
| | | pojo.setType(DataTypeEnum.FLOAT_LAST_BAK.getCode()); |
| | | pojo.setOutPutId(configEntity.getOutputId()); |
| | | List<InfluxModelResultVO> influxModelResult = influxDBService.queryModelResults(pojo, resultStartTime, resultEndTime); |
| | | |
| | | List<InfluxModelResultPOJO> lastList = new ArrayList<>(); |
| | | for (InfluxModelResultVO resultVO : influxModelResult) { |
| | | InfluxModelResultLastSimPOJO adjustPojo = new InfluxModelResultLastSimPOJO(); |
| | | // 设置新的调整值 |
| | | adjustPojo.setValue(Double.parseDouble(resultVO.getValue().toString()) + adjustValue); |
| | | adjustPojo.setTimestamp(resultVO.getTimestamp()); |
| | | adjustPojo.setOutPutId(configEntity.getOutputId()); |
| | | lastList.add(adjustPojo); |
| | | } |
| | | // 相同时间直接覆盖旧值 |
| | | influxDBService.asyncWriteModelResults(lastList); |
| | | log.info("t+l自动调整。configCode:" + configCode + ",adjustValue:" + adjustValue + ",resultStartTime:" + resultStartTime + ",resultEndTime:" + resultEndTime + "调整长度:" + lastList.size()); |
| | | return true; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.vo; |
| | | |
| | | import com.iailab.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 14:35 |
| | | **/ |
| | | @Schema(description = "预测结果自动调整配置 - Page Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MmPredictAutoAdjustConfigPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "配置名称") |
| | | private String configName; |
| | | |
| | | @Schema(description = "配置编码") |
| | | private String configCode; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.mcs.pre.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/4/8 11:59 |
| | | **/ |
| | | @Data |
| | | public class MmPredictAutoAdjustConfigVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | private String id; |
| | | |
| | | /** |
| | | * 配置名称 |
| | | */ |
| | | private String configName; |
| | | |
| | | /** |
| | | * 配置编码 |
| | | */ |
| | | private String configCode; |
| | | |
| | | /** |
| | | * 预测输出id |
| | | */ |
| | | private String outputId; |
| | | |
| | | /** |
| | | * 测点id |
| | | */ |
| | | private String pointId; |
| | | |
| | | /** |
| | | * 取值时间范围 |
| | | */ |
| | | private Integer t; |
| | | |
| | | /** |
| | | * 触发规则 |
| | | */ |
| | | private String triggerRule; |
| | | |
| | | /** |
| | | * 触发值 |
| | | */ |
| | | private Double triggerValue; |
| | | |
| | | /** |
| | | * 调整方向(1:正向,-1:反向) |
| | | */ |
| | | private Integer adjustDirection; |
| | | |
| | | /** |
| | | * 调整长度 |
| | | */ |
| | | private Integer adjustLength; |
| | | |
| | | /** |
| | | * 调整值计算规则 |
| | | */ |
| | | private String adjustValueRule; |
| | | |
| | | /** |
| | | * 是否启用(0禁用 1启用) |
| | | */ |
| | | private Integer isEnable; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 预测项名称 |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * 预测项输出名称 |
| | | */ |
| | | private String outputName; |
| | | } |
| | |
| | | //打印结果 |
| | | log.info("预测模型计算完成:modelId=" + modelId + ",modelName=" + predictModel.getModelname() + ",modelResult=" + JSON.toJSONString(modelResult)); |
| | | //判断模型结果 |
| | | if (!modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT) || |
| | | if (modelResult == null || !modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT) || |
| | | !modelResult.get(CommonConstant.MDK_STATUS_CODE).toString().equals(CommonConstant.MDK_STATUS_100)) { |
| | | throw new ModelResultErrorException("模型结果异常:" + modelResult); |
| | | } |
| | |
| | | log.info("参数: " + JSON.toJSONString(param2Values)); |
| | | //IAILMDK.run |
| | | HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, scheduleScheme.getMpkprojectid()); |
| | | HashMap<String, Object> result = new HashMap<>(); |
| | | if (modelResult == null) { |
| | | //返回调度结果 |
| | | scheduleResult.setResultCode("null"); |
| | | scheduleResult.setResult(result); |
| | | scheduleResult.setModelId(modelId); |
| | | scheduleResult.setSchemeId(scheduleScheme.getId()); |
| | | scheduleResult.setScheduleTime(scheduleTime); |
| | | return scheduleResult; |
| | | } |
| | | |
| | | if (!modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT)) { |
| | | log.info("模型结果异常:" + modelResult); |
| | | } |
| | | String statusCode = modelResult.get(CommonConstant.MDK_STATUS_CODE).toString(); |
| | | HashMap<String, Object> result = new HashMap<>(); |
| | | |
| | | if (modelResult.containsKey(CommonConstant.MDK_RESULT) && modelResult.get(CommonConstant.MDK_RESULT) != null && |
| | | CommonConstant.MDK_STATUS_100.equals(modelResult.get(CommonConstant.MDK_STATUS_CODE).toString())) { |
| | | result = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT); |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.pre.dao.MmPredictAutoAdjustConfigDao"> |
| | | <select id="getPage" resultType="com.iailab.module.model.mcs.pre.vo.MmPredictAutoAdjustConfigVO"> |
| | | select |
| | | t1.*, |
| | | t2.result_name output_name, |
| | | t3.itemname item_name |
| | | from t_mm_predict_auto_adjust_config t1 |
| | | left join t_mm_item_output t2 on t1.output_id = t2.id |
| | | left join t_mm_predict_item t3 on t2.itemid = t3.id |
| | | <where> |
| | | <if test="params.configName != null and params.configName != ''"> |
| | | and t1.config_name like CONCAT('%', #{params.configName},'%') |
| | | </if> |
| | | <if test="params.configCode != null and params.configCode != ''"> |
| | | and t1.config_code like CONCAT('%', #{params.configCode},'%') |
| | | </if> |
| | | </where> |
| | | order by t1.create_time desc |
| | | </select> |
| | | </mapper> |
| | |
| | | <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- Job 定时任务相关 --> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.iailab</groupId>--> |
| | | <!-- <artifactId>iailab-common-job</artifactId>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <!-- 消息队列相关 --> |
| | | <dependency> |
| | | <groupId>com.iailab</groupId> |
| | |
| | | <artifactId>iailab-common-monitor</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 三方云服务相关 --> |
| | | <dependency> |
| | | <groupId>com.xingyuv</groupId> |
| | | <artifactId>spring-boot-starter-justauth</artifactId> <!-- 社交登陆(例如说,个人微信、企业微信等等) --> |
| | | </dependency> |
| | | <!-- <!– 三方云服务相关 –>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.xingyuv</groupId>--> |
| | | <!-- <artifactId>spring-boot-starter-justauth</artifactId> <!– 社交登陆(例如说,个人微信、企业微信等等) –>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>com.github.binarywang</groupId> |
| | | <artifactId>wx-java-mp-spring-boot-starter</artifactId> <!-- 微信登录(公众号) --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.github.binarywang</groupId> |
| | | <artifactId>wx-java-miniapp-spring-boot-starter</artifactId> <!-- 微信登录(小程序) --> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>aliyun-java-sdk-core</artifactId> <!-- 短信(阿里云) --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <!-- 短信(阿里云) --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.tencentcloudapi</groupId> |
| | | <artifactId>tencentcloud-sdk-java-sms</artifactId> <!-- 短信(腾讯云) --> |
| | | </dependency> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.aliyun</groupId>--> |
| | | <!-- <artifactId>aliyun-java-sdk-core</artifactId> <!– 短信(阿里云) –>--> |
| | | <!-- </dependency>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.aliyun</groupId>--> |
| | | <!-- <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <!– 短信(阿里云) –>--> |
| | | <!-- </dependency>--> |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.tencentcloudapi</groupId>--> |
| | | <!-- <artifactId>tencentcloud-sdk-java-sms</artifactId> <!– 短信(腾讯云) –>--> |
| | | <!-- </dependency>--> |
| | | |
| | | <dependency> |
| | | <groupId>com.xingyuv</groupId> |
| | | <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 验证码,一般用于登录使用 --> |
| | | </dependency> |
| | | |
| | | <!-- <dependency>--> |
| | | <!-- <groupId>com.iailab</groupId>--> |
| | | <!-- <artifactId>iailab-plat-sdk</artifactId>--> |
| | | <!-- <version>1.0.0</version>--> |
| | | <!-- </dependency>--> |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | <!-- 设置构建的 jar 包名 --> |
| | | <finalName>${project.artifactId}</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>com.github.wvengen</groupId> |
| | | <artifactId>proguard-maven-plugin</artifactId> |
| | | <version>2.7.0</version> |
| | | <executions> |
| | | <!-- 以下配置说明执行mvn的package命令时候,会执行proguard--> |
| | | <execution> |
| | | <phase>package</phase> |
| | | <goals> |
| | | <goal>proguard</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | <configuration> |
| | | <!-- 就是输入Jar的名称,我们要知道,代码混淆其实是将一个原始的jar,生成一个混淆后的jar,那么就会有输入输出。 --> |
| | | <injar>${project.build.finalName}.jar</injar> |
| | | <!-- 输出jar名称,输入输出jar同名的时候就是覆盖,也是比较常用的配置。 --> |
| | | <outjar>${project.build.finalName}.jar</outjar> |
| | | <!-- 是否混淆 默认是true --> |
| | | <obfuscate>true</obfuscate> |
| | | <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir> |
| | | <!-- 配置一个文件,通常叫做proguard.cfg,该文件主要是配置options选项,也就是说使用proguard.cfg那么options下的所有内容都可以移到proguard.cfg中 --> |
| | | <proguardInclude>${project.basedir}/proguard.cfg</proguardInclude> |
| | | <!-- 额外的jar包,通常是项目编译所需要的jar --> |
| | | <libs> |
| | | <lib>${java.home}/lib/rt.jar</lib> |
| | | <lib>${java.home}/lib/jce.jar</lib> |
| | | <lib>${java.home}/lib/jsse.jar</lib> |
| | | </libs> |
| | | <!-- 对输入jar进行过滤比如,如下配置就是对META-INFO文件不处理。 --> |
| | | <inLibsFilter>!META-INF/**,!META-INF/versions/9/**.class</inLibsFilter> |
| | | <!-- 这是输出路径配置,但是要注意这个路径必须要包括injar标签填写的jar --> |
| | | <outputDirectory>${project.basedir}/target</outputDirectory> |
| | | <!--这里特别重要,此处主要是配置混淆的一些细节选项,比如哪些类不需要混淆,哪些需要混淆--> |
| | | <options> |
| | | <!-- 可以在此处写option标签配置,不过我上面使用了proguardInclude,故而我更喜欢在proguard.cfg中配置 --> |
| | | </options> |
| | | </configuration> |
| | | </plugin> |
| | | <!-- 打包 --> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.iailab.framework.common.enums.CommonStatusEnum; |
| | | import com.iailab.framework.common.enums.UserTypeEnum; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.security.config.SecurityProperties; |
| | | import com.iailab.framework.security.core.LoginUser; |
| | | import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
| | | import com.iailab.module.system.controller.admin.app.vo.AppMenuRespVO; |
| | | import com.iailab.module.system.controller.admin.app.vo.AppRespVO; |
| | | import com.iailab.module.system.controller.admin.auth.vo.*; |
| | | import com.iailab.module.system.controller.admin.permission.vo.menu.MenuListReqVO; |
| | | import com.iailab.module.system.controller.admin.permission.vo.menu.MenuRespVO; |
| | | import com.iailab.module.system.convert.auth.AuthConvert; |
| | | import com.iailab.module.system.dal.dataobject.app.AppDO; |
| | | import com.iailab.module.system.dal.dataobject.permission.MenuDO; |
| | |
| | | import com.iailab.module.system.service.permission.MenuService; |
| | | import com.iailab.module.system.service.permission.PermissionService; |
| | | import com.iailab.module.system.service.permission.RoleService; |
| | | import com.iailab.module.system.service.social.SocialClientService; |
| | | import com.iailab.module.system.service.user.AdminUserService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private MenuService menuService; |
| | | @Resource |
| | | private PermissionService permissionService; |
| | | @Resource |
| | | private SocialClientService socialClientService; |
| | | @Resource |
| | | private SecurityProperties securityProperties; |
| | | @Resource |
| | |
| | | menuVOS = AuthConvert.INSTANCE.buildMenuTree(tempChildren, menuDO.getId(), menuDO.getPath(), info.getType()); |
| | | // 2. 拼接结果返回 |
| | | return success(menuVOS); |
| | | } |
| | | |
| | | // ========== 短信登录相关 ========== |
| | | |
| | | @PostMapping("/sms-login") |
| | | @PermitAll |
| | | @Operation(summary = "使用短信验证码登录") |
| | | public CommonResult<AuthLoginRespVO> smsLogin(@RequestBody @Valid AuthSmsLoginReqVO reqVO) { |
| | | return success(authService.smsLogin(reqVO)); |
| | | } |
| | | |
| | | @PostMapping("/send-sms-code") |
| | | @PermitAll |
| | | @Operation(summary = "发送手机验证码") |
| | | public CommonResult<Boolean> sendLoginSmsCode(@RequestBody @Valid AuthSmsSendReqVO reqVO) { |
| | | authService.sendSmsCode(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | // ========== 社交登录相关 ========== |
| | | |
| | | @GetMapping("/social-auth-redirect") |
| | | @PermitAll |
| | | @Operation(summary = "社交授权的跳转") |
| | | @Parameters({ |
| | | @Parameter(name = "type", description = "社交类型", required = true), |
| | | @Parameter(name = "redirectUri", description = "回调路径") |
| | | }) |
| | | public CommonResult<String> socialLogin(@RequestParam("type") Integer type, |
| | | @RequestParam("redirectUri") String redirectUri) { |
| | | return success(socialClientService.getAuthorizeUrl( |
| | | type, UserTypeEnum.ADMIN.getValue(), redirectUri)); |
| | | } |
| | | |
| | | @PostMapping("/social-login") |
| | | @PermitAll |
| | | @Operation(summary = "社交快捷登录,使用 code 授权码", description = "适合未登录的用户,但是社交账号已绑定用户") |
| | | public CommonResult<AuthLoginRespVO> socialQuickLogin(@RequestBody @Valid AuthSocialLoginReqVO reqVO) { |
| | | return success(authService.socialLogin(reqVO)); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.iailab.module.system.controller.admin.user; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.iailab.framework.common.enums.UserTypeEnum; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.datapermission.core.annotation.DataPermission; |
| | | import com.iailab.module.system.controller.admin.user.vo.profile.UserProfileRespVO; |
| | |
| | | import com.iailab.module.system.dal.dataobject.dept.DeptDO; |
| | | import com.iailab.module.system.dal.dataobject.dept.PostDO; |
| | | import com.iailab.module.system.dal.dataobject.permission.RoleDO; |
| | | import com.iailab.module.system.dal.dataobject.social.SocialUserDO; |
| | | import com.iailab.module.system.dal.dataobject.user.AdminUserDO; |
| | | import com.iailab.module.system.service.dept.DeptService; |
| | | import com.iailab.module.system.service.dept.PostService; |
| | | import com.iailab.module.system.service.permission.PermissionService; |
| | | import com.iailab.module.system.service.permission.RoleService; |
| | | import com.iailab.module.system.service.social.SocialUserService; |
| | | import com.iailab.module.system.service.user.AdminUserService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | private PermissionService permissionService; |
| | | @Resource |
| | | private RoleService roleService; |
| | | @Resource |
| | | private SocialUserService socialService; |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得登录用户信息") |
| | |
| | | // 获得岗位信息 |
| | | List<PostDO> posts = CollUtil.isNotEmpty(user.getPostIds()) ? postService.getPostList(user.getPostIds()) : null; |
| | | // 获得社交用户信息 |
| | | List<SocialUserDO> socialUsers = socialService.getSocialUserList(user.getId(), UserTypeEnum.ADMIN.getValue()); |
| | | return success(UserConvert.INSTANCE.convert(user, userRoles, dept, posts, socialUsers)); |
| | | return success(UserConvert.INSTANCE.convert(user, userRoles, dept, posts)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | |
| | | * 所属岗位数组 |
| | | */ |
| | | private List<PostSimpleRespVO> posts; |
| | | /** |
| | | * 社交用户数组 |
| | | */ |
| | | private List<SocialUser> socialUsers; |
| | | |
| | | @Schema(description = "社交用户") |
| | | @Data |
| | | public static class SocialUser { |
| | | |
| | | @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") |
| | | private Integer type; |
| | | |
| | | @Schema(description = "社交用户的 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "IPRmJ0wvBptiPIlGEZiPewGwiEiE") |
| | | private String openid; |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.system.api.sms.dto.code.SmsCodeSendReqDTO; |
| | | import com.iailab.module.system.api.sms.dto.code.SmsCodeUseReqDTO; |
| | | import com.iailab.module.system.api.social.dto.SocialUserBindReqDTO; |
| | | import com.iailab.module.system.controller.admin.auth.vo.*; |
| | | import com.iailab.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; |
| | | import com.iailab.module.system.dal.dataobject.permission.MenuDO; |
| | |
| | | } |
| | | return menuVOS; |
| | | } |
| | | |
| | | SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialLoginReqVO reqVO); |
| | | |
| | | SmsCodeSendReqDTO convert(AuthSmsSendReqVO reqVO); |
| | | |
| | | SmsCodeUseReqDTO convert(AuthSmsLoginReqVO reqVO, Integer scene, String usedIp); |
| | | |
| | | } |
| | |
| | | import com.iailab.module.system.dal.dataobject.dept.DeptDO; |
| | | import com.iailab.module.system.dal.dataobject.dept.PostDO; |
| | | import com.iailab.module.system.dal.dataobject.permission.RoleDO; |
| | | import com.iailab.module.system.dal.dataobject.social.SocialUserDO; |
| | | import com.iailab.module.system.dal.dataobject.user.AdminUserDO; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.factory.Mappers; |
| | |
| | | } |
| | | |
| | | default UserProfileRespVO convert(AdminUserDO user, List<RoleDO> userRoles, |
| | | DeptDO dept, List<PostDO> posts, List<SocialUserDO> socialUsers) { |
| | | DeptDO dept, List<PostDO> posts) { |
| | | UserProfileRespVO userVO = BeanUtils.toBean(user, UserProfileRespVO.class); |
| | | userVO.setRoles(BeanUtils.toBean(userRoles, RoleSimpleRespVO.class)); |
| | | userVO.setDept(BeanUtils.toBean(dept, DeptSimpleRespVO.class)); |
| | | userVO.setPosts(BeanUtils.toBean(posts, PostSimpleRespVO.class)); |
| | | userVO.setSocialUsers(BeanUtils.toBean(socialUsers, UserProfileRespVO.SocialUser.class)); |
| | | return userVO; |
| | | } |
| | | |
对比新文件 |
| | |
| | | //package com.iailab.module.system.job.config; |
| | | // |
| | | //import org.springframework.context.annotation.Configuration; |
| | | // |
| | | //import javax.annotation.PostConstruct; |
| | | //import java.net.InetAddress; |
| | | //import java.net.UnknownHostException; |
| | | // |
| | | ///** |
| | | // * 服务器资源监控配置文件 |
| | | // */ |
| | | //@Configuration |
| | | //public class ServerInfoConfiguration { |
| | | // |
| | | // public static String hostName; |
| | | // |
| | | // public static String hostIp; |
| | | // |
| | | // @PostConstruct |
| | | // public void initServerInfo() throws UnknownHostException { |
| | | // System.out.println("初始化获取服务器信息initServerInfo..."); |
| | | // // 获取本地主机对象 |
| | | // InetAddress localHost = InetAddress.getLocalHost(); |
| | | // // 获取主机名 |
| | | // hostName = localHost.getHostName(); |
| | | // // 获取IP地址 |
| | | // hostIp = localHost.getHostAddress(); |
| | | // } |
| | | // |
| | | //} |
| | |
| | | void logout(String token, Integer logType); |
| | | |
| | | /** |
| | | * 短信验证码发送 |
| | | * |
| | | * @param reqVO 发送请求 |
| | | */ |
| | | void sendSmsCode(AuthSmsSendReqVO reqVO); |
| | | |
| | | /** |
| | | * 短信登录 |
| | | * |
| | | * @param reqVO 登录信息 |
| | | * @return 登录结果 |
| | | */ |
| | | AuthLoginRespVO smsLogin(AuthSmsLoginReqVO reqVO) ; |
| | | |
| | | /** |
| | | * 社交快捷登录,使用 code 授权码 |
| | | * |
| | | * @param reqVO 登录信息 |
| | | * @return 登录结果 |
| | | */ |
| | | AuthLoginRespVO socialLogin(@Valid AuthSocialLoginReqVO reqVO); |
| | | |
| | | /** |
| | | * 刷新访问令牌 |
| | | * |
| | | * @param refreshToken 刷新令牌 |
| | |
| | | import com.iailab.framework.common.util.servlet.ServletUtils; |
| | | import com.iailab.framework.common.util.validation.ValidationUtils; |
| | | import com.iailab.module.system.api.logger.dto.LoginLogCreateReqDTO; |
| | | import com.iailab.module.system.api.sms.SmsCodeApi; |
| | | import com.iailab.module.system.api.social.dto.SocialUserBindReqDTO; |
| | | import com.iailab.module.system.api.social.dto.SocialUserRespDTO; |
| | | import com.iailab.module.system.controller.admin.auth.vo.*; |
| | | import com.iailab.module.system.convert.auth.AuthConvert; |
| | | import com.iailab.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; |
| | |
| | | import com.iailab.module.system.service.logger.LoginLogService; |
| | | import com.iailab.module.system.service.member.MemberService; |
| | | import com.iailab.module.system.service.oauth2.OAuth2TokenService; |
| | | import com.iailab.module.system.service.social.SocialUserService; |
| | | import com.iailab.module.system.service.user.AdminUserService; |
| | | import com.google.common.annotations.VisibleForTesting; |
| | | import com.xingyuv.captcha.model.common.ResponseModel; |
| | |
| | | import java.util.Objects; |
| | | |
| | | import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static com.iailab.framework.common.util.servlet.ServletUtils.getClientIP; |
| | | import static com.iailab.module.system.enums.ErrorCodeConstants.*; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private OAuth2TokenService oauth2TokenService; |
| | | @Resource |
| | | private SocialUserService socialUserService; |
| | | @Resource |
| | | private MemberService memberService; |
| | | @Resource |
| | | private Validator validator; |
| | | @Resource |
| | | private CaptchaService captchaService; |
| | | @Resource |
| | | private SmsCodeApi smsCodeApi; |
| | | |
| | | /** |
| | | * 验证码的开关,默认为 true |
| | |
| | | // 使用账号密码,进行登录 |
| | | AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword()); |
| | | |
| | | // 如果 socialType 非空,说明需要绑定社交用户 |
| | | if (reqVO.getSocialType() != null) { |
| | | socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), |
| | | reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); |
| | | } |
| | | // 创建 Token 令牌,记录登录日志 |
| | | return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); |
| | | } |
| | | |
| | | @Override |
| | | public void sendSmsCode(AuthSmsSendReqVO reqVO) { |
| | | // 登录场景,验证是否存在 |
| | | if (userService.getUserByMobile(reqVO.getMobile()) == null) { |
| | | throw exception(AUTH_MOBILE_NOT_EXISTS); |
| | | } |
| | | // 发送验证码 |
| | | smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP())); |
| | | } |
| | | |
| | | @Override |
| | | public AuthLoginRespVO smsLogin(AuthSmsLoginReqVO reqVO) { |
| | | // 校验验证码 |
| | | smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.ADMIN_MEMBER_LOGIN.getScene(), getClientIP())).getCheckedData(); |
| | | |
| | | // 获得用户信息 |
| | | AdminUserDO user = userService.getUserByMobile(reqVO.getMobile()); |
| | | if (user == null) { |
| | | throw exception(USER_NOT_EXISTS); |
| | | } |
| | | |
| | | // 创建 Token 令牌,记录登录日志 |
| | | return createTokenAfterLoginSuccess(user.getId(), reqVO.getMobile(), LoginLogTypeEnum.LOGIN_MOBILE); |
| | | } |
| | | |
| | | private void createLoginLog(Long userId, String username, |
| | |
| | | if (userId != null && Objects.equals(LoginResultEnum.SUCCESS.getResult(), loginResult.getResult())) { |
| | | userService.updateUserLogin(userId, ServletUtils.getClientIP()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AuthLoginRespVO socialLogin(AuthSocialLoginReqVO reqVO) { |
| | | // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 |
| | | SocialUserRespDTO socialUser = socialUserService.getSocialUserByCode(UserTypeEnum.ADMIN.getValue(), reqVO.getType(), |
| | | reqVO.getCode(), reqVO.getState()); |
| | | if (socialUser == null || socialUser.getUserId() == null) { |
| | | throw exception(AUTH_THIRD_LOGIN_NOT_BIND); |
| | | } |
| | | |
| | | // 获得用户 |
| | | AdminUserDO user = userService.getUser(socialUser.getUserId()); |
| | | if (user == null) { |
| | | throw exception(USER_NOT_EXISTS); |
| | | } |
| | | |
| | | // 创建 Token 令牌,记录登录日志 |
| | | return createTokenAfterLoginSuccess(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL); |
| | | } |
| | | |
| | | @VisibleForTesting |
| | |
| | | primary: master |
| | | datasource: |
| | | master: |
| | | url: jdbc:mysql://172.16.8.100:3306/iailab_plat_system?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 |
| | | url: jdbc:mysql://localhost:3306/iailab_plat_system?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 |
| | | username: root |
| | | password: 123456 |
| | | slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 |
| | |
| | | spring: |
| | | # RabbitMQ 配置项,对应 RabbitProperties 配置类 |
| | | rabbitmq: |
| | | host: 172.16.8.200 # RabbitMQ 服务的地址 |
| | | host: 172.16.1.221 # RabbitMQ 服务的地址 |
| | | port: 5672 # RabbitMQ 服务的端口 |
| | | username: admin # RabbitMQ 服务的账号 |
| | | password: admin123 # RabbitMQ 服务的密码 |
| | |
| | | kafka: |
| | | bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 |
| | | |
| | | --- #################### 定时任务相关配置 #################### |
| | | xxl: |
| | | job: |
| | | enabled: true # 是否开启调度中心,默认为 true 开启 |
| | | admin: |
| | | addresses: http://172.16.216.135:9090/xxl-job-admin # 调度中心部署跟地址 |
| | | |
| | | --- #################### 服务保障相关配置 #################### |
| | | |
| | | # Lock4j 配置项 |
| | |
| | | username: @nacos.username@ |
| | | password: @nacos.password@ |
| | | discovery: # 【配置中心】配置项 |
| | | # ip: 172.16.8.200 |
| | | namespace: @profiles.active@ |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
| | | metadata: |
| | |
| | | req-check-minute-limit: 60 # check 接口一分钟内请求数限制 |
| | | req-verify-minute-limit: 60 # verify 接口一分钟内请求数限制 |
| | | |
| | | --- #################### 定时任务相关配置 #################### |
| | | |
| | | xxl: |
| | | job: |
| | | executor: |
| | | # ip: 172.16.8.200 |
| | | appname: ${spring.application.name} # 执行器 AppName |
| | | logpath: D:/DLUT/IailabPlat/webapp/infra/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 |
| | | accessToken: default_token # 执行器通讯TOKEN |
| | | |
| | | --- #################### 平台相关配置 #################### |
| | | |
| | | iailab: |
| | |
| | | private static final String RESP_DATA = "data"; |
| | | |
| | | /** |
| | | * 用户名密码方式获取平台token |
| | | * 客户端方式获取平台token |
| | | */ |
| | | public static synchronized TokenDTO authenticate() { |
| | | System.out.println("登录获取平台token"); |
| | |
| | | <!-- 各种 module 拓展 --> |
| | | <module>iailab-module-system</module> |
| | | <module>iailab-module-infra</module> |
| | | <module>iailab-module-bpm</module> |
| | | <module>iailab-module-report</module> |
| | | <!-- <module>iailab-module-bpm</module>--> |
| | | <!-- <module>iailab-module-report</module>--> |
| | | <module>iailab-module-data</module> |
| | | <module>iailab-module-model</module> |
| | | </modules> |