Commit 74fa9450 by 徐高华

Merge remote-tracking branch 'origin/master_xgh_停用功能' into developer

Conflicts:
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/WxEnterpriseService.java
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/WxEnterpriseServiceImpl.java
parents 840ab001 7e2f1426
package com.gic.haoban.manage.api.service; package com.gic.haoban.manage.api.service;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.*;
...@@ -214,5 +213,15 @@ public interface WxEnterpriseApiService { ...@@ -214,5 +213,15 @@ public interface WxEnterpriseApiService {
* @date 2022-06-27 13:44:16 * @date 2022-06-27 13:44:16
*/ */
SecretSettingDTO getSecretSettingById(String secretId); SecretSettingDTO getSecretSettingById(String secretId);
/**
*
* @Title: stopHaoban
* @Description: 停用好办
* @author xugh
* @param enterpriseId
* @throws
*/
void stopHaoban(String enterpriseId) ;
} }
package com.gic.haoban.manage.service.dao.mapper; package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
public interface WxEnterpriseRelatedMapper { public interface WxEnterpriseRelatedMapper {
int deleteByPrimaryKey(String wxEnterpriseRelatedId); int deleteByPrimaryKey(String wxEnterpriseRelatedId);
int deleteByEnterpriseId(String enterpriseId) ;
int insertSelective(TabHaobanWxEnterpriseRelated record); int insertSelective(TabHaobanWxEnterpriseRelated record);
...@@ -19,7 +22,7 @@ public interface WxEnterpriseRelatedMapper { ...@@ -19,7 +22,7 @@ public interface WxEnterpriseRelatedMapper {
List<TabHaobanWxEnterpriseRelated> listByWxenterpriseIdList(@Param("wxEnterpriseIdList") List<String> wxEnterpriseIdList); List<TabHaobanWxEnterpriseRelated> listByWxenterpriseIdList(@Param("wxEnterpriseIdList") List<String> wxEnterpriseIdList);
TabHaobanWxEnterpriseRelated findOneByEnterpriseId(String enterpriseId); List<TabHaobanWxEnterpriseRelated> listByEnterpriseId(String enterpriseId);
List<TabHaobanWxEnterpriseRelated> queryAllHasGicEnterpriseId(); List<TabHaobanWxEnterpriseRelated> queryAllHasGicEnterpriseId();
......
...@@ -65,4 +65,7 @@ public interface WxEnterpriseService { ...@@ -65,4 +65,7 @@ public interface WxEnterpriseService {
* @date 2022-06-30 18:49:31 * @date 2022-06-30 18:49:31
*/ */
int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId); int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId);
void stopHaoban(String enterpriseId);
} }
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service @Service
public class WxEnterpriseServiceImpl implements WxEnterpriseService { public class WxEnterpriseServiceImpl implements WxEnterpriseService {
private static org.apache.logging.log4j.Logger logger= LogManager.getLogger(WxEnterpriseService.class);
@Autowired @Autowired
private WxEnterpriseMapper mapper; private WxEnterpriseMapper mapper;
@Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper ;
@Override @Override
public String add(WxEnterpriseDTO wxDTO) { public String add(WxEnterpriseDTO wxDTO) {
...@@ -95,8 +108,43 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -95,8 +108,43 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
return mapper.listAll(); return mapper.listAll();
} }
@Override @Override
public int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId) { public int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId) {
return mapper.updateUseridFlagById(useridFlag, corpid, wxEnterpriseId); return mapper.updateUseridFlagById(useridFlag, corpid, wxEnterpriseId);
} }
@Override
public void stopHaoban(String enterpriseId) {
List<TabHaobanWxEnterpriseRelated> list = this.wxEnterpriseRelatedMapper.listByEnterpriseId(enterpriseId) ;
logger.info("停用好办={},list={}",enterpriseId,JSON.toJSONString(list));
List<String> wxEnterpriseIdList = new ArrayList<>();
for(TabHaobanWxEnterpriseRelated item : list) {
String wxEnterpriseId = item.getWxEnterpriseId() ;
wxEnterpriseIdList.add(wxEnterpriseId) ;
}
this.wxEnterpriseRelatedMapper.deleteByEnterpriseId(enterpriseId) ;
Map<String,Object> enMap = new HashMap<>();
enMap.put("enterpriseId", enterpriseId) ;
alert("删除商户企微关联告警", enMap);
for(String wxEnterpriseId : wxEnterpriseIdList) {
List<TabHaobanWxEnterpriseRelated> relationList = this.wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId) ;
if(CollectionUtils.isEmpty(relationList)) {
// 停用企微
TabHaobanWxEnterprise tab = new TabHaobanWxEnterprise() ;
tab.setWxEnterpriseId(wxEnterpriseId);
tab.setStatusFlag(0);
tab.setUpdateTime(new Date());
this.mapper.updateByPrimaryKeySelective(tab) ;
Map<String,Object> map = new HashMap<>();
map.put("wxEnterpriseId", wxEnterpriseId) ;
alert("删除企微告警", map);
}
}
}
private void alert(String title, Map<String, Object> map) {
String msg = title + JSON.toJSONString(map);
String dingUrl = "https://oapi.dingtalk.com/robot/send?access_token=c38fdc53d26e9a019640755bdada1ce07ebd44a2555d1c8acc299de7a7b5b857";
DingUtils.send(msg, dingUrl, true);
}
} }
...@@ -376,4 +376,9 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -376,4 +376,9 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
public SecretSettingDTO getSecretSettingById(String secretId) { public SecretSettingDTO getSecretSettingById(String secretId) {
return secretSettingService.getSecretSettingById(secretId); return secretSettingService.getSecretSettingById(secretId);
} }
@Override
public void stopHaoban(String enterpriseId) {
this.wxEnterpriseService.stopHaoban(enterpriseId) ;
}
} }
package com.gic.haoban.manage.service.util;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.commons.util.DingtalkMessageUtil;
public class DingUtils {
private static boolean isDev = false;
static {
Config config = ConfigService.getConfig("COMMON.gic-properties");
String env = config.getProperty("environment.value", "");
isDev = !"prod".equals(env);
}
public static void send(String msg, String dingUrl, boolean skipDev) {
try {
if (skipDev && isDev) {
return;
}
if (isDev) {
msg = "【dev】" + msg;
}
DingtalkMessageUtil.sendAlertMessage(msg, dingUrl);
} catch (Exception e) {
}
}
}
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
from tab_haoban_wx_enterprise_related from tab_haoban_wx_enterprise_related
where wx_enterprise_related_id = #{wxEnterpriseRelatedId,jdbcType=VARCHAR} where wx_enterprise_related_id = #{wxEnterpriseRelatedId,jdbcType=VARCHAR}
</delete> </delete>
<update id="deleteByEnterpriseId">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where enterprise_id=#{enterpriseId} and status_flag=1
</update>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated"> <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated">
insert into tab_haoban_wx_enterprise_related insert into tab_haoban_wx_enterprise_related
...@@ -185,7 +190,7 @@ ...@@ -185,7 +190,7 @@
and status_flag = 1 and status_flag = 1
</select> </select>
<select id="findOneByEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="listByEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_wx_enterprise_related from tab_haoban_wx_enterprise_related
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment