| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- package xin.glue.ui.B;
- import java.io.BufferedInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.zip.GZIPInputStream;
- import javax.servlet.http.HttpServletRequest;
- import xin.glue.ui.B.B02.MutilConditionFind;
- import xin.glue.ui.common.PosDBEngine;
- import xin.glue.ui.common.blob.PosExcelInterface;
- import com.posdata.glue.PosException;
- import com.posdata.glue.biz.constants.PosBizControlConstants;
- import com.posdata.glue.biz.control.PosBizProvider;
- import com.posdata.glue.context.PosContext;
- import com.posdata.glue.dao.vo.PosParameter;
- import com.posdata.glue.dao.vo.PosRow;
- import com.posdata.glue.dao.vo.PosRowSet;
- public class PosCertSave extends PosDBEngine {
- /*
- * 传入参数:
- * TMPL_NM - 模板名
- * 数据传入字段参数:
- * BLOBFILE
- */
- public String runActivity(PosContext ctx) {
- List dataList = new ArrayList();
- String[] resultKeys;
- HttpServletRequest request = (HttpServletRequest)ctx.findRequestAttr("HttpServletRequest");
- if (request.getParameter("resultKey") != null) {
- resultKeys = request.getParameter("resultKey").split("\\|");
- } else {
- resultKeys = (String[])ctx.get("ResultKeyList");
- }
- for (int i = 0, length = resultKeys.length; i < length; i++) {
- Object obj = ctx.get(resultKeys[i]);
- if (obj != null)
- dataList.add(obj);
- }
- //获取模板
- ctx.put(PosBizControlConstants.SERVICE_NAME, "Excel-Template-service");
- PosBizProvider.getController().doSubController(ctx, false);
- PosRowSet rowSet = (PosRowSet)ctx.get("ListResult_0");
- if (rowSet == null || !rowSet.hasNext())
- return PosBizControlConstants.SUCCESS;
- Initialize();
- PosRow row = rowSet.next();
- InputStream in = (InputStream)row.getAttribute("TMPL_CONTENT");
- if (in == null)
- return PosBizControlConstants.SUCCESS;
- String clsName = (String)row.getAttribute("JAVA_CLASS");
- if (clsName == null)
- return PosBizControlConstants.SUCCESS;
- PosExcelInterface excelInferface;
- try {
- excelInferface = (PosExcelInterface)Class.forName(clsName).newInstance();
- } catch (Exception e) {
- throw new PosException("Class " + clsName + " not exist!");
- }
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- try {
- excelInferface.setData(dataList, new BufferedInputStream(new GZIPInputStream(in)), bout,
- Integer.parseInt(row.getAttribute("DATA_ROW").toString()),
- Integer.parseInt(row.getAttribute("PAGE_SIZE").toString()));
- excelInferface = null;
- dataList.clear();
- in.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
-
- // try
- // {
- // File f1 = File.createTempFile("temp008", ".html");
- //// String sPath = f1.getCanonicalPath();
- // FileOutputStream fos = new FileOutputStream(f1);
- // fos.write(bout.toByteArray());
- // fos.close();
- //
- // }catch(Exception ex)
- // {
- // ex.printStackTrace();
- // }
-
-
- setParamMap(ctx, "sqlkey", "param");
- ctx.put("BLOBFILE", bout.toByteArray());
- // Execute(ctx, "sqlkey", "param", 'i');
-
- String[]INV_NO = (String[])ctx.get("INV_NO");
- String[]ORD_NO = (String[])ctx.get("ORD_NO");
- String[]ORD_SEQ = (String[])ctx.get("ORD_SEQ");
- String[]CUST_CD = (String[])ctx.get("CUST_CD");
- String[]ORDCUST_CD = (String[])ctx.get("ORDCUST_CD");
- String[]ORD_USE_TP = (String[])ctx.get("ORD_USE_TP");
- String[]SPEC_ABBSYM = (String[])ctx.get("SPEC_ABBSYM");
- String[]CAR_GP = (String[])ctx.get("CAR_GP");
- String[]SUM_WGT = (String[])ctx.get("SUM_WGT");
- String[]SUM_CNT = (String[])ctx.get("SUM_CNT");
- String[]ORD_DEVLMT_DATE=(String[])ctx.get("ORD_DEVLMT_DATE");//交货日期
- String[]TRNF_DTIME = (String[])ctx.get("TRNF_DTIME");//发货日期
- // String[]BLOBFILE = (String[])ctx.get("BLOBFILE");
-
- Connection con = null;
- PreparedStatement pstm = null;
- String[]CRET_NO = (String[])ctx.get("CRET_NO");
- try
- {
- String driverClassName = "oracle.jdbc.driver.OracleDriver";
- Class.forName(driverClassName);
- //连接数据库
- String url = "jdbc:oracle:thin:@172.16.0.109:1521:mestest";
- String userName = "XSUSER";
- String userPsw = "XSUSER";
-
- // String url = "jdbc:oracle:thin:@10.10.0.8:1521:SQMESDB"; //测试
- // String userName = "XG3Q";
- // String userPsw = "XG3Q123";
- con = DriverManager.getConnection(url , userName , userPsw);
-
- String SQL2 = "DELETE FROM ZL_ZBS_DETAIL_DATA T WHERE T.ZBS_BH = ? ";
- String SQL3 = "DELETE FROM ZL_ZBS_MAIN_DATA T WHERE T.ZBS_BH = ? ";
- String SQL4 = "UPDATE TBB02_MS_COM T SET T.SEND_TP = 'Y' , T.SEND_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') WHERE T.CRET_NO = ? ";
- String SQL5 = "UPDATE TBB03_MS_COM T SET T.SEND_TP = 'Y' , T.SEND_DTIME = TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') WHERE T.CRET_NO = ? ";
- con.setAutoCommit(false);
- //delete
- pstm = con.prepareStatement(SQL2);
- pstm.setString(1, CRET_NO[0]);
- pstm.execute();
- //delete
- pstm = con.prepareStatement(SQL3);
- pstm.setString(1, CRET_NO[0]);
- pstm.execute();
-
- PosParameter param = new PosParameter();
- param.setWhereClauseParameter(0, CRET_NO[0]);
- if("XR".equals(CRET_NO[0].subSequence(0, 2)))//热轧
- {
- //UPDATE,已发送的标志
-
- this.getDao("mesdao").updateByQueryStatement(SQL4 , param);
- }
- else if("BR".equals(CRET_NO[0].subSequence(0, 2)))//板加
- {
- this.getDao("mesdao").updateByQueryStatement(SQL5 , param);
- }
- // pstm = con.prepareStatement(SQL4);
- // pstm.setString(1, CRET_NO[0]);
- // pstm.execute();
-
- //insert
- MutilConditionFind mcf = new MutilConditionFind();
- String sql = mcf.getQuerySql("UIB021100_01.INSERT").toString();
- System.out.println(sql);
- pstm = con.prepareStatement(sql);
- pstm.setString(1, INV_NO[0]);
- pstm.setString(2, ORD_NO[0]);
- pstm.setString(3, ORD_SEQ[0]);
- pstm.setString(4, CUST_CD[0]);
- pstm.setString(5, ORDCUST_CD[0]);
- pstm.setString(6, ORD_USE_TP[0]);
- pstm.setString(7, SPEC_ABBSYM[0]);
- pstm.setString(8, CAR_GP[0]);
- // param.setValueParamter(8, SUM_WGT[0]);
- // param.setValueParamter(9, SUM_CNT[0]);
- // System.out.println("####################"+TRNF_DTIME[0]+"#####################"+ORD_DEVLMT_DATE[0]+"###########");
- pstm.setFloat(9, Float.valueOf(SUM_WGT[0]).floatValue());
- pstm.setInt(10, Integer.valueOf(SUM_CNT[0]).intValue());
- pstm.setBytes(11, bout.toByteArray());
- pstm.setString(12, CRET_NO[0]);
- pstm.setString(13, TRNF_DTIME[0]);
- pstm.setString(14, ORD_DEVLMT_DATE[0]);
- // pstm.setBytes(15, bout.toByteArray());
- // DateFormat df = new SimpleDateFormat("yyyyMMdd");
- // String strDate= df.format(TRNF_DTIME[0]);
- // pstm.setDate(13, Date.valueOf(TRNF_DTIME[0]));
- // pstm.setString(13, strDate);
- pstm.execute();
-
-
- param = new PosParameter();
- param.setWhereClauseParameter(0, CRET_NO[0]);
- PosRowSet rowset = this.getDao("mesdao").find("UIB021100_001.SELECT", param);
-
-
-
- // sql = mcf.getQuerySql("UIB021100_001.SELECT").toString();
- // pstm = con.prepareStatement(sql);
- // pstm.setString(1, CRET_NO[0]);
- // ResultSet rs = pstm.executeQuery();
-
- pstm = null;
-
- String sql1 = mcf.getQuerySql("UIB021100_02.INSERT").toString();
- // System.out.println("!!!!!!!!"+sql1);
- pstm = con.prepareStatement(sql1);
-
- while(rowset.hasNext())
- {
- PosRow rs = rowset.next();
- pstm.setString(1 , rs.getAttribute("SHIP_INVNO").toString());
- pstm.setString(2 , rs.getAttribute("OLD_SAMPL_NO").toString());
- pstm.setString(3 , rs.getAttribute("SLAB_NO").toString());
- pstm.setString(4 , rs.getAttribute("SPEC_STL_GRD").toString());
- pstm.setString(5 , rs.getAttribute("INSTR_COIL_THK")== null ?"" : rs.getAttribute("INSTR_COIL_THK").toString());
- pstm.setString(6 , rs.getAttribute("COIL_LEN")== null ?"" : rs.getAttribute("COIL_LEN").toString());
- pstm.setString(7 , rs.getAttribute("INSTR_COIL_WTH")== null ?"" : rs.getAttribute("INSTR_COIL_WTH").toString());
- pstm.setInt(8 , Integer.valueOf(rs.getAttribute("SUM_CNT").toString()).intValue());
- pstm.setInt(9 , Integer.valueOf(rs.getAttribute("SUM_WGT").toString()).intValue());
- pstm.setString(10, rs.getAttribute("PRODNM_CD").toString());
- pstm.setString(11, CRET_NO[0]);
- pstm.execute();
- con.commit();
- }
-
- }catch(Exception ex)
- {
- ex.printStackTrace();
- try
- {
- con.rollback();
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- finally
- {
- try
- {
- if(pstm != null) pstm.close();
- if(con != null) con.close();
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- return PosBizControlConstants.SUCCESS;
- }
- }
|