public OperResult queryProcessInAndOut(String pt_id) {
OperResult result = new OperResult();
if(pt_id==null){
result.setFailed(PROCESS_REQUIRE_ID);
}else{
Process process = processDAO.findById(pt_id);
if(process==null){
result.setFailed(PROCESS_NOTEXIST,pt_id);
}else{
ArrayList<LazyDynaBean> inMeasureBeans = new ArrayList<LazyDynaBean>();
ArrayList<LazyDynaBean> outMeasureBeans = new ArrayList<LazyDynaBean>();
ProcessTemplate processTemplate = process.getProcessTemplate();
if(processTemplate==null){
Set<PInMeasure> inMeasures = process.getPInMeasures();
for(PInMeasure in:inMeasures){
Measure inMeasure = in.getMeasure();
if(inMeasure!=null){
LazyDynaBean bean = new LazyDynaBean();
bean.set("measure_id", inMeasure.getId());
bean.set("measure_path", inMeasure.getPath());
EnergyMedia media = inMeasure.getEnergyMedia();
if(media!=null){
bean.set("media_id", media.getId());
bean.set("media_name", media.getName());
bean.set("media_description", media.getDescription());
}
inMeasureBeans.add(bean);
}
}
Set<POutMeasure> outMeasures = process.getPOutMeasures();
for(POutMeasure out:outMeasures){
Measure outMeasure = out.getMeasure();
if(outMeasure!=null){
LazyDynaBean bean = new LazyDynaBean();
bean.set("measure_id", outMeasure.getId());
bean.set("measure_path", outMeasure.getPath());
EnergyMedia media = outMeasure.getEnergyMedia();
if(media!=null){
bean.set("media_id", media.getId());
bean.set("media_name", media.getName());
bean.set("media_description", media.getDescription());
}
outMeasureBeans.add(bean);
}
}
}else{
/**!
* 处理输入计量点
*/
Hashtable<String,LazyDynaBean> mediaID2inBean = new Hashtable<String,LazyDynaBean>();
Set<ProcessTemplateIn> inMedias = processTemplate.getProcessTemplateIns();
ArrayList<ProcessTemplateIn> inMediasList = new ArrayList<ProcessTemplateIn>();
inMediasList.addAll(inMedias);
Collections.sort(inMediasList,processTemplateInComparator);
for(ProcessTemplateIn in:inMediasList){
EnergyMedia media = in.getEnergyMedia();
if(media!=null){
LazyDynaBean bean = new LazyDynaBean();
bean.set("media_id", media.getId());
bean.set("media_name", media.getName());
bean.set("media_description", media.getDescription());
inMeasureBeans.add(bean);
mediaID2inBean.put(media.getId(), bean);
}
}
Set<PInMeasure> inMeasures = process.getPInMeasures();
for(PInMeasure in:inMeasures){
Measure inMeasure = in.getMeasure();
if(inMeasure!=null){
EnergyMedia media = inMeasure.getEnergyMedia();
if(media!=null){
if(mediaID2inBean.containsKey(media.getId())){
LazyDynaBean bean = mediaID2inBean.get(media.getId());
bean.set("measure_id", inMeasure.getId());
bean.set("measure_path", inMeasure.getPath());
}else{
LazyDynaBean bean = new LazyDynaBean();
bean.set("media_id", media.getId());
bean.set("media_name", media.getName());
bean.set("media_description", media.getDescription());
bean.set("measure_id", inMeasure.getId());
bean.set("measure_path", inMeasure.getPath());
inMeasureBeans.add(bean);
}
}
}
}
/**!
* 处理输出计量点
*/
Hashtable<String,LazyDynaBean> mediaID2OutBean = new Hashtable<String,LazyDynaBean>();
Set<ProcessTemplateOut> outMedias = processTemplate.getProcessTemplateOuts();
ArrayList<ProcessTemplateOut> outMediasList = new ArrayList<ProcessTemplateOut>();
outMediasList.addAll(outMedias);
Collections.sort(outMediasList,processTemplateOutComparator);
for(ProcessTemplateOut out:outMediasList){
EnergyMedia media = out.getEnergyMedia();
if(media!=null){
LazyDynaBean bean = new LazyDynaBean();
bean.set("media_id", media.getId());
bean.set("media_name", media.getName());
bean.set("media_description", media.getDescription());
outMeasureBeans.add(bean);
mediaID2OutBean.put(media.getId(), bean);
}
}
Set<POutMeasure> outMeasures = process.getPOutMeasures();
for(POutMeasure out:outMeasures){
Measure outMeasure = out.getMeasure();
if(outMeasure!=null){
EnergyMedia media = outMeasure.getEnergyMedia();
if(media!=null){