home 2 жил өмнө
parent
commit
5f9b8146be

+ 5 - 0
hx-common/common-client-util/pom.xml

@@ -29,6 +29,11 @@
         </dependency>
 
         <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>blade-ex-api</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
         </dependency>

+ 22 - 0
hx-common/common-client-util/src/main/java/com/fjhx/utils/RegionClientUtil.java

@@ -0,0 +1,22 @@
+package com.fjhx.utils;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.fjhx.feign.IRegionClient;
+
+public class RegionClientUtil {
+
+    private static IRegionClient iRegionClient;
+
+    /**
+     * 懒汉式单例
+     */
+    private synchronized static IRegionClient getRegionClient() {
+        if (iRegionClient == null) {
+            iRegionClient = SpringUtil.getBean(IRegionClient.class);
+        }
+        return iRegionClient;
+    }
+
+
+
+}

+ 2 - 2
hx-common/common-tool/src/main/java/com/fjhx/base/BaseService.java

@@ -18,7 +18,7 @@ public interface BaseService<T> extends IService<T> {
     /**
      * 获取分页
      */
-    default Page<T> createPage(Map<String, String> condition) {
+    default Page<T> createPage(Map<String, ?> condition) {
         return PageUtil.createPage(condition);
     }
 
@@ -36,7 +36,7 @@ public interface BaseService<T> extends IService<T> {
      * @param queryWrapper wrapper
      * @return 分页后的对象
      */
-    default Page<T> page(Map<String, String> condition, Wrapper<T> queryWrapper) {
+    default Page<T> page(Map<String, ?> condition, Wrapper<T> queryWrapper) {
         Page<T> page = createPage(condition);
         return page(page, queryWrapper);
     }

+ 6 - 0
hx-common/pom.xml

@@ -111,6 +111,12 @@
                 <version>${hx.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.fjhx</groupId>
+                <artifactId>blade-ex-api</artifactId>
+                <version>${hx.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 

+ 19 - 0
hx-service-api/blade-ex-api/pom.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hx-service-api</artifactId>
+        <groupId>com.fjhx</groupId>
+        <version>3.2.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>blade-ex-api</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 0 - 0
hx-service/blade-ex/src/main/java/com/fjhx/entity/ExRegion.java → hx-service-api/blade-ex-api/src/main/java/com/fjhx/entity/ExRegion.java


+ 28 - 0
hx-service-api/blade-ex-api/src/main/java/com/fjhx/feign/IRegionClient.java

@@ -0,0 +1,28 @@
+package com.fjhx.feign;
+
+import com.fjhx.constants.ClientConstant;
+import org.springblade.core.tool.api.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * File Feign接口类
+ */
+@FeignClient(value = "blade-ex")
+public interface IRegionClient {
+
+    String GET_CHINESE_NAME_BY_ID = ClientConstant.API_PREFIX + "/getChineseNameById";
+
+    /**
+     * 根据城市id获取城市名称
+     *
+     * @param regionSet 城市id集合
+     */
+    @PostMapping(GET_CHINESE_NAME_BY_ID)
+    R<Map<String, String>> getChineseNameById(@RequestBody List<String> regionSet);
+
+}

+ 0 - 0
hx-service/blade-ex/src/main/java/com/fjhx/params/TenantVo.java → hx-service-api/blade-ex-api/src/main/java/com/fjhx/params/TenantVo.java


+ 1 - 1
hx-service-api/crm-api/src/main/java/com/fjhx/entity/contract/Contract.java

@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ * 合同
  * </p>
  *
  * @author ${author}

+ 8 - 0
hx-service-api/crm-api/src/main/java/com/fjhx/params/customer/CustomerVo.java

@@ -1,9 +1,12 @@
 package com.fjhx.params.customer;
 
 import com.fjhx.entity.customer.Customer;
+import com.fjhx.entity.customer.CustomerLink;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * 客户
  *
@@ -14,4 +17,9 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class CustomerVo extends Customer {
 
+    /**
+     * 客户联系人
+     */
+    private List<CustomerLink> customerLinkList;
+
 }

+ 1 - 0
hx-service-api/pom.xml

@@ -32,6 +32,7 @@
         <module>basics-api</module>
         <module>foreign-trade-superman-api</module>
         <module>crm-api</module>
+        <module>blade-ex-api</module>
     </modules>
 
     <dependencyManagement>

+ 6 - 1
hx-service/blade-ex/pom.xml

@@ -9,7 +9,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>bladex-ex</artifactId>
+    <artifactId>blade-ex</artifactId>
 
     <properties>
         <maven.compiler.source>8</maven.compiler.source>
@@ -33,6 +33,11 @@
             <artifactId>blade-user-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>blade-ex-api</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 18 - 0
hx-service/blade-ex/src/main/java/com/fjhx/BladeExApplication.java

@@ -0,0 +1,18 @@
+package com.fjhx;
+
+import org.springblade.core.cloud.client.BladeCloudApplication;
+import org.springblade.core.launch.BladeApplication;
+
+/**
+ * 基础架构拓展接口
+ */
+@BladeCloudApplication
+public class BladeExApplication {
+
+    private static final String APP_NAME = "blade-ex";
+
+    public static void main(String[] args) {
+        BladeApplication.run(APP_NAME, BladeExApplication.class, args);
+    }
+
+}

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/feign/RegionClient.java

@@ -0,0 +1,30 @@
+package com.fjhx.feign;
+
+import com.fjhx.service.ExRegionService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tenant.annotation.NonDS;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
+import java.util.Map;
+
+@NonDS
+@ApiIgnore
+@RestController
+@AllArgsConstructor
+public class RegionClient implements IRegionClient {
+
+    @Autowired
+    private ExRegionService exRegionService;
+
+    @PostMapping(GET_CHINESE_NAME_BY_ID)
+    @Override
+    public R<Map<String, String>> getChineseNameById(List<String> regionSet) {
+        return R.success(exRegionService.getChineseNameById(regionSet));
+    }
+
+}

+ 2 - 2
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/ExRegionServiceImpl.java

@@ -29,7 +29,7 @@ public class ExRegionServiceImpl extends ServiceImpl<ExRegionMapper, ExRegion> i
     public Map<String, String> getChineseNameById(Collection<String> regionSet) {
 
         List<ExRegion> list = lambdaQuery()
-                .select(ExRegion::getId, ExRegion::getChineseName)
+                .select(ExRegion::getId, ExRegion::getName)
                 .in(ExRegion::getId, regionSet)
                 .list();
 
@@ -39,7 +39,7 @@ public class ExRegionServiceImpl extends ServiceImpl<ExRegionMapper, ExRegion> i
 
         return list.stream().collect(Collectors.toMap(
                 ExRegion::getId,
-                ExRegion::getChineseName,
+                ExRegion::getName,
                 (v1, v2) -> v1
         ));
     }

+ 13 - 6
hx-service/crm/pom.xml

@@ -10,18 +10,25 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>crm</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
     <dependencies>
+
         <dependency>
             <groupId>com.fjhx</groupId>
             <artifactId>crm-api</artifactId>
-            <version>3.2.0</version>
-            <scope>compile</scope>
         </dependency>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>blade-ex-api</artifactId>
+        </dependency>
+
     </dependencies>
 
-    <properties>
-        <maven.compiler.source>8</maven.compiler.source>
-        <maven.compiler.target>8</maven.compiler.target>
-    </properties>
 
 </project>

+ 2 - 1
hx-service/crm/src/main/java/com/fjhx/controller/customer/CustomerController.java

@@ -1,6 +1,7 @@
 package com.fjhx.controller.customer;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.base.Condition;
 import org.springblade.core.tool.api.R;
 import com.fjhx.entity.customer.Customer;
 import com.fjhx.params.customer.CustomerVo;
@@ -29,7 +30,7 @@ public class CustomerController {
     private CustomerService customerService;
 
     @PostMapping("/page")
-    public R page(@RequestBody Map<String, String> condition){
+    public R page(@RequestBody Condition condition){
         Page<Customer> result = customerService.getPage(condition);
         return R.success(result);
     }

+ 3 - 4
hx-service/crm/src/main/java/com/fjhx/service/customer/CustomerService.java

@@ -1,11 +1,10 @@
 package com.fjhx.service.customer;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.base.BaseService;
+import com.fjhx.base.Condition;
 import com.fjhx.entity.customer.Customer;
 import com.fjhx.params.customer.CustomerVo;
-import com.fjhx.base.BaseService;
-
-import java.util.Map;
 
 /**
  * <p>
@@ -17,7 +16,7 @@ import java.util.Map;
  */
 public interface CustomerService extends BaseService<Customer> {
 
-    Page<Customer> getPage(Map<String, String> condition);
+    Page<Customer> getPage(Condition condition);
 
     void add(CustomerVo customerVo);
 

+ 52 - 9
hx-service/crm/src/main/java/com/fjhx/service/customer/impl/CustomerServiceImpl.java

@@ -1,17 +1,24 @@
 package com.fjhx.service.customer.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.utils.WrapperUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.base.BaseEntity;
+import com.fjhx.base.Condition;
 import com.fjhx.entity.customer.Customer;
-import com.fjhx.params.customer.CustomerVo;
+import com.fjhx.entity.customer.CustomerLink;
 import com.fjhx.mapper.customer.CustomerMapper;
+import com.fjhx.params.customer.CustomerVo;
+import com.fjhx.service.customer.CustomerLinkService;
 import com.fjhx.service.customer.CustomerService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Map;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -24,31 +31,67 @@ import java.util.Map;
 @Service
 public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
 
+    @Autowired
+    private CustomerLinkService customerLinkService;
+
     @Override
-    public Page<Customer> getPage(Map<String, String> condition) {
+    public Page<Customer> getPage(Condition condition) {
+        String keyword = condition.getKeyword();
 
-        QueryWrapper<Customer> wrapper = Wrappers.query();
+        LambdaQueryWrapper<Customer> wrapper = Wrappers.lambdaQuery();
+        wrapper.and(ObjectUtil.isNotEmpty(keyword), q -> q
+                .like(Customer::getCode, keyword)
+                .like(Customer::getName, keyword)
+        );
 
-        WrapperUtil.init(condition, wrapper)
-                .createTimeDesc();
 
         Page<Customer> page = page(condition, wrapper);
+        List<Customer> records = page.getRecords();
+        if (records.size() == 0) {
+            return page;
+        }
+
+
+
+
         return page;
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void add(CustomerVo customerVo) {
         save(customerVo);
+
+        List<CustomerLink> customerLinkList = customerVo.getCustomerLinkList();
+        customerLinkList.forEach(customerLink -> customerLink.setCustomerId(customerVo.getId()));
+
+        customerLinkService.saveBatch(customerLinkList);
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void edit(CustomerVo customerVo) {
+        // 更新客户
         updateById(customerVo);
+
+        // 更新联系人
+        List<CustomerLink> customerLinkList = customerVo.getCustomerLinkList();
+        customerLinkList.forEach(customerLink -> customerLink.setCustomerId(customerVo.getId()));
+        customerLinkService.saveOrUpdateBatch(customerLinkList);
+
+        // 删除没有上传的联系人
+        List<Long> customerLinkIdList = customerLinkList.stream().map(BaseEntity::getId).collect(Collectors.toList());
+        customerLinkService.remove(
+                Wrappers.<CustomerLink>lambdaQuery()
+                        .eq(CustomerLink::getCustomerId, customerVo.getId())
+                        .notIn(BaseEntity::getId, customerLinkIdList));
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void delete(CustomerVo customerVo) {
         removeById(customerVo.getId());
+        customerLinkService.remove(CustomerLink::getCustomerId, customerVo.getId());
     }
 
 }

+ 12 - 0
hx-service/pom.xml

@@ -134,6 +134,18 @@
                 <version>${hx.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.fjhx</groupId>
+                <artifactId>blade-ex-api</artifactId>
+                <version>${hx.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.fjhx</groupId>
+                <artifactId>crm-api</artifactId>
+                <version>${hx.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>