|
|
@@ -343,14 +343,23 @@ public class ERPServiceImpl implements ERPService {
|
|
|
commonService.logFRecord("订单关联发票对接","("+errCode+")"+errMsg,ioid);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
errMsg = "发票获取异常";
|
|
|
if(StringUtil.hasText(e.getMessage())){
|
|
|
errMsg = e.getMessage();
|
|
|
}else if(e.getCause()!=null&&StringUtil.hasText(e.getCause().getMessage())){
|
|
|
errMsg = e.getCause().getMessage();
|
|
|
}
|
|
|
+ logger.info("ElecI-DownLoad-master: {} ,id {} message {}",SpObserver.getSp(),ioid,errMsg);
|
|
|
commonService.logFRecord("订单关联发票对接",errMsg.replaceAll("'","''"),ioid);
|
|
|
}
|
|
|
+ //获取红字发票PDF地址
|
|
|
+ List<String> serialNosAll = baseDao.queryForList("select ei_redsid from ElecInvoice " +
|
|
|
+ "where ei_ioid = "+ioid+" and EI_RELATIVEREFNO is not null and ei_redpdfurl is null and nvl(EI_BILLSTATUS,' ') in (' ','01','04')",String.class);
|
|
|
+ if (!CollectionUtil.isEmpty(serialNosAll)){
|
|
|
+ queryRedPdfUrl(serialNosAll,m);
|
|
|
+ }
|
|
|
+// queryRedPdfUrl()
|
|
|
if(StringUtil.hasText(errMsg)&&!"调用成功".equals(errMsg)){
|
|
|
res.put("success", false);
|
|
|
res.put("errCode", errCode);
|
|
|
@@ -365,7 +374,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
boolean syncToBillOut = baseDao.isDBSetting("BillOut","syncToBillOut");
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
FindOrderRelationInvoiceDTO friDto = data.get(i);
|
|
|
- sqls.add(friDto.toMergeSql(ioid,(i+1)));
|
|
|
+ sqls.addAll(friDto.toMergeSql(ioid,(i+1)));
|
|
|
}
|
|
|
sqls.add("update invoiceOrder set io_refno = (select (min(ei_refno)||(case when max(ei_refno) <> min(ei_refno) then '-'||max(ei_refno) else '' end)) from ELECINVOICE where ei_ioid = io_id and EI_INVOICETYPE= 1 and nvl(ei_rushredstate,0) <> 1)" +
|
|
|
"where io_id = "+ioid);
|
|
|
@@ -373,6 +382,8 @@ public class ERPServiceImpl implements ERPService {
|
|
|
if(syncToBillOut){
|
|
|
sqls.add("update BillOut set bi_refno = (select max(io_refno) from invoiceOrder where io_id = "+ioid+" and io_biid = bi_id) where bi_id in (select io_biid from invoiceOrder where io_id = "+ioid+" and io_refno is not null)");
|
|
|
}
|
|
|
+// System.out.println("sqls:");
|
|
|
+// System.out.println(sqls.toString());
|
|
|
return sqls;
|
|
|
}
|
|
|
|
|
|
@@ -478,10 +489,10 @@ public class ERPServiceImpl implements ERPService {
|
|
|
SqlRowList bluePiao = baseDao.queryForRowSet("select ei_id,ei_redapplyid,ei_billStatus,ei_billNo,ei_billUuid,ei_taxExcludedAmount,ei_taxAmount,ei_redReason " +
|
|
|
"from elecinvoice " +
|
|
|
"where ei_ioid = '"+ioid+"' "+(eiid>0?"and ei_id = "+eiid:"")
|
|
|
- +" and EI_INVOICETYPE = '1' and ei_redapplyid is not null and EI_RELATIVEREFNO is null and nvl(ei_billStatus,' ') in (' ','02','03') " +
|
|
|
+ +" and EI_INVOICETYPE = '1' and ei_redapplyid is not null and EI_RELATIVEREFNO is null and nvl(ei_billStatus,' ') in (' ','01','02','03') " +
|
|
|
"order by ei_Detno");
|
|
|
if(bluePiao.hasNext()){
|
|
|
- Map<Integer,List<String>> serialNoLists = new HashMap<>();
|
|
|
+ boolean isRushRedBill = false;
|
|
|
while (bluePiao.next()){
|
|
|
String redApplyId =bluePiao.getGeneralString("ei_redapplyid");
|
|
|
eiid = bluePiao.getGeneralInt("ei_id");
|
|
|
@@ -492,8 +503,6 @@ public class ERPServiceImpl implements ERPService {
|
|
|
String rCode = "-999";
|
|
|
String describe = "";
|
|
|
String logCode = "发票红字确认状态查询";
|
|
|
- List<String> serialNos = new ArrayList<>();
|
|
|
- boolean isRushRedBill = false;
|
|
|
try {
|
|
|
QueryInvoiceRedConfirmResp qircResp = nuoNuoSDKService.queryInvoiceRedConfirm(qircReq,m);
|
|
|
rCode = qircResp.getCode();
|
|
|
@@ -520,13 +529,9 @@ public class ERPServiceImpl implements ERPService {
|
|
|
if("1".equals(qircfDTO.getOpenStatus())){ //已开具红字发票标记: 1:已开具 0:未开具 //orderNo 20230731182154174492
|
|
|
isRushRedBill = true;
|
|
|
// serialNos 流水号 -- EI_SID -- invoiceSerialNum ; orderNos 开票单号 --- EI_ORDERNO -- ORDERNO
|
|
|
-// serialNos.add(qircfDTO.getInvoiceSerialNum());
|
|
|
}
|
|
|
}
|
|
|
baseDao.execute(sqls);
|
|
|
- if(serialNos.size()>0){
|
|
|
- serialNoLists.put(eiid,serialNos);
|
|
|
- }
|
|
|
describe = "";
|
|
|
}else{
|
|
|
if(describe.length() > 3980){
|
|
|
@@ -550,11 +555,14 @@ public class ERPServiceImpl implements ERPService {
|
|
|
errmsg.append(describe);
|
|
|
}
|
|
|
}
|
|
|
-// if(isRushRedBill){
|
|
|
-// map = getElecInvoices(m);
|
|
|
-// }
|
|
|
- if(serialNoLists.size()>0){
|
|
|
- queryInvoiceResultByserialNos(serialNoLists,m);
|
|
|
+ if(isRushRedBill){
|
|
|
+ Map<String,Object> elM = new HashMap<>();
|
|
|
+ elM.put("appKey",m.get("appKey"));
|
|
|
+ elM.put("appSecret",m.get("appSecret"));
|
|
|
+ elM.put("token",m.get("token"));
|
|
|
+ elM.put("taxnum",m.get("taxnum"));
|
|
|
+ elM.put("io_id",ioid);
|
|
|
+ getElecInvoices(elM);
|
|
|
}
|
|
|
}
|
|
|
if(errmsg.length()>0){
|
|
|
@@ -565,25 +573,13 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
- private Map<String,Object> queryRedPdfUrl(){
|
|
|
- Map<String,Object> res = new HashMap<>();
|
|
|
- List<String> serialNos = baseDao.queryForList("",String.class);
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
//根据红票流水号 获取红票号及其他信息
|
|
|
- private Map<String,Object> queryInvoiceResultByserialNos(Map<Integer,List<String>> serialNoLists,Map<String,Object> m){
|
|
|
+ public Map<String,Object> queryRedPdfUrl(List<String> serialNosAll,Map<String,Object> m){
|
|
|
Map<String,Object> res = new HashMap<>();
|
|
|
String describe = "";
|
|
|
- int eiid = 0;
|
|
|
try {
|
|
|
+ logger.info("ElecI-queryRedPdfUrl:master {} ,serialNosAll {}",SpObserver.getSp(),serialNosAll.toString());
|
|
|
List<String> rSql = new ArrayList<String>();
|
|
|
- Set<Integer> eiSet = serialNoLists.keySet();
|
|
|
- List<String> serialNosAll = new ArrayList<>();
|
|
|
- for (int eiid_ : eiSet) {
|
|
|
- eiid = eiid_;
|
|
|
- serialNosAll.addAll(serialNoLists.get(eiid));
|
|
|
- }
|
|
|
if(serialNosAll.size()>0){
|
|
|
Stream.iterate(0, n -> n + 1)
|
|
|
.limit((int) Math.ceil((double) serialNosAll.size() / 50)).forEach(page -> {
|
|
|
@@ -592,10 +588,10 @@ public class ERPServiceImpl implements ERPService {
|
|
|
qirReq.setIsOfferInvoiceDetail("0");
|
|
|
qirReq.setSerialNos(serialNos);
|
|
|
QueryInvoiceResultResp qirResp = nuoNuoSDKService.queryInvoiceResult(qirReq,m);
|
|
|
- List<QueryInvoiceResultDTO> list = qirResp.getList();
|
|
|
+ List<QueryInvoiceResultDTO> list = qirResp.getResult();
|
|
|
if(!CollectionUtil.isEmpty(list)){
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
- String sql = list.get(i).toUpdateSql();
|
|
|
+ String sql = list.get(i).updatePdfUrlSql();
|
|
|
if(!"".equals(sql)){
|
|
|
rSql.add(sql);
|
|
|
}
|
|
|
@@ -603,10 +599,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- String sqls = "update ELECINVOICE set ei_rushredstate = (case when abs(nvl(ei_taxexcludedamount,0)) = 0 then 0 when abs(nvl(ei_taxexcludedamount,0)) < abs(nvl(ei_calcexcludingtaxamount,0)) then 2 else 1 end) " +
|
|
|
- " where ei_id in ("+eiSet.toString()+")";
|
|
|
- rSql.add(sqls);
|
|
|
- System.out.println("rSql:"+rSql.toString());
|
|
|
+// System.out.println("rSql:"+rSql.toString());
|
|
|
baseDao.execute(rSql);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
@@ -616,7 +609,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}else if(e.getCause()!=null&&StringUtil.hasText(e.getCause().getMessage())){
|
|
|
describe = e.getCause().getMessage();
|
|
|
}
|
|
|
- commonService.logFRecord("查询红票详情",describe.replaceAll("'","''"),eiid);
|
|
|
+ commonService.logFRecord("查询红票详情",describe.replaceAll("'","''"),0);
|
|
|
}
|
|
|
return res;
|
|
|
}
|