Commit 4be67721 by fudahua

清空数据据

parent 1b129c2c
......@@ -110,5 +110,12 @@ public interface DealSyncOperationApiService {
*/
public void dealQywxDepartment(String taskId, String wxEnterpriseId);
/**
* 清理不存在的数据
* @param wxEnterpriseId
* @param taskId
*/
public void cleanDiffrence(String wxEnterpriseId,String taskId);
}
......@@ -8,6 +8,7 @@ import org.apache.xpath.operations.Bool;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.github.pagehelper.Page;
import retrofit2.http.PATCH;
public interface DepartmentMapper {
int deleteByPrimaryKey(String departmentId);
......@@ -66,4 +67,6 @@ public interface DepartmentMapper {
TabHaobanDepartment getTempFlagDepartment(@Param("wxEnterpriseId") String wxEnterpriseId);
Integer totalStoreCountByEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId);
public int cleanDepartment(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("dIds") List<String> wxDeIds);
}
\ No newline at end of file
......@@ -38,4 +38,6 @@ public interface StaffMapper {
List<TabHaobanStaff> listByPhoneNumber(@Param("phoneNumber")String phoneNumber);
List<TabHaobanStaff> listByUserIdsAndWxEnterpriseId(@Param("userIds")List<String> userIds, @Param("wxEnterpriseId")String wxEnterpriseId);
public int cleanStaff(@Param("wxEnterpriseId")String wxEnterpriseId,@Param("staffIds")List<String> staffIds);
}
\ No newline at end of file
......@@ -56,4 +56,12 @@ public interface DepartmentService {
Integer totalStoreCountByEnterpriseId(String wxEnterpriseId);
/**
* 清空数据
* @param wxEnterpriseId
* @param wxDepartmentList
* @return
*/
Integer cleanDepartment(String wxEnterpriseId,List<String> wxDepartmentList);
}
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Set;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import org.apache.ibatis.annotations.Param;
public interface StaffClerkRelationService {
......@@ -44,4 +45,6 @@ public interface StaffClerkRelationService {
String insert(StaffClerkRelationDTO staffClerkRelation);
public int cleanStaffClerk(@Param("wxEnterpriseId") String wxEnterpriseId,@Param("staffIds") List<String> staffIds);
}
......@@ -6,6 +6,7 @@ import java.util.Set;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
public interface StaffService {
......@@ -25,4 +26,12 @@ public interface StaffService {
List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/**
* 清楚微信信息
* @param wxEnterpriseId
* @param wxUserIds
* @return
*/
public int cleanStaff(@Param("wxEnterpriseId") String wxEnterpriseId,@Param("staffIds") List<String> staffIds);
}
......@@ -195,4 +195,10 @@ public class DepartmentServiceImpl implements DepartmentService {
public Integer totalStoreCountByEnterpriseId(String wxEnterpriseId) {
return mapper.totalStoreCountByEnterpriseId(wxEnterpriseId);
}
@Override
public Integer cleanDepartment(String wxEnterpriseId, List<String> wxDepartmentList) {
return mapper.cleanDepartment(wxEnterpriseId,wxDepartmentList);
}
}
......@@ -82,4 +82,8 @@ public class StaffServiceImpl implements StaffService {
return EntityUtil.changeEntityListByJSON(StaffDTO.class, this.mapper.listByUserIdsAndWxEnterpriseId(userIds,wxEnterpriseId));
}
@Override
public int cleanStaff(String wxEnterpriseId, List<String> staffIds) {
return mapper.cleanStaff(wxEnterpriseId,staffIds);
}
}
......@@ -88,6 +88,9 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private StaffClerkRelationService staffClerkRelationService;
private static final String LOCK_KEY = "sync_wx_lock_";
private static final String LOCK_SUCCESS_KEY = "sync_wx_success_lock_";
......@@ -534,4 +537,27 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
}
@Override
public void cleanDiffrence(String wxEnterpriseId, String taskId) {
List<TabHaobanPreDealLog> groupList = preDealService.listByTaskId(taskId, PreDealTypeEnum.group.getVal(), 1);
List<TabHaobanPreDealLog> clerkList = preDealService.listByTaskId(taskId, PreDealTypeEnum.clerk.getVal(), 1);
//清空staff
if (CollectionUtils.isNotEmpty(clerkList)) {
List<String> clerkIds = clerkList.stream().map(TabHaobanPreDealLog::getDataId).collect(Collectors.toList());
List<StaffDTO> retLists = staffService.listByUserIdsAndWxEnterpriseId(clerkIds, wxEnterpriseId);
List<String> staffIds = retLists.stream().map(StaffDTO::getStaffId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(staffIds)) {
staffClerkRelationService.cleanStaffClerk(wxEnterpriseId, staffIds);
staffService.cleanStaff(wxEnterpriseId, staffIds);
}
}
//清空cleak
if (CollectionUtils.isNotEmpty(groupList)) {
List<String> groupIdList = (List<String>) groupList.stream().map(TabHaobanPreDealLog::getDataId).collect(Collectors.toList());
departmentService.cleanDepartment(wxEnterpriseId,groupIdList);
}
}
}
......@@ -128,6 +128,7 @@ public class QywxClerkSyncOperation implements BaseSyncOperation {
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.compute.getVal());
dealSyncOperationApiService.unlockTask(syncTask.getWxEnterpriseId());
}
dealSyncOperationApiService.cleanDiffrence(syncTask.getWxEnterpriseId(),taskId);
}
RedisUtil.unlock(key);
}
......
......@@ -500,4 +500,16 @@
and recycle_flag != 1
and is_store = 1
</select>
<update id="cleanDepartment" >
update tab_haoban_department
set
status_flag = 0,
update_time=now()
where wx_enterprise_id = #{wxEnterpriseId} and status_flag = 1 and
wx_department_id not in
<foreach collection="dIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -341,4 +341,18 @@
</if>
</select>
<update id="cleanStaff" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaff" >
update tab_haoban_staff
set wx_user_id = #{wxUserId,jdbcType=VARCHAR},
status_flag = 0,
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR} and status_flag = 1
and staff_id not in
<foreach collection="wxUserIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>
\ No newline at end of file
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