Commit e024d474 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/MVP1.5.2' into MVP1.5.2

parents 770e03f4 a94cd822
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId> <artifactId>yifu-common-log</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId>
<version>3.6.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.yifu.cloud.plus.v1.yifu.auth.config;
import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;
import org.jasig.cas.client.util.HttpServletRequestWrapperFilter;
import org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.*;
@Configuration
@Component
public class CASAutoConfig {
/**
* SingleSignOutHttpSessionListener 添加监听器
* 用于单点退出,该过滤器用于实现单点登出功能,可选配置
*
* @author licancan
* @param
* @return {@link ServletListenerRegistrationBean<EventListener>}
*/
@Bean
public ServletListenerRegistrationBean<EventListener> singleSignOutListenerRegistration() {
ServletListenerRegistrationBean<EventListener> registrationBean = new ServletListenerRegistrationBean<EventListener>();
registrationBean.setListener(new SingleSignOutHttpSessionListener());
registrationBean.setOrder(1);
return registrationBean;
}
/**
* SingleSignOutFilter 登出过滤器
* 该过滤器用于实现单点登出功能,可选配置
*
* @author licancan
* @param
* @return {@link FilterRegistrationBean}
*/
@Bean
public FilterRegistrationBean filterSingleRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new SingleSignOutFilter());
// 设定匹配的路径
registration.addUrlPatterns("/*");
Map<String, String> initParameters = new HashMap();
initParameters.put("casServerUrlPrefix", CASproperties.CAS_SERVER_LOGIN_PATH);
registration.setInitParameters(initParameters);
// 设定加载的顺序
registration.setOrder(2);
return registration;
}
/**
* AuthenticationFilter 授权过滤器
*
* @author licancan
* @param
* @return {@link FilterRegistrationBean}
*/
@Bean
public FilterRegistrationBean filterAuthenticationRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
Map<String, String> initParameters = new HashMap();
registration.setFilter(new AuthenticationFilter());
//registration.addUrlPatterns("*.html");
initParameters.put("casServerLoginUrl", CASproperties.CAS_SERVER_PATH);
initParameters.put("serverName", CASproperties.CLIENT_SERVER_NAME);
// 不拦截的请求
initParameters.put("ignorePattern", "^.*[.](js|css|gif|png|zip)$");
// 表示过滤所有
initParameters.put("ignoreUrlPatternType", "com.yifu.cloud.plus.v1.yifu.auth.filter.SimpleUrlPatternMatcherStrategy");
registration.setInitParameters(initParameters);
// 设定加载的顺序
registration.setOrder(3);
return registration;
}
/**
* Cas30ProxyReceivingTicketValidationFilter 验证过滤器
* 该过滤器负责对Ticket的校验工作,必须启用它
*
* @author licancan
* @param
* @return {@link FilterRegistrationBean}
*/
@Bean
public FilterRegistrationBean filterValidationRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new Cas30ProxyReceivingTicketValidationFilter());
// 设定匹配的路径
//registration.addUrlPatterns("*.html");
Map<String, String> initParameters = new HashMap();
initParameters.put("casServerUrlPrefix", CASproperties.CAS_SERVER_PATH);
initParameters.put("serverName", CASproperties.CLIENT_SERVER_NAME);
// 是否对serviceUrl进行编码,默认true:设置false可以在302对URL跳转时取消显示;jsessionid=xxx的字符串
// 观察CommonUtils.constructServiceUrl方法可以看到
//initParameters.put("encodeServiceUrl", "false");
registration.setInitParameters(initParameters);
// 设定加载的顺序
registration.setOrder(4);
return registration;
}
/**
* 该过滤器用于单点登录功能 ,对HttpServletRequest请求包装, 可通过HttpServletRequest的getRemoteUser()方法获得登录用户的登录名
* @return
*/
@Bean
public FilterRegistrationBean casHttpServletRequestWrapperFilter(){
FilterRegistrationBean authenticationFilter = new FilterRegistrationBean();
authenticationFilter.setFilter(new HttpServletRequestWrapperFilter());
authenticationFilter.setOrder(5);
List<String> urlPatterns = new ArrayList<>();
urlPatterns.add("/*");
authenticationFilter.setUrlPatterns(urlPatterns);
return authenticationFilter;
}
/**
* HttpServletRequestWrapperFilter wraper过滤器
* 该过滤器负责实现HttpServletRequest请求的包裹,
* 比如允许开发者通过HttpServletRequest的getRemoteUser()方法获得SSO登录用户的登录名,可选配置。
*
* @author licancan
* @param
* @return {@link FilterRegistrationBean}
*/
@Bean
public FilterRegistrationBean filterWrapperRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new HttpServletRequestWrapperFilter());
// 设定匹配的路径
registration.addUrlPatterns("/*");
// 设定加载的顺序
registration.setOrder(6);
return registration;
}
}
package com.yifu.cloud.plus.v1.yifu.auth.config;
public class CASproperties {
/**
* 当前应用程序的baseUrl(注意最后面的斜线)
*/
public static String CLIENT_SERVER_NAME = "http://127.0.0.1:8888/";
/**
* 当前应用程序的登陆界面
*/
public static String CLIENT_LOGIN_PAGE = "http://127.0.0.1:8888/login";
/**
* CAS服务器地址
*/
public static String CAS_SERVER_PATH = "http://192.168.1.62:8443/cas";
/**
* CAS登陆服务器地址
*/
public static String CAS_SERVER_LOGIN_PATH = "http://192.168.1.62:8443/cas/login";
/**
* CAS登出服务器地址
*/
public static String CAS_SERVER_LOGOUT_PATH = "http://192.168.1.62:8443/cas/logout";
}
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.yifu.cloud.plus.v1.yifu.auth.controller;
import com.yifu.cloud.plus.v1.yifu.auth.config.CASproperties;
import com.yifu.cloud.plus.v1.yifu.auth.util.LoginUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.logging.Logger;
/**
* @author huyc
* @since 1.6.0
*/
@RequiredArgsConstructor
@RestController
@RequestMapping("/auth")
public class AuthController {
private static final Logger LOG = Logger.getLogger(AuthController.class.getName());
@PostMapping("/login")
public String login(HttpServletRequest request, String username, String password) {
return null;
}
@PostMapping(value = "/logout")
public void logout(HttpServletRequest request) {
request.getSession().invalidate();
}
@PostMapping(value = "/check")
public String check(HttpServletRequest request, String username, String password) {
String st = LoginUtils.getTicket(CASproperties.CAS_SERVER_LOGOUT_PATH,username,password,CASproperties.CLIENT_LOGIN_PAGE);
LOG.info(st);
return st;
}
}
package com.yifu.cloud.plus.v1.yifu.auth.filter;
import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy;
import java.util.Arrays;
import java.util.List;
public class SimpleUrlPatternMatcherStrategy implements UrlPatternMatcherStrategy {
/**
* 判断是否匹配这个字符串
*
* @author licancan
* @param url 用户请求的连接
* @return {@link boolean} true:不拦截 false:必须得登录了
*/
@Override
public boolean matches(String url) {
List<String> list = Arrays.asList(
"/login",
"/restLogin"
);
String name = url.substring(url.lastIndexOf("/"));
// String url = "http://127.0.0.1:8082/login?service=http%3A%2F%2F127.0.0.1%3A8082%2Fb";
// 为了防止出现匹配中,忽略了后续参数的URL,出现比如:/login?service=http%3A%2F%2F127.0.0.1%3A8082%2Fb 现象
// 这种现象,会导致重定向过多异常,所以,不管什么url,只取出请求的最终 /login 即可
if (name.indexOf("?") != -1) {
name = name.substring(0, name.indexOf("?"));
}
boolean result = list.contains(name);
if (!result) {
System.out.println("拦截URL:" + url);
}
return result;
}
/**
* 正则表达式的规则,这个地方可以是web传递过来的
*
* @author licancan
* @param pattern
* @return void
*/
@Override
public void setPattern(String pattern) {
System.out.println(11111);
}
}
package com.yifu.cloud.plus.v1.yifu.auth.util;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.logging.Logger;
public class LoginUtils {
private static final Logger LOG = Logger.getLogger(LoginUtils.class.getName());
/**
* 登录
*
* @author licancan
* @param server cas服务端获取tgt地址
* @param username 用户名
* @param password 密码
* @param service 需要跳转的应用地址
* @return {@link String}
*/
public static String getTicket(final String server, final String username, final String password, final String service) {
//重定向
return getServiceTicket(server, getTicketGrantingTicket(server, username, password), service);
}
/**
* 获取ST
*
* @author licancan
* @param server cas服务端获取tgt地址
* @param ticketGrantingTicket tgt
* @param service 需要跳转的应用地址
* @return {@link String}
*/
private static String getServiceTicket(final String server, final String ticketGrantingTicket, final String service) {
if (ticketGrantingTicket == null){
return null;
}
try {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("service",service);
HttpEntity<MultiValueMap<String,Object>> entity = new HttpEntity<>(wholeForm,headers);
ResponseEntity<String> obj = restTemplate.exchange(server + "/" + ticketGrantingTicket, HttpMethod.POST, entity, String.class);
switch (obj.getStatusCode().value()) {
case 200:
LOG.info("Successful service ticket request: " + obj.getBody());
return obj.getBody();
default:
LOG.warning("Invalid response code (" + obj.getStatusCode().value() + ") from CAS server!");
LOG.info("Response (1k): " + obj.getBody());
break;
}
} catch (Exception e) {
LOG.warning(e.getMessage());
}
return null;
}
/**
* 获取 TGT
*
* @author licancan
* @param server cas服务端获取tgt地址
* @param username 用户名
* @param password 密码
* @return {@link String}
*/
private static String getTicketGrantingTicket(final String server, final String username, final String password) {
try {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String,Object> wholeForm = new LinkedMultiValueMap<>();
wholeForm.add("username",username);
wholeForm.add("password",password);
HttpEntity<MultiValueMap<String,Object>> entity = new HttpEntity<>(wholeForm,headers);
ResponseEntity<String> obj = restTemplate.exchange(server, HttpMethod.POST, entity, String.class);
switch (obj.getStatusCode().value()) {
case 201:
LOG.info("Successful ticket granting ticket request: " + obj.getBody());
return obj.getBody();
default:
LOG.warning("Invalid response code (" + obj.getStatusCode().value() + ") from CAS server!");
LOG.info("Response (1k): " + obj.getBody());
break;
}
} catch (Exception e) {
LOG.warning(e.getMessage());
}
return null;
}
}
...@@ -19,6 +19,6 @@ public class ResultConstants { ...@@ -19,6 +19,6 @@ public class ResultConstants {
public static final String REQUEST_LOCK_FAIL = "获取锁失败"; public static final String REQUEST_LOCK_FAIL = "获取锁失败";
public static final String DATA_IMPORT_PARSING_RESULT = "数据导入解析!数据行数:"; public static final String DATA_IMPORT_PARSING_RESULT = "数据导入解析!数据行数:";
public static final String NO_SELECT_DATA = "请选择数据"; public static final String NO_SELECT_DATA = "请选择数据";
public static final String NO_GETLOCK_DATA = "获取锁失败,10秒后重试!"; public static final String NO_GETLOCK_DATA = "当前用户操作处理中,请稍后重试!";
public static final String NO_ID = "操作失败,id不能为空!"; public static final String NO_ID = "操作失败,id不能为空!";
} }
...@@ -328,7 +328,12 @@ public class TDispatchInfoController { ...@@ -328,7 +328,12 @@ public class TDispatchInfoController {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
try { try {
return tDispatchInfoService.importDiy(file.getInputStream(),orderId); if (Common.isNotNull(requestId)) {
//主动释放锁
return tDispatchInfoService.importDiy(file.getInputStream(),orderId);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally { }finally {
//主动释放锁 //主动释放锁
RedisDistributedLock.unlock(key, requestId); RedisDistributedLock.unlock(key, requestId);
...@@ -410,7 +415,12 @@ public class TDispatchInfoController { ...@@ -410,7 +415,12 @@ public class TDispatchInfoController {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
try { try {
return tDispatchInfoService.importReduceDiy(file.getInputStream(),orderId); if (Common.isNotNull(requestId)) {
//主动释放锁
return tDispatchInfoService.importReduceDiy(file.getInputStream(),orderId);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally { }finally {
//主动释放锁 //主动释放锁
RedisDistributedLock.unlock(key, requestId); RedisDistributedLock.unlock(key, requestId);
......
...@@ -168,7 +168,11 @@ public class TPaymentInfoController { ...@@ -168,7 +168,11 @@ public class TPaymentInfoController {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
try { try {
return tPaymentInfoService.importSocialDiy(file.getInputStream()); if (Common.isNotNull(requestId)) {
return tPaymentInfoService.importSocialDiy(file.getInputStream());
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally { }finally {
//主动释放锁 //主动释放锁
RedisDistributedLock.unlock(key, requestId); RedisDistributedLock.unlock(key, requestId);
...@@ -200,7 +204,11 @@ public class TPaymentInfoController { ...@@ -200,7 +204,11 @@ public class TPaymentInfoController {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
try { try {
return tPaymentInfoService.importSocialHeFeiDiy(file.getInputStream(), random, type); if (Common.isNotNull(requestId)) {
return tPaymentInfoService.importSocialHeFeiDiy(file.getInputStream(), random, type);
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally { }finally {
//主动释放锁 //主动释放锁
RedisDistributedLock.unlock(key, requestId); RedisDistributedLock.unlock(key, requestId);
...@@ -232,7 +240,11 @@ public class TPaymentInfoController { ...@@ -232,7 +240,11 @@ public class TPaymentInfoController {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
try { try {
return tPaymentInfoService.batchImportPaymentFundInfo(file.getInputStream()); if (Common.isNotNull(requestId)) {
return tPaymentInfoService.batchImportPaymentFundInfo(file.getInputStream());
} else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}finally { }finally {
//主动释放锁 //主动释放锁
RedisDistributedLock.unlock(key, requestId); RedisDistributedLock.unlock(key, requestId);
......
...@@ -250,34 +250,38 @@ public class TPreDispatchInfoController { ...@@ -250,34 +250,38 @@ public class TPreDispatchInfoController {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage()); throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
} }
ExcelUtil<TPreDispatchInfo> util1 = null; if (Common.isNotNull(requestId)) {
try { ExcelUtil<TPreDispatchInfo> util1 = null;
jsonString = URLDecoder.decode(jsonString, CommonConstants.UTF8).replace("=", ""); try {
util1 = new ExcelUtil<>(TPreDispatchInfo.class); jsonString = URLDecoder.decode(jsonString, CommonConstants.UTF8).replace("=", "");
util1.getJsonStringToList(jsonString, null); util1 = new ExcelUtil<>(TPreDispatchInfo.class);
List<TPreDispatchInfo> listInfo = util1.getEntityList(); util1.getJsonStringToList(jsonString, null);
//用于返回错误信息 List<TPreDispatchInfo> listInfo = util1.getEntityList();
List<ErrorMessage> errorInfo = new ArrayList<>(); //用于返回错误信息
if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) { List<ErrorMessage> errorInfo = new ArrayList<>();
for (ErrorMessage errorMessage: util1.getErrorInfo()) { if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) {
errorInfo.add(errorMessage); for (ErrorMessage errorMessage: util1.getErrorInfo()) {
errorInfo.add(errorMessage);
}
} }
if (null != listInfo && !listInfo.isEmpty()) {
errorInfo = tPreDispatchInfoService.batchSavePreDisPatchAdd(listInfo, user,socialHouse,fundHouse,
departId,errorInfo);
} else {
errorInfo.add(new ErrorMessage(null, CommonConstants.DATA_CAN_NOT_EMPTY));
}
List<ErrorMessage> newErrorList = errorInfo.stream().sorted(Comparator.comparing(ErrorMessage::getLineNum))
.collect(Collectors.toList());
return R.ok(newErrorList);
} catch (Exception e) {
e.printStackTrace();
return R.failed(PreDispatchConstants.DATA_IMPORT_ANALYSIS_ERROR);
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
} }
if (null != listInfo && !listInfo.isEmpty()) { } else {
errorInfo = tPreDispatchInfoService.batchSavePreDisPatchAdd(listInfo, user,socialHouse,fundHouse, return R.failed(ResultConstants.NO_GETLOCK_DATA);
departId,errorInfo);
} else {
errorInfo.add(new ErrorMessage(null, CommonConstants.DATA_CAN_NOT_EMPTY));
}
List<ErrorMessage> newErrorList = errorInfo.stream().sorted(Comparator.comparing(ErrorMessage::getLineNum))
.collect(Collectors.toList());
return R.ok(newErrorList);
} catch (Exception e) {
e.printStackTrace();
return R.failed(PreDispatchConstants.DATA_IMPORT_ANALYSIS_ERROR);
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
} }
} }
......
...@@ -38,7 +38,9 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo; ...@@ -38,7 +38,9 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.ErrorDetailVO; import com.yifu.cloud.plus.v1.yifu.common.core.vo.ErrorDetailVO;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
...@@ -270,7 +272,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -270,7 +272,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override @Override
public R<Boolean> removeInFoById(String id) { public R<Boolean> removeInFoById(String id) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CacheConstants.PAYMENT_SOCIAL_PUSH; String key = CacheConstants.PAYMENT_SOCIAL_PUSH + CommonConstants.DOWN_LINE_STRING +user.getId() ;
if (Common.isNotNull(redisUtil.get(key))) { if (Common.isNotNull(redisUtil.get(key))) {
return R.failed("用户正在推送实缴数据中禁止删除!"); return R.failed("用户正在推送实缴数据中禁止删除!");
} }
...@@ -298,7 +300,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -298,7 +300,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return R.failed(CommonConstants.NO_DATA_TO_HANDLE); return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
} }
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CacheConstants.PAYMENT_SOCIAL_PUSH; String key = CacheConstants.PAYMENT_SOCIAL_PUSH + CommonConstants.DOWN_LINE_STRING +user.getId() ;
if (Common.isNotNull(redisUtil.get(key))) { if (Common.isNotNull(redisUtil.get(key))) {
return R.failed("用户正在推送实缴数据中禁止删除!"); return R.failed("用户正在推送实缴数据中禁止删除!");
} }
...@@ -340,7 +342,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -340,7 +342,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
String socialCreateMonth, String socialPayMonth) { String socialCreateMonth, String socialPayMonth) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CacheConstants.PAYMENT_SOCIAL_PUSH; String key = CacheConstants.PAYMENT_SOCIAL_PUSH + CommonConstants.DOWN_LINE_STRING +user.getId() ;
if (Common.isNotNull(redisUtil.get(key))) { if (Common.isNotNull(redisUtil.get(key))) {
return R.failed("用户正在推送实缴数据中禁止删除!"); return R.failed("用户正在推送实缴数据中禁止删除!");
} }
...@@ -2814,31 +2816,43 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa ...@@ -2814,31 +2816,43 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override @Override
public R<Boolean> pushPaymentSocialFundInfo(TPaymentInfoSearchVo searchVo) { public R<Boolean> pushPaymentSocialFundInfo(TPaymentInfoSearchVo searchVo) {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
String key = user.getId() + CommonConstants.DOWN_LINE_STRING + CacheConstants.PAYMENT_SOCIAL_PUSH; String key = CacheConstants.PAYMENT_SOCIAL_PUSH + CommonConstants.DOWN_LINE_STRING +user.getId() ;
if (Common.isNotNull(redisUtil.get(key))) { if (Common.isNotNull(redisUtil.get(key))) {
return R.failed("用户正在推送实缴数据中,禁止重复推送!"); return R.failed("用户正在推送实缴数据中,禁止重复推送!");
} else { } else {
redisUtil.set(key, user.getId(), 1200L); redisUtil.set(key, user.getId(), 1200L);
} }
// 获取redis分布式事务锁
Map<String, TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap(); String requestId;
//手动推送未推送的社保公积金明细数据 try {
createPaymentSocialInfoReal(user, searchVo, mapSelectVo); requestId = RedisDistributedLock.getLock(key,"10");
createPaymentFundInfoReal(user, searchVo, mapSelectVo); } catch (Exception e) {
//推送社保公积金收入数据 throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
String redisKey = String.valueOf(UUID.randomUUID()).replaceAll("-", "") + "_incomePush"; }
createPaymentInfoIncomeReal(user, searchVo, mapSelectVo, redisKey); if (Common.isNotNull(requestId)) {
createPaymentFundIncomeReal(user, searchVo, mapSelectVo, redisKey); Map<String, TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
//推送失败的数据重新推送 //手动推送未推送的社保公积金明细数据
if (Common.isNotNull(redisUtil.get(redisKey))) { createPaymentSocialInfoReal(user, searchVo, mapSelectVo);
List<TIncome> list = (List<TIncome>) redisUtil.get(redisKey); createPaymentFundInfoReal(user, searchVo, mapSelectVo);
for (TIncome income : list) { //推送社保公积金收入数据
doJointSocialTask.asynchronousEkpIncomePaymentT(income); String redisKey = String.valueOf(UUID.randomUUID()).replaceAll("-", "") + "_incomePush";
createPaymentInfoIncomeReal(user, searchVo, mapSelectVo, redisKey);
createPaymentFundIncomeReal(user, searchVo, mapSelectVo, redisKey);
//推送失败的数据重新推送
if (Common.isNotNull(redisUtil.get(redisKey))) {
List<TIncome> list = (List<TIncome>) redisUtil.get(redisKey);
for (TIncome income : list) {
doJointSocialTask.asynchronousEkpIncomePaymentT(income);
}
redisUtil.remove(redisKey);
} }
redisUtil.remove(redisKey); redisUtil.remove(key);
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
return R.ok();
}else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
} }
redisUtil.remove(key);
return R.ok();
} }
@Override @Override
......
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