master:打印条码功能完善;
parent
b738f2cd78
commit
bd0c2b09e9
|
|
@ -6,6 +6,7 @@ import com.ruoyi.common.core.controller.XktBaseController;
|
|||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeProdColorSize.*;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StorePrintSnDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreProdSnDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreSaleSnDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreStockTakingSnDTO;
|
||||
|
|
@ -20,6 +21,8 @@ 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;
|
||||
|
||||
/**
|
||||
* 档口商品颜色的尺码Controller
|
||||
*
|
||||
|
|
@ -58,9 +61,12 @@ public class StoreProductColorSizeController extends XktBaseController {
|
|||
return R.ok(BeanUtil.toBean(prodColorSizeService.stockTakingSnList(BeanUtil.toBean(snVO, StoreStockTakingSnDTO.class)), StoreStockTakingSnResVO.class));
|
||||
}
|
||||
|
||||
|
||||
// TODO 打印条码
|
||||
// TODO 打印条码
|
||||
// TODO 打印条码
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@Log(title = "[打印条码] 获取商品条码", businessType = BusinessType.INSERT)
|
||||
@ApiOperation(value = "[打印条码] 获取商品条码", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/sn/print")
|
||||
public R<List<StorePrintSnResVO>> getPrintSnList(@Validated @RequestBody StorePrintSnVO snVO) {
|
||||
return R.ok(BeanUtil.copyToList(prodColorSizeService.getPrintSnList(BeanUtil.toBean(snVO, StorePrintSnDTO.class)), StorePrintSnResVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "打印条码返回前端数据model")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StorePrintSnResVO {
|
||||
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "打印size条码列表")
|
||||
private List<SPSizeSnVO> sizeSnList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPSizeSnVO {
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "条码列表")
|
||||
private List<String> snList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "打印条码请求入参")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StorePrintSnVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private String storeId;
|
||||
@Valid
|
||||
@NotNull(message = "打印颜色尺码列表不能为空!")
|
||||
@ApiModelProperty(value = "打印颜色尺码列表", required = true)
|
||||
private List<SPColorSizeVO> colorSizeList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPColorSizeVO {
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID", required = true)
|
||||
private Long storeProdColorId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID", required = true)
|
||||
private Long storeProdId;
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口颜色ID", required = true)
|
||||
private Long storeColorId;
|
||||
@NotNull(message = "打印尺码列表不能为空!")
|
||||
@Valid
|
||||
@ApiModelProperty(value = "打印尺码列表", required = true)
|
||||
private List<SPSizeVO> sizeQuantityList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPSizeVO {
|
||||
@NotNull(message = "尺码不能为空!")
|
||||
@ApiModelProperty(value = "尺码", required = true)
|
||||
private Integer size;
|
||||
@NotNull(message = "数量不能为空!")
|
||||
@ApiModelProperty(value = "数量", required = true)
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreProdSnResVO {
|
||||
|
||||
@ApiModelProperty(value = "错误列表")
|
||||
List<String> failList;
|
||||
@ApiModelProperty(value = "成功列表")
|
||||
List<SPSDetailVO> successList;
|
||||
|
||||
@Data
|
||||
public static class SPSDetailVO {
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "档口商品颜色尺码ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "颜色")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "销售条码")
|
||||
private String sn;
|
||||
@ApiModelProperty(value = "销售单价")
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "档口客户优惠金额")
|
||||
private BigDecimal discount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "档口销售扫码返回数据")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreSaleSnResVO {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "档口库存返回数据")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreStockTakingSnResVO {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="档口入库扫码返回数据")
|
||||
@Accessors(chain = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreStorageSnResVO {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package com.ruoyi.xkt.dto.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "打印条码请求入参")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StorePrintSnDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private String storeId;
|
||||
@ApiModelProperty(value = "打印颜色尺码列表")
|
||||
private List<SPColorSizeVO> colorSizeList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPColorSizeVO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "打印尺码列表")
|
||||
private List<SPSizeVO> sizeQuantityList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPSizeVO {
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.xkt.dto.storeProdColorSize;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "打印条码返回前端数据model")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StorePrintSnResDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "打印size条码列表")
|
||||
private List<SPSizeSnDTO> sizeSnList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SPSizeSnDTO {
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "条码列表")
|
||||
private List<String> snList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.xkt.service;
|
|||
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 档口商品颜色的尺码Service接口
|
||||
*
|
||||
|
|
@ -33,4 +35,13 @@ public interface IStoreProductColorSizeService {
|
|||
* @return StoreStorageSnResDTO
|
||||
*/
|
||||
StoreStockTakingSnResDTO stockTakingSnList(StoreStockTakingSnDTO snDTO);
|
||||
|
||||
/**
|
||||
* 打印条码时获取条码
|
||||
*
|
||||
* @param snDTO 条码入参
|
||||
* @return StorePrintSnResDTO
|
||||
*/
|
||||
List<StorePrintSnResDTO> getPrintSnList(StorePrintSnDTO snDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.xkt.domain.StoreProductColorSize;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.*;
|
||||
import com.ruoyi.xkt.mapper.StoreProductColorSizeMapper;
|
||||
import com.ruoyi.xkt.mapper.StoreSaleDetailMapper;
|
||||
|
|
@ -13,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -45,6 +52,10 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreSaleSnResDTO storeSaleSn(StoreSaleSnDTO snDTO) {
|
||||
// 用户是否为档口管理者或子账户
|
||||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
}
|
||||
// 非纯数字,则直接返回
|
||||
if (!POSITIVE_PATTERN.matcher(snDTO.getSn()).matches()) {
|
||||
return new StoreSaleSnResDTO().setSuccess(Boolean.FALSE).setSn(snDTO.getSn());
|
||||
|
|
@ -74,6 +85,10 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreStorageSnResDTO storageSnList(StoreProdSnDTO snDTO) {
|
||||
// 用户是否为档口管理者或子账户
|
||||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
}
|
||||
List<String> snList = snDTO.getSnList().stream().filter(s -> POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(snList)) {
|
||||
return new StoreStorageSnResDTO().setFailList(snDTO.getSnList());
|
||||
|
|
@ -123,6 +138,10 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreStockTakingSnResDTO stockTakingSnList(StoreStockTakingSnDTO snDTO) {
|
||||
// 用户是否为档口管理者或子账户
|
||||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
}
|
||||
List<String> snList = snDTO.getSnList().stream().filter(s -> POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(snList)) {
|
||||
return new StoreStockTakingSnResDTO().setFailList(snDTO.getSnList());
|
||||
|
|
@ -162,6 +181,70 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
return new StoreStockTakingSnResDTO().setFailList(failList).setSuccessList(successList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印条码时获取条码
|
||||
*
|
||||
* @param snDTO 条码入参
|
||||
* @return StorePrintSnResDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public List<StorePrintSnResDTO> getPrintSnList(StorePrintSnDTO snDTO) {
|
||||
// 用户是否为档口管理者或子账户
|
||||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
}
|
||||
// 获取商品颜色尺码基础数据
|
||||
List<Long> storeProdIdList = snDTO.getColorSizeList().stream().map(StorePrintSnDTO.SPColorSizeVO::getStoreProdId).distinct().collect(Collectors.toList());
|
||||
List<Long> storeColorIdList = snDTO.getColorSizeList().stream().map(StorePrintSnDTO.SPColorSizeVO::getStoreColorId).distinct().collect(Collectors.toList());
|
||||
List<StoreProductColorSize> colorSizeList = this.prodColorSizeMapper.selectList(new LambdaQueryWrapper<StoreProductColorSize>()
|
||||
.eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED).in(StoreProductColorSize::getStoreProdId, storeProdIdList)
|
||||
.in(StoreProductColorSize::getStoreColorId, storeColorIdList));
|
||||
if (CollectionUtils.isEmpty(colorSizeList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// key storeProdId + storeColorId + size, value storeProductColorSize
|
||||
Map<String, StoreProductColorSize> colorSizeMap = colorSizeList.stream().collect(Collectors
|
||||
.toMap(x -> x.getStoreProdId() + ":" + x.getStoreColorId() + ":" + x.getSize(), Function.identity()));
|
||||
// 待更新列表
|
||||
List<StoreProductColorSize> updateList = new ArrayList<>();
|
||||
// 返回给前端的待打印条码列表
|
||||
List<StorePrintSnResDTO> printSnList = new ArrayList<>();
|
||||
for (int i = 0; i < snDTO.getColorSizeList().size(); i++) {
|
||||
final StorePrintSnDTO.SPColorSizeVO colorSizeVO = snDTO.getColorSizeList().get(i);
|
||||
List<StorePrintSnDTO.SPSizeVO> sizeQuantityList = colorSizeVO.getSizeQuantityList();
|
||||
// storeProductColorId 下 所有的条码
|
||||
List<StorePrintSnResDTO.SPSizeSnDTO> sizeSnList = new ArrayList<>();
|
||||
for (int j = 0; j < sizeQuantityList.size(); j++) {
|
||||
final StorePrintSnDTO.SPSizeVO quantityVO = sizeQuantityList.get(j);
|
||||
// 获取系统条码对应信息
|
||||
final String key = colorSizeVO.getStoreProdId() + ":" + colorSizeVO.getStoreColorId() + ":" + quantityVO.getSize();
|
||||
StoreProductColorSize colorSize = colorSizeMap.get(key);
|
||||
if (ObjectUtils.isEmpty(colorSize)) {
|
||||
continue;
|
||||
}
|
||||
// 待打印的下一个条码
|
||||
Integer nextSn = colorSize.getNextSn();
|
||||
// 当前尺码对应的条码列表
|
||||
List<String> snList = new ArrayList<>();
|
||||
for (int k = 0; k < quantityVO.getQuantity(); k++) {
|
||||
nextSn += 1;
|
||||
// 更新下一次打印的条码编号
|
||||
// 取 colorSize 的 nextSn 字段,不足8位填充为8位
|
||||
snList.add(colorSize.getSnPrefix() + String.format("%08d", nextSn));
|
||||
}
|
||||
// 更新下一个待打印条码开始值
|
||||
updateList.add( colorSize.setNextSn(nextSn));
|
||||
sizeSnList.add(new StorePrintSnResDTO.SPSizeSnDTO().setSize(quantityVO.getSize()).setSnList(snList));
|
||||
}
|
||||
printSnList.add(new StorePrintSnResDTO().setStoreProdColorId(colorSizeVO.getStoreProdColorId()).setSizeSnList(sizeSnList));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(updateList)) {
|
||||
this.prodColorSizeMapper.updateById(updateList);
|
||||
}
|
||||
return printSnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通销售流程获取条码对应的商品信息
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue