diff --git a/shapelight-admin/pom.xml b/shapelight-admin/pom.xml
index a83d240..dbbb016 100644
--- a/shapelight-admin/pom.xml
+++ b/shapelight-admin/pom.xml
@@ -156,7 +156,7 @@
com.alibaba
easyexcel
- 1.1.2-beta5
+ 2.1.6
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java
index 17b0748..1d002b3 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java
@@ -2,9 +2,14 @@ package net.shapelight.modules.ten.controller;
import java.awt.image.BufferedImage;
import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
import java.util.*;
import java.util.zip.ZipOutputStream;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
+import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
@@ -37,10 +42,12 @@ import net.shapelight.modules.sys.service.SysUserRoleService;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
+import net.shapelight.modules.ten.vo.PersonExcelModel;
import net.shapelight.modules.vo.TenDeviceVo;
import net.shapelight.modules.vo.TenPersonOperationVo;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -48,6 +55,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletResponse;
/**
@@ -92,6 +100,8 @@ public class TenPersonController extends AbstractController {
private TenCellDeptService tenCellDeptService;
@Autowired
private TenLabelService tenLabelService;
+ @Autowired
+ private HttpServletResponse response;
/**
@@ -138,6 +148,81 @@ public class TenPersonController extends AbstractController {
return R.ok().put("data", page);
}
+ /**
+ * 查询住户列表
+ */
+ @GetMapping("/download")
+ @RequiresPermissions("ten:person")
+ @ApiOperation(value = "查询住户列表", response = TenPersonEntity.class)
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "limit", value = "每页条数", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "areaId", value = "区域ID", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "cellId", value = "小区ID", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "buildId", value = "楼栋ID", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "layer", value = "楼层", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "roomNumber", value = "房间名称", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "name", value = "姓名", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "gender", value = "性别", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "idCard", value = "证件号", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "personType", value = "类型", paramType = "query", dataType = "String", required = true),
+ @ApiImplicitParam(name = "faceFailure", value = "人脸提取标志", paramType = "query", dataType = "String", required = true),
+ })
+ public void downloadPersonList(@RequestParam Map params){
+ String tenantId = getUser().getTenantId() + "";
+ params.put("tenantId", tenantId + "");
+ SysUserEntity user = getUser();
+ List roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId());
+ //小区管理员
+ if (roleIdList.get(0).longValue() == Constant.ROLE_TEN_CELL) {
+ TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper().eq("user_id", user.getUserId()));
+ params.put("cellId", scope.getCellId().toString());
+ }
+ List personTypeList = new ArrayList<>();
+ List tenLabel = tenLabelService.list(new QueryWrapper()
+ .eq("tenant_id",getUser().getTenantId()));
+ personTypeList.add(Constant.PERSON_TYPE_OWNER);
+ personTypeList.add(Constant.PERSON_TYPE_MEMBER);
+ personTypeList.add(Constant.PERSON_TYPE_TENANT);
+ params.put("personTypeList",personTypeList);
+ String fileName = "person.xlsx";
+
+ List list = tenPersonService.queryPersonModel(params);
+
+ //表头样式策略
+ WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+ //设置头居中
+ headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+ //内容策略
+ WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+ //设置 水平居中
+ contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
+ //初始化表格样式
+ HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
+
+// response.setContentType("application/vnd.ms-excel;charset=utf-8");
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
+ try {
+ fileName = URLEncoder.encode("person.xlsx", "UTF-8").replaceAll("\\+", "%20");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ //响应首部 Access-Control-Expose-Headers 就是控制“暴露”的开关,它列出了哪些首部可以作为响应的一部分暴露给外部。
+ //此处设置了开放Content-Disposition,前端可获取该响应参数获取文件名称
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName);
+
+ try {
+ EasyExcelFactory.write(response.getOutputStream(),PersonExcelModel.class).sheet("人员信息").doWrite(list);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* 查询访客列表
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java
index 625a895..e3b5daa 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java
@@ -2,9 +2,11 @@ package net.shapelight.modules.ten.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import net.shapelight.modules.excel.model.PersonModel;
import net.shapelight.modules.ten.entity.TenLabelEntity;
import net.shapelight.modules.ten.entity.TenPersonEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import net.shapelight.modules.ten.vo.PersonExcelModel;
import net.shapelight.modules.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -35,6 +37,10 @@ public interface TenPersonDao {
IPage findPageAll(Page page, @Param("cellIds") List cellIds,@Param("params") Map params);
+ List findAll(@Param("cellIds") List cellIds,@Param("params") Map params);
+
+ List findExtractAll(@Param("cellIds") List cellIds, @Param("params") Map params);
+
int findAllCount(@Param("cellIds") List cellIds,@Param("params") Map params);
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java
index b898577..e4cd90e 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.modules.excel.model.PersonModel;
import net.shapelight.modules.ten.entity.*;
+import net.shapelight.modules.ten.vo.PersonExcelModel;
import net.shapelight.modules.vo.*;
import org.apache.ibatis.annotations.Param;
@@ -17,6 +18,7 @@ import java.util.Map;
public interface TenPersonService {
PageUtils queryPage(Map params);
+ List queryPersonModel(Map params);
PageUtils queryGlobalPage(Map params);
PageUtils queryVerify(Map params);
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java
index 32b9e49..a42df0c 100644
--- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java
@@ -10,6 +10,7 @@ import com.arcsoft.face.toolkit.ImageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.minio.MinioClient;
import io.minio.PutObjectOptions;
+import io.minio.errors.*;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import net.shapelight.common.config.GlobalValue;
@@ -31,8 +32,12 @@ import net.shapelight.modules.face.util.UserInfo;
import net.shapelight.modules.face.util.UserRamCache;
import net.shapelight.modules.face.util.UserRamGroup;
import net.shapelight.modules.nettyapi.service.ServerApiService;
+import net.shapelight.modules.sys.entity.SysUserEntity;
+import net.shapelight.modules.sys.service.SysUserService;
+import net.shapelight.modules.ten.controller.TenUserController;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
+import net.shapelight.modules.ten.vo.PersonExcelModel;
import net.shapelight.modules.vo.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
@@ -41,6 +46,7 @@ import org.apache.commons.lang.RandomStringUtils;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
@@ -48,6 +54,10 @@ import org.springframework.stereotype.Service;
import java.awt.image.BufferedImage;
import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.regex.Pattern;
@@ -102,7 +112,12 @@ public class TenPersonServiceImpl implements TenPersonService {
private FaceEngineService faceEngineService;
@Autowired
private TenLabelService tenLabelService;
-
+ @Autowired
+ private TenUserController tenUserController;
+ @Value("${global.minio.endpoint}")
+ private String baseImageUrl;
+ @Value("${global.minio.bucketName}")
+ private String bucketName;
@Override
public PageUtils queryPage(Map params) {
@@ -173,6 +188,117 @@ public class TenPersonServiceImpl implements TenPersonService {
}
+ public List queryPersonModel(Map params){
+ List cellIds = new ArrayList<>();
+// cellIds.add(709832651506188289L);
+
+ String areaIdStr = (String) params.get("areaId");
+ String cellIdStr = (String) params.get("cellId");
+
+ String faceFailure = (String) params.get("faceFailure");
+
+ if (areaIdStr != null && !areaIdStr.isEmpty() && (cellIdStr == null || cellIdStr.isEmpty())) {
+ Long areaId = Long.parseLong(areaIdStr);
+ //子区域
+ List allArea = tenAreaService.getSubAreaIdList(areaId);
+ //本区域
+ allArea.add(areaId);
+ List cellList = tenCellService.list(new QueryWrapper()
+ .in("area_id", allArea));
+ for (TenCellEntity cell : cellList) {
+ cellIds.add(cell.getCellId());
+ }
+ } else if (cellIdStr != null && !cellIdStr.isEmpty()) {
+ Long cellLong = Long.parseLong(cellIdStr);
+ cellIds.add(cellLong);
+ } else {
+ List cells = tenCellService.queryAll(params);
+ for (TenCellEntity cell : cells) {
+ cellIds.add(cell.getCellId());
+ }
+ }
+ if (cellIds.size() == 0) {
+ return new ArrayList<>();
+ }
+ List list = null;
+ if(faceFailure!=null && faceFailure.equals("1")){
+ list = tenPersonDao.findExtractAll(cellIds, params);
+ }else{
+ list = tenPersonDao.findAll(cellIds, params);
+ }
+ for (PersonExcelModel personEntity : list) {
+ Map sexMap = new HashMap<>();
+ sexMap.put("0","女");
+ sexMap.put("1","男");
+ personEntity.setGender(sexMap.get(personEntity.getGender()));
+ Map statusMap = new HashMap<>();
+ statusMap.put("0","正常");
+ statusMap.put("1","禁用");
+ statusMap.put("2","待审核");
+ statusMap.put("3","审核不通过");
+ statusMap.put("4","照片质量不合格");
+ statusMap.put("5","未生效");
+ statusMap.put("6","已失效");
+ personEntity.setStatus(statusMap.get(personEntity.getStatus()));
+ List extracts = tenPersonExtractService.list(
+ new QueryWrapper()
+ .eq("person_id", personEntity.getPersonId())
+ );
+ R r = tenUserController.displayFaceFlag();
+ int displayInt = (int) r.get("data");
+
+ if(displayInt == 1) {
+ try {
+ boolean fileExists = isObjectExist(personEntity.getFaceImage());
+ if(fileExists) {
+ personEntity.setUrl(new URL(baseImageUrl+"/cell/"+personEntity.getFaceImage()));
+ }
+ } catch (
+ IOException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ try {
+ boolean fileExists = isObjectExist(personEntity.getFaceModel());
+ if(fileExists) {
+ personEntity.setUrl(new URL(baseImageUrl+"/cell/"+personEntity.getFaceModel()));
+ }
+ } catch (
+ IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ //personEntity.setUrl(new URL(baseImageUrl+"/cell/"+personEntity.getFaceImage()));
+ if(personEntity.getDeptId()!=null){
+ TenCellDeptEntity dept = tenCellDeptService.getById(personEntity.getDeptId());
+
+ if(dept!=null){
+ personEntity.setDeptName(dept.getName());
+ String deptAllName = tenCellDeptService.getAllParentName(dept.getParentId());
+ personEntity.setDeptAllName(deptAllName);
+ }
+ }
+ }
+ return list;
+ }
+
+ public boolean isObjectExist(String name) {
+ if(StringUtils.isEmpty(name)) {
+ return false;
+ }
+ try {
+ minioClient.statObject(bucketName,name);
+ return true;
+ } catch (ErrorResponseException e) {
+ e.printStackTrace();
+ return false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+
@Override
public PageUtils queryVerify(Map params) {
List cellIds = new ArrayList<>();
diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/PersonExcelModel.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/PersonExcelModel.java
new file mode 100644
index 0000000..00ee74b
--- /dev/null
+++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/vo/PersonExcelModel.java
@@ -0,0 +1,61 @@
+package net.shapelight.modules.ten.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.converters.string.StringImageConverter;
+import lombok.Data;
+
+import java.net.URL;
+
+@Data
+@ContentRowHeight(100)
+@ColumnWidth(100 / 8)
+public class PersonExcelModel {
+
+ @ExcelIgnore
+ private Long personId;
+
+ @ExcelIgnore
+ private Long deptId;
+
+ @ExcelIgnore
+ private String faceImage;
+
+ @ExcelIgnore
+ private String faceModel;
+
+
+ @ExcelProperty(value = "人像图",index = 0)
+ private URL url;
+
+ @ExcelProperty(value = "姓名", index = 1)
+ private String name;
+
+ @ExcelProperty(value = "性别", index = 2)
+ private String gender;
+
+ @ExcelProperty(value = "手机号", index = 3)
+ private String mobile;
+
+ @ExcelProperty(value = "区域名称", index = 4)
+ private String areaName;
+
+ @ExcelProperty(value = "学校名称", index = 5)
+ private String cellName;
+
+ @ExcelProperty(value = "上级组织", index = 6)
+ private String deptAllName;
+
+ @ExcelProperty(value = "组织", index = 7)
+ private String deptName;
+
+ @ExcelProperty(value = "人员类型", index = 8)
+ private String labelName;
+
+ @ExcelProperty(value = "状态", index = 9)
+ private String status;
+
+
+}
diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml
index 1feb92d..d5c0510 100644
--- a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml
+++ b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml
@@ -89,6 +89,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -765,6 +787,112 @@
+ select p.*,r.layer,r.room_name from ten_person p left join ten_room r
+ on p.room_id = r.room_id where p.delete_flag = 0
+
+ and r.build_id = #{params.buildId}
+
+
+ and r.layer = #{params.layer}
+
+
+ and r.room_name like CONCAT('%', '${params.roomName}', '%')
+
+
+ and r.room_id = #{params.roomId}
+
+
+ and p.name like CONCAT('%', '${params.name}', '%')
+
+
+ and p.gender = #{params.gender}
+
+
+ and p.status = #{params.status}
+
+
+ and p.id_card like CONCAT('%', '${params.idCard}', '%')
+
+
+ and p.mobile like CONCAT('%', '${params.mobile}', '%')
+
+
+ and p.person_type = #{params.personType}
+
+
+ and p.face_failure = #{params.faceFailure}
+
+
+ and p.person_type in
+
+ #{personType}
+
+
+
+ and p.cell_id in
+
+ #{cellId}
+
+
+
+ and p.dept_id = #{params.deptId}
+
+
+ and p.label_id = #{params.labelId}
+
+ order by p.create_time desc
+
+
+
+
+
+
+