Commit a5ee8e79 authored by 赵啸非's avatar 赵啸非

修改重复导入,用户名相同的,做更新操作

parent 395d541a
......@@ -177,6 +177,11 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
if (FileUtil.isEmpty(new File(targetFilePath))) {
throw new AppException("文件不存在!");
}
if (!FileUtil.getSuffix(picfilePath).equals("zip")) {
throw new AppException("压缩只支持zip文件!");
}
//解压图片
String fileEncode = "UTF-8";
try {
......@@ -243,12 +248,26 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
StringBuilder failureDetailMsg = new StringBuilder();
for (WorkmanEntity entity : list) {
try {
entity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
//通过用户名判断是更新还是新增;
WorkmanEntity workmanEntity = this.selectOne(new WorkmanQuery().loginName(entity.getLoginName()), context);
if (ObjectUtils.isEmpty(workmanEntity)) {
entity.setId(workmanEntity.getId());
entity.setDeleted(YesNoEnum.NO.getValue());
entity.setUpdateUserId(this.getContextUserId(context));
entity.setCreateTime(new Date());
WorkmanEntity update = this.update(entity, context);
if (update != null) {
successNum++;
}
}else{
entity.setCreateUserId(this.getContextUserId(context));
entity.setCreateTime(new Date());
WorkmanEntity save = this.save(entity, context);
if (save != null) {
successNum++;
}
}
} catch (Exception e) {
log.error("导入异常", e);
failureNum++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment