|
|
@ -1,17 +1,31 @@ |
|
|
|
package com.yxt.supervise.report.biz.stock; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.util.ListUtils; |
|
|
|
import com.alibaba.excel.write.builder.ExcelWriterBuilder; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@RestController("com.yxt.supervise.report.biz.stock.StockDayRest") |
|
|
|
@RequestMapping("/reportstock") |
|
|
|
public class StockDayRest { |
|
|
|
private static final String TEMPLATE_FILE_NAME="C:\\Users\\www19\\Desktop\\1.xlsx"; |
|
|
|
@Value("${image.upload.path:static/upload/}") |
|
|
|
private String uploadPath; |
|
|
|
@Value("${image.url.prefix:http://127.0.0.1:8080/upload/}") |
|
|
|
private String urlPrefix; |
|
|
|
@Value("${image.xlsxtmpl:static/upload/}") |
|
|
|
private String xlsxtmplPath; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ReportStockDayService reportStockDayService; |
|
|
@ -48,4 +62,56 @@ public class StockDayRest { |
|
|
|
|
|
|
|
return rb.success().setData(pv); |
|
|
|
} |
|
|
|
@GetMapping("/buildExcel/{projectSid}/{orderDate}") |
|
|
|
public ResultBean<ReportStockDay> buildExcel(@PathVariable("projectSid") String projectSid,@PathVariable("orderDate") String orderDate) throws IOException { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ReportStockDay pv = reportStockDayService.fetchByProjectAndDay(projectSid, orderDate); |
|
|
|
|
|
|
|
//仓库list
|
|
|
|
List<ReportStockDayStore> list = reportStockDayStoreService.listByProjectAndDay(projectSid, orderDate); |
|
|
|
int i=0; |
|
|
|
for(ReportStockDayStore store:list){ |
|
|
|
i++; |
|
|
|
this.SalesReport(store,i); |
|
|
|
} |
|
|
|
|
|
|
|
return rb.success().setData(pv); |
|
|
|
} |
|
|
|
@PostMapping("/SalesReport") |
|
|
|
public void SalesReport(ReportStockDayStore store,int i) throws IOException { |
|
|
|
String xlsxpath = xlsxtmplPath + "销售汇总日报表"+store.getOrderDate()+".xlsx"; |
|
|
|
// 创建ExcelWriterBuilder
|
|
|
|
ExcelWriterBuilder excelWriterBuilder = EasyExcel.write(xlsxpath).withTemplate(TEMPLATE_FILE_NAME); |
|
|
|
ExcelWriter excelWriter = excelWriterBuilder.build(); |
|
|
|
Map<String, Object> map =new HashMap<>(); |
|
|
|
//得到所有要导出的数据
|
|
|
|
WriteSheet writeSheetGood = EasyExcel.writerSheet(i).build(); |
|
|
|
List<ReportStockDayProduct> pv = reportStockDayProductService.listByReportStoreSid(store.getStoreSid()); |
|
|
|
//填写数据
|
|
|
|
excelWriter.fill(pv, writeSheetGood); |
|
|
|
if(pv.size()>0){ |
|
|
|
map.put("storeName",pv.get(0).getStoreName()); |
|
|
|
} |
|
|
|
excelWriter.fill(map, writeSheetGood); |
|
|
|
// list 后面还有个统计 想办法手动写入
|
|
|
|
// List<List<String>> totalListList1 = ListUtils.newArrayList();
|
|
|
|
// List<String> totalList1 = ListUtils.newArrayList();
|
|
|
|
// totalListList1.add(totalList1);
|
|
|
|
// BigDecimal total=new BigDecimal("0");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("");
|
|
|
|
// totalList1.add("统计:");
|
|
|
|
// if(SalesVos.get(0).getCountAmount().equals("")|| SalesVos.get(0).getCountAmount().equals(null)){
|
|
|
|
// totalList1.add("0");
|
|
|
|
// }else{
|
|
|
|
// totalList1.add(SalesVos.get(0).getCountAmount());
|
|
|
|
// }
|
|
|
|
// // 这里是write 别和fill 搞错了
|
|
|
|
// excelWriter.write(totalListList1,writeSheetGood);
|
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|