Commit a88f761e by 徐高华

Merge branch 'bugfix/2023-09-04' into 'master'

Bugfix/2023 09 04

See merge request !1420
parents 3a8770a1 68f061ac
......@@ -358,4 +358,5 @@ public interface StaffApiService {
com.gic.api.base.commons.ServiceResponse<StaffActiveAllocationDTO> staffActiveAllocation(String wxEnterpriseId,String staffIds);
void updateStaffHead(String wxEnterpriseId ,String staffId, String headUrl);
}
......@@ -207,6 +207,11 @@
<artifactId>gic-operating-api</artifactId>
<version>${gic-operating-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-content-api</artifactId>
<version>${gic-content-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -15,6 +15,8 @@ public interface StaffMapper {
TabHaobanStaff selectByPrimaryKey(String staffId);
TabHaobanStaff selectByPrimaryKeyNoStatus(String staffId);
int updateByPrimaryKeySelective(TabHaobanStaff record);
TabHaobanStaff selectByNationcodeAndPhoneNumber(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("nationCode") String nationcode, @Param("phoneNumber") String phoneNumber);
......@@ -190,5 +192,6 @@ public interface StaffMapper {
TabHaobanStaff getNumByActiveCode(@Param("wxEnterpriseId") String wxEnterpriseId,@Param("activeCode")String activeCode);
void updateOccupyFlagByStaffId(@Param("staffId") String staffId);
void updateStaffHead(@Param("staffId")String staffId, @Param("headUrl")String headUrl);
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ public interface WxEnterpriseRelatedMapper {
int deleteByEnterpriseId(String enterpriseId) ;
int deleteById(String id) ;
int insertSelective(TabHaobanWxEnterpriseRelated record);
TabHaobanWxEnterpriseRelated selectByPrimaryKey(String wxEnterpriseRelatedId);
......
......@@ -121,4 +121,6 @@ public interface HandoverService {
*/
public List<HandoverStaffFriendCountDTO> listFriendCountByWxStaffIds(String wxEnterpriseId, List<String> staffIds);
Boolean filterHandoverStaff(String wxEnterpriseId, String wxUserId);
public void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) ;
}
......@@ -154,4 +154,6 @@ public interface StaffService {
* @return
*/
List<String> queryStaffIdsWithEnterpriseId(List<String> wxEnterpriseIds);
void updateStaffHead(String wxEnterpriseId ,String staffId, String headUrl);
}
......@@ -85,7 +85,6 @@ public class HandoverServiceImpl implements HandoverService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (CollectionUtils.isEmpty(infoList)) {
logger.info("没有要保存的数据,删除所有需要删除逇");
// delHandoverStaff(wxEnterpriseId, null);
return false;
}
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
......@@ -127,20 +126,6 @@ public class HandoverServiceImpl implements HandoverService {
handoverExternalMapper.insertBatch(needAdd);
}
});
//删除不需要的staff数据
/*List<TabHandoverStaff> handoverStaffList = handoverStaffMapper.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(handoverStaffList)) {
logger.info("没有新数据,无需删除");
return true;
}
Set<String> hasWxUserIds = handoverStaffList.stream().map(dto -> dto.getHandoverUserId()).collect(Collectors.toSet());
Sets.SetView<String> needDelUserIds = Sets.difference(hasWxUserIds, handoverUserMap.keySet());
if (CollectionUtils.isEmpty(needDelUserIds)) {
logger.info("没有新数据,无需删除2");
return true;
}
logger.info("删除数据");
delHandoverStaff(wxEnterpriseId, new ArrayList<>(needDelUserIds));*/
return false;
}
......@@ -158,7 +143,7 @@ public class HandoverServiceImpl implements HandoverService {
* @param wxEnterpriseId
* @param wxUserIds
*/
private void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) {
public void delHandoverStaff(String wxEnterpriseId, List<String> wxUserIds) {
handoverStaffMapper.delByUserIds(wxEnterpriseId, wxUserIds);
handoverExternalMapper.delNoTransferExternal(wxUserIds, wxEnterpriseId);
}
......
......@@ -6,10 +6,13 @@ import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.content.api.service.ContentProducerApiService;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
......@@ -30,9 +33,8 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class StaffServiceImpl implements StaffService {
......@@ -50,6 +52,10 @@ public class StaffServiceImpl implements StaffService {
private HaobanQywxFeeAccountStaffService haobanQywxFeeAccountStaffService;
@Autowired
private QywxUserApiService qywxUserApiService ;
@Autowired
private TabHaobanStaffClerkRelationMapper staffClerkRelationMapper ;
@Autowired
private ContentProducerApiService contentProducerApiService ;
@Override
public TabHaobanStaff selectById(String id) {
......@@ -296,4 +302,20 @@ public class StaffServiceImpl implements StaffService {
}
return this.mapper.queryStaffIdsWithEnterpriseId(wxEnterpriseIds);
}
@Override
public void updateStaffHead(String wxEnterpriseId , String staffId, String headUrl) {
this.mapper.updateStaffHead(staffId,headUrl) ;
List<StaffClerkRelationDTO> list = this.staffClerkRelationMapper.lisByStaffId(wxEnterpriseId,staffId,null) ;
if(CollectionUtils.isNotEmpty(list)) {
Map<String,List<StaffClerkRelationDTO>> map = list.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getEnterpriseId)) ;
Set<String> set = map.keySet() ;
Iterator<String> it = set.iterator() ;
while(it.hasNext()) {
String enterpriseId = it.next() ;
List<String> clerkIdList = map.get(enterpriseId).stream().map(o->o.getClerkId()).collect(Collectors.toList());
this.contentProducerApiService.updateClerkProducer(enterpriseId,clerkIdList,headUrl) ;
}
}
}
}
......@@ -10,6 +10,8 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.HandoverStaffMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHandoverExternal;
import com.gic.haoban.manage.service.entity.TabHandoverStaff;
import com.gic.haoban.manage.service.entity.TabHandoverTransfer;
......@@ -23,6 +25,7 @@ import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO;
import com.gic.wechat.api.dto.qywx.response.QywxGetUnassignedListDTO;
import com.gic.wechat.api.dto.qywx.response.QywxTransferCustomerDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
......@@ -53,11 +56,13 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private Config config;
private HandoverStaffMapper handoverStaffMapper;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private StaffService staffService;
@Autowired
private StaffMapper staffMapper ;
@Override
......@@ -100,10 +105,11 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//这里改成LinkedList,避免使用ArrayList导致频繁扩容,从而减少内存的浪费
List<QywxUnassignedInfoDTO> ret = new LinkedList<>();
List<QywxUnassignedInfoDTO> retList = new LinkedList<>();
QywxGetUnassignedListDTO unassignedListDTO = null;
String cursor = null;
Map<String,Boolean> map = new HashMap<>() ;
Set<String> leaveStaffSet = new HashSet<>() ;
do {
//离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost());
......@@ -116,20 +122,34 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
String handoverUserid = dto.getHandoverUserid();
Boolean flag = map.get(handoverUserid) ;
if(null == flag) {
leaveStaffSet.add(handoverUserid) ;
flag = handoverService.filterHandoverStaff(wxEnterpriseId, handoverUserid) ;
map.put(handoverUserid,flag) ;
}
if (flag) {
ret.add(dto);
retList.add(dto);
}
}
}
} while (StringUtils.isNotBlank(cursor) && unassignedListDTO.getErrcode() == 0);
if (CollectionUtils.isEmpty(ret)) {
return ret;
//删除不需要的staff数据
List<TabHandoverStaff> handoverStaffList = handoverStaffMapper.listByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(handoverStaffList) && CollectionUtils.isNotEmpty(leaveStaffSet)) {
Set<String> hasWxUserIds = handoverStaffList.stream().map(dto -> dto.getHandoverUserId()).collect(Collectors.toSet());
Sets.SetView<String> needDelUserIds = Sets.difference(hasWxUserIds, leaveStaffSet);
if (CollectionUtils.isNotEmpty(needDelUserIds)) {
logger.info("需要删除的离职人={}",needDelUserIds);
this.handoverService.delHandoverStaff(wxEnterpriseId, new ArrayList<>(needDelUserIds));
}
}
if (CollectionUtils.isEmpty(retList)) {
logger.info("无待处理的离职继承数");
return retList;
}
logger.info("无待处理的离职继承数={}",retList.size());
//去重
return ret.stream().collect(
return retList.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(dto -> {
return dto.getExternalUserid() + dto.getHandoverUserid();
......@@ -150,7 +170,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
}
transfers.forEach(dto -> {
try {
TabHaobanStaff handover = staffService.selectById(dto.getHandoverStaffId());
TabHaobanStaff handover = staffMapper.selectByPrimaryKeyNoStatus(dto.getHandoverStaffId());
TabHaobanStaff takeover = staffService.selectById(dto.getTakeoverStaffId());
if(null == handover) {
logger.info("handover is null={}",dto.getHandoverStaffId());
......
......@@ -1388,4 +1388,9 @@ public class StaffApiServiceImpl implements StaffApiService {
}
return com.gic.api.base.commons.ServiceResponse.failure("-9999","成员不存在");
}
@Override
public void updateStaffHead(String wxEnterpriseId ,String staffId, String headUrl) {
this.staffService.updateStaffHead(wxEnterpriseId,staffId,headUrl) ;
}
}
......@@ -22,6 +22,7 @@ import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.DepartmentService;
......@@ -54,6 +55,8 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
@Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper ;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private StoreGroupService storeGroupService;
......@@ -191,12 +194,26 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
return details;
}
// @Override
// public List<EnterpriseDetailDTO> queryBindGicEnterpriseByTime(String seqTime) {
// List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedMapper.listEnterpriseByTime(seqTime);
// List<EnterpriseDetailDTO> details = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, list);
// return details;
// }
private String isBindMany(String enterpriseId , String wxEnterpriseId) {
List<TabHaobanWxEnterpriseRelated> list = this.wxEnterpriseRelatedMapper.listByEnterpriseId(enterpriseId) ;
List<String> bindNameList = new ArrayList<>() ;
if(CollectionUtils.isNotEmpty(list)) {
for(TabHaobanWxEnterpriseRelated item : list) {
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseMapper.selectByPrimaryKey(item.getWxEnterpriseId()) ;
if(null == wxEnterprise || 0 == wxEnterprise.getStatusFlag()) {
this.wxEnterpriseRelatedMapper.deleteById(item.getWxEnterpriseRelatedId()) ;
} else {
if(!item.getWxEnterpriseId().equals(wxEnterpriseId)) {
bindNameList.add(wxEnterprise.getCorpName()) ;
}
}
}
if(CollectionUtils.isNotEmpty(bindNameList)) {
return bindNameList.stream().collect(Collectors.joining("、"));
}
}
return null ;
}
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -220,6 +237,13 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
String wxEnterpriseId = detailDTO.getWxEnterpriseId();
//校验关联已经企业绑定
TabHaobanWxEnterpriseRelated tab = wxEnterpriseRelatedMapper.findOneByEIdAndWxEid(enterpriseId, wxEnterpriseId);
String bindMany = this.isBindMany(enterpriseId , wxEnterpriseId) ;
if(StringUtils.isNotBlank(bindMany)) {
logger.info("一GIC商户绑不能绑定多个");
resp.setCode(2);
resp.setMessage("商户不能绑多个企微("+bindMany+")");
return resp;
}
if (tab != null && (!tab.getWxEnterpriseRelatedId().equals(detailDTO.getWxEnterpriseRelatedId()))) {
logger.info("该企业已经被绑定过");
resp.setCode(2);
......
......@@ -232,5 +232,6 @@
<dubbo:service interface="com.gic.haoban.manage.api.service.content.task.CommissionTaskApiService"
ref="commissionTaskApiService" timeout="10000" />
<dubbo:reference id="memberOrderReadApiService" interface="com.gic.order.api.service.member.MemberOrderReadApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference id="contentProducerApiService" interface="com.gic.content.api.service.ContentProducerApiService" timeout="10000" retries="0" check="false" />
</beans>
\ No newline at end of file
......@@ -45,6 +45,13 @@
where staff_id = #{staffId,jdbcType=VARCHAR} and status_flag = 1
</select>
<select id="selectByPrimaryKeyNoStatus" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff
where staff_id = #{staffId,jdbcType=VARCHAR}
</select>
<update id="delOtherStaffByWxUserId">
update tab_haoban_staff
......@@ -664,4 +671,9 @@
where staff_id= #{staffId}
</update>
<update id="updateStaffHead">
update tab_haoban_staff set head_img = #{headUrl}, update_time= now()
where staff_id= #{staffId}
</update>
</mapper>
\ No newline at end of file
......@@ -31,7 +31,10 @@
<update id="deleteByEnterpriseId">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where enterprise_id=#{enterpriseId} and status_flag=1
</update>
<update id="deleteById">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where wx_enterprise_related_id=#{id} and status_flag=1
</update>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated">
insert into tab_haoban_wx_enterprise_related
......
......@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatPlanDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.haoban.manage.api.service.QywxTagApiService;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.gic.haoban.manage.service.config.Config;
......@@ -33,19 +34,11 @@ public class ChatTest {
private static Logger logger = LoggerFactory.getLogger(ChatTest.class);
@Autowired
private GroupChatPlanService groupChatPlanService;
private HandoverOperationApiService handoverOperationApiService;
@Test
public void test() {
String str = "{\"name\":\"测试\",\"remark\":\"测试\",\"expireDays\":\"2\",\"sendType\":1,\"sendTime\":\"\",\"chatContent\":\"[{\\\"img\\\":\\\"https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/marketing_common-edc68cbf153846928c0ac28e2b2aa92f.jpg\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":2},{\\\"img\\\":\\\"https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/jhdm/marketing_common-3acc9bc9bbe8416e8aefe459b23eea5e.jpg\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":2},{\\\"content\\\":\\\"莎啦啦啦🐮\\\",\\\"relation_id\\\":\\\"510923843246776342\\\",\\\"type\\\":1}]\",\"staffIdList\":\"36067cdee7ba4ff6adc7551b34cc2005\",\"requestProject\":\"haoban-manage-web\"}";
GroupChatPlanDTO groupChatPlanDTO = JSONObject.parseObject(str, GroupChatPlanDTO.class);
groupChatPlanDTO.setWxEnterpriseId("ca66a01b79474c40b3e7c7f93daf1a3b");
groupChatPlanDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
groupChatPlanDTO.setCreatorId("fefd1c81641711e69d0818c58a146fd2");
groupChatPlanDTO.setCreatorName("达摩管理员");
groupChatPlanDTO.setMaterialFrom(2);
groupChatPlanService.save(groupChatPlanDTO);
this.handoverOperationApiService.dealQywxEnterpriseHandoverMq("ca66a01b79474c40b3e7c7f93daf1a3b") ;
}
@Test
......
......@@ -1906,4 +1906,13 @@ public class WxStaffController extends WebBaseController {
}
return RestResponse.successResult(vo);
}
@RequestMapping("update-staff-head")
public RestResponse<Object> updateStaffHead(String wxEnterpriseId , String staffId , String headUrl){
if(StrUtil.isBlank(headUrl)){
return RestResponse.failure("-1", "参数不能为空!!!");
}
this.staffApiService.updateStaffHead(wxEnterpriseId,staffId,headUrl) ;
return RestResponse.successResult() ;
}
}
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