|
|
@ -3,17 +3,20 @@ package com.dxhy.erp.service.impl; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.dxhy.erp.controller.SDNYMainProcessController; |
|
|
|
|
|
|
|
import com.dxhy.erp.entity.CheckReInfo; |
|
|
|
|
|
|
|
import com.dxhy.erp.entity.sdny.SNRequestObject; |
|
|
|
|
|
|
|
import com.dxhy.erp.entity.sdny.SNSAPObject; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
@ -57,6 +60,9 @@ public class GatherServiceImpl extends MpBaseServiceImpl<TdxRecordInvoiceDao, Td |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private SysDeptDao sysDeptDao; |
|
|
|
private SysDeptDao sysDeptDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private SDNYMainProcessController mainService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String get(GlobalInfo globalInfo, Map<String, String> map, HttpServletRequest request, |
|
|
|
public String get(GlobalInfo globalInfo, Map<String, String> map, HttpServletRequest request, |
|
|
|
HttpServletResponse response, Authorize authorize) { |
|
|
|
HttpServletResponse response, Authorize authorize) { |
|
|
@ -729,6 +735,126 @@ public class GatherServiceImpl extends MpBaseServiceImpl<TdxRecordInvoiceDao, Td |
|
|
|
return info; |
|
|
|
return info; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String singleInvoiceChenck(GlobalInfo globalInfo, Map<String, String> map, HttpServletRequest request, |
|
|
|
|
|
|
|
HttpServletResponse response, Authorize authorize) { |
|
|
|
|
|
|
|
ReturnStateInfo run = new ReturnStateInfo(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (run.getReturnCode() != null || run.getReturnMessage() != null) { |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(run); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String dbName = "business"; |
|
|
|
|
|
|
|
DynamicContextHolder.push(dbName + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
Map<String, String> param = JSONObject.parseObject(map.get("data").getBytes(),Map.class); |
|
|
|
|
|
|
|
ResponseEntity<?> responseEntity = mainService.singleInvoiceCheck(param); |
|
|
|
|
|
|
|
String body = responseEntity.getBody().toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body = body.replaceAll("=",":"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Map<String, String> resultMap = Arrays.asList(body.split("=")).stream()
|
|
|
|
|
|
|
|
// .map(elem -> elem.split(":"))
|
|
|
|
|
|
|
|
// .collect(Collectors.toMap(e -> e[0], e -> e[1]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String result = ""; |
|
|
|
|
|
|
|
if (body != null) { |
|
|
|
|
|
|
|
result = body; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ReturnStateInfo runInfo = new ReturnStateInfo(); |
|
|
|
|
|
|
|
runInfo.setReturnCode(ReturnCodeEnum.FPBCZ.getFhzDm()); |
|
|
|
|
|
|
|
runInfo.setReturnMessage(ReturnCodeEnum.FPBCZ.getFhzMc(ReturnCodeEnum.FPBCZ.getIndex())); |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(runInfo); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("===========发票实体转换完成============" + globalInfo.getDataExchangeId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run.setReturnCode(ReturnCodeEnum.CLCG.getFhzDm()); |
|
|
|
|
|
|
|
run.setReturnMessage(ReturnCodeEnum.CLCG.getFhzMc(ReturnCodeEnum.CLCG.getIndex())); |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(run); |
|
|
|
|
|
|
|
interfaceCode.setData(Base64.encode(result)); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
run.setReturnCode("2011"); |
|
|
|
|
|
|
|
run.setReturnMessage("其他异常"); |
|
|
|
|
|
|
|
String globalJson = null; |
|
|
|
|
|
|
|
String runJson = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
runJson = JSON.toJSONString(run); |
|
|
|
|
|
|
|
globalJson = JSON.toJSONString(globalInfo); |
|
|
|
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
|
|
|
response.setContentType("application/json; charset=utf-8"); |
|
|
|
|
|
|
|
return "{\"globalInfo\":" + globalJson + ",\"returnStateInfo\":" + runJson + "}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String syncInvoiceInfo(GlobalInfo globalInfo, Map<String, String> map, HttpServletRequest request, |
|
|
|
|
|
|
|
HttpServletResponse response, Authorize authorize) { |
|
|
|
|
|
|
|
ReturnStateInfo run = new ReturnStateInfo(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (run.getReturnCode() != null || run.getReturnMessage() != null) { |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(run); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String dbName = "business"; |
|
|
|
|
|
|
|
DynamicContextHolder.push(dbName + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
String data = map.get("data"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SNRequestObject snRequestObject = JSONObject.parseObject(data.getBytes(), SNRequestObject.class); |
|
|
|
|
|
|
|
ResponseEntity<?> responseEntity = mainService.syncInvoiceInfo(snRequestObject); |
|
|
|
|
|
|
|
String body = responseEntity.getBody().toString(); |
|
|
|
|
|
|
|
body = body.replaceAll("=",":"); |
|
|
|
|
|
|
|
String result = ""; |
|
|
|
|
|
|
|
if (body != null) { |
|
|
|
|
|
|
|
result = body; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ReturnStateInfo runInfo = new ReturnStateInfo(); |
|
|
|
|
|
|
|
runInfo.setReturnCode(ReturnCodeEnum.FPBCZ.getFhzDm()); |
|
|
|
|
|
|
|
runInfo.setReturnMessage(ReturnCodeEnum.FPBCZ.getFhzMc(ReturnCodeEnum.FPBCZ.getIndex())); |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(runInfo); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("===========发票实体转换完成============" + globalInfo.getDataExchangeId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run.setReturnCode(ReturnCodeEnum.CLCG.getFhzDm()); |
|
|
|
|
|
|
|
run.setReturnMessage(ReturnCodeEnum.CLCG.getFhzMc(ReturnCodeEnum.CLCG.getIndex())); |
|
|
|
|
|
|
|
InterfaceCode interfaceCode = new InterfaceCode(); |
|
|
|
|
|
|
|
interfaceCode.setGlobalInfo(globalInfo); |
|
|
|
|
|
|
|
interfaceCode.setReturnStateInfo(run); |
|
|
|
|
|
|
|
interfaceCode.setData(Base64.encode(result)); |
|
|
|
|
|
|
|
return JSON.toJSONString(interfaceCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
run.setReturnCode("2011"); |
|
|
|
|
|
|
|
run.setReturnMessage("其他异常"); |
|
|
|
|
|
|
|
String globalJson = null; |
|
|
|
|
|
|
|
String runJson = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
runJson = JSON.toJSONString(run); |
|
|
|
|
|
|
|
globalJson = JSON.toJSONString(globalInfo); |
|
|
|
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
|
|
|
response.setContentType("application/json; charset=utf-8"); |
|
|
|
|
|
|
|
return "{\"globalInfo\":" + globalJson + ",\"returnStateInfo\":" + runJson + "}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public InvoiceDetailInfo getInvoiceDetailInfo(InvoiceDetailInfo detail) { |
|
|
|
public InvoiceDetailInfo getInvoiceDetailInfo(InvoiceDetailInfo detail) { |
|
|
|
InvoiceDetailInfo detailInfo = new InvoiceDetailInfo(); |
|
|
|
InvoiceDetailInfo detailInfo = new InvoiceDetailInfo(); |
|
|
|
detailInfo.setDetailNo(detail.getDetailNo() + ""); |
|
|
|
detailInfo.setDetailNo(detail.getDetailNo() + ""); |
|
|
|