diff --git a/web/src/main/java/com/example/web/entity/InformationTra.java b/web/src/main/java/com/example/web/entity/InformationTra.java new file mode 100644 index 0000000..91cf7e8 --- /dev/null +++ b/web/src/main/java/com/example/web/entity/InformationTra.java @@ -0,0 +1,150 @@ +package com.example.web.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * 信息跟踪表实体类 + */ +@Data +@NoArgsConstructor +public class InformationTra { + private Integer id; // 主键ID + private String tracompany; // 修改者公司 + private String tradepartment; // 修改者部门 + private String traorganization; // 修改者组织 + private String trarole; // 修改者角色 + private String trauserName; // 修改者名字 + private String traassistant; // 修改协助人 + private String userId; // 客户ID + private String operationEvent; // 操作事件 + private LocalDateTime operationTime; // 操作时间 + private LocalDateTime created_at; // 创建时间 + private LocalDateTime updated_at; // 更新时间 + private String originalData; // 原始数据JSON + private String modifiedData; // 修改后数据JSON + private String changedFields; // 变更字段列表JSON + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getTracompany() { + return tracompany; + } + + public void setTracompany(String tracompany) { + this.tracompany = tracompany; + } + + public String getTradepartment() { + return tradepartment; + } + + public void setTradepartment(String tradepartment) { + this.tradepartment = tradepartment; + } + + public String getTraorganization() { + return traorganization; + } + + public void setTraorganization(String traorganization) { + this.traorganization = traorganization; + } + + public String getTrarole() { + return trarole; + } + + public void setTrarole(String trarole) { + this.trarole = trarole; + } + + public String getTrauserName() { + return trauserName; + } + + public void setTrauserName(String trauserName) { + this.trauserName = trauserName; + } + + public String getTraassistant() { + return traassistant; + } + + public void setTraassistant(String traassistant) { + this.traassistant = traassistant; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getOperationEvent() { + return operationEvent; + } + + public void setOperationEvent(String operationEvent) { + this.operationEvent = operationEvent; + } + + public LocalDateTime getOperationTime() { + return operationTime; + } + + public void setOperationTime(LocalDateTime operationTime) { + this.operationTime = operationTime; + } + + public LocalDateTime getCreated_at() { + return created_at; + } + + public void setCreated_at(LocalDateTime created_at) { + this.created_at = created_at; + } + + public LocalDateTime getUpdated_at() { + return updated_at; + } + + public void setUpdated_at(LocalDateTime updated_at) { + this.updated_at = updated_at; + } + + public String getOriginalData() { + return originalData; + } + + public void setOriginalData(String originalData) { + this.originalData = originalData; + } + + public String getModifiedData() { + return modifiedData; + } + + public void setModifiedData(String modifiedData) { + this.modifiedData = modifiedData; + } + + public String getChangedFields() { + return changedFields; + } + + public void setChangedFields(String changedFields) { + this.changedFields = changedFields; + } +} \ No newline at end of file diff --git a/web/src/main/java/com/example/web/mapper/InformationTraMapper.java b/web/src/main/java/com/example/web/mapper/InformationTraMapper.java new file mode 100644 index 0000000..6506c27 --- /dev/null +++ b/web/src/main/java/com/example/web/mapper/InformationTraMapper.java @@ -0,0 +1,44 @@ +package com.example.web.mapper; + +import com.example.web.annotation.DataSource; +import com.example.web.entity.InformationTra; +import org.apache.ibatis.annotations.Mapper; + +/** + * 信息跟踪表Mapper + */ +@Mapper +public interface InformationTraMapper { + + /** + * 插入信息跟踪记录 + * @param informationTra 信息跟踪实体 + * @return 影响行数 + */ + @DataSource("wechat") + int insert(InformationTra informationTra); + + /** + * 根据用户ID查询最新的跟踪记录 + * @param userId 用户ID + * @return 信息跟踪实体 + */ + @DataSource("wechat") + InformationTra selectLatestByUserId(String userId); + + /** + * 根据ID查询跟踪记录 + * @param id 主键ID + * @return 信息跟踪实体 + */ + @DataSource("wechat") + InformationTra selectById(Integer id); + + /** + * 更新跟踪记录 + * @param informationTra 信息跟踪实体 + * @return 影响行数 + */ + @DataSource("wechat") + int update(InformationTra informationTra); +} \ No newline at end of file diff --git a/web/src/main/java/com/example/web/mapper/UsersMapper.java b/web/src/main/java/com/example/web/mapper/UsersMapper.java index 0657f07..8cf7b00 100644 --- a/web/src/main/java/com/example/web/mapper/UsersMapper.java +++ b/web/src/main/java/com/example/web/mapper/UsersMapper.java @@ -60,4 +60,7 @@ public interface UsersMapper { @DataSource("wechat") int clearUsersManagements(Map params); + + @DataSource("wechat") + Users findByUserId(String userId); } diff --git a/web/src/main/java/com/example/web/service/InformationTraService.java b/web/src/main/java/com/example/web/service/InformationTraService.java new file mode 100644 index 0000000..577eafe --- /dev/null +++ b/web/src/main/java/com/example/web/service/InformationTraService.java @@ -0,0 +1,37 @@ +package com.example.web.service; + +import com.example.web.entity.InformationTra; + +/** + * 信息跟踪服务接口 + */ +public interface InformationTraService { + + /** + * 记录用户操作 + * @param informationTra 信息跟踪实体 + * @return 是否成功 + */ + boolean recordUserOperation(InformationTra informationTra); + + /** + * 根据用户ID查询最新的操作记录 + * @param userId 用户ID + * @return 信息跟踪实体 + */ + InformationTra getLatestOperationByUserId(String userId); + + /** + * 根据ID查询操作记录 + * @param id 主键ID + * @return 信息跟踪实体 + */ + InformationTra getOperationById(Integer id); + + /** + * 更新操作记录 + * @param informationTra 信息跟踪实体 + * @return 是否成功 + */ + boolean updateOperation(InformationTra informationTra); +} \ No newline at end of file diff --git a/web/src/main/java/com/example/web/service/impl/InformationTraServiceImpl.java b/web/src/main/java/com/example/web/service/impl/InformationTraServiceImpl.java new file mode 100644 index 0000000..9f25762 --- /dev/null +++ b/web/src/main/java/com/example/web/service/impl/InformationTraServiceImpl.java @@ -0,0 +1,97 @@ +package com.example.web.service.impl; + +import com.example.web.entity.InformationTra; +import com.example.web.mapper.InformationTraMapper; +import com.example.web.service.InformationTraService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; + +/** + * 信息跟踪服务实现类 + */ +@Service +public class InformationTraServiceImpl implements InformationTraService { + + @Autowired + private InformationTraMapper informationTraMapper; + + /** + * 记录用户操作 + * @param informationTra 信息跟踪实体 + * @return 是否成功 + */ + @Override + public boolean recordUserOperation(InformationTra informationTra) { + try { + // 设置操作时间和创建时间 + if (informationTra.getOperationTime() == null) { + informationTra.setOperationTime(LocalDateTime.now()); + } + if (informationTra.getCreated_at() == null) { + informationTra.setCreated_at(LocalDateTime.now()); + } + if (informationTra.getUpdated_at() == null) { + informationTra.setUpdated_at(LocalDateTime.now()); + } + // 插入记录 + int result = informationTraMapper.insert(informationTra); + return result > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据用户ID查询最新的操作记录 + * @param userId 用户ID + * @return 信息跟踪实体 + */ + @Override + public InformationTra getLatestOperationByUserId(String userId) { + try { + return informationTraMapper.selectLatestByUserId(userId); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据ID查询操作记录 + * @param id 主键ID + * @return 信息跟踪实体 + */ + @Override + public InformationTra getOperationById(Integer id) { + try { + return informationTraMapper.selectById(id); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 更新操作记录 + * @param informationTra 信息跟踪实体 + * @return 是否成功 + */ + @Override + public boolean updateOperation(InformationTra informationTra) { + try { + // 设置更新时间 + if (informationTra.getUpdated_at() == null) { + informationTra.setUpdated_at(LocalDateTime.now()); + } + // 更新记录 + int result = informationTraMapper.update(informationTra); + return result > 0; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } +} \ No newline at end of file diff --git a/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java b/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java index 8875f9a..0018e31 100644 --- a/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java +++ b/web/src/main/java/com/example/web/service/impl/UserServiceImpl.java @@ -1,11 +1,13 @@ package com.example.web.service.impl; +import com.example.web.entity.InformationTra; import com.example.web.entity.Managers; import com.example.web.entity.Users; import com.example.web.entity.UsersManagements; -import com.example.web.mapper.ManagersMapper; import com.example.web.mapper.UsersMapper; +import com.example.web.mapper.ManagersMapper; import com.example.web.mapper.UsersManagementsMapper; +import com.example.web.service.InformationTraService; import com.example.web.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +28,9 @@ public class UserServiceImpl implements UserService { @Autowired private UsersManagementsMapper usersManagementsMapper; + @Autowired + private InformationTraService informationTraService; + @Override public Map getUserList(Map requestParams) { Map result = new HashMap<>(); @@ -159,6 +164,12 @@ public class UserServiceImpl implements UserService { try { String userId = (String) params.get("userId"); String followup = (String) params.get("followup"); + String userName = (String) params.get("userName"); + String managercompany = (String) params.get("managercompany"); + String managerdepartment = (String) params.get("managerdepartment"); + String organization = (String) params.get("organization"); + String role = (String) params.get("role"); + String assistant = (String) params.get("assistant"); if (userId == null || followup == null) { result.put("success", false); @@ -169,6 +180,19 @@ public class UserServiceImpl implements UserService { // 更新跟进信息 usersMapper.updateFollowup(params); + // 记录跟进操作 + InformationTra tra = createInformationTra( + managercompany, + managerdepartment, + organization, + role, + userName, + assistant, + userId, + "跟进客户: " + followup + ); + informationTraService.recordUserOperation(tra); + result.put("success", true); result.put("message", "跟进成功"); } catch (Exception e) { @@ -186,6 +210,11 @@ public class UserServiceImpl implements UserService { try { String userId = (String) params.get("userId"); String userName = (String) params.get("userName"); + String managercompany = (String) params.get("managercompany"); + String managerdepartment = (String) params.get("managerdepartment"); + String organization = (String) params.get("organization"); + String role = (String) params.get("role"); + String assistant = (String) params.get("assistant"); if (userId == null || userName == null) { result.put("success", false); @@ -196,15 +225,22 @@ public class UserServiceImpl implements UserService { // 1. 更新 usermanagements 表,为客户添加认领人信息 usersMapper.updateUsersManagements(params); - // 2. 更新 users 表,设置 followup 字段为认领人 - Map followupParams = new HashMap<>(); - followupParams.put("userId", userId); - followupParams.put("followup", userName); - usersMapper.updateFollowup(followupParams); - - // 3. 更新 users 表,设置 sync_status 为 0 + // 2. 更新 users 表,设置 sync_status 为 0 usersMapper.updateSyncStatus(params); + // 记录认领操作 + InformationTra tra = createInformationTra( + managercompany, + managerdepartment, + organization, + role, + userName, + assistant, + userId, + "认领客户" + ); + informationTraService.recordUserOperation(tra); + result.put("success", true); result.put("message", "认领成功"); } catch (Exception e) { @@ -222,6 +258,12 @@ public class UserServiceImpl implements UserService { try { String userId = (String) params.get("userId"); String type = (String) params.get("type"); + String userName = (String) params.get("userName"); + String managercompany = (String) params.get("managercompany"); + String managerdepartment = (String) params.get("managerdepartment"); + String organization = (String) params.get("organization"); + String role = (String) params.get("role"); + String assistant = (String) params.get("assistant"); if (userId == null || type == null) { result.put("success", false); @@ -235,6 +277,19 @@ public class UserServiceImpl implements UserService { // 2. 清除 usermanagements 表中的记录 usersMapper.clearUsersManagements(params); + // 记录归还操作 + InformationTra tra = createInformationTra( + managercompany, + managerdepartment, + organization, + role, + userName, + assistant, + userId, + "归还客户到" + type + ); + informationTraService.recordUserOperation(tra); + result.put("success", true); result.put("message", "归还成功"); } catch (Exception e) { @@ -251,6 +306,12 @@ public class UserServiceImpl implements UserService { try { String userId = (String) params.get("userId"); + String userName = (String) params.get("userName"); + String managercompany = (String) params.get("managercompany"); + String managerdepartment = (String) params.get("managerdepartment"); + String organization = (String) params.get("organization"); + String role = (String) params.get("role"); + String assistant = (String) params.get("assistant"); if (userId == null) { result.put("success", false); @@ -261,6 +322,19 @@ public class UserServiceImpl implements UserService { // 更新 users 表,设置 sync_statuss 字段值为 0 usersMapper.updateSyncStatusToZero(params); + // 记录操作 + InformationTra tra = createInformationTra( + managercompany, + managerdepartment, + organization, + role, + userName, + assistant, + userId, + "简道云操作" + ); + informationTraService.recordUserOperation(tra); + result.put("success", true); result.put("message", "操作成功"); } catch (Exception e) { @@ -284,6 +358,11 @@ public class UserServiceImpl implements UserService { List userIds = (List) params.get("userIds"); String managerId = (String) params.get("managerId"); String userName = (String) params.get("userName"); + String operatorUserName = (String) params.get("operatorUserName"); + String managercompany = (String) params.get("managercompany"); + String managerdepartment = (String) params.get("managerdepartment"); + String organization = (String) params.get("organization"); + String role = (String) params.get("role"); if (userIds == null || userIds.isEmpty() || managerId == null || userName == null) { result.put("success", false); @@ -339,6 +418,19 @@ public class UserServiceImpl implements UserService { // 不更新users表的sync_status,保持原始值 // usersMapper.updateSyncStatus(updateParams); + + // 记录分配操作 + InformationTra tra = createInformationTra( + managercompany, + managerdepartment, + organization, + role, + operatorUserName, + "", + userId, + "分配负责人: " + selectedManager.getUserName() + ); + informationTraService.recordUserOperation(tra); } result.put("success", true); @@ -350,4 +442,37 @@ public class UserServiceImpl implements UserService { return result; } + + /** + * 创建信息跟踪记录 + * @param tracompany 修改者公司 + * @param tradepartment 修改者部门 + * @param traorganization 修改者组织 + * @param trarole 修改者角色 + * @param trauserName 修改者名字 + * @param traassistant 修改协助人 + * @param userId 客户ID + * @param operationEvent 操作事件 + * @return 信息跟踪实体 + */ + private InformationTra createInformationTra( + String tracompany, + String tradepartment, + String traorganization, + String trarole, + String trauserName, + String traassistant, + String userId, + String operationEvent) { + InformationTra tra = new InformationTra(); + tra.setTracompany(tracompany); + tra.setTradepartment(tradepartment); + tra.setTraorganization(traorganization); + tra.setTrarole(trarole); + tra.setTrauserName(trauserName); + tra.setTraassistant(traassistant); + tra.setUserId(userId); + tra.setOperationEvent("跟进系统-" + operationEvent); + return tra; + } } diff --git a/web/src/main/resources/mapper/InformationTraMapper.xml b/web/src/main/resources/mapper/InformationTraMapper.xml new file mode 100644 index 0000000..2990f5a --- /dev/null +++ b/web/src/main/resources/mapper/InformationTraMapper.xml @@ -0,0 +1,75 @@ + + + + + + + INSERT INTO informationtra ( + tracompany, + tradepartment, + traorganization, + trarole, + trauserName, + traassistant, + userId, + operationEvent, + operationTime, + created_at, + updated_at, + originalData, + modifiedData, + changedFields + ) VALUES ( + #{tracompany}, + #{tradepartment}, + #{traorganization}, + #{trarole}, + #{trauserName}, + #{traassistant}, + #{userId}, + #{operationEvent}, + #{operationTime}, + #{created_at}, + #{updated_at}, + #{originalData}, + #{modifiedData}, + #{changedFields} + ) + + + + + + + + + + + UPDATE informationtra SET + tracompany = #{tracompany}, + tradepartment = #{tradepartment}, + traorganization = #{traorganization}, + trarole = #{trarole}, + trauserName = #{trauserName}, + traassistant = #{traassistant}, + userId = #{userId}, + operationEvent = #{operationEvent}, + operationTime = #{operationTime}, + updated_at = #{updated_at}, + originalData = #{originalData}, + modifiedData = #{modifiedData}, + changedFields = #{changedFields} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/web/src/main/resources/mapper/UsersMapper.xml b/web/src/main/resources/mapper/UsersMapper.xml index fa8585b..8c84ac3 100644 --- a/web/src/main/resources/mapper/UsersMapper.xml +++ b/web/src/main/resources/mapper/UsersMapper.xml @@ -224,4 +224,8 @@ userName = '' WHERE userId = #{userId} + + \ No newline at end of file diff --git a/web/src/main/resources/static/index.html b/web/src/main/resources/static/index.html index ca6100e..6c2df13 100644 --- a/web/src/main/resources/static/index.html +++ b/web/src/main/resources/static/index.html @@ -469,7 +469,8 @@ - @@ -637,6 +638,12 @@ var userName = userInfo.loginInfo.userName; var usersManagements = userInfo.usersManagements; + // 如果当前是已跟进或未跟进筛选,重新加载所有数据后在前端筛选 + if (personalFilter === 'followed' || personalFilter === 'unfollowed') { + loadAllPersonalData(); + return; + } + // 构建查询参数 var params = { page: personalPage, @@ -713,6 +720,7 @@ var managerHeader = document.getElementById('managerHeader'); var personalPagination = document.getElementById('personalPagination'); var selectAllPersonal = document.getElementById('selectAllPersonal'); + var personalTotalCount = document.getElementById('personalTotalCount'); personalBody.innerHTML = ''; // 检查用户角色,只对管理员显示负责人列和复选框列 @@ -748,6 +756,9 @@ return true; }); + // 更新统计信息 + personalTotalCount.textContent = filteredUsers.length; + console.log('过滤后的数据量:', filteredUsers.length); if (filteredUsers.length > 0) { @@ -1028,6 +1039,7 @@ var managerHeader = document.getElementById('managerHeader'); var personalPagination = document.getElementById('personalPagination'); var selectAllPersonal = document.getElementById('selectAllPersonal'); + var personalTotalCount = document.getElementById('personalTotalCount'); personalBody.innerHTML = ''; // 检查用户角色,只对管理员显示负责人列和复选框列 @@ -1075,6 +1087,9 @@ return true; }); + // 更新统计信息 + personalTotalCount.textContent = data.total; + console.log('过滤后的数据量:', filteredUsers.length); if (filteredUsers.length > 0) { @@ -1346,9 +1361,15 @@ function saveJianDaoYun() { var userId = document.getElementById('jianDaoYunUserId').value; + var usersManagements = userInfo.usersManagements; var params = { - userId: userId + userId: userId, + userName: usersManagements.userName || '', + managercompany: usersManagements.managercompany || '', + managerdepartment: usersManagements.managerdepartment || '', + organization: usersManagements.organization || '', + role: usersManagements.role || '' }; var url = 'http://8.137.125.67:8083/KH/api/users/jianDaoYun'; @@ -1375,10 +1396,16 @@ function saveReturn() { var userId = document.getElementById('returnUserId').value; var type = document.getElementById('returnType').value; + var usersManagements = userInfo.usersManagements; var params = { userId: userId, - type: type + type: type, + userName: usersManagements.userName || '', + managercompany: usersManagements.managercompany || '', + managerdepartment: usersManagements.managerdepartment || '', + organization: usersManagements.organization || '', + role: usersManagements.role || '' }; var url = 'http://8.137.125.67:8083/KH/api/users/return'; @@ -1577,6 +1604,7 @@ function saveAssign() { var checkboxes = document.querySelectorAll('.userCheckbox:checked'); var selectedUserIds = []; + var usersManagements = userInfo.usersManagements; checkboxes.forEach(function(checkbox) { selectedUserIds.push(checkbox.getAttribute('data-userid')); @@ -1593,7 +1621,12 @@ var params = { userIds: selectedUserIds, managerId: selectedOption.value, - userName: selectedOption.textContent + userName: selectedOption.textContent, + operatorUserName: usersManagements.userName || '', + managercompany: usersManagements.managercompany || '', + managerdepartment: usersManagements.managerdepartment || '', + organization: usersManagements.organization || '', + role: usersManagements.role || '' }; var url = '/KH/api/users/assign';