2e0d26d235ab6d28e26cfb39c63aceb44380e51b.svn-base 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package xin.glue.ui.G.G08;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.net.URL;
  5. import java.net.URLConnection;
  6. import java.sql.CallableStatement;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. import java.util.Map;
  10. import com.alibaba.fastjson.JSONObject;
  11. import com.posdata.glue.biz.activity.PosActivity;
  12. import com.posdata.glue.biz.constants.PosBizControlConstants;
  13. import com.posdata.glue.context.PosContext;
  14. import com.posdata.glue.dao.PosGenericDao;
  15. import com.posdata.glue.dao.vo.PosParameter;
  16. import com.posdata.glue.dao.vo.PosRow;
  17. import com.posdata.glue.dao.vo.PosRowSet;
  18. public class SendBack extends PosActivity{
  19. //外销退回
  20. public String runActivity(PosContext context) {
  21. String[] SLAB_NO= (String[])context.get("SERIALNUMBER");
  22. String[] SEND_NO= (String[])context.get("PLANVEHICLEID"); //发运指示号
  23. String[] MEMO = (String[])context.get("MEMO");//退回备注
  24. String[] LISTNUMBER = (String[])context.get("LISTNUMBER");//明细编码
  25. String[] chk= (String[])context.get("CHK");
  26. String[] GBZL = (String[])context.get("GBZL");
  27. String[] PLT_TRS_EMP_ID = (String[])context.get("REG_NM");
  28. String err= new String();
  29. String mes= new String();
  30. PosGenericDao dao = this.getDao("mesdao");
  31. ArrayList al = new ArrayList();
  32. for(int i = 0 ; i < chk.length ; i++){
  33. if(chk[i].equals("")||chk[i] == null||chk[i].equals("N"))continue;
  34. // PosParameter param = new PosParameter();
  35. // param.setWhereClauseParameter(0, SLAB_NO[i]);
  36. // param.setWhereClauseParameter(1, err);
  37. // param.setWhereClauseParameter(2, mes);
  38. // int updtCnt = getDao("mesdao").update("UIG080010_03.CAL", param);
  39. try{
  40. PosParameter param1 = new PosParameter();
  41. param1.setWhereClauseParameter(0, SEND_NO[i]);
  42. param1.setWhereClauseParameter(1, SLAB_NO[i]);
  43. PosRowSet rs = this.getDao("mesdao").find("UIG080010_05.SELECT", param1);
  44. if(rs.hasNext())
  45. {
  46. PosRow rsRow = rs.next();
  47. String flag = (String) rsRow.getAttribute("AFFIRM_FLAG");
  48. if("0".equals(flag))
  49. {
  50. context.put("MESSAGES",SLAB_NO[i] + " 未进行审核,不可退回! ");
  51. return PosBizControlConstants.SUCCESS;
  52. }
  53. if("2".equals(flag))
  54. {
  55. context.put("MESSAGES",SLAB_NO[i] + " 审核不通过,不可退回! ");
  56. return PosBizControlConstants.SUCCESS;
  57. }
  58. }
  59. else
  60. {
  61. String msg = sendGet("http://10.90.0.166:8083/api/TqMes/IS_Leave_Factory?forecast_no=",SEND_NO[i]);
  62. JSONObject jsonObj = JSONObject.parseObject(msg);
  63. String condition = jsonObj.getString("condition");
  64. if("FALSE".equals(condition.toUpperCase()))
  65. {
  66. if(MEMO[i] == null || "".equals(MEMO[i]))
  67. {
  68. context.put("MESSAGES",SLAB_NO[i] + " 请输入退回原因!");
  69. return PosBizControlConstants.SUCCESS;
  70. }
  71. PosParameter param2 = new PosParameter();
  72. param2.setWhereClauseParameter(0, MEMO[i]);
  73. param2.setWhereClauseParameter(1, PLT_TRS_EMP_ID[0]);
  74. param2.setWhereClauseParameter(2, SLAB_NO[i]);
  75. param2.setWhereClauseParameter(3, SEND_NO[i]);
  76. this.getDao("mesdao").update("UIG080010_05.INSERT", param2);
  77. context.put("MESSAGES",SLAB_NO[i] + " 已出厂,如要删除明细需走审批流程,请去审批界面进行审核! ");
  78. return PosBizControlConstants.SUCCESS;
  79. }
  80. }
  81. }catch (Exception e)
  82. {
  83. context.put("MESSAGES",e.getMessage());
  84. return PosBizControlConstants.SUCCESS;
  85. }
  86. CallableStatement cstm = null;
  87. cstm = dao.getCallableStatement("UIG080010_03.CAL");
  88. try
  89. {
  90. cstm.setString(1, SLAB_NO[i]);
  91. cstm.setString(2, PLT_TRS_EMP_ID[0]);
  92. cstm.registerOutParameter(3, java.sql.Types.VARCHAR);
  93. cstm.registerOutParameter(4, java.sql.Types.VARCHAR);
  94. cstm.execute();
  95. //财务数据上抛 移入存储过程MES_LG_KC.BACKLIST_BP
  96. /*cstm = this.getDao("mesdao").getCallableStatement("UPLOAD_DATA.CAL");
  97. cstm.setString(1, SLAB_NO[i]);
  98. cstm.setString(2, "69A");
  99. cstm.setString(3, "D");
  100. cstm.setString(4, "板坯外销撤回");
  101. cstm.setString(5, PLT_TRS_EMP_ID[0]);
  102. cstm.registerOutParameter(6, java.sql.Types.VARCHAR);
  103. cstm.execute();
  104. String err1 = cstm.getString(6);*/
  105. }catch(Exception ex)
  106. {
  107. ex.printStackTrace();
  108. }
  109. finally
  110. {
  111. if(cstm != null)
  112. {
  113. try
  114. {
  115. al.add("<SLAB_NO>"+SLAB_NO[i]+"</SLAB_NO>"+"<TISHI>"+cstm.getString(4)+"</TISHI>");
  116. cstm.close();
  117. }catch(Exception e)
  118. {
  119. e.printStackTrace();
  120. }
  121. }
  122. }
  123. context.put("BK", al);System.out.println(al);
  124. }
  125. return PosBizControlConstants.SUCCESS;
  126. }
  127. /**
  128. * 向指定URL发送GET方法的请求
  129. *
  130. * @param url
  131. * 发送请求的URL
  132. * @param param
  133. * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
  134. * @return URL 所代表远程资源的响应结果
  135. */
  136. public String sendGet(String url, String param) {
  137. String result = "";
  138. BufferedReader in = null;
  139. try {
  140. String urlNameString = url + param;
  141. URL realUrl = new URL(urlNameString);
  142. // 打开和URL之间的连接
  143. URLConnection connection = realUrl.openConnection();
  144. // 设置通用的请求属性
  145. connection.setRequestProperty("accept", "*/*");
  146. connection.setRequestProperty("connection", "Keep-Alive");
  147. connection.setRequestProperty("user-agent",
  148. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
  149. // 建立实际的连接
  150. connection.connect();
  151. // 获取所有响应头字段
  152. Map<String, List<String>> map = connection.getHeaderFields();
  153. // 遍历所有的响应头字段
  154. for (String key : map.keySet()) {
  155. System.out.println(key + "--->" + map.get(key));
  156. }
  157. // 定义 BufferedReader输入流来读取URL的响应
  158. in = new BufferedReader(new InputStreamReader(
  159. connection.getInputStream(),"UTF-8"));
  160. String line;
  161. while ((line = in.readLine()) != null) {
  162. result += line;
  163. }
  164. } catch (Exception e) {
  165. System.out.println("发送GET请求出现异常!" + e);
  166. e.printStackTrace();
  167. }
  168. // 使用finally块来关闭输入流
  169. finally {
  170. try {
  171. if (in != null) {
  172. in.close();
  173. }
  174. } catch (Exception e2) {
  175. e2.printStackTrace();
  176. }
  177. }
  178. return result;
  179. }
  180. }