|
|
@ -1098,153 +1098,158 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService {
|
|
|
|
public HttpResult getInvoice(InvLinkInfo info) {
|
|
|
|
public HttpResult getInvoice(InvLinkInfo info) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InvInvoiceInfo> list = invInvoiceInfoMapper.selectcheck();
|
|
|
|
List<InvLinkInfo> linkinfos = invLinkInfoMapper.selectLinkInfoByStatus();
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
for(InvLinkInfo invlink : linkinfos){
|
|
|
|
ResponseData data = null;
|
|
|
|
List<InvInvoiceInfo> list = invInvoiceInfoMapper.selectcheck(invlink.getGID());
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
|
|
|
ResponseData data = null;
|
|
|
|
String linkid = invInvoiceSplitMapper.getLinkIdsByinvoiceId(invoice.getGID());
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String linkid = invInvoiceSplitMapper.getLinkIdsByinvoiceId(invoice.getGID());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// InvLinkInfo invlink = new InvLinkInfo();
|
|
|
|
|
|
|
|
// invlink.setGID(linkid);
|
|
|
|
|
|
|
|
// InvLinkInfo linkinfo = invLinkInfoMapper.selectByGID(invlink);
|
|
|
|
|
|
|
|
// if(!"1".equals(linkinfo.getStatus())){
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
InvLinkInfo invlink = new InvLinkInfo();
|
|
|
|
try {
|
|
|
|
invlink.setGID(linkid);
|
|
|
|
data = new ResponseData();
|
|
|
|
InvLinkInfo linkinfo = invLinkInfoMapper.selectByGID(invlink);
|
|
|
|
log.info(df.format(new Date())+"开始调用瑞宏查询接口"+",invoiceId="+invoice.getGID());
|
|
|
|
if(!"1".equals(linkinfo.getStatus())){
|
|
|
|
data = UploadData.doPost(cmdCxName, getCx1Data(invoice));
|
|
|
|
continue;
|
|
|
|
if(0 == data.getCode()){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultInvoice[] invoices = data.getInvoices();
|
|
|
|
|
|
|
|
if(null != invoices && invoices.length>0){
|
|
|
|
|
|
|
|
ResultInvoice result = invoices[0];
|
|
|
|
|
|
|
|
String code = result.getCode();
|
|
|
|
|
|
|
|
invoice.setInvCode(code.substring(0,12));
|
|
|
|
|
|
|
|
invoice.setInvNum(code.substring(12,20));
|
|
|
|
|
|
|
|
invoice.setPdfUrl(result.getPdfUnsignedUrl());
|
|
|
|
|
|
|
|
invoice.setPictureUrl(result.getViewUrl());
|
|
|
|
|
|
|
|
invoice.setApiReadTime(df.parse(df.format(new Date())));
|
|
|
|
|
|
|
|
invoice.setStatus("success");
|
|
|
|
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
}else if(6 == data.getCode()){//正在处理中
|
|
|
|
data = new ResponseData();
|
|
|
|
invoice.setStatus("process");
|
|
|
|
log.info(df.format(new Date())+"开始调用瑞宏查询接口"+",invoiceId="+invoice.getGID());
|
|
|
|
invoice.setMessage(JSON.toJSONString(data));
|
|
|
|
data = UploadData.doPost(cmdCxName, getCx1Data(invoice));
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
if(0 == data.getCode()){
|
|
|
|
}else{
|
|
|
|
|
|
|
|
invoice.setStatus("fail");
|
|
|
|
ResultInvoice[] invoices = data.getInvoices();
|
|
|
|
invoice.setMessage(JSON.toJSONString(data));
|
|
|
|
if(null != invoices && invoices.length>0){
|
|
|
|
|
|
|
|
ResultInvoice result = invoices[0];
|
|
|
|
|
|
|
|
String code = result.getCode();
|
|
|
|
|
|
|
|
invoice.setInvCode(code.substring(0,12));
|
|
|
|
|
|
|
|
invoice.setInvNum(code.substring(12,20));
|
|
|
|
|
|
|
|
invoice.setPdfUrl(result.getPdfUnsignedUrl());
|
|
|
|
|
|
|
|
invoice.setPictureUrl(result.getViewUrl());
|
|
|
|
|
|
|
|
invoice.setApiReadTime(df.parse(df.format(new Date())));
|
|
|
|
|
|
|
|
invoice.setStatus("success");
|
|
|
|
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(6 == data.getCode()){//正在处理中
|
|
|
|
}
|
|
|
|
invoice.setStatus("process");
|
|
|
|
|
|
|
|
invoice.setMessage(JSON.toJSONString(data));
|
|
|
|
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
invoice.setStatus("fail");
|
|
|
|
|
|
|
|
invoice.setMessage(JSON.toJSONString(data));
|
|
|
|
|
|
|
|
invInvoiceInfoMapper.updateBySerinal(invoice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//查询所有发票对应的链接
|
|
|
|
|
|
|
|
List<InvLinkInfo> links = new ArrayList<>();
|
|
|
|
|
|
|
|
List<String> lindIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//查询所有发票对应的链接
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
List<InvLinkInfo> links = new ArrayList<>();
|
|
|
|
|
|
|
|
List<String> lindIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(InvInvoiceInfo invoice : list){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String linkid = invInvoiceSplitMapper.getLinkIdsByinvoiceId(invoice.getGID());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// InvLinkInfo invlink = new InvLinkInfo();
|
|
|
|
|
|
|
|
// invlink.setGID(linkid);
|
|
|
|
|
|
|
|
// InvLinkInfo invlinkinfo = invLinkInfoMapper.selectByGID(invlink);
|
|
|
|
|
|
|
|
// if(!"1".equals(invlinkinfo.getStatus())){
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
String linkid = invInvoiceSplitMapper.getLinkIdsByinvoiceId(invoice.getGID());
|
|
|
|
String likid = invInvoiceSplitMapper.getlinkdId(invoice.getGID());
|
|
|
|
|
|
|
|
//判断是否存在重复的linkid
|
|
|
|
|
|
|
|
if(lindIds.contains(likid)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
lindIds.add(likid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InvLinkInfo invlink = new InvLinkInfo();
|
|
|
|
InvLinkInfo linkinfo = new InvLinkInfo();
|
|
|
|
invlink.setGID(linkid);
|
|
|
|
linkinfo.setGID(likid);
|
|
|
|
InvLinkInfo invlinkinfo = invLinkInfoMapper.selectByGID(invlink);
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(linkinfo);
|
|
|
|
if(!"1".equals(invlinkinfo.getStatus())){
|
|
|
|
links.add(link);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String likid = invInvoiceSplitMapper.getlinkdId(invoice.getGID());
|
|
|
|
|
|
|
|
//判断是否存在重复的linkid
|
|
|
|
|
|
|
|
if(lindIds.contains(likid)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
lindIds.add(likid);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InvLinkInfo linkinfo = new InvLinkInfo();
|
|
|
|
|
|
|
|
linkinfo.setGID(likid);
|
|
|
|
|
|
|
|
InvLinkInfo link = invLinkInfoMapper.selectByGID(linkinfo);
|
|
|
|
|
|
|
|
links.add(link);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(null != links && links.size()>0){
|
|
|
|
if(null != links && links.size()>0){
|
|
|
|
|
|
|
|
|
|
|
|
InvLinkTaskDto dto = null;
|
|
|
|
InvLinkTaskDto dto = null;
|
|
|
|
|
|
|
|
|
|
|
|
for(InvLinkInfo link : links){
|
|
|
|
for(InvLinkInfo link : links){
|
|
|
|
|
|
|
|
|
|
|
|
dto = new InvLinkTaskDto();
|
|
|
|
dto = new InvLinkTaskDto();
|
|
|
|
|
|
|
|
|
|
|
|
//查询当前链表下的所有发票
|
|
|
|
//查询当前链表下的所有发票
|
|
|
|
List<String> listId = invInvoiceSplitMapper.getIdsBylinkdId(link.getGID());
|
|
|
|
List<String> listId = invInvoiceSplitMapper.getIdsBylinkdId(link.getGID());
|
|
|
|
|
|
|
|
|
|
|
|
if(null !=listId && listId.size()>0){
|
|
|
|
if(null !=listId && listId.size()>0){
|
|
|
|
List<InvInvoiceInfo> invoices = new ArrayList<>();
|
|
|
|
List<InvInvoiceInfo> invoices = new ArrayList<>();
|
|
|
|
int size = listId.size();
|
|
|
|
int size = listId.size();
|
|
|
|
for(int i=0;i<listId.size();i++){
|
|
|
|
for(int i=0;i<listId.size();i++){
|
|
|
|
//如果状态Status是success 或fail
|
|
|
|
//如果状态Status是success 或fail
|
|
|
|
InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGidAndStatus(listId.get(i));
|
|
|
|
InvInvoiceInfo invoice = invInvoiceInfoMapper.getByGidAndStatus(listId.get(i));
|
|
|
|
if(null != invoice && null != invoice.getGID()){
|
|
|
|
if(null != invoice && null != invoice.getGID()){
|
|
|
|
invoices.add(invoice);
|
|
|
|
invoices.add(invoice);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//判断改链接底下的查询出的发票success 或fail是否与总数相等
|
|
|
|
//判断改链接底下的查询出的发票success 或fail是否与总数相等
|
|
|
|
if(size == invoices.size()){
|
|
|
|
if(size == invoices.size()){
|
|
|
|
link.setStatus("2");
|
|
|
|
link.setStatus("2");
|
|
|
|
invLinkInfoMapper.updateById(link);
|
|
|
|
invLinkInfoMapper.updateById(link);
|
|
|
|
String content ="";
|
|
|
|
String content ="";
|
|
|
|
|
|
|
|
// String subject = "发票信息";
|
|
|
|
// String subject = "发票信息";
|
|
|
|
for(InvInvoiceInfo invoice : invoices){
|
|
|
|
for(InvInvoiceInfo invoice : invoices){
|
|
|
|
|
|
|
|
|
|
|
|
if("fail".equals(invoice.getStatus())){
|
|
|
|
if("fail".equals(invoice.getStatus())){
|
|
|
|
content = content +"<div>开票流水号:"+invoice.getSerialNo()+"</div>&&&"+"<div>开票失败原因:"+invoice.getMessage()+"</div>#";
|
|
|
|
content = content +"<div>开票流水号:"+invoice.getSerialNo()+"</div>&&&"+"<div>开票失败原因:"+invoice.getMessage()+"</div>#";
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
content = content +"<div>发票号码:"+invoice.getInvNum()+"</div>&&&"+"<div>发票PDF地址:"+invoice.getPdfUrl()+"</div>#";
|
|
|
|
content = content +"<div>发票号码:"+invoice.getInvNum()+"</div>&&&"+"<div>发票PDF地址:"+invoice.getPdfUrl()+"</div>#";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
content = content.substring(0,content.length()-1);
|
|
|
|
content = content.substring(0,content.length()-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendEmailParams param = new SendEmailParams();
|
|
|
|
SendEmailParams param = new SendEmailParams();
|
|
|
|
|
|
|
|
|
|
|
|
List<SendEmail> listEmail = new ArrayList<>();
|
|
|
|
List<SendEmail> listEmail = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
SendEmail email = new SendEmail();
|
|
|
|
SendEmail email = new SendEmail();
|
|
|
|
email.setSendTo(link.getEmail());
|
|
|
|
email.setSendTo(link.getEmail());
|
|
|
|
email.setTitle(subject);
|
|
|
|
email.setTitle(subject);
|
|
|
|
email.setBody(content);
|
|
|
|
email.setBody(content);
|
|
|
|
email.setSmtpConfig(SmtpConfig);
|
|
|
|
email.setSmtpConfig(SmtpConfig);
|
|
|
|
listEmail.add(email);
|
|
|
|
listEmail.add(email);
|
|
|
|
param.setList(listEmail);
|
|
|
|
param.setList(listEmail);
|
|
|
|
|
|
|
|
|
|
|
|
String str = JSONObject.toJSONString(param.getList());
|
|
|
|
String str = JSONObject.toJSONString(param.getList());
|
|
|
|
sendEMail(str);
|
|
|
|
sendEMail(str);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
link.setStatus("3");
|
|
|
|
link.setStatus("3");
|
|
|
|
invLinkInfoMapper.updateById(link);
|
|
|
|
invLinkInfoMapper.updateById(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HttpResult.ok();
|
|
|
|
return HttpResult.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|