|
|
|
@ -1,6 +1,9 @@ |
|
|
|
package com.gaotao.modules.pallet.service.impl; |
|
|
|
|
|
|
|
import cn.idev.excel.FastExcel; |
|
|
|
import cn.idev.excel.write.metadata.style.WriteCellStyle; |
|
|
|
import cn.idev.excel.write.metadata.style.WriteFont; |
|
|
|
import cn.idev.excel.write.style.HorizontalCellStyleStrategy; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
@ -45,8 +48,18 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
String fileName = URLEncoder.encode("Pallet Check List", "UTF-8").replaceAll("\\+", "%20"); |
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
WriteCellStyle contentCellStyle = new WriteCellStyle(); |
|
|
|
WriteFont writeFont = new WriteFont(); |
|
|
|
writeFont.setFontName("Arial"); |
|
|
|
contentCellStyle.setWriteFont(writeFont); |
|
|
|
|
|
|
|
// 注册策略 |
|
|
|
HorizontalCellStyleStrategy strategy = new HorizontalCellStyleStrategy(null, contentCellStyle); |
|
|
|
|
|
|
|
|
|
|
|
FastExcel.write(response.getOutputStream(), CatchPallet.class) |
|
|
|
.sheet() |
|
|
|
.registerWriteHandler(strategy) |
|
|
|
.sheet("SN List") |
|
|
|
.doWrite(list); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
@ -58,7 +71,7 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
public void saveCatchPallet(CatchPallet pallet) { |
|
|
|
// 1、判断CatchPallet 是否扫托盘 |
|
|
|
if (!StringUtils.hasText(pallet.getPalletNo())) { |
|
|
|
throw new RuntimeException("please input Pallet Label"); |
|
|
|
throw new RuntimeException("Please Scan Pallet No"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Pallet> list = palletService.lambdaQuery() |
|
|
|
@ -68,7 +81,7 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
.orderByAsc(Pallet::getSn) |
|
|
|
.list(); |
|
|
|
if (list.isEmpty()){ |
|
|
|
throw new RuntimeException("no Pallet Label found \""+pallet.getPalletNo().trim()+"\""); |
|
|
|
throw new RuntimeException("no Pallet No found \""+pallet.getPalletNo().trim()+"\""); |
|
|
|
} |
|
|
|
|
|
|
|
int count = lambdaQuery() |
|
|
|
@ -77,7 +90,7 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|
|
|
.count(); |
|
|
|
if (count > 0){ |
|
|
|
throw new RuntimeException("Pallet Label \""+pallet.getPalletNo()+"\" already exist"); |
|
|
|
throw new RuntimeException("Pallet No \""+pallet.getPalletNo()+"\" already exist"); |
|
|
|
} |
|
|
|
Date date = new Date(); |
|
|
|
List<CatchPallet> catchPalletList = new ArrayList<>(); |
|
|
|
@ -101,7 +114,7 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
public void removeCatchPallet(CatchPallet pallet) { |
|
|
|
// 1、判断CatchPallet 是否扫托盘 |
|
|
|
if (!StringUtils.hasText(pallet.getPalletNo())) { |
|
|
|
throw new RuntimeException("please input Pallet Label"); |
|
|
|
throw new RuntimeException("Please Scan Pallet No"); |
|
|
|
} |
|
|
|
Integer count = lambdaQuery() |
|
|
|
.eq(CatchPallet::getSite, pallet.getSite()) |
|
|
|
@ -109,7 +122,7 @@ public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, Catch |
|
|
|
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|
|
|
.count(); |
|
|
|
if (count == 0){ |
|
|
|
throw new RuntimeException("not find any Pallet Label"); |
|
|
|
throw new RuntimeException("not find any Pallet Bo"); |
|
|
|
} |
|
|
|
lambdaUpdate() |
|
|
|
.eq(CatchPallet::getSite, pallet.getSite()) |
|
|
|
|