{
result.setFailed(MEASUREEQUIPMENT_ID_IS_NULL);
return result;
}
// id = GetObjectString.getMDB2RDBID(id);
MeasureEquipment measureEquipment = measureEquipmentDAO.findById(id);
if(measureEquipment==null)
{
result.setFailed(MEASUREEQUIPMENT_NOT_EXIST,id);
return result;
}
Object dateObj = properties.get("lastMaintainStr");
if(dateObj!=null)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try{
Date lastMaintain = sdf.parse(stringValue(dateObj));
measureEquipment.setLastMaintain(lastMaintain);
}
catch(Exception e)
{
System.out.println("Wrong time format: "+stringValue(dateObj));
// e.printStackTrace();
}
}
try{
Object measureIDObject = properties.get("measure_id");
if(measureIDObject!=null&&stringValue(measureIDObject)!="")
{
String measureID = stringValue(measureIDObject);
/**
* 比较现id与原id是否一致;若不一致,需要重置设备中的计量点;若原measure为空,也要重新关联
* 新关联的计量点可能查询为空,不作处理,仍保持原计量点
* */
if((measureEquipment.getMeasure()==null)||(!measureID.equalsIgnoreCase(measureEquipment.getMeasure().getId())))
{
Measure measure = measureDAO.findById(measureID);
if(measure==null)//同add,判断新的部门是否存在,不存在,返回失败
{
result.setFailed(MEASURE_NOTEXIST,measureID);
return result;
}
measureEquipment.setMeasure(measure);
}
}
BeanUtils.populate(measureEquipment, properties);
// equipment.setId(id);
measureEquipmentDAO.merge(measureEquipment);
result.setSucceed(MEASUREEQUIPMENT_MODIFY_SUCCED,measureEquipment.getName());
}
catch (IllegalAccessException e)
{
// TODO Auto-generated catch block
e.printStackTrace();