|
|
@@ -3,12 +3,15 @@ package com.ydtech.modules.admin.utils;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ydtech.modules.admin.constants.UserWorkStatus;
|
|
|
+import com.ydtech.modules.admin.model.SysPosition;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.SysUserRecord;
|
|
|
import com.ydtech.modules.admin.model.record.UserInfoRecord;
|
|
|
import com.ydtech.modules.admin.model.record.UserRecord;
|
|
|
import com.ydtech.modules.admin.model.vo.SysUserInfoQuery;
|
|
|
import com.ydtech.modules.admin.service.SysPositionService;
|
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserTrackService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -28,35 +31,33 @@ public class DifferentPropertyUtils {
|
|
|
if (CollectionUtils.isEmpty(userList)){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
-
|
|
|
UserRecord sysUser = JSONObject.parseObject(JSONObject.toJSONString(sysUserVo.getSysUser()), UserRecord.class);
|
|
|
Map<String, String> mapValue = objectToMap(sysUser);
|
|
|
-
|
|
|
UserInfoRecord userInfoRecord = JSONObject.parseObject(JSONObject.toJSONString(sysUserVo.getSysUserInfo()), UserInfoRecord.class);
|
|
|
Map<String, String> userInfoMapValue = objectToMap(userInfoRecord);
|
|
|
-
|
|
|
- List<Object> list = new ArrayList<>();
|
|
|
-
|
|
|
+ List<Object> list = new ArrayList<>(userList.size());
|
|
|
+ int rowNum = 1;
|
|
|
for (SysUserRecord userRecord : userList) {
|
|
|
HashMap<String, Object> objectHashMap = new HashMap<>();
|
|
|
ArrayList<Object> objectArrayList = new ArrayList<>();
|
|
|
Map<String, String> newRecord = objectToMap(JSONObject.parseObject(userRecord.getSysUser(), UserRecord.class));
|
|
|
- for (String name : getFiledName(sysUser)) {
|
|
|
- if ("status".equals(name)){
|
|
|
- continue;
|
|
|
- }
|
|
|
+ for (String name : getFiledName(sysUser)) {
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
if (!mapValue.get(name).equals(newRecord.get(name))){
|
|
|
- HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
hashMap.put("propertyName",name);
|
|
|
if (Arrays.asList(userKey).contains(name)){
|
|
|
- hashMap.put("newValue",getDistName(name,mapValue.get(name)));
|
|
|
+ String newValue = getDistName(name, mapValue.get(name));
|
|
|
+ if ("status".equals(name)){
|
|
|
+ String mess = SpringUtil.getBean(SysUserTrackService.class).getApproveMessByUserId(mapValue.get("id"), String.valueOf(rowNum));
|
|
|
+ if (StringUtils.isNotEmpty(mess)){
|
|
|
+ newValue += " (驳回原因:" + mess + ")";
|
|
|
+ }
|
|
|
+ rowNum ++ ;
|
|
|
+ }
|
|
|
+ hashMap.put("newValue",newValue);
|
|
|
hashMap.put("oldValue",getDistName(name,newRecord.get(name)));
|
|
|
- } else if (Arrays.asList(dateTimeKey).contains(name)) {
|
|
|
- hashMap.put("newValue",dateTime(mapValue.get(name)));
|
|
|
- hashMap.put("oldValue",dateTime(newRecord.get(name)));
|
|
|
- }else {
|
|
|
- hashMap.put("newValue",mapValue.get(name));
|
|
|
- hashMap.put("oldValue",newRecord.get(name));
|
|
|
+ } else {
|
|
|
+ getByKey(mapValue, newRecord, name, hashMap);
|
|
|
}
|
|
|
objectArrayList.add(hashMap);
|
|
|
}
|
|
|
@@ -66,13 +67,8 @@ public class DifferentPropertyUtils {
|
|
|
objectHashMap.put("createTime",userRecord.getCreateTime());
|
|
|
objectHashMap.put("user",objectArrayList);
|
|
|
mapValue = newRecord;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
ArrayList<Object> userInfoList = new ArrayList<>();
|
|
|
Map<String, String> userInfoNewRecord = objectToMap(JSONObject.parseObject(userRecord.getSysUserInfo(), UserInfoRecord.class));
|
|
|
-
|
|
|
for (String name : getFiledName(userInfoRecord)) {
|
|
|
if ("salary".equals(name)){
|
|
|
if (new BigDecimal(userInfoMapValue.get(name)).compareTo(new BigDecimal(userInfoNewRecord.get(name))) != 0){
|
|
|
@@ -86,13 +82,7 @@ public class DifferentPropertyUtils {
|
|
|
if (!userInfoMapValue.get(name).equals(userInfoNewRecord.get(name))){
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
hashMap.put("propertyName",name);
|
|
|
- if (Arrays.asList(dateTimeKey).contains(name)){
|
|
|
- hashMap.put("newValue",dateTime(userInfoMapValue.get(name)));
|
|
|
- hashMap.put("oldValue",dateTime(userInfoNewRecord.get(name)));
|
|
|
- }else {
|
|
|
- hashMap.put("newValue",userInfoMapValue.get(name));
|
|
|
- hashMap.put("oldValue",userInfoNewRecord.get(name));
|
|
|
- }
|
|
|
+ getByKey(userInfoMapValue, userInfoNewRecord, name, hashMap);
|
|
|
userInfoList.add(hashMap);
|
|
|
}
|
|
|
}
|
|
|
@@ -103,11 +93,19 @@ public class DifferentPropertyUtils {
|
|
|
list.add(objectHashMap);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private static void getByKey(Map<String, String> mapValue, Map<String, String> newRecord, String name, HashMap<String, Object> hashMap) {
|
|
|
+ if (Arrays.asList(dateTimeKey).contains(name)) {
|
|
|
+ hashMap.put("newValue",dateTime(mapValue.get(name)));
|
|
|
+ hashMap.put("oldValue",dateTime(newRecord.get(name)));
|
|
|
+ }else {
|
|
|
+ hashMap.put("newValue",mapValue.get(name));
|
|
|
+ hashMap.put("oldValue",newRecord.get(name));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static String dateTime(String timestamp){
|
|
|
if (StringUtils.isEmpty(timestamp) || "null".equals(timestamp)){
|
|
|
return "";
|
|
|
@@ -123,9 +121,11 @@ public class DifferentPropertyUtils {
|
|
|
}
|
|
|
switch (key){
|
|
|
case "leaderId":
|
|
|
- return SpringUtil.getBean(SysUserService.class).getById(value).getName();
|
|
|
+ SysUser user = SpringUtil.getBean(SysUserService.class).getById(value);
|
|
|
+ return null == user ? "" : user.getName();
|
|
|
case "positionId":
|
|
|
- return SpringUtil.getBean(SysPositionService.class).getById(value).getPostName();
|
|
|
+ SysPosition position = SpringUtil.getBean(SysPositionService.class).getById(value);
|
|
|
+ return null == position ? "" : position.getPostName();
|
|
|
case "status":
|
|
|
return UserWorkStatus.getNameByRole(Integer.valueOf(value));
|
|
|
default:
|