manailin
2021-06-20 8f0425e065676d57a3dd813e94b869c1193d8f13
[新增]新增定时向浪潮传送事件信息包括文件信息
11个文件已修改
28个文件已添加
2021 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/api/LangchaoApiConstants.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/KeyPersonLabelEnum.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/LocalEventToLangChaoEventTypeEnum.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/EventFile.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/EventInfo.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/LcGridMember.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/PartiesBody.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/api/ApiServiceFeign.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/grid/GridService.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/pom.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/pom.xml 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/ServiceApiApplication.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/aop/OperLogAspect.java 227 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/api/LcEventApi.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/api/TokenApi.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/biz/LcApiService.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/biz/impl/LcApiServiceImpl.java 233 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/config/SwaggerConfig.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/model/dto/LcGridData.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/resources/bootstrap.yml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/resources/logback-spring.xml 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_api/src/test/java/com/panzhihua/service_api/biz/impl/LcApiServiceImplTest.java 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/test/java/com/panzhihua/service_community/ServiceCommunityApplicationTests.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/EventApi.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/LcCompareCodeApi.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/LcCompareCodeMapper.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/LcCompareMemberCodeMapper.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/EventDO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/EventResourceDO.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/LcCompareCodeDO.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/LcCompareCodeMemberDO.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/EventService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/LcCompareCodeService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/LcCompareCodeServiceImpl.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/test/java/com/panzhihua/service_grid/service/impl/EventServiceImplTest.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/test/java/com/panzhihua/service_grid/service/impl/LcCompareCodeServiceImplTest.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/timejob/src/main/java/com/panzhihua/timejob/jobhandler/LangChaoEventUploadJobHandler.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/pom.xml
@@ -17,7 +17,7 @@
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-core</artifactId>
            <version>4.0.7</version>
            <version>5.6.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/api/LangchaoApiConstants.java
