12 changed files with 425 additions and 0 deletions
-
70src/main/java/com/gaotao/modules/pallet/controller/CatchPalletController.java
-
25src/main/java/com/gaotao/modules/pallet/controller/PalletController.java
-
49src/main/java/com/gaotao/modules/pallet/entity/CatchPallet.java
-
34src/main/java/com/gaotao/modules/pallet/entity/Pallet.java
-
12src/main/java/com/gaotao/modules/pallet/mapper/CatchPalletMapper.java
-
12src/main/java/com/gaotao/modules/pallet/mapper/PalletMapper.java
-
23src/main/java/com/gaotao/modules/pallet/service/CatchPalletService.java
-
11src/main/java/com/gaotao/modules/pallet/service/PalletService.java
-
140src/main/java/com/gaotao/modules/pallet/service/impl/CatchPalletServiceImpl.java
-
27src/main/java/com/gaotao/modules/pallet/service/impl/PalletServiceImpl.java
-
11src/main/resources/mapper/pallet/CatchPalletMapper.xml
-
11src/main/resources/mapper/pallet/PalletMapper.xml
@ -0,0 +1,70 @@ |
|||
package com.gaotao.modules.pallet.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.gaotao.common.utils.R; |
|||
import com.gaotao.modules.pallet.entity.CatchPallet; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
import com.gaotao.modules.pallet.service.CatchPalletService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("/catch/pallet") |
|||
public class CatchPalletController { |
|||
|
|||
@Autowired |
|||
private CatchPalletService catchPalletService; |
|||
|
|||
@PostMapping("/export") |
|||
public void export(HttpServletResponse response, @RequestBody CatchPallet pallet) { |
|||
catchPalletService.export(response,pallet); |
|||
} |
|||
|
|||
@PostMapping("/save") |
|||
public R save(@RequestBody CatchPallet pallet) { |
|||
catchPalletService.saveCatchPallet(pallet); |
|||
return R.ok(); |
|||
} |
|||
@PostMapping("/save/batch") |
|||
public R saveBatch(@RequestBody List<CatchPallet> palletList) { |
|||
catchPalletService.saveCatchPalletBatch(palletList); |
|||
return R.ok(); |
|||
} |
|||
@PostMapping("/remove") |
|||
public R remove(@RequestBody CatchPallet pallet) { |
|||
catchPalletService.removeCatchPallet(pallet); |
|||
return R.ok(); |
|||
} |
|||
|
|||
@PostMapping("/remove/{id}") |
|||
public R removeById(@PathVariable Long id) { |
|||
catchPalletService.removeById(id); |
|||
return R.ok(); |
|||
} |
|||
|
|||
@PostMapping("/remove/all") |
|||
public R removeAll(@RequestBody CatchPallet pallet) { |
|||
catchPalletService.removeAllCatchPallet(pallet); |
|||
return R.ok(); |
|||
} |
|||
|
|||
@PostMapping("/list") |
|||
public R list(@RequestBody CatchPallet pallet) { |
|||
List<CatchPallet> list = catchPalletService.list(new QueryWrapper<>(pallet)); |
|||
return R.ok().put("rows", list); |
|||
} |
|||
|
|||
@PostMapping("/{no}/{size}") |
|||
public R update(@PathVariable("no") Integer no, |
|||
@PathVariable("size") Integer size, |
|||
@RequestBody CatchPallet pallet) { |
|||
IPage<CatchPallet> page = catchPalletService.queryPage(no,size,pallet); |
|||
return R.ok().put("rows", page.getRecords()).put("total", page.getTotal()); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.gaotao.modules.pallet.controller; |
|||
|
|||
import cn.idev.excel.FastExcel; |
|||
import com.gaotao.common.utils.R; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
import com.gaotao.modules.pallet.service.PalletService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("/pallet") |
|||
public class PalletController { |
|||
@Autowired |
|||
private PalletService palletService; |
|||
|
|||
@PostMapping("/save/batch") |
|||
public R saveBatch(@RequestBody List<Pallet> pallets) { |
|||
palletService.saveBatchPallet(pallets); |
|||
return R.ok("操作成功"); |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
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.HeadRowHeight; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@TableName("catch_pallet") |
|||
@Data |
|||
@HeadRowHeight(value = -1) |
|||
@ColumnWidth(value = 25) |
|||
public class CatchPallet { |
|||
|
|||
|
|||
@ExcelIgnore |
|||
private Long id; |
|||
|
|||
@ExcelIgnore |
|||
private String site; |
|||
|
|||
@ExcelProperty(value = "Pallet Label",index = 1) |
|||
private String palletNo; |
|||
|
|||
@ExcelProperty(value = "SN",index = 2) |
|||
private String sn; |
|||
|
|||
@ExcelProperty(value = "SKU",index = 3) |
|||
private String sku; |
|||
|
|||
@ExcelProperty(value = "Part Description",index = 4) |
|||
private String partDesc; |
|||
|
|||
@ExcelIgnore |
|||
private String erpPartNo; |
|||
|
|||
@ExcelIgnore |
|||
private String createBy; |
|||
|
|||
@ExcelIgnore |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date createTime; |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
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.HeadRowHeight; |
|||
import cn.idev.excel.annotation.write.style.HeadStyle; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
@TableName("pallet") |
|||
@Data |
|||
@HeadRowHeight(value = -1) |
|||
@ColumnWidth(value = 25) |
|||
public class Pallet { |
|||
|
|||
@ExcelIgnore |
|||
private Long id; |
|||
|
|||
@ExcelProperty("Pallet Label") |
|||
private String palletNo; |
|||
|
|||
@ExcelProperty("SN") |
|||
private String sn; |
|||
|
|||
@ExcelProperty("SKU") |
|||
private String sku; |
|||
|
|||
@ExcelProperty("Part Description") |
|||
private String partDesc; |
|||
|
|||
@ExcelIgnore |
|||
private String erpPartNo; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.gaotao.modules.pallet.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.gaotao.modules.pallet.entity.CatchPallet; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface CatchPalletMapper extends BaseMapper<CatchPallet> { |
|||
int saveBatch(List<CatchPallet> catchPalletList); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.gaotao.modules.pallet.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface PalletMapper extends BaseMapper<Pallet> { |
|||
int saveBatch(List<Pallet> pallets); |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.gaotao.modules.pallet.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.gaotao.modules.pallet.entity.CatchPallet; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
|
|||
public interface CatchPalletService extends IService<CatchPallet> { |
|||
void export(HttpServletResponse response, CatchPallet pallet); |
|||
|
|||
void saveCatchPallet(CatchPallet pallet); |
|||
|
|||
void removeCatchPallet(CatchPallet pallet); |
|||
|
|||
IPage<CatchPallet> queryPage(Integer no, Integer size, CatchPallet pallet); |
|||
|
|||
void removeAllCatchPallet(CatchPallet pallet); |
|||
|
|||
void saveCatchPalletBatch(List<CatchPallet> palletList); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
package com.gaotao.modules.pallet.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
|
|||
public interface PalletService extends IService<Pallet> { |
|||
void saveBatchPallet(List<Pallet> pallets); |
|||
} |
|||
@ -0,0 +1,140 @@ |
|||
package com.gaotao.modules.pallet.service.impl; |
|||
|
|||
import cn.idev.excel.FastExcel; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.gaotao.modules.pallet.entity.CatchPallet; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
import com.gaotao.modules.pallet.mapper.CatchPalletMapper; |
|||
import com.gaotao.modules.pallet.mapper.PalletMapper; |
|||
import com.gaotao.modules.pallet.service.CatchPalletService; |
|||
import com.gaotao.modules.pallet.service.PalletService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.net.URLEncoder; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class CatchPalletServiceImpl extends ServiceImpl<CatchPalletMapper, CatchPallet> implements CatchPalletService { |
|||
|
|||
@Autowired |
|||
private PalletService palletService; |
|||
|
|||
@Override |
|||
public void export(HttpServletResponse response, CatchPallet pallet) { |
|||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|||
response.setCharacterEncoding("utf-8"); |
|||
List<CatchPallet> list = list(new QueryWrapper<>(pallet)); |
|||
if (list.isEmpty()) { |
|||
throw new RuntimeException("not find any Pallet Label"); |
|||
} |
|||
try { |
|||
String fileName = URLEncoder.encode("Pallet Check List", "UTF-8").replaceAll("\\+", "%20"); |
|||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|||
|
|||
FastExcel.write(response.getOutputStream(), Pallet.class) |
|||
.sheet() |
|||
.doWrite(list); |
|||
} catch (Exception e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void saveCatchPallet(CatchPallet pallet) { |
|||
// 1、判断CatchPallet 是否扫托盘 |
|||
if (!StringUtils.hasText(pallet.getPalletNo())) { |
|||
throw new RuntimeException("please input Pallet Label"); |
|||
} |
|||
|
|||
List<Pallet> list = palletService.lambdaQuery() |
|||
.eq(Pallet::getPalletNo, pallet.getPalletNo().trim()) |
|||
.list(); |
|||
if (list.isEmpty()){ |
|||
throw new RuntimeException("no Pallet Label found "+pallet.getPalletNo().trim()); |
|||
} |
|||
|
|||
int count = lambdaQuery() |
|||
.eq(CatchPallet::getSite, pallet.getSite()) |
|||
.eq(CatchPallet::getPalletNo, pallet.getPalletNo().trim()) |
|||
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|||
.count(); |
|||
if (count > 0){ |
|||
throw new RuntimeException("Pallet Label \""+pallet.getPalletNo()+"\" already exist"); |
|||
} |
|||
Date date = new Date(); |
|||
List<CatchPallet> catchPalletList = new ArrayList<>(); |
|||
for (Pallet value : list) { |
|||
CatchPallet catchPallet = new CatchPallet(); |
|||
catchPallet.setPalletNo(value.getPalletNo()); |
|||
catchPallet.setPartDesc(value.getPartDesc()); |
|||
catchPallet.setSn(value.getSn()); |
|||
catchPallet.setSku(value.getSku()); |
|||
catchPallet.setErpPartNo(value.getErpPartNo()); |
|||
|
|||
catchPallet.setSite(pallet.getSite()); |
|||
catchPallet.setCreateBy(pallet.getCreateBy()); |
|||
catchPallet.setCreateTime(date); |
|||
catchPalletList.add(catchPallet); |
|||
} |
|||
int i = baseMapper.saveBatch(catchPalletList); |
|||
} |
|||
|
|||
@Override |
|||
public void removeCatchPallet(CatchPallet pallet) { |
|||
// 1、判断CatchPallet 是否扫托盘 |
|||
if (!StringUtils.hasText(pallet.getPalletNo())) { |
|||
throw new RuntimeException("please input Pallet Label"); |
|||
} |
|||
Integer count = lambdaQuery() |
|||
.eq(CatchPallet::getSite, pallet.getSite()) |
|||
.eq(CatchPallet::getPalletNo, pallet.getPalletNo()) |
|||
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|||
.count(); |
|||
if (count == 0){ |
|||
throw new RuntimeException("not find any Pallet Label"); |
|||
} |
|||
lambdaUpdate() |
|||
.eq(CatchPallet::getSite, pallet.getSite()) |
|||
.eq(CatchPallet::getPalletNo, pallet.getPalletNo()) |
|||
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|||
.remove(); |
|||
} |
|||
|
|||
@Override |
|||
public IPage<CatchPallet> queryPage(Integer no, Integer size, CatchPallet pallet) { |
|||
Page<CatchPallet> page = new Page<>(no, size); |
|||
|
|||
return lambdaQuery() |
|||
.eq(CatchPallet::getSite,pallet.getSite()) |
|||
.eq(CatchPallet::getCreateBy,pallet.getCreateBy()) |
|||
.orderByDesc(CatchPallet::getId) |
|||
.page(page); |
|||
} |
|||
|
|||
@Override |
|||
public void removeAllCatchPallet(CatchPallet pallet) { |
|||
lambdaUpdate() |
|||
.eq(CatchPallet::getSite, pallet.getSite()) |
|||
.eq(CatchPallet::getCreateBy, pallet.getCreateBy()) |
|||
.remove(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void saveCatchPalletBatch(List<CatchPallet> palletList) { |
|||
for (CatchPallet pallet : palletList) { |
|||
saveCatchPallet(pallet); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.gaotao.modules.pallet.service.impl; |
|||
|
|||
import cn.idev.excel.FastExcel; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.gaotao.modules.pallet.entity.Pallet; |
|||
import com.gaotao.modules.pallet.mapper.PalletMapper; |
|||
import com.gaotao.modules.pallet.service.PalletService; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.net.URLEncoder; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class PalletServiceImpl extends ServiceImpl<PalletMapper, Pallet> implements PalletService { |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void saveBatchPallet(List<Pallet> pallets) { |
|||
if (pallets.isEmpty()){ |
|||
return; |
|||
} |
|||
int i = baseMapper.saveBatch(pallets); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.gaotao.modules.pallet.mapper.CatchPalletMapper"> |
|||
|
|||
<insert id="saveBatch"> |
|||
insert into catch_pallet(site, pallet_no, sn, sku, part_desc, erp_part_no, create_by, create_time) values |
|||
<foreach collection="list" item="item" separator=","> |
|||
(#{item.site},#{item.palletNo},#{item.sn},#{item.sku},#{item.partDesc},#{item.erpPartNo},#{item.createBy},#{item.createTime}) |
|||
</foreach> |
|||
</insert> |
|||
</mapper> |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.gaotao.modules.pallet.mapper.PalletMapper"> |
|||
|
|||
<insert id="saveBatch"> |
|||
insert into pallet(pallet_no, sn, sku, part_desc, erp_part_no) values |
|||
<foreach collection="list" item="item" separator=","> |
|||
(#{item.palletNo},#{item.sn},#{item.sku},#{item.partDesc},#{item.erpPartNo}) |
|||
</foreach> |
|||
</insert> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue