123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package com.chinacreator.process.dao;
- import com.chinacreator.process.util.DataSource;
- import com.frameworkset.common.poolman.SQLExecutor;
- import oracle.sql.CLOB;
- import org.springframework.stereotype.Component;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.Reader;
- import java.sql.SQLException;
- import java.util.HashMap;
- import java.util.List;
- @Component
- public class NewYearVideoDao {
- /**
- * 获取配置数据
- * @return
- * @throws SQLException
- */
- public List<HashMap> getpushData()throws SQLException {
- String sql = " SELECT id,userid,base64code,videomodules FROM TD_WXVIDEO_QUEUE A WHERE A.STATUS = '-1' order by seqnumber";
- return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
- }
- public List<HashMap> getData()throws SQLException {
- String sql = " SELECT id,userid,returnvideourl,modulesname,modulestime FROM TD_WXVIDEO_QUEUE A WHERE A.STATUS = '0' order by seqnumber";
- return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
- }
- public List<HashMap> getFailData()throws SQLException {
- 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";
- return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
- }
-
- /**
- * 获取流水号
- * @return
- */
- public String getNo()throws SQLException {
- String sql = " SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval SENO FROM DUAL";
- return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G, sql);
- }
- /**
- * 更新状态为下载视频并调cdn接口等
- * @return
- */
- public void updateHasDowload(String id)throws SQLException {
- String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '3' WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
- }
- /**
- * 更新状态为全部完成
- * @return
- */
- public void updateHasFinish(String id,String resultcode,String resultinfo,String videourl)throws SQLException {
- String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '4',HASCACHE = '0',VIDEOURL=?,RESULTCODE=?,RESULTINFO=? WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,videourl,resultcode,resultinfo,id);
- }
- /**
- * 更新状态回滚重试
- * @return
- */
- public void updateRowback(String id)throws SQLException {
- String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '0' ,HASCACHE = '-1' WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
- }
- /**
- * 更新状态回滚重试
- * @return
- */
- public void updateRowbackPhotos(String id)throws SQLException {
- String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '-1' WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
- }
- /**
- * 更新状态为处理中
- * @return
- */
- public void updateProcessing(String id)throws SQLException {
- String sql = " UPDATE TD_WXVIDEO_QUEUE SET STATUS = '1' WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,id);
- }
- /**
- * 更新状态为已提交工单
- * @return
- */
- public void upHasSubmit(String id,String resultcode,String resultinfo,String photosurl)throws SQLException {
- String sql = "UPDATE TD_WXVIDEO_QUEUE SET STATUS = '2',PHOTOSURL=?,RESULTCODE=?,RESULTINFO=? WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,photosurl,resultcode,resultinfo,id);
- }
- /**
- * 更新状态为已通知
- * @return
- */
- public void updateHasNotify(String id,String resultcode,String resultinfo)throws SQLException {
- String sql = "UPDATE TD_WXVIDEO_QUEUE SET STATUS = '7',RESULTCODE=?,RESULTINFO=? WHERE id=?";
- SQLExecutor.updateWithDBName(DataSource.NET3G, sql,resultcode,resultinfo,id);
- }
-
- public static void main(String[] args) throws Exception{
- NewYearVideoDao dao = new NewYearVideoDao();
- dao.updateProcessing("20210201144255000001");
- // List<HashMap> maps = dao.getpushData();
- // CLOB clob = (CLOB) maps.get(0).get("BASE64CODE");
- // String[] base64 = ClobToString(clob).split(",");
- // int flag = 0;
- // for(String s:base64) {
- // BASE64Decoder decoder = new BASE64Decoder();
- // //base64解码
- // byte[] bytes = decoder.decodeBuffer(s);
- // flag++;
- // FileOutputStream fout = new FileOutputStream("F:\\"+flag+".jpg");
- // //将字节写入文件
- // fout.write(bytes);
- // fout.close();
- // }
- }
- // Clob类型 转String
- public static String ClobToString(CLOB clob) throws SQLException, IOException {
- String reString = "";
- Reader is = clob.getCharacterStream();
- BufferedReader br = new BufferedReader(is);
- String s = br.readLine();
- StringBuffer sb = new StringBuffer();
- while (s != null) {
- sb.append(s);
- s = br.readLine();
- }
- reString = sb.toString();
- if(br!=null){
- br.close();
- }
- if(is!=null){
- is.close();
- }
- return reString;
- }
- }
|