Commit 56a151a516667270db20b00ea79e3d8d0a1adfa2
1 parent
a7985eed
1、修改使用dubbo的controller创建过程,使用spring @Condition配置config工程的DubboConfigCondition判定是否创建
2、对应不使用dubbo的controller,使用spring @ConditionOnMissBean 判定是否创建 3、将TTInfoBx相关的服务代码拷贝到主项目中(防止不使用dubbo时这部分业务报错) 4、修改相关配置文件
Showing
16 changed files
with
230 additions
and
10 deletions
src/main/java/com/bsth/controller/schedule/core/LogController_facade.java
| 1 | 1 | package com.bsth.controller.schedule.core; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.dubbo.config.annotation.Reference; |
| 4 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 4 | 5 | import com.bsth.control_v2.plan_module.common.dto.schedule.log.ModuleOperatorLogDto; |
| 5 | 6 | import com.bsth.control_v2.plan_module.common.service.BServiceFacade; |
| 6 | 7 | import com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade; |
| 7 | 8 | import com.bsth.controller.schedule.BController_facade; |
| 9 | +import org.springframework.context.annotation.Conditional; | |
| 8 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | 11 | import org.springframework.web.bind.annotation.RestController; |
| 10 | 12 | |
| 11 | 13 | @RestController |
| 14 | +@Conditional(DubboConfigCondition.class) | |
| 12 | 15 | @RequestMapping("s_log") |
| 13 | 16 | public class LogController_facade extends BController_facade<Long, ModuleOperatorLogDto> { |
| 14 | 17 | @Reference | ... | ... |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
| ... | ... | @@ -5,9 +5,11 @@ import com.bsth.controller.schedule.BController; |
| 5 | 5 | import com.bsth.entity.schedule.SchedulePlan; |
| 6 | 6 | import com.bsth.service.schedule.SchedulePlanService; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 8 | 9 | import org.springframework.web.bind.annotation.PathVariable; |
| 9 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | 11 | import org.springframework.web.bind.annotation.RequestMethod; |
| 12 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | 13 | |
| 12 | 14 | import java.util.Date; |
| 13 | 15 | import java.util.HashMap; |
| ... | ... | @@ -16,8 +18,9 @@ import java.util.Map; |
| 16 | 18 | /** |
| 17 | 19 | * Created by xu on 16/6/16. |
| 18 | 20 | */ |
| 19 | -//@RestController | |
| 20 | -//@RequestMapping("spc") | |
| 21 | +@RestController | |
| 22 | +@ConditionalOnMissingBean(SchedulePlanController_facade.class) | |
| 23 | +@RequestMapping("spc") | |
| 21 | 24 | public class SchedulePlanController extends BController<SchedulePlan, Long> { |
| 22 | 25 | @Autowired |
| 23 | 26 | private SchedulePlanService schedulePlanService; | ... | ... |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController_facade.java
| ... | ... | @@ -2,6 +2,7 @@ package com.bsth.controller.schedule.core; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.dubbo.config.annotation.Reference; |
| 4 | 4 | import com.bsth.common.ResponseCode; |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | 6 | import com.bsth.control_v2.plan_module.common.dto.schedule.PlanDto; |
| 6 | 7 | import com.bsth.control_v2.plan_module.common.service.BServiceFacade; |
| 7 | 8 | import com.bsth.control_v2.plan_module.common.service.schedule.PlanGenerateFacade; |
| ... | ... | @@ -11,6 +12,7 @@ import com.bsth.controller.schedule.BController_facade; |
| 11 | 12 | import com.bsth.entity.schedule.SchedulePlan; |
| 12 | 13 | import com.bsth.service.schedule.SchedulePlanService; |
| 13 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.context.annotation.Conditional; | |
| 14 | 16 | import org.springframework.web.bind.annotation.PathVariable; |
| 15 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| 16 | 18 | import org.springframework.web.bind.annotation.RequestMethod; |
| ... | ... | @@ -21,6 +23,7 @@ import java.util.HashMap; |
| 21 | 23 | import java.util.Map; |
| 22 | 24 | |
| 23 | 25 | @RestController |
| 26 | +@Conditional(DubboConfigCondition.class) | |
| 24 | 27 | @RequestMapping("spc") |
| 25 | 28 | public class SchedulePlanController_facade extends BController_facade<Long, PlanDto> { |
| 26 | 29 | @Reference |
| ... | ... | @@ -84,7 +87,7 @@ public class SchedulePlanController_facade extends BController_facade<Long, Plan |
| 84 | 87 | */ |
| 85 | 88 | @Override |
| 86 | 89 | protected PlanDto saveExtend(PlanDto planDto) { |
| 87 | - planGenerateFacade.generatePlan(planDto); | |
| 90 | +// planGenerateFacade.generatePlan(planDto); | |
| 88 | 91 | return planDto; |
| 89 | 92 | } |
| 90 | 93 | ... | ... |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController.java
| ... | ... | @@ -5,6 +5,7 @@ import com.bsth.controller.schedule.BController; |
| 5 | 5 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 6 | 6 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 8 | 9 | import org.springframework.web.bind.annotation.*; |
| 9 | 10 | |
| 10 | 11 | import java.util.Date; |
| ... | ... | @@ -15,8 +16,9 @@ import java.util.Map; |
| 15 | 16 | /** |
| 16 | 17 | * Created by xu on 17/5/1. |
| 17 | 18 | */ |
| 18 | -//@RestController | |
| 19 | -//@RequestMapping("spic") | |
| 19 | +@RestController | |
| 20 | +@ConditionalOnMissingBean(SchedulePlanInfoController_facade.class) | |
| 21 | +@RequestMapping("spic") | |
| 20 | 22 | public class SchedulePlanInfoController extends BController<SchedulePlanInfo, Long> { |
| 21 | 23 | @Autowired |
| 22 | 24 | private SchedulePlanInfoService schedulePlanInfoService; | ... | ... |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController_facade.java
| ... | ... | @@ -2,12 +2,14 @@ package com.bsth.controller.schedule.core; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.dubbo.config.annotation.Reference; |
| 4 | 4 | import com.bsth.common.ResponseCode; |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | 6 | import com.bsth.control_v2.plan_module.common.dto.schedule.PlanInfoDto; |
| 6 | 7 | import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; |
| 7 | 8 | import com.bsth.control_v2.plan_module.common.service.BServiceFacade; |
| 8 | 9 | import com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade; |
| 9 | 10 | import com.bsth.control_v2.plan_module.common.utils.SystemInfoUtils; |
| 10 | 11 | import com.bsth.controller.schedule.BController_facade; |
| 12 | +import org.springframework.context.annotation.Conditional; | |
| 11 | 13 | import org.springframework.web.bind.annotation.PathVariable; |
| 12 | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | 15 | import org.springframework.web.bind.annotation.RequestMethod; |
| ... | ... | @@ -18,6 +20,7 @@ import java.util.HashMap; |
| 18 | 20 | import java.util.Map; |
| 19 | 21 | |
| 20 | 22 | @RestController |
| 23 | +@Conditional(DubboConfigCondition.class) | |
| 21 | 24 | @RequestMapping("spic") |
| 22 | 25 | public class SchedulePlanInfoController_facade extends BController_facade<Long, PlanInfoDto> { |
| 23 | 26 | @Reference | ... | ... |
src/main/java/com/bsth/controller/schedule/core/TTInfoBxDetailController.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.bsth.controller.schedule.BController; | |
| 4 | +import com.bsth.entity.schedule.TTInfoBxDetail; | |
| 5 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 7 | +import org.springframework.web.bind.annotation.RestController; | |
| 8 | + | |
| 9 | +@RestController | |
| 10 | +@ConditionalOnMissingBean(TTInfoBxDetailController_facade.class) | |
| 11 | +@RequestMapping("tibxdc") | |
| 12 | +public class TTInfoBxDetailController extends BController<TTInfoBxDetail, Long> { | |
| 13 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/TTInfoBxDetailController_facade.java
| 1 | 1 | package com.bsth.controller.schedule.core; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.dubbo.config.annotation.Reference; |
| 4 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 4 | 5 | import com.bsth.control_v2.plan_module.common.dto.schedule.timetable.TTInfoBxDetailDto; |
| 5 | 6 | import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; |
| 6 | 7 | import com.bsth.control_v2.plan_module.common.service.BServiceFacade; |
| 7 | 8 | import com.bsth.control_v2.plan_module.common.service.schedule.timetable.TTInfoBxDetailServiceFacade; |
| 8 | 9 | import com.bsth.controller.schedule.BController_facade; |
| 10 | +import org.springframework.context.annotation.Conditional; | |
| 9 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | 12 | import org.springframework.web.bind.annotation.RestController; |
| 11 | 13 | |
| 12 | 14 | import java.util.Date; |
| 13 | 15 | |
| 14 | 16 | @RestController |
| 17 | +@Conditional(DubboConfigCondition.class) | |
| 15 | 18 | @RequestMapping("tibxdc") |
| 16 | 19 | public class TTInfoBxDetailController_facade extends BController_facade<Long, TTInfoBxDetailDto> { |
| 17 | 20 | @Reference | ... | ... |
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
| ... | ... | @@ -10,6 +10,7 @@ import com.bsth.service.schedule.timetable.ExcelFormatType; |
| 10 | 10 | import com.bsth.service.schedule.utils.DataToolsFile; |
| 11 | 11 | import com.bsth.service.schedule.utils.DataToolsFileType; |
| 12 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
| 13 | 14 | import org.springframework.web.bind.annotation.*; |
| 14 | 15 | |
| 15 | 16 | import javax.servlet.http.HttpServletResponse; |
| ... | ... | @@ -21,8 +22,9 @@ import java.util.Map; |
| 21 | 22 | /** |
| 22 | 23 | * Created by xu on 17/1/4. |
| 23 | 24 | */ |
| 24 | -//@RestController | |
| 25 | -//@RequestMapping("tidc") | |
| 25 | +@RestController | |
| 26 | +@ConditionalOnMissingBean(TTInfoDetailController_facade.class) | |
| 27 | +@RequestMapping("tidc") | |
| 26 | 28 | public class TTInfoDetailController extends BController<TTInfoDetail, Long> { |
| 27 | 29 | @Autowired |
| 28 | 30 | private TTInfoDetailService ttInfoDetailService; | ... | ... |
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController_facade.java
| ... | ... | @@ -2,6 +2,7 @@ package com.bsth.controller.schedule.core; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.dubbo.config.annotation.Reference; |
| 4 | 4 | import com.bsth.common.ResponseCode; |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | 6 | import com.bsth.control_v2.plan_module.common.dto.schedule.timetable.TTInfoDetailDto; |
| 6 | 7 | import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; |
| 7 | 8 | import com.bsth.control_v2.plan_module.common.service.BServiceFacade; |
| ... | ... | @@ -11,6 +12,7 @@ import com.bsth.controller.schedule.BController_facade; |
| 11 | 12 | import com.bsth.service.schedule.TTInfoDetailService; |
| 12 | 13 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; |
| 13 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.context.annotation.Conditional; | |
| 14 | 16 | import org.springframework.web.bind.annotation.PathVariable; |
| 15 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| 16 | 18 | import org.springframework.web.bind.annotation.RequestMethod; |
| ... | ... | @@ -22,6 +24,7 @@ import java.util.List; |
| 22 | 24 | import java.util.Map; |
| 23 | 25 | |
| 24 | 26 | @RestController |
| 27 | +@Conditional(DubboConfigCondition.class) | |
| 25 | 28 | @RequestMapping("tidc") |
| 26 | 29 | public class TTInfoDetailController_facade extends BController_facade<Long, TTInfoDetailDto> { |
| 27 | 30 | @Reference | ... | ... |
src/main/java/com/bsth/entity/schedule/TTInfoBxDetail.java
0 → 100644
| 1 | +package com.bsth.entity.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.control_v2.plan_module.common.enums.ttinfo.BxType; | |
| 4 | +import com.bsth.entity.Line; | |
| 5 | +import com.bsth.entity.schedule.covert.BxTypeConverter; | |
| 6 | + | |
| 7 | +import javax.persistence.*; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 时刻表明细信息(班型信息)。 | |
| 11 | + */ | |
| 12 | +@Entity | |
| 13 | +@Table(name = "bsth_c_s_ttinfo_bx_detail") | |
| 14 | +public class TTInfoBxDetail extends BEntity { | |
| 15 | + | |
| 16 | + /** 主健Id */ | |
| 17 | + @Id | |
| 18 | + @GeneratedValue | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + | |
| 22 | + /** 关联线路 */ | |
| 23 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 24 | + private Line xl; | |
| 25 | + /** 线路版本(bsth_c_line_versions表对应字段) */ | |
| 26 | + @Column(nullable = false) | |
| 27 | + private int lineVersion; | |
| 28 | + /** 时刻表主对象关联 */ | |
| 29 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 30 | + private TTInfo ttinfo; | |
| 31 | + /** 关联的路牌 */ | |
| 32 | + @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) | |
| 33 | + private GuideboardInfo lp; | |
| 34 | + | |
| 35 | + /** 路牌班型1 */ | |
| 36 | + @Convert(converter = BxTypeConverter.class) | |
| 37 | + @Column(nullable = false) | |
| 38 | + private BxType bxType1; | |
| 39 | + /** 路牌班型2 */ | |
| 40 | + @Column(nullable = false) | |
| 41 | + @Convert(converter = BxTypeConverter.class) | |
| 42 | + private BxType bxType2; | |
| 43 | + /** 路牌配档数 */ | |
| 44 | + private String bxPds; | |
| 45 | + | |
| 46 | + /** 版本控制 */ | |
| 47 | + @Version | |
| 48 | + @Column(nullable = false) | |
| 49 | + private int version; | |
| 50 | + | |
| 51 | + // TODO: | |
| 52 | + | |
| 53 | + public Long getId() { | |
| 54 | + return id; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void setId(Long id) { | |
| 58 | + this.id = id; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public Line getXl() { | |
| 62 | + return xl; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setXl(Line xl) { | |
| 66 | + this.xl = xl; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public int getLineVersion() { | |
| 70 | + return lineVersion; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setLineVersion(int lineVersion) { | |
| 74 | + this.lineVersion = lineVersion; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public TTInfo getTtinfo() { | |
| 78 | + return ttinfo; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setTtinfo(TTInfo ttinfo) { | |
| 82 | + this.ttinfo = ttinfo; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public GuideboardInfo getLp() { | |
| 86 | + return lp; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setLp(GuideboardInfo lp) { | |
| 90 | + this.lp = lp; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public BxType getBxType1() { | |
| 94 | + return bxType1; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setBxType1(BxType bxType1) { | |
| 98 | + this.bxType1 = bxType1; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public BxType getBxType2() { | |
| 102 | + return bxType2; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setBxType2(BxType bxType2) { | |
| 106 | + this.bxType2 = bxType2; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public String getBxPds() { | |
| 110 | + return bxPds; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setBxPds(String bxPds) { | |
| 114 | + this.bxPds = bxPds; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public int getVersion() { | |
| 118 | + return version; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setVersion(int version) { | |
| 122 | + this.version = version; | |
| 123 | + } | |
| 124 | + | |
| 125 | +} | ... | ... |
src/main/java/com/bsth/entity/schedule/covert/BxTypeConverter.java
0 → 100644
| 1 | +package com.bsth.entity.schedule.covert; | |
| 2 | + | |
| 3 | +import com.bsth.control_v2.plan_module.common.enums.ttinfo.BxType; | |
| 4 | +import org.apache.commons.lang3.StringUtils; | |
| 5 | + | |
| 6 | +import javax.persistence.AttributeConverter; | |
| 7 | +import javax.persistence.Convert; | |
| 8 | + | |
| 9 | +@Convert | |
| 10 | +public class BxTypeConverter implements AttributeConverter<BxType, String> { | |
| 11 | + @Override | |
| 12 | + public String convertToDatabaseColumn(BxType attribute) { | |
| 13 | + return attribute.getDicDesc(); | |
| 14 | + } | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public BxType convertToEntityAttribute(String dbData) { | |
| 18 | + if (StringUtils.isEmpty(dbData)) { | |
| 19 | + return null; | |
| 20 | + } else { | |
| 21 | + return BxType.fromDicDesc(dbData); | |
| 22 | + } | |
| 23 | + | |
| 24 | + } | |
| 25 | +} | ... | ... |
src/main/java/com/bsth/repository/schedule/TTInfoBxDetailRepository.java
0 → 100644
| 1 | +package com.bsth.repository.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoBxDetail; | |
| 4 | +import com.bsth.repository.BaseRepository; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | + | |
| 7 | +@Repository | |
| 8 | +public interface TTInfoBxDetailRepository extends BaseRepository<TTInfoBxDetail, Long> { | |
| 9 | + | |
| 10 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/TTInfoBxDetailService.java
0 → 100644
src/main/java/com/bsth/service/schedule/TTInfoBxDetailServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoBxDetail; | |
| 4 | +import com.bsth.service.schedule.impl.BServiceImpl; | |
| 5 | +import org.springframework.stereotype.Service; | |
| 6 | +import org.springframework.transaction.annotation.Isolation; | |
| 7 | +import org.springframework.transaction.annotation.Propagation; | |
| 8 | +import org.springframework.transaction.annotation.Transactional; | |
| 9 | + | |
| 10 | +@Service | |
| 11 | +@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 12 | +public class TTInfoBxDetailServiceImpl extends BServiceImpl<TTInfoBxDetail, Long> implements TTInfoBxDetailService { | |
| 13 | + | |
| 14 | +} | ... | ... |
src/main/resources/application-prod.properties
| ... | ... | @@ -3,7 +3,7 @@ server.port=9088 |
| 3 | 3 | #management.address= 127.0.0.1 |
| 4 | 4 | management.security.enabled=false |
| 5 | 5 | management.context-path=/manage |
| 6 | -dubbo.use=true | |
| 6 | +dubbo.use=false | |
| 7 | 7 | |
| 8 | 8 | spring.jpa.hibernate.ddl-auto= update |
| 9 | 9 | spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | ... | ... |
src/main/resources/datatools/config-prod.properties
| ... | ... | @@ -5,11 +5,11 @@ datatools.kettle_properties=/datatools/kettle.properties |
| 5 | 5 | # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) |
| 6 | 6 | |
| 7 | 7 | #数据库ip地址 |
| 8 | -datatools.kvars_dbip=10.10.150.20 | |
| 8 | +datatools.kvars_dbip=10.10.200.121 | |
| 9 | 9 | #数据库用户名 |
| 10 | 10 | datatools.kvars_dbuname=root |
| 11 | 11 | #数据库密码 |
| 12 | -datatools.kvars_dbpwd=root2jsp@JSP | |
| 12 | +datatools.kvars_dbpwd=root2jsp | |
| 13 | 13 | #数据库库名 |
| 14 | 14 | datatools.kvars_dbdname=control |
| 15 | 15 | ... | ... |