Commit 4c16ba73 authored by caixingbing's avatar caixingbing
parents 16adbad1 55760942
package com.dsk.web.controller.customer;
import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpException;
......@@ -15,6 +16,7 @@ import com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto;
import com.dsk.system.domain.customer.dto.CustomerSearchDto;
import com.dsk.system.service.ICustomerService;
import com.dsk.web.controller.search.service.BusinessOpportunityRadarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
......@@ -66,6 +68,17 @@ public class CustomerController extends BaseController {
@PostMapping()
@RepeatSubmit
public AjaxResult add(@RequestBody Customer customer) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) throw new BeanException("企业名称不能为空");
if (ObjectUtils.isEmpty(customer.getCompanyId())) {
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());
}
}
return AjaxResult.success(baseService.add(customer));
}
......
......@@ -29,8 +29,11 @@
:fixed="item.fixed"
:sortable="item.sortable"
:resizable="false">
<template v-if="item.slotHeader" slot="header">
<slot :name="item.slotName"></slot>
</template>
<template slot-scope="scope">
<slot :name="item.prop" :row="item" :index="scope.$index" :data="scope.row.punishReason"></slot>
<slot :name="item.prop" :row="scope.row" :index="scope.$index" :data="item"></slot>
</template>
</el-table-column>
<el-table-column
......@@ -41,7 +44,12 @@
align="left"
:fixed="item.fixed"
:sortable="item.sortable"
:resizable="false" />
:resizable="false">
<template v-if="item.slotHeader" slot="header">
<slot :name="item.slotName"></slot>
</template>
</el-table-column>
</template>
</el-table>
</div>
......@@ -104,5 +112,7 @@ export default {
</script>
<style lang="scss" scoped>
::v-deep .el-table__body tr.current-row > td.el-table__cell{
background-color: #ffffff;
}
</style>
......@@ -29,6 +29,10 @@ public class Customer implements Serializable {
* jsk企业id
*/
private Integer companyId;
/**
* 城投企业id
*/
private String uipId;
/**
* 客户名称(企业名称)
*/
......
......@@ -14,6 +14,10 @@ public class CustomerListVo {
* jsk企业id
*/
private Integer companyId;
/**
* 城投企业id
*/
private String uipId;
/**
* 客户名称(企业名称)
*/
......
package com.dsk.system.dskService;
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.model.*;
import com.dsk.common.core.page.TableDataInfo;
......@@ -128,4 +129,11 @@ public class EnterpriseService {
Map<String, Object> map = dskOpenApiUtil.requestBody("/operate/enterprise/financial", BeanUtil.beanToMap(body, false, false));
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> {
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;
import cn.hutool.core.bean.BeanException;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.core.domain.R;
import com.dsk.common.exception.ServiceException;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.customer.Customer;
......@@ -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.CustomerListVo;
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.CustomerUserMapper;
import com.dsk.system.service.IBusinessInfoService;
......@@ -41,6 +44,8 @@ public class CustomerServiceImpl implements ICustomerService {
private CustomerUserMapper customerUserMapper;
@Autowired
private IBusinessInfoService businessInfoService;
@Autowired
private EnterpriseService enterpriseService;
@Override
public List<CustomerListVo> selectList(CustomerSearchDto dto) {
......@@ -70,13 +75,20 @@ public class CustomerServiceImpl implements ICustomerService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(Customer customer) {
if (ObjectUtils.isEmpty(customer.getCompanyName())) throw new BeanException("企业名称不能为空");
if (ObjectUtils.isEmpty(customer.getCompanyId())) throw new BeanException("企业id不能为空");
final Long userId = SecurityUtils.getUserId();
try {
R res = enterpriseService.getUipId(customer.getCompanyName());
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.setUpdateId(userId);
//查重
Customer verifyCustomer = baseMapper.selectByCompanyIdAndUserId(customer.getCompanyId(), userId);
Customer verifyCustomer = baseMapper.selectByCompanyNameAndUserId(customer.getCompanyName(), userId);
if (!ObjectUtils.isEmpty(verifyCustomer)) {
throw new ServiceException("当前客户信息已存在,请勿重复添加!");
}
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.dsk.system.mapper.CustomerMapper">
<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.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,
......@@ -29,12 +29,12 @@
where ctu.user_id = #{userId}
</select>
<select id="selectByCompanyIdAndUserId" resultType="com.dsk.system.domain.customer.Customer">
<select id="selectByCompanyNameAndUserId" resultType="com.dsk.system.domain.customer.Customer">
select
<include refid="Base_Bean"></include>
from customer ct
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>
</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