package QCM.QCM03.QCM0301; import CoreFS.SA01.CoreIComponent; import CoreFS.SA06.CoreReturnObject; import QCM.COMMUNAL.QCM02.SqlJoint; import QCM.COMMUNAL.VO.*; import QCM.QCM03.QCM0303.QcmJudgeMeasureServiceImpl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.apache.ibatis.session.SqlSession; import org.apache.log4j.Logger; import java.util.Date; import java.util.HashMap; import java.util.List; public class QcmJudgeChemicalServiceImpl extends CoreIComponent{ CoreReturnObject cro = new CoreReturnObject(); SqlSession SqlSession = QCM.COMMUNAL.SqlSessionBuilder.openSqlSession(); QCM.COMMUNAL.OrderSqMapper mapper = SqlSession.getMapper(QCM.COMMUNAL.OrderSqMapper.class); QcmJudgeMeasureServiceImpl qjm = new QcmJudgeMeasureServiceImpl(); private Logger logger = Logger.getLogger(this.getClass().getName()); public String StrSky(String begintime,String endtime){ String sql = "select (to_date('"+endtime+"','yyyy-MM-dd') - to_date('"+begintime+"','yyyy-MM-dd')) SKY from dual"; HashMap list = mapper.queryOne(sql); Double ble = Double.parseDouble(list.get("SKY").toString()); String tstr="FALSE"; if(ble>=0 && ble <=30 ){ tstr="TRUE"; } return tstr; } /** * 获取成品成分判定记录 * @param page * @return */ public CoreReturnObject GetJudgeChemRecord(String begintime,String endtime,String batch_no,String boardno,String design_key,String psc_desc,String type,String prodline){ try{ if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime) && SqlJoint.IsNullOrSpace(batch_no)) { String sky=StrSky(begintime,endtime); if(sky.equals("FALSE")){ SqlSession.close(); cro.setV_errCode(-1); cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!"); return cro; } } //String sqls = "select chemid from zj_result_all@xgcx union all select chemid from QCM_JUDGE_COIL_RESULT"; String con= "1=1"; String sql = "select * from QCM_JUDGE_CHEMICAL where "; if(!SqlJoint.IsNullOrSpace(batch_no)){ con += " and batch_no like '%"+batch_no+"%'"; } if(!SqlJoint.IsNullOrSpace(boardno)){ con += " and BOARD_NO like '%"+boardno+"%'"; } if(!SqlJoint.IsNullOrSpace(design_key)){ con += " and design_key like '%"+design_key+"%'"; } if(!SqlJoint.IsNullOrSpace(psc_desc)){ con += "psc_desc like '%"+psc_desc+"%'"; } if(!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) { 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') "; } if(!SqlJoint.IsNullOrSpace(type)){ //卷板 if(type.equals("0")){ con += " and pline_code in ('LT1','SZ1','RZ1','4001RZ1','4001LT1','4001LZ1')"; } //中厚板 else if(type.equals("1")){ con += " and pline_code in ('ZB1','HB1')"; } //线棒 else if(type.equals("2")){ con += " and pline_code in ('GX1','BC1','BC2','GX2')"; } } if(prodline.equals("中板线")){ con += " and pline_code in ('ZB1') "; }else if(prodline.equals("厚板线")){ con += " and pline_code in ('HB1') "; }else if(prodline.equals("热连轧")){ con += " and pline_code in ('RZ1') "; }else if(prodline.equals("酸轧")){ con += " and pline_code in ('SZ1') "; }else if(prodline.equals("连退")){ con += " and pline_code in ('LT1') "; }else if(prodline.equals("高棒")){ con += " and pline_code in ('GX1') "; }else if(prodline.equals("棒二")){ con += " and pline_code in ('BC2') "; }else if(prodline.equals("高线")){ con += " and pline_code in ('GX2') "; } con += " and cic_id like 'C%'"; //con += " and cic_id in ("+sqls+")"; sql += con + " order by judge_ttime desc"; List listChemical = mapper.queryQcmJudgeChemical(sql); /*for(QcmJudgeChemical qjc:listChemical){ List 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()+"'"); for(HashMap lists:listss) { qjc.setCic_result_code(lists.get("CHEMRESULT").toString()); qjc.setCic_result_desc(lists.get("CHEMRESULT_DESC").toString()); } }*/ cro.setResult(listChemical); }catch(Exception ex){ cro.setV_errCode(-1); cro.setV_errMsg("查询失败!"+ex.getMessage()); } SqlSession.close(); return cro; } /** * 获取熔炼成分判定记录 * @param page * @return */ 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){ try{ //String sqls = "select r_chemid from zj_result_all@xgcx union all select r_chemid from QCM_JUDGE_COIL_RESULT"; if (!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime) && SqlJoint.IsNullOrSpace(heatno) && SqlJoint.IsNullOrSpace(sbatchno)) { String sky=StrSky(begintime,endtime); if(sky.equals("FALSE")){ SqlSession.close(); cro.setV_errCode(-1); cro.setV_errMsg("查询时间不能大于30天,请核实查询时间条件!"); return cro; } } String con= "1=1"; String sql = "select * from QCM_JUDGE_CHEMICAL where "; if(!SqlJoint.IsNullOrSpace(heatno)){ con += " and heat_no like '%"+heatno+"%'"; } if(!SqlJoint.IsNullOrSpace(boardno)){ con += " and BOARD_NO like '%"+boardno+"%'"; } if(!SqlJoint.IsNullOrSpace(design_key)){ con += " and design_key like '%"+design_key+"%'"; } if(!SqlJoint.IsNullOrSpace(material_no)){ con += " and material_no like '%"+material_no+"%'"; } if(!SqlJoint.IsNullOrSpace(sbatchno)){ con += " and batch_no >= '"+sbatchno+"'"; } if(!SqlJoint.IsNullOrSpace(ebatchno)){ con += " and batch_no <= '"+ebatchno+"'"; } if(!SqlJoint.IsNullOrSpace(begintime) && !SqlJoint.IsNullOrSpace(endtime)) { 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') "; } if(prodline.equals("中板线")){ con += " and pline_code in ('ZB1') "; }else if(prodline.equals("厚板线")){ con += " and pline_code in ('HB1') "; }else if(prodline.equals("热连轧")){ con += " and pline_code in ('RZ1') "; }else if(prodline.equals("酸轧")){ con += " and pline_code in ('SZ1') "; }else if(prodline.equals("连退")){ con += " and pline_code in ('LT1') "; }else if(prodline.equals("高棒")){ con += " and pline_code in ('GX1') "; }else if(prodline.equals("棒二")){ con += " and pline_code in ('BC2') "; }else if(prodline.equals("高线")){ con += " and pline_code in ('GX2') "; }else if(prodline.equals("优特")){ con += " and pline_code in ('YT1') "; } if(!SqlJoint.IsNullOrSpace(type)){ //卷板 if(type.equals("0")){ con += " and pline_code in ('LT1','SZ1','RZ1','4001RZ1','4001LT1','4001LZ1')"; } //中厚板 else if(type.equals("1")){ con += " and pline_code in ('ZB1','HB1')"; } //线棒 else if(type.equals("2")){ con += " and pline_code in ('GX1','BC1','BC2','GX2')"; } //优特 else if(type.equals("3")){ con += " and pline_code in ('YT1')"; } } con += " and cic_id like 'R%'"; //con += " and cic_id in ("+sqls+")"; sql += con + " order by judge_ttime desc"; List listChemical = mapper.queryQcmJudgeChemical(sql); /*for(QcmJudgeChemical qjc:listChemical){ List 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()+"'"); for(HashMap lists:listss) { qjc.setCic_result_code(lists.get("R_CHEMRESULT").toString()); qjc.setCic_result_desc(lists.get("R_CHEMRESULT_DESC").toString()); } }*/ cro.setResult(listChemical); }catch(Exception ex){ cro.setV_errCode(-1); cro.setV_errMsg("查询失败!"+ex.getMessage()); } SqlSession.close(); return cro; } /** * 取消判定 检验号 */ public CoreReturnObject CancelJudge(String inspection_lot,String smp_no,String username) throws Exception{ try{ //判断是否进行了综合判定 String sql = "select * from zj_result_all@xgcx where BILLETID_JY = '"+inspection_lot+"'"; List list1 = mapper.query(sql); sql = "select * from QCM_JUDGE_COIL_RESULT where INSPECTION_LOT = '"+inspection_lot+"'"; List list2 = mapper.query(sql); if(list1.size() >0 || list2.size() >0){ if(list1.size()>0){ for(HashMap list:list1){ if(!list.get("JUDGERESULT").toString().equals("0")){ throw new Exception("该检验号下已有物料号做了综合判定,不能取消判定!"); } if(list.get("CIC_IS_LOCK").toString().equals("1")){ throw new Exception("该检验号已锁定,不能取消判定!"); } } mapper.clearCHEMRESULT(inspection_lot); }else{ for(HashMap list:list2){ if(!list.get("JUDGERESULT").toString().equals("0")){ throw new Exception("该检验号下已有物料号做了综合判定,不能取消判定!"); } if(list.get("CIC_IS_LOCK").toString().equals("1")){ throw new Exception("该检验号已锁定,不能取消判定!"); } } mapper.clearCHEMRESULT1(inspection_lot); } }else{ throw new Exception("未找到该检验号下的库存信息!"); } List qjsr = mapper.queryQcmJhySampleROrd1("select * from qcm_jhy_sample_r_ord where smp_no = '"+smp_no+"'"); //清空试样与合同信息表成分判定记录号 QcmJhySampleROrd qsrd = new QcmJhySampleROrd(); qsrd.setInspection_lot(inspection_lot); qsrd.setSmp_no(smp_no); mapper.UpdateQcmJhySampleROrd(qsrd); QcmJudgeOperateLog qjog = new QcmJudgeOperateLog(); qjog.setOperate_name(username); qjog.setOperate_type("成品成分取消判定"); qjog.setParams(smp_no); qjog.setBatchno(qjsr.get(0).getBatch_no()); qjog.setProd_line(qjsr.get(0).getPline_code()); mapper.insertQcmJudgeOperateLog(qjog); SqlSession.commit(); }catch(Exception e){ SqlSession.rollback(); cro.setV_errCode(-1); cro.setV_errMsg("取消判定失败!"+e.getMessage()); logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelJudge:【" + inspection_lot + "," + smp_no + "】" + e); } SqlSession.close(); return cro; } /** * 取消判定 */ public CoreReturnObject CancelRJudge(String material_no,String username) throws Exception{ try{ //判断是否进行了综合判定 String sql = "select * from zj_result_all@xgcx where BILLETID = '"+material_no+"'"; List list1 = mapper.query(sql); sql = "select * from QCM_JUDGE_COIL_RESULT where COIL_NO = '"+material_no+"'"; List list2 = mapper.query(sql); sql = "select * from QCM_JUDGE_YT_COIL_RESULT where COIL_NO = '"+material_no+"'"; List list3 = mapper.query(sql); if(list1.size() >0 || list2.size() >0 || list3.size() >0){ if(list1.size()>0){ for(HashMap list:list1){ if(!list.get("JUDGERESULT").toString().equals("0")){ throw new Exception("该物料号做了综合判定,不能取消判定!"); } if(list.get("R_CIC_IS_LOCK").toString().equals("1")){ throw new Exception("该物料号已锁定,不能取消判定!"); } } ZjResultAll zra = new ZjResultAll(); zra.setBilletid(material_no); zra.setR_chemid(""); zra.setR_chemresult_desc("待判"); zra.setR_chemresult("0"); mapper.UpdateJugeResultB(zra); }else if(list2.size()>0){ for(HashMap list:list2){ if(!list.get("JUDGERESULT").toString().equals("0")){ throw new Exception("该物料号做了综合判定,不能取消判定!"); } if(list.get("R_CIC_IS_LOCK").toString().equals("1")){ throw new Exception("该物料号已锁定,不能取消判定!"); } } QcmJudgeCoilResult zra = new QcmJudgeCoilResult(); zra.setCoil_no(material_no); zra.setR_chemid(""); zra.setR_chemresult_desc("待判"); zra.setR_chemresult("0"); mapper.UpdateJugeResultJ(zra); }else{ for(HashMap list:list3){ if(!list.get("JUDGERESULT").toString().equals("0")){ throw new Exception("该物料号做了综合判定,不能取消判定!"); } if(list.get("R_CIC_IS_LOCK").toString().equals("1")){ throw new Exception("该物料号已锁定,不能取消判定!"); } } QcmJudgeYtCoilResult zra = new QcmJudgeYtCoilResult(); zra.setCoil_no(material_no); zra.setR_chemid(""); zra.setR_chemresult_desc("待判"); zra.setR_chemresult("0"); mapper.UpdateJugeResultY(zra); } }else{ throw new Exception("未找到库存信息!"); } List qjc = mapper.queryQcmJudgeChemical("select * from qcm_judge_chemical where material_no = '"+material_no+"' order by judge_ttime desc"); QcmJudgeOperateLog qjog = new QcmJudgeOperateLog(); qjog.setOperate_name(username); qjog.setOperate_type("轧钢熔炼成分取消判定"); qjog.setParams(material_no); qjog.setBatchno(qjc.get(0).getBatch_no()); qjog.setProd_line(qjc.get(0).getPline_code()); mapper.insertQcmJudgeOperateLog(qjog); SqlSession.commit(); }catch(Exception e){ SqlSession.rollback(); cro.setV_errCode(-1); cro.setV_errMsg("取消判定失败!"+e.getMessage()); logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelRJudge:【" + material_no + "】" + e); } SqlSession.close(); return cro; } /** * 取消判定 */ public CoreReturnObject CancelLgRJudge(String material_no,String username) throws Exception{ try{ QcmJhyElementsServiceImpl qjes = new QcmJhyElementsServiceImpl(); List qj = mapper.queryQCMJudgeLockings("select * from qcm_judge_locking where material_no = '"+material_no+"' and unlock_type_code is null"); if(qj.size() > 0){ throw new Exception("该检验结果已生成异常材处置,请完成异常材处置!"); } List qjc = mapper.queryQcmJudgeChemical("select * from qcm_judge_chemical where material_no = '"+material_no+"' order by judge_ttime desc"); QcmJudgeOperateLog qjog = new QcmJudgeOperateLog(); qjog.setOperate_name(username); qjog.setOperate_type("炼钢熔炼成分取消判定"); qjog.setParams(material_no); qjog.setProd_line(qjc.get(0).getPline_code()); mapper.insertQcmJudgeOperateLog(qjog); //调用单项判定 JSONObject jsobj2 = new JSONObject(); JSONArray ttmaps = new JSONArray(); JSONObject jsobj1 = new JSONObject(); jsobj1.put("CHEMRESULT_LK", ""); jsobj1.put("FACERESULT",""); jsobj1.put("COMPREHENSIVERESULT",""); jsobj1.put("CHEMJUDGEID",""); jsobj1.put("FACECHECKID",""); jsobj1.put("COMPREHENSIVEID",""); jsobj1.put("JUDGE_TYPE","C"); jsobj1.put("PROD_LINE",qjc.get(0).getPline_code()); jsobj1.put("ISJUDGE","2"); jsobj1.put("PROD_TYPE",qjc.get(0).getProd_name()); jsobj1.put("SLAB_NO",qjc.get(0).getMaterial_no()); jsobj1.put("CHECKNO",qjc.get(0).getAssay_no_rl()); jsobj1.put("OPTMAN", username); jsobj1.put("ISFX", "0"); jsobj1.put("CHEMRESULT_FX", ""); ttmaps.add(jsobj1); String url = "http://10.70.0.237:9000/LgdoChemJudgeService?wsdl"; String result = qjes.callWebserviceASMX(url,"ChemJudge",JSON.toJSONString(ttmaps)); JSONObject jo = JSONObject.parseObject(result); if(jo.get("code").toString().equals("1")){ throw new Exception("成分取消判定失败!"); } SqlSession.commit(); }catch(Exception e){ SqlSession.rollback(); cro.setV_errCode(-1); cro.setV_errMsg("取消判定失败!"+e.getMessage()); logger.info(new Date().toString() + " QCM.QCM03.QCM0301.QcmJudgeChemicalServiceImpl.CancelRJudge:【" + material_no + "," + username + "】" + e); } SqlSession.close(); return cro; } }