Commit 34550292 authored by lcl's avatar lcl

客户导入,企业名称匹配

parent 9f53bc99
package com.dsk.web.controller.customer;
import com.dsk.common.annotation.Log;
import com.dsk.common.annotation.RepeatSubmit;
import com.dsk.common.core.controller.BaseController;
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.enums.BusinessType;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
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 {
*/
@PreAuthorize("@ss.hasPermi('customer:list')")
@GetMapping("/list")
public TableDataInfo selectPageList(CustomerSearchDto dto){
public TableDataInfo selectPageList(CustomerSearchDto dto) {
startPage();
return getDataTable(baseService.selectList(dto));
}
......@@ -40,7 +48,7 @@ public class CustomerController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('customer:info')")
@GetMapping("/{customerId}")
public AjaxResult info(@PathVariable("customerId") String customerId){
public AjaxResult info(@PathVariable("customerId") String customerId) {
return AjaxResult.success(baseService.info(customerId));
}
......@@ -50,7 +58,7 @@ public class CustomerController extends BaseController {
@PreAuthorize("@ss.hasPermi('customer:add')")
@PostMapping()
@RepeatSubmit
public AjaxResult add(@RequestBody Customer customer){
public AjaxResult add(@RequestBody Customer customer) {
return AjaxResult.success(baseService.add(customer));
}
......@@ -60,7 +68,7 @@ public class CustomerController extends BaseController {
@PreAuthorize("@ss.hasPermi('customer:edit')")
@PutMapping()
@RepeatSubmit
public AjaxResult edit(@RequestBody Customer customer){
public AjaxResult edit(@RequestBody Customer customer) {
return AjaxResult.success(baseService.edit(customer));
}
......@@ -68,7 +76,7 @@ public class CustomerController extends BaseController {
* 获取个人客户列表
*/
@GetMapping("/user/list")
public AjaxResult userList(){
public AjaxResult userList() {
return AjaxResult.success(baseService.selectUserList());
}
......@@ -77,9 +85,15 @@ public class CustomerController extends BaseController {
*/
// @PreAuthorize("@ss.hasPermi('customer:business:list')")
@GetMapping("/business/list")
public TableDataInfo businessList(CustomerBusinessSearchDto dto){
public TableDataInfo businessList(CustomerBusinessSearchDto dto) {
startPage();
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 {
AjaxResult establishmentPage(ComposeQueryDto compose);
AjaxResult enterprisePage(ComposeQueryDto compose);
AjaxResult enterpriseByName(ComposeQueryDto compose);
}
......@@ -54,4 +54,10 @@ public class BusinessOpportunityRadarServiceImpl implements BusinessOpportunityR
Map<String, Object> map = dskOpenApiUtil.requestBody("/api/nationzj/enterprice/index", BeanUtil.beanToMap(compose, false, false));
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;
import com.baomidou.mybatisplus.annotation.*;
import com.dsk.common.annotation.Excel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.context.annotation.Import;
import java.io.Serializable;
import java.util.Date;
......@@ -30,6 +32,7 @@ public class Customer implements Serializable {
/**
* 客户名称(企业名称)
*/
@Excel(name = "企业名称")
private String companyName;
/**
* 法定代表人
......
......@@ -29,4 +29,6 @@ public interface ICustomerService {
List<CustomerBusinessListVo> selectBusinessList(CustomerBusinessSearchDto dto);
List<String> importData(List<Customer> customerList);
}
......@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.exception.ServiceException;
import com.dsk.common.utils.DskOpenApiUtil;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.customer.Customer;
import com.dsk.system.domain.customer.CustomerUser;
......@@ -16,12 +17,14 @@ import com.dsk.system.mapper.CustomerMapper;
import com.dsk.system.mapper.CustomerUserMapper;
import com.dsk.system.service.IBusinessInfoService;
import com.dsk.system.service.ICustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -30,6 +33,7 @@ import java.util.List;
* @author makejava
* @since 2023-05-16 09:27:57
*/
@Slf4j
@Service
public class CustomerServiceImpl implements ICustomerService {
......@@ -39,6 +43,8 @@ public class CustomerServiceImpl implements ICustomerService {
private CustomerUserMapper customerUserMapper;
@Autowired
private IBusinessInfoService businessInfoService;
@Autowired
private DskOpenApiUtil dskOpenApiUtil;
@Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) {
......@@ -108,4 +114,22 @@ public class CustomerServiceImpl implements ICustomerService {
dto.setUserId(SecurityUtils.getUserId());
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