package com.sinosoft.gps.bgd_mxb.service; import java.util.ArrayList; import java.util.List; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import javax.ws.rs.core.Context; import org.apache.log4j.Logger; import net.sf.json.JSONArray; import com.formaction.Utils; import com.sinosoft.gps.bgd_mxb.DAO.BGDMXBdao; import com.sinosoft.gps.bgd_mxb.vo.BGDTask; import com.sinosoft.gps.bgd_mxb.vo.BGDmingxi; @Path("/BGDMXBService/") public class BGDMXBService { @Context private org.apache.cxf.jaxrs.ext.MessageContext mc; private final Logger log = Logger.getLogger(getClass()); @POST @ProduceMime("application/json") @Path("/queryByConditions/") public String queryByConditions(String params){//获取到fd_objectid String deptId = Utils.getParameter("deptId", params)==null?"":Utils.getParameter("deptId", params); String userId = Utils.getParameter("userId", params)==null?"":Utils.getParameter("userId", params); BGDMXBdao dao = new BGDMXBdao(); List list = new ArrayList(); try { list = dao.queryByCondition1(deptId,userId); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } String result = JSONArray.fromObject(list).toString(); return result; } @ProduceMime("application/json") @POST @Path("/gpsstatistics/") public String GPSStatistics(String params) throws Exception{ String GPS_AREA_ID_610 = Utils.getParameter("GPS_AREA_ID_610", params) == null ? "" : Utils.getParameter("GPS_AREA_ID_610", params); String GPS_NAME_610 = Utils.getParameter("GPS_NAME_610", params) == null ? "" : Utils.getParameter("GPS_NAME_610", params); String GPS_YEAR_610 = Utils.getParameter("GPS_YEAR_610", params) == null ? "" : Utils.getParameter("GPS_YEAR_610", params); String END_TIME_610 = Utils.getParameter("END_TIME_610", params) == null ? "" : Utils.getParameter("END_TIME_610", params); String result=""; //通过单位id,年份,结束时间查询任务信息 List taskList = queryTaskByIds(GPS_AREA_ID_610,GPS_NAME_610,GPS_YEAR_610,END_TIME_610); result = JSONArray.fromObject(taskList).toString(); return result; } private List queryTaskByIds(String GPS_AREA_ID_610,String gPS_NAME_610, String gPS_YEAR_610, String eND_TIME_610) { StringBuffer condition = new StringBuffer(); condition.append(""); if(!"".equals(GPS_AREA_ID_610)){ condition.append(" and BGD_DW = '" + GPS_AREA_ID_610 + "' "); } if(!"".equals(gPS_NAME_610)){ condition.append(" and "); condition.append(" FD_TASK_NAME = '" + gPS_NAME_610 + "' "); } if(!"".equals(gPS_YEAR_610)){ condition.append(" and BGD_RW_TIME like'%"+gPS_YEAR_610+"%'"); if(!"".equals(eND_TIME_610)){ String preTime = ""; String aftTime = ""; switch (Integer.parseInt(eND_TIME_610)) { case 0://第一季度 preTime = gPS_YEAR_610 + "-01-01 00:00:00"; aftTime = gPS_YEAR_610 + "-04-01 00:00:00"; break; case 1://第二季度 preTime = gPS_YEAR_610 + "-04-01 00:00:00"; aftTime = gPS_YEAR_610 + "-07-01 00:00:00"; break; case 2://第三季度 preTime = gPS_YEAR_610 + "-07-01 00:00:00"; aftTime = gPS_YEAR_610 + "-10-01 00:00:00"; break; case 3://第四季度 preTime = gPS_YEAR_610 + "-10-01 00:00:00"; aftTime = (Integer.parseInt(gPS_YEAR_610)+1) + "-01-01 00:00:00"; break; default: break; } condition.append(" and BGD_RW_TIME between '"+preTime+"' and '" + aftTime + "'"); } } BGDMXBdao dao = new BGDMXBdao(); List taskList = dao.queryTask(condition.toString()); return taskList; } }