Commit b54c462e authored by lcl's avatar lcl

字段添加,逻辑修改

parent 24888aae
package com.dsk.web.controller.customer; package com.dsk.web.controller.customer;
import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpException; import cn.hutool.http.HttpException;
...@@ -15,6 +16,7 @@ import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto; ...@@ -15,6 +16,7 @@ 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 com.dsk.web.controller.search.service.BusinessOpportunityRadarService; import com.dsk.web.controller.search.service.BusinessOpportunityRadarService;
import lombok.extern.slf4j.Slf4j;
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.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -66,6 +68,16 @@ public class CustomerController extends BaseController { ...@@ -66,6 +68,16 @@ public class CustomerController extends BaseController {
@PostMapping() @PostMapping()
@RepeatSubmit @RepeatSubmit
public AjaxResult add(@RequestBody Customer customer) { public AjaxResult add(@RequestBody Customer customer) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) throw new BeanException("企业名称不能为空");
try {
Map<String, Object> map = opportunityRadarService.enterpriseByName(customer.getCompanyName());
if(!ObjectUtils.isEmpty(map.get("data"))) {
customer.setCompanyId(MapUtil.getInt(BeanUtil.beanToMap(map.get("data")), "jskEid"));
}
} catch (Exception e) {
logger.debug("获取企业id错误!error:{}", e.getMessage());
}
baseService.add(customer);
return AjaxResult.success(baseService.add(customer)); return AjaxResult.success(baseService.add(customer));
} }
......
...@@ -29,6 +29,10 @@ public class Customer implements Serializable { ...@@ -29,6 +29,10 @@ public class Customer implements Serializable {
* jsk企业id * jsk企业id
*/ */
private Integer companyId; private Integer companyId;
/**
* 城投企业id
*/
private String uipId;
/** /**
* 客户名称(企业名称) * 客户名称(企业名称)
*/ */
......
...@@ -14,6 +14,10 @@ public class CustomerListVo { ...@@ -14,6 +14,10 @@ public class CustomerListVo {
* jsk企业id * jsk企业id
*/ */
private Integer companyId; private Integer companyId;
/**
* 城投企业id
*/
private String uipId;
/** /**
* 客户名称(企业名称) * 客户名称(企业名称)
*/ */
......
package com.dsk.system.dskService; package com.dsk.system.dskService;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import com.dsk.common.core.domain.R; import com.dsk.common.core.domain.R;
import com.dsk.common.core.domain.model.*; import com.dsk.common.core.domain.model.*;
import com.dsk.common.core.page.TableDataInfo; import com.dsk.common.core.page.TableDataInfo;
...@@ -128,4 +129,11 @@ public class EnterpriseService { ...@@ -128,4 +129,11 @@ public class EnterpriseService {
Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/financial", BeanUtil.beanToMap(body, false, false)); Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/financial", BeanUtil.beanToMap(body, false, false));
return BeanUtil.toBean(map, R.class); return BeanUtil.toBean(map, R.class);
} }
public R getUipId(String companyName) throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("companyName",companyName);
Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/getUipId", params);
return BeanUtil.toBean(map, R.class);
}
} }
...@@ -23,7 +23,7 @@ public interface CustomerMapper extends BaseMapper<Customer> { ...@@ -23,7 +23,7 @@ public interface CustomerMapper extends BaseMapper<Customer> {
List<Customer> selectUserList(Long userId); List<Customer> selectUserList(Long userId);
Customer selectByCompanyIdAndUserId(@Param("companyId")Integer companyId,@Param("userId")Long userId); Customer selectByCompanyNameAndUserId(@Param("companyName")String companyName,@Param("userId")Long userId);
} }
...@@ -2,7 +2,9 @@ package com.dsk.system.service.impl; ...@@ -2,7 +2,9 @@ package com.dsk.system.service.impl;
import cn.hutool.core.bean.BeanException; import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.core.domain.R;
import com.dsk.common.exception.ServiceException; import com.dsk.common.exception.ServiceException;
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;
...@@ -12,6 +14,7 @@ import com.dsk.system.domain.customer.dto.CustomerSearchDto; ...@@ -12,6 +14,7 @@ import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.domain.customer.vo.CustomerBusinessListVo; import com.dsk.system.domain.customer.vo.CustomerBusinessListVo;
import com.dsk.system.domain.customer.vo.CustomerListVo; import com.dsk.system.domain.customer.vo.CustomerListVo;
import com.dsk.system.domain.customer.vo.CustomerVo; import com.dsk.system.domain.customer.vo.CustomerVo;
import com.dsk.system.dskService.EnterpriseService;
import com.dsk.system.mapper.CustomerMapper; 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;
...@@ -41,6 +44,8 @@ public class CustomerServiceImpl implements ICustomerService { ...@@ -41,6 +44,8 @@ public class CustomerServiceImpl implements ICustomerService {
private CustomerUserMapper customerUserMapper; private CustomerUserMapper customerUserMapper;
@Autowired @Autowired
private IBusinessInfoService businessInfoService; private IBusinessInfoService businessInfoService;
@Autowired
private EnterpriseService enterpriseService;
@Override @Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) { public List<CustomerListVo> selectList(CustomerSearchDto dto) {
...@@ -70,13 +75,20 @@ public class CustomerServiceImpl implements ICustomerService { ...@@ -70,13 +75,20 @@ public class CustomerServiceImpl implements ICustomerService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean add(Customer customer) { public boolean add(Customer customer) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) throw new BeanException("企业名称不能为空"); try {
if (ObjectUtils.isEmpty(customer.getCompanyId())) throw new BeanException("企业id不能为空"); R res = enterpriseService.getUipId(customer.getCompanyName());
final Long userId = SecurityUtils.getUserId(); if (!ObjectUtils.isEmpty(res.getData())) {
customer.setUipId(MapUtil.getStr(BeanUtil.beanToMap(res.getData()), "uipId"));
}
} catch (Exception e) {
log.error("获取城投平台企业id错误!error:{}", e.getMessage());
}
Long userId = SecurityUtils.getUserId();
customer.setCreateId(userId); customer.setCreateId(userId);
customer.setUpdateId(userId); customer.setUpdateId(userId);
//查重 //查重
Customer verifyCustomer = baseMapper.selectByCompanyIdAndUserId(customer.getCompanyId(), userId); Customer verifyCustomer = baseMapper.selectByCompanyNameAndUserId(customer.getCompanyName(), userId);
if (!ObjectUtils.isEmpty(verifyCustomer)) { if (!ObjectUtils.isEmpty(verifyCustomer)) {
throw new ServiceException("当前客户信息已存在,请勿重复添加!"); throw new ServiceException("当前客户信息已存在,请勿重复添加!");
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.dsk.system.mapper.CustomerMapper"> <mapper namespace="com.dsk.system.mapper.CustomerMapper">
<sql id="Base_Bean"> <sql id="Base_Bean">
ct.customer_id, ct.company_id, ct.company_name, ct.legal_person, ct.credit_code, ct.register_capital, ct.customer_id, ct.company_id, ct.uip_id, ct.company_name, ct.legal_person, ct.credit_code, ct.register_capital,
ct.province_id, ct.city_id, ct.district_id, ct.register_address, ct.company_nature, ct.company_level, ct.province_id, ct.city_id, ct.district_id, ct.register_address, ct.company_nature, ct.company_level,
ct.credit_level, ct.super_company, ct.is_on, ct.is_major, ct.company_attribute, ct.main_business, ct.credit_level, ct.super_company, ct.is_on, ct.is_major, ct.company_attribute, ct.main_business,
ct.business_scope, ct.customer_level, ct.business_characteristic, ct.decision_chain, ct.bid_characteristic, ct.business_scope, ct.customer_level, ct.business_characteristic, ct.decision_chain, ct.bid_characteristic,
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
where ctu.user_id = #{userId} where ctu.user_id = #{userId}
</select> </select>
<select id="selectByCompanyIdAndUserId" resultType="com.dsk.system.domain.customer.Customer"> <select id="selectByCompanyNameAndUserId" resultType="com.dsk.system.domain.customer.Customer">
select select
<include refid="Base_Bean"></include> <include refid="Base_Bean"></include>
from customer ct from customer ct
join customer_user ctu on ct.customer_id = ctu.customer_id join customer_user ctu on ct.customer_id = ctu.customer_id
where ct.company_id = ${companyId} and ctu.user_id = #{userId} where ct.company_name = #{companyName} and ctu.user_id = #{userId}
</select> </select>
</mapper> </mapper>
......
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