Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
潘荣晟
2025-10-11 18:01:55 +08:00
46 changed files with 719 additions and 456 deletions

View File

@@ -1,7 +1,6 @@
package com.zt.plat.module.contractorder.api.dto; package com.zt.plat.module.contractorder.api.dto;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -13,9 +12,6 @@ public class ContractCoefficientRespDTO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;
@@ -28,25 +24,21 @@ public class ContractCoefficientRespDTO {
@Schema(description = "金属元素名称") @Schema(description = "金属元素名称")
private String elementName; private String elementName;
@Schema(description = "系数值")
private String settlementCoefficient;
@Schema(description = "系数上限") @Schema(description = "系数上限")
private BigDecimal coefficientUp; private BigDecimal coefficientUp;
@Schema(description = "系数下限") @Schema(description = "系数下限")
private BigDecimal coefficientDown; private BigDecimal coefficientDown;
@Schema(description = "是否包含上限") @Schema(description = "区间方式(字典STLM_RNG_WY)")
private String isInUp; private String rangeWay;
@Schema(description = "是否包含下限")
private String isInDown;
@Schema(description = "是否省内") @Schema(description = "是否省内")
@NotEmpty(message = "是否省内不能为空")
private String inState; private String inState;
@Schema(description = "类型") @Schema(description = "类型")
private String type; private String type;
@Schema(description = "系数值")
private BigDecimal settlementCoefficient;
} }

View File

@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "RPC 服务 - 调整价配置 Response DTO") @Schema(description = "RPC 服务 - 调整价配置 Response DTO")
@Data @Data
@@ -12,39 +13,18 @@ public class ContractDeductRespDTO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;
@Schema(description = "物料编码;推送ERP") @Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String materialNumber; private String configType;
@Schema(description = "物料名称")
private String materialName;
@Schema(description = "上限")
private BigDecimal gradeUp;
@Schema(description = "下限")
private BigDecimal gradeDown;
@Schema(description = "是否包含上限")
private String isInUp;
@Schema(description = "是否包含下限")
private String isInDown;
@Schema(description = "方式")
private String way;
@Schema(description = "类型")
private String type;
@Schema(description = "是否省内") @Schema(description = "是否省内")
private String inState; private String inState;
@Schema(description = "调整价") @Schema(description = "调整价")
private BigDecimal gradeAmount; private BigDecimal gradeAmount;
@Schema(description = "创建时间")
private LocalDateTime createTime;
} }

View File

@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "RPC 服务 - 品位等级价配置 Response DTO") @Schema(description = "RPC 服务 - 品位等级价配置 Response DTO")
@Data @Data
@@ -12,9 +13,6 @@ public class ContractGradeRespDTO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;
@@ -36,27 +34,30 @@ public class ContractGradeRespDTO {
@Schema(description = "品位下限") @Schema(description = "品位下限")
private BigDecimal gradeDown; private BigDecimal gradeDown;
@Schema(description = "是否包含上限;包含则是大于等于,不包含则是大于") @Schema(description = "区间方式(字典:STLM_RNG_WY)")
private String isInUp; private String rangeWay;
@Schema(description = "是否包含下限;包含则是小于等于,不包含则是小于") @Schema(description = "默认计价品位")
private String isInDown;
@Schema(description = "默认计价品位;计价方式为加时,默认为为下限,计价方式为减时,默认为为上限,可手动填写")
private BigDecimal gradeDefault; private BigDecimal gradeDefault;
@Schema(description = "系数;计价类型为阶梯价使用,标识没上升多少系数进行加款还是减款") @Schema(description = "系数")
private BigDecimal settlementCoefficient; private BigDecimal settlementCoefficient;
@Schema(description = "不足系数值按比例计算") @Schema(description = "是否比例计算(字典:ERP_CTRT_YN)")
private String useCoefficient; private String useCoefficient;
@Schema(description = "计价类型") @Schema(description = "计价类型(字典:STLM_GRD_TP)")
private String priceType; private String priceType;
@Schema(description = "是否省内") @Schema(description = "是否省内(字典:ERP_CTRT_YN)")
private String inState; private String inState;
@Schema(description = "等级单价") @Schema(description = "等级单价", example = "3565")
private BigDecimal unitPrice; private BigDecimal unitPrice;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String configType;
} }

View File

@@ -13,9 +13,6 @@ public class ContractPriceRespDTO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;

View File

@@ -1,46 +0,0 @@
package com.zt.plat.module.contractorder.enums.contract;
/**
* 合同审核结果
*/
public enum AuditResultEnum {
/**
* 合同状态-草稿
*/
PASS("通过","PASS", null),
/**
* 合同状态-正在审核
*/
REJECT("驳回","REJECT",null);
AuditResultEnum(String label, String code, String remark) {
this.label = label;
this.code = code;
this.remark = remark;
}
/**
* 标签
*/
private final String label;
/**
* 编码
*/
private final String code;
/**
* 备注
*/
private final String remark;
public String getLabel() {
return label;
}
public String getCode() {
return code;
}
public String getRemark() {
return remark;
}
}

View File

@@ -1,67 +0,0 @@
package com.zt.plat.module.contractorder.enums.contract;
/**
* 合同状态枚举
*/
public enum ContractStatusEnum {
/**
* 合同状态-草稿
*/
DRAFT("草稿","DRAFT","可以删除"),
/**
* 合同状态-正在审核
*/
UNDER_REVIEW("正在审核","UNDER_REVIEW","不允许任何操作"),
/**
* 合同状态-执行中
*/
IN_PROGRESS("执行中","IN_PROGRESS","可以终止、归档"),
/**
* 合同状态-已驳回
*/
REJECTED("已驳回","REJECTED","可以删除"),
/**
* 合同状态-已终止
*/
TERMINATED("已终止","TERMINATED","只允许归档"),
/**
* 合同状态-已归档
*/
ARCHIVED("已归档","ARCHIVED","不允许任何操作"),
/**
* 合同状态-已删除
*/
DELETED("已删除","DELETED","不允许任何操作");
ContractStatusEnum(String label, String code, String remark) {
this.label = label;
this.code = code;
this.remark = remark;
}
/**
* 字典标签
*/
private final String label;
/**
* 字典编码
*/
private final String code;
/**
* 备注
*/
private final String remark;
public String getLabel() {
return label;
}
public String getCode() {
return code;
}
public String getRemark() {
return remark;
}
}

View File

@@ -1,55 +0,0 @@
package com.zt.plat.module.contractorder.enums.contract;
/**
* 合同类型枚举
*/
public enum ContractTypeEnum {
/**
* 采购
*/
PRCH("采购","PRCH",null),
/**
* 销售
*/
SALE("销售","SALE",null),
/**
* 委托加工
*/
ENTT("委托加工","ENTT",null),
/**
* 来料加工
*/
MKE("来料加工","MKE",null);
ContractTypeEnum(String label, String code, String remark) {
this.label = label;
this.code = code;
this.remark = remark;
}
/**
* 字典标签
*/
private final String label;
/**
* 字典编码
*/
private final String code;
/**
* 备注
*/
private final String remark;
public String getLabel() {
return label;
}
public String getCode() {
return code;
}
public String getRemark() {
return remark;
}
}

View File

@@ -0,0 +1,73 @@
package com.zt.plat.module.contractorder.enums.contract;
/**
* 字典枚举
*/
public enum DictEnum {
/** ERP收支方向 */
// 支出
ERP_RCV_DLVY_EXPENSES("支出","2","对应采购"),
// 收入
ERP_RCV_DLVY_INCOME("收入","1","对应销售"),
/** ERP是否 */
// 是
ERP_CTRT_YN_YES("","1",null),
// 否
ERP_CTRT_YN_NO("","0",null),
/** 合同状态 */
// 草稿
BSE_CTRT_STS_DRAFT("草稿","DRAFT","可以删除"),
// 正在审核
BSE_CTRT_STS_UNDER_REVIEW("正在审核","UNDER_REVIEW","不允许任何操作"),
// 已驳回
BSE_CTRT_STS_REJECTED("已驳回","REJECTED","可以删除"),
// 待推送
BSE_CTRT_STS_WAIT_PUSH("待推送","WAIT_PUSH",null),
// 推送失败
BSE_CTRT_STS_PUSH_ERROR("推送失败","PUSH_ERROR",null),
// 执行中
BSE_CTRT_STS_IN_PROGRESS("执行中","IN_PROGRESS","可以终止、归档"),
// 已删除
BSE_CTRT_STS_DELETED("已删除","DELETED","不允许任何操作"),
// 已归档
BSE_CTRT_STS_ARCHIVED("已归档","ARCHIVED","不允许任何操作"),
// 已完结
BSE_CTRT_STS_TERMINATED("已完结","TERMINATED","只允许归档"),
// 待审核
BSE_CTRT_STS_WAIT_AUDIT("待审核","WAIT_AUDIT",null),
// 已作废
BSE_CTRT_STS_VOID("已作废","VOID",null);
DictEnum(String label, String code, String remark) {
this.label = label;
this.code = code;
this.remark = remark;
}
/**
* 字典标签
*/
private final String label;
/**
* 字典编码
*/
private final String code;
/**
* 备注
*/
private final String remark;
public String getLabel() {
return label;
}
public String getCode() {
return code;
}
public String getRemark() {
return remark;
}
}

