| | |
| | | import com.integrated.zyyt.enetity.business.Zyyt; |
| | | import com.integrated.zyyt.util.ZyytUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Date; |
| | |
| | | |
| | | @Service |
| | | @Slf4j |
| | | @Transactional(rollbackFor = Exception.class) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public class ZyytService { |
| | | @Resource |
| | | private JdbcTemplate jdbcTemplate; |
| | |
| | | } |
| | | |
| | | Zyyt<StationInfo> stationInfoService = ZyytUtil.getBusinessEntity("STATIONINFO", yestDay); |
| | | String exeSql = "merge into STATIONINFO A USING" + " (select ? V_JGBH from dual ) C " + "ON(A.V_JGBH=C.V_JGBH) " + "when matched then " + "update SET A.V_SFMC=?,A.V_SFDM=?,A.V_DSDM=?,A.V_DSMC=?,A.V_QXDM=?,A.V_XSMC=?,A.V_TDJGBH=?,A.V_TDJGMC=?,A.V_JGMC=?,A.V_LXRXM=?,A.V_LXDH=?,A.V_SJHM=?,A.V_LXDZ=?,A.ISCOUNTRY=?,A.C_WDLX =?,A.C_YZBM=?,A.V_YYWDBH=?,A.V_YYWDMC=?,A.V_GPSJD=?,A.V_GPSWD=?,A.YLGZDID =?,A.YLGZDMC=?,A.V_STATUS=?,A.D_SQRQ=?,A.D_SPRQ=?" + "when not matched then " + "insert(A.V_SFMC,A.V_SFDM,A.V_DSDM,A.V_DSMC,A.V_QXDM,A.V_XSMC,A.V_TDJGBH,A.V_TDJGMC,A.V_JGBH,A.V_JGMC,A.V_LXRXM,A.V_LXDH,A.V_SJHM,A.V_LXDZ,A.ISCOUNTRY,A.C_WDLX ,A.C_YZBM,A.V_YYWDBH,A.V_YYWDMC,A.V_GPSJD,A.V_GPSWD,A.YLGZDID ,A.YLGZDMC,A.V_STATUS,A.D_SQRQ,A.D_SPRQ) values " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | |
| | | // String exeSql = "merge into STATIONINFO A USING" + " (select ? V_JGBH from dual ) C " + "ON(A.V_JGBH=C.V_JGBH) " + "when matched then " + "update SET A.V_SFMC=?,A.V_SFDM=?,A.V_DSDM=?,A.V_DSMC=?,A.V_QXDM=?,A.V_XSMC=?,A.V_TDJGBH=?,A.V_TDJGMC=?,A.V_JGMC=?,A.V_LXRXM=?,A.V_LXDH=?,A.V_SJHM=?,A.V_LXDZ=?,A.ISCOUNTRY=?,A.C_WDLX =?,A.C_YZBM=?,A.V_YYWDBH=?,A.V_YYWDMC=?,A.V_GPSJD=?,A.V_GPSWD=?,A.YLGZDID =?,A.YLGZDMC=?,A.V_STATUS=?,A.D_SQRQ=?,A.D_SPRQ=?" + "when not matched then " + "insert(A.V_SFMC,A.V_SFDM,A.V_DSDM,A.V_DSMC,A.V_QXDM,A.V_XSMC,A.V_TDJGBH,A.V_TDJGMC,A.V_JGBH,A.V_JGMC,A.V_LXRXM,A.V_LXDH,A.V_SJHM,A.V_LXDZ,A.ISCOUNTRY,A.C_WDLX ,A.C_YZBM,A.V_YYWDBH,A.V_YYWDMC,A.V_GPSJD,A.V_GPSWD,A.YLGZDID ,A.YLGZDMC,A.V_STATUS,A.D_SQRQ,A.D_SPRQ) values " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | Long recordId = stationInfoService.insertRecord("STATIONINFO", batchNo); |
| | | String exeSql = "merge into STATIONINFO A USING" + " (select ? V_JGBH, ? CPBD_LOAD_DT from dual ) C " + "ON(A.V_JGBH=C.V_JGBH) " + "when matched then " + "update SET A.CPBD_LOAD_DT=?, A.V_SFMC=?,A.V_SFDM=?,A.V_DSDM=?,A.V_DSMC=?,A.V_QXDM=?,A.V_XSMC=?,A.V_TDJGBH=?,A.V_TDJGMC=?,A.V_JGMC=?,A.V_LXRXM=?,A.V_LXDH=?,A.V_SJHM=?,A.V_LXDZ=?,A.ISCOUNTRY=?,A.C_WDLX =?,A.C_YZBM=?,A.V_YYWDBH=?,A.V_YYWDMC=?,A.V_GPSJD=?,A.V_GPSWD=?,A.YLGZDID =?,A.YLGZDMC=?,A.V_STATUS=?,A.D_SQRQ=?,A.D_SPRQ=? where A.CPBD_LOAD_DT < C.CPBD_LOAD_DT " + "when not matched then " + "insert(A.V_SFMC,A.V_SFDM,A.V_DSDM,A.V_DSMC,A.V_QXDM,A.V_XSMC,A.V_TDJGBH,A.V_TDJGMC,A.V_JGBH,A.V_JGMC,A.V_LXRXM,A.V_LXDH,A.V_SJHM,A.V_LXDZ,A.ISCOUNTRY,A.C_WDLX ,A.C_YZBM,A.V_YYWDBH,A.V_YYWDMC,A.V_GPSJD,A.V_GPSWD,A.YLGZDID ,A.YLGZDMC,A.V_STATUS,A.D_SQRQ,A.D_SPRQ,A.CPBD_LOAD_DT) values " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | Long totalSize = 0L; |
| | | |
| | | int pageNum = 0; |
| | | int pageSize = 1000; |
| | | // int pageSize = 1000; |
| | | |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | // Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | |
| | | try { |
| | | // 查询总数 |
| | | Long totalElements = ZyytUtil.getApiTotalElements("STATIONINFO", yestDay); |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, pageSize); |
| | | log.info("共{}条数据,每页{}条,可分{}页,", totalElements, pageSize, totalPages); |
| | | if (totalElements == null || totalElements == 0) { |
| | | log.info("共0条数据"); |
| | | stationInfoService.updateRecord(recordId, 0, totalSize, "未拉取到数据"); |
| | | return; |
| | | } |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, PAGESIZE); |
| | | log.info("共{}条数据,每页{}条,可分{}页,", totalElements, PAGESIZE, totalPages); |
| | | for (pageNum = 0; pageNum <= totalPages - 1; pageNum++) { |
| | | ZyytDataResult<StationInfo> zyytDataResult = stationInfoService.getData(pageNum, pageSize); |
| | | ZyytDataResult<StationInfo> zyytDataResult = stationInfoService.getData(pageNum, PAGESIZE); |
| | | |
| | | List<StationInfo> stationInfoList = zyytDataResult.getContent(); |
| | | log.info("第{}次获取,本次获取到{}条数据", pageNum + 1, zyytDataResult.getContentSize()); |
| | |
| | | StationInfo stationInfo = stationInfoListCopy.get(i); |
| | | // log.info("stationInfo==> {}", JSON.toJSONString(stationInfo)); |
| | | |
| | | ps.setObject(1, stationInfo.getVJgbh()); |
| | | ps.setString(1, stationInfo.getVJgbh()); |
| | | // 6.14新增 |
| | | // 查询用 |
| | | ps.setDate(2, stationInfo.getCpbdLoadDt() == null ? null : |
| | | new Date(stationInfo.getCpbdLoadDt().getTime())); |
| | | // 更新用 |
| | | ps.setDate(3, stationInfo.getCpbdLoadDt() == null ? null : |
| | | new Date(stationInfo.getCpbdLoadDt().getTime())); |
| | | |
| | | ps.setObject(2, stationInfo.getVSfmc()); |
| | | ps.setObject(3, stationInfo.getVSfdm()); |
| | | ps.setObject(4, stationInfo.getVDsdm()); |
| | | ps.setObject(5, stationInfo.getVDsmc()); |
| | | ps.setObject(6, stationInfo.getVQxdm()); |
| | | ps.setObject(7, stationInfo.getVXsmc()); |
| | | ps.setObject(8, stationInfo.getVTdjgbh()); |
| | | ps.setObject(9, stationInfo.getVTdjgmc()); |
| | | ps.setObject(10, stationInfo.getVJgmc()); |
| | | ps.setObject(11, stationInfo.getVLxrxm()); |
| | | ps.setObject(12, stationInfo.getVLxdh()); |
| | | ps.setObject(13, stationInfo.getVSjhm()); |
| | | ps.setObject(14, stationInfo.getVLxdz()); |
| | | ps.setObject(15, stationInfo.getIscountry()); |
| | | ps.setObject(16, stationInfo.getCWdlx()); |
| | | ps.setObject(17, stationInfo.getCYzbm()); |
| | | ps.setObject(18, stationInfo.getVYywdbh()); |
| | | ps.setObject(19, stationInfo.getVYywdmc()); |
| | | ps.setObject(20, stationInfo.getVGpsjd()); |
| | | ps.setObject(21, stationInfo.getVGpswd()); |
| | | ps.setObject(22, stationInfo.getYlgzdid()); |
| | | ps.setObject(23, stationInfo.getYlgzdmc()); |
| | | ps.setObject(24, stationInfo.getVStatus()); |
| | | ps.setDate(25, new Date(stationInfo.getDSqrq().getTime())); |
| | | // ps.setObject(25, stationInfo.getDSqrq()); |
| | | // ps.setObject(26, stationInfo.getDSprq()); |
| | | ps.setDate(26, new Date(stationInfo.getDSprq().getTime())); |
| | | ps.setString(4, stationInfo.getVSfmc()); |
| | | ps.setString(5, stationInfo.getVSfdm()); |
| | | ps.setString(6, stationInfo.getVDsdm()); |
| | | ps.setString(7, stationInfo.getVDsmc()); |
| | | ps.setString(8, stationInfo.getVQxdm()); |
| | | ps.setString(9, stationInfo.getVXsmc()); |
| | | ps.setString(10, stationInfo.getVTdjgbh()); |
| | | ps.setString(11, stationInfo.getVTdjgmc()); |
| | | ps.setString(12, stationInfo.getVJgmc()); |
| | | ps.setString(13, stationInfo.getVLxrxm()); |
| | | ps.setString(14, stationInfo.getVLxdh()); |
| | | ps.setString(15, stationInfo.getVSjhm()); |
| | | ps.setString(16, stationInfo.getVLxdz()); |
| | | ps.setString(17, stationInfo.getIscountry()); |
| | | ps.setShort(18, stationInfo.getCWdlx()); |
| | | ps.setString(19, stationInfo.getCYzbm()); |
| | | ps.setString(20, stationInfo.getVYywdbh()); |
| | | ps.setString(21, stationInfo.getVYywdmc()); |
| | | ps.setString(22, stationInfo.getVGpsjd()); |
| | | ps.setString(23, stationInfo.getVGpswd()); |
| | | ps.setString(24, stationInfo.getYlgzdid()); |
| | | ps.setString(25, stationInfo.getYlgzdmc()); |
| | | ps.setString(26, stationInfo.getVStatus()); |
| | | // ps.setDate(25, new Date(stationInfo.getDSqrq().getTime())); |
| | | ps.setDate(27, |
| | | stationInfo.getDSqrq() == null ? null : |
| | | new Date(stationInfo.getDSqrq().getTime())); |
| | | // ps.setString(25, stationInfo.getDSqrq()); |
| | | // ps.setString(26, stationInfo.getDSprq()); |
| | | ps.setDate(28, stationInfo.getDSprq() == null ? null : |
| | | new Date(stationInfo.getDSprq().getTime())); |
| | | |
| | | ps.setObject(27, stationInfo.getVSfmc()); |
| | | ps.setObject(28, stationInfo.getVSfdm()); |
| | | ps.setObject(29, stationInfo.getVDsdm()); |
| | | ps.setObject(30, stationInfo.getVDsmc()); |
| | | ps.setObject(31, stationInfo.getVQxdm()); |
| | | ps.setObject(32, stationInfo.getVXsmc()); |
| | | ps.setObject(33, stationInfo.getVTdjgbh()); |
| | | ps.setObject(34, stationInfo.getVTdjgmc()); |
| | | ps.setObject(35, stationInfo.getVJgbh()); |
| | | ps.setObject(36, stationInfo.getVJgmc()); |
| | | ps.setObject(37, stationInfo.getVLxrxm()); |
| | | ps.setObject(38, stationInfo.getVLxdh()); |
| | | ps.setObject(39, stationInfo.getVSjhm()); |
| | | ps.setObject(40, stationInfo.getVLxdz()); |
| | | ps.setObject(41, stationInfo.getIscountry()); |
| | | ps.setObject(42, stationInfo.getCWdlx()); |
| | | ps.setObject(43, stationInfo.getCYzbm()); |
| | | ps.setObject(44, stationInfo.getVYywdbh()); |
| | | ps.setObject(45, stationInfo.getVYywdmc()); |
| | | ps.setObject(46, stationInfo.getVGpsjd()); |
| | | ps.setObject(47, stationInfo.getVGpswd()); |
| | | ps.setObject(48, stationInfo.getYlgzdid()); |
| | | ps.setObject(49, stationInfo.getYlgzdmc()); |
| | | ps.setObject(50, stationInfo.getVStatus()); |
| | | // ps.setObject(51, stationInfo.getDSqrq()); |
| | | ps.setDate(51, new Date(stationInfo.getDSqrq().getTime())); |
| | | ps.setString(29, stationInfo.getVSfmc()); |
| | | ps.setString(30, stationInfo.getVSfdm()); |
| | | ps.setString(31, stationInfo.getVDsdm()); |
| | | ps.setString(32, stationInfo.getVDsmc()); |
| | | ps.setString(33, stationInfo.getVQxdm()); |
| | | ps.setString(34, stationInfo.getVXsmc()); |
| | | ps.setString(35, stationInfo.getVTdjgbh()); |
| | | ps.setString(36, stationInfo.getVTdjgmc()); |
| | | ps.setString(37, stationInfo.getVJgbh()); |
| | | ps.setString(38, stationInfo.getVJgmc()); |
| | | ps.setString(39, stationInfo.getVLxrxm()); |
| | | ps.setString(40, stationInfo.getVLxdh()); |
| | | ps.setString(41, stationInfo.getVSjhm()); |
| | | ps.setString(42, stationInfo.getVLxdz()); |
| | | ps.setString(43, stationInfo.getIscountry()); |
| | | ps.setShort(44, stationInfo.getCWdlx()); |
| | | ps.setString(45, stationInfo.getCYzbm()); |
| | | ps.setString(46, stationInfo.getVYywdbh()); |
| | | ps.setString(47, stationInfo.getVYywdmc()); |
| | | ps.setString(48, stationInfo.getVGpsjd()); |
| | | ps.setString(49, stationInfo.getVGpswd()); |
| | | ps.setString(50, stationInfo.getYlgzdid()); |
| | | ps.setString(51, stationInfo.getYlgzdmc()); |
| | | ps.setString(52, stationInfo.getVStatus()); |
| | | // ps.setString(51, stationInfo.getDSqrq()); |
| | | ps.setDate(53, stationInfo.getDSqrq() == null ? null : new Date(stationInfo.getDSqrq().getTime())); |
| | | |
| | | ps.setObject(52, stationInfo.getDSprq()); |
| | | ps.setDate(52, new Date(stationInfo.getDSprq().getTime())); |
| | | ps.setDate(54, stationInfo.getDSprq() == null ? null : new Date(stationInfo.getDSprq().getTime())); |
| | | |
| | | //6.14新增 insert用 |
| | | ps.setDate(55, stationInfo.getCpbdLoadDt() == null ? null : |
| | | new Date(stationInfo.getCpbdLoadDt().getTime())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | } catch (Exception e) { |
| | | log.error("设置参数值报错了"); |
| | | e.printStackTrace(); |
| | | // e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | //手工回滚异常 |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | // TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, e.getMessage()); |
| | | return; |
| | | } |
| | | //试试代码 |
| | | // break; |
| | | } |
| | | //试试代码 |
| | | // break; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | |
| | | log.info("···········中邮易通 {}站点信息 任务执行完毕···········", yestDay); |
| | | } |
| | | |
| | | private int PAGESIZE = 1000; |
| | | |
| | | @Value("${pullData.pageSize}") |
| | | public void setTRYNUM(Integer pageSize) { |
| | | pageSize = pageSize <= 0 ? 1000 : pageSize; |
| | | this.PAGESIZE = pageSize; |
| | | } |
| | | |
| | | //社会快递日报表 |
| | | |
| | |
| | | log.info("YYZT_T_SHKDRB 的 批次{}正在运行", batchNo); |
| | | return; |
| | | } |
| | | Zyyt<YyztTShkdrb> stationInfoService = ZyytUtil.getBusinessEntity("YYZT_T_SHKDRB", date); |
| | | Long recordId = stationInfoService.insertRecord("YYZT_T_SHKDRB", batchNo); |
| | | |
| | | // 删除已有批次数据 |
| | | String delSql = "delete from YYZT_T_SHKDRB where BATCH_NO='" + batchNo + "'"; |
| | | jdbcTemplate.update(delSql); |
| | | |
| | | Zyyt<YyztTShkdrb> stationInfoService = ZyytUtil.getBusinessEntity("YYZT_T_SHKDRB", date); |
| | | Long recordId = stationInfoService.insertRecord("YYZT_T_SHKDRB", batchNo); |
| | | Long totalSize = 0L; |
| | | Long totalElements = 0L; |
| | | |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | // Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | int pageNum = 0; |
| | | int pageSize = 1000; |
| | | // int pageSize = 1000; |
| | | |
| | | String batchInsertSql = "INSERT INTO YYZT_T_SHKDRB (\"V_SFDM\",\"V_SFMC\",\"V_DSDM\",\"V_DSMC\",\"V_QXDM\",\"V_XSMC\",\"V_TDJGBH\",\"V_TDJGMC\",\"V_JGBH\",\"V_JGMC\",\"D_RBRQ\",\"N_ZGYZLJS\",\"N_ZGYZQJS\",\"N_SHKDLJS\",\"N_SHKDQJS\",\"N_ZTLJS\",\"N_ZTQJS\",\"N_YTLJS\",\"N_YTQJS\",\"N_STLJS\",\"N_STQJS\",\"N_BSLJS\",\"N_BSQJS\",\"N_YDLJS\",\"N_YDQJS\",\"N_YFLJS\",\"N_YFQJS\",\"N_JDLJS\",\"N_JDQJS\",\"N_JTLJS\",\"N_JTQJS\",\"N_TTLJS\",\"N_TTQJS\",\"N_DBLJS\",\"N_DBQJS\",\"N_DNLJS\",\"N_DNQJS\",\"N_FWLJS\",\"N_FWQJS\",\"N_YSLJS\",\"N_YSQJS\",\"N_QTLJS\",\"N_QTQJS\",\"RESERVED1\",\"RESERVED2\",\"RESERVED3\",\"RESERVED4\",\"BATCH_NO\") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | |
| | | // 查询总数 |
| | | Long totalElements = ZyytUtil.getApiTotalElements("YYZT_T_SHKDRB", date); |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, pageSize); |
| | | log.info("社会快递日报表(YYZT_T_SHKDRB) 共{}条数据,每页{}条,可分{}页,", totalElements, pageSize, totalPages); |
| | | totalElements = ZyytUtil.getApiTotalElements("YYZT_T_SHKDRB", date); |
| | | if (totalElements == null || totalElements == 0) { |
| | | log.info("共0条数据"); |
| | | stationInfoService.updateRecord(recordId, 0, totalSize, "未拉取到数据"); |
| | | return; |
| | | } |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, PAGESIZE); |
| | | log.info("社会快递日报表(YYZT_T_SHKDRB) 共{}条数据,每页{}条,可分{}页,", totalElements, PAGESIZE, totalPages); |
| | | |
| | | for (pageNum = 0; pageNum <= totalPages - 1; pageNum++) { |
| | | ZyytDataResult<YyztTShkdrb> zyytDataResult = stationInfoService.getData(pageNum, pageSize); |
| | | ZyytDataResult<YyztTShkdrb> zyytDataResult = stationInfoService.getData(pageNum, PAGESIZE); |
| | | |
| | | List<YyztTShkdrb> stationInfoList = zyytDataResult.getContent(); |
| | | totalSize += zyytDataResult.getContentSize(); |
| | |
| | | item.getReserved2(), |
| | | item.getReserved3(), |
| | | item.getReserved4(), |
| | | item.getBatchNo() |
| | | }); |
| | | batchNo}); |
| | | }); |
| | | jdbcTemplate.batchUpdate(batchInsertSql, insertShkdrbList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | //手工回滚异常 |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | // TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, e.getMessage()); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } catch ( |
| | | Exception e) { |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, e.getMessage()); |
| | | return; |
| | | } |
| | | if (totalSize != totalElements) { |
| | | log.error("拉取到的总条数:{}与接口显示的总条数:{}不一致,删除拉取到数据! ", totalSize, totalElements); |
| | | jdbcTemplate.update(delSql); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, "拉取到的总条数与接口显示的总条数不一致!"); |
| | | return; |
| | | } |
| | | stationInfoService.updateRecord(recordId, 0, totalSize, null); |
| | |
| | | log.info("YYZT_T_DJTJB 的 批次{}正在运行", batchNo); |
| | | return; |
| | | } |
| | | Zyyt<YyztTDjtjb> stationInfoService = ZyytUtil.getBusinessEntity("YYZT_T_DJTJB", date); |
| | | Long recordId = stationInfoService.insertRecord("YYZT_T_DJTJB", batchNo); |
| | | |
| | | // 删除已有批次数据 |
| | | String delSql = "delete from YYZT_T_DJTJB where BATCH_NO='" + batchNo + "'"; |
| | | jdbcTemplate.update(delSql); |
| | | |
| | | Zyyt<YyztTDjtjb> stationInfoService = ZyytUtil.getBusinessEntity("YYZT_T_DJTJB", date); |
| | | Long recordId = stationInfoService.insertRecord("YYZT_T_DJTJB", batchNo); |
| | | |
| | | Long totalSize = 0L; |
| | | Long totalElements = 0L; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | // Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | |
| | | try { |
| | | int pageNum = 0; |
| | | int pageSize = 1000; |
| | | // int pageSize = 1000; |
| | | |
| | | String batchInsertSql = "INSERT INTO YYZT_T_DJTJB (\"V_SFDM\", \"V_SFMC\", \"V_DSDM\", \"V_DSMC\", \"V_QXDM\", \"V_XSMC\", \"V_TDJGBH\", \"V_JGBH\", \"V_JGMC\", \"D_RBRQ\", \"V_YLGZDID\", \"V_YLGZDMC\", \"N_SJYWL\", \"N_TKYWL\", \"N_BKYEL\", \"N_SJZJE\", \"N_TKSR\", \"N_BKSR\", \"BATCH_NO\") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
| | | // 查询总数 |
| | | Long totalElements = ZyytUtil.getApiTotalElements("YYZT_T_DJTJB", date); |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, pageSize); |
| | | log.info("共{}条数据,每页{}条,可分{}页,", totalElements, pageSize, totalPages); |
| | | totalElements = ZyytUtil.getApiTotalElements("YYZT_T_DJTJB", date); |
| | | if (totalElements == null || totalElements == 0) { |
| | | log.info("共0条数据"); |
| | | stationInfoService.updateRecord(recordId, 0, totalSize, "未拉取到数据"); |
| | | return; |
| | | } |
| | | Long totalPages = ZyytUtil.calcPages(totalElements, PAGESIZE); |
| | | log.info("共{}条数据,每页{}条,可分{}页,", totalElements, PAGESIZE, totalPages); |
| | | |
| | | for (pageNum = 0; pageNum <= totalPages - 1; pageNum++) { |
| | | ZyytDataResult<YyztTDjtjb> zyytDataResult = stationInfoService.getData(pageNum, pageSize); |
| | | ZyytDataResult<YyztTDjtjb> zyytDataResult = stationInfoService.getData(pageNum, PAGESIZE); |
| | | List<YyztTDjtjb> djtjbList = zyytDataResult.getContent(); |
| | | totalSize += zyytDataResult.getContentSize(); |
| | | log.info("第{}次获取,本次获取到{}条数据", pageNum + 1, zyytDataResult.getContentSize()); |
| | |
| | | item.getNSjzje(), |
| | | item.getNTksr(), |
| | | item.getNBksr(), |
| | | item.getBatchNo() |
| | | batchNo |
| | | }); |
| | | }); |
| | | jdbcTemplate.batchUpdate(batchInsertSql, insertShkdrbList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | //手工回滚异常 |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | // TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, e.getMessage()); |
| | | return; |
| | | } |
| | |
| | | stationInfoService.updateRecord(recordId, 1, 0L, e.getMessage()); |
| | | return; |
| | | } |
| | | |
| | | if (totalSize != totalElements) { |
| | | log.error("拉取到的总条数:{}与接口显示的总条数:{}不一致,删除拉取到数据! ", totalSize, totalElements); |
| | | jdbcTemplate.update(delSql); |
| | | stationInfoService.updateRecord(recordId, 1, 0L, "拉取到的总条数与接口显示的总条数不一致!"); |
| | | return; |
| | | } |
| | | stationInfoService.updateRecord(recordId, 0, totalSize, null); |
| | | log.info("···········中邮易通 代寄统计表 -- [{}] 任务执行完毕···········", date); |
| | | } |