a85357bee4f91cd1e27879d5358f7301308b4222.svn-base 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.util.DataSource;
  3. import com.frameworkset.common.poolman.SQLExecutor;
  4. import oracle.sql.CLOB;
  5. import org.springframework.stereotype.Component;
  6. import java.io.BufferedReader;
  7. import java.io.IOException;
  8. import java.io.Reader;
  9. import java.sql.SQLException;
  10. import java.util.HashMap;
  11. import java.util.List;
  12. @Component
  13. public class NewYearVideoDao {
  14. /**
  15. * 获取配置数据
  16. * @return
  17. * @throws SQLException
  18. */
  19. public List<HashMap> getpushData()throws SQLException {
  20. String sql = " SELECT id,userid,base64code,videomodules FROM TD_WXVIDEO_QUEUE A WHERE A.STATUS = '-1' order by seqnumber";
  21. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
  22. }
  23. public List<HashMap> getData()throws SQLException {
  24. String sql = " SELECT id,userid,returnvideourl,modulesname,modulestime FROM TD_WXVIDEO_QUEUE A WHERE A.STATUS = '0' order by seqnumber";
  25. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
  26. }
  27. public List<HashMap> getFailData()throws SQLException {
  28. String sql = " SELECT id,userid,TO_CHAR(finishtime,'yyyy-MM-dd HH:mm:ss') finishtime FROM TD_WXVIDEO_QUEUE A WHERE A.STATUS = '6' order by seqnumber";
  29. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
  30. }
  31. /**
  32. * 获取流水号
  33. * @return
  34. */
  35. public String getNo()throws SQLException {
  36. String sql = " SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval SENO FROM DUAL";
  37. return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G, sql);
  38. }
  39. /**
  40. * 更新状态为下载视频并调cdn接口等
  41. * @return
  42. */
  43. public void updateHasDowload(String id)throws SQLException {
  44. String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '3' WHERE id=?";
  45. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
  46. }
  47. /**
  48. * 更新状态为全部完成
  49. * @return
  50. */
  51. public void updateHasFinish(String id,String resultcode,String resultinfo,String videourl)throws SQLException {
  52. String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '4',HASCACHE = '0',VIDEOURL=?,RESULTCODE=?,RESULTINFO=? WHERE id=?";
  53. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,videourl,resultcode,resultinfo,id);
  54. }
  55. /**
  56. * 更新状态回滚重试
  57. * @return
  58. */
  59. public void updateRowback(String id)throws SQLException {
  60. String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '0' ,HASCACHE = '-1' WHERE id=?";
  61. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
  62. }
  63. /**
  64. * 更新状态回滚重试
  65. * @return
  66. */
  67. public void updateRowbackPhotos(String id)throws SQLException {
  68. String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '-1' WHERE id=?";
  69. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
  70. }
  71. /**
  72. * 更新状态为处理中
  73. * @return
  74. */
  75. public void updateProcessing(String id)throws SQLException {
  76. String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '1' WHERE id=?";
  77. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
  78. }
  79. /**
  80. * 更新状态为已提交工单
  81. * @return
  82. */
  83. public void upHasSubmit(String id,String resultcode,String resultinfo,String photosurl)throws SQLException {
  84. String sql = "UPDATE TD_WXVIDEO_QUEUE SET STATUS = '2',PHOTOSURL=?,RESULTCODE=?,RESULTINFO=? WHERE id=?";
  85. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,photosurl,resultcode,resultinfo,id);
  86. }
  87. /**
  88. * 更新状态为已通知
  89. * @return
  90. */
  91. public void updateHasNotify(String id,String resultcode,String resultinfo)throws SQLException {
  92. String sql = "UPDATE TD_WXVIDEO_QUEUE SET STATUS = '7',RESULTCODE=?,RESULTINFO=? WHERE id=?";
  93. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,resultcode,resultinfo,id);
  94. }
  95. public static void main(String[] args) throws Exception{
  96. NewYearVideoDao dao = new NewYearVideoDao();
  97. dao.updateProcessing("20210201144255000001");
  98. // List<HashMap> maps = dao.getpushData();
  99. // CLOB clob = (CLOB) maps.get(0).get("BASE64CODE");
  100. // String[] base64 = ClobToString(clob).split(",");
  101. // int flag = 0;
  102. // for(String s:base64) {
  103. // BASE64Decoder decoder = new BASE64Decoder();
  104. // //base64解码
  105. // byte[] bytes = decoder.decodeBuffer(s);
  106. // flag++;
  107. // FileOutputStream fout = new FileOutputStream("F:\\"+flag+".jpg");
  108. // //将字节写入文件
  109. // fout.write(bytes);
  110. // fout.close();
  111. // }
  112. }
  113. // Clob类型 转String
  114. public static String ClobToString(CLOB clob) throws SQLException, IOException {
  115. String reString = "";
  116. Reader is = clob.getCharacterStream();
  117. BufferedReader br = new BufferedReader(is);
  118. String s = br.readLine();
  119. StringBuffer sb = new StringBuffer();
  120. while (s != null) {
  121. sb.append(s);
  122. s = br.readLine();
  123. }
  124. reString = sb.toString();
  125. if(br!=null){
  126. br.close();
  127. }
  128. if(is!=null){
  129. is.close();
  130. }
  131. return reString;
  132. }
  133. }