View File

@@ -1,47 +0,0 @@
package com.zt.plat.module.contractorder.enums.contract;
/**
* ERP是否枚举
*/
public enum ErpCtrtYesNoEnum {
/**
* 是
*/
YES("","1",null),
/**
* 否
*/
NO("","0",null);
ErpCtrtYesNoEnum(String label, String code, String remark) {
this.label = label;
this.code = code;
this.remark = remark;
}
/**
* 字典标签
*/
private final String label;
/**
* 字典编码
*/
private final String code;
/**
* 备注
*/
private final String remark;
public String getLabel() {
return label;
}
public String getCode() {
return code;
}
public String getRemark() {
return remark;
}
}

View File

@@ -19,7 +19,6 @@ public class ContractApiImpl implements ContractApi {
@Override @Override
public List<ContractFormulaRespDTO> getFormulas(String contractPaperNumber) { public List<ContractFormulaRespDTO> getFormulas(String contractPaperNumber) {
System.out.println("contract feign" + contractPaperNumber); return contractService.getFormulasByPaperNumber(contractPaperNumber);
return List.of();
} }
} }

View File

@@ -148,6 +148,7 @@ public class ContractController implements BusinessControllerMarker {
@PostMapping("/submit/erp") @PostMapping("/submit/erp")
@Operation(summary = "提交ERP") @Operation(summary = "提交ERP")
@PreAuthorize("@ss.hasPermission('base:contract:erp')") @PreAuthorize("@ss.hasPermission('base:contract:erp')")
public void submitErp() { public void submitErp(@RequestBody List<Long> ids) {
contractService.submitErp(ids);
} }
} }

View File

@@ -1,20 +1,18 @@
package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract; package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 品位等级价配置 Response VO") @Schema(description = "管理后台 - 品位等级价配置 Response VO")
@Data @Data
public class GradeRespVO { public class GradeRespVO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;
@@ -36,28 +34,30 @@ public class GradeRespVO {
@Schema(description = "品位下限") @Schema(description = "品位下限")
private BigDecimal gradeDown; private BigDecimal gradeDown;
@Schema(description = "是否包含上限;包含则是大于等于,不包含则是大于") @Schema(description = "区间方式(字典:STLM_RNG_WY)")
private String isInUp; private String rangeWay;
@Schema(description = "是否包含下限;包含则是小于等于,不包含则是小于") @Schema(description = "默认计价品位")
private String isInDown;
@Schema(description = "默认计价品位;计价方式为加时,默认为为下限,计价方式为减时,默认为为上限,可手动填写")
private BigDecimal gradeDefault; private BigDecimal gradeDefault;
@Schema(description = "系数;计价类型为阶梯价使用,标识没上升多少系数进行加款还是减款") @Schema(description = "系数")
private BigDecimal settlementCoefficient; private BigDecimal settlementCoefficient;
@Schema(description = "不足系数值按比例计算") @Schema(description = "是否比例计算(字典:ERP_CTRT_YN)")
private String useCoefficient; private String useCoefficient;
@Schema(description = "计价类型") @Schema(description = "计价类型(字典:STLM_GRD_TP)")
private String priceType; private String priceType;
@Schema(description = "是否省内") @Schema(description = "是否省内(字典:ERP_CTRT_YN)")
@NotEmpty(message = "是否省内不能为空")
private String inState; private String inState;
@Schema(description = "等级单价") @Schema(description = "等级单价", example = "3565")
private BigDecimal unitPrice; private BigDecimal unitPrice;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)")
private String configType;
} }

View File

@@ -1,21 +1,18 @@
package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract; package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
@Schema(description = "管理后台 - 品位等级价配置新增/修改 Request VO") @Schema(description = "管理后台 - 品位等级价配置新增/修改 Request VO")
@Data @Data
public class GradeSaveReqVO { public class GradeSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "15414") @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6211")
private Long id; private Long id;
@Schema(description = "配置主键", example = "16734") @Schema(description = "条款主键", example = "2426")
private Long parameterId;
@Schema(description = "条款主键", example = "15344")
private Long formulaId; private Long formulaId;
@Schema(description = "金属元素编码") @Schema(description = "金属元素编码")
@@ -24,7 +21,7 @@ public class GradeSaveReqVO {
@Schema(description = "金属元素缩写") @Schema(description = "金属元素缩写")
private String elementAbbreviation; private String elementAbbreviation;
@Schema(description = "金属元素名称", example = "芋艿") @Schema(description = "金属元素名称", example = "王五")
private String elementName; private String elementName;
@Schema(description = "品位单位") @Schema(description = "品位单位")
@@ -36,28 +33,27 @@ public class GradeSaveReqVO {
@Schema(description = "品位下限") @Schema(description = "品位下限")
private BigDecimal gradeDown; private BigDecimal gradeDown;
@Schema(description = "是否包含上限;包含则是大于等于,不包含则是大于") @Schema(description = "区间方式(字典:STLM_RNG_WY)")
private String isInUp; private String rangeWay;
@Schema(description = "是否包含下限;包含则是小于等于,不包含则是小于") @Schema(description = "默认计价品位")
private String isInDown;
@Schema(description = "默认计价品位;计价方式为加时,默认为为下限,计价方式为减时,默认为为上限,可手动填写")
private BigDecimal gradeDefault; private BigDecimal gradeDefault;
@Schema(description = "系数;计价类型为阶梯价使用,标识没上升多少系数进行加款还是减款") @Schema(description = "系数")
private BigDecimal settlementCoefficient; private BigDecimal settlementCoefficient;
@Schema(description = "不足系数值按比例计算") @Schema(description = "是否比例计算(字典:ERP_CTRT_YN)")
private String useCoefficient; private String useCoefficient;
@Schema(description = "计价类型", example = "2") @Schema(description = "计价类型(字典:STLM_GRD_TP)", example = "2")
private String priceType; private String priceType;
@Schema(description = "是否省内", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "是否省内(字典:ERP_CTRT_YN)")
@NotEmpty(message = "是否省内不能为空")
private String inState; private String inState;
@Schema(description = "等级单价", example = "26237") @Schema(description = "等级单价", example = "3565")
private BigDecimal unitPrice; private BigDecimal unitPrice;
@Schema(description = "数据项类型(字典:GRD_CFG_TP)", example = "1")
private String configType;
} }

View File

@@ -12,9 +12,6 @@ public class PriceRespVO {
@Schema(description = "主键") @Schema(description = "主键")
private Long id; private Long id;
@Schema(description = "配置主键")
private Long parameterId;
@Schema(description = "条款主键") @Schema(description = "条款主键")
private Long formulaId; private Long formulaId;

View File

@@ -12,9 +12,6 @@ public class PriceSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13654") @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13654")
private Long id; private Long id;
@Schema(description = "配置主键", example = "1590")
private Long parameterId;
@Schema(description = "条款主键", example = "24677") @Schema(description = "条款主键", example = "24677")
private Long formulaId; private Long formulaId;

View File

