Commit 38cb7761 by qwmqiuwenmin

fix

parent 3e1137e0
......@@ -158,5 +158,7 @@ public interface DepartmentApiService {
* @return
*/
ServiceResponse<List<DepartmentDTO>> listStoreListByStaffId(String wxUserId);
void initwxDepartmentMQ(String res);
}
......@@ -47,7 +47,7 @@ public interface StaffApiService {
StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code);
void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId);
void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId,String taskId);
public List<String> listUnBindClerk(String storeId);
......@@ -60,4 +60,5 @@ public interface StaffApiService {
public List<StaffDTO> listByPhoneNumber(String phoneNumber);
public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
}
package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
public interface TabHaobanSyncErrorLogMapper {
int deleteByPrimaryKey(Integer id);
int insert(TabHaobanSyncErrorLog record);
int insertSelective(TabHaobanSyncErrorLog record);
TabHaobanSyncErrorLog selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TabHaobanSyncErrorLog record);
int updateByPrimaryKey(TabHaobanSyncErrorLog record);
}
\ No newline at end of file
package com.gic.haoban.manage.service.entity;
import java.io.Serializable;
import java.util.Date;
public class TabHaobanSyncErrorLog implements Serializable {
private Integer id;
private Integer logType;
private String taskId;
private String dataId;
private Integer dataType;
private String reason;
private String wxEnterpriseId;
private String gicEnterpriseId;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getLogType() {
return logType;
}
public void setLogType(Integer logType) {
this.logType = logType;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId == null ? null : taskId.trim();
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId == null ? null : dataId.trim();
}
public Integer getDataType() {
return dataType;
}
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason == null ? null : reason.trim();
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim();
}
public String getGicEnterpriseId() {
return gicEnterpriseId;
}
public void setGicEnterpriseId(String gicEnterpriseId) {
this.gicEnterpriseId = gicEnterpriseId == null ? null : gicEnterpriseId.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
public interface SyncErrorLogService {
void add(TabHaobanSyncErrorLog tab);
}
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanSyncErrorLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
@Service
public class SyncErrorLogServiceImpl implements SyncErrorLogService {
@Autowired
private TabHaobanSyncErrorLogMapper mapper;
@Override
public void add(TabHaobanSyncErrorLog tab) {
tab.setCreateTime(new Date());
tab.setUpdateTime(new Date());
mapper.insert(tab);
}
}
......@@ -40,9 +40,11 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.github.pagehelper.PageHelper;
......@@ -72,6 +74,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private SyncErrorLogService syncErrorLogService;
@Override
......@@ -498,17 +502,18 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//
// DepartmentDTO parent = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId));
// this.addSon(subList, wxEnterpriseId, parent,corpid,suiteid);
String taskId = StringUtil.randomUUID();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null);
logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret);
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret,taskId);
}
}
private void addAllDepartment(List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list, Integer parentId,
String wxEnterpriseId, String corpid, String contactSecret){
String wxEnterpriseId, String corpid, String contactSecret,String taskId){
int level = 1;
String chainId = "0";
String chainName = "0";
......@@ -523,25 +528,36 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
}
}
for(com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list){
if (parentId.equals(departmentDTO.getParentid())) {
TabHaobanDepartment exist = this.departmentService.getByWxId(departmentDTO.getId() + "", wxEnterpriseId);
logger.info("分组是否存在:{}", JSON.toJSONString(exist));
if(exist == null){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(level);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(pId);
dto.setChainId(chainId);
dto.setChainName(chainName);
dto.setSort(departmentDTO.getOrder());
dto.setIsStore(0);
this.departmentService.add(dto);
try {
if (parentId.equals(departmentDTO.getParentid())) {
TabHaobanDepartment exist = this.departmentService.getByWxId(departmentDTO.getId() + "", wxEnterpriseId);
logger.info("分组是否存在:{}", JSON.toJSONString(exist));
if(exist == null){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(level);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(pId);
dto.setChainId(chainId);
dto.setChainName(chainName);
dto.setSort(departmentDTO.getOrder());
dto.setIsStore(0);
this.departmentService.add(dto);
}
}
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, contactSecret);
this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId());
} catch (Exception e) {
TabHaobanSyncErrorLog tab = new TabHaobanSyncErrorLog();
tab.setDataId(departmentDTO.getId()+"");
tab.setDataType(0);
tab.setLogType(0);
tab.setReason(e.getMessage());
tab.setTaskId(taskId);
tab.setWxEnterpriseId(wxEnterpriseId);
syncErrorLogService.add(tab);
}
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, contactSecret,taskId);
this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId(),taskId);
}
}
......@@ -620,4 +636,17 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
rer.setResult(departmentList);
return rer;
}
@Override
public void initwxDepartmentMQ(String res) {
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseService.selectById(res);
if(enterpriseDTO != null){
if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null && enterpriseDTO.getContactFlag() == 0){
this.initwxDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), enterpriseDTO.getWxEnterpriseId());
enterpriseDTO.setContactFlag(1);
this.wxEnterpriseService.update(enterpriseDTO);
}
}
}
}
......@@ -47,9 +47,11 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.SyncErrorLogService;
import com.gic.haoban.manage.service.service.UserLoginLogService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.UserDTO;
......@@ -87,6 +89,8 @@ public class StaffApiServiceImpl implements StaffApiService {
private UserLoginLogService userLoginLogService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private SyncErrorLogService syncErrorLogService;
@Override
public StaffDTO selectById(String staffId) {
......@@ -771,11 +775,22 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId) {
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId,String taskId) {
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0);
if(CollectionUtils.isNotEmpty(list)){
for(UserDTO dto : list){
this.wxGetAdd(dto.getUserid(), wxEnterpriseId);
try {
this.wxGetAdd(dto.getUserid(), wxEnterpriseId);
} catch (Exception e) {
TabHaobanSyncErrorLog tab = new TabHaobanSyncErrorLog();
tab.setDataId(dto.getUserid());
tab.setDataType(0);
tab.setLogType(0);
tab.setReason(e.getMessage());
tab.setTaskId(taskId);
tab.setWxEnterpriseId(wxEnterpriseId);
syncErrorLogService.add(tab);
}
}
}
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.TabHaobanSyncErrorLogMapper" >
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="log_type" property="logType" jdbcType="INTEGER" />
<result column="task_id" property="taskId" jdbcType="VARCHAR" />
<result column="data_id" property="dataId" jdbcType="VARCHAR" />
<result column="data_type" property="dataType" jdbcType="INTEGER" />
<result column="reason" property="reason" jdbcType="VARCHAR" />
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="gic_enterprise_id" property="gicEnterpriseId" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, log_type, task_id, data_id, data_type, reason, wx_enterprise_id, gic_enterprise_id,
create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from tab_haoban_sync_error_log
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tab_haoban_sync_error_log
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog" >
insert into tab_haoban_sync_error_log (id, log_type, task_id,
data_id, data_type, reason,
wx_enterprise_id, gic_enterprise_id, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{logType,jdbcType=INTEGER}, #{taskId,jdbcType=VARCHAR},
#{dataId,jdbcType=VARCHAR}, #{dataType,jdbcType=INTEGER}, #{reason,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{gicEnterpriseId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog" >
insert into tab_haoban_sync_error_log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="logType != null" >
log_type,
</if>
<if test="taskId != null" >
task_id,
</if>
<if test="dataId != null" >
data_id,
</if>
<if test="dataType != null" >
data_type,
</if>
<if test="reason != null" >
reason,
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="gicEnterpriseId != null" >
gic_enterprise_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="logType != null" >
#{logType,jdbcType=INTEGER},
</if>
<if test="taskId != null" >
#{taskId,jdbcType=VARCHAR},
</if>
<if test="dataId != null" >
#{dataId,jdbcType=VARCHAR},
</if>
<if test="dataType != null" >
#{dataType,jdbcType=INTEGER},
</if>
<if test="reason != null" >
#{reason,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="gicEnterpriseId != null" >
#{gicEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog" >
update tab_haoban_sync_error_log
<set >
<if test="logType != null" >
log_type = #{logType,jdbcType=INTEGER},
</if>
<if test="taskId != null" >
task_id = #{taskId,jdbcType=VARCHAR},
</if>
<if test="dataId != null" >
data_id = #{dataId,jdbcType=VARCHAR},
</if>
<if test="dataType != null" >
data_type = #{dataType,jdbcType=INTEGER},
</if>
<if test="reason != null" >
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="gicEnterpriseId != null" >
gic_enterprise_id = #{gicEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog" >
update tab_haoban_sync_error_log
set log_type = #{logType,jdbcType=INTEGER},
task_id = #{taskId,jdbcType=VARCHAR},
data_id = #{dataId,jdbcType=VARCHAR},
data_type = #{dataType,jdbcType=INTEGER},
reason = #{reason,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
gic_enterprise_id = #{gicEnterpriseId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.common.utils.GlobalVar;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.ApplicationSettingApiService;
......@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.service.ApplicationApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.utils.RouterConstant;
import javax.servlet.http.HttpServletResponse;
......@@ -153,6 +155,28 @@ public class ApplicationController extends WebBaseController{
e.printStackTrace();
}
}
@RequestMapping("init-wx-department")
public HaobanResponse initWxDepartment(){
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if(enterpriseDTO != null){
if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null){
log.info("【初始化部门调用】{},{},{}",RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME,RouterConstant.INIT_WX_DEPARTMENT_METHODNAME,wxEnterpriseId);
try {
GICMQClientUtil.getClientInstance().sendCommonMessage(RouterConstant.ROUTERTYPE, wxEnterpriseId,
RouterConstant.INIT_WX_DEPARTMENT_SERVICENAME, RouterConstant.INIT_WX_DEPARTMENT_METHODNAME);
} catch (Exception e) {
log.info(e.getMessage(),e);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, true);
}
@RequestMapping("cancal-suite")
@IgnoreLogin
......
package com.gic.haoban.manage.web.utils;
/**
* @author
*/
public class RouterConstant {
/**
* 分配_服务名
*/
public final static String INIT_WX_DEPARTMENT_SERVICENAME = "com.gic.haoban.manage.api.service.DepartmentApiService";
/**
*
*/
public final static String INIT_WX_DEPARTMENT_METHODNAME = "initwxDepartmentMQ";
/**
* 路由类型(通用)
*/
public final static String ROUTERTYPE = "commonRouter";
public final static String INIT_WX_DEPARTMENT_APP_CODE = "INIT_WX_DEPARTMENT";
/**
* 默认的数据状态
*/
public final static int DEFAULT_STATUS = 1;
}
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