Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
zhangsiqi 3 months ago
parent
commit
95fcfd8bca
  1. 38
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java
  2. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportSalesOrderVo.java
  3. 10
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesOrderService.java
  4. 147
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java
  5. BIN
      ruoyi-admin/src/main/resources/static/attachments/销售订单.xlsx
  6. 34
      ruoyi-admin/src/main/resources/templates/system/salesOrder/exportSalesOrder.html
  7. 46
      ruoyi-admin/src/main/resources/templates/system/salesOrder/salesOrder.html

38
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java

@ -203,20 +203,42 @@ public class SysSalesOrderController extends BaseController
return AjaxResult.success(); return AjaxResult.success();
} }
// /**
// * 加载填写导出销售订单模板数据页面
// */
// @GetMapping("/exportSalesOrder/{salesOrderId}")
// public String exportSalesOrder(@PathVariable("salesOrderId") Long salesOrderId, ModelMap mmap)
// {
// ExportSalesOrderVo exportSalesOrderVo = sysSalesOrderService.selectExportSalesOrderById(salesOrderId);
// mmap.put("exportSalesOrderVo", exportSalesOrderVo);
// return prefix + "/exportSalesOrder";
// }
// /**
// * 导出销售订单模板数据
// */
// @RequiresPermissions("system:salesOrder:exportSalesOrder")
// @Log(title = "销售订单", businessType = BusinessType.EXPORT)
// @PostMapping("/exportSalesOrder")
// @ResponseBody
// public void exportSalesOrder(@RequestBody ExportSalesOrderVo exportSalesOrderVo, HttpServletResponse response) {
// sysSalesOrderService.exportSalesOrder(exportSalesOrderVo, response);
// }
/** /**
* 加载填写导出销售订单模板数据页面 * 导出销售订单模板数据
*/ */
@GetMapping("/exportSalesOrder/{salesOrderId}") @RequiresPermissions("system:salesOrder:exportSalesOrder")
public String exportSalesOrder(@PathVariable("salesOrderId") Long salesOrderId, ModelMap mmap) @Log(title = "销售订单", businessType = BusinessType.EXPORT)
{ @GetMapping("/exportSalesOrder/{salesOrderCode}")
ExportSalesOrderVo exportSalesOrderVo = sysSalesOrderService.selectExportSalesOrderById(salesOrderId); public void exportSalesOrder(@PathVariable("salesOrderCode") String salesOrderCode, HttpServletResponse response) {
mmap.put("exportSalesOrderVo", exportSalesOrderVo); sysSalesOrderService.exportSalesOrderByCode(salesOrderCode, response);
return prefix + "/exportSalesOrder";
} }
/** /**
* 展示导出销售订单列表子表数据 * 展示导出销售订单列表子表数据
*/ */

5
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportSalesOrderVo.java

@ -4,6 +4,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 导出销售订单模板类 * 导出销售订单模板类
@ -50,4 +51,8 @@ public class ExportSalesOrderVo {
//备注 //备注
private String remark; private String remark;
//导出销售订单子表模板类
private List<ExportSalesOrderChildVo> exportSalesOrderChildVoList;
} }

10
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesOrderService.java

@ -8,6 +8,7 @@ import com.ruoyi.system.domain.Vo.ExportSalesOrderVo;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@ -105,4 +106,13 @@ public interface ISysSalesOrderService
* */ * */
List<ExportSalesOrderChildVo> showExportSalesOrderChildListByICode(String salesOrderCode); List<ExportSalesOrderChildVo> showExportSalesOrderChildListByICode(String salesOrderCode);
/**
* 导出销售订单模板数据
*/
void exportSalesOrder(ExportSalesOrderVo exportSalesOrderVo, HttpServletResponse response);
/**
* 导出销售订单数据
*/
void exportSalesOrderByCode(String salesOrderCode, HttpServletResponse response);
} }

147
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java