@@ -29,11 +29,6 @@ public class ContractGradeDO extends BusinessBaseDO {
*/ */
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
private Long id; private Long id;
/**
* 配置主键
*/
@TableField("PRM_ID")
private Long parameterId;
/** /**
* 条款主键 * 条款主键
*/ */
@@ -70,37 +65,32 @@ public class ContractGradeDO extends BusinessBaseDO {
@TableField("GRD_DOWN") @TableField("GRD_DOWN")
private BigDecimal gradeDown; private BigDecimal gradeDown;
/** /**
* 是否包含上限;包含则是大于等于,不包含则是大于 * 区间方式(字典:STLM_RNG_WY)
*/ */
@TableField("IS_IN_UP") @TableField("RNG_WY")
private String isInUp; private String rangeWay;
/** /**
* 是否包含下限;包含则是小于等于,不包含则是小于 * 默认计价品位
*/
@TableField("IS_IN_DOWN")
private String isInDown;
/**
* 默认计价品位;计价方式为加时,默认为为下限,计价方式为减时,默认为为上限,可手动填写
*/ */
@TableField("GRD_DFT") @TableField("GRD_DFT")
private BigDecimal gradeDefault; private BigDecimal gradeDefault;
/** /**
* 系数;计价类型为阶梯价使用,标识没上升多少系数进行加款还是减款 * 系数
*/ */
@TableField("STLM_COEF") @TableField("STLM_COEF")
private BigDecimal settlementCoefficient; private BigDecimal settlementCoefficient;
/** /**
* 不足系数值按比例计算 * 是否比例计算(字典:ERP_CTRT_YN)
*/ */
@TableField("USE_COEF") @TableField("USE_COEF")
private String useCoefficient; private String useCoefficient;
/** /**
* 计价类型 * 计价类型(字典:STLM_GRD_TP)
*/ */
@TableField("PRC_TP") @TableField("PRC_TP")
private String priceType; private String priceType;
/** /**
* 是否省内 * 是否省内(字典:ERP_CTRT_YN)
*/ */
@TableField("IN_STA") @TableField("IN_STA")
private String inState; private String inState;
@@ -109,4 +99,9 @@ public class ContractGradeDO extends BusinessBaseDO {
*/ */
@TableField("UPRC") @TableField("UPRC")
private BigDecimal unitPrice; private BigDecimal unitPrice;
/**
* 数据项类型(字典:GRD_CFG_TP)
*/
@TableField("CFG_TP")
private String configType;
} }

View File

@@ -30,11 +30,6 @@ public class ContractPriceDO extends BusinessBaseDO {
*/ */
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
private Long id; private Long id;
/**
* 配置主键
*/
@TableField("PRM_ID")
private Long parameterId;
/** /**
* 条款主键 * 条款主键
*/ */

View File

@@ -1,6 +1,7 @@
package com.zt.plat.module.contractorder.service.contract; package com.zt.plat.module.contractorder.service.contract;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.module.contractorder.api.dto.ContractFormulaRespDTO;
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*; import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO; import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -85,4 +86,20 @@ public interface ContractService {
* @return 结算公式列表 * @return 结算公式列表
*/ */
List<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO); List<FormulaRespVO> getFormulas(FormulasQueryReqVO queryReqVO);
/**
* 通过合同编号获取对应的结算条款数据
*
* @param contractPaperNumber 合同编号
* @return 结算条款数据
*/
List<ContractFormulaRespDTO> getFormulasByPaperNumber(String contractPaperNumber);
/**
* 提交ERP
*
* @param ids 合同ID集合
* @return
*/
void submitErp(List<Long> ids);
} }

View File

