<%@page import="com.northglass.Globel.mes"%> <%@page import="com.northglass.SqlHelper.*"%> <%@page import="org.json.*"%> <%@ page contentType="text/json;charset=UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <% //String yemian = request.getParameter("gongyi"); String line = request.getParameter("line"); String caozuo = request.getParameter("caozuo"); String leixing = request.getParameter("leixing"); String Id = request.getParameter("Id"); String gongyi = request.getParameter("gongyi"); String lckh = request.getParameter("lckh"); DBSession sn = null; boolean ok = false; //System.out.println("操作类型:" + leixing + ";工艺:" + gongyi+";操作:"+caozuo); try { sn = mes.getMesDBHelper().createSession(false); String strSQL = ""; if ("查询".equals(caozuo)) { if ("磨边开合查询".equals(leixing)) { String stime = request.getParameter("stime"); String etime = request.getParameter("etime"); String trigger = request.getParameter("trigger"); String Edg = request.getParameter("Edg"); String banzu = request.getParameter("banzu"); String gby=""; //String isdb = request.getParameter("isdb"); System.out.println(etime); /* if("".equals(etime)||etime==null){ etime="Now()"; }else{ etime="'"+etime+"'"; } */ if("".equals(Edg)||Edg==null||"0".equals(Edg)){ Edg="width,height,SendTime,Line,count(*) as piece,ifnull(banzu,'')"; gby="Recordsid"; }else if("1".equals(Edg)){ Edg="width,SendTime,Line,ifnull(banzu,''),count(*) as piece"; gby="RecordsidW"; }else if("2".equals(Edg)){ Edg="height,SendTime,Line,ifnull(banzu,''),count(*) as piece"; gby="RecordsidH"; } if("".equals(banzu)||banzu==null||"0".equals(banzu)){ banzu=""; }else{ banzu=" banzu='"+banzu+"' and"; } if("1".equals(trigger)){//查询 strSQL = "select "+Edg+" from Y_Edg_Statistics"+ " where Line="+line+" and "+banzu+" SendTime>='"+stime+"' and SendTime<='"+etime+"'"+ " GROUP BY "+gby; }else{//默认 strSQL ="select width,height,SendTime,Line,count(*) as piece,ifnull(banzu,'') from Y_Edg_Statistics"+ " where Line="+line+" and SendTime>=CONCAT(DATE_FORMAT(Now(),'%Y-%m-%d'),' 00:00:00') and SendTime<=CONCAT(DATE_FORMAT(Now(),'%Y-%m-%d'),' 23:59:59')"+ " GROUP BY Recordsid"; } System.out.println(strSQL); } if ("次破类型".equals(leixing)) { strSQL = "select id,cipoleixing from cipoleixing"; } if ("次破原因".equals(leixing)) { strSQL = "select xuhao,cipoyuanyin,cipoleixing from cipoyuanyin"; } if ("班组列表".equals(leixing)) { String gy = gongyi.contains("钢化") ? "钢化" : gongyi; strSQL = "select banzumingcheng from banzu where gongyi='" + gongyi + "'"; } if ("当前班组".equals(leixing)) { gongyi = gongyi.contains("钢化") ? "钢化" : gongyi; strSQL = "select banzu,isPaused from gmms_user_current where gongyi= '" + gongyi + "' and chanxian = " + line; } if ("流程卡详情".equals(leixing)) { if ("钢化".equals(gongyi)) { strSQL = "select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_2 where processcard_id = '" + lckh + "' order by stop_rank"; }else if("磨边".equals(gongyi)){ strSQL="SELECT a.processcard_id,b.stop_rank,a.id,a.edg_width,a.edg_height,concat( a.thickness, 'mm ', a.color ) moxi, b.work_procedure,"+ "if((select count(1) from e_pierceds where glass_id = a.id)>0 ,'破损',b.work_state) as state,a.Id,if((select count(1) from e_record_stock where glass_id = a.id)>0 ,1,0) as isReport FROM gmms_galss_task_buffer a LEFT JOIN gmms_galss_task_details b ON a.id = b.id"+ " WHERE a.processcard_id = '"+lckh+"' ORDER BY b.stop_rank desc;"; }else if("仓储".equals(gongyi)){ strSQL="select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_shelf where processcard_id = '" + lckh + "' order by stop_rank"; }else if("仓储配对".equals(gongyi)){ strSQL="select gb.processcard_id,count(gb.id) as pricesz,count(gs.id) as prices,gb.edg_width,gb.edg_height,concat(gb.thickness,'mm ',gb.color) as moxi from gmms_galss_task_buffer as gb" +" left join gmms_galss_task_shelf as gs on gs.id=gb.id" +" where gb.processcard_id = '"+lckh+"' group by gb.edg_width,gb.edg_height,gb.thickness,gb.color order by gb.edg_width"; } else { strSQL = "select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_shelf where processcard_id = '" + lckh + "' order by stop_rank"; } } if("全部班组".equals(leixing)){ strSQL="select gongxu,banzumingcheng from banzu group by gongxu,banzumingcheng order by gongxu desc"; } if("报工详情".equals(leixing)){ //strSQL="select null, processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id ) as '破损数',count(1) as '完成数' ,concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间' from e_record_stock s where is_report = 0 and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)"; /* strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id ) as '破损数', "+ "(select IFNULL(sum(tb.edg_width*tb.edg_height),0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id) as '破损平方', "+ "count(1) as '完成数' ,IFNULL(sum(bf.edg_width*bf.edg_height)/1000000,0) as '完成平方', "+ "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间' from e_record_stock s left join gmms_galss_task_buffer as bf on s.glass_id=bf.id where is_report = 0 and line = 3 group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)"; */ strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id and process='磨边' and is_report!=-1) as '破损数', "+ "count(1) as '完成数' , "+ "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间', "+ "(select IFNULL(sum(tb.edg_width*tb.edg_height)/1000000,0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id and process='磨边' and is_report!=-1) as '破损平方',IFNULL(sum(bf.edg_width*bf.edg_height)/1000000,0) as '完成平方' from e_record_stock s left join gmms_galss_task_buffer as bf on s.glass_id=bf.id where is_report = 0 and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color) "; } if("钢化报工详情".equals(leixing)){ strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id and process='钢化' and is_report!=-1) as '破损数', "+ "count(1) as '完成数' , "+ "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间', "+ "(select IFNULL(sum(tb.edg_width*tb.edg_height)/1000000,0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id and process='钢化' and is_report!=-1) as '破损平方',IFNULL(sum(s.width*s.height)/1000000,0) as '完成平方' from e_record_tempering s where is_report != 4 and report_time is null and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)"; } if ("次破列表".equals(leixing)) { String info = request.getParameter("cpInfo"); //System.out.println("传入数据:"+info); //工艺,班组 String[] s = info.split("-"); if("0".equals(s[2])){ strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1"; }if("1".equals(s[2])){ strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report = 0"; }if("2".equals(s[2])){ //strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and pierced_cause is null and is_report !=-1"; strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1"; }if("3".equals(s[2])){ strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1"; } } if("空架".equals(leixing)){ strSQL="select r.id,f.rank from gmms_drop_frame_5 f left join gmms_shelf_rack_2 r on f.rank =r.id where f.groups_ = 100 and f.stops <21 and f.rank is not null and r.processcard_id is null"; } if("仓储配对信息".equals(leixing)){ strSQL="select * from v_cc_cpinfo"; } if("所有膜系".equals(leixing)){ strSQL ="SELECT DISTINCT(glass_id) FROM `gmms_glass_number_color` "; } //System.out.println("信息查询:" + strSQL); if("切割工位模式".equals(leixing)){ strSQL="select gongwei_mode from gmms_prod_line_state where line ="+line; } if("可钢化膜系".equals(leixing)){ strSQL ="select moxi from v_ghq_liuchengka group by moxi order by count(1) desc"; } if("切割原片详情".equals(leixing)){ strSQL ="select null,width,height,thickness,color,batch_id,sum(pieces),dengluname from gmms_cutmanage where groups ="+line+" and BgTime is null "+ "group by width,height,thickness,color,batch_id,dengluname"; } if ("理片笼单双片模式".equals(leixing)) { strSQL = "select lipianlong_mode from gmms_prod_line_state where line =" + line; } if ("原片库存图".equals(leixing)) { strSQL = "select sr.id,sr.create_time,sr.mod_time,rp.pieces,rp.left_pieces,rp.create_time, "+ "(CASE WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<3 THEN "+ " 0 "+ " WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<5 THEN "+ " 1 "+ " WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<8 THEN "+ " 2 "+ " ELSE "+ " 3 "+ " END) as datetype,CONCAT(IFNULL(rp.raw_width,0),'mm'),CONCAT(IFNULL(rp.raw_height,0),'mm'),CONCAT(IFNULL(rp.raw_thickness,0),'mm'),rp.color,rp.batch_id from gmms_shelf_rack as sr left join gmms_raw_package as rp on sr.raw_package_id1=rp.id where sr.raw_package_id1 is not null"; } if ("切裁率图-原片使用".equals(leixing)) { strSQL = "select IFNULL(SUM(gc.width*gc.height)/1000000,0) from "+ "(SELECT DATE_FORMAT(DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL (CAST(help_topic_id AS SIGNED INTEGER)) DAY),'%Y-%m-%d') month "+ "FROM mysql.help_topic WHERE help_topic_id < 14 ORDER BY month ASC) as d "+ "left JOIN gmms_cutmanage as gc on d.month=DATE_FORMAT(gc.BgTime,'%Y-%m-%d') group by d.month;"; } if ("切裁率图-原片使用当月".equals(leixing)) { strSQL = "select IFNULL(SUM(width*height)/1000000,0),IFNULL(DATE_FORMAT(BgTime,'%Y-%m'),DATE_FORMAT(NOW(),'%Y-%m-01')) from gmms_cutmanage where BgTime>DATE_FORMAT(NOW(),'%Y-%m-01');"; } if ("单炉最大装载率-面积最大比例差".equals(leixing)) { strSQL = "select IFNULL(maxLoadingRate,0),IFNULL(maxTolerance,0) from gmms_furnace where id=" + line; } if ("单炉最大面积比例差".equals(leixing)) { strSQL = "select IFNULL(maxTolerance,0) from gmms_furnace where id=" + line; } sn.createSql(strSQL); JSONArray a = sn.query().resultToJson(false); if (a != null) { out.print(a.toString()); } else { out.print("[]"); } } if ("修改".equals(caozuo)) { if ("变更班组".equals(leixing)) { String bzinfo = request.getParameter("info"); strSQL = "update gmms_user_current set banzu = '" + bzinfo + "',isPaused=null where gongyi = '" + gongyi + "' and chanxian = " + line; } if("次破".equals(leixing)){ String info = request.getParameter("cpInfo"); //次破类型,次破原因 String[] s = info.split("-"); strSQL="Update e_pierceds set pierced_type = '"+s[0]+"',pierced_cause = '"+s[1]+"' where glass_id = "+Id; } if("提交报工".equals(leixing)){ String info = request.getParameter("cpInfo"); //次破类型,次破原因 String[] s = info.split("-"); strSQL="Update e_pierceds set is_report = 1 where process = '"+s[0]+"' and team_name = '"+s[1]+"' and pierced_type is not null and is_report=0"; } if("班组下班".equals(leixing)){ strSQL = "update gmms_user_current set banzu = null where gongyi = '" + gongyi+ "' and chanxian = " + line; } //System.out.println("修改:" + strSQL); if("变更切割工位模式".equals(leixing)){ strSQL="update gmms_prod_line_state set gongwei_mode= if(gongwei_mode=1,2,1) where line ="+line; } if ("变更理片笼单双片模式".equals(leixing)) { strSQL = "update gmms_prod_line_state set lipianlong_mode= if(lipianlong_mode=1,2,1) where line =" + line; } if ("单炉最大装载率".equals(leixing)) { String value = request.getParameter("value"); strSQL = "update gmms_furnace set maxLoadingRate='"+value+"' where id=" + line; } if ("单炉最大面积比例差".equals(leixing)) { String value = request.getParameter("value"); strSQL = "update gmms_furnace set maxTolerance='"+value+"' where id=" + line; } sn.createSql(strSQL); int s = sn.update(); //System.out.println(s); out.print(s); } if ("次破".equals(caozuo)) { //gongyi = gongyi.contains("钢化") ? "钢化" : gongyi; if ("钢化".equals(gongyi)) { String info = request.getParameter("cpInfo"); //System.out.println("传入信息:" + info); String[] s = info.split("-"); sn.createStdCall("proc_ePiercedsByGlassIdSave", 5); DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } if ("中空".equals(gongyi)) { String info = request.getParameter("cpInfo"); //System.out.println("中空传入信息:" + info); String[] s = info.split("-"); sn.createStdCall("proc_ePiercedsByGlassIdSave", 5); DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } if ("仓储".equals(gongyi)) { String info = request.getParameter("cpInfo"); //System.out.println("仓储传入信息:" + info); String[] s = info.split("-"); sn.createStdCall("proc_ePiercedsByGlassIdSave", 5); DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } if ("磨边".equals(gongyi)) { String info = request.getParameter("cpInfo"); //System.out.println("磨边传入信息:" + info); String[] s = info.split("-"); sn.createStdCall("proc_ePiercedsByGlassIdSave", 5); DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } } if("取消破损".equals(caozuo)){ strSQL ="INSERT INTO e_record_tempering(processcard_id, glass_id, width, height, thinkess, color, sequence, create_time, line, team_name, type_num, is_report,rank) "+ "select gt.processcard_id,gt.id,gt.edg_width,gt.edg_height,gt.thickness,gt.color,gt.stop_rank,NOW(),ep.line,ep.team_name,gt.edg_speed2,1,0 from gmms_galss_task_buffer as gt "+ "left join e_record_tempering as et on gt.id=et.glass_id "+ "left join e_pierceds as ep on ep.glass_id=gt.id "+ "where et.glass_id is null and ep.glass_id is not null and gt.id='"+Id+"'"; //System.out.println("修改:" + strSQL); sn.createSql(strSQL); int qx = sn.update(); //System.out.println(s); out.print(qx); String strquxiao="Update e_pierceds set is_report=-1 where glass_id = "+Id; sn.createSql(strquxiao); int qxposun = sn.update(); } if("报工确认".equals(caozuo)){ //System.out.println("报工确认数据:" + lckh + ";产线:" + line); sn.createStdCall("proc_eRecordStockByGlassIdSave", 2); DBSession.StdCallResult scr = sn.stdCall(lckh, line); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } if("报工提交".equals(caozuo)){ sn.createStdCall("proc_eRecordStockByLineUpdata", 1); DBSession.StdCallResult scr = sn.stdCall(line); int rC = scr.ResultCode; String rM = scr.ResultMessage; if (rC == 1) { out.print("OK"); } else { out.print(rC + "_" + rM); } } if("钢化报工提交".equals(caozuo)){ strSQL = "update e_record_tempering set report_time = now() where is_report != 4 and report_time is null and line = " + line; sn.createSql(strSQL); int s = sn.update(); //out.print(s); String postrSQL="update e_pierceds set report_time = now() where is_report != -1 and is_report != 4 and report_time is null and line = "+line+" and process = '钢化'"; sn.createSql(postrSQL); int ps = sn.update(); out.print(ps); } if("切割提交".equals(caozuo)){ strSQL = "update gmms_cutmanage set BgTime=now() where BgTime is null and groups=" + line; System.out.println(strSQL); sn.createSql(strSQL); int s = sn.update(); out.print(s); String bzSQL = "update gmms_user_current set isPaused='暂停' where gongyi = '磨边' and chanxian = " + line; sn.createSql(bzSQL); int ps = sn.update(); } } catch (Exception e) { e.printStackTrace(); } finally { if (sn != null) sn.close(); } %>