Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

yanliming 5 tahun lalu
induk
melakukan
82d8a08f73

+ 25 - 0
pom.xml

@@ -24,8 +24,33 @@
         <fastjson.version>1.2.29</fastjson.version>
         <alipay.version>4.8.10.ALL</alipay.version>
         <ijpay.version>2.3.2</ijpay.version>
+        <poi.version>4.1.0</poi.version>
     </properties>
     <dependencies>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>${poi.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-scratchpad</artifactId>
+            <version>${poi.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>${poi.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>${poi.version}</version>
+            <scope>compile</scope>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>

+ 70 - 60
src/main/java/com/jpsoft/smart/modules/base/controller/CompanyPositionController.java

@@ -1,12 +1,17 @@
 package com.jpsoft.smart.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 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.CompanyPosition;
 import com.jpsoft.smart.modules.base.service.CompanyPositionService;
+import com.jpsoft.smart.modules.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -26,38 +31,37 @@ public class CompanyPositionController {
 
     @Autowired
     private CompanyPositionService companyPositionService;
+    @Autowired
+    private UserService userService;
 
-    @ApiOperation(value="创建空记录")
-    @GetMapping("create")
-    public MessageResult<CompanyPosition> create(){
-        MessageResult<CompanyPosition> msgResult = new MessageResult<>();
-
-        CompanyPosition companyPosition = new CompanyPosition();
-
-        msgResult.setData(companyPosition);
-        msgResult.setResult(true);
-
-        return msgResult;
-    }
-    
-    @ApiOperation(value="添加信息")
-    @PostMapping("add")
-    public MessageResult<CompanyPosition> add(@RequestBody CompanyPosition companyPosition,@RequestAttribute String subject){
+    @ApiOperation(value="保存信息")
+    @PostMapping("save")
+    public MessageResult<CompanyPosition> save(@RequestBody CompanyPosition companyPosition,@RequestAttribute String subject){
+        User user = userService.get(subject);
         MessageResult<CompanyPosition> msgResult = new MessageResult<>();
 
         try {
-            companyPosition.setId(UUID.randomUUID().toString());
-            companyPosition.setCreateBy(subject);
-            companyPosition.setCreateTime(new Date());
-            
-            int affectCount = companyPositionService.insert(companyPosition);
+            int affectCount = 0;
+            if(StringUtils.isEmpty(companyPosition.getId())) {
+                companyPosition.setCompanyId(user.getCompanyId());
+                companyPosition.setDelFlag(false);
+                companyPosition.setCreateBy(subject);
+                companyPosition.setCreateTime(new Date());
+
+                affectCount = companyPositionService.insert(companyPosition);
+            }else{
+                companyPosition.setUpdateBy(subject);
+                companyPosition.setUpdateTime(new Date());
+
+                affectCount = companyPositionService.update(companyPosition);
+            }
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
                 msgResult.setData(companyPosition);
-            } else {
+            }else{
                 msgResult.setResult(false);
-                msgResult.setMessage("数据库添加失败");
+                msgResult.setMessage("数据库保存失败");
             }
         }
         catch(Exception ex){
@@ -70,9 +74,9 @@ public class CompanyPositionController {
         return msgResult;
     }
 
-    @ApiOperation(value="获取信息")
-    @GetMapping("edit/{id}")
-    public MessageResult<CompanyPosition> edit(@PathVariable("id") String id){
+    @ApiOperation(value="获取详情信息")
+    @GetMapping("detail/{id}")
+    public MessageResult<CompanyPosition> detail(@PathVariable("id") String id){
         MessageResult<CompanyPosition> msgResult = new MessageResult<>();
 
         try {
@@ -96,36 +100,7 @@ public class CompanyPositionController {
         return msgResult;
     }
 
-    @ApiOperation(value="更新用户")
-    @PostMapping("update")
-    public MessageResult<CompanyPosition> update(@RequestBody CompanyPosition companyPosition,@RequestAttribute String subject){
-        MessageResult<CompanyPosition> msgResult = new MessageResult<>();
-
-        try {
-            companyPosition.setUpdateBy(subject);
-            companyPosition.setUpdateTime(new Date());
-            
-            int affectCount = companyPositionService.update(companyPosition);
-
-            if (affectCount > 0) {
-                msgResult.setResult(true);
-                msgResult.setData(companyPosition);
-            } else {
-                msgResult.setResult(false);
-                msgResult.setMessage("数据库更新失败");
-            }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
-
-            msgResult.setResult(false);
-            msgResult.setMessage(ex.getMessage());
-        }
-
-        return msgResult;
-    }
-
-	@ApiOperation(value="删除")
+    @ApiOperation(value="删除")
     @PostMapping("delete/{id}")
     public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
         MessageResult<Integer> msgResult = new MessageResult<>();
@@ -156,7 +131,6 @@ public class CompanyPositionController {
         return msgResult;
     }
 
-
     @ApiOperation(value="批量删除")
     @PostMapping("batchDelete")
     public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
@@ -194,8 +168,11 @@ public class CompanyPositionController {
 
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "companyId",value = "公司编号", required = false, paramType = "form",dataType = "String"),
+    })
     public MessageResult<Map> pageList(
-            String id,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -210,8 +187,8 @@ public class CompanyPositionController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("id_","asc"));
 
-        if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId",companyId);
         }
 
         Page<CompanyPosition> page = companyPositionService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
@@ -221,4 +198,37 @@ public class CompanyPositionController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="根据公司获取详情信息")
+    @GetMapping("detailForCompany")
+    public MessageResult<CompanyPosition> detailForCompany(@RequestAttribute String subject){
+        User user = userService.get(subject);
+        MessageResult<CompanyPosition> msgResult = new MessageResult<>();
+
+        try {
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("companyId",user.getCompanyId());
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("id_","asc"));
+
+            CompanyPosition companyPosition = new CompanyPosition();
+            Page<CompanyPosition> page = companyPositionService.pageSearch(searchParams,1,1,false,sortList);
+
+            if (page.size() > 0) {
+                companyPosition = page.get(0);
+            }
+
+            msgResult.setResult(true);
+            msgResult.setData(companyPosition);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 383 - 60
src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -6,15 +6,22 @@ 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.sys.entity.User;
+import com.jpsoft.smart.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -26,39 +33,37 @@ public class PersonInfoController {
 
     @Autowired
     private PersonInfoService personInfoService;
+    @Autowired
+    private UserService userService;
 
-    @ApiOperation(value="创建空记录")
-    @GetMapping("create")
-    public MessageResult<PersonInfo> create(){
-        MessageResult<PersonInfo> msgResult = new MessageResult<>();
-
-        PersonInfo personInfo = new PersonInfo();
-
-        msgResult.setData(personInfo);
-        msgResult.setResult(true);
-
-        return msgResult;
-    }
-    
-    @ApiOperation(value="添加信息")
-    @PostMapping("add")
-    public MessageResult<PersonInfo> add(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+    @ApiOperation(value="保存信息")
+    @PostMapping("save")
+    public MessageResult<PersonInfo> save(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
+        User user = userService.get(subject);
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
-//            personInfo.setId(UUID.randomUUID().toString());
-            personInfo.setDelFlag(false);
-            personInfo.setCreateBy(subject);
-            personInfo.setCreateTime(new Date());
-            
-            int affectCount = personInfoService.insert(personInfo);
+            int affectCount = 0;
+            if(personInfo.getId() != null) {
+                personInfo.setCompanyId(user.getCompanyId());
+                personInfo.setDelFlag(false);
+                personInfo.setCreateBy(subject);
+                personInfo.setCreateTime(new Date());
+
+                affectCount = personInfoService.insert(personInfo);
+            }else{
+                personInfo.setUpdateBy(subject);
+                personInfo.setUpdateTime(new Date());
+
+                affectCount = personInfoService.update(personInfo);
+            }
 
             if (affectCount > 0) {
                 msgResult.setResult(true);
                 msgResult.setData(personInfo);
-            } else {
+            }else{
                 msgResult.setResult(false);
-                msgResult.setMessage("数据库添加失败");
+                msgResult.setMessage("数据库保存失败");
             }
         }
         catch(Exception ex){
@@ -71,9 +76,9 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="获取信息")
-    @GetMapping("edit/{id}")
-    public MessageResult<PersonInfo> edit(@PathVariable("id") String id){
+    @ApiOperation(value="获取详情信息")
+    @GetMapping("detail/{id}")
+    public MessageResult<PersonInfo> detail(@PathVariable("id") String id){
         MessageResult<PersonInfo> msgResult = new MessageResult<>();
 
         try {
@@ -97,35 +102,6 @@ public class PersonInfoController {
         return msgResult;
     }
 
-    @ApiOperation(value="更新用户")
-    @PostMapping("update")
-    public MessageResult<PersonInfo> update(@RequestBody PersonInfo personInfo,@RequestAttribute String subject){
-        MessageResult<PersonInfo> msgResult = new MessageResult<>();
-
-        try {
-            personInfo.setUpdateBy(subject);
-            personInfo.setUpdateTime(new Date());
-            
-            int affectCount = personInfoService.update(personInfo);
-
-            if (affectCount > 0) {
-                msgResult.setResult(true);
-                msgResult.setData(personInfo);
-            } else {
-                msgResult.setResult(false);
-                msgResult.setMessage("数据库更新失败");
-            }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
-
-            msgResult.setResult(false);
-            msgResult.setMessage(ex.getMessage());
-        }
-
-        return msgResult;
-    }
-
 	@ApiOperation(value="删除")
     @PostMapping("delete/{id}")
     public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
@@ -157,7 +133,6 @@ public class PersonInfoController {
         return msgResult;
     }
 
-
     @ApiOperation(value="批量删除")
     @PostMapping("batchDelete")
     public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
@@ -195,8 +170,21 @@ public class PersonInfoController {
 
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name",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"),
+            @ApiImplicitParam(name = "position4",value = "四级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position5",value = "五级位置", required = false, paramType = "form",dataType = "String")
+    })
     public MessageResult<Map> pageList(
-            String id,
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="position1",defaultValue="") String position1,
+            @RequestParam(value="position2",defaultValue="") String position2,
+            @RequestParam(value="position3",defaultValue="") String position3,
+            @RequestParam(value="position4",defaultValue="") String position4,
+            @RequestParam(value="position5",defaultValue="") String position5,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -211,8 +199,23 @@ public class PersonInfoController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("id_","asc"));
 
-        if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(position1)) {
+            searchParams.put("position1",position1);
+        }
+        if (StringUtils.isNotEmpty(position2)) {
+            searchParams.put("position2",position2);
+        }
+        if (StringUtils.isNotEmpty(position3)) {
+            searchParams.put("position3",position3);
+        }
+        if (StringUtils.isNotEmpty(position4)) {
+            searchParams.put("position4",position4);
+        }
+        if (StringUtils.isNotEmpty(position5)) {
+            searchParams.put("position5",position5);
         }
 
         Page<PersonInfo> page = personInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
@@ -222,4 +225,324 @@ public class PersonInfoController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="人脸授权")
+    @PostMapping("EnabledFace")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<PersonInfo> EnabledFace(@RequestParam(value="id",defaultValue="") String id,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if(personInfo.getFaceEnabled()){
+                personInfo.setFaceEnabled(false);
+            }else{
+                personInfo.setFaceEnabled(true);
+            }
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="刷卡授权")
+    @PostMapping("EnabledCard")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<PersonInfo> EnabledCard(@RequestParam(value="id",defaultValue="") String id,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if(personInfo.getCardEnabled()){
+                personInfo.setCardEnabled(false);
+            }else{
+                personInfo.setCardEnabled(true);
+            }
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="手机授权")
+    @PostMapping("EnabledApp")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<PersonInfo> EnabledApp(@RequestParam(value="id",defaultValue="") String id,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if(personInfo.getAppEnabled()){
+                personInfo.setAppEnabled(false);
+            }else{
+                personInfo.setAppEnabled(true);
+            }
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="访客授权")
+    @PostMapping("EnabledGuest")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<PersonInfo> EnabledGuest(@RequestParam(value="id",defaultValue="") String id,@RequestAttribute String subject){
+        MessageResult<PersonInfo> msgResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(id);
+
+            if(personInfo.getGuestEnabled()){
+                personInfo.setGuestEnabled(false);
+            }else{
+                personInfo.setGuestEnabled(true);
+            }
+            personInfo.setUpdateBy(subject);
+            personInfo.setUpdateTime(new Date());
+
+            int affectCount = personInfoService.update(personInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(personInfo);
+            }else{
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+//    @ApiOperation(value="导入企业人员")
+//    @PostMapping("importXls")
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "companyId",value = "企业ID", required = true, paramType = "form",dataType = "String"),
+//            @ApiImplicitParam(name = "uploadFile",value = "上传文件", required = true,paramType="form", dataType = "__file")
+//    })
+//    public MessageResult<String> importXls(@RequestParam(value="companyId",defaultValue="") String companyId,
+//                                           MultipartFile uploadFile,
+//                                           @RequestAttribute String subject){
+//        User user = userService.get(subject);
+//
+//        MessageResult<String> msgResult = new MessageResult<>();
+//        PersonInfo personInfo = new PersonInfo();
+//
+//        try {
+//            POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
+//            int sheetIndex = 0;
+//            Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
+//
+//            int affectCount = 0;
+//            int failCount = 0;
+//            int validateColIndex = 7;
+//
+//            for(int rowIndex=1 ; rowIndex<=sheet1.getLastRowNum(); rowIndex++){
+//                try {
+//                    String name = (String)poiUtils.getCellValue(sheetIndex,rowIndex,1);
+//                    String cardType = (String)poiUtils.getCellValue(sheetIndex,rowIndex,2);
+//                    String cardNo = (String)poiUtils.getCellValue(sheetIndex,rowIndex,3);
+//                    String sex = (String)poiUtils.getCellValue(sheetIndex,rowIndex,4);
+////                  String age = array[5].toString();
+//                    String jobName = (String)poiUtils.getCellValue(sheetIndex,rowIndex,5);
+//                    String healthStatus = (String)poiUtils.getCellValue(sheetIndex,rowIndex,6);
+//
+//                    if(StringUtils.isEmpty(name)){
+//                        break;
+//                    }
+//
+//                    Map<String, Object> searchParams = new HashMap<>();
+//                    searchParams.put("companyId", company.getId());
+//                    searchParams.put("cardNo", cardNo);
+//                    searchParams.put("delFlag", false);
+//
+//                    List<Sort> sortList = new ArrayList<>();
+//                    Page<CompanyMember> page = companyMemberService.pageSearch(searchParams, 1, 100, sortList);
+//
+//                    if (page.size() > 0) {
+//                        sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证已导入!");
+//                        failCount++;
+//                        continue;
+//                    } else {
+//                        companyMember.setId(UUID.randomUUID().toString());
+//                        if (StringUtils.isNotEmpty(company.getId())) companyMember.setCompanyId(company.getId());
+//                        if (StringUtils.isNotEmpty(name)) companyMember.setName(name);
+//
+//                        CheckIdCard cic = null;
+//
+//                        if(StringUtils.isEmpty(cardNo)){
+//                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证不能为空!");
+//                            failCount++;
+//                            continue;
+//                        }
+//                        else{
+//                            cardNo = cardNo.trim().toUpperCase();
+//                        }
+//
+//                        for(DataDictionary dd : ddList){
+//                            if(dd.getName().equals(cardType)) {
+//                                companyMember.setCardType(dd.getValue());
+//                                break;
+//                            }
+//                        }
+//
+//                        if (StringUtils.isEmpty(companyMember.getCardType())){
+//                            sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("证件类型未选择!");
+//                            failCount++;
+//                            continue;
+//                        }
+//
+//                        if (cardType.contains("身份证")) {
+//                            cic = new CheckIdCard(cardNo);
+//
+//                            if (!cic.validate()){
+//                                sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("身份证验证失败!");
+//                                failCount++;
+//
+//                                continue;
+//                            }
+//                        }
+//
+//                        companyMember.setCardNo(cardNo);
+//
+//                        List<Jobs> jobsList = jobsService.findByName(jobsName);
+//
+//                        if (jobsList.size() > 0) {
+//                            companyMember.setJobsId(jobsList.get(0).getId());
+//                        }
+//
+//                        if (StringUtils.isNotEmpty(healthStatus)) companyMember.setHealthStatus(healthStatus);
+//
+//                        companyMember.setStatus("0");
+//                        companyMember.setDelFlag(false);
+//                        companyMember.setCreateBy(principal.getName());
+//                        companyMember.setCreateTime(new Date());
+//
+//                        if (companyMemberService.insert(companyMember) > 0) {
+//                            affectCount++;
+//                        }
+//                    }
+//                }
+//                catch(Exception innerEx){
+//                    logger.error(innerEx.getMessage(),innerEx);
+//                }
+//            }
+//
+//            if (failCount>0){
+//                //有导入失败的记录
+//                msgResult.setResult(false);
+//                msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
+//
+//                //todo 只保留错误数据的sheet
+//                int rowIndex = 1;
+//
+//                while(rowIndex<= sheet1.getLastRowNum()){
+//                    Cell cell = sheet1.getRow(rowIndex).getCell(validateColIndex);
+//
+//                    if (cell==null || StringUtils.isEmpty(cell.getStringCellValue())){
+//                        sheet1.removeRow(sheet1.getRow(rowIndex));
+//
+//                        if (rowIndex<sheet1.getLastRowNum()) {
+//                            sheet1.shiftRows(rowIndex + 1, sheet1.getLastRowNum(), -1); //删除后下面行上移,则不需要移动rowIndex
+//                        }
+//                    }
+//                    else {
+//                        rowIndex++;
+//                    }
+//                }
+//
+//                //todo 将wb保存到oss
+//                ByteArrayOutputStream output = new ByteArrayOutputStream();
+//                poiUtils.getWorkbook().write(output);
+//
+//                byte[] buffer = output.toByteArray();
+//                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+//
+//                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+//
+//                //todo 返回导入失败报表下载链接
+//                msgResult.setData(downloadUrl);
+//            }
+//            else{
+//                msgResult.setResult(true);
+//                msgResult.setMessage("数据成功导入" + affectCount + "条");
+//            }
+//        }
+//        catch(Exception ex){
+//            logger.error(ex.getMessage(),ex);
+//
+//            msgResult.setResult(false);
+//            msgResult.setMessage(ex.getMessage());
+//        }
+//
+//        return msgResult;
+//    }
 }

+ 375 - 0
src/main/java/com/jpsoft/smart/modules/common/utils/POIUtils.java

@@ -0,0 +1,375 @@
+package com.jpsoft.smart.modules.common.utils;
+
+import org.apache.poi.hssf.converter.ExcelToHtmlConverter;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description:POI解析Excel获取所有数据(支持xls/xlsx)
+ *
+ * @author zhjun 2015-11-5
+ */
+public class POIUtils {
+    InputStream ins = null;
+    Workbook wb = null;
+    List<Object[]> dataList = new ArrayList<Object[]>(100);
+
+    public static void CreateBorder(CellStyle cellStyle) {
+        if (cellStyle != null) {
+            cellStyle.setBorderTop(BorderStyle.THIN);
+            cellStyle.setBorderBottom(BorderStyle.THIN);
+            cellStyle.setBorderLeft(BorderStyle.THIN);
+            cellStyle.setBorderRight(BorderStyle.THIN);
+        }
+    }
+
+    public static Cell setCellValue(Row row, int i, String value) {
+        // TODO Auto-generated method stub
+        Cell cell = row.createCell(i);
+        cell.setCellValue(value);
+
+        return cell;
+    }
+
+    public static Cell setCellValue(Row row, int i, int value) {
+        // TODO Auto-generated method stub
+        Cell cell = row.createCell(i);
+        cell.setCellValue(value);
+
+        return cell;
+    }
+
+    public static Cell setCellValue(Row row, int cellIndex, CellStyle cellStyle, Object value) {
+        Cell cell = row.createCell(cellIndex);
+        cell.setCellStyle(cellStyle);
+
+        if (value != null) {
+            if (value instanceof BigDecimal) {
+                cell.setCellValue(((BigDecimal) value).doubleValue());
+            } else if (value instanceof String) {
+                cell.setCellValue(value.toString());
+            } else if (value instanceof Integer) {
+                cell.setCellValue(Double.valueOf(value.toString()));
+            } else if (value instanceof Long) {
+                cell.setCellValue(Double.valueOf(value.toString()));
+            }
+        }
+
+        return cell;
+    }
+
+    public static String xls2html(HSSFWorkbook wb) {
+        String result = "";
+
+        try {
+            ExcelToHtmlConverter converter = new ExcelToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
+            converter.setOutputColumnHeaders(false);
+            converter.setOutputRowNumbers(false);
+
+            converter.processWorkbook(wb);
+
+            Document htmlDocument = converter.getDocument();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            DOMSource domSource = new DOMSource(htmlDocument);
+            StreamResult streamResult = new StreamResult(out);
+            TransformerFactory tf = TransformerFactory.newInstance();
+            Transformer serializer = tf.newTransformer();
+            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
+            serializer.setOutputProperty(OutputKeys.METHOD, "html");
+            serializer.transform(domSource, streamResult);
+            out.close();
+
+            result = new String(out.toByteArray(), "UTF-8");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过流读取
+     *
+     * @param ins
+     */
+    public POIUtils(InputStream ins) {
+        try {
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public Sheet getSheetAt(int sheetIndex){
+        return wb.getSheetAt(sheetIndex);
+    }
+
+    public Workbook getWorkbook(){
+        return wb;
+    }
+
+    /**
+     * 通过文件读取
+     *
+     * @param file
+     */
+    public POIUtils(File file) {
+        try {
+            ins = new FileInputStream(file);
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 通过文件路径读取
+     *
+     * @param path
+     */
+    public POIUtils(String path) {
+        try {
+            ins = new FileInputStream(path);
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 取Excel所有数据,包含header
+     *
+     * @return List<Object   [   ]>
+     */
+    public List<Object[]> getAllData(int sheetIndex) {
+        int columnNum = 0;
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        if (sheet.getRow(0) != null) {
+            columnNum = sheet.getRow(0).getLastCellNum() - sheet.getRow(0).getFirstCellNum();
+        }
+        if (columnNum > 0) {
+            for (Row row : sheet) {
+                Object[] singleRow = new Object[columnNum];
+                int n = 0;
+
+                for (int i = 0; i < columnNum; i++) {
+                    Cell cell = row.getCell(i, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                    singleRow[n] = getCellValue(cell);
+                    n++;
+                }
+
+                //在后续方法中校验
+//				if("".equals(singleRow[0])){continue;}//如果第一列为空,跳过
+
+                dataList.add(singleRow);
+            }
+        }
+        return dataList;
+    }
+
+    public List<Object[]> getAllData(int sheetIndex, int firstRowNum) {
+        int columnNum = 0;
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        if (sheet.getRow(0) != null) {
+            columnNum = sheet.getRow(firstRowNum).getLastCellNum();
+        }
+        if (columnNum > 0) {
+            for (Row row : sheet) {
+                Object[] singleRow = new Object[columnNum];
+                int n = 0;
+                for (int i = 0; i < columnNum; i++) {
+                    Cell cell = row.getCell(i, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                    singleRow[n] = getCellValue(cell);
+                    n++;
+                }
+                if ("".equals(singleRow[0])) {
+                    continue;
+                }//如果第一行为空,跳过
+                dataList.add(singleRow);
+            }
+        }
+        return dataList;
+    }
+
+    public Object getCellValue(int sheetIndex,int rowIndex,int colIndex){
+        Row row = wb.getSheetAt(sheetIndex).getRow(rowIndex);
+        Cell cell = row.getCell(colIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+
+        return getCellValue(cell);
+    }
+
+    /**
+     * 获取列的数据信息
+     *
+     * @param cell
+     * @return
+     */
+    private Object getCellValue(Cell cell) {
+        Object cellValue = null;
+        FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+
+        switch (cell.getCellType()) {
+            case BLANK:
+                cellValue = "";
+                break;
+            case BOOLEAN:
+                cellValue = Boolean.toString(cell.getBooleanCellValue());
+                break;
+            //数值
+            case NUMERIC:
+                DecimalFormat df = new DecimalFormat("0");
+                double value = cell.getNumericCellValue();
+
+                if (value > Math.floor(value)) {
+                    df = new DecimalFormat("0.00");
+                }
+
+                cellValue = df.format(value);
+                break;
+            case STRING:
+                cellValue = cell.getStringCellValue().trim();
+                break;
+            case ERROR:
+                cellValue = "";
+                break;
+            case FORMULA:
+                CellValue cv = evaluator.evaluate(cell);
+
+                if (cv.getCellType() == CellType.STRING) {
+                    cellValue = cv.getStringValue();
+                } else if (cv.getCellType() == CellType.NUMERIC) {
+                    cellValue = cv.getNumberValue();
+                } else {
+                    cellValue = cell.getCellFormula();
+                }
+
+                break;
+            default:
+                cellValue = "";
+        }
+
+        return cellValue;
+    }
+
+
+    /**
+     * 返回Excel最大行index值,实际行数要加1
+     *
+     * @return
+     */
+    public int getRowNum(int sheetIndex) {
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        return sheet.getLastRowNum();
+    }
+
+    /**
+     * 返回数据的列数
+     *
+     * @param sheetIndex
+     * @return
+     */
+    public int getColumnNum(int sheetIndex) {
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        Row row = sheet.getRow(0);
+        if (row != null && row.getLastCellNum() > 0) {
+            return row.getLastCellNum();
+        }
+        return 0;
+    }
+
+    /**
+     * 获取某一行数据
+     *
+     * @param rowIndex 计数从0开始,rowIndex为0代表header行
+     * @return
+     */
+    public Object[] getRowData(int sheetIndex, int rowIndex) {
+        Object[] dataArray = null;
+        if (rowIndex > this.getColumnNum(sheetIndex)) {
+            return dataArray;
+        } else {
+//			dataArray = new Object[this.getColumnNum(sheetIndex)];
+            return this.dataList.get(rowIndex);
+        }
+    }
+
+
+    /**
+     * 获取某一列数据
+     *
+     * @param colIndex
+     * @return
+     */
+    public Object[] getColumnData(int sheetIndex, int colIndex) {
+        Object[] dataArray = null;
+        if (colIndex > this.getColumnNum(sheetIndex)) {
+            return dataArray;
+        } else {
+            if (this.dataList != null && this.dataList.size() > 0) {
+                dataArray = new Object[this.getRowNum(sheetIndex) + 1];
+                int index = 0;
+                for (Object[] rowData : dataList) {
+                    if (rowData != null) {
+                        dataArray[index] = rowData[colIndex];
+                        index++;
+                    }
+                }
+            }
+        }
+
+        return dataArray;
+    }
+
+    public static void main(String[] args) {
+        POIUtils re = new POIUtils("D:\\fpb.xlsx");
+
+        List<Object[]> objList = re.getAllData(0);
+
+        for (int i = 0; i < objList.size(); i++) {
+            String result = "";
+            for (int j = 0; j < objList.get(i).length; j++) {
+                result += objList.get(i)[j] + "_";
+            }
+
+            System.out.println(result);
+        }
+    }
+}

+ 2 - 2
src/main/resources/mapper/base/CompanyPosition.xml

@@ -100,8 +100,8 @@ id_,company_id,position1_name,position2_name,position3_name,position4_name,posit
 			select * from base_company_position
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			<if test="searchParams.companyId != null">
+				and company_id like #{searchParams.companyId}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

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

@@ -150,6 +150,23 @@
             del_flag = 0
             <if test="searchParams.id != null">
                 and ID_ like #{searchParams.id}
+            <if test="searchParams.name != null">
+                and name_ like #{searchParams.name}
+            </if>
+            <if test="searchParams.position1 != null">
+                and position1_ like #{searchParams.position1}
+            </if>
+            <if test="searchParams.position2 != null">
+                and position2_ like #{searchParams.position2}
+            </if>
+            <if test="searchParams.position3 != null">
+                and position3_ like #{searchParams.position3}
+            </if>
+            <if test="searchParams.position4 != null">
+                and position4_ like #{searchParams.position4}
+            </if>
+            <if test="searchParams.position5 != null">
+                and position5_ like #{searchParams.position5}
             </if>
         </where>
         <foreach item="sort" collection="sortList" open="order by" separator=",">