huanghongfa
2021-06-07 8788a78ad30c1bb9d50d91b10e76d3ae47ed8da2
springcloud_k8s_panzhihuazhihuishequ/grid_app/src/main/java/com/panzhihua/grid_app/api/EventApi.java
@@ -5,8 +5,8 @@
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.utlis.ClazzUtils;
import com.panzhihua.common.utlis.IdCardUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -17,7 +17,6 @@
import javax.annotation.Resource;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventVO;
/**
 *
@@ -29,92 +28,11 @@
@Slf4j
@RestController
@RequestMapping("/event")
@Api(tags = {"事件-突发/矛盾纠纷事件/治安隐患/不稳定因素/公共服务 @陈东"})
@Api(tags = {"网格综治事件管理 @chendong", "宣传教育 @chendong","特殊人群上报(开发中..) @chendong"})
public class EventApi extends BaseController {
    @Resource
    private GridService gridService;
    private boolean isDefaultType(Integer eventType){
        if(eventType==null){
            return false;
        }
        boolean inType = eventType==1 | eventType==2 |eventType==3| eventType==4| eventType==5;
        return inType;
    }
    /**
     * 事件列表
     * @param pageEventDTO 查找事件
     * @return 查找结果
     */
    @GetMapping("/usersList")
    @ApiOperation(value = "事件列表", response= EventVO.class)
    R usersList(@Validated @ModelAttribute PageEventDTO pageEventDTO){
        ClazzUtils.setIfStringIsEmpty(pageEventDTO);
        if(!isDefaultType(pageEventDTO.getEventType())){
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        pageEventDTO.setUserId(loginUserInfoVO.getUserId());
        return gridService.query(pageEventDTO);
    }
    /**
     * 新增事件
     * @param {classNameFirstLower}AddDTO 添加事件传递对象
     * @return 新增结果
     */
    @PostMapping("/release")
    @ApiOperation(value = "发布事件(直接)", response = R.class)
    R add(@Validated @RequestBody CommonEventAddDTO commonEventAddDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventAddDTO);
        if(!isDefaultType(commonEventAddDTO.getEventType())){
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventAddDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventAddDTO.setUserName(loginUserInfoVO.getName());
        commonEventAddDTO.setPhone(loginUserInfoVO.getPhone());
        return gridService.addCommon(commonEventAddDTO);
    }
    /**
     * 保存草稿
     * @param commonEventEditDTO 保存草稿传递对象
     * @return 新增结果
     */
    @PostMapping("/draft")
    @ApiOperation(value = "保存草稿", response = R.class)
    R saveDraft(@Validated @RequestBody CommonEventEditDTO commonEventEditDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventEditDTO);
        ClazzUtils.setIfStringIsEmpty(commonEventEditDTO);
        if(!isDefaultType(commonEventEditDTO.getEventType())){
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventEditDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventEditDTO.setUserName(loginUserInfoVO.getName());
        commonEventEditDTO.setPhone(loginUserInfoVO.getPhone());
        return gridService.saveDraft(commonEventEditDTO);
    }
    /**
     * 上报社区
     * @param commonEventReportDTO 上报社区传递对象
     * @return 上报结果
     */
    @PutMapping("/report")
    @ApiOperation(value = "上报社区", response = R.class)
    R report(@Validated @RequestBody CommonEventReportDTO commonEventReportDTO){
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        ClazzUtils.setIfStringIsEmpty(commonEventReportDTO);
        commonEventReportDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventReportDTO.setUserName(loginUserInfoVO.getName());
        return gridService.report(commonEventReportDTO);
    }
    /**
     * 撤销事件
@@ -125,53 +43,10 @@
    @ApiOperation(value = "撤销事件", response = R.class)
    R revoke(@Validated @RequestBody EventRevokeDTO eventRevokeDTO){
        ClazzUtils.setIfStringIsEmpty(eventRevokeDTO);
        eventRevokeDTO.setUserId(getUserId());
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        eventRevokeDTO.setUserId(loginUserInfoVO.getUserId());
        eventRevokeDTO.setUserName(loginUserInfoVO.getNickName());
        return gridService.emergenciesRevoke(eventRevokeDTO);
    }
    /**
     * 处理事件
     * @param commonEventDealDTO 修改事件传递对象
     * @return 处理结果
     */
    @PutMapping("/deal")
    @ApiOperation(value = "处理事件", response = R.class)
    R deal(@Validated @RequestBody CommonEventDealDTO commonEventDealDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventDealDTO);
        LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO();
        commonEventDealDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventDealDTO.setUserName(loginUserInfoVO.getName());
        return gridService.dealEvent(commonEventDealDTO);
    }
    /**
     * 验证事件
     * @param commonEventVerifyDTO 验证事件传递对象
     * @return 验证结果
     */
    @PutMapping("/verify")
    @ApiOperation(value = "验证事件", response = R.class)
    R verify(@Validated @RequestBody CommonEventVerifyDTO commonEventVerifyDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventVerifyDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventVerifyDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventVerifyDTO.setUserName(loginUserInfoVO.getName());
        return gridService.verifyEvent(commonEventVerifyDTO);
    }
    /**
     * 重新发布事件
     * @param commonEventRepublicDTO 重新发布事件传递对象
     * @return 修改结果
     */
    @PutMapping("/republish")
    @ApiOperation(value = "重新发布事件", response = R.class)
    R republish(@Validated @RequestBody CommonEventRepublicDTO commonEventRepublicDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventRepublicDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventRepublicDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventRepublicDTO.setUserName(loginUserInfoVO.getName());
        return gridService.republishEvent(commonEventRepublicDTO);
    }
    /**
@@ -186,6 +61,33 @@
    }
    /**
     * 删除
     * @param eventDeleteDTO 删除事件传递对象
     * @return 删除结果
     */
    @DeleteMapping()
    @ApiOperation(value = "删除事件", response = R.class)
    R delete(@Validated @RequestBody EventDeleteDTO  eventDeleteDTO){
        ClazzUtils.setIfStringIsEmpty(eventDeleteDTO);
        return gridService.delete(eventDeleteDTO);
    }
    /**
     * 重新发布事件
     * @param commonEventRepublishDTO 重新发布事件传递对象
     * @return 修改结果
     */
    @PutMapping("/republish")
    @ApiOperation(value = "重新发布事件", response = R.class)
    R republish(@Validated @RequestBody CommonEventRepublishDTO commonEventRepublishDTO){
        ClazzUtils.setIfStringIsEmpty(commonEventRepublishDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventRepublishDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventRepublishDTO.setUserName(loginUserInfoVO.getNickName());
        return gridService.republishEvent(commonEventRepublishDTO);
    }
    /**
     * 发布草稿
     * @param commonEventPublicDTO 添加事件传递对象
     * @return 新增结果
@@ -196,57 +98,17 @@
        ClazzUtils.setIfStringIsEmpty(commonEventPublicDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventPublicDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventPublicDTO.setUserName(loginUserInfoVO.getName());
        commonEventPublicDTO.setUserName(loginUserInfoVO.getNickName());
        return gridService.draftRelease(commonEventPublicDTO);
    }
    //---
    //---
    /**
     * 添加特殊人群
     * @param specialEventAddDTO 特殊人群信息
     * 查询社区列表
     * @return 查找结果
     */
    @PostMapping("/special")
    @ApiOperation(value = "添加特殊人群")
    R addSpecial(@Validated @RequestBody SpecialEventAddDTO specialEventAddDTO){
        ClazzUtils.setIfStringIsEmpty(specialEventAddDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        specialEventAddDTO.setUserId(loginUserInfoVO.getUserId());
        specialEventAddDTO.setUserName(loginUserInfoVO.getName());
        specialEventAddDTO.setPhone(loginUserInfoVO.getPhone());
        return gridService.addSpecial(specialEventAddDTO);
    @GetMapping("/actList")
    @ApiOperation(value = "查询社区列表", response = ComActVO.class)
    R actList(){
        return gridService.actList();
    }
    /**
     * 保存特殊人群草稿
     * @param specialEventEditDTO 保存草稿传递对象
     * @return 新增结果
     */
    @PostMapping("/special/draft")
    @ApiOperation(value = "保存特殊人群草稿", response = R.class)
    R saveSpecialDraft(@Validated @RequestBody SpecialEventEditDTO specialEventEditDTO){
        ClazzUtils.setIfStringIsEmpty(specialEventEditDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        specialEventEditDTO.setUserId(loginUserInfoVO.getUserId());
        specialEventEditDTO.setUserName(loginUserInfoVO.getName());
        specialEventEditDTO.setPhone(loginUserInfoVO.getPhone());
        return gridService.saveSpecialDraft(specialEventEditDTO);
    }
    @GetMapping("/special/{idCard}")
    @ApiOperation(value = "查询特殊人群信息")
    R getSpecialByIdCard(@PathVariable String idCard){
        if(idCard!=null){
            boolean verified = IdCardUtil.strongVerifyIdNumber(idCard);
            if(!verified){
                return R.fail("身份证格式错误");
            }
            return gridService.getSpecialPopulation(idCard);
        }
        return R.fail();
    }
}