njs 1 year ago
parent
commit
2376d217d7

+ 59 - 22
suishenbang-admin/src/main/java/com/dgtly/web/controller/system/AlertConfigurationController.java

@@ -1,15 +1,15 @@
 package com.dgtly.web.controller.system;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import com.dgtly.system.domain.OrderSalesParameter;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 import com.dgtly.common.annotation.Log;
 import com.dgtly.common.enums.BusinessType;
 import com.dgtly.system.domain.AlertConfiguration;
@@ -87,7 +87,7 @@ public class AlertConfigurationController extends BaseController
     public AjaxResult addSave(AlertConfiguration alertConfiguration)
     {
         int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
-        if (alertConfiguration.getAlertStatus().equals("1")&&num==1){
+        if (alertConfiguration.getAlertStatus().equals("1") && num==1){
             return error("弹幕通知只能有一个启动,请修改后重新添加");
         }
         return toAjax(alertConfigurationService.insertAlertConfiguration(alertConfiguration));
@@ -103,7 +103,6 @@ public class AlertConfigurationController extends BaseController
         mmap.put("alertConfiguration", alertConfiguration);
         return prefix + "/edit";
     }
-
     /**
      * 修改保存弹框配置
      */
@@ -113,23 +112,31 @@ public class AlertConfigurationController extends BaseController
     @ResponseBody
     public AjaxResult editSave(AlertConfiguration alertConfiguration)
     {
-        //没改之前的配置
-        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationById(alertConfiguration.getAlertId());
-        //判断之前有没有
-        int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
-        if(num==1){
-            if (alertConfiguration1.getAlertStatus().equals("1")){
-                return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
-            }else {
-                if (alertConfiguration.getAlertStatus().equals("1")){
-                    return AjaxResult.error("列表中只能有一条日志配置启动");
-                }else {
-                    return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
-                }
-            }
-        }else {
+        if(("0").equals(alertConfiguration.getAlertStatus())){
             return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
         }
+        return error("请取消发布后再做修改");
+    }
+    /**
+     * 是否发布/取消发布弹框配置
+     */
+    @RequiresPermissions("system:configuration:edit")
+    @Log(title = "发布弹框", businessType = BusinessType.UPDATE)
+    @PostMapping("/release")
+    @ResponseBody
+    public AjaxResult release(AlertConfiguration alertConfiguration)
+    {
+       if(alertConfiguration.getAlertStatus().equals("0")){
+           return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
+       }else{
+           int num = alertConfigurationService.selectAlertConfigurationListFilter(alertConfiguration);
+           if(num==1){
+               return AjaxResult.error("已发布该组织弹框,请核查");
+           }else {
+               return toAjax(alertConfigurationService.updateAlertConfiguration(alertConfiguration));
+           }
+
+       }
     }
 
     /**
@@ -143,4 +150,34 @@ public class AlertConfigurationController extends BaseController
     {
         return toAjax(alertConfigurationService.deleteAlertConfigurationByIds(ids));
     }
+
+
+    @PostMapping("/searchOrg")
+    @ResponseBody
+    public Map searchProductParamByCustomerCode(@RequestBody OrderSalesParameter salesManager) {
+        if("".equals(salesManager.getParType()) || salesManager.getParType() ==null){
+            salesManager.setParType("div_level");
+        }
+        Map map = new HashMap();
+        List<Map<String,Object>> dataList = alertConfigurationService.searchProductParamByCustomerCode(
+                salesManager.getParType(),salesManager.getParValue());
+        if(dataList != null && dataList.size() > 0){
+            map.put("levelInfo",dataList.get(0));
+            if ("suboffice_level".equals(salesManager.getParType()) ||
+                    "customer_level".equals(salesManager.getParType()) ||
+                    "emp_level".equals(salesManager.getParType()) ||
+                    "saledept_level".equals(salesManager.getParType())
+            ){
+                map.put("dataList",new ArrayList());
+            }else{
+                map.put("dataList",dataList);
+            }
+            return map;
+        } else {
+            Map mapnull = new HashMap();
+            map.put("levelInfo",mapnull);
+            map.put("dataList",dataList);
+            return map;
+        }
+    }
 }

+ 2 - 2
suishenbang-admin/src/main/resources/templates/system/alertConfiguration/add.html

@@ -46,7 +46,7 @@
                 </select>
             </div>
         </div>
-        <div class="form-group">
+<!--        <div class="form-group">
             <label class="col-sm-3 control-label">是否启动:</label>
             <div class="col-sm-8">
                 <div class="radio-box" th:each="dict : ${@dict.getType('sys_ziti_show_hide')}">
@@ -55,7 +55,7 @@
                     <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                 </div>
             </div>
-        </div>
+        </div>-->
         <!--<div class="form-group">-->
             <!--<label class="col-sm-3 control-label">是否启动</label>-->
             <!--<div class="col-sm-8">-->

+ 2 - 2
suishenbang-admin/src/main/resources/templates/system/alertConfiguration/edit.html

@@ -48,7 +48,7 @@
                     </select>
                 </div>
             </div>
-            <div class="form-group">
+       <!--     <div class="form-group">
                 <label class="col-sm-3 control-label">是否启动:</label>
                 <div class="col-sm-8">
                     <div class="radio-box" th:each="dict : ${@dict.getType('sys_ziti_show_hide')}">
@@ -57,7 +57,7 @@
                         <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                     </div>
                 </div>
-            </div>
+            </div>-->
             <!--<div class="form-group">    -->
                 <!--<label class="col-sm-3 control-label">是否启动:</label>-->
                 <!--<div class="col-sm-8">-->

+ 25 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/AlertConfiguration.java

@@ -47,6 +47,15 @@ public class AlertConfiguration extends BaseEntity
     @Excel(name = "是否启动默认0未启动,1启动")
     private String alertStatus;
 
+    /** 组织级别 */
+    private String salesLevel;
+
+    /** 组织机构 */
+    private String orgCode;
+
+    /** 组织机构名称 */
+    private String orgName;
+
     public void setAlertId(Long alertId) 
     {
         this.alertId = alertId;
@@ -119,6 +128,22 @@ public class AlertConfiguration extends BaseEntity
         this.alertStatus = alertStatus;
     }
 
+    public String getSalesLevel() {
+        return salesLevel;
+    }
+
+    public void setSalesLevel(String salesLevel) {
+        this.salesLevel = salesLevel;
+    }
+
+    public String getOrgCode() {
+        return orgCode;
+    }
+
+    public void setOrgCode(String orgCode) {
+        this.orgCode = orgCode;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 25 - 0
suishenbang-system/src/main/java/com/dgtly/system/domain/OrderSalesParameter.java

@@ -0,0 +1,25 @@
+package com.dgtly.system.domain;
+
+import lombok.Data;
+
+/**
+ * @ClassName OrderSalesParameter
+ * @Description: 订单销售目标与达成 请求参数
+ * @Author nsy
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+@Data
+public class OrderSalesParameter {
+
+    private String parType;
+
+
+    /**
+     * type 相应类型对应的 code值
+     * 部门级别传部门编号
+     * 销售员级别传人员编号
+     * 经销商级别传经销商编号
+     */
+    private String parValue;
+}

+ 9 - 2
suishenbang-system/src/main/java/com/dgtly/system/mapper/AlertConfigurationMapper.java

@@ -4,6 +4,7 @@ import com.dgtly.system.domain.AlertConfiguration;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 弹框配置Mapper接口
@@ -21,7 +22,7 @@ public interface AlertConfigurationMapper
      */
     public AlertConfiguration selectAlertConfigurationById(Long alertId);
 
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(@Param("userType") String userType);
+    public List<AlertConfiguration> selectAlertConfigurationByAlertStatus(@Param("userType") String userType);
 
 
     /**
@@ -32,7 +33,7 @@ public interface AlertConfigurationMapper
      */
     public List<AlertConfiguration> selectAlertConfigurationList(AlertConfiguration alertConfiguration);
 
-    public int selectAlertConfigurationListFilter(AlertConfiguration alertConfiguration);
+    public List<AlertConfiguration> selectAlertConfigurationListFilter(AlertConfiguration alertConfiguration);
 
     /**
      * 新增弹框配置
@@ -65,4 +66,10 @@ public interface AlertConfigurationMapper
      * @return 结果
      */
     public int deleteAlertConfigurationByIds(String[] alertIds);
+
+    public List<String> selectOrgCode(@Param("parType") String parType,@Param("parValue") String parValue);
+
+    public List<String> selectOrgCodeByInterface(@Param("parType") String parType,@Param("parValue") String parValue);
+
+    List<Map<String, Object>> searchProductParamByCustomerCode(@Param("salesLevel")String salesLevel, @Param("orgCode")String orgCode, @Param("groupByStr") String groupByStr);
 }

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

@@ -2,6 +2,7 @@ package com.dgtly.system.service;
 
 import com.dgtly.system.domain.AlertConfiguration;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 弹框配置Service接口
@@ -19,7 +20,7 @@ public interface IAlertConfigurationService
      */
     public AlertConfiguration selectAlertConfigurationById(Long alertId);
 
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(String userType);
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(String userType,String salesLevel,String orgCode);
 
     /**
      * 查询弹框配置列表
@@ -63,4 +64,6 @@ public interface IAlertConfigurationService
      * @return 结果
      */
     public int deleteAlertConfigurationById(Long alertId);
+
+    List<Map<String, Object>>  searchProductParamByCustomerCode(String salesLevel, String orgCode);
 }

