| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- 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<QcmJudgeChemical> listChemical = mapper.queryQcmJudgeChemical(sql);
- /*for(QcmJudgeChemical qjc:listChemical){
- 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()+"'");
- 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<QcmJudgeChemical> listChemical = mapper.queryQcmJudgeChemical(sql);
- /*for(QcmJudgeChemical qjc:listChemical){
- 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()+"'");
- 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<HashMap> list1 = mapper.query(sql);
- sql = "select * from QCM_JUDGE_COIL_RESULT where INSPECTION_LOT = '"+inspection_lot+"'";
- List<HashMap> 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<QcmJhySampleROrd> 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<HashMap> list1 = mapper.query(sql);
- sql = "select * from QCM_JUDGE_COIL_RESULT where COIL_NO = '"+material_no+"'";
- List<HashMap> list2 = mapper.query(sql);
- sql = "select * from QCM_JUDGE_YT_COIL_RESULT where COIL_NO = '"+material_no+"'";
- List<HashMap> 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<QcmJudgeChemical> 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<QCMJudgeLocking> 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<QcmJudgeChemical> 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;
-
- }
- }
|