Browse Source

Merge branch 'alert' of http://git.dgtis.com/qxp/suishenbang-oneportal into alert

yanym 1 year ago
parent
commit
f2069fd17c

+ 6 - 5
suishenbang-admin/src/main/java/com/dgtly/web/controller/system/AlertConfigurationController.java

@@ -86,10 +86,10 @@ public class AlertConfigurationController extends BaseController
     @ResponseBody
     public AjaxResult addSave(AlertConfiguration alertConfiguration)
     {
-        int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
+      /*  int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
         if ( num==1){
-            return error("弹幕通知只能有一个启动,请修改后重新添加");
-        }
+            return error("弹幕通知只能有一个该组织下启动,请先关闭该组织下已启动的后重新添加");
+        }*/
         return toAjax(alertConfigurationService.insertAlertConfiguration(alertConfiguration));
     }
 
@@ -129,9 +129,10 @@ public class AlertConfigurationController extends BaseController
        if(alertConfiguration.getAlertStatus().equals("0")){
            return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
        }else{
-           int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
+           AlertConfiguration alert = alertConfigurationService.selectAlertConfigurationById(alertConfiguration.getAlertId());
+           int num = alertConfigurationService.selectAlertConfigurationListFilter(alert);
            if(num==1){
-               return AjaxResult.error("已发布该组织弹框,请核查");
+               return AjaxResult.error("已发布该组织在该时间内的弹框,请核查关闭已启动的后可开启本弹框");
            }else {
                return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
            }

+ 1 - 1
suishenbang-system/src/main/java/com/dgtly/system/service/IAlertConfigurationService.java

@@ -30,7 +30,7 @@ public interface IAlertConfigurationService
      */
     public List<AlertConfiguration> selectAlertConfigurationList(AlertConfiguration alertConfiguration);
 
-//
+//发布
     public int selectAlertConfigurationListFilter(AlertConfiguration alertConfiguration);
 
     /**

+ 23 - 5
suishenbang-system/src/main/java/com/dgtly/system/service/impl/AlertConfigurationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.dgtly.system.service.impl;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 import com.dgtly.common.utils.DateUtils;
@@ -73,24 +74,41 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
 
     @Override
     public int selectAlertConfigurationListFilter(AlertConfiguration alertConfiguration) {
+        Date start1 = alertConfiguration.getAlertStartTime();
+        Date end1 = alertConfiguration.getAlertEndTime();
         List<AlertConfiguration> alertConfigurationList= alertConfigurationMapper.selectAlertConfigurationListFilter(alertConfiguration);
         if(alertConfigurationList !=null && alertConfigurationList.size()>0){
             Iterator<AlertConfiguration> it = alertConfigurationList.iterator();
             List<String> orgCodes =new ArrayList<>();
             if(alertConfiguration.getOrgCode() !=null &&  !("null").equals(alertConfiguration.getOrgCode() )  ) {
                  orgCodes = alertConfigurationMapper.selectOrgCode(alertConfiguration.getSalesLevel(), alertConfiguration.getOrgCode());
-            }else{
-                //diy
-                return 1;
             }
             while (it.hasNext()) {
                 AlertConfiguration alert = it.next();
                     if(orgCodes !=null && orgCodes.size()>0 && alert.getOrgCode() !=null && !("null").equals(alert.getOrgCode())){
                         if(orgCodes.contains(alert.getOrgCode())){
-                            return 1;
+                            Date start2 = alert.getAlertStartTime();
+                            Date end2 = alert.getAlertEndTime();
+                            if ((start1.after(start2) && start1.before(end2)) ||
+                                    (end1.after(start2) && end1.before(end2)) ||
+                                    (start2.after(start1) && start2.before(end1)) ||
+                                    (end2.after(start1) && end2.before(end1))) {
+                               return 1;
+                            } else {
+                               return 0;
+                            }
                         }
                 }else{
-                        return 1;
+                        Date start2 = alert.getAlertStartTime();
+                        Date end2 = alert.getAlertEndTime();
+                        if ((start1.after(start2) && start1.before(end2)) ||
+                                (end1.after(start2) && end1.before(end2)) ||
+                                (start2.after(start1) && start2.before(end1)) ||
+                                (end2.after(start1) && end2.before(end1))) {
+                            return 1;
+                        } else {
+                            return 0;
+                        }
                     }
             }
         }else{

+ 3 - 0
suishenbang-system/src/main/resources/mapper/system/AlertConfigurationMapper.xml

@@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           and ( user_type =#{userType}  or user_type ='2')
         </if>
 
+
     </select>
     
     <select id="selectAlertConfigurationById" parameterType="Long" resultMap="AlertConfigurationResult">
@@ -61,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="userType !=null and userType !=''  ">
             and ( user_type =#{userType}  or user_type ='2')
         </if>
+        AND now() >=alert_start_time
+        AND alert_end_time > now()
     </select>
 
     <insert id="insertAlertConfiguration" parameterType="AlertConfiguration" useGeneratedKeys="true" keyProperty="alertId">

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

@@ -68,7 +68,7 @@ public class WxAlertLogController  extends ApiBaseController {
             Date date = new Date();
             int i = date.compareTo(alertConfiguration1.getAlertStartTime());
             int i1 = date.compareTo(alertConfiguration1.getAlertEndTime());
-            if (i >= 0 && i1 <= 0) {
+            if (i >= 0 && i1 < 0) {
                 //满足时间
                 String[] split = alertConfiguration1.getUserType().split(",");
                 List<String> strings = Arrays.asList(split);

+ 1 - 1
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxController.java

@@ -107,7 +107,7 @@ public class WxController extends ApiBaseController {
         log.info("当前企业用户登录名称:"+userId);
         SysUser user = sysUserService.selectUserByLoginName(userId);
         if(user==null){
-            return AjaxResult.error(302,"当前用户:"+userId+",不属于DIY用户或经销商用户");
+            return AjaxResult.error(302,"当前用户:"+userId+",不属于TUC用户或经销商用户");
         }else if(user.getRoles().size()==0){
             return AjaxResult.error(302,"当前用户:"+userId+",企业微信尚未分配用户权限,请联系管理员!");
         }else{