Equipment equipment = equipmentDAO.findById(equipmentID);
if(equipment==null)
{
result.setFailed(EQUIPMENT_NOT_EXIST,equipmentID);
}
MaintainRecord maintainRecord = new MaintainRecord();
Object sendTimeObj = properties.get("sendTimeStr");//获取送修时间,接口为sendTimeStr
Object backTimeObj = properties.get("backTimeStr");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if(sendTimeObj!=null)
{
try{
Date sendTime = sdf.parse(stringValue(sendTimeObj));
maintainRecord.setSendTime(sendTime);
}
catch(Exception e)
{
//异常,就不设置sendTime
System.out.println("Wrong time format: "+stringValue(sendTimeObj));
// e.printStackTrace();
}
}
if(backTimeObj!=null)
{
try{
Date backTime = sdf.parse(stringValue(backTimeObj));
maintainRecord.setBackTime(backTime);
}
catch(Exception e)
{
System.out.println("Wrong time format: "+stringValue(backTimeObj));
// e.printStackTrace();
}
}
try{
BeanUtils.populate(maintainRecord, properties);
maintainRecord.setId(MyUUIDGen.getUUID());
maintainRecord.setEquipment(equipment);
maintainRecordDAO.merge(maintainRecord);
result.setSucceed(maintainRecord.getId());
}
catch (IllegalAccessException e)
{
// TODO Auto-generated catch block
e.printStackTrace();