@@ -17,6 +17,7 @@ import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
import com.zt.plat.module.bpm.api.task.BpmTaskApi; import com.zt.plat.module.bpm.api.task.BpmTaskApi;
import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO; import com.zt.plat.module.bpm.api.task.dto.BpmTaskRespDTO;
import com.zt.plat.module.contractorder.api.dto.*;
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*; import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
import com.zt.plat.module.contractorder.dal.dataobject.contract.*; import com.zt.plat.module.contractorder.dal.dataobject.contract.*;
import com.zt.plat.module.contractorder.dal.mysql.contract.*; import com.zt.plat.module.contractorder.dal.mysql.contract.*;
@@ -24,8 +25,8 @@ import com.zt.plat.module.contractorder.enums.ApiConstants;
import com.zt.plat.module.contractorder.enums.DateConstants; import com.zt.plat.module.contractorder.enums.DateConstants;
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.ContractStatusEnum; import com.zt.plat.module.contractorder.enums.contract.DictEnum;
import com.zt.plat.module.contractorder.enums.contract.ErpCtrtYesNoEnum; import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO;
import com.zt.plat.module.erp.service.erp.ErpCompanyService; import com.zt.plat.module.erp.service.erp.ErpCompanyService;
import com.zt.plat.module.system.api.user.AdminUserApi; import com.zt.plat.module.system.api.user.AdminUserApi;
import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO; import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO;
@@ -133,7 +134,7 @@ public class ContractServiceImpl implements ContractService {
// 合同主信息 // 合同主信息
ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class); ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
// 合同状态保存为草稿 // 合同状态保存为草稿
contractMainDO.setStatus(ContractStatusEnum.DRAFT.getCode()); contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DRAFT.getCode());
// 生成系统合同编号 // 生成系统合同编号
contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getCategory())); contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getCategory()));
@@ -399,14 +400,14 @@ public class ContractServiceImpl implements ContractService {
} }
// 合同状态校验 // 合同状态校验
if (ContractStatusEnum.DELETED.getCode().equals(oldContractMainDO.getStatus()) if (DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(oldContractMainDO.getStatus())
|| ContractStatusEnum.ARCHIVED.getCode().equals(oldContractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(oldContractMainDO.getStatus())
|| ContractStatusEnum.TERMINATED.getCode().equals(oldContractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(oldContractMainDO.getStatus())
|| ContractStatusEnum.IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(oldContractMainDO.getStatus())
|| ContractStatusEnum.UNDER_REVIEW.getCode().equals(oldContractMainDO.getStatus())) { || DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(oldContractMainDO.getStatus())) {
throw exception(CONTRACT_STATUS_NOT_UPDATE, throw exception(CONTRACT_STATUS_NOT_UPDATE,
ContractStatusEnum.valueOf(oldContractMainDO.getStatus()).getLabel()); DictEnum.valueOf(oldContractMainDO.getStatus()).getLabel());
} }
// 请求更新的合同信息 // 请求更新的合同信息
@@ -605,14 +606,14 @@ public class ContractServiceImpl implements ContractService {
} }
// 合同状态校验 // 合同状态校验
if (ContractStatusEnum.UNDER_REVIEW.getCode().equals(contractMainDO.getStatus()) if (DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.IN_PROGRESS.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.TERMINATED.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.ARCHIVED.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.DELETED.getCode().equals(contractMainDO.getStatus())) { || DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL, throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL,
ContractStatusEnum.valueOf(contractMainDO.getStatus()).getLabel()); DictEnum.valueOf(contractMainDO.getStatus()).getLabel());
} }
// 合同内容校验 // 合同内容校验
@@ -643,7 +644,7 @@ public class ContractServiceImpl implements ContractService {
BpmTaskRespDTO undoTask = taskList.get(taskList.size() - 1); BpmTaskRespDTO undoTask = taskList.get(taskList.size() - 1);
contractMainDO.setTaskNodeId(undoTask.getId()); contractMainDO.setTaskNodeId(undoTask.getId());
} }
contractMainDO.setStatus(ContractStatusEnum.UNDER_REVIEW.getCode()); contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode());
contractMainMapper.updateById(contractMainDO); contractMainMapper.updateById(contractMainDO);
return "提交审批成功"; return "提交审批成功";
} }
@@ -670,20 +671,27 @@ public class ContractServiceImpl implements ContractService {
} }
// 合同状态校验 // 合同状态校验
if (ContractStatusEnum.DRAFT.getCode().equals(contractMainDO.getStatus()) if (DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.IN_PROGRESS.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.REJECTED.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_REJECTED.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.TERMINATED.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.ARCHIVED.getCode().equals(contractMainDO.getStatus()) || DictEnum.BSE_CTRT_STS_ARCHIVED.getCode().equals(contractMainDO.getStatus())
|| ContractStatusEnum.DELETED.getCode().equals(contractMainDO.getStatus())) { || DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
throw exception(CONTRACT_STATUS_NOT_APPROVAL, throw exception(CONTRACT_STATUS_NOT_APPROVAL,
ContractStatusEnum.valueOf(contractMainDO.getStatus()).getLabel()); DictEnum.valueOf(contractMainDO.getStatus()).getLabel());
} }
return ""; return "";
} }
/**
* 获取合同ID集合
*
* @param contractName 合同名称
* @param contractPaperNumber 合同编号
* @return 合同ID集合
*/
private List<Long> getContractIds(String contractName, String contractPaperNumber) { private List<Long> getContractIds(String contractName, String contractPaperNumber) {
List<Long> contractIds = new ArrayList<>(); List<Long> contractIds = new ArrayList<>();
List<ContractMainDO> contractMainDOS = contractMainMapper.selectList(new LambdaQueryWrapperX<ContractMainDO>() List<ContractMainDO> contractMainDOS = contractMainMapper.selectList(new LambdaQueryWrapperX<ContractMainDO>()
@@ -727,6 +735,169 @@ public class ContractServiceImpl implements ContractService {
return contractFormulaMapper.selectFormulas(contractIds, queryReqVO.getMaterialName(), queryReqVO.getElementName()); return contractFormulaMapper.selectFormulas(contractIds, queryReqVO.getMaterialName(), queryReqVO.getElementName());
} }
@Override
public List<ContractFormulaRespDTO> getFormulasByPaperNumber(String contractPaperNumber) {
// 通过合同编号查询合同信息
ContractMainDO contractMainDO = contractMainMapper
.selectOne(TableFieldConstants.BSE_CTRT_MAIN_CTRT_PPR_NUM, contractPaperNumber);
// 合同不存在
if (contractMainDO == null) {
throw exception(CONTRACT_NOT_EXISTS);
}
// 合同ID
Long contractId = contractMainDO.getId();
// 查询并设置价款结算条款
List<ContractFormulaRespDTO> formulas = new ArrayList<>();
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, contractId);
if (formulaDOS != null && !formulaDOS.isEmpty()) {
formulas = BeanUtils.toBean(formulaDOS, ContractFormulaRespDTO.class);
formulas.forEach(formula -> {
// 查询并设置基础系数配置
List<ContractCoefficientDO> coefficientDOS = contractCoefficientMapper
.selectList(TableFieldConstants.BSE_CTRT_COEF_FMU_ID, formula.getId());
if (coefficientDOS != null && !coefficientDOS.isEmpty()) {
formula.setCoefficients(BeanUtils.toBean(coefficientDOS, ContractCoefficientRespDTO.class));
}
// 查询并设置品位等级价配置
List<ContractGradeDO> gradeDOS = contractGradeMapper
.selectList(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formula.getId());
if (gradeDOS != null && !gradeDOS.isEmpty()) {
formula.setGrades(BeanUtils.toBean(gradeDOS, ContractGradeRespDTO.class));
}
// 查询并设置调整价配置
List<ContractDeductDO> deductDOS = contractDeductMapper
.selectList(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formula.getId());
if (deductDOS != null && !deductDOS.isEmpty()) {
formula.setDeducts(BeanUtils.toBean(deductDOS, ContractDeductRespDTO.class));
}
// 查询并设置市场价配置
List<ContractPriceDO> priceDOS = contractPriceMapper
.selectList(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formula.getId());
if (priceDOS != null && !priceDOS.isEmpty()) {
formula.setPrices(BeanUtils.toBean(priceDOS, ContractPriceRespDTO.class));
}
});
}
return formulas;
}
@Override
public void submitErp(List<Long> ids) {
// 遍历合同ID集合
ids.forEach(id -> {
// 查询合同信息
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
if (contractMainDO != null) {
// 生成ERP合同映射表
ErpContractDO erpContractDO = new ErpContractDO();
// 合同主信息表主键:BSE_CTRT_MAIN
erpContractDO.setContractMainId(id);
// 操作标识:OPTN_ID TODO
/*
1、先调用009ERP接口查询合同信息
2、如果009接口返回值中“合同编号”字段存在值并且与传入的相同则OPTN_ID值为“1”
3、如果009接口返回值中“合同编号”字段不存在值根据合同主键查询映射表中是否存在没有删除的数据如果有值为“1”如果没有值为“0”
*/
// 合同编号:CTRT_PPR_NUM
erpContractDO.setContractPaperNumber(contractMainDO.getContractPaperNumber());
// 合同名称:CTRT_NAME
erpContractDO.setContractName(contractMainDO.getContractName());
// 合同类型编号:CTRT_TP_NUM
erpContractDO.setContractTypeNumber(contractMainDO.getConstructionTypeNumber());
// 合同类型名称:CTRT_TP_NAME
erpContractDO.setContractTypeName(contractMainDO.getConstructionTypeName());
// 合同类别:CTRT_CTGR
erpContractDO.setContractCategory(contractMainDO.getCategory());
// 是否虚拟合同:IS_VRTL_CTRT
erpContractDO.setIsVirtualContract(contractMainDO.getContractVirtual());
// 客商编号:SPLR_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司编码”反之为“ERP甲方公司编码”
// erpContractDO.setSupplierNumber();
// 客商名称:SPLR_NAME 根据合同主表的收支方向判断如果为“支出”值为“ERP乙方公司名称”反之为“ERP甲方公司名称”
// erpContractDO.setSupplierName();
// 代理方:AGT
erpContractDO.setAgent(contractMainDO.getAgent());
// 合同实施主体编号:CTRT_IMPL_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司编码”反之为“ERP乙方公司编码”
// erpContractDO.setContractImplementNumber();
// 合同签订主体编号:CTRT_SGN_NUM 根据合同主表的收支方向判断如果为“支出”值为“ERP甲方公司名称”反之为“ERP乙方公司名称”
// erpContractDO.setContractSignNumber();
// 合同签订日期:SGN_DT
if (contractMainDO.getSignDate() != null) {
erpContractDO.setSignDate(contractMainDO.getSignDate().toLocalDate());
}
// 合同起始日期:STRT_DT
if (contractMainDO.getStartDate() != null) {
erpContractDO.setStartDate(contractMainDO.getStartDate().toLocalDate());
}
// 合同终止日期:STOP_DT
if (contractMainDO.getEndDate() != null) {
erpContractDO.setStopDate(contractMainDO.getEndDate().toLocalDate());
}
// 币种编号:CUR
erpContractDO.setCurrency(contractMainDO.getCurrency());
// 合同总金额(原币-含税):SRC_AMT
erpContractDO.setSourceAmount(contractMainDO.getCooAmount());
// 合同总金额(本位币-含税):BSC_AMT
erpContractDO.setBasicAmount(contractMainDO.getBasicAmount());
// 变更后合同总金额(原币-含税):CHG_SRC_AMT
erpContractDO.setChangeSourceAmount(contractMainDO.getChangeCooAmount());
// 变更后合同总金额(本位币-含税):CHG_BSC_AMT
erpContractDO.setChangeBasicAmount(contractMainDO.getChangeBasicAmount());
// 合同状态编号:STS_NUM 参照060接口
// erpContractDO.setStatusNumber();
// 合同状态名称:STS_NAME 参照060接口
// erpContractDO.setStatusName();
// 是否有预付款:IS_PPYM
erpContractDO.setIsPrepayment(contractMainDO.getHasPrepayment());
// 预付款比例:PPYM_RTIO
erpContractDO.setPrepaymentRatio(contractMainDO.getPrepaymentRatio());
// 预付款金额:PPYM_AMT
erpContractDO.setPrepaymentAmount(contractMainDO.getPrepaymentAmount());
// 履约保证金-变更前(原币):SRC_BFR_BND
erpContractDO.setSourceBeforeBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更前(本位币):BSC_BFR_BND
erpContractDO.setBasicBeforeBond(contractMainDO.getChangeBasicAmountDeposit());
// 履约保证金-变更后(原币):SRC_AFT_BND
erpContractDO.setSourceAfterBond(contractMainDO.getChangeCooAmountDeposit());
// 履约保证金-变更后(本位币):BSC_AFT_BND
erpContractDO.setBasicAfterBond(contractMainDO.getChangeBasicAmountDeposit());
// 是否含质保金:IS_QUA_AMT
erpContractDO.setIsQualityassuranceAmount(contractMainDO.getHasQualityAmount());
// 质保金比例:QUA_RTIO
erpContractDO.setQualityassuranceRatio(contractMainDO.getQualityRatio());
// 质保金金额:QUA_AMT
erpContractDO.setQualityassuranceAmount(contractMainDO.getQualityAmount());
// 是否内部企业:IS_INTL
erpContractDO.setIsInternal(contractMainDO.getIsInternal());
// 收支性质:NTR
erpContractDO.setNature(contractMainDO.getDirection());
// 备注信息:RMK
erpContractDO.setRemark(contractMainDO.getRemark());
// 是否框架合同:IS_FMWK
erpContractDO.setIsFramework(contractMainDO.getIsFramework());
// 境内/境外:IS_DOM
erpContractDO.setIsDomestic(contractMainDO.getIsDomestic());
// 达到收款条件金额:PYEE_CND_AMT
erpContractDO.setPayeeConditionAmount(contractMainDO.getPayeeConditionAmount());
// 建筑服务发生地:ARCH_SVC_PLCE
erpContractDO.setArchitectureServicePlace(contractMainDO.getArchitectureServicePlace());
// 调用ERP模块
}
});
}
/** /**
* 校验合同内容 * 校验合同内容
* *
@@ -818,7 +989,7 @@ public class ContractServiceImpl implements ContractService {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_DPST_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_DPST_LABEL);
} }
// 是否有履约保证金为是的情况 // 是否有履约保证金为是的情况
if (ErpCtrtYesNoEnum.YES.getCode().equals(contract.getHasDeposit())) { if (DictEnum.ERP_CTRT_YN_YES.getCode().equals(contract.getHasDeposit())) {
// 原币履约保证金不能为空 // 原币履约保证金不能为空
if (contract.getCooAmountDeposit() == null) { if (contract.getCooAmountDeposit() == null) {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_COO_AMT_DPST_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_COO_AMT_DPST_LABEL);
@@ -833,7 +1004,7 @@ public class ContractServiceImpl implements ContractService {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_PPYM_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_PPYM_LABEL);
} }
// 是否有预付款为是的情况 // 是否有预付款为是的情况
if (ErpCtrtYesNoEnum.YES.getCode().equals(contract.getHasPrepayment())) { if (DictEnum.ERP_CTRT_YN_YES.getCode().equals(contract.getHasPrepayment())) {
// 预付款比例不能为空 // 预付款比例不能为空
if (contract.getPrepaymentRatio() == null) { if (contract.getPrepaymentRatio() == null) {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_PPYM_RTIO_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_PPYM_RTIO_LABEL);
@@ -848,7 +1019,7 @@ public class ContractServiceImpl implements ContractService {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_QLT_AMT_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_HS_QLT_AMT_LABEL);
} }
// 是否有质保金为是的情况 // 是否有质保金为是的情况
if (ErpCtrtYesNoEnum.YES.getCode().equals(contract.getHasPrepayment())) { if (DictEnum.ERP_CTRT_YN_YES.getCode().equals(contract.getHasPrepayment())) {
// 质保金比例不能为空 // 质保金比例不能为空
if (contract.getQualityRatio() == null) { if (contract.getQualityRatio() == null) {
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_QLT_RTIO_LABEL); throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_QLT_RTIO_LABEL);

View File

@@ -1,15 +1,18 @@
package com.zt.plat.module.erp.api; package com.zt.plat.module.erp.api;
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO; import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
import com.zt.plat.module.erp.enums.ApiConstants; import com.zt.plat.module.erp.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
@FeignClient(name = ApiConstants.NAME) @FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - ERP") @Tag(name = "RPC 服务 - ERP")
@@ -21,4 +24,8 @@ public interface ErpExternalApi {
@Operation(summary = "erp数据提交") @Operation(summary = "erp数据提交")
HashMap<String, String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO); HashMap<String, String> submitDataToErp(@Valid @RequestBody ErpSubmitReqDTO reqDTO);
@GetMapping(PREFIX + "/query")
@Operation(summary = "erp数据查询")
HashMap<String, Object> queryDataToErp(@Valid @RequestBody ErpQueryReqDTO reqDTO);
} }

View File

@@ -0,0 +1,21 @@
package com.zt.plat.module.erp.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Map;
@Schema(description = "RPC 服务 - 查询 ERP DTO")
@Data
public class ErpQueryReqDTO {
/**
* 调用ERP接口查询erp数据
*
* 请求参数说明:
* "funcnr": 接口编号必须参见RFC功能列表可调用接口编号范围001-021
* "req": {具体参数参见RFC功能列表}
*/
private String funcnr;
private Map<String, Object> req;
}

View File

@@ -13,6 +13,10 @@ public interface ErrorCodeConstants {
ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在"); ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在");
ErrorCode ERP_MATERIAL_NOT_EXISTS = new ErrorCode(1_002_000_001, "ERP物料数据不存在"); 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”的数据");
ErrorCode ERP_MATERIAL_OTHER_NOT_ALLOW_DELETE = new ErrorCode(1_002_000_004, "只允许删除不存在配置关系的数据");
ErrorCode ERP_MATERIAL_EXISTS = new ErrorCode(1_002_000_005, "已存在相同中铜编码的物料数据");
ErrorCode ERP_COMPANY_NOT_EXISTS = new ErrorCode(1_003_000_001, "ERP公司数据不存在"); ErrorCode ERP_COMPANY_NOT_EXISTS = new ErrorCode(1_003_000_001, "ERP公司数据不存在");
ErrorCode ERP_COMPANY_REDIS_NOT_EXISTS = new ErrorCode(1_003_000_002, "ERP公司代码缓存数据丢失,请重新同步公司代码"); ErrorCode ERP_COMPANY_REDIS_NOT_EXISTS = new ErrorCode(1_003_000_002, "ERP公司代码缓存数据丢失,请重新同步公司代码");
@@ -28,6 +32,7 @@ public interface ErrorCodeConstants {
ErrorCode ERP_FACTORY_NOT_EXISTS = new ErrorCode(1_008_000_001, "ERP工厂数据不存在"); ErrorCode ERP_FACTORY_NOT_EXISTS = new ErrorCode(1_008_000_001, "ERP工厂数据不存在");
ErrorCode ERP_FACTORY_REDIS_NOT_EXISTS = new ErrorCode(1_008_000_002, "ERP工厂redis数据不存在"); ErrorCode ERP_FACTORY_REDIS_NOT_EXISTS = new ErrorCode(1_008_000_002, "ERP工厂redis数据不存在");
ErrorCode ERP_FACTORY_NOT_ALLOW_UPDATE = new ErrorCode(1_008_000_003, "类型为ERP的数据或启用的数据不允许编辑"); ErrorCode ERP_FACTORY_NOT_ALLOW_UPDATE = new ErrorCode(1_008_000_003, "类型为ERP的数据或启用的数据不允许编辑");
ErrorCode ERP_FACTORY_EXISTS = new ErrorCode(1_008_000_004, "工厂编码重复,数据已存在");
ErrorCode ERP_COSTCENTER_NOT_EXISTS = new ErrorCode(1_009_000_001, "ERP成本中心数据不存在"); ErrorCode ERP_COSTCENTER_NOT_EXISTS = new ErrorCode(1_009_000_001, "ERP成本中心数据不存在");
@@ -40,6 +45,8 @@ public interface ErrorCodeConstants {
ErrorCode ERP_SALES_ORGANIZATION_NOT_EXISTS = new ErrorCode(1_013_000_001, "ERP销售组织数据不存在"); ErrorCode ERP_SALES_ORGANIZATION_NOT_EXISTS = new ErrorCode(1_013_000_001, "ERP销售组织数据不存在");
ErrorCode ERP_WAREHOUSE_NOT_EXISTS = new ErrorCode(1_014_000_001, "ERP库位数据不存在"); ErrorCode ERP_WAREHOUSE_NOT_EXISTS = new ErrorCode(1_014_000_001, "ERP库位数据不存在");
ErrorCode ERP_WAREHOUSE_NOT_ALLOW_UPDATE = new ErrorCode(1_014_000_002, "只允许状态为“供应链”,且“禁用”的数据编辑");
ErrorCode ERP_WAREHOUSE_EXISTS = new ErrorCode(1_014_000_003, "已存在相同库位编码和工厂编码的记录");
ErrorCode ERP_ASSET_NOT_EXISTS = new ErrorCode(1_015_000_001, "ERP资产卡片数据不存在"); ErrorCode ERP_ASSET_NOT_EXISTS = new ErrorCode(1_015_000_001, "ERP资产卡片数据不存在");

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.erp.api; package com.zt.plat.module.erp.api;
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO; import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
import com.zt.plat.module.erp.utils.ErpConfig; import com.zt.plat.module.erp.utils.ErpConfig;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@@ -7,6 +8,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* ERP Api 实现类 * ERP Api 实现类
@@ -25,4 +27,11 @@ public class ErpExternalApiImpl implements ErpExternalApi {
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) { public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
return erpConfig.pushDataToErp(reqDTO); return erpConfig.pushDataToErp(reqDTO);
} }
@Override
public HashMap<String, Object> queryDataToErp(ErpQueryReqDTO reqDTO) {
String funcnr = reqDTO.getFuncnr();
Map<String, Object> req = new HashMap<>();
return erpConfig.fetchDataFromERP(funcnr, req);
}
} }

