a0a5851c007fb2cb4156f3ab151067cd4936cdff.svn-base 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package cn.com.goldenwater.dcproj.controller.tac;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
  5. import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
  6. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
  7. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  8. import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupPersService;
  9. import cn.com.goldenwater.id.util.UuidUtil;
  10. import com.github.pagehelper.PageInfo;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.slf4j.Logger;
  16. import org.slf4j.LoggerFactory;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.data.redis.core.RedisTemplate;
  19. import org.springframework.web.bind.annotation.*;
  20. import java.util.Base64;
  21. import java.util.List;
  22. /**
  23. * @author lune
  24. * @date 2019-9-6
  25. */
  26. @Api(value = "TAC 稽察组和人员关系表管理", tags = "TAC 稽察组和人员关系表管理")
  27. @RestController
  28. @RequestMapping("/tac/insp/year/batch/group/pers")
  29. public class TacInspYearBatchGroupPersController extends BaseController {
  30. private Logger logger = LoggerFactory.getLogger(getClass());
  31. @Autowired
  32. private TacInspYearBatchGroupPersService tacInspYearBatchGroupPersService;
  33. @Autowired
  34. private RedisTemplate redisTemplate;
  35. @Autowired
  36. private OlBisInspOrgService olBisInspOrgService;
  37. @ApiOperation(value = "添加/修改稽察组和人员关系表")
  38. @RequestMapping(value = "", method = RequestMethod.POST)
  39. public BaseResponse<TacInspYearBatchGroupPers> insert(@ApiParam(name = "tacInspYearBatchGroupPers", value = "TacInspYearBatchGroupPers", required = true) @RequestBody TacInspYearBatchGroupPers tacInspYearBatchGroupPers) {
  40. if (StringUtils.isBlank(tacInspYearBatchGroupPers.getId())) {
  41. String uuid = UuidUtil.uuid(); // 生成uuid
  42. tacInspYearBatchGroupPers.setId(uuid);
  43. tacInspYearBatchGroupPersService.insert(tacInspYearBatchGroupPers);
  44. } else {
  45. tacInspYearBatchGroupPersService.update(tacInspYearBatchGroupPers);
  46. }
  47. return buildSuccessResponse(tacInspYearBatchGroupPers);
  48. }
  49. @ApiOperation(value = "根据ID删除稽察组和人员关系表")
  50. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  51. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  52. int ret = tacInspYearBatchGroupPersService.delete(id);
  53. return buildSuccessResponse();
  54. }
  55. @ApiOperation(value = "根据ID获取稽察组和人员关系表(单表)")
  56. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  57. public BaseResponse<TacInspYearBatchGroupPers> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  58. TacInspYearBatchGroupPers tacInspYearBatchGroupPers = tacInspYearBatchGroupPersService.get(id);
  59. return buildSuccessResponse(tacInspYearBatchGroupPers);
  60. }
  61. @ApiOperation(value = "获取稽察组和人员关系表(列表所有)")
  62. @RequestMapping(value = "/list", method = RequestMethod.POST)
  63. public BaseResponse<List<TacInspYearBatchGroupPers>> list(@ApiParam(name = "tacInspYearBatchGroupPersParam", value = "tacInspYearBatchGroupPersParam", required = true) @RequestBody TacInspYearBatchGroupPersParam tacInspYearBatchGroupPersParam) {
  64. tacInspYearBatchGroupPersParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  65. List<TacInspYearBatchGroupPers> tacInspYearBatchGroupPersList = tacInspYearBatchGroupPersService.findList(tacInspYearBatchGroupPersParam);
  66. return buildSuccessResponse(tacInspYearBatchGroupPersList);
  67. }
  68. @ApiOperation(value = "获取稽察组和人员关系表(列表--分页)")
  69. @RequestMapping(value = "/page", method = RequestMethod.POST)
  70. public BaseResponse<PageInfo<TacInspYearBatchGroupPers>> page(@ApiParam(name = "tacInspYearBatchGroupPersParam", value = "tacInspYearBatchGroupPersParam", required = true) @RequestBody TacInspYearBatchGroupPersParam tacInspYearBatchGroupPersParam) {
  71. tacInspYearBatchGroupPersParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  72. PageInfo<TacInspYearBatchGroupPers> tacInspYearBatchGroupPersList = tacInspYearBatchGroupPersService.findPageInfo(tacInspYearBatchGroupPersParam);
  73. return buildSuccessResponse(tacInspYearBatchGroupPersList);
  74. }
  75. @ApiOperation(value = "保存督查组与人员关系")
  76. @RequestMapping(value = "/updateGroupPers", method = RequestMethod.POST)
  77. public BaseResponse updateGroupPers(@RequestBody TacInspYearBatchGroupDto groupDto) {
  78. groupDto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  79. int a = this.tacInspYearBatchGroupPersService.updateGroupPers(groupDto);
  80. return buildSuccessResponse();
  81. }
  82. @ApiOperation(value = "是否参加本次稽察")
  83. @RequestMapping(value = "/updateGroupPersInfo", method = RequestMethod.POST)
  84. public BaseResponse updateGroupPersInfo(@RequestBody TacInspYearBatchGroupPers group) {
  85. if (StringUtils.isBlank(group.getId())) {
  86. return buildFailResponse();
  87. }
  88. group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  89. int a = tacInspYearBatchGroupPersService.updateGroupPersInfo(group);
  90. if (a == 0) {
  91. return buildFailResponse();
  92. }
  93. return buildSuccessResponse();
  94. }
  95. @ApiOperation(value = "根据code查询是否参加")
  96. @RequestMapping(value = "/getGroupPerByCode", method = RequestMethod.POST)
  97. public BaseResponse getGroupPerByCode(@RequestBody TacInspYearBatchGroupPers group) {
  98. if (group == null) {
  99. return buildFailResponse(10010, "请传递正确参数");
  100. }
  101. Base64.Decoder decoder = Base64.getDecoder();
  102. String code = new String(decoder.decode(group.getPhone()));
  103. if (StringUtils.isBlank(code) || code.length() < 11) {
  104. return buildFailResponse(10010, "请传递正确参数");
  105. }
  106. String phone = code.substring(0, 11);
  107. String yearBatchId = code.substring(11);
  108. if (StringUtils.isBlank(group.getPhone())) {
  109. return buildFailResponse(10010, "手机不能为空");
  110. }
  111. Object value = redisTemplate.opsForValue().get(yearBatchId);
  112. if (value == null) {
  113. return buildFailResponse(10010, "确认参加时间已过");
  114. }
  115. group.setPhone(phone);
  116. group.setYearBatchId(yearBatchId);
  117. group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  118. TacInspYearBatchGroupPers groupPers = tacInspYearBatchGroupPersService.getGroupPerByCode(group);
  119. if (groupPers != null && StringUtils.isBlank(groupPers.getIsJoin())) {
  120. return buildFailResponse(10011, "不可重复选择");
  121. }
  122. return buildSuccessResponse(groupPers);
  123. }
  124. }