物料拓展功能实现

This commit is contained in:
潘荣晟
2025-12-30 18:08:59 +08:00
parent 4bc69718d8
commit 69375988c2
5 changed files with 72 additions and 31 deletions

View File

@@ -38,6 +38,7 @@ public class ErpMaterialController {
@Resource @Resource
private ErpMaterialService erpMaterialService; private ErpMaterialService erpMaterialService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建ERP物料数据") @Operation(summary = "创建ERP物料数据")
@PreAuthorize("@ss.hasPermission('sply:erp-material:create')") @PreAuthorize("@ss.hasPermission('sply:erp-material:create')")
@@ -65,7 +66,7 @@ public class ErpMaterialController {
@DeleteMapping("/delete-list") @DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true) @Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除ERP物料数据") @Operation(summary = "批量删除ERP物料数据")
@PreAuthorize("@ss.hasPermission('sply:erp-material:delete')") @PreAuthorize("@ss.hasPermission('sply:erp-material:delete')")
public CommonResult<Boolean> deleteErpMaterialList(@RequestBody BatchDeleteReqVO req) { public CommonResult<Boolean> deleteErpMaterialList(@RequestBody BatchDeleteReqVO req) {
erpMaterialService.deleteErpMaterialListByIds(req.getIds()); erpMaterialService.deleteErpMaterialListByIds(req.getIds());
return success(true); return success(true);
@@ -93,12 +94,12 @@ public class ErpMaterialController {
@PreAuthorize("@ss.hasPermission('sply:erp-material:export')") @PreAuthorize("@ss.hasPermission('sply:erp-material:export')")
@ApiAccessLog(operateType = EXPORT) @ApiAccessLog(operateType = EXPORT)
public void exportErpMaterialExcel(@Valid ErpMaterialPageReqVO pageReqVO, public void exportErpMaterialExcel(@Valid ErpMaterialPageReqVO pageReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ErpMaterialDO> list = erpMaterialService.getErpMaterialPage(pageReqVO).getList(); List<ErpMaterialDO> list = erpMaterialService.getErpMaterialPage(pageReqVO).getList();
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "ERP物料数据.xls", "数据", ErpMaterialRespVO.class, ExcelUtils.write(response, "ERP物料数据.xls", "数据", ErpMaterialRespVO.class,
BeanUtils.toBean(list, ErpMaterialRespVO.class)); BeanUtils.toBean(list, ErpMaterialRespVO.class));
} }
@PostMapping("/getErpMaterialTask") @PostMapping("/getErpMaterialTask")
@@ -116,20 +117,38 @@ public class ErpMaterialController {
PageResult<ErpMaterialRespVO> pageResult = erpMaterialService.getErpMaterialPageAndOther(pageReqVO); PageResult<ErpMaterialRespVO> pageResult = erpMaterialService.getErpMaterialPageAndOther(pageReqVO);
return success(BeanUtils.toBean(pageResult, ErpMaterialRespVO.class)); return success(BeanUtils.toBean(pageResult, ErpMaterialRespVO.class));
} }
//创建物料拓展关系
@PostMapping("/createErpMaterialCorr")
@Operation(summary = "创建ERP物料关系")
@PreAuthorize("@ss.hasPermission('sply:erp-material:create')")
public CommonResult<List<ErpMaterialRespVO>> createErpMaterialCorr(@Valid @RequestBody ErpMaterialCorrSaveReqVO erpMaterialCorrSaveReqVO) {
return success(erpMaterialService.createErpMaterialCorr(erpMaterialCorrSaveReqVO));
}
//删除物料关系
@DeleteMapping("/deleteErpMaterialCorr")
@Operation(summary = "删除ERP物料关系")
@PreAuthorize("@ss.hasPermission('sply:erp-material:delete')")
public CommonResult<Boolean> deleteErpMaterialCorr(@RequestBody BatchDeleteReqVO req) {
erpMaterialService.deleteErpMaterialCorr(req);
return success(true);
}
//创建物料拓展关系
@PostMapping("/createErpMaterialCorr")
@Operation(summary = "创建ERP物料关系")
@PreAuthorize("@ss.hasPermission('sply:erp-material:create')")
public CommonResult<List<ErpMaterialRespVO>> createErpMaterialCorr(@Valid @RequestBody ErpMaterialCorrSaveReqVO erpMaterialCorrSaveReqVO) {
return success(erpMaterialService.createErpMaterialCorr(erpMaterialCorrSaveReqVO));
}
//删除物料关系
@DeleteMapping("/deleteErpMaterialCorr")
@Operation(summary = "删除ERP物料关系")
@PreAuthorize("@ss.hasPermission('sply:erp-material:delete')")
public CommonResult<Boolean> deleteErpMaterialCorr(@RequestBody BatchDeleteReqVO req) {
erpMaterialService.deleteErpMaterialCorr(req);
return success(true);
}
//通过物料id查询物料详情
@GetMapping("/getErpMaterialById")
@Operation(summary = "通过物料id查询物料详情")
@PreAuthorize("@ss.hasPermission('sply:erp-material:query')")
public CommonResult<ErpMaterialRespVO> getErpMaterialById(@RequestParam("id") Long id) {
ErpMaterialDO erpMaterial = erpMaterialService.getErpMaterialById(id);
return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class));
}
//通过主物料查询子物料信息
@GetMapping("/getErpMaterialByMainMaterialById")
@Operation(summary = "通过主物料查询子物料信息")
@PreAuthorize("@ss.hasPermission('sply:erp-material:query')")
public CommonResult<List<ErpMaterialRespVO>> getErpMaterialByMainMaterial(@RequestParam("id") Long mainMaterialId) {
List<ErpMaterialDO> erpMaterial = erpMaterialService.getErpMaterialByMainMaterial(mainMaterialId);
return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class));
}
} }

