LIVE_YE 2 éve
szülő
commit
104ef411f0

+ 14 - 0
pom.xml

@@ -170,6 +170,20 @@
                 <version>${ruoyi.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>cn.jpush.api</groupId>
+                <artifactId>jpush-client</artifactId>
+                <version>3.4.3</version>
+            </dependency>
+
+            <dependency>
+                <groupId>cn.jpush.api</groupId>
+                <artifactId>jpush-client</artifactId>
+                <version>3.4.3</version>
+            </dependency>
+
+
+
         </dependencies>
     </dependencyManagement>
 

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -236,4 +236,6 @@ public class SysUserController extends BaseController {
     }
 
 
+
+
 }

+ 8 - 0
ruoyi-admin/src/main/resources/application-prod.yml

@@ -109,3 +109,11 @@ spring:
                 wall:
                     config:
                         multi-statement-allow: true
+
+
+#极光推送
+jpush:
+    environment: false
+    masterSecret: vf8g4f84f74v8f4d78g4ff48
+push:
+    appKey: 54456f5d662dfdsg

+ 2 - 2
ruoyi-admin/src/main/resources/application.yml

@@ -19,8 +19,8 @@ spring:
     # 国际化资源文件路径
     basename: i18n/messages
   profiles:
-    active: druid
-    #active: prod
+    #active: druid
+    active: prod
   # 文件上传
   servlet:
      multipart:

+ 13 - 0
ruoyi-common/pom.xml

@@ -132,6 +132,19 @@
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
+        <!---->
+        <dependency>
+            <groupId>cn.jpush.api</groupId>
+            <artifactId>jpush-client</artifactId>
+            <version>3.4.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.jpush.api</groupId>
+            <artifactId>jiguang-common</artifactId>
+            <version>1.1.7</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -70,6 +70,10 @@ public class SysUser extends BaseEntity
     @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
     private Date loginDate;
 
