From 43a53e5a46ba45a6d35e3913fdfdd6f82a84a038 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 28 二月 2025 12:59:32 +0800
Subject: [PATCH] jtt808初始化
---
server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java | 76 +++++++++++++++++++++++++++++++++++---
1 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
index 74ee0c0..94b3265 100644
--- a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -1,5 +1,15 @@
package com.doumee.service.system.impl;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.business.web.request.LocaltionDTO;
+import com.doumee.dao.business.web.response.MiniProgrammeDTO;
+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;
@@ -11,13 +21,16 @@
import com.doumee.service.system.SystemDictDataService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.commons.lang3.StringUtils;
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.List;
-import java.util.UUID;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
import com.doumee.core.constants.Constants;
@@ -31,6 +44,8 @@
@Autowired
private SystemDictDataMapper systemDictDataMapper;
+ @Autowired
+ private SystemDictMapper systemDictMapper;
@Override
public String create(SystemDictData systemDictData) {
@@ -77,7 +92,7 @@
@Override
public SystemDictData findOne(SystemDictData systemDictData) {
- Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData);
+ Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData).last(" limit 1");
return systemDictDataMapper.selectOne(wrapper );
}
@@ -86,7 +101,7 @@
Wrapper<SystemDictData> wrapper = new QueryWrapper<>(systemDictData).orderByAsc("sort");
return systemDictDataMapper.selectList(wrapper);
}
-
+
@Override
public PageData<SystemDictDataListVO> findPage(PageWrap<QuerySystemDictDataDTO> pageWrap) {
PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
@@ -99,7 +114,56 @@
return systemDictDataMapper.selectCount(wrapper);
}
+ @Override
+ public MiniProgrammeDTO getMiniProgrammeDTO() {
+ try {
+ String jasonStr = MiniProgrammeDTO.toUnderlineJSONString(new MiniProgrammeDTO());
+ JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+ List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList());
+ QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
+ wrapper.lambda()
+ .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();
+ MiniProgrammeDTO miniProgrammeDTO = MiniProgrammeDTO.toSnakeObject(s, MiniProgrammeDTO.class);
+ return miniProgrammeDTO;
+ } catch (Exception e) {
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+ }
+ }
-
-
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+ @Override
+ public void updateMiniProgrammeDTO(MiniProgrammeDTO miniProgrammeDTO) {
+ try {
+ if(miniProgrammeDTO.getParkLatLngList()!=null){
+ try {
+ TypeReference typeReference = new TypeReference<List<LocaltionDTO>>(){};
+ List<LocaltionDTO> response = JSONObject.parseObject(miniProgrammeDTO.getParkLatLngList(), typeReference.getType());
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"杩愯惀鍖哄煙鍙傛暟瑙f瀽鏈夎锛�");
+ }
+ }
+ String jasonStr = MiniProgrammeDTO.toUnderlineJSONString(miniProgrammeDTO);
+ JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+ parse.entrySet().forEach(s->{
+// if (StringUtils.isNotBlank((String)s.getValue())){
+ UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
+ wrapper.lambda()
+ .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