导出全部盘点

merge-requests/5/merge
yiming 4 years ago
parent ad41d5fddb
commit ef8cfff5b8

@ -81,7 +81,7 @@ public class StockController {
return Result.success(stockService.page(pageSearch));
}
@ApiOperation(value = "导出全部巷道excel")
@ApiOperation(value = "导出巷道excel")
@RequestMapping(value = "/export", method = RequestMethod.GET)
public void export(@RequestParam Integer streetId, HttpServletResponse response) throws IOException {
OutputStream os = response.getOutputStream();
@ -93,6 +93,18 @@ public class StockController {
EasyExcel.write(os, StockExportExcel.class).sheet().doWrite(excels);
}
@ApiOperation(value = "导出巷道excel")
@RequestMapping(value = "/exportAll", method = RequestMethod.GET)
public void exportAll(HttpServletResponse response) throws IOException {
OutputStream os = response.getOutputStream();
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("全部巷道盘点结果" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<StockExportExcel> excels = stockService.exportAllExcels();
EasyExcel.write(os, StockExportExcel.class).sheet().doWrite(excels);
}
@ApiOperation(value = "复核页面的核对信息")
@RequestMapping(value = "/info", method = RequestMethod.POST)
public Result<Stock> stockInfo(@RequestBody StockCheck stockCheck) {

@ -13,6 +13,7 @@ import com.zhehekeji.web.entity.Street;
import com.zhehekeji.web.mapper.CheckLogMapper;
import com.zhehekeji.web.mapper.StockLogMapper;
import com.zhehekeji.web.mapper.StockMapper;
import com.zhehekeji.web.mapper.StreetMapper;
import com.zhehekeji.web.pojo.category.PageSearch;
import com.zhehekeji.web.pojo.stock.*;
import io.swagger.models.auth.In;
@ -40,6 +41,8 @@ public class StockService {
private CheckLogMapper logMapper;
@Resource
private StockLogMapper stockLogMapper;
@Resource
private StreetMapper streetMapper;
public void importExcel(MultipartFile file) {
log.info("import excel stock");
@ -278,6 +281,37 @@ public class StockService {
return stockExportExcels;
}
public List<StockExportExcel> exportAllExcels() {
List<Stock> stocks = stockMapper.selectByMap(new HashMap<>());
List<Street> streets = streetMapper.selectByMap(new HashMap<>());
Map<String,List<String>> shevleMaps = new HashMap<>();
streets.forEach(street -> {
List<String> shelveIds = streetService.check(street);
shevleMaps.put(street.getName(),shelveIds);
});
//Street street = streetService.streetById(streetId);
List<StockExportExcel> stockExportExcels = new ArrayList<>(stocks.size());
stocks.forEach(stock -> {
StockExportExcel stockExportExcel = new StockExportExcel();
stockExportExcel.setCode(stock.getTrayCode());
stockExportExcel.setLotnum(stock.getLotnum());
stockExportExcel.setColumn(stock.getColumn());
//stockExportExcel.setCount(stock.getCount());
stockExportExcel.setRow(stock.getRow());
shevleMaps.forEach((k,v)->{
if(v.contains(stock.getShelveId())){
stockExportExcel.setStreetName(k);
}
});
stockExportExcel.setExportTime(stock.getExportTime());
stockExportExcel.setShelveId(stock.getShelveId());
stockExportExcel.setStatus(stock.getStatus());
stockExportExcels.add(stockExportExcel);
});
return stockExportExcels;
}
/**
*
*

Loading…
Cancel
Save