Procházet zdrojové kódy

弹窗最后一次清缓存

njs před 1 rokem
rodič
revize
a10bdbe6e9

+ 11 - 1
suishenbang-system/src/main/java/com/dgtly/system/domain/AlertLog.java

@@ -42,6 +42,8 @@ public class AlertLog extends BaseEntity
     @Excel(name = "用户类型0立邦员工1经销商")
     private String userType;
 
+    private String isClearCache;
+
 
     public void setAlertLogId(Long alertLogId) 
     {
@@ -57,7 +59,15 @@ public class AlertLog extends BaseEntity
         this.alertId = alertId;
     }
 
-    public Long getAlertId() 
+    public String getIsClearCache() {
+        return isClearCache;
+    }
+
+    public void setIsClearCache(String isClearCache) {
+        this.isClearCache = isClearCache;
+    }
+
+    public Long getAlertId()
     {
         return alertId;
     }

+ 6 - 1
suishenbang-system/src/main/resources/mapper/system/AlertLogMapper.xml

@@ -16,10 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="loginName"    column="login_name"    />
         <result property="alertNum"    column="alert_num"    />
         <result property="userType"    column="user_type"    />
+        <result property="isClearCache"    column="is_clear_cache"    />
     </resultMap>
 
     <sql id="selectAlertLogVo">
-        select alert_log_id, alert_id, create_by, create_time, update_by, update_time, is_delete, user_id, login_name, alert_num, user_type from alert_log
+        select alert_log_id, alert_id, create_by, create_time, update_by, update_time, is_delete, user_id, login_name, alert_num, user_type,is_clear_cache from alert_log
     </sql>
 
     <select id="selectAlertLogList" parameterType="AlertLog" resultMap="AlertLogResult">
@@ -52,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="isCacheType !=null and  isCacheType == '0'.toString()">
             and DATE_FORMAT(create_time,'%Y%m%d') = DATE_FORMAT(NOW(),'%Y%m%d')
         </if>
+        order by  create_time desc
         limit 1
     </select>
 
@@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="loginName != null  and loginName != ''">login_name,</if>
             <if test="alertNum != null ">alert_num,</if>
             <if test="userType != null  and userType != ''">user_type,</if>
+            <if test="isClearCache !=null and isClearCache !='' ">is_clear_cache,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="alertId != null ">#{alertId},</if>
@@ -80,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="loginName != null  and loginName != ''">#{loginName},</if>
             <if test="alertNum != null ">#{alertNum},</if>
             <if test="userType != null  and userType != ''">#{userType},</if>
+            <if test="isClearCache !=null and isClearCache !='' ">#{isClearCache},</if>
          </trim>
     </insert>
 
@@ -96,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="loginName != null  and loginName != ''">login_name = #{loginName},</if>
             <if test="alertNum != null ">alert_num = #{alertNum},</if>
             <if test="userType != null  and userType != ''">user_type = #{userType},</if>
+            <if test="isClearCache !=null and isClearCache !='' ">is_clear_cache = #{isClearCache},</if>
         </trim>
         where alert_log_id = #{alertLogId}
     </update>

+ 106 - 8
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxAlertLogController.java

@@ -19,7 +19,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.ApiOperation;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -49,7 +52,7 @@ public class WxAlertLogController  extends ApiBaseController {
             @ApiImplicitParam(name = "params" , paramType = "body")
     })
     @PostMapping("/getAlert")