View File

@@ -15,4 +15,6 @@ import java.util.List;
public interface ErpErpMaterialCorrService { public interface ErpErpMaterialCorrService {
List<ErpMaterialCorrRspVO> create(@Valid ErpMaterialCorrSaveReqVO reqVO); List<ErpMaterialCorrRspVO> create(@Valid ErpMaterialCorrSaveReqVO reqVO);
void deleteBatch(BatchDeleteReqVO reqVO); void deleteBatch(BatchDeleteReqVO reqVO);
List<ErpMaterialCorrRspVO> getErpMaterialByMainMaterial(Long mainMaterialId);
} }

View File

@@ -38,4 +38,9 @@ public class ErpErpMaterialCorrServiceImpl implements ErpErpMaterialCorrService{
public void deleteBatch(BatchDeleteReqVO reqVO) { public void deleteBatch(BatchDeleteReqVO reqVO) {
erpErpMaterialCorrMapper.deleteByIds(reqVO.getIds()); erpErpMaterialCorrMapper.deleteByIds(reqVO.getIds());
} }
@Override
public List<ErpMaterialCorrRspVO> getErpMaterialByMainMaterial(Long mainMaterialId) {
return BeanUtils.toBean( erpErpMaterialCorrMapper.selectList(ErpMaterialCorrDO::getMaterialParentId, mainMaterialId), ErpMaterialCorrRspVO.class);
}
} }

View File

@@ -73,4 +73,8 @@ public interface ErpMaterialService {
List<ErpMaterialRespVO> createErpMaterialCorr(ErpMaterialCorrSaveReqVO erpMaterialCorrSaveReqVO); List<ErpMaterialRespVO> createErpMaterialCorr(ErpMaterialCorrSaveReqVO erpMaterialCorrSaveReqVO);
void deleteErpMaterialCorr(BatchDeleteReqVO reqVO); void deleteErpMaterialCorr(BatchDeleteReqVO reqVO);
ErpMaterialDO getErpMaterialById(Long id);
List<ErpMaterialDO> getErpMaterialByMainMaterial(Long mainMaterialId);
} }

View File

@@ -252,6 +252,30 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
erpMaterialCorrService.deleteBatch(reqVO); erpMaterialCorrService.deleteBatch(reqVO);
} }
@Override
public ErpMaterialDO getErpMaterialById(Long id) {
CommonResult<MaterialInfomationRespDTO> materialInfomation = materialInfomationApi.getMaterialInfomation(id);
return buildErpMaterialDOData(materialInfomation);
}
@Override
public List<ErpMaterialDO> getErpMaterialByMainMaterial(Long mainMaterial) {
List<ErpMaterialCorrRspVO> erpMaterialByMainMaterial = erpMaterialCorrService.getErpMaterialByMainMaterial(mainMaterial);
List<ErpMaterialDO> erpMaterialDOList = new ArrayList<>();
CommonResult<List<MaterialInfomationRespDTO>> materialInfomationListByIds = materialInfomationApi.getMaterialInfomationListByIds(erpMaterialByMainMaterial.stream().map(ErpMaterialCorrRspVO::getMaterialId).toList());
if (materialInfomationListByIds.getData() == null || materialInfomationListByIds.getData().isEmpty()) {
return erpMaterialDOList;
}
materialInfomationListByIds.getData().forEach(
materialInfomation -> {
ErpMaterialDO erpMaterialDO = buildErpMaterialDOData(CommonResult.success(materialInfomation));
erpMaterialDOList.add(erpMaterialDO);
}
);
return erpMaterialDOList;
}
@Override @Override
@Transactional @Transactional
@XxlJob("getErpMaterialTask") @XxlJob("getErpMaterialTask")
@@ -374,17 +398,4 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
.collect(Collectors.toList()); .collect(Collectors.toList());
myRedisConfig.updateRedisCache(key, existingNumbers); myRedisConfig.updateRedisCache(key, existingNumbers);
} }
public record MaterialAttribute(
String baseUnitCode, // 基础单位编码
String baseUnitName, // 基础单位名称
String shortDesc, // 物料短描述
String longDesc, // 物料长描述
String chalcoCode, // 中铝编码
String zhongtongCode, // 中铜编码
String specification, // 规格
String texture, // 材质
String recordTime// 记录时间
) {
}
} }