View File

@@ -88,14 +88,6 @@ public class ErpFactoryController {
return success(BeanUtils.toBean(pageResult, ErpFactoryRespVO.class)); return success(BeanUtils.toBean(pageResult, ErpFactoryRespVO.class));
} }
@GetMapping("/pageByCpn")
@Operation(summary = "获得ERP工厂分页")
@PreAuthorize("@ss.hasPermission('base:erp-factory:query')")
public CommonResult<PageResult<ErpFactoryRespVO>> getErpFactoryPageByCpn(@Valid ErpFactoryPageReqVO pageReqVO) {
PageResult<ErpFactoryDO> pageResult = erpFactoryService.getErpFactoryPageByCpn(pageReqVO);
return success(BeanUtils.toBean(pageResult, ErpFactoryRespVO.class));
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出ERP工厂 Excel") @Operation(summary = "导出ERP工厂 Excel")
@PreAuthorize("@ss.hasPermission('base:erp-factory:export')") @PreAuthorize("@ss.hasPermission('base:erp-factory:export')")

View File

@@ -101,6 +101,14 @@ public class ErpWarehouseController {
BeanUtils.toBean(list, ErpWarehouseRespVO.class)); BeanUtils.toBean(list, ErpWarehouseRespVO.class));
} }
@PutMapping("/enable-list")
@Operation(summary = "批量更新")
@PreAuthorize("@ss.hasPermission('base:warehouse:update')")
public CommonResult<Boolean> enableWarehouseList(@RequestBody List<ErpWarehouseSaveReqVO> saveReqVOS) {
erpWarehouseService.enableWarehouseList(saveReqVOS);
return success(true);
}
@PostMapping("/getErpWarehouseTask") @PostMapping("/getErpWarehouseTask")
@Operation(summary = "定时获得erp更新库位") @Operation(summary = "定时获得erp更新库位")
@PreAuthorize("@ss.hasPermission('sply:erp-warehouse:create')") @PreAuthorize("@ss.hasPermission('sply:erp-warehouse:create')")

View File

