员工资源对应表

master
赵嘉伟 4 years ago
parent 948db138ef
commit 32eca67b0a

@ -79,6 +79,12 @@ public class UserResourceHandler extends BaseHandler {
@Override @Override
public int visit(long index, JSONObject jsonObject) { public int visit(long index, JSONObject jsonObject) {
Object[] params = new Object[10];
params[0] = index;
params[1] = jsonObject.getString("resrce");
String resultMessage = null;
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String user = CommonMethods.getUser(); String user = CommonMethods.getUser();
String resrce = StringUtil.toString(jsonObject.getString("resrce")); String resrce = StringUtil.toString(jsonObject.getString("resrce"));
@ -95,13 +101,13 @@ public class UserResourceHandler extends BaseHandler {
// userResource.setResrceDescription(resrceDescription); // userResource.setResrceDescription(resrceDescription);
userResource.setUserId(userId); userResource.setUserId(userId);
userResource.setUserDescription(userDescription); userResource.setUserDescription(userDescription);
if("Y".equals(temporaryUser)){ if("".equals(temporaryUser)){
userResource.setTemporaryUser("true"); userResource.setTemporaryUser("true");
}else { }else {
userResource.setTemporaryUser("false"); userResource.setTemporaryUser("false");
} }
if("N".equals(status)){ if("".equals(status)){
userResource.setStatus("false"); userResource.setStatus("false");
}else { }else {
userResource.setStatus("true"); userResource.setStatus("true");
@ -115,19 +121,23 @@ public class UserResourceHandler extends BaseHandler {
} }
userResource.setModifiedUser(user); userResource.setModifiedUser(user);
userResource.setModifiedDateTime(now); userResource.setModifiedDateTime(now);
try { //如果资源为空或者员工编号为空,则直接跳过
//如果资源为空或者员工编号为空,则直接跳过 if (StringUtil.notEmpty(resrce) && StringUtil.notEmpty(userId)) {
if (StringUtil.notEmpty(resrce) && StringUtil.notEmpty(userId)) { //站点
//站点 jsonObject.put("site", site);
jsonObject.put("site", site); //不管用户选啥模式,都是更新和插入
//不管用户选啥模式,都是更新和插入 resultMessage = this.updateAndInsert(userResource,index);
this.updateAndInsert(userResource,index);
userResourceService.saveOrUpdate(userResource); if (resultMessage != null) {
params[2] = resultMessage;
failedNumber[0]++;
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
return 0;
} }
userResourceService.saveOrUpdate(userResource);
return 1; return 1;
} catch (Exception e) {
throw BusinessException.build(e.getMessage());
} }
return 0;
} }
@Override @Override
@ -135,12 +145,12 @@ public class UserResourceHandler extends BaseHandler {
return null; return null;
} }
boolean updateAndInsert(UserResource userResource,Long index){ String updateAndInsert(UserResource userResource,Long index){
//判断资源是否存在 //判断资源是否存在
Resrce resrce = resrceMapper.selectById(userResource.getResourceBo()); Resrce resrce = resrceMapper.selectById(userResource.getResourceBo());
if(resrce == null){ if(resrce == null){
throw BusinessException.build("第"+index+"行的资源不存在"); return "第"+index+"行的资源不存在";
} }
//设置资源描述 //设置资源描述
userResource.setResrceDescription(resrce.getDescription()); userResource.setResrceDescription(resrce.getDescription());
@ -151,9 +161,9 @@ public class UserResourceHandler extends BaseHandler {
}else if("true".equals(userResource.getTemporaryUser())){ }else if("true".equals(userResource.getTemporaryUser())){
//不做任何操作 //不做任何操作
}else{ }else{
throw BusinessException.build("第"+index+"行的用户不存在,必须为临时员工"); return "第"+index+"行的用户不存在,必须为临时员工";
} }
return true; return null;
} }
}; };

Loading…
Cancel
Save