+ 63 - 3
suishenbang-system/src/main/java/com/dgtly/system/service/impl/AlertConfigurationServiceImpl.java

@@ -1,6 +1,10 @@
 package com.dgtly.system.service.impl;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+
 import com.dgtly.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,8 +38,28 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
     }
 
     @Override
-    public AlertConfiguration selectAlertConfigurationByAlertStatus(String userType) {
-        return alertConfigurationMapper.selectAlertConfigurationByAlertStatus(userType);
+    public AlertConfiguration selectAlertConfigurationByAlertStatus(String userType,String salesLevel,String orgCode) {
+        List<AlertConfiguration> alertConfigurationList = alertConfigurationMapper.selectAlertConfigurationByAlertStatus(userType);
+        if(alertConfigurationList !=null && alertConfigurationList.size()> 0 ){
+            Iterator<AlertConfiguration> it = alertConfigurationList.iterator();
+            while (it.hasNext()) {
+                AlertConfiguration alert = it.next();
+                //diy
+                if(orgCode ==null || ("").equals(orgCode)){
+                    if( alert.getOrgCode() ==null){
+                        return alert;
+                    }
+                }else{
+                    List<String>  orgCodes = alertConfigurationMapper.selectOrgCodeByInterface(alert.getSalesLevel(),alert.getOrgCode());
+                    if(orgCodes !=null && orgCodes.size()>0){
+                        if(orgCodes.contains(orgCode)){
+                            return alert;
+                        }
+                    }
+                }
+            }
+        }
+        return  null;
     }
 
     /**
@@ -52,7 +76,28 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
 
     @Override
     public int selectAlertConfigurationListFilter(AlertConfiguration alertConfiguration) {
-        return alertConfigurationMapper.selectAlertConfigurationListFilter(alertConfiguration);
+        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) {
+                 orgCodes = alertConfigurationMapper.selectOrgCode(alertConfiguration.getSalesLevel(), alertConfiguration.getOrgCode());
+            }else{
+                //diy
+                return 1;
+            }
+            while (it.hasNext()) {
+                AlertConfiguration alert = it.next();
+                    if(orgCodes !=null && orgCodes.size()>0){
+                        if(orgCodes.contains(alert.getOrgCode())){
+                            return 1;
+                        }
+                }
+            }
+        }else{
+                    return 0;
+        }
+        return 0;
     }
 
     /**
@@ -102,4 +147,19 @@ public class AlertConfigurationServiceImpl implements IAlertConfigurationService
     {
         return alertConfigurationMapper.deleteAlertConfigurationById(alertId);
     }
+
+    @Override
+    public List<Map<String, Object>> searchProductParamByCustomerCode(String salesLevel, String orgCode) {
+        String groupByStr =null;
+        if(salesLevel !=null && ("diy_level").equals(salesLevel)){
+            groupByStr = "company_code";
+        }else if(salesLevel !=null && ("division_level").equals(salesLevel)){
+            groupByStr = "company_code";
+        }else if(salesLevel !=null && ("company_level").equals(salesLevel)){
+            groupByStr = "office_code";
+        }else if(salesLevel !=null && ("office_level").equals(salesLevel)){
+            groupByStr = "suboffice_code";
+        }
+        return alertConfigurationMapper.searchProductParamByCustomerCode(salesLevel, orgCode,groupByStr);
+    }
 }

+ 123 - 7
suishenbang-system/src/main/resources/mapper/system/AlertConfigurationMapper.xml

@@ -17,10 +17,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="alertNum"    column="alert_num"    />
         <result property="userType"    column="user_type"    />
         <result property="alertStatus"    column="alert_status"    />
+        <result property="salesLevel"    column="sales_level"    />
+        <result property="orgCode"    column="org_code"    />
     </resultMap>
 
     <sql id="selectAlertConfigurationVo">
-        select alert_id, create_by, create_time, update_by, update_time, is_delete, alert_content, alert_start_time, alert_end_time, alert_num, user_type, alert_status from alert_configuration
+        select alert_id, create_by, create_time, update_by, update_time, is_delete, alert_content, alert_start_time, alert_end_time, alert_num, user_type, alert_status,sales_level,org_code from alert_configuration
     </sql>
 
     <select id="selectAlertConfigurationList" parameterType="AlertConfiguration" resultMap="AlertConfigurationResult">
@@ -36,11 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
-    <select id="selectAlertConfigurationListFilter" resultType="java.lang.Integer">
-        SELECT
-            count(0)
-        FROM
-            alert_configuration
+    <select id="selectAlertConfigurationListFilter" parameterType="Long" resultMap="AlertConfigurationResult">
+        <include refid="selectAlertConfigurationVo"/>
         WHERE alert_status = 1
         <if test="userType !=null and userType !=''">
             and user_type = #{userType}
@@ -118,5 +117,122 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{alertId}
         </foreach>
     </delete>
-    
+
+    <sql id="orgListWhere">
+        and cal_month = date_format( CURDATE(), '%Y%m' )
+        <if test="parType != null and parType == 'company_level'">
+            and company_code = #{parValue}
+        </if>
+        <if test="parType != null and parType == 'saledept_level'  ">
+            and saledept_code = #{parValue}
+        </if>
+        <if test="parType != null and parType == 'office_level'">
+            and office_code = #{parValue}
+        </if>
+        <if test="parType != null and parType == 'suboffice_level'">
+            and suboffice_code = #{parValue}
+        </if>
+    </sql>
+    <select id="selectOrgCodeByInterface" resultType="java.lang.String">
+        <if test="parType != null and parType == 'company_level' or parType == 'diy_level' ">
+        SELECT
+        company_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        company_code UNION
+        </if>
+        <if test="parType != null and parType == 'saledept_level' or parType == 'office_level' or parType == 'diy_level' ">
+        SELECT
+        saledept_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        saledept_code UNION
+        </if>
+        <if test="parType != null and parType == 'suboffice_level' or  parType == 'diy_level'  ">
+        SELECT
+        suboffice_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        suboffice_code
+        </if>
+    </select>
+    <select id="selectOrgCode" resultType="java.lang.String">
+
+        SELECT
+        company_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        company_code UNION
+        SELECT
+        saledept_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        saledept_code UNION
+        SELECT
+        suboffice_code AS orgCode
+        FROM
+        order_sales_sum_tuc_group
+        WHERE
+        BUSINESS_UNIT = '零售'
+        <include refid="orgListWhere"/>
+        GROUP BY
+        suboffice_code
+    </select>
+
+    <select id="searchProductParamByCustomerCode" resultType="java.util.Map">
+        SELECT
+        g.company_code,
+        g.company_name,
+        g.office_code,
+        g.office_name,
+        g.suboffice_code,
+        g.suboffice_name
+        FROM
+        order_sales_sum_tuc_group g
+        left join tuc_company_sort sort on g.company_code=sort.company_code
+        WHERE
+        1 = 1 AND g.BUSINESS_UNIT = '零售'
+        <if test="salesLevel != null and salesLevel == 'company_level'  ">
+            and g.office_code  is not null
+            and g.office_code  !=''
+            and g.company_code = #{orgCode}
+
+        </if>
+        <if test="salesLevel != null and salesLevel == 'office_level'">
+            and g.suboffice_code  is not null
+            and g.suboffice_code  !=''
+            and g.office_code = #{orgCode}
+        </if>
+        <if test="salesLevel != null and salesLevel == 'suboffice_level' ">
+            and g.suboffice_code  is not null
+            and g.suboffice_code  !=''
+            and g.suboffice_code = #{orgCode}
+        </if>
+        <if test="groupByStr != null and groupByStr != ''">
+            GROUP BY g.${groupByStr}
+        </if>
+        <if test="salesLevel != null and  salesLevel == 'diy_level' ">
+            ORDER BY sort.company_sort+0 asc
+        </if>
+    </select>
 </mapper>

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

@@ -55,13 +55,13 @@ public class WxAlertLogController  extends ApiBaseController {
         Long userId = Long.valueOf(obj.getString("userId"));
         SysUserExt sysUserExt = sysUserExtService.selectSysUserExtById(userId);
         String salesLevel = sysUserExt.getSalesLevel();
-        if(("customer_level").equals(salesLevel)){
+        if(("customer_level").equals(salesLevel) || ("reseller_level").equals(salesLevel)){
             userType = "1";
         }else{
             userType = "0";
         }
         //是否有启动
-        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(userType);
+        AlertConfiguration alertConfiguration1 = alertConfigurationService.selectAlertConfigurationByAlertStatus(userType,sysUserExt.getSalesLevel(),sysUserExt.getOrgCode());
 
         if (alertConfiguration1!=null){
             //有启动