802c2b0380b52bfbc986c08adbce71c9164bbe7d.svn-base 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. package QCM.QCM03.QCM0301;
  2. import CoreFS.SA01.CoreIComponent;
  3. import CoreFS.SA06.CoreReturnObject;
  4. import QCM.COMMUNAL.QCM02.SqlJoint;
  5. import QCM.COMMUNAL.VO.*;
  6. import QCM.QCM03.QCM0303.QcmJudgeMeasureServiceImpl;
  7. import com.alibaba.fastjson.JSON;
  8. import com.alibaba.fastjson.JSONArray;
  9. import com.alibaba.fastjson.JSONObject;
  10. import org.apache.ibatis.session.SqlSession;
  11. import org.apache.log4j.Logger;
  12. import java.util.Date;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. public class QcmJudgeChemicalServiceImpl extends CoreIComponent{
  16. CoreReturnObject cro = new CoreReturnObject();
  17. SqlSession SqlSession =
  18. QCM.COMMUNAL.SqlSessionBuilder.openSqlSession();
  19. QCM.COMMUNAL.OrderSqMapper mapper = SqlSession.getMapper(QCM.COMMUNAL.OrderSqMapper.class);
  20. QcmJudgeMeasureServiceImpl qjm = new QcmJudgeMeasureServiceImpl();
  21. private Logger logger = Logger.getLogger(this.getClass().getName());
  22. public String StrSky(String begintime,String endtime){
  23. String sql = "select (to_date('"+endtime+"','yyyy-MM-dd') - to_date('"+begintime+"','yyyy-MM-dd')) SKY from dual";
  24. HashMap list = mapper.queryOne(sql);
  25. Double ble = Double.parseDouble(list.get("SKY").toString());
  26. String tstr="FALSE";
  27. if(ble>=0 && ble <=30 ){
  28. tstr="TRUE";
  29. }
  30. return tstr;
  31. }
  32. /**
  33. * 获取成品成分判定记录
  34. * @param page
  35. * @return
  36. */
  37. public CoreReturnObject GetJudgeChemRecord(String begintime,String endtime,String batch_no,String boardno,String design_key,String psc_desc,String type,String prodline){
  38. try{
  39. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime) && SqlJoint.IsNullOrSpace(batch_no)) {
  40. String sky=StrSky(begintime,endtime);
  41. if(sky.equals("FALSE")){
  42. SqlSession.close();
  43. cro.setV_errCode(-1);
  44. cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!");
  45. return cro;
  46. }
  47. }
  48. //String sqls = "select chemid from zj_result_all@xgcx union all select chemid from QCM_JUDGE_COIL_RESULT";
  49. String con= "1=1";
  50. String sql = "select * from QCM_JUDGE_CHEMICAL where ";
  51. if(!SqlJoint.IsNullOrSpace(batch_no)){
  52. con += " and batch_no like '%"+batch_no+"%'";
  53. }
  54. if(!SqlJoint.IsNullOrSpace(boardno)){
  55. con += " and BOARD_NO like '%"+boardno+"%'";
  56. }
  57. if(!SqlJoint.IsNullOrSpace(design_key)){
  58. con += " and design_key like '%"+design_key+"%'";
  59. }
  60. if(!SqlJoint.IsNullOrSpace(psc_desc)){
  61. con += "psc_desc like '%"+psc_desc+"%'";
  62. }
  63. if(!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime))
  64. {
  65. con += " and to_date(to_char(JUDGE_TTIME,'yyyy-mm-dd'),'yyyy-mm-dd') between to_date('"+begintime+"','yyyy-mm-dd') and to_date('"+endtime+"','yyyy-mm-dd') ";
  66. }
  67. if(!SqlJoint.IsNullOrSpace(type)){
  68. //卷板
  69. if(type.equals("0")){
  70. con += " and pline_code in ('LT1','SZ1','RZ1','4001RZ1','4001LT1','4001LZ1')";
  71. }
  72. //中厚板
  73. else if(type.equals("1")){
  74. con += " and pline_code in ('ZB1','HB1')";
  75. }
  76. //线棒
  77. else if(type.equals("2")){
  78. con += " and pline_code in ('GX1','BC1','BC2','GX2')";
  79. }
  80. }
  81. if(prodline.equals("中板线")){
  82. con += " and pline_code in ('ZB1') ";
  83. }else if(prodline.equals("厚板线")){
  84. con += " and pline_code in ('HB1') ";
  85. }else if(prodline.equals("热连轧")){
  86. con += " and pline_code in ('RZ1') ";
  87. }else if(prodline.equals("酸轧")){
  88. con += " and pline_code in ('SZ1') ";
  89. }else if(prodline.equals("连退")){
  90. con += " and pline_code in ('LT1') ";
  91. }else if(prodline.equals("高棒")){
  92. con += " and pline_code in ('GX1') ";
  93. }else if(prodline.equals("棒二")){
  94. con += " and pline_code in ('BC2') ";
  95. }else if(prodline.equals("高线")){
  96. con += " and pline_code in ('GX2') ";
  97. }
  98. con += " and cic_id like 'C%'";
  99. //con += " and cic_id in ("+sqls+")";
  100. sql += con + " order by judge_ttime desc";
  101. List<QcmJudgeChemical> listChemical = mapper.queryQcmJudgeChemical(sql);
  102. /*for(QcmJudgeChemical qjc:listChemical){
  103. List<HashMap> listss = mapper.query("select CHEMRESULT,CHEMRESULT_DESC from zj_result_all@xgcx where chemid = '"+qjc.getCic_id()+"' union all select CHEMRESULT,CHEMRESULT_DESC from QCM_JUDGE_COIL_RESULT where chemid = '"+qjc.getCic_id()+"'");
  104. for(HashMap lists:listss)
  105. {
  106. qjc.setCic_result_code(lists.get("CHEMRESULT").toString());
  107. qjc.setCic_result_desc(lists.get("CHEMRESULT_DESC").toString());
  108. }
  109. }*/
  110. cro.setResult(listChemical);
  111. }catch(Exception ex){
  112. cro.setV_errCode(-1);
  113. cro.setV_errMsg("查询失败!"+ex.getMessage());
  114. }
  115. SqlSession.close();
  116. return cro;
  117. }
  118. /**
  119. * 获取熔炼成分判定记录
  120. * @param page
  121. * @return
  122. */
  123. public CoreReturnObject GetJudgeRChemRecord(String begintime,String endtime,String heatno,String boardno,String design_key,String material_no,String type,String prodline,String sbatchno,String ebatchno){
  124. try{
  125. //String sqls = "select r_chemid from zj_result_all@xgcx union all select r_chemid from QCM_JUDGE_COIL_RESULT";
  126. if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime) && SqlJoint.IsNullOrSpace(heatno) && SqlJoint.IsNullOrSpace(sbatchno)) {
  127. String sky=StrSky(begintime,endtime);
  128. if(sky.equals("FALSE")){
  129. SqlSession.close();
  130. cro.setV_errCode(-1);
  131. cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!");
  132. return cro;
  133. }
  134. }
  135. String con= "1=1";
  136. String sql = "select * from QCM_JUDGE_CHEMICAL where ";
  137. if(!SqlJoint.IsNullOrSpace(heatno)){
  138. con += " and heat_no like '%"+heatno+"%'";
  139. }
  140. if(!SqlJoint.IsNullOrSpace(boardno)){
  141. con += " and BOARD_NO like '%"+boardno+"%'";
  142. }
  143. if(!SqlJoint.IsNullOrSpace(design_key)){
  144. con += " and design_key like '%"+design_key+"%'";
  145. }
  146. if(!SqlJoint.IsNullOrSpace(material_no)){
  147. con += " and material_no like '%"+material_no+"%'";
  148. }
  149. if(!SqlJoint.IsNullOrSpace(sbatchno)){
  150. con += " and batch_no >= '"+sbatchno+"'";
  151. }
  152. if(!SqlJoint.IsNullOrSpace(ebatchno)){
  153. con += " and batch_no <= '"+ebatchno+"'";
  154. }
  155. if(!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime))
  156. {
  157. con += " and to_date(to_char(JUDGE_TTIME,'yyyy-mm-dd'),'yyyy-mm-dd') between to_date('"+begintime+"','yyyy-mm-dd') and to_date('"+endtime+"','yyyy-mm-dd') ";
  158. }
  159. if(prodline.equals("中板线")){
  160. con += " and pline_code in ('ZB1') ";
  161. }else if(prodline.equals("厚板线")){
  162. con += " and pline_code in ('HB1') ";
  163. }else if(prodline.equals("热连轧")){
  164. con += " and pline_code in ('RZ1') ";
  165. }else if(prodline.equals("酸轧")){
  166. con += " and pline_code in ('SZ1') ";
  167. }else if(prodline.equals("连退")){
  168. con += " and pline_code in ('LT1') ";
  169. }else if(prodline.equals("高棒")){
  170. con += " and pline_code in ('GX1') ";
  171. }else if(prodline.equals("棒二")){
  172. con += " and pline_code in ('BC2') ";
  173. }else if(prodline.equals("高线")){
  174. con += " and pline_code in ('GX2') ";
  175. }else if(prodline.equals("优特")){
  176. con += " and pline_code in ('YT1') ";
  177. }
  178. if(!SqlJoint.IsNullOrSpace(type)){
  179. //卷板
  180. if(type.equals("0")){
  181. con += " and pline_code in ('LT1','SZ1','RZ1','4001RZ1','4001LT1','4001LZ1')";
  182. }
  183. //中厚板
  184. else if(type.equals("1")){
  185. con += " and pline_code in ('ZB1','HB1')";
  186. }
  187. //线棒
  188. else if(type.equals("2")){
  189. con += " and pline_code in ('GX1','BC1','BC2','GX2')";
  190. }
  191. //优特
  192. else if(type.equals("3")){
  193. con += " and pline_code in ('YT1')";
  194. }
  195. }
  196. con += " and cic_id like 'R%'";
  197. //con += " and cic_id in ("+sqls+")";
  198. sql += con + " order by judge_ttime desc";
  199. List<QcmJudgeChemical> listChemical = mapper.queryQcmJudgeChemical(sql);
  200. /*for(QcmJudgeChemical qjc:listChemical){
  201. List<HashMap> listss = mapper.query("select R_CHEMRESULT,R_CHEMRESULT_DESC from zj_result_all@xgcx where r_chemid = '"+qjc.getCic_id()+"' union all select R_CHEMRESULT,R_CHEMRESULT_DESC from QCM_JUDGE_COIL_RESULT where r_chemid = '"+qjc.getCic_id()+"'");
  202. for(HashMap lists:listss)
  203. {
  204. qjc.setCic_result_code(lists.get("R_CHEMRESULT").toString());
  205. qjc.setCic_result_desc(lists.get("R_CHEMRESULT_DESC").toString());
  206. }
  207. }*/
  208. cro.setResult(listChemical);
  209. }catch(Exception ex){
  210. cro.setV_errCode(-1);
  211. cro.setV_errMsg("查询失败!"+ex.getMessage());
  212. }
  213. SqlSession.close();
  214. return cro;
  215. }
  216. /**
  217. * 取消判定 检验号
  218. */
  219. public CoreReturnObject CancelJudge(String inspection_lot,String smp_no,String username) throws Exception{
  220. try{
  221. //判断是否进行了综合判定
  222. String sql = "select * from zj_result_all@xgcx where BILLETID_JY = '"+inspection_lot+"'";
  223. List<HashMap> list1 = mapper.query(sql);
  224. sql = "select * from QCM_JUDGE_COIL_RESULT where INSPECTION_LOT = '"+inspection_lot+"'";
  225. List<HashMap> list2 = mapper.query(sql);
  226. if(list1.size() >0 || list2.size() >0){
  227. if(list1.size()>0){
  228. for(HashMap list:list1){
  229. if(!list.get("JUDGERESULT").toString().equals("0")){
  230. throw new Exception("该检验号下已有物料号做了综合判定,不能取消判定!");
  231. }
  232. if(list.get("CIC_IS_LOCK").toString().equals("1")){
  233. throw new Exception("该检验号已锁定,不能取消判定!");
  234. }
  235. }
  236. mapper.clearCHEMRESULT(inspection_lot);
  237. }else{
  238. for(HashMap list:list2){
  239. if(!list.get("JUDGERESULT").toString().equals("0")){
  240. throw new Exception("该检验号下已有物料号做了综合判定,不能取消判定!");
  241. }
  242. if(list.get("CIC_IS_LOCK").toString().equals("1")){
  243. throw new Exception("该检验号已锁定,不能取消判定!");
  244. }
  245. }
  246. mapper.clearCHEMRESULT1(inspection_lot);
  247. }
  248. }else{
  249. throw new Exception("未找到该检验号下的库存信息!");
  250. }
  251. List<QcmJhySampleROrd> qjsr = mapper.queryQcmJhySampleROrd1("select * from qcm_jhy_sample_r_ord where smp_no = '"+smp_no+"'");
  252. //清空试样与合同信息表成分判定记录号
  253. QcmJhySampleROrd qsrd = new QcmJhySampleROrd();
  254. qsrd.setInspection_lot(inspection_lot);
  255. qsrd.setSmp_no(smp_no);
  256. mapper.UpdateQcmJhySampleROrd(qsrd);
  257. QcmJudgeOperateLog qjog = new QcmJudgeOperateLog();
  258. qjog.setOperate_name(username);
  259. qjog.setOperate_type("成品成分取消判定");
  260. qjog.setParams(smp_no);
  261. qjog.setBatchno(qjsr.get(0).getBatch_no());
  262. qjog.setProd_line(qjsr.get(0).getPline_code());
  263. mapper.insertQcmJudgeOperateLog(qjog);
  264. SqlSession.commit();
  265. }catch(Exception e){
  266. SqlSession.rollback();
  267. cro.setV_errCode(-1);
  268. cro.setV_errMsg("取消判定失败!"+e.getMessage());
  269. logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelJudge:【" + inspection_lot + "," + smp_no + "】" + e);
  270. }
  271. SqlSession.close();
  272. return cro;
  273. }
  274. /**
  275. * 取消判定
  276. */
  277. public CoreReturnObject CancelRJudge(String material_no,String username) throws Exception{
  278. try{
  279. //判断是否进行了综合判定
  280. String sql = "select * from zj_result_all@xgcx where BILLETID = '"+material_no+"'";
  281. List<HashMap> list1 = mapper.query(sql);
  282. sql = "select * from QCM_JUDGE_COIL_RESULT where COIL_NO = '"+material_no+"'";
  283. List<HashMap> list2 = mapper.query(sql);
  284. sql = "select * from QCM_JUDGE_YT_COIL_RESULT where COIL_NO = '"+material_no+"'";
  285. List<HashMap> list3 = mapper.query(sql);
  286. if(list1.size() >0 || list2.size() >0 || list3.size() >0){
  287. if(list1.size()>0){
  288. for(HashMap list:list1){
  289. if(!list.get("JUDGERESULT").toString().equals("0")){
  290. throw new Exception("该物料号做了综合判定,不能取消判定!");
  291. }
  292. if(list.get("R_CIC_IS_LOCK").toString().equals("1")){
  293. throw new Exception("该物料号已锁定,不能取消判定!");
  294. }
  295. }
  296. ZjResultAll zra = new ZjResultAll();
  297. zra.setBilletid(material_no);
  298. zra.setR_chemid("");
  299. zra.setR_chemresult_desc("待判");
  300. zra.setR_chemresult("0");
  301. mapper.UpdateJugeResultB(zra);
  302. }else if(list2.size()>0){
  303. for(HashMap list:list2){
  304. if(!list.get("JUDGERESULT").toString().equals("0")){
  305. throw new Exception("该物料号做了综合判定,不能取消判定!");
  306. }
  307. if(list.get("R_CIC_IS_LOCK").toString().equals("1")){
  308. throw new Exception("该物料号已锁定,不能取消判定!");
  309. }
  310. }
  311. QcmJudgeCoilResult zra = new QcmJudgeCoilResult();
  312. zra.setCoil_no(material_no);
  313. zra.setR_chemid("");
  314. zra.setR_chemresult_desc("待判");
  315. zra.setR_chemresult("0");
  316. mapper.UpdateJugeResultJ(zra);
  317. }else{
  318. for(HashMap list:list3){
  319. if(!list.get("JUDGERESULT").toString().equals("0")){
  320. throw new Exception("该物料号做了综合判定,不能取消判定!");
  321. }
  322. if(list.get("R_CIC_IS_LOCK").toString().equals("1")){
  323. throw new Exception("该物料号已锁定,不能取消判定!");
  324. }
  325. }
  326. QcmJudgeYtCoilResult zra = new QcmJudgeYtCoilResult();
  327. zra.setCoil_no(material_no);
  328. zra.setR_chemid("");
  329. zra.setR_chemresult_desc("待判");
  330. zra.setR_chemresult("0");
  331. mapper.UpdateJugeResultY(zra);
  332. }
  333. }else{
  334. throw new Exception("未找到库存信息!");
  335. }
  336. List<QcmJudgeChemical> qjc = mapper.queryQcmJudgeChemical("select * from qcm_judge_chemical where material_no = '"+material_no+"' order by judge_ttime desc");
  337. QcmJudgeOperateLog qjog = new QcmJudgeOperateLog();
  338. qjog.setOperate_name(username);
  339. qjog.setOperate_type("轧钢熔炼成分取消判定");
  340. qjog.setParams(material_no);
  341. qjog.setBatchno(qjc.get(0).getBatch_no());
  342. qjog.setProd_line(qjc.get(0).getPline_code());
  343. mapper.insertQcmJudgeOperateLog(qjog);
  344. SqlSession.commit();
  345. }catch(Exception e){
  346. SqlSession.rollback();
  347. cro.setV_errCode(-1);
  348. cro.setV_errMsg("取消判定失败!"+e.getMessage());
  349. logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelRJudge:【" + material_no + "】" + e);
  350. }
  351. SqlSession.close();
  352. return cro;
  353. }
  354. /**
  355. * 取消判定
  356. */
  357. public CoreReturnObject CancelLgRJudge(String material_no,String username) throws Exception{
  358. try{
  359. QcmJhyElementsServiceImpl qjes = new QcmJhyElementsServiceImpl();
  360. List<QCMJudgeLocking> qj = mapper.queryQCMJudgeLockings("select * from qcm_judge_locking where material_no = '"+material_no+"' and unlock_type_code is null");
  361. if(qj.size() > 0){
  362. throw new Exception("该检验结果已生成异常材处置,请完成异常材处置!");
  363. }
  364. List<QcmJudgeChemical> qjc = mapper.queryQcmJudgeChemical("select * from qcm_judge_chemical where material_no = '"+material_no+"' order by judge_ttime desc");
  365. QcmJudgeOperateLog qjog = new QcmJudgeOperateLog();
  366. qjog.setOperate_name(username);
  367. qjog.setOperate_type("炼钢熔炼成分取消判定");
  368. qjog.setParams(material_no);
  369. qjog.setProd_line(qjc.get(0).getPline_code());
  370. mapper.insertQcmJudgeOperateLog(qjog);
  371. //调用单项判定
  372. JSONObject jsobj2 = new JSONObject();
  373. JSONArray ttmaps = new JSONArray();
  374. JSONObject jsobj1 = new JSONObject();
  375. jsobj1.put("CHEMRESULT_LK", "");
  376. jsobj1.put("FACERESULT","");
  377. jsobj1.put("COMPREHENSIVERESULT","");
  378. jsobj1.put("CHEMJUDGEID","");
  379. jsobj1.put("FACECHECKID","");
  380. jsobj1.put("COMPREHENSIVEID","");
  381. jsobj1.put("JUDGE_TYPE","C");
  382. jsobj1.put("PROD_LINE",qjc.get(0).getPline_code());
  383. jsobj1.put("ISJUDGE","2");
  384. jsobj1.put("PROD_TYPE",qjc.get(0).getProd_name());
  385. jsobj1.put("SLAB_NO",qjc.get(0).getMaterial_no());
  386. jsobj1.put("CHECKNO",qjc.get(0).getAssay_no_rl());
  387. jsobj1.put("OPTMAN", username);
  388. jsobj1.put("ISFX", "0");
  389. jsobj1.put("CHEMRESULT_FX", "");
  390. ttmaps.add(jsobj1);
  391. String url = "http://10.70.0.237:9000/LgdoChemJudgeService?wsdl";
  392. String result = qjes.callWebserviceASMX(url,"ChemJudge",JSON.toJSONString(ttmaps));
  393. JSONObject jo = JSONObject.parseObject(result);
  394. if(jo.get("code").toString().equals("1")){
  395. throw new Exception("成分取消判定失败!");
  396. }
  397. SqlSession.commit();
  398. }catch(Exception e){
  399. SqlSession.rollback();
  400. cro.setV_errCode(-1);
  401. cro.setV_errMsg("取消判定失败!"+e.getMessage());
  402. logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelRJudge:【" + material_no + "," + username + "】" + e);
  403. }
  404. SqlSession.close();
  405. return cro;
  406. }
  407. }