Commit c3da527a by fudahua

同步刷新好办成员信息

parent 7f34f175
...@@ -64,4 +64,6 @@ public interface TabHaobanStaffClerkRelationMapper { ...@@ -64,4 +64,6 @@ public interface TabHaobanStaffClerkRelationMapper {
* 解绑 * 解绑
*/ */
int cleanStaffDepart( @Param("wxEnterpriseId")String wxEnterpriseId,@Param("staffIds")List<String> staffIds); int cleanStaffDepart( @Param("wxEnterpriseId")String wxEnterpriseId,@Param("staffIds")List<String> staffIds);
TabHaobanStaffClerkRelation getOneBindCodeNoStatus(@Param("enterpriseId")String enterpriseId, @Param("clerkCode")String clerkCode);
} }
\ No newline at end of file
...@@ -47,4 +47,6 @@ public interface StaffClerkRelationService { ...@@ -47,4 +47,6 @@ public interface StaffClerkRelationService {
public int cleanStaffClerk( String wxEnterpriseId, List<String> staffIds); public int cleanStaffClerk( String wxEnterpriseId, List<String> staffIds);
StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode);
} }
...@@ -90,4 +90,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -90,4 +90,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds) { public int cleanStaffClerk(String wxEnterpriseId, List<String> staffIds) {
return mapper.cleanStaffDepart(wxEnterpriseId,staffIds); return mapper.cleanStaffDepart(wxEnterpriseId,staffIds);
} }
@Override
public StaffClerkRelationDTO getOneBindCodeNoStatus(String enterpriseId, String clerkCode) {
return EntityUtil.changeEntityByJSON(StaffClerkRelationDTO.class,mapper.getOneBindCodeNoStatus(enterpriseId,clerkCode));
}
} }
...@@ -4,19 +4,20 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,19 +4,20 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.binlog.base.entity.GicField; import com.gic.binlog.base.entity.GicField;
import com.gic.binlog.base.entity.GicRecord; import com.gic.binlog.base.entity.GicRecord;
import com.gic.binlog.base.entity.enums.GicRecordType; import com.gic.binlog.base.entity.enums.GicRecordType;
import com.gic.commons.util.BeanUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.contacts.manage.api.enums.StatusEnum;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.service.pojo.BinlogBasePojo; import com.gic.haoban.manage.service.pojo.BinlogBasePojo;
import com.gic.haoban.manage.service.pojo.ClerkSyncPojo; import com.gic.haoban.manage.service.pojo.ClerkSyncPojo;
import com.gic.haoban.manage.service.service.StaffClerkRelationService; import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.listener.MessageListener; import org.springframework.kafka.listener.MessageListener;
import java.util.ArrayList; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -58,7 +59,32 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor ...@@ -58,7 +59,32 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
if(gicRecordType.equals(GicRecordType.DELETE)){ if(gicRecordType.equals(GicRecordType.DELETE)){
staffClerkRelationService.delBind(syncPojo.getClerkId()); staffClerkRelationService.delBind(syncPojo.getClerkId());
}else if (gicRecordType.equals(GicRecordType.INSERT)) { }else if (gicRecordType.equals(GicRecordType.INSERT)) {
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getOneBindCodeNoStatus(syncPojo.getEnterpriseId(), syncPojo.getClerkCode());
if (null == relationDTO) {
logger.info("没有关联导购,不需要新增");
return;
}
//正常的时候
if (relationDTO.getStatusFlag() != StatusEnum.DEL.getValue()) {
staffClerkRelationService.delBind(relationDTO.getClerkId());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
staffClerkRelationService.bind(relationDTO);
}else {//删除状态 需要判断是否近段时间有操作删除 2分组内有更新 判断是转移操作
Date timeDiff = DateUtils.addMinutes(new Date(), -2);
if(relationDTO.getUpdateTime().after(timeDiff)){
staffClerkRelationService.delBind(relationDTO.getClerkId());
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
staffClerkRelationService.bind(relationDTO);
}
}
}else if (gicRecordType.equals(GicRecordType.UPDATE)) {
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkId(syncPojo.getClerkId());
relationDTO.setStoreId(syncPojo.getStoreId());
relationDTO.setClerkCode(syncPojo.getClerkCode());
staffClerkRelationService.updateByClerkId(relationDTO);
} }
} }
......
...@@ -274,4 +274,14 @@ ...@@ -274,4 +274,14 @@
#{item} #{item}
</foreach> </foreach>
</update> </update>
<select id="getOneBindCodeNoStatus" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_clerk_relation
where enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
and clerk_code = #{clerkCode}
order by update_time desc limit 1
</select>
</mapper> </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