Browse Source

20240325

master
qiezi 1 year ago
parent
commit
1b930b647f
  1. 7
      src/main/java/com/gaotao/modules/pallet/entity/CatchPallet.java
  2. 25
      src/main/java/com/gaotao/modules/pallet/service/impl/CatchPalletServiceImpl.java

7
src/main/java/com/gaotao/modules/pallet/entity/CatchPallet.java

@ -3,7 +3,10 @@ package com.gaotao.modules.pallet.entity;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.HeadFontStyle;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import cn.idev.excel.annotation.write.style.HeadStyle;
import cn.idev.excel.enums.BooleanEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@ -15,6 +18,8 @@ import java.util.Date;
@Data
@HeadRowHeight(value = -1)
@ColumnWidth(value = 25)
@HeadStyle(fillForegroundColor = -1) // 将背景色恢复为默认透明
@HeadFontStyle(fontName = "Arial",fontHeightInPoints = 11, bold = BooleanEnum.FALSE) // 重置字体为默认值
public class CatchPallet {
@ -24,7 +29,7 @@ public class CatchPallet {
@ExcelIgnore
private String site;
@ExcelProperty(value = "Pallet Label",index = 0)
@ExcelProperty(value = "Pallet No",index = 0)
private String palletNo;
@ExcelProperty(value = "SN",index = 1)

25
src/main/java/com/gaotao/modules/pallet/service/impl/CatchPalletServiceImpl.java

@ -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())

Loading…
Cancel
Save