@ -1,5 +1,9 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
@ -12,6 +16,7 @@ import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileDownloadUtils;
import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.*;
@ -33,8 +38,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -93,7 +102,6 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
private final static String RMB = "1"; //RMB private final static String RMB = "1"; //RMB
private final static String USD = "2"; //美元
/** /**
* 查询销售订单 * 查询销售订单
@ -558,4 +566,141 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
vo.setMaterialTaxMoney(tax); vo.setMaterialTaxMoney(tax);
} }
} }
/**
* 导出销售订单模板数据
*/
@Override
public void exportSalesOrder(ExportSalesOrderVo exportSalesOrderVo, HttpServletResponse response) {
String salesOrderCode = exportSalesOrderVo.getSalesOrderCode();
Long salesOrderId = exportSalesOrderVo.getSalesOrderId();
String fileName = "销售订单.xlsx";
try {
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils();
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName);
String realFileName = salesOrderCode +"-" +fileRelativePath.substring(0,fileName.lastIndexOf(".")) + ".xlsx";
// 设置响应头,指定文件名和文件类型
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8"));
response.setContentType("application/octet-stream");
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderById(salesOrderId);
if (sysSalesOrderVo == null){
throw new RuntimeException("销售订单为空");
}
HashMap<String, Object> map = new HashMap<>();
map.put("salesOrderType", exportSalesOrderVo.getSalesOrderType());
map.put("enterpriseCode", exportSalesOrderVo.getEnterpriseCode());
map.put("salesOrderNumber", exportSalesOrderVo.getSalesOrderNumber());
map.put("paymentTerms", exportSalesOrderVo.getPaymentTerms());
map.put("tradeClause", exportSalesOrderVo.getTradeClause());
map.put("invoice", sysSalesOrderVo.getInvoice());
map.put("commonCurrency", sysSalesOrderVo.getCommonCurrency());
map.put("taxMoneySum", exportSalesOrderVo.getTaxMoneySum());
map.put("noTaxMoneySum", exportSalesOrderVo.getNoTaxMoneySum());
map.put("warrantyDate", exportSalesOrderVo.getWarrantyDate());
map.put("remark", exportSalesOrderVo.getRemark());
List<ExportSalesOrderChildVo> exportSalesOrderChildVoList = exportSalesOrderVo.getExportSalesOrderChildVoList();
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileRelativePath).build();
WriteSheet sheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
workBook.fill(map, sheet);
workBook.fill(exportSalesOrderChildVoList, fillConfig, sheet);
workBook.finish();
}catch (IOException | RuntimeException e){
throw new RuntimeException("文件处理失败",e);
}
}
@Override
public void exportSalesOrderByCode(String salesOrderCode, HttpServletResponse response) {
String fileName = "销售订单.xlsx";
try {
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils();
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName);
String realFileName = salesOrderCode +"-" +fileName.substring(0,fileName.lastIndexOf(".")) + ".xlsx";
// 设置响应头,指定文件名和文件类型
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8"));
response.setContentType("application/octet-stream");
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode);
if (sysSalesOrderVo == null){
throw new RuntimeException("销售订单为空");
}
ExportSalesOrderVo exportSalesOrderVo = selectExportSalesOrderById(sysSalesOrderVo.getSalesOrderId());
List<ExportSalesOrderChildVo> exportSalesOrderChildVoList = showExportSalesOrderChildListByICode(salesOrderCode);
AtomicInteger index = new AtomicInteger(1);
exportSalesOrderChildVoList.forEach(exportSalesOrderChildVo -> {
exportSalesOrderChildVo.setIndex(index.getAndIncrement());
});
String invoice = sysSalesOrderVo.getInvoice();
if ("1".equals(invoice)){
invoice = "是";
}else {
invoice = "否";
}
String commonCurrency = sysSalesOrderVo.getCommonCurrency();
if (RMB.equals(commonCurrency)){
commonCurrency = "人民币";
}else {
commonCurrency = "美元";
}
HashMap<String, Object> map = new HashMap<>();
map.put("salesOrderType", exportSalesOrderVo.getSalesOrderType());
map.put("enterpriseCode", exportSalesOrderVo.getEnterpriseCode());
map.put("salesOrderNumber", exportSalesOrderVo.getSalesOrderNumber());
map.put("paymentTerms", exportSalesOrderVo.getPaymentTerms());
map.put("tradeClause", exportSalesOrderVo.getTradeClause());
map.put("invoice",invoice );
map.put("commonCurrency", commonCurrency);
map.put("taxMoneySum", exportSalesOrderVo.getTaxMoneySum());
map.put("noTaxMoneySum", exportSalesOrderVo.getNoTaxMoneySum());
map.put("warrantyDate", exportSalesOrderVo.getWarrantyDate());
map.put("remark", exportSalesOrderVo.getRemark());
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileRelativePath).build();
WriteSheet sheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
workBook.fill(map, sheet);
workBook.fill(exportSalesOrderChildVoList, fillConfig, sheet);
workBook.finish();
}catch (IOException | RuntimeException e){
throw new RuntimeException("文件处理失败",e);
}
}
} }

