diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java index d3f25a36..f16eb541 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java @@ -68,7 +68,7 @@ public class AftersalesComplaintNotice extends BaseEntity private Integer enterpriseSum; - + private String emergencyDegree; private List noticeDetailList; @@ -203,6 +203,14 @@ public class AftersalesComplaintNotice extends BaseEntity this.snCode = snCode; } + public String getEmergencyDegree() { + return emergencyDegree; + } + + public void setEmergencyDegree(String emergencyDegree) { + this.emergencyDegree = emergencyDegree; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -216,6 +224,7 @@ public class AftersalesComplaintNotice extends BaseEntity .append("materialName", getMaterialName()) .append("materialSum", getMaterialSum()) .append("enterpriseSum", getEnterpriseSum()) + .append("emergencyDegree", getEmergencyDegree()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) 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 b6cb1fd4..576735da 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,7 +2,7 @@ package com.ruoyi.aftersales.service; import java.util.List; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; -import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; +import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.system.domain.SysMakeOrder; @@ -94,4 +94,9 @@ public interface IAftersalesComplaintNoticeService * 根据客诉单号查找售后客诉通知单 * */ List selectAftersalesComplaintNoticeListByCodes(String[] complaintNoticeCodes); + + /** + * 导出售后客诉通知单 + * */ + List exportAfterComplaintExportList(List list); } 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 11740ae5..b3c9bb96 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 @@ -1,15 +1,14 @@ package com.ruoyi.aftersales.service.impl; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Optional; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; +import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeDetailMapper; import com.ruoyi.common.core.redis.RedisCache; @@ -18,15 +17,12 @@ 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.domain.SysMakeorderBom; import com.ruoyi.system.domain.SysSalesOrder; import com.ruoyi.system.domain.SysSalesOrderChild; import com.ruoyi.system.mapper.SysMakeOrderMapper; import com.ruoyi.system.mapper.SysMakeorderBomMapper; import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.system.mapper.SysSalesOrderMapper; -import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; -import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -50,6 +46,7 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain @Autowired private AftersalesComplaintNoticeMapper aftersalesComplaintNoticeMapper; + @Autowired private SysMakeOrderMapper sysMakeOrderMapper; @@ -297,4 +294,54 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain String newCode = df.format(Integer.parseInt(roundCode)); return newCode; } + + + /** + * 导出客诉单明细 + * */ + @Override + public List exportAfterComplaintExportList(List list) { + // 获取所有的客诉单号 + List collectNoticeCodes = list.stream() + .map(AftersalesComplaintNotice::getComplaintNoticeCode) + .collect(Collectors.toList()); + + // 根据客诉单号查询对应的客诉详情列表 + List noticeDetails = noticeDetailMapper.selectAftersalesComplaintNoticeDetailListByCodeList(collectNoticeCodes); + + // 创建一个 AftersalesComplaintNotice 的 Map,键为客诉单号 + Map aftersalesComplaintNoticeMap = list.stream() + .collect(Collectors.toMap(AftersalesComplaintNotice::getComplaintNoticeCode, Function.identity())); + + // 初始化导出列表 + List aftersalesComplaintExportVOS = new ArrayList<>(); + + for (AftersalesComplaintNoticeDetail detail : noticeDetails) { + AftersalesComplaintExportVO exportVo = new AftersalesComplaintExportVO(); + + // 从 AftersalesComplaintNoticeDetail 填充数据 + exportVo.setComplaintProblem(detail.getComplaintProblem()); + exportVo.setEmergencyDegree(detail.getEmergencyDegree()); + + // 从 AftersalesComplaintNotice 填充数据,通过客诉单号进行关联 + AftersalesComplaintNotice notice = aftersalesComplaintNoticeMap.get(detail.getComplaintNoticeCode()); + if (notice != null) { + exportVo.setSnCode(notice.getSnCode()); + exportVo.setComplaintNoticeCode(notice.getComplaintNoticeCode()); + exportVo.setSalesOrderCode(notice.getSalesOrderCode()); + exportVo.setCustomerName(notice.getCustomerName()); + exportVo.setMakeNo(notice.getMakeNo()); + exportVo.setMaterialNo(notice.getMaterialNo()); + exportVo.setMaterialName(notice.getMaterialName()); + exportVo.setMaterialBrand(notice.getMaterialBrand()); + exportVo.setMaterialModelCode(notice.getMaterialModelCode()); + exportVo.setClosingProcedures(notice.getClosingProcedures()); + } + + // 添加到结果列表 + aftersalesComplaintExportVOS.add(exportVo); + } + + return aftersalesComplaintExportVOS; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java index 2984298a..64bb1191 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java @@ -2,6 +2,7 @@ package com.ruoyi.quality.controller; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; +import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeDetailService; import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeService; @@ -10,6 +11,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysMakeOrder; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -67,11 +69,21 @@ public class QualityComplaintNoticeController extends BaseController { @Log(title = "售后客诉通知单", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(AftersalesComplaintNoticeDetail aftersalesComplaintNoticeDetail) + public AjaxResult export(AftersalesComplaintNotice complaintNotice,String ids) { - List complaintNoticeDetails = complaintNoticeDetailService.selectAftersalesComplaintNoticeDetailList(aftersalesComplaintNoticeDetail); - ExcelUtil util = new ExcelUtil(AftersalesComplaintNoticeDetail.class); - return util.exportExcel(complaintNoticeDetails, "售后客诉通知单数据"); + if(StringUtils.isEmpty(ids)){ + List list = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeList(complaintNotice); + List exportAftersalesComplaintNoticeVos = aftersalesComplaintNoticeService.exportAfterComplaintExportList(list); + ExcelUtil util = new ExcelUtil(AftersalesComplaintExportVO.class); + return util.exportExcel(exportAftersalesComplaintNoticeVos, "售后客诉通知单数据"); + }else{ + String[] complaintNoticeCodes = ids.split(","); + List list = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeListByCodes(complaintNoticeCodes); + List exportAftersalesComplaintNoticeVos = aftersalesComplaintNoticeService.exportAfterComplaintExportList(list); + ExcelUtil util = new ExcelUtil(AftersalesComplaintExportVO.class); + return util.exportExcel(exportAftersalesComplaintNoticeVos, "售后客诉通知单数据"); + } + } /** diff --git a/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html b/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html index 0fd70c14..f2b32aa4 100644 --- a/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html +++ b/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html @@ -10,6 +10,10 @@
    +
  • + + +
  • @@ -21,17 +25,14 @@
  • -
  • - - -
  • +
  • + + +
  • @@ -56,7 +57,7 @@
@@ -70,7 +71,6 @@ var returnInspectionFlag = [[${@permission.hasPermi('quality:complaintNotice:returnInspectionProcessing')}]]; var detailFlag = [[${@permission.hasPermi('quality:complaintNotice:detail')}]]; var removeFlag = [[${@permission.hasPermi('quality:complaintNotice:remove')}]]; - var emergencyDegreeDatas = [[${@dict.getType('aftersales_emergency_degree')}]]; var closingProceduresDatas = [[${@dict.getType('aftersales_closing_procedures')}]]; var prefix = ctx + "quality/complaintNotice"; @@ -85,58 +85,83 @@ columns: [{ checkbox: true }, - { - title: '客诉通知详情ID', - field: 'complaintNoticeId', - visible: false - }, - { - title: '客诉单号', - field: 'complaintNoticeCode', - }, + { + title: '客诉通知详情ID', + field: 'complaintNoticeId', + visible: false + }, + { + title: 'SN号', + field: 'snCode', + align: 'center', + }, + { + title: '客诉单号', + field: 'complaintNoticeCode', + align: 'center', + }, + { + title: '销售订单号', + field: 'salesOrderCode', + align: 'center', + }, { title: '是否结案', field: 'closingProcedures', + align: 'center', formatter: function(value, row, index) { return $.table.selectDictLabel(closingProceduresDatas, value); } }, - - { - title: '关联生产单号', - field: 'makeNo', - }, - { - title: '紧急程度', - field: 'emergencyDegree', - formatter: function(value, row, index) { - return $.table.selectDictLabel(emergencyDegreeDatas, value); - } - }, - - { - title: '物料合计', - field: 'materialSum', - }, - { - title: '数量合计', - field: 'enterpriseSum', - }, - { - title: '录入人', - field: 'createBy', - }, - { - title: '录入时间', - field: 'createTime', - }, - { - title: '更新人', - field: 'updateBy', - }, { - title: '上次更新时间', + title: '客户名称', + field: 'customerName', + align: 'center', + }, + { + title: '关联生产单号', + field: 'makeNo', + align: 'center', + }, + { + title: '料号', + field: 'materialNo', + align: 'center', + }, + { + title: '物料名称', + field: 'materialName', + align: 'center', + }, + { + title: '设备型号', + field: 'materialModelCode', + align: 'center', + }, + { + title: '品牌', + field: 'materialBrand', + align: 'center', + }, + { + title: '录入人', + field: 'createBy', + align: 'center', + }, + { + title: '录入时间', + field: 'createTime', + align: 'center', + }, + { + title: '更新人', + field: 'updateBy', + align: 'center', + }, + { + title: '更新时间', field: 'updateTime', + align: 'center', }, { title: '操作', @@ -170,6 +195,31 @@ console.log(url); $.modal.open("退检处理",url); } + + // 导出 + function exportExcel() { + var ids = $.table.selectColumns("complaintNoticeCode"); + var dataParam = $("#formId").serializeArray(); + + let tipMsg = "确定导出当前所有数据吗?"; + if ($.common.isNotEmpty(ids)) { + tipMsg = `确定导出 ${ids} 数据吗?`; + dataParam.push({ "name": "ids", "value": ids }); + } + $.modal.confirm(tipMsg, function () { + $.modal.loading("正在导出数据,请稍后..."); + $.post( prefix + "/export", dataParam, function (result) { + if (result.code === web_status.SUCCESS) { + window.location.href = ctx + "common/download?fileName="+ encodeURI(result.msg) + "&delete=" + true; + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + }); + }); + } + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html b/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html index 7d312c8e..8d77ad18 100644 --- a/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html +++ b/ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html @@ -1,46 +1,67 @@ - +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- + +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
@@ -60,229 +81,41 @@ var aftersalesComplaintNotice = [[${aftersalesComplaintNotice}]]; var prefix = ctx + "aftersales/complaintNotice" var customerId = [[${aftersalesComplaintNotice.customerId}]] - var makeNo = [[${aftersalesComplaintNotice.makeNo}]] + var makeNo = [[${aftersalesComplaintNotice.makeNo}]]; + var emergencyDegreeDatas = [[${@dict.getType('aftersales_emergency_degree')}]]; $("#form-complaintNotice-edit").validate({ focusCleanup: true }); - // 新增提交 - function submitHandler() { - // 获取表单数据 - // const complaintNoticeData = $("#form-complaintNotice-edit").serializeArray(); - // 获取表单数据 - const complaintNoticeData = $("#form-complaintNotice-edit").serializeArray().reduce((obj, item) => { - obj[item.name] = item.value; - return obj; - }, {}); - // 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 - var table = $('#bootstrap-table').bootstrapTable('getData'); - - // 将表数据转换成与complaintNoticeData格式一致的数组 - var materialDataList = table.map(function(item) { - // 根据实际字段名调整 - return { - "materialNo": item.materialNo, // 假设id对应materialId - "materialPhotourl": item.materialPhotourl, // 假设quantity是物料数量字段 - "materialName": item.materialName, - "materialType": item.materialType, - "materialUnit": item.materialUnit, - "materialBrand": item.materialBrand, - "materialDescribe": item.materialDescribe, - "snCode": item.snCode, - "complaintProblem": item.complaintProblem, - // "emergencyDegree": item.emergencyDegree, - "adverseReportUrl": item.adverseReportUrl, - // ...其他字段 - }; - }); - - // 合并表单数据和表格数据 - //const combinedData = Object.assign({}, ...complaintNoticeData.map(item => ({ [item.name]: item.value })), ...materialData); - const combinedData = Object.assign({}, complaintNoticeData, { aftersalesMaterialVOs: materialDataList }); - - console.log(combinedData) - // 使用 JSON.stringify() 序列化数据 - const jsonData = JSON.stringify(combinedData); - // 发送 AJAX 请求到后端接口 - $.operate.saveJson(prefix + "/edit", jsonData); - } - - - //获取客户信息 - $(document).ready(function() { - // 初始化时默认加载客户编号列表 - loadCustomerIds(); - - // 监听客户编号下拉框的变化 - $('#customerId').on('change', function() { - 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(''); - }); - $("#makeNo").val(makeNo); - } else { - console.error('数据为空.'); - // 可能还需要处理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(''); - }); - $('#customerId').val(customerId); - loadMakeNos(); - } else { - $.modal.errMsg("数据为空"); - } - }, - // error: function(jqXHR, textStatus, errorThrown) { - // console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); - // } - }); - } - - // 点击选择物料按钮 - function insertRow() { - var selectedMakeNo = $("#makeNo").val(); - if (!selectedMakeNo) { - alert("请先选择生产单号。"); - return; - } - var encodedMakeNo = encodeURIComponent(selectedMakeNo); - var url = ctx + 'aftersales/complaintNotice/materialSelect?makeNo=' + encodedMakeNo; - var options = { - title: '选择物料', - url: url, - callBack: doSubmit - }; - $.modal.openOptions(options); - } - //物料信息展示列表 $(function() { var options = { - url: ctx + "aftersales/complaintNotice/getMaterialListByNoticeCode", + url: ctx + "aftersales/complaintNotice/getDetailListByNoticeCode", queryParams: queryParams, modalName: "选择物料", - columns: [{ - checkbox: true - }, - { - title: '料号', - field: 'materialNo', - }, - { - title: '图片', - field: 'materialPhotourl', - }, + columns: [ { - title: '物料名称', - field: 'materialName', + title: 'detailId', + field: 'complaintNoticeDetailId', + visible: false, }, { - title: '物料类型', - field: 'materialType', - }, - { - title: '单位', - field: 'materialUnit', - }, - { - title: '品牌', - field: 'materialBrand', - }, - { - title: '描述', - field: 'materialDescribe', + title: '客诉问题', + field: 'complaintProblem', + align: 'center', }, { - title: 'SN号', - field: 'snCode' - }, - - { - title: '客诉问题', - field: 'complaintProblem' + title: '紧急程度', + align: 'center', + field: 'emergencyDegree', + formatter: function(value, row, index) { + return $.table.selectDictLabel(emergencyDegreeDatas, value); + } }, { - title: '售后问题', - field: 'adverseReportUrl' + title: '不良报告', + align: 'center', + field: 'adverseReportUrl', }, ] }; @@ -298,39 +131,6 @@ return curParams; } - function doSubmit(index, layero,uniqueId){ - console.log(uniqueId); - var iframeWin = window[layero.find('iframe')[0]['name']]; - var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0]; - console.log("rowData: "+rowData); - $("#bootstrap-table").bootstrapTable('insertRow', { - index:1, - row: { - materialNo:rowData.materialNo, - materialPhotourl:rowData.materialPhotourl, - materialName: rowData.materialName, - materialType: rowData.materialType, - materialDescribe: rowData.materialDescribe, - materialBrand: rowData.materialBrand, - materialUnit: rowData.materialUnit, - materialProcessMethod: rowData.materialProcessMethod, - shippedGoodsSum: rowData.shippedGoodsSum, - snCode:"", - complaintProblem:"", - adverseReportUrl:"", - } - }) - layer.close(index); - } - - // 逻辑删除前端的一行数据 - function removeRow(materialNo){ - $("#bootstrap-table").bootstrapTable('remove', { - field: 'materialNo', - values: materialNo - }) - } - \ No newline at end of file