bb3990354fab338a396dff4e709c2d436e037974.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.sinosoft.gps.bgd_mxb.service;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.ws.rs.POST;
  5. import javax.ws.rs.Path;
  6. import javax.ws.rs.ProduceMime;
  7. import javax.ws.rs.core.Context;
  8. import org.apache.log4j.Logger;
  9. import net.sf.json.JSONArray;
  10. import com.formaction.Utils;
  11. import com.sinosoft.gps.bgd_mxb.DAO.BGDMXBdao;
  12. import com.sinosoft.gps.bgd_mxb.vo.BGDTask;
  13. import com.sinosoft.gps.bgd_mxb.vo.BGDmingxi;
  14. @Path("/BGDMXBService/")
  15. public class BGDMXBService {
  16. @Context
  17. private org.apache.cxf.jaxrs.ext.MessageContext mc;
  18. private final Logger log = Logger.getLogger(getClass());
  19. @POST
  20. @ProduceMime("application/json")
  21. @Path("/queryByConditions/")
  22. public String queryByConditions(String params){//获取到fd_objectid
  23. String deptId = Utils.getParameter("deptId", params)==null?"":Utils.getParameter("deptId", params);
  24. String userId = Utils.getParameter("userId", params)==null?"":Utils.getParameter("userId", params);
  25. BGDMXBdao dao = new BGDMXBdao();
  26. List list = new ArrayList<BGDTask>();
  27. try {
  28. list = dao.queryByCondition1(deptId,userId);
  29. } catch (Exception e) {
  30. // TODO Auto-generated catch block
  31. e.printStackTrace();
  32. }
  33. String result = JSONArray.fromObject(list).toString();
  34. return result;
  35. }
  36. @ProduceMime("application/json")
  37. @POST
  38. @Path("/gpsstatistics/")
  39. public String GPSStatistics(String params) throws Exception{
  40. String GPS_AREA_ID_610 = Utils.getParameter("GPS_AREA_ID_610", params) == null ? "" : Utils.getParameter("GPS_AREA_ID_610", params);
  41. String GPS_NAME_610 = Utils.getParameter("GPS_NAME_610", params) == null ? "" : Utils.getParameter("GPS_NAME_610", params);
  42. String GPS_YEAR_610 = Utils.getParameter("GPS_YEAR_610", params) == null ? "" : Utils.getParameter("GPS_YEAR_610", params);
  43. String END_TIME_610 = Utils.getParameter("END_TIME_610", params) == null ? "" : Utils.getParameter("END_TIME_610", params);
  44. String result="";
  45. //通过单位id,年份,结束时间查询任务信息
  46. List<BGDmingxi> taskList = queryTaskByIds(GPS_AREA_ID_610,GPS_NAME_610,GPS_YEAR_610,END_TIME_610);
  47. result = JSONArray.fromObject(taskList).toString();
  48. return result;
  49. }
  50. private List<BGDmingxi> queryTaskByIds(String GPS_AREA_ID_610,String gPS_NAME_610, String gPS_YEAR_610, String eND_TIME_610) {
  51. StringBuffer condition = new StringBuffer();
  52. condition.append("");
  53. if(!"".equals(GPS_AREA_ID_610)){
  54. condition.append(" and BGD_DW = '" + GPS_AREA_ID_610 + "' ");
  55. }
  56. if(!"".equals(gPS_NAME_610)){
  57. condition.append(" and ");
  58. condition.append(" FD_TASK_NAME = '" + gPS_NAME_610 + "' ");
  59. }
  60. if(!"".equals(gPS_YEAR_610)){
  61. condition.append(" and BGD_RW_TIME like'%"+gPS_YEAR_610+"%'");
  62. if(!"".equals(eND_TIME_610)){
  63. String preTime = "";
  64. String aftTime = "";
  65. switch (Integer.parseInt(eND_TIME_610)) {
  66. case 0://第一季度
  67. preTime = gPS_YEAR_610 + "-01-01 00:00:00";
  68. aftTime = gPS_YEAR_610 + "-04-01 00:00:00";
  69. break;
  70. case 1://第二季度
  71. preTime = gPS_YEAR_610 + "-04-01 00:00:00";
  72. aftTime = gPS_YEAR_610 + "-07-01 00:00:00";
  73. break;
  74. case 2://第三季度
  75. preTime = gPS_YEAR_610 + "-07-01 00:00:00";
  76. aftTime = gPS_YEAR_610 + "-10-01 00:00:00";
  77. break;
  78. case 3://第四季度
  79. preTime = gPS_YEAR_610 + "-10-01 00:00:00";
  80. aftTime = (Integer.parseInt(gPS_YEAR_610)+1) + "-01-01 00:00:00";
  81. break;
  82. default:
  83. break;
  84. }
  85. condition.append(" and BGD_RW_TIME between '"+preTime+"' and '" + aftTime + "'");
  86. }
  87. }
  88. BGDMXBdao dao = new BGDMXBdao();
  89. List<BGDmingxi> taskList = dao.queryTask(condition.toString());
  90. return taskList;
  91. }
  92. }