@@ -16,10 +16,10 @@ public class ErpFactoryPageReqVO extends PageParam {
private String number; private String number;
@Schema(description = "公司编号") @Schema(description = "公司编号")
private String companyNumber; private String erpCompanyNumber;
@Schema(description = "公司名称") @Schema(description = "公司名称")
private String companyName; private String erpCompanyName;
@Schema(description = "类型") @Schema(description = "类型")
private String type; private String type;

View File

@@ -23,7 +23,10 @@ public class ErpFactoryRespVO {
private String number; private String number;
@Schema(description = "公司编号") @Schema(description = "公司编号")
private String companyNumber; private String erpCompanyNumber;
@Schema(description = "公司编号")
private String erpCompanyName;
@Schema(description = "类型") @Schema(description = "类型")
private String type; private String type;

View File

@@ -20,10 +20,7 @@ public class ErpFactorySaveReqVO {
private String number; private String number;
@Schema(description = "公司编号") @Schema(description = "公司编号")
private String companyNumber; private String erpCompanyNumber;
@Schema(description = "公司编号")
private String companyName;
@Schema(description = "类型") @Schema(description = "类型")
private String type; private String type;

View File

@@ -8,6 +8,9 @@ import lombok.Data;
@Data @Data
public class ErpWarehousePageReqVO extends PageParam { public class ErpWarehousePageReqVO extends PageParam {
@Schema(description = "工厂名称")
private String factoryName;
@Schema(description = "工厂编码;将查询参数存入") @Schema(description = "工厂编码;将查询参数存入")
private String factoryNumber; private String factoryNumber;
@@ -17,4 +20,8 @@ public class ErpWarehousePageReqVO extends PageParam {
@Schema(description = "库位编码") @Schema(description = "库位编码")
private String number; private String number;
@Schema(description = "类型")
private String type;
} }

View File

@@ -2,6 +2,7 @@ package com.zt.plat.module.erp.controller.admin.erp.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -18,6 +19,9 @@ public class ErpWarehouseRespVO {
@ExcelProperty("工厂编码;将查询参数存入") @ExcelProperty("工厂编码;将查询参数存入")
private String factoryNumber; private String factoryNumber;
@Schema(description = "工厂名称")
private String factoryName;
@Schema(description = "库位描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") @Schema(description = "库位描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ExcelProperty("库位描述") @ExcelProperty("库位描述")
private String name; private String name;
@@ -26,4 +30,16 @@ public class ErpWarehouseRespVO {
@ExcelProperty("库位编码") @ExcelProperty("库位编码")
private String number; private String number;
@Schema(description = "类别")
private String type;
@Schema(description = "绑定库位名")
private String relName;
@Schema(description = "绑定库位编码")
private String relnumber;
@Schema(description = "是否启用")
private String isEnable;
} }

View File

@@ -22,4 +22,16 @@ public class ErpWarehouseSaveReqVO {
@NotEmpty(message = "库位编码不能为空") @NotEmpty(message = "库位编码不能为空")
private String number; private String number;
@Schema(description = "类别")
private String type;
@Schema(description = "绑定库位名")
private String relName;
@Schema(description = "绑定库位编码")
private String relnumber;
@Schema(description = "是否启用")
private String isEnable;
} }

View File

@@ -41,13 +41,13 @@ public class ErpFactoryDO extends BusinessBaseDO {
* 公司编号 * 公司编号
*/ */
@TableField("CPN_ID") @TableField("CPN_ID")
private String companyNumber; private String erpCompanyNumber;
/** /**
* 公司名称 * 公司名称
*/ */
@TableField(exist = false) @TableField(exist = false)
private String companyName; private String erpCompanyName;
/** /**
* 类型 * 类型

View File

@@ -1,6 +1,7 @@
package com.zt.plat.module.erp.dal.dataobject.erp; package com.zt.plat.module.erp.dal.dataobject.erp;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
import lombok.*; import lombok.*;
/** /**
* ERP库位 DO * ERP库位 DO
@@ -18,7 +19,7 @@ import lombok.*;
/** /**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO * 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/ */
public class ErpWarehouseDO { public class ErpWarehouseDO extends BusinessBaseDO {
/** /**
* 主键 * 主键
@@ -30,6 +31,11 @@ public class ErpWarehouseDO {
*/ */
@TableField("FACT_NUM") @TableField("FACT_NUM")
private String factoryNumber; private String factoryNumber;
/**
* 工厂名称;将查询参数存入
*/
@TableField(exist = false)
private String factoryName;
/** /**
* 库位描述 * 库位描述
*/ */
@@ -47,4 +53,22 @@ public class ErpWarehouseDO {
@TableField("TP") @TableField("TP")
private String type; private String type;
/**
* 绑定库位名
*/
@TableField("REL_NAME")
private String relName;
/**
* 绑定库位编码
*/
@TableField("REL_NUM")
private String relnumber;
/**
* 类型
*/
@TableField("IS_ENB")
private String isEnable;
} }

View File

@@ -18,14 +18,6 @@ import java.util.List;
@Mapper @Mapper
public interface ErpFactoryMapper extends BaseMapperX<ErpFactoryDO> { public interface ErpFactoryMapper extends BaseMapperX<ErpFactoryDO> {
default PageResult<ErpFactoryDO> selectPage(ErpFactoryPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ErpFactoryDO>()
.likeIfPresent(ErpFactoryDO::getName, reqVO.getName())
.eqIfPresent(ErpFactoryDO::getNumber, reqVO.getNumber())
.eqIfPresent(ErpFactoryDO::getType, reqVO.getType())
.orderByDesc(ErpFactoryDO::getId));
}
String selectMaxCode(); String selectMaxCode();
List<ErpFactoryDO> getPageByReq(ErpFactoryPageReqVO pageReqVO); List<ErpFactoryDO> getPageByReq(ErpFactoryPageReqVO pageReqVO);

View File

@@ -37,4 +37,8 @@ public interface ErpMaterialMapper extends BaseMapperX<ErpMaterialDO> {
} }
void updateBatchByNumber(@Param("toUpdate") List<ErpMaterialDO> toUpdate); void updateBatchByNumber(@Param("toUpdate") List<ErpMaterialDO> toUpdate);
String selectMaxCode();
Integer selectByErpMNumbers(List<String> erpMNumber);
} }

View File

@@ -7,6 +7,8 @@ import com.zt.plat.module.erp.controller.admin.erp.vo.ErpWarehousePageReqVO;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO; import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* ERP库位 Mapper * ERP库位 Mapper
* *
@@ -15,13 +17,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface ErpWarehouseMapper extends BaseMapperX<ErpWarehouseDO> { public interface ErpWarehouseMapper extends BaseMapperX<ErpWarehouseDO> {
default PageResult<ErpWarehouseDO> selectPage(ErpWarehousePageReqVO reqVO) { String selectMaxCode();
return selectPage(reqVO, new LambdaQueryWrapperX<ErpWarehouseDO>()
.eqIfPresent(ErpWarehouseDO::getFactoryNumber, reqVO.getFactoryNumber())
.likeIfPresent(ErpWarehouseDO::getName, reqVO.getName())
// .betweenIfPresent(ErpWarehouseDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(ErpWarehouseDO::getNumber, reqVO.getNumber())
.orderByDesc(ErpWarehouseDO::getId));
}
List<ErpWarehouseDO> getPageByReq(ErpWarehousePageReqVO pageReqVO);
} }

View File

@@ -0,0 +1,9 @@
package com.zt.plat.module.erp.job;
public class erpJob {
public void execute() throws Exception {
// TODO Auto-generated method stub
}
}

View File

@@ -64,6 +64,4 @@ public interface ErpFactoryService {
void callErpRfcInterface(); void callErpRfcInterface();
void enableFactoryList(List<ErpFactoryRespVO> saveReqVOS); void enableFactoryList(List<ErpFactoryRespVO> saveReqVOS);
PageResult<ErpFactoryDO> getErpFactoryPageByCpn(ErpFactoryPageReqVO pageReqVO);
} }

View File

@@ -50,6 +50,8 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
@Override @Override
public ErpFactoryRespVO createErpFactory(ErpFactorySaveReqVO createReqVO) { public ErpFactoryRespVO createErpFactory(ErpFactorySaveReqVO createReqVO) {
// 校验存在
validateErpFactoryExistsNumber(createReqVO.getNumber());
// 插入 // 插入
ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class); ErpFactoryDO erpFactory = BeanUtils.toBean(createReqVO, ErpFactoryDO.class);
// 工厂编码自动生成,格式 GC-0001,依次新增 // 工厂编码自动生成,格式 GC-0001,依次新增
@@ -65,7 +67,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
erpFactory.setNumber(nextCode); erpFactory.setNumber(nextCode);
} }
} }
erpFactory.setType("供应链"); erpFactory.setType("SPLY");
erpFactory.setIsEnable("1"); erpFactory.setIsEnable("1");
erpFactoryMapper.insert(erpFactory); erpFactoryMapper.insert(erpFactory);
// 返回 // 返回
@@ -113,6 +115,14 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
} }
} }
private void validateErpFactoryExistsNumber(String number) {
List<ErpFactoryDO> list = erpFactoryMapper.selectList(new LambdaQueryWrapperX<ErpFactoryDO>())
.stream().filter(erpFactoryDO -> erpFactoryDO.getNumber().equals(number)).toList();
if (!list.isEmpty()) {
throw exception(ERP_FACTORY_EXISTS);
}
}
@Override @Override
public ErpFactoryDO getErpFactory(Long id) { public ErpFactoryDO getErpFactory(Long id) {
return erpFactoryMapper.selectById(id); return erpFactoryMapper.selectById(id);
@@ -120,20 +130,6 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
@Override @Override
public PageResult<ErpFactoryDO> getErpFactoryPage(ErpFactoryPageReqVO pageReqVO) { public PageResult<ErpFactoryDO> getErpFactoryPage(ErpFactoryPageReqVO pageReqVO) {
return erpFactoryMapper.selectPage(pageReqVO);
}
@Override
public void enableFactoryList(List<ErpFactoryRespVO> saveReqVOS) {
List<ErpFactoryDO> updateObj = BeanUtils.toBean(saveReqVOS, ErpFactoryDO.class);
List<BatchResult> count = erpFactoryMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
}
@Override
public PageResult<ErpFactoryDO> getErpFactoryPageByCpn(ErpFactoryPageReqVO pageReqVO) {
// 获取分页数据 // 获取分页数据
List<ErpFactoryDO> list = erpFactoryMapper.getPageByReq(pageReqVO); List<ErpFactoryDO> list = erpFactoryMapper.getPageByReq(pageReqVO);
if (list == null) { if (list == null) {
@@ -155,6 +151,15 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
return new PageResult<>(pageList, (long) total); return new PageResult<>(pageList, (long) total);
} }
@Override
public void enableFactoryList(List<ErpFactoryRespVO> saveReqVOS) {
List<ErpFactoryDO> updateObj = BeanUtils.toBean(saveReqVOS, ErpFactoryDO.class);
List<BatchResult> count = erpFactoryMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) {
throw exception(ERP_FACTORY_NOT_EXISTS);
}
}
@Override @Override
@Transactional @Transactional
@XxlJob("getErpFactoryTask") @XxlJob("getErpFactoryTask")
@@ -170,7 +175,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
// 1. 调用ERP接口获取数据 // 1. 调用ERP接口获取数据
Map<String, Object> req = new HashMap<>(); Map<String, Object> req = new HashMap<>();
JSONArray dataArrayALL = new JSONArray(); JSONArray dataArrayALL = new JSONArray();
String companykey = "erp" + OftenEnum.FuncnrEnum.公司代码.getFuncnr(); String companykey = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey); Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
if (CollUtil.isEmpty(redisCache)) { if (CollUtil.isEmpty(redisCache)) {
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS); throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
@@ -225,7 +230,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
ErpFactoryDO DO = new ErpFactoryDO(); ErpFactoryDO DO = new ErpFactoryDO();
DO.setName(dataJson.getString("NAME1")); DO.setName(dataJson.getString("NAME1"));
DO.setNumber(number); DO.setNumber(number);
DO.setCompanyNumber(dataJson.getString("BUKRS")); DO.setErpCompanyNumber(dataJson.getString("BUKRS"));
DO.setType("ERP"); DO.setType("ERP");
if (numbers.get(number)!=null) { if (numbers.get(number)!=null) {
// 更新 // 更新

View File

@@ -7,6 +7,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
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.ErpConfig;
import com.zt.plat.module.erp.utils.MyRedisConfig; import com.zt.plat.module.erp.utils.MyRedisConfig;
import com.zt.plat.module.erp.enums.OftenEnum; import com.zt.plat.module.erp.enums.OftenEnum;
@@ -29,8 +30,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_INTERNAL_ORDER_NOT_EXISTS; import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_MATERIAL_NOT_EXISTS;
import static dm.jdbc.util.DriverUtil.log; import static dm.jdbc.util.DriverUtil.log;
/** /**
@@ -51,8 +51,24 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
@Override @Override
public ErpMaterialRespVO createErpMaterial(ErpMaterialSaveReqVO createReqVO) { public ErpMaterialRespVO createErpMaterial(ErpMaterialSaveReqVO createReqVO) {
// 校验存在
validateErpFactoryExistsNumber(createReqVO.getDownCenterNumber());
// 插入 // 插入
ErpMaterialDO erpMaterial = BeanUtils.toBean(createReqVO, ErpMaterialDO.class); ErpMaterialDO erpMaterial = BeanUtils.toBean(createReqVO, ErpMaterialDO.class);
// 工厂编码自动生成,格式 GC-0001,依次新增
if (erpMaterial.getDownCenterNumber() == null) {
String maxCode = erpMaterialMapper.selectMaxCode();
if (maxCode == null) {
erpMaterial.setDownCenterNumber("WL-0001");
} else {
String prefix = "WL-";
String numberPart = maxCode.substring(prefix.length());
int nextNumber = Integer.parseInt(numberPart) + 1;
String nextCode = prefix + String.format("%04d", nextNumber);
erpMaterial.setDownCenterNumber(nextCode);
}
}
erpMaterial.setType("SPLY");
erpMaterialMapper.insert(erpMaterial); erpMaterialMapper.insert(erpMaterial);
// 返回 // 返回
return BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class); return BeanUtils.toBean(erpMaterial, ErpMaterialRespVO.class);
@@ -64,7 +80,11 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
validateErpMaterialExists(updateReqVO.getId()); validateErpMaterialExists(updateReqVO.getId());
// 更新 // 更新
ErpMaterialDO updateObj = BeanUtils.toBean(updateReqVO, ErpMaterialDO.class); ErpMaterialDO updateObj = BeanUtils.toBean(updateReqVO, ErpMaterialDO.class);
if (updateObj.getType().equals("SPLY")) {
erpMaterialMapper.updateById(updateObj); erpMaterialMapper.updateById(updateObj);
} else {
throw exception(ERP_MATERIAL_NOT_ALLOW_UPDATE);
}
} }
@Override @Override
@@ -88,6 +108,22 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
if (CollUtil.isEmpty(list) || list.size() != ids.size()) { if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(ERP_MATERIAL_NOT_EXISTS); throw exception(ERP_MATERIAL_NOT_EXISTS);
} }
List<ErpMaterialDO> erpMaterialDOList = list.stream()
.filter(erpMaterialDO -> erpMaterialDO.getType().equals("ERP"))
.collect(Collectors.toList());
if (CollUtil.isEmpty(erpMaterialDOList)) {
throw exception(ERP_MATERIAL_NOT_ALLOW_DELETE);
}
// 优化成批量查询使用IN语句
List<String> downCenterNumbers = list.stream()
.map(ErpMaterialDO::getDownCenterNumber)
.collect(Collectors.toList());
// 使用IN语句批量查询所有物料编码的数量
Integer countMap = erpMaterialMapper.selectByErpMNumbers(downCenterNumbers);
if (countMap > 1) {
throw exception(ERP_MATERIAL_OTHER_NOT_ALLOW_DELETE);
}
} }
private void validateErpMaterialExists(Long id) { private void validateErpMaterialExists(Long id) {
@@ -96,6 +132,15 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
} }
} }
private void validateErpFactoryExistsNumber(String number) {
List<ErpMaterialDO> list = erpMaterialMapper.selectList(new LambdaQueryWrapperX<ErpMaterialDO>()).stream()
.filter(erpWarehouseDO -> erpWarehouseDO.getDownCenterNumber().equals(number))
.toList();
if (!list.isEmpty()) {
throw exception(ERP_MATERIAL_EXISTS);
}
}
@Override @Override
public ErpMaterialDO getErpMaterial(Long id) { public ErpMaterialDO getErpMaterial(Long id) {
return erpMaterialMapper.selectById(id); return erpMaterialMapper.selectById(id);

View File

@@ -62,4 +62,6 @@ public interface ErpWarehouseService {
PageResult<ErpWarehouseDO> getErpWarehousePage(ErpWarehousePageReqVO pageReqVO); PageResult<ErpWarehouseDO> getErpWarehousePage(ErpWarehousePageReqVO pageReqVO);
void callErpRfcInterface(); void callErpRfcInterface();
void enableWarehouseList(List<ErpWarehouseSaveReqVO> saveReqVOS);
} }

View File

@@ -7,6 +7,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpFactoryDO;
import com.zt.plat.module.erp.utils.ErpConfig; import com.zt.plat.module.erp.utils.ErpConfig;
import com.zt.plat.module.erp.utils.MyRedisConfig; import com.zt.plat.module.erp.utils.MyRedisConfig;
import com.zt.plat.module.erp.enums.OftenEnum; import com.zt.plat.module.erp.enums.OftenEnum;
@@ -16,6 +17,7 @@ import com.zt.plat.module.erp.controller.admin.erp.vo.ErpWarehouseSaveReqVO;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO; import com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO;
import com.zt.plat.module.erp.dal.mysql.erp.ErpWarehouseMapper; import com.zt.plat.module.erp.dal.mysql.erp.ErpWarehouseMapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.ibatis.executor.BatchResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -49,11 +51,28 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
@Override @Override
public ErpWarehouseRespVO createErpWarehouse(ErpWarehouseSaveReqVO createReqVO) { public ErpWarehouseRespVO createErpWarehouse(ErpWarehouseSaveReqVO createReqVO) {
// 校验存在
validateErpFactoryExistsNumber(createReqVO.getNumber(), createReqVO.getFactoryNumber());
// 插入 // 插入
ErpWarehouseDO erpWarehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class); ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class);
erpWarehouseMapper.insert(erpWarehouse); // 库位编码自动生成,格式 KW-0001,依次新增
if (warehouse.getNumber() == null) {
String maxCode = erpWarehouseMapper.selectMaxCode();
if (maxCode == null) {
warehouse.setNumber("KW-0001");
} else {
String prefix = "KW-";
String numberPart = maxCode.substring(prefix.length());
int nextNumber = Integer.parseInt(numberPart) + 1;
String nextCode = prefix + String.format("%04d", nextNumber);
warehouse.setNumber(nextCode);
}
}
warehouse.setType("SPLY");
warehouse.setIsEnable("1");
erpWarehouseMapper.insert(warehouse);
// 返回 // 返回
return BeanUtils.toBean(erpWarehouse, ErpWarehouseRespVO.class); return BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class);
} }
@Override @Override
@@ -62,7 +81,11 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
validateErpWarehouseExists(updateReqVO.getId()); validateErpWarehouseExists(updateReqVO.getId());
// 更新 // 更新
ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class); ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class);
if (updateObj.getType().equals("SPLY") && updateObj.getIsEnable().equals("0")) {
erpWarehouseMapper.updateById(updateObj); erpWarehouseMapper.updateById(updateObj);
} else {
throw exception(ERP_WAREHOUSE_NOT_ALLOW_UPDATE);
}
} }
@Override @Override
@@ -94,14 +117,52 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
} }
} }
private void validateErpFactoryExistsNumber(String number, String factoryNumber) {
List<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).stream()
.filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number))
.filter(erpWarehouseDO -> erpWarehouseDO.getFactoryNumber().equals(factoryNumber))
.toList();
if (!list.isEmpty()) {
throw exception(ERP_WAREHOUSE_EXISTS);
}
}
@Override @Override
public ErpWarehouseDO getErpWarehouse(Long id) { public ErpWarehouseDO getErpWarehouse(Long id) {
return erpWarehouseMapper.selectById(id); return erpWarehouseMapper.selectById(id);
} }
@Override
public void enableWarehouseList(List<ErpWarehouseSaveReqVO> saveReqVOS) {
List<ErpWarehouseDO> updateObj = BeanUtils.toBean(saveReqVOS, ErpWarehouseDO.class);
List<BatchResult> count = erpWarehouseMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) {
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
}
}
@Override @Override
public PageResult<ErpWarehouseDO> getErpWarehousePage(ErpWarehousePageReqVO pageReqVO) { public PageResult<ErpWarehouseDO> getErpWarehousePage(ErpWarehousePageReqVO pageReqVO) {
return erpWarehouseMapper.selectPage(pageReqVO); // 获取分页数据
List<ErpWarehouseDO> list = erpWarehouseMapper.getPageByReq(pageReqVO);
if (list == null) {
list = CollUtil.newArrayList();
}
// 分页处理
int pageNo = pageReqVO.getPageNo();
int pageSize = pageReqVO.getPageSize();
int total = list.size();
// 计算分页起始和结束位置
int fromIndex = (pageNo - 1) * pageSize;
int toIndex = Math.min(fromIndex + pageSize, total);
// 如果起始位置超出范围,则返回空列表
if (fromIndex >= total) {
return new PageResult<>(new ArrayList<>(), (long) total);
}
// 截取当前页数据
List<ErpWarehouseDO> pageList = list.subList(fromIndex, toIndex);
return new PageResult<>(pageList, (long) total);
} }
@Override @Override

View File

@@ -5,10 +5,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO; import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@@ -16,7 +14,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*; import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
@@ -25,7 +22,6 @@ import static dm.jdbc.util.DriverUtil.log;
@Configuration @Configuration
public class ErpConfig { public class ErpConfig {
@Value("${erp.address}") @Value("${erp.address}")
private String erpAddress; private String erpAddress;

View File

@@ -10,27 +10,35 @@
--> -->
<select id="getPageByReq" resultType="com.zt.plat.module.erp.dal.dataobject.erp.ErpFactoryDO"> <select id="getPageByReq" resultType="com.zt.plat.module.erp.dal.dataobject.erp.ErpFactoryDO">
select f.*, c.NAME as companyName select f.id,
from sply_erp_fact f left join sply_erp_company c on f.CPN_ID = c.NUM; f.name as name,
f.NUM as number,
f.CPN_ID as erpCompanyNumber,
f.TP as type,
f.REL_NAME as relName,
f.REL_NUM as relnumber,
f.IS_ENB as isEnable,
c.NAME as erpCompanyName
from sply_erp_fact f left join sply_erp_cpn c on f.CPN_ID = c.NUM
where f.DELETED = 0 where f.DELETED = 0
<if test="reqVO.name != null"> <if test="name != null">
and f.NAME like concat('%', #{reqVO.name}, '%') and f.NAME like concat('%', #{name}, '%')
</if> </if>
<if test="reqVO.number != null"> <if test="number != null">
and f.NUM like concat('%', #{reqVO.number}, '%') and f.NUM like concat('%', #{number}, '%')
</if> </if>
<if test="reqVO.companyNumber != null"> <if test="erpCompanyNumber != null">
and f.CPN_ID = like concat('%', #{reqVO.companyNumber}, '%') and f.CPN_ID like concat('%', #{erpCompanyNumber}, '%')
</if> </if>
<if test="reqVO.companyName != null"> <if test="erpCompanyName != null">
and c.NAME like concat('%', #{reqVO.companyName}, '%') and c.NAME like concat('%', #{erpCompanyName}, '%')
</if> </if>
<if test="reqVO.type != null"> <if test="type != null">
and f.TP like concat('%', #{reqVO.type}, '%') and f.TP like concat('%', #{type}, '%')
</if> </if>
</select> </select>
<select id="selectMaxCode" resultType="java.lang.String"> <select id="selectMaxCode" resultType="java.lang.String">
SELECT MAX(NUM) FROM sply_erp_fact where TP = '供应链' SELECT MAX(NUM) FROM sply_erp_fact
</select> </select>
</mapper> </mapper>

View File

@@ -33,5 +33,21 @@
WHERE DOWN_CTR_NUM = #{item.downCenterNumber} WHERE DOWN_CTR_NUM = #{item.downCenterNumber}
</foreach> </foreach>
</update> </update>
<select id="selectMaxCode" resultType="java.lang.String">
SELECT MAX(MTRL_CODE) FROM SPLY_ERP_MTRL
</select>
<select id="selectByErpMId">
SELECT * FROM SPLY_ERP_MTRL WHERE MTRL_ID = #{erpMId}
</select>
<select id="selectByErpMNumbers" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM sply_mtrl_oth
WHERE ERP_MTRL_NUM IN
<foreach item="erpMNumber" collection="erpMNumbers" open="(" separator="," close=")">
#{erpMNumber}
</foreach>
</select>
</mapper> </mapper>

View File

@@ -9,4 +9,36 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<select id="selectMaxCode" resultType="java.lang.String">
SELECT MAX(NUM) FROM sply_erp_wrh
</select>
<select id="getPageByReq" resultType="com.zt.plat.module.erp.dal.dataobject.erp.ErpWarehouseDO">
select f.id,
f.name as name,
f.NUM as number,
f.TP as type,
f.REL_NAME as relName,
f.REL_NUM as relnumber,
f.IS_ENB as isEnable,
f.FACT_NUM as factoryNumber,
c.NAME as factoryName
from sply_erp_wrh f left join sply_erp_fact c on f.FACT_NUM = c.NUM
where f.DELETED = 0
<if test="name != null">
and f.NAME like concat('%', #{name}, '%')
</if>
<if test="number != null">
and f.NUM like concat('%', #{number}, '%')
</if>
<if test="factoryNumber != null">
and f.FACT_NUM like concat('%', #{factoryNumber}, '%')
</if>
<if test="factoryName != null">
and c.NAME like concat('%', #{factoryName}, '%')
</if>
<if test="type != null">
and f.TP like concat('%', #{type}, '%')
</if>
</select>
</mapper> </mapper>