|
@ -10,9 +10,10 @@ import java.util.concurrent.atomic.AtomicInteger; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.util.MapUtils; |
|
|
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.WriteSheet; |
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
|
|
|
import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; |
|
|
|
|
|
import com.ruoyi.aftersales.mapper.AfterSalesShippingDeviceMapper; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
@ -20,22 +21,18 @@ 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.common.utils.file.FileDownloadUtils; |
|
|
import com.ruoyi.system.domain.*; |
|
|
import com.ruoyi.system.domain.*; |
|
|
import com.ruoyi.system.dto.ExportSalesShippingInformDto; |
|
|
import com.ruoyi.system.dto.ExportShippingInformOrderDto; |
|
|
import com.ruoyi.system.mapper.SysSalesOrderChildMapper; |
|
|
import com.ruoyi.system.dto.ExportShippingOrderDto; |
|
|
import com.ruoyi.system.mapper.SysSalesOrderMapper; |
|
|
import com.ruoyi.system.mapper.*; |
|
|
import com.ruoyi.system.mapper.SysSalesShippingInformDetailMapper; |
|
|
|
|
|
import com.ruoyi.warehouse.domain.WarehouseOutOrder; |
|
|
import com.ruoyi.warehouse.domain.WarehouseOutOrder; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; |
|
|
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.ruoyi.system.mapper.SysSalesShippingInformMapper; |
|
|
|
|
|
import com.ruoyi.system.service.ISysSalesShippingInformService; |
|
|
import com.ruoyi.system.service.ISysSalesShippingInformService; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -65,6 +62,13 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysSalesOrderChildMapper salesOrderChildMapper; |
|
|
private SysSalesOrderChildMapper salesOrderChildMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysMakeOrderMapper sysMakeOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private AfterSalesShippingDeviceMapper salesShippingDeviceMapper; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询销售出货通知 |
|
|
* 查询销售出货通知 |
|
|
* |
|
|
* |
|
@ -401,19 +405,19 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
|
|
|
//处理物料数据
|
|
|
//处理物料数据
|
|
|
List<ExportSalesShippingInformDto> exportSalesShippingInformDtos = new ArrayList<>(); |
|
|
List<ExportShippingOrderDto> exportShippingOrderDtos = new ArrayList<>(); |
|
|
|
|
|
|
|
|
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) { |
|
|
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) { |
|
|
ExportSalesShippingInformDto exportSalesShippingInformDto = new ExportSalesShippingInformDto(); |
|
|
ExportShippingOrderDto exportShippingOrderDto = new ExportShippingOrderDto(); |
|
|
exportSalesShippingInformDto.setIndex(index.getAndIncrement()); |
|
|
exportShippingOrderDto.setIndex(index.getAndIncrement()); |
|
|
exportSalesShippingInformDto.setMaterialName(salesShippingInformDetail.getMaterialName()); |
|
|
exportShippingOrderDto.setMaterialName(salesShippingInformDetail.getMaterialName()); |
|
|
exportSalesShippingInformDto.setMaterialNo(salesShippingInformDetail.getMaterialNo()); |
|
|
exportShippingOrderDto.setMaterialNo(salesShippingInformDetail.getMaterialNo()); |
|
|
exportSalesShippingInformDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe()); |
|
|
exportShippingOrderDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe()); |
|
|
exportSalesShippingInformDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit()); |
|
|
exportShippingOrderDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit()); |
|
|
exportSalesShippingInformDto.setMakeNum(salesShippingInformDetail.getMakeNum()); |
|
|
exportShippingOrderDto.setMakeNum(salesShippingInformDetail.getMakeNum()); |
|
|
exportSalesShippingInformDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber()); |
|
|
exportShippingOrderDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber()); |
|
|
exportSalesShippingInformDto.setRemark(salesShippingInform.getRemark()); |
|
|
exportShippingOrderDto.setRemark(salesShippingInform.getRemark()); |
|
|
exportSalesShippingInformDtos.add(exportSalesShippingInformDto); |
|
|
exportShippingOrderDtos.add(exportShippingOrderDto); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -435,7 +439,7 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
|
|
|
|
|
|
// 写入数据
|
|
|
// 写入数据
|
|
|
workBook.fill(map, sheet); |
|
|
workBook.fill(map, sheet); |
|
|
workBook.fill(exportSalesShippingInformDtos, fillConfig, sheet); |
|
|
workBook.fill(exportShippingOrderDtos, fillConfig, sheet); |
|
|
workBook.finish(); |
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
@ -470,19 +474,19 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
|
|
|
//处理物料数据
|
|
|
//处理物料数据
|
|
|
List<ExportSalesShippingInformDto> exportSalesShippingInformDtos = new ArrayList<>(); |
|
|
List<ExportShippingOrderDto> exportShippingOrderDtos = new ArrayList<>(); |
|
|
|
|
|
|
|
|
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) { |
|
|
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) { |
|
|
ExportSalesShippingInformDto exportSalesShippingInformDto = new ExportSalesShippingInformDto(); |
|
|
ExportShippingOrderDto exportShippingOrderDto = new ExportShippingOrderDto(); |
|
|
exportSalesShippingInformDto.setIndex(index.getAndIncrement()); |
|
|
exportShippingOrderDto.setIndex(index.getAndIncrement()); |
|
|
exportSalesShippingInformDto.setMaterialName(salesShippingInformDetail.getMaterialName()); |
|
|
exportShippingOrderDto.setMaterialName(salesShippingInformDetail.getMaterialName()); |
|
|
exportSalesShippingInformDto.setMaterialNo(salesShippingInformDetail.getMaterialNo()); |
|
|
exportShippingOrderDto.setMaterialNo(salesShippingInformDetail.getMaterialNo()); |
|
|
exportSalesShippingInformDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe()); |
|
|
exportShippingOrderDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe()); |
|
|
exportSalesShippingInformDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit()); |
|
|
exportShippingOrderDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit()); |
|
|
exportSalesShippingInformDto.setMakeNum(salesShippingInformDetail.getMakeNum()); |
|
|
exportShippingOrderDto.setMakeNum(salesShippingInformDetail.getMakeNum()); |
|
|
exportSalesShippingInformDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber()); |
|
|
exportShippingOrderDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber()); |
|
|
exportSalesShippingInformDto.setRemark(salesShippingInform.getRemark()); |
|
|
exportShippingOrderDto.setRemark(salesShippingInform.getRemark()); |
|
|
exportSalesShippingInformDtos.add(exportSalesShippingInformDto); |
|
|
exportShippingOrderDtos.add(exportShippingOrderDto); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -504,11 +508,71 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
|
|
|
|
|
|
// 写入数据
|
|
|
// 写入数据
|
|
|
workBook.fill(map, sheet); |
|
|
workBook.fill(map, sheet); |
|
|
workBook.fill(exportSalesShippingInformDtos, fillConfig, sheet); |
|
|
workBook.fill(exportShippingOrderDtos, fillConfig, sheet); |
|
|
|
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 导出出货通知单模板 |
|
|
|
|
|
* */ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void exportShippingInformOrder(String outOrderCode, HttpServletResponse response) { |
|
|
|
|
|
|
|
|
|
|
|
String fileName = "出货通知单.xlsx"; |
|
|
|
|
|
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils(); |
|
|
|
|
|
try { |
|
|
|
|
|
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName); |
|
|
|
|
|
|
|
|
|
|
|
SysSalesShippingInform sysSalesShippingInform = sysSalesShippingInformMapper.selectSysSalesShippingInformByCode(outOrderCode); |
|
|
|
|
|
String salesOrderCode = sysSalesShippingInform.getSalesOrderCode(); |
|
|
|
|
|
SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderBySaleNo(salesOrderCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String realFileName = sysSalesShippingInform.getSalesOrderCode() +"-"+ fileName.substring(0, fileName.lastIndexOf("."))+ ".xlsx"; |
|
|
|
|
|
// 设置响应头,指定文件名和文件类型
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); |
|
|
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
|
|
List<AfterSalesShippingDevice> salesShippingDeviceList = salesShippingDeviceMapper.selectShippingDeviceBySalesOrderCode(salesOrderCode); |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<ExportShippingInformOrderDto> shippingInformOrderDtos = new ArrayList<>(); |
|
|
|
|
|
for (AfterSalesShippingDevice afterSalesShippingDevice : salesShippingDeviceList) { |
|
|
|
|
|
ExportShippingInformOrderDto shippingInformOrderDto = new ExportShippingInformOrderDto(); |
|
|
|
|
|
shippingInformOrderDto.setDeviceModelCode(afterSalesShippingDevice.getDeviceModelCode()); |
|
|
|
|
|
shippingInformOrderDto.setMaterialName(afterSalesShippingDevice.getMaterialName()); |
|
|
|
|
|
shippingInformOrderDtos.add(shippingInformOrderDto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
String shippingDate = dateFormat.format(new Date()); |
|
|
|
|
|
map.put("makeNo",sysMakeOrder.getMakeNo()); |
|
|
|
|
|
map.put("salesOrderNumber",sysSalesShippingInform.getSalesOrderNumber()); |
|
|
|
|
|
map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); |
|
|
|
|
|
map.put("shippingDate",shippingDate); |
|
|
|
|
|
map.put("customerName",sysSalesShippingInform.getCustomerName()); |
|
|
|
|
|
map.put("businessMembers",sysSalesShippingInform.getBusinessMembers()); |
|
|
|
|
|
|
|
|
|
|
|
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(shippingInformOrderDtos, fillConfig, sheet); |
|
|
workBook.finish(); |
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|