From 26b071c4477042877db370c79786db229fa46bbf Mon Sep 17 00:00:00 2001 From: xd <844539747@qq.com> Date: Mon, 1 Apr 2024 11:13:35 +0800 Subject: [PATCH] '123' --- .../customer/CustomerController.java | 51 +++++++++++++++---- .../java/com/ruoyi/web/utils/IdUtils.java | 51 ++++++++++++++++++- ruoyi-admin/src/main/resources/common.yml | 1 + .../com/ruoyi/common/enums/BusinessType.java | 5 -- .../java/com/ruoyi/customer/domain/Bank.java | 22 ++++---- .../com/ruoyi/customer/domain/Customer.java | 6 +-- .../ruoyi/customer/mapper/CustomerMapper.java | 36 ++++++------- .../customer/service/ICustomerService.java | 22 ++++---- .../service/impl/CustomerServiceImpl.java | 11 ++-- .../mapper/customer/CustomerMapper.xml | 14 ++--- ruoyi-ui/src/api/customer/customer.js | 9 ++++ .../src/views/customer/customer/index.vue | 33 +++++------- 12 files changed, 171 insertions(+), 90 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java index b0c7955..cb0632d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/customer/CustomerController.java @@ -5,6 +5,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson2.JSON; 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.QccFuzzySearchJsonResult; import com.ruoyi.web.utils.IdUtils; @@ -43,11 +44,14 @@ import com.ruoyi.common.core.page.TableDataInfo; @PropertySource("classpath:/common.yml") public class CustomerController extends BaseController { + // 接口请求Key @Value("${qichacha.key}") private String Qcc_Key; - // 接口请求Key @Value("${qichacha.secretKey}") private String Qcc_SecretKey; + // 接口请求地址 + @Value("${qichacha.serviceName}") + private String Qcc_serviceName; @Autowired private ICustomerService customerService; @@ -68,7 +72,7 @@ public class CustomerController extends BaseController * 导出客户管理列表 */ @PreAuthorize("@ss.hasPermi('customer:customer:export')") - @Log(title = "客户管理", businessType = BusinessType.EXPORT) + @Log(title = "客户信息导出", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, Customer customer) { @@ -82,7 +86,7 @@ public class CustomerController extends BaseController */ @PreAuthorize("@ss.hasPermi('customer:customer:query')") @GetMapping(value = "/{cusId}") - public AjaxResult getInfo(@PathVariable("cusId") Long cusId) + public AjaxResult getInfo(@PathVariable("cusId") String cusId) { return success(customerService.selectCustomerByCusId(cusId)); } @@ -90,11 +94,12 @@ public class CustomerController extends BaseController /** * 新增客户管理 */ - @PreAuthorize("@ss.hasPermi('customer:customer:add')") - @Log(title = "客户管理", businessType = BusinessType.INSERT) + @PreAuthorize("@ss.hasPermi('customer:customer:save')") + @Log(title = "客户信息新增", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Customer customer) { + customer.setCusId(UUID.fastUUID().toString()); customer.setCusCode(IdUtils.createNo("KH_",2)); customer.setCreateBy(getUsername()); return toAjax(customerService.insertCustomer(customer)); @@ -103,8 +108,8 @@ public class CustomerController extends BaseController /** * 修改客户管理 */ - @PreAuthorize("@ss.hasPermi('customer:customer:edit')") - @Log(title = "客户管理", businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('customer:customer:save')") + @Log(title = "客户信息修改", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody Customer customer) { @@ -112,13 +117,38 @@ public class CustomerController extends BaseController 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')") - @Log(title = "客户管理", businessType = BusinessType.DELETE) + @Log(title = "客户信息删除", businessType = BusinessType.DELETE) @DeleteMapping("/{cusIds}") - public AjaxResult remove(@PathVariable Long[] cusIds) + public AjaxResult remove(@PathVariable String[] cusIds) { return toAjax(customerService.deleteCustomerByCusIds(cusIds)); } @@ -128,11 +158,12 @@ public class CustomerController extends BaseController * 查询企查查客户列表 */ @PreAuthorize("@ss.hasPermi('customer:customer:qcclist')") + @Log(title = "企查查客户信息查询", businessType = BusinessType.OTHER) @GetMapping("/qccListCustomer") public TableDataInfo qccListCustomer(FuzzySearch qcc) { String customerName = qcc.getName(); - String reqInterNme = "https://api.qichacha.com/FuzzySearch/GetList"; + String reqInterNme = Qcc_serviceName; List result = new ArrayList(); try { if(!StringUtils.isEmpty(customerName)){ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/IdUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/IdUtils.java index ca4653d..177f7e3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/IdUtils.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/IdUtils.java @@ -1,11 +1,15 @@ package com.ruoyi.web.utils; +import com.ruoyi.common.utils.uuid.UUID; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; public class IdUtils { + + /***********************************************生成永不重复的单号*********************************************/ /** - * 生成永不重复的订单号 + * 生成永不重复的单号 * @param startLetter 订单号开头字符串 * @param size 订单号中随机的大写字母个数 * @return @@ -52,6 +56,51 @@ public class IdUtils { } 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*********************************************/ /** * 测试 diff --git a/ruoyi-admin/src/main/resources/common.yml b/ruoyi-admin/src/main/resources/common.yml index 4f7d077..b4e5dca 100644 --- a/ruoyi-admin/src/main/resources/common.yml +++ b/ruoyi-admin/src/main/resources/common.yml @@ -9,3 +9,4 @@ sapWebservice.psw: QAZ54321 qichacha.key: 824936f8e78c4f4788978da38b26d488 qichacha.secretKey: 8B9EB102FD17E0CF2EDEC0FB507DEC1E +qichacha.serviceName: https://api.qichacha.com/FuzzySearch/GetList diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index 0999c54..f6bf342 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -22,11 +22,6 @@ public enum BusinessType */ UPDATE, - /** - * 新增修改 - */ - INSERT_OR_UPDATE, - /** * 删除 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Bank.java b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Bank.java index 437272a..2d9efb5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Bank.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Bank.java @@ -7,7 +7,7 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 银行对象 bank - * + * * @author ruoyi * @date 2024-03-25 */ @@ -16,7 +16,7 @@ public class Bank extends BaseEntity private static final long serialVersionUID = 1L; /** 银行ID */ - private Long bankId; + private String bankId; /** 银行名称 */ @Excel(name = "银行名称") @@ -28,41 +28,41 @@ public class Bank extends BaseEntity /** 客户ID */ @Excel(name = "客户ID") - private Long cusId; + private String cusId; - public void setBankId(Long bankId) + public void setBankId(String bankId) { this.bankId = bankId; } - public Long getBankId() + public String getBankId() { return bankId; } - public void setBankName(String bankName) + public void setBankName(String bankName) { this.bankName = bankName; } - public String getBankName() + public String getBankName() { return bankName; } - public void setBankAccount(String bankAccount) + public void setBankAccount(String bankAccount) { this.bankAccount = bankAccount; } - public String getBankAccount() + public String getBankAccount() { return bankAccount; } - public void setCusId(Long cusId) + public void setCusId(String cusId) { this.cusId = cusId; } - public Long getCusId() + public String getCusId() { return cusId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java index 3fceeb9..90d33d2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/domain/Customer.java @@ -17,7 +17,7 @@ public class Customer extends BaseEntity private static final long serialVersionUID = 1L; /** 客户ID */ - private Long cusId; + private String cusId; /** 客户编码 */ @Excel(name = "客户编码") @@ -106,12 +106,12 @@ public class Customer extends BaseEntity /** 银行信息 */ private List bankList; - public void setCusId(Long cusId) + public void setCusId(String cusId) { this.cusId = cusId; } - public Long getCusId() + public String getCusId() { return cusId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/mapper/CustomerMapper.java b/ruoyi-system/src/main/java/com/ruoyi/customer/mapper/CustomerMapper.java index d1c8172..ee347d9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/mapper/CustomerMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/mapper/CustomerMapper.java @@ -6,23 +6,23 @@ import com.ruoyi.customer.domain.Bank; /** * 客户管理Mapper接口 - * + * * @author ruoyi * @date 2024-03-25 */ -public interface CustomerMapper +public interface CustomerMapper { /** * 查询客户管理 - * + * * @param cusId 客户管理主键 * @return 客户管理 */ - public Customer selectCustomerByCusId(Long cusId); + public Customer selectCustomerByCusId(String cusId); /** * 查询客户管理列表 - * + * * @param customer 客户管理 * @return 客户管理集合 */ @@ -30,7 +30,7 @@ public interface CustomerMapper /** * 新增客户管理 - * + * * @param customer 客户管理 * @return 结果 */ @@ -38,7 +38,7 @@ public interface CustomerMapper /** * 修改客户管理 - * + * * @param customer 客户管理 * @return 结果 */ @@ -46,42 +46,42 @@ public interface CustomerMapper /** * 删除客户管理 - * + * * @param cusId 客户管理主键 * @return 结果 */ - public int deleteCustomerByCusId(Long cusId); + public int deleteCustomerByCusId(String cusId); /** * 批量删除客户管理 - * + * * @param cusIds 需要删除的数据主键集合 * @return 结果 */ - public int deleteCustomerByCusIds(Long[] cusIds); + public int deleteCustomerByCusIds(String[] cusIds); /** * 批量删除银行 - * + * * @param cusIds 需要删除的数据主键集合 * @return 结果 */ - public int deleteBankByCusIds(Long[] cusIds); - + public int deleteBankByCusIds(String[] cusIds); + /** * 批量新增银行 - * + * * @param bankList 银行列表 * @return 结果 */ public int batchBank(List bankList); - + /** * 通过客户管理主键删除银行信息 - * + * * @param cusId 客户管理ID * @return 结果 */ - public int deleteBankByCusId(Long cusId); + public int deleteBankByCusId(String cusId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/service/ICustomerService.java b/ruoyi-system/src/main/java/com/ruoyi/customer/service/ICustomerService.java index ec909c9..78ca274 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/service/ICustomerService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/service/ICustomerService.java @@ -5,23 +5,23 @@ import com.ruoyi.customer.domain.Customer; /** * 客户管理Service接口 - * + * * @author ruoyi * @date 2024-03-25 */ -public interface ICustomerService +public interface ICustomerService { /** * 查询客户管理 - * + * * @param cusId 客户管理主键 * @return 客户管理 */ - public Customer selectCustomerByCusId(Long cusId); + public Customer selectCustomerByCusId(String cusId); /** * 查询客户管理列表 - * + * * @param customer 客户管理 * @return 客户管理集合 */ @@ -29,7 +29,7 @@ public interface ICustomerService /** * 新增客户管理 - * + * * @param customer 客户管理 * @return 结果 */ @@ -37,7 +37,7 @@ public interface ICustomerService /** * 修改客户管理 - * + * * @param customer 客户管理 * @return 结果 */ @@ -45,17 +45,17 @@ public interface ICustomerService /** * 批量删除客户管理 - * + * * @param cusIds 需要删除的客户管理主键集合 * @return 结果 */ - public int deleteCustomerByCusIds(Long[] cusIds); + public int deleteCustomerByCusIds(String[] cusIds); /** * 删除客户管理信息 - * + * * @param cusId 客户管理主键 * @return 结果 */ - public int deleteCustomerByCusId(Long cusId); + public int deleteCustomerByCusId(String cusId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/customer/service/impl/CustomerServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/customer/service/impl/CustomerServiceImpl.java index 1dac82d..bd8c7b5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/customer/service/impl/CustomerServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/customer/service/impl/CustomerServiceImpl.java @@ -1,8 +1,8 @@ package com.ruoyi.customer.service.impl; import java.util.List; - import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.utils.uuid.UUID; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -32,7 +32,7 @@ public class CustomerServiceImpl implements ICustomerService * @return 客户管理 */ @Override - public Customer selectCustomerByCusId(Long cusId) + public Customer selectCustomerByCusId(String cusId) { return customerMapper.selectCustomerByCusId(cusId); } @@ -88,7 +88,7 @@ public class CustomerServiceImpl implements ICustomerService */ @Transactional @Override - public int deleteCustomerByCusIds(Long[] cusIds) + public int deleteCustomerByCusIds(String[] cusIds) { customerMapper.deleteBankByCusIds(cusIds); return customerMapper.deleteCustomerByCusIds(cusIds); @@ -102,7 +102,7 @@ public class CustomerServiceImpl implements ICustomerService */ @Transactional @Override - public int deleteCustomerByCusId(Long cusId) + public int deleteCustomerByCusId(String cusId) { customerMapper.deleteBankByCusId(cusId); return customerMapper.deleteCustomerByCusId(cusId); @@ -116,12 +116,13 @@ public class CustomerServiceImpl implements ICustomerService public void insertBank(Customer customer) { List bankList = customer.getBankList(); - Long cusId = customer.getCusId(); + String cusId = customer.getCusId(); if (StringUtils.isNotNull(bankList)) { List list = new ArrayList(); for (Bank bank : bankList) { + bank.setBankId(UUID.fastUUID().toString()); bank.setCusId(cusId); list.add(bank); } diff --git a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml index 3676248..4a13247 100644 --- a/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/customer/CustomerMapper.xml @@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 from customer a @@ -78,9 +78,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where a.cus_id = #{cusId} - + insert into customer + cus_id, cus_code, cus_name, cus_sap_code, @@ -105,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time + #{cusId}, #{cusCode}, #{cusName}, #{cusSapCode}, @@ -159,7 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where cus_id = #{cusId} - + delete from customer where cus_id = #{cusId} @@ -177,14 +179,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + delete from bank where cus_id = #{cusId} - insert into bank(bank_name, bank_account, cus_id) values + insert into bank(bank_id, bank_name, bank_account, cus_id) values - ( #{item.bankName}, #{item.bankAccount}, #{item.cusId}) + ( #{item.bankId}, #{item.bankName}, #{item.bankAccount}, #{item.cusId}) diff --git a/ruoyi-ui/src/api/customer/customer.js b/ruoyi-ui/src/api/customer/customer.js index 5626766..38435f2 100644 --- a/ruoyi-ui/src/api/customer/customer.js +++ b/ruoyi-ui/src/api/customer/customer.js @@ -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) { return request({ diff --git a/ruoyi-ui/src/views/customer/customer/index.vue b/ruoyi-ui/src/views/customer/customer/index.vue index 1777016..8afe8be 100644 --- a/ruoyi-ui/src/views/customer/customer/index.vue +++ b/ruoyi-ui/src/views/customer/customer/index.vue @@ -310,8 +310,8 @@ @@ -358,11 +358,11 @@ font-size: 14px; word-break: break-all; overflow-y: auto; /* 自动显示垂直滚动条 */ - max-height: 580px; /* 设置最大高度,根据需要调整 */ + max-height: 560px; /* 设置最大高度,根据需要调整 */ }