@@ -10,6 +10,10 @@
{
    /**
     * 将浪潮对接接口中所需的token存在Redis里面的KEY
     */
    public static final String LANG_CHAO_TOKEN ="lang_chao_token";
    /**
     * 获取token
     */
    public static final String GRID_GET_TOKEN_URL = "http://171.217.92.33:53303/aaToken?username=#username&password=#password";
@@ -41,4 +45,8 @@
     * 通过AREAID获取辖区网格树
     */
    public static final String GRID_GET_EVENT_INFO_AREA_ID_URL = "http://171.217.92.33:53303/area/getAreaGridTreeByAreaId";
    /**
     * 获取所有或者根据姓名和工号查询,分页
     */
    public static final String GRID_GET_getAll_Search_Page_URL = "http://171.217.92.33:53303/gridOperator/getAllOrSearchByPage?areaId=jhRxqEQp&limit=200&page=1";
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/KeyPersonLabelEnum.java
@@ -3,9 +3,9 @@
import lombok.Getter;
/**
 * 婚姻状况
 *
 * 
 * @author huanghongfa
 * @author manaiilin
 */
@Getter
public enum KeyPersonLabelEnum
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/LocalEventToLangChaoEventTypeEnum.java
New file
@@ -0,0 +1,48 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 *
 * 本地事件类型1治安隐患、2公共服务、3矛盾纠纷、4不稳定因素、5突发事件、6特殊人群信息上报 7宣传教育
 * @author manaiilin
 */
@Getter
public enum LocalEventToLangChaoEventTypeEnum
{
    ZA(1, "6","治安隐患"),
    GG(2, "4","公共服务"),
    MD(3, "5","矛盾纠纷"),
    BWD(4, "55d8def10c1344dc853b9ccf0484c06d","不稳定因素"),
    TF(5, "1b62afbccc2a4bb98125f999b7133242","突发事件"),
    TSRQ(6, "7da14163537b4b7e9a73ae28f4a58b72","特殊人群信息上报"),
    XC(7, "9306ca7327a44b5ca474426f2da0e206","宣传教育"),
    QT(8, "55d8def10c1344dc853b9ccf0484c06d","其他");
    private final Integer code;
    private final String name;
    private final String eventName;
    LocalEventToLangChaoEventTypeEnum(Integer code, String name,String eventName)
    {
        this.code = code;
        this.name = name;
        this.eventName = eventName;
    }
    public static String getCodeByName(Integer code) {
        for (LocalEventToLangChaoEventTypeEnum item : LocalEventToLangChaoEventTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return BWD.getName();
    }
    public static String getEventNameByCode(Integer code) {
        for (LocalEventToLangChaoEventTypeEnum item : LocalEventToLangChaoEventTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getEventName();
            }
        }
        return BWD.getEventName();
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/EventFile.java
New file
@@ -0,0 +1,35 @@
package com.panzhihua.common.model.dtos.api;
import lombok.Data;
/**
 * program 攀枝花智慧社区项目
 * description 上报事件关联的文件实体对象
 *
 * @author manailin
 * Date 2021-06-17 15:30
 **/
@Data
public class EventFile {
    /**
     * 事件业务ID,本地的ID
     */
    private String dataId;
    /**
     * 事件关联的文件对象
     */
    private String files;
    /**
     * 文件类型
     */
    private String fileName;
    /**
     * 文件类型
     */
    private String type;
    /**
     * 关联模块
     */
    private String module;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/EventInfo.java
New file
@@ -0,0 +1,86 @@
package com.panzhihua.common.model.dtos.api;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
 * program 攀枝花智慧社区项目
 * description 上报事件实体对象
 *
 * @author manailin
 * Date 2021-06-17 15:30
 **/
@Data
public class EventInfo {
    /**
     *网格id,APP端每个网格员应该是固定的网格
     */
    private String gridId;
    /**
     *网格 名称
     */
    private String  gridName;
    /**
     *事件类型code
     */
    private String  caseTypeCode;
    /**
     *事件类型名称
     */
    private String  caseTypeName;
    /**
     *事件发生时间,时间的实际发生时间,网格员可以修改的时间
     */
    private String  happenTime;
    /**
     *地址,手动填写或通过天地图获取的地址信息
     */
    private String  happenAddress;
    /**
     *经度,double字符串
     */
    private String  longitude;
    /**
     *纬度,double字符串
     */
    private String  latitude;
    /**
     *对本次事件的描述信息
     */
    private String  caseDescription;
    /**
     *对本次事件记录的时间,APP记录本条数据的时间,网格员自己看不到
     */
    private String caseRecordTime;
    /**
     *处理方式,caseReport(立即上报)、caseHandler(事件自处)、caseCache(事件暂存)
     */
    private String handleType;
    /**
     *处理的描述信息
     */
    private String handleDescription;
    /**
     *APP生产的数据id,用于平台判断重复提交
     */
    private String   dataId;
    /**
     *用户id
     */
    private String  userId;
    /**
     *处理的时间,APP点击提交的时间,并非平台接收的时间(APP可以离线使用
     */
    private String   handleTime;
    /**
     * 标题
     */
    private String   caseName;
    /**
     *当事人姓名
     */
    private List<PartiesBody> partiesBody =new ArrayList<>();
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/LcGridMember.java
New file
@@ -0,0 +1,47 @@
package com.panzhihua.common.model.dtos.api;
import lombok.Data;
/**
 * program 攀枝花智慧社区项目
 * description 上报事件关联的网格员实体对象
 *
 * @author manailin
 * Date 2021-06-17 15:30
 **/
@Data
public class LcGridMember {
    /**
     * 网格员名字
     */
    private String name;
    /**
     * 网格员电话
     */
    private String  contactPhone;
    /**
     * 网格员工号
     */
    private String jobNum;
    /**
     * 网格员联系电话
     */
    private String imei;
    /**
     * 网格员登录密码
     */
    private String password;
    /**
     * 网格员任职时间 2021-06-18
     */
    private String orgDutyDate;
    /**
     * 网格员责任网格  8c86b8b467194270b6b066b9c32e3b9b,a028fe8a7fff455781fa0bc3f66132fd
     */
    private String  select;
    /**
     * 网格员责任网格  8c86b8b467194270b6b066b9c32e3b9b,a028fe8a7fff455781fa0bc3f66132fd
     */
    private String gridDutyId;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/api/PartiesBody.java
New file
@@ -0,0 +1,22 @@
package com.panzhihua.common.model.dtos.api;
import lombok.Data;
/**
 * program 攀枝花智慧社区项目
 * description 上报事件中当事人实体对象
 *
 * @author manailin
 * Date 2021-06-17 15:30
 **/
@Data
public class PartiesBody {
    /**
     * 当事人名字
     */
    private String partyName;
    /**
     * 当事人电话
     */
    private String partyPhone;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/api/ApiServiceFeign.java
New file
@@ -0,0 +1,61 @@
package com.panzhihua.common.service.api;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 *
 * @author manailin
 * desc  主要是提供给浪潮服务器上传事件
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 * */
@FeignClient(name = "serviceApi")
public interface ApiServiceFeign {
    /**
     * description 生成或更新redis里面的对接浪潮所需的token信息
     * @param name 账号
     * @param password 密码
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("get/token")
    void getToken(@RequestParam("name") String name,@RequestParam("password") String password);
    /**
     * description 向浪潮服务器提交网格事件登记     *
     * @param eventInfo 事件信息对象
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @PostMapping("lc/event/upload")
    void automationUpload(@RequestBody EventInfo eventInfo);
    /**
     * description 提交事件登记关联的文件或者图片信息
     * @param eventFile 文件对象
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @PostMapping("lc/event/upload/file")
    void automationUploadFile(@RequestBody EventFile eventFile);
    /**
     * description 提交事件登记关联的文件或者图片信息
     *
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "提交事件登记关联的文件或者图片信息")
    @PostMapping("lc/event/upload/event_and_file")
    void automationUploadEventAndFile();
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/grid/GridService.java
@@ -892,4 +892,43 @@
     */
    @PostMapping("/eventgridmemberwarnlog/judge")
    R timedTaskGridMember();
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  id 本地网格ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/lc_compare/{id}")
    String getLcGridIdByLocal(@PathVariable("id") Long id);
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  localUserId 本地网格员ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/lc_compare/getLcUserId")
    String getLcUserIdByLocalUserId(@RequestParam("localUserId") String localUserId);
    /**
     * description 获取所有未上传到浪潮平台的事件列表
     *
     * @return String 事件列表
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/event/getUnUploadEvent")
    List<EventDetailsVO> getUnUploadEvent();
    /**
     * description 更新上传是否成功标识
     * @param id 事件主键ID
     * @return Boolean 上传是否成功
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/event/updateLcUploadFlag")
    Boolean updateLcUploadFlag(@RequestParam("id")Long id);
}
springcloud_k8s_panzhihuazhihuishequ/pom.xml
@@ -209,6 +209,8 @@
        <module>grid_backstage</module>
        <!--网格治理-基础服务service-->
        <module>service_grid</module>
        <!--网格治理-对接浪潮的市平台综治接口-->
        <module>service_api</module>
    </modules>
    <packaging>pom</packaging>
springcloud_k8s_panzhihuazhihuishequ/service_api/pom.xml
New file
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.panzhihua</groupId>
        <artifactId>zhihuishequ</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.panzhihua</groupId>
    <artifactId>service_api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>service_api</name>
    <description>对接第三方接口项目</description>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.panzhihua</groupId>
            <artifactId>common</artifactId>
        </dependency>
        <dependency>
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-javanica</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-http</artifactId>
            <version>5.6.7</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.panzhihua.community_backstage.CommunityBackstageApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.0</version>
                <configuration>
                    <imageName>registry.cn-chengdu.aliyuncs.com/panzhihua/community_backstage:v1</imageName>
                    <serverId></serverId>
                    <baseImage>java</baseImage>
                    <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
</project>
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/ServiceApiApplication.java
New file
@@ -0,0 +1,30 @@
package com.panzhihua.serviceapi;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * program 攀枝花智慧社区项目-对接第三方接口
 * description 对接浪潮市平台事件管理API
 *
 * @author manailin
 * Date 2021-06-18 15:30
 **/
@EnableSwagger2
@SpringCloudApplication
@EnableCircuitBreaker
@EnableEurekaClient
@EnableFeignClients(basePackages = {"com.panzhihua.common.service"})
@ComponentScan({"com.panzhihua.serviceapi","com.panzhihua.common"})
public class ServiceApiApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceApiApplication.class, args);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/aop/OperLogAspect.java
New file
@@ -0,0 +1,227 @@
package com.panzhihua.serviceapi.aop;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.constants.TokenConstant;
import com.panzhihua.common.interfaces.OperLog;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.user.SysOperLogVO;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.AES;
import com.panzhihua.common.utlis.IPUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 切面处理类,操作日志异常日志记录处理
 *
 * @author wu
 * @date 2019/03/21
 */
@Slf4j
@Aspect
@Component
public class OperLogAspect {
    @Resource
    private UserService userService;
    /**
     * 设置操作日志切入点 记录操作日志 在注解的位置切入代码
     */
    @Pointcut("@annotation(com.panzhihua.common.interfaces.OperLog)")
    public void operLogPoinCut() {
    }
//    /**
//     * 设置操作异常切入点记录异常日志 扫描所有controller包下操作
//     */
//    @Pointcut("execution(* com.hyd.zcar.cms.controller..*.*(..))")
//    public void operExceptionLogPoinCut() {
//    }
    /**
     * 正常返回通知,拦截用户操作日志,连接点正常执行完成后执行, 如果连接点抛出异常,则不会执行
     *
     * @param joinPoint 切入点
     * @param keys      返回结果
     */
    @AfterReturning(value = "operLogPoinCut()", returning = "keys")
    public void saveOperLog(JoinPoint joinPoint, Object keys) {
        log.info("进入切面");
        // 获取RequestAttributes
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        // 从获取RequestAttributes中获取HttpServletRequest的信息
        HttpServletRequest request = (HttpServletRequest) requestAttributes
                .resolveReference(RequestAttributes.REFERENCE_REQUEST);
//        登录对象信息
        String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO);
        boolean empty = ObjectUtils.isEmpty(userInfo);
        if (empty) {
            log.error("操作日志获取登录用户信息失败【{}】",joinPoint);
            return;
        }
        byte[] bytes = AES.parseHexStr2Byte(userInfo);
        byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY);
        userInfo=new String(decrypt);
        LoginUserInfoVO loginUserInfoVO= JSONObject.parseObject(userInfo,LoginUserInfoVO.class);
        SysOperLogVO operlog = new SysOperLogVO();
        try {
            // 从切面织入点处通过反射机制获取织入点处的方法
            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
            // 获取切入点所在的方法
            Method method = signature.getMethod();
            // 获取操作
            OperLog opLog = method.getAnnotation(OperLog.class);
            if (opLog != null) {
                String operModul = opLog.operModul();
                int operType = opLog.operType();
                operlog.setTitle(operModul); // 操作模块
                operlog.setBusinessType(operType); // 操作类型
            }
            // 获取请求的类名
            String className = joinPoint.getTarget().getClass().getName();
            // 获取请求的方法名
            String methodName = method.getName();
            methodName = className + "." + methodName;
            operlog.setMethod(methodName); // 请求方法
            if (joinPoint.getArgs().length > 0) {
                for (Object o : joinPoint.getArgs()) {
                    if (o instanceof HttpServletRequest || o instanceof HttpServletResponse) {
                        continue;
                    }
                    operlog.setOperParam(JSONObject.toJSONString(o)); // 请求参数
                }
            }
            operlog.setJsonResult(JSONObject.toJSONString(keys)); // 返回结果
            operlog.setAccount(loginUserInfoVO.getAccount());
            operlog.setOperName(loginUserInfoVO.getName()); // 请求用户名称
            operlog.setOperIp(IPUtil.getIpAddress(request)); // 请求IP
            operlog.setOperUrl(request.getRequestURI()); // 请求URI
            operlog.setRequestMethod(request.getMethod());
            operlog.setOperLocation(IPUtil.getIpBelongAddress(request));
            operlog.setOperTime(new Date()); // 创建时间
            operlog.setAccount(loginUserInfoVO.getAccount());
            Long communityId = loginUserInfoVO.getCommunityId();
            operlog.setCommunityId(null==communityId?0:communityId);
            userService.addOperLog(operlog);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//    /**
//     * 异常返回通知,用于拦截异常日志信息 连接点抛出异常后执行
//     *
//     * @param joinPoint 切入点
//     * @param e         异常信息
//     */
//    @AfterThrowing(pointcut = "operExceptionLogPoinCut()", throwing = "e")
//    public void saveExceptionLog(JoinPoint joinPoint, Throwable e) {
//        // 获取RequestAttributes
//        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
//        // 从获取RequestAttributes中获取HttpServletRequest的信息
//        HttpServletRequest request = (HttpServletRequest) requestAttributes
//                .resolveReference(RequestAttributes.REFERENCE_REQUEST);
//
//        ExceptionLog excepLog = new ExceptionLog();
//        try {
//            // 从切面织入点处通过反射机制获取织入点处的方法
//            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//            // 获取切入点所在的方法
//            Method method = signature.getMethod();
//            excepLog.setExcId(UuidUtil.get32UUID());
//            // 获取请求的类名
//            String className = joinPoint.getTarget().getClass().getName();
//            // 获取请求的方法名
//            String methodName = method.getName();
//            methodName = className + "." + methodName;
//            // 请求的参数
//            Map<String, String> rtnMap = converMap(request.getParameterMap());
//            // 将参数所在的数组转换成json
//            String params = JSON.toJSONString(rtnMap);
//            excepLog.setExcRequParam(params); // 请求参数
//            excepLog.setOperMethod(methodName); // 请求方法名
//            excepLog.setExcName(e.getClass().getName()); // 异常名称
//            excepLog.setExcMessage(stackTraceToString(e.getClass().getName(), e.getMessage(), e.getStackTrace())); // 异常信息
//            excepLog.setOperUserId(UserShiroUtil.getCurrentUserLoginName()); // 操作员ID
//            excepLog.setOperUserName(UserShiroUtil.getCurrentUserName()); // 操作员名称
//            excepLog.setOperUri(request.getRequestURI()); // 操作URI
//            excepLog.setOperIp(IPUtil.getRemortIP(request)); // 操作员IP
//            excepLog.setOperVer(operVer); // 操作版本号
//            excepLog.setOperCreateTime(new Date()); // 发生异常时间
//
//            exceptionLogService.insert(excepLog);
//
//        } catch (Exception e2) {
//            e2.printStackTrace();
//        }
//
//    }
    /**
     * 转换request 请求参数
     *
     * @param paramMap request获取的参数数组
     */
    public Map<String, String> converMap(Map<String, String[]> paramMap) {
        Map<String, String> rtnMap = new HashMap<String, String>();
        for (String key : paramMap.keySet()) {
            rtnMap.put(key, paramMap.get(key)[0]);
        }
        return rtnMap;
    }
    private  String getPostData(HttpServletRequest request) {
        StringBuffer data = new StringBuffer();
        String line = null;
        BufferedReader reader = null;
        try {
            reader = request.getReader();
            while (null != (line = reader.readLine()))
                data.append(line);
        } catch (IOException e) {
        } finally {
        }
        return data.toString();
    }
    /**
     * 转换异常信息为字符串
     *
     * @param exceptionName    异常名称
     * @param exceptionMessage 异常信息
     * @param elements         堆栈信息
     */
    public String stackTraceToString(String exceptionName, String exceptionMessage, StackTraceElement[] elements) {
        StringBuffer strbuff = new StringBuffer();
        for (StackTraceElement stet : elements) {
            strbuff.append(stet + "\n");
        }
        String message = exceptionName + ":" + exceptionMessage + "\n\t" + strbuff.toString();
        return message;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/api/LcEventApi.java
New file
@@ -0,0 +1,138 @@
package com.panzhihua.serviceapi.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.serviceapi.biz.LcApiService;
import com.panzhihua.serviceapi.model.dto.LcGridData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
 * program 攀枝花智慧社区项目
 * description 浪潮事件管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Slf4j
@Api(tags = {"浪潮事件管理API"})
@RestController
@RequestMapping("/")
public class LcEventApi extends BaseController {
    @Resource
    private LcApiService lcApiService;
    /**
     * description 向浪潮服务器提交网格事件登记
     *
     * @param eventInfo 事件信息对象
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "向浪潮服务器提交网格事件登记")
    @PostMapping("lc/event/upload")
    public void automationUpload(@RequestBody EventInfo eventInfo) {
        try {
            lcApiService.submitEventRegister(eventInfo);
        } catch (Exception e) {
            log.error("向浪潮服务器提交网格事件登记出现错误:{}", e.getMessage());
        }
    }
    /**
     * description 提交事件登记关联的文件或者图片信息
     *
     * @param eventFile 文件对象
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "提交事件登记关联的文件或者图片信息")
    @PostMapping("lc/event/upload/file")
    public R automationUploadFile(@RequestBody EventFile eventFile) {
        return lcApiService.submitEventRelationFile(eventFile);
    }
    /**
     * description 提交事件登记关联的文件或者图片信息
     *
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "提交事件登记关联的文件或者图片信息")
    @PostMapping("lc/event/upload/event_and_file")
    public void automationUploadEventAndFile() {
        try {
            lcApiService.automationUploadEventAndFile();
        } catch (Exception e) {
            log.error("提交事件登记关联的文件或者图片信息出现错误:{}", e.getMessage());
        }
    }
    /**
     * description 获取指定事件信息
     *
     * @param eventId 事件ID
     * @return String 事件信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "获取指定事件信息")
    @GetMapping("lc/event/getEventInfoById")
    public String getEventInfoById(String eventId) {
        try {
            return lcApiService.getEventInfoById(eventId);
        } catch (Exception e) {
            log.error("获取指定事件信息出现错误:{}", e.getMessage());
        }
        return eventId;
    }
    /**
     * description 获取所有或者根据姓名和工号查询,分页
     *
     * @param eventId 事件ID
     * @return String 事件信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "获取所有或者根据姓名和工号查询,分页")
    @GetMapping("lc/event/getGridMemberListByAreaIdOrName")
    public String getGridMemberListByAreaIdOrName(String eventId) {
        try {
            return lcApiService.getGridMemberListByAreaIdOrName(eventId);
        } catch (Exception e) {
            log.error("获取所有或者根据姓名和工号查询,分页出现错误:{}", e.getMessage());
        }
        return eventId;
    }
    /**
     * description 获取指定区域网格列表
     *
     * @param areaId 区域ID
     * @return String 事件信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "获取指定区域网格列表")
    @GetMapping("lc/grid/list")
    public List<LcGridData> getGridListByAreaId(String areaId) {
        try {
            return lcApiService.getGridListByAreaId(areaId);
        } catch (Exception e) {
            log.error("获取指定区域网格列表出现错误:{}", e.getMessage());
        }
        return Collections.emptyList();
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/api/TokenApi.java
New file
@@ -0,0 +1,49 @@
package com.panzhihua.serviceapi.api;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.serviceapi.biz.LcApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * program 攀枝花智慧社区项目
 * description token管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Slf4j
@Api(tags = {"token管理API"})
@RestController
@RequestMapping("/")
public class TokenApi extends BaseController {
    @Resource
    private LcApiService lcApiService;
    /**
     * description 生成或更新redis里面的对接浪潮所需的token信息
     *
     * @param name     账号
     * @param password 密码
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @ApiOperation(value = "生成或更新redis里面的对接浪潮所需的token信息")
    @GetMapping("get/token")
    public void getToken(String name, String password) {
        try {
            lcApiService.saveTokenFromRemoteRequest(name, password);
        } catch (Exception e) {
            log.error("对接浪潮接口——更新或生成token出现错误:{}", e.getMessage());
        }
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/biz/LcApiService.java
New file
@@ -0,0 +1,98 @@
package com.panzhihua.serviceapi.biz;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.serviceapi.model.dto.LcGridData;
import java.util.List;
/**
 * program 攀枝花智慧社区项目
 * description 浪潮综治市平台网格管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
public interface LcApiService {
    /**
     * description 获取token,并将token存入到redis,设置失效时间是12小时
     * 超过12个小时,重新获取token存入到redis数据库
     *
     * @param name     账号
     * @param password 密码
     * @return String token
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String saveTokenFromRemoteRequest(String name, String password);
    /**
     * description 获取全部的事件类型信息
     *
     * @return String token
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String getAllEventTypeList();
    /**
     * description 提交事件登记
     *
     * @param eventInfo 事件信息
     * @return String 上传成功或失败信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String submitEventRegister(EventInfo eventInfo);
    /**
     * description 提交事件登记关联的文件或者图片信息
     *
     * @param eventFile 事件信息
     * @return String 上传成功或失败信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    R submitEventRelationFile(EventFile eventFile);
    /**
     * description 获取指定事件信息
     *
     * @param eventId 事件ID
     * @return String 事件信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String getEventInfoById(String eventId);
    /**
     * description 获取指定区域网格列表
     *
     * @param areaId 区域ID
     * @return String 事件信息
     * @author manailin
     * @date 2021/6/10 17:00
     */
    List<LcGridData> getGridListByAreaId(String areaId);
    /**
     * description 获取所有或者根据姓名和工号查询,分页
     *
     * @param areaId 区域ID
     * @return String 网格员列表
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String getGridMemberListByAreaIdOrName(String areaId);
    /**
     * description 提交事件登记关联的文件或者图片信息
     *
     * @author manailin
     * @date 2021/6/10 17:00
     */
    void automationUploadEventAndFile();
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/biz/impl/LcApiServiceImpl.java
New file
@@ -0,0 +1,233 @@
package com.panzhihua.serviceapi.biz.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.panzhihua.common.api.LangchaoApiConstants;
import com.panzhihua.common.constants.TokenConstant;
import com.panzhihua.common.enums.LocalEventToLangChaoEventTypeEnum;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventGridDataDetailsVO;
import com.panzhihua.common.model.vos.grid.EventResourceVO;
import com.panzhihua.common.service.grid.GridService;
import com.panzhihua.serviceapi.biz.LcApiService;
import com.panzhihua.serviceapi.model.dto.LcGridData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * program 攀枝花智慧社区项目
 * description 第三方浪潮市平台对接接口管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Slf4j
@Service
public class LcApiServiceImpl implements LcApiService {
    @Resource
    private GridService gridService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 从redis获取token
     *
     * @return String 浪潮对接的token
     */
    private String getAuthToken() {
        ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
        if(valueOperations.get(LangchaoApiConstants.LANG_CHAO_TOKEN) ==null){
            saveTokenFromRemoteRequest("18080799023", "123456");
        }
        return valueOperations.get(LangchaoApiConstants.LANG_CHAO_TOKEN);
    }
    @Override
    public String saveTokenFromRemoteRequest(String name, String password) {
        if (redisTemplate.hasKey(LangchaoApiConstants.LANG_CHAO_TOKEN)) {
            //如果redis存在token,直接返回redis存储的token
            ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
            return valueOperations.get(LangchaoApiConstants.LANG_CHAO_TOKEN);
        } else {
            //如果第一次请求浪潮的token请求,请求完成后,保存对于的token到数据库中。便于12小时内重复调用
            HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_GET_TOKEN_URL.replace("#username", name).replace("#password", password));
            HttpResponse result = request.execute();
            ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
            valueOperations.set(LangchaoApiConstants.LANG_CHAO_TOKEN, result.body(), TokenConstant.EXPIRETIME, TimeUnit.MINUTES);
            return result.toString();
        }
    }
    @Override
    public String getAllEventTypeList() {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_EVENT_CATEGORY_URL);
        request.auth(getAuthToken());
        HttpResponse result = request.execute();
        return result.body();
    }
    @Override
    public String submitEventRegister(EventInfo eventInfo) {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_REGIST_EVENT_URL);
        request.auth(getAuthToken());
        ObjectMapper mapper = new ObjectMapper();
        try {
            //对象转map
            Map m = mapper.readValue(mapper.writeValueAsString(eventInfo), Map.class);
            request.form(m);
        } catch (JsonProcessingException e) {
            log.info("方法submitEventRegister发生错误:{}",e.getMessage());
        }
        HttpResponse result = request.execute();
        log.info(result.body());
        return result.body();
    }
    @Override
    public R submitEventRelationFile(EventFile eventFile) {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_EVENT_FILE_UPLOAD_URL);
        request.auth(getAuthToken());
        try {
            HttpURLConnection httpUrl = (HttpURLConnection) new URL(eventFile.getFiles()).openConnection();
            httpUrl.connect();
            File file = inputStreamToFile(httpUrl.getInputStream(), eventFile.getFileName());
            request.form("files", file);
            httpUrl.disconnect();
            request.form("dataId", eventFile.getDataId());
            request.form("type", eventFile.getType());
            request.form("module", eventFile.getModule());
            HttpResponse result = request.execute();
            file.delete();
            return R.ok(result.body());
        } catch (Exception e) {
            log.info("方法submitEventRelationFile发生错误:{}",e.getMessage());
        }
        return R.fail();
    }
    @Override
    public String getEventInfoById(String eventId) {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_APP_EVENT_INFO_DETAIL_URL);
        request.auth(getAuthToken());
        request.form("eventId", eventId);
        HttpResponse result = request.execute();
        return result.body();
    }
    @Override
    public List<LcGridData> getGridListByAreaId(String areaId) {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_GET_EVENT_INFO_AREA_ID_URL);
        request.auth(getAuthToken());
        request.form("areaId", areaId);
        HttpResponse result = request.execute();
        return JSONArray.parseArray(result.body(), LcGridData.class);
    }
    @Override
    public String getGridMemberListByAreaIdOrName(String areaId) {
        HttpRequest request = HttpUtil.createPost(LangchaoApiConstants.GRID_GET_getAll_Search_Page_URL);
        request.auth(getAuthToken());
        request.form("areaId", areaId);
        HttpResponse result = request.execute();
        return result.body();
    }
    @Override
    public void automationUploadEventAndFile() {
        List<EventDetailsVO> unUploadEventList = gridService.getUnUploadEvent();
        unUploadEventList.forEach(eventInfoVo -> {
            log.info("定时向浪潮服务器提交网格事件登记开始");
            EventInfo eventInfo = new EventInfo();
            String lcGrid = gridService.getLcGridIdByLocal(eventInfoVo.getGridId());
            String lcGridUserId = gridService.getLcUserIdByLocalUserId(eventInfoVo.getGridMemberId().toString());
            eventInfo.setGridId(lcGrid);
            R grid = gridService.eventGridDataDetails(eventInfoVo.getGridId());
            EventGridDataDetailsVO gridData = (EventGridDataDetailsVO) grid.getData();
            eventInfo.setGridName(gridData.getGridName());
            eventInfo.setCaseTypeCode(LocalEventToLangChaoEventTypeEnum.getCodeByName(eventInfoVo.getEventType()));
            eventInfo.setCaseTypeName(LocalEventToLangChaoEventTypeEnum.getEventNameByCode(eventInfoVo.getEventType()));
            eventInfo.setHappenTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
            eventInfo.setHappenAddress(eventInfoVo.getHappenAddress());
            String[] data = eventInfoVo.getHappentLatLng().split(",");
            eventInfo.setLongitude(data[0]);
            eventInfo.setLatitude(data[1]);
            eventInfo.setCaseDescription(eventInfoVo.getEventDes());
            eventInfo.setCaseRecordTime(String.valueOf(eventInfoVo.getCreateAt().getTime()));
            eventInfo.setHandleType("REPORT");
            eventInfo.setHandleDescription(eventInfoVo.getProcessDesc());
            eventInfo.setDataId(eventInfoVo.getId().toString());
            //获取系统网格员映射的浪潮网格员对于的用户ID
            eventInfo.setUserId(lcGridUserId);
            eventInfo.setHandleTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
            eventInfo.setCaseName(eventInfoVo.getEventTitle());
            submitEventRegister(eventInfo);
            log.info("定时向浪潮服务器提交网格事件登记结束");
            log.info("开始上传附件信息");
            List<EventResourceVO> picsList = eventInfoVo.getPics();
            uploadLcApiEventFile(eventInfoVo, picsList, "png");
            List<EventResourceVO> audiosList = eventInfoVo.getAudios();
            uploadLcApiEventFile(eventInfoVo, audiosList, "mp3");
            List<EventResourceVO> videoList = eventInfoVo.getVideos();
            uploadLcApiEventFile(eventInfoVo, videoList, "mp4");
            log.info("结束上传附件信息");
            gridService.updateLcUploadFlag(eventInfoVo.getId());
        });
    }
    private void uploadLcApiEventFile(EventDetailsVO eventInfoVo, List<EventResourceVO> picsList, String type) {
        picsList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(eventInfoVo.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType(type);
            eventFile.setModule("event");
            eventFile.setFileName(eventResourceVO.getResourceName());
            submitEventRelationFile(eventFile);
        });
    }
    /**
     * 工具方法
     * inputStream 转 File
     */
    public static File inputStreamToFile(InputStream ins, String name) throws Exception {
        File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
        log.info(System.getProperty("java.io.tmpdir") + File.separator + name);
        if (file.exists()) {
            return file;
        }
        OutputStream os = new FileOutputStream(file);
        int bytesRead;
        int len = 8192;
        byte[] buffer = new byte[len];
        while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
            os.write(buffer, 0, bytesRead);
        }
        os.close();
        ins.close();
        return file;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/config/SwaggerConfig.java
New file
@@ -0,0 +1,40 @@
package com.panzhihua.serviceapi.config;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: swagger3
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-11-19 16:08
 **/
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("社区后台管理接口")
                .description("。")
                .contact(new Contact("Ray。", "http://www.ruiyeclub.cn", "ruiyeclub@foxmail.com"))
                .version("1.0")
                .build();
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/java/com/panzhihua/serviceapi/model/dto/LcGridData.java
New file
@@ -0,0 +1,29 @@
package com.panzhihua.serviceapi.model.dto;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
 * program 攀枝花智慧社区项目
 * description 浪潮接口返回的网格数据接口,网格按照区域层级展开
 *
 * @author manailin
 * Date 2021-06-22 15:30
 **/
@Data
public class LcGridData {
    private String id;
    private String title;
    private String level;
    private String other;
    private String other4;
    private String name;
    private String open;
    private String checked;
    private String count;
    private String pid;
    private List<LcGridData> children = new ArrayList<>();
}
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/resources/bootstrap.yml
New file
@@ -0,0 +1,23 @@
spring:
  application:
    name: serviceApi
  cloud:
    config:
      discovery:
        enabled: true
        service-id: config  # 注册中心的服务名
      profile: ${ENV:dev}  # 指定配置文件的环境
      uri: http://${CONFIG_URL:localhost}:8193/
  profiles:
    active: ${ENV:dev}
  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB
eureka:
  client:
    service-url:
      defaultZone: http://${EUREKA_URL:localhost}:8192/eureka
server:
  port: 8065
springcloud_k8s_panzhihuazhihuishequ/service_api/src/main/resources/logback-spring.xml
New file
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
    <springProfile name="dev">
        <property name="LOG_HOME" value="F:/log" />
    </springProfile>
       <springProfile name="test">
        <property name="LOG_HOME" value="/mnt/data/gocd/log" />
    </springProfile>
<property name="LOG_HOME" value="/mnt/data/gocd/log" />
    <!-- 控制台输出 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
        </encoder>
    </appender>
    <!-- 按照每天生成日志文件 -->
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--日志文件输出的文件名-->
            <FileNamePattern>${LOG_HOME}/community_backstage.log.%d{yyyy-MM-dd}.log</FileNamePattern>
            <!--日志文件保留天数-->
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
        </encoder>
        <!--日志文件最大的大小-->
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>10MB</MaxFileSize>
        </triggeringPolicy>
    </appender>
    <!--myibatis log configure-->
    <logger name="com.apache.ibatis" level="TRACE"/>
    <logger name="java.sql.Connection" level="DEBUG"/>
    <logger name="java.sql.Statement" level="DEBUG"/>
    <logger name="java.sql.PreparedStatement" level="DEBUG"/>
    <logger name="com.panzhihua.community_backstage" level="DEBUG"/>
    <!-- 日志输出级别 -->
    <root level="DEBUG">
        <appender-ref ref="STDOUT" />
    </root>
    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
</configuration>
springcloud_k8s_panzhihuazhihuishequ/service_api/src/test/java/com/panzhihua/service_api/biz/impl/LcApiServiceImplTest.java
New file
@@ -0,0 +1,173 @@
package com.panzhihua.service_api.biz.impl;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.panzhihua.common.enums.LocalEventToLangChaoEventTypeEnum;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.dtos.api.PartiesBody;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventGridDataDetailsVO;
import com.panzhihua.common.model.vos.grid.EventResourceVO;
import com.panzhihua.common.service.api.ApiServiceFeign;
import com.panzhihua.common.service.grid.GridService;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.serviceapi.ServiceApiApplication;
import com.panzhihua.serviceapi.biz.LcApiService;
import com.panzhihua.serviceapi.model.dto.LcGridData;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@SpringBootTest(classes = ServiceApiApplication.class)
class LcApiServiceImplTest {
    @Autowired
    private LcApiService lcApiService;
    @Resource
    private GridService gridService;
    @Resource
    private ApiServiceFeign ApiServiceFeign;
    @Test
    void saveTokenFromRemoteRequest() {
        String result = lcApiService.saveTokenFromRemoteRequest("18080799023", "123456");
        log.info(JSONObject.toJSONString(result));
    }
    @Test
    void getAllEventTypeList() {
        String result = lcApiService.getAllEventTypeList();
        log.info(result);
    }
    @Test
    void submitEventRegister() {
        EventInfo eventInfo = new EventInfo();
        eventInfo.setGridId("8c86b8b467194270b6b066b9c32e3b9b");
        eventInfo.setGridName("金沙社区网格1");
        eventInfo.setCaseTypeCode("04e0506d78884d218050a4c89a2e34c3");
        eventInfo.setCaseTypeName("18080799023");
        eventInfo.setHappenTime(String.valueOf(DateUtils.getCurrentDataLong()));
        eventInfo.setHappenAddress("四川省攀枝花市");
        eventInfo.setLongitude("116.397128");
        eventInfo.setLatitude("39.916527");
        eventInfo.setCaseDescription("描述");
        eventInfo.setCaseRecordTime(String.valueOf(DateUtils.getCurrentDataLong()));
        eventInfo.setHandleType("REPORT");
        eventInfo.setHandleDescription("处理描述");
        String dataID = String.valueOf(RandomUtil.randomLong(20));
        log.info("random:" + dataID);
        eventInfo.setDataId(dataID);
        eventInfo.setUserId("3e318dbeddc048328933d8b4ca759a36");
        eventInfo.setHandleTime(String.valueOf(DateUtils.getCurrentDataLong()));
        eventInfo.setCaseName("测试标题17");
        List<PartiesBody> partiesBody = new ArrayList<>();
        PartiesBody partiesBody1 = new PartiesBody();
        partiesBody1.setPartyName("测试见证人");
        partiesBody1.setPartyPhone("17345623565");
        partiesBody.add(partiesBody1);
        eventInfo.setPartiesBody(partiesBody);
        String result = lcApiService.submitEventRegister(eventInfo);
        log.info(result);
    }
    @Test
    void submitEventRelationFile() throws URISyntaxException {
        EventFile eventFile = new EventFile();
        eventFile.setDataId("1111116");
        //eventFile.setFiles("https://www.baidu.com/img/flexible/logo/pc/result@2.png");
        eventFile.setFiles("http://image.panzhihua.nhys.cdnhxx.com//idcard/4f843ad2d756456e900d5f24b419aa7c.mp4");
        eventFile.setType("mp4");
        eventFile.setModule("event");
        eventFile.setFileName("4f843ad2d756456e900d5f24b419aa7c.mp4");
        R result = lcApiService.submitEventRelationFile(eventFile);
        log.info(JSONObject.toJSONString(result));
    }
    @Test
    void submitEventRegisterJobTest() {
        log.info("定时向浪潮服务器提交网格事件登记开始");
        R<EventDetailsVO> event = gridService.eventDetails(1111113L);
        EventDetailsVO eventInfoVo = event.getData();
        EventInfo eventInfo = new EventInfo();
        String lcGrid = gridService.getLcGridIdByLocal(eventInfoVo.getGridId());
        String lcGridUserId = gridService.getLcUserIdByLocalUserId(eventInfoVo.getGridMemberId().toString());
        eventInfo.setGridId(lcGrid);
        R grid = gridService.eventGridDataDetails(eventInfoVo.getGridId());
        EventGridDataDetailsVO gridData = (EventGridDataDetailsVO) grid.getData();
        eventInfo.setGridName(gridData.getGridName());
        eventInfo.setCaseTypeCode(LocalEventToLangChaoEventTypeEnum.getCodeByName(eventInfoVo.getEventType()));
        eventInfo.setCaseTypeName(LocalEventToLangChaoEventTypeEnum.getEventNameByCode(eventInfoVo.getEventType()));
        eventInfo.setHappenTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
        eventInfo.setHappenAddress(eventInfoVo.getHappenAddress());
        String[] data = eventInfoVo.getHappentLatLng().split(",");
        eventInfo.setLongitude(data[0]);
        eventInfo.setLatitude(data[1]);
        eventInfo.setCaseDescription(eventInfoVo.getEventDes());
        eventInfo.setCaseRecordTime(String.valueOf(eventInfoVo.getCreateAt().getTime()));
        eventInfo.setHandleType("REPORT");
        eventInfo.setHandleDescription(eventInfoVo.getProcessDesc());
        eventInfo.setDataId(eventInfoVo.getId().toString());
        //获取系统网格员映射的浪潮网格员对于的用户ID
        eventInfo.setUserId(lcGridUserId);
        eventInfo.setHandleTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
        eventInfo.setCaseName(eventInfoVo.getEventTitle());
        lcApiService.submitEventRegister(eventInfo);
        log.info("定时向浪潮服务器提交网格事件登记结束");
        log.info("开始上传附件图片信息");
        List<EventResourceVO> picsList = eventInfoVo.getPics();
        picsList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(eventInfoVo.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType("png");
            eventFile.setModule("event");
            eventFile.setFileName(eventResourceVO.getResourceName());
            lcApiService.submitEventRelationFile(eventFile);
        });
        List<EventResourceVO> audiosList = eventInfoVo.getAudios();
        audiosList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(eventInfoVo.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType("mp3");
            eventFile.setModule("event");
            eventFile.setFileName(eventResourceVO.getResourceName());
            lcApiService.submitEventRelationFile(eventFile);
        });
        List<EventResourceVO> videoList = eventInfoVo.getVideos();
        videoList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(eventInfoVo.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType("mp4");
            eventFile.setModule("event");
            eventFile.setFileName(eventResourceVO.getResourceName());
            lcApiService.submitEventRelationFile(eventFile);
        });
        log.info("结束上传附件图片信息");
    }
    @Test
    void getGridListByAreaId() {
        //jhRxqEQp 代表西区
        List<LcGridData> list = lcApiService.getGridListByAreaId("jhRxqEQp");
        String pretty = JSONArray.toJSONString(list, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        log.info(pretty);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/test/java/com/panzhihua/service_community/ServiceCommunityApplicationTests.java
@@ -1,13 +1,16 @@
package com.panzhihua.service_community;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@Slf4j
@SpringBootTest
class ServiceCommunityApplicationTests {
    @Test
    void contextLoads() {
        log.info("test");
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/EventApi.java
@@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 *
@@ -29,6 +30,28 @@
    private EventService eventService;
    /**
     * description 获取所有未上传到浪潮平台的事件列表
     *
     * @return String 事件列表
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/getUnUploadEvent")
    List<EventDetailsVO> getUnUploadEvent(){
        return eventService.getUnUploadEvent();
    }
    /**
     * description 更新上传是否成功标识
     * @param id 事件主键ID
     * @return Boolean 上传是否成功
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/updateLcUploadFlag")
    Boolean updateLcUploadFlag(Long id){
        return eventService.updateLcUploadFlag(id);
    }
    /**
     * 分页查找事件
     * @param pageEventDTO
     * @return 维护结果
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/api/LcCompareCodeApi.java
New file
@@ -0,0 +1,55 @@
package com.panzhihua.service_grid.api;
import com.panzhihua.common.model.dtos.grid.*;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.grid.EventGridDataDetailsVO;
import com.panzhihua.service_grid.service.EventGridDataService;
import com.panzhihua.service_grid.service.LcCompareCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
 *
 * @author cedoo email:cedoo(a)qq.com
 * @version 1.0
 * @since 1.0
 * @date 2021-05-26
 * */
@Slf4j
@RestController
@RequestMapping("/lc_compare")
public class LcCompareCodeApi {
    @Resource
    private LcCompareCodeService lcCompareCodeService;
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  id 本地网格ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/{id}")
    String getLcGridIdByLocal(@PathVariable("id") Long id){
        return lcCompareCodeService.getLcGridIdByLocal(id);
    }
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  localUserId 本地网格员ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @GetMapping("/getLcUserId")
    String getLcUserIdByLocalUserId(String localUserId){
        return lcCompareCodeService.getLcUserIdByLocal(localUserId);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/LcCompareCodeMapper.java
New file
@@ -0,0 +1,19 @@
package com.panzhihua.service_grid.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.service_grid.model.dos.LcCompareCodeDO;
import org.apache.ibatis.annotations.Mapper;
/**
 * program 攀枝花智慧社区项目
 * description 本地网格和浪潮的对码表管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Mapper
public interface LcCompareCodeMapper extends BaseMapper<LcCompareCodeDO> {
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/dao/LcCompareMemberCodeMapper.java
New file
@@ -0,0 +1,19 @@
package com.panzhihua.service_grid.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.service_grid.model.dos.LcCompareCodeMemberDO;
import org.apache.ibatis.annotations.Mapper;
/**
 * program 攀枝花智慧社区项目
 * description 本地网格和浪潮的对码表管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Mapper
public interface LcCompareMemberCodeMapper extends BaseMapper<LcCompareCodeMemberDO> {
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/EventDO.java
@@ -215,4 +215,6 @@
     */
    @TableField(fill = FieldFill.UPDATE)
    private Date updateAt;
    private Boolean upload;
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/EventResourceDO.java
@@ -64,4 +64,5 @@
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createAt;
    private Boolean upload;
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/LcCompareCodeDO.java
New file
@@ -0,0 +1,35 @@
package com.panzhihua.service_grid.model.dos;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * Description  本地网格和浪潮的对码表
 * ClassName    LcCompareCode
 * @author      manailin
 */
 @Data
 @TableName("lc_compare_code")
public class LcCompareCodeDO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.INPUT)
    private Long id;
    /**本地网格ID*/
    private String localGridId;
    /**网格名称*/
    private String gridName;
    /**浪潮市平台网格ID*/
    private String lcGridId;
    /**浪潮市平台网格名称*/
    private String lcGridName;
    /**创建时间*/
    private Date createAt;
    /**修改时间*/
    private Date updateAt;
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/model/dos/LcCompareCodeMemberDO.java
New file
@@ -0,0 +1,38 @@
package com.panzhihua.service_grid.model.dos;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * Description  本地网格和浪潮的对码表
 * ClassName    LcCompareCode
 * @author      manailin
 */
 @Data
 @TableName("lc_compare_code_member")
public class LcCompareCodeMemberDO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.INPUT)
    private Long id;
    /**本地网格ID*/
    private String localGridMemberId;
    /**网格名称*/
    private String gridMemberName;
    /**浪潮市平台网格ID*/
    private String lcGridMemberId;
    /**浪潮市平台网格名称*/
    private String lcGridMemberName;
    /**浪潮网格员绑定的用户ID*/
    private String lcBindUserId;
    /**创建时间*/
    private Date createAt;
    /**修改时间*/
    private Date updateAt;
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/EventService.java
@@ -9,6 +9,8 @@
import com.panzhihua.common.model.vos.grid.EventVO;
import com.panzhihua.service_grid.model.dos.EventDO;
import java.util.List;
/**
 * 事件 service
 *
@@ -240,4 +242,20 @@
     * @return
     */
    R reportDirect(CommonEventDirectReportDTO commonEventDirectReportDTO);
    /**
     * description 获取所有未上传到浪潮平台的事件列表
     *
     * @return String 事件列表
     * @author manailin
     * @date 2021/6/10 17:00
     */
    List<EventDetailsVO> getUnUploadEvent();
    /**
     * description 更新上传是否成功标识
     * @param id 事件主键ID
     * @return Boolean 上传是否成功
     * @author manailin
     * @date 2021/6/10 17:00
     */
    Boolean updateLcUploadFlag(Long id);
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/LcCompareCodeService.java
New file
@@ -0,0 +1,33 @@
package com.panzhihua.service_grid.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.service_grid.model.dos.LcCompareCodeDO;
/**
 * program 攀枝花智慧社区项目
 * description 本地网格和浪潮的对码表管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
public interface LcCompareCodeService extends IService<LcCompareCodeDO> {
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  id 本地网格ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String getLcGridIdByLocal(Long id);
    /**
     * description 根据本地网格ID,查询对于的浪潮市平台对应的ID
     *
     * @param  localUserId 本地网格员ID
     * @return String 浪潮市平台对应的ID
     * @author manailin
     * @date 2021/6/10 17:00
     */
    String getLcUserIdByLocal(String localUserId);
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -13,6 +14,7 @@
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.grid.*;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.ExcelSelectListUtil;
import com.panzhihua.common.utlis.LngLatUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_grid.dao.*;
@@ -55,7 +57,8 @@
    private EventGridMemberRelationMapper eventGridMemberRelationMapper;
    @Resource
    private EventGridDataService eventGridDataService;
    @Resource
    private EventResourceMapper eventResourceMapper;
    /**
     * 分页查找事件
     *
@@ -2043,4 +2046,33 @@
        return R.fail();
    }
    @Override
    public List<EventDetailsVO> getUnUploadEvent() {
        List<EventDetailsVO> eventDetailsVOList =new ArrayList<>();
        List<EventDO> unEventList = baseMapper.selectList(
                new QueryWrapper<EventDO>()
                        .eq("upload", false)
        );
        unEventList.forEach(eventDO -> {
            eventDetailsVOList.add(eventDetails(eventDO.getId()).getData());
        });
        return eventDetailsVOList;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateLcUploadFlag(Long id) {
        EventDO event = baseMapper.selectById(id);
        event.setUpload(true);
        baseMapper.updateById(event);
        EventResourceDO eventResourceDO =new EventResourceDO();
        eventResourceDO.setUpload(true);
        int flag = eventResourceMapper.update(eventResourceDO, new QueryWrapper<EventResourceDO>()
                .eq("ref_id", id));
        if(flag>0){
            return true;
        }
        return false;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/LcCompareCodeServiceImpl.java
New file
@@ -0,0 +1,55 @@
package com.panzhihua.service_grid.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.service_grid.dao.LcCompareCodeMapper;
import com.panzhihua.service_grid.dao.LcCompareMemberCodeMapper;
import com.panzhihua.service_grid.model.dos.LcCompareCodeDO;
import com.panzhihua.service_grid.model.dos.LcCompareCodeMemberDO;
import com.panzhihua.service_grid.service.LcCompareCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * program 攀枝花智慧社区项目
 * description 本地网格和浪潮的对码表管理API
 *
 * @author manailin
 * Date 2021-01-22 15:30
 **/
@Slf4j
@Service
public class LcCompareCodeServiceImpl extends ServiceImpl<LcCompareCodeMapper, LcCompareCodeDO> implements LcCompareCodeService {
   @Resource
   private LcCompareMemberCodeMapper compareMemberCodeMapper;
    @Override
    public String getLcGridIdByLocal(Long id) {
        try {
           return baseMapper.selectOne(
                    new QueryWrapper<LcCompareCodeDO>()
                            .eq("local_grid_id", id)
            ).getLcGridId();
        } catch (Exception e) {
            log.error("根据本地GRID查询浪潮网格对应表数据出错");
        }
        return null;
    }
    @Override
    public String getLcUserIdByLocal(String localUserId) {
        try {
            return compareMemberCodeMapper.selectOne(
                    new QueryWrapper<LcCompareCodeMemberDO>()
                            .eq("local_grid_member_id", localUserId)
            ).getLcBindUserId();
        } catch (Exception e) {
            log.error("根据本地GRID查询浪潮网格对应表数据出错");
        }
        return null;
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/test/java/com/panzhihua/service_grid/service/impl/EventServiceImplTest.java
New file
@@ -0,0 +1,37 @@
package com.panzhihua.service_grid.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.service_grid.ServiceGridApplication;
import com.panzhihua.service_grid.service.EventService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@Slf4j
@SpringBootTest(classes = ServiceGridApplication.class)
class EventServiceImplTest {
    @Resource
    private EventService eventService;
    @Test
    void getUnUploadEvent() {
        List<EventDetailsVO> eventList = eventService.getUnUploadEvent();
        String pretty = JSONArray.toJSONString(eventList, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        log.info(pretty);
    }
    @Test
    void updateLcUploadFlag() {
      Boolean  uploadFlag = eventService.updateLcUploadFlag(1111115L);
      log.info(uploadFlag.toString());
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/test/java/com/panzhihua/service_grid/service/impl/LcCompareCodeServiceImplTest.java
New file
@@ -0,0 +1,28 @@
package com.panzhihua.service_grid.service.impl;
import com.panzhihua.service_grid.ServiceGridApplication;
import com.panzhihua.service_grid.service.LcCompareCodeService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@SpringBootTest(classes = ServiceGridApplication.class)
class LcCompareCodeServiceImplTest {
    @Autowired
    private LcCompareCodeService lcCompareCodeService;
    @Test
    void getLcGridIdByLocal() {
    }
    @Test
    void getLcUserIdByLocal() {
        String lcUserId = lcCompareCodeService.getLcUserIdByLocal("2614");
        log.info(lcUserId);
    }
}
springcloud_k8s_panzhihuazhihuishequ/timejob/src/main/java/com/panzhihua/timejob/jobhandler/LangChaoEventUploadJobHandler.java
New file
@@ -0,0 +1,54 @@
package com.panzhihua.timejob.jobhandler;
import com.panzhihua.common.service.api.ApiServiceFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
 * program 攀枝花智慧社区项目
 * description 定时上报事件信息
 *
 * @author manailin
 * Date 2021-06-17 15:30
 **/
@Slf4j
@Component
public class LangChaoEventUploadJobHandler {
    @Resource
    private ApiServiceFeign ApiServiceFeign;
    /**
     * description 生成或更新redis里面的对接浪潮所需的token信息,token有效期12小时
     *
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @XxlJob("langChaoGetToken")
    public ReturnT<String> langChaoGetToken(String param) {
        log.info("定时更新浪潮对接token。token有效期12小时");
        ApiServiceFeign.getToken("18080799023", "123456");
        log.info("定时更新浪潮对接token完成");
        return ReturnT.SUCCESS;
    }
    /**
     * description 向浪潮服务器提交网格事件登记包括基础信息和文件(图片、mp3、mp4)信息
     *
     * @author manailin
     * @date 2021/6/10 17:00
     */
    @XxlJob("langChaoAutomationUpload")
    public ReturnT<String> langChaoAutomationUpload(String param) {
        log.info("向浪潮服务器提交网格事件登记开始");
        ApiServiceFeign.automationUploadEventAndFile();
        log.info("向浪潮服务器提交网格事件登记完成");
        return ReturnT.SUCCESS;
    }
}