新增合同收发货规则

This commit is contained in:
潘荣晟
2026-01-07 16:10:45 +08:00
parent 960c5b5b25
commit cb554f35f3
17 changed files with 720 additions and 30 deletions

View File

@@ -0,0 +1,63 @@
package com.zt.plat.module.contractorder.api.dto.contract;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 收发货规则 Response VO")
@Data
public class ContractReceiveSendRespDTO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26349")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "物料名称", example = "ZT")
@ExcelProperty("物料名称")
private String materialName;
@Schema(description = "物料编码")
@ExcelProperty("物料编码")
private String materialNumber;
@Schema(description = "元素缩写")
@ExcelProperty("元素缩写")
private String elementAbbreviation;
@Schema(description = "元素名称", example = "张三")
@ExcelProperty("元素名称")
private String elementName;
@Schema(description = "元素编码")
@ExcelProperty("元素编码")
private String elementNumber;
@Schema(description = "类型", example = "2")
@ExcelProperty("类型")
private String type;
@Schema(description = "规则")
@ExcelProperty("规则")
private String rule;
@Schema(description = "区间方式")
@ExcelProperty("区间方式")
private String rangeWay;
@Schema(description = "区间下限")
@ExcelProperty("区间下限")
private String gradeDown;
@Schema(description = "区间上限")
@ExcelProperty("区间上限")
private String gradeUp;
@Schema(description = "合同id", example = "22162")
@ExcelProperty("合同id")
private Long contractId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -283,4 +283,6 @@ public class ContractRespDTO {
// 品位不计价规则 // 品位不计价规则
private List<NotRespDTO> nots; private List<NotRespDTO> nots;
//收发货规则
private List<ContractReceiveSendRespDTO> contractReceiveSends;
} }

View File

@@ -0,0 +1,53 @@
package com.zt.plat.module.contractorder.api.vo.contract;
import com.zt.plat.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 收发货规则分页 Request VO")
@Data
public class ContractReceiveSendPageReqVO extends PageParam {
@Schema(description = "物料名称", example = "ZT")
private String materialName;
@Schema(description = "物料编码")
private String materialNumber;
@Schema(description = "元素缩写")
private String elementAbbreviation;
@Schema(description = "元素名称", example = "张三")
private String elementName;
@Schema(description = "元素编码")
private String elementNumber;
@Schema(description = "类型", example = "2")
private String type;
@Schema(description = "规则")
private String rule;
@Schema(description = "区间方式")
private String rangeWay;
@Schema(description = "区间下限")
private String gradeDown;
@Schema(description = "区间上限")
private String gradeUp;
@Schema(description = "合同id", example = "22162")
private Long contractId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,67 @@
package com.zt.plat.module.contractorder.api.vo.contract;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 收发货规则 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ContractReceiveSendRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26349")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "物料名称", example = "ZT")
@ExcelProperty("物料名称")
private String materialName;
@Schema(description = "物料编码")
@ExcelProperty("物料编码")
private String materialNumber;
@Schema(description = "元素缩写")
@ExcelProperty("元素缩写")
private String elementAbbreviation;
@Schema(description = "元素名称", example = "张三")
@ExcelProperty("元素名称")
private String elementName;
@Schema(description = "元素编码")
@ExcelProperty("元素编码")
private String elementNumber;
@Schema(description = "类型", example = "2")
@ExcelProperty("类型")
private String type;
@Schema(description = "规则")
@ExcelProperty("规则")
private String rule;
@Schema(description = "区间方式")
@ExcelProperty("区间方式")
private String rangeWay;
@Schema(description = "区间下限")
@ExcelProperty("区间下限")
private String gradeDown;
@Schema(description = "区间上限")
@ExcelProperty("区间上限")
private String gradeUp;
@Schema(description = "合同id", example = "22162")
@ExcelProperty("合同id")
private Long contractId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,46 @@
package com.zt.plat.module.contractorder.api.vo.contract;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 收发货规则新增/修改 Request VO")
@Data
public class ContractReceiveSendSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26349")
private Long id;
@Schema(description = "物料名称", example = "ZT")
private String materialName;
@Schema(description = "物料编码")
private String materialNumber;
@Schema(description = "元素缩写")
private String elementAbbreviation;
@Schema(description = "元素名称", example = "张三")
private String elementName;
@Schema(description = "元素编码")
private String elementNumber;
@Schema(description = "类型", example = "2")
private String type;
@Schema(description = "规则")
private String rule;
@Schema(description = "区间方式")
private String rangeWay;
@Schema(description = "区间下限")
private String gradeDown;
@Schema(description = "区间上限")
private String gradeUp;
@Schema(description = "合同id", example = "22162")
private Long contractId;
}

