123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- package com.sinosoft.em.response.equipment.records.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("EquipAllotUpdateEquipState")
- public class EquipAllotUpdateEquipState {
-
- @POST
- @ProduceMime("application/json")
- @Path("/updateEquipStateToBusy/")
- public String updateEquipStateToBusy(String param){//修改应急装备的状态
- //param = param.toString().split("=")[1];
- //String sql="update EMC_AM_GENERATOR_CAR set IS_USED='2' , USED_STAT='2' where FD_OBJECTID='"+param+"' and is_del='0'";
-
- String equipId = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param);//装备ID
- String equipType = Utils.getParameter("EQUIPMENT_TYPE", param) == null ? "" : Utils.getParameter("EQUIPMENT_TYPE", param);//装备类型,用于判断sql从哪张表里面查
- String sql = "";
- if("265".equals(equipType)){
- //sql = "select CAR_NUM,IS_USED from EMC_AM_GENERATOR_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_GENERATOR_CAR set IS_USED = '2' , USED_STAT = '2' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//IS_USED = '2' 不可调用
- } else if("266".equals(equipType)){
- //sql = "select NUM,USED_STAT from EMC_AM_GENERATOR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_GENERATOR set USED_STAT = '2' , IS_USED = '2' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//USED_STAT = '2' 调拨中
- } else if("270".equals(equipType)){
- //sql = "select CAR_NUM,USED_STAT from EMC_AM_DINING_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_DINING_CAR set IS_USED = '2' , USED_STAT = '2' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//IS_USED = '2' 不可调用
- } else if("269".equals(equipType)){
- //sql = "select CAR_NUM,USED_STAT from EMC_AM_EMERGENCY_COMMAND_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_EMERGENCY_COMMAND_CAR set USED_STAT = '2' , IS_USED = '2' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//USED_STAT = '2' 调拨中
- }
-
- //System.out.println("******//////////***********"+sql);
-
- DbConnection dbConn = new DbConnection();//数据库连接
- Connection conn = null;
- PreparedStatement pstm = null;//sql语句的执行者
- int n = 0;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- 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 "";
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/getEquipRealName/")
- public String getEquipRealName(String param){//修改应急装备的状态
- String equipName = Utils.getParameter("EQUIPMENT_NAME", param) == null ? "" : Utils.getParameter("EQUIPMENT_NAME", param);//装备名称
- String equipType1 = Utils.getParameter("EQUIPMENT_TYPE", param) == null ? "" : Utils.getParameter("EQUIPMENT_TYPE", param);//装备类型,用于判断sql从哪张表里面查
- String sql = "";
- if("265".equals(equipType1)){
- sql = "select CAR_NAME from EMC_AM_GENERATOR_CAR where FD_OBJECTID='"+equipName+"'";
- } else if("266".equals(equipType1)){
- sql = "select NAME from EMC_AM_GENERATOR where FD_OBJECTID='"+equipName+"'";
- } else if("270".equals(equipType1)){
- sql = "select CAR_NAME from EMC_AM_DINING_CAR where FD_OBJECTID='"+equipName+"'";
- } else if("269".equals(equipType1)){
- sql = "select CAR_NAME from EMC_AM_EMERGENCY_COMMAND_CAR where FD_OBJECTID='"+equipName+"'";
- }
- System.out.println("**************"+sql);
- 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()){
- if("265".equals(equipType1)){
- sb.append(rs.getString("CAR_NAME"));
- } else if("266".equals(equipType1)){
- sb.append(rs.getString("NAME"));
- } else if("270".equals(equipType1)){
- sb.append(rs.getString("CAR_NAME"));
- } else if("269".equals(equipType1)){
- sb.append( rs.getString("CAR_NAME"));
- }
- }
- // sb.append("]}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- return sb.toString();
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/updateEquipStateToFree/")
- public String updateEquipStateToFree(String param){//修改应急装备的状态
- //param = param.toString().split("=")[1];
- //String sql="update EMC_AM_GENERATOR_CAR set IS_USED='2' , USED_STAT='2' where FD_OBJECTID='"+param+"' and is_del='0'";
-
- String equipId = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param);//装备ID
- String equipType = Utils.getParameter("EQUIPMENT_TYPE", param) == null ? "" : Utils.getParameter("EQUIPMENT_TYPE", param);//装备类型,用于判断sql从哪张表里面查
- String sql = "";
- if("265".equals(equipType)){
- //sql = "select CAR_NUM,IS_USED from EMC_AM_GENERATOR_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_GENERATOR_CAR set IS_USED = '1' , USED_STAT = '1' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//IS_USED = '2' 不可调用
- } else if("266".equals(equipType)){
- //sql = "select NUM,USED_STAT from EMC_AM_GENERATOR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_GENERATOR set USED_STAT = '1' , IS_USED = '1' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//USED_STAT = '2' 调拨中
- } else if("270".equals(equipType)){
- //sql = "select CAR_NUM,USED_STAT from EMC_AM_DINING_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_DINING_CAR set IS_USED = '1' , USED_STAT = '1' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//IS_USED = '2' 不可调用
- } else if("269".equals(equipType)){
- //sql = "select CAR_NUM,USED_STAT from EMC_AM_EMERGENCY_COMMAND_CAR where FD_OBJECTID='"+equipId+"'";
- sql = "update EMC_AM_EMERGENCY_COMMAND_CAR set USED_STAT = '1' , IS_USED = '1' where FD_OBJECTID = '"+equipId+"' and is_del='0'";//USED_STAT = '2' 调拨中
- }
-
- //System.out.println("******//////////***********"+sql);
-
- DbConnection dbConn = new DbConnection();//数据库连接
- Connection conn = null;
- PreparedStatement pstm = null;//sql语句的执行者
- int n = 0;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- 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 "";
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/updateEquipDemandStateTo56/")
- public String updateEquipDemandStateTo56(String param){//修改应急装备的状态
- String taskName = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param);//装备ID
- String sql = "update ECM_EM_EQUIPMENT_DEMAND set AUDIT_STATE = '56' where FD_OBJECTID = '"+taskName+"' 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);
- 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 "";
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/updateEquipDemandStateTo57/")
- public String updateEquipDemandStateTo57(String param){//修改应急装备的状态
- String taskName = Utils.getParameter("FD_OBJECTID", param) == null ? "" : Utils.getParameter("FD_OBJECTID", param);//装备ID
- String sql = "update ECM_EM_EQUIPMENT_DEMAND set AUDIT_STATE = '57' where FD_OBJECTID = '"+taskName+"' 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);
- 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 "";
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/getDeptName/")
- public String getDeptName(String params){ //装备需求详细信息页面用到
- params = Utils.getParameter("DEPT_ID", params) == null ? "" : Utils.getParameter("DEPT_ID", params);
- String sql = "select DEPT_NAME from SYS_DEPARTMENT where DEPT_ID=?";
- //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, params);
- rs = pstm.executeQuery();
-
- while(rs.next()){
- // sb.append("{\"TEAM_TYPE\":\""+rs.getString("TEAM_TYPE")+"\"},");
- sb.append( rs.getString("DEPT_NAME") );
- }
- sb.append("\"}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- 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("/getEquipAmount/")
- public String getEquipAmount(String params){ //装备需求详细信息页面用到
- String equipId = Utils.getParameter("FD_OBJECTID", params) == null ? "" : Utils.getParameter("FD_OBJECTID", params);//装备ID
- String equipType = Utils.getParameter("EQUIPMENT_TYPE", params) == null ? "" : Utils.getParameter("EQUIPMENT_TYPE", params);//装备类型,用于判断sql从哪张表里面查
- String sql = "";
- if("265".equals(equipType)){
- sql = "select CAR_NUM,IS_USED from EMC_AM_GENERATOR_CAR where FD_OBJECTID='"+equipId+"'";
- } else if("266".equals(equipType)){
- sql = "select NUM,USED_STAT from EMC_AM_GENERATOR where FD_OBJECTID='"+equipId+"'";
- } else if("270".equals(equipType)){
- sql = "select CAR_NUM,USED_STAT from EMC_AM_DINING_CAR where FD_OBJECTID='"+equipId+"'";
- } else if("269".equals(equipType)){
- sql = "select CAR_NUM,USED_STAT from EMC_AM_EMERGENCY_COMMAND_CAR where FD_OBJECTID='"+equipId+"'";
- }
- 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, params);
- rs = pstm.executeQuery();
-
- while(rs.next()){
- if("265".equals(equipType)){
- sb.append(rs.getString("CAR_NUM") +","+rs.getString("IS_USED"));
- } else if("266".equals(equipType)){
- sb.append(rs.getString("NUM") +","+rs.getString("USED_STAT"));
- } else if("270".equals(equipType)){
- sb.append(rs.getString("CAR_NUM") +","+rs.getString("USED_STAT"));
- } else if("269".equals(equipType)){
- sb.append( rs.getString("CAR_NUM") +","+rs.getString("USED_STAT"));
- }
- }
- sb.append("]}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- 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("/getSubDeptIds/")
- public String getSubDeptIds(String params){ //装备需求详细信息页面用到
- params = Utils.getParameter("PARENT_ID", params) == null ? "" : Utils.getParameter("PARENT_ID", params);
- String sql = "select DEPT_ID from SYS_DEPARTMENT where PARENT_ID=?";
- //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, params);
- rs = pstm.executeQuery();
-
- while(rs.next()){
- sb.append("'" + rs.getString("DEPT_ID") + "'," );
- }
- sb.deleteCharAt(sb.length()-1);
- // sb.append("\"}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- 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("/getPersonId/")
- public String getPersonId(String params){ //装备需求详细信息页面用到
- String businessId = Utils.getParameter("BUSINESS_ID", params) == null ? "" : Utils.getParameter("BUSINESS_ID", params);
- String state = Utils.getParameter("state", params) == null ? "" : Utils.getParameter("state", params);
- String sql = "select distinct PERSON_ID from ECM_EM_TREATED_HUMAN where BUSINESS_ID=? and STATUES=?";
- //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, businessId);
- pstm.setString(2, state);
- rs = pstm.executeQuery();
-
- while(rs.next()){
- // sb.append("{\"TEAM_TYPE\":\""+rs.getString("TEAM_TYPE")+"\"},");
- sb.append(rs.getString("PERSON_ID"));
- }
- // sb.append("\"}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- 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("/getNeedUnit/")
- public String getNeedUnit(String params){ //装备需求详细信息页面用到
- params = Utils.getParameter("FD_OBJECTID", params) == null ? "" : Utils.getParameter("FD_OBJECTID", params);
- String sql = "select DEPT_NAME from SYS_DEPARTMENT where DEPT_ID=(select RECIPIENT_DEPARTMENT from ECM_EM_EQUIPMENT_DEMAND 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, params);
- rs = pstm.executeQuery();
- while(rs.next()){
- sb.append( rs.getString("DEPT_NAME") );
- }
- // sb.append("\"}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return sb.toString();
- }
-
- @POST
- @ProduceMime("application/text")
- @Path("/getNextHandlerFrom378/")
- public String getNextHandlerFrom378(String params){ //装备需求详细信息页面用到
- String businessId = Utils.getParameter("BUSINESS_ID", params) == null ? "" : Utils.getParameter("BUSINESS_ID", params);
- String statues = Utils.getParameter("STATUES", params) == null ? "" : Utils.getParameter("STATUES", params);
- String sql = "select top 1 PERSON_ID,PERSON_NAME from ECM_EM_TREATED_HUMAN where BUSINESS_ID=? and STATUES=? order by updatedate desc";
- 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, businessId);
- pstm.setString(2, statues);
- rs = pstm.executeQuery();
- while(rs.next()){
- sb.append( rs.getString("PERSON_ID") );
- }
- // sb.append("\"}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null){
- rs.close();}
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- // System.out.println("**************************"+sb.toString());
- return sb.toString();
- }
-
- }
|