24282 1 жил өмнө
parent
commit
9e6ef664d0

+ 40 - 0
hx-area/src/main/java/com/fjhx/area/controller/CustomizeAreaController.java

@@ -0,0 +1,40 @@
+package com.fjhx.area.controller;
+
+import com.fjhx.area.entity.dto.AreaInfoSelectDto;
+import com.fjhx.area.entity.po.AreaInfo;
+import com.fjhx.area.entity.po.CustomizeArea;
+import com.fjhx.area.service.AreaInfoService;
+import com.fjhx.area.service.CustomizeAreaService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * 自定义地区表 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-05-15
+ */
+@RestController
+@RequestMapping("/customizeArea")
+public class CustomizeAreaController {
+
+    @Autowired
+    private CustomizeAreaService customizeAreaService;
+
+    /**
+     * 国家城市表列表
+     */
+    @PostMapping("/list")
+    public List<CustomizeArea> list(@RequestBody AreaInfoSelectDto dto) {
+        return customizeAreaService.getList(dto);
+    }
+
+}

+ 41 - 0
hx-area/src/main/java/com/fjhx/area/entity/po/CustomizeArea.java

@@ -0,0 +1,41 @@
+package com.fjhx.area.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BaseIdPo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 自定义地区表
+ * </p>
+ *
+ * @author
+ * @since 2023-05-15
+ */
+@Getter
+@Setter
+@TableName("customize_area")
+public class CustomizeArea extends BaseIdPo {
+
+    /**
+     * 地区名称
+     */
+    private String name;
+
+    /**
+     * 地区中文名称
+     */
+    private String chineseName;
+
+    /**
+     * 父级节点
+     */
+    private Long parentId;
+
+    /**
+     * 层级 1国家 2省份/州 3市区
+     */
+    private Integer levelCode;
+    
+}

+ 17 - 0
hx-area/src/main/java/com/fjhx/area/mapper/CustomizeAreaMapper.java

@@ -0,0 +1,17 @@
+package com.fjhx.area.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.area.entity.po.CustomizeArea;
+
+
+/**
+ * <p>
+ * 自定义地区表 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-05-15
+ */
+public interface CustomizeAreaMapper extends BaseMapper<CustomizeArea> {
+
+}

+ 29 - 0
hx-area/src/main/java/com/fjhx/area/service/CustomizeAreaService.java

@@ -0,0 +1,29 @@
+package com.fjhx.area.service;
+
+import com.fjhx.area.entity.dto.AreaInfoSelectDto;
+import com.fjhx.area.entity.po.CustomizeArea;
+import com.ruoyi.common.core.service.BaseService;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * <p>
+ * 自定义地区表 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-05-15
+ */
+public interface CustomizeAreaService extends BaseService<CustomizeArea> {
+
+    void setAreaId(List<? extends SetCustomizeAreaId> setAreaIdList);
+
+    void setAreaName(List<? extends SetCustomizeAreaName> setAreaNameList);
+
+    Map<Long, String> getAreaMapByIds(List<Long> idList);
+
+    List<CustomizeArea> getList(AreaInfoSelectDto dto);
+
+}

+ 1 - 0
hx-area/src/main/java/com/fjhx/area/service/ISetAreaName.java

@@ -1,5 +1,6 @@
 package com.fjhx.area.service;
 
+@Deprecated
 public interface ISetAreaName {
 
     /**

+ 40 - 0
hx-area/src/main/java/com/fjhx/area/service/SetCustomizeAreaId.java

@@ -0,0 +1,40 @@
+package com.fjhx.area.service;
+
+public interface SetCustomizeAreaId {
+
+    /**
+     * 赋值省id
+     */
+    void setProvinceId(Long provinceId);
+
+    /**
+     * 赋值市id
+     */
+    void setCityId(Long cityId);
+
+    /**
+     * 获取国家id
+     */
+    Long getCountryId();
+
+    /**
+     * 获取省/州id
+     */
+    Long getProvinceId();
+
+    /**
+     * 获取市id
+     */
+    Long getCityId();
+
+    /**
+     * 获取省/州名称
+     */
+    String getProvinceName();
+
+    /**
+     * 获取市名称
+     */
+    String getCityName();
+
+}

+ 47 - 0
hx-area/src/main/java/com/fjhx/area/service/SetCustomizeAreaName.java

@@ -0,0 +1,47 @@
+package com.fjhx.area.service;
+
+// 添加字段
+//
+// /**
+//  * 省/州名称
+//  */
+// private String provinceName;
+//
+// /**
+//  * 市名称
+//  */
+// private String cityName;
+//
+public interface SetCustomizeAreaName {
+
+    /**
+     * 获取国家id
+     */
+    Long getCountryId();
+
+    /**
+     * 获取省id
+     */
+    Long getProvinceId();
+
+    /**
+     * 市id
+     */
+    Long getCityId();
+
+    /**
+     * 赋值国家名称
+     */
+    void setCountryName(String countryName);
+
+    /**
+     * 赋值省名称
+     */
+    void setProvinceName(String provinceName);
+
+    /**
+     * 赋值市id
+     */
+    void setCityName(String cityName);
+
+}

