From d87c4fcb4fcf74c12d0836fc6ba97fbcf507c62f Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 03 一月 2024 11:37:43 +0800
Subject: [PATCH] Mr.Shi
---
server/dmvisit_service/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 150 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..1a7911d 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,16 @@
package com.doumee.service.system.impl;
+import com.alibaba.fastjson.JSON;
+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.model.LoginUserInfo;
import com.doumee.core.utils.Constants;
+import com.doumee.dao.admin.request.*;
+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;
@@ -15,13 +22,19 @@
import com.doumee.service.system.SystemDictDataService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import java.util.Date;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static net.sf.jsqlparser.parser.feature.Feature.set;
+import static net.sf.jsqlparser.parser.feature.Feature.update;
/**
* 瀛楀吀鏁版嵁Service瀹炵幇
@@ -34,6 +47,8 @@
@Autowired
private SystemDictDataMapper systemDictDataMapper;
+ @Autowired
+ private SystemDictMapper systemDictMapper;
@Override
public Integer create(SystemDictData systemDictData) {
systemDictDataMapper.insert(systemDictData);
@@ -91,7 +106,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 +127,138 @@
.in(SystemDictData::getLabel,codes);
return systemDictDataMapper.selectList(wrapper);
}
+
+ @Override
+ public VisitConfigDTO getVisitConfigDTO() {
+
+ 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(),"瀛楀吀涓嶅瓨鍦�");
+ }
+ QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .eq(SystemDictData::getDictId,systemDict.getId());
+ List<SystemDictData> systemDictDatas = systemDictDataMapper.selectList(wrapper);
+ if (CollectionUtils.isEmpty(systemDictDatas)){
+ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀鍊间笉瀛樺湪");
+ }
+ VisitConfigDTO visitConfigDTO = null;
+ for (SystemDictData obj:systemDictDatas) {
+ visitConfigDTO = new VisitConfigDTO();
+ visitConfigDTO.setVisitConfigParam(JSONObject.parseObject(obj.getCode(),VisitConfigParam.class));
+ visitConfigDTO.setDescription(obj.getRemark());
+ visitConfigDTO.setTheme(obj.getLabel());
+ }
+ return visitConfigDTO;
+ } catch (Exception e) {
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+ }
+ }
+
+ @Override
+ public void updateVisitConfig(VisitConfigDTO miniProgrammeDTO) {
+
+ 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(),"瀛楀吀涓嶅瓨鍦�");
+ }
+ QuerySystemDictDataDTO dictData = new QuerySystemDictDataDTO();
+ dictData.setDictId((systemDict.getId()));
+ List<SystemDictDataListVO> systemDictDataListVOS = systemDictDataMapper.selectManageList(dictData);
+ SystemDictData systemDictData = getSystemDictDataListVO(systemDict);
+ systemDictData.setCode(JSON.toJSONString(miniProgrammeDTO.getVisitConfigParam()));
+ systemDictData.setLabel(miniProgrammeDTO.getTheme());
+ systemDictData.setRemark(miniProgrammeDTO.getDescription());
+ if(null != systemDictDataListVOS && systemDictDataListVOS.size() > 0) {
+ systemDictData.setId(systemDictDataListVOS.get(0).getId());
+ systemDictDataMapper.updateById(systemDictData);
+ }else {
+ systemDictDataMapper.insert(systemDictData);
+ }
+ }
+
+ private SystemDictData getSystemDictDataListVO(SystemDict systemDict) {
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ SystemDictData systemDictData = new SystemDictData();
+ systemDictData.setDictId(systemDict.getId());
+ systemDictData.setDisabled(true);
+ systemDictData.setSort(Constants.ONE);
+ systemDictData.setCreateTime(new Date());
+ systemDictData.setUpdateTime(new Date());
+ systemDictData.setCreateUser(loginUserInfo.getId());
+ systemDictData.setUpdateUser(loginUserInfo.getId());
+
+ return systemDictData;
+ }
+
+ @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());
+ List<SystemDictData> systemDictDatas = systemDictDataMapper.selectList(wrapper);
+ LaborConfigDTO laborConfigDTO = null;
+ for (SystemDictData obj:systemDictDatas) {
+ laborConfigDTO = new LaborConfigDTO();
+ laborConfigDTO.setLaborConfigParam(JSONObject.parseObject(obj.getCode(), LaborConfigParam.class));
+ laborConfigDTO.setDescription(obj.getRemark());
+ laborConfigDTO.setTheme(obj.getLabel());
+ }
+ return laborConfigDTO;
+ } catch (Exception e) {
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+ }
+ }
+
+ @Override
+ public void updateLaborConfigDTO(LaborConfigDTO miniProgrammeDTO) {
+ 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(),"瀛楀吀涓嶅瓨鍦�");
+ }
+ QuerySystemDictDataDTO dictData = new QuerySystemDictDataDTO();
+ dictData.setDictId((systemDict.getId()));
+ List<SystemDictDataListVO> systemDictDataListVOS = systemDictDataMapper.selectManageList(dictData);
+ SystemDictData systemDictData = getSystemDictDataListVO(systemDict);
+ systemDictData.setCode(JSON.toJSONString(miniProgrammeDTO.getLaborConfigParam()));
+ systemDictData.setLabel(miniProgrammeDTO.getTheme());
+ systemDictData.setRemark(miniProgrammeDTO.getDescription());
+ if(null != systemDictDataListVOS && systemDictDataListVOS.size() > 0) {
+ systemDictData.setId(systemDictDataListVOS.get(0).getId());
+ systemDictDataMapper.updateById(systemDictData);
+ }else {
+ systemDictDataMapper.insert(systemDictData);
+ }
+ }
}
--
Gitblit v1.9.3