diff --git a/src/main/java/com/cm/inspection/controller/app/apis/check/CheckApp2Controller.java b/src/main/java/com/cm/inspection/controller/app/apis/check/CheckApp2Controller.java index d05b9b7..f14708e 100644 --- a/src/main/java/com/cm/inspection/controller/app/apis/check/CheckApp2Controller.java +++ b/src/main/java/com/cm/inspection/controller/app/apis/check/CheckApp2Controller.java @@ -50,7 +50,7 @@ public class CheckApp2Controller extends AbstractController { @ApiImplicitParam(name = "checkId", value = "原检查ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("save") + @PostMapping("save-re") @CheckRequestBodyAnnotation public SuccessResult saveRe(@RequestHeader("token") String token, @PathVariable("checkId") String checkId, diff --git a/src/main/java/com/cm/inspection/pojo/dtos/gridpersonnel/GridPersonnelDTO.java b/src/main/java/com/cm/inspection/pojo/dtos/gridpersonnel/GridPersonnelDTO.java index 2283695..256b5e2 100644 --- a/src/main/java/com/cm/inspection/pojo/dtos/gridpersonnel/GridPersonnelDTO.java +++ b/src/main/java/com/cm/inspection/pojo/dtos/gridpersonnel/GridPersonnelDTO.java @@ -26,10 +26,6 @@ public class GridPersonnelDTO implements Serializable { private String userId; @ApiModelProperty(name = "userName", value = "用户名称") private String userName; - @ApiModelProperty(name = "departmentId", value = "部门ID") - private String departmentId; - @ApiModelProperty(name = "departmentName", value = "部门名称") - private String departmentName; @ApiModelProperty(name = "area1", value = "1级区域") private String area1; @ApiModelProperty(name = "area1Name", value = "1级区域名称") @@ -54,10 +50,6 @@ public class GridPersonnelDTO implements Serializable { private String leaderUserId; @ApiModelProperty(name = "leaderUserName", value = "领导用户昵称") private String leaderUserName; - @ApiModelProperty(name = "leaderDepartmentId", value = "领导部门ID") - private String leaderDepartmentId; - @ApiModelProperty(name = "leaderDepartmentName", value = "领导部门名称") - private String leaderDepartmentName; @ApiModelProperty(name = "personType", value = "人员类型") private String personType; @ApiModelProperty(name = "gridType", value = "网格类型") diff --git a/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java b/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java index 91e9026..a53f4a7 100644 --- a/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/gridpersonnel/impl/GridPersonnelServiceImpl.java @@ -29,10 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @ClassName: GridPersonnelServiceImpl @@ -203,7 +200,9 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson @Override public List list(Map params) throws SearchException { - return gridPersonnelDao.listGridPersonnel(params); + List gridPersonnelDTOs = gridPersonnelDao.listGridPersonnel(params); + setGridPersonnelUserInfo(gridPersonnelDTOs); + return gridPersonnelDTOs; } @Override @@ -222,9 +221,8 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson } page.getParams().put("userIds", userIds); } - List gridPersonnelDTOs = gridPersonnelDao.listGridPersonnel(page.getParams()); + List gridPersonnelDTOs = list(page.getParams()); PageInfo pageInfo = new PageInfo<>(gridPersonnelDTOs); - setGridPersonnelUserInfo(gridPersonnelDTOs); return new SuccessResultList<>(gridPersonnelDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } @@ -350,50 +348,24 @@ public class GridPersonnelServiceImpl extends BaseService implements IGridPerson * @param gridPersonnelDTOs */ private void setGridPersonnelUserInfo(List gridPersonnelDTOs) { - List userIds = new ArrayList<>(); - StringBuilder userIdsSB = new StringBuilder(); - for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { - if (userIdsSB.length() > 0) { - userIdsSB.append("_"); - } - String userId = gridPersonnelDTO.getUserId(); - userIdsSB.append(userId); - userIds.add(userId); - } - if (userIds.isEmpty()) { + if (gridPersonnelDTOs.isEmpty()) { return; } - // 账号信息 - Map params = getHashMap(2); - params.put("userIds", userIdsSB.toString()); - JSONArray userJSONArray = userService.listUserByIds(params); - // 动态个人信息 - JSONArray userInfoJSONArray = userService.listDynamicUserInfoByIds(userIds); + Set userIdSet = new HashSet<>(); for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { - String userId = gridPersonnelDTO.getUserId(); - // 设置账号 - if (!userJSONArray.isEmpty()) { - for (int i = 0; i < userJSONArray.size(); i++) { - JSONObject userJSONObject = userJSONArray.getJSONObject(i); - if (!StringUtils.equals(userId, userJSONObject.getString("userId"))) { - continue; - } - gridPersonnelDTO.setUserPhone(userJSONObject.getString("userPhone")); - break; + userIdSet.add(gridPersonnelDTO.getUserId()); + userIdSet.add(gridPersonnelDTO.getLeaderUserId()); + } + // 账号信息 + List userResourceBOs = userService.listUserResourceByIds(new ArrayList<>(userIdSet)); + for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) { + for (UserResourceBO userResourceBO : userResourceBOs) { + if (StringUtils.equals(gridPersonnelDTO.getUserId(), userResourceBO.getUserId())) { + gridPersonnelDTO.setUserName(userResourceBO.getUserName()); + gridPersonnelDTO.setUserPhone(userResourceBO.getUserPhone()); } - } - // 个人信息 - if (!userInfoJSONArray.isEmpty()) { - for (int i = 0; i < userInfoJSONArray.size(); i++) { - JSONObject userInfoJSONObject = userInfoJSONArray.getJSONObject(i); - if (!StringUtils.equals(userId, userInfoJSONObject.getString("userId"))) { - continue; - } - gridPersonnelDTO.setUserSex(userInfoJSONObject.getString("userSex")); - gridPersonnelDTO.setUserBirth(userInfoJSONObject.getString("userBirth")); - gridPersonnelDTO.setUserExplain(userInfoJSONObject.getString("userExplain")); - gridPersonnelDTO.setUserNation(userInfoJSONObject.getString("userNation")); - break; + if (StringUtils.equals(gridPersonnelDTO.getLeaderUserId(), userResourceBO.getUserId())) { + gridPersonnelDTO.setLeaderUserName(userResourceBO.getUserName()); } } } diff --git a/src/main/resources/mybatis/mapper/gridpersonnel/gridpersonnel-mapper.xml b/src/main/resources/mybatis/mapper/gridpersonnel/gridpersonnel-mapper.xml index 0b56dda..ce39e3c 100644 --- a/src/main/resources/mybatis/mapper/gridpersonnel/gridpersonnel-mapper.xml +++ b/src/main/resources/mybatis/mapper/gridpersonnel/gridpersonnel-mapper.xml @@ -8,8 +8,6 @@ - - @@ -21,9 +19,6 @@ - - - @@ -35,18 +30,12 @@ INSERT INTO gen_grid_personnel( grid_personnel_id, user_id, - user_name, - department_id, - department_name, area1, area2, area3, area4, area5, leader_user_id, - leader_user_name, - leader_department_id, - leader_department_name, person_type, grid_type, level, @@ -58,18 +47,12 @@ ) VALUES( #{gridPersonnelId}, #{userId}, - #{userName}, - #{departmentId}, - #{departmentName}, #{area1}, #{area2}, #{area3}, #{area4}, #{area5}, #{leaderUserId}, - #{leaderUserName}, - #{leaderDepartmentId}, - #{leaderDepartmentName}, #{personType}, #{gridType}, #{level}, @@ -104,15 +87,6 @@ user_id = #{userId}, - - user_name = #{userName}, - - - department_id = #{departmentId}, - - - department_name = #{departmentName}, - area1 = #{area1}, @@ -131,15 +105,6 @@ leader_user_id = #{leaderUserId}, - - leader_user_name = #{leaderUserName}, - - - leader_department_id = #{leaderDepartmentId}, - - - leader_department_name = #{leaderDepartmentName}, - person_type = #{personType}, @@ -159,18 +124,12 @@ SELECT t1.user_id, - t1.user_name, - t1.department_id, - t1.department_name, t1.area1, dt1.dictionary_name area1_name, t1.area2, @@ -207,9 +163,6 @@ t1.area5, dt5.dictionary_name area5_name, t1.leader_user_id, - t1.leader_user_name, - t1.leader_department_id, - t1.leader_department_name, t1.person_type, t1.grid_type, t1.level, @@ -338,18 +291,12 @@ - - -
- - - - +
@@ -67,7 +61,7 @@ @@ -94,7 +88,7 @@ @@ -121,7 +115,7 @@ @@ -148,7 +142,7 @@ @@ -227,52 +221,6 @@ form.render('radio', 'dataForm'); } - // 初始化用户ID选择人员 - function initUserIdSelectUser() { - $(document.body).on('click', '#userIdSelectUser', function() { - top.dialog.dialogData.selectedUsers = [{ - userId: $('#userId').val(), - departmentId: $('#departmentId').val() - }]; - top.dialog.open({ - url: top.restAjax.path('route/tree/treeuser', []), - title: '选择组织部门人员', - width: '500px', - height: '500px', - onClose: function() { - var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers; - if(selectedUsers != null && selectedUsers.length == 1) { - var selectedUsersId = ''; - var selectedUserName = ''; - var selectedDepartmentId = ''; - var selectedDepartmentName = ''; - var showSelectedUsersVal = ''; - for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) { - selectedUsersId = selectUser.userId; - selectedUserName = selectUser.userName; - selectedDepartmentId = selectUser.departmentId; - selectedDepartmentName = selectUser.userTitle.split('】')[0].substr(1); - showSelectedUsersVal = selectUser.userTitle; - } - $('#userId').val(selectedUsersId); - $('#userName').val(selectedUserName); - $('#departmentId').val(selectedDepartmentId); - $('#departmentName').val(selectedDepartmentName); - $('#userIdSelectUser').val(showSelectedUsersVal); - } else if(selectedUsers != null && selectedUsers.length > 1) { - top.dialog.msg('只能选择一位人员'); - } else { - $('#userId').val(''); - $('#userName').val(''); - $('#departmentId').val(''); - $('#departmentName').val(''); - $('#userIdSelectUser').val(''); - } - } - }); - }); - } - // 初始化选择框、单选、复选模板 function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) { laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) { @@ -389,7 +337,6 @@ // 初始化内容 function initData() { - initUserIdSelectUser(); initArea1Select(); initArea2Select(); if(level > 1) { @@ -445,6 +392,37 @@ return false; }); + $(document).on('click', '#userName', function() { + top.dialog.dialogData.selectedUserIds = $('#userId').val(); + top.dialog.user({ + url: top.restAjax.path('route/system/user/select-department-user.html', []), + title: '选择组织部门人员', + width: '500px', + height: '500px', + onClose: function () { + var userIds = ''; + var userNames = ''; + var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers; + if(selectedUsers != null && selectedUsers.length > 0) { + if(selectedUsers.length > 1) { + top.dialog.msg('最多选择一名人员,请重新选择'); + return false; + } + for (var i = 0, item; item = selectedUsers[i++];) { + if(userIds.length > 0) { + userIds += ','; + userNames += ','; + } + userIds += item.userId; + userNames += item.userName; + } + } + $('#userId').val(userIds); + $('#userName').val(userNames); + } + }); + }); + $('.close').on('click', function() { closeBox(); }); diff --git a/src/main/resources/static/route/gridpersonnel/update-gridpersonnel.html b/src/main/resources/static/route/gridpersonnel/update-gridpersonnel.html index 8a13bcb..8654cbc 100644 --- a/src/main/resources/static/route/gridpersonnel/update-gridpersonnel.html +++ b/src/main/resources/static/route/gridpersonnel/update-gridpersonnel.html @@ -22,17 +22,11 @@
- - -
- - - - +
@@ -67,7 +61,7 @@ @@ -94,7 +88,7 @@ @@ -121,7 +115,7 @@ @@ -148,7 +142,7 @@ @@ -229,54 +223,6 @@ form.render('radio', 'dataForm'); } - // 初始化用户ID选择人员 - function initUserIdSelectUser() { - $('#userIdSelectUser').val('【'+ $('#departmentName').val() +'】'+ $('#userName').val()); - - $(document.body).on('click', '#userIdSelectUser', function() { - top.dialog.dialogData.selectedUsers = [{ - userId: $('#userId').val(), - departmentId: $('#departmentId').val() - }]; - top.dialog.open({ - url: top.restAjax.path('route/tree/treeuser', []), - title: '选择组织部门人员', - width: '500px', - height: '500px', - onClose: function() { - var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers; - if(selectedUsers != null && selectedUsers.length == 1) { - var selectedUsersId = ''; - var selectedUserName = ''; - var selectedDepartmentId = ''; - var selectedDepartmentName = ''; - var showSelectedUsersVal = ''; - for(var j = 0, selectUser = selectedUsers[j]; selectUser = selectedUsers[j++];) { - selectedUsersId = selectUser.userId; - selectedUserName = selectUser.userName; - selectedDepartmentId = selectUser.departmentId; - selectedDepartmentName = selectUser.userTitle.split('】')[0].substr(1); - showSelectedUsersVal = selectUser.userTitle; - } - $('#userId').val(selectedUsersId); - $('#userName').val(selectedUserName); - $('#departmentId').val(selectedDepartmentId); - $('#departmentName').val(selectedDepartmentName); - $('#userIdSelectUser').val(showSelectedUsersVal); - } else if(selectedUsers != null && selectedUsers.length > 1) { - top.dialog.msg('只能选择一位人员'); - } else { - $('#userId').val(''); - $('#userName').val(''); - $('#departmentId').val(''); - $('#departmentName').val(''); - $('#userIdSelectUser').val(''); - } - } - }); - }); - } - // 初始化选择框、单选、复选模板 function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) { laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) { @@ -492,8 +438,6 @@ form.val('dataForm', dataFormData); form.render(null, 'dataForm'); - initUserIdSelectUser(); - initArea1Select(data['area1'], function() { var leader = data['leaderUserId'] +'|'+ data['leaderUserName'] +'|'+ data['leaderDepartmentId']+'|'+ data['leaderDepartmentName']; initArea2Select(data['area1'], data['area2'], function() { @@ -571,6 +515,37 @@ return false; }); + $(document).on('click', '#userName', function() { + top.dialog.dialogData.selectedUserIds = $('#userId').val(); + top.dialog.user({ + url: top.restAjax.path('route/system/user/select-department-user.html', []), + title: '选择组织部门人员', + width: '500px', + height: '500px', + onClose: function () { + var userIds = ''; + var userNames = ''; + var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers; + if(selectedUsers != null && selectedUsers.length > 0) { + if(selectedUsers.length > 1) { + top.dialog.msg('最多选择一名人员,请重新选择'); + return false; + } + for (var i = 0, item; item = selectedUsers[i++];) { + if(userIds.length > 0) { + userIds += ','; + userNames += ','; + } + userIds += item.userId; + userNames += item.userName; + } + } + $('#userId').val(userIds); + $('#userName').val(userNames); + } + }); + }); + $('.close').on('click', function() { closeBox(); });