BIN
ruoyi-admin/src/main/resources/static/attachments/销售订单.xlsx

Binary file not shown.

34
ruoyi-admin/src/main/resources/templates/system/salesOrder/exportSalesOrder.html

@ -152,18 +152,44 @@
}); });
const combinedData = Object.assign({}, salesOrderData, { const combinedData = Object.assign({}, salesOrderData, {
sysSalesOrderChildList: materialDataList, exportSalesOrderChildVoList: materialDataList,
}); });
// 合并表单数据和表格数据
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据 // 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData); const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口 // 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/salesDeliverGoods", jsonData); $.operate.saveJson(prefix + "/exportSalesOrder", jsonData);
// saveExportSalesOrder(prefix + "/exportSalesOrder", jsonData)
} }
// function saveExportSalesOrder(url, data) {
// // 发送 AJAX 请求
// $.ajax({
// type: "POST",
// url: url,
// data: data, // 直接发送序列化的表单数据
// //contentType: "application/json;charset=UTF-8", // 设置请求内容类型为 JSON
// dataType: "json", // 设置返回数据类型为 JSON
// success: function(response) {
// // 处理服务器返回的成功响应
// if (response.code === 200) { // 假设 200 表示成功
// alert("导出成功!");
// // 可以在这里刷新页面或者做其他操作
// } else {
// alert("导出失败:" + response.message);
// }
// },
// error: function(xhr, status, error) {
// // 处理请求失败的情况
// console.error("请求失败:", error);
// alert("请求失败,请稍后再试!");
// }
// });
// }
$(function() { $(function() {
var options = { var options = {
modalName: "选择物料", modalName: "选择物料",

46
ruoyi-admin/src/main/resources/templates/system/salesOrder/salesOrder.html

@ -416,9 +416,15 @@
}else { }else {
// 检查是否已审核 // 检查是否已审核
if (row.auditStatus === AUDIT_STATUS_APPROVED) { if (row.auditStatus === AUDIT_STATUS_APPROVED) {
var salesOrderId = row.salesOrderId; // 使用 $.modal.confirm 显示确认对话框
var url = prefix + "/exportSalesOrder/" + salesOrderId; $.modal.confirm("确定导出这条数据的出货单吗?", function() {
$.modal.open("导出",url); // 如果用户点击确定,继续导出
var salesOrderCode = row.salesOrderCode;
window.location.href = prefix + "/exportSalesOrder/" + salesOrderCode;
$('#bootstrap-table').bootstrapTable('refresh'); // 刷新表格
});
} else { } else {
showWarning("请先审核"); showWarning("请先审核");
} }
@ -432,6 +438,40 @@
} }
/*旧导出销售订单模板*/
// function exportSalesOrder(){
//
// const selectRows = $("#bootstrap-table").bootstrapTable('getSelections');
// // 定义状态码常量
// const AUDIT_STATUS_APPROVED = "1";//审核通过
// const DELETE_FLAG = "2"; //作废
//
// if (selectRows.length === 1){
// const row = selectRows[0];
// // 检查是否已作废
// if (row.useStatus === DELETE_FLAG) {
// showWarning("该订单已作废");
//
// }else {
// // 检查是否已审核
// if (row.auditStatus === AUDIT_STATUS_APPROVED) {
// var salesOrderId = row.salesOrderId;
// var url = prefix + "/exportSalesOrder/" + salesOrderId;
// $.modal.open("导出",url);
// } else {
// showWarning("请先审核");
// }
// }
//
// }else {
// $.modal.alertWarning("请选择一条数据");
// return;
// }
//
// }
/*下载*/ /*下载*/
function downloadFile(filepath) { function downloadFile(filepath) {
window.location.href =prefix + "/downloadFile?filepath="+ filepath; window.location.href =prefix + "/downloadFile?filepath="+ filepath;

Loading…
Cancel
Save