diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/QRCodeUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/QRCodeUtil.java index 8c681de92..9db8e4c7b 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/QRCodeUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/QRCodeUtil.java @@ -73,6 +73,34 @@ public class QRCodeUtil { return null; } + public static String createCodeToFileType(String content) { + try { + //getResource("/")等同于到resource文件夹下 + String imgPath = QRCodeUtil.class.getResource("").getPath()+path; + File codeImgFileSaveDir = new File(imgPath); + //1. 使用UUID重新生成文件名,防止文件名称重复造成文件覆盖 + String fileName = UUID.randomUUID() + "." +FileFormat; + content = content.trim(); + if (codeImgFileSaveDir==null || codeImgFileSaveDir.isFile()) { + //二维码图片存在目录为空,默认放在桌面... + codeImgFileSaveDir = FileSystemView.getFileSystemView().getHomeDirectory(); + } + if (!codeImgFileSaveDir.exists()) { + //二维码图片存在目录不存在,开始创建... + codeImgFileSaveDir.mkdirs(); + } + //核心代码-生成二维码 + BufferedImage bufferedImage = getBufferedImageMatrix(content); + File codeImgFile = new File(codeImgFileSaveDir, fileName); + ImageIO.write(bufferedImage, FileFormat, codeImgFile); + fileName = imgPath.substring(1) +"/"+fileName; + return fileName; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + /** * 生成二维码并输出到输出流, 通常用于输出到网页上进行显示,输出到网页与输出到磁盘上的文件中,区别在于最后一句 ImageIO.write * write(RenderedImage im,String formatName,File output):写到文件中 @@ -118,5 +146,31 @@ public class QRCodeUtil { } } return bufferedImage; + } //核心代码-生成二维码 + public static BufferedImage getBufferedImageMatrix(String content) throws WriterException { + + //com.google.zxing.EncodeHintType:编码提示类型,枚举类型 + Map hints = new HashMap(); + + //EncodeHintType.CHARACTER_SET:设置字符编码类型 + hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); + + //EncodeHintType.ERROR_CORRECTION:设置误差校正 + //ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction + //不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的 + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + + //EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近 + hints.put(EncodeHintType.MARGIN, 1); + + MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); + BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.CODE_128, 100, 30, hints); + BufferedImage bufferedImage = new BufferedImage(100, 30, BufferedImage.TYPE_INT_BGR); + for (int x = 0; x < 100; x++) { + for (int y = 0; y < 30; y++) { + bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? FRONT_COLOR : BACKGROUND_COLOR); + } + } + return bufferedImage; } } diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java index ba5e36b96..2cea44827 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockArticleEntity.java @@ -83,6 +83,11 @@ public class DistributionStockArticleEntity extends TenantEntity { */ @ApiModelProperty(value = "订单自编号") private String orderCode; + /** + * 寄件信息 + */ + @ApiModelProperty(value = "寄件信息") + private String sending; /** * 门店id diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleQRCodeVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleQRCodeVO.java new file mode 100644 index 000000000..7cac5dcd4 --- /dev/null +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleQRCodeVO.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package com.logpm.distribution.vo; + +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 配送在库订单 视图实体类 + * + * @author cyz + * @since 2023-06-13 + */ +@Data +public class DistributionStockArticleQRCodeVO { + + /** + * 物料名称 + */ + @ApiModelProperty(value = "物料名称") + private String orderCode; + /** + * 已备货数量 + */ + @ApiModelProperty(value = "已备货数量") + private String mallName; + /** + * 备货数量 + */ + @ApiModelProperty(value = "备货数量") + private String customerName; + /** + * 托盘 + */ + @ApiModelProperty(value = "托盘") + private String customerTelephone; + /** + * 货位信息 + */ + @ApiModelProperty(value = "货位信息") + private String customerAddress; + /** + * 订单状态 + */ + @ApiModelProperty(value = "订单状态") + private String sending; + /** + * 物料名称 + */ + @ApiModelProperty(value = "物料名称") + private String materialName; + /** + * 品类 + */ + @ApiModelProperty(value = "品类") + private String category; + /** + * 运单数 + */ + @ApiModelProperty(value = "运单数") + private String waybillsNum; + /** + * 目的仓 + */ + @ApiModelProperty(value = "目的仓") + private String objective; + /** + * 发起仓 + */ + @ApiModelProperty(value = "发起仓") + private String departureStation; + /** + * 订单状态 + */ + @ApiModelProperty(value = "订单状态") + private String dealerCode; + /** + * 订单状态 + */ + @ApiModelProperty(value = "订单状态") + private String dealerName; + /** + * 订单状态 + */ + @ApiModelProperty(value = "订单状态") + private String waybillNumber; + /** + * 订单状态 + */ + @ApiModelProperty(value = "订单状态") + private String totalNumber; +// /** +// * 订单状态 +// */ +// @ApiModelProperty(value = "订单状态") +// private String waybillsNum; + + + public Map toMap() throws IllegalAccessException { + Map map = new HashMap<>(); + + // 使用反射获取所有字段 + Field[] fields = this.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); // 设置可以访问私有字段 + String fieldName = field.getName(); + Object value = field.get(this); + map.put(fieldName, value); + } + + return map; + } + +} diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleVO.java index aa0cf861c..d8d5dcf94 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleVO.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockArticleVO.java @@ -24,7 +24,10 @@ import org.springblade.core.tool.node.INode; import lombok.Data; import lombok.EqualsAndHashCode; +import java.lang.reflect.Field; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 配送在库订单 视图实体类 @@ -103,6 +106,19 @@ public class DistributionStockArticleVO extends DistributionStockArticleEntity { @ApiModelProperty(value = "是否齐套名称") private List parcelListVOS; + public Map toMap() throws IllegalAccessException { + Map map = new HashMap<>(); + // 使用反射获取所有字段 + Field[] fields = this.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); // 设置可以访问私有字段 + String fieldName = field.getName(); + Object value = field.get(this); + map.put(fieldName, value); + } + + return map; + } } diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupOrderInfoVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupOrderInfoVO.java index 6510c9cab..6fc89f44b 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupOrderInfoVO.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupOrderInfoVO.java @@ -13,6 +13,8 @@ public class DistributionStockupOrderInfoVO implements Serializable { private String customer;//客户 + private String address;//地址 + private Integer planNum;//计划件数 private Integer scanNum;//备货件数 diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupStockListInfoVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupStockListInfoVO.java index 228e1df26..07420b7f9 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupStockListInfoVO.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/DistributionStockupStockListInfoVO.java @@ -14,6 +14,7 @@ public class DistributionStockupStockListInfoVO implements Serializable { private Long stockListId;//库存品id private String customer;//客户 + private String deliveryAddress;//地址 private Integer planNum;//计划件数 diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/PackageStockupVO.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/PackageStockupVO.java index 014b67253..f04a83cf3 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/PackageStockupVO.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/vo/PackageStockupVO.java @@ -1,8 +1,11 @@ package com.logpm.distribution.vo; +import com.logpm.distribution.entity.DistributionParcelDetailsEntity; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @Data public class PackageStockupVO implements Serializable { @@ -21,4 +24,6 @@ public class PackageStockupVO implements Serializable { private Long scanId;//扫码记录id + private List detailsEntities = new ArrayList<>(); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockArticleController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockArticleController.java index f62cb9586..4a3684cfa 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockArticleController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockArticleController.java @@ -254,10 +254,9 @@ public class DistributionStockArticleController extends BladeController { @GetMapping("/getShowTemplate") @ApiOperationSupport(order = 2) @ApiOperation(value = "生成二维码图片返回前端渲染") - public R getShowTemplate(@ApiIgnore @RequestParam Map params,HttpServletResponse response) { + public void getShowTemplate(@ApiIgnore @RequestParam Map params,HttpServletResponse response) throws IllegalAccessException { // boolean result = basicdataGoodsShelfService.getTemplate(params,response); - R result = distributionStockArticleService.getShowTemplate(params,response); - return result; + distributionStockArticleService.getShowTemplate(params,response); } /** diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java index f5aad8e2d..3a9a06eab 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java @@ -17,6 +17,7 @@ package com.logpm.distribution.mapper; import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.vo.DistributionStockArticleQRCodeVO; import com.logpm.distribution.vo.DistributionStockArticleVO; import com.logpm.distribution.excel.DistributionStockArticleExcel; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -70,4 +71,12 @@ public interface DistributionStockArticleMapper extends BaseMapper selectClientListPage(IPage page, DistributionStockArticleVO distributionStockArticleVO,@Param("loginUserId") Long loginUserId); List getAllReservationStockArticleInfo(@Param("ew") Map query); + + /** + * 查询二维码包件数据 + * @param qrCode + * @param o + * @return + */ + DistributionStockArticleQRCodeVO getOrderNoList(@Param("qrCode") String qrCode, @Param("o") String o); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml index ad404f831..c432bf1b8 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml @@ -191,4 +191,15 @@ + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml index e57dae62f..a8815bb84 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockListMapper.xml @@ -170,6 +170,7 @@ select ldr.id reservationId, ldsl.id stockListId, ldr.consignee customer, + ldr.delivery_address deliveryAddress, ldr.goods_area_name stockupArea, ldrs.reservation_num planNum, ldsl.storage_location warehouseArea, diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java index 3b30c8d76..1d3cc0c03 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java @@ -96,7 +96,7 @@ public interface IDistributionStockArticleService extends BaseService> selectStockArticleAndParcel(Map query); - R getShowTemplate(Map params, HttpServletResponse response); + void getShowTemplate(Map params, HttpServletResponse response) throws IllegalAccessException; R getPrintTemplates(List ids, HttpServletResponse response); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index 33a44465e..fcb007f2d 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -530,6 +530,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl 0) { for (DistributionLoadscaninvnEntity distributionLoadscanEntity : distributionLoadscanvnEntitiesopen) { //查询是否重复扫码 - List distributionLoadscanEntitiesflag = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() + List distributionLoadscaninvnEntitiesflag = distributionLoadscaninvnMapper.selectList(new QueryWrapper().lambda() .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId()) .eq(DistributionLoadscaninvnEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode()) .ne(DistributionLoadscaninvnEntity::getScanStatus, 1) .eq(DistributionLoadscaninvnEntity::getSignforState,2) ); + if (distributionLoadscaninvnEntitiesflag.size() > 0) { + // 修改该记录 + for (DistributionLoadscaninvnEntity loadscanEntity : distributionLoadscaninvnEntitiesflag) { + if (loadscanEntity.getSignforState() ==2)break; + distributionLoadscaninvnService.update(new UpdateWrapper().lambda() + .eq(DistributionLoadscaninvnEntity::getDeliveryId, distributionLoadscanEntity.getDeliveryId()) + .eq(DistributionLoadscaninvnEntity::getOrderPackageCode, distributionLoadscanEntity.getOrderPackageCode()) + .set(DistributionLoadscaninvnEntity::getSigningTime,simpleDateFormat.format(new Date())) + .set(DistributionLoadscaninvnEntity::getSignforState,2) + .set(DistributionLoadscaninvnEntity::getReceivedQuantity,1) + ); + //更新签收表的签收数量和装车数量 + Integer j = distributionSignforMapper.updateSignforByReservationId(loadscanEntity.getDeliveryId(),loadscanEntity.getReservationId(), loadscanEntity.getPackageNub()); + } +// distributionLoadscanService.update() + continue; + } //依次插入该装车记录,设置车辆 if (null != distributionDeliverySelfEntity.getDriverId()) { distributionLoadscanEntity.setDriverId(distributionDeliverySelfEntity.getDriverId()); @@ -571,6 +589,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl getShowTemplate(Map params, HttpServletResponse response) { + public void getShowTemplate(Map params, HttpServletResponse response) throws IllegalAccessException { String tenantId = AuthUtil.getTenantId(); // String templateId = (String) params.get("templateId"); - BasicPrintTemplateEntity template = basicPrintTemplateClient.getTemplate(tenantId); + BasicPrintTemplateEntity template = basicPrintTemplateClient.getTemplate("1688431772497219586"); String qrCode = (String) params.get("qrCode"); if (Func.isBlank(qrCode)){ log.error("参数异常:+{"+qrCode+"}"); - return R.fail("服务器正忙!!!"); + throw new ServiceException("服务器正忙!!!"); } String filename = QRCodeUtil.createCodeToFile(qrCode); + String filetypeName = QRCodeUtil.createCodeToFileType(qrCode); +// params.put("img","/"+filename); params.put("img","/"+filename); + params.put("imgType","/"+filetypeName); + //查询订单号 + String o =(String) params.get("id"); + DistributionStockArticleQRCodeVO orderNoList = baseMapper.getOrderNoList(qrCode, o); + Map map = orderNoList.toMap(); + // 创建一个新的Map,并将map1和map2合并到其中 + Map mergedMap = new HashMap<>(); + mergedMap.putAll(params); + mergedMap.putAll(map); ServletOutputStream os =null; try { - BufferedImage image = TemplateUtil.turnImage(template.getTemplateName(), params,template.getTemplateUrl(),template.getTemplateWidth(),template.getTemplateHeight()); + BufferedImage image = TemplateUtil.turnImage(template.getTemplateName(), mergedMap,template.getTemplateUrl(),template.getTemplateWidth(),template.getTemplateHeight()); os = response.getOutputStream(); ImageIO.write(image, "png",os); os.flush(); @@ -418,13 +427,14 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl selectDistributionStockupPage(IPage page, DistributionStockupVO distributionStockup) { @@ -343,10 +348,16 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl qw = new QueryWrapper<>(); + qw.eq("package_code",orderPackageCode); + List parcelDetailsEntityList = distributionParcelDetailsService.list(qw); + vo.setDetailsEntities(parcelDetailsEntityList); } DistributionStockupOrderInfoVO vo = new DistributionStockupOrderInfoVO(); vo.setReservationId(reservationId); vo.setCustomer(reservationEntity.getConsignee()); + vo.setAddress(reservationEntity.getDeliveryAddress()); vo.setPlanNum(size); vo.setScanNum(scanNum); vo.setStockupArea(reservationEntity.getGoodsAreaName());