新增物料拓展表
This commit is contained in:
@@ -12,7 +12,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ERP_REDIS_EXISTS = new ErrorCode(1_000_000_004, "公司调用缓存失败");
|
||||
|
||||
ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在");
|
||||
|
||||
ErrorCode ERP_NUMBER_EXISTS = new ErrorCode(1_001_000_002, "工厂编码已存在");
|
||||
ErrorCode ERP_NUMBER_IS_NULL = new ErrorCode(1_001_000_003, "工厂编码为空");
|
||||
ErrorCode ERP_MATERIAL_NOT_EXISTS = new ErrorCode(1_002_000_001, "ERP物料数据不存在");
|
||||
ErrorCode ERP_MATERIAL_NOT_ALLOW_UPDATE = new ErrorCode(1_002_000_002, "只允许编辑状态为“供应链”的数据");
|
||||
ErrorCode ERP_MATERIAL_NOT_ALLOW_DELETE = new ErrorCode(1_002_000_003, "不允许删除状态为“ERP”的数据");
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
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;
|
||||
@@ -116,5 +117,20 @@ public class ErpMaterialController {
|
||||
PageResult<ErpMaterialRespVO> pageResult = erpMaterialService.getErpMaterialPageAndOther(pageReqVO);
|
||||
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 List<ErpMaterialCorrSaveReqVO> erpMaterialCorrSaveReqVOS) {
|
||||
return success(erpMaterialService.createErpMaterialCorr(erpMaterialCorrSaveReqVOS));
|
||||
}
|
||||
//删除物料关系
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 物料拓展关系 响应 VO")
|
||||
@Data
|
||||
public class ErpMaterialCorrRspVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2038")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 拓展关系主物料
|
||||
*/
|
||||
@Schema(description = "拓展关系主物料", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "拓展关系主物料不能为空")
|
||||
private Long materialParentId;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
@Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long materialId;
|
||||
/**
|
||||
* 拓展关系主物料编号
|
||||
*/
|
||||
@Schema(description = "拓展关系主物料编号")
|
||||
private String materialParentCode;
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@Schema(description = "拓展关系物料编号")
|
||||
private String materialCode;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
||||
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 物料拓展关系 Request VO")
|
||||
@Data
|
||||
public class ErpMaterialCorrSaveReqVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2038")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 拓展关系主物料
|
||||
*/
|
||||
@Schema(description = "拓展关系主物料", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "拓展关系主物料不能为空")
|
||||
private Long materialParentId;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
@Schema(description = "物料ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long materialId;
|
||||
/**
|
||||
* 拓展关系主物料编号
|
||||
*/
|
||||
@Schema(description = "拓展关系主物料编号")
|
||||
private String materialParentCode;
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@Schema(description = "拓展关系物料编号")
|
||||
private String materialCode;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ErpFactoryDO extends BusinessBaseDO {
|
||||
private String relnumber;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 是否启用
|
||||
*/
|
||||
@TableField("IS_ENB")
|
||||
private String isEnable;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zt.plat.module.erp.dal.dataobject.erp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 物料关联关系 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("SPLY_ERP_MTRL_CORR")
|
||||
@KeySequence("SPLY_ERP_MTRL_CORR_SEQ")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class ErpMaterialCorrDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 拓展关系主物料
|
||||
*/
|
||||
@TableField("MTRL_PRN_ID")
|
||||
private Long materialParentId;
|
||||
/**
|
||||
* 拓展关系主物料编码
|
||||
*/
|
||||
@TableField("MTRL_PRN_CODE")
|
||||
private String materialParentCode;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
@TableField("MTRL_ID")
|
||||
private Long materialId;
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@TableField("MTRL_CODE")
|
||||
private String materialCode;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.zt.plat.module.erp.dal.mysql.erp;
|
||||
|
||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpMaterialCorrDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ErpErpMaterialCorrMapper extends BaseMapperX<ErpMaterialCorrDO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialCorrRspVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialCorrSaveReqVO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ERP物料拓展数据 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface ErpErpMaterialCorrService {
|
||||
List<ErpMaterialCorrRspVO> create(@Valid List<ErpMaterialCorrSaveReqVO> reqVO);
|
||||
void deleteBatch(BatchDeleteReqVO reqVO);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialCorrRspVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialCorrSaveReqVO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpMaterialCorrDO;
|
||||
import com.zt.plat.module.erp.dal.mysql.erp.ErpErpMaterialCorrMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ErpErpMaterialCorrServiceImpl implements ErpErpMaterialCorrService{
|
||||
@Resource
|
||||
private ErpErpMaterialCorrMapper erpErpMaterialCorrMapper;
|
||||
|
||||
@Override
|
||||
public List<ErpMaterialCorrRspVO> create(List<ErpMaterialCorrSaveReqVO> reqVO) {
|
||||
List<ErpMaterialCorrDO> bean = BeanUtils.toBean(reqVO, ErpMaterialCorrDO.class);
|
||||
erpErpMaterialCorrMapper.insertBatch(bean);
|
||||
return BeanUtils.toBean(bean, ErpMaterialCorrRspVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(BatchDeleteReqVO reqVO) {
|
||||
erpErpMaterialCorrMapper.deleteByIds(reqVO.getIds());
|
||||
}
|
||||
}
|
||||
@@ -55,25 +55,40 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
// 插入
|
||||
ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class);
|
||||
// 工厂编码自动生成,格式 GC-0001,依次新增
|
||||
if (erpFactory.getNumber() == null) {
|
||||
String maxCode = erpFactoryMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
erpFactory.setNumber("GC-0001");
|
||||
} else {
|
||||
String prefix = "GC-";
|
||||
String numberPart = maxCode.substring(prefix.length());
|
||||
int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||
String nextCode = prefix + String.format("%04d", nextNumber);
|
||||
erpFactory.setNumber(nextCode);
|
||||
}
|
||||
// if (erpFactory.getNumber() == null) {
|
||||
// String maxCode = erpFactoryMapper.selectMaxCode();
|
||||
// if (maxCode == null) {
|
||||
// erpFactory.setNumber("GC-0001");
|
||||
// } else {
|
||||
// String prefix = "GC-";
|
||||
// String numberPart = maxCode.substring(prefix.length());
|
||||
// int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||
// String nextCode = prefix + String.format("%04d", nextNumber);
|
||||
// erpFactory.setNumber(nextCode);
|
||||
// }
|
||||
// }
|
||||
//工厂编码校验
|
||||
// validateErpFactoryNumberExists(erpFactory);
|
||||
if (erpFactory.getType() == null || erpFactory.getType().isEmpty()) {
|
||||
erpFactory.setType("SPLY");
|
||||
}
|
||||
erpFactory.setType("SPLY");
|
||||
erpFactory.setIsEnable("1");
|
||||
erpFactoryMapper.insert(erpFactory);
|
||||
// 返回
|
||||
return BeanUtils.toBean(erpFactory, ErpFactoryRespVO.class);
|
||||
}
|
||||
|
||||
private void validateErpFactoryNumberExists(ErpFactoryDO erpFactory) {
|
||||
String number = erpFactory.getNumber();
|
||||
if (number == null || number.isEmpty()) {
|
||||
throw exception(ERP_NUMBER_IS_NULL);
|
||||
}
|
||||
boolean exists = erpFactoryMapper.exists(new LambdaQueryWrapperX<ErpFactoryDO>().eq(ErpFactoryDO::getNumber, number));
|
||||
if (exists) {
|
||||
throw exception(ERP_NUMBER_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateErpFactory(ErpFactorySaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
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;
|
||||
@@ -67,4 +69,8 @@ public interface ErpMaterialService {
|
||||
PageResult<ErpMaterialRespVO> getErpMaterialPageAndOther(ErpMaterialPageReqVO pageReqVO);
|
||||
|
||||
String getMaterialUnit(String materialNumber);
|
||||
|
||||
List<ErpMaterialRespVO> createErpMaterialCorr(List<ErpMaterialCorrSaveReqVO> erpMaterialCorrSaveReqVOS);
|
||||
|
||||
void deleteErpMaterialCorr(BatchDeleteReqVO reqVO);
|
||||
}
|
||||
@@ -5,18 +5,17 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.api.BaseApi;
|
||||
import com.zt.plat.module.api.dto.MaterialOtherDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpMaterialDTO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.*;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
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.dal.dataobject.erp.ErpMaterialDO;
|
||||
import com.zt.plat.module.erp.dal.mysql.erp.ErpMaterialMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -53,6 +52,8 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
@Resource
|
||||
private ErpErpMaterialCorrService erpMaterialCorrService;
|
||||
|
||||
@Override
|
||||
public ErpMaterialRespVO createErpMaterial(ErpMaterialSaveReqVO createReqVO) {
|
||||
@@ -182,6 +183,22 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
return erpMaterialMapper.getMaterialUnit(materialNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErpMaterialRespVO> createErpMaterialCorr(List<ErpMaterialCorrSaveReqVO> erpMaterialCorrSaveReqVOS) {
|
||||
List<ErpMaterialCorrRspVO> erpMaterialCorrRspVOS = erpMaterialCorrService.create(erpMaterialCorrSaveReqVOS);
|
||||
return erpMaterialCorrRspVOS.stream().map(erpMaterialCorrRspVO -> {
|
||||
//TODO 通过物料id返回物料信息
|
||||
ErpMaterialRespVO erpMaterialRespVO = new ErpMaterialRespVO();
|
||||
BeanUtils.copyProperties(erpMaterialCorrRspVO, erpMaterialRespVO);
|
||||
return erpMaterialRespVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteErpMaterialCorr(BatchDeleteReqVO reqVO) {
|
||||
erpMaterialCorrService.deleteBatch(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@XxlJob("getErpMaterialTask")
|
||||
|
||||
Reference in New Issue
Block a user