//修改头像
publicvoideachJsonUpdatePicture(){
try{
if(employee.getRole()==null||employee.getRole().getRoleId()==null)
employee.setRole(null);
StringcropData=request.getParameter(“cropData”);
if(cropData ==null){
EmployeeemployeeNew=newEmployee();
employeeNew.setEmployeeId(employee.getEmployeeId());
employeeNew=employeeService.queryOne(employeeNew);
employeeNew.setPicture(employee.getPicture());
employeeService.update(employeeNew);
}else{
JSONObjectjsonCropData=newJSONObject(cropData);
Stringinitw=request.getParameter(“initw”);
Stringinith=request.getParameter(“inith”);
if(initw!=null&&inith!=null){
employeeService.updatePicture(employee,jsonCropData.getInt(“x”),jsonCropData.getInt(“y”),Integer.parseInt(inith),Integer.parseInt(initw));
}else{
employeeService.updatePicture(employee,jsonCropData.getInt(“x”),jsonCropData.getInt(“y”),jsonCropData.getInt(“h”),jsonCropData.getInt(“w”));
}
EmployeeemployeeNew=newEmployee();
employeeNew.setEmployeeId(employee.getEmployeeId());
employeeNew=employeeService.queryOne(employeeNew);
this.request.getSession().setAttribute(“currentUser”, employeeNew);
}
JSONObjectjsonResponse=newJSONObject();
jsonResponse.put(“result”,”success”);
jsonResponse.put(“message”,”修改’员工’成功!”);
HttpJsonUtil.writeJsonData(response, jsonResponse);
OperateLogoperateLog=newOperateLog();
operateLog.setOperator((Employee)request.getSession().getAttribute(“currentUser”));
operateLog.setLogType(5);
operateLog.setHappenTime(newDate());
operateLog.setLogContent(“修改’员工’成功!”);
employeeService.saveOrUpdate(operateLog);
}catch(CurrentException ce){
JSONObjectjsonResponse=newJSONObject();
try{
jsonResponse.put(“result”,”failed”);
jsonResponse.put(“message”,ce.getMessage());
HttpJsonUtil.writeJsonData(response, jsonResponse);
}catch(Exception e1){
e1.printStackTrace();
}
OperateLogoperateLog=newOperateLog();
operateLog.setOperator((Employee)request.getSession().getAttribute(“currentUser”));
operateLog.setLogType(5);
operateLog.setHappenTime(newDate());
operateLog.setLogContent(“操作’员工’异常,”+ce.getMessage());
employeeService.saveOrUpdate(operateLog);
}catch(Exception ex){
ex.printStackTrace();
JSONObjectjsonResponse=newJSONObject();
try{
jsonResponse.put(“result”,”failed”);
jsonResponse
.put(“message”,”发生异常!”);
HttpJsonUtil.writeJsonData(response, jsonResponse);
}catch(Exception e1){
e1.printStackTrace();
}
OperateLogoperateLog=newOperateLog();
operateLog.setOperator((Employee)request.getSession().getAttribute(“currentUser”));
operateLog.setLogType(5);
operateLog.setHappenTime(newDate());
operateLog.setLogContent(“操作’员工’异常!”);
employeeService.saveOrUpdate(operateLog);
}