+ 152 - 0
hx-area/src/main/java/com/fjhx/area/service/impl/CustomizeAreaServiceImpl.java

@@ -0,0 +1,152 @@
+package com.fjhx.area.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.area.entity.dto.AreaInfoSelectDto;
+import com.fjhx.area.entity.po.CustomizeArea;
+import com.fjhx.area.mapper.CustomizeAreaMapper;
+import com.fjhx.area.service.CustomizeAreaService;
+import com.fjhx.area.service.SetCustomizeAreaId;
+import com.fjhx.area.service.SetCustomizeAreaName;
+import com.ruoyi.common.constant.BaseSourceConstant;
+import org.springframework.stereotype.Service;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+
+/**
+ * <p>
+ * 自定义地区表 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-05-15
+ */
+@Service
+public class CustomizeAreaServiceImpl extends ServiceImpl<CustomizeAreaMapper, CustomizeArea> implements CustomizeAreaService {
+
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public void setAreaId(List<? extends SetCustomizeAreaId> setAreaIdList) {
+
+        for (SetCustomizeAreaId item : setAreaIdList) {
+
+            // 国家id
+            Long countryId = item.getCountryId();
+
+            // 省/州 id
+            if (item.getProvinceId() == null) {
+
+                // 省名称
+                String provinceName = item.getProvinceName();
+
+                CustomizeArea customizeArea = getOne(q -> q
+                        .eq(CustomizeArea::getParentId, countryId)
+                        .eq(CustomizeArea::getName, provinceName));
+
+                if (customizeArea == null) {
+                    customizeArea = new CustomizeArea();
+                    customizeArea.setName(provinceName);
+                    customizeArea.setChineseName(provinceName);
+                    customizeArea.setLevelCode(2);
+                    customizeArea.setParentId(countryId);
+                    save(customizeArea);
+                }
+
+                item.setProvinceId(customizeArea.getId());
+            }
+
+            // 市id
+            if (item.getCityId() != null) {
+
+                // 市名称
+                String cityName = item.getCityName();
+
+                CustomizeArea customizeArea = getOne(q -> q
+                        .eq(CustomizeArea::getParentId, item.getProvinceId())
+                        .eq(CustomizeArea::getName, cityName));
+
+                if (customizeArea == null) {
+                    customizeArea = new CustomizeArea();
+                    customizeArea.setName(cityName);
+                    customizeArea.setChineseName(cityName);
+                    customizeArea.setLevelCode(3);
+                    customizeArea.setParentId(item.getProvinceId());
+                    save(customizeArea);
+                }
+
+                item.setCityId(customizeArea.getId());
+            }
+
+        }
+
+    }
+
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public void setAreaName(List<? extends SetCustomizeAreaName> areaList) {
+        Set<Long> areaIdList = new HashSet<>();
+
+        for (SetCustomizeAreaName item : areaList) {
+            if (ObjectUtil.isNotEmpty(item.getCountryId())) {
+                areaIdList.add(item.getCountryId());
+            }
+            if (ObjectUtil.isNotEmpty(item.getProvinceId())) {
+                areaIdList.add(item.getProvinceId());
+            }
+            if (ObjectUtil.isNotEmpty(item.getCityId())) {
+                areaIdList.add(item.getCityId());
+            }
+        }
+
+        if (areaIdList.size() == 0) {
+            return;
+        }
+
+        // 地区
+        List<CustomizeArea> areaInfoList = listByIds(areaIdList);
+
+        Map<Long, CustomizeArea> areaInfoMap = areaInfoList.stream().collect(Collectors.toMap(CustomizeArea::getId, item -> item));
+
+        for (SetCustomizeAreaName item : areaList) {
+            if (ObjectUtil.isNotEmpty(item.getCountryId())) {
+                CustomizeArea customizeArea = areaInfoMap.get(item.getCountryId());
+                if (customizeArea != null) {
+                    item.setCountryName(customizeArea.getName());
+                }
+            }
+            if (ObjectUtil.isNotEmpty(item.getProvinceId())) {
+                CustomizeArea customizeArea = areaInfoMap.get(item.getProvinceId());
+                if (customizeArea != null) {
+                    item.setProvinceName(customizeArea.getName());
+                }
+            }
+            if (ObjectUtil.isNotEmpty(item.getCityId())) {
+                CustomizeArea customizeArea = areaInfoMap.get(item.getCityId());
+                if (customizeArea != null) {
+                    item.setCityName(customizeArea.getName());
+                }
+            }
+        }
+    }
+
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public Map<Long, String> getAreaMapByIds(List<Long> idList) {
+        List<CustomizeArea> areaInfos = listByIds(idList);
+        return areaInfos.stream().collect(Collectors.toMap(CustomizeArea::getId, CustomizeArea::getName));
+    }
+
+    @Override
+    public List<CustomizeArea> getList(AreaInfoSelectDto dto) {
+        String parentId = ObjectUtil.defaultIfNull(dto.getParentId(), "0");
+        return list(Wrappers.<CustomizeArea>lambdaQuery().eq(CustomizeArea::getParentId, parentId));
+    }
+
+}

