diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforAssistContract.java b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforAssistContract.java index 37475d154..0fa41d80b 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforAssistContract.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforAssistContract.java @@ -360,7 +360,7 @@ public class VoucherToNCforAssistContract implements Job{ int con=0; for (String old_batch : batchList) { // 查询集合, 获取旧批次的失败总数 - String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH;"; + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH"; List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); if(dataList!=null && dataList.size()>0) { con=Integer.valueOf(dataList.get(0).get("CON")); @@ -373,12 +373,27 @@ public class VoucherToNCforAssistContract implements Job{ Sqlca.executeSQL(updateSql); } } - - // count不等于0说明有新数据, 否则就只有旧的错误数据, 不需要新增 + // 如果count不等于0, 说明有新数据, 判断是否全部传输成功做相应新增操作 if(count != 0 ) { - insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+failed_count+"','含失败记录 !','"+formatter2.format(new Date())+"')"; - Sqlca.executeSQL(insertSql); - logger.info("本批次包含失败数据 !"); + int con=0; + // 查询本批次错误数据 + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+batch+"' GROUP BY BATCH;"; + List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); + // 如果有数据, 统计, 失败记录 + if(dataList!=null && dataList.size()>0) { + con=Integer.valueOf(dataList.get(0).get("CON")); + } + // 如果con等于0, 说明没有失败记录, 插入成功记录 + if(con==0) { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','Y','"+count+"','"+con+"','导入成功 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次传输成功!"); + // 如果con不等于0, 记录含失败记录的数据如总表 + }else { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+con+"','含失败记录 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次包含失败数据 !"); + } } // 状态为Y表示, 本次导入全部成功 diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforCustomer.java b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforCustomer.java index 59848c4ff..35a6c250c 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforCustomer.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforCustomer.java @@ -429,7 +429,7 @@ public class VoucherToNCforCustomer implements Job{ int con=0; for (String old_batch : batchList) { // 查询集合, 获取旧批次的失败总数 - String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH;"; + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH"; List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); if(dataList!=null && dataList.size()>0) { con=Integer.valueOf(dataList.get(0).get("CON")); @@ -442,12 +442,27 @@ public class VoucherToNCforCustomer implements Job{ Sqlca.executeSQL(updateSql); } } - - // count不等于0说明有新数据, 否则就只有旧的错误数据, 不需要新增 + // 如果count不等于0, 说明有新数据, 判断是否全部传输成功做相应新增操作 if(count != 0 ) { - insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+failed_count+"','含失败记录 !','"+formatter2.format(new Date())+"')"; - Sqlca.executeSQL(insertSql); - logger.info("本批次包含失败数据 !"); + int con=0; + // 查询本批次错误数据 + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+batch+"' GROUP BY BATCH;"; + List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); + // 如果有数据, 统计, 失败记录 + if(dataList!=null && dataList.size()>0) { + con=Integer.valueOf(dataList.get(0).get("CON")); + } + // 如果con等于0, 说明没有失败记录, 插入成功记录 + if(con==0) { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','Y','"+count+"','"+con+"','导入成功 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次传输成功!"); + // 如果con不等于0, 记录含失败记录的数据如总表 + }else { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+con+"','含失败记录 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次包含失败数据 !"); + } } // 状态为Y表示, 本次导入全部成功 @@ -485,4 +500,4 @@ public class VoucherToNCforCustomer implements Job{ logger.info("未找到successful属性"); } } -} \ No newline at end of file +} diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforDistributor.java b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforDistributor.java index 944e045e8..87da6ccde 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforDistributor.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforDistributor.java @@ -505,7 +505,7 @@ public class VoucherToNCforDistributor implements Job{ int con=0; for (String old_batch : batchList) { // 查询集合, 获取旧批次的失败总数 - String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH;"; + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH"; List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); if(dataList!=null && dataList.size()>0) { con=Integer.valueOf(dataList.get(0).get("CON")); @@ -518,12 +518,27 @@ public class VoucherToNCforDistributor implements Job{ Sqlca.executeSQL(updateSql); } } - - // count不等于0说明有新数据, 否则就只有旧的错误数据, 不需要新增 + // 如果count不等于0, 说明有新数据, 判断是否全部传输成功做相应新增操作 if(count != 0 ) { - insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+failed_count+"','含失败记录 !','"+formatter2.format(new Date())+"')"; - Sqlca.executeSQL(insertSql); - logger.info("本批次包含失败数据 !"); + int con=0; + // 查询本批次错误数据 + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+batch+"' GROUP BY BATCH;"; + List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); + // 如果有数据, 统计, 失败记录 + if(dataList!=null && dataList.size()>0) { + con=Integer.valueOf(dataList.get(0).get("CON")); + } + // 如果con等于0, 说明没有失败记录, 插入成功记录 + if(con==0) { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','Y','"+count+"','"+con+"','导入成功 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次传输成功!"); + // 如果con不等于0, 记录含失败记录的数据如总表 + }else { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+con+"','含失败记录 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次包含失败数据 !"); + } } // 状态为Y表示, 本次导入全部成功 diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforVoucherPZ.java b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforVoucherPZ.java index e5b16c9fc..9194213d0 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforVoucherPZ.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherToNCforVoucherPZ.java @@ -689,7 +689,7 @@ public class VoucherToNCforVoucherPZ implements Job{ int con=0; for (String old_batch : batchList) { // 查询集合, 获取旧批次的失败总数 - String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH;"; + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+old_batch+"' GROUP BY BATCH"; List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); if(dataList!=null && dataList.size()>0) { con=Integer.valueOf(dataList.get(0).get("CON")); @@ -702,12 +702,27 @@ public class VoucherToNCforVoucherPZ implements Job{ Sqlca.executeSQL(updateSql); } } - - // count不等于0说明有新数据, 否则就只有旧的错误数据, 不需要新增 + // 如果count不等于0, 说明有新数据, 判断是否全部传输成功做相应新增操作 if(count != 0 ) { - insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+failed_count+"','含失败记录 !','"+formatter2.format(new Date())+"')"; - Sqlca.executeSQL(insertSql); - logger.info("本批次包含失败数据 !"); + int con=0; + // 查询本批次错误数据 + String selectSql="SELECT BATCH,COUNT(BILLID) CON FROM ncxml_detail_records WHERE flag !=1 AND xml_type='"+type+"' AND BATCH='"+batch+"' GROUP BY BATCH;"; + List> dataList=DataOperatorUtil.getDataBySql(Sqlca, selectSql,null); + // 如果有数据, 统计, 失败记录 + if(dataList!=null && dataList.size()>0) { + con=Integer.valueOf(dataList.get(0).get("CON")); + } + // 如果con等于0, 说明没有失败记录, 插入成功记录 + if(con==0) { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','Y','"+count+"','"+con+"','导入成功 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次传输成功!"); + // 如果con不等于0, 记录含失败记录的数据如总表 + }else { + insertSql = "INSERT INTO NCXML_TOTAL_RECORDS(ID,BATCH,XML_TYPE,FLAG_,COUNT_,FAILED_COUNT,ERR_DESCRIBE,CREATETIME) VALUES('"+UUID.randomUUID().toString().replace("-", "")+"','"+batch+"','"+type+"','"+resSuc+"','"+count+"','"+con+"','含失败记录 !','"+formatter2.format(new Date())+"')"; + Sqlca.executeSQL(insertSql); + logger.info("本批次包含失败数据 !"); + } } // 状态为Y表示, 本次导入全部成功