计划管理相关功能实现

This commit is contained in:
潘荣晟
2026-01-21 16:09:35 +08:00
parent 4007160524
commit 1bb5c117d2
12 changed files with 170 additions and 39 deletions

View File

@@ -57,7 +57,7 @@ public interface ErrorCodeConstants {
ErrorCode ERP_PRODUCTIVE_ORDER_NOT_EXISTS = new ErrorCode(1_017_000_001, "ERP生产订单数据不存在");
ErrorCode MATERIAL_ERROR = new ErrorCode( 1_017_000_009, "主物料信息错误");
ErrorCode CUSTOM_ERROR = new ErrorCode(1_017_000_010, "{}");
ErrorCode INTERNAL_WAREHOUSE_NOT_EXISTS= new ErrorCode(1_017_000_011,"内部仓库不存在");
ErrorCode INTERNAL_WAREHOUSE_EXISTS=new ErrorCode(1_017_000_012,"内部仓库已存在");
ErrorCode WAREHOUSE_FACTORY_NOT_EXISTS=new ErrorCode(1_017_000_010,"库位与工厂信息不存在");

View File

@@ -158,13 +158,8 @@ public class ErpMaterialController implements BusinessControllerMarker {
@Operation(summary = "通过接口查询物料")
@PreAuthorize("@ss.hasAnyPermissions({'sply:erp-material:query','basic:material-config:query'})")
public CommonResult<PageResult<ErpMaterialRespVO>> getErpMaterialByApi(@RequestBody MaterialInfomationApiVO vo) {
DepartmentMaterialPageReqDTO material = new DepartmentMaterialPageReqDTO();
material.setMaterialNumber(vo.getMaterialNumber());
material.setMaterialName(vo.getMaterialName());
material.setPageSize(vo.getPageSize());
material.setPageNo(vo.getPageNo());
material.setDeptId(Long.valueOf(vo.getDeptId()));
PageResult<ErpMaterialDO> erpMaterialByApi = erpMaterialService.getErpMaterialByApi(material);
PageResult<ErpMaterialDO> erpMaterialByApi = erpMaterialService.getErpMaterialByApi(vo);
return success(BeanUtils.toBean(erpMaterialByApi, ErpMaterialRespVO.class));
}
//通过主物料查询子物料信息

View File

@@ -35,4 +35,26 @@ public class ErpMaterialCorrRspVO {
*/
@Schema(description = "拓展关系物料编号")
private String materialCode;
/**
* 公司编码
*/
@Schema(description = "公司编码")
@NotNull(message = "公司编码不能为空")
private String companyId;
/**
* 公司编码
*/
@Schema(description = "公司编码")
private String companyCode;
/**
* 部门ID
*/
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED)
private Long deptId;
/**
* 部门编码
*/
@Schema(description = "部门编码", requiredMode = Schema.RequiredMode.REQUIRED)
private String deptCode;
}

View File

@@ -1,6 +1,7 @@
package com.zt.plat.module.erp.controller.admin.erp.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@@ -28,6 +29,22 @@ public class ErpMaterialCorrSaveReqVO {
*/
@Schema(description = "拓展关系主物料编号")
private String materialParentCode;
/**
* 公司编码
*/
@Schema(description = "公司编码")
private String companyCode;
/**
* 部门ID
*/
@Schema(description = "部门ID")
private Long deptId;
/**
* 部门编码
*/
@Schema(description = "部门编码")
private String deptCode;
/**
* 拓展关系物料
*/

View File

@@ -50,4 +50,30 @@ public class ErpMaterialCorrDO extends BaseDO {
*/
@TableField("MTRL_CODE")
private String materialCode;
/**
* 公司ID
*/
@TableField("COMPANY_ID")
private Long companyId;
/**
* 公司编码
*/
@TableField("COMPANY_CODE")
private String companyCode;
/**
* 部门ID
*/
@TableField("DEPT_ID")
private Long deptId;
/**
* 部门编码
*/
@TableField("DEPT_CODE")
private String deptCode;
}

View File

@@ -19,4 +19,6 @@ public interface ErpErpMaterialCorrService {
List<ErpMaterialCorrRspVO> getErpMaterialByMainMaterial(List<Long> mainMaterialIds);
List<ErpMaterialCorrRspVO> getErpMaterialByMainMaterialByCode(String code);
List<ErpMaterialCorrRspVO> getErpMaterialByCompanyCode(String CompanyCode);
}

View File

@@ -23,6 +23,10 @@ public class ErpErpMaterialCorrServiceImpl implements ErpErpMaterialCorrService{
public List<ErpMaterialCorrRspVO> create(ErpMaterialCorrSaveReqVO reqVO) {
List<ErpMaterialCorrDO> erpMaterialCorrDOS=new ArrayList<>();
reqVO.getMaterials().forEach(materials -> {
//判断是否存在
if (erpErpMaterialCorrMapper.selectOne(ErpMaterialCorrDO::getMaterialParentId,reqVO.getMaterialParentId(), ErpMaterialCorrDO::getMaterialId,materials.getMaterialId()) != null) {
return;
}
erpMaterialCorrDOS.add(ErpMaterialCorrDO.builder()
.materialParentId(reqVO.getMaterialParentId())
.materialParentCode(reqVO.getMaterialParentCode())
@@ -48,4 +52,9 @@ public class ErpErpMaterialCorrServiceImpl implements ErpErpMaterialCorrService{
public List<ErpMaterialCorrRspVO> getErpMaterialByMainMaterialByCode(String code) {
return BeanUtils.toBean(erpErpMaterialCorrMapper.selectList(ErpMaterialCorrDO::getMaterialParentCode, code), ErpMaterialCorrRspVO.class);
}
@Override
public List<ErpMaterialCorrRspVO> getErpMaterialByCompanyCode(String CompanyCode) {
return BeanUtils.toBean(erpErpMaterialCorrMapper.selectList(ErpMaterialCorrDO::getCompanyCode, CompanyCode), ErpMaterialCorrRspVO.class);
}
}

View File

@@ -5,10 +5,7 @@ import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.module.base.api.departmentmaterial.dto.DepartmentMaterialPageReqDTO;
import com.zt.plat.module.base.api.materialinfomation.dto.MaterialInfomationPageReqDTO;
import com.zt.plat.module.erp.api.dto.ErpMaterialDTO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialCorrSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialPageReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialRespVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialSaveReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.*;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpMaterialDO;
import jakarta.validation.Valid;
@@ -80,7 +77,7 @@ public interface ErpMaterialService {
List<ErpMaterialRespVO> getErpMaterialByMainMaterial(Long mainMaterialId);
PageResult<ErpMaterialDO> getErpMaterialByApi( DepartmentMaterialPageReqDTO material);
PageResult<ErpMaterialDO> getErpMaterialByApi( MaterialInfomationApiVO vo);
List<ErpMaterialDO> getErpMaterialByMainMaterialByCode(String code,String deptId);

View File

@@ -210,7 +210,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
private ErpMaterialRespVO buildErpMaterialRespDataById(Long id) {
DepartmentMaterialPageReqDTO departmentMaterialPageReqDTO = new DepartmentMaterialPageReqDTO();
departmentMaterialPageReqDTO.setInfomationId(id);
departmentMaterialPageReqDTO.setPageSize(PAGE_SIZE_NONE);
departmentMaterialPageReqDTO.setPageSize(10000);
PageResult<DepartmentMaterialRespDTO> data = departmentMaterialApi.getDepartmentMaterialPage(departmentMaterialPageReqDTO).getData();
if (data == null || data.getList().isEmpty()) {
return null;
@@ -294,30 +294,38 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
erpMaterialDOList.add(erpMaterialDO);
});
erpMaterialRespVOS = BeanUtils.toBean(erpMaterialDOList, ErpMaterialRespVO.class);
erpMaterialRespVOS.forEach(
m -> {
erpMaterialByMainMaterial.forEach(
i -> {
if (Objects.equals(m.getId(), i.getMaterialId())) {
m.setCorrId(i.getId());
}
}
);
}
);
return erpMaterialRespVOS;
}
@Override
public PageResult<ErpMaterialDO> getErpMaterialByApi(DepartmentMaterialPageReqDTO material) {
public PageResult<ErpMaterialDO> getErpMaterialByApi(MaterialInfomationApiVO vo) {
//通过部门编码查询数据库获取到部门ID
List<ErpMaterialCorrRspVO> erpMaterialByCompanyCode = erpMaterialCorrService.getErpMaterialByCompanyCode(vo.getDeptId());
if (erpMaterialByCompanyCode.isEmpty()) {
return new PageResult<>();
}
Set<Long> collect = erpMaterialByCompanyCode.stream().map(ErpMaterialCorrRspVO::getDeptId).collect(Collectors.toSet());
if (collect.size() != 1) {
throw exception(CUSTOM_ERROR, "部门编码不唯一或部门编码不存在");
}
DepartmentMaterialPageReqDTO material = new DepartmentMaterialPageReqDTO();
material.setMaterialNumber(vo.getMaterialNumber());
material.setMaterialName(vo.getMaterialName());
material.setPageSize(vo.getPageSize());
material.setPageNo(vo.getPageNo());
material.setDeptId(collect.iterator().next());
CommonResult<PageResult<DepartmentMaterialRespDTO>> departmentMaterialPage = departmentMaterialApi.getDepartmentMaterialPage(material);
List<ErpMaterialDO> erpMaterialDOList = new ArrayList<>();
//开始时间
long startTime = System.currentTimeMillis();
if (departmentMaterialPage.getData() != null && departmentMaterialPage.getData().getList() != null && !departmentMaterialPage.getData().getList().isEmpty()) {
departmentMaterialPage.getData().getList().forEach(materialInfomation -> {
ErpMaterialDO erpMaterialDO = buildErpMaterialDOData(CommonResult.success(materialInfomation));
erpMaterialDOList.add(erpMaterialDO);
});
}
System.out.println("==============查询物料数据耗时:============"+String.valueOf(System.currentTimeMillis() - startTime));
return new PageResult<>(erpMaterialDOList, departmentMaterialPage.getData().getTotal());
}
@@ -340,17 +348,26 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
}
@Override
public List<ErpMaterialDO> getErpMaterialByApiByCode(String code, String deptId) {
public List<ErpMaterialDO> getErpMaterialByApiByCode(String code, String companyCode) {
List<ErpMaterialDO> erpMaterialDOList = new ArrayList<>();
//获取该物料编码下的所有物料id,并根据这个ID查询子物料
List<ErpMaterialCorrRspVO> erpMaterialByMainMaterialByCode = erpMaterialCorrService.getErpMaterialByMainMaterialByCode(code);
if (erpMaterialByMainMaterialByCode.isEmpty()) {
return erpMaterialDOList;
}
List<Long> mIds = erpMaterialByMainMaterialByCode.stream().map(ErpMaterialCorrRspVO::getId).toList();
List<ErpMaterialCorrRspVO> erpMaterialByCompanyCode = erpMaterialCorrService.getErpMaterialByCompanyCode(companyCode);
if (erpMaterialByCompanyCode.isEmpty()){
return erpMaterialDOList;
}
Set<Long> collect = erpMaterialByCompanyCode.stream().map(ErpMaterialCorrRspVO::getDeptId).collect(Collectors.toSet());
if (collect.size() != 1) {
throw exception(CUSTOM_ERROR, "部门编码不唯一或部门编码不存在");
}
List<Long> mIds = erpMaterialByMainMaterialByCode.stream().map(ErpMaterialCorrRspVO::getMaterialId).toList();
DepartmentMaterialPageReqDTO departmentMaterialPageReqDTO = new DepartmentMaterialPageReqDTO();
departmentMaterialPageReqDTO.setInfomationIds(mIds);
departmentMaterialPageReqDTO.setPageSize(10000);
departmentMaterialPageReqDTO.setDeptId(collect.iterator().next());
PageResult<DepartmentMaterialRespDTO> departmentMaterialPage = departmentMaterialApi.getDepartmentMaterialPage(departmentMaterialPageReqDTO).getData();
if (departmentMaterialPage == null || departmentMaterialPage.getList() == null || departmentMaterialPage.getList().isEmpty()) {
return erpMaterialDOList;