|
|
|
@ -14,6 +14,8 @@ import com.hzya.frame.plugin.cinvoice.lexmis.service.*;
|
|
|
|
|
import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportHService;
|
|
|
|
|
import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportPluginService;
|
|
|
|
|
import com.hzya.frame.seeyon.util.YzfSignUtil;
|
|
|
|
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
|
|
|
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -21,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -48,7 +52,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
private ILexmiscivPlaneticketService lexmiscivPlaneticketService;
|
|
|
|
|
@Autowired
|
|
|
|
|
ILexmiscivPlaneticketsService lexmiscivPlaneticketsService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
|
|
|
|
@Value("${zt.url:}")
|
|
|
|
|
private String url;
|
|
|
|
|
@Value("${yzf.accessSecret:}")
|
|
|
|
@ -67,8 +72,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//1、 查OA主表
|
|
|
|
|
requestJson.get("");
|
|
|
|
|
String dataSourceCode = "HT-OA";
|
|
|
|
|
String dataSourceCode = requestJson.getString("sourceCode");
|
|
|
|
|
String id = requestJson.getString("id");//主表id
|
|
|
|
|
CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity();
|
|
|
|
|
importHEntity.setDataSourceCode(dataSourceCode);
|
|
|
|
|
importHEntity.setId("3922481031277596479");
|
|
|
|
@ -88,15 +93,16 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
int no = 1;//序号
|
|
|
|
|
//4、 根据发票类型,组装不同参数
|
|
|
|
|
long timestamp = System.currentTimeMillis();
|
|
|
|
|
Map<String, Object> parametersMap = new HashMap<>();
|
|
|
|
|
parametersMap.put("accessKey",accesskey);
|
|
|
|
|
parametersMap.put("timestamp",timestamp);
|
|
|
|
|
String sign = YzfSignUtil.signRequest(parametersMap, accessSecret);
|
|
|
|
|
//Map<String, Object> parametersMap = new HashMap<>();
|
|
|
|
|
//parametersMap.put("accessKey",accesskey);
|
|
|
|
|
//parametersMap.put("timestamp",timestamp);
|
|
|
|
|
//String sign = YzfSignUtil.signRequest(parametersMap, accessSecret);
|
|
|
|
|
JSONObject head = new JSONObject();
|
|
|
|
|
head.put("accessKey","6X3B526P5HqE6ums");//密钥
|
|
|
|
|
head.put("sign",sign);//签名
|
|
|
|
|
head.put("timestamp",timestamp);//时间戳
|
|
|
|
|
//head.put("accessKey",accesskey);//密钥
|
|
|
|
|
// head.put("sign",sign);//签名
|
|
|
|
|
// head.put("timestamp",timestamp);//时间戳
|
|
|
|
|
head.put("taxNo","91330110MAC5FPUY2U");//当前企业税号
|
|
|
|
|
//head.put("taxNo",lexmisPublicinfoEntityList.get(0).getPI_TAXNO());
|
|
|
|
|
JSONArray inputInfos = new JSONArray();
|
|
|
|
|
head.put("inputInfos",inputInfos);//发票录入信息,单次最大50张
|
|
|
|
|
|
|
|
|
@ -108,7 +114,6 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
for (Map.Entry<String,List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()){
|
|
|
|
|
String key = entry.getKey();//对应发票类型的表名
|
|
|
|
|
List<LexmisPublicinfoEntity> publicinfoList = entry.getValue();
|
|
|
|
|
ParamAssemblerContext context = null;//策略上下文类
|
|
|
|
|
for (LexmisPublicinfoEntity info : publicinfoList){
|
|
|
|
|
|
|
|
|
|
JSONObject inputInfo = new JSONObject();
|
|
|
|
@ -153,6 +158,22 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
.build();
|
|
|
|
|
String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body();
|
|
|
|
|
logger.info("调用有度发票批量导入接口响应参数:{}",body);
|
|
|
|
|
//保存操作日志
|
|
|
|
|
if (StrUtil.isNotEmpty(body)){
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
|
Boolean flag = jsonObject.getBoolean("flag");
|
|
|
|
|
//保存日志
|
|
|
|
|
IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
|
|
|
|
|
taskLivingDetail.setCreate_time(new Date());
|
|
|
|
|
taskLivingDetail.setModify_time(new Date());
|
|
|
|
|
taskLivingDetail.setRootAppPk(cInvoiceH.getId());
|
|
|
|
|
taskLivingDetail.setRootAppBill(cInvoiceH.getBill_code());
|
|
|
|
|
taskLivingDetail.setPluginId("CInvoiceImportPluginInitializer");
|
|
|
|
|
taskLivingDetail.setRootAppNewData(head.toString());
|
|
|
|
|
taskLivingDetail.setNewTransmitInfo(body);
|
|
|
|
|
taskLivingDetail.setNewPushDate(new Date());
|
|
|
|
|
this.saveLog(id,flag,taskLivingDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -161,6 +182,36 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存日志
|
|
|
|
|
* @param integration_task_living_details_id
|
|
|
|
|
* @param flag
|
|
|
|
|
* @param taskLivingDetail
|
|
|
|
|
*/
|
|
|
|
|
public void saveLog(String integration_task_living_details_id, Boolean flag, IntegrationTaskLivingDetailsEntity taskLivingDetail){
|
|
|
|
|
try {
|
|
|
|
|
//判断,成功调用这个方法
|
|
|
|
|
if (StrUtil.isEmpty(integration_task_living_details_id)){
|
|
|
|
|
if (flag){
|
|
|
|
|
taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
|
|
|
|
|
}else {
|
|
|
|
|
//失败 调用这个方法
|
|
|
|
|
taskLivingDetailsService.saveLogToFail(taskLivingDetail);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
taskLivingDetail.setId(integration_task_living_details_id);
|
|
|
|
|
if (flag){
|
|
|
|
|
//如果是重试 成功调这个方法
|
|
|
|
|
taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
|
|
|
|
|
}else {
|
|
|
|
|
//如果是重试 失败调这个方法
|
|
|
|
|
taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
logger.error("保存日志出错:{}",e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 机票
|
|
|
|
|
* @param dataSourceCode
|
|
|
|
@ -169,7 +220,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
* @param baseInfo
|
|
|
|
|
*/
|
|
|
|
|
private void planeInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
|
|
|
|
|
ParamAssemblerContext context;
|
|
|
|
|
ParamAssemblerContext context;//策略上下文类
|
|
|
|
|
JSONObject contentInfo;
|
|
|
|
|
ParamAssembler assembler;
|
|
|
|
|
LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode));
|
|
|
|
@ -220,7 +271,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
private void trainInvoice(String dataSourceCode, JSONArray inputInfos, LexmisPublicinfoEntity info, JSONObject inputInfo, JSONObject invoiceInfo, JSONObject baseInfo) {
|
|
|
|
|
JSONObject contentInfo;
|
|
|
|
|
ParamAssembler assembler;
|
|
|
|
|
ParamAssemblerContext context;
|
|
|
|
|
ParamAssemblerContext context;//策略上下文类
|
|
|
|
|
LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode);
|
|
|
|
|
trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开,3和4没遇到过,先查1
|
|
|
|
|
LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity);
|
|
|
|
@ -264,7 +315,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|
|
|
|
* @param baseInfo 发票基本数据对象
|
|
|
|
|
*/
|
|
|
|
|
private void zzsInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
|
|
|
|
|
ParamAssemblerContext context;
|
|
|
|
|
ParamAssemblerContext context;//策略上下文类
|
|
|
|
|
JSONObject contentInfo;
|
|
|
|
|
ParamAssembler assembler;
|
|
|
|
|
LexmiscivInvoicemainEntity zzsInvoiceH = lexmiscivInvoicemainService.queryOne(new LexmiscivInvoicemainEntity(info.getPI_DATAKEY(), dataSourceCode));
|
|
|
|
|