|
|
@ -36,6 +36,7 @@ import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Matcher; |
|
|
import java.util.regex.Pattern; |
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
@ -493,6 +494,11 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
@Override |
|
|
@Override |
|
|
public Page<SaleNoWorkerVO> getSaleByCompanyId(SalePageQuery salePageQuery) { |
|
|
public Page<SaleNoWorkerVO> getSaleByCompanyId(SalePageQuery salePageQuery) { |
|
|
final Page<SaleNoWorkerVO> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize()); |
|
|
final Page<SaleNoWorkerVO> page = new Page<>(salePageQuery.getPageNum(), salePageQuery.getPageSize()); |
|
|
|
|
|
//结束时间-1天
|
|
|
|
|
|
if(StringUtils.isNotEmpty(salePageQuery.getEndDate())){ |
|
|
|
|
|
String endDate = DateUtil.addDay(salePageQuery.getEndDate(), 1); |
|
|
|
|
|
salePageQuery.setEndDate(endDate); |
|
|
|
|
|
} |
|
|
final Page<SaleNoWorkerVO> saleNoWorkerVOPage = saleMapper.getSaleByCompanyId(page, salePageQuery); |
|
|
final Page<SaleNoWorkerVO> saleNoWorkerVOPage = saleMapper.getSaleByCompanyId(page, salePageQuery); |
|
|
return saleNoWorkerVOPage; |
|
|
return saleNoWorkerVOPage; |
|
|
} |
|
|
} |
|
|
@ -554,10 +560,12 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<SaleDetailDTO> buyAi(String aiMsg) { |
|
|
public JSONObject buyAi(String aiMsg) { |
|
|
|
|
|
JSONObject returnJsonObject = new JSONObject(); |
|
|
// 叉转X 文本纠错 使用正则表达式替换单个或多个连续的“叉”字符
|
|
|
// 叉转X 文本纠错 使用正则表达式替换单个或多个连续的“叉”字符
|
|
|
aiMsg = replaceAllX(aiMsg); |
|
|
aiMsg = replaceAllX(aiMsg); |
|
|
final List<SaleDetailDTO> saleDetailDTOS = new ArrayList<>(); |
|
|
final List<SaleDetailDTO> saleDetailDTOS = new ArrayList<>(); |
|
|
|
|
|
final CopyOnWriteArrayList<String> aiNotRecognitionList = new CopyOnWriteArrayList<>(); |
|
|
// shopId从缓存中设置
|
|
|
// shopId从缓存中设置
|
|
|
final String shopId = securityUtil.getShopId(); |
|
|
final String shopId = securityUtil.getShopId(); |
|
|
try { |
|
|
try { |
|
|
@ -595,23 +603,7 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
final List<SaleDetailQueryDTO> saleDetailQueryDTOS = new ArrayList<>(); |
|
|
final List<SaleDetailQueryDTO> saleDetailQueryDTOS = new ArrayList<>(); |
|
|
final String attributeList = object.getString("attributeList"); |
|
|
final String attributeList = object.getString("attributeList"); |
|
|
final JSONArray attributeListJsonArray = JSON.parseArray(attributeList); |
|
|
final JSONArray attributeListJsonArray = JSON.parseArray(attributeList); |
|
|
for (int j = 0; j < attributeListJsonArray.size(); j++) { |
|
|
// 获取商品分类及规格信息
|
|
|
final JSONObject attributeListObject = attributeListJsonArray.getJSONObject(j); |
|
|
|
|
|
String color = attributeListObject.getString("color").toUpperCase(); |
|
|
|
|
|
String size = attributeListObject.getString("size").toUpperCase(); |
|
|
|
|
|
final String productCount1 = attributeListObject.getString("productCount"); |
|
|
|
|
|
final int productCount = Integer.parseInt(COMPILE.matcher(productCount1).replaceAll("")); |
|
|
|
|
|
// 20240330 只能新增颜色和尺码,颜色统一改为*色、尺码统一转大写,加‘码’;
|
|
|
|
|
|
// 根据规格id规格是颜色、还是尺码。
|
|
|
|
|
|
if (!color.contains("色")) { |
|
|
|
|
|
color += '色'; |
|
|
|
|
|
} |
|
|
|
|
|
if (!size.contains("码")) { |
|
|
|
|
|
size += '码'; |
|
|
|
|
|
} |
|
|
|
|
|
size = size.toUpperCase(); |
|
|
|
|
|
// if (color.contains("所有") && size.contains("所有")) {
|
|
|
|
|
|
if ("SYYS色".equals(color) && "SYCM码".equals(size)) { |
|
|
|
|
|
final List<String> categoryIdList = new ArrayList<>(); |
|
|
final List<String> categoryIdList = new ArrayList<>(); |
|
|
categoryIdList.add(categoryId); |
|
|
categoryIdList.add(categoryId); |
|
|
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList); |
|
|
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList); |
|
|
@ -627,9 +619,37 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
if (productAttributeOfAddVoMap.containsKey("颜色")) { |
|
|
if (productAttributeOfAddVoMap.containsKey("颜色")) { |
|
|
colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList(); |
|
|
colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList(); |
|
|
} |
|
|
} |
|
|
|
|
|
// 将所有颜色放到一个集合中
|
|
|
|
|
|
final CopyOnWriteArrayList<String> colorList = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { |
|
|
|
|
|
colorList.add(productAttributeValueVo.getValue()); |
|
|
|
|
|
} |
|
|
if (productAttributeOfAddVoMap.containsKey("尺码")) { |
|
|
if (productAttributeOfAddVoMap.containsKey("尺码")) { |
|
|
sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList(); |
|
|
sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList(); |
|
|
} |
|
|
} |
|
|
|
|
|
// 将所有尺码放到一个集合中
|
|
|
|
|
|
final CopyOnWriteArrayList<String> sizeList = new CopyOnWriteArrayList<>(); |
|
|
|
|
|
for (ProductAttributeValueVo productAttributeValueVo : sizeProductAttributeValueVoList) { |
|
|
|
|
|
sizeList.add(productAttributeValueVo.getValue()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < attributeListJsonArray.size(); j++) { |
|
|
|
|
|
final JSONObject attributeListObject = attributeListJsonArray.getJSONObject(j); |
|
|
|
|
|
String color = attributeListObject.getString("color").toUpperCase(); |
|
|
|
|
|
String size = attributeListObject.getString("size").toUpperCase(); |
|
|
|
|
|
final String productCount1 = attributeListObject.getString("productCount"); |
|
|
|
|
|
final int productCount = Integer.parseInt(COMPILE.matcher(productCount1).replaceAll("")); |
|
|
|
|
|
// 20240330 只能新增颜色和尺码,颜色统一改为*色、尺码统一转大写,加‘码’;
|
|
|
|
|
|
// 根据规格id规格是颜色、还是尺码。
|
|
|
|
|
|
if (!color.contains("色")) { |
|
|
|
|
|
color += '色'; |
|
|
|
|
|
} |
|
|
|
|
|
if (!size.contains("码")) { |
|
|
|
|
|
size += '码'; |
|
|
|
|
|
} |
|
|
|
|
|
size = size.toUpperCase(); |
|
|
|
|
|
|
|
|
|
|
|
if ("SYYS色".equals(color) && "SYCM码".equals(size)) { |
|
|
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { |
|
|
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { |
|
|
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { |
|
|
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
@ -645,21 +665,8 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
// 所有颜色,所有尺码
|
|
|
// 所有颜色,所有尺码
|
|
|
} |
|
|
} |
|
|
if ("SYYS色".equals(color)) { |
|
|
if ("SYYS色".equals(color)) { |
|
|
|
|
|
if (sizeList.contains(size)) { |
|
|
// 所有颜色,固定尺码
|
|
|
// 所有颜色,固定尺码
|
|
|
final List<String> categoryIdList = new ArrayList<>(); |
|
|
|
|
|
categoryIdList.add(categoryId); |
|
|
|
|
|
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList); |
|
|
|
|
|
final ProductCategoryVo productCategoryVo = shopCategory.get(0); |
|
|
|
|
|
final List<ProductAttributeOfAddVo> productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos(); |
|
|
|
|
|
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new HashMap<>(); |
|
|
|
|
|
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) { |
|
|
|
|
|
productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeName(), productAttributeOfAddVo); |
|
|
|
|
|
} |
|
|
|
|
|
//获取颜色及规格进行拼接
|
|
|
|
|
|
List<ProductAttributeValueVo> colorProductAttributeValueVoList = new ArrayList<>(); |
|
|
|
|
|
if (productAttributeOfAddVoMap.containsKey("颜色")) { |
|
|
|
|
|
colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList(); |
|
|
|
|
|
} |
|
|
|
|
|
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { |
|
|
for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final String attribute = "{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + size + "\"}"; |
|
|
final String attribute = "{\"颜色\":\"" + productAttributeValueVo.getValue() + "\",\"尺码\":\"" + size + "\"}"; |
|
|
@ -669,24 +676,16 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
final String msg = "商品:" + product.getProductName() + ",尺码:" + size + ",不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
if ("SYCM码".equals(size)) { |
|
|
if ("SYCM码".equals(size)) { |
|
|
|
|
|
if (colorList.contains(color)) { |
|
|
// 所有尺码,固定颜色
|
|
|
// 所有尺码,固定颜色
|
|
|
final List<String> categoryIdList = new ArrayList<>(); |
|
|
|
|
|
categoryIdList.add(categoryId); |
|
|
|
|
|
final List<ProductCategoryVo> shopCategory = productCategoryService.getShopCategory(categoryIdList); |
|
|
|
|
|
final ProductCategoryVo productCategoryVo = shopCategory.get(0); |
|
|
|
|
|
final List<ProductAttributeOfAddVo> productAttributeOfAddVos = productCategoryVo.getProductAttributeOfAddVos(); |
|
|
|
|
|
final Map<String, ProductAttributeOfAddVo> productAttributeOfAddVoMap = new HashMap<>(); |
|
|
|
|
|
for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) { |
|
|
|
|
|
productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeName(), productAttributeOfAddVo); |
|
|
|
|
|
} |
|
|
|
|
|
//获取颜色及规格进行拼接
|
|
|
|
|
|
List<ProductAttributeValueVo> sizeProductAttributeValueVoList = new ArrayList<>(); |
|
|
|
|
|
if (productAttributeOfAddVoMap.containsKey("尺码")) { |
|
|
|
|
|
sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList(); |
|
|
|
|
|
} |
|
|
|
|
|
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { |
|
|
for (ProductAttributeValueVo attributeValueVo : sizeProductAttributeValueVoList) { |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"; |
|
|
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + attributeValueVo.getValue() + "\"}"; |
|
|
@ -696,8 +695,14 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
final String msg = "商品:" + product.getProductName() + ",颜色:" + color + ",不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
if (colorList.contains(color) && sizeList.contains(size)) { |
|
|
// 不包含所有按照获取的拼接
|
|
|
// 不包含所有按照获取的拼接
|
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final SaleDetailQueryDTO saleDetailQueryDTO = new SaleDetailQueryDTO(); |
|
|
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + size + "\"}"; |
|
|
final String attribute = "{\"颜色\":\"" + color + "\",\"尺码\":\"" + size + "\"}"; |
|
|
@ -706,10 +711,29 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); |
|
|
saleDetailQueryDTO.setStockCount(stockMap.getOrDefault(attribute, null)); |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailDTO.setProductCount(saleDetailDTO.getProductCount() + productCount); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
saleDetailQueryDTOS.add(saleDetailQueryDTO); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 封装颜色和尺码可能不存在的情况封装到返回结果中去
|
|
|
|
|
|
if (!colorList.contains(color) && !sizeList.contains(size)) { |
|
|
|
|
|
// 颜色和尺码都不存在
|
|
|
|
|
|
final String msg = "商品:" + product.getProductName() + ",颜色:" + color + ",尺码:" + size + ",颜色及尺码都不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
|
|
|
} else if (!colorList.contains(color)) { |
|
|
|
|
|
// 颜色不存在
|
|
|
|
|
|
final String msg = "商品:" + product.getProductName() + ",颜色:" + color + ",不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
|
|
|
} else if (!sizeList.contains(size)) { |
|
|
|
|
|
final String msg = "商品:" + product.getProductName() + ",尺码:" + size + ",不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
saleDetailDTO.setStockLogList1(saleDetailQueryDTOS); |
|
|
saleDetailDTO.setStockLogList1(saleDetailQueryDTOS); |
|
|
saleDetailDTOS.add(saleDetailDTO); |
|
|
saleDetailDTOS.add(saleDetailDTO); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 没查到去找下一个
|
|
|
|
|
|
final String msg = "货号为:" + productSn + "的商品,不存在"; |
|
|
|
|
|
aiNotRecognitionList.add(msg); |
|
|
// 没查到去找下一个
|
|
|
// 没查到去找下一个
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
@ -720,7 +744,9 @@ public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements Sa |
|
|
} catch (InputRequiredException e) { |
|
|
} catch (InputRequiredException e) { |
|
|
throw new RuntimeException(e); |
|
|
throw new RuntimeException(e); |
|
|
} |
|
|
} |
|
|
return saleDetailDTOS; |
|
|
returnJsonObject.put("data",saleDetailDTOS); |
|
|
|
|
|
returnJsonObject.put("aiNotRecognition",String.join(";", aiNotRecognitionList)); |
|
|
|
|
|
return returnJsonObject; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|