package com.casic.PgInterface.rs; import com.casic.PgInterface.core.util.StringUtils; import com.casic.PgInterface.devTable.domain.PgPipeLine; import com.casic.PgInterface.devTable.dto.PgPipeLineDto; import com.casic.PgInterface.devTable.dto.PgPipeLineLengthStatic; import com.casic.PgInterface.devTable.dto.PgPipeLineTypeDto; import com.casic.PgInterface.devTable.dto.PgPipeLineTypeNumDto; import com.casic.PgInterface.devTable.manager.PgPipeLineManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.annotation.Resource; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Created by yxw on 2017/11/8. */ @Component @Path("pgPipeLine") public class PgPipeLineRs { private static Logger logger = LoggerFactory.getLogger(PgPipeLineRs.class); @Resource private PgPipeLineManager pgPipeLineManager; /** * 新增管线 */ @POST @Path("addPipeLine") @Produces(MediaType.APPLICATION_JSON) public Map<String, Object> addLog(@FormParam("lineCode") String lineCode, @FormParam("lineType") String lineType, @FormParam("secRow") String secRow, @FormParam("secColumn") String secColumn, @FormParam("lineState") String lineState, @FormParam("pileAcuList") String pileAcuList) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Map<String, Object> resultMap = new HashMap<>(); try { int _lineState=StringUtils.isNotBlank(lineState)?Integer.valueOf(lineState):0; resultMap = pgPipeLineManager.addPipeLine(lineCode,lineType,secRow,secColumn,_lineState,pileAcuList); } catch (Exception e) { e.printStackTrace(); resultMap.put("code","0"); resultMap.put("result","false"); resultMap.put("msg","提交失败"); return resultMap; } return resultMap; } /* * 根据管线类型获取管线列表 */ @POST @Path("getPipeLineByLineType") @Produces(MediaType.APPLICATION_JSON) public Map<String, Object> getPipeLineByLineType(@FormParam("lineType") String lineType) throws Exception { Map<String, Object> resultMap = new HashMap<String, Object>(); String msg = ""; String code="0"; List<PgPipeLineDto> pgPipeLineDtoList=new ArrayList<PgPipeLineDto>(); try { pgPipeLineDtoList = pgPipeLineManager.getPipeLineByLineType(lineType); code="200"; msg = "获取成功"; } catch (Exception e) { msg = "获取失败"; e.printStackTrace(); } resultMap.put("code",code); resultMap.put("msg", msg); resultMap.put("result", pgPipeLineDtoList); return resultMap; } /** * 根据管线名称获取管线信息 */ @POST @Path("getPipeLineByCode") @Produces(MediaType.APPLICATION_JSON) public Map<String, Object> getPipeLineByName(@FormParam("lineCode") String lineCode) throws Exception { Map<String, Object> resultMap = new HashMap<>(); String msg = ""; String code="0"; PgPipeLineDto pgPipeLineDto=null; try { PgPipeLine pgPipeLine = pgPipeLineManager.getPipeLineBylineCode(lineCode); if(pgPipeLine==null) msg="不存在:"+lineCode; else { pgPipeLineDto = new PgPipeLineDto(pgPipeLine); code="200"; msg = "获取成功"; } } catch (Exception e) { msg = "获取失败"; e.printStackTrace(); } resultMap.put("code",code); resultMap.put("msg", msg); resultMap.put("result", pgPipeLineDto); return resultMap; } /** * 根据管线类型获取管线长度 */ @POST @Path("getPipeLengthStatic") @Produces(MediaType.APPLICATION_JSON) public Map<String,Object> getPipeLengthStatic()throws Exception{ Map<String, Object> resultMap = new HashMap<>(); String msg = ""; String code="0"; List<PgPipeLineLengthStatic> pgPipeLineLengthStaticList=new ArrayList<>(); try { pgPipeLineLengthStaticList = pgPipeLineManager.getPipeLengthByName(); code="200"; msg="管线长度获取成功"; }catch(Exception e) { e.printStackTrace(); msg="管线长度统计失败"; } resultMap.put("code",code); resultMap.put("msg",msg); resultMap.put("result",pgPipeLineLengthStaticList); return resultMap; } /** * 获取管线类型 */ @POST @Path("getPipeLineType") @Produces(MediaType.APPLICATION_JSON) public Map<String, Object> getPipeLineType() throws Exception { Map<String, Object> resultMap = new HashMap<String, Object>(); String msg = ""; String code="0"; List<PgPipeLineTypeDto> pgPipeLineTypeDtoList=new ArrayList<PgPipeLineTypeDto>(); try { pgPipeLineTypeDtoList = pgPipeLineManager.getPipeType(); code="200"; msg = "获取成功"; } catch (Exception e) { msg = "获取失败"; e.printStackTrace(); } resultMap.put("code",code); resultMap.put("msg", msg); resultMap.put("result", pgPipeLineTypeDtoList); return resultMap; } /** * 根据管线名称获取管线数量 */ @POST @Path("getPipeNumStatic") @Produces(MediaType.APPLICATION_JSON) public Map<String,Object> getPipeNumStatic() throws Exception{ Map<String,Object> resultMap=new HashMap<String, Object>(); String msg=""; String code="0"; List<PgPipeLineTypeNumDto> pgPipeLineTypeNumDtoList=new ArrayList<PgPipeLineTypeNumDto>(); try { pgPipeLineTypeNumDtoList = pgPipeLineManager.getPipeTypeNum(); if (pgPipeLineTypeNumDtoList == null) msg = "不存在管线类型占比"; else { code="200"; msg = "管线占比获取成功"; } } catch (Exception e){ msg="管线占比数量获取失败"; e.printStackTrace(); } resultMap.put("code",code); resultMap.put("msg",msg); resultMap.put("result",pgPipeLineTypeNumDtoList); return resultMap; } /** * 获取管线类型 */ @POST @Path("editLineState") @Produces(MediaType.APPLICATION_JSON) public Map<String,Object> editLineState(@FormParam("lineCode") String lineCode, @FormParam("lineState") String lineState){ Map<String,Object> resultMap=new HashMap<>(); String msg=""; String code="0"; try{ if(StringUtils.isNotBlank(lineState)) { int _lineState = Integer.valueOf(lineState); resultMap = pgPipeLineManager.editLineState(lineCode, _lineState); }else { resultMap.put("msg","请输入修改后的管线这状态"); resultMap.put("code","0"); } } catch (Exception ex) { resultMap.put("msg","管线状态修改成功"); resultMap.put("code","0"); ex.printStackTrace(); } return resultMap; } }