CeDo
2021-06-07 11e5c5ff34de7da51ae105b4922115ce61f96610
add:根据经纬度查询网格&& bugfixed
14个文件已修改
4个文件已添加
604 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/CommonEventBatchRepublishDTO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/EventBatchRevokeDTO.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/EventDeleteDTO.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/PageEventGridNearbyDTO.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/PublicityEventAddDTO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/grid/LatLngVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/grid/GridService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/LngLatUtils.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/CommonApi.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/EventApi.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/EventManageApi.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/PublicityEventApi.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/EventApi.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/EventGridDataMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/EventService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/resources/mapper/EventGridDataMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/resources/mapper/EventMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/CommonEventBatchRepublishDTO.java
New file
@@ -0,0 +1,33 @@
package com.panzhihua.common.model.dtos.grid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
 * 事件重新发布请求参表单
 *
 * @author cedoo email:cedoo(a)qq.com
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 * */
@Data
@ApiModel("事件重新发布请求参数")
public class CommonEventBatchRepublishDTO {
    @ApiModelProperty(value = "事件id", hidden = false, example = "1", required = true)
    @NotNull
    private List<Long> id;
    @ApiModelProperty(value = "(当前操作)用户ID", hidden = true, example = "1")
    private Long userId;
    @ApiModelProperty(value = "(当前操作)用户姓名", hidden = true, example = "张三")
    private String userName;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/EventBatchRevokeDTO.java
New file
@@ -0,0 +1,39 @@
package com.panzhihua.common.model.dtos.grid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
 * 编辑表单
 *
 * @author cedoo email:cedoo(a)qq.com
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 * */
@Data
@ApiModel("撤销事件请求参数")
public class EventBatchRevokeDTO {
    @ApiModelProperty(value = "id", hidden = false, example = "1", required = true)
    @NotNull
    private List<Long> id;
    @ApiModelProperty(value = "(当前操作)用户ID", hidden = true, example = "1")
    private Long userId;
    @ApiModelProperty(value = "(当前操作)用户姓名", hidden = true, example = "李四")
    private String userName;
    @ApiModelProperty(value = "操作人所属社区", hidden = true, example = "学院社区")
    private String communityName;
    @ApiModelProperty(value = "操作人所属社区", hidden = true, example = "学院社区")
    private Long communityId;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/EventDeleteDTO.java
@@ -4,6 +4,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@@ -20,7 +21,8 @@
public class EventDeleteDTO {
    @ApiModelProperty(value = "id", hidden = false, example = "1")
    private Long id;
    @NotNull
    private List<Long> id;
    @ApiModelProperty(value = "(当前操作)用户ID", hidden = true, example = "1")
    private Long userId;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/PageEventGridNearbyDTO.java
New file
@@ -0,0 +1,56 @@
package com.panzhihua.common.model.dtos.grid;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.base.CaseFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
/**
 * 分页查询表单
 *
 * @author cedoo email:cedoo(a)qq.com
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 * */
@Data
@ApiModel("查询事件请求参数")
public class PageEventGridNearbyDTO {
    @ApiModelProperty(value = "分页-当前页数", example = "1")
    private Long pageNum = 1L;
    @ApiModelProperty(value = "分页-每页记录数", example = "10")
    private Long pageSize = 10L;
    @ApiModelProperty(value = "排序字段, 默认createAt", example = "createAt")
    private String sortAttr="createAt";
    @ApiModelProperty(value = "排序方式: asc/desc(默认)", example = "desc")
    @Pattern(regexp = "asc|desc|ASC|DESC", message = "排序方式参数错误")
    private String sortType="desc";
    public String getSortColumns(){
        String dbColumn = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sortAttr);
        return dbColumn;
    }
    @Length(max=255)
    @ApiModelProperty(value = "发生的精度纬度信息(逗号隔开)", hidden = false, example = "", required = true)
    @NotNull
    private String happentLatLng;
    @ApiModelProperty(value = "(当前操作)用户ID", hidden = true, example = "1")
    private Long userId;
    @ApiModelProperty(value = "(当前操作)用户ID", hidden = true, example = "1")
    private Long userName;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/grid/PublicityEventAddDTO.java
@@ -49,6 +49,11 @@
    @NotNull(message = "宣传区域不能为空")
    private Long gridId;
    @Max(9223372036854775807L)
    @ApiModelProperty(value = "上报人ID", hidden = false, example = "1", required = true)
    @NotNull(message = "上报人不能为空")
    private Long gridMemberId;
    @Length(max=255)
    @ApiModelProperty(value = "宣传主题", hidden = false, example = "", required = true)
    @NotNull(message = "宣传主题不能为空")
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/grid/LatLngVO.java
@@ -1,8 +1,10 @@
package com.panzhihua.common.model.vos.grid;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LatLngVO {
    private Double lng;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/grid/GridService.java
@@ -821,4 +821,36 @@
     */
    @PostMapping("/statistics/admin/gridMemberStatistics")
    R gridMemberStatistics(@RequestBody MemberStatisticsAdminDTO statisticsAdminDTO);
    /**
     * 批量删除
     * @param eventDeleteDTO
     * @return
     */
    @PostMapping("/event/deleteEventBatch")
    R deleteEventBatch(@RequestBody EventDeleteDTO eventDeleteDTO);
    /**
     * 批量发布事件
     * @param commonEventBatchRepublishDTO
     * @return
     */
    @PostMapping("/event/batchRepublishEvent")
    R batchRepublishEvent(@RequestBody CommonEventBatchRepublishDTO commonEventBatchRepublishDTO);
    /**
     * 批量事件标为无效
     * @param eventBatchRevokeDTO
     * @return
     */
    @PostMapping("/event/batchMarkInvalid")
    R batchMarkEventInvalid(@RequestBody EventBatchRevokeDTO eventBatchRevokeDTO);
    /**
     * 批量事件标为无效
     * @param pageEventGridNearbyDTO
     * @return
     */
    @PostMapping("/event/grid/nearby")
    R getNearByGrid(PageEventGridNearbyDTO pageEventGridNearbyDTO);
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/LngLatUtils.java
@@ -36,4 +36,30 @@
        }
        return check(point, pointList);
    }
    /**
     * 从txt数据中获取经纬度
     * @param latlngTxt
     * @return
     */
    public static List<LatLngVO> getLatLngFromText(String latlngTxt){
        List<LatLngVO> rtResult = new ArrayList<>();
        String str = latlngTxt.replace("[[","");
        str=str.replace("]]","");
        String[] loca=str.split("],\\[");
        for (int i=0;i<loca.length;i++)
        {
            String[] loca1=loca[i].split(",");
            rtResult.add(new LatLngVO(Double.valueOf(loca1[1]), Double.valueOf(loca1[0])));
        }
        return rtResult;
    }
    public static void main(String[] args) {
        String latLngTxt = "[[104.065958,30.662621],[104.06419,30.663172],[104.06315,30.660648],[104.065548,30.661036]]";
        List<LatLngVO> latLngList = getLatLngFromText(latLngTxt);
        System.out.println(isInPolygon(latLngList, 104.0612, 30.6608));
    }
}
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/CommonApi.java
@@ -79,6 +79,11 @@
            fileExtension = ".mp4";
        }
        if(originName.toLowerCase().endsWith(".mp3")){
            fileExtension = ".mp3";
        }
        String fileName = property + File.separator + UUID.randomUUID().toString().replace("-", "") + fileExtension;
        File file1 = new File(fileName);
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/EventApi.java
New file
@@ -0,0 +1,99 @@
package com.panzhihua.grid_backstage.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.grid.CommonEventBatchRepublishDTO;
import com.panzhihua.common.model.dtos.grid.EventBatchRevokeDTO;
import com.panzhihua.common.model.dtos.grid.EventDeleteDTO;
import com.panzhihua.common.model.dtos.grid.PageEventGridNearbyDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.service.grid.GridService;
import com.panzhihua.common.utlis.ClazzUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
 * @ClasssName EventApi
 * @Description 事件通用接口
 * @Author cedoo
 * @Date 2021/6/7
 * @Version 1.0
 **/
