fix(智慧超市):库存pd导入适配
This commit is contained in:
1 parent
2b8c81e9c5
commit
622caf7949
4 files changed
+88
-15
No files matched your search
+3
-8
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.supermarket.controller;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.sequence.sequence.Sequence;
|
||||
import com.bsd.pjcloud.supermarket.constant.InventoryTypeEnum;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpCommonService;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpInventoryRecordsService;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpSpuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -26,12 +27,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SmErpCommonController {
|
||||
|
||||
private final SmErpInventoryRecordsService smErpInventoryRecordsService;
|
||||
private final SmErpCommonService smErpCommonService;
|
||||
|
||||
private final SmErpSpuService smErpSpuService;
|
||||
|
||||
@Autowired
|
||||
private Sequence sequence;
|
||||
|
||||
/**
|
||||
* 采购计划选择商品分页数据
|
||||
@@ -42,11 +40,8 @@ public class SmErpCommonController {
|
||||
@Operation(summary = "获取业务流水编号" , description = "获取业务流水编号" )
|
||||
@GetMapping("/getSequence")
|
||||
public R getErpSpuPage(@RequestParam("type")String type) {
|
||||
String valueByType = InventoryTypeEnum.getValueByType(type);
|
||||
String s = sequence.nextNo();
|
||||
String result = valueByType + "-" + s;
|
||||
String result=smErpCommonService.getSequence(type);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.bsd.pjcloud.supermarket.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SmErpCommonService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取业务流水编号
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
String getSequence(String type);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.supermarket.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.sequence.sequence.Sequence;
|
||||
import com.bsd.pjcloud.supermarket.constant.InventoryTypeEnum;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopCategoryEntity;
|
||||
import com.bsd.pjcloud.supermarket.mapper.ShopCategoryMapper;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopCategoryService;
|
||||
import com.bsd.pjcloud.supermarket.service.SmErpCommonService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线商品分类
|
||||
*
|
||||
* @author zjf
|
||||
* @date 2025-06-18 16:49:20
|
||||
*/
|
||||
@Service
|
||||
public class SmErpCommonServiceImpl implements SmErpCommonService {
|
||||
|
||||
@Autowired
|
||||
private Sequence sequence;
|
||||
@Override
|
||||
public String getSequence(String type) {
|
||||
String valueByType = InventoryTypeEnum.getValueByType(type);
|
||||
String s = sequence.nextNo();
|
||||
String result = valueByType + "-" + s;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+30
-7
@@ -100,7 +100,7 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
|
||||
private final SmErpInventoryRecordsItemService smErpInventoryRecordsItemService;
|
||||
|
||||
|
||||
private final SmErpCommonController smErpCommonController;
|
||||
private final SmErpCommonService smErpCommonService;
|
||||
|
||||
@Autowired
|
||||
private Sequence sequence;
|
||||
@@ -1913,14 +1913,37 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
|
||||
if (unit != null) {
|
||||
unitId = unit.getId();
|
||||
} else {
|
||||
// 记录单位不匹配的警告信息
|
||||
String unitWarning = "警告:商品 '" + spu.getProductName() + "' 未找到单位 '" + dto.getUnit() + "' 的包装单位";
|
||||
if (item.getRemark() != null) {
|
||||
item.setRemark(item.getRemark() + ";" + unitWarning);
|
||||
// 如果匹配不到指定单位,则使用基础单位作为默认值
|
||||
SmErpUnitEntity baseUnit = smErpUnitService.getOne(new LambdaQueryWrapper<SmErpUnitEntity>()
|
||||
.eq(SmErpUnitEntity::getSpuId, spu.getId())
|
||||
.eq(SmErpUnitEntity::getIsBase, true));
|
||||
if (baseUnit != null) {
|
||||
unitId = baseUnit.getId();
|
||||
// 记录单位替换的提示信息
|
||||
String unitNote = String.format("单位替换:Excel中的单位 '%s' 未找到,已使用基础单位 '%s'", dto.getUnit(), baseUnit.getUnit());
|
||||
if (item.getRemark() != null) {
|
||||
item.setRemark(item.getRemark() + ";" + unitNote);
|
||||
} else {
|
||||
item.setRemark(unitNote);
|
||||
}
|
||||
} else {
|
||||
item.setRemark(unitWarning);
|
||||
// 如果连基础单位都没有,记录警告信息
|
||||
String unitWarning = "警告:商品 '" + spu.getProductName() + "' 未找到单位 '" + dto.getUnit() + "' 的包装单位,且无基础单位";
|
||||
if (item.getRemark() != null) {
|
||||
item.setRemark(item.getRemark() + ";" + unitWarning);
|
||||
} else {
|
||||
item.setRemark(unitWarning);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果Excel中没有指定单位,也使用基础单位
|
||||
SmErpUnitEntity baseUnit = smErpUnitService.getOne(new LambdaQueryWrapper<SmErpUnitEntity>()
|
||||
.eq(SmErpUnitEntity::getSpuId, spu.getId())
|
||||
.eq(SmErpUnitEntity::getIsBase, true));
|
||||
if (baseUnit != null) {
|
||||
unitId = baseUnit.getId();
|
||||
}
|
||||
}
|
||||
item.setUnitId(unitId);
|
||||
|
||||
@@ -1976,7 +1999,7 @@ public class SmErpSpuServiceImpl extends ServiceImpl<SmErpSpuMapper, SmErpSpuEnt
|
||||
if (!pdItemList.isEmpty()) {
|
||||
// 创建盘点主记录
|
||||
PDSaveDTO pdSaveDTO = new PDSaveDTO();
|
||||
pdSaveDTO.setInventoryCode(String.valueOf(smErpCommonController.getErpSpuPage("7").getData()));
|
||||
pdSaveDTO.setInventoryCode(String.valueOf(smErpCommonService.getSequence("7")));
|
||||
pdSaveDTO.setInventoryDate(LocalDate.now());
|
||||
pdSaveDTO.setInventoryType("7"); // KCPD 库存盘点
|
||||
pdSaveDTO.setHandlerUserId(SecurityUtils.getUser().getId());
|
||||
|
||||
Reference in new issue
Block a user