Commit 19768d26 by qwmqiuwenmin

Merge branch 'developer' into 'master'

Developer

See merge request !46
parents 1a16783d e66fe145
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
public class ClerkMainStoreRelatedDTO implements Serializable{
private String clerkMainStoreRelatedId;
private String staffId;
private String wxEnterpriseId;
private String storeId;
private Integer mainStoreFlag;
private Integer statusFlag;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
public String getClerkMainStoreRelatedId() {
return clerkMainStoreRelatedId;
}
public void setClerkMainStoreRelatedId(String clerkMainStoreRelatedId) {
this.clerkMainStoreRelatedId = clerkMainStoreRelatedId == null ? null : clerkMainStoreRelatedId.trim();
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId == null ? null : storeId.trim();
}
public Integer getMainStoreFlag() {
return mainStoreFlag;
}
public void setMainStoreFlag(Integer mainStoreFlag) {
this.mainStoreFlag = mainStoreFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
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;
}
}
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
/**
* Created 2020/4/10.
*
* @author hua
*/
public class DealParamMqDTO implements Serializable {
private String taskId;
private String data;
private Integer type;
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}
......@@ -51,6 +51,16 @@ public class DepartmentDTO implements Serializable {
private Boolean hasSonNode;
private Integer tempFlag;
public Integer getTempFlag() {
return tempFlag;
}
public void setTempFlag(Integer tempFlag) {
this.tempFlag = tempFlag;
}
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
......
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
*
* @author fdh
*/
public class PreDealLogInfoDTO implements Serializable {
/**
*
*/
private Integer id;
/**
* 企业微信id
*/
private String wxEnterpriseId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 数据id
*/
private String dataId;
private String dataCode;
/**
* 数据名称
*/
private String dataName;
/**
* 父dataid
*/
private String pDataId;
/**
* 数据分组
*/
private String chainName;
/**
* 任务id
*/
private String taskId;
/**
* 数据类型 0 分组 1门店 2成员
*/
private Integer dataType;
/**
* 状态 0 未同步 1同步完成 2 同步失败
*/
private Integer statusFlag;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public String getDataCode() {
return dataCode;
}
public void setDataCode(String dataCode) {
this.dataCode = dataCode;
}
public String getDataName() {
return dataName;
}
public void setDataName(String dataName) {
this.dataName = dataName;
}
public String getChainName() {
return chainName;
}
public void setChainName(String chainName) {
this.chainName = chainName;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.id
*
* @return the value of tab_haoban_pre_deal_log.id
*/
public Integer getId() {
return id;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.id
*
* @param id the value for tab_haoban_pre_deal_log.id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.wx_enterprise_id
*
* @return the value of tab_haoban_pre_deal_log.wx_enterprise_id
*/
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.wx_enterprise_id
*
* @param wxEnterpriseId the value for tab_haoban_pre_deal_log.wx_enterprise_id
*/
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.data_id
*
* @return the value of tab_haoban_pre_deal_log.data_id
*/
public String getDataId() {
return dataId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.data_id
*
* @param dataId the value for tab_haoban_pre_deal_log.data_id
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.p_data_id
*
* @return the value of tab_haoban_pre_deal_log.p_data_id
*/
public String getpDataId() {
return pDataId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.p_data_id
*
* @param pDataId the value for tab_haoban_pre_deal_log.p_data_id
*/
public void setpDataId(String pDataId) {
this.pDataId = pDataId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.task_id
*
* @return the value of tab_haoban_pre_deal_log.task_id
*/
public String getTaskId() {
return taskId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.task_id
*
* @param taskId the value for tab_haoban_pre_deal_log.task_id
*/
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.data_type
*
* @return the value of tab_haoban_pre_deal_log.data_type
*/
public Integer getDataType() {
return dataType;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.data_type
*
* @param dataType the value for tab_haoban_pre_deal_log.data_type
*/
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.status_flag
*
* @return the value of tab_haoban_pre_deal_log.status_flag
*/
public Integer getStatusFlag() {
return statusFlag;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.status_flag
*
* @param statusFlag the value for tab_haoban_pre_deal_log.status_flag
*/
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.create_time
*
* @return the value of tab_haoban_pre_deal_log.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.create_time
*
* @param createTime the value for tab_haoban_pre_deal_log.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.update_time
*
* @return the value of tab_haoban_pre_deal_log.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.update_time
*
* @param updateTime the value for tab_haoban_pre_deal_log.update_time
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
......@@ -55,6 +55,8 @@ public class StaffDTO implements Serializable{
private Integer superManagerFlag;
private Boolean weixinPush;
private long memberCount;
private static final long serialVersionUID = 1L;
......@@ -261,5 +263,13 @@ public class StaffDTO implements Serializable{
this.weixinPush = weixinPush;
}
public long getMemberCount() {
return memberCount;
}
public void setMemberCount(long memberCount) {
this.memberCount = memberCount;
}
}
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.List;
/**
* Created 2020/4/13.
*
* @author hua
*/
public class SyncCheckDTO implements Serializable {
private Integer syncStatus;
private Integer groupErrCount;
private Integer storeErrCount;
private Integer staffErrCount;
private Integer totalDeal;
private Integer hasDeal;
public Integer getSyncStatus() {
return syncStatus;
}
public void setSyncStatus(Integer syncStatus) {
this.syncStatus = syncStatus;
}
public Integer getGroupErrCount() {
return groupErrCount;
}
public void setGroupErrCount(Integer groupErrCount) {
this.groupErrCount = groupErrCount;
}
public Integer getStoreErrCount() {
return storeErrCount;
}
public void setStoreErrCount(Integer storeErrCount) {
this.storeErrCount = storeErrCount;
}
public Integer getStaffErrCount() {
return staffErrCount;
}
public void setStaffErrCount(Integer staffErrCount) {
this.staffErrCount = staffErrCount;
}
public Integer getTotalDeal() {
return totalDeal;
}
public void setTotalDeal(Integer totalDeal) {
this.totalDeal = totalDeal;
}
public Integer getHasDeal() {
return hasDeal;
}
public void setHasDeal(Integer hasDeal) {
this.hasDeal = hasDeal;
}
}
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
/**
* Created 2020/4/9.
*
* @author hua
*/
public class SyncSingleDealDTO implements Serializable {
private String departmentId;
private String departmentName;
private String parentDepartmentId;
private String relatedId;
private Integer storeFlag;
private String enterpriseId;
//0 管理员 1 分组
private Integer type;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getDepartmentId() {
return departmentId;
}
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getParentDepartmentId() {
return parentDepartmentId;
}
public void setParentDepartmentId(String parentDepartmentId) {
this.parentDepartmentId = parentDepartmentId;
}
public String getRelatedId() {
return relatedId;
}
public void setRelatedId(String relatedId) {
this.relatedId = relatedId;
}
public Integer getStoreFlag() {
return storeFlag;
}
public void setStoreFlag(Integer storeFlag) {
this.storeFlag = storeFlag;
}
}
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
*
* @author fdh
*/
public class SyncTaskDTO implements Serializable {
/**
*
*/
private String taskId;
private String wxEnterpriseId;
/**
*
*/
private String taskName;
/**
* 任务创建人
*/
private String addUser;
private String userName;
/**
* 任务描述
*/
private String taskDesc;
/**
* 任务状态
*/
private Integer statusFlag;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_id
*
* @return the value of tab_haoban_sync_task.task_id
*/
public String getTaskId() {
return taskId;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_id
*
* @param taskId the value for tab_haoban_sync_task.task_id
*/
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_name
*
* @return the value of tab_haoban_sync_task.task_name
*/
public String getTaskName() {
return taskName;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_name
*
* @param taskName the value for tab_haoban_sync_task.task_name
*/
public void setTaskName(String taskName) {
this.taskName = taskName;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.add_user
*
* @return the value of tab_haoban_sync_task.add_user
*/
public String getAddUser() {
return addUser;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.add_user
*
* @param addUser the value for tab_haoban_sync_task.add_user
*/
public void setAddUser(String addUser) {
this.addUser = addUser;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_desc
*
* @return the value of tab_haoban_sync_task.task_desc
*/
public String getTaskDesc() {
return taskDesc;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_desc
*
* @param taskDesc the value for tab_haoban_sync_task.task_desc
*/
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.status_flag
*
* @return the value of tab_haoban_sync_task.status_flag
*/
public Integer getStatusFlag() {
return statusFlag;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.status_flag
*
* @param statusFlag the value for tab_haoban_sync_task.status_flag
*/
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.create_time
*
* @return the value of tab_haoban_sync_task.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.create_time
*
* @param createTime the value for tab_haoban_sync_task.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.update_time
*
* @return the value of tab_haoban_sync_task.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.update_time
*
* @param updateTime the value for tab_haoban_sync_task.update_time
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.haoban.manage.api.enums;
/**
* Created by tgs on 2020/2/20.
*/
public enum AppPageType {
//工作台
INDEX(1, ""),
//门店详情
STORE_DETAIL(2, "store_detail"),
//任务详情(会话、话务、不良评价)
TASK_DETAIL(3, "hbapp_task_detail"),
//日报详情
DAILY_DETAIL(4, "hbapp_task_daily_report_detail"),
//指标管理详情
PERFORMANCE_DETAIL(5, "hbapp_task_kpi_detail"),
//顾客详情
CUSTOMER_DETAIL(6, "hbapp_customer_detail"),
//会员列表
MEMBER_LIST(7, "hbapp_customer_list"),
//分配会员
DISTRIBUTE_MEMBER(8, "hbapp_customer_distribute"),
//任务列表
TASK_LIST(9, "hbapp_task_list"),
//商品详情
GOOD_DETAIL(10, "hbapp_commodity_detail");
AppPageType(int type, String desc){
this.code = type;
this.desc = desc;
}
private int code;
private String desc;
public static String getDescByCode(int type) {
for (AppPageType c : AppPageType.values()) {
if (c.getCode() == type) {
return c.desc;
}
}
return null;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.gic.haoban.manage.api.enums;
/**
* Created by hua on 2020/4/10.
*/
public enum PreDealStatusEnum {
all(-1),
pre(0),
dealing(1),
computed(2),
exception(3);
private int val;
PreDealStatusEnum(int val) {
this.val = val;
}
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
package com.gic.haoban.manage.api.enums;
/**
* Created by hua on 2020/4/10.
*/
public enum PreDealTypeEnum {
all(-1),
group(0),
store(1),
clerk(2);
private int val;
PreDealTypeEnum(int val) {
this.val = val;
}
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
......@@ -8,27 +8,41 @@ package com.gic.haoban.manage.api.enums;
public enum StoreFieldEnum {
//门店名称
STORE_NAME("1"),
STORE_NAME("1","门店名称"),
//门店面积
STORE_AREA("2"),
STORE_AREA("2","门店面积"),
//联系电话
CONACTS_PHONE("3"),
CONACTS_PHONE("3","联系电话"),
//营业时间
BUSINESS_TIME_STRING("4"),
BUSINESS_TIME_STRING("4","营业时间"),
//门店地址
STORE_ADDRESS("5"),
STORE_ADDRESS("5","门店地址"),
//门店图片
STORE_IMAG("6");
STORE_IMAG("6","门店图片");
/**
* 类型
*/
private String value;
private String name;
StoreFieldEnum(String value) {
StoreFieldEnum(String value,String name) {
this.value = value;
this.name = name;
}
public String getValue() {
return value;
}
public String getName() {
return name;
}
public static String getValueName(String changeField) {
for (StoreFieldEnum c : StoreFieldEnum.values()) {
if (c.getValue() == changeField) {
return c.name;
}
}
return null;
}
}
package com.gic.haoban.manage.api.enums;
/**
* Created by hua on 2020/4/10.
*/
public enum SyncTaskStatusEnum {
init(0),
group_sync(1),
store_sync(2),
clerk_sync(3),
compute(4),
exception_compute(5),
exception_close(6);
private int val;
SyncTaskStatusEnum(int val) {
this.val = val;
}
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
package com.gic.haoban.manage.api.service;
import com.gic.haoban.manage.api.dto.ClerkMainStoreRelatedDTO;
public interface ClerkMainStoreRelatedApiService {
void setMainStore(String staffId, String storeId, String wxEnterpriseId);
ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId);
}
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.manage.api.dto.PreDealLogInfoDTO;
import com.gic.haoban.manage.api.dto.SyncCheckDTO;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import com.gic.haoban.manage.api.dto.SyncTaskDTO;
import java.util.List;
/**
* Created 2020/4/9.
*
* @author hua
*/
public interface DealSyncOperationApiService {
/**
* 部门同步处理
*
* @param params
*/
public void departmentDealMq(String params);
/**
* 处理前端数据
*
* @param addList
* @param editList
*/
public void dealDepartment(String taskId, String wxEnterpriseId, List<SyncSingleDealDTO> addList, List<SyncSingleDealDTO> editList);
/**
* 重新执行任务
*
* @param taskId
*/
public void reDealDepartment(String taskId, int dataType);
/**
* 创建任务
*
* @param taskName
* @param userId
* @param desc
*/
public String createTask(String wxEnterpriseId, String taskName, String userId, String desc);
/**
* 创建任务
*
* @param taskName
* @param userId
* @param desc
*/
public String createQywxTask(String wxEnterpriseId, String taskName, String userId, String desc);
/**
* 关闭任务
*
* @param wxEnterpriseId
* @return
*/
public boolean closeTask(String wxEnterpriseId);
/**
* 解锁
*
* @param taskId
*/
public void unlockTask(String taskId);
/**
* 校验是否锁
*
* @param wxEnterpriseId
* @return
*/
public String getTaskLock(String wxEnterpriseId);
/**
* 校验同步状态
*
* @param wxEnterpriseId
* @return
*/
public SyncCheckDTO getTaskCheck(String wxEnterpriseId);
/**
* 同步日志
*
* @param wxEnterpriseId
* @return
*/
public Page<SyncTaskDTO> listSyncTask(String wxEnterpriseId, BasePageInfo pageInfo);
/**
* 同步日志
*
* @param wxEnterpriseId
* @return
*/
public Page<PreDealLogInfoDTO> listSyncTaskDetail(String wxEnterpriseId, String taskId, BasePageInfo pageInfo);
/**
* 处理同步
*/
public void dealQywxDepartment(String taskId, String wxEnterpriseId);
}
......@@ -47,7 +47,7 @@ public interface DepartmentApiService {
* @param department
* @return
*/
ServiceResponse add(DepartmentDTO department);
ServiceResponse<DepartmentDTO> add(DepartmentDTO department);
/**
* 修改部门
* @param department
......@@ -158,5 +158,11 @@ public interface DepartmentApiService {
* @return
*/
ServiceResponse<List<DepartmentDTO>> listStoreListByStaffId(String wxUserId);
void initwxDepartmentMQ(String res);
boolean isInitLocked(String wxEnterpriseId);
void syncWxDepartmentByParentMQ(String res);
}
......@@ -19,4 +19,6 @@ public interface MemberUnionidRelatedApiService {
List<MemberStoreDTO> listByExTernalUseridAndWxUserId(String externalUserid, String wxUserId);
String add(String wxEnterpriseId, String selfExternalUserId, String userId1);
}
......@@ -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,12 @@ public interface StaffApiService {
public List<StaffDTO> listByPhoneNumber(String phoneNumber);
public List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/**
* 保存gic成员
*
* @param clerkDTO
* @return
*/
public ServiceResponse saveSyncStaffByGic(GicClerkDTO clerkDTO);
}
......@@ -27,4 +27,11 @@ public interface StaffDepartmentRelatedApiService {
StaffDepartmentRelatedDTO getOneByStaffIdAndDepartmentId(String staffId, String departmentId);
String getWxUserIdByClerkId(String clerkId);
String getPageUrl(int type,String data);
//发送消息,单人发送
boolean sendSingleMessage(String wxUserId,String title,String content,String pageUrl);
}
......@@ -115,6 +115,13 @@
<version>3.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-thirdparty-api</artifactId>
<version>${gic-thirdparty-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -18,8 +18,18 @@ public class Config {
private String host;
@Value("${wxSuiteid}")
private String wxSuiteid;
public String getCorpid() {
@Value("${appid}")
private String appid;
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getCorpid() {
return corpid;
}
......
......@@ -62,4 +62,6 @@ public interface DepartmentMapper {
TabHaobanDepartment getByRelatedIdNotInRecycle(@Param("relatedId")String relatedId);
List<TabHaobanDepartment> listByIds(@Param("departmentIds")List<String> departmentIds);
TabHaobanDepartment getTempFlagDepartment(@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.api.dto.SyncCheckDTO;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface PreDealLogMapper {
/**
*/
int deleteByPrimaryKey(Integer id);
/**
*/
int insert(TabHaobanPreDealLog record);
/**
*/
int insertSelective(TabHaobanPreDealLog record);
/**
*/
int insertSelectiveBatch(List<TabHaobanPreDealLog> record);
/**
*/
TabHaobanPreDealLog selectByPrimaryKey(Integer id);
/**
*/
int updateByPrimaryKeySelective(TabHaobanPreDealLog record);
/**
*/
int updateByPrimaryKey(TabHaobanPreDealLog record);
/**
* 获取单条数据
*
* @param taskId
* @param dataId
* @return
*/
List<TabHaobanPreDealLog> getByDataId(@Param("taskId") String taskId, @Param("dataId") String dataId, @Param("status") int status);
/**
* 获取单条数据
*
* @param taskId
* @param pDataId
* @return
*/
List<TabHaobanPreDealLog> listByPDataId(@Param("taskId") String taskId, @Param("dataId") String pDataId
, @Param("status") int status, @Param("dataType") int dataType);
/**
* 获取单条数据
*
* @param taskId
* @param pDataId
* @return
*/
List<TabHaobanPreDealLog> listReByPDataId(@Param("taskId") String taskId, @Param("dataId") String pDataId
, @Param("dataType") int dataType);
/**
* 更新状态
*
* @param taskId
* @param dataId
* @param status
* @return
*/
public int updateStatusByDataId(@Param("taskId") String taskId, @Param("dataId") String dataId, @Param("status") int status, @Param("reason") String reason);
/**
* 校验任务
*
* @param taskId
* @param dataType
* @return
*/
public int checkTask(@Param("taskId") String taskId, @Param("dataType") int dataType, @Param("status") int status);
public List<TabHaobanPreDealLog> listByTaskId(@Param("taskId") String taskId, @Param("dataType") int dataType, @Param("status") int status);
/**
* 统计任务数量
*listRebuildByTaskId
* @param taskId
* @return
*/
public int countByTaskId(@Param("taskId") String taskId, @Param("dataType") int dataType, @Param("status") int status);
/**
* 统计任务数量
* countExcepAndPreByTaskId
*
* @param taskId
* @return
*/
public int countExcepAndPreByTaskId(@Param("taskId") String taskId, @Param("dataType") int dataType);
/**
* 重试的时候 第一级部门
*
* @param taskId
* @return
*/
public List<TabHaobanPreDealLog> listRebuildDepartByTaskId(@Param("taskId") String taskId);
/**
* 统计重试任务数量
*
* @param taskId
* @return
*/
public List<TabHaobanPreDealLog> listRebuildByTaskId(@Param("taskId") String taskId, @Param("dataType") int dataType);
/**
* 更新状态
*
* @param taskId
* @param dataId
* @param status
* @return
*/
public int updateExceptionToPre(@Param("taskId") String taskId);
/**
* 统计重试任务数量
*
* @param taskId
* @return
*/
public List<TabHaobanPreDealLog> listExceptionByTask(@Param("taskId") String taskId);
/**
* 统计任务数量
* countExcepAndPreByTaskId
*
* @param taskId
* @return
*/
public int countByDataId(@Param("taskId") String taskId, @Param("dataId") String dataId);
}
\ No newline at end of file
......@@ -45,5 +45,7 @@ public interface StaffDepartmentRelatedMapper {
int countByDepartmentIds(@Param("departmentIds")List<String> departmentIds);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(@Param("wxUserId")String wxUserId);
List<TabHaobanStaffDepartmentRelated> listByClerkCode(@Param("clerkCode")String clerkCode);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface SyncTaskMapper {
/**
*/
int deleteByPrimaryKey(String taskId);
/**
*/
int insert(TabHaobanSyncTask record);
/**
*/
int insertSelective(TabHaobanSyncTask record);
/**
*/
TabHaobanSyncTask selectByPrimaryKey(String taskId);
/**
*/
int updateByPrimaryKeySelective(TabHaobanSyncTask record);
/**
*/
int updateByPrimaryKey(TabHaobanSyncTask record);
/**
*/
List<TabHaobanSyncTask> listPageByWxEid(String wxEnterpriseId);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
public interface TabHaobanClerkMainStoreRelatedMapper {
int deleteByPrimaryKey(String clerkMainStoreRelatedId);
int insert(TabHaobanClerkMainStoreRelated record);
int insertSelective(TabHaobanClerkMainStoreRelated record);
TabHaobanClerkMainStoreRelated selectByPrimaryKey(String clerkMainStoreRelatedId);
int updateByPrimaryKeySelective(TabHaobanClerkMainStoreRelated record);
int updateByPrimaryKey(TabHaobanClerkMainStoreRelated record);
TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(@Param("staffId")String staffId, @Param("wxEnterpriseId")String wxEnterpriseId);
}
\ No newline at end of file
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 TabHaobanClerkMainStoreRelated implements Serializable {
private String clerkMainStoreRelatedId;
private String staffId;
private String wxEnterpriseId;
private String storeId;
private Integer mainStoreFlag;
private Integer statusFlag;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1L;
public String getClerkMainStoreRelatedId() {
return clerkMainStoreRelatedId;
}
public void setClerkMainStoreRelatedId(String clerkMainStoreRelatedId) {
this.clerkMainStoreRelatedId = clerkMainStoreRelatedId == null ? null : clerkMainStoreRelatedId.trim();
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId == null ? null : storeId.trim();
}
public Integer getMainStoreFlag() {
return mainStoreFlag;
}
public void setMainStoreFlag(Integer mainStoreFlag) {
this.mainStoreFlag = mainStoreFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
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
......@@ -40,6 +40,16 @@ public class TabHaobanDepartment implements Serializable {
private Integer gicDelFlag;
private Integer tempFlag;
public Integer getTempFlag() {
return tempFlag;
}
public void setTempFlag(Integer tempFlag) {
this.tempFlag = tempFlag;
}
private static final long serialVersionUID = 1L;
public String getDepartmentId() {
......
package com.gic.haoban.manage.service.entity;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
*
* @author fdh
*/
public class TabHaobanPreDealLog implements Serializable {
/**
*
*/
private Integer id;
/**
* 企业微信id
*/
private String wxEnterpriseId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 数据id
*/
private String dataId;
/**
* 父dataid
*/
private String pDataId;
/**
* 任务id
*/
private String taskId;
/**
* 数据类型 0 分组 1门店 2成员
*/
private Integer dataType;
/**
* 状态 0 未同步 1同步完成 2 同步失败
*/
private Integer statusFlag;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
private String dataContent;
public String getDataContent() {
return dataContent;
}
public void setDataContent(String dataContent) {
this.dataContent = dataContent;
}
/**
*/
private static final long serialVersionUID = 1L;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.id
*
* @return the value of tab_haoban_pre_deal_log.id
*/
public Integer getId() {
return id;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.id
*
* @param id the value for tab_haoban_pre_deal_log.id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.wx_enterprise_id
*
* @return the value of tab_haoban_pre_deal_log.wx_enterprise_id
*/
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.wx_enterprise_id
*
* @param wxEnterpriseId the value for tab_haoban_pre_deal_log.wx_enterprise_id
*/
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.data_id
*
* @return the value of tab_haoban_pre_deal_log.data_id
*/
public String getDataId() {
return dataId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.data_id
*
* @param dataId the value for tab_haoban_pre_deal_log.data_id
*/
public void setDataId(String dataId) {
this.dataId = dataId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.p_data_id
*
* @return the value of tab_haoban_pre_deal_log.p_data_id
*/
public String getpDataId() {
return pDataId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.p_data_id
*
* @param pDataId the value for tab_haoban_pre_deal_log.p_data_id
*/
public void setpDataId(String pDataId) {
this.pDataId = pDataId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.task_id
*
* @return the value of tab_haoban_pre_deal_log.task_id
*/
public String getTaskId() {
return taskId;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.task_id
*
* @param taskId the value for tab_haoban_pre_deal_log.task_id
*/
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.data_type
*
* @return the value of tab_haoban_pre_deal_log.data_type
*/
public Integer getDataType() {
return dataType;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.data_type
*
* @param dataType the value for tab_haoban_pre_deal_log.data_type
*/
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.status_flag
*
* @return the value of tab_haoban_pre_deal_log.status_flag
*/
public Integer getStatusFlag() {
return statusFlag;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.status_flag
*
* @param statusFlag the value for tab_haoban_pre_deal_log.status_flag
*/
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.create_time
*
* @return the value of tab_haoban_pre_deal_log.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.create_time
*
* @param createTime the value for tab_haoban_pre_deal_log.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_pre_deal_log.update_time
*
* @return the value of tab_haoban_pre_deal_log.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_pre_deal_log.update_time
*
* @param updateTime the value for tab_haoban_pre_deal_log.update_time
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ 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.entity;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
*
* @author fdh
*/
public class TabHaobanSyncTask implements Serializable {
/**
*
*/
private String taskId;
private String wxEnterpriseId;
/**
*
*/
private String taskName;
/**
* 任务创建人
*/
private String addUser;
/**
* 任务描述
*/
private String taskDesc;
/**
* 任务状态
*/
private Integer statusFlag;
private Integer taskType;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public Integer getTaskType() {
return taskType;
}
public void setTaskType(Integer taskType) {
this.taskType = taskType;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_id
*
* @return the value of tab_haoban_sync_task.task_id
*/
public String getTaskId() {
return taskId;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_id
*
* @param taskId the value for tab_haoban_sync_task.task_id
*/
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_name
*
* @return the value of tab_haoban_sync_task.task_name
*/
public String getTaskName() {
return taskName;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_name
*
* @param taskName the value for tab_haoban_sync_task.task_name
*/
public void setTaskName(String taskName) {
this.taskName = taskName;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.add_user
*
* @return the value of tab_haoban_sync_task.add_user
*/
public String getAddUser() {
return addUser;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.add_user
*
* @param addUser the value for tab_haoban_sync_task.add_user
*/
public void setAddUser(String addUser) {
this.addUser = addUser;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.task_desc
*
* @return the value of tab_haoban_sync_task.task_desc
*/
public String getTaskDesc() {
return taskDesc;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.task_desc
*
* @param taskDesc the value for tab_haoban_sync_task.task_desc
*/
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.status_flag
*
* @return the value of tab_haoban_sync_task.status_flag
*/
public Integer getStatusFlag() {
return statusFlag;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.status_flag
*
* @param statusFlag the value for tab_haoban_sync_task.status_flag
*/
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.create_time
*
* @return the value of tab_haoban_sync_task.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.create_time
*
* @param createTime the value for tab_haoban_sync_task.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_sync_task.update_time
*
* @return the value of tab_haoban_sync_task.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_sync_task.update_time
*
* @param updateTime the value for tab_haoban_sync_task.update_time
*/
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.TabHaobanClerkMainStoreRelated;
public interface ClerkMainStoreRelatedService {
void setMainStore(String staffId, String storeId, String wxEnterpriseId);
TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId);
void update(TabHaobanClerkMainStoreRelated r);
}
......@@ -46,4 +46,12 @@ public interface DepartmentService {
List<DepartmentDTO> listByIds(List<String> departmentIds);
/**
* 获取暂存区
*
* @param wxEnterpriseId
* @return
*/
DepartmentDTO getTempFlagDepartment(String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.PreDealLogInfoDTO;
import com.gic.haoban.manage.api.dto.SyncCheckDTO;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import java.util.List;
/**
* Created 2020/4/9.
*
* @author hua
*/
public interface PreDealService {
/**
* 批量新增
*
* @param list
* @return
*/
public boolean insert(List<TabHaobanPreDealLog> list);
/**
* 获取单条数据
*
* @param dataId
* @return
*/
public TabHaobanPreDealLog getByDataId(String taskId, String dataId, int status);
/**
* 根据父数据id 获取子节点
*
* @param pDataId
* @param status
* @return
*/
public List<TabHaobanPreDealLog> listByPDataId(String taskId, String pDataId, int status);
/**
* 根据父数据id 获取子节点
*
* @param pDataId
* @param status
* @return
*/
public List<TabHaobanPreDealLog> listReByPDataId(String taskId, String pDataId);
/**
* 更新单条数据状态
*
* @param dataId
* @param status
* @return
*/
public boolean updateStatusByDataId(String taskId, String dataId, int status, String reason);
/**
* 获取任务是否有在同步中
*
* @param dataType
* @return
*/
public boolean checkTask(String taskId, int dataType);
/**
* 获取任务列表
*
* @param type
* @param status
* @return
*/
public List<TabHaobanPreDealLog> listByTaskId(String taskId, int dataType, int status);
/**
* 获取错误任务数量
*
* @param status
* @return
*/
public int countByTaskId(String taskId, int dataType, int status);
/**
* 获取任务数量
*
* @return
*/
public int countExcepAndPreByTaskId(String taskId, int dataType);
/**
* 获取重试时 需要处理的数据
*
* @param taskId
* @return
*/
public List<TabHaobanPreDealLog> queryDepartRebuildDealLog(String taskId);
/**
* 获取重试任务列表
*
* @param status
* @return
*/
public List<TabHaobanPreDealLog> listRebuildByTaskId(String taskId, int dataType);
/**
* 把任务重置到预处理
*
* @param taskId
* @return
*/
public boolean updateExceptionToPre(String taskId);
/**
* 获取异常任务列表
*
* @return
*/
public Page<PreDealLogInfoDTO> listExceptionByTaskId(String taskId, BasePageInfo pageInfo);
/**
* 获取单条数据
*
* @param dataId
* @return
*/
public boolean existDataId(String taskId, String dataId);
}
......@@ -27,5 +27,7 @@ public interface StaffDepartmentRelatedService {
List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(String departmentId, String keyword);
List<TabHaobanStaffDepartmentRelated> listByWxUserId(String wxUserId);
StaffDepartmentRelatedDTO getById(String staffDepartmentStaffRelatedId);
}
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;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.SyncTaskDTO;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
/**
* Created 2020/4/10.
*
* @author hua
*/
public interface SyncTaskService {
/**
* 创建任务
*
* @param tabHaobanSyncTask
*/
public void createTask(TabHaobanSyncTask tabHaobanSyncTask);
/**
* 更新任务状态
*
* @param taskId
* @param status
*/
public boolean updateTaskStatus(String taskId, int status);
/**
* 获取任务
*
* @param taskId
* @return
*/
public TabHaobanSyncTask getSyncTask(String taskId);
/**
* 获取任务列表
*
* @param wxEnterpriseId
* @return
*/
public Page<SyncTaskDTO> listTaskPage(String wxEnterpriseId, BasePageInfo pageInfo);
}
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.TabHaobanClerkMainStoreRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
@Service
public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedService {
@Autowired
private TabHaobanClerkMainStoreRelatedMapper mapper;
@Override
public void setMainStore(String staffId, String storeId, String wxEnterpriseId) {
String uuId = com.gic.haoban.common.utils.StringUtil.randomUUID();
Date now = new Date();
TabHaobanClerkMainStoreRelated t = new TabHaobanClerkMainStoreRelated();
t.setStaffId(staffId);
t.setWxEnterpriseId(wxEnterpriseId);
t.setStoreId(storeId);
t.setCreateTime(now);
t.setUpdateTime(now);
t.setStatusFlag(1);
t.setClerkMainStoreRelatedId(uuId);
mapper.insert(t);
}
@Override
public TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId,wxEnterpriseId);
}
@Override
public void update(TabHaobanClerkMainStoreRelated r) {
r.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(r);
}
}
......@@ -3,7 +3,9 @@ package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import com.gic.haoban.base.api.common.Constant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -38,11 +40,23 @@ public class DepartmentServiceImpl implements DepartmentService {
public String add(DepartmentDTO department) {
Date now = new Date();
TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department);
Integer sort = tab.getSort();
if(sort == null) {
int maxSort = mapper.selectMaxSort(department.getParentDepartmentId());
tab.setSort(maxSort + 1);
}
tab.setDepartmentId(StringUtil.randomUUID());
Integer sort = tab.getSort();
if(sort == null) {
int maxSort = mapper.selectMaxSort(department.getParentDepartmentId());
tab.setSort(maxSort + 1);
}
if (StringUtils.isBlank(department.getChainId())) {
TabHaobanDepartment pDepartment = this.selectById(department.getParentDepartmentId());
if (null == pDepartment) {
throw new RuntimeException("父部门不存在");
}
tab.setChainId(pDepartment.getChainId() + Constant.ID_SEPARATOR + pDepartment.getDepartmentId());
tab.setChainName(pDepartment.getChainName() + Constant.NAME_SEPARATOR + pDepartment.getDepartmentName());
tab.setLevel(pDepartment.getLevel() + 1);
}
Integer isStore = department.getIsStore();
if(isStore == null){
department.setIsStore(0);
......@@ -51,8 +65,11 @@ public class DepartmentServiceImpl implements DepartmentService {
tab.setUpdateTime(now);
tab.setStatusFlag(1);
tab.setRecycleFlag(0);
tab.setDepartmentId(StringUtil.randomUUID());
mapper.insert(tab);
if (department.getTempFlag() == null) {
department.setTempFlag(0);
}
mapper.insert(tab);
return tab.getDepartmentId();
}
......@@ -169,4 +186,8 @@ public class DepartmentServiceImpl implements DepartmentService {
return EntityUtil.changeEntityListByJSON(DepartmentDTO.class, mapper.listByIds(departmentIds));
}
@Override
public DepartmentDTO getTempFlagDepartment(String wxEnterpriseId) {
return EntityUtil.changeEntityByJSON(DepartmentDTO.class, mapper.getTempFlagDepartment(wxEnterpriseId));
}
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.PreDealLogInfoDTO;
import com.gic.haoban.manage.api.dto.SyncCheckDTO;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.PreDealLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.service.PreDealService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created 2020/4/9.
*
* @author hua
*/
@Service
public class PreDealServiceImpl implements PreDealService {
@Autowired
private PreDealLogMapper preDealLogMapper;
@Override
public boolean insert(List<TabHaobanPreDealLog> list) {
if (CollectionUtils.isEmpty(list)) {
return true;
}
preDealLogMapper.insertSelectiveBatch(list);
return true;
}
@Override
public TabHaobanPreDealLog getByDataId(String taskId, String dataId, int status) {
List<TabHaobanPreDealLog> list = preDealLogMapper.getByDataId(taskId, dataId, status);
if (CollectionUtils.isEmpty(list)) {
return null;
} else {
return list.get(0);
}
}
@Override
public List<TabHaobanPreDealLog> listByPDataId(String taskId, String pDataId, int status) {
return preDealLogMapper.listByPDataId(taskId, pDataId, status, PreDealTypeEnum.group.getVal());
}
@Override
public List<TabHaobanPreDealLog> listReByPDataId(String taskId, String pDataId) {
return preDealLogMapper.listReByPDataId(taskId, pDataId, PreDealTypeEnum.group.getVal());
}
@Override
public boolean updateStatusByDataId(String taskId, String dataId, int status, String reason) {
int i = preDealLogMapper.updateStatusByDataId(taskId, dataId, status, reason);
return i >= 0;
}
@Override
public boolean checkTask(String taskId, int dataType) {
int i = preDealLogMapper.checkTask(taskId, dataType, PreDealStatusEnum.pre.getVal());
return i == 0;
}
@Override
public List<TabHaobanPreDealLog> listByTaskId(String taskId, int dataType, int status) {
return preDealLogMapper.listByTaskId(taskId, dataType, status);
}
@Override
public int countByTaskId(String taskId, int dataType, int status) {
return preDealLogMapper.countByTaskId(taskId, dataType, status);
}
@Override
public int countExcepAndPreByTaskId(String taskId, int dataType) {
return preDealLogMapper.countExcepAndPreByTaskId(taskId, dataType);
}
@Override
public List<TabHaobanPreDealLog> queryDepartRebuildDealLog(String taskId) {
return preDealLogMapper.listRebuildDepartByTaskId(taskId);
}
@Override
public List<TabHaobanPreDealLog> listRebuildByTaskId(String taskId, int dataType) {
return preDealLogMapper.listRebuildByTaskId(taskId, dataType);
}
@Override
public boolean updateExceptionToPre(String taskId) {
int i = preDealLogMapper.updateExceptionToPre(taskId);
return i >= 0;
}
@Override
public Page<PreDealLogInfoDTO> listExceptionByTaskId(String taskId, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabHaobanPreDealLog> page = preDealLogMapper.listExceptionByTask(taskId);
Page<PreDealLogInfoDTO> retPage = PageUtil.changePageHelperToCurrentPage(new PageInfo<>(page), PreDealLogInfoDTO.class);
return retPage;
}
@Override
public boolean existDataId(String taskId, String dataId) {
int i = preDealLogMapper.countByDataId(taskId, dataId);
return i > 0;
}
}
......@@ -84,6 +84,10 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
public List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(String departmentId, String keyword) {
return mapper.listByDepartmentIdByKeyword(departmentId,keyword);
}
@Override
public StaffDepartmentRelatedDTO getById(String staffDepartmentStaffRelatedId) {
return EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, mapper.getById(staffDepartmentStaffRelatedId));
}
}
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);
}
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.SyncTaskDTO;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
import com.gic.haoban.manage.service.dao.mapper.SyncTaskMapper;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import com.gic.haoban.manage.service.service.SyncTaskService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* Created 2020/4/10.
*
* @author hua
*/
@Service
public class SyncTaskServiceImpl implements SyncTaskService {
@Autowired
private SyncTaskMapper syncTaskMapper;
@Override
public void createTask(TabHaobanSyncTask tabHaobanSyncTask) {
tabHaobanSyncTask.setTaskId(ToolUtil.randomUUID());
tabHaobanSyncTask.setStatusFlag(SyncTaskStatusEnum.init.getVal());
syncTaskMapper.insert(tabHaobanSyncTask);
}
@Override
public boolean updateTaskStatus(String taskId, int status) {
TabHaobanSyncTask tabHaobanSyncTask = new TabHaobanSyncTask();
tabHaobanSyncTask.setTaskId(taskId);
tabHaobanSyncTask.setStatusFlag(status);
tabHaobanSyncTask.setUpdateTime(new Date());
int i = syncTaskMapper.updateByPrimaryKeySelective(tabHaobanSyncTask);
return i >= 0;
}
@Override
public TabHaobanSyncTask getSyncTask(String taskId) {
return syncTaskMapper.selectByPrimaryKey(taskId);
}
@Override
public Page<SyncTaskDTO> listTaskPage(String wxEnterpriseId, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabHaobanSyncTask> list = syncTaskMapper.listPageByWxEid(wxEnterpriseId);
Page<SyncTaskDTO> page = PageUtil.changePageHelperToCurrentPage(new PageInfo<>(list), SyncTaskDTO.class);
return page;
}
}
......@@ -30,14 +30,20 @@ import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.AuditDTO;
import com.gic.haoban.manage.api.dto.StoreAddressDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.enums.StoreFieldEnum;
import com.gic.haoban.manage.api.service.AuditApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanAuditMapper;
import com.gic.haoban.manage.service.entity.TabHaobanAudit;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.message.api.dto.MessageDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.PageHelper;
/**
......@@ -55,6 +61,12 @@ public class AuditApiServiceImpl implements AuditApiService{
private StaffMapper staffMapper;
@Autowired
private StoreService storeService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private Config config;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Override
public Page<AuditDTO> page(Integer auditType, String search,String wxEnterpriseId,
......@@ -112,6 +124,15 @@ public class AuditApiServiceImpl implements AuditApiService{
String newValue = tab.getNewValue();
String changeField = tab.getChangeField();
this.editStoreInfo(storeId, changeField, oldValue, newValue);
//发送消息
String title = "门店信息修改通知";
String content = StoreFieldEnum.getValueName(changeField);
content = "["+content+"]"+"修改审核通过";
TabHaobanAudit tab2 = auditMapper.selectByPrimaryKey(auditId);
String staffId = tab2.getCommitStaffId();
// this.sendMessageByStaffId(staffId, storeId, title, content);
}
@Override
public void refuse(String auditId, String auditReason,String auditName) {
......@@ -121,7 +142,18 @@ public class AuditApiServiceImpl implements AuditApiService{
tab.setUpdateTime(new Date());
tab.setAuditReason(auditReason);
tab.setAuditName(auditName);
auditMapper.updateByPrimaryKeySelective(tab);
auditMapper.updateByPrimaryKeySelective(tab);
//发送消息
TabHaobanAudit tab2 = auditMapper.selectByPrimaryKey(auditId);
String changeField = tab2.getChangeField();
String title = "门店信息修改通知";
String content = StoreFieldEnum.getValueName(changeField);
content = "["+content+"]"+"被拒绝。拒绝理由:"+auditReason;
String staffId = tab2.getCommitStaffId();
String storeId = tab2.getCommitStoreId();
// this.sendMessageByStaffId(staffId, storeId, title, content);
}
@Override
public int save(Integer auditType,String wxEnterpriseId, String enterpriseId,
......@@ -242,4 +274,29 @@ public class AuditApiServiceImpl implements AuditApiService{
}
return EntityUtil.changeEntityByJSON(AuditDTO.class, tab);
}
public void sendMessageByStaffId(String staffId,String storeId,String title,String content){
TabHaobanStaff staff = staffMapper.selectByPrimaryKey(staffId);
if(staff == null){
logger.info("staff不存在");
return;
}
String wxUserId = staff.getWxUserId();
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.STORE_DETAIL.getCode(), data);
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setDescription(content);
boolean b = qywxSuiteApiService.sendMessage(config.getCorpid(), config.getSuiteId(), messageDTO);
}
}
package com.gic.haoban.manage.service.service.out.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.ClerkMainStoreRelatedDTO;
import com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
@Service
public class ClerkMainStoreRelatedApiServiceImpl implements ClerkMainStoreRelatedApiService {
@Autowired
ClerkMainStoreRelatedService clerkMainStoreRelatedService;
@Override
public void setMainStore(String staffId, String storeId, String wxEnterpriseId) {
TabHaobanClerkMainStoreRelated r = clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId,wxEnterpriseId);
if(r != null){
r.setStoreId(storeId);
clerkMainStoreRelatedService.update(r);
}else{
clerkMainStoreRelatedService.setMainStore(staffId, storeId, wxEnterpriseId);
}
}
@Override
public ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId) {
return EntityUtil.changeEntityByJSON(ClerkMainStoreRelatedDTO.class, clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId,wxEnterpriseId));
}
}
......@@ -29,10 +29,12 @@ import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.MemberStoreDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
......@@ -96,6 +98,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
@Autowired
private ESDataDynamicOperationApiService eSDataDynamicOperationApiService;
@Autowired
private Config config;
@Override
public List<MemberStoreDTO> listByExTernalUseridAndWxUserId(String externalUserid, String wxUserId) {
List<MemberUnionidRelated> list = memberUnionidRelatedMapper.listByExTernalUseridAndWxUserId(externalUserid, wxUserId);
......@@ -119,8 +124,11 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
log.info("staff关联门店不存在1");
return null;
}
List<String> storeIds = stores.stream().map(s->s.getRelatedId()).collect(Collectors.toList());
List<String> storeIds = stores.stream().filter(s->(s.getRelatedId()!=null || "".equals(s.getRelatedId()))).map(s->s.getRelatedId()).collect(Collectors.toList());
if(CollectionUtil.isEmpty(storeIds)){
log.info("staff关联门店不存在2");
return null;
}
//2、获取member的storeId
for(MemberUnionidRelated tab : list){
String memberId = tab.getMemberId();
......@@ -157,15 +165,23 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
String[] memberStoreIds =storeId.split(" ");
List<String> memberStoreIdList = Arrays.asList(memberStoreIds);
//取交集
memberStoreIdList.retainAll(storeIds);
if(CollectionUtil.isEmpty(memberStoreIdList)){
log.info("会员门店不存在");
continue;
}
log.info("memberStoreIdList===============>{}",JSONObject.toJSONString(memberStoreIdList));
log.info("storeIds===============>{}",JSONObject.toJSONString(storeIds));
//取交集(解决不支持的报错现象)
List list3= new ArrayList(memberStoreIdList);
List list4= new ArrayList(storeIds);
list3.retainAll(list4);
if(CollectionUtil.isEmpty(list3)){
continue;
}else{
for(String resultStoreId : memberStoreIdList){
for(Object resultStoreId : list3){
MemberStoreDTO dto = new MemberStoreDTO();
dto.setMemberId(memberId);
dto.setStoreId(resultStoreId);
dto.setStoreId(resultStoreId.toString());
result.add(dto);
}
......@@ -372,6 +388,144 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
// }
return "";
}
@Override
public String add(String wxEnterpriseId,String selfExternalUserId,String userId1) {
WxEnterpriseDTO wxEnterprise = wxEnterpriseService.selectById(wxEnterpriseId);
if(wxEnterprise == null){
return "";
}
List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterprise.getWxEnterpriseId());
String unionIdJson = qywxUserApiService.getCorpSelfExternalUseridInfo(wxEnterprise.getCorpid(), wxEnterprise.getWxSecretKey(), selfExternalUserId);
String externalUserId = selfExternalUserId;
// String uJ = qywxUserApiService.getExternalUseridInfo(wxEnterprise.getCorpid(), config.getSuiteId(), externalUserId);
// if(StringUtils.isNotBlank(uJ)){
// JSONObject jo = JSON.parseObject(unionIdJson);
// String external_contact = jo.getString("external_contact");
// String uj_follow_user = jo.getString("follow_user");
// if(StringUtils.isNotBlank(uj_follow_user)){
// JSONArray j = JSON.parseArray(uj_follow_user);
// String uj_userId = "";
// for (Object object : j) {
// String followJson = JSON.toJSONString(object);
// JSONObject follow = JSON.parseObject(followJson);
// uj_userId = follow.getString("userid");
// if(uj_userId.equals(userId1)){
//
// }
// }
// }
// }
MemberUnionidRelatedDTO dto = new MemberUnionidRelatedDTO();
log.info("【新增外部联系人回调】unionIdJson={}",JSON.toJSONString(unionIdJson));
String unionId = "";
String name = "";
String follow_user = "";
String createTime = "";
String userId = "";
String avatar = "";
String relaName = "";
if(StringUtils.isNotBlank(unionIdJson)){
JSONObject jo = JSON.parseObject(unionIdJson);
String external_contact = jo.getString("external_contact");
if(StringUtils.isNotBlank(external_contact)){
JSONObject jt = JSON.parseObject(external_contact);
unionId = jt.getString("unionid");
name = EmojiFilterUtil.filterEmojiLast(jt.getString("name"), true);
relaName = EmojiFilterUtil.filterEmojiLast(jt.getString("name"), true);
avatar = jt.getString("avatar");
}
follow_user = jo.getString("follow_user");
if(StringUtils.isNotBlank(follow_user)){
JSONArray j = JSON.parseArray(follow_user);
for (Object object : j) {
String followJson = JSON.toJSONString(object);
JSONObject follow = JSON.parseObject(followJson);
userId = follow.getString("userid");
if(userId.equals(userId1)){
createTime = follow.getString("createtime");
}
}
}
}
for (TabHaobanWxEnterpriseRelated tabHaobanWxEnterpriseRelated : list) {
String key = "external" + tabHaobanWxEnterpriseRelated.getEnterpriseId() + "_"+ userId1 + "_" + name + "_" + createTime;
RedisUtil.lock(key,2l);
dto.setWxEnterpriseId(tabHaobanWxEnterpriseRelated.getWxEnterpriseId());
dto.setEnterpriseId(tabHaobanWxEnterpriseRelated.getEnterpriseId());
MemberDTO member = null;
TabHaobanStaff staff = staffService.selectByUserIdAndEnterpriseId(userId1, tabHaobanWxEnterpriseRelated.getWxEnterpriseId());
if(staff == null){
continue;
}
List<StaffDepartmentRelatedDTO> relatedList = staffDepartmentRelatedApiService.listByStaffId(staff.getStaffId());
log.info("【部门list】staffId={}",staff.getStaffId());
List<StaffDepartmentRelatedDTO> rList = new ArrayList<StaffDepartmentRelatedDTO>();
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : relatedList) {
DepartmentDTO depart = departmentApiService.selectById(staffDepartmentRelatedDTO.getDepartmentId());
log.info("【部门list】depart={},deparmentId={}",JSON.toJSONString(depart),staffDepartmentRelatedDTO.getDepartmentId());
if(depart != null && tabHaobanWxEnterpriseRelated != null && depart.getEnterpriseId() != null && tabHaobanWxEnterpriseRelated.getEnterpriseId() != null){
log.info("【部门list】enterpriseId={},enterpriseId2={}",depart.getEnterpriseId(),tabHaobanWxEnterpriseRelated.getEnterpriseId());
if(depart.getEnterpriseId().equals(tabHaobanWxEnterpriseRelated.getEnterpriseId())){
rList.add(staffDepartmentRelatedDTO);
}
}
}
log.info("【部门list】rList={}",JSON.toJSONString(rList));
//DepartmentDTO departmentDTO =
String clerkCode = "";
if(!rList.isEmpty()){
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : rList) {
clerkCode = staffDepartmentRelatedDTO.getClerkCode();
if(StringUtils.isNotBlank(clerkCode)){
break;
}
}
}
ClerkDTO clerk = clerkService.getClerkByClerkCode(tabHaobanWxEnterpriseRelated.getEnterpriseId(), clerkCode);
log.info("【新增外部联系人】clerkCode={}",clerkCode);
if(clerk != null && StringUtils.isNotBlank(clerk.getQrcodeParam())){
log.info("【新增外部联系人会员】enterpriseId={},unionId={},name={},avatar={},QrcodeParam={}",tabHaobanWxEnterpriseRelated.getEnterpriseId(),unionId,name,avatar,clerk.getQrcodeParam());
member = memberOpenCardBusinessService.getMemberByQywxChannelParam(tabHaobanWxEnterpriseRelated.getEnterpriseId(),unionId,"",relaName,avatar,clerk.getQrcodeParam());
}
log.info("【新增外部联系人】member={},clerk={}",JSON.toJSONString(member),JSON.toJSONString(clerk));
if(member != null){
dto.setMemberId(member.getMemberId());
}
dto.setExternalUserid(externalUserId);
dto.setUnionid(unionId);
dto.setExternalName(name);
dto.setAddCreateTime(createTime);
if(StringUtils.isBlank(unionId)){
return "";
}
dto.setSuiteid(wxEnterprise.getWxSecretKey());
MemberUnionidRelatedDTO exsitDTO = memberUnionRelatedService.getByParams(userId, tabHaobanWxEnterpriseRelated.getEnterpriseId(),name,createTime);
String uuid = "";
if(exsitDTO == null){
dto.setUnionid(unionId);
dto.setMemberId(dto.getMemberId());
//更新对外联系人id
dto.setSelfExternalUserid(selfExternalUserId);
memberUnionRelatedService.update(exsitDTO);
uuid = memberUnionRelatedService.addMemberUnionidRelated(dto);
}else{
return "";
}
}
return "";
}
@Override
public void delMemberUnionidRelated(MemberUnionidRelatedDTO dto) {
memberUnionRelatedService.delMemberUnionidRelated(dto);
......
package com.gic.haoban.manage.service.service.out.impl;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.MessageDTO;
import com.gic.haoban.manage.api.dto.ApplicationDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.service.ApplicationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanApplication;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.service.ApplicationService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.springframework.stereotype.Service;
@Service
public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRelatedApiService {
private static Logger logger= LoggerFactory.getLogger(StaffDepartmentRelatedApiServiceImpl.class);
@Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
@Autowired
private ClerkService clerkService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private Config config;
@Override
public List<StaffDepartmentRelatedDTO> listByDepartmentId(
......@@ -86,6 +106,61 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
StaffDepartmentRelatedDTO dto = EntityUtil.changeEntity(StaffDepartmentRelatedDTO.class, tab);
return dto;
}
@Override
public String getWxUserIdByClerkId(String clerkId) {
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if(clerkDTO == null){
return null;
}
String clerkCode =clerkDTO.getClerkCode();
if(StringUtil.isEmpty(clerkCode) ){
return null;
}
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedMapper.listByClerkCode(clerkCode);
if(CollectionUtil.isEmpty(list)){
return null;
}
String wxUserId = list.get(0).getWxUserId();
return wxUserId;
}
@Override
public boolean sendSingleMessage(String clerkId, String title,
String content, String pageUrl) {
String wxUserId = getWxUserIdByClerkId(clerkId);
if(StringUtils.isEmpty(wxUserId)){
logger.info("wxUserId不存在============clerkId={}",clerkId);
return false;
}
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setDescription(content);
boolean b = qywxSuiteApiService.sendMessage(config.getCorpid(), config.getSuiteId(), messageDTO);
logger.info("发送===============》{}",b);
return b;
}
@Override
public String getPageUrl(int type, String data) {
String baseUrl = "/pages/route/index";
String addurl = AppPageType.getDescByCode(type);
String url = "";
if(type == AppPageType.INDEX.getCode()){
//工作台
url = baseUrl+"?pageType="+addurl;
}else{
url = baseUrl+"?pageType="+addurl;
}
url = url+"&data="+data;
String resultUrl = URLEncoder.encode(url);
return resultUrl;
}
}
package com.gic.haoban.manage.service.task;
import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
/**
* Created 2020/4/13.
*
* @author hua
*/
public interface BaseSyncOperation {
/**
* 处理单条数据
*
* @param dealParamMqDTO
*/
public abstract void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre);
/**
* 单条处理异常
*
* @param taskId
* @param dataId
* @param enterpriseId
* @param reason
*/
public abstract void dealException(String taskId, String dataId, String enterpriseId, String reason);
/**
* 单条处理成功
*
* @param taskId
* @param dataId
* @param wxEnterpriseId
*/
public abstract void dealSuccess(String taskId, String dataId, String enterpriseId, String wxEnterpriseId);
public void checkDepartmentTask(String taskId);
}
package com.gic.haoban.manage.service.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Created 2020/4/13.
*
* @author hua
*/
@Service
public class ClerkSyncOperation implements BaseSyncOperation {
private static final Logger logger = LoggerFactory.getLogger(ClerkSyncOperation.class);
@Autowired
private DepartmentService departmentService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private PreDealService preDealService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private SyncTaskService syncTaskService;
@Autowired
private StoreService storeService;
@Autowired
private ClerkService clerkService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("成员处理:{}", JSONObject.toJSONString(dealParamMqDTO));
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNodel(dealParamMqDTO.getData());
String reason = "";
boolean dealFlag = true;
if (clerkDTO == null) {
logger.info("成员不存在:t:{},d:{}", dealParamMqDTO.getTaskId(), dealParamMqDTO.getData());
dealException(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), "成员不存在");
return;
}
//处理clerk
try {
GicClerkDTO gicClerkDTO = new GicClerkDTO();
gicClerkDTO.setNationcode(clerkDTO.getNationcode());
gicClerkDTO.setClerkCode(clerkDTO.getClerkCode());
gicClerkDTO.setPostionName(clerkDTO.getPositionName());
gicClerkDTO.setHeadImgUrl(clerkDTO.getHeadImgUrl());
gicClerkDTO.setPhoneNumber(clerkDTO.getPhoneNumber());
gicClerkDTO.setStatus(clerkDTO.getStatus());
if (!StringUtils.isBlank(clerkDTO.getClerkGender())) {
gicClerkDTO.setClerkGender(Integer.valueOf(clerkDTO.getClerkGender()));
}
gicClerkDTO.setClerkName(clerkDTO.getClerkName());
gicClerkDTO.setStoreId(clerkDTO.getStoreId());
gicClerkDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
ServiceResponse response = staffApiService.saveSyncStaffByGic(gicClerkDTO);
if (response.getCode() != 1) {
reason = response.getMessage();
dealFlag = false;
}
} catch (Exception e) {
e.printStackTrace();
logger.info("同步失败:", JSONObject.toJSONString(dataPre));
reason = "成员处理异常";
dealFlag = false;
} finally {
if (!dealFlag) {
dealException(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), reason);
} else {
dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId());
}
}
}
@Override
public void dealException(String taskId, String dataId, String enterpriseId, String reason) {
logger.info("成员处理失败:t:{},d:{}", taskId, dataId);
boolean b = preDealService.updateStatusByDataId(taskId, dataId, PreDealStatusEnum.exception.getVal(), reason);
if (!b) {
logger.info("成员处理异常:t:{}, d:{}", taskId, dataId);
return;
}
checkDepartmentTask(taskId);
}
@Override
public void dealSuccess(String taskId, String dataId, String enterpriseId, String wxEnterpriseId) {
logger.info("成员处理成功:t:{},d:{}", taskId, dataId);
boolean b = preDealService.updateStatusByDataId(taskId, dataId, PreDealStatusEnum.computed.getVal(), "成功");
if (!b) {
logger.info("成功修改错误!{}", dataId);
return;
}
checkDepartmentTask(taskId);
}
@Override
public void checkDepartmentTask(String taskId) {
boolean b = preDealService.checkTask(taskId, PreDealTypeEnum.clerk.getVal());
if (!b) {
return;
}
logger.info("店员同步成功:{}", taskId);
String key = "haoban_sync_clerk_task_" + taskId;
RedisUtil.lock(key, 3L);
TabHaobanSyncTask syncTask = syncTaskService.getSyncTask(taskId);
//同步成功 进入门店处理
if (syncTask.getStatusFlag().equals(SyncTaskStatusEnum.clerk_sync.getVal())) {
int errCount = preDealService.countByTaskId(taskId, -1, PreDealStatusEnum.exception.getVal());
if (errCount > 0) {
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_compute.getVal());
} else {
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.compute.getVal());
dealSyncOperationApiService.unlockTask(syncTask.getWxEnterpriseId());
}
}
RedisUtil.unlock(key);
}
}
package com.gic.haoban.manage.service.task;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.GicClerkDTO;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created 2020/4/13.
*
* @author hua
*/
@Service
public class QywxClerkSyncOperation implements BaseSyncOperation {
private static final Logger logger = LoggerFactory.getLogger(QywxClerkSyncOperation.class);
@Autowired
private DepartmentService departmentService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private PreDealService preDealService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private SyncTaskService syncTaskService;
@Autowired
private StoreService storeService;
@Autowired
private ClerkService clerkService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("微信成员处理:{}", JSONObject.toJSONString(dealParamMqDTO));
boolean dealFlag = true;
//处理clerk
try {
staffApiService.wxGetAdd(dealParamMqDTO.getData(), dataPre.getWxEnterpriseId());
} catch (Exception e) {
e.printStackTrace();
logger.info("微信成员同步失败:", JSONObject.toJSONString(dataPre));
dealFlag = false;
} finally {
if (!dealFlag) {
dealException(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), "成员处理异常");
} else {
dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId());
}
}
}
@Override
public void dealException(String taskId, String dataId, String enterpriseId, String reason) {
logger.info("微信成员处理失败:t:{},d:{}", taskId, dataId);
boolean b = preDealService.updateStatusByDataId(taskId, dataId, PreDealStatusEnum.exception.getVal(), reason);
if (!b) {
logger.info("微信成员处理异常:t:{}, d:{}", taskId, dataId);
return;
}
checkDepartmentTask(taskId);
}
@Override
public void dealSuccess(String taskId, String dataId, String enterpriseId, String wxEnterpriseId) {
logger.info("微信成员处理成功:t:{},d:{}", taskId, dataId);
boolean b = preDealService.updateStatusByDataId(taskId, dataId, PreDealStatusEnum.computed.getVal(), "成功");
if (!b) {
logger.info("微信成功修改错误!{}", dataId);
return;
}
checkDepartmentTask(taskId);
}
@Override
public void checkDepartmentTask(String taskId) {
boolean b = preDealService.checkTask(taskId, PreDealTypeEnum.clerk.getVal());
if (!b) {
return;
}
logger.info("微信同步成功:{}", taskId);
String key = "haoban_sync_clerk_task_" + taskId;
RedisUtil.lock(key, 3L);
TabHaobanSyncTask syncTask = syncTaskService.getSyncTask(taskId);
//同步成功 进入门店处理
if (syncTask.getStatusFlag().equals(SyncTaskStatusEnum.clerk_sync.getVal())) {
int errCount = preDealService.countByTaskId(taskId, -1, PreDealStatusEnum.exception.getVal());
if (errCount > 0) {
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_compute.getVal());
dealSyncOperationApiService.unlockTask(syncTask.getWxEnterpriseId());
} else {
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.compute.getVal());
dealSyncOperationApiService.unlockTask(syncTask.getWxEnterpriseId());
}
}
RedisUtil.unlock(key);
}
}
package com.gic.haoban.manage.service.task;
/**
* @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 = "syncWxDepartmentByParentMQ";
/**
* 路由类型(通用)
*/
public final static String ROUTERTYPE = "commonRouter";
public final static String INIT_WX_DEPARTMENT_LIST_APP_CODE = "INIT_WX_DEPARTMENT_LIST";
/**
* 默认的数据状态
*/
public final static int DEFAULT_STATUS = 1;
}
......@@ -36,10 +36,15 @@
<dubbo:service interface="com.gic.haoban.manage.api.service.AuditSettingApiService" ref="auditSettingApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.DictApiService" ref="dictApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.AuditApiService" ref="auditApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService" ref="clerkMainStoreRelatedApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.DealSyncOperationApiService"
ref="dealSyncOperationApiServiceImpl" timeout="10000"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService" id="qywxDepartmentApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxUserApiService" id="qywxUserApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreGroupService" id="storeGroupService"/>
......@@ -51,6 +56,8 @@
<dubbo:reference interface="com.gic.member.api.service.MemberOpenCardBusinessService" id="memberOpenCardBusinessService"/>
<dubbo:reference id="eSDataDynamicOperationApiService" interface="com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService" timeout="10000"/>
<dubbo:reference id="qqCloudPicService" interface="com.gic.thirdparty.api.service.QQCloudPicService" timeout="10000" retries="0" check="false" />
</beans>
\ No newline at end of file
......@@ -20,10 +20,12 @@
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR" />
<result column="sort" property="sort" jdbcType="INTEGER" />
<result column="level" property="level" jdbcType="INTEGER" />
<result column="temp_flag" property="tempFlag" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List" >
department_id, department_name, parent_department_id, related_id, related_code,chain_id, is_store,
status_flag, recycle_flag, create_time, update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name,enterprise_id,gic_del_flag
department_id, department_name, parent_department_id, related_id, related_code,chain_id, is_store,
status_flag, recycle_flag, create_time,
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name,enterprise_id,gic_del_flag,temp_flag
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......@@ -39,12 +41,12 @@
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department (department_id, department_name, parent_department_id,
related_id,related_code, chain_id, is_store,
status_flag, recycle_flag, create_time,
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name,enterprise_id)
status_flag, recycle_flag, create_time,
update_time,wx_department_id,sort,level,wx_enterprise_id,chain_name,enterprise_id,temp_flag)
values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{parentDepartmentId,jdbcType=VARCHAR},
#{relatedId,jdbcType=VARCHAR},#{relatedCode,jdbcType=VARCHAR}, #{chainId,jdbcType=VARCHAR}, #{isStore,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId},#{sort},#{level},#{wxEnterpriseId},#{chainName},#{enterpriseId})
#{statusFlag,jdbcType=INTEGER}, #{recycleFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{wxDepartmentId},#{sort},#{level},#{wxEnterpriseId},#{chainName},#{enterpriseId},#{tempFlag})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanDepartment" >
insert into tab_haoban_department
......@@ -476,4 +478,15 @@
</if>
order by sort desc
</select>
<select id="getTempFlagDepartment" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_department
where wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
and temp_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -241,6 +241,14 @@
and status_flag = 1
</select>
<select id="listByClerkCode" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_department_related
where clerk_code = #{clerkCode}
and status_flag = 1
</select>
<select id="countByDepartmentId" resultType="java.lang.Integer" parameterType="java.lang.String" >
select
......
<?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.SyncTaskMapper">
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
<id column="task_id" jdbcType="VARCHAR" property="taskId"/>
<result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/>
<result column="task_name" jdbcType="VARCHAR" property="taskName"/>
<result column="add_user" jdbcType="VARCHAR" property="addUser"/>
<result column="task_desc" jdbcType="VARCHAR" property="taskDesc"/>
<result column="task_type" jdbcType="INTEGER" property="taskType"/>
<result column="status_flag" jdbcType="INTEGER" property="statusFlag"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
task_id,wx_enterprise_id, task_name, add_user, task_desc,task_type, status_flag, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_sync_task
where task_id = #{taskId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from tab_haoban_sync_task
where task_id = #{taskId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
insert into tab_haoban_sync_task (task_id,wx_enterprise_id, task_name, add_user,
task_desc, status_flag,task_type, create_time,
update_time)
values (#{taskId,jdbcType=VARCHAR},#{wxEnterpriseId}, #{taskName,jdbcType=VARCHAR}, #{addUser,jdbcType=VARCHAR},
#{taskDesc,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER},#{taskType}, now(),now())
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
insert into tab_haoban_sync_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">
task_id,
</if>
<if test="taskName != null">
task_name,
</if>
<if test="addUser != null">
add_user,
</if>
<if test="taskDesc != null">
task_desc,
</if>
<if test="statusFlag != null">
status_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">
#{taskId,jdbcType=VARCHAR},
</if>
<if test="taskName != null">
#{taskName,jdbcType=VARCHAR},
</if>
<if test="addUser != null">
#{addUser,jdbcType=VARCHAR},
</if>
<if test="taskDesc != null">
#{taskDesc,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
#{statusFlag,jdbcType=INTEGER},
</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.TabHaobanSyncTask">
update tab_haoban_sync_task
<set>
<if test="taskName != null">
task_name = #{taskName,jdbcType=VARCHAR},
</if>
<if test="addUser != null">
add_user = #{addUser,jdbcType=VARCHAR},
</if>
<if test="taskDesc != null">
task_desc = #{taskDesc,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where task_id = #{taskId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
update tab_haoban_sync_task
set task_name = #{taskName,jdbcType=VARCHAR},
add_user = #{addUser,jdbcType=VARCHAR},
task_desc = #{taskDesc,jdbcType=VARCHAR},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where task_id = #{taskId,jdbcType=VARCHAR}
</update>
<select id="listPageByWxEid" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_sync_task
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR} order by update_time desc
</select>
</mapper>
\ No newline at end of file
<?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.TabHaobanClerkMainStoreRelatedMapper" >
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated" >
<id column="clerk_main_store_related_id" property="clerkMainStoreRelatedId" jdbcType="VARCHAR" />
<result column="staff_id" property="staffId" jdbcType="VARCHAR" />
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="store_id" property="storeId" jdbcType="VARCHAR" />
<result column="main_store_flag" property="mainStoreFlag" jdbcType="INTEGER" />
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
clerk_main_store_related_id, staff_id, wx_enterprise_id, store_id, main_store_flag,
status_flag, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_clerk_main_store_related
where clerk_main_store_related_id = #{clerkMainStoreRelatedId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from tab_haoban_clerk_main_store_related
where clerk_main_store_related_id = #{clerkMainStoreRelatedId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated" >
insert into tab_haoban_clerk_main_store_related (clerk_main_store_related_id, staff_id,
wx_enterprise_id, store_id, main_store_flag,
status_flag, create_time, update_time
)
values (#{clerkMainStoreRelatedId,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{storeId,jdbcType=VARCHAR}, #{mainStoreFlag,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated" >
insert into tab_haoban_clerk_main_store_related
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="clerkMainStoreRelatedId != null" >
clerk_main_store_related_id,
</if>
<if test="staffId != null" >
staff_id,
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="storeId != null" >
store_id,
</if>
<if test="mainStoreFlag != null" >
main_store_flag,
</if>
<if test="statusFlag != null" >
status_flag,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="clerkMainStoreRelatedId != null" >
#{clerkMainStoreRelatedId,jdbcType=VARCHAR},
</if>
<if test="staffId != null" >
#{staffId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null" >
#{storeId,jdbcType=VARCHAR},
</if>
<if test="mainStoreFlag != null" >
#{mainStoreFlag,jdbcType=INTEGER},
</if>
<if test="statusFlag != null" >
#{statusFlag,jdbcType=INTEGER},
</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.TabHaobanClerkMainStoreRelated" >
update tab_haoban_clerk_main_store_related
<set >
<if test="staffId != null" >
staff_id = #{staffId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null" >
store_id = #{storeId,jdbcType=VARCHAR},
</if>
<if test="mainStoreFlag != null" >
main_store_flag = #{mainStoreFlag,jdbcType=INTEGER},
</if>
<if test="statusFlag != null" >
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where clerk_main_store_related_id = #{clerkMainStoreRelatedId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated" >
update tab_haoban_clerk_main_store_related
set staff_id = #{staffId,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
store_id = #{storeId,jdbcType=VARCHAR},
main_store_flag = #{mainStoreFlag,jdbcType=INTEGER},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where clerk_main_store_related_id = #{clerkMainStoreRelatedId,jdbcType=VARCHAR}
</update>
<select id="selectByWxEnterpriseIdAndStoreId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_clerk_main_store_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
limit 1
</select>
</mapper>
\ No newline at end of file
<?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
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class DealSyncTest {
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Test
public void test() {
List<SyncSingleDealDTO> add = new ArrayList<>();
List<SyncSingleDealDTO> edit = new ArrayList<>();
{
SyncSingleDealDTO dealDTO = new SyncSingleDealDTO();
dealDTO.setDepartmentId("ff80808166c3a1050166c43175d9000e");
dealDTO.setParentDepartmentId("a101b3a51cd549e79f3daec1aa628301");
dealDTO.setDepartmentName("西溪花园");
dealDTO.setRelatedId("ff80808166c3a1050166c43175d9000e");
dealDTO.setStoreFlag(0);
dealDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
add.add(dealDTO);
}
{
SyncSingleDealDTO dealDTO = new SyncSingleDealDTO();
dealDTO.setDepartmentId("100333808083");
dealDTO.setParentDepartmentId("a101b3a51cd549e79f3daec1aa628301");
dealDTO.setDepartmentName("测试门店1003338");
dealDTO.setRelatedId("100333808083");
dealDTO.setStoreFlag(1);
dealDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
add.add(dealDTO);
}
dealSyncOperationApiService.dealQywxDepartment("111", "ca66a01b79474c40b3e7c7f93daf1a3b");
}
}
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -6,28 +15,119 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class ServiceTest {
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private QywxDepartmentApiService qywxDepartmentApiService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Test
public void test() {
//wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId("073e89a37eb14acabf258e59a57359b6");
System.err.println(RedisUtil.getCache("init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"));
}
@Test
public void test1() {
String corpSelfExternalUseridInfo = qywxUserApiService.getCorpSelfExternalUseridInfo("ww50d418adce14b4a9"
, "1azg6LG5Vj_YKFO-X27to4S4x_y-f6APR0fwE9YnQd8", "wm-0J8CQAAbGIhtnLd51B97OO_0gf3zw");
System.out.println(corpSelfExternalUseridInfo);
}
// @Test
// public void test1() {
// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
// JSONArray jsonArray = JSONArray.parseArray(res);
// jsonArray.forEach(o -> {
// JSONObject mid = (JSONObject) o;
// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
// , mid.getString("handover_userid"), mid.getString("external_userid"));
// });
// System.out.println(res);
// }
//
// @Test
// public void test2() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong");
// userDTO.setName("空闻大师");
// userDTO.setDepartment(new Integer[]{4});
// userDTO.setMobile("17605628855");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
// @Test
// public void list() {
//
// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
// Iterator<DepartmentDTO> iterator = list.iterator();
//// while (iterator.hasNext()) {
//// DepartmentDTO next = iterator.next();
//// if(!next.getParentid().equals("1")) {
//// iterator.remove();
//// }
//// }
// System.out.println(JSONObject.toJSONString(list));
// }
//
// @Test
// public void addDepart() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
//// JSONResponse department = qywxDepartmentApiService.createDepartment("ww9ede832a84b7ae5f"
//// , "ww7d6566614055cf27", null);
//// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
//// System.out.println(JSONObject.toJSONString(list));
// }
//
// @Test
// public void getUser() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", "13735457631");
//// String phonenumber = phonenumber;
//// UserDTO phonenumber = (UserDTO) useridBymobile;
// System.out.println(JSONObject.toJSONString(phonenumber));
// }
//
// @Test
// public void createSelfUser() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong2");
// userDTO.setName("空闻大师2");
// userDTO.setDepartment(new Integer[]{5072});
// userDTO.setMobile("17605628851");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "ww9ede832a84b7ae5f",
// "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
//
// @Test
// public void sendMessage() {
// QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
// messageDTO.setAppid("wx6054e7be35015afc");
// ArrayList<String> userIDs = new ArrayList<>();
// userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
// messageDTO.setUserIds(userIDs);
// messageDTO.setTitle("我的测试test");
// messageDTO.setDescription("我的测试test11111");
// boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
// "ww2c34dc56739bb105", messageDTO);
// System.out.println(JSONObject.toJSONString(ret));
// }
}
......@@ -11,9 +11,11 @@ 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;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
......@@ -35,6 +37,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;
......@@ -55,6 +58,8 @@ public class ApplicationController extends WebBaseController{
private DepartmentApiService departmentApiService;
@Autowired
private ApplicationSettingApiService applicationSettingApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@RequestMapping("application-list")
public HaobanResponse applicationList() {
......@@ -107,14 +112,45 @@ public class ApplicationController extends WebBaseController{
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if(enterpriseDTO != null){
if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null && enterpriseDTO.getContactFlag() == 0){
this.departmentApiService.initwxDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), enterpriseDTO.getWxEnterpriseId());
String taskId = dealSyncOperationApiService.createQywxTask(wxEnterpriseId, "同步企业微信架构", login.getStaffDTO().getWxUserId(), "首次同步企业微信架构");
if(StringUtils.isBlank(taskId)){
return resultResponse(HaoBanErrCode.ERR_1, false);
}
//this.departmentApiService.initwxDepartmentMQ(enterpriseDTO.getWxEnterpriseId());
dealSyncOperationApiService.dealQywxDepartment(taskId, wxEnterpriseId);
enterpriseDTO.setContactFlag(1);
wxEnterpriseApiService.update(enterpriseDTO);
// 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("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){
String taskId = dealSyncOperationApiService.createQywxTask(wxEnterpriseId, "后门同步企业微信架构", login.getStaffDTO().getWxUserId(), "后门同步企业微信架构");
if(StringUtils.isBlank(taskId)){
return resultResponse(HaoBanErrCode.ERR_1, false);
}
dealSyncOperationApiService.dealQywxDepartment(taskId, wxEnterpriseId);
}
}
return resultResponse(HaoBanErrCode.ERR_1, true);
}
@RequestMapping("get-auth-url")
public HaobanResponse getAuthUrl(){
......@@ -153,6 +189,7 @@ public class ApplicationController extends WebBaseController{
e.printStackTrace();
}
}
@RequestMapping("cancal-suite")
@IgnoreLogin
......
......@@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -147,12 +149,21 @@ public class DepartmentContoller extends WebBaseController{
}
Map<String,EnterpriseDTO> enterpriseMap = new HashMap<>();
for (String enterpriseId : enterpriseSet) {
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
if(enterprise != null){
enterpriseMap.put(enterpriseId, enterprise);
List<String> enterpriseSetList = new ArrayList<>(enterpriseSet);
logger.info("size大小为=====================》{}",enterpriseSetList.size());
List<EnterpriseDTO> enterprises = enterpriseService.listEnterpriseByIds(enterpriseSetList);
if(CollectionUtil.isNotEmpty(enterprises)){
for (EnterpriseDTO enterprise : enterprises) {
enterpriseMap.put(enterprise.getEnterpriseId(), enterprise);
}
}
}
//先注释调
// for (String enterpriseId : enterpriseSet) {
// EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
// if(enterprise != null){
// enterpriseMap.put(enterpriseId, enterprise);
// }
// }
for (DepartmentDTO departmentDTO : list) {
String enterpriseId = departmentDTO.getEnterpriseId();
......@@ -186,12 +197,13 @@ public class DepartmentContoller extends WebBaseController{
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0);
department.setLevel(dto.getLevel() + 1);
ServiceResponse hr = departmentApiService.add(department);
ServiceResponse<DepartmentDTO> hr = departmentApiService.add(department);
if(hr.getCode() != 1){
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1,hr.getResult());
DepartmentDTO departmentDTO = hr.getResult();
departmentDTO.setHasSonNode(false);
return resultResponse(HaoBanErrCode.ERR_1, departmentDTO);
}
......@@ -526,7 +538,10 @@ public class DepartmentContoller extends WebBaseController{
for (GicTreeDTO departmentDTO : departmentList) {
DepartmentDTO dto = departmentApiService.selectByRelatedId(departmentDTO.getId());
if(dto == null) {
DepartmentDTO unBindDTO = new DepartmentDTO();
if (departmentDTO.getType() == 1) {
continue;
}
DepartmentDTO unBindDTO = new DepartmentDTO();
unBindDTO.setRelatedId(departmentDTO.getId());
Integer storeType = departmentDTO.getType();
if(storeType == 3){
......@@ -795,7 +810,8 @@ public class DepartmentContoller extends WebBaseController{
@RequestMapping("department-user-init")
public HaobanResponse departmentInit(String corpid, String suiteid, String wxEnterpriseId, Integer wxDepartmentId) {
RedisUtil.delCache("haoban-user-department-" + wxEnterpriseId);
staffApiService.initWxUser(corpid, suiteid, wxEnterpriseId, wxDepartmentId);
//TODO 这里有段代码没提交上来
staffApiService.initWxUser(corpid, suiteid, wxEnterpriseId, wxDepartmentId,"");
return resultResponse(HaoBanErrCode.ERR_1);
}
......
package com.gic.haoban.manage.web.controller;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.PreDealLogInfoDTO;
import com.gic.haoban.manage.api.dto.SyncCheckDTO;
import com.gic.haoban.manage.api.dto.SyncTaskDTO;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.SyncDealQO;
import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SyncDealContoller extends WebBaseController {
private static Logger logger = LoggerFactory.getLogger(SyncDealContoller.class);
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@RequestMapping("/test/department-sync")
@ResponseBody
public HaobanResponse departmentBatchSyncTest(@RequestBody SyncDealQO qo, String wxEid) {
String task = null;
if (StringUtils.isNotBlank(wxEid)) {
task = dealSyncOperationApiService.createTask(wxEid, "门店同步", "11111", "部门同步");
dealSyncOperationApiService.dealDepartment(task, wxEid, qo.getAddDepartment(), qo.getEditDepartment());
} else {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String key = "haoban-sync-department-" + wxEnterpriseId;
if (RedisUtil.getCache(key) != null) {
return resultResponse(HaoBanErrCode.ERR_10011);
}
task = dealSyncOperationApiService.createTask(wxEnterpriseId, "门店同步", login.getStaffDTO().getStaffId(), "部门同步");
dealSyncOperationApiService.dealDepartment(task, login.getWxEnterpriseId(), qo.getAddDepartment(), qo.getEditDepartment());
}
return resultResponse(HaoBanErrCode.ERR_1, task);
}
@RequestMapping("/department-sync")
@ResponseBody
public HaobanResponse departmentBatchSync(@RequestBody SyncDealQO qo) {
String task = null;
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String taskLock = dealSyncOperationApiService.getTaskLock(wxEnterpriseId);
if (null != taskLock) {
return resultResponse(HaoBanErrCode.ERR_10011);
}
task = dealSyncOperationApiService.createTask(wxEnterpriseId, "门店同步", login.getStaffDTO().getStaffId(), "部门同步");
if (task == null) {
return resultResponse(HaoBanErrCode.ERR_10011);
}
dealSyncOperationApiService.dealDepartment(task, login.getWxEnterpriseId(), qo.getAddDepartment(), qo.getEditDepartment());
return resultResponse(HaoBanErrCode.ERR_1, task);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping("department-sync-check")
public HaobanResponse syncSuccess(String wxEnterpriseId) {
if (StringUtils.isBlank(wxEnterpriseId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
wxEnterpriseId = login.getWxEnterpriseId();
}
SyncCheckDTO taskCheck = dealSyncOperationApiService.getTaskCheck(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, taskCheck);
}
/**
* 同步状态校验
*
* @param syncKey
* @return
*/
@RequestMapping("/test/department-sync-check")
public HaobanResponse testSyncSuccess(String wxEnterpriseId) {
if (StringUtils.isBlank(wxEnterpriseId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
wxEnterpriseId = login.getWxEnterpriseId();
}
SyncCheckDTO taskCheck = dealSyncOperationApiService.getTaskCheck(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, taskCheck);
}
@RequestMapping("/re-sync")
@ResponseBody
public HaobanResponse clerkReSync(String taskId) {
if (StringUtils.isBlank(taskId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
taskId = dealSyncOperationApiService.getTaskLock(wxEnterpriseId);
}
dealSyncOperationApiService.reDealDepartment(taskId, -1);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("/close-sync")
@ResponseBody
public HaobanResponse closeReSync(String wxEnterpriseId) {
if (StringUtils.isBlank(wxEnterpriseId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
wxEnterpriseId = login.getWxEnterpriseId();
}
dealSyncOperationApiService.closeTask(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 同步日志列表
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping("/sync-task")
@ResponseBody
public HaobanResponse syncTask(String wxEnterpriseId, BasePageInfo pageInfo) {
if (StringUtils.isBlank(wxEnterpriseId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
wxEnterpriseId = login.getWxEnterpriseId();
}
Page<SyncTaskDTO> retPage = dealSyncOperationApiService.listSyncTask(wxEnterpriseId, pageInfo);
return resultResponse(HaoBanErrCode.ERR_1, retPage);
}
/**
* 同步日志详情
*
* @param wxEnterpriseId
* @param pageInfo
* @return
*/
@RequestMapping("/sync-task-detail")
@ResponseBody
public HaobanResponse syncTaskDetail(String wxEnterpriseId, String taskId, BasePageInfo pageInfo) {
if (StringUtils.isBlank(wxEnterpriseId)) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
wxEnterpriseId = login.getWxEnterpriseId();
}
Page<PreDealLogInfoDTO> retPage = dealSyncOperationApiService.listSyncTaskDetail(wxEnterpriseId, taskId, pageInfo);
return resultResponse(HaoBanErrCode.ERR_1, retPage);
}
}
package com.gic.haoban.manage.web.controller;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.QywxXcxSendMessageQo;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
/**
* Created 2020/4/9.
*
* @author hua
*/
@RestController
@RequestMapping("/test")
public class TestController extends WebBaseController {
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@RequestMapping("/send-message-test")
public HaobanResponse testSendMessage(QywxXcxSendMessageQo qo) {
QywxXcxSendMessageDTO messageDTO = EntityUtil.changeEntityByOrika(QywxXcxSendMessageDTO.class, qo);
ArrayList<String> list = new ArrayList<>();
list.add(qo.getUserId());
messageDTO.setUserIds(list);
boolean b = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", messageDTO);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_0);
}
}
}
......@@ -21,26 +21,19 @@ import java.util.regex.Pattern;
*
* @author hua
*/
//@ControllerAdvice
@ControllerAdvice
public class GlobalExceptionHandler extends WebBaseController {
private static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
private static final Pattern pattern = Pattern.compile("(.*: )(.*)(\\n.*)");
@ResponseBody
@ExceptionHandler(ShowFrontMessageException.class)
public HaobanResponse ControllerException(HttpServletResponse response, ShowFrontMessageException ex) {
HaobanResponse res = new HaobanResponse();
res.setErrorCode(HaoBanErrCode.ERR_0.getCode());
res.setMessage(ex.getMessage());
return res;
}
@ResponseBody
@ExceptionHandler(RuntimeException.class)
public HaobanResponse ControllerException(HttpServletResponse response, RuntimeException ex) {
logger.info("exceoprion:{}", ex.getStackTrace());
ex.printStackTrace();
HaobanResponse res = new HaobanResponse();
res.setErrorCode(HaoBanErrCode.ERR_3.getCode());
String message = ex.getMessage();
......
package com.gic.haoban.manage.web.qo;
import java.io.Serializable;
/**
* Created by hua on 2020/4/8.
*/
public class QywxXcxSendMessageQo implements Serializable {
private String userId;
private String appid;
private String page;
private String title;
private String description;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
package com.gic.haoban.manage.web.qo;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import java.io.Serializable;
import java.util.List;
public class SyncDealQO implements Serializable {
private List<SyncSingleDealDTO> editDepartment;
private List<SyncSingleDealDTO> addDepartment;
public List<SyncSingleDealDTO> getEditDepartment() {
return editDepartment;
}
public void setEditDepartment(List<SyncSingleDealDTO> editDepartment) {
this.editDepartment = editDepartment;
}
public List<SyncSingleDealDTO> getAddDepartment() {
return addDepartment;
}
public void setAddDepartment(List<SyncSingleDealDTO> addDepartment) {
this.addDepartment = addDepartment;
}
}
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;
}
......@@ -32,7 +32,8 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.DepartmentApiService" id="departmentApiService">
<dubbo:method name="initwxDepartment" async="true"/>
</dubbo:reference>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreGroupService" id="storeGroupService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreGroupService" id="storeGroupService"
timeout="20000"/>
<dubbo:reference interface="com.gic.clerk.api.service.ClerkService" id="clerkService"/>
......@@ -51,5 +52,8 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.DictApiService" id="dictApiService"/>
<dubbo:reference interface="com.gic.wechat.token.api.service.QywxTokenManageService" id="qywxTokenManageService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.DealSyncOperationApiService"
id="dealSyncOperationApiService"/>
</beans>
......@@ -220,6 +220,12 @@
<artifactId>gic-quartz-api</artifactId>
<version>${gic-quartz-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-app-customer-api</artifactId>
<version>${haoban-app-customer-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -16,25 +16,36 @@ import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.app.customer.service.api.service.DistributeApiService;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.BindApiService;
import com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.web.anno.HttpLimit;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.interceptor.WebInterceptor;
import com.gic.haoban.manage.web.vo.ClerkVo;
import com.gic.haoban.manage.web.vo.StoreVO;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
@RestController
public class ClerkController extends WebBaseController{
......@@ -52,6 +63,18 @@ public class ClerkController extends WebBaseController{
private DepartmentApiService departmentApiService;
@Autowired
private BindApiService bindApiService;
@Autowired
private SyncHaobanToGicServiceApi syncHaobanToGicServiceApi;
@Autowired
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService;
@Autowired
private DistributeApiService distributeApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
//导购列表
@RequestMapping("/clerk-list")
......@@ -125,23 +148,41 @@ public class ClerkController extends WebBaseController{
Map<String,StaffDepartmentRelatedDTO> relatedMap = com.gic.commons.util.CollectionUtil.toMap(list, "staffId");
List<String> staffIds = list.stream().map(s->s.getStaffId()).collect(Collectors.toList());
List<StaffDTO> resultlist= staffApiService.listByIds(staffIds);
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
int size = 0;
if(resultlist != null){
size = resultlist.size();
}
for(StaffDTO dto :resultlist){
if(relatedMap.get(dto.getStaffId()) != null){
dto.setStaffDepartmentRelatedId(relatedMap.get(dto.getStaffId()).getStaffDepartmentRelatedId());
if(org.apache.commons.lang.StringUtils.isNotBlank(relatedMap.get(dto.getStaffId()).getClerkCode())){
StaffDepartmentRelatedDTO related = relatedMap.get(dto.getStaffId());
if(related != null){
dto.setStaffDepartmentRelatedId(related.getStaffDepartmentRelatedId());
if(org.apache.commons.lang.StringUtils.isNotBlank(related.getClerkCode())){
dto.setBindFlag(1);
dto.setClerkCode(relatedMap.get(dto.getStaffId()).getClerkCode());
dto.setClerkCode(related.getClerkCode());
if(size > 20){
ClerkDTO clerk = clerkService.getClerkByClerkCode(departmentDTO.getEnterpriseId(), related.getClerkCode());
if(clerk != null){
dto.setMemberCount(0);
// dto.setMemberCount(distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId));
}
}else{
dto.setMemberCount(0);
}
}else{
dto.setBindFlag(0);
dto.setMemberCount(0);
}
}else{
dto.setBindFlag(0);
}
}
//查找店长clerkType
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
if(StringUtils.isEmpty(storeId)){
}else{
String storeClerkCode = "";
......@@ -212,4 +253,122 @@ public class ClerkController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_1);
}
//新增店员
@HttpLimit
@RequestMapping("/staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String storeId,String clerkCode) {
String wxEnterpriseId = staffDTO.getWxEnterpriseId();
String staffName = staffDTO.getStaffName();
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
String postion = staffDTO.getPostion();
Integer sex = staffDTO.getSex();
staffDTO.setWxEnterpriseId(wxEnterpriseId);
if(StringUtils.isBlank(staffName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId,nationcode,phoneNumber);
if(staff != null) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
boolean flag = syncHaobanToGicServiceApi.syncClerkToGicClerkAdd(storeId, clerkCode, sex, staffName, phoneNumber, nationcode, postion);
if(!flag){
return resultResponse(HaoBanErrCode.ERR_10010);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
//删除店员
@HttpLimit
@RequestMapping("/staff-del")
public HaobanResponse staffDel(String staffDepartmentRelatedIds,String storeId) {
DepartmentDTO departmentDTO = departmentApiService.selectByRelatedId(storeId);
if(departmentDTO == null){
return resultResponse(HaoBanErrCode.ERR_10009);
}
if(StringUtils.isBlank(staffDepartmentRelatedIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffDepartmentRelatedIdArr = staffDepartmentRelatedIds.split(",");
boolean flag = false;
for (String staffDepartmentRelatedId : staffDepartmentRelatedIdArr) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentRelatedId);
if(related == null){
flag = true;
continue;
}
if(StringUtils.isBlank(related.getClerkCode())){
staffApiService.del(staffDepartmentRelatedId);
}else{
ClerkDTO clerk = clerkService.getClerkByClerkCode(departmentDTO.getEnterpriseId(), related.getClerkCode());
// if(clerk != null && distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId) == 0){
// syncHaobanToGicServiceApi.delGicClerk(clerk.getClerkId());
// staffApiService.del(staffDepartmentRelatedId);
// }
}
}
if(flag){
return resultResponse(HaoBanErrCode.ERR_999);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
//设置主导购
@HttpLimit
@RequestMapping("/set-main-store")
public HaobanResponse setMainStore(String staffId,String storeId,String wxEnterpriseId,String staffDepartmentRelatedId) {
StaffDTO staff = staffApiService.selectById(staffId);
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
if(staff == null){
return resultResponse(HaoBanErrCode.ERR_10006);
}
String key = "haoban_set_main_store_" + yyyyMM + staffId;
Object hasSet = RedisUtil.getCache(key);
if(hasSet == null){
RedisUtil.setCache(key,true,31 * 24 * 60 * 60l);
clerkMainStoreRelatedApiService.setMainStore(staffId,storeId,wxEnterpriseId);
}else{
return resultResponse(HaoBanErrCode.ERR_10007);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
//刷新微信好友
@RequestMapping("/fresh-wx-friend")
public HaobanResponse freshWxFrend(String staffId,String storeId,String wxEnterpriseId,String staffDepartmentRelatedId,String wxUserId) {
// StaffDTO staff = staffApiService.selectById(staffId);
// String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
// if(staff == null){
// return resultResponse(HaoBanErrCode.ERR_10006);
// }
// String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
// Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key);
// if(count == null || count < 4){
// WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
// RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l);
// String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), staff.getWxUserId());
// JSONObject json = JSON.parseObject(res);
// if("0".equals(json.getString("errcode"))){
// String external_userid = json.getString("external_userid");
// JSONArray jsonArr = json.getJSONArray(external_userid);
// List<MemberUnionidRelatedDTO> list = memberUnionidRelatedApiService.getByWxUserIdAndWxEnterpriseId(wxUserId, wxEnterpriseId);
// List<String> externalUserIdList = list.stream().map(student->student.getExternalUserid())
// .collect(Collectors.toList());
// for (Object object : jsonArr) {
// if(externalUserIdList.contains(object.toString())){
// continue;
// }else{
// //String string = qywxUserApiService.getCorpSelfExternalUseridInfo(enterprise.getCorpid(), enterprise.getWxSecretKey(), object.toString());
// memberUnionidRelatedApiService.add(wxEnterpriseId, object.toString(), wxUserId);
// }
// }
// }
// }else{
// return resultResponse(HaoBanErrCode.ERR_10011);
// }
return resultResponse(HaoBanErrCode.ERR_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