+
+    /** 极光id */
+    private String jgId;
+
     /** 部门对象 */
     @Excels({
         @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@@ -297,6 +301,14 @@ public class SysUser extends BaseEntity
         this.roleId = roleId;
     }
 
+    public String getJgId() {
+        return jgId;
+    }
+
+    public void setJgId(String jgId) {
+        this.jgId = jgId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 138 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/jPush/AbstractJPushToolUtil.java

@@ -0,0 +1,138 @@
+package com.ruoyi.common.utils.jPush;
+
+import cn.jiguang.common.resp.APIConnectionException;
+import cn.jiguang.common.resp.APIRequestException;
+import cn.jpush.api.JPushClient;
+import cn.jpush.api.push.PushResult;
+import cn.jpush.api.push.model.Message;
+import cn.jpush.api.push.model.Options;
+import cn.jpush.api.push.model.Platform;
+import cn.jpush.api.push.model.PushPayload;
+import cn.jpush.api.push.model.audience.Audience;
+import cn.jpush.api.push.model.notification.AndroidNotification;
+import cn.jpush.api.push.model.notification.IosAlert;
+import cn.jpush.api.push.model.notification.Notification;
+import com.alibaba.fastjson2.JSON;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component
+public abstract class AbstractJPushToolUtil {
+
+    private static final Logger log = LoggerFactory.getLogger(AbstractJPushToolUtil.class);
+
+    @Autowired
+    private JPushConfig jPush;
+
+    protected static AbstractJPushToolUtil abstractJPushToolUtils;
+
+    @PostConstruct
+    public void init() {
+        abstractJPushToolUtils = this;
+    }
+
+
+    private final static String appKey = "275af46e0d888270da3cfd1d";
+
+    private final static String masterSecret = "47047dfe7509f243bb8e25c7";
+
+    private static JPushClient jPushClient = new JPushClient(masterSecret, appKey);
+
+    /**
+     * 发送给指定极光Id
+     *
+     * @param registrationId
+     * @param notificationTitle
+     * @param msgTitle
+     * @param msgContent
+     * @param jPushVO
+     * @return
+     */
+    public static boolean sendToRegistrationId1(String notificationTitle, String
+            msgTitle, String msgContent, String jPushVO, String... registrationId) {
+        boolean result = false;
+        try {
+            PushPayload pushPayload = buildPushObject_all_registrationId_alertWithTitle
+                    (notificationTitle, msgTitle, msgContent, jPushVO, registrationId);
+            //TODO
+            log.info("极光推送入参信息pushPayload:{}", JSON.toJSONString(pushPayload));
+            PushResult pushResult = jPushClient.sendPush(pushPayload);
+            log.info("极光推送出参信息pushResult:{}", JSON.toJSONString(pushResult));
+            if (pushResult.getResponseCode() == 200) {
+                result = true;
+            }
+        } catch (APIConnectionException e) {
+            e.printStackTrace();
+        } catch (APIRequestException e) {
+            e.printStackTrace();
+        }
+        return result;
+
+    }
+    /**
+     * 给指定设备id推送
+     *
+     * @param notificationTitle 通知标题
+     * @param msgTitle          消息标题
+     * @param msgContent        消息内容
+     * @param jPushVO       附加字段
+     * @param registrationId     设备id
+     * @return
+     */
+
+    private static PushPayload buildPushObject_all_registrationId_alertWithTitle(
+            String notificationTitle, String msgTitle, String msgContent, String jPushVO, String... registrationId) {
+        return PushPayload.newBuilder()
+                //指定要推送的平台,all代表当前应用配置了的所有平台,也可以传android等具体平台
+                .setPlatform(Platform.all())
+                //指定推送的接收对象,all代表所有人,也可以指定已经设置成功的tag或alias或该应应用客户端调用接口获取到的registration id
+                .setAudience(Audience.registrationId(registrationId))
+                //jpush的通知,android的由jpush直接下发,iOS的由apns服务器下发,Winphone的由mpns下发
+                .setNotification(Notification.newBuilder()
+                        //指定当前推送的android通知
+                        .addPlatformNotification(
+                                AndroidNotification.newBuilder()
+                                        .setTitle(notificationTitle)
+                                        .setAlert(msgContent)
+                                        //此字段为透传字段(类型被极光限定,不能传object),不会显示在通知栏。用户可以通过此字段来做一些定制需求,如特定的key传要指定跳转的页面(value)
+                                        .addExtra("data", JSON.toJSONString(jPushVO))
+                                        .build())
+                        .build())
+
+                //Platform指定了哪些平台就会像指定平台中符合推送条件的设备进行推送。 jpush的自定义消息,
+                // sdk默认不做任何处理,不会有通知提示。建议看文档http://docs.jpush.io/guideline/faq/的
+                // [通知与自定义消息有什么区别?]了解通知和自定义消息的区别
+                .setMessage(Message.newBuilder()
+                        .setMsgContent(msgContent)
+                        .setTitle(msgTitle)
+                        .addExtra("data", JSON.toJSONString(jPushVO))
+                        .build())
+                .setOptions(Options.newBuilder()
+                        //此字段的值是用来指定本推送要推送的apns环境,false表示开发,true表示生产;对android和自定义消息无意义
+                        .setApnsProduction(false)
+                        //此字段是给开发者自己给推送编号,方便推送者分辨推送记录
+                        .setSendno(1)
+                        //此字段的值是用来指定本推送的离线保存时长,如果不传此字段则默认保存一天,最多指定保留十天;
+                        .setTimeToLive(86400)
+                        .build())
+                .build();
+    }
+
+
+    /**
+     * 获取IOS的IosAlert
+     *
+     * @param notificationTitle
+     * @param subTitle
+     * @param msgContent
+     * @return
+     */
+    private static IosAlert queryIosAlert(String notificationTitle, String subTitle, String msgContent) {
+        return IosAlert.newBuilder().setTitleAndBody(notificationTitle, subTitle, msgContent).build();
+    }
+
+    }

+ 54 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/jPush/JPushConfig.java

@@ -0,0 +1,54 @@
+package com.ruoyi.common.utils.jPush;
+
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class JPushConfig {
+
+    /**
+     * 极光官网-个人管理中心-点击查看-secret
+     */
+    @Value("${jpush.masterSecret}")
+    private String masterSecret;
+
+    /**
+     * 指定本推送要推送的apns环境,true表示生产,false表示开发
+     */
+    @Value("${jpush.environment}")
+    private boolean environment;
+
+    /**
+     * 极光官网-个人管理中心-appkey
+     */
+    @Value("${jpush.appKey}")
+    private String appKey;
+
+    public String getMasterSecret() {
+        return masterSecret;
+    }
+
+    public boolean isEnvironment() {
+        return environment;
+    }
+
+    public String getAppKey() {
+        return appKey;
+    }
+
+    public void setMasterSecret(String masterSecret) {
+        this.masterSecret = masterSecret;
+    }
+
+    public void setEnvironment(boolean environment) {
+        this.environment = environment;
+    }
+
+    public void setAppKey(String appKey) {
+        this.appKey = appKey;
+    }
+
+
+
+}

+ 36 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/jPush/JPushToolUtil.java

@@ -0,0 +1,36 @@
+package com.ruoyi.common.utils.jPush;
+
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class JPushToolUtil extends AbstractJPushToolUtil {
+    /**
+     * 发送给指定的极光ID
+     * @param notificationTitle  标题
+     * @param msgTitle 内容标题
+     * @param msgContent 内容
+     * @param jPushVO 扩展的json
+     * @param registrationId 极光id
+     * @return
+     */
+    public static boolean sendToRegistrationId(
+            String notificationTitle,
+            String msgTitle,
+            String msgContent,
+            String jPushVO,
+            String... registrationId) {
+        return sendToRegistrationId1(notificationTitle,msgTitle,msgContent,jPushVO,registrationId);
+    }
+
+    /*public static void main(String[] args) {
+        String num = "-0405-别名";
+        String notificationTitle = "推送测试-通知标题" + num;
+        String msgTitle = "推送测试-内容标题" + num;
+        String msgContent = "我是内容" + num;
+        String jPushVO = "我是扩展的json" + num;
+        boolean b = JPushToolUtil.sendToRegistrationId(notificationTitle, msgTitle, msgContent, jPushVO, "1104a897924659ab708");
+        System.out.println("i="+b);
+    }*/
+}
+

+ 51 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/jPush/JPushVO.java

@@ -0,0 +1,51 @@
+package com.ruoyi.common.utils.jPush;
+
+
+/**
+ * 极光拓展字段不能传输object,限制了类型,所以封装更好些
+ * 此类为极光推送拓展字段封装类(目前字段是暂定,你也可以拓展)
+ *
+ * @author juzi
+ * @date 2022-12-2
+ */
+public class JPushVO {
+    private Long id;
+
+    private String userName;
+
+    private String content;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    @Override
+    public String toString() {
+        return "JPushVO{" +
+                "id=" + id +
+                ", userName='" + userName + '\'' +
+                ", content='" + content + '\'' +
+                '}';
+    }
+}
+

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/Task.java

@@ -57,7 +57,7 @@ public class Task {
      * */
     @Async
     //@Scheduled(cron = "0 0/2 * * * ? ")
-    //@Scheduled(cron = "0 1 0 * * ? ")
+    @Scheduled(cron = "0 1 0 * * ? ")
     public void generateDb() throws Exception {
 
         //查询当前年的借鉴日信息
@@ -794,7 +794,7 @@ public class Task {
      */
     @Async
     //@Scheduled(cron = "0 0/2 * * * ? ")
-    //@Scheduled(cron = "0 1 0 * * ? ")
+    @Scheduled(cron = "0 1 0 * * ? ")
     public void popover() throws Exception {
         //获取当前时间
         String endTime = DateUtils.getYear();

+ 8 - 4
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="delFlag"      column="del_flag"     />
         <result property="loginIp"      column="login_ip"     />
         <result property="loginDate"    column="login_date"   />
+		<result property="jgId"    column="jg_id"   />
         <result property="createBy"     column="create_by"    />
         <result property="createTime"   column="create_time"  />
         <result property="updateBy"     column="update_by"    />
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 	
 	<sql id="selectUserVo">
-        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, 
+        select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date,u.jg_id, u.create_by, u.create_time, u.remark,
         d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
         from sys_user u
@@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
     
     <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
-		select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
+		select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date,u.jg_id, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
 		left join sys_dept d on u.dept_id = d.dept_id
 		where u.del_flag = '0'
 		<if test="userId != null and userId != 0">
@@ -86,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
+	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time,u.jg_id
 	    from sys_user u
 			 left join sys_dept d on u.dept_id = d.dept_id
 			 left join sys_user_role ur on u.user_id = ur.user_id
@@ -103,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
 	
 	<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
-	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
+	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time,u.jg_id
 	    from sys_user u
 			 left join sys_dept d on u.dept_id = d.dept_id
 			 left join sys_user_role ur on u.user_id = ur.user_id
@@ -154,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="sex != null and sex != ''">sex,</if>
  			<if test="password != null and password != ''">password,</if>
  			<if test="status != null and status != ''">status,</if>
+			<if test="jgId != null and jgId != ''">jg_id,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			create_time
@@ -168,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="sex != null and sex != ''">#{sex},</if>
  			<if test="password != null and password != ''">#{password},</if>
  			<if test="status != null and status != ''">#{status},</if>
+			<if test="jgId != null and jgId != ''">#{jgId},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			sysdate()
@@ -188,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null and status != ''">status = #{status},</if>
  			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  			<if test="loginDate != null">login_date = #{loginDate},</if>
+			<if test="jgId != null and jgId != ''">jg_id= #{jgId},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			<if test="remark != null">remark = #{remark},</if>
  			update_time = sysdate()

+ 4 - 4
ruoyi-system/src/main/resources/mapper/system/projectV2/ZsyzLcjlMapper.xml

@@ -44,19 +44,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
-    <select id="selectZsyzLcjlListQc" parameterType="ZsyzLcjl" resultMap="ZsyzLcjlResult">
+    <!--<select id="selectZsyzLcjlListQc" parameterType="ZsyzLcjl" resultMap="ZsyzLcjlResult">
         select ANY_VALUE(a.id) as id, ANY_VALUE(a.xm_id) as xm_id, ANY_VALUE(a.xmbh) as xmbh, ANY_VALUE(a.xmmc)as xmmc,
                ANY_VALUE(a.dept_id) as dept_id, ANY_VALUE(a.dept_name) as dept_name, ANY_VALUE(MAX(a.cl_time)) as cl_time, ANY_VALUE(a.progress) as progress
         from (select id, xm_id, xmbh, xmmc, dept_id, dept_name, cl_time, progress
         from zsyz_lcjl order by xm_id, cl_time desc) a group by xm_id
-    </select>
+    </select>-->
 
-   <!-- <select id="selectZsyzLcjlListQc" resultType="com.ruoyi.system.domain.projectV2.ZsyzLcjl">
+    <select id="selectZsyzLcjlListQc" resultType="com.ruoyi.system.domain.projectV2.ZsyzLcjl">
         select id, xm_id, xmbh, xmmc,
                dept_id, dept_name, MAX(cl_time) as cl_time, progress
         from (select id, xm_id, xmbh, xmmc, dept_id, dept_name, cl_time) as cl_time, progress
               from zsyz_lcjl order by xm_id, cl_time desc) a group by xm_id
-    </select>-->
+    </select>
 
     <insert id="insertZsyzLcjl" parameterType="ZsyzLcjl" useGeneratedKeys="true" keyProperty="id">
         insert into zsyz_lcjl

+ 10 - 10
ruoyi-system/src/main/resources/mapper/system/projectV2/ZsyzShyjMapper.xml

@@ -70,7 +70,7 @@
     </select>
 
 
-    <select id="selectZsyzShyjListByWt" resultMap="ZsyzShyjResult">
+    <!--<select id="selectZsyzShyjListByWt" resultMap="ZsyzShyjResult">
         SELECT
         ANY_VALUE ( s.id ) as id,
         ANY_VALUE ( s.xm_id ) as xm_id ,
@@ -87,20 +87,20 @@
         <where>
             s.shjg = '3'
             <if test="xmmc != null  and xmmc != ''">and s.xmmc like concat( #{xmmc}, '%') </if>
-            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+            <if test="params.beginTime != null and params.beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;
                 AND date_format(s.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
             </if>
-            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+            <if test="params.endTime != null and params.endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;
                 AND date_format(s.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
             </if>
         </where>
-        <!-- 数据范围过滤 -->
+        &lt;!&ndash; 数据范围过滤 &ndash;&gt;
         ${params.dataScope}
         GROUP BY
         s.xm_id
-    </select>
+    </select>-->
 
-    <!--<select id="selectZsyzShyjListByWt" resultMap="ZsyzShyjResult">
+    <select id="selectZsyzShyjListByWt" resultMap="ZsyzShyjResult">
         SELECT
         s.id,
         s.xm_id ,
@@ -117,18 +117,18 @@
         <where>
             s.shjg = '3'
             <if test="xmmc != null  and xmmc != ''">and s.xmmc like concat( #{xmmc}, '%') </if>
-            <if test="params.beginTime != null and params.beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;
+            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                 AND date_format(s.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
             </if>
-            <if test="params.endTime != null and params.endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;
+            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                 AND date_format(s.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
             </if>
         </where>
-        &lt;!&ndash; 数据范围过滤 &ndash;&gt;
+        <!-- 数据范围过滤 -->
         ${params.dataScope}
         GROUP BY
         s.xm_id
-    </select>-->
+    </select>
 
     <insert id="insertZsyzShyj" parameterType="ZsyzShyj" useGeneratedKeys="true" keyProperty="id">
         insert into zsyz_shyj