Commit 34550292 authored by lcl's avatar lcl

客户导入,企业名称匹配

parent 9f53bc99
package com.dsk.web.controller.customer; package com.dsk.web.controller.customer;
import com.dsk.common.annotation.Log;
import com.dsk.common.annotation.RepeatSubmit; import com.dsk.common.annotation.RepeatSubmit;
import com.dsk.common.core.controller.BaseController; import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.domain.entity.SysRole;
import com.dsk.common.core.page.TableDataInfo; import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.system.domain.customer.Customer; import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto; import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto; import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.service.ICustomerService; import com.dsk.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* 客户相关 * 客户相关
...@@ -30,7 +38,7 @@ public class CustomerController extends BaseController { ...@@ -30,7 +38,7 @@ public class CustomerController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('customer:list')") @PreAuthorize("@ss.hasPermi('customer:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo selectPageList(CustomerSearchDto dto){ public TableDataInfo selectPageList(CustomerSearchDto dto) {
startPage(); startPage();
return getDataTable(baseService.selectList(dto)); return getDataTable(baseService.selectList(dto));
} }
...@@ -40,7 +48,7 @@ public class CustomerController extends BaseController { ...@@ -40,7 +48,7 @@ public class CustomerController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('customer:info')") @PreAuthorize("@ss.hasPermi('customer:info')")
@GetMapping("/{customerId}") @GetMapping("/{customerId}")
public AjaxResult info(@PathVariable("customerId") String customerId){ public AjaxResult info(@PathVariable("customerId") String customerId) {
return AjaxResult.success(baseService.info(customerId)); return AjaxResult.success(baseService.info(customerId));
} }
...@@ -50,7 +58,7 @@ public class CustomerController extends BaseController { ...@@ -50,7 +58,7 @@ public class CustomerController extends BaseController {
@PreAuthorize("@ss.hasPermi('customer:add')") @PreAuthorize("@ss.hasPermi('customer:add')")
@PostMapping() @PostMapping()
@RepeatSubmit @RepeatSubmit
public AjaxResult add(@RequestBody Customer customer){ public AjaxResult add(@RequestBody Customer customer) {
return AjaxResult.success(baseService.add(customer)); return AjaxResult.success(baseService.add(customer));
} }
...@@ -60,7 +68,7 @@ public class CustomerController extends BaseController { ...@@ -60,7 +68,7 @@ public class CustomerController extends BaseController {
@PreAuthorize("@ss.hasPermi('customer:edit')") @PreAuthorize("@ss.hasPermi('customer:edit')")
@PutMapping() @PutMapping()
@RepeatSubmit @RepeatSubmit
public AjaxResult edit(@RequestBody Customer customer){ public AjaxResult edit(@RequestBody Customer customer) {
return AjaxResult.success(baseService.edit(customer)); return AjaxResult.success(baseService.edit(customer));
} }
...@@ -68,7 +76,7 @@ public class CustomerController extends BaseController { ...@@ -68,7 +76,7 @@ public class CustomerController extends BaseController {
* 获取个人客户列表 * 获取个人客户列表
*/ */
@GetMapping("/user/list") @GetMapping("/user/list")
public AjaxResult userList(){ public AjaxResult userList() {
return AjaxResult.success(baseService.selectUserList()); return AjaxResult.success(baseService.selectUserList());
} }
...@@ -77,9 +85,15 @@ public class CustomerController extends BaseController { ...@@ -77,9 +85,15 @@ public class CustomerController extends BaseController {
*/ */
// @PreAuthorize("@ss.hasPermi('customer:business:list')") // @PreAuthorize("@ss.hasPermi('customer:business:list')")
@GetMapping("/business/list") @GetMapping("/business/list")
public TableDataInfo businessList(CustomerBusinessSearchDto dto){ public TableDataInfo businessList(CustomerBusinessSearchDto dto) {
startPage(); startPage();
return getDataTable(baseService.selectBusinessList(dto)); return getDataTable(baseService.selectBusinessList(dto));
} }
@Log(title = "客户数据导入", businessType = BusinessType.IMPORT)
//@PreAuthorize("@ss.hasPermi('customer:importData')")
@PostMapping("/importData")
public AjaxResult importData(@RequestPart("file") MultipartFile file) throws Exception {
return AjaxResult.success(baseService.importData(new ExcelUtil<>(Customer.class).importExcel(file.getInputStream(), 3)));
}
} }
...@@ -19,4 +19,6 @@ public interface BusinessOpportunityRadarService { ...@@ -19,4 +19,6 @@ public interface BusinessOpportunityRadarService {
AjaxResult establishmentPage(ComposeQueryDto compose); AjaxResult establishmentPage(ComposeQueryDto compose);
AjaxResult enterprisePage(ComposeQueryDto compose); AjaxResult enterprisePage(ComposeQueryDto compose);
AjaxResult enterpriseByName(ComposeQueryDto compose);
} }
...@@ -54,4 +54,10 @@ public class BusinessOpportunityRadarServiceImpl implements BusinessOpportunityR ...@@ -54,4 +54,10 @@ public class BusinessOpportunityRadarServiceImpl implements BusinessOpportunityR
Map<String, Object> map = dskOpenApiUtil.requestBody("/api/nationzj/enterprice/index", BeanUtil.beanToMap(compose, false, false)); Map<String, Object> map = dskOpenApiUtil.requestBody("/api/nationzj/enterprice/index", BeanUtil.beanToMap(compose, false, false));
return BeanUtil.toBean(map, AjaxResult.class); return BeanUtil.toBean(map, AjaxResult.class);
} }
@Override
public AjaxResult enterpriseByName(ComposeQueryDto compose){
Map<String, Object> map = dskOpenApiUtil.requestBody("/api/nationzj/enterprice/findByName", BeanUtil.beanToMap(compose, false, false));
return BeanUtil.toBean(map, AjaxResult.class);
}
} }
package com.dsk.system.domain.customer; package com.dsk.system.domain.customer;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.dsk.common.annotation.Excel;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.context.annotation.Import;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -30,6 +32,7 @@ public class Customer implements Serializable { ...@@ -30,6 +32,7 @@ public class Customer implements Serializable {
/** /**
* 客户名称(企业名称) * 客户名称(企业名称)
*/ */
@Excel(name = "企业名称")
private String companyName; private String companyName;
/** /**
* 法定代表人 * 法定代表人
......
...@@ -29,4 +29,6 @@ public interface ICustomerService { ...@@ -29,4 +29,6 @@ public interface ICustomerService {
List<CustomerBusinessListVo> selectBusinessList(CustomerBusinessSearchDto dto); List<CustomerBusinessListVo> selectBusinessList(CustomerBusinessSearchDto dto);
List<String> importData(List<Customer> customerList);
} }
...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanException; ...@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.exception.ServiceException; import com.dsk.common.exception.ServiceException;
import com.dsk.common.utils.DskOpenApiUtil;
import com.dsk.common.utils.SecurityUtils; import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.customer.Customer; import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.CustomerUser; import com.dsk.system.domain.customer.CustomerUser;
...@@ -16,12 +17,14 @@ import com.dsk.system.mapper.CustomerMapper; ...@@ -16,12 +17,14 @@ import com.dsk.system.mapper.CustomerMapper;
import com.dsk.system.mapper.CustomerUserMapper; import com.dsk.system.mapper.CustomerUserMapper;
import com.dsk.system.service.IBusinessInfoService; import com.dsk.system.service.IBusinessInfoService;
import com.dsk.system.service.ICustomerService; import com.dsk.system.service.ICustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -30,6 +33,7 @@ import java.util.List; ...@@ -30,6 +33,7 @@ import java.util.List;
* @author makejava * @author makejava
* @since 2023-05-16 09:27:57 * @since 2023-05-16 09:27:57
*/ */
@Slf4j
@Service @Service
public class CustomerServiceImpl implements ICustomerService { public class CustomerServiceImpl implements ICustomerService {
...@@ -39,6 +43,8 @@ public class CustomerServiceImpl implements ICustomerService { ...@@ -39,6 +43,8 @@ public class CustomerServiceImpl implements ICustomerService {
private CustomerUserMapper customerUserMapper; private CustomerUserMapper customerUserMapper;
@Autowired @Autowired
private IBusinessInfoService businessInfoService; private IBusinessInfoService businessInfoService;
@Autowired
private DskOpenApiUtil dskOpenApiUtil;
@Override @Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) { public List<CustomerListVo> selectList(CustomerSearchDto dto) {
...@@ -108,4 +114,22 @@ public class CustomerServiceImpl implements ICustomerService { ...@@ -108,4 +114,22 @@ public class CustomerServiceImpl implements ICustomerService {
dto.setUserId(SecurityUtils.getUserId()); dto.setUserId(SecurityUtils.getUserId());
return businessInfoService.selectCustomerBusinessList(dto); return businessInfoService.selectCustomerBusinessList(dto);
} }
@Override
public List<String> importData(List<Customer> customerList) {
List<String> resultList = new ArrayList<>();
for (Customer customer : customerList) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) {
continue;
}
try {
//TODO 名称查询企业信息
this.add(customer);
} catch (Exception e) {
resultList.add(customer.getCompanyName().concat(e.getMessage()));
}
}
return resultList;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment