Browse Source

[feat] 销售管理

新增销售出货单2excel模板
新增 导出出货单1模板后端接口。完成对销售出货单2excel模板的数据填充
销售出货单前端列表新增 导出销售出货单2按钮和js方法
dev
liuxiaoxu 3 months ago
parent
commit
b889e613bb
  1. 15
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesShippingInformController.java
  2. 4
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesShippingInformService.java
  3. 68
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java
  4. BIN
      ruoyi-admin/src/main/resources/attachments/销售出货单2.xlsx
  5. 27
      ruoyi-admin/src/main/resources/templates/system/salesShippingInform/salesShippingInform.html

15
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesShippingInformController.java

@ -92,12 +92,25 @@ public class SysSalesShippingInformController extends BaseController
@RequiresPermissions("system:salesShippingInform:exportShippingOrderOne")
@Log(title = "采购订单", businessType = BusinessType.EXPORT)
@GetMapping("/exportShippingOrderOne/{outOrderCode}")
public void export(@PathVariable("outOrderCode") String outOrderCode,HttpServletResponse response) {
public void exportShippingOrderOne(@PathVariable("outOrderCode") String outOrderCode,HttpServletResponse response) {
sysSalesShippingInformService.exportShippingOrderOne(outOrderCode, response);
}
/**
* 导出出货单2模板
* */
@RequiresPermissions("system:salesShippingInform:exportShippingOrderTwo")
@Log(title = "采购订单", businessType = BusinessType.EXPORT)
@GetMapping("/exportShippingOrderTwo/{outOrderCode}")
public void exportShippingOrderTwo(@PathVariable("outOrderCode") String outOrderCode,HttpServletResponse response) {
sysSalesShippingInformService.exportShippingOrderTwo(outOrderCode, response);
}
/**
* 新增销售出货通知
*/

4
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesShippingInformService.java

@ -116,4 +116,8 @@ public interface ISysSalesShippingInformService
* */
void exportShippingOrderOne(String outOrderCode, HttpServletResponse response);
/**
* 导出出货单2模板
* */
void exportShippingOrderTwo(String outOrderCode, HttpServletResponse response);
}

68
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java

@ -443,4 +443,72 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor
}
}
/**
* 导出出货单2模板
* */
@Override
public void exportShippingOrderTwo(String outOrderCode, HttpServletResponse response) {
String fileName = "销售出货单2.xlsx";
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils();
try {
String fileAbsolutePath = fileDownloadUtils.getFileAbsolutePath(fileName);
SysSalesShippingInform salesShippingInform = sysSalesShippingInformMapper.selectSysSalesShippingInformByCode(outOrderCode);
List<SysSalesShippingInformDetail> salesShippingInformDetails = shippingInformDetailMapper.selectSysSalesShippingInformDetailByCode(outOrderCode);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String deliverTime = dateFormat.format(salesShippingInform.getDeliverTime());
String realFileName = salesShippingInform.getSalesOrderCode() +"-"+ fileName.substring(0, fileName.lastIndexOf("."))+ ".xlsx";
// 设置响应头,指定文件名和文件类型
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8"));
response.setContentType("application/octet-stream");
AtomicInteger index = new AtomicInteger(1);
//处理物料数据
List<ExportSalesShippingInformDto> exportSalesShippingInformDtos = new ArrayList<>();
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) {
ExportSalesShippingInformDto exportSalesShippingInformDto = new ExportSalesShippingInformDto();
exportSalesShippingInformDto.setIndex(index.getAndIncrement());
exportSalesShippingInformDto.setMaterialName(salesShippingInformDetail.getMaterialName());
exportSalesShippingInformDto.setMaterialNo(salesShippingInformDetail.getMaterialNo());
exportSalesShippingInformDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe());
exportSalesShippingInformDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit());
exportSalesShippingInformDto.setMakeNum(salesShippingInformDetail.getMakeNum());
exportSalesShippingInformDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber());
exportSalesShippingInformDto.setRemark(salesShippingInform.getRemark());
exportSalesShippingInformDtos.add(exportSalesShippingInformDto);
}
//totalMakeNum
String totalMakeNum = String.valueOf(salesShippingInformDetails.stream().mapToInt(SysSalesShippingInformDetail::getMakeNum).sum());
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileAbsolutePath).build();
WriteSheet sheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
HashMap<String, Object> map = MapUtils.newHashMap();
map.put("customerId",salesShippingInform.getCustomerId());
map.put("deliverTime",deliverTime);
map.put("businessMembers",salesShippingInform.getBusinessMembers());
map.put("totalMakeNum",totalMakeNum);
// 写入数据
workBook.fill(map, sheet);
workBook.fill(exportSalesShippingInformDtos, fillConfig, sheet);
workBook.finish();
} catch (IOException e) {
throw new RuntimeException("文件处理失败",e);
}
}
}

BIN
ruoyi-admin/src/main/resources/attachments/销售出货单2.xlsx

Binary file not shown.

27
ruoyi-admin/src/main/resources/templates/system/salesShippingInform/salesShippingInform.html

@ -52,6 +52,10 @@
<a class="btn btn-warning" onclick="exportShippingOrderOne()" shiro:hasPermission="system:salesShippingInform:exportShippingOrderOne">
<i class="fa fa-download"></i> 导出销售出货单1
</a>
<a class="btn btn-warning" onclick="exportShippingOrderTwo()" shiro:hasPermission="system:salesShippingInform:exportShippingOrderTwo">
<i class="fa fa-download"></i> 导出销售出货单2
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
@ -329,6 +333,29 @@
$.modal.msgWarning(message);
}
//导出出货单2
function exportShippingOrderTwo() {
// 获取选中的行
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
if (selectedRows.length !== 1) {
showWarning("请先选择一条销售出货通知单");
return;
}
const row = selectedRows[0];
// 使用 $.modal.confirm 显示确认对话框
$.modal.confirm("确定导出这条数据的出货单吗?", function() {
// 如果用户点击确定,继续导出
var outOrderCode = row.outOrderCode;
window.location.href = prefix + "/exportShippingOrderTwo/" + outOrderCode;
$('#bootstrap-table').bootstrapTable('refresh'); // 刷新表格
});
}
</script>
</body>
</html>
Loading…
Cancel
Save