From 7edf9a7c98fadade6cfd439083337634e7b80019 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 08 十二月 2023 18:22:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java |  139 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 138 insertions(+), 1 deletions(-)

diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
index a34d8ba..f4a56d5 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -1,9 +1,15 @@
 package com.doumee.service.system.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.utils.Constants;
+import com.doumee.dao.admin.request.LaborConfigDTO;
+import com.doumee.dao.admin.request.VisitConfigDTO;
+import com.doumee.dao.system.SystemDictMapper;
 import com.doumee.dao.system.model.SystemDict;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.doumee.core.model.PageData;
@@ -22,6 +28,7 @@
 
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 瀛楀吀鏁版嵁Service瀹炵幇
@@ -34,6 +41,8 @@
     @Autowired
     private SystemDictDataMapper systemDictDataMapper;
 
+    @Autowired
+    private SystemDictMapper systemDictMapper;
     @Override
     public Integer create(SystemDictData systemDictData) {
         systemDictDataMapper.insert(systemDictData);
@@ -91,7 +100,7 @@
         Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData);
         return systemDictDataMapper.selectList(wrapper);
     }
-  
+
     @Override
     public PageData<SystemDictDataListVO> findPage(PageWrap<QuerySystemDictDataDTO> pageWrap) {
         PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
@@ -112,4 +121,132 @@
                 .in(SystemDictData::getLabel,codes);
         return systemDictDataMapper.selectList(wrapper);
     }
+
+    @Override
+    public VisitConfigDTO getVisitConfigDTO() {
+
+        try {
+            String jasonStr = Constants.toUnderlineJSONString(new VisitConfigDTO());
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList());
+
+            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
+            systemDictQuery.lambda()
+                            .eq(SystemDict::getDeleted,Boolean.FALSE)
+                            .eq(SystemDict::getCode,Constants.VISIT_CONFIG);
+            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
+
+            if (Objects.isNull(systemDict)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀涓嶅瓨鍦�");
+            }
+            QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
+            wrapper.lambda()
+                    .eq(SystemDictData::getDictId,systemDict.getId())
+                    .in(SystemDictData::getLabel,collect);
+            List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
+            if (CollectionUtils.isEmpty(systemDictData)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀鍊间笉瀛樺湪");
+            }
+            systemDictData.forEach(s->{
+                parse.put(s.getLabel().toLowerCase(),s.getCode());
+            });
+            String s = parse.toJSONString();
+            VisitConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, VisitConfigDTO.class);
+            return miniProgrammeDTO;
+        } catch (Exception e) {
+            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+    }
+
+    @Override
+    public void updateVisitConfig(VisitConfigDTO miniProgrammeDTO) {
+        try {
+
+            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
+            systemDictQuery.lambda()
+                    .eq(SystemDict::getDeleted,Boolean.FALSE)
+                    .eq(SystemDict::getCode,Constants.VISIT_CONFIG);
+            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
+
+            if (Objects.isNull(systemDict)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀涓嶅瓨鍦�");
+            }
+            String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO);
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            parse.entrySet().forEach(s->{
+                UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
+                wrapper.lambda()
+                        .eq(SystemDictData::getDictId,systemDict.getId())
+                        .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
+                        .set(SystemDictData::getCode,s.getValue());
+                systemDictDataMapper.update(null,wrapper);
+            });
+        } catch (JsonProcessingException e) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+    }
+
+    @Override
+    public LaborConfigDTO getLaborConfigDTO() {
+
+        try {
+            String jasonStr = Constants.toUnderlineJSONString(new LaborConfigDTO());
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList());
+
+            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
+            systemDictQuery.lambda()
+                    .eq(SystemDict::getDeleted,Boolean.FALSE)
+                    .eq(SystemDict::getCode,Constants.LABOR_CONFIG);
+            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
+
+            if (Objects.isNull(systemDict)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀涓嶅瓨鍦�");
+            }
+            QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
+            wrapper.lambda()
+                    .eq(SystemDictData::getDictId,systemDict.getId())
+                    .in(SystemDictData::getLabel,collect);
+            List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
+            if (CollectionUtils.isEmpty(systemDictData)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀鍊间笉瀛樺湪");
+            }
+            systemDictData.forEach(s->{
+                parse.put(s.getLabel().toLowerCase(),s.getCode());
+            });
+            String s = parse.toJSONString();
+            LaborConfigDTO miniProgrammeDTO = Constants.toSnakeObject(s, LaborConfigDTO.class);
+            return miniProgrammeDTO;
+        } catch (Exception e) {
+            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+    }
+
+    @Override
+    public void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO) {
+        try {
+
+            QueryWrapper<SystemDict> systemDictQuery = new QueryWrapper<>();
+            systemDictQuery.lambda()
+                    .eq(SystemDict::getDeleted,Boolean.FALSE)
+                    .eq(SystemDict::getCode,Constants.VISIT_CONFIG);
+            SystemDict systemDict = systemDictMapper.selectOne(systemDictQuery);
+
+            if (Objects.isNull(systemDict)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀涓嶅瓨鍦�");
+            }
+            String jasonStr = Constants.toUnderlineJSONString(miniProgrammeDTO);
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            parse.entrySet().forEach(s->{
+                UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
+                wrapper.lambda()
+                        .eq(SystemDictData::getDictId,systemDict.getId())
+                        .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
+                        .set(SystemDictData::getCode,s.getValue());
+                systemDictDataMapper.update(null,wrapper);
+            });
+        } catch (JsonProcessingException e) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+    }
 }

--
Gitblit v1.9.3