Browse Source

Merge remote-tracking branch 'origin/V1' into V1

yanliming 5 years ago
parent
commit
05c661803b

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

@@ -169,9 +169,12 @@
                 and a.company_id = #{searchParams.companyId}
             </if>
             <if test="searchParams.name != null">
-            <foreach item="name" collection="searchParams.name"  open="and" separator="or">
-                a.name_ like #{name}
-            </foreach>
+                and a.name_ like #{searchParams.name}
+            </if>
+            <if test="searchParams.nameList != null">
+                <foreach item="name" collection="searchParams.nameList"  open="and" separator="or">
+                    a.name_ like #{name}
+                </foreach>
             </if>
             <if test="searchParams.idCard != null">
                 and a.id_card like #{searchParams.idCard}

+ 31 - 26
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -72,30 +72,31 @@ public class PersonInfoController {
         try {
             Map<String, Object> searchParams = new HashMap<>();
             searchParams.put("companyId", personInfo.getCompanyId());
-            searchParams.put("idCard", personInfo.getIdCard());
+            searchParams.put("name", personInfo.getName());
+            searchParams.put("phone", personInfo.getPhone());
             List<Sort> sortList = new ArrayList<>();
             sortList.add(new Sort("id_","asc"));
             Page<PersonInfo> page = personInfoService.pageSearch(searchParams, 1, 1,false, sortList);
 
             if (page.size() > 0) {
-                msgResult.setMessage("身份证已导入!");
+                msgResult.setMessage("该人员已存在!");
                 msgResult.setResult(false);
                 return msgResult;
             } else {
                 CheckIdCard cic = null;
                 if (StringUtils.isEmpty(personInfo.getIdCard())) {
-                    msgResult.setMessage("身份证不能为空!");
-                    msgResult.setResult(false);
-                    return msgResult;
+//                    msgResult.setMessage("身份证不能为空!");
+//                    msgResult.setResult(false);
+//                    return msgResult;
                 } else {
                     personInfo.setIdCard(personInfo.getIdCard().trim().toUpperCase());
-                }
 
-                cic = new CheckIdCard(personInfo.getIdCard());
-                if (!cic.validate()) {
-                    msgResult.setMessage("身份证验证失败!");
-                    msgResult.setResult(false);
-                    return msgResult;
+                    cic = new CheckIdCard(personInfo.getIdCard());
+                    if (!cic.validate()) {
+                        msgResult.setMessage("身份证验证失败!");
+                        msgResult.setResult(false);
+                        return msgResult;
+                    }
                 }
             }
 
@@ -338,7 +339,7 @@ public class PersonInfoController {
             @RequestAttribute String subject){
 
         //当前用户ID
-        System.out.println(subject);
+        User user = userService.get(subject);
 
         MessageResult<Map> msgResult = new MessageResult<>();
 
@@ -354,7 +355,7 @@ public class PersonInfoController {
                 for (String n : names) {
                     nameList.add("%"+ n +"%");
                 }
-                searchParams.put("name", nameList);
+                searchParams.put("nameList", nameList);
         }
         if (StringUtils.isNotEmpty(idCard)) {
             searchParams.put("idCard","%" + idCard + "%");
@@ -362,7 +363,10 @@ public class PersonInfoController {
         if (StringUtils.isNotEmpty(phone)) {
             searchParams.put("phone","%" + phone + "%");
         }
-        if (StringUtils.isNotEmpty(companyId)) {
+        if(userService.hasRole(subject,"ADMIN")){
+            searchParams.put("companyId",user.getCompanyId());
+        }
+        if (userService.hasRole(subject,"SYSADMIN") && StringUtils.isNotEmpty(companyId)) {
             searchParams.put("companyId",companyId);
         }
         if (StringUtils.isNotEmpty(position1)) {
@@ -657,13 +661,14 @@ public class PersonInfoController {
 
                     Map<String, Object> searchParams = new HashMap<>();
                     searchParams.put("companyId", companyId);
-                    searchParams.put("idCard", idCard);
+                    searchParams.put("name", name);
+                    searchParams.put("phone", phone);
                     List<Sort> sortList = new ArrayList<>();
                     sortList.add(new Sort("id_","asc"));
                     Page<PersonInfo> page = personInfoService.pageSearch(searchParams, 1, 1,false, sortList);
 
                     if (page.size() > 0) {
-                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证已导入!");
+                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("该人员已存在!");
                         failCount++;
                         continue;
                     } else {
@@ -672,19 +677,19 @@ public class PersonInfoController {
 
                         CheckIdCard cic = null;
                         if(StringUtils.isEmpty(idCard)){
-                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证不能为空!");
-                            failCount++;
-                            continue;
+//                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证不能为空!");
+//                            failCount++;
+//                            continue;
                         }
                         else{
                             idCard = idCard.trim().toUpperCase();
-                        }
 
-                        cic = new CheckIdCard(idCard);
-                        if (!cic.validate()){
-                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证验证失败!");
-                            failCount++;
-                            continue;
+                            cic = new CheckIdCard(idCard);
+                            if (!cic.validate()){
+                                sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证验证失败!");
+                                failCount++;
+                                continue;
+                            }
                         }
 
                         personInfo.setIdCard(idCard);
@@ -832,7 +837,7 @@ public class PersonInfoController {
                 for (String n : names) {
                     nameList.add("%"+ n +"%");
                 }
-                searchParams.put("name", nameList);
+                searchParams.put("nameList", nameList);
             }
             if (StringUtils.isNotEmpty(idCard)) {
                 searchParams.put("idCard","%" + idCard + "%");