|
|
|
|
@ -411,7 +411,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 搜索
|
|
|
|
|
*
|
|
|
|
|
* @param request 请求参数
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("search")
|
|
|
|
|
@ -421,7 +420,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据单据号获取列表
|
|
|
|
|
*
|
|
|
|
|
* @param orderNo 单据号
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("getList")
|
|
|
|
|
@ -431,7 +429,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取订单托盘详情
|
|
|
|
|
*
|
|
|
|
|
* @param id 订单id
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("getTrayInfo")
|
|
|
|
|
@ -455,9 +452,9 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
// 获取托盘号:如果物料项有关联的托盘,则使用托盘号;否则为空
|
|
|
|
|
if (item.getTrayId() != null) {
|
|
|
|
|
WmsStructuralPackageOrderTray tray = trays.stream()
|
|
|
|
|
.filter(t -> t.getId().equals(item.getTrayId()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
.filter(t -> t.getId().equals(item.getTrayId()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
if (tray != null) {
|
|
|
|
|
ivo.setNo(tray.getNo());
|
|
|
|
|
} else {
|
|
|
|
|
@ -480,7 +477,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param ids 要删除的id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("delete")
|
|
|
|
|
@ -491,7 +487,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据订单状态搜索
|
|
|
|
|
*
|
|
|
|
|
* @param request 请求参数
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("searchByState")
|
|
|
|
|
@ -501,7 +496,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出选中的id列表
|
|
|
|
|
*
|
|
|
|
|
* @param ids id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("exportByIds")
|
|
|
|
|
@ -512,7 +506,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出搜索结果
|
|
|
|
|
*
|
|
|
|
|
* @param request 搜索参数
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("exportSearchByState")
|
|
|
|
|
@ -526,7 +519,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取托盘零件列表
|
|
|
|
|
*
|
|
|
|
|
* @param id 订单id
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("getItems")
|
|
|
|
|
@ -549,7 +541,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出老鼠图PDF
|
|
|
|
|
*
|
|
|
|
|
* @param id 订单id
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("exportPdf")
|
|
|
|
|
@ -629,7 +620,7 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
variables.put("list", datas);
|
|
|
|
|
String html = ThymeleafUtil.generator("/template/qrcode/", "spitem", ".html", variables);
|
|
|
|
|
URL baseUrl = new ClassPathResource("template/qrcode/").getURL();
|
|
|
|
|
PdfGeneratorUtil.generatePdf("零件标签"+DateTimeUtil.format(LocalDateTime.now(),"yyyyMMddHHmmss"), html, baseUrl.toString(), response);
|
|
|
|
|
PdfGeneratorUtil.generatePdf("零件标签" + DateTimeUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss"), html, baseUrl.toString(), response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -1542,7 +1533,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加备注
|
|
|
|
|
*
|
|
|
|
|
* @param request 请求参数
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("itemRemark")
|
|
|
|
|
@ -1560,7 +1550,6 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据指定托盘数量重新生成订单托盘信息
|
|
|
|
|
*
|
|
|
|
|
* @param request 请求参数
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
@ -1762,10 +1751,10 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
.filter(t -> StrUtil.equals(t.getNo(), trayQO.getTrayNo()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 收集当前托盘需要绑定的托盘项
|
|
|
|
|
List<WmsStructuralPackageOrderTrayItem> currentTrayItems = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理托盘中的每个物料
|
|
|
|
|
for (TrayMaterialQO materialQO : trayQO.getItems()) {
|
|
|
|
|
// 从订单级别的所有托盘项中查找匹配的物料(排除已使用的,且trayId为null或-1表示未绑定)
|
|
|
|
|
@ -1814,12 +1803,12 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
allQrCodeDTOs.addAll(dtos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量更新当前托盘项的trayId
|
|
|
|
|
if (CollectionUtil.isNotEmpty(currentTrayItems)) {
|
|
|
|
|
structuralPackageOrderTrayItemService.updateBatchById(currentTrayItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新托盘状态为已打包
|
|
|
|
|
VUtil.trueThrowBusinessError(!structuralPackageOrderTrayService.lambdaUpdate()
|
|
|
|
|
.set(WmsStructuralPackageOrderTray::getState, OrderState.Packaged.getState())
|
|
|
|
|
@ -1853,7 +1842,7 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
VUtil.trueThrowBusinessError(StrUtil.isBlank(diffItem.getRemark()))
|
|
|
|
|
.throwMessage("物料" + diffItem.getMaterialNo() + "的差异原因不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 根据orderId查询订单信息
|
|
|
|
|
DeliverStructuralPackageOrderVO order = structuralPackageOrderService.getInfo(request.getOrderId());
|
|
|
|
|
VUtil.trueThrowBusinessError(Objects.isNull(order)).throwMessage("订单不存在");
|
|
|
|
|
@ -1889,10 +1878,10 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
.filter(t -> StrUtil.equals(t.getNo(), trayQO.getTrayNo()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 收集当前托盘需要绑定的托盘项
|
|
|
|
|
List<WmsStructuralPackageOrderTrayItem> currentTrayItems = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理托盘中的每个物料
|
|
|
|
|
for (TrayMaterialQO materialQO : trayQO.getItems()) {
|
|
|
|
|
// 从订单级别的所有托盘项中查找匹配的物料(排除已使用的,且trayId为null或-1表示未绑定)
|
|
|
|
|
@ -1948,12 +1937,12 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
allQrCodeDTOs.addAll(dtos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量更新当前托盘项的trayId
|
|
|
|
|
if (CollectionUtil.isNotEmpty(currentTrayItems)) {
|
|
|
|
|
structuralPackageOrderTrayItemService.updateBatchById(currentTrayItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新托盘状态为已打包
|
|
|
|
|
VUtil.trueThrowBusinessError(!structuralPackageOrderTrayService.lambdaUpdate()
|
|
|
|
|
.set(WmsStructuralPackageOrderTray::getState, OrderState.Packaged.getState())
|
|
|
|
|
@ -1999,14 +1988,14 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
// 9. 构建返回结果
|
|
|
|
|
PackTraySubmitWithDiffVO result = new PackTraySubmitWithDiffVO();
|
|
|
|
|
result.setOrderId(request.getOrderId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 转换托盘列表
|
|
|
|
|
List<TrayItemVO2> trayVOs = new ArrayList<>();
|
|
|
|
|
for (TraySubmitQO trayQO : request.getTrays()) {
|
|
|
|
|
TrayItemVO2 trayVO = new TrayItemVO2();
|
|
|
|
|
trayVO.setTrayNo(trayQO.getTrayNo());
|
|
|
|
|
trayVO.setOrderId(trayQO.getOrderId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TrayMaterialVO> materialVOs = new ArrayList<>();
|
|
|
|
|
for (TrayMaterialQO materialQO : trayQO.getItems()) {
|
|
|
|
|
TrayMaterialVO materialVO = new TrayMaterialVO();
|
|
|
|
|
@ -2038,4 +2027,116 @@ public class StructuralPackageOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
return ApiResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据托盘id列表导出托盘标签PDF
|
|
|
|
|
* @param ids 托盘id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("exportTrayPdfByTrayIds")
|
|
|
|
|
public void exportTrayPdfByTrayIds(HttpServletResponse response, @RequestBody @NotEmpty List<Long> ids) throws Exception {
|
|
|
|
|
List<WmsStructuralPackageOrderTray> trays = structuralPackageOrderTrayService.listByIds(ids);
|
|
|
|
|
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(trays)).throwMessage("数据不存在");
|
|
|
|
|
|
|
|
|
|
// 收集所有托盘的HTML内容
|
|
|
|
|
List<String> htmlList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 遍历所有托盘,生成每个托盘的HTML内容
|
|
|
|
|
for (WmsStructuralPackageOrderTray tray : trays) {
|
|
|
|
|
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(tray.getId());
|
|
|
|
|
VUtil.trueThrowBusinessError(Objects.isNull(trayVO)).throwMessage("数据不存在");
|
|
|
|
|
trayVO.setQrCode(QRCodeUtil.generateQRCodeBase64(trayVO.getTrayNo(), 100, 100));
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
variables.put("info", trayVO);
|
|
|
|
|
String html = ThymeleafUtil.generator("/template/qrcode/", "tray", ".html", variables);
|
|
|
|
|
htmlList.add(html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将所有托盘标签合并成一个PDF文件,每页一个标签
|
|
|
|
|
PdfGeneratorUtil.generatePdf("托盘标签", htmlList, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据托盘id列表导出托盘标签图片ZIP
|
|
|
|
|
* @param ids 托盘id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "exportTrayImageZipByTrayIds", produces = MediaType.IMAGE_PNG_VALUE)
|
|
|
|
|
public ResponseEntity<byte[]> exportTrayImageZipByTrayIds(@RequestBody @NotEmpty List<Long> ids) throws Exception {
|
|
|
|
|
List<WmsStructuralPackageOrderTray> trays = structuralPackageOrderTrayService.listByIds(ids);
|
|
|
|
|
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(trays)).throwMessage("数据不存在");
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
|
|
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
|
|
|
|
|
for (WmsStructuralPackageOrderTray tray : trays) {
|
|
|
|
|
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(tray.getId());
|
|
|
|
|
VUtil.trueThrowBusinessError(Objects.isNull(trayVO)).throwMessage("数据不存在");
|
|
|
|
|
trayVO.setQrCode(QRCodeUtil.generateQRCodeBase64(trayVO.getTrayNo(), 200, 200));
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
variables.put("info", trayVO);
|
|
|
|
|
String html = ThymeleafUtil.generator("/template/qrcode/", "tray-label", ".html", variables);
|
|
|
|
|
ZipEntry entry = new ZipEntry(trayVO.getTrayNo() + ".png");
|
|
|
|
|
zos.putNextEntry(entry);
|
|
|
|
|
byte[] imageBytes = HtmlToImageUtil.convertToPng(html, 600);
|
|
|
|
|
zos.write(imageBytes, 0, imageBytes.length);
|
|
|
|
|
zos.closeEntry();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
byte[] zipBytes = baos.toByteArray();
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.setContentType(MediaType.valueOf("application/zip"));
|
|
|
|
|
headers.setContentLength(zipBytes.length);
|
|
|
|
|
return new ResponseEntity<>(zipBytes, headers, HttpStatus.OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据托盘id列表导出托盘零件列表
|
|
|
|
|
* @param ids 托盘id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("exportItemsByTrayIds")
|
|
|
|
|
public void exportItemsByTrayIds(HttpServletResponse response, @RequestBody @NotEmpty List<Long> ids) throws IOException {
|
|
|
|
|
List<DeliverStructuralPackageOrderTrayItemVO> list = structuralPackageOrderTrayItemService.getListVOByTrayIds(ids);
|
|
|
|
|
EecExcelUtil.export("零件信息", "sheet1", list, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据托盘id列表导出老鼠图PDF
|
|
|
|
|
* @param ids 托盘id列表
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("exportPdfByTrayIds")
|
|
|
|
|
public ApiResult<String> exportPdfByTrayIds(@RequestBody @NotEmpty List<Long> ids) throws Exception {
|
|
|
|
|
List<DeliverStructuralPackageOrderTrayItemVO> list = structuralPackageOrderTrayItemService.getListVOByTrayIds(ids);
|
|
|
|
|
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(list)).throwMessage("数据不存在");
|
|
|
|
|
DeliverStructuralPackageOrderExtendVO trayVO = structuralPackageOrderTrayService.getInfo(list.get(0).getTrayId());
|
|
|
|
|
|
|
|
|
|
PackageVO vo = new PackageVO()
|
|
|
|
|
.setNo(trayVO.getPackageNo())
|
|
|
|
|
.setExternalOrderNo(trayVO.getExternalOrderNo())
|
|
|
|
|
.setRowNo(trayVO.getRowNo())
|
|
|
|
|
.setSupplierName(trayVO.getSupplierName())
|
|
|
|
|
.setModelNos(trayVO.getModelNo())
|
|
|
|
|
.setVersion(trayVO.getPackageVersion())
|
|
|
|
|
.setWorkbenchCode(trayVO.getWorkbenchCode())
|
|
|
|
|
.setCate(trayVO.getPackageCate())
|
|
|
|
|
.setWeight(trayVO.getWeight())
|
|
|
|
|
.setDrawingNo(trayVO.getPackageDrawingNo())
|
|
|
|
|
.setName(trayVO.getPackageDesc())
|
|
|
|
|
.setQrCode(QRCodeUtil.generateQRCodeBase64(trayVO.getPackageNo(), 100, 100));
|
|
|
|
|
|
|
|
|
|
List<PackageMaterialDTO> items = list.stream()
|
|
|
|
|
.map(item -> new PackageMaterialDTO()
|
|
|
|
|
.setImage(item.getImage())
|
|
|
|
|
.setNo(item.getMaterialNo())
|
|
|
|
|
.setDrawingNo(item.getDrawingNo())
|
|
|
|
|
.setName(item.getMaterialDesc())
|
|
|
|
|
.setNum(item.getShipmentNum())
|
|
|
|
|
.setWeight(item.getWeight())
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
|
|
variables.put("info", vo);
|
|
|
|
|
variables.put("pages", PdfPageDTO.create(items, 9, new PackageMaterialDTO()));
|
|
|
|
|
String html = ThymeleafUtil.generator("/template/", "钢构件老鼠图", ".html", variables);
|
|
|
|
|
// PdfGeneratorUtil.generatePdf(vo.getExternalOrderNo() + "-" + vo.getWorkbenchCode() + "老鼠图", html, response);
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
|
|
PdfGeneratorUtil.generatePdf(vo.getExternalOrderNo() + "-" + vo.getWorkbenchCode() + "老鼠图", html, outputStream);
|
|
|
|
|
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
|
|
|
|
return ApiResult.success(fileUploadService.upload("tmp/sp/" + RandomUtil.randomString(10) + "/" + "老鼠图.pdf", inputStream, MediaType.APPLICATION_PDF_VALUE));
|
|
|
|
|
}
|
|
|
|
|
}
|