|
|
@@ -349,6 +349,81 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> rushRed(String master, int id) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ Object[] obs=baseDao.getFieldsDataByCondition("YITOA_DATACENTER.dock_invoice_config",new String[]{"appKey","appSecret","token","taxnum"},"username='"+master+"'");
|
|
|
+ String url=donlimConfig.getRoute();
|
|
|
+ String appKey = donlimConfig.getAppKey();
|
|
|
+ String appSecret = donlimConfig.getAppSecret();
|
|
|
+ String token = donlimConfig.getToken();
|
|
|
+ String taxnum= donlimConfig.getTaxnum();
|
|
|
+ if(donlimConfig.isProd()){
|
|
|
+ appKey = obs[0].toString();
|
|
|
+ appSecret = obs[1].toString();
|
|
|
+ token = obs[2].toString();// 访问令牌
|
|
|
+ taxnum = obs[3].toString();// 授权企业税号
|
|
|
+ }
|
|
|
+ logger.info("rushRed begin: master {} ,id {} ",master,id);
|
|
|
+ SpObserver.putSp(master);
|
|
|
+ SqlRowList rs_main = baseDao.queryForRowSet("select * from invoiceOrder left join customer on io_cucode=cu_code left join elecinvoice on io_id=ei_ioid where io_id="+id);
|
|
|
+ if(rs_main.next()){
|
|
|
+ RedInvoiceReq redInvoiceReq=new RedInvoiceReq();
|
|
|
+ redInvoiceReq.setBlueInvoiceLine(rs_main.getGeneralString("io_invoiceline"));//蓝票发票种类
|
|
|
+ redInvoiceReq.setApplySource("0");//申请方(录入方)身份: 0 销方 1 购方
|
|
|
+ redInvoiceReq.setSellerTaxNo(donlimConfig.getTaxnum());//销方税号
|
|
|
+ redInvoiceReq.setBuyerName(rs_main.getGeneralString("cu_name"));//购方名称
|
|
|
+ redInvoiceReq.setBuyerTaxNo(rs_main.getGeneralString("ei_taxno"));
|
|
|
+ redInvoiceReq.setRedReason(rs_main.getGeneralString("io_redreason"));
|
|
|
+ redInvoiceReq.setBlueElecInvoiceNumber(rs_main.getGeneralString("ei_allelectronicinvoicenumber"));
|
|
|
+ NNOpenSDK sdk = NNOpenSDK.getIntance();
|
|
|
+ String content =sdk.convertToUtf8(JSONArray.toJSONString(redInvoiceReq));
|
|
|
+ String method = "nuonuo.OpeMplatform.saveInvoiceRedConfirm"; // API方法名
|
|
|
+ String senid = UUID.randomUUID().toString().replace("-", ""); // 唯一标识,32位随机码,无需修改,保持默认即可
|
|
|
+ String resp = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, token, taxnum, method, content);
|
|
|
+ System.out.println(resp);
|
|
|
+ Map<Object, Object> res=JSONUtil.toMap(resp);
|
|
|
+ System.out.println(res);
|
|
|
+ Object code=res.get("code");
|
|
|
+ Object describe=res.get("describe");
|
|
|
+ Object result=res.get("result");
|
|
|
+
|
|
|
+ //{"code":"E0000","describe":"调用成功","result":"1135624457459470336"}
|
|
|
+ if(code !=null && "E0000".equals(code.toString())){//调用成功
|
|
|
+ queryInvoiceRedConfirm( taxnum, appKey, appSecret, token, url, result.toString());
|
|
|
+ baseDao.execute("update elecinvoice set ei_redapplycode='"+result.toString()+"' where ei_id="+rs_main.getGeneralInt("ei_id"));
|
|
|
+ //baseDao.execute("update invoiceOrder set io_resstatus='' where io_id="+id);
|
|
|
+ baseDao.execute("insert into invoicedockLog(id_,code_,date_,result_,err_,keyvalue_)values(invoicedockLog_seq.nextval,'红字确认单申请',sysdate,'SUCCEED','',"+id+") ");
|
|
|
+ }else{
|
|
|
+ //baseDao.execute("update invoiceOrder set io_resstatus='对接失败' where io_id="+id);
|
|
|
+ baseDao.execute("insert into invoicedockLog(id_,code_,date_,result_,err_,keyvalue_)values(invoicedockLog_seq.nextval,'红字确认单申请',sysdate,'FAILED','("+code+")"+describe+"',"+id+") ");
|
|
|
+ }
|
|
|
+ //logger.info("pushInvoiceOrder master {} ,id {} status {} message {}",master,id,status,message);
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("describe", describe);
|
|
|
+ return map;
|
|
|
+ }else{//数据无效
|
|
|
+ logger.info("rushRed err {对接源信息无效} ,master {} , id {} status {} message {}",master,id);
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "对接源信息无效");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void queryInvoiceRedConfirm(String taxnum, String appKey, String appSecret, String token,String url,String redApplycode) {
|
|
|
+ NNOpenSDK sdk = NNOpenSDK.getIntance();
|
|
|
+ String method = "nuonuo.OpeMplatform.queryInvoiceRedConfirm"; // API方法名
|
|
|
+ Map<String,String> reqParam=new HashMap<>();
|
|
|
+ reqParam.put("identity","0");
|
|
|
+ reqParam.put("billId",redApplycode);
|
|
|
+ String content=JSONArray.toJSONString(reqParam);
|
|
|
+ String senid = UUID.randomUUID().toString().replace("-", ""); // 唯一标识,32位随机码,无需修改,保持默认即可
|
|
|
+ String result = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, token, taxnum, method, content);
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
+
|
|
|
private List<String> getElecInvoicesSqls(int ioid,List<FindOrderRelationInvoiceDTO> data){
|
|
|
List<String> sqls = new ArrayList<String>();
|
|
|
boolean syncToBillOut = baseDao.isDBSetting("BillOut","syncToBillOut");
|