Commit d4f0e49d authored by hongguangwu's avatar hongguangwu

MVP1.7.7-friend-改为批量

parent a2e5a768
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
/**
* 税友推送和拉取的日志表,用于10分钟只能推拉一次
*
* @author hgw
* @date 2025-03-18 15:43:40
*/
@Data
@TableName("t_social_freind_push_and_get")
@Schema(description = "税友推送和拉取的日志表,用于10分钟只能推拉一次")
public class TSocialFreindPushAndGet {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ExcelProperty("id")
@Schema(description = "id")
private String id;
/**
* 类型:1推送;2拉取
*/
@ExcelAttribute(name = "类型:1推送;2拉取", isNotEmpty = true, errorInfo = "类型:1推送;2拉取不能为空")
@NotBlank(message = "类型:1推送;2拉取不能为空")
@ExcelProperty("类型:1推送;2拉取")
@Schema(description = "类型:1推送;2拉取")
private Integer type;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间", isNotEmpty = true, errorInfo = "创建时间不能为空", isDate = true)
@NotBlank(message = "创建时间不能为空")
@ExcelProperty("创建时间")
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 创建人姓名
*/
@ExcelAttribute(name = "创建人姓名", isNotEmpty = true, errorInfo = "创建人姓名不能为空", maxLength = 50)
@NotBlank(message = "创建人姓名不能为空")
@Length(max = 50, message = "创建人姓名不能超过50个字符")
@ExcelProperty("创建人姓名")
@Schema(description = "创建人姓名")
private String createUserName;
}
......@@ -17,19 +17,27 @@
package com.yifu.cloud.plus.v1.yifu.social.controller;
import com.alibaba.fastjson.JSONObject;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFreindPushAndGet;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFreindPushAndGetService;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFriendPushService;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFriendService;
import com.yifu.cloud.plus.v1.yifu.social.vo.FriendResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicInteger;
/**
......@@ -44,8 +52,12 @@ import java.util.List;
@Tag(name = "税友")
public class TSocialFriendController {
private AtomicInteger atomicPush = new AtomicInteger(0);
private AtomicInteger atomicGet = new AtomicInteger(0);
private final TSocialFriendService tSocialFriendService;
private final TSocialFriendPushService tSocialFriendPushService;
private final TSocialFreindPushAndGetService tSocialFreindPushAndGetService;
@Operation(description = "1定时任务推送税友")
@PostMapping("/inner/doPushFriend")
......@@ -63,4 +75,93 @@ public class TSocialFriendController {
return tSocialFriendService.getInfoByRequestId();
}
/**
* @Description: 主动推送税友
* @Author: hgw
* @Date: 2025/3/18 10:44
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "主动推送税友")
@GetMapping("/doPushFriendByActive")
@SysLog("主动推送税友")
public R<String> doPushFriendActive() {
if (atomicPush.incrementAndGet() <= 1) {
try {
R<String> failed = getCore(CommonConstants.ONE_INT);
if (failed != null) return failed;
} finally {
atomicPush.decrementAndGet();
}
return R.ok();
} else {
atomicPush.decrementAndGet();
return R.failed("距离上一次推送任务时间间隔太短,请10分钟后再试!!");
}
}
/**
* @param type 1推送2拉取
* @Description: 核心处理
* @Author: hgw
* @Date: 2025/3/18 17:27
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
private R<String> getCore(int type) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getNickname())) {
return R.failed("请先登录!");
}
// 先加限制 查有没有到10分钟
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 计算10分钟前的时间
LocalDateTime tenMinutesAgo = now.minusMinutes(10);
LocalDateTime time = tSocialFreindPushAndGetService.getMaxTimeByType(type);
if (Common.isEmpty(time) || time.isBefore(tenMinutesAgo)) {
TSocialFreindPushAndGet info = new TSocialFreindPushAndGet();
info.setType(type);
info.setCreateTime(now);
info.setCreateUserName(user.getNickname());
tSocialFreindPushAndGetService.save(info);
if (type == CommonConstants.ONE_INT) {
tSocialFriendPushService.pushFriendByAsync();
} else {
tSocialFriendService.getInfoByRequestIdByAsync();
}
return R.ok();
}
if (Common.isNotNull(time) && time.isAfter(tenMinutesAgo)) {
if (type == CommonConstants.ONE_INT) {
return R.failed("距离上一次推送任务时间间隔太短,请10分钟后再试!");
} else {
return R.failed("距离上一次拉取任务时间间隔太短,请10分钟后再试!");
}
}
return null;
}
/**
* @Description: 主动获取税友
* @Author: hgw
* @Date: 2025/3/18 10:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Operation(description = "主动获取税友")
@GetMapping("/doGetFriendByActive")
@SysLog("主动获取税友")
public R<String> doGetFriendByActive() {
if (atomicGet.incrementAndGet() <= 1) {
try {
R<String> failed = getCore(CommonConstants.TWO_INT);
if (failed != null) return failed;
} finally {
atomicGet.decrementAndGet();
}
return R.ok();
} else {
atomicGet.decrementAndGet();
return R.failed("距离上一次推送任务时间间隔太短,请10分钟后再试!!");
}
}
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFreindPushAndGet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
/**
* 税友推送和拉取的日志表,用于10分钟只能推拉一次
*
* @author hgw
* @date 2025-03-18 15:43:40
*/
@Mapper
public interface TSocialFreindPushAndGetMapper extends BaseMapper<TSocialFreindPushAndGet> {
/**
* @param type 类型:1推送;2拉取
* @Description: 获取当前类型最大的时间,用来判断10分钟内是否有操作过
* @Author: hgw
* @Date: 2025/3/18 15:57
* @return: java.time.LocalDateTime
**/
LocalDateTime getMaxTimeByType(@Param("type") Integer type);
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFreindPushAndGet;
import java.time.LocalDateTime;
/**
* 税友推送和拉取的日志表,用于10分钟只能推拉一次
*
* @author hgw
* @date 2025-03-18 15:43:40
*/
public interface TSocialFreindPushAndGetService extends IService<TSocialFreindPushAndGet> {
/**
* @param type 类型:1推送;2拉取
* @Description: 获取当前类型最大的时间,用来判断10分钟内是否有操作过
* @Author: hgw
* @Date: 2025/3/18 15:57
* @return: java.time.LocalDateTime
**/
LocalDateTime getMaxTimeByType(Integer type);
}
......@@ -40,5 +40,13 @@ public interface TSocialFriendPushService extends IService<TSocialInfo> {
**/
R<String> pushFriend(List<String> dispatchIdList);
/**
* @Description: 主动推送税友-异步
* @Author: hgw
* @Date: 2025/3/18 10:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
void pushFriendByAsync();
R<String> doExportRoster(String socialId, String type, String unitCreditCode);
}
......@@ -37,4 +37,12 @@ public interface TSocialFriendService extends IService<TSocialInfo> {
**/
R<String> getInfoByRequestId();
/**
* @Description: 主动获取税友-异步
* @Author: hgw
* @Date: 2025/3/18 10:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
void getInfoByRequestIdByAsync();
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.social.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFreindPushAndGet;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFreindPushAndGetMapper;
import com.yifu.cloud.plus.v1.yifu.social.service.TSocialFreindPushAndGetService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* 税友推送和拉取的日志表,用于10分钟只能推拉一次
*
* @author hgw
* @date 2025-03-18 15:43:40
*/
@Log4j2
@Service
public class TSocialFreindPushAndGetServiceImpl extends ServiceImpl<TSocialFreindPushAndGetMapper, TSocialFreindPushAndGet> implements TSocialFreindPushAndGetService {
/**
* @param type 类型:1推送;2拉取
* @Description: 获取当前类型最大的时间,用来判断10分钟内是否有操作过
* @Author: hgw
* @Date: 2025/3/18 15:57
* @return: java.time.LocalDateTime
**/
@Override
public LocalDateTime getMaxTimeByType(Integer type) {
return baseMapper.getMaxTimeByType(type);
}
}
......@@ -40,12 +40,14 @@ import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 税友-推送
......@@ -66,6 +68,8 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
private final TSocialFriendBackLogService tSocialFriendBackLogService;
private final TSocialFreindSetService tSocialFreindSetService;
private final TSocialInfoMapper socialMapper;
private final AtomicInteger atomicPushFriend = new AtomicInteger(0);
@Autowired
private ExcelMergeImage excelMergeImage;
@Autowired
......@@ -82,6 +86,19 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
@Autowired
private TDispatchInfoMapper dispatchInfoMapper;
/**
* @Description: 核心推送改为异步
* @Author: hgw
* @Date: 2025/3/18 10:52
* @return: void
**/
@Async
@Override
public void pushFriendByAsync() {
this.pushFriend(null);
}
/**
* @Description: 推送到税友
* @Author: hgw
......@@ -90,43 +107,52 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
**/
@Override
public R<String> pushFriend(List<String> dispatchIdList) {
TSocialFreindSet set = tSocialFreindSetService.getById("1");
if (set != null && Common.isNotNull(set.getType()) && 1 == set.getType()) {
if (atomicPushFriend.incrementAndGet() <= 1) {
try {
TSocialFreindSet set = tSocialFreindSetService.getById("1");
if (set != null && Common.isNotNull(set.getType()) && 1 == set.getType()) {
// 获取时间限制配置(获取 当月启用 的配置)
Map<String, TSocialDeadlineInfo> socialSetMap = tSocialDeadlineInfoService.getSocialSetByAreaId();
// 获取时间限制配置(获取 当月启用 的配置)
Map<String, TSocialDeadlineInfo> socialSetMap = tSocialDeadlineInfoService.getSocialSetByAreaId();
// 社保增员、社保减员、医保增员、医保减员
// 养工失新增列表
List<SociaFriendYgsAddVo> ygsAddlist = baseMapper.getSocialSoldierYgsAddVoList(dispatchIdList);
if (ygsAddlist != null && !ygsAddlist.isEmpty()) {
this.doPushSocialAndLogYgs(socialSetMap, ygsAddlist, 1);
}
// 社保增员、社保减员、医保增员、医保减员
// 养工失新增列表
List<SociaFriendYgsAddVo> ygsAddlist = baseMapper.getSocialSoldierYgsAddVoList(dispatchIdList);
if (ygsAddlist != null && !ygsAddlist.isEmpty()) {
this.doPushSocialAndLogYgs(socialSetMap, ygsAddlist, 1);
}
// 养工失减少列表
List<SociaFriendYgsAddVo> ygsReducelist = baseMapper.getSocialSoldierYgsReduceVoList(dispatchIdList);
if (ygsReducelist != null && !ygsReducelist.isEmpty()) {
this.doPushSocialAndLogYgs(socialSetMap, ygsReducelist, 2);
}
// 医生大新增列表
List<SociaFriendYgsAddVo> ysdAddlist = baseMapper.getSocialSoldierYsdAddVoList(dispatchIdList);
if (ysdAddlist != null && !ysdAddlist.isEmpty()) {
this.doPushSocialAndLogYsd(socialSetMap, ysdAddlist, 3);
}
// 医生大减少列表
List<SociaFriendYgsAddVo> ysdReducelist = baseMapper.getSocialSoldierYsdReduceVoList(dispatchIdList);
if (ysdReducelist != null && !ysdReducelist.isEmpty()) {
this.doPushSocialAndLogYsd(socialSetMap, ysdReducelist, 4);
}
if ((ygsAddlist == null || ygsAddlist.isEmpty())
&& (ygsReducelist == null || ygsReducelist.isEmpty())
&& (ysdAddlist == null || ysdAddlist.isEmpty())
&& (ysdReducelist == null || ysdReducelist.isEmpty())
) {
return R.failed("无数据,推送结束!");
// 养工失减少列表
List<SociaFriendYgsAddVo> ygsReducelist = baseMapper.getSocialSoldierYgsReduceVoList(dispatchIdList);
if (ygsReducelist != null && !ygsReducelist.isEmpty()) {
this.doPushSocialAndLogYgs(socialSetMap, ygsReducelist, 2);
}
// 医生大新增列表
List<SociaFriendYgsAddVo> ysdAddlist = baseMapper.getSocialSoldierYsdAddVoList(dispatchIdList);
if (ysdAddlist != null && !ysdAddlist.isEmpty()) {
this.doPushSocialAndLogYsd(socialSetMap, ysdAddlist, 3);
}
// 医生大减少列表
List<SociaFriendYgsAddVo> ysdReducelist = baseMapper.getSocialSoldierYsdReduceVoList(dispatchIdList);
if (ysdReducelist != null && !ysdReducelist.isEmpty()) {
this.doPushSocialAndLogYsd(socialSetMap, ysdReducelist, 4);
}
if ((ygsAddlist == null || ygsAddlist.isEmpty())
&& (ygsReducelist == null || ygsReducelist.isEmpty())
&& (ysdAddlist == null || ysdAddlist.isEmpty())
&& (ysdReducelist == null || ysdReducelist.isEmpty())
) {
return R.failed("无数据,推送结束!");
}
}
} finally {
atomicPushFriend.decrementAndGet();
}
return R.ok();
} else {
atomicPushFriend.decrementAndGet();
return R.failed("距离上一次推送任务时间间隔太短,请10分钟后再试!!!");
}
return R.ok("推送成功!!");
}
/**
......
......@@ -23,6 +23,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.social.config.SocialFriendConfig;
import com.yifu.cloud.plus.v1.yifu.social.entity.*;
import com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFriendMapper;
......@@ -30,12 +31,16 @@ import com.yifu.cloud.plus.v1.yifu.social.service.*;
import com.yifu.cloud.plus.v1.yifu.social.vo.FriendResult;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 税友
......@@ -57,6 +62,18 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
private final TSocialSoldierLogService tSocialSoldierLogService;
private final TSocialFriendBackLogService tSocialFriendBackLogService;
private final TSocialFreindSetService tSocialFreindSetService;
private final AtomicInteger atomicGetFriend = new AtomicInteger(0);
/**
* @Description: 核心推送改为异步
* @Author: hgw
* @Date: 2025/3/18 10:52
* @return: void
**/
@Async
@Override
public void getInfoByRequestIdByAsync() {
this.getInfoByRequestId();
}
/**
* @Description: 5 查看任务进度
......@@ -66,96 +83,105 @@ public class TSocialFriendServiceImpl extends ServiceImpl<TSocialFriendMapper, T
**/
@Override
public R<String> getInfoByRequestId() {
TSocialFreindSet set = tSocialFreindSetService.getById("1");
if (set != null && Common.isNotNull(set.getType()) && 1 == set.getType()) {
// true养工失 false 医生大
boolean typeFlag = true;
Set<String> dbAuthsSet = new HashSet<>();
Collection<? extends GrantedAuthority> authorities = AuthorityUtils
.createAuthorityList(dbAuthsSet.toArray(new String[0]));
YifuUser user = new YifuUser("1", 1L, "", "税友",
"税友", "0", SecurityConstants.BCRYPT + "123456",
"12345678911", true, true, true,
true,
"1", authorities, "1",
null, null,
null, null);
// 失败原因配置
Map<String, FailReasonConfig> errorMap = failReasonConfigService.getFailReasonMap();
// 获取所有需要反馈的任务id
List<TSocialInfo> socialList = tSocialInfoService.getSocialFriendYgsAll();
List<TSocialFriendBackLog> logList;
TSocialFriendBackLog backLog;
FriendResult info;
List<FriendResult> resultList;
Map<String, FriendResult> resultMap;
if (socialList != null && !socialList.isEmpty()) {
logList = new ArrayList<>();
resultMap = new HashMap<>();
for (TSocialInfo socialInfo : socialList) {
backLog = new TSocialFriendBackLog();
backLog.setSocialId(socialInfo.getId());
backLog.setRequestId(socialInfo.getYgsRequestId());
backLog.setType(1);
if (Common.isNotNull(socialInfo.getDispatchType()) && CommonConstants.ONE_STRING.equals(socialInfo.getDispatchType())) {
backLog.setType(2);
}
info = resultMap.get(socialInfo.getEmpIdcard());
if (info == null) {
resultList = socialFriendConfig.getFriendByRequestId(restTemplate, socialInfo.getYgsRequestId()
, backLog, socialInfo.getDispatchType());
if (resultList != null && !resultList.isEmpty()) {
for (FriendResult result : resultList) {
resultMap.put(result.getIdCard(), result);
if (atomicGetFriend.incrementAndGet() <= 1) {
try {
TSocialFreindSet set = tSocialFreindSetService.getById("1");
if (set != null && Common.isNotNull(set.getType()) && 1 == set.getType()) {
// true养工失 false 医生大
boolean typeFlag = true;
Set<String> dbAuthsSet = new HashSet<>();
Collection<? extends GrantedAuthority> authorities = AuthorityUtils
.createAuthorityList(dbAuthsSet.toArray(new String[0]));
YifuUser user = new YifuUser("1", 1L, "", "税友",
"税友", "0", SecurityConstants.BCRYPT + "123456",
"12345678911", true, true, true,
true,
"1", authorities, "1",
null, null,
null, null);
// 失败原因配置
Map<String, FailReasonConfig> errorMap = failReasonConfigService.getFailReasonMap();
// 获取所有需要反馈的任务id
List<TSocialInfo> socialList = tSocialInfoService.getSocialFriendYgsAll();
List<TSocialFriendBackLog> logList;
TSocialFriendBackLog backLog;
FriendResult info;
List<FriendResult> resultList;
Map<String, FriendResult> resultMap;
if (socialList != null && !socialList.isEmpty()) {
logList = new ArrayList<>();
resultMap = new HashMap<>();
for (TSocialInfo socialInfo : socialList) {
backLog = new TSocialFriendBackLog();
backLog.setSocialId(socialInfo.getId());
backLog.setRequestId(socialInfo.getYgsRequestId());
backLog.setType(1);
if (Common.isNotNull(socialInfo.getDispatchType()) && CommonConstants.ONE_STRING.equals(socialInfo.getDispatchType())) {
backLog.setType(2);
}
info = resultMap.get(socialInfo.getEmpIdcard());
if (info == null) {
resultList = socialFriendConfig.getFriendByRequestId(restTemplate, socialInfo.getYgsRequestId()
, backLog, socialInfo.getDispatchType());
if (resultList != null && !resultList.isEmpty()) {
for (FriendResult result : resultList) {
resultMap.put(result.getIdCard(), result);
}
info = resultMap.get(socialInfo.getEmpIdcard());
}
}
logList.add(backLog);
if (info != null && Common.isNotNull(info.getZt())) {
doCore(info, socialInfo, typeFlag, user, errorMap);
}
}
if (!logList.isEmpty()) {
tSocialFriendBackLogService.saveBatch(logList);
}
}
logList.add(backLog);
if (info != null && Common.isNotNull(info.getZt())) {
doCore(info, socialInfo, typeFlag, user, errorMap);
}
}
if (!logList.isEmpty()) {
tSocialFriendBackLogService.saveBatch(logList);
}
}
// 医保
typeFlag = false;
List<TSocialInfo> socialYsdList = tSocialInfoService.getSocialFriendYsdAll();
if (socialYsdList != null && !socialYsdList.isEmpty()) {
logList = new ArrayList<>();
resultMap = new HashMap<>();
for (TSocialInfo socialInfo : socialYsdList) {
backLog = new TSocialFriendBackLog();
backLog.setSocialId(socialInfo.getId());
backLog.setRequestId(socialInfo.getYsdRequestId());
backLog.setType(3);
if (Common.isNotNull(socialInfo.getDispatchType()) && CommonConstants.ONE_STRING.equals(socialInfo.getDispatchType())) {
backLog.setType(4);
}
info = resultMap.get(socialInfo.getEmpIdcard());
if (info == null) {
resultList = socialFriendConfig.getFriendByRequestId(restTemplate, socialInfo.getYsdRequestId()
, backLog, socialInfo.getDispatchType());
if (resultList != null && !resultList.isEmpty()) {
for (FriendResult result : resultList) {
resultMap.put(result.getIdCard(), result);
// 医保
typeFlag = false;
List<TSocialInfo> socialYsdList = tSocialInfoService.getSocialFriendYsdAll();
if (socialYsdList != null && !socialYsdList.isEmpty()) {
logList = new ArrayList<>();
resultMap = new HashMap<>();
for (TSocialInfo socialInfo : socialYsdList) {
backLog = new TSocialFriendBackLog();
backLog.setSocialId(socialInfo.getId());
backLog.setRequestId(socialInfo.getYsdRequestId());
backLog.setType(3);
if (Common.isNotNull(socialInfo.getDispatchType()) && CommonConstants.ONE_STRING.equals(socialInfo.getDispatchType())) {
backLog.setType(4);
}
info = resultMap.get(socialInfo.getEmpIdcard());
if (info == null) {
resultList = socialFriendConfig.getFriendByRequestId(restTemplate, socialInfo.getYsdRequestId()
, backLog, socialInfo.getDispatchType());
if (resultList != null && !resultList.isEmpty()) {
for (FriendResult result : resultList) {
resultMap.put(result.getIdCard(), result);
}
info = resultMap.get(socialInfo.getEmpIdcard());
}
}
logList.add(backLog);
if (info != null && Common.isNotNull(info.getZt())) {
doCore(info, socialInfo, typeFlag, user, errorMap);
}
}
if (!logList.isEmpty()) {
tSocialFriendBackLogService.saveBatch(logList);
}
}
logList.add(backLog);
if (info != null && Common.isNotNull(info.getZt())) {
doCore(info, socialInfo, typeFlag, user, errorMap);
}
}
if (!logList.isEmpty()) {
tSocialFriendBackLogService.saveBatch(logList);
}
} finally {
atomicGetFriend.decrementAndGet();
}
return R.ok();
} else {
atomicGetFriend.decrementAndGet();
return R.failed("距离上一次获取任务时间间隔太短,请10分钟后再试!!!");
}
return R.ok();
}
/**
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.TSocialFreindPushAndGetMapper">
<resultMap id="tSocialFreindPushAndGetMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFreindPushAndGet">
<id property="id" column="ID"/>
<result property="type" column="TYPE"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="createUserName" column="CREATE_USER_NAME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.TYPE,
a.CREATE_TIME,
a.CREATE_USER_NAME
</sql>
<sql id="tSocialFreindPushAndGet_where">
<if test="tSocialFreindPushAndGet != null">
<if test="tSocialFreindPushAndGet.id != null and tSocialFreindPushAndGet.id.trim() != ''">
AND a.ID = #{tSocialFreindPushAndGet.id}
</if>
<if test="tSocialFreindPushAndGet.type != null">
AND a.TYPE = #{tSocialFreindPushAndGet.type}
</if>
<if test="tSocialFreindPushAndGet.createTime != null">
AND a.CREATE_TIME = #{tSocialFreindPushAndGet.createTime}
</if>
<if test="tSocialFreindPushAndGet.createUserName != null and tSocialFreindPushAndGet.createUserName.trim() != ''">
AND a.CREATE_USER_NAME = #{tSocialFreindPushAndGet.createUserName}
</if>
</if>
</sql>
<!--获取当前类型最大的时间,用来判断10分钟内是否有操作过-->
<select id="getMaxTimeByType" resultType="java.time.LocalDateTime">
SELECT
max(a.CREATE_TIME)
FROM t_social_freind_push_and_get a
where a.TYPE = #{type}
</select>
</mapper>
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