回写失败原因

This commit is contained in:
xiang2lin 2025-06-19 09:20:36 +08:00
parent 9a91d156e6
commit 6f39ac218e
1 changed files with 45 additions and 0 deletions

View File

@ -22,6 +22,8 @@ import com.hzya.frame.mdm.mdmModuleDistributeTripartite.entity.MdmModuleDistribu
import com.hzya.frame.mdm.mdmModuleSendLog.dao.IMdmModuleSendLogDao;
import com.hzya.frame.mdm.mdmModuleSendLog.entity.MdmModuleSendLogEntity;
import com.hzya.frame.mdm.service.IMdmServiceCache;
import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao;
import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity;
import com.hzya.frame.sys.sysenum.SysEnum;
import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
@ -45,6 +47,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
@ -78,6 +81,8 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
private IMdmModuleSendLogDao mdmModuleSendLogDao;
@Resource
private IMdmModuleDistributeTripartiteDao mdmModuleDistributeTripartiteDao;
@Autowired
private IInvoiceDao invoiceDao;
@Value("${zt.url}")
private String url ;
@ -1117,6 +1122,8 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
logger.info("=========开始执行开票申请单申请新增数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
logger.info("=====开票申请单申请数据新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString());
//todo 更新OA开票结果
updateOAForm(jsonResultEntity,doObjects.get(i));
if(jsonResultEntity.isFlag()){
if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) {
logger.info("=========开始执行开票申请单申请数据新增返回脚本==============");
@ -1208,6 +1215,44 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
}*/
}
/**
* 更新OA开票结果
* @param jsonResultEntity
* @param data
*/
private void updateOAForm(JsonResultEntity jsonResultEntity, JSONObject data) {
try {
logger.info("准备更新开票结果到OA单据返回参数:{}data_id:{}",JSONObject.toJSONString(jsonResultEntity),data.getString("data_id"));
if (null != jsonResultEntity && null != data && StrUtil.isNotEmpty(data.getString("data_id"))){
String data_id = data.getString("data_id");
String attrStr = (String) jsonResultEntity.getAttribute();
JSONObject attrObj = JSONObject.parseObject(attrStr);
JSONObject attribute = attrObj.getJSONObject("attribute");
if (null != attribute && !"0".equals(attribute.getString("code"))){
String message = attribute.getString("message");
InvoiceEntity invoiceEntity = new InvoiceEntity();
invoiceEntity.setId(data_id);
invoiceEntity.setResult_status(message);
invoiceDao.updateInvoiceResult(invoiceEntity);
}
}
}catch (Exception e){
logger.info("调用有度开票申请接口后更新OA表单开票结果出错:{}",e);
}
}
public static void main(String[] args) {
String resultStr = "{\"attribute\":\"{\\\"msg\\\":\\\"转发成功\\\",\\\"type\\\":null,\\\"flag\\\":true,\\\"status\\\":\\\"200\\\",\\\"attribute\\\":{\\\"result\\\":{\\\"businessNo\\\":\\\"KP202506170028\\\",\\\"applicationNumber\\\":\\\"LZ250617000004\\\",\\\"applicationId\\\":\\\"1384530530992742657\\\"},\\\"code\\\":\\\"0\\\",\\\"cause\\\":null,\\\"message\\\":\\\"成功\\\"}}\",\"flag\":true,\"msg\":\"转发成功\",\"status\":\"200\"}";
JsonResultEntity jsonResultEntity = JSON.parseObject(resultStr,JsonResultEntity.class);
JSONObject data = new JSONObject();
data.put("data_id","2076813022629089234");
InvoiceDistributePluginInitializer plugin = new InvoiceDistributePluginInitializer();
String attrStr = (String) jsonResultEntity.getAttribute();
JSONObject attrObj = JSONObject.parseObject(attrStr);
plugin.updateOAForm(jsonResultEntity,data);
}
private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String appId, String target_api,String apiID, String source_data, String option_type) throws Exception {
MdmModuleSendLogEntity mdmModuleSendLogEntity = new MdmModuleSendLogEntity();
mdmModuleSendLogEntity.setTableName(dbname+"_send_log");