Kaynağa Gözat

1.人员查询修改。

zhengqiang 5 yıl önce
ebeveyn
işleme
daa70d3470

+ 3 - 0
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -179,6 +179,9 @@
             <if test="searchParams.companyId != null">
                 and a.company_id = #{searchParams.companyId}
             </if>
+            <if test="searchParams.companyCode != null">
+                and b.code_ like #{searchParams.companyCode}
+            </if>
             <if test="searchParams.name != null">
                 and a.name_ like #{searchParams.name}
             </if>

+ 27 - 14
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -3,20 +3,14 @@ package com.jpsoft.smart.modules.base.controller;
 import com.github.pagehelper.Page;
 import com.jpsoft.smart.config.OSSConfig;
 import com.jpsoft.smart.modules.base.dto.PersonInfoDTO;
-import com.jpsoft.smart.modules.base.entity.DeviceInfo;
-import com.jpsoft.smart.modules.base.entity.PersonCompany;
-import com.jpsoft.smart.modules.base.entity.PersonDeviceRelation;
-import com.jpsoft.smart.modules.base.service.DeviceInfoService;
-import com.jpsoft.smart.modules.base.service.PersonCompanyService;
-import com.jpsoft.smart.modules.base.service.PersonDeviceRelationService;
+import com.jpsoft.smart.modules.base.entity.*;
+import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.common.utils.CheckIdCard;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.common.utils.POIUtils;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
-import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.sys.entity.User;
@@ -64,6 +58,10 @@ public class PersonInfoController {
     private PersonDeviceRelationService personDeviceRelationService;
     @Autowired
     private DeviceInfoService deviceInfoService;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
     @Autowired
     private PersonCompanyService personCompanyService;
 
@@ -424,7 +422,8 @@ public class PersonInfoController {
             @ApiImplicitParam(name = "name",value = "姓名", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
-            @ApiImplicitParam(name = "companyId",value = "企业id", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "companyCode",value = "企业编码", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
@@ -437,7 +436,8 @@ public class PersonInfoController {
             @RequestParam(value="name",defaultValue="") String name,
             @RequestParam(value="idCard",defaultValue="") String idCard,
             @RequestParam(value="phone",defaultValue="") String phone,
-            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestParam(value="companyCode",defaultValue="")  String companyCode,
+            @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
             @RequestParam(value="position1",defaultValue="") String position1,
             @RequestParam(value="position2",defaultValue="") String position2,
             @RequestParam(value="position3",defaultValue="") String position3,
@@ -452,6 +452,8 @@ public class PersonInfoController {
         //当前用户ID
         User user = userService.get(subject);
 
+        CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+
         MessageResult<Map> msgResult = new MessageResult<>();
 
         Map<String,Object> searchParams = new HashMap<>();
@@ -476,13 +478,24 @@ public class PersonInfoController {
             searchParams.put("phone","%" + phone + "%");
         }
 
-        if (userService.hasRole(subject,"SYSADMIN")) {
-            if(StringUtils.isNotEmpty(companyId)) {
-                searchParams.put("companyId", companyId);
+        if (StringUtils.isEmpty(companyCode)){
+            if (!userService.hasRole(subject,"SYSADMIN")) {
+
+                if(subordinate){
+                    searchParams.put("companyCode", companyInfo.getCode() + "%");
+                }
+                else {
+                    searchParams.put("companyCode", companyInfo.getCode());
+                }
             }
         }
         else{
-            searchParams.put("companyId",user.getCompanyId());
+            if(subordinate){
+                searchParams.put("companyCode", companyCode + "%");
+            }
+            else {
+                searchParams.put("companyCode", companyCode);
+            }
         }
 
         if (StringUtils.isNotEmpty(position1)) {