Commit cf2081a89d674da4435f7333d172808b32caad5c
1 parent
45862b32
1、添加BControl_facade基础类
2、添加排班明细信息facade控制器 3、修改dubbo消费端配置,添加排班明细服务
Showing
6 changed files
with
254 additions
and
43 deletions
pom.xml
| @@ -301,6 +301,7 @@ | @@ -301,6 +301,7 @@ | ||
| 301 | <dependency> | 301 | <dependency> |
| 302 | <groupId>com.alibaba</groupId> | 302 | <groupId>com.alibaba</groupId> |
| 303 | <artifactId>dubbo</artifactId> | 303 | <artifactId>dubbo</artifactId> |
| 304 | + <!--<version>2.6.3</version>--> | ||
| 304 | <version>2.5.3</version> | 305 | <version>2.5.3</version> |
| 305 | <exclusions> | 306 | <exclusions> |
| 306 | <exclusion> | 307 | <exclusion> |
| @@ -327,6 +328,20 @@ | @@ -327,6 +328,20 @@ | ||
| 327 | <artifactId>zkclient</artifactId> | 328 | <artifactId>zkclient</artifactId> |
| 328 | <version>0.3</version> | 329 | <version>0.3</version> |
| 329 | </dependency> | 330 | </dependency> |
| 331 | + | ||
| 332 | + <!--<dependency>--> | ||
| 333 | + <!--<groupId>org.apache.curator</groupId>--> | ||
| 334 | + <!--<artifactId>curator-framework</artifactId>--> | ||
| 335 | + <!--<version>4.0.1</version>--> | ||
| 336 | + <!--<type>bundle</type>--> | ||
| 337 | + <!--</dependency>--> | ||
| 338 | + | ||
| 339 | + <!--<dependency>--> | ||
| 340 | + <!--<groupId>org.apache.curator</groupId>--> | ||
| 341 | + <!--<artifactId>curator-recipes</artifactId>--> | ||
| 342 | + <!--<version>4.0.1</version>--> | ||
| 343 | + <!--<type>bundle</type>--> | ||
| 344 | + <!--</dependency>--> | ||
| 330 | <!-- dubbo 需要的jar end --> | 345 | <!-- dubbo 需要的jar end --> |
| 331 | 346 | ||
| 332 | <!-- common工程依赖 --> | 347 | <!-- common工程依赖 --> |
| @@ -371,6 +386,13 @@ | @@ -371,6 +386,13 @@ | ||
| 371 | <groupId>org.springframework.boot</groupId> | 386 | <groupId>org.springframework.boot</groupId> |
| 372 | <artifactId>spring-boot-maven-plugin</artifactId> | 387 | <artifactId>spring-boot-maven-plugin</artifactId> |
| 373 | </plugin> | 388 | </plugin> |
| 389 | + | ||
| 390 | + <!--<plugin>--> | ||
| 391 | + <!--<groupId>org.apache.felix</groupId>--> | ||
| 392 | + <!--<artifactId>maven-bundle-plugin</artifactId>--> | ||
| 393 | + <!--<extensions>true</extensions>--> | ||
| 394 | + <!--</plugin>--> | ||
| 395 | + | ||
| 374 | </plugins> | 396 | </plugins> |
| 375 | <resources> | 397 | <resources> |
| 376 | <resource> | 398 | <resource> |
src/main/java/com/bsth/controller/schedule/BController_facade.java
0 → 100644
| 1 | +package com.bsth.controller.schedule; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.Constants; | ||
| 4 | +import com.bsth.common.ResponseCode; | ||
| 5 | +import com.bsth.control_v2.plan_module.common.dto.PageRequestDto; | ||
| 6 | +import com.bsth.control_v2.plan_module.common.exception.PlanModuleException; | ||
| 7 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | ||
| 8 | +import com.bsth.entity.sys.SysUser; | ||
| 9 | +import com.bsth.service.sys.SysUserService; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.web.bind.annotation.*; | ||
| 12 | + | ||
| 13 | +import javax.servlet.http.HttpSession; | ||
| 14 | +import java.io.Serializable; | ||
| 15 | +import java.util.Date; | ||
| 16 | +import java.util.HashMap; | ||
| 17 | +import java.util.List; | ||
| 18 | +import java.util.Map; | ||
| 19 | + | ||
| 20 | +public class BController_facade<Id extends Serializable, DTO> { | ||
| 21 | + @Autowired | ||
| 22 | + private BServiceFacade<Id, DTO> bServiceFacade; | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + private SysUserService sysUserService; | ||
| 26 | + | ||
| 27 | + //---------------- 设置操作用户 ----------------// | ||
| 28 | + public void setCreateUserInfo(DTO dto, Integer userId, Date createDate) { | ||
| 29 | + throw new PlanModuleException("子类必须override setCUserInfo方法!"); | ||
| 30 | + } | ||
| 31 | + public void setUpdateUserInfo(DTO dto, Integer userId, Date updateDate) { | ||
| 32 | + throw new PlanModuleException("子类必须override setUpdateUserInfo方法!"); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + //---------------- CRUD 操作 ----------------// | ||
| 36 | + // Create操作 | ||
| 37 | + @RequestMapping(method = RequestMethod.POST) | ||
| 38 | + public Map<String, Object> save(@RequestBody DTO dto, HttpSession httpSession) { | ||
| 39 | + String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | ||
| 40 | + SysUser sysUser = sysUserService.findByUserName(userName); | ||
| 41 | + setCreateUserInfo(dto, sysUser.getId(), new Date()); | ||
| 42 | + setUpdateUserInfo(dto, sysUser.getId(), new Date()); | ||
| 43 | + | ||
| 44 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 45 | + try { | ||
| 46 | + DTO dto_saved = bServiceFacade.save(dto); | ||
| 47 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 48 | + rtn.put("data", dto_saved); | ||
| 49 | + } catch (Exception exp) { | ||
| 50 | + rtn.put("status", ResponseCode.ERROR); | ||
| 51 | + rtn.put("msg", exp.getMessage()); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + return rtn; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + // Update操作 | ||
| 58 | + @RequestMapping(value="/{id}", method = RequestMethod.POST) | ||
| 59 | + public Map<String, Object> update(@RequestBody DTO dto, HttpSession httpSession) { | ||
| 60 | + String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | ||
| 61 | + SysUser sysUser = sysUserService.findByUserName(userName); | ||
| 62 | + setUpdateUserInfo(dto, sysUser.getId(), new Date()); | ||
| 63 | + | ||
| 64 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 65 | + try { | ||
| 66 | + DTO dto_updated = bServiceFacade.save(dto); | ||
| 67 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 68 | + rtn.put("data", dto_updated); | ||
| 69 | + } catch (Exception exp) { | ||
| 70 | + rtn.put("status", ResponseCode.ERROR); | ||
| 71 | + rtn.put("msg", exp.getMessage()); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + return rtn; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + // Research操作 | ||
| 78 | + @RequestMapping(value = "/{id}", method = RequestMethod.GET) | ||
| 79 | + public Map<String, Object> findById(@PathVariable("id") Id id) { | ||
| 80 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 81 | + try { | ||
| 82 | + DTO dto = bServiceFacade.findById(id); | ||
| 83 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 84 | + rtn.put("data", dto); | ||
| 85 | + } catch (Exception exp) { | ||
| 86 | + rtn.put("status", ResponseCode.ERROR); | ||
| 87 | + rtn.put("msg", exp.getMessage()); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + return rtn; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // 查询所有操作 | ||
| 94 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | ||
| 95 | + public Map<String, Object> list(@RequestParam Map<String, Object> param) { | ||
| 96 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 97 | + try { | ||
| 98 | + List<DTO> tList = bServiceFacade.list(param); | ||
| 99 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 100 | + rtn.put("data", tList); | ||
| 101 | + } catch (Exception exp) { | ||
| 102 | + rtn.put("status", ResponseCode.ERROR); | ||
| 103 | + rtn.put("msg", exp.getMessage()); | ||
| 104 | + } | ||
| 105 | + return rtn; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + // 分页查询操作 | ||
| 109 | + @RequestMapping(method = RequestMethod.GET) | ||
| 110 | + public Map<String, Object> list( | ||
| 111 | + @RequestParam Map<String, Object> map, | ||
| 112 | + @RequestParam(defaultValue = "0") int page, | ||
| 113 | + @RequestParam(defaultValue = "10") int size, | ||
| 114 | + @RequestParam(defaultValue = "id") String order, | ||
| 115 | + @RequestParam(defaultValue = "DESC") String direction) { | ||
| 116 | + PageRequestDto pageRequestDto = PageRequestDto.getBuilder() | ||
| 117 | + .setPage(page) | ||
| 118 | + .setSize(size) | ||
| 119 | + .setOrder(order) | ||
| 120 | + .setDirection(direction) | ||
| 121 | + .build(); | ||
| 122 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 123 | + try { | ||
| 124 | + rtn.put("data", bServiceFacade.list(map, pageRequestDto)); | ||
| 125 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 126 | + } catch (Exception exp) { | ||
| 127 | + rtn.put("status", ResponseCode.ERROR); | ||
| 128 | + rtn.put("msg", exp.getMessage()); | ||
| 129 | + } | ||
| 130 | + return rtn; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + // Delete操作 | ||
| 134 | + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) | ||
| 135 | + public Map<String, Object> delete(@PathVariable("id") Id id, HttpSession httpSession) { | ||
| 136 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 137 | + try { | ||
| 138 | + // 由于种种原因,这里不保存用户和操作时间了 | ||
| 139 | + bServiceFacade.delete(id); | ||
| 140 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 141 | + } catch (Exception exp) { | ||
| 142 | + rtn.put("status", ResponseCode.ERROR); | ||
| 143 | + rtn.put("msg", exp.getMessage()); | ||
| 144 | + } | ||
| 145 | + return rtn; | ||
| 146 | + } | ||
| 147 | +} |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController_dubbo.java
| 1 | package com.bsth.controller.schedule.core; | 1 | package com.bsth.controller.schedule.core; |
| 2 | 2 | ||
| 3 | -import com.bsth.common.ResponseCode; | ||
| 4 | -import com.bsth.control_v2.plan_module.common.dto.PageRequestDto; | ||
| 5 | -import com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade; | ||
| 6 | -import com.google.common.base.Splitter; | ||
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | -import org.springframework.data.domain.PageRequest; | ||
| 9 | -import org.springframework.data.domain.Sort; | 3 | +import com.bsth.control_v2.plan_module.common.dto.schedule.PlanDto; |
| 4 | +import com.bsth.controller.schedule.BController_facade; | ||
| 10 | import org.springframework.web.bind.annotation.RequestMapping; | 5 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 12 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 13 | import org.springframework.web.bind.annotation.RestController; | 6 | import org.springframework.web.bind.annotation.RestController; |
| 14 | 7 | ||
| 15 | -import java.util.ArrayList; | ||
| 16 | -import java.util.HashMap; | ||
| 17 | -import java.util.List; | ||
| 18 | -import java.util.Map; | ||
| 19 | - | ||
| 20 | @RestController | 8 | @RestController |
| 21 | @RequestMapping("spc") | 9 | @RequestMapping("spc") |
| 22 | -public class SchedulePlanController_dubbo { | ||
| 23 | - @Autowired | ||
| 24 | - private PlanServiceFacade planServiceFacade; | ||
| 25 | - | ||
| 26 | - //---------------- CRUD 操作 ----------------// | ||
| 27 | - // 分页查询操作 | ||
| 28 | - @RequestMapping(method = RequestMethod.GET) | ||
| 29 | - public Map<String, Object> list( | ||
| 30 | - @RequestParam Map<String, Object> map, | ||
| 31 | - @RequestParam(defaultValue = "0") int page, | ||
| 32 | - @RequestParam(defaultValue = "10") int size, | ||
| 33 | - @RequestParam(defaultValue = "id") String order, | ||
| 34 | - @RequestParam(defaultValue = "DESC") String direction) { | ||
| 35 | - | ||
| 36 | - PageRequestDto pageRequestDto = PageRequestDto.getBuilder() | ||
| 37 | - .setPage(page) | ||
| 38 | - .setSize(size) | ||
| 39 | - .setOrder(order) | ||
| 40 | - .setDirection(direction) | ||
| 41 | - .build(); | ||
| 42 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 43 | - rtn.put("data", planServiceFacade.list(map, pageRequestDto)); | ||
| 44 | - rtn.put("status", ResponseCode.SUCCESS); | ||
| 45 | - return rtn; | ||
| 46 | - | ||
| 47 | - } | 10 | +public class SchedulePlanController_dubbo extends BController_facade<Long, PlanDto> { |
| 48 | 11 | ||
| 49 | // TODO | 12 | // TODO |
| 50 | } | 13 | } |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController.java
| @@ -15,8 +15,8 @@ import java.util.Map; | @@ -15,8 +15,8 @@ import java.util.Map; | ||
| 15 | /** | 15 | /** |
| 16 | * Created by xu on 17/5/1. | 16 | * Created by xu on 17/5/1. |
| 17 | */ | 17 | */ |
| 18 | -@RestController | ||
| 19 | -@RequestMapping("spic") | 18 | +//@RestController |
| 19 | +//@RequestMapping("spic") | ||
| 20 | public class SchedulePlanInfoController extends BController<SchedulePlanInfo, Long> { | 20 | public class SchedulePlanInfoController extends BController<SchedulePlanInfo, Long> { |
| 21 | @Autowired | 21 | @Autowired |
| 22 | private SchedulePlanInfoService schedulePlanInfoService; | 22 | private SchedulePlanInfoService schedulePlanInfoService; |
src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController_dubbo.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 4 | +import com.bsth.control_v2.plan_module.common.dto.schedule.PlanInfoDto; | ||
| 5 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | ||
| 6 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | ||
| 7 | +import com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade; | ||
| 8 | +import com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade; | ||
| 9 | +import com.bsth.controller.schedule.BController_facade; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 14 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | + | ||
| 16 | +import java.util.Date; | ||
| 17 | +import java.util.HashMap; | ||
| 18 | +import java.util.Map; | ||
| 19 | + | ||
| 20 | +@RestController | ||
| 21 | +@RequestMapping("spic") | ||
| 22 | +public class SchedulePlanInfoController_dubbo extends BController_facade<Long, PlanInfoDto> { | ||
| 23 | + @Autowired | ||
| 24 | + private PlanInfoServiceFacade planInfoServiceFacade; | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void setCreateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date createDate) { | ||
| 28 | + UserDto userDto = UserDto.getBuilder() | ||
| 29 | + .setId(userId) | ||
| 30 | + .build(); | ||
| 31 | + planInfoDto.setCreateBy(userDto); | ||
| 32 | + planInfoDto.setCreateDate(createDate); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void setUpdateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date updateDate) { | ||
| 37 | + UserDto userDto = UserDto.getBuilder() | ||
| 38 | + .setId(userId) | ||
| 39 | + .build(); | ||
| 40 | + planInfoDto.setUpdateBy(userDto); | ||
| 41 | + planInfoDto.setUpdateDate(updateDate); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @RequestMapping(value = "/groupextinfos/{xlid}/{date}", method = RequestMethod.GET) | ||
| 45 | + public Map<String, Object> findGroupInfoExt( | ||
| 46 | + @PathVariable(value = "xlid") Integer xlid, | ||
| 47 | + @PathVariable(value = "date") Date scheduleDate) { | ||
| 48 | + Map<String, Object> resultMap = new HashMap<>(); | ||
| 49 | + try { | ||
| 50 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 51 | + resultMap.put("data", planInfoServiceFacade.findPlanGroupInfo(xlid, scheduleDate)); | ||
| 52 | + | ||
| 53 | + } catch (Exception exp) { | ||
| 54 | + exp.printStackTrace(); | ||
| 55 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 56 | + resultMap.put("msg", exp.getLocalizedMessage()); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + return resultMap; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @RequestMapping(value = "/lastestsd/{xlid}", method = RequestMethod.GET) | ||
| 63 | + public Map<String, Object> findLastestPlanInfoDate( | ||
| 64 | + @PathVariable(value = "xlid") Integer xlid) { | ||
| 65 | + Map<String, Object> resultMap = new HashMap<>(); | ||
| 66 | + try { | ||
| 67 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 68 | + resultMap.put("data", planInfoServiceFacade.findLastestPlanInfoDate(xlid)); | ||
| 69 | + | ||
| 70 | + } catch (Exception exp) { | ||
| 71 | + exp.printStackTrace(); | ||
| 72 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 73 | + resultMap.put("msg", exp.getLocalizedMessage()); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + return resultMap; | ||
| 77 | + } | ||
| 78 | +} |
src/main/resources/dubbo/applicationContext_dubbo_consumer.xml
| @@ -12,8 +12,9 @@ | @@ -12,8 +12,9 @@ | ||
| 12 | <!-- 注册中心地址 --> | 12 | <!-- 注册中心地址 --> |
| 13 | <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181" /> | 13 | <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181" /> |
| 14 | 14 | ||
| 15 | - <!-- 用户服务接口 --> | 15 | + <!-- 计划排班服务接口 --> |
| 16 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade" id="planServiceFacadeImpl" check="false" /> | 16 | <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade" id="planServiceFacadeImpl" check="false" /> |
| 17 | + <dubbo:reference interface="com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade" id="planInfoServiceFacadeImpl" check="false" /> | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | </beans> | 20 | </beans> |
| 20 | \ No newline at end of file | 21 | \ No newline at end of file |