package com.sinosoft.em.response.team.service; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import com.persistence.DbConnection; import com.sinosoft.lz.system.Utils; @Path("TeamAllotUpdateTeamState") public class TeamAllotUpdateTeamState { @POST @ProduceMime("application/json") @Path("/updateTeamStateToBusiness/") public String updateTeamStateToBusiness(String param){ String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); String sql="update ECM_AM_EMERGENCY_TEAM set TEAM_STAT='2' where FD_OBJECTID=? and is_del='0'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 int n = 0; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); n = pstm.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ return "00"; } @POST @ProduceMime("application/json") @Path("/updateTeamStateToFree/") public String updateTeamStateToFree(String param){ String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); String sql="update ECM_AM_EMERGENCY_TEAM set TEAM_STAT='1' where FD_OBJECTID=? and is_del='0'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 /*List userList = new ArrayList();*/ //sb.append("{\"result\":"); int n = 0; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); n = pstm.executeUpdate(); //while(rs.next()){ //sb.append("{\"key\":\"" + rs.getString("REAL_NAME") + "\",\"value\":\""+rs.getString("USER_ID")+"\"},"); //sb.append("true}"); //} //sb.append("]}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return ""; } @POST @ProduceMime("application/json") @Path("/updateTeamDemandStateToAlloting/") public String updateTeamDemandStateToAlloting(String param){ String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); // String sql="update ECM_EM_TEAM_WRR set STATE='136' where FD_OBJECTID=? and is_del='0'"; String sql="update ECM_EM_TEAM_WRR set ISALLOT='1' where FD_OBJECTID=? and is_del='0'";//20160920 DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 int n = 0; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); n = pstm.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ return "11"; } /*@POST @ProduceMime("application/json") @Path("/updateTeamDemandStateToEnd/") public String updateTeamDemandStateToEnd(String param){*/ public String updateTeamDemandStateToEnd(String fdObjectid){//设置队伍需求的状态为结束-----如果需求的调拨单位字段的长度(,)和UNITS_GETBACK的长度相等,再改 //String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); String sql="update ECM_EM_TEAM_WRR set STATE='137' where FD_OBJECTID=? and is_del='0'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 int n = 0; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); n = pstm.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ return "11"; } @POST @ProduceMime("application/json") @Path("/addUnitIdToUNITS_GETBACK/") public String addUnitIdToUNITS_GETBACK(String param){ String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); String unitId = Utils.getParameter("unitId", param) == null ? "" : Utils.getParameter("unitId", param); addUnitIdToUNITS_GETBACK1(param);//更新ECM_EM_TEAM_WRR.UNITS_GETBACK的值 String allTwoTypeUnits = getAllTwoTypeUnits(fdObjectid);//获取调拨单位ID和已返回的单位ID int allotUnitsLen = allTwoTypeUnits.split("-")[0].split(",").length;//调拨单位ID的长度(单位个数) String unitsGetBack = allTwoTypeUnits.split("-")[1]; int unitsGetBackLen = -1;//已返回的单位ID的长度(单位个数) if("kong".equals(unitsGetBack)){ unitsGetBackLen = 0; }else{ unitsGetBackLen = unitsGetBack.split(",").length; } if(allotUnitsLen == unitsGetBackLen){ updateTeamDemandStateToEnd(fdObjectid);//设置队伍需求的状态为结束-----如果需求的调拨单位字段的长度(,)和UNITS_GETBACK的长度相等,再改 } return ""; } public String addUnitIdToUNITS_GETBACK1(String param){//更新ECM_EM_TEAM_WRR.UNITS_GETBACK的值 String fdObjectid = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param); String unitId = Utils.getParameter("unitId", param) == null ? "" : Utils.getParameter("unitId", param); //判断ECM_EM_TEAM_WRR.UNITS_GETBACK是否包含unitId的值,如果包含就不添加,否则添加进去 boolean isContainsUnit = false; isContainsUnit = isContainsTheUnit(fdObjectid,unitId); if(isContainsUnit){//如果包含,结束该方法 return ""; }else{//否则,添加单位ID到ECM_EM_TEAM_WRR.UNITS_GETBACK String units_getBack = getUnits_getBack(fdObjectid); if(units_getBack.equals(null) || "null".equals(units_getBack) || "".equals(units_getBack)){ units_getBack = unitId; }else{ units_getBack += ","+unitId; } String sql="update ECM_EM_TEAM_WRR set UNITS_GETBACK='"+units_getBack+"' where FD_OBJECTID=? and is_del='0'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 int n = 0; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); n = pstm.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return "11"; } } public String getUnits_getBack(String fdObjectid){//查询ECM_EM_TEAM_WRR.UNITS_GETBACK的值 String sql = "select UNITS_GETBACK from ECM_EM_TEAM_WRR where FD_OBJECTID ='"+fdObjectid+"'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); rs = pstm.executeQuery(); while(rs.next()){ sb.append(rs.getString("UNITS_GETBACK") == null ? "" : rs.getString("UNITS_GETBACK")); } } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return sb.toString(); } public boolean isContainsTheUnit(String fdObjectid,String unitId){// String allTwoTypeUnits = getAllTwoTypeUnits(fdObjectid);//获取调拨单位ID和已返回的单位ID //String allotUnits = allTwoTypeUnits.split("-")[0];//获取调拨单位ID String unitsGetBack = allTwoTypeUnits.split("-")[1];//获取已返回的单位ID boolean isContainsTheUnit = unitsGetBack.contains(unitId); return isContainsTheUnit; } public String getAllTwoTypeUnits(String fdObjectid){//获取调拨单位ID和已返回单位 String sql = "select RANGE_UNITS_ID,UNITS_GETBACK from ECM_EM_TEAM_WRR where FD_OBJECTID ='"+fdObjectid+"'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); rs = pstm.executeQuery(); while(rs.next()){ String allotUnits = rs.getString("RANGE_UNITS_ID") == null ? "" : rs.getString("RANGE_UNITS_ID"); String unitsGetBack = rs.getString("UNITS_GETBACK") == null ? "kong" : rs.getString("UNITS_GETBACK"); sb.append(allotUnits+"-"+unitsGetBack); } } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getTeamMsgFromDailyTeam/") public String getTeamMsgFromDailyTeam(String params){ String fdObjectid = Utils.getParameter("FD_OBJECTID", params) == null ? "" : Utils.getParameter("FD_OBJECTID", params); String sql = "select e.TEAM_TYPE,e.TEAM_LEVEL,e.TEAM_LEADER,e.TEAM_PHONE,e.TEAM_MEMBER_NUMBER from ECM_AM_EMERGENCY_TEAM e where FD_OBJECTID =?"; //System.out.println("-------------------------------------------------"+sql); DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); /*List userList = new ArrayList();*/ sb.append("{\"result\":["); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); rs = pstm.executeQuery(); while(rs.next()){ sb.append("{\"TEAM_TYPE\":\""+rs.getString("TEAM_TYPE")+"\"},"); sb.append("{\"TEAM_LEVEL\":\""+rs.getString("TEAM_LEVEL")+"\"},"); sb.append("{\"TEAM_LEADER\":\""+rs.getString("TEAM_LEADER")+"\"},"); sb.append("{\"TEAM_PHONE\":\""+rs.getString("TEAM_PHONE")+"\"},"); sb.append("{\"TEAM_MEMBER_NUMBER\":\""+rs.getString("TEAM_MEMBER_NUMBER")+"\"}"); } sb.append("]}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ // System.out.println("-------------------------------------------------"+sb.toString()); return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getTeamType/") public String getTeamType(String params){ String fdCode = Utils.getParameter("FD_CODE", params) == null ? "" : Utils.getParameter("FD_CODE", params); String sql = "select FD_DESCRIPTION from BM_MAPVALUECANST where FD_TYPE='BM_TEAMTYPE' and FD_CODE=?"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); /*List userList = new ArrayList();*/ sb.append("{\"result\":\""); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdCode); rs = pstm.executeQuery(); while(rs.next()){ sb.append(rs.getString("FD_DESCRIPTION")); } sb.append("\"}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getTeamLevel/") public String getTeamLevel(String params){ String fdCode = Utils.getParameter("FD_CODE", params) == null ? "" : Utils.getParameter("FD_CODE", params); String sql = "select FD_DESCRIPTION from BM_MAPVALUECANST where FD_TYPE='BM_DYDJ' and FD_CODE=?"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); /*List userList = new ArrayList();*/ sb.append("{\"result\":\""); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdCode); rs = pstm.executeQuery(); while(rs.next()){ sb.append(rs.getString("FD_DESCRIPTION")); } sb.append("\"}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getTeamName/") public String getTeamName(String params){ String fdObjectid = Utils.getParameter("FD_OBJECTID", params) == null ? "" : Utils.getParameter("FD_OBJECTID", params); String sql = "select TEAM_NAME from ECM_AM_EMERGENCY_TEAM where FD_OBJECTID=?"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); /*List userList = new ArrayList();*/ sb.append("{\"result\":\""); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, fdObjectid); rs = pstm.executeQuery(); while(rs.next()){ sb.append(rs.getString("TEAM_NAME")); } sb.append("\"}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getTeamCallerRealName/") public String getTeamCallerRealName(String params){ String userId = Utils.getParameter("USER_ID", params) == null ? "" : Utils.getParameter("USER_ID", params); String sql = "select REAL_NAME from SYS_USER_INFO where USER_ID=?"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); /*List userList = new ArrayList();*/ sb.append("{\"result\":\""); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); pstm.setString(1, userId); rs = pstm.executeQuery(); while(rs.next()){ sb.append(rs.getString("REAL_NAME")); } sb.append("\"}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return sb.toString(); } @POST @ProduceMime("application/json") @Path("/getLinkMenMsg/") public String getLinkMenMsg(String params){ String fdObjectid = Utils.getParameter("objectId391", params) == null ? "" : Utils.getParameter("objectId391", params); String sql = "select ENTRY_UNIT_ATTN,ENTRY_UNIT_ATTN_TEL,ENTRY_ALTERNATIVE,ENTRY_ALTERNATIVE_TEL from ECM_EM_TEAM_WRR where FD_OBJECTID='"+fdObjectid+"'"; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 StringBuffer sb = new StringBuffer(); sb.append("{\"result\":["); try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); rs = pstm.executeQuery(); while(rs.next()){ String linkManId1 = rs.getString("ENTRY_UNIT_ATTN") == null ? "" : rs.getString("ENTRY_UNIT_ATTN");//联系人ID String linkPhone1 = rs.getString("ENTRY_UNIT_ATTN_TEL") == null ? "" : rs.getString("ENTRY_UNIT_ATTN_TEL");//联系人电话 String linkManName1 = "";//联系人NAME String linkManId2 = rs.getString("ENTRY_ALTERNATIVE") == null ? "" : rs.getString("ENTRY_ALTERNATIVE");//联系人ID String linkPhone2 = rs.getString("ENTRY_ALTERNATIVE_TEL") == null ? "" : rs.getString("ENTRY_ALTERNATIVE_TEL");//联系人电话 String linkManName2 = "";//联系人NAME if(!"".equals(linkManId1)){ linkManName1 = getRealName(linkManId1); } if(!"".equals(linkManId2)){ linkManName2 = getRealName(linkManId2); } sb.append("{\"linkManId1\":\""+linkManId1+"\"},{\"linkManName1\":\""+linkManName1+"\"},{\"linkPhone1\":\""+linkPhone1+"\"},"+ "{\"linkManId2\":\""+linkManId2+"\"},{\"linkManName2\":\""+linkManName2+"\"},{\"linkPhone2\":\""+linkPhone2+"\"}"); } sb.append("]}"); } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } /*String usersJson = JsonPluginsUtil.listToJson(userList); Log.info(usersJson); return usersJson;*/ // System.out.println("-------------------------------------------------"+sb.toString()); return sb.toString(); } public String getRealName(String userId){ String sql = " select REAL_NAME from SYS_USER_INFO where USER_ID='"+userId+"' "; DbConnection dbConn = new DbConnection();//数据库连接 Connection conn = null; PreparedStatement pstm = null;//sql语句的执行者 ResultSet rs = null;//结果集 String realName = ""; try { conn = dbConn.getConnection(); pstm = conn.prepareStatement(sql); rs = pstm.executeQuery(); while(rs.next()){ realName = rs.getString("REAL_NAME") == null ? "" : rs.getString("REAL_NAME");//联系人NAME } } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); }finally{ try { if(pstm!=null) pstm.close(); if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } return realName; } }