Commit 4ee0e2c56a44b5ad19e24573a5043f3afac178f8
1 parent
6ae9d134
iss提交4:
1、在consumer.xml中添加排班计划,验证,生成服务定义 2、修改schedulePlanController定义,添加facade定义
Showing
3 changed files
with
116 additions
and
3 deletions
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
| ... | ... | @@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 8 | import org.springframework.web.bind.annotation.PathVariable; |
| 9 | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
| 11 | -import org.springframework.web.bind.annotation.RestController; | |
| 12 | 11 | |
| 13 | 12 | import java.util.Date; |
| 14 | 13 | import java.util.HashMap; |
| ... | ... | @@ -17,8 +16,8 @@ import java.util.Map; |
| 17 | 16 | /** |
| 18 | 17 | * Created by xu on 16/6/16. |
| 19 | 18 | */ |
| 20 | -@RestController | |
| 21 | -@RequestMapping("spc") | |
| 19 | +//@RestController | |
| 20 | +//@RequestMapping("spc") | |
| 22 | 21 | public class SchedulePlanController extends BController<SchedulePlan, Long> { |
| 23 | 22 | @Autowired |
| 24 | 23 | private SchedulePlanService schedulePlanService; | ... | ... |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController_facade.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.dto.schedule.PlanDto; | |
| 6 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 7 | +import com.bsth.control_v2.plan_module.common.service.schedule.PlanGenerateFacade; | |
| 8 | +import com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade; | |
| 9 | +import com.bsth.control_v2.plan_module.common.service.schedule.validate.PlanPreValidateFacade; | |
| 10 | +import com.bsth.controller.schedule.BController_facade; | |
| 11 | +import com.bsth.entity.schedule.SchedulePlan; | |
| 12 | +import com.bsth.service.schedule.SchedulePlanService; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.web.bind.annotation.PathVariable; | |
| 15 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 17 | +import org.springframework.web.bind.annotation.RestController; | |
| 18 | + | |
| 19 | +import java.util.Date; | |
| 20 | +import java.util.HashMap; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +@RestController | |
| 24 | +@RequestMapping("spc") | |
| 25 | +public class SchedulePlanController_facade extends BController_facade<Long, PlanDto> { | |
| 26 | + @Reference | |
| 27 | + private PlanServiceFacade planServiceFacade; | |
| 28 | + @Reference | |
| 29 | + private PlanPreValidateFacade planPreValidateFacade; | |
| 30 | + @Reference | |
| 31 | + private PlanGenerateFacade planGenerateFacade; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + protected BServiceFacade<Long, PlanDto> getBServiceFacade() { | |
| 35 | + return planServiceFacade; | |
| 36 | + } | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 创建指定线路,指定时间范围内的排班计划,使用的时刻表情况 | |
| 40 | + * @param xlid 线路id | |
| 41 | + * @param from 开始时间 | |
| 42 | + * @param to 结束时间 | |
| 43 | + * @return | |
| 44 | + * @throws Exception | |
| 45 | + */ | |
| 46 | + @RequestMapping(value = "/valttinfo/{xlid}/{from}/{to}", method = RequestMethod.GET) | |
| 47 | + public Map<String, Object> validateTTInfo( | |
| 48 | + @PathVariable(value = "xlid") Integer xlid, | |
| 49 | + @PathVariable(value = "from") Date from, | |
| 50 | + @PathVariable(value = "to") Date to | |
| 51 | + ) throws Exception { | |
| 52 | + Map<String, Object> rtn = new HashMap<>(); | |
| 53 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 54 | + rtn.put("data", planPreValidateFacade.validateTTInfo(xlid, from, to)); | |
| 55 | + return rtn; | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 验证排班计划时间范围内规则的正确性。 | |
| 60 | + * @return | |
| 61 | + * @throws Exception | |
| 62 | + */ | |
| 63 | + @RequestMapping(value = "/valttrule/{xlid}/{from}/{to}", method = RequestMethod.GET) | |
| 64 | + public Map<String, Object> validateRule( | |
| 65 | + @PathVariable(value = "xlid") Integer xlid, | |
| 66 | + @PathVariable(value = "from") Date from, | |
| 67 | + @PathVariable(value = "to") Date to | |
| 68 | + ) throws Exception { | |
| 69 | + Map<String, Object> rtn = new HashMap<>(); | |
| 70 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 71 | + rtn.put("data", planPreValidateFacade.validateRule(xlid, from, to)); | |
| 72 | + return rtn; | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Override | |
| 76 | + protected boolean isSaveExtend() { | |
| 77 | + return true; | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 生成排班计划。 | |
| 82 | + * @param planDto | |
| 83 | + * @return | |
| 84 | + */ | |
| 85 | + @Override | |
| 86 | + protected PlanDto saveExtend(PlanDto planDto) { | |
| 87 | + planGenerateFacade.generatePlan(planDto); | |
| 88 | + return planDto; | |
| 89 | + } | |
| 90 | + | |
| 91 | + //------------------------- 以下是还未服务话的功能 --------------------------// | |
| 92 | + @Autowired | |
| 93 | + private SchedulePlanService schedulePlanService; | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * 获取明天的一歌排班计划。 | |
| 97 | + * @return | |
| 98 | + * @throws Exception | |
| 99 | + */ | |
| 100 | + @RequestMapping(value = "/tommorw", method = RequestMethod.GET) | |
| 101 | + public SchedulePlan getTommorwPlan() throws Exception { | |
| 102 | + try { | |
| 103 | + return schedulePlanService.findSchedulePlanTommorw(); | |
| 104 | + } catch (Exception exp) { | |
| 105 | + throw new Exception(exp.getCause()); | |
| 106 | + } | |
| 107 | + } | |
| 108 | +} | ... | ... |
src/main/resources/dubbo/applicationContext_dubbo_consumer.xml
| ... | ... | @@ -20,7 +20,13 @@ |
| 20 | 20 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade" id="logServiceFacadeImpl" check="false" /> |
| 21 | 21 | |
| 22 | 22 | <!-- TODO:还有其他排班计划服务 --> |
| 23 | + <!-- 排班计划查询服务 --> | |
| 24 | + <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade" id="planServiceFacadeImpl" check="false" /> | |
| 23 | 25 | <!-- 排班明细查询服务 --> |
| 24 | 26 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade" id="planInfoServiceFacadeImpl" check="false" /> |
| 27 | + <!-- 排班前置验证服务 --> | |
| 28 | + <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.validate.PlanPreValidateFacade" id="planPreValidateFacadeImpl" check="false" /> | |
| 29 | + <!-- 排班生成服务 --> | |
| 30 | + <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanGenerateFacade" ref="planGenerateFacadeImpl" check="false" /> | |
| 25 | 31 | |
| 26 | 32 | </beans> |
| 27 | 33 | \ No newline at end of file | ... | ... |