This commit is contained in:
xd 2024-04-01 11:13:35 +08:00
parent a7ee87edf5
commit 26b071c447
12 changed files with 171 additions and 90 deletions

View File

@ -5,6 +5,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.customer.domain.qcc.FuzzySearch; import com.ruoyi.customer.domain.qcc.FuzzySearch;
import com.ruoyi.customer.domain.qcc.QccFuzzySearchJsonResult; import com.ruoyi.customer.domain.qcc.QccFuzzySearchJsonResult;
import com.ruoyi.web.utils.IdUtils; import com.ruoyi.web.utils.IdUtils;
@ -43,11 +44,14 @@ import com.ruoyi.common.core.page.TableDataInfo;
@PropertySource("classpath:/common.yml") @PropertySource("classpath:/common.yml")
public class CustomerController extends BaseController public class CustomerController extends BaseController
{ {
// 接口请求Key
@Value("${qichacha.key}") @Value("${qichacha.key}")
private String Qcc_Key; private String Qcc_Key;
// 接口请求Key
@Value("${qichacha.secretKey}") @Value("${qichacha.secretKey}")
private String Qcc_SecretKey; private String Qcc_SecretKey;
// 接口请求地址
@Value("${qichacha.serviceName}")
private String Qcc_serviceName;
@Autowired @Autowired
private ICustomerService customerService; private ICustomerService customerService;
@ -68,7 +72,7 @@ public class CustomerController extends BaseController
* 导出客户管理列表 * 导出客户管理列表
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:export')") @PreAuthorize("@ss.hasPermi('customer:customer:export')")
@Log(title = "客户管理", businessType = BusinessType.EXPORT) @Log(title = "客户信息导出", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Customer customer) public void export(HttpServletResponse response, Customer customer)
{ {
@ -82,7 +86,7 @@ public class CustomerController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:query')") @PreAuthorize("@ss.hasPermi('customer:customer:query')")
@GetMapping(value = "/{cusId}") @GetMapping(value = "/{cusId}")
public AjaxResult getInfo(@PathVariable("cusId") Long cusId) public AjaxResult getInfo(@PathVariable("cusId") String cusId)
{ {
return success(customerService.selectCustomerByCusId(cusId)); return success(customerService.selectCustomerByCusId(cusId));
} }
@ -90,11 +94,12 @@ public class CustomerController extends BaseController
/** /**
* 新增客户管理 * 新增客户管理
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:add')") @PreAuthorize("@ss.hasPermi('customer:customer:save')")
@Log(title = "客户管理", businessType = BusinessType.INSERT) @Log(title = "客户信息新增", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Customer customer) public AjaxResult add(@RequestBody Customer customer)
{ {
customer.setCusId(UUID.fastUUID().toString());
customer.setCusCode(IdUtils.createNo("KH_",2)); customer.setCusCode(IdUtils.createNo("KH_",2));
customer.setCreateBy(getUsername()); customer.setCreateBy(getUsername());
return toAjax(customerService.insertCustomer(customer)); return toAjax(customerService.insertCustomer(customer));
@ -103,8 +108,8 @@ public class CustomerController extends BaseController
/** /**
* 修改客户管理 * 修改客户管理
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:edit')") @PreAuthorize("@ss.hasPermi('customer:customer:save')")
@Log(title = "客户管理", businessType = BusinessType.UPDATE) @Log(title = "客户信息修改", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Customer customer) public AjaxResult edit(@RequestBody Customer customer)
{ {
@ -112,13 +117,38 @@ public class CustomerController extends BaseController
return toAjax(customerService.updateCustomer(customer)); return toAjax(customerService.updateCustomer(customer));
} }
/**
* 提交客户信息
*/
@PreAuthorize("@ss.hasPermi('customer:customer:commit')")
@Log(title = "客户信息提交", businessType = BusinessType.OTHER)
@PostMapping("/commitCustomer")
public AjaxResult commitCustomer(@RequestBody Customer customer)
{
String cus_id = customer.getCusId();
if(StringUtils.isEmpty(cus_id)){
customer.setCusCode(IdUtils.createNo("KH_",2));
customer.setCreateBy(getUsername());
customerService.insertCustomer(customer);
//提交OA中间表 TODO
//....
return toAjax(customerService.insertCustomer(customer));
}else{
customer.setUpdateBy(getUsername());
customerService.updateCustomer(customer);
//提交OA中间表 TODO
//....
return toAjax(customerService.updateCustomer(customer));
}
}
/** /**
* 删除客户管理 * 删除客户管理
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:remove')") @PreAuthorize("@ss.hasPermi('customer:customer:remove')")
@Log(title = "客户管理", businessType = BusinessType.DELETE) @Log(title = "客户信息删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{cusIds}") @DeleteMapping("/{cusIds}")
public AjaxResult remove(@PathVariable Long[] cusIds) public AjaxResult remove(@PathVariable String[] cusIds)
{ {
return toAjax(customerService.deleteCustomerByCusIds(cusIds)); return toAjax(customerService.deleteCustomerByCusIds(cusIds));
} }
@ -128,11 +158,12 @@ public class CustomerController extends BaseController
* 查询企查查客户列表 * 查询企查查客户列表
*/ */
@PreAuthorize("@ss.hasPermi('customer:customer:qcclist')") @PreAuthorize("@ss.hasPermi('customer:customer:qcclist')")
@Log(title = "企查查客户信息查询", businessType = BusinessType.OTHER)
@GetMapping("/qccListCustomer") @GetMapping("/qccListCustomer")
public TableDataInfo qccListCustomer(FuzzySearch qcc) public TableDataInfo qccListCustomer(FuzzySearch qcc)
{ {
String customerName = qcc.getName(); String customerName = qcc.getName();
String reqInterNme = "https://api.qichacha.com/FuzzySearch/GetList"; String reqInterNme = Qcc_serviceName;
List<FuzzySearch> result = new ArrayList<FuzzySearch>(); List<FuzzySearch> result = new ArrayList<FuzzySearch>();
try { try {
if(!StringUtils.isEmpty(customerName)){ if(!StringUtils.isEmpty(customerName)){

View File

@ -1,11 +1,15 @@
package com.ruoyi.web.utils; package com.ruoyi.web.utils;
import com.ruoyi.common.utils.uuid.UUID;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Random; import java.util.Random;
public class IdUtils { public class IdUtils {
/***********************************************生成永不重复的单号*********************************************/
/** /**
* 生成永不重复的订单号 * 生成永不重复的单号
* @param startLetter 订单号开头字符串 * @param startLetter 订单号开头字符串
* @param size 订单号中随机的大写字母个数 * @param size 订单号中随机的大写字母个数
* @return * @return
@ -52,6 +56,51 @@ public class IdUtils {
} }
return keyArr; return keyArr;
} }
/***********************************************生成永不重复的单号*********************************************/
/***********************************************获取随机UUID*********************************************/
/**
* 获取随机UUID
*
* @return 随机UUID
*/
public static String randomUUID()
{
return UUID.randomUUID().toString();
}
/**
* 简化的UUID去掉了横线
*
* @return 简化的UUID去掉了横线
*/
public static String simpleUUID()
{
return UUID.randomUUID().toString(true);
}
/**
* 获取随机UUID使用性能更好的ThreadLocalRandom生成UUID
*
* @return 随机UUID
*/
public static String fastUUID()
{
return UUID.fastUUID().toString();
}
/**
* 简化的UUID去掉了横线使用性能更好的ThreadLocalRandom生成UUID
*
* @return 简化的UUID去掉了横线
*/
public static String fastSimpleUUID()
{
return UUID.fastUUID().toString(true);
}
/***********************************************获取随机UUID*********************************************/
/** /**
* 测试 * 测试

View File

@ -9,3 +9,4 @@ sapWebservice.psw: QAZ54321
qichacha.key: 824936f8e78c4f4788978da38b26d488 qichacha.key: 824936f8e78c4f4788978da38b26d488
qichacha.secretKey: 8B9EB102FD17E0CF2EDEC0FB507DEC1E qichacha.secretKey: 8B9EB102FD17E0CF2EDEC0FB507DEC1E
qichacha.serviceName: https://api.qichacha.com/FuzzySearch/GetList

View File

@ -22,11 +22,6 @@ public enum BusinessType
*/ */
UPDATE, UPDATE,
/**
* 新增修改
*/
INSERT_OR_UPDATE,
/** /**
* 删除 * 删除
*/ */

View File

@ -16,7 +16,7 @@ public class Bank extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 银行ID */ /** 银行ID */
private Long bankId; private String bankId;
/** 银行名称 */ /** 银行名称 */
@Excel(name = "银行名称") @Excel(name = "银行名称")
@ -28,14 +28,14 @@ public class Bank extends BaseEntity
/** 客户ID */ /** 客户ID */
@Excel(name = "客户ID") @Excel(name = "客户ID")
private Long cusId; private String cusId;
public void setBankId(Long bankId) public void setBankId(String bankId)
{ {
this.bankId = bankId; this.bankId = bankId;
} }
public Long getBankId() public String getBankId()
{ {
return bankId; return bankId;
} }
@ -57,12 +57,12 @@ public class Bank extends BaseEntity
{ {
return bankAccount; return bankAccount;
} }
public void setCusId(Long cusId) public void setCusId(String cusId)
{ {
this.cusId = cusId; this.cusId = cusId;
} }
public Long getCusId() public String getCusId()
{ {
return cusId; return cusId;
} }

View File

@ -17,7 +17,7 @@ public class Customer extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 客户ID */ /** 客户ID */
private Long cusId; private String cusId;
/** 客户编码 */ /** 客户编码 */
@Excel(name = "客户编码") @Excel(name = "客户编码")
@ -106,12 +106,12 @@ public class Customer extends BaseEntity
/** 银行信息 */ /** 银行信息 */
private List<Bank> bankList; private List<Bank> bankList;
public void setCusId(Long cusId) public void setCusId(String cusId)
{ {
this.cusId = cusId; this.cusId = cusId;
} }
public Long getCusId() public String getCusId()
{ {
return cusId; return cusId;
} }

View File

@ -18,7 +18,7 @@ public interface CustomerMapper
* @param cusId 客户管理主键 * @param cusId 客户管理主键
* @return 客户管理 * @return 客户管理
*/ */
public Customer selectCustomerByCusId(Long cusId); public Customer selectCustomerByCusId(String cusId);
/** /**
* 查询客户管理列表 * 查询客户管理列表
@ -50,7 +50,7 @@ public interface CustomerMapper
* @param cusId 客户管理主键 * @param cusId 客户管理主键
* @return 结果 * @return 结果
*/ */
public int deleteCustomerByCusId(Long cusId); public int deleteCustomerByCusId(String cusId);
/** /**
* 批量删除客户管理 * 批量删除客户管理
@ -58,7 +58,7 @@ public interface CustomerMapper
* @param cusIds 需要删除的数据主键集合 * @param cusIds 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteCustomerByCusIds(Long[] cusIds); public int deleteCustomerByCusIds(String[] cusIds);
/** /**
* 批量删除银行 * 批量删除银行
@ -66,7 +66,7 @@ public interface CustomerMapper
* @param cusIds 需要删除的数据主键集合 * @param cusIds 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
public int deleteBankByCusIds(Long[] cusIds); public int deleteBankByCusIds(String[] cusIds);
/** /**
* 批量新增银行 * 批量新增银行
@ -83,5 +83,5 @@ public interface CustomerMapper
* @param cusId 客户管理ID * @param cusId 客户管理ID
* @return 结果 * @return 结果
*/ */
public int deleteBankByCusId(Long cusId); public int deleteBankByCusId(String cusId);
} }

View File

@ -17,7 +17,7 @@ public interface ICustomerService
* @param cusId 客户管理主键 * @param cusId 客户管理主键
* @return 客户管理 * @return 客户管理
*/ */
public Customer selectCustomerByCusId(Long cusId); public Customer selectCustomerByCusId(String cusId);
/** /**
* 查询客户管理列表 * 查询客户管理列表
@ -49,7 +49,7 @@ public interface ICustomerService
* @param cusIds 需要删除的客户管理主键集合 * @param cusIds 需要删除的客户管理主键集合
* @return 结果 * @return 结果
*/ */
public int deleteCustomerByCusIds(Long[] cusIds); public int deleteCustomerByCusIds(String[] cusIds);
/** /**
* 删除客户管理信息 * 删除客户管理信息
@ -57,5 +57,5 @@ public interface ICustomerService
* @param cusId 客户管理主键 * @param cusId 客户管理主键
* @return 结果 * @return 结果
*/ */
public int deleteCustomerByCusId(Long cusId); public int deleteCustomerByCusId(String cusId);
} }

View File

@ -1,8 +1,8 @@
package com.ruoyi.customer.service.impl; package com.ruoyi.customer.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.uuid.UUID;
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 java.util.ArrayList; import java.util.ArrayList;
@ -32,7 +32,7 @@ public class CustomerServiceImpl implements ICustomerService
* @return 客户管理 * @return 客户管理
*/ */
@Override @Override
public Customer selectCustomerByCusId(Long cusId) public Customer selectCustomerByCusId(String cusId)
{ {
return customerMapper.selectCustomerByCusId(cusId); return customerMapper.selectCustomerByCusId(cusId);
} }
@ -88,7 +88,7 @@ public class CustomerServiceImpl implements ICustomerService
*/ */
@Transactional @Transactional
@Override @Override
public int deleteCustomerByCusIds(Long[] cusIds) public int deleteCustomerByCusIds(String[] cusIds)
{ {
customerMapper.deleteBankByCusIds(cusIds); customerMapper.deleteBankByCusIds(cusIds);
return customerMapper.deleteCustomerByCusIds(cusIds); return customerMapper.deleteCustomerByCusIds(cusIds);
@ -102,7 +102,7 @@ public class CustomerServiceImpl implements ICustomerService
*/ */
@Transactional @Transactional
@Override @Override
public int deleteCustomerByCusId(Long cusId) public int deleteCustomerByCusId(String cusId)
{ {
customerMapper.deleteBankByCusId(cusId); customerMapper.deleteBankByCusId(cusId);
return customerMapper.deleteCustomerByCusId(cusId); return customerMapper.deleteCustomerByCusId(cusId);
@ -116,12 +116,13 @@ public class CustomerServiceImpl implements ICustomerService
public void insertBank(Customer customer) public void insertBank(Customer customer)
{ {
List<Bank> bankList = customer.getBankList(); List<Bank> bankList = customer.getBankList();
Long cusId = customer.getCusId(); String cusId = customer.getCusId();
if (StringUtils.isNotNull(bankList)) if (StringUtils.isNotNull(bankList))
{ {
List<Bank> list = new ArrayList<Bank>(); List<Bank> list = new ArrayList<Bank>();
for (Bank bank : bankList) for (Bank bank : bankList)
{ {
bank.setBankId(UUID.fastUUID().toString());
bank.setCusId(cusId); bank.setCusId(cusId);
list.add(bank); list.add(bank);
} }

View File

@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectCustomerByCusId" parameterType="Long" resultMap="CustomerBankResult"> <select id="selectCustomerByCusId" parameterType="java.lang.String" resultMap="CustomerBankResult">
select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_payment_terms, a.cus_phone_number, a.cus_industry_code, a.cus_group, a.cus_vat_no, a.cus_type, a.cus_country, a.cus_language, a.cus_label, a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark, a.cus_state, a.cus_approval_status, select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_payment_terms, a.cus_phone_number, a.cus_industry_code, a.cus_group, a.cus_vat_no, a.cus_type, a.cus_country, a.cus_language, a.cus_label, a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark, a.cus_state, a.cus_approval_status,
b.bank_id as sub_bank_id, b.bank_name as sub_bank_name, b.bank_account as sub_bank_account, b.cus_id as sub_cus_id b.bank_id as sub_bank_id, b.bank_name as sub_bank_name, b.bank_account as sub_bank_account, b.cus_id as sub_cus_id
from customer a from customer a
@ -78,9 +78,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where a.cus_id = #{cusId} where a.cus_id = #{cusId}
</select> </select>
<insert id="insertCustomer" parameterType="Customer" useGeneratedKeys="true" keyProperty="cusId"> <insert id="insertCustomer" parameterType="Customer">
insert into customer insert into customer
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cusId != null">cus_id,</if>
<if test="cusCode != null">cus_code,</if> <if test="cusCode != null">cus_code,</if>
<if test="cusName != null and cusName != ''">cus_name,</if> <if test="cusName != null and cusName != ''">cus_name,</if>
<if test="cusSapCode != null">cus_sap_code,</if> <if test="cusSapCode != null">cus_sap_code,</if>
@ -105,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_time create_time
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cusId != null">#{cusId},</if>
<if test="cusCode != null">#{cusCode},</if> <if test="cusCode != null">#{cusCode},</if>
<if test="cusName != null and cusName != ''">#{cusName},</if> <if test="cusName != null and cusName != ''">#{cusName},</if>
<if test="cusSapCode != null">#{cusSapCode},</if> <if test="cusSapCode != null">#{cusSapCode},</if>
@ -159,7 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where cus_id = #{cusId} where cus_id = #{cusId}
</update> </update>
<delete id="deleteCustomerByCusId" parameterType="Long"> <delete id="deleteCustomerByCusId" parameterType="java.lang.String">
delete from customer where cus_id = #{cusId} delete from customer where cus_id = #{cusId}
</delete> </delete>
@ -177,14 +179,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<delete id="deleteBankByCusId" parameterType="Long"> <delete id="deleteBankByCusId" parameterType="java.lang.String">
delete from bank where cus_id = #{cusId} delete from bank where cus_id = #{cusId}
</delete> </delete>
<insert id="batchBank"> <insert id="batchBank">
insert into bank(bank_name, bank_account, cus_id) values insert into bank(bank_id, bank_name, bank_account, cus_id) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
( #{item.bankName}, #{item.bankAccount}, #{item.cusId}) ( #{item.bankId}, #{item.bankName}, #{item.bankAccount}, #{item.cusId})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>

View File

@ -35,6 +35,15 @@ export function updateCustomer(data) {
}) })
} }
//提交客户信息
export function commitCustomer(data) {
return request({
url: '/customer/customer/commitCustomer',
method: 'post',
data: data
})
}
// 删除客户管理 // 删除客户管理
export function delCustomer(cusId) { export function delCustomer(cusId) {
return request({ return request({

View File

@ -310,8 +310,8 @@
</el-table> </el-table>
</el-form> </el-form>
<div slot="footer" class="dialog-footer" v-if="buttonShow"> <div slot="footer" class="dialog-footer" v-if="buttonShow">
<el-button @click="saveForm"> </el-button> <el-button @click="saveForm" v-hasPermi="['customer:customer:save']"> </el-button>
<el-button type="primary" plain @click="commitForm"> </el-button> <el-button type="primary" plain @click="commitForm" v-hasPermi="['customer:customer:commit']"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
@ -358,11 +358,11 @@
font-size: 14px; font-size: 14px;
word-break: break-all; word-break: break-all;
overflow-y: auto; /* 自动显示垂直滚动条 */ overflow-y: auto; /* 自动显示垂直滚动条 */
max-height: 580px; /* 设置最大高度,根据需要调整 */ max-height: 560px; /* 设置最大高度,根据需要调整 */
} }
</style> </style>
<script> <script>
import { listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer, qccListCustomer } from "@/api/customer/customer"; import { listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer, commitCustomer, qccListCustomer } from "@/api/customer/customer";
export default { export default {
name: "Customer", name: "Customer",
@ -531,7 +531,7 @@ export default {
this.form.cusGroup = 'Z001'; this.form.cusGroup = 'Z001';
this.form.cusCountry = 'CN'; this.form.cusCountry = 'CN';
this.form.cusLanguage = 'ZH'; this.form.cusLanguage = 'ZH';
this.form.cusType = 'saleCus'; this.form.cusType = '0';
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -566,25 +566,18 @@ export default {
} }
}); });
}, },
/** 提交按钮 */
commitForm() { commitForm() {
/*this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.bankList = this.bankList; this.form.bankList = this.bankList;
if (this.form.cusId != null) {
commitCustomer(this.form).then(response => { commitCustomer(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("提交成功");
this.open = false;
this.getList();
});
} else {
commitCustomer(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} }
} });
});*/
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {