package com.sinosoft.em.warning.duty; import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Map; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import org.apache.log4j.Logger; import com.formaction.Utils; import com.formaction.service.CRUDServiceImpl; import com.formaction.vo.Msg; import com.persistence.service.exception.PersistenceException; import com.sinosoft.common.excel.JsonPluginsUtil; import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl; @Path("/WarningDutyService/") public class WarningDutyService { private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class); /** * 功能:保存值班详细 */ @POST @ProduceMime("application/json") @Path("/saveDutyDetail/") public String saveDutyDetail(String params) { try { params = java.net.URLDecoder.decode(java.net.URLDecoder.decode(params, "UTF-8"), "UTF-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } String[] paramArr = params.split("[||]"); CRUDServiceImpl crud = new CRUDServiceImpl(); try { for (int i = 0; i < paramArr.length; i++) { if(!"".equals(paramArr[i].trim())){ if(paramArr[i]!=null && paramArr[i].indexOf("FD_OBJECTID312")>-1){ crud.update(paramArr[i]); }else{ crud.create(paramArr[i]); } } } } catch (Exception e) { e.printStackTrace(); } return null; } /** * 功能:根据值班任务id查询各部门值班填报详细 */ @POST @ProduceMime("application/json") @Path("/loadDutyDetailByDeptIds/") public String loadDutyDetailByDeptIds(String params) { String deptids = Utils.getParameter("deptids", params) == null ? "" : Utils .getParameter("deptids", params); String planId = Utils.getParameter("planId", params) == null ? "" : Utils .getParameter("planId", params); WarningDutyDao dao = new WarningDutyDao(); try { String result = dao.loadDutyDetailByDeptIds(deptids,planId); return result; } catch (Exception e) { e.printStackTrace(); } return null; } /** * 功能:根据值班任务id查询各部门值班填报详细 */ @POST @ProduceMime("application/json") @Path("/loadPlanByDeptId/") public String loadPlanByDeptId(String params) { String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils .getParameter("deptId", params); WarningDutyDao dao = new WarningDutyDao(); try { String result = dao.loadPlanByDeptId(deptId); return result; } catch (Exception e) { e.printStackTrace(); } return null; } /** * 功能:根据值班记录id查询值班填报详细 */ @POST @ProduceMime("application/json") @Path("/loadDutyDetailByRecordsId/") public String loadDutyDetailByRecordsId(String params) { String recordsId = Utils.getParameter("recordsId", params) == null ? "" : Utils .getParameter("recordsId", params); WarningDutyDao dao = new WarningDutyDao(); try { String result = dao.loadDutyDetailByRecordsId(recordsId); return result; } catch (Exception e) { e.printStackTrace(); } return null; } /** *保存值班辅助表格数据 */ @POST @ProduceMime("application/json") @Path("/saveDutyFuZhu/") public Msg saveDutyFuZhu(String params) { String planId = Utils.getParameter("planId", params) == null ? "" : Utils .getParameter("planId", params); String data = Utils.getParameter("data", params) == null ? "" : Utils .getParameter("data", params); List> list = JsonPluginsUtil.jsonToMapList(data); WarningDutyDao dao = new WarningDutyDao(); try { Msg m = dao.saveDutyFuZhu(planId,list); return m; } catch (Exception e) { e.printStackTrace(); } return null; } /** *删除值班辅助表格数据 */ @POST @ProduceMime("application/json") @Path("/deleteDutyFuZhu/") public Msg deleteDutyFuZhu(String params) { String planId = Utils.getParameter("planId", params) == null ? "" : Utils .getParameter("planId", params); WarningDutyDao dao = new WarningDutyDao(); try { Msg m = dao.deleteDutyFuZhu(planId); return m; } catch (Exception e) { e.printStackTrace(); } return null; } @POST @ProduceMime("application/json") @Path("/getPeople/") public String getPeople(String params){ String pageSize = Utils.getParameter("pageSize", params) == null ? "10" : Utils .getParameter("pageSize", params); String page = Utils.getParameter("page", params) == null ? "1" : Utils .getParameter("page", params); String name = Utils.getParameter("name", params) == null ? "" : Utils .getParameter("name", params); String id = Utils.getParameter("id", params) == null ? "" : Utils .getParameter("id", params); String result = ""; WarningDutyDao dao = new WarningDutyDao(); try { result = dao.getPeople(name,Integer.parseInt(pageSize),Integer.parseInt(page),id); } catch (NumberFormatException e) { log.info(e.getMessage(),e); } catch (PersistenceException e) { log.info(e.getMessage(),e); } return result; } }