diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java index 5b16e5d6..d9b5d33d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java @@ -1,6 +1,10 @@ package com.ruoyi.aftersales.controller; import java.util.List; + +import com.ruoyi.system.domain.SysCustomer; +import com.ruoyi.system.domain.SysMakeOrder; +import com.ruoyi.system.service.ISysMakeOrderService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -147,5 +151,14 @@ public class AftersalesComplaintNoticeController extends BaseController return toAjax(aftersalesComplaintNoticeService.restoreAftersalesComplaintNoticeById(id)); } + /** + * 查找与客户id关联的生成单号 + * */ + @ResponseBody + @GetMapping("/getMakeNosByCustomerId/{customerId}") + public List getCustomers(@PathVariable String customerId) { + List list = aftersalesComplaintNoticeService.selectMakeOrdersByCustomerId(customerId); + return list; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java index c85a3b4b..8b5a2363 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java @@ -2,6 +2,7 @@ package com.ruoyi.aftersales.service; import java.util.List; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; +import com.ruoyi.system.domain.SysMakeOrder; /** * 售后客诉通知单Service接口 @@ -72,4 +73,10 @@ public interface IAftersalesComplaintNoticeService * @return */ int restoreAftersalesComplaintNoticeById(Long complaintNoticeId); + + /** + * 查找与客户id关联的生成单号 + * @param customerId + * */ + List selectMakeOrdersByCustomerId(String customerId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java index ed17ea2e..088d4557 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java @@ -3,6 +3,10 @@ package com.ruoyi.aftersales.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysMakeOrder; +import com.ruoyi.system.mapper.SysMakeOrderMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeMapper; @@ -16,12 +20,16 @@ import com.ruoyi.common.core.text.Convert; * @author 刘晓旭 * @date 2024-04-25 */ +@Slf4j @Service public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplaintNoticeService { @Autowired private AftersalesComplaintNoticeMapper aftersalesComplaintNoticeMapper; + @Autowired + SysMakeOrderMapper sysMakeOrderMapper; + /** * 查询售后客诉通知单 * @@ -123,4 +131,17 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain { return aftersalesComplaintNoticeMapper.restoreAftersalesComplaintNoticeById(complaintNoticeId); } + + + /** + * 查找与客户id关联的生成单号 + * */ + @Override + public List selectMakeOrdersByCustomerId(String customerId) { + List sysMakeOrders = sysMakeOrderMapper.selectMakeOrdersByCustomerId(customerId); + if (!StringUtils.isNotEmpty(sysMakeOrders)){ + log.warn("未查找到与客户ID关联的生成订单数据, 客户ID: {}", customerId); + } + return sysMakeOrders; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java index e1ebee8d..a147c0af 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java @@ -285,15 +285,7 @@ public class SysCustomerController extends BaseController List list = sysCustomerService.selectSysCustomerToList(); return getDataTable(list); } - /** - * 客诉报告查询客户信息 - * */ - @ResponseBody - @GetMapping("/getCustomers") - public List getCustomers() { - List list = sysCustomerService.selectSysCustomerToList(); - return list; - } + @RequiresPermissions("system:customer:audit") @@ -497,4 +489,24 @@ public class SysCustomerController extends BaseController sysCustomerVo.setKeyword(keyword); return success(sysCustomerService.selectSysCustomerList(sysCustomerVo)); } + + + /** + * 客诉报告查询客户信息 + * */ + @ResponseBody + @GetMapping("/getCustomers") + public List getCustomers() { + List list = sysCustomerService.selectSysCustomerWithComplaintNotice(); + return list; + } + /** + * 客诉报告根据客户id查询客户姓名 + * */ + @GetMapping("/getCustomerNameByEnterpriseCode/{enterpriseCode}") + @ResponseBody + public AjaxResult getCustomerNameByEnterpriseCode(@PathVariable String enterpriseCode) { + SysCustomer sysCustomer = sysCustomerService.selectSysCustomerByCustomerId(enterpriseCode); + return AjaxResult.success(sysCustomer); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java index f74ecbed..736bc93a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java @@ -23,8 +23,6 @@ public class SysCustomer extends BaseEntity /** 客户表索引id */ private Long id; - private Long customerId; - /** 客户/企业代码 */ @Excel(name = "客户/企业ID") private String enterpriseCode; @@ -194,6 +192,15 @@ public class SysCustomer extends BaseEntity /** 申请时间 */ private Date applyTime; + + /*客户名称别名*/ + private String customerName; + + + /** 客户id别名*/ + private String customerId; + + public String getCustomerSign() { return customerSign; } @@ -203,13 +210,6 @@ public class SysCustomer extends BaseEntity } - public Long getCustomerId() { - return customerId; - } - - public void setCustomerId(Long customerId) { - this.customerId = customerId; - } public String getAuditStatus() { return auditStatus; @@ -244,9 +244,9 @@ public class SysCustomer extends BaseEntity this.customerOffice = customerOffice; } - public void setId(Long customerId) + public void setId(Long id) { - this.id = customerId; + this.id = id; } public Long getId() @@ -665,6 +665,22 @@ public class SysCustomer extends BaseEntity this.applyTime = applyTime; } + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -711,6 +727,8 @@ public class SysCustomer extends BaseEntity .append("updateInfoTime", getUpdateInfoTime()) .append("auditStatus",getAuditStatus()) .append("useStatus",getUseStatus()) + .append("customerId",getCustomerId()) + .append("customerName",getCustomerName()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/exportDto/SysCustomerDto.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/exportDto/SysCustomerDto.java index 16f8bf0f..933d9003 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/exportDto/SysCustomerDto.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/exportDto/SysCustomerDto.java @@ -196,15 +196,6 @@ public class SysCustomerDto extends SysCustomer @ExcelProperty("国家/地区编号") private String countryNumber; - public void setCustomerId(Long customerId) - { - this.customerId = customerId; - } - - public Long getCustomerId() - { - return customerId; - } public void setEnterpriseCode(String enterpriseCode) { this.enterpriseCode = enterpriseCode; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java index 7c74fac5..6e6faf75 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java @@ -33,6 +33,9 @@ public interface SysCustomerMapper */ List selectSysCustomerList(SysCustomerVo sysCustomerVo); + + List selectSysCustomerWithComplaintNotice(); + /** * 新增客户基本信息 * @@ -70,6 +73,8 @@ public interface SysCustomerMapper SysCustomer selectSysCustomerByEnterpriseCode(String enterpriseCode); + SysCustomer selectSysCustomerByCustomerId(String customerId); + int updateSysCustomerSign(SysCustomer sysCustomer); int restoreSysCustomerById(Long id); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeOrderMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeOrderMapper.java index 8a242f10..c243fac3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeOrderMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeOrderMapper.java @@ -87,4 +87,10 @@ public interface SysMakeOrderMapper * 生产订单完成的订单 */ public Integer selectSysMakeOrderByFinsh(); + + + /** + * 查找与客户id关联的生成单号 + * */ + public List selectMakeOrdersByCustomerId(String customerId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java index fa8336cb..e1f6ac8f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java @@ -75,6 +75,9 @@ public interface ISysCustomerService public SysCustomer selectSysCustomerByEnterpriseCode(String enterpriseCode); + + public SysCustomer selectSysCustomerByCustomerId(String customerId); + public int add(SysCustomer sysCustomer); public String getId(); @@ -91,4 +94,6 @@ public interface ISysCustomerService ProcessInstance updateSysCustomerVo(SysCustomer sysCustomer); CustomerDto selectCustomerDtoByEnterpriseCode(String customerId); + + List selectSysCustomerWithComplaintNotice(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java index 5d204d7c..361c1242 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java @@ -250,6 +250,12 @@ public class SysCustomerServiceImpl implements ISysCustomerService return customerDto; } + @Override + public List selectSysCustomerWithComplaintNotice() { + List sysCustomers = sysCustomerMapper.selectSysCustomerWithComplaintNotice(); + return sysCustomers; + } + @Override public int deleteSysCustomerByIds(String[] ids) { return sysCustomerMapper.deleteSysCustomerByIds(ids); @@ -294,6 +300,12 @@ public class SysCustomerServiceImpl implements ISysCustomerService return sysCustomerMapper.selectSysCustomerByEnterpriseCode(enterpriseCode); } + + @Override + public SysCustomer selectSysCustomerByCustomerId(String enterpriseCode) { + return sysCustomerMapper.selectSysCustomerByCustomerId(enterpriseCode); + } + @Override public int add(SysCustomer sysCustomer) { return sysCustomerMapper.insertSysCustomer(sysCustomer); @@ -377,7 +389,7 @@ public class SysCustomerServiceImpl implements ISysCustomerService SysUser user = ShiroUtils.getSysUser(); sysCustomer.setApplyUser(user.getLoginName()); sysCustomer.setApplyTime(DateUtils.getNowDate()); - if (sysCustomer.getCustomerId() == null || sysCustomer.getCustomerId() == 0){ + if (sysCustomer.getId() == null || sysCustomer.getId() == 0){ insertSysCustomer(sysCustomer); } // 启动流程 @@ -430,4 +442,6 @@ public class SysCustomerServiceImpl implements ISysCustomerService variables.put("authority",1); } } + + } diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml index d2905025..1566f631 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml @@ -113,6 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + select id,enterprise_code,enterprise_name,english_name,customer_abbreviation ,customer_purser , @@ -169,7 +171,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and s.customer_sign = #{customerSign} - + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html index 32244112..bd79de4a 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html @@ -9,34 +9,37 @@
- +
- +
- +
- +
- +
- +
-
- +
+
- +
@@ -74,24 +77,113 @@ } //获取客户信息 - $(document).ready(function() { - // 初始化客户编号下拉框 - $.getJSON(ctx + "system/customer/getCustomers", function(customers) { - $.each(customers, function(index, customer) { - $('#customerId').append(new Option(customer.customerId, customer.customerId)); - }); - }); + // 初始化时默认加载客户编号列表 + loadCustomerIds(); - // 监听客户编号选择事件 + // 监听客户编号下拉框的变化 $('#customerId').on('change', function() { - const customerId = $(this).val(); - $.getJSON(prefix + "/getCustomerDetails?customerId=" + encodeURIComponent(customerId), function(customer) { - $('#customerName').val(customer.customerName); - }); + var selectedCustomerId = $(this).val(); // 获取选中的客户ID + if (selectedCustomerId) { + // 发起Ajax请求获取客户名称 + $.ajax({ + type: 'GET', + url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedCustomerId, // 替换为你的实际API路径 + dataType: 'json', // 假设返回的数据格式是JSON + success: function(data) { + console.log(data); + // 将获取到的客户名称填充到输入框 + if(data.data == null){ + // 如果返回的数据有问题,可以给出提示或处理 + alert('未能获取到客户名称!'); + } + $('input[name="customerName"]').val(data.data.customerName); + }, + error: function(jqXHR, textStatus, errorThrown) { + console.error('Error:', textStatus, errorThrown); + alert('查询客户名称时发生错误!'); + } + }); + } else { + // 如果没有选择客户ID,清空客户名称输入框 + $('input[name="customerName"]').val(''); + } }); }); + + //获取已经选择客户Id相关的生产单号 + function loadMakeNos() { + var selectedCustomerId = $('#customerId').val(); // 获取选中的客户ID + if (!selectedCustomerId) { + // 如果没有选中客户,则清空生产单号下拉框并可添加提示信息 + $('#makeNo').empty().append(''); + return; // 直接返回,不发起请求 + } + + var makeNoUrl = ctx + 'aftersales/complaintNotice/getMakeNosByCustomerId/' + selectedCustomerId; // 假定的后端接口URL,根据实际调整 + + $.ajax({ + type: 'GET', + url: makeNoUrl, + dataType: 'json', + success: function(data) { + console.log(data); + if (data && Array.isArray(data)) { + var selectElement = $('#makeNo'); // 获取生产单号下拉框元素 + selectElement.empty(); // 清空现有选项 + + // 添加默认选项(如果需要) + selectElement.append(''); + + // 遍历返回的数据,添加为下拉框的选项 + $.each(data, function(index, item) { + // 假设item有makeNo属性,代表生产单号 + selectElement.append(''); + }); + } else { + console.error('Data is not an array or is empty.'); + // 可能还需要处理UI显示,比如提示无相关生产单号 + } + }, + error: function(jqXHR, textStatus, errorThrown) { + console.error('Failed to fetch make numbers: ' + textStatus + ', ' + errorThrown); + // 同样考虑UI反馈,如提示加载失败 + } + }); + } + // 假设的加载客户编号列表函数 + function loadCustomerIds() { + var url = ctx + 'system/customer/getCustomers'; + + $.ajax({ + type: 'GET', // 请求类型 + url: url, // 后端接口URL + dataType: 'json', // 预期服务器返回的数据类型 + success: function(data) { + if (data && Array.isArray(data)) { + var selectElement = $('#customerId'); // 获取客户编号下拉框元素 + + // 清空下拉框现有选项 + selectElement.empty(); + + // 添加默认选项(如果需要) + selectElement.append(''); + + // 遍历返回的数据,添加为下拉框的选项 + $.each(data, function(index, item) { + // 假设item有id和name两个属性,分别代表客户ID和客户编号 + selectElement.append(''); + }); + } else { + console.error('Data is not an array or is empty.'); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); + } + }); + } \ No newline at end of file