master:条码迁移部分功能完善;
parent
544a24d19e
commit
de67934e92
|
|
@ -6,20 +6,14 @@ 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;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.*;
|
||||
import com.ruoyi.xkt.service.IStoreProductColorSizeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -69,4 +63,20 @@ public class StoreProductColorSizeController extends XktBaseController {
|
|||
return R.ok(BeanUtil.copyToList(prodColorSizeService.getPrintSnList(BeanUtil.toBean(snVO, StorePrintSnDTO.class)), StorePrintSnResVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@Log(title = "一键迁移条码", businessType = BusinessType.INSERT)
|
||||
@ApiOperation(value = "一键迁移条码", httpMethod = "PUT", response = R.class)
|
||||
@PutMapping("/sn/other")
|
||||
public R<Integer> updateOtherSn(@Validated @RequestBody StoreUpdateOtherSnVO snVO) {
|
||||
return R.ok(prodColorSizeService.updateOtherSn(BeanUtil.toBean(snVO, StoreUpdateOtherSnDTO.class)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@Log(title = "获取未设置条码的商品", businessType = BusinessType.INSERT)
|
||||
@ApiOperation(value = "获取未设置条码的商品", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/sn/unset/{storeId}")
|
||||
public R<StoreUnsetSnVO> getUnSetSnProdList(@PathVariable Long storeId) {
|
||||
return R.ok(BeanUtil.toBean(prodColorSizeService.getUnSetSnProdList(storeId), StoreUnsetSnVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.StoreProdColorBarcodeRecord;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class StoreProdColorBarcodeExistResVO {
|
||||
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "商品颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "已有条码")
|
||||
private String existBarcode;
|
||||
@ApiModelProperty(value = "新条码")
|
||||
private String newBarcode;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.StoreProdColorBarcodeRecord;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class StoreProdColorBarcodeExistVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private Long storeId;
|
||||
@NotNull(message = "条码列表不能为空!")
|
||||
@Valid
|
||||
@ApiModelProperty(value = "条码列表", required = true)
|
||||
List<BarcodeItemVO> barcodeList;
|
||||
|
||||
@Data
|
||||
public static class BarcodeItemVO {
|
||||
@NotBlank(message = "商品货号不能为空!")
|
||||
@ApiModelProperty(value = "商品货号", required = true)
|
||||
private String prodArtNum;
|
||||
@NotNull(message = "档口颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口颜色ID", required = true)
|
||||
private Long storeColorId;
|
||||
@NotBlank(message = "颜色名称不能为空!")
|
||||
@ApiModelProperty(value = "颜色名称", required = true)
|
||||
private String colorName;
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID", required = true)
|
||||
private Long storeProdColorId;
|
||||
@NotBlank(message = "条码不能为空!")
|
||||
@ApiModelProperty(value = "条码", required = true)
|
||||
private String barcode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class StoreUnsetSnVO {
|
||||
|
||||
/**
|
||||
* 未设置条码商品列表
|
||||
*/
|
||||
@ApiModelProperty(value = "未设置条码商品列表")
|
||||
List<String> unsetSnList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeProdColorSize;
|
||||
|
||||
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.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
|
||||
public class StoreUpdateOtherSnVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID", required = true)
|
||||
private Long storeId;
|
||||
@Valid
|
||||
@NotNull(message = "更新条码列表不能为空!")
|
||||
@ApiModelProperty(value = "更新条码列表", required = true)
|
||||
private List<SUOSnVO> snList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
@Accessors(chain = true)
|
||||
public static class SUOSnVO {
|
||||
@NotNull(message = "档口颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口颜色ID", required = true)
|
||||
private Long storeColorId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID", required = true)
|
||||
private Long storeProdId;
|
||||
@NotBlank(message = "商品货号不能为空!")
|
||||
@ApiModelProperty(value = "商品货号", required = true)
|
||||
private String prodArtNum;
|
||||
@NotBlank(message = "颜色名称不能为空!")
|
||||
@ApiModelProperty(value = "颜色名称", required = true)
|
||||
private String colorName;
|
||||
@NotBlank(message = "录入的条码")
|
||||
@ApiModelProperty(value = "条码", required = true)
|
||||
@Size(min = 0, max = 50, message = "条码长度不能超过100个字符")
|
||||
private String sn;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -248,8 +248,12 @@ public class Constants
|
|||
public static final Integer BU_JU_SN_PREFIX_LENGTH = 13;
|
||||
// 天友条码前缀长度
|
||||
public static final Integer TIAN_YOU_SN_PREFIX_LENGTH = 6;
|
||||
// 天友条码 公共部分 前缀长度
|
||||
public static final Integer TIAN_YOU_SN_COMMON_PREFIX_LENGTH = 4;
|
||||
// 发货宝条码前缀长度
|
||||
public static final Integer FA_HUO_BAO_SN_PREFIX_LENGTH = 10;
|
||||
// 发货宝条码 公共部分 前缀长度
|
||||
public static final Integer FA_HUO_BAO_SN_COMMON_PREFIX_LENGTH = 8;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.xkt.dto.StoreProdColorBarcodeRecord;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class StoreProdColorBarcodeExistDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "条码列表")
|
||||
List<BarcodeItemDTO> barcodeList;
|
||||
|
||||
@Data
|
||||
public static class BarcodeItemDTO {
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "条码")
|
||||
private String barcode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.xkt.dto.StoreProdColorBarcodeRecord;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class StoreProdColorBarcodeExistResDTO {
|
||||
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "商品颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "已有条码")
|
||||
private String existBarcode;
|
||||
@ApiModelProperty(value = "新条码")
|
||||
private String newBarcode;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.xkt.dto.storeProdColorSize;
|
||||
|
||||
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
|
||||
@Accessors(chain = true)
|
||||
public class StoreUnsetSnDTO {
|
||||
|
||||
/**
|
||||
* 未设置条码商品列表
|
||||
*/
|
||||
@ApiModelProperty(value = "未设置条码商品列表")
|
||||
List<String> unsetSnList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.xkt.dto.storeProdColorSize;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class StoreUnsetSnTempDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.ruoyi.xkt.dto.storeProdColorSize;
|
||||
|
||||
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
|
||||
|
||||
public class StoreUpdateOtherSnDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "更新条码列表")
|
||||
private List<SUOSnDTO> snList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
@Accessors(chain = true)
|
||||
public static class SUOSnDTO {
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "条码")
|
||||
private String sn;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,10 +2,7 @@ package com.ruoyi.xkt.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.StoreProductColorSize;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreProdSizeDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreSaleSnResDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreStockTakingSnTempDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.StoreStorageSnDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
@ -92,5 +89,13 @@ public interface StoreProductColorSizeMapper extends BaseMapper<StoreProductColo
|
|||
*/
|
||||
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> selectStockOtherSnList(@Param("storeId") Long storeId, @Param("otherPrefixSnList") List<String> otherPrefixSnList);
|
||||
|
||||
/**
|
||||
* 获取未设置条码的商品颜色尺码列表
|
||||
*
|
||||
* @param storeId 档口ID
|
||||
* @return List<StoreUnsetSnTempDTO>
|
||||
*/
|
||||
List<StoreUnsetSnTempDTO> selectUnsetProdList(@Param("storeId") Long storeId);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,4 +44,20 @@ public interface IStoreProductColorSizeService {
|
|||
*/
|
||||
List<StorePrintSnResDTO> getPrintSnList(StorePrintSnDTO snDTO);
|
||||
|
||||
/**
|
||||
* 一键迁移条码
|
||||
*
|
||||
* @param otherSnDTO 条码入参
|
||||
* @return Integer
|
||||
*/
|
||||
Integer updateOtherSn(StoreUpdateOtherSnDTO otherSnDTO);
|
||||
|
||||
/**
|
||||
* 获取未设置条码的商品
|
||||
*
|
||||
* @param storeId 档口ID
|
||||
* @return StoreUnsetSnResDTO
|
||||
*/
|
||||
StoreUnsetSnDTO getUnSetSnProdList(Long storeId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,20 +8,16 @@ import com.ruoyi.common.constant.HttpStatus;
|
|||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.xkt.domain.Store;
|
||||
import com.ruoyi.xkt.domain.StoreProductColorSize;
|
||||
import com.ruoyi.xkt.domain.StoreProductStock;
|
||||
import com.ruoyi.xkt.domain.*;
|
||||
import com.ruoyi.xkt.dto.storeProdColorSize.*;
|
||||
import com.ruoyi.xkt.enums.StockSysType;
|
||||
import com.ruoyi.xkt.mapper.StoreMapper;
|
||||
import com.ruoyi.xkt.mapper.StoreProductColorSizeMapper;
|
||||
import com.ruoyi.xkt.mapper.StoreProductStockMapper;
|
||||
import com.ruoyi.xkt.mapper.StoreSaleDetailMapper;
|
||||
import com.ruoyi.xkt.mapper.*;
|
||||
import com.ruoyi.xkt.service.IStoreProductColorSizeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -43,15 +39,13 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
final StoreProductColorSizeMapper prodColorSizeMapper;
|
||||
final StoreSaleDetailMapper saleDetailMapper;
|
||||
final StoreProductStockMapper prodStockMapper;
|
||||
final StoreProductMapper storeProdMapper;
|
||||
final StoreColorMapper storeColorMapper;
|
||||
final StoreMapper storeMapper;
|
||||
final RedisCache redisCache;
|
||||
|
||||
// 纯数字
|
||||
private static final Pattern POSITIVE_PATTERN = Pattern.compile("^\\d+$");
|
||||
/* // 步橘系统条码截止索引
|
||||
private static final Integer buJuEndIndex = 13;
|
||||
// 其它系统的条码截止索引
|
||||
private static final Integer otherSysEndIndex = 10;*/
|
||||
|
||||
// 当前库存系统的条码前缀长度
|
||||
private static final Map<Integer, Integer> STOCK_PREFIX_LENGTH_MAP = new HashMap<>();
|
||||
|
|
@ -365,6 +359,138 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
|
|||
return printSnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键更新条码
|
||||
*
|
||||
* @param otherSnDTO 条码入参
|
||||
* @return Integer
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer updateOtherSn(StoreUpdateOtherSnDTO otherSnDTO) {
|
||||
// 更新条码前的校验
|
||||
Integer stockSys = this.otherSnCheck(otherSnDTO);
|
||||
// 截取的条码长度
|
||||
final Integer interceptLength = Objects.equals(stockSys, StockSysType.TIAN_YOU.getValue())
|
||||
? Constants.TIAN_YOU_SN_COMMON_PREFIX_LENGTH : Constants.FA_HUO_BAO_SN_COMMON_PREFIX_LENGTH;
|
||||
// 找到所有已录入的条码
|
||||
List<StoreProductColorSize> existList = this.prodColorSizeMapper.selectList(new LambdaQueryWrapper<StoreProductColorSize>()
|
||||
.eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED)
|
||||
.in(StoreProductColorSize::getStoreColorId, otherSnDTO.getSnList().stream().map(StoreUpdateOtherSnDTO.SUOSnDTO::getStoreColorId).collect(Collectors.toList()))
|
||||
.in(StoreProductColorSize::getStoreProdId, otherSnDTO.getSnList().stream().map(StoreUpdateOtherSnDTO.SUOSnDTO::getStoreProdId).collect(Collectors.toList())));
|
||||
if (CollectionUtils.isEmpty(existList)) {
|
||||
throw new ServiceException("商品尺码不存在,请联系管理员", HttpStatus.ERROR);
|
||||
}
|
||||
// key storeProdId + storeColorId, value SUOSnDTO
|
||||
Map<String, StoreUpdateOtherSnDTO.SUOSnDTO> updateMap = otherSnDTO.getSnList().stream().collect(Collectors
|
||||
.toMap(x -> x.getStoreProdId() + ":" + x.getStoreColorId(), Function.identity()));
|
||||
// key storeProdId + storeColorId, value storeProductColorSize
|
||||
Map<String, StoreProductColorSize> existMap = existList.stream().collect(Collectors
|
||||
.toMap(x -> x.getStoreProdId() + ":" + x.getStoreColorId(), Function.identity(), (s1, s2) -> s2));
|
||||
// key storeProdId + storeColorId, value List<storeProductColorSize>
|
||||
Map<String, List<StoreProductColorSize>> existGroupMap = existList.stream().collect(Collectors.groupingBy(x -> x.getStoreProdId() + ":" + x.getStoreColorId()));
|
||||
List<StoreProductColorSize> updateSnList = new ArrayList<>();
|
||||
existMap.forEach((key, exist) -> {
|
||||
StoreUpdateOtherSnDTO.SUOSnDTO updateSn = updateMap.get(key);
|
||||
if (ObjectUtils.isNotEmpty(updateSn)) {
|
||||
final String updateCommonPrefix = updateSn.getSn().substring(0, interceptLength);
|
||||
// 未设置过条码,则直接新增
|
||||
if (StringUtils.isEmpty(exist.getOtherSnPrefix())) {
|
||||
this.updateOtherSn(existGroupMap, key, updateCommonPrefix, updateSnList);
|
||||
} else {
|
||||
final String existCommonPrefix = exist.getOtherSnPrefix().substring(0, interceptLength);
|
||||
// 更新的条码和存储的条码不一致,则更新
|
||||
if (!Objects.equals(existCommonPrefix, updateCommonPrefix)) {
|
||||
this.updateOtherSn(existGroupMap, key, updateCommonPrefix, updateSnList);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return CollectionUtils.isEmpty(updateSnList) ? 0 : this.prodColorSizeMapper.updateById(updateSnList).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未设置条码的商品列表
|
||||
* @param storeId 档口ID
|
||||
* @return StoreUnsetSnDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreUnsetSnDTO getUnSetSnProdList(Long storeId) {
|
||||
List<StoreUnsetSnTempDTO> unsetList = this.prodColorSizeMapper.selectUnsetProdList(storeId);
|
||||
if (CollectionUtils.isEmpty(unsetList)) {
|
||||
return new StoreUnsetSnDTO().setUnsetSnList(Collections.emptyList());
|
||||
}
|
||||
final List<Long> storeProdIdList = unsetList.stream().map(StoreUnsetSnTempDTO::getStoreProdId).collect(Collectors.toList());
|
||||
List<StoreProduct> storeProdList = this.storeProdMapper.selectByIds(storeProdIdList);
|
||||
Map<Long, StoreProduct> storeProdMap = CollectionUtils.isEmpty(storeProdList) ? new HashMap<>()
|
||||
: storeProdList.stream().collect(Collectors.toMap(StoreProduct::getId, Function.identity()));
|
||||
final List<Long> storeColorIdList = unsetList.stream().map(StoreUnsetSnTempDTO::getStoreColorId).collect(Collectors.toList());
|
||||
List<StoreColor> storeColorList = this.storeColorMapper.selectByIds(storeColorIdList);
|
||||
Map<Long, String> storeColorMap = CollectionUtils.isEmpty(storeColorList) ? new HashMap<>()
|
||||
: storeColorList.stream().collect(Collectors.toMap(StoreColor::getId, StoreColor::getColorName));
|
||||
List<String> unsetSnList = new ArrayList<>();
|
||||
unsetList.stream().collect(Collectors.groupingBy(StoreUnsetSnTempDTO::getStoreProdId))
|
||||
.forEach((storeProdId, groupList) -> {
|
||||
String str = groupList.stream().map(x -> storeColorMap.get(x.getStoreColorId())).filter(Objects::nonNull).collect(Collectors.joining("、"));
|
||||
// 商品名称 + 颜色名称
|
||||
unsetSnList.add(storeProdMap.get(storeProdId).getProdArtNum() + ":" + str);
|
||||
});
|
||||
return new StoreUnsetSnDTO().setUnsetSnList(unsetSnList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据库其它系统的条码
|
||||
*
|
||||
* @param existGroupMap 已存在的条码map
|
||||
* @param key storeProdId:storeColorId
|
||||
* @param updateCommonPrefix 更新条码前缀
|
||||
* @param updateSnList 待更新条码列表
|
||||
*/
|
||||
private void updateOtherSn(Map<String, List<StoreProductColorSize>> existGroupMap, String key,
|
||||
String updateCommonPrefix, List<StoreProductColorSize> updateSnList) {
|
||||
List<StoreProductColorSize> groupList = existGroupMap.get(key);
|
||||
if (CollectionUtils.isNotEmpty(groupList)) {
|
||||
groupList.forEach(x -> x.setOtherSnPrefix(updateCommonPrefix + x.getSize()));
|
||||
updateSnList.addAll(groupList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新条码前的校验
|
||||
*
|
||||
* @param otherSnDTO 更新入参
|
||||
* @return stockSys
|
||||
*/
|
||||
private Integer otherSnCheck(StoreUpdateOtherSnDTO otherSnDTO) {
|
||||
// 判断当前库存系统 是步橘还是发货宝 或 天友
|
||||
Store store = redisCache.getCacheObject(CacheConstants.STORE_KEY + otherSnDTO.getStoreId());
|
||||
if (ObjectUtils.isEmpty(store)) {
|
||||
store = Optional.ofNullable(this.storeMapper.selectById(otherSnDTO.getStoreId()))
|
||||
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
|
||||
}
|
||||
// 如果是步橘系统,则不能录入条码
|
||||
if (Objects.equals(store.getStockSys(), StockSysType.BU_JU.getValue())) {
|
||||
throw new ServiceException("当前库存系统为步橘网自带系统,不可录入条码!", HttpStatus.ERROR);
|
||||
}
|
||||
// 其它系统条码长度
|
||||
final Integer otherSnLength = Objects.equals(store.getStockSys(), StockSysType.TIAN_YOU.getValue())
|
||||
? Constants.TIAN_YOU_SN_LENGTH : Constants.FA_HUO_BAO_SN_LENGTH;
|
||||
// 校验条码长度是否合法
|
||||
final Integer stockSys = this.stockSys(otherSnDTO.getStoreId());
|
||||
// 不符合规则的条码列表
|
||||
List<StoreUpdateOtherSnDTO.SUOSnDTO> illegalSnList = otherSnDTO.getSnList().stream()
|
||||
// 非纯数字 或 长度不合法
|
||||
.filter(s -> !POSITIVE_PATTERN.matcher(s.getSn()).matches() || !Objects.equals(s.getSn().length(), otherSnLength))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(illegalSnList)) {
|
||||
String errorMsg = illegalSnList.stream().map(x -> x.getProdArtNum() + " " + x.getColorName() + ":" + x.getSn())
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new ServiceException("以下条码不符合规则: " + errorMsg, HttpStatus.ERROR);
|
||||
}
|
||||
return stockSys;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通销售流程获取条码对应的商品信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -712,7 +712,8 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
// 将颜色信息按产品ID分组,并转换为所需的颜色DTO列表
|
||||
Map<Long, List<StoreProdFuzzyColorResDTO.SPFCColorDTO>> colorMap = CollectionUtils.isEmpty(colorList) ? new HashMap<>()
|
||||
: colorList.stream().collect(Collectors.groupingBy(StoreProductColor::getStoreProdId, Collectors
|
||||
.collectingAndThen(Collectors.toList(), list -> list.stream().map(y -> BeanUtil.toBean(y, StoreProdFuzzyColorResDTO.SPFCColorDTO.class))
|
||||
.collectingAndThen(Collectors.toList(), list -> list.stream()
|
||||
.map(y -> BeanUtil.toBean(y, StoreProdFuzzyColorResDTO.SPFCColorDTO.class))
|
||||
.collect(Collectors.toList()))));
|
||||
// 将产品列表转换为所需的产品DTO列表,并关联颜色信息
|
||||
return storeProdList.stream().map(x -> BeanUtil.toBean(x, StoreProdFuzzyColorResDTO.class).setStoreProdId(x.getId())
|
||||
|
|
|
|||
|
|
@ -157,4 +157,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectUnsetProdList">
|
||||
SELECT DISTINCT
|
||||
spcs.store_prod_id,
|
||||
spcs.store_color_id
|
||||
FROM
|
||||
store_product_color_size spcs
|
||||
JOIN store_color sc ON spcs.store_color_id = sc.id AND sc.del_flag = 0 AND sc.store_id = #{storeId}
|
||||
JOIN store_product sp ON spcs.store_prod_id = sp.id AND sp.del_flag = 0 AND sp.store_id = #{storeId}
|
||||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.other_sn_prefix IS NULL;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue