| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- package cn.com.goldenwater.dcproj.controller.tac;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.dto.TacInspYearBatchGroupDto;
- import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupPersService;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.web.bind.annotation.*;
- import java.util.Base64;
- import java.util.List;
- /**
- * @author lune
- * @date 2019-9-6
- */
- @Api(value = "TAC 稽察组和人员关系表管理", tags = "TAC 稽察组和人员关系表管理")
- @RestController
- @RequestMapping("/tac/insp/year/batch/group/pers")
- public class TacInspYearBatchGroupPersController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacInspYearBatchGroupPersService tacInspYearBatchGroupPersService;
- @Autowired
- private RedisTemplate redisTemplate;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @ApiOperation(value = "添加/修改稽察组和人员关系表")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacInspYearBatchGroupPers> insert(@ApiParam(name = "tacInspYearBatchGroupPers", value = "TacInspYearBatchGroupPers", required = true) @RequestBody TacInspYearBatchGroupPers tacInspYearBatchGroupPers) {
- if (StringUtils.isBlank(tacInspYearBatchGroupPers.getId())) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- tacInspYearBatchGroupPers.setId(uuid);
- tacInspYearBatchGroupPersService.insert(tacInspYearBatchGroupPers);
- } else {
- tacInspYearBatchGroupPersService.update(tacInspYearBatchGroupPers);
- }
- return buildSuccessResponse(tacInspYearBatchGroupPers);
- }
- @ApiOperation(value = "根据ID删除稽察组和人员关系表")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = tacInspYearBatchGroupPersService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取稽察组和人员关系表(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacInspYearBatchGroupPers> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacInspYearBatchGroupPers tacInspYearBatchGroupPers = tacInspYearBatchGroupPersService.get(id);
- return buildSuccessResponse(tacInspYearBatchGroupPers);
- }
- @ApiOperation(value = "获取稽察组和人员关系表(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<TacInspYearBatchGroupPers>> list(@ApiParam(name = "tacInspYearBatchGroupPersParam", value = "tacInspYearBatchGroupPersParam", required = true) @RequestBody TacInspYearBatchGroupPersParam tacInspYearBatchGroupPersParam) {
- tacInspYearBatchGroupPersParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- List<TacInspYearBatchGroupPers> tacInspYearBatchGroupPersList = tacInspYearBatchGroupPersService.findList(tacInspYearBatchGroupPersParam);
- return buildSuccessResponse(tacInspYearBatchGroupPersList);
- }
- @ApiOperation(value = "获取稽察组和人员关系表(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacInspYearBatchGroupPers>> page(@ApiParam(name = "tacInspYearBatchGroupPersParam", value = "tacInspYearBatchGroupPersParam", required = true) @RequestBody TacInspYearBatchGroupPersParam tacInspYearBatchGroupPersParam) {
- tacInspYearBatchGroupPersParam.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- PageInfo<TacInspYearBatchGroupPers> tacInspYearBatchGroupPersList = tacInspYearBatchGroupPersService.findPageInfo(tacInspYearBatchGroupPersParam);
- return buildSuccessResponse(tacInspYearBatchGroupPersList);
- }
- @ApiOperation(value = "保存督查组与人员关系")
- @RequestMapping(value = "/updateGroupPers", method = RequestMethod.POST)
- public BaseResponse updateGroupPers(@RequestBody TacInspYearBatchGroupDto groupDto) {
- groupDto.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = this.tacInspYearBatchGroupPersService.updateGroupPers(groupDto);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "是否参加本次稽察")
- @RequestMapping(value = "/updateGroupPersInfo", method = RequestMethod.POST)
- public BaseResponse updateGroupPersInfo(@RequestBody TacInspYearBatchGroupPers group) {
- if (StringUtils.isBlank(group.getId())) {
- return buildFailResponse();
- }
- group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- int a = tacInspYearBatchGroupPersService.updateGroupPersInfo(group);
- if (a == 0) {
- return buildFailResponse();
- }
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据code查询是否参加")
- @RequestMapping(value = "/getGroupPerByCode", method = RequestMethod.POST)
- public BaseResponse getGroupPerByCode(@RequestBody TacInspYearBatchGroupPers group) {
- if (group == null) {
- return buildFailResponse(10010, "请传递正确参数");
- }
- Base64.Decoder decoder = Base64.getDecoder();
- String code = new String(decoder.decode(group.getPhone()));
- if (StringUtils.isBlank(code) || code.length() < 11) {
- return buildFailResponse(10010, "请传递正确参数");
- }
- String phone = code.substring(0, 11);
- String yearBatchId = code.substring(11);
- if (StringUtils.isBlank(group.getPhone())) {
- return buildFailResponse(10010, "手机不能为空");
- }
- Object value = redisTemplate.opsForValue().get(yearBatchId);
- if (value == null) {
- return buildFailResponse(10010, "确认参加时间已过");
- }
- group.setPhone(phone);
- group.setYearBatchId(yearBatchId);
- group.setProvince(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- TacInspYearBatchGroupPers groupPers = tacInspYearBatchGroupPersService.getGroupPerByCode(group);
- if (groupPers != null && StringUtils.isBlank(groupPers.getIsJoin())) {
- return buildFailResponse(10011, "不可重复选择");
- }
- return buildSuccessResponse(groupPers);
- }
- }
|