private RecordedCase ModelToBean(GWTRecordedCase gwtRecordedCase) { RecordedCase bean = new RecordedCase(); bean.setRequestMsg(gwtRecordedCase.getRequestMsg()); bean.setResponseMsg(gwtRecordedCase.getResponseMsg()); bean.setResponseFlag(gwtRecordedCase.getResponseFlag()); bean.setIsCased(gwtRecordedCase.getIsCased()); bean.setMemo(gwtRecordedCase.getMemo()); bean.setCreateTime(gwtRecordedCase.GetCreateTime()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); try { String recordTime = gwtRecordedCase.GetRecordTime(); date = sdf.parse(recordTime); } catch (ParseException e) { String recordTime = gwtRecordedCase.GetCreateTime(); try { date = sdf.parse(recordTime); } catch (ParseException e1) { e1.printStackTrace(); } } bean.setRecordTime(date); bean.setSystemId(Integer.parseInt(gwtRecordedCase.getSystemID())); if (gwtRecordedCase.GetRecordUserId() != null) { bean.setRecordUserId(Integer.parseInt(gwtRecordedCase.GetRecordUserId())); } if (!gwtRecordedCase.IsNew()) { bean.setId(Integer.parseInt(gwtRecordedCase.getID())); } // bean.setRecordTime(gwtRecordedCase.GetRecordTime()); return bean; }
@Override public Boolean SaveRecordedCase(GWTRecordedCase recordedCase, Integer loginLogId) { RecordedCase data = ModelToBean(recordedCase); String userId = OperationLogService.getLoginLogById(loginLogId).getUserId(); if (recordedCase.IsNew()) { data.setRecordTime(new Date()); data.setRecordUserId(Integer.parseInt(userId)); dataDao.Add(data); OperationLogService.writeOperationLog( OpType.RecordedCase, IDUType.Insert, data.getId(), data.getRequestMsg(), "memo", null, data.getRequestMsg(), loginLogId); } else { RecordedCase oldBean = dataDao.Get(Op.EQ("id", Integer.parseInt(recordedCase.getID()))); data.setLastModifiedTime(new Date()); data.setLastModifiedUserId(userId); try { OperationLogService.writeUpdateOperationLog( OpType.RecordedCase, RecordedCase.class, oldBean.getId(), "ID=" + recordedCase.getID(), oldBean, data, loginLogId); } catch (Exception e) { log.error(e, e); } dataDao.Edit(data); } return true; }
@Override public Boolean DeleteRecordedCase(List<GWTRecordedCase> recordedCaseList, Integer loginLogId) { for (GWTRecordedCase recordedCase : recordedCaseList) { dataDao.Del(ModelToBean(recordedCase)); try { OperationLogService.writeOperationLog( OpType.RecordedCase, IDUType.Delete, Integer.parseInt(recordedCase.getID()), recordedCase.getMemo(), "requestMsg/recordTime", recordedCase.getRequestMsg() == null ? "" : recordedCase.getRequestMsg().substring(0, 1024), recordedCase.GetRecordTime(), loginLogId); } catch (Exception e) { log.error(e, e); } } return true; }