@Slf4j
@RestController
@RequestMapping("/event/common")
@Api(tags = {"宣传教育 @chendong", "事件管理 @chendong"})
public class EventApi extends BaseController {
    @Resource
    private GridService gridService;
    /**
     * 重新发布事件
     *
     * @param commonEventBatchRepublishDTO 重新发布事件传递对象
     * @return 修改结果
     */
    @PutMapping("/republishBatch")
    @ApiOperation(value = "(批量)重新发布已标记无效事件", response = R.class)
    R republishBatch(@Validated @RequestBody CommonEventBatchRepublishDTO commonEventBatchRepublishDTO) {
        ClazzUtils.setIfStringIsEmpty(commonEventBatchRepublishDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        commonEventBatchRepublishDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventBatchRepublishDTO.setUserName(loginUserInfoVO.getName());
        return gridService.batchRepublishEvent(commonEventBatchRepublishDTO);
    }
    /**
     * (批量)删除
     *
     * @param eventDeleteDTO 删除事件传递对象
     * @return 删除结果
     */
    @DeleteMapping()
    @ApiOperation(value = "(批量)删除", response = R.class)
    R deleteBatch(@Validated @RequestBody EventDeleteDTO eventDeleteDTO) {
        ClazzUtils.setIfStringIsEmpty(eventDeleteDTO);
        eventDeleteDTO.setUserId(this.getUserId());
        return gridService.deleteEventBatch(eventDeleteDTO);
    }
    /**
     * 事件标为无效
     *
     * @param eventBatchRevokeDTO 修改事件传递对象
     * @return 修改结果
     */
    @PutMapping("/markInvalidBatch")
    @ApiOperation(value = "(批量)事件标为无效", response = R.class)
    R markInvalidBatch(@Validated @RequestBody EventBatchRevokeDTO eventBatchRevokeDTO) {
        ClazzUtils.setIfStringIsEmpty(eventBatchRevokeDTO);
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        eventBatchRevokeDTO.setUserId(loginUserInfoVO.getUserId());
        eventBatchRevokeDTO.setUserName(loginUserInfoVO.getName());
        eventBatchRevokeDTO.setCommunityName(loginUserInfoVO.getCommunityName());
        eventBatchRevokeDTO.setCommunityId(loginUserInfoVO.getCommunityId());
        return gridService.batchMarkEventInvalid(eventBatchRevokeDTO);
    }
    /**
     * 查询距离当前事件最近的网格数据
     * @param pageEventGridNearbyDTO
     * @return
     */
    @PostMapping("/grid/nearby")
    @ApiOperation(value = "查询距离当前事件最近的网格数据", response = R.class)
    R getNearByGrid(@Validated @RequestBody PageEventGridNearbyDTO pageEventGridNearbyDTO){
        return gridService.getNearByGrid(pageEventGridNearbyDTO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/EventManageApi.java
@@ -54,9 +54,6 @@
    @ApiOperation(value = "事件列表", response= EventVO.class)
    R usersList(@Validated @RequestBody PageEventManageDTO pageEventManageDTO){
        ClazzUtils.setIfStringIsEmpty(pageEventManageDTO);
        if(!isCommonType(pageEventManageDTO.getEventType())){
            return R.fail(400, "事件类型错误");
        }
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        pageEventManageDTO.setUserId(loginUserInfoVO.getUserId());
        pageEventManageDTO.setCommunityId(loginUserInfoVO.getCommunityId());
springcloud_k8s_panzhihuazhihuishequ/grid_backstage/src/main/java/com/panzhihua/grid_backstage/api/PublicityEventApi.java
@@ -41,9 +41,9 @@
     * @param pagePublicityEventDTO 查找事件
     * @return 查找结果
     */
    @GetMapping("/usersList")
    @PostMapping("/usersList")
    @ApiOperation(value = "宣传教育事件列表", response = EventVO.class)
    R usersPublicityList(@Validated @ModelAttribute PagePublicityEventCommunityDTO pagePublicityEventDTO) {
    R usersPublicityList(@Validated @RequestBody PagePublicityEventCommunityDTO pagePublicityEventDTO) {
        ClazzUtils.setIfStringIsEmpty(pagePublicityEventDTO);
        LoginUserInfoVO loginUserInfoVO = this.getLoginUserInfo();
        pagePublicityEventDTO.setUserId(loginUserInfoVO.getUserId());
@@ -81,20 +81,6 @@
    }
    /**
     * 删除
     *
     * @param eventDeleteDTO 删除事件传递对象
     * @return 删除结果
     */
    @DeleteMapping()
    @ApiOperation(value = "删除事件", response = R.class)
    R delete(@Validated @RequestBody EventDeleteDTO eventDeleteDTO) {
        ClazzUtils.setIfStringIsEmpty(eventDeleteDTO);
        return gridService.delete(eventDeleteDTO);
    }
    /**
     * 撤销事件
     *
     * @param eventRevokeDTO 修改事件传递对象
@@ -124,25 +110,6 @@
        commonEventRepublishDTO.setUserId(loginUserInfoVO.getUserId());
        commonEventRepublishDTO.setUserName(loginUserInfoVO.getName());
        return gridService.republishEvent(commonEventRepublishDTO);
    }
    /**
     * 事件标为无效
     *
     * @param eventRevokeDTO 修改事件传递对象
     * @return 修改结果
     */
    @PutMapping("/markInvalid")
    @ApiOperation(value = "事件标为无效", response = R.class)
    R markInvalid(@Validated @RequestBody EventRevokeDTO eventRevokeDTO) {
        ClazzUtils.setIfStringIsEmpty(eventRevokeDTO);
        LoginUserInfoVO loginUserInfoVO = getLoginUserInfo();
        eventRevokeDTO.setUserId(loginUserInfoVO.getUserId());
        eventRevokeDTO.setUserName(loginUserInfoVO.getName());
        eventRevokeDTO.setCommunityName(loginUserInfoVO.getCommunityName());
        eventRevokeDTO.setCommunityId(loginUserInfoVO.getCommunityId());
        return gridService.markEventInvalid(eventRevokeDTO);
    }
    @ApiOperation(value = "查询当前社区所有网格员", response = EventGridMemberAdminVO.class)
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/EventApi.java
@@ -46,8 +46,17 @@
    @PostMapping("/delete")
    R delete(@RequestBody CommonEventDeleteDTO commonEventDeleteDTO){
        return eventService.delete(commonEventDeleteDTO);
    };
    }
    /**
     * 批量删除
     * @param eventDeleteDTO
     * @return
     */
    @PostMapping("/deleteEventBatch")
    R deleteEventBatch(@RequestBody EventDeleteDTO eventDeleteDTO){
        return  eventService.deleteEventBatch(eventDeleteDTO);
    }
    /**
     * 查询事件详细信息
     * @param id 事件 id
@@ -56,7 +65,7 @@
    @PostMapping("/{id}")
    R<EventDetailsVO> eventDetails(@PathVariable("id") Long id){
        return eventService.eventDetails(id);
    };
    }
    /**
     * 添加突发事件
@@ -66,7 +75,7 @@
    @PostMapping("/addCommon")
    R addCommon(@RequestBody CommonEventAddDTO commonEventAddDTO){
        return eventService.addCommon(commonEventAddDTO);
    };
    }
    /**
     * 保存草稿
     * @param {classNameFirstLower}AddDTO 添加事件传递对象
@@ -135,6 +144,15 @@
        return eventService.republishEvent(commonEventRepublishDTO);
    }
    /**
     * 批量发布事件
     * @param commonEventBatchRepublishDTO
     * @return
     */
    @PostMapping("/batchRepublishEvent")
    R batchRepublishEvent(@RequestBody CommonEventBatchRepublishDTO commonEventBatchRepublishDTO){
        return eventService.batchRepublishEvent(commonEventBatchRepublishDTO);
    }
    /**
     * 草稿发布
     * @param commonEventPublicDTO
@@ -246,6 +264,16 @@
    }
    /**
     * 批量事件标为无效
     * @param eventBatchRevokeDTO
     * @return
     */
    @PostMapping("/batchMarkInvalid")
    R batchMarkEventInvalid(@RequestBody EventBatchRevokeDTO eventBatchRevokeDTO){
        return eventService.batchMarkEventInvalid(eventBatchRevokeDTO);
    }
    /**
     * 社区网格后台重新发布已标记无效的事件
     * @param commonEventRepublishDTO
     * @return
@@ -255,4 +283,14 @@
        return eventService.republishInvalidEvent(commonEventRepublishDTO);
    }
    /**
     * 查询距离当前事件最近的网格数据
     * @param pageEventGridNearbyDTO
     * @return
     */
    @PostMapping("/grid/nearby")
    R getNearByGrid(@RequestBody PageEventGridNearbyDTO pageEventGridNearbyDTO){
        return eventService.getNearByGrid(pageEventGridNearbyDTO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/EventGridDataMapper.java
@@ -7,6 +7,7 @@
import com.panzhihua.common.model.dtos.grid.EventGridTodoDataDTO;
import com.panzhihua.common.model.dtos.grid.PageEventGridDataAdminDTO;
import com.panzhihua.common.model.dtos.grid.PageEventGridDataDTO;
import com.panzhihua.common.model.dtos.grid.PageEventGridNearbyDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.*;
import com.panzhihua.service_grid.model.dos.EventGridDataDO;
@@ -64,4 +65,6 @@
    List<EventGridMemberAdminVO> getGridMemberListsByGrid(@Param("gridId") Long gridId);
    List<EventGridDataAreaVO> getGridDataListByCommunity(@Param("communityId") Long communityId);
    List<EventGridDataAreaVO> selectGridWithArea(Page page, PageEventGridNearbyDTO pageEventGridNearbyDTO);
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/EventService.java
@@ -191,4 +191,32 @@
     * @return  网格员统计信息
     */
    R gridMemberStatistics(MemberStatisticsAdminDTO statisticsAdminDTO);
    /**
     * 获取最近的网格
     * @return
     * @param pageEventGridNearbyDTO
     */
    R getNearByGrid(PageEventGridNearbyDTO pageEventGridNearbyDTO);
    /**
     * 批量删除事件
     * @param eventDeleteDTO
     * @return
     */
    R deleteEventBatch(EventDeleteDTO eventDeleteDTO);
    /**
     * 批量重新发布事件
     * @param commonEventBatchRepublishDTO
     * @return
     */
    R batchRepublishEvent(CommonEventBatchRepublishDTO commonEventBatchRepublishDTO);
    /**
     * 批量标记事件无效
     * @param eventBatchRevokeDTO
     * @return
     */
    R batchMarkEventInvalid(EventBatchRevokeDTO eventBatchRevokeDTO);
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
@@ -11,14 +11,13 @@
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventResourceVO;
import com.panzhihua.common.model.vos.grid.EventTransferRecordVO;
import com.panzhihua.common.model.vos.grid.EventVO;
import com.panzhihua.common.model.vos.grid.*;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.LngLatUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_grid.dao.*;
import com.panzhihua.service_grid.model.dos.*;
import com.panzhihua.service_grid.service.EventGridDataService;
import com.panzhihua.service_grid.service.EventResourceService;
import com.panzhihua.service_grid.service.EventService;
import com.panzhihua.service_grid.service.EventTransferRecordService;
@@ -54,9 +53,12 @@
    private EventGridDataMapper eventGridDataMapper;
    @Resource
    private EventGridMemberRelationMapper eventGridMemberRelationMapper;
    @Resource
    private EventGridDataService eventGridDataService;
    /**
     * 分页查找事件
     *
     * @param pageEventDTO
     * @return 维护结果
     */
@@ -117,6 +119,7 @@
    /**
     * 删除事件
     *
     * @param commonEventDeleteDTO
     * @return 平台用户信息
     */
@@ -138,6 +141,7 @@
    /**
     * 查询事件详细信息
     *
     * @param id 事件 id
     * @return 查找结果
     */
@@ -183,7 +187,6 @@
            eventDetailsVO.setAudios(audioList);
            eventDetailsVO.setPics(picList);
            eventDetailsVO.setVideos(videoList);
            //查询事件流转记录
@@ -689,6 +692,7 @@
    /**
     * 生成服务单号
     *
     * @param eventType 事件类型,宣传事件默认为20
     * @return
     */
@@ -935,7 +939,12 @@
        eventDO.setGridMemberId(publicityEventAddDTO.getUserId());
        eventDO.setEventCategory(2l);//宣传事件
        eventDO.setEventStatus(2);//事件状态 2发布
        eventDO.setEventType(8);
        if(publicityEventAddDTO.getGridMemberId()!=null) {
            eventDO.setGridMemberId(publicityEventAddDTO.getGridMemberId());
        }else{
        eventDO.setGridMemberId(publicityEventAddDTO.getUserId());
        }
        eventDO.setGridMemberName(publicityEventAddDTO.getUserName());
        eventDO.setGridMemberTelephone(publicityEventAddDTO.getPhone());
        eventDO.setCreateBy(publicityEventAddDTO.getUserId());
@@ -1009,6 +1018,7 @@
            eventDO.setGridMemberName(publicityEventEditDTO.getUserName());
            eventDO.setGridMemberTelephone(publicityEventEditDTO.getPhone());
            eventDO.setEventDealStatus(5);//草稿状态
            eventDO.setEventType(8);
            if (eventMapper.insert(eventDO) > 0) {
                //添加音频
                if (StringUtils.isNotEmpty(publicityEventEditDTO.getAudio())) {
@@ -1452,6 +1462,7 @@
    /**
     * 添加发布事件流转记录
     *
     * @param eventId 事件ID
     * @param userId 操作用户ID
     * @param userName 操作用户姓名
@@ -1480,6 +1491,7 @@
    /**
     * 查询最后的流转记录,并添加事件流转记录
     *
     * @param eventId 事件ID
     * @param toId 流转到 ID
     * @param toName 流转到 名称
@@ -1534,6 +1546,7 @@
    /**
     * 根据子状态 查询用户事件处理状态
     *
     * @param eventId 事件ID
     */
    private EventDO  updateEventDealStatus(Long eventId){
@@ -1550,6 +1563,7 @@
    /**
     * 根据子状态 查询用户事件处理状态
     *
     * @param eventDO 事件
     */
    private Integer  getEventDealStatus(EventDO eventDO){
@@ -1606,6 +1620,7 @@
    /**
     * 后台管理-统计模块
     *
     * @param communityId   社区id
     * @return  统计信息
     */
@@ -1613,8 +1628,10 @@
    public R eventStatistics(Long communityId){
        return R.ok(this.baseMapper.eventStatistics(communityId));
    }
    /**
     * 后台管理-网格员统计
     *
     * @param statisticsAdminDTO    请求参数
     * @return  网格员统计信息
     */
@@ -1622,4 +1639,153 @@
    public R gridMemberStatistics(MemberStatisticsAdminDTO statisticsAdminDTO){
        return R.ok(eventGridMemberRelationMapper.gridMemberStatistics(new Page(statisticsAdminDTO.getPageNum(),statisticsAdminDTO.getPageSize()),statisticsAdminDTO));
    }
    @Override
    public R getNearByGrid(PageEventGridNearbyDTO pageEventGridNearbyDTO) {
        Page page = new Page(pageEventGridNearbyDTO.getPageNum(), pageEventGridNearbyDTO.getPageSize());
        String latLng = pageEventGridNearbyDTO.getHappentLatLng();
        if(!latLng.matches("^[\\-\\+]?((0|([1-8]\\d?))(\\.\\d{1,10})?|90(\\.0{1,10})?),[\\-\\+]?(0(\\.\\d{1,10})?|([1-9](\\d)?)(\\.\\d{1,10})?|1[0-7]\\d{1}(\\.\\d{1,10})?|180\\.0{1,10})$")){
            return R.fail("经纬度参数错误");
        }
        String latLngArr[] = latLng.split(",");
        try {
            Double lat = Double.valueOf(latLngArr[1]);
            Double lng = Double.valueOf(latLngArr[0]);
            List<EventGridDataAreaVO> gridList =
                    eventGridDataMapper.selectGridWithArea(page, pageEventGridNearbyDTO);
            if (gridList != null && gridList.size() > 0) {
                List<EventGridDataVO> rtEventGridList = new ArrayList<>();
                for (EventGridDataAreaVO eventGridDataDO : gridList) {
                    String data = eventGridDataDO.getData();
                    if(data!=null) {
                        List<LatLngVO> latLngList = LngLatUtils.getLatLngFromText(data);
                        boolean inGrid = LngLatUtils.isInPolygon(latLngList, lng, lat);
                        if (inGrid) {
                            EventGridDataVO eventGridDataVO = new EventGridDataVO();
                            BeanUtils.copyProperties(eventGridDataDO, eventGridDataVO);
                            rtEventGridList.add(eventGridDataVO);
                        }
                    }
                }
                return R.ok(rtEventGridList);
            } else {
                return R.ok("未找到社区");
            }
        }catch (Exception e){
            return R.fail(e.getMessage());
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R deleteEventBatch(EventDeleteDTO eventDeleteDTO) {
        List<Long> eventIds = eventDeleteDTO.getId();
        if (eventIds != null && eventIds.size() > 0) {
            R rt = null;
            Long userId = eventDeleteDTO.getUserId();
            for (Long id : eventIds) {
                EventDO eventDO = eventMapper.selectById(id);
                if (eventDO == null) {
                    throw new ServiceException("id为" + id + "的事件不存在");
                }
                if (eventDO.getEventStatus() != null &&
                        (eventDO.getEventStatus().intValue() == 1 || eventDO.getEventStatus().intValue() == 4)) {//草稿 或者 已撤销 的事件可以删除
                    eventDO.setEventStatus(3);//逻辑删除
                    eventDO.setUpdateBy(userId);
                    int updated = this.getBaseMapper().updateById(eventDO);
                    if (updated != 1) {
                        throw new ServiceException("删除事件失败");
                    }
                }
            }
            return R.ok();
        } else {
            return R.fail("参数错误");
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R batchRepublishEvent(CommonEventBatchRepublishDTO commonEventBatchRepublishDTO) {
        List<Long> ids = commonEventBatchRepublishDTO.getId();
        if (ids != null && ids.size() > 0) {
            Long userId = commonEventBatchRepublishDTO.getUserId();
            String userName = commonEventBatchRepublishDTO.getUserName();
            for (Long id : ids) {
                EventDO eventDO = this.getBaseMapper().selectById(id);
                if (eventDO == null) {
                    throw new ServiceException("id为" + id + "的事件不存在");
                }
                boolean canRepublishByUser = eventDO.getEventStatus() != null &&
                        eventDO.getEventStatus() == 4 || eventDO.getEventStatus() == 1;
                if (!canRepublishByUser) {
                    throw new ServiceException("当前不是撤销/草稿状态");
                }
                eventDO.setEventStatus(2);//2 发布
                eventDO.setEventProcessStatus(1); //待解决
                eventDO.setProcessType(1);   //网格员处理
                eventDO.setUpdateBy(userId);
                int updated = this.getBaseMapper().updateById(eventDO);
                if (updated != 1) {
                    throw new ServiceException("更新事件状态失败");
                }
                addTransferRecord(eventDO.getId(), userId, userName, 1,
                        "重新发布已撤销事件", userId, userName, 8);
            }
            return R.ok();
        } else {
            return R.fail("参数错误");
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R batchMarkEventInvalid(EventBatchRevokeDTO eventBatchRevokeDTO) {
        List<Long> ids = eventBatchRevokeDTO.getId();
        if (ids != null && ids.size() > 0) {
            Long userId = eventBatchRevokeDTO.getUserId();
            String userName = eventBatchRevokeDTO.getUserName();
            Long communityId = eventBatchRevokeDTO.getCommunityId();
            String communityName = eventBatchRevokeDTO.getCommunityName();
            for (Long id : ids) {
                EventDO eventDO = this.getBaseMapper().selectById(id);
                if (eventDO == null) {
                    throw new ServiceException("id为" + id + "的事件不存在");
                }
                if (eventDO.getEventCategory() != null) {
                    if (eventDO.getEventCategory() == 1) {
                        boolean canRevoke = eventDO.getEventDealStatus() == 3; //上报状态
                        if (!canRevoke) {
                            throw new ServiceException("当前事件不是上报状态,不允许标为无效");
                        }
                    } else if (eventDO.getEventCategory() == 2) {
                        boolean canRevoke = eventDO.getEventDealStatus() == 8; //发布状态
                        if (!canRevoke) {
                            throw new ServiceException("当前事件不是发布状态,不允许标为无效");
                        }
                    } else {
                        throw new ServiceException("事件分类错误");
                    }
                } else {
                    throw new ServiceException("事件所属错误");
                }
                eventDO.setInvalid(false);
                //标为无效后, 交给网格员处理
                eventDO.setUpdateBy(userId);
                eventDO.setEventStatus(4);//4、撤销
                eventDO.setProcessType(1);//网格员处理
                eventDO.setCommunityProcess(0);//非 社区处理
                int updated = this.getBaseMapper().updateById(eventDO);
                if (updated == 1) {
                    addTransferRecord(eventDO.getId(), userId, userName, 1, "标为无效", communityId, communityName, 4);
                } else {
                    throw new ServiceException("事件流转信息添加错误");
                }
            }
            return R.ok();
        } else {
            return R.fail("参数错误");
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/resources/mapper/EventGridDataMapper.xml
@@ -232,6 +232,14 @@
            LEFT JOIN com_act act ON gd.grid_community_id = act.community_id
        WHERE gd.grid_community_id = #{communityId}
    </select>
    <select id="selectGridWithArea" resultType="com.panzhihua.common.model.vos.grid.EventGridDataAreaVO"  parameterType="long">
        SELECT
            gd.id, gd.grid_name , ad.district_name AS zoneName, st.name AS gridStreetName,  act.name AS gridCommunityName, gd.data
        FROM event_grid_data gd LEFT JOIN com_mng_struct_area_district ad ON gd.zone_id = ad.district_adcode
            LEFT JOIN com_street st ON gd.grid_street_id = st.street_id
            LEFT JOIN com_act act ON gd.grid_community_id = act.community_id
        WHERE  gd.type=3
    </select>
    <delete id="removeGridRelationByGridId">
        delete from event_grid_member_relation where grid_id = #{gridId}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/resources/mapper/EventMapper.xml
@@ -236,7 +236,7 @@
        <where>
            e.event_status != 3 AND e.event_category = 2
            <if test="pagePublicityEventDTO.communityId!=null">
                AND egd.grid_community_id = #{pageEventManageDTO.communityId}
                AND egd.grid_community_id = #{pagePublicityEventDTO.communityId}
            </if>
            <if test="pagePublicityEventDTO.eventDealStatus!=null">
                AND e.event_deal_status = #{pagePublicityEventDTO.eventDealStatus}
@@ -500,7 +500,7 @@
                )
            </if>
            <if test="pagePublicityEventCommunityDTO.communityId!=null">
                AND egd.grid_community_id = #{pageEventManageDTO.communityId}
                AND egd.grid_community_id = #{pagePublicityEventCommunityDTO.communityId}
            </if>
            <if test="pagePublicityEventCommunityDTO.eventDealStatus!=null">
                AND e.event_deal_status = #{pagePublicityEventCommunityDTO.eventDealStatus}