Commit d2a2ec6e by ddx

增加批量解锁功能

parent 1e0b33cf
package com.yxcheng.token.common.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InvoiceFileTaxBatchManageFunctionReq implements Serializable {
private static final long serialVersionUID = 191691175092676420L;
private String zoneCode;
private String taxno;
}
package com.yxcheng.token.common.model;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InvoiceFileTaxBatchManageReq implements Serializable {
private static final long serialVersionUID = 191691175092676480L;
private String userCode;
private String errorCode;
private List<InvoiceFileTaxBatchManageFunctionReq> functionList;
}
......@@ -82,6 +82,8 @@ public class TaxUserInfo {
private String serNo = "";
private String etaxType = "";
@Override
public String toString() {
return "TaxUserInfo{" +
......
package com.yxcheng.token.common.model;
import lombok.*;
/**
* @ProjectName: tax-sys-nacos
* @Package: com.yxcheng.token.common.model
* @ClassName: TokenInfo
* @Author: ddx
* @Description:
* @Date: 2024-02-01 21:21
* @Version: 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TokenInfo {
private String taxno;
private String zoneCode;
}
package com.tax.file.model;
import com.yxcheng.token.common.model.MqMessage;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
@Getter
@Setter
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InvoiceFileTaxManageFunctionReq implements MqMessage {
private String optType;//操作类型 0-增加 1-删除 2-开启 3-停用
......@@ -16,6 +17,15 @@ public class InvoiceFileTaxManageFunctionReq implements MqMessage {
private String initMonth;
private String invSpec;
public InvoiceFileTaxManageFunctionReq(String optType, String functionNo) {
this.optType = optType;
this.functionNo = functionNo;
this.validType = "0";
this.bussinessType = "1";
this.keyType = "0";
this.initMonth = "1";
}
@Override
public String toString() {
return "InvoiceFileTaxManageFunctionReq [optType=" + optType + ", functionNo=" + functionNo + ", validType="
......
......@@ -3,14 +3,15 @@ package com.tax.file.model;
import com.yxcheng.token.common.model.MqMessage;
import com.yxcheng.token.common.model.SafeModel;
import com.yxcheng.token.common.model.TaxUserInfo;
import lombok.Getter;
import lombok.Setter;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Getter
@Setter
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class InvoiceFileTaxManageReq extends SafeModel implements MqMessage {
private String taxno;
private String zoneCode;
......
package com.tax.file.integration.token;
import com.yxcheng.token.common.model.CrRpcResult;
import com.yxcheng.token.common.model.SafeModel;
import com.yxcheng.token.common.model.TokenInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name="taxsys-token")
@Service
public interface TokenClient {
@RequestMapping(value ="/client/selectTokenListByErrorCode" , method = RequestMethod.POST, consumes = {"application/json;charset=UTF-8"})
public List<TokenInfo> selectTokenListByErrorCode(@RequestParam(value="userCode",required = true)String userCode,
@RequestParam(value="errorCode",required = true)String errorCode);
}
package com.tax.file.service.api;
import com.tax.file.model.InvoiceFileReq;
import com.yxcheng.token.common.model.InvoiceFileTaxBatchManageReq;
import com.tax.file.model.InvoiceFileTaxManageReq;
import com.tax.file.model.TkTaxUser;
import com.tax.file.model.fileManage.ApplyFileReq;
......@@ -82,4 +83,6 @@ public interface InvoiceFileService {
JsonResult<Map> queryErrorFileList(String uuidFlag, TkTaxUser taxUser, QueryFileReqModel queryFileReqModel);
JsonResult<Map> handApplyMonthFile(String uuidFlag, TkTaxUser taxUser, ApplyMonthFileReq applyMonthFileReq);
JsonResult<String> batchTaxManage(InvoiceFileTaxBatchManageReq invoiceFileTaxBatchManageReq);
}
......@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.tax.file.constants.FileConstants;
import com.tax.file.integration.token.TokenClient;
import com.tax.file.model.*;
import com.tax.file.model.fileManage.*;
import com.tax.file.service.api.*;
......@@ -13,7 +14,9 @@ import com.tax.file.utils.CommonUtil;
import com.tax.file.utils.ExpCacheUtils;
import com.yxcheng.token.common.cache.RedisService;
import com.yxcheng.token.common.enumutil.ResultEnum;
import com.yxcheng.token.common.model.InvoiceFileTaxBatchManageReq;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.common.model.TokenInfo;
import com.yxcheng.token.constants.HttpRedisContants;
import com.yxcheng.token.constants.RedisContants;
import com.yxcheng.token.utils.*;
......@@ -63,6 +66,8 @@ public class InvoiceFileServiceImpl implements InvoiceFileService {
private FileUserLogService fileUserLogService;
@Autowired
private FileApplyLogServiceImpl fileApplyLogServiceImpl;
@Autowired
private TokenClient tokenClient;
/**
* 发票文件下载
......@@ -1184,6 +1189,35 @@ public class InvoiceFileServiceImpl implements InvoiceFileService {
return jsonResult;
}
@Override
public JsonResult<String> batchTaxManage(InvoiceFileTaxBatchManageReq invoiceFileTaxBatchManageReq) {
JsonResult jsonResult = new JsonResult();
List<TokenInfo> errorTokenList = tokenClient.selectTokenListByErrorCode(invoiceFileTaxBatchManageReq.getUserCode(), invoiceFileTaxBatchManageReq.getErrorCode());
int rightNum = 0;
for(TokenInfo errorToken:errorTokenList) {
List<InvoiceFileTaxManageFunctionReq> functionList = Lists.newArrayList();
functionList.add(new InvoiceFileTaxManageFunctionReq("1","05"));
String uuidFlag = UUIDGenerator.generate();
InvoiceFileTaxManageReq invoiceFileReq = new InvoiceFileTaxManageReq();
invoiceFileReq.setTaxno(errorToken.getTaxno());
invoiceFileReq.setZoneCode(errorToken.getZoneCode());
invoiceFileReq.setFunctionList(functionList);
invoiceFileReq.setAccessKeyID(invoiceFileTaxBatchManageReq.getUserCode());
invoiceFileReq.setSignatureNonce(uuidFlag);
JsonResult<String> manageResult = taxManage(invoiceFileReq);
log.info(uuidFlag + "taxManage" + manageResult);
if(manageResult.isSuccess()) {
rightNum++;
}
}
jsonResult.setData(errorTokenList.size() + "=" + rightNum);
return jsonResult;
}
public Map createErrorResponseJson(String taskno, List<TkFile> invFileList) {
Map result = new HashMap();
List<InvoiceErrorFileRes> invoiceFiles = getFileErrorModel(invFileList);
......
......@@ -5,10 +5,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.tax.file.constants.CommonConstants;
import com.tax.file.integration.user.UserClient;
import com.tax.file.model.InvoiceApplyRes;
import com.tax.file.model.InvoiceFileReq;
import com.tax.file.model.InvoiceFileTaxManageReq;
import com.tax.file.model.TkTaxUser;
import com.tax.file.model.*;
import com.tax.file.model.fileManage.QueryFileReqModel;
import com.tax.file.service.api.InvoiceFileService;
import com.tax.file.service.api.TkUserUrlService;
......@@ -20,6 +17,7 @@ import com.yxcheng.token.common.annotation.RedisLimit;
import com.yxcheng.token.common.controller.BaseClientController;
import com.yxcheng.token.common.enumutil.ResultEnum;
import com.yxcheng.token.common.model.CrRpcResult;
import com.yxcheng.token.common.model.InvoiceFileTaxBatchManageReq;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.utils.ObjectUtil;
import com.yxcheng.token.utils.StringUtil;
......@@ -445,4 +443,22 @@ public class InvoiceFileController extends BaseClientController {
return new JsonResult().errorResponse(ResultEnum.system_error);
}
}
/**
* 税号批量管理接口
*
* @param invoiceFileTaxBatchManageReq
* @return
*/
@RequestMapping(value ="/batchTaxManage" , method = RequestMethod.POST)
@LogT(LogT.LOG_VIEW_PART)
public JsonResult<String> batchTaxManage(@RequestBody InvoiceFileTaxBatchManageReq invoiceFileTaxBatchManageReq){
try {
return invoiceFileService.batchTaxManage(invoiceFileTaxBatchManageReq);
} catch (Exception e) {
e.printStackTrace();
log.error("batchTaxManage系统异常:", e.getMessage());
return new JsonResult().errorResponse(ResultEnum.system_error);
}
}
}
......@@ -12,8 +12,8 @@ import java.util.Map;
public class FileManageTest {
String accessKeyID = "bwgf-limit";
static String accessKeySecret = "bw@2u9%5Ts#2";
// static String host = "http://127.0.0.1:8767";
static String host = "https://api.taxservices.cn";
static String host = "http://127.0.0.1:8767";
// static String host = "https://api.taxservices.cn";
// static String host = "http://60.205.138.54:8767";
@Test
public void testHandApplyFile() throws Exception{
......@@ -77,6 +77,18 @@ public class FileManageTest {
System.out.println(ret);
}
@Test
public void testBatchTaxManage() throws Exception {
String url = host + "/invoicefile/batchTaxManage";
Map param = new HashMap<>();
param.put("userCode","edaxiang");
param.put("errorCode","4042");
System.out.println(url);
String ret = HttpHelper.postWithJson(url,JSON.toJSONString(param));
System.out.println(ret);
}
public static String getSign(String data){
try {
return Security.getSignature(data.getBytes("UTF-8"),accessKeySecret.getBytes("UTF-8"));
......
......@@ -12,8 +12,8 @@ import org.springframework.stereotype.Component;
@Component
public class ZoneInfoJob implements SimpleJob {
// @Autowired
// private ZoneClient zoneClient;
@Autowired
private ZoneClient zoneClient;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -22,7 +22,7 @@ public class ZoneInfoJob implements SimpleJob {
public void execute(ShardingContext shardingContext) {
logger.info("ZoneInfoJob is start");
// zoneClient.findAllZoneList(new ZoneModel());
zoneClient.findAllZoneList(new ZoneModel());
logger.info("ZoneInfoJob is end");
}
......
......@@ -98,4 +98,6 @@ public interface TkTokenMapper {
List<TkToken> selectErrorTokenList(@Param("userCode") String userCode, @Param("id") Integer id, @Param("pageNum") Integer pageNum);
int updateTokenInfo(TkToken record);
List<TkToken> selectTokenListByErrorCode(@Param("userCode") String userCode, @Param("errorCode") String errorCode);
}
\ No newline at end of file
......@@ -537,4 +537,14 @@
is_valid = #{isValid,jdbcType=CHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectTokenListByErrorCode" resultMap="BaseResultMap">
SELECT
t.*
FROM
tk_token t
WHERE
t.user_code = #{userCode,jdbcType=VARCHAR}
and t.error_code = #{errorCode,jdbcType=VARCHAR}
AND t.is_valid = '0'
</select>
</mapper>
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.tax.token.service.api;
import com.tax.token.model.*;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.common.model.TaxUserInfo;
import com.yxcheng.token.common.model.TokenInfo;
import java.util.List;
......@@ -50,6 +51,8 @@ public interface TkTokenService {
JsonResult<String> queryTokenInfo(String optType, String userCode, String taxno);
List<TokenInfo> selectTokenListByErrorCode(String userCode, String errorCode);
boolean checkTokenRealRequestCount(String userCode, String taxno);
int getTokenRealRequestCount(String userCode, String taxno);
......
......@@ -2,6 +2,7 @@ package com.tax.token.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.tax.token.constants.TokenConstants;
import com.tax.token.mapper.TkTokenMapper;
import com.tax.token.model.*;
......@@ -19,6 +20,7 @@ import com.yxcheng.token.common.cache.RedisService;
import com.yxcheng.token.common.enumutil.ResultEnum;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.common.model.TaxUserInfo;
import com.yxcheng.token.common.model.TokenInfo;
import com.yxcheng.token.constants.RedisContants;
import com.yxcheng.token.utils.*;
import org.apache.commons.lang.StringUtils;
......@@ -958,6 +960,18 @@ public class TkTokenServiceImpl implements TkTokenService {
return result;
}
public List<TokenInfo> selectTokenListByErrorCode(String userCode, String errorCode) {
List<TokenInfo> showTokenList = Lists.newArrayList();
List<TkToken> errorTokenList = tkTokenMapper.selectTokenListByErrorCode(userCode, errorCode);
if(null!=errorTokenList&&errorTokenList.size()>0) {
for(TkToken token:errorTokenList) {
showTokenList.add(TokenInfo.builder().taxno(token.getTaxno()).zoneCode(token.getZoneCode()).build());
}
}
logger.info("selectTokenListByErrorCode number is " + showTokenList.size());
return showTokenList;
}
public boolean checkTokenRealRequestCount(String userCode, String taxno) {
return redisService.exists(RedisContants.TOKEN_REALREQUEST_COUNT + userCode + RedisContants.DELIMITER + taxno);
}
......
......@@ -9,6 +9,7 @@ import com.yxcheng.token.common.controller.BaseClientController;
import com.yxcheng.token.common.enumutil.ResultEnum;
import com.yxcheng.token.common.model.CrRpcResult;
import com.yxcheng.token.common.model.JsonResult;
import com.yxcheng.token.common.model.TokenInfo;
import com.yxcheng.token.utils.ObjectUtil;
import com.yxcheng.token.utils.StringUtil;
import com.yxcheng.token.utils.UUIDGenerator;
......@@ -17,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* token服务统一入口
*/
......@@ -30,11 +33,6 @@ public class TokenController extends BaseClientController {
@Autowired
private UserClient userClient;
// @Autowired
// private NioWebSocketClient webSocketClient;
@RequestMapping(value ="/getToken" , method = RequestMethod.GET)
@LogT
public JsonResult<String>getToken(@RequestParam(value="taxno",required = true)String taxno,
......@@ -135,33 +133,11 @@ public class TokenController extends BaseClientController {
if(!checkUserSafe(crRpcResult)){
return JsonResult.errorResult(crRpcResult.getCode(),crRpcResult.getMessage());
}
//负责校验提交的税号是否正常结束流程
// ValidTokenInfo validTokenInfo = ValidTokenClient.validTokenFrom(pushTokenReq);
// //如果不为空,调用成功
// if(StringUtil.isNotEmpty(validTokenInfo.getCode())) {
// //如果异常,则返回标准异常
// if(validTokenInfo.getCode().equals("-1")) {
// return new JsonResult().errorResponse(ResultEnum.system_error);
// } else {
// //如果调用成功,并且不是正常,将返回值直接返回
// if(!validTokenInfo.getCode().equals("0")) {
// return new JsonResult().errorResult(validTokenInfo.getCode(), validTokenInfo.getMessage());
// }
// }
// } else {
//如果调用失败,则返回标准异常
return new JsonResult().errorResponse(ResultEnum.system_error);
// }
// pushTokenReq.clearSafeData();
// return tokenService.pushToken(pushTokenReq);
return new JsonResult().errorResponse(ResultEnum.system_error);
}
@RequestMapping(value ="list" , method = RequestMethod.GET)
public JsonResult<String>test(){
// TkZoneInfo tkZoneInfo = tkZoneInfoService.selectByPrimaryKey(1);
return new JsonResult<String>();
}
......@@ -236,4 +212,11 @@ public class TokenController extends BaseClientController {
return tokenService.queryTokenInfo(optType, userCode, taxno);
}
@RequestMapping(value ="/selectTokenListByErrorCode")
@LogT
public List<TokenInfo> selectTokenListByErrorCode(@RequestParam(value="userCode",required = true)String userCode,
@RequestParam(value="errorCode",required = true)String errorCode){
return tokenService.selectTokenListByErrorCode(userCode, errorCode);
}
}
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