美文网首页
便民寻访台2.0版-(经测试)

便民寻访台2.0版-(经测试)

作者: 弹钢琴的崽崽 | 来源:发表于2020-11-27 19:49 被阅读0次

    一. 数据库设计

    业务表常用的9个字段都加上了,时间类型为varchar2类型

    • 走失人员表和丢失物品表是主要的业务表

    • 对这两个表进行数据添加时,往消息表中增加数据

    • 对这两个表进行数据修改时,同时修改消息表

    • 对这两个表进行删除时,消息表的数据也删除(逻辑删除),签阅表和签阅历史表的数据删除

    • 办结消息后要修改消息表对应数据状态删除签阅表对应的数据

    • 取消办结消息后要修改消息表对应数据状态,从历史签约表中查出该数据并插入到签阅表中

    • 所有未读消息是消息表中有,签阅表中没有的数据

    • 全部标记已读是查出所有未读的消息插入到签阅表中

    二. 项目

    1. 导入依赖

    <build>标签里面是打包配置后面会讲

    这里的名称和id都是大写的与项目名对应,否则打包后Linux启动会出错,如下:因为打的jar包是小写的启动拿大写的字母去启动

    许可证配置不生效,意思是不管配置文件配没配值启动许可证,都需要导入许可证才能访问

    <dependencyManagement>
        <dependencies>
            <!-- 导入duceap 2.1 POM定义-->
            <dependency>
                <groupId>com.dragonsoft</groupId>
                <artifactId>duceap-parent</artifactId>
                <version>2.1.0-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
    
        <!--web开发基础包-->
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-boot-starter-web</artifactId>
        </dependency>
        <!--flyway模块-->
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-boot-starter-flyway</artifactId>
        </dependency>
        <!--swagger-->
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-boot-starter-swagger</artifactId>
        </dependency>
        <!--表码模块-->
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-boot-starter-code</artifactId>
        </dependency>
        <!--上传组件模块-->
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-boot-starter-uploader</artifactId>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
        </dependency>
        <dependency>
            <groupId>com.dragonsoft</groupId>
            <artifactId>duceap-security-dcuc</artifactId>
        </dependency>
    </dependencies>
    <!--指定仓库地址-->
    <repositories>
        <repository>
            <id>duceap-releases</id>
            <name>Team Nexus Release Repository</name>
            <url>http://192.168.6.13:8081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <build>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>copy-libs</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <excludeScope>provided</excludeScope>
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                <!--取消依赖包的时间戳-->
                                <useBaseVersion>true</useBaseVersion>
                                <excludeArtifactIds>duceap-support-licenseignore</excludeArtifactIds>
                            </configuration>
                        </execution>
                        <execution>
                            <id>unpack</id>
                            <phase>package</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>com.dragonsoft</groupId>
                                        <artifactId>duceap-base</artifactId>
                                        <!--根据框架版本修改-->
                                        <version>2.1.0-SNAPSHOT</version>
                                        <outputDirectory>${project.build.directory}/temp</outputDirectory>
                                        <!--加入平台的启动脚本-->
                                        <includes>META-INF/scripts/**</includes>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.5.5</version>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <finalName>${project.name}-${project.version}</finalName>
                                <appendAssemblyId>false</appendAssemblyId>
                                <!--配置描述文件路径-->
                                <descriptor>src/main/assembly/assembly.xml</descriptor>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <!--运行jar包时运行的主类,要求类全名-->
                                <mainClass>com.dragonsoft.StartDemoApplication</mainClass>
                                <addClasspath>true</addClasspath>
                                <!--取消MANIFEST.MF中classpath下的时间戳-->
                                <useUniqueVersions>false</useUniqueVersions>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.0</version>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    2. 配置文件(dids登录)

    application.properties

    2.1 前端地址

    对接的前端地址为duceap.security.dids2.SSOServiceUrl=http://20.20.32.130:1645/bmxft/login

    要加上http://+ip:+端口/+上下文/login

    2.2 许可证配置

    duceap2.1不需要 删除author.properties配置文件

    # 应用名称
    spring.application.name = BMXFT2.0
    #授权
    duceap.license.enabled=false
    duceap.license.dataCacheMethod=file
    

    采用dids登录方式

    spring.datasource.url=jdbc:oracle:thin:@20.20.30.112:1521:ORCL
    spring.datasource.username=bmxft_tj
    spring.datasource.password=dragon
    spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
    #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    #spring.datasource.max-idle=10
    #spring.datasource.max-wait=10000
    #spring.datasource.min-idle=5
    #spring.datasource.initial-size=5
    server.port=8082
    server.servlet.context-path=/bmxft
    #打印sql日志
    spring.jpa.show-sql=true
    #配置登陆方式,dids、dssoac、dcuc
    duceap.security.type=dids
    #dids登录配置#
    #应用代码
    duceap.security.dids2.appCode=640000112000001
    #duceap.security.dids2.useSSO=true
    #单点登录服务器地址
    duceap.security.dids2.SSOLoginUrl=http://192.168.120.142:9999/didsserver/login
    #单点登录服务接口地址
    duceap.security.dids2.SSOValidateUrl=http://192.168.120.142:9999/didsserver/serviceValidate
    #对接系统地址(ip:端口/上下文/login) 开发环境中, ip端口需要配置成代理的前端地址(请全程使用真实的ip 而不是localhost或者127.0.0.1,否则会导致登录失败)
    duceap.security.dids2.SSOServiceUrl=http://20.20.32.130:1645/bmxft/login
    #duceap.security.dids2.accessType=1
    #单点登录服务接口地址
    duceap.security.dids2.webServiceUrl=http://192.168.120.142:9999/didsserver/webservices/
    #duceap.security.dids2.jndi=JDBC/DIDS
    #duceap.security.dids2.filterType=1
    #若匹配该地址,则无须过滤
    duceap.security.dids2.noFilterUrl=services,hessian,commons,install.action,.xml,/install,/widgets-src/,/authorizationPage.html,/importAuthorizationFile.html,/license/LicenseManagerServlet,/authorizationFile/,/api/file/,/v2/
    
    
    #设置文件上传大小,springboot默认的最大上传大小是1MB
    spring.servlet.multipart.max-file-size=1024MB
    spring.servlet.multipart.max-request-size=1024MB
    #设置服务端存储路径
    duceap.uploader.store.strategy=fileSystem
    duceap.uploader.store.fileSystem.path=file:/D:/upload/
    
    #授权
    duceap.license.enabled=false
    duceap.license.dataCacheMethod=file
    
    #flyway
    duceap.flyway.enabled=false
    #数据表空间
    duceap.flyway.placeholders.TABLESPACE_DATA=USERS
    ##索引表空间
    duceap.flyway.placeholders.TABLESPACE_INDEX=USERS
    ##大字段表空间
    duceap.flyway.placeholders.TABLESPACE_LOB=USERS
    #
    ##默认根据驱动名进行自动匹配
    flyway.dbtype=oracle
    #
    ##当没有配置flyway脚本扫描器类,默认加载此目录下flyway脚本
    duceap.flyway.locations=classpath:/sql/BMXFT
    duceap.flyway.placeholderPrefix=#{
    duceap.flyway.placeholderSuffix=}
    duceap.flyway.outOfOrder=true
    duceap.flyway.initOnMigrate=true
    duceap.flyway.initVersion=0.5.0
    duceap.flyway.ignoreFailedFutureMigration=false
    
    #swagger开关
    duceap.swagger.enabled = true
    #swagger扫描包路径 默认com.dragonsoft
    duceap.swagger.packagePath =com.dragonsoft.bmxft
    

    2.3 swagger路径

    http://20.20.32.132:8082/bmxft/v2/api-docs

    2.4 flyway脚本

    a. 建表V1.0.0__InitTable.sql
    
    /*==============================================================*/
    /* Table: T_LOST_PEOPLE                                         */
    /*==============================================================*/
    create table T_LOST_PEOPLE
    (
       ID                   varchar2(32)         not null,
       TITLE                varchar2(150)        not null,
       PEOPLE_TYPE_CODE     varchar2(10)         not null,
       PEOPLE_NAME          varchar2(30),
       UNKNOWN_NAME         varchar2(10)         default '0' not null,
       SEX_CODE             varchar2(10)         not null,
       ID_CARD              varchar2(20),
       HEIGHT_CODE          varchar2(10),
       SHAPE_CODE           varchar2(10),
       HAIRSTYLE_CODE       varchar2(10),
       HAIRCOLOR_CODE       varchar2(10),
       PEOPLE_TYPE          varchar2(10),
       AGE_CODE             varchar2(10),
       HEADWEAR             VARCHAR2(150),
       JACKET               VARCHAR2(150),
       TROUSERS             VARCHAR2(150),
       SHOES                VARCHAR2(150),
       BELONGINGS           VARCHAR2(300),
       SOMATOTYPE_MARKER    VARCHAR2(150),
       ACCENT               VARCHAR2(90),
       FIND_ADDRESS         VARCHAR2(210),
       OTHER_FEATURES       VARCHAR2(900),
       PHOTOS               VARCHAR2(2000),
       PREVIEW_PHOTO        VARCHAR2(200),
       REPORTER_NAME        VARCHAR2(30),
       REPORTER_TEL         VARCHAR2(30),
       REPORTER_ID_CARD     VARCHAR2(20),
       FIND_TIME            DATE,
       LOST_STATE           varchar2(10)         default '0',
       FINISH_REMARK        VARCHAR2(50),
       UNFINISH_TIME        DATE,
       FUZZY_SEARCH         VARCHAR2(3000),
       CREATE_TIME          VARCHAR2(50)         default SYSDATE,
       CREATE_USER          VARCHAR2(50),
       CREATE_USERNAME      VARCHAR2(30),
       CREATE_DEPT          VARCHAR2(50),
       CREATE_DEPTNAME      VARCHAR2(150),
       CREATER_TEL          VARCHAR2(30),
       HIDE_CREATER_TEL     varchar2(10)         default '0' not null,
       DELETED              varchar2(10)         default '0' not null,
       DELETE_TIME          VARCHAR2(50),
       UPDATE_TIME          VARCHAR2(50),
       UPDATE_USER          VARCHAR2(50),
       UPDATE_DEPT          VARCHAR2(50),
       DELETE_USER          VARCHAR2(50),
       DELETE_DEPT          VARCHAR2(50),
       constraint PK_T_LOST_PEOPLE primary key (ID)
    );
    
    comment on table T_LOST_PEOPLE is
    '走失人员表';
    
    comment on column T_LOST_PEOPLE.ID is
    '主键';
    
    comment on column T_LOST_PEOPLE.TITLE is
    '标题';
    
    comment on column T_LOST_PEOPLE.PEOPLE_TYPE_CODE is
    '人员类型【代码】';
    
    comment on column T_LOST_PEOPLE.PEOPLE_NAME is
    '人员姓名,不详直接不设置';
    
    comment on column T_LOST_PEOPLE.UNKNOWN_NAME is
    '是否人员姓名不详,1:是,0:否';
    
    comment on column T_LOST_PEOPLE.SEX_CODE is
    '性别【代码】';
    
    comment on column T_LOST_PEOPLE.ID_CARD is
    '身份证号';
    
    comment on column T_LOST_PEOPLE.HEIGHT_CODE is
    '人员身高【代码】';
    
    comment on column T_LOST_PEOPLE.SHAPE_CODE is
    '人员体型【代码】';
    
    comment on column T_LOST_PEOPLE.HAIRSTYLE_CODE is
    '发型【代码】';
    
    comment on column T_LOST_PEOPLE.HAIRCOLOR_CODE is
    '头发颜色【代码】';
    
    comment on column T_LOST_PEOPLE.PEOPLE_TYPE is
    '人员类型【代码】';
    
    comment on column T_LOST_PEOPLE.AGE_CODE is
    '人员年龄【代码】';
    
    comment on column T_LOST_PEOPLE.HEADWEAR is
    '头饰';
    
    comment on column T_LOST_PEOPLE.JACKET is
    '上衣';
    
    comment on column T_LOST_PEOPLE.TROUSERS is
    '裤子';
    
    comment on column T_LOST_PEOPLE.SHOES is
    '鞋子';
    
    comment on column T_LOST_PEOPLE.BELONGINGS is
    '随时物品';
    
    comment on column T_LOST_PEOPLE.SOMATOTYPE_MARKER is
    '体型标记';
    
    comment on column T_LOST_PEOPLE.ACCENT is
    '口音';
    
    comment on column T_LOST_PEOPLE.FIND_ADDRESS is
    '发现地点,通常用于尸体类型';
    
    comment on column T_LOST_PEOPLE.OTHER_FEATURES is
    '其他特征';
    
    comment on column T_LOST_PEOPLE.PHOTOS is
    '相关照片(id/url,多个),JSON格式,字符串数组,例如:["A","B","C"]';
    
    comment on column T_LOST_PEOPLE.PREVIEW_PHOTO is
    '预览图';
    
    comment on column T_LOST_PEOPLE.REPORTER_NAME is
    '报案人姓名';
    
    comment on column T_LOST_PEOPLE.REPORTER_TEL is
    '报案人电话';
    
    comment on column T_LOST_PEOPLE.REPORTER_ID_CARD is
    '报案人身份证号';
    
    comment on column T_LOST_PEOPLE.FIND_TIME is
    '发现时间';
    
    comment on column T_LOST_PEOPLE.LOST_STATE is
    '走失状态,1:办结,0:办理中';
    
    comment on column T_LOST_PEOPLE.FINISH_REMARK is
    '办结备注';
    
    comment on column T_LOST_PEOPLE.UNFINISH_TIME is
    '取消办结时间';
    
    comment on column T_LOST_PEOPLE.FUZZY_SEARCH is
    '模糊搜索信息';
    
    comment on column T_LOST_PEOPLE.CREATE_TIME is
    '创建时间';
    
    comment on column T_LOST_PEOPLE.CREATE_USER is
    '创建用户ID';
    
    comment on column T_LOST_PEOPLE.CREATE_USERNAME is
    '创建用户名';
    
    comment on column T_LOST_PEOPLE.CREATE_DEPT is
    '创建部门ID';
    
    comment on column T_LOST_PEOPLE.CREATE_DEPTNAME is
    '创建部门名称';
    
    comment on column T_LOST_PEOPLE.CREATER_TEL is
    '创建人手机号';
    
    comment on column T_LOST_PEOPLE.HIDE_CREATER_TEL is
    '是否隐藏创建人联系电话,1:隐藏,0:显示';
    
    comment on column T_LOST_PEOPLE.DELETED is
    '逻辑删除标记,1:删除,0:未删除';
    
    comment on column T_LOST_PEOPLE.DELETE_TIME is
    '删除时间';
    
    comment on column T_LOST_PEOPLE.UPDATE_TIME is
    '修改时间';
    
    comment on column T_LOST_PEOPLE.UPDATE_USER is
    '修改用户id';
    
    comment on column T_LOST_PEOPLE.UPDATE_DEPT is
    '修改部门id';
    
    comment on column T_LOST_PEOPLE.DELETE_USER is
    '删除用户id';
    
    comment on column T_LOST_PEOPLE.DELETE_DEPT is
    '删除部门id';
    
    /*==============================================================*/
    /* Index: IDX_PEOPLE_STATE__CREATE_TIME                         */
    /*==============================================================*/
    create index IDX_PEOPLE_STATE__CREATE_TIME on T_LOST_PEOPLE (
       LOST_STATE ASC,
       CREATE_TIME ASC
    );
    
    /*==============================================================*/
    /* Table: T_LOST_THINGS                                         */
    /*==============================================================*/
    create table T_LOST_THINGS
    (
       ID                   varchar2(32)         not null,
       TITLE                varchar2(150)        not null,
       THINGS_TYPE_CODE     varchar2(10)         not null,
       OTHER_THINGS_TYPE    varchar2(10)         default '0',
       OTHER_THINGS_TYPE_NAME VARCHAR2(90),
       BRAND                varchar2(100),
       UNKNOWN_BRAND        varchar2(10)         default '0' not null,
       MODEL                VARCHAR2(100),
       UNKNOWN_MODEL        varchar2(10)         default '0',
       COLOR                VARCHAR2(50),
       SOURCE               VARCHAR2(300),
       OTHER_FEATURES       VARCHAR2(900),
       PHOTOS               VARCHAR2(2000),
       PREVIEW_PHOTO        VARCHAR2(200),
       REPORTER_NAME        VARCHAR2(30),
       REPORTER_TEL         VARCHAR2(30),
       REPORTER_ID_CARD     VARCHAR2(20),
       FIND_TIME            DATE,
       LOST_STATE           varchar2(10)         default '0',
       FINISH_REMARK        VARCHAR2(50),
       UNFINISH_TIME        DATE,
       FUZZY_SEARCH         VARCHAR2(3000),
       CREATE_TIME          VARCHAR2(50)         default SYSDATE,
       CREATE_USER          VARCHAR2(50),
       CREATE_USERNAME      VARCHAR2(30),
       CREATE_DEPT          VARCHAR2(50),
       CREATE_DEPTNAME      VARCHAR2(150),
       CREATER_TEL          VARCHAR2(30),
       HIDE_CREATER_TEL     varchar2(10)         default '0' not null,
       DELETED              varchar2(10)         default '0' not null,
       DELETE_TIME          VARCHAR2(50),
       UPDATE_TIME          VARCHAR2(50),
       UPDATE_USER          VARCHAR2(50),
       UPDATE_DEPT          VARCHAR2(50),
       DELETE_USER          VARCHAR2(50),
       DELETE_DEPT          VARCHAR2(50),
       constraint PK_T_LOST_THINGS primary key (ID)
    );
    
    comment on table T_LOST_THINGS is
    '丢失物品表';
    
    comment on column T_LOST_THINGS.ID is
    '主键';
    
    comment on column T_LOST_THINGS.TITLE is
    '标题';
    
    comment on column T_LOST_THINGS.THINGS_TYPE_CODE is
    '物品类型【代码】';
    
    comment on column T_LOST_THINGS.OTHER_THINGS_TYPE is
    '是其他物品类型,1:是,0:否(默认)';
    
    comment on column T_LOST_THINGS.OTHER_THINGS_TYPE_NAME is
    '其他物品类型名称';
    
    comment on column T_LOST_THINGS.BRAND is
    '品牌';
    
    comment on column T_LOST_THINGS.UNKNOWN_BRAND is
    '品牌是否不详,1:是,0:否';
    
    comment on column T_LOST_THINGS.MODEL is
    '型号';
    
    comment on column T_LOST_THINGS.UNKNOWN_MODEL is
    '型号是否不详,1:是,0:否';
    
    comment on column T_LOST_THINGS.COLOR is
    '颜色';
    
    comment on column T_LOST_THINGS.SOURCE is
    '物品来源';
    
    comment on column T_LOST_THINGS.OTHER_FEATURES is
    '其他特征';
    
    comment on column T_LOST_THINGS.PHOTOS is
    '相关照片(id/url,多个),JSON格式,字符串数组,例如:["A","B","C"]';
    
    comment on column T_LOST_THINGS.PREVIEW_PHOTO is
    '预览图';
    
    comment on column T_LOST_THINGS.REPORTER_NAME is
    '报案人姓名';
    
    comment on column T_LOST_THINGS.REPORTER_TEL is
    '报案人电话';
    
    comment on column T_LOST_THINGS.REPORTER_ID_CARD is
    '报案人身份证号';
    
    comment on column T_LOST_THINGS.FIND_TIME is
    '发现丢失时间';
    
    comment on column T_LOST_THINGS.LOST_STATE is
    '寻找状态,1:办结,0:办理中';
    
    comment on column T_LOST_THINGS.FINISH_REMARK is
    '办结备注';
    
    comment on column T_LOST_THINGS.UNFINISH_TIME is
    '取消办结时间';
    
    comment on column T_LOST_THINGS.FUZZY_SEARCH is
    '模糊搜索信息';
    
    comment on column T_LOST_THINGS.CREATE_TIME is
    '创建时间';
    
    comment on column T_LOST_THINGS.CREATE_USER is
    '创建用户ID';
    
    comment on column T_LOST_THINGS.CREATE_USERNAME is
    '创建用户名';
    
    comment on column T_LOST_THINGS.CREATE_DEPT is
    '创建部门ID';
    
    comment on column T_LOST_THINGS.CREATE_DEPTNAME is
    '创建部门名称';
    
    comment on column T_LOST_THINGS.CREATER_TEL is
    '创建人手机号';
    
    comment on column T_LOST_THINGS.HIDE_CREATER_TEL is
    '是否隐藏创建人联系电话,1:隐藏,0:显示';
    
    comment on column T_LOST_THINGS.DELETED is
    '逻辑删除标记,1:删除,0:未删除';
    
    comment on column T_LOST_THINGS.DELETE_TIME is
    '删除时间';
    
    comment on column T_LOST_THINGS.UPDATE_TIME is
    '修改时间';
    
    comment on column T_LOST_THINGS.UPDATE_USER is
    '修改用户id';
    
    comment on column T_LOST_THINGS.UPDATE_DEPT is
    '修改部门id';
    
    comment on column T_LOST_THINGS.DELETE_USER is
    '删除用户id';
    
    comment on column T_LOST_THINGS.DELETE_DEPT is
    '删除部门id';
    
    /*==============================================================*/
    /* Index: IDX_THINGS_STATE                                      */
    /*==============================================================*/
    create index IDX_THINGS_STATE on T_LOST_THINGS (
       LOST_STATE ASC
    );
    
    /*==============================================================*/
    /* Table: T_MESSAGE                                             */
    /*==============================================================*/
    create table T_MESSAGE
    (
       ID                   VARCHAR2(32)         not null,
       MESSAGE_TYPE         VARCHAR2(32)         not null,
       DATA_ID              VARCHAR2(32),
       MESSAGE_TITLE        VARCHAR2(210)        not null,
       CREATE_TIME          VARCHAR2(50)                 not null,
       LOST_TIME            DATE,
       LOST_STATE           VARCHAR2(32)         default '0' not null,
       CREATE_USER_ID       VARCHAR2(50),
       DELETED              VARCHAR2(2)          default '0',
       UPDATE_TIME          VARCHAR2(50),
       UPDATE_USER          VARCHAR2(50),
       UPDATE_DEPT          VARCHAR2(50),
       DELETE_USER          VARCHAR2(50),
       DELETE_DEPT          VARCHAR2(50),
       DELETE_TIME          VARCHAR2(50),
       CREATE_USER          VARCHAR2(50),
       CREATE_DEPT          VARCHAR2(50),
       constraint PK_T_MESSAGE primary key (ID)
    );
    
    comment on table T_MESSAGE is
    '消息表,这个表保存所有数据,并且必须根据办结状态进行筛选';
    
    comment on column T_MESSAGE.ID is
    '主键';
    
    comment on column T_MESSAGE.MESSAGE_TYPE is
    '消息类型,1:人员消息,2:物品消息';
    
    comment on column T_MESSAGE.DATA_ID is
    '物品/人员表数据ID';
    
    comment on column T_MESSAGE.MESSAGE_TITLE is
    '消息标题';
    
    comment on column T_MESSAGE.CREATE_TIME is
    '创建时间/发布时间';
    
    comment on column T_MESSAGE.LOST_TIME is
    '丢失时间';
    
    comment on column T_MESSAGE.LOST_STATE is
    '办结状态,1:已办结(无须再查询),0:未办结(默认)';
    
    comment on column T_MESSAGE.CREATE_USER_ID is
    '创建用户ID';
    
    comment on column T_MESSAGE.DELETED is
    '逻辑删除标识,1:删除,0:未删除';
    
    comment on column T_MESSAGE.UPDATE_TIME is
    '修改时间';
    
    comment on column T_MESSAGE.UPDATE_USER is
    '修改用户id';
    
    comment on column T_MESSAGE.UPDATE_DEPT is
    '修改部门id';
    
    comment on column T_MESSAGE.DELETE_USER is
    '删除用户id';
    
    comment on column T_MESSAGE.DELETE_DEPT is
    '删除部门id';
    
    comment on column T_MESSAGE.DELETE_TIME is
    '删除时间';
    
    comment on column T_MESSAGE.CREATE_USER is
    '创建用户id';
    
    comment on column T_MESSAGE.CREATE_DEPT is
    '创建部门id';
    
    /*==============================================================*/
    /* Index: IDX_ST__MSG_TYPE__DATA_ID                             */
    /*==============================================================*/
    create index IDX_ST__MSG_TYPE__DATA_ID on T_MESSAGE (
       LOST_STATE ASC,
       MESSAGE_TYPE ASC,
       DATA_ID ASC
    );
    
    /*==============================================================*/
    /* Table: T_MESSAGE_READ                                        */
    /*==============================================================*/
    create table T_MESSAGE_READ 
    (
       USER_ID              VARCHAR2(50)         not null,
       MESSAGE_ID           VARCHAR2(32)         not null,
       READ_TIME            DATE                 default SYSDATE,
       constraint PK_T_MESSAGE_READ primary key (MESSAGE_ID, USER_ID)
    );
    
    comment on table T_MESSAGE_READ is
    '未办结消息签阅表,这个表的数据只保留待办结的消息签约状态';
    
    comment on column T_MESSAGE_READ.USER_ID is
    '阅读用户ID';
    
    comment on column T_MESSAGE_READ.MESSAGE_ID is
    '消息ID';
    
    comment on column T_MESSAGE_READ.READ_TIME is
    '阅读时间';
    
    /*==============================================================*/
    /* Index: IDX_MSG_TYPE2                                         */
    /*==============================================================*/
    create index IDX_MSG_TYPE2 on T_MESSAGE_READ (
       MESSAGE_ID ASC
    );
    
    /*==============================================================*/
    /* Table: T_MESSAGE_READ_HISTORY                                */
    /*==============================================================*/
    create table T_MESSAGE_READ_HISTORY 
    (
       USER_ID              VARCHAR2(50)       not null,
       MESSAGE_ID           VARCHAR2(32)         not null,
       READ_TIME            DATE                 default SYSDATE,
       constraint PK_T_MESSAGE_READ_HISTORY primary key (MESSAGE_ID, USER_ID)
    );
    
    comment on table T_MESSAGE_READ_HISTORY is
    '消息签阅历史表,这个表的数据永久存储';
    
    comment on column T_MESSAGE_READ_HISTORY.USER_ID is
    '阅读用户ID';
    
    comment on column T_MESSAGE_READ_HISTORY.MESSAGE_ID is
    '消息ID';
    
    comment on column T_MESSAGE_READ_HISTORY.READ_TIME is
    '阅读时间';
    
    /*==============================================================*/
    /* Index: IDX_MSG_TYPE3                                         */
    /*==============================================================*/
    create index IDX_MSG_TYPE3 on T_MESSAGE_READ_HISTORY (
       MESSAGE_ID ASC
    );
    
    
    b. 码表插入数据V1.0.1__CodeData.sql
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '走失人口消息', 'DM_PEOPLE_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '迷途人员消息', 'DM_PEOPLE_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '无名尸体消息', 'DM_PEOPLE_TYPE_CODE');
    
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_PEOPLE_TYPE_CODE', NULL, '消息类型', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL, 'CODE_ID=''DM_PEOPLE_TYPE_CODE''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('1', '160cm以下', 'DM_HEIGHT_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('2', '161-170cm', 'DM_HEIGHT_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('3', '171-175cm', 'DM_HEIGHT_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('4', '175-180cm', 'DM_HEIGHT_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('5', '181cm以上', 'DM_HEIGHT_CODE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_HEIGHT_CODE', NULL, '身高', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_HEIGHT_CODE''', '1', NULL);
    
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '中等',
    
    'DM_SHAPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '微瘦',
    
    'DM_SHAPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '瘦',
    
    'DM_SHAPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('4', '微胖',
    
    'DM_SHAPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('5', '胖',
    
    'DM_SHAPE_CODE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_SHAPE_CODE', NULL, '人员体型', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_SHAPE_CODE''', '1', NULL);
    
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '光头',
    
    'DM_HAIRSTYLE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '短发',
    
    'DM_HAIRSTYLE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '中长发',
    
    'DM_HAIRSTYLE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('4', '长发',
    
    'DM_HAIRSTYLE_CODE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_HAIRSTYLE_CODE', NULL, '人员发型', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_HAIRSTYLE_CODE''', '1', NULL);
    
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '黑色',
    
    'DM_HAIRCOLOR_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '白色',
    
    'DM_HAIRCOLOR_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '灰白色',
    
    'DM_HAIRCOLOR_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('4', '棕色',
    
    'DM_HAIRCOLOR_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('5', '其他',
    
    'DM_HAIRCOLOR_CODE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_HAIRCOLOR_CODE', NULL, '人员头发颜色', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_HAIRCOLOR_CODE''', '1', NULL);
    
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '精神病',
    
    'DM_PEOPLE_TYPE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '老年人',
    
    'DM_PEOPLE_TYPE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '儿童',
    
    'DM_PEOPLE_TYPE');
    INSERT INTO "DM_SYS_CODE" VALUES ('4', '无行为能力',
    
    'DM_PEOPLE_TYPE');
    INSERT INTO "DM_SYS_CODE" VALUES ('5', '其他',
    
    'DM_PEOPLE_TYPE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_PEOPLE_TYPE', NULL, '人员类型', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_PEOPLE_TYPE''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('1', '10岁以下', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('2', '11-20岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('3', '21-30岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('4', '31-40岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('5', '41-50岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('6', '51-60岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('7', '61-70岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('8', '71-80岁', 'DM_AGE_CODE');
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('9', '80岁以上', 'DM_AGE_CODE');
    
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_AGE_CODE', NULL, '人员年龄', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_AGE_CODE''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '寻找中',
    
    'DM_LOST_STATE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '已办结',
    
    'DM_LOST_STATE');
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_LOST_STATE', NULL, '消息状态', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_LOST_STATE''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" VALUES ('1', '手机',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('2', '钱包',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '背包',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('4', '挎包',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('5', '行李箱',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('6', '文件',
    
    'DM_THINGS_TYPE_CODE');
    INSERT INTO "DM_SYS_CODE" VALUES ('7', '其他(填写)',
    
    'DM_THINGS_TYPE_CODE');
    
    
    INSERT INTO "T_MD_SYS_CODE_DIC" VALUES ('DM_THINGS_TYPE_CODE', NULL, '物品类型', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL,
    
    'CODE_ID=''DM_THINGS_TYPE_CODE''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" VALUES ('3', '未知',
    
    'DM_SEX');
    
    
    
    INSERT INTO "T_MD_SYS_CODE_DIC" ("CODE_ID", "DATASOURCE_ID", "NAME", "ENTITY_NAME", "CODE_FIELD", "NAME_FIELD", "PY_FIELD", "WB_FIELD", "ORDER_FIELD", "SEGMENT_RULE", "VIEW_SQL", "LOAD_TYPE", "PARENT_CODE_FIELD") VALUES ('T_ORG_INFO', NULL, '机构信息', 'T_ORG_INFO', 'CODE', 'FULL_NAME', NULL, NULL, NULL, NULL, NULL, '1', NULL);
    
    
    INSERT INTO "T_MD_SYS_CODE_DIC" ("CODE_ID", "DATASOURCE_ID", "NAME", "ENTITY_NAME", "CODE_FIELD", "NAME_FIELD", "PY_FIELD", "WB_FIELD", "ORDER_FIELD", "SEGMENT_RULE", "VIEW_SQL", "LOAD_TYPE", "PARENT_CODE_FIELD") VALUES ('WebsiteVisiteUrl', NULL, '请求服务器地址', 'DM_SYS_CODE', 'CODE', 'VALUE', NULL, NULL, NULL, NULL, 'CODE_ID=''WebsiteVisiteUrl''', '1', NULL);
    
    INSERT INTO "DM_SYS_CODE" ("CODE", "VALUE", "CODE_ID") VALUES ('http://20.20.32.130:8082/bmxft', '图片地址path', 'WebsiteVisiteUrl');
    
    c. 还有一张机构表从现场导过来的

    3. 自动生成实体类

    公司工具路径

    生成后直接复制进项目,删除自动生成的常用的9个业务字段

    3.1 实体类常用业务字段处理

    在进行实体类赋值操作时set常用业务字段显得很冗余,我们可以通过继承一个类来解决这个问题:

    public class LostPeople extends CurdEntity<String> implements Serializable {
    }
    

    这时候发现没有往业务字段中赋值,还需要加上如下注解即可

    @EntityListeners({JpaAuditingEntityListener.class})
    public class LostPeople extends CurdEntity<String> implements Serializable {
    }
    

    3.2 自动生成主键UUID

    添加如下注解

    @Id
    @GeneratedValue(generator="idGenerator")
    @GenericGenerator(name="idGenerator", strategy="uuid")
    @Column(name = "ID")
    private String id;
    

    3.3 全局模糊查询字段处理

    全局搜索字段在实体类的get方法中进行拼接用来进行模糊查询

    private static String nvl(String str){
        return str == null ? "" : str ;
    }
    @Column(name=FUZZY_SEARCH, nullable=true, length=3000)
    public String getFuzzySearch() {
        return nvl(this.getPeopleName()) +
            nvl(this.getTitle()) +
            nvl(this.getIdCard()) +
            nvl(this.getHeadwear()) +
            nvl(this.getJacket()) +
            nvl(this.getTrousers()) +
            nvl(this.getShoes())+
            nvl(this.getBelongings())+
            nvl(this.getSomatotypeMarker())+
            nvl(this.getAccent())+
            nvl(this.getFindAddress())+
            nvl(this.getOtherFeatures())+
            nvl(this.getReporterIdCard())+
            nvl(this.getReporterName())+
            nvl(this.getReporterTel())+
            nvl(this.getCreateDeptname())+
            nvl(this.getCreateUsername())+
            nvl(this.getCreaterTel());
    }
    

    4. 走失人员业务接口

    4.1 LostPeopleController

    人员走失的相关接口

    a. 查询所有走失人员数据(swagger注释)

    swagger注释要写清楚,传的参数为页面中提供查询的字段

    b. 发布/编辑人员走失消息(需要返回实体类数据)
    1. 全局搜索人员信息
    2. swagger注释的使用
    3. 通过ID查询人员详情
    4. 删除人员消息
    5. 办结人员消息
    6. 取消办结人员消息
    c. 接口路径后面跟id注意!
    1. 请求是get请求
    2. 路径拼接id的格式/cancelFinishPeople/{id}
    3. 获取值(@PathVariable("id") String id)
    @RestController
    @Api(value = "人员走失相关接口")
    @RequestMapping(value = "/v1/lostpeople")
    public class LostPeopleController extends BaseRestController<LostPeople, String> {
    
        private ILostPeopleService lostPeopleService;
    
        public LostPeopleController(ILostPeopleService lostPeopleService){
            super(lostPeopleService);
            this.lostPeopleService = lostPeopleService;
        }
    
        /**
         * 查询所有走失人员数据
         * @param
         * @return
         */
        @ApiOperation(value = "查询所有的走失人员数据")
        @PostMapping(value = "/findList")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "peopleTypeCode", value = "消息类型【代码】", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "peopleName", value = "人员姓名", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "sexCode", value = "性别【代码】", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "heightCode", value = "人员身高【代码】", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "otherFeatures", value = "其他特征", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "lostState", value = "走失状态,1:办结,2:办理中", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "发布时间start", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "发布时间end", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "发布时间", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createUser", value = "发布人", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "peopleType", value = "人员类型", dataType = "String", required = false),
        })
        public Page<LostPeople> findList(Searchable searchCondition) {
            Page<LostPeople> page = lostPeopleService.findList(searchCondition);
            return page;
        }
    
        /**
         * 发布/编辑人员走失消息
         * @param lostPeople
         * @return
         */
        @ApiOperation(value = "发布/编辑人员走失消息")
        @PostMapping(value = "/releaseOrEditPeopleMessage")
        public ResponseResult releaseOrEditPeopleMessage(@RequestBody LostPeople lostPeople){
            LostPeople people = lostPeopleService.releaseOrEditPeopleMessage(lostPeople);
            return ResponseResult.newInstance(people);
        }
    
        /**
         * 全局搜索人物信息
         * @param searchable
         * @return
         */
        @ApiOperation(value = "全局搜索人物信息")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "fuzzySearch", value = "模糊搜索信息", dataType = "String", required = false)
        })
        @PostMapping(value = "/globalSearchPeople")
        public Page<LostPeople> globalSearch(Searchable searchable){
            Page<LostPeople> page = lostPeopleService.globalSearch(searchable);
            return page;
        }
    
        /**
         * 通过ID查询人员详情
         * @param id
         * @return
         */
        @ApiOperation(value = "查询人员详情")
        @GetMapping(value = "/findPeopleInfo/{id}")
        public ResponseResult findPeopleInfo(@PathVariable("id") String id){
            LostPeople lostPeople = lostPeopleService.findPeopleById(id);
            return ResponseResult.newInstance(lostPeople);
        }
    
        @ApiOperation(value = "删除人员消息")
        @GetMapping(value = "/deletePeople/{id}")
        public ResponseResult deletePeople(@PathVariable("id") String id){
            lostPeopleService.deletePeople(id);
            return ResponseResult.newInstance("删除成功");
        }
    
        @ApiOperation(value = "办结人员消息")
        @GetMapping(value = "/finishPeople/{id}")
        public ResponseResult finishPeople(@PathVariable("id") String id){
            lostPeopleService.finishPeople(id);
            return ResponseResult.newInstance("办结成功");
        }
    
        @ApiOperation(value = "取消办结人员消息")
        @GetMapping(value = "/cancelFinishPeople/{id}")
        public ResponseResult cancelFinishPeople(@PathVariable("id") String id){
            lostPeopleService.cancelFinishPeople(id);
            return ResponseResult.newInstance("取消办结成功");
        }
    }
    

    4.2 LostPeopleService

    a. 查询列表的Searchable条件(多选框)

    注意点

    1. 消息类型是多选框,自己需要进行判断用or拼接条件

      前端用字符串的形式将code传过来用,分割,后端处理

      public static void searchInfo(Searchable searchable) {
          searchable.addSearchFilter("deleted", SearchOperator.eq,"0");
          Condition peopleTypeCode = searchable.getSearchFilter("peopleTypeCode", SearchOperator.eq);
          searchable.removeSearchFilter("peopleTypeCode", SearchOperator.eq);
          List<SearchFilter> searchFilters = new ArrayList<>();
          if(null != peopleTypeCode && null != peopleTypeCode.getValue()){
              String value = (String)peopleTypeCode.getValue();
              List<String> codes = Arrays.asList(value.split(","));
              for (String str : codes){
                  searchFilters.add(SearchFilterHelper.newCondition("peopleTypeCode", SearchOperator.eq, str));
              }
              searchable.removeSearchFilter("peopleTypeCode", SearchOperator.eq);
              SearchFilter [] filters=searchFilters.toArray(new SearchFilter[searchFilters.size()]);
              searchable.addSearchFilter(SearchFilterHelper.or(searchFilters.get(0),filters));
          }
          searchable.addSort(Sort.Direction.DESC, "createTime");
          searchable.addSort(Sort.Direction.ASC,"lostState");
      }
      
    2. 发布/编辑操作根据有无ID进行判断操作类型,发布/编辑人员表的同时添加/修改消息表对应的数据

    @Service
    @Transactional
    public class LostPeopleService extends BaseService<LostPeople, String> implements ILostPeopleService {
    
        private LostPeopleRepository lostPeopleRepository;
        @Autowired
        private MessageRepository messageRepository;
    
        @Autowired
        private MessageService messageService;
    
        public LostPeopleService(LostPeopleRepository lostPeopleRepository){
                super(lostPeopleRepository);
                this.lostPeopleRepository=lostPeopleRepository;
        }
    
        /**
         * 查询人员列表
         * @param searchable
         * @return
         */
        @Override
        public Page<LostPeople> findList(Searchable searchable) {
            LostThingsService.searchInfo(searchable);
            Page<LostPeople> paging = lostPeopleRepository.paging(searchable);
            return paging;
        }
    
        /**
         * 发布/编辑人员消息
         * 人员表+数据,消息表+数据
         * @param lostPeople
         */
        @Override
        public LostPeople releaseOrEditPeopleMessage(LostPeople lostPeople) {
            String id = lostPeople.getId();
            if(StringUtils.isEmpty(id)) {
                /**
                 * 发布操作
                 */
                SecurityUser securityUser = SessionUtils.getUserInfo();
                lostPeople.setCreateUsername(securityUser.getName());
                lostPeople.setFuzzySearch(lostPeople.getFuzzySearch());
                lostPeople.setLostState(LostPeopleEnum.XZZ.getCode());//寻找中
                LostPeople lp = this.save(lostPeople);
                //往消息表中插入
                messageService.savePeopleMessage(lp);
                return lp;
            }else {
                /**
                 * 编辑操作
                 */
                LostPeople one = this.findOne(id);
                lostPeople.setLostState(one.getLostState());
                lostPeople.setUnfinishTime(one.getUnfinishTime());
                LostPeople update = lostPeopleRepository.update(lostPeople);
                //消息表也要修改
                messageService.updatePeopleMessage(lostPeople);
                return update;
            }
        }
    
        /**
         * 全局搜索人员消息
         * @param searchable
         * @return
         */
        @Override
        public Page<LostPeople> globalSearch(Searchable searchable) {
            searchable.addSort(Sort.Direction.DESC,"createTime");
            searchable.addSort(Sort.Direction.ASC,"lostState");
            Page<LostPeople> paging = this.paging(searchable);
            return paging;
        }
    
        /**
         * 通过ID查询人员详情
         * @param id
         * @return
         */
        @Override
        public LostPeople findPeopleById(String id) {
            messageService.isRead(id);
            LostPeople one = lostPeopleRepository.findOne(id);
            return one;
        }
    
        /**
         * 删除人员消息
         * @param id
         */
        @Override
        public void deletePeople(String id) {
            //逻辑删除
            this.deleteById(id);
            //逻辑删除消息表的数据
            Message message = messageService.delMessages(id);
            //删除签阅表和签阅历史表的数据
            messageRepository.delReadHistoryByMessageId(message.getId());
            messageRepository.delReadByMessageId(message.getId());
        }
    
        /**
         * 办结物品消息
         * @param id
         */
        @Override
        public void finishPeople(String id) {
            LostPeople lostPeople = this.findOne(id);
            lostPeople.setLostState(LostPeopleEnum.YBJ.getCode());
            //修改人员表状态已办结
            this.update(lostPeople);
            //修改消息表办结状态,删除签阅表数据
            messageService.finishMessageByDataId(id);
        }
    
        /**
         * 取消办结,修改状态
         * @param id
         */
        @Override
        public void cancelFinishPeople(String id) {
            LostPeople lostPeople = this.findOne(id);
            lostPeople.setLostState(LostPeopleEnum.XZZ.getCode());
            //设置取消办结时间
            lostPeople.setUnfinishTime(new Date());
            //修改人员表状态寻找中
            this.update(lostPeople);
            messageService.cancelFinishMessageByDataId(id);
        }
    }
    

    4.3 LostPeopleEnum

    public enum LostPeopleEnum {
    
    
    
        URL("URL", "/api/file/view/"),
    
        XZZ("1","寻找中"),
        YBJ("2","已办结");
    
    
        private final String code;
        private final String desc;
    
    
        private LostPeopleEnum(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }
    
    
        public String getCode() {
            return this.code;
        }
    
        public String getDesc() {
            return this.desc;
        }
    }
    

    5. 丢失物品业务

    5.1 LostThingsController

    相关接口

    1. 查询所有物品丢失数据
    2. 发布/编辑物品丢失消息
    3. 通过ID查询物品丢失详情
    4. 删除物品丢失消息
    5. 办结物品丢失消息
    6. 取消办结物品丢失消息
    @RestController
    @RequestMapping(value = "/v1/lostthings")
    public class LostThingsController extends BaseRestController<LostThings, String> {
    
        private ILostThingsService lostThingsService;
    
        public LostThingsController(ILostThingsService lostThingsService){
            super(lostThingsService);
            this.lostThingsService = lostThingsService;
        }
    
        /**
         * 查询所有物品丢失数据
         * @param
         * @return
         */
        @ApiOperation(value = "查询所有的物品丢失数据")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "thingsTypeCode", value = "物品类型【代码】", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "brand", value = "品牌", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "model", value = "型号", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "color", value = "颜色", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "otherFeatures", value = "其他特征", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "lostState", value = "走失状态,1:办结,2:办理中", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "发布时间start", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "发布时间end", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createDept", value = "发布单位", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "reporterName", value = "报案人姓名", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "reporterIdCard", value = "报案人身份证号", dataType = "String", required = false),
                @ApiImplicitParam(paramType = "query", name = "createUser", value = "发布人", dataType = "String", required = false),
        })
        @PostMapping(value = "/findList")
        public Page<LostThings> findList(Searchable searchCondition) {
            Page<LostThings> page = lostThingsService.findList(searchCondition);
            return page;
        }
    
        /**
         * 发布/编辑物品丢失消息
         * @param lostThings
         * @return
         */
        @ApiOperation(value = "发布/编辑物品丢失消息")
        @PostMapping(value = "/releaseOrEditPeopleMessage")
        public ResponseResult releaseOrEditThingsMessage(@RequestBody LostThings lostThings){
            LostThings things = lostThingsService.releaseOrEditThingsMessage(lostThings);
            return ResponseResult.newInstance(things);
        }
    
        /**
         * 全局搜索物品信息
         * @param searchable
         * @return
         */
        @ApiOperation(value = "全局搜索物品信息")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "fuzzySearch", value = "模糊搜索信息", dataType = "String", required = false)
        })
        @PostMapping(value = "/globalSearchThings")
        public Page<LostThings> globalSearchThings(Searchable searchable){
            Page<LostThings> page = lostThingsService.globalSearchThings(searchable);
            return page;
        }
    
        /**
         * 通过ID查询物品详情
         * @param id
         * @return
         */
        @ApiOperation(value = "查询物品详情")
        @GetMapping(value = "/findThingsInfo/{id}")
        public ResponseResult findThingsInfo(@PathVariable("id") String id){
            LostThings lostThings = lostThingsService.findThingsById(id);
            return ResponseResult.newInstance(lostThings);
        }
    
        @ApiOperation(value = "删除物品消息")
        @GetMapping(value = "/deleteThings/{id}")
        public ResponseResult deleteThings(@PathVariable("id") String id){
            lostThingsService.deleteThings(id);
            return ResponseResult.newInstance("删除成功");
        }
    
        @ApiOperation(value = "办结物品消息")
        @GetMapping(value = "/finishThings/{id}")
        public ResponseResult finishThings(@PathVariable("id") String id){
            lostThingsService.finishThings(id);
            return ResponseResult.newInstance("办结成功");
        }
    
        @ApiOperation(value = "取消办结物品消息")
        @GetMapping(value = "/cancelFinishThings/{id}")
        public ResponseResult cancelFinishThings(@PathVariable("id") String id){
            lostThingsService.cancelFinishThings(id);
            return ResponseResult.newInstance("取消办结成功");
        }
    }
    

    5.2 LostThingsService

    a. 处理查询条件:复选框or拼接sql
    @Service
    @Transactional
    public class LostThingsService extends BaseService<LostThings, String> implements ILostThingsService {
    
        private LostThingsRepository lostThingsRepository;
    
        @Autowired
        private MessageRepository messageRepository;
    
        @Autowired
        private MessageService messageService;
    
        public LostThingsService(LostThingsRepository lostThingsRepository){
                super(lostThingsRepository);
                this.lostThingsRepository=lostThingsRepository;
        }
    
    
        /**
         * 查询物品列表
         * @param searchable
         * @return
         */
        @Override
        public Page<LostThings> findList(Searchable searchable) {
            searchInfo(searchable);
            Page<LostThings> paging = this.paging(searchable);
            return paging;
        }
    
        /**
         * 发布/编辑物品消息
         * @param lostThings
         * @return
         */
        @Override
        public LostThings releaseOrEditThingsMessage(LostThings lostThings) {
            String id = lostThings.getId();
            if(StringUtils.isEmpty(id)){
                /**
                 * 发布操作
                 */
                SecurityUser securityUser = SessionUtils.getUserInfo();
                lostThings.setCreateUsername(securityUser.getName());
                lostThings.setFuzzySearch(lostThings.getFuzzySearch());
                lostThings.setLostState(LostThingsEnum.XZZ.getCode());//寻找中
                LostThings newLostThings = lostThingsRepository.save(lostThings);
                //消息表中同时增加数据
                messageService.saveThingMessage(newLostThings);
                return newLostThings;
            }else {
                /**
                 * 编辑操作
                 */
                LostThings one = this.findOne(id);
                lostThings.setLostState(one.getLostState());
                lostThings.setUnfinishTime(one.getUnfinishTime());
                LostThings updateThings = lostThingsRepository.update(lostThings);
                //修改消息表
                messageService.updateThingsMessage(updateThings);
                return updateThings;
            }
        }
    
        /**
         * 全局搜索物品消息
         * @param searchable
         * @return
         */
        @Override
        public Page<LostThings> globalSearchThings(Searchable searchable) {
            searchable.addSort(Sort.Direction.DESC,"createTime");
            searchable.addSort(Sort.Direction.ASC,"lostState");
            Page<LostThings> paging = this.paging(searchable);
            return paging;
        }
    
        /**
         * 通过ID查询物品详情
         * @param id
         * @return
         */
        @Override
        public LostThings findThingsById(String id) {
            messageService.isRead(id);
            LostThings one = lostThingsRepository.findOne(id);
            return one;
        }
    
        /**
         * 删除物品消息
         * @param id
         */
        @Override
        public void deleteThings(String id) {
            //逻辑删除
            this.deleteById(id);
            //逻辑删除消息表的数据
            Message message = messageService.delMessages(id);
            //删除签阅表和签阅历史表的数据
            messageRepository.delReadHistoryByMessageId(message.getId());
            messageRepository.delReadByMessageId(message.getId());
        }
    
        /**
         * 办结物品消息
         * @param id
         */
        @Override
        public void finishThings(String id) {
            LostThings lostThings = this.findOne(id);
            lostThings.setLostState(LostPeopleEnum.YBJ.getCode());
            this.update(lostThings);
            //修改消息表办结状态,删除签阅表数据
            messageService.finishMessageByDataId(id);
        }
    
        /**
         * 取消办结物品消息
         * @param id
         */
        @Override
        public void cancelFinishThings(String id) {
            LostThings lostThings = this.findOne(id);
            lostThings.setLostState(LostPeopleEnum.XZZ.getCode());
            //设置取消办结时间
            lostThings.setUnfinishTime(new Date());
            //修改人员表状态寻找中
            this.update(lostThings);
            messageService.cancelFinishMessageByDataId(id);
        }
    
        /**
         * 封装查询的条件
         * @param searchable
         */
        public static void searchInfo(Searchable searchable) {
            searchable.addSearchFilter("deleted", SearchOperator.eq,"0");
            Condition peopleTypeCode = searchable.getSearchFilter("peopleTypeCode", SearchOperator.eq);
            searchable.removeSearchFilter("peopleTypeCode", SearchOperator.eq);
            List<SearchFilter> searchFilters = new ArrayList<>();
            if(null != peopleTypeCode && null != peopleTypeCode.getValue()){
                String value = (String)peopleTypeCode.getValue();
                List<String> codes = Arrays.asList(value.split(","));
                for (String str : codes){
                    searchFilters.add(SearchFilterHelper.newCondition("peopleTypeCode", SearchOperator.eq, str));
                }
                searchable.removeSearchFilter("peopleTypeCode", SearchOperator.eq);
                SearchFilter [] filters=searchFilters.toArray(new SearchFilter[searchFilters.size()]);
                searchable.addSearchFilter(SearchFilterHelper.or(searchFilters.get(0),filters));
            }
            searchable.addSort(Sort.Direction.DESC, "createTime");
            searchable.addSort(Sort.Direction.ASC,"lostState");
        }
    
    }
    

    6. 消息业务

    6.1 MessageController

    消息相关接口

    1. 查询所有消息列表
    2. 查询未读数
    3. 全部标记已读
    4. 将图片与业务表关联
    @RestController
    @RequestMapping(value = "/v1/message")
    public class MessageController extends BaseRestController<Message, String> {
    
        private IMessageService messageService;
    
    
        public MessageController(IMessageService messageService){
            super(messageService);
            this.messageService = messageService;
        }
        /**
         * 查询所有消息列表
         * @param
         * @return
         */
        @ApiOperation(value = "查询所有消息列表")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "固定时间", dataType = "String", required = true)
        })
        @PostMapping(value = "/findList")
        public ResponseResult findList(Searchable searchable) {
            Page<MessageVo> messageVoList = messageService.findList(searchable);
            return ResponseResult.newInstance(messageVoList);
        }
    
        @ApiOperation(value = "查询所有消息数")
        @ApiImplicitParams({
                @ApiImplicitParam(paramType = "query", name = "createTime", value = "固定时间", dataType = "String", required = true)
        })
        @PostMapping(value = "/findUnReadCount")
        public ResponseResult findUnReadCount(Searchable searchable) {
            Integer count = messageService.AllUnReadCount(searchable);
            return ResponseResult.newInstance(count);
        }
    
        /**
         * 全部标记已读
         */
        @ApiOperation(value = "全部标记已读")
        @PostMapping(value = "/allRead")
        public ResponseResult allRead(){
            messageService.allRead();
            return ResponseResult.newInstance("全部已读");
        }
    
        @ApiOperation(value = "将图片与业务表关联")
        @PostMapping(value = "/relatedBusiness")
        public ResponseResult relatedBusiness(@RequestBody RequestFileVo requestFileVo){
            messageService.updateImage(requestFileVo.getBusId(),requestFileVo.getImageIds(),requestFileVo.getType());
            return ResponseResult.newInstance("操作成功");
        }
    }
    

    6.2 MessageService

    a. 查询消息列表(未读消息SQL)
    SELECT
        tm. ID,
        tm.MESSAGE_TYPE,
        tm.DATA_ID,
        tm.MESSAGE_TITLE,
        tm.CREATE_TIME,
        tm.LOST_TIME,
        tm.LOST_STATE,
        tm.CREATE_USER_ID
    FROM
        T_MESSAGE tm
    WHERE
        TM. ID NOT IN (
            SELECT
                T .MESSAGE_ID
            FROM
                T_MESSAGE_READ T
            WHERE
                T .USER_ID = ?
        )
    AND tm.CREATE_USER_ID != ?
    AND tm.DELETED = '0'
    AND tm.LOST_STATE = '1'
    ORDER BY
        tm.CREATE_TIME DESC
    
    1. 从签阅表中插槽当前登录用户读过的消息id(T_MESSAGE_ID)
    2. 从消息表查出消息id不存在在(T_MESSAGE_ID)的数据,就是当前登录的所有未读消息

    消息列表从消息表中查询创建者不是自己并且状态是未办结的消息按照创建时间倒序排

    返回的类型是MessageVo类型时间类型转成字符串,添加照片信息

    public class MessageVo {
        private String id;
        private String messageType;
        private String dataId;
        private String messageTitle;
        private String createTime;
        private Date lostTime;
    
        private String lostState;
        private String createUserId ;
        private String photos;
        //.......get(),set()方法
    }
    

    赋值工具类BeanUtils.copyProperties(m,messageVo);

    返回方式

    return PersistentFactory.getJdbcDao().paging(sql, searchable, MessageVo.class, new Object[]{userId,userId})
    
    b. 全部已读

    查询所有没读的消息ID和查未读数类似,通过消息ID往签阅表和历史签阅表填数据

    c. 删除消息

    根据消息类型判断是人员表还是物品表来进行逻辑删除,同时逻辑删除消息表的数据,删除签阅表和历史签阅表的数据

    d. 办结消息

    修改人员或物品的状态为已办结,同时也修改消息表的状态已办结,删除签阅表中的数据

    e. 取消办结

    修改人员或物品的状态为寻找中,同时也修改消息表的状态寻找中,从历史签阅表中查出数据存入签阅表中(之前读过该消息)

    f. 查看消息详情

    如果消息的创建人不是当前登录用户,状态不是已办结,签阅表中没有当前登录用户查看这个消息的记录,那么往签阅表和历史签阅表中添加数据

    g. 将图片与业务表关联

    从码表中查出配置的服务器路径,删除该业务与附件的关联,用“,”分割图片ID进行业务和图片的关联操作,拼接字符串:服务器地址+api+文件ID,存入业务表的图片字段中进行修改

    @Service
    public class MessageService extends BaseService<Message, String> implements IMessageService {
    
        private MessageRepository messageRepository;
    
        @Autowired
        private MessageReadRepository messageReadRepository;
        @Autowired
        private MessageReadHistoryRepository messageReadHistoryRepository;
        @Autowired
        private MessageReadService messageReadService;
        @Autowired
        private ILostPeopleService lostPeopleService;
    
        @Autowired
        private MessageReadHistoryService messageReadHistoryService;
    
        @Autowired
        private ILostThingsService lostThingsService;
    
        public MessageService(MessageRepository messageRepository){
                super(messageRepository);
                this.messageRepository=messageRepository;
        }
    
        /**
         * 查询未读消息列表
         * @param searchable
         * @return
         */
        @Override
        public Page<MessageVo> findList(Searchable searchable) {
            Page<MessageVo> paging = getMessageVos(searchable);
            List<MessageVo> messageVos = paging.getContent();
            if(!CollectionUtils.isEmpty(messageVos)) {
                for (MessageVo m : messageVos) {
                    if (MessageEnum.WPXX.getCode().equals(m.getMessageType())) {//物品消息
                        LostThings one = lostThingsService.findOne(m.getDataId());
                        m.setPhotos(one.getPhotos());
                    } else if (MessageEnum.RYXX.getCode().equals(m.getMessageType())) {//人员消息
                        LostPeople one = lostPeopleService.findOne(m.getDataId());
                        m.setPhotos(one.getPhotos());
                    }
                }
            }
            return paging;
        }
    
        /**
         * 获取当前登录用户的id
         * @return
         */
        private String getUserId() {
            return SessionUtils.getUserInfo().getId();
        }
    
    
        /**
         * 全部已读
         */
        @Override
        public void allRead() {
            String userId = getUserId();
            String sql = "SELECT " +
                    "tm.id "+
                    "FROM " +
                    "T_MESSAGE tm WHERE TM.ID not IN(select  t.MESSAGE_ID from T_MESSAGE_READ t where t.USER_ID = ?)  and tm.CREATE_USER_ID != ? "+
                    "and tm.DELETED = '0' and tm.LOST_STATE = '1' ";
            List<Map<String, Object>> ids = PersistentFactory.getJdbcDao().queryForList(sql, new Object[]{userId,userId});
            for(Map<String,Object> id : ids){//消息ID
                InsertReadAndHistory((String)id.get("ID"));
            }
        }
    
        /**
         * 点击详情后已读
         * @param lostId
         */
        @Transactional(rollbackFor = Exception.class)
        public void isRead(String lostId) {
            String userId = getUserId();
            Message message = messageRepository.findByDataId(lostId);
            String messageId = message.getId();
            //如果消息是自己发布的不往签阅表里加数据
            if(!userId.equals(message.getCreateUserId())) {
                //如果消息状态是寻找中
                if (LostPeopleEnum.XZZ.getCode().equals(message.getLostState())) {
                    List<MessageRead> messageReads = messageReadRepository.findByUserIdAndMessageId(userId,messageId);
                    //如果签约表中没有数据
                    if (CollectionUtils.isEmpty(messageReads)) {
                        messageReadService.saveMessageRead(userId,messageId);
                        List<MessageReadHistory> messageReadHistories = messageReadHistoryRepository.findByUserIdAndMessageId(userId,messageId);
                        //如果签阅历史表中没有数据
                        if(CollectionUtils.isEmpty(messageReadHistories)){
                            messageReadHistoryService.saveMessageReadHistory(userId,messageId);
                        }
                    }
                }
            }
        }
    
        /**
         * 根据消息ID往签约表及历史签约表中加数据
         * @param messageId
         * @return
         */
        @Transactional(rollbackFor = Exception.class)
        public void InsertReadAndHistory(String messageId) {
            String userId = getUserId();
            messageReadService.saveMessageRead(userId,messageId);
            messageReadHistoryService.saveMessageReadHistory(userId,messageId);
        }
    
    
        /**
         * 进行办结操作后
         * 根据数据ID修改办结状态为以办结,删除签阅表数据
         * @param id 数据id
         */
        @Transactional(rollbackFor = Exception.class)
        public void finishMessageByDataId(String id) {
            Message message = messageRepository.findByDataId(id);
            message.setLostState(LostPeopleEnum.YBJ.getCode());
            messageRepository.update(message);
            messageReadRepository.deleteByMessageId(message.getId());
        }
    
        /**
         * 关联图片与业务表
         * @param busId
         * @param imageIds
         * @param type
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void updateImage(String busId, String imageIds, String type) {
            List<CodeRecord> list = CodeInfoUtils.getCodeListByCodeDicId(SysEnum.QQSH.getCode());
            //先删除改业务与附件的关联,用于编辑操作
            messageRepository.updateDelFile(busId);
            if(!StringUtils.isEmpty(imageIds)){
                List<String> strings = Arrays.asList(imageIds.split(","));
                for(String imageId : strings){
                    messageRepository.updateFile(busId,imageId,type);
                }
                List<UploaderFile> fileList = messageRepository.findFileByBusinessId(busId);
                String apis = "";
                for(UploaderFile file : fileList){
                    apis += list.get(0).getValue()+LostPeopleEnum.URL.getDesc()+file.getId()+",";
                }
                String substring = apis.substring(0, apis.length() - 1);
                if(MessageEnum.RYTP.getCode().equals(type)){//图片类型为人员图片
                    LostPeople one = lostPeopleService.findOne(busId);
                    one.setPhotos(substring);
                    lostPeopleService.update(one);
                }else if(MessageEnum.WPTP.getCode().equals(type)){
                    LostThings one = lostThingsService.findOne(busId);
                    one.setPhotos(substring);
                    lostThingsService.update(one);
                }
    
            }
        }
    
        /**
         * 保存存物的消息
         * @param newLostThings
         */
        @Override
        public void saveThingMessage(LostThings newLostThings) {
            Message message = new Message();
            message.setMessageType(MessageEnum.WPXX.getCode());
            message.setDataId(newLostThings.getId());
            message.setMessageTitle(newLostThings.getCreateDeptname()+"发布"+newLostThings.getTitle());
            message.setLostTime(newLostThings.getFindTime());
            message.setLostState(newLostThings.getLostState());
            message.setCreateUserId(newLostThings.getCreateUser());
            messageRepository.save(message);
        }
    
        @Override
        public void updateThingsMessage(LostThings updateThings) {
            Message message = messageRepository.findByDataId(updateThings.getId());
            message.setLostTime(updateThings.getFindTime());
            message.setMessageType(MessageEnum.WPXX.getCode());
            message.setCreateUserId(updateThings.getCreateUser());
            message.setLostState(updateThings.getLostState());
            message.setMessageTitle(updateThings.getCreateDeptname() + "发布" + updateThings.getTitle());
            messageRepository.update(message);
        }
    
        @Override
        public void savePeopleMessage(LostPeople lp) {
            Message message = new Message();
            message.setMessageType(MessageEnum.RYXX.getCode());
            message.setDataId(lp.getId());
            message.setMessageTitle(lp.getCreateDeptname()+"发布"+lp.getTitle());
            message.setLostTime(lp.getFindTime());
            message.setLostState(lp.getLostState());
            message.setCreateUserId(lp.getCreateUser());
            this.save(message);
        }
    
        @Override
        public void updatePeopleMessage(LostPeople lostPeople) {
            Message message = messageRepository.findByDataId(lostPeople.getId());
            message.setLostTime(lostPeople.getFindTime());
            message.setMessageType(MessageEnum.RYXX.getCode());
            message.setCreateUserId(lostPeople.getCreateUser());
            message.setLostState(lostPeople.getLostState());
            message.setMessageTitle(lostPeople.getCreateDeptname() + "发布" + lostPeople.getTitle());
            messageRepository.update(message);
        }
    
        @Override
        public Integer AllUnReadCount(Searchable searchable) {
            Page<MessageVo> paging = getMessageVos(searchable);
            long totalElements = paging.getTotalElements();
            return (int)totalElements;
        }
    
        /**
         * 查询所有的消息列表Page
         * @param searchable
         * @return
         */
        private Page<MessageVo> getMessageVos(Searchable searchable) {
            String userId = getUserId();
            String sql = "SELECT " +
                    "tm.id , tm.MESSAGE_TYPE ,tm.DATA_ID , " +
                    "tm.MESSAGE_TITLE , tm.CREATE_TIME , " +
                    "tm.LOST_TIME ,tm.LOST_STATE , " +
                    "tm.CREATE_USER_ID  " +
                    "FROM " +
                    "T_MESSAGE tm WHERE TM.ID not IN(select  t.MESSAGE_ID from T_MESSAGE_READ t where t.USER_ID = ?)  and tm.CREATE_USER_ID != ? " +
                    "and tm.DELETED = '0' and tm.LOST_STATE = '1' " +
                    "ORDER BY tm.CREATE_TIME DESC";
            Condition createTime = searchable.getSearchFilter("createTime", SearchOperator.eq);
            if (!StringUtils.isEmpty(createTime)) {
                searchable.removeSearchFilter("createTime", SearchOperator.eq);
                searchable.addSearchFilter("CREATE_TIME", SearchOperator.le, createTime.getValue().toString());
            }
            return PersistentFactory.getJdbcDao().paging(sql, searchable, MessageVo.class, new Object[]{userId,userId});
        }
    
    
        /**
         * 进行取消办结操作后
         * 把消息表的状态改变并且通过消息ID从历史签阅表中查出数据存入签阅表中
         * @param lostId
         */
        @Transactional(rollbackFor = Exception.class)
        public void cancelFinishMessageByDataId(String lostId) {
            Message message = messageRepository.findByDataId(lostId);
            message.setLostState(LostPeopleEnum.XZZ.getCode());
            messageRepository.update(message);
            //从历史签阅表中查出数据存入签阅表里
            String insertReadByHistoryData = "INSERT INTO T_MESSAGE_READ " +
                    "SELECT * FROM T_MESSAGE_READ_HISTORY " +
                    "WHERE MESSAGE_ID = '" + message.getId() + "'";
            PersistentFactory.getJdbcDao().execute(insertReadByHistoryData);
        }
    
        /**
         * 根据数据ID逻辑删除消息
         */
        public Message delMessages(String id) {
            Message message = messageRepository.findByDataId(id);
            messageRepository.delete(message);
            return message;
        }
    }
    

    6.3 MessageRepository

    a. 通过业务ID查询消息对象(jpa方法规范)
    b. 删除业务与附件的关联
    c. 将业务与附件关联
    1. 通过消息ID删除消息表数据
    2. 通过消息ID删除签约表数据
    d. 根据业务类型获取业务附件
    e. sql添加数据时添加当前时间
    @Modifying
    @NativeQuery("insert into T_MESSAGE_READ_HISTORY (USER_ID,MESSAGE_ID,READ_TIME) values (:userId,:messageId,sysdate)")
    void saveMessageReadHistory(@Param("userId") String userId,@Param("messageId") String messageId);
    
    public interface MessageRepository extends BaseRepository<Message, String> {
        Message findByDataId(String id);
    
        /**
         * 删除业务与附件的关联
         * @param
         */
        @Modifying
        @NativeQuery("UPDATE T_UPLOADER_FILE SET BUSINESS_ID = '', BUSINESS_TYPE = '' WHERE BUSINESS_ID = :busId")
        void updateDelFile(@Param("busId") String busId);
    
        /**
         * 将业务与附件做关联
         * @param
         */
        @Modifying
        @NativeQuery("UPDATE T_UPLOADER_FILE SET BUSINESS_ID = :busId, BUSINESS_TYPE = :type WHERE ID = :imageId")
        void updateFile(@Param("busId") String busId,@Param("imageId") String imageId,@Param("type") String type);
    
        /**
         * 通过消息ID删除消息表数据
         * @param id
         */
        @Modifying
        @NativeQuery("delete from T_MESSAGE_READ_HISTORY where MESSAGE_ID = :id")
        void delReadHistoryByMessageId(@Param("id") String id);
    
        /**
         * 通过消息ID删除签约表的数据
         * @param id
         */
        @Modifying
        @NativeQuery("delete from T_MESSAGE_READ where MESSAGE_ID  = :id")
        void delReadByMessageId(@Param("id") String id);
    
        /**
         * 根据业务类型获取业务附件
         * @return
         */
        @NativeQuery(value = "SELECT * from T_UPLOADER_FILE WHERE BUSINESS_ID =:busId  ORDER by GENERATE_TIME ASC")
        List<UploaderFile> findFileByBusinessId(@Param("busId") String busId);
    }
    

    6.4 RequestFileVo

    public class RequestFileVo {
        private String busId;
    
        private String type;
    
        private String imageIds;
    
        public String getBusId() {
            return busId;
        }
    
        public void setBusId(String busId) {
            this.busId = busId;
        }
    
        public String getType() {
            return type;
        }
    
        public void setType(String type) {
            this.type = type;
        }
    
        public String getImageIds() {
            return imageIds;
        }
    
        public void setImageIds(String imageIds) {
            this.imageIds = imageIds;
        }
    }
    

    7. 系统通用

    7.1 DictController(根据code查码表)

    查询码表数据的接口

    @RestController
    @RequestMapping(value = "/v1/dict")
    public class DictController extends BaseRestController<Object,String> {
    
        /**
         * 查询字典项
         * @param
         * @return
         */
        @PostMapping(value = "/findDictList")
        public ResponseResult findDictList(@RequestParam(value="codeDicId") String codeDicId) {
            List<CodeRecord> list = CodeInfoUtils.getCodeListByCodeDicId(codeDicId);
            return ResponseResult.newInstance(list);
        }
    
    }
    

    7.2 LoginInfoController

    a. 根据机构code查出单位名(码表)
    @RestController
    @RequestMapping(value = "/v1/loginInfo")
    public class LoginInfoController {
        @ApiOperation(value = "查询当前登录用户信息")
        @PostMapping(value = "/findUser")
        public ResponseResult findUser() {
            SecurityUser securityUser = SessionUtils.getUserInfo();
            UserInfo userInfo= new UserInfo();
            if(securityUser != null) {
                userInfo.setCreateUserTel(securityUser.getTelephone());//电话
                userInfo.setCreateUserId(securityUser.getId());//用户ID
                userInfo.setCreateUserName(securityUser.getName());
                userInfo.setCreateDeptCode(securityUser.getSecurityOrg());//单位ID
                userInfo.setCreateDeptName(CodeInfoUtils.getLabel("T_ORG_INFO",securityUser.getSecurityOrg()));
            }
            return ResponseResult.newInstance(userInfo);
        }
    }
    

    7.3 SysEnum(用来获取码表里图片路径)

    public enum SysEnum {
        QQSH("WebsiteVisiteUrl", "请求方式"),
        ;
        private final String code;
        private final String desc;
    
    
        private SysEnum(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }
    
    
        public String getCode() {
            return this.code;
        }
    
        public String getDesc() {
            return this.desc;
        }
    }
    

    7.4 OrgInfoController(java生成树)

    @RestController
    @RequestMapping(value = "/v1/orgInfo")
    public class OrgInfoController {
        @Autowired
        private IOrgInfoService orgInfoService;
        @ApiOperation(value = "查询机构信息")
        @PostMapping(value = "/findOrgInfo")
        public ResponseResult findOrgInfo() {
            List<TreeNode> orgInfos = orgInfoService.findOrgInfo();
            return ResponseResult.newInstance(orgInfos);
        }
    }
    
    a. TreeNode
    public class TreeNode {
        private String id;
        private String label;
        private String pid;
        private List children = new ArrayList();
    }
    
    b. OrgInfoService
    public List<TreeNode> findOrgInfo() {
        return TreeExtendUtils.recursiveTree();
    }
    
    c. TreeExtendUtils
    public class TreeExtendUtils {
    
        public static List<TreeNode> recursiveTree() {
            String sql1 = "SELECT CODE as id,FULL_NAME as label,UP_GOV_CODE pid FROM T_ORG_INFO";
            List<TreeNode> treeNodeList = PersistentFactory.getJdbcDao().queryForList(sql1,TreeNode.class);
            return toTreeTwo(treeNodeList);
    }
        private static List<TreeNode> toTreeTwo(List<TreeNode> treeNodeList){
            Map<String,List<TreeNode>> listMap = treeNodeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
            treeNodeList.forEach(node -> node.setChildren(listMap.get(node.getId())));
            return treeNodeList.stream().filter(t -> "0".equals(t.getPid())).collect(Collectors.toList());
        }
    }
    

    相关文章

      网友评论

          本文标题:便民寻访台2.0版-(经测试)

          本文链接:https://www.haomeiwen.com/subject/lphfwktx.html