diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java new file mode 100644 index 0000000..13719eb --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.business.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotNull; + + +/** + * @author ysj + */ +@Data +@TableName("hzims_alarm") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "告警对象", description = "各告警数据源保存对象") +public class BusinessEarlyEntity extends TenantEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("任务ID") + @NotNull + private Long taskId; + + @ApiModelProperty("业务类型 :0 - 固定资产 1 - 日常维护 2 - 安全工器- 具 3 - 巡检 4 - 检修 5 - 缺陷 6 - 值班") + @NotNull + private Integer businessType; + + @ApiModelProperty("预警内容") + @NotNull + private String content; + + @ApiModelProperty("机构Id") + private Long deptId; + +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java new file mode 100644 index 0000000..8bf7032 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.business.feign; + +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Component; + +/** + * @author hx + */ +@Component +public class BusinessEarlyClientFallback implements IBusinessEarlyClient { + + @Override + public R save(BusinessEarlyEntity entity) { + return R.status(false); + } +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java new file mode 100644 index 0000000..cfb3b93 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.business.feign; + +import com.hnac.hzims.alarm.config.constants.AlarmConstants; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author ysj + */ +@FeignClient( + value = AlarmConstants.APP_NAME, + fallback = BusinessEarlyClientFallback.class +) +public interface IBusinessEarlyClient { + + String API_PREFIX = "/feign/businessEarly"; + + String BUSINESS_EARLY_SAVE = API_PREFIX + "/save"; + + @PostMapping(BUSINESS_EARLY_SAVE) + R save(@RequestBody BusinessEarlyEntity entity); +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java similarity index 90% rename from hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java rename to hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java index 9aa90e1..4e7c270 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.alarm; +package com.hnac.hzims; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import org.mybatis.spring.annotation.MapperScan; @@ -17,9 +17,10 @@ import javax.annotation.Resource; @EnableBladeFeign @SpringCloudApplication @MapperScan("com.hnac.hzims.**.mapper.**") -@ComponentScan(basePackages = {"com.hnac.hzims.alarm.*"}) +@ComponentScan(basePackages = {"com.hnac.hzims.alarm.*","com.hnac.hzims.business.*"}) @Resource public class AlarmApplication extends SpringBootServletInitializer { + public static void main(String[] args) { BladeApplication.run(AlarmConstants.APP_NAME, AlarmApplication.class, args); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java new file mode 100644 index 0000000..6a60e98 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.business.early.feign; + +import com.hnac.hzims.business.early.service.BusinessEarlyService; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import com.hnac.hzims.business.feign.IBusinessEarlyClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@RestController +@Slf4j +@RequiredArgsConstructor +public class BusinessEarlyClient implements IBusinessEarlyClient { + + private final BusinessEarlyService businessEarlyService; + + /** + * 业务预警信息保存 + * @param entity + * @return + */ + @Override + @PostMapping(BUSINESS_EARLY_SAVE) + public R save(@RequestBody BusinessEarlyEntity entity) { + return R.status(businessEarlyService.save(entity)); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java new file mode 100644 index 0000000..0cbe996 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.business.early.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; + +/** + * @author ysj + */ +public interface BusinessEarlyMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml new file mode 100644 index 0000000..7ccae0f --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java new file mode 100644 index 0000000..6d31eda --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.business.early.service; + +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface BusinessEarlyService extends BaseService { + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java new file mode 100644 index 0000000..7281828 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.business.early.service.impl; + +import com.hnac.hzims.business.early.mapper.BusinessEarlyMapper; +import com.hnac.hzims.business.early.service.BusinessEarlyService; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +public class BusinessEarlyServiceImpl extends BaseServiceImpl implements BusinessEarlyService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java b/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java index ffa0e00..0d3f950 100644 --- a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java +++ b/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java @@ -1,5 +1,6 @@ package com.hnac.hzims.alarm; +import com.hnac.hzims.AlarmApplication; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest;