93d1c8f5a37a4428146ee0f85000c70ffa712296.svn-base 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. package QCM.QCM01.QCM0106;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import org.apache.ibatis.session.SqlSession;
  5. import CoreFS.SA01.CoreIComponent;
  6. import CoreFS.SA06.CoreReturnObject;
  7. import QCM.COMMUNAL.communalClass;
  8. import QCM.COMMUNAL.QCM02.SqlJoint;
  9. import java.text.ParseException;
  10. public class QueryDefect extends CoreIComponent {
  11. CoreReturnObject cro = new CoreReturnObject();
  12. SqlSession SqlSession =
  13. QCM.COMMUNAL.SqlSessionBuilder.openSqlSession();
  14. QCM.COMMUNAL.OrderSqMapper mapper = SqlSession.getMapper(QCM.COMMUNAL.OrderSqMapper.class);
  15. public String StrSky(String begintime,String endtime){
  16. String sql = "select (to_date('"+endtime+"','yyyy-MM-dd') - to_date('"+begintime+"','yyyy-MM-dd')) SKY from dual";
  17. HashMap list = mapper.queryOne(sql);
  18. Double ble = Double.parseDouble(list.get("SKY").toString());
  19. String tstr="FALSE";
  20. if(ble>=0 && ble <=30 ){
  21. tstr="TRUE";
  22. }
  23. return tstr;
  24. }
  25. //轧钢历史操作记录
  26. public CoreReturnObject Query(String begintime,String endtime,String prodline,String bbatchno,String ebatchno){
  27. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) {
  28. String sky=StrSky(begintime,endtime);
  29. if(sky.equals("FALSE")){
  30. SqlSession.close();
  31. cro.setV_errCode(-1);
  32. cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!");
  33. return cro;
  34. }
  35. }
  36. String swhere = " 1 = 1";
  37. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) { //操作时间
  38. swhere += " and to_date(to_char(OPERATE_TIME,'yyyy-mm-dd'),'yyyy-mm-dd') between to_date('"+begintime+"','yyyy-mm-dd') and to_date('"+endtime+"','yyyy-mm-dd')";
  39. }
  40. if (!SqlJoint.IsNullOrSpace(bbatchno)) { //起始轧批号
  41. swhere += "and batchno >= '"+bbatchno+"'";
  42. }
  43. if (!SqlJoint.IsNullOrSpace(ebatchno)) { //最后轧批号
  44. swhere += "and batchno <= '"+ebatchno+"'";
  45. }
  46. if (!SqlJoint.IsNullOrSpace(prodline)) { //Psc_desc
  47. swhere += " and prod_line = '"+prodline+"'";
  48. }
  49. String sqlucomm = "select t.OPERATE_TYPE OPERATE_TYPE,t.PARAMS PARAMS,t.OPERATE_NAME OPERATE_NAME,"
  50. + "t.OPERATE_TIME OPERATE_TIME,decode(t.PROD_LINE,\r\n" +
  51. " 'LT1',\r\n" +
  52. " '连退线',\r\n" +
  53. " 'RZ1',\r\n" +
  54. " '热轧线',\r\n" +
  55. " 'SZ1',\r\n" +
  56. " '酸轧线',\r\n" +
  57. " 'GX1',\r\n" +
  58. " '高棒线',\r\n" +
  59. " 'GX2',\r\n" +
  60. " '高线',\r\n" +
  61. " 'BC2',\r\n" +
  62. " '棒二线',\r\n" +
  63. " 'ZB1',\r\n" +
  64. " '中板线',\r\n" +
  65. " 'HB1',\r\n" +
  66. " '厚板线') PROD_LINE,t.OPERATION_INTERFACE OPERATION_INTERFACE,t.BATCHNO BATCHNO,t.MEMO MEMO,"
  67. + " decode(T.JUDGE_RESULT,'0','待判','1','合格','2','不合格') JUDGE_RESULT "
  68. + " from qcm_judge_operate_log t where "+swhere;
  69. cro=this.getDao("test1Dao").ExcuteQuery(sqlucomm.toString());
  70. return cro;
  71. }
  72. //炼钢历史操作记录
  73. public CoreReturnObject QueryLG(String begintime,String endtime,String prodline,String bbatchno){
  74. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) {
  75. String sky=StrSky(begintime,endtime);
  76. if(sky.equals("FALSE")){
  77. SqlSession.close();
  78. cro.setV_errCode(-1);
  79. cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!");
  80. return cro;
  81. }
  82. }
  83. String swhere = " 1 = 1";
  84. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) { //操作时间
  85. swhere += " and to_date(to_char(OPERATE_TIME,'yyyy-mm-dd'),'yyyy-mm-dd') between to_date('"+begintime+"','yyyy-mm-dd') and to_date('"+endtime+"','yyyy-mm-dd')";
  86. }
  87. if (!SqlJoint.IsNullOrSpace(bbatchno)) { //炉号/产品序号
  88. swhere += "and PARAMS like '"+bbatchno+"%'";
  89. }
  90. if (!SqlJoint.IsNullOrSpace(prodline)) { //产线
  91. swhere += " and prod_line = '"+prodline+"'";
  92. }
  93. String sqlucomm = "select t.OPERATE_TYPE OPERATE_TYPE,t.PARAMS PARAMS,t.OPERATE_NAME OPERATE_NAME,"
  94. + "t.OPERATE_TIME OPERATE_TIME,decode(t.PROD_LINE,\r\n" +
  95. " '4001LGX',\r\n" +
  96. " '二炼钢',\r\n" +
  97. " '4001LG0',\r\n" +
  98. " '一炼钢',''\r\n" +
  99. ") PROD_LINE,t.OPERATION_INTERFACE OPERATION_INTERFACE,t.BATCHNO BATCHNO,t.MEMO MEMO,"
  100. + " decode(T.JUDGE_RESULT,'0','待判','1','合格','2','不合格') JUDGE_RESULT "
  101. + " from qcm_judge_operate_log t where "+swhere;
  102. cro=this.getDao("test1Dao").ExcuteQuery(sqlucomm.toString());
  103. return cro;
  104. }
  105. //轧钢历史操作记录
  106. public CoreReturnObject QueryJHY(String begintime,String endtime,String prodline,String bbatchno,String ebatchno){
  107. String swhere = " 1 = 1";
  108. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) { //操作时间
  109. swhere += " and to_date(to_char(OPERATE_TIME,'yyyy-mm-dd'),'yyyy-mm-dd') between to_date('"+begintime+"','yyyy-mm-dd') and to_date('"+endtime+"','yyyy-mm-dd')";
  110. }
  111. if (!SqlJoint.IsNullOrSpace(bbatchno)) { //起始轧批号
  112. swhere += "and batchno >= '"+bbatchno+"'";
  113. }
  114. if (!SqlJoint.IsNullOrSpace(ebatchno)) { //最后轧批号
  115. swhere += "and batchno <= '"+ebatchno+"'";
  116. }
  117. if (!SqlJoint.IsNullOrSpace(prodline)) { //Psc_desc
  118. swhere += " and prod_line = '"+prodline+"'";
  119. }
  120. String sqlucomm = "select t.OPERATE_TYPE OPERATE_TYPE,t.PARAMS PARAMS,t.OPERATE_NAME OPERATE_NAME,"
  121. + "t.OPERATE_TIME OPERATE_TIME,decode(t.PROD_LINE,\r\n" +
  122. " 'LT1',\r\n" +
  123. " '连退线',\r\n" +
  124. " 'RZ1',\r\n" +
  125. " '热轧线',\r\n" +
  126. " 'SZ1',\r\n" +
  127. " '酸轧线',\r\n" +
  128. " 'GX1',\r\n" +
  129. " '高棒线',\r\n" +
  130. " 'GX2',\r\n" +
  131. " '高线',\r\n" +
  132. " 'BC2',\r\n" +
  133. " '棒二线',\r\n" +
  134. " 'ZB1',\r\n" +
  135. " '中板线',\r\n" +
  136. " 'HB1',\r\n" +
  137. " '厚板线') PROD_LINE,t.OPERATION_INTERFACE OPERATION_INTERFACE,t.BATCHNO BATCHNO,t.MEMO MEMO,"
  138. + " decode(T.JUDGE_RESULT,'0','待判','1','合格','2','不合格') JUDGE_RESULT "
  139. + " from qcm_judge_operate_log t where "+swhere;
  140. cro=this.getDao("test1Dao").ExcuteQuery(sqlucomm.toString());
  141. return cro;
  142. }
  143. public CoreReturnObject QueryMemo(String prodline){
  144. String swhere = " 1 = 1";
  145. if (!SqlJoint.IsNullOrSpace(prodline)) { //Psc_desc
  146. swhere += " and pline_code = '"+prodline+"'";
  147. }
  148. String sqlucomm = "select MEMO,memo_code,creat_name,to_char(creat_time,'yyyy/mm/dd HH24:MI:SS') creat_time,decode(pline_code," +
  149. " 'JB1','卷板'," +
  150. " 'ZHB', '中厚板'," +
  151. " 'XB1','线棒'," +
  152. " 'LG','炼钢')pline_code,mod_id,to_char(mod_time,'yyyy/mm/dd HH24:MI:SS') mod_time from deal_memo where "+swhere;
  153. cro=this.getDao("test1Dao").ExcuteQuery(sqlucomm.toString());
  154. return cro;
  155. }
  156. public CoreReturnObject AddMemo(String prodline,String memo,String usename,String memo_code) {
  157. String swhere = " 1 = 1";
  158. if (!SqlJoint.IsNullOrSpace(prodline)) { //Psc_desc
  159. swhere += " and pline_code = '"+prodline+"'";
  160. }
  161. /*if (!SqlJoint.IsNullOrSpace(memo)) { //Psc_desc
  162. swhere += " and memo = '"+memo+"'";
  163. }*/
  164. if (!SqlJoint.IsNullOrSpace(memo_code)) { //Psc_desc
  165. swhere += " and memo_code = '"+memo_code+"'";
  166. }
  167. try{
  168. String sql = "select * from deal_memo where "+swhere;
  169. List<HashMap> list1 = mapper.query(sql);
  170. if(list1.size() >0){
  171. throw new Exception("该产线已有该处理备注代码,请换一个处理备注代码后再添加");
  172. }
  173. String sql1 = "insert into deal_memo(pline_code,memo,memo_code,creat_name,creat_time) "
  174. + " values('"+prodline+"','"+memo+"','"+memo_code+"','"+usename+"',"
  175. + "TO_DATE('"+communalClass.getDate()+"','YYYY-MM-DD HH24:MI:SS'))";
  176. mapper.insert(sql1.toString());
  177. }catch(Exception e){
  178. SqlSession.rollback();
  179. SqlSession.close();
  180. cro.setV_errCode(-1);
  181. cro.setV_errMsg("处理备注失败"+e.getMessage());
  182. return cro;
  183. }
  184. SqlSession.commit();
  185. SqlSession.close();
  186. cro.setV_errCode(1);
  187. return cro;
  188. }
  189. public CoreReturnObject EMemo(String prodline,String memo,String username,String memo_code) {
  190. String swhere = " 1 = 1";
  191. if (!SqlJoint.IsNullOrSpace(prodline)) { //Psc_desc
  192. swhere += " and pline_code = '"+prodline+"'";
  193. }
  194. if (!SqlJoint.IsNullOrSpace(memo)) { //Psc_desc
  195. swhere += " and memo_code = '"+memo_code+"'";
  196. }
  197. try{
  198. String sql = "select * from deal_memo where "+swhere;
  199. List<HashMap> list1 = mapper.query(sql);
  200. if(list1.size() <=0){
  201. throw new Exception("该产线没有该备注,请点击添加备注");
  202. }
  203. String sql1 = "update deal_memo set memo = '"+memo+"',mod_id = '"+username+"',"
  204. + " mod_time = TO_DATE('"+communalClass.getDate()+"','YYYY-MM-DD HH24:MI:SS') "
  205. + " where memo_code = '"+memo_code+"'";
  206. mapper.insert(sql1.toString());
  207. }catch(Exception e){
  208. SqlSession.rollback();
  209. SqlSession.close();
  210. cro.setV_errCode(-1);
  211. cro.setV_errMsg("修改处理备注失败"+e.getMessage());
  212. return cro;
  213. }
  214. SqlSession.commit();
  215. SqlSession.close();
  216. cro.setV_errCode(1);
  217. return cro;
  218. }
  219. }