TRX 1 年間 前
コミット
a88d962ba3

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoModel.java

@@ -42,7 +42,7 @@ public class DeviceInfoModel extends SuperModel {
     }
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 
     private String deviceModelStr;
 

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoParam.java

@@ -23,7 +23,7 @@ public class DeviceInfoParam extends SuperParam {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 
     @Schema(description = "网关号")
     private String gateWayId;

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoSearch.java

@@ -39,7 +39,7 @@ public class DeviceInfoSearch extends SuperSearch {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 
     @Schema(description = "网关号")
     private String gateWayId;

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductBindDeviceModel.java

@@ -44,6 +44,6 @@ public class DeviceProductBindDeviceModel extends SuperModel {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 
 }

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductBindDeviceSearch.java

@@ -30,5 +30,5 @@ public class DeviceProductBindDeviceSearch extends SuperSearch {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 }

+ 11 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/visitor/VisitorMainController.java

@@ -10,6 +10,8 @@ import com.zhongshu.card.server.core.service.visitor.VisitorMainService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -20,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.io.IOException;
+
 /**
  * 访客管理
  *
@@ -127,4 +131,11 @@ public class VisitorMainController {
     public ResultContent staticCurrentUserTotal(@RequestBody VisitorStaticParam param) {
         return this.visitorMainService.staticCurrentUserTotal(param);
     }
+    
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "exportData", method = RequestMethod.POST)
+    @Operation(summary = "导出访客数据", description = "导出访客数据")
+    public void exportData(HttpServletRequest request, HttpServletResponse response, VisitorMainSearch param) throws IOException {
+        visitorMainService.exportData(request, response, param);
+    }
 }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceInfo.java

@@ -76,7 +76,7 @@ public class DeviceInfo extends SuperMain {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 
     @Schema(description = "网关号")
     private String gateWayId;

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceProductBindDevice.java

@@ -45,5 +45,5 @@ public class DeviceProductBindDevice extends SuperMain {
     private DeviceType deviceType;
 
     @Schema(description = "设备型号")
-    private DeviceSpecType deviceModel;
+    private DeviceSpecType specType;
 }

+ 106 - 90
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/dictionary/DictionaryService.java

@@ -1,7 +1,5 @@
 package com.zhongshu.card.server.core.service.dictionary;
 
-import ch.qos.logback.core.joran.conditional.IfAction;
-import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.components.data.base.util.PageEntityUtil;
 import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
 import com.github.microservice.net.ResultContent;
@@ -14,14 +12,12 @@ import com.zhongshu.card.server.core.dao.dictionary.DictionaryItemDao;
 import com.zhongshu.card.server.core.dataConfig.DictionaryInitConfig;
 import com.zhongshu.card.server.core.domain.dictionary.Dictionary;
 import com.zhongshu.card.server.core.domain.dictionary.DictionaryItem;
-import com.zhongshu.card.server.core.domain.org.Organization;
-import com.zhongshu.card.server.core.model.dictionary.DItemChildrenResult;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.bson.types.ObjectId;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.KeysetScrollPosition;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
@@ -44,24 +40,25 @@ public class DictionaryService extends SuperService {
     @Autowired
     DictionaryInitConfig dictionaryInitConfig;
 
-    public ResultContent init(){
+    public ResultContent init() {
         return null;
     }
 
     /**
      * 添加字典
+     *
      * @param param
      * @return
      */
-    public ResultContent addDictionary(AddDictionaryParam param){
-        if (StringUtils.isNotBlank(param.getId())){
+    public ResultContent addDictionary(AddDictionaryParam param) {
+        if (StringUtils.isNotBlank(param.getId())) {
             UpdateDictionaryParam updateParam = new UpdateDictionaryParam();
             BeanUtils.copyProperties(param, updateParam);
             return updateDictionary(updateParam);
         }
 
         Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getKey());
-        if (byProjectIdAndKey != null){
+        if (byProjectIdAndKey != null) {
             return ResultContent.buildFail("字典编码已存在");
         }
 
@@ -76,27 +73,27 @@ public class DictionaryService extends SuperService {
     /**
      * 编辑字典
      */
-    public ResultContent updateDictionary(UpdateDictionaryParam param){
+    public ResultContent updateDictionary(UpdateDictionaryParam param) {
         Dictionary dictionary = dictionaryDao.findTopById(param.getId());
-        if (dictionary == null){
+        if (dictionary == null) {
             return ResultContent.buildFail("数据不存在");
         }
 
         DictionaryType type = dictionary.getType();
-        if (DictionaryType.Standard.equals(type)){//如果为标准类型
-            if (StringUtils.isNotBlank(param.getKey())){
+        if (DictionaryType.Standard.equals(type)) {//如果为标准类型
+            if (StringUtils.isNotBlank(param.getKey())) {
                 return ResultContent.buildFail("标准类型字典编码不允许修改");
             }
-            if (param.isDisabled()){
+            if (param.isDisabled()) {
                 return ResultContent.buildFail("标准类型字典不允许禁用");
             }
         }
 
         Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(dictionary.getProjectId(), param.getKey());
-        if (byProjectIdAndKey != null && !byProjectIdAndKey.getId().equals(param.getId())){
+        if (byProjectIdAndKey != null && !byProjectIdAndKey.getId().equals(param.getId())) {
             return ResultContent.buildFail("字典编码已存在");
         }
-        com.zhongshu.card.server.core.util.BeanUtils.copyProperties(param, dictionary,"id");
+        com.zhongshu.card.server.core.util.BeanUtils.copyProperties(param, dictionary, "id");
         dictionaryDao.save(dictionary);
         return ResultContent.buildSuccess();
     }
@@ -104,13 +101,13 @@ public class DictionaryService extends SuperService {
     /**
      * 删除字典
      */
-    public ResultContent deleteDictionary(String id){
+    public ResultContent deleteDictionary(String id) {
         Dictionary dictionary = dictionaryDao.findTopById(id);
-        if (dictionary == null){
+        if (dictionary == null) {
             return ResultContent.buildFail("数据不存在");
         }
-        if (DictionaryType.Standard.equals(dictionary.getType())){
-            if (dictionary.getPermission() == null || !dictionary.getPermission().contains(DictionaryPermission.delete)){
+        if (DictionaryType.Standard.equals(dictionary.getType())) {
+            if (dictionary.getPermission() == null || !dictionary.getPermission().contains(DictionaryPermission.delete)) {
                 return ResultContent.buildFail("标准字典不允许删除");
             }
         }
@@ -119,22 +116,23 @@ public class DictionaryService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    public Object page(Pageable pageable, DictionaryQueryParam param){
+    public Object page(Pageable pageable, DictionaryQueryParam param) {
         String projectId = param.getProjectId();
-        if (StringUtils.isBlank(projectId)){
+        if (StringUtils.isBlank(projectId)) {
             projectId = getCurrentProjectOid();
         }
-        if (StringUtils.isBlank(projectId)){
+        if (StringUtils.isBlank(projectId)) {
             return ResultContent.buildFail("项目id不能为空");
-        };
+        }
+        ;
 
         Page<Dictionary> page = dictionaryDao.page(pageable, param.getProjectId(), param.getName(), param.getType());
         return ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
 
-    private DictionaryModel toModel(Dictionary dictionary){
+    private DictionaryModel toModel(Dictionary dictionary) {
         DictionaryModel dictionaryModel = new DictionaryModel();
-        if (dictionary != null){
+        if (dictionary != null) {
             BeanUtils.copyProperties(dictionary, dictionaryModel);
         }
         return dictionaryModel;
@@ -143,35 +141,35 @@ public class DictionaryService extends SuperService {
     /**
      * 添加项
      */
-    public ResultContent addItem(AddDictionaryItemParam param){
+    public ResultContent addItem(AddDictionaryItemParam param) {
 
 
-        if (StringUtils.isNotBlank(param.getId())){
+        if (StringUtils.isNotBlank(param.getId())) {
             return updateItem(param);
         }
         Dictionary dictionary = dictionaryDao.findTopById(param.getDictionaryId());
-        if (dictionary == null){
+        if (dictionary == null) {
             return ResultContent.buildFail("字典不存在");
         }
 
-        if (dictionary.getType().equals(DictionaryType.Standard)){
+        if (dictionary.getType().equals(DictionaryType.Standard)) {
             List<DictionaryPermission> permission = dictionary.getPermission();
-            if (permission==null || !permission.contains(DictionaryPermission.add)){
+            if (permission == null || !permission.contains(DictionaryPermission.add)) {
                 return ResultContent.buildFail("该字典不允许添加项");
             }
         }
 
-        if (param.getParentId()!=null){
+        if (param.getParentId() != null) {
             DictionaryItem parentItem = dictionaryItemDao.findTopById(param.getParentId());
-            if (parentItem != null && parentItem.getType().equals(DictionaryType.Standard)){
-                if (parentItem.getPermission() == null || !parentItem.getPermission().contains(DictionaryPermission.add)){
+            if (parentItem != null && parentItem.getType().equals(DictionaryType.Standard)) {
+                if (parentItem.getPermission() == null || !parentItem.getPermission().contains(DictionaryPermission.add)) {
                     return ResultContent.buildFail("该项不允许添加下级");
                 }
             }
         }
 
         DictionaryItem updateItem = dictionaryItemDao.findTopByDictionary_IdAndKey(param.getDictionaryId(), param.getKey());
-        if (updateItem != null && !updateItem.getId().equals(param.getId())){
+        if (updateItem != null && !updateItem.getId().equals(param.getId())) {
             return ResultContent.buildFail("项编码已存在");
         }
 
@@ -184,7 +182,7 @@ public class DictionaryService extends SuperService {
         dictionaryItem.setIdString(id);
         dictionaryItem.setCreateTime(System.currentTimeMillis());
 
-        if (StringUtils.isEmpty(param.getParentId())){
+        if (StringUtils.isEmpty(param.getParentId())) {
             dictionaryItem.setParentId(null);
         }
         dictionaryItemDao.save(dictionaryItem);
@@ -194,23 +192,23 @@ public class DictionaryService extends SuperService {
     /**
      * 编辑项
      */
-    public ResultContent updateItem(AddDictionaryItemParam param){
-        if (StringUtils.isBlank(param.getId())){
+    public ResultContent updateItem(AddDictionaryItemParam param) {
+        if (StringUtils.isBlank(param.getId())) {
             return ResultContent.buildFail("id不能为null");
         }
         DictionaryItem dictionaryItem = dictionaryItemDao.findTopById(param.getId());
-        if (dictionaryItem == null){
+        if (dictionaryItem == null) {
             return ResultContent.buildFail("数据不存在");
         }
 
-        if (dictionaryItem.getType().equals(DictionaryType.Standard)){//标准
-            if (StringUtils.isNotBlank(param.getKey())){
+        if (dictionaryItem.getType().equals(DictionaryType.Standard)) {//标准
+            if (StringUtils.isNotBlank(param.getKey())) {
                 return ResultContent.buildFail("标准字典的项编码不允许修改");
             }
         }
 
         DictionaryItem updateItem = dictionaryItemDao.findTopByDictionary_IdAndKey(param.getDictionaryId(), param.getKey());
-        if (updateItem != null && !updateItem.getId().equals(param.getId())){
+        if (updateItem != null && !updateItem.getId().equals(param.getId())) {
             return ResultContent.buildFail("项编码已存在");
         }
 
@@ -222,13 +220,13 @@ public class DictionaryService extends SuperService {
     /**
      * 删除项
      */
-    public ResultContent deleteItem(String id){
+    public ResultContent deleteItem(String id) {
         DictionaryItem dictionaryItem = dictionaryItemDao.findTopById(id);
-        if (dictionaryItem == null){
+        if (dictionaryItem == null) {
             return ResultContent.buildFail("数据不存在");
         }
-        if (DictionaryType.Standard.equals(dictionaryItem.getType())){
-            if (dictionaryItem.getPermission() == null || dictionaryItem.getPermission().contains(DictionaryPermission.delete)){
+        if (DictionaryType.Standard.equals(dictionaryItem.getType())) {
+            if (dictionaryItem.getPermission() == null || dictionaryItem.getPermission().contains(DictionaryPermission.delete)) {
                 return ResultContent.buildFail("标准字典的项不允许删除");
             }
         }
@@ -236,7 +234,7 @@ public class DictionaryService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    public Object pageItem(Pageable pageable, DictionaryItemQueryParam param){
+    public Object pageItem(Pageable pageable, DictionaryItemQueryParam param) {
         Page<DictionaryItem> page = dictionaryItemDao.page(pageable, param.getDictionaryId(), param.getName(), param.getParentId());
         Page<DictionaryItemModel> pageModel = PageEntityUtil.concurrent2PageModel(page, it -> {
             return toItemModel(it);
@@ -244,8 +242,8 @@ public class DictionaryService extends SuperService {
 
         List<DictionaryItemModel> dItemChildrenResults = dictionaryItemDao.deepAggregate(param.getDictionaryId(), pageModel.getContent().stream().map(DictionaryItemModel::getKey).toList());
         List<DictionaryItemModel> ret = new ArrayList<>();
-        dItemChildrenResults.forEach(it->{
-            if (it.getChildren()!=null && it.getChildren().size() > 0){
+        dItemChildrenResults.forEach(it -> {
+            if (it.getChildren() != null && it.getChildren().size() > 0) {
                 ret.addAll(it.getChildren());
             }
             it.setChildren(new ArrayList<>());
@@ -271,6 +269,7 @@ public class DictionaryService extends SuperService {
         }
         return root;
     }
+
     // 递归构建子树
     private static void buildSubTree(Map<String, DictionaryItemModel> itemMap, DictionaryItemModel parent) {
         // 遍历所有节点,查找当前parent的子节点
@@ -284,9 +283,9 @@ public class DictionaryService extends SuperService {
         }
     }
 
-    private DictionaryItemModel toItemModel(DictionaryItem dictionaryItem){
+    private DictionaryItemModel toItemModel(DictionaryItem dictionaryItem) {
         DictionaryItemModel dictionaryItemModel = new DictionaryItemModel();
-        if (dictionaryItem != null){
+        if (dictionaryItem != null) {
             BeanUtils.copyProperties(dictionaryItem, dictionaryItemModel);
             dictionaryItemModel.setDictionaryId(dictionaryItem.getDictionary().getId());
         }
@@ -295,20 +294,22 @@ public class DictionaryService extends SuperService {
 
     /**
      * 根据字典编码获取字典
+     *
      * @param param
      * @return
      */
-    public ResultContent listDictionary(ListDictionaryParam param){
+    public ResultContent listDictionary(ListDictionaryParam param) {
 
         String projectId = param.getProjectId();
-        if (StringUtils.isBlank(projectId)){
+        if (StringUtils.isBlank(projectId)) {
             projectId = getCurrentProjectOid();
         }
-        if (StringUtils.isBlank(projectId)){
+        if (StringUtils.isBlank(projectId)) {
             return ResultContent.buildFail("项目id不能为空");
-        };
+        }
+        ;
 
-        if (param.getKeys()==null || param.getKeys().isEmpty()){
+        if (param.getKeys() == null || param.getKeys().isEmpty()) {
             return ResultContent.buildFail("字典编码不能为null或空");
         }
 
@@ -322,48 +323,49 @@ public class DictionaryService extends SuperService {
 
     /**
      * 根据项编码获取项
+     *
      * @param param
      * @return
      */
-    public ResultContent listItem(ListDictionaryParam param){
+    public ResultContent listItem(ListDictionaryParam param) {
 
-        if (StringUtils.isBlank(param.getDictionaryKey())){
+        if (StringUtils.isBlank(param.getDictionaryKey())) {
             return ResultContent.buildFail("字典编码不能为空");
         }
 
 
         Dictionary dictionary = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getDictionaryKey());
-        if (dictionary == null){
+        if (dictionary == null) {
             return ResultContent.buildFail("字典不存在");
         }
 
         List<DictionaryItem> dictionaryItemList = new ArrayList<>();
 
-        if (param.getKeys()==null || param.getKeys().isEmpty()){
+        if (param.getKeys() == null || param.getKeys().isEmpty()) {
             dictionaryItemList = dictionaryItemDao.findByDictionary_Id(dictionary.getId());
-        }else {
+        } else {
             dictionaryItemList = dictionaryItemDao.findTopByDictionary_IdAndKeyIn(dictionary.getId(), param.getKeys());
         }
         return ResultContent.buildContent(dictionaryItemList.stream().map(this::toItemModel).toList());
     }
 
-    public Object deepTreeItem(String projectId, String dictionaryKey, String dictionaryId){
-        if (StringUtils.isBlank(dictionaryKey) && StringUtils.isBlank(dictionaryId)){
+    public Object deepTreeItem(String projectId, String dictionaryKey, String dictionaryId) {
+        if (StringUtils.isBlank(dictionaryKey) && StringUtils.isBlank(dictionaryId)) {
             return ResultContent.buildFail("字典编码和字典id不能为空");
         }
 
         Dictionary dictionary = null;
 
-        if (StringUtils.isNotBlank(dictionaryId)){
+        if (StringUtils.isNotBlank(dictionaryId)) {
             dictionary = dictionaryDao.findTopById(dictionaryId);
-        }else if (StringUtils.isNotBlank(dictionaryKey)){
+        } else if (StringUtils.isNotBlank(dictionaryKey)) {
             dictionary = dictionaryDao.findTopByProjectIdAndKey(projectId, dictionaryKey);
         }
 
-        if (dictionary == null){
+        if (dictionary == null) {
             return ResultContent.buildFail("字典不存在");
         }
-        if (dictionary.isDisabled()){
+        if (dictionary.isDisabled()) {
             return ResultContent.buildFail("字典已被禁用");
         }
 
@@ -373,9 +375,9 @@ public class DictionaryService extends SuperService {
         return ResultContent.buildContent(buildTree(modelList, null));
     }
 
-    private List<DictionaryItemModel> buildTree(List<DictionaryItemModel> list, String parentId){
+    private List<DictionaryItemModel> buildTree(List<DictionaryItemModel> list, String parentId) {
         Map<String, DictionaryItemModel> itemMap = new HashMap<>();
-        itemMap = list.stream().collect(Collectors.toMap(DictionaryItemModel::getId, it->it));
+        itemMap = list.stream().collect(Collectors.toMap(DictionaryItemModel::getId, it -> it));
 
         List<DictionaryItemModel> rootItems = new ArrayList<>();
 
@@ -392,7 +394,7 @@ public class DictionaryService extends SuperService {
 //            }
 //        }
 
-        if (StringUtils.isNotBlank(parentId)){
+        if (StringUtils.isNotBlank(parentId)) {
             for (DictionaryItemModel item : list) {
                 if (item.getId().equals(parentId)) {
                     // 没有父节点的项是根节点
@@ -405,7 +407,7 @@ public class DictionaryService extends SuperService {
                     }
                 }
             }
-        }else {
+        } else {
             for (DictionaryItemModel item : list) {
                 if (item.getParentId() == null || item.getParentId().isEmpty()) {
                     // 没有父节点的项是根节点
@@ -425,26 +427,26 @@ public class DictionaryService extends SuperService {
     /**
      * 更新检查
      */
-    public ResultContent<DictionaryUpdateStatus> updateCheck(String projectId){
-        if (StringUtils.isBlank(projectId)){
+    public ResultContent<DictionaryUpdateStatus> updateCheck(String projectId) {
+        if (StringUtils.isBlank(projectId)) {
             projectId = getCurrentProjectOid();
         }
 
-        if (StringUtils.isBlank(projectId)){
+        if (StringUtils.isBlank(projectId)) {
             return ResultContent.buildFail("项目id不能未空");
         }
         return ResultContent.buildContent(getUpdateStatus(projectId));
     }
 
 
-    public DictionaryUpdateStatus getUpdateStatus(String projectId){
+    public DictionaryUpdateStatus getUpdateStatus(String projectId) {
         List<DictionaryInitConfig.Dictionary> initDicList = dictionaryInitConfig.getDictionaryList();
         List<String> initDictKeys = new ArrayList<>();
         List<String> initItemKeys = new ArrayList<>();
         getConfigKey(initDicList, initDictKeys, initItemKeys);
 
         List<Dictionary> dic = dictionaryDao.findByProjectId(projectId);
-        if (dic.isEmpty()){//未初始化
+        if (dic.isEmpty()) {//未初始化
             return DictionaryUpdateStatus.NoInit;
         }
         List<String> dictKeys = new ArrayList<>(dic.stream().map(Dictionary::getKey).toList());
@@ -452,27 +454,27 @@ public class DictionaryService extends SuperService {
         List<DictionaryItem> item = dictionaryItemDao.findByDictionary_IdIn(dic.stream().map(SuperEntity::getId).toList());
         List<String> itemKeys = item.stream().map(DictionaryItem::getKey).toList();
 
-        if (initDictKeys.size() != dictKeys.size() || initItemKeys != itemKeys){//需要更新
+        if (initDictKeys.size() != dictKeys.size() || initItemKeys != itemKeys) {//需要更新
             return DictionaryUpdateStatus.Update;
         }
         //无需更新
         return DictionaryUpdateStatus.LastVersion;
     }
 
-    private void getConfigKey(List<DictionaryInitConfig.Dictionary> dictionaryList, List<String> dictKeys, List<String> itemKeys){
+    private void getConfigKey(List<DictionaryInitConfig.Dictionary> dictionaryList, List<String> dictKeys, List<String> itemKeys) {
 
         for (DictionaryInitConfig.Dictionary dictionary : dictionaryList) {
             dictKeys.add(dictionary.getKey());
-            if (dictionary.getItem() != null && !dictionary.getItem().isEmpty()){
+            if (dictionary.getItem() != null && !dictionary.getItem().isEmpty()) {
                 getConfigItemKey(dictionary.getItem(), itemKeys);
             }
         }
     }
 
-    private void getConfigItemKey(List<DictionaryInitConfig.Dictionary> dictionaryList, List<String> keys){
+    private void getConfigItemKey(List<DictionaryInitConfig.Dictionary> dictionaryList, List<String> keys) {
         for (DictionaryInitConfig.Dictionary dictionary : dictionaryList) {
             keys.add(dictionary.getKey());
-            if (dictionary.getItem() != null && !dictionary.getItem().isEmpty()){
+            if (dictionary.getItem() != null && !dictionary.getItem().isEmpty()) {
                 getConfigItemKey(dictionary.getItem(), keys);
             }
         }
@@ -480,12 +482,13 @@ public class DictionaryService extends SuperService {
 
     /**
      * 更新标签字典初始化数据
+     *
      * @return
      */
-    public ResultContent updateInit(String projectId, boolean coverName, boolean coverCustomize){
+    public ResultContent updateInit(String projectId, boolean coverName, boolean coverCustomize) {
         DictionaryUpdateStatus updateStatus = getUpdateStatus(projectId);
 
-        if (updateStatus.equals(DictionaryUpdateStatus.LastVersion)){
+        if (updateStatus.equals(DictionaryUpdateStatus.LastVersion)) {
             return ResultContent.buildFail("已是最新版本,无需修复或更新");
         }
         //TODO 更新至最新版本
@@ -497,7 +500,7 @@ public class DictionaryService extends SuperService {
 
         List<DictionaryType> typeList = new ArrayList<>(List.of(DictionaryType.Standard));
 
-        if (coverCustomize){
+        if (coverCustomize) {
             typeList.add(DictionaryType.Customize);
         }
 
@@ -515,12 +518,12 @@ public class DictionaryService extends SuperService {
 
 
     public void updateInitDictionary(String projectId, List<DictionaryInitConfig.Dictionary> dictionaryList, boolean coverName, List<DictionaryType> typeList) {
-        for(DictionaryInitConfig.Dictionary dict : dictionaryList){
+        for (DictionaryInitConfig.Dictionary dict : dictionaryList) {
             Dictionary dictionary = syncDictionary(projectId, dict, coverName);
             if (dict.getItem() != null) {
                 List<String> itemKeys = dict.getItem().stream().map(DictionaryInitConfig.Dictionary::getKey).toList();
                 dictionaryItemDao.deleteByDictionary_IdAndKeyNotInAndTypeIn(dictionary.getId(), itemKeys, typeList);
-                for (DictionaryInitConfig.Dictionary item : dict.getItem()){
+                for (DictionaryInitConfig.Dictionary item : dict.getItem()) {
                     syncDictionaryItem(item, null, dictionary, coverName);
                 }
             }
@@ -537,7 +540,7 @@ public class DictionaryService extends SuperService {
             dictionary.setDisabled(false);
             dictionary.setId(new ObjectId().toHexString());
             dictionaryDao.save(dictionary);
-        }else if (coverName){
+        } else if (coverName) {
             dictionary.setName(dict.getName());
             dictionary.setDescription(dict.getDescription());
             dictionaryDao.save(dictionary);
@@ -562,19 +565,32 @@ public class DictionaryService extends SuperService {
             item.setCreateTime(System.currentTimeMillis());
             item.setDisable(false);
             dictionaryItemDao.save(item);
-        }else if (coverName){
+        } else if (coverName) {
             item.setName(dict.getName());
             item.setDescription(dict.getDescription());
 
         }
 
-        if (dict.getItem() !=null && !dict.getItem().isEmpty()){
-            for (DictionaryInitConfig.Dictionary children: dict.getItem()){
+        if (dict.getItem() != null && !dict.getItem().isEmpty()) {
+            for (DictionaryInitConfig.Dictionary children : dict.getItem()) {
                 syncDictionaryItem(children, item, dictionary, coverName);
             }
         }
     }
 
+    public String queryItemName(String projectOid, String visitorType, String key) {
+        if (StringUtils.isNotEmpty(visitorType) && StringUtils.isNotEmpty(projectOid)) {
+            Dictionary dictionary = dictionaryDao.findTopByProjectIdAndKey(projectOid, visitorType);
+            if (ObjectUtils.isNotEmpty(dictionary)) {
+                DictionaryItem item = dictionaryItemDao.findTopByDictionary_IdAndKey(dictionary.getId(), key);
+                if (item != null) {
+                    return item.getName();
+                }
+            }
+        }
+        return "";
+    }
+
 //    /**
 //     * 字典项向下查询
 //     */

+ 92 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/visitor/VisitorMainService.java

@@ -3,6 +3,7 @@ package com.zhongshu.card.server.core.service.visitor;
 import com.github.microservice.auth.client.model.UserFaceUploadModel;
 import com.github.microservice.auth.client.service.UserFaceService;
 import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.core.util.bean.BeanUtil;
 import com.github.microservice.models.gateDoor.use.DeviceUseParam;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
@@ -24,14 +25,20 @@ import com.zhongshu.card.server.core.domain.visitor.VisitorMain;
 import com.zhongshu.card.server.core.domain.visitor.VisitorSetting;
 import com.zhongshu.card.server.core.service.base.CommonService;
 import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
+import com.zhongshu.card.server.core.service.dictionary.DictionaryService;
 import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
 import com.zhongshu.card.server.core.service.permissVerify.Device2UseUsableService;
 import com.zhongshu.card.server.core.service.permissVerify.SuperPermissService;
 import com.zhongshu.card.server.core.service.projectAbout.OrgUserFaceService;
 import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
 import com.zhongshu.card.server.core.util.CommonUtil;
+import com.zhongshu.card.server.core.util.ExcelUtils;
 import com.zhongshu.card.server.core.util.TempUserUtil;
 import com.zhongshu.card.server.core.util.ValidateUtils;
+import com.zhongshu.card.server.core.util.excel.CommonExeclParam;
+import com.zhongshu.card.server.core.util.excel.CommonExeclTd;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -41,9 +48,12 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -87,6 +97,9 @@ public class VisitorMainService extends SuperPermissService {
     @Autowired
     private OrgUserFaceService orgUserFaceService;
 
+    @Autowired
+    private DictionaryService dictionaryService;
+
     /**
      * 保存访客申请
      *
@@ -556,6 +569,85 @@ public class VisitorMainService extends SuperPermissService {
         }
     }
 
+    public void exportData(HttpServletRequest request, HttpServletResponse response, VisitorMainSearch param) throws IOException {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        Pageable pageable = PageRequest.of(0, Integer.MAX_VALUE);
+        Page<VisitorMain> page = visitorMainDao.page(pageable, param);
+        List<VisitorMain> list = page.getContent();
+        List<Map<String, Object>> maps = new ArrayList<>();
+        if (ObjectUtils.isNotEmpty(list)) {
+            maps = list.stream().map(it -> {
+                Map<String, Object> map = BeanUtil.bean2Map(it);
+                String visitorTypeName = dictionaryService.queryItemName(it.getProjectOid(), "visitorType", it.getVisitorType());
+                map.put("visitorTypeName", visitorTypeName);
+                String finalStateStr = "";
+                if (it.getFinalState() != null) {
+                    finalStateStr = it.getFinalState().getRemark();
+                }
+                map.put("finalStateStr", finalStateStr);
+
+                String firstVisitTimeStr = "";
+                if (!CommonUtil.longIsEmpty(it.getFirstVisitTime())) {
+                    firstVisitTimeStr = DateUtils.paresTime(it.getFirstVisitTime(), DateUtils.FORMAT_LONG);
+                }
+                map.put("firstVisitTimeStr", firstVisitTimeStr);
+
+                String startTimeStr = "";
+                if (!CommonUtil.longIsEmpty(it.getStartTime())) {
+                    startTimeStr = DateUtils.paresTime(it.getStartTime(), DateUtils.FORMAT_LONG);
+                }
+                map.put("startTimeStr", startTimeStr);
+
+                String endTimeStr = "";
+                if (!CommonUtil.longIsEmpty(it.getEndTime())) {
+                    endTimeStr = DateUtils.paresTime(it.getEndTime(), DateUtils.FORMAT_LONG);
+                }
+                map.put("endTimeStr", endTimeStr);
+
+                UserAccount visitorUserAccount = it.getVisitorUserAccount();
+                String visitorUserName = "";
+                String visitorUserPhone = "";
+                if (ObjectUtils.isNotEmpty(visitorUserAccount)) {
+                    visitorUserName = visitorUserAccount.getName();
+                    visitorUserPhone = visitorUserAccount.getPhone();
+                }
+                map.put("visitorUserName", visitorUserName);
+                map.put("visitorUserPhone", visitorUserPhone);
+
+                String applyTypeStr = "";
+                if (it.getApplyType() != null) {
+                    applyTypeStr = it.getApplyType().getRemark();
+                }
+                map.put("applyTypeStr", applyTypeStr);
+                return map;
+            }).collect(Collectors.toUnmodifiableList());
+        }
+
+        CommonExeclParam execlParam = new CommonExeclParam();
+        execlParam.setTitle(String.format("访客列表"));
+        execlParam.setStartRow(2);
+        execlParam.setDatas(maps);
+
+        List<CommonExeclTd> tds = new ArrayList<>();
+        tds.add(CommonExeclTd.build("访客姓名", "name"));
+        tds.add(CommonExeclTd.build("访客手机", "phone"));
+        tds.add(CommonExeclTd.build("访客类型", "visitorTypeName"));
+        tds.add(CommonExeclTd.build("审核状态", "finalStateStr"));
+        tds.add(CommonExeclTd.build("实际到访时间", "firstVisitTime"));
+
+        tds.add(CommonExeclTd.build("身份证号码", "cardNumber"));
+        tds.add(CommonExeclTd.build("预约时间", "startTimeStr"));
+        tds.add(CommonExeclTd.build("结束时间", "endTimeStr"));
+
+        tds.add(CommonExeclTd.build("被访人", "visitorUserName"));
+        tds.add(CommonExeclTd.build("被访人手机号", "visitorUserPhone"));
+        tds.add(CommonExeclTd.build("预约类型", "applyTypeStr"));
+        tds.add(CommonExeclTd.build("车牌号", "carNo"));
+
+        execlParam.setTds(tds);
+        ExcelUtils.commonExecuteExcel(request, response, execlParam);
+    }
+
     public VisitorMainModel toDesenModel(VisitorMain entity) {
         VisitorMainModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {