Browse Source

[feat] 销售管理

新增导出销售出货单模板数据实体类
新增销售出货单1excel模板
新增 导出出货单1模板后端接口。完成对销售出货单excel模板的数据填充
销售出货单前端列表新增 导出销售出货单1按钮和js方法:新增只能选择一条数据;新增是否导出该条数据的提示
dev
liuxiaoxu 3 months ago
parent
commit
872a60b2b2
  1. 16
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesShippingInformController.java
  2. 27
      ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportSalesShippingInformDto.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesShippingInformMapper.java
  4. 8
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysSalesShippingInformService.java
  5. 90
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java
  6. BIN
      ruoyi-admin/src/main/resources/attachments/销售出货单1.xlsx
  7. 11
      ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml
  8. 30
      ruoyi-admin/src/main/resources/templates/system/salesShippingInform/salesShippingInform.html

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

@ -5,6 +5,7 @@ import java.util.List;
import com.ruoyi.aftersales.domain.vo.SelectShippingDeviceVO;
import com.ruoyi.erp.domain.ErpBom;
import com.ruoyi.erp.domain.ErpBomVo;
import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesShippingInformDetail;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -21,6 +22,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import javax.servlet.http.HttpServletResponse;
/**
* 销售出货通知Controller
*
@ -82,6 +85,19 @@ public class SysSalesShippingInformController extends BaseController
ExcelUtil<SysSalesShippingInform> util = new ExcelUtil<SysSalesShippingInform>(SysSalesShippingInform.class);
return util.exportExcel(list, "销售出货通知数据");
}
/**
* 导出出货单1模板
* */
@RequiresPermissions("system:salesShippingInform:exportShippingOrderOne")
@Log(title = "采购订单", businessType = BusinessType.EXPORT)
@GetMapping("/exportShippingOrderOne/{outOrderCode}")
public void export(@PathVariable("outOrderCode") String outOrderCode,HttpServletResponse response) {
sysSalesShippingInformService.exportShippingOrderOne(outOrderCode, response);
}
/**
* 新增销售出货通知
*/

27
ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportSalesShippingInformDto.java

@ -0,0 +1,27 @@
package com.ruoyi.system.dto;
import lombok.Data;
/**
* 导出销售出货单模板数据
* */
@Data
public class ExportSalesShippingInformDto {
private Integer index;
private String materialName;
private String materialNo;
private String materialDescribe;
private String materialUnit;
private Integer makeNum;
private String salesOrderNumber;
private String remark;
}

8
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesShippingInformMapper.java

@ -94,4 +94,12 @@ public interface SysSalesShippingInformMapper
* @return 出货单集合
*/
public List<SysSalesShippingInform> selectSalesShippingInformListbyCodes(String[] outOrderCodes);
/**
* 根据出库单号查询销售出货通知单
* */
SysSalesShippingInform selectSysSalesShippingInformByCode(String outOrderCode);
}

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

@ -6,6 +6,8 @@ import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesShippingInform;
import com.ruoyi.system.domain.SysSalesShippingInformDetail;
import javax.servlet.http.HttpServletResponse;
/**
* 销售出货通知Service接口
*
@ -108,4 +110,10 @@ public interface ISysSalesShippingInformService
int updateCustomerCheckGoodsDetail(SysSalesShippingInform sysSalesShippingInform);
List<SysSalesShippingInform> getExportListByNos(String[] outOrderCodes);
/**
* 导出出货单1模板
* */
void exportShippingOrderOne(String outOrderCode, HttpServletResponse response);
}

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

@ -1,15 +1,26 @@
package com.ruoyi.system.service.impl;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.util.MapUtils;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileDownloadUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.dto.ExportSalesShippingInformDto;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.system.mapper.SysSalesShippingInformDetailMapper;
@ -24,6 +35,9 @@ import com.ruoyi.system.service.ISysSalesShippingInformService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
/**
* 销售出货通知Service业务层处理
*
@ -359,4 +373,74 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor
public List<SysSalesShippingInform> getExportListByNos(String[] outOrderCodes) {
return sysSalesShippingInformMapper.selectSalesShippingInformListbyCodes(outOrderCodes);
}
/**
* 导出出货单1模板
* */
@Override
public void exportShippingOrderOne(String outOrderCode, HttpServletResponse response) {
String fileName = "销售出货单1.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/销售出货单1.xlsx

Binary file not shown.

11
ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml

@ -54,7 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSysSalesShippingInformVo"/>
where shipping_inform_id = #{shippingInformId}
</select>
<select id="selectSysSalesShippingInformByCode" parameterType="String" resultMap="SysSalesShippingInformResult">
<include refid="selectSysSalesShippingInformVo"/>
where out_order_code = #{outOrderCode}
</select>
<insert id="insertSysSalesShippingInform" parameterType="SysSalesShippingInform" useGeneratedKeys="true" keyProperty="shippingInformId">
insert into sys_sales_shipping_inform
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -213,4 +219,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{outOrderCode}
</foreach>
</select>
</mapper>

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

@ -49,6 +49,9 @@
<a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="system:salesShippingInform:export">
<i class="fa fa-download"></i> 导出
</a>
<a class="btn btn-warning" onclick="exportShippingOrderOne()" shiro:hasPermission="system:salesShippingInform:exportShippingOrderOne">
<i class="fa fa-download"></i> 导出销售出货单1
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
@ -299,6 +302,33 @@
}
};
//导出出货单1
function exportShippingOrderOne() {
// 获取选中的行
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 + "/exportShippingOrderOne/" + outOrderCode;
$('#bootstrap-table').bootstrapTable('refresh'); // 刷新表格
});
}
// 显示警告消息的通用函数
function showWarning(message) {
$.modal.msgWarning(message);
}
</script>
</body>
</html>
Loading…
Cancel
Save