View File

@@ -272,6 +272,9 @@ public class ContractRespVO {
@Schema(description = "乙方税号/社会信用代码") @Schema(description = "乙方税号/社会信用代码")
private String salesTaxNumber; private String salesTaxNumber;
@Schema(description = "是否信用", example = "1")
private String hasCredit;
// 物料信息 // 物料信息
private List<DetailRespVO> detail; private List<DetailRespVO> detail;

View File

@@ -9,6 +9,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@@ -241,6 +242,10 @@ public class ContractSaveReqVO {
@Schema(description = "乙方税号/社会信用代码") @Schema(description = "乙方税号/社会信用代码")
private String salesTaxNumber; private String salesTaxNumber;
@Schema(description = "是否信用", example = "1")
private String hasCredit;
// 收发货规则
private List<ContractReceiveSendSaveReqVO> contractReceiveSends;
// 物料信息 // 物料信息
private List<DetailSaveReqVO> detail; private List<DetailSaveReqVO> detail;

View File

@@ -32,4 +32,7 @@ public interface ErrorCodeConstants {
ErrorCode CONTRACT_PARTNER_NOT_EXISTS = new ErrorCode(1_027_000_017, "客商信息不存在"); ErrorCode CONTRACT_PARTNER_NOT_EXISTS = new ErrorCode(1_027_000_017, "客商信息不存在");
ErrorCode CONTRACT_PUSH_FAIL = new ErrorCode(1_027_000_019, "推送合同失败:{}"); ErrorCode CONTRACT_PUSH_FAIL = new ErrorCode(1_027_000_019, "推送合同失败:{}");
ErrorCode CONTRACT_STATUS_NOT_CANCEL = new ErrorCode(1_027_000_020, "{}状态合同不允许作废"); ErrorCode CONTRACT_STATUS_NOT_CANCEL = new ErrorCode(1_027_000_020, "{}状态合同不允许作废");
ErrorCode CONTRACT_RECEIVE_SEND_NOT_EXISTS = new ErrorCode(1_027_000_021, "收发货规则不存在");
} }

View File

@@ -0,0 +1,105 @@
package com.zt.plat.module.contractorder.controller.admin.contractreceivesend;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageParam;
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.contractorder.api.vo.contract.ContractReceiveSendPageReqVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendRespVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendSaveReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend.ContractReceiveSendDO;
import com.zt.plat.module.contractorder.service.contractreceivesend.ContractReceiveSendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 收发货规则")
@RestController
@RequestMapping("/base/contract-receive-send")
@Validated
public class ContractReceiveSendController implements BusinessControllerMarker {
@Resource
private ContractReceiveSendService contractReceiveSendService;
@PostMapping("/create")
@Operation(summary = "创建收发货规则")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:create')")
public CommonResult<ContractReceiveSendRespVO> createContractReceiveSend(@Valid @RequestBody ContractReceiveSendSaveReqVO createReqVO) {
return success(contractReceiveSendService.createContractReceiveSend(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新收发货规则")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:update')")
public CommonResult<Boolean> updateContractReceiveSend(@Valid @RequestBody ContractReceiveSendSaveReqVO updateReqVO) {
contractReceiveSendService.updateContractReceiveSend(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除收发货规则")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:delete')")
public CommonResult<Boolean> deleteContractReceiveSend(@RequestParam("id") Long id) {
contractReceiveSendService.deleteContractReceiveSend(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除收发货规则")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:delete')")
public CommonResult<Boolean> deleteContractReceiveSendList(@RequestBody BatchDeleteReqVO req) {
contractReceiveSendService.deleteContractReceiveSendListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得收发货规则")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:query')")
public CommonResult<ContractReceiveSendRespVO> getContractReceiveSend(@RequestParam("id") Long id) {
ContractReceiveSendDO contractReceiveSend = contractReceiveSendService.getContractReceiveSend(id);
return success(BeanUtils.toBean(contractReceiveSend, ContractReceiveSendRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得收发货规则分页")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:query')")
public CommonResult<PageResult<ContractReceiveSendRespVO>> getContractReceiveSendPage(@Valid ContractReceiveSendPageReqVO pageReqVO) {
PageResult<ContractReceiveSendDO> pageResult = contractReceiveSendService.getContractReceiveSendPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ContractReceiveSendRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出收发货规则 Excel")
@PreAuthorize("@ss.hasPermission('bse:contract-receive-send:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportContractReceiveSendExcel(@Valid ContractReceiveSendPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ContractReceiveSendDO> list = contractReceiveSendService.getContractReceiveSendPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "收发货规则.xls", "数据", ContractReceiveSendRespVO.class,
BeanUtils.toBean(list, ContractReceiveSendRespVO.class));
}
}

View File

@@ -450,4 +450,9 @@ public class ContractMainDO extends BusinessBaseDO {
*/ */
@TableField("SALE_TAX_NUM") @TableField("SALE_TAX_NUM")
private String salesTaxNumber; private String salesTaxNumber;
/**
* 否启用授信
*/
@TableField("HS_CRDT")
private String hasCredit;
} }

View File

@@ -0,0 +1,88 @@
package com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend;
import com.baomidou.mybatisplus.annotation.*;
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
import lombok.*;
/**
* 收发货规则 DO
*
* @author 后台管理-1
*/
@TableName("bse_ctrt_rcv_snd")
@KeySequence("bse_ctrt_rcv_snd_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class ContractReceiveSendDO extends BusinessBaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 物料名称
*/
@TableField("MTRL_NAME")
private String materialName;
/**
* 物料编码
*/
@TableField("MTRL_NUM")
private String materialNumber;
/**
* 元素缩写
*/
@TableField("ELEM_ABBR")
private String elementAbbreviation;
/**
* 元素名称
*/
@TableField("ELEM_NAME")
private String elementName;
/**
* 元素编码
*/
@TableField("ELEM_NUM")
private String elementNumber;
/**
* 类型
*/
@TableField("TP")
private String type;
/**
* 规则
*/
@TableField("RUL")
private String rule;
/**
* 区间方式
*/
@TableField("RNG_WY")
private String rangeWay;
/**
* 区间下限
*/
@TableField("GRD_DOWN")
private String gradeDown;
/**
* 区间上限
*/
@TableField("GRD_UP")
private String gradeUp;
/**
* 合同id
*/
@TableField("CTRT_ID")
private Long contractId;
}

View File

@@ -0,0 +1,36 @@
package com.zt.plat.module.contractorder.dal.mysql.contractreceivesend;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendPageReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend.ContractReceiveSendDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 收发货规则 Mapper
*
* @author 后台管理-1
*/
@Mapper
public interface ContractReceiveSendMapper extends BaseMapperX<ContractReceiveSendDO> {
default PageResult<ContractReceiveSendDO> selectPage(ContractReceiveSendPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ContractReceiveSendDO>()
.likeIfPresent(ContractReceiveSendDO::getMaterialName, reqVO.getMaterialName())
.eqIfPresent(ContractReceiveSendDO::getMaterialNumber, reqVO.getMaterialNumber())
.eqIfPresent(ContractReceiveSendDO::getElementAbbreviation, reqVO.getElementAbbreviation())
.likeIfPresent(ContractReceiveSendDO::getElementName, reqVO.getElementName())
.eqIfPresent(ContractReceiveSendDO::getElementNumber, reqVO.getElementNumber())
.eqIfPresent(ContractReceiveSendDO::getType, reqVO.getType())
.eqIfPresent(ContractReceiveSendDO::getRule, reqVO.getRule())
.eqIfPresent(ContractReceiveSendDO::getRangeWay, reqVO.getRangeWay())
.eqIfPresent(ContractReceiveSendDO::getGradeDown, reqVO.getGradeDown())
.eqIfPresent(ContractReceiveSendDO::getGradeUp, reqVO.getGradeUp())
.eqIfPresent(ContractReceiveSendDO::getContractId, reqVO.getContractId())
.betweenIfPresent(ContractReceiveSendDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ContractReceiveSendDO::getId));
}
}

View File

@@ -34,6 +34,7 @@ import com.zt.plat.module.contractorder.enums.DictTypeConstants;
import com.zt.plat.module.contractorder.enums.ProcessConstants; import com.zt.plat.module.contractorder.enums.ProcessConstants;
import com.zt.plat.module.contractorder.enums.TableFieldConstants; import com.zt.plat.module.contractorder.enums.TableFieldConstants;
import com.zt.plat.module.contractorder.enums.contract.DictEnum; import com.zt.plat.module.contractorder.enums.contract.DictEnum;
import com.zt.plat.module.contractorder.service.contractreceivesend.ContractReceiveSendService;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO; import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO; import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO; import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO;
@@ -118,6 +119,9 @@ public class ContractServiceImpl implements ContractService {
@Resource @Resource
private TmplInscItmBsnService tmplInscItmBsnService; private TmplInscItmBsnService tmplInscItmBsnService;
@Resource
private ContractReceiveSendService contractReceiveSendService;
@Override @Override
public PageResult<ContractMainDO> getContractPage(ContractPageReqVO pageReqVO) { public PageResult<ContractMainDO> getContractPage(ContractPageReqVO pageReqVO) {
return contractMainMapper.selectContractPage(pageReqVO); return contractMainMapper.selectContractPage(pageReqVO);
@@ -297,7 +301,13 @@ public class ContractServiceImpl implements ContractService {
// }); // });
tmplInscItmBsnService.updateTmplInscItmBsnBatch(dynamicsItems); tmplInscItmBsnService.updateTmplInscItmBsnBatch(dynamicsItems);
} }
//插入收发货规则
if (reqVO.getContractReceiveSends() != null && !reqVO.getContractReceiveSends().isEmpty()) {
reqVO.getContractReceiveSends().forEach(contractReceiveSend -> {
contractReceiveSend.setContractId(contractId);
contractReceiveSendService.createContractReceiveSend(contractReceiveSend);
});
}
return contractId; return contractId;
} }
@@ -1369,6 +1379,9 @@ public class ContractServiceImpl implements ContractService {
if (notDOS != null && !notDOS.isEmpty()) { if (notDOS != null && !notDOS.isEmpty()) {
respDTO.setNots(BeanUtils.toBean(notDOS, NotRespDTO.class)); respDTO.setNots(BeanUtils.toBean(notDOS, NotRespDTO.class));
} }
//收发货
List<ContractReceiveSendRespVO> contractReceiveSendListByContractId = contractReceiveSendService.getContractReceiveSendListByContractId(contractMainDO.getId());
respDTO.setContractReceiveSends(BeanUtils.toBean(contractReceiveSendListByContractId, ContractReceiveSendRespDTO.class));
return respDTO; return respDTO;
} }

View File

@@ -0,0 +1,73 @@
package com.zt.plat.module.contractorder.service.contractreceivesend;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendPageReqVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendRespVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendSaveReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend.ContractReceiveSendDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 收发货规则 Service 接口
*
* @author 后台管理-1
*/
public interface ContractReceiveSendService {
/**
* 创建收发货规则
*
* @param createReqVO 创建信息
* @return 编号
*/
ContractReceiveSendRespVO createContractReceiveSend(@Valid ContractReceiveSendSaveReqVO createReqVO);
/**
* 更新收发货规则
*
* @param updateReqVO 更新信息
*/
void updateContractReceiveSend(@Valid ContractReceiveSendSaveReqVO updateReqVO);
/**
* 删除收发货规则
*
* @param id 编号
*/
void deleteContractReceiveSend(Long id);
/**
* 批量删除收发货规则
*
* @param ids 编号
*/
void deleteContractReceiveSendListByIds(List<Long> ids);
/**
* 获得收发货规则
*
* @param id 编号
* @return 收发货规则
*/
ContractReceiveSendDO getContractReceiveSend(Long id);
/**
* 获得收发货规则分页
*
* @param pageReqVO 分页查询
* @return 收发货规则分页
*/
PageResult<ContractReceiveSendDO> getContractReceiveSendPage(ContractReceiveSendPageReqVO pageReqVO);
/**
* 通过合同ID获得收发货规则
*
* @param contractId 合同号
* @return 收发货规则
*/
List<ContractReceiveSendRespVO> getContractReceiveSendListByContractId(Long contractId);
}

View File

@@ -0,0 +1,96 @@
package com.zt.plat.module.contractorder.service.contractreceivesend;
import cn.hutool.core.collection.CollUtil;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendPageReqVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendRespVO;
import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendSaveReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend.ContractReceiveSendDO;
import com.zt.plat.module.contractorder.dal.mysql.contractreceivesend.ContractReceiveSendMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import java.util.List;
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_RECEIVE_SEND_NOT_EXISTS;
/**
* 收发货规则 Service 实现类
*
* @author 后台管理-1
*/
@Service
@Validated
public class ContractReceiveSendServiceImpl implements ContractReceiveSendService {
@Resource
private ContractReceiveSendMapper contractReceiveSendMapper;
@Override
public ContractReceiveSendRespVO createContractReceiveSend(ContractReceiveSendSaveReqVO createReqVO) {
// 插入
ContractReceiveSendDO contractReceiveSend = BeanUtils.toBean(createReqVO, ContractReceiveSendDO.class);
contractReceiveSendMapper.insert(contractReceiveSend);
// 返回
return BeanUtils.toBean(contractReceiveSend, ContractReceiveSendRespVO.class);
}
@Override
public void updateContractReceiveSend(ContractReceiveSendSaveReqVO updateReqVO) {
// 校验存在
validateContractReceiveSendExists(updateReqVO.getId());
// 更新
ContractReceiveSendDO updateObj = BeanUtils.toBean(updateReqVO, ContractReceiveSendDO.class);
contractReceiveSendMapper.updateById(updateObj);
}
@Override
public void deleteContractReceiveSend(Long id) {
// 校验存在
validateContractReceiveSendExists(id);
// 删除
contractReceiveSendMapper.deleteById(id);
}
@Override
public void deleteContractReceiveSendListByIds(List<Long> ids) {
// 校验存在
validateContractReceiveSendExists(ids);
// 删除
contractReceiveSendMapper.deleteByIds(ids);
}
private void validateContractReceiveSendExists(List<Long> ids) {
List<ContractReceiveSendDO> list = contractReceiveSendMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(CONTRACT_RECEIVE_SEND_NOT_EXISTS);
}
}
private void validateContractReceiveSendExists(Long id) {
if (contractReceiveSendMapper.selectById(id) == null) {
throw exception(CONTRACT_RECEIVE_SEND_NOT_EXISTS);
}
}
@Override
public ContractReceiveSendDO getContractReceiveSend(Long id) {
return contractReceiveSendMapper.selectById(id);
}
@Override
public PageResult<ContractReceiveSendDO> getContractReceiveSendPage(ContractReceiveSendPageReqVO pageReqVO) {
return contractReceiveSendMapper.selectPage(pageReqVO);
}
@Override
public List<ContractReceiveSendRespVO> getContractReceiveSendListByContractId(Long contractId) {
return BeanUtils.toBean(contractReceiveSendMapper.selectList(ContractReceiveSendDO::getContractId, contractId), ContractReceiveSendRespVO.class);
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.bse.dal.dao.contractreceivesend.ContractReceiveSendMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@@ -144,6 +144,7 @@ public class ErpMaterialController {
ErpMaterialDO erpMaterial = erpMaterialService.getErpMaterialById(id); ErpMaterialDO erpMaterial = erpMaterialService.getErpMaterialById(id);
return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class)); return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class));
} }
//通过主物料查询子物料信息 //通过主物料查询子物料信息
@GetMapping("/getErpMaterialByMainMaterialById") @GetMapping("/getErpMaterialByMainMaterialById")
@Operation(summary = "通过主物料查询子物料信息") @Operation(summary = "通过主物料查询子物料信息")
@@ -161,4 +162,23 @@ public class ErpMaterialController {
List<ErpMaterialDO> erpMaterial = erpMaterialService.getErpMaterialByApi(material); List<ErpMaterialDO> erpMaterial = erpMaterialService.getErpMaterialByApi(material);
return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class)); return success(BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class));
} }
//通过主物料查询子物料信息
@GetMapping("/erpMaterial-mainMaterial-code")
@Operation(summary = "通过主物料编号查询子物料信息")
@PreAuthorize("@ss.hasPermission('sply:erp-material:query')")
public CommonResult<List<ErpMaterialRespVO>> getErpMaterialByMainMaterialByCOde(String code) {
return success(BeanUtils.toBean(List.of(new MaterialInfomationPageReqDTO()), ErpMaterialRespVO.class));
}
//查询物料
@GetMapping("/api-erp-material-code")
@Operation(summary = "通过编号接口查询物料")
@PreAuthorize("@ss.hasPermission('sply:erp-material:query')")
public CommonResult<List<ErpMaterialRespVO>> getErpMaterialByApiByCode(String code) {
return success(BeanUtils.toBean(List.of(new MaterialInfomationPageReqDTO()), ErpMaterialRespVO.class));
}
} }