-    public Object getAlertLog(){
+    public Object getAlertLog() throws ParseException {
         String userType="";
         ParameterObject obj = getParameterObject();
         Long userId = Long.valueOf(obj.getString("userId"));
@@ -77,13 +80,37 @@ public class WxAlertLogController  extends ApiBaseController {
                 if ((strings.contains("1")  || strings.contains("2")) &&sysUserExt.getSalesLevel().equals("customer_level")){
                     //满足类型对应a
                     AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
-                    AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
-                    if(log == null){
+                    //AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
+                  /*  if(log == null){
                         alertConfiguration1.setIsClearCache(true);
-                    }
+                    }*/
                     if (alertLog!=null){
                         if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            alertLog.setAlertNum(alertLog.getAlertNum()+1);
+                            Long count =alertLog.getAlertNum()+1;
+                            // 创建两个日期对象
+                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                            Date date1 = dateFormat.parse(alertLog.getCreateTime().toString());
+                            Date date2 = dateFormat.parse(alertConfiguration1.getAlertEndTime().toString());
+                            // 设置时间部分为零点
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTime(date1);
+                            calendar.set(Calendar.HOUR_OF_DAY, 0);
+                            calendar.set(Calendar.MINUTE, 0);
+                            calendar.set(Calendar.SECOND, 0);
+                            calendar.set(Calendar.MILLISECOND, 0);
+                            date1 = calendar.getTime();
+                            calendar.setTime(date2);
+                            calendar.set(Calendar.HOUR_OF_DAY, 0);
+                            calendar.set(Calendar.MINUTE, 0);
+                            calendar.set(Calendar.SECOND, 0);
+                            calendar.set(Calendar.MILLISECOND, 0);
+                            date2 = calendar.getTime();
+                            int clearT = date1.compareTo(date2);
+                            if(count == alertConfiguration1.getAlertNum() && clearT==0){
+                                alertConfiguration1.setIsClearCache(true);
+                                alertLog.setIsClearCache("1");
+                            }
+                            alertLog.setAlertNum(count);
                             alertLogService.updateAlertLog(alertLog);
                             return AjaxResult.success(alertConfiguration1);
                         }else {
@@ -96,19 +123,67 @@ public class WxAlertLogController  extends ApiBaseController {
                         alertLog1.setUserId(userId);
                         alertLog1.setUserType("1");
                         alertLog1.setAlertNum(1L);
+                        // 创建两个日期对象
+                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                        Date date1 = dateFormat.parse(date.toString());
+                        Date date2 = dateFormat.parse(alertConfiguration1.getAlertEndTime().toString());
+                        // 设置时间部分为零点
+                        Calendar calendar = Calendar.getInstance();
+                        calendar.setTime(date1);
+                        calendar.set(Calendar.HOUR_OF_DAY, 0);
+                        calendar.set(Calendar.MINUTE, 0);
+                        calendar.set(Calendar.SECOND, 0);
+                        calendar.set(Calendar.MILLISECOND, 0);
+                        date1 = calendar.getTime();
+                        calendar.setTime(date2);
+                        calendar.set(Calendar.HOUR_OF_DAY, 0);
+                        calendar.set(Calendar.MINUTE, 0);
+                        calendar.set(Calendar.SECOND, 0);
+                        calendar.set(Calendar.MILLISECOND, 0);
+                        date2 = calendar.getTime();
+                        int clearT = date1.compareTo(date2);
+                        if(clearT==0 && alertConfiguration1.getAlertNum()==1){
+                            alertConfiguration1.setIsClearCache(true);
+                            alertLog1.setIsClearCache("1");
+                        }
                         alertLogService.insertAlertLog(alertLog1);
                         return AjaxResult.success(alertConfiguration1);
                     }
                 }
                 if((strings.contains("0") || strings.contains("2")) && !sysUserExt.getSalesLevel().equals("customer_level")){
                     AlertLog alertLog = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),"0");
-                    AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
+                  /*  AlertLog log = alertLogService.selectAlertLogByUserIdAndAlertId(userId, alertConfiguration1.getAlertId(),null);
                     if(log == null){
                         alertConfiguration1.setIsClearCache(true);
-                    }
+                    }*/
                     if (alertLog!=null){
                         if (alertLog.getAlertNum()<alertConfiguration1.getAlertNum()){
-                            alertLog.setAlertNum(alertLog.getAlertNum()+1);
+                            Long count =alertLog.getAlertNum()+1;
+                            // 创建两个日期对象
+                            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                            Date date1 = dateFormat.parse(alertLog.getCreateTime().toString());
+                            Date date2 = dateFormat.parse(alertConfiguration1.getAlertEndTime().toString());
+                            // 设置时间部分为零点
+                            Calendar calendar = Calendar.getInstance();
+                            calendar.setTime(date1);
+                            calendar.set(Calendar.HOUR_OF_DAY, 0);
+                            calendar.set(Calendar.MINUTE, 0);
+                            calendar.set(Calendar.SECOND, 0);
+                            calendar.set(Calendar.MILLISECOND, 0);
+                            date1 = calendar.getTime();
+
+                            calendar.setTime(date2);
+                            calendar.set(Calendar.HOUR_OF_DAY, 0);
+                            calendar.set(Calendar.MINUTE, 0);
+                            calendar.set(Calendar.SECOND, 0);
+                            calendar.set(Calendar.MILLISECOND, 0);
+                            date2 = calendar.getTime();
+                            int clearT = date1.compareTo(date2);
+                            if(count == alertConfiguration1.getAlertNum() && clearT==0){
+                                alertConfiguration1.setIsClearCache(true);
+                                alertLog.setIsClearCache("1");
+                            }
+                            alertLog.setAlertNum(count);
                             alertLogService.updateAlertLog(alertLog);
                             return AjaxResult.success(alertConfiguration1);
                         }else {
@@ -121,6 +196,29 @@ public class WxAlertLogController  extends ApiBaseController {
                         alertLog1.setUserId(userId);
                         alertLog1.setUserType("0");
                         alertLog1.setAlertNum(1L);
+                        // 创建两个日期对象
+                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                        Date date1 = dateFormat.parse(date.toString());
+                        Date date2 = dateFormat.parse(alertConfiguration1.getAlertEndTime().toString());
+                        // 设置时间部分为零点
+                        Calendar calendar = Calendar.getInstance();
+                        calendar.setTime(date1);
+                        calendar.set(Calendar.HOUR_OF_DAY, 0);
+                        calendar.set(Calendar.MINUTE, 0);
+                        calendar.set(Calendar.SECOND, 0);
+                        calendar.set(Calendar.MILLISECOND, 0);
+                        date1 = calendar.getTime();
+                        calendar.setTime(date2);
+                        calendar.set(Calendar.HOUR_OF_DAY, 0);
+                        calendar.set(Calendar.MINUTE, 0);
+                        calendar.set(Calendar.SECOND, 0);
+                        calendar.set(Calendar.MILLISECOND, 0);
+                        date2 = calendar.getTime();
+                        int clearT = date1.compareTo(date2);
+                        if(clearT==0 && alertConfiguration1.getAlertNum()==1){
+                            alertConfiguration1.setIsClearCache(true);
+                            alertLog1.setIsClearCache("1");
+                        }
                         alertLogService.insertAlertLog(alertLog1);
                         return AjaxResult.success(alertConfiguration1);
                     }