+ 1 - 0
hx-area/src/main/java/com/fjhx/area/utils/AreaUtil.java

@@ -8,6 +8,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+@Deprecated
 public class AreaUtil {
 
     private static final AreaInfoService fileInfoService = SpringUtil.getBean(AreaInfoService.class);

+ 51 - 0
hx-area/src/main/java/com/fjhx/area/utils/CustomizeAreaUtil.java

@@ -0,0 +1,51 @@
+package com.fjhx.area.utils;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.fjhx.area.service.CustomizeAreaService;
+import com.fjhx.area.service.SetCustomizeAreaId;
+import com.fjhx.area.service.SetCustomizeAreaName;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class CustomizeAreaUtil {
+
+    private static final CustomizeAreaService customizeAreaService = SpringUtil.getBean(CustomizeAreaService.class);
+
+    /**
+     * 赋值地区id
+     */
+    public static void setAreaId(List<? extends SetCustomizeAreaId> setAreaIdList) {
+        customizeAreaService.setAreaId(setAreaIdList);
+    }
+
+    /**
+     * 赋值地区id
+     */
+    public static void setAreaId(SetCustomizeAreaId setAreaId) {
+        customizeAreaService.setAreaId(Collections.singletonList(setAreaId));
+    }
+
+    /**
+     * 赋值地区名称
+     */
+    public static void setAreaName(List<? extends SetCustomizeAreaName> setAreaNameList) {
+        customizeAreaService.setAreaName(setAreaNameList);
+    }
+
+    /**
+     * 赋值地区名称
+     */
+    public static void setAreaName(SetCustomizeAreaName setAreaName) {
+        customizeAreaService.setAreaName(Collections.singletonList(setAreaName));
+    }
+
+    /**
+     * 获取地区map
+     */
+    public static Map<Long, String> getAreaMapByIds(List<Long> idList) {
+        return customizeAreaService.getAreaMapByIds(idList);
+    }
+
+}

+ 5 - 0
hx-area/src/main/resources/mapper/area/CustomizeAreaMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.area.mapper.CustomizeAreaMapper">
+
+</mapper>

+ 17 - 17
hx-socket/src/main/java/com/fjhx/socket/config/WebSocketConfig.java

@@ -1,17 +1,17 @@
-package com.fjhx.socket.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.config.annotation.EnableWebSocket;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
-
-@Configuration
-@EnableWebSocket
-public class WebSocketConfig {
-
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
-
-}
+// package com.fjhx.socket.config;
+//
+// import org.springframework.context.annotation.Bean;
+// import org.springframework.context.annotation.Configuration;
+// import org.springframework.web.socket.config.annotation.EnableWebSocket;
+// import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+//
+// @Configuration
+// @EnableWebSocket
+// public class WebSocketConfig {
+//
+//     @Bean
+//     public ServerEndpointExporter serverEndpointExporter() {
+//         return new ServerEndpointExporter();
+//     }
+//
+// }

+ 58 - 0
ruoyi-admin/src/main/java/com/ruoyi/test/TestFlow.java

@@ -0,0 +1,58 @@
+package com.ruoyi.test;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.fjhx.flow.core.FlowDelegate;
+import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.system.service.ISysConfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@DS("iot")
+@Slf4j
+@Service
+public class TestFlow extends FlowDelegate {
+
+    @Autowired
+    private ISysConfigService sysConfigService;
+
+    @Override
+    public String getFlowKey() {
+        return "test_flow";
+    }
+
+    @Override
+    public Long start(Long flowId, JSONObject data) {
+        SysConfig sysConfig = new SysConfig();
+        sysConfig.setConfigName("备注");
+        sysConfigService.save(sysConfig);
+        return sysConfig.getConfigId();
+    }
+
+    @Override
+    public void end(Long flowId, Long businessId, JSONObject submitData) {
+        System.out.println("默认结束方法");
+    }
+
+    public void testEnd() {
+        log.error("测试结束方法");
+        SysConfig sysConfig = new SysConfig();
+        sysConfig.setConfigName("备注2");
+        sysConfigService.save(sysConfig);
+    }
+
+    public void type1() {
+        log.error("type1");
+    }
+
+    public void type2() {
+        log.error("type2");
+    }
+
+    public void type3() {
+        log.error("type2");
+    }
+
+}