员工资源对应表

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

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

Loading…
Cancel
Save