Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -65,3 +65,7 @@ spec:
|
||||
port: 48100
|
||||
targetPort: 48100
|
||||
nodePort: 30097
|
||||
- protocol: TCP
|
||||
port: 9999
|
||||
targetPort: 9999
|
||||
nodePort: 30197
|
||||
|
||||
@@ -17,6 +17,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CONTRACT_PAPER_NUMBER_EXISTS = new ErrorCode(1_027_000_002, "合同编号已存在");
|
||||
ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_027_000_003, "合同不存在");
|
||||
ErrorCode CONTRACT_ID_NOT_EXISTS = new ErrorCode(1_027_000_004, "合同主键为空");
|
||||
ErrorCode CONTRACT_STATUS_NOT_UPDATE = new ErrorCode(1_027_000_005, "{}合同不允许修改");
|
||||
ErrorCode CONTRACT_STATUS_NOT_UPDATE = new ErrorCode(1_027_000_005, "{}状态合同不允许修改");
|
||||
ErrorCode CONTRACT_DATA_NOT_EXISTS = new ErrorCode(1_027_000_006, "{}不存在");
|
||||
ErrorCode CONTRACT_STATUS_NOT_SUBMIT_APPROVAL = new ErrorCode(1_027_000_007, "{}状态合同不允许提交审核");
|
||||
ErrorCode CONTRACT_STATUS_NOT_APPROVAL = new ErrorCode(1_027_000_008, "{}状态合同不允许审核");
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ public class TableFieldConstants {
|
||||
public static final String BSE_CTRT_PLN_CTRT_DTL_ID = "CTRT_DTL_ID";
|
||||
|
||||
/* 价款结算条款表 */
|
||||
// 合同明细主键
|
||||
public static final String BSE_CTRT_FMU_CTRT_DTL_ID = "CTRT_DTL_ID";
|
||||
// 合同主键
|
||||
public static final String BSE_CTRT_FMU_CTRT_ID = "CTRT_ID";
|
||||
|
||||
/* 基础系数配置表 */
|
||||
// 条款主键
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.zt.plat.module.contractorder.controller.admin.contract;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractPageReqVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractRespVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractSaveReqVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractViewRespVO;
|
||||
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.service.contract.ContractService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -43,9 +41,9 @@ public class ContractController implements BusinessControllerMarker {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新增合同")
|
||||
@PreAuthorize("@ss.hasPermission('system:contract:create')")
|
||||
public CommonResult<Long> create(@Valid @RequestBody ContractSaveReqVO reqVO) {
|
||||
public CommonResult<JSONObject> create(@Valid @RequestBody ContractSaveReqVO reqVO) {
|
||||
Long id = contractService.createContract(reqVO);
|
||||
return success(id);
|
||||
return success(new JSONObject().putOnce("id", id));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@@ -101,7 +99,6 @@ public class ContractController implements BusinessControllerMarker {
|
||||
public void archive() {
|
||||
}
|
||||
|
||||
// TODO
|
||||
@GetMapping("/submit/approval")
|
||||
@Operation(summary = "合同提交审批")
|
||||
@PreAuthorize("@ss.hasPermission('system:contract:approval')")
|
||||
@@ -109,6 +106,14 @@ public class ContractController implements BusinessControllerMarker {
|
||||
return success(contractService.submitApproval(id));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/approval")
|
||||
@Operation(summary = "合同审批")
|
||||
@PreAuthorize("@ss.hasPermission('system:contract:approval')")
|
||||
public CommonResult<String> approval(@Valid @RequestBody ContractApprovalReqVO reqVO) {
|
||||
return success(contractService.approval(reqVO));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/view/approval")
|
||||
@Operation(summary = "查看审批")
|
||||
@@ -117,9 +122,9 @@ public class ContractController implements BusinessControllerMarker {
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/submit/ERP")
|
||||
@PostMapping("/submit/erp")
|
||||
@Operation(summary = "提交ERP")
|
||||
@PreAuthorize("@ss.hasPermission('system:contract:erp')")
|
||||
public void submitERP() {
|
||||
public void submitErp() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 合同审核请求对象 Request VO")
|
||||
@Data
|
||||
public class ContractApprovalReqVO {
|
||||
|
||||
@Schema(description = "合同主键ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "合同主键ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "审核结果(通过:PASS,驳回:REJECT)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "审核结果不能为空")
|
||||
private String auditResult;
|
||||
|
||||
@Schema(description = "审批意见", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "审核意见不能为空")
|
||||
private String reviewOpinion;
|
||||
}
|
||||
@@ -42,7 +42,4 @@ public class ContractDetailSaveReqVO {
|
||||
|
||||
// 交货计划
|
||||
private List<ContractPlanSaveReqVO> plans;
|
||||
|
||||
// 价款结算条款
|
||||
private List<ContractFormulaSaveReqVO> formulas;
|
||||
}
|
||||
@@ -10,14 +10,14 @@ import java.util.List;
|
||||
@Data
|
||||
public class ContractFormulaSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28539")
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22933")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "合同明细主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "8181")
|
||||
@NotNull(message = "合同明细主键不能为空")
|
||||
private Long contractDetailId;
|
||||
@Schema(description = "合同主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "9162")
|
||||
@NotNull(message = "合同主键不能为空")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "公式类型;单价/总价/水扣款/加工费", example = "UNIT_PRICE")
|
||||
@Schema(description = "公式类型;单价/总价/水扣款/加工费", example = "1")
|
||||
private String formulaType;
|
||||
|
||||
@Schema(description = "公式")
|
||||
@@ -26,7 +26,7 @@ public class ContractFormulaSaveReqVO {
|
||||
@Schema(description = "编码公式")
|
||||
private String numberFormula;
|
||||
|
||||
@Schema(description = "物料名称", example = "物料名称")
|
||||
@Schema(description = "物料名称", example = "赵六")
|
||||
private String materialName;
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
@@ -41,10 +41,10 @@ public class ContractFormulaSaveReqVO {
|
||||
@Schema(description = "金属元素缩写")
|
||||
private String elementAbbreviation;
|
||||
|
||||
@Schema(description = "金属元素名称", example = "金属元素名称")
|
||||
@Schema(description = "金属元素名称", example = "赵六")
|
||||
private String elementName;
|
||||
|
||||
@Schema(description = "结算类型,多条使用逗号分隔(字典:PRCH_STLM_TP)", example = "LST")
|
||||
@Schema(description = "结算类型,多条使用逗号分隔(字典:PRCH_STLM_TP)", example = "1")
|
||||
private String settlementType;
|
||||
|
||||
// 基础系数配置
|
||||
|
||||
@@ -20,6 +20,9 @@ public class ContractPageReqVO extends PageParam {
|
||||
@Schema(description = "合同编号;与ERP(HTBH)对应,校验唯一")
|
||||
private String contractPaperNumber;
|
||||
|
||||
@Schema(description = "状态", example = "DRAFT")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "甲方公司名称", example = "王五")
|
||||
private String purchaseCompanyName;
|
||||
|
||||
|
||||
@@ -21,132 +21,144 @@ public class ContractSaveReqVO {
|
||||
|
||||
@NotNull(message = "步骤不能为空")
|
||||
@Schema(description = "步骤", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("步骤")
|
||||
private Integer step;
|
||||
|
||||
@Schema(description = "交货地点")
|
||||
private String deliveryAddress;
|
||||
|
||||
@Schema(description = "交货方式(字典:FRCST_ASN)")
|
||||
private String deliveryWay;
|
||||
|
||||
// 基础信息
|
||||
@Schema(description = "附件对象存储")
|
||||
private String fileObject;
|
||||
|
||||
@Schema(description = "其它附件对象存储")
|
||||
private String fileObjectOther;
|
||||
|
||||
// 合同基本信息
|
||||
@Schema(description = "甲方公司编号;如果是采购合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是销售合同,手动选择,且与ERP(WLDWBH)对应。", example = "甲方公司编号")
|
||||
@ExcelProperty("甲方公司编号;如果是采购合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是销售合同,手动选择,且与ERP(WLDWBH)对应。")
|
||||
private String purchaseCompanyNumber;
|
||||
|
||||
@Schema(description = "甲方公司名称", example = "甲方公司名称")
|
||||
@ExcelProperty("甲方公司名称")
|
||||
private String purchaseCompanyName;
|
||||
|
||||
@Schema(description = "甲方地址", example = "甲方地址")
|
||||
@ExcelProperty("甲方地址")
|
||||
private String purchaseAddress;
|
||||
|
||||
@Schema(description = "甲方法定代表人", example = "甲方法定代表人")
|
||||
@ExcelProperty("甲方法定代表人")
|
||||
private String purchaseLeader;
|
||||
|
||||
@Schema(description = "甲方联系人", example = "甲方联系人")
|
||||
private String purchaseHuman;
|
||||
|
||||
@Schema(description = "甲方电话", example = "甲方电话")
|
||||
private String purchaseTel;
|
||||
|
||||
@Schema(description = "甲方邮箱", example = "甲方邮箱")
|
||||
private String purchaseEmail;
|
||||
|
||||
@Schema(description = "甲方传真", example = "甲方传真")
|
||||
private String purchaseFax;
|
||||
|
||||
@Schema(description = "甲方联系地址", example = "甲方联系地址")
|
||||
private String purchaseContactAddress;
|
||||
|
||||
@Schema(description = "乙方公司编号;如果是销售合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是采购合同,手动选择,且与ERP(WLDWBH)对应。", example = "乙方公司编号")
|
||||
@ExcelProperty("乙方公司编号;如果是销售合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是采购合同,手动选择,且与ERP(WLDWBH)对应。")
|
||||
private String salesCompanyNumber;
|
||||
|
||||
@Schema(description = "乙方公司名称", example = "乙方公司名称")
|
||||
@ExcelProperty("乙方公司名称")
|
||||
private String salesCompanyName;
|
||||
|
||||
@Schema(description = "乙方地址", example = "乙方地址")
|
||||
@ExcelProperty("乙方地址")
|
||||
private String salesAddress;
|
||||
|
||||
@Schema(description = "乙方企业负责人", example = "乙方企业负责人")
|
||||
@ExcelProperty("乙方企业负责人")
|
||||
private String salesPurchaseLeader;
|
||||
|
||||
@Schema(description = "乙方联系人", example = "乙方联系人")
|
||||
private String salesHuman;
|
||||
|
||||
@Schema(description = "乙方电话", example = "乙方电话")
|
||||
private String salesTel;
|
||||
|
||||
@Schema(description = "乙方邮箱", example = "乙方邮箱")
|
||||
private String salesEmail;
|
||||
|
||||
@Schema(description = "乙方传真", example = "乙方传真")
|
||||
private String salesFax;
|
||||
|
||||
@Schema(description = "乙方联系地址", example = "乙方联系地址")
|
||||
private String salesContactAddress;
|
||||
|
||||
@NotBlank(message = "合同名称不能为空")
|
||||
@Size(max = 90, message = "合同名称长度不能超过90个字符")
|
||||
@Schema(description = "合同名称;与ERP(HTMC)对应,校验唯一", example = "合同名称")
|
||||
@ExcelProperty("合同名称;与ERP(HTMC)对应,校验唯一")
|
||||
private String contractName;
|
||||
|
||||
@Schema(description = "合同编号;与ERP(HTBH)对应,校验唯一", example = "合同编号")
|
||||
@ExcelProperty("合同编号;与ERP(HTBH)对应,校验唯一")
|
||||
private String contractPaperNumber;
|
||||
|
||||
@NotBlank(message = "合同类型不能为空")
|
||||
// @NotBlank(message = "合同类型不能为空")
|
||||
@Schema(description = "合同类型", example = "PRCH")
|
||||
@ExcelProperty("合同类型")
|
||||
private String contractType;
|
||||
|
||||
@Schema(description = "收支性质;与ERP(SZXZ)对应", example = "EXPENSES")
|
||||
@ExcelProperty("收支性质;与ERP(SZXZ)对应")
|
||||
private String direction;
|
||||
|
||||
@Schema(description = "签署日期;与ERP(HTQDRQ)对应")
|
||||
@ExcelProperty("签署日期;与ERP(HTQDRQ)对应")
|
||||
private String signDate;
|
||||
|
||||
@Schema(description = "开始日期;与ERP(HTQSRQ)对应")
|
||||
@ExcelProperty("开始日期;与ERP(HTQSRQ)对应")
|
||||
private String startDate;
|
||||
|
||||
@Schema(description = "结束日期;与ERP(HTZZRQ)对应")
|
||||
@ExcelProperty("结束日期;与ERP(HTZZRQ)对应")
|
||||
private String endDate;
|
||||
|
||||
@Schema(description = "签署地", example = "签署地")
|
||||
@ExcelProperty("签署地")
|
||||
private String signPlace;
|
||||
|
||||
// 金额信息
|
||||
@Schema(description = "币种;与ERP(BZBH)对应", example = "CNY")
|
||||
@ExcelProperty("币种;与ERP(BZBH)对应")
|
||||
private String currency;
|
||||
|
||||
@Schema(description = "本币金额;与ERP(HTBWBZJE)对应")
|
||||
@ExcelProperty("本币金额;与ERP(HTBWBZJE)对应")
|
||||
private BigDecimal basicAmount;
|
||||
|
||||
@Schema(description = "原币金额;与ERP(HTYBZJE)对应,币种不是人民币时,显示并手动填写,如果是人民币,隐藏且等于本币金额")
|
||||
@ExcelProperty("原币金额;与ERP(HTYBZJE)对应,币种不是人民币时,显示并手动填写,如果是人民币,隐藏且等于本币金额")
|
||||
private BigDecimal cooAmount;
|
||||
|
||||
@Schema(description = "是否有履约保证金;为是,则保证金必填。", example = "1")
|
||||
@ExcelProperty("是否有履约保证金;为是,则保证金必填。")
|
||||
private String hasDeposit;
|
||||
|
||||
@Schema(description = "原币履约保证金;与ERP(LYBZJBGQYB)对应,币种不是人民币时,显示并手动填写,如果是人民币,隐藏且等于本币金额")
|
||||
@ExcelProperty("原币履约保证金;与ERP(LYBZJBGQYB)对应,币种不是人民币时,显示并手动填写,如果是人民币,隐藏且等于本币金额")
|
||||
private BigDecimal cooAmountDeposit;
|
||||
|
||||
@Schema(description = "本币履约保证金-变更后;与ERP(LYBZJBGHBWB)对应,拓展信息")
|
||||
@ExcelProperty("本币履约保证金-变更后;与ERP(LYBZJBGHBWB)对应,拓展信息")
|
||||
private BigDecimal changeBasicAmountDeposit;
|
||||
|
||||
@Schema(description = "是否有预付款;与ERP(SFYYFK)对应", example = "1")
|
||||
@ExcelProperty("是否有预付款;与ERP(SFYYFK)对应")
|
||||
private String hasPrepayment;
|
||||
|
||||
@Schema(description = "预付款比例;与ERP(YFKBL)对应")
|
||||
@ExcelProperty("预付款比例;与ERP(YFKBL)对应")
|
||||
private BigDecimal prepaymentRatio;
|
||||
|
||||
@Schema(description = "预付款金额;与ERP(YFKJE)对应")
|
||||
@ExcelProperty("预付款金额;与ERP(YFKJE)对应")
|
||||
private BigDecimal prepaymentAmount;
|
||||
|
||||
@Schema(description = "是否有质保金;与ERP(SFHZBJ)对应", example = "1")
|
||||
@ExcelProperty("是否有质保金;与ERP(SFHZBJ)对应")
|
||||
private String hasQualityAmount;
|
||||
|
||||
@Schema(description = "质保金比例;与ERP(ZBJBL)对应")
|
||||
@ExcelProperty("质保金比例;与ERP(ZBJBL)对应")
|
||||
private BigDecimal qualityRatio;
|
||||
|
||||
@Schema(description = "质保金金额;与ERP(BZJJE)对应")
|
||||
@ExcelProperty("质保金金额;与ERP(BZJJE)对应")
|
||||
private BigDecimal qualityAmount;
|
||||
|
||||
@Schema(description = "是否先款后货", example = "1")
|
||||
@ExcelProperty("是否先款后货")
|
||||
private String hasPayable;
|
||||
|
||||
@Schema(description = "备注;与ERP(BZXX)对应", example = "备注")
|
||||
@ExcelProperty("备注;与ERP(BZXX)对应")
|
||||
private String remark;
|
||||
|
||||
// 物料信息
|
||||
@@ -154,74 +166,55 @@ public class ContractSaveReqVO {
|
||||
|
||||
// 扩展信息
|
||||
@Schema(description = "原币金额-变更后;与ERP(BGHHTYBZJE)对应,拓展信息")
|
||||
@ExcelProperty("原币金额-变更后;与ERP(BGHHTYBZJE)对应,拓展信息")
|
||||
private BigDecimal changeCooAmount;
|
||||
|
||||
@Schema(description = "本币金额-变更后;与ERP(BGHHTBWBZJE)对应,拓展信息")
|
||||
@ExcelProperty("本币金额-变更后;与ERP(BGHHTBWBZJE)对应,拓展信息")
|
||||
private BigDecimal changeBasicAmount;
|
||||
|
||||
@Schema(description = "原币履约保证金-变更后;与ERP(LYBZJBGHYB)对应,拓展信息")
|
||||
@ExcelProperty("原币履约保证金-变更后;与ERP(LYBZJBGHYB)对应,拓展信息")
|
||||
private BigDecimal changeCooAmountDeposit;
|
||||
|
||||
@Schema(description = "本币履约保证金;与ERP(LYBZJBGQBWB)对应")
|
||||
@ExcelProperty("本币履约保证金;与ERP(LYBZJBGQBWB)对应")
|
||||
private BigDecimal basicAmountDeposit;
|
||||
|
||||
@Schema(description = "是否框架合同;与ERP(SFKJHT)对应,拓展信息", example = "1")
|
||||
@ExcelProperty("是否框架合同;与ERP(SFKJHT)对应,拓展信息")
|
||||
private String isFramework;
|
||||
|
||||
@Schema(description = "境内/境外;与ERP(JNJW)对应,拓展信息", example = "DOMESTIC")
|
||||
@ExcelProperty("境内/境外;与ERP(JNJW)对应,拓展信息")
|
||||
private String isDomestic;
|
||||
|
||||
@Schema(description = "施工类型编号;与ERP(HTLXBH)对应,拓展信息", example = "施工类型编号")
|
||||
@ExcelProperty("施工类型编号;与ERP(HTLXBH)对应,拓展信息")
|
||||
private String constructionTypeNumber;
|
||||
|
||||
@Schema(description = "施工类型名称;与ERP(HTLXMC)对应,拓展信息", example = "施工类型名称")
|
||||
@ExcelProperty("施工类型名称;与ERP(HTLXMC)对应,拓展信息")
|
||||
private String constructionTypeName;
|
||||
|
||||
@Schema(description = "代理方;与ERP(ZLIFNR)对应,拓展信息", example = "代理方")
|
||||
@ExcelProperty("代理方;与ERP(ZLIFNR)对应,拓展信息")
|
||||
private String agent;
|
||||
|
||||
@NotBlank(message = "合同类别不能为空")
|
||||
@Schema(description = "类别;与ERP(HTLB)对应,拓展信息", example = "PROCESSING")
|
||||
@ExcelProperty("类别;与ERP(HTLB)对应,拓展信息")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "是否虚拟合同;与ERP(SFXNHT)对应", example = "1")
|
||||
@ExcelProperty("是否虚拟合同;与ERP(SFXNHT)对应")
|
||||
private String contractVirtual;
|
||||
|
||||
@Schema(description = "补充协议类型;变更协议/增加条款", example = "补充协议类型")
|
||||
@ExcelProperty("补充协议类型;变更协议/增加条款")
|
||||
private String replenishAgreementType;
|
||||
|
||||
@Schema(description = "建筑服务发生地;与ERP(JZFWFSD)对应,拓展信息,销售合同,且类型为SAP02COSR必填", example = "建筑服务发生地")
|
||||
@ExcelProperty("建筑服务发生地;与ERP(JZFWFSD)对应,拓展信息,销售合同,且类型为SAP02COSR必填")
|
||||
private String architectureServicePlace;
|
||||
|
||||
@Schema(description = "达到收款条件金额;与ERP(DDSKJE)对应,拓展信息,销售合同,且类型为SAP02COSR必填")
|
||||
@ExcelProperty("达到收款条件金额;与ERP(DDSKJE)对应,拓展信息,销售合同,且类型为SAP02COSR必填")
|
||||
private BigDecimal payeeConditionAmount;
|
||||
|
||||
@Schema(description = "附件对象存储")
|
||||
@ExcelProperty("附件对象存储")
|
||||
private String fileObject;
|
||||
|
||||
@Schema(description = "其它附件对象存储")
|
||||
@ExcelProperty("其它附件对象存储")
|
||||
private String fileObjectOther;
|
||||
|
||||
// 模板部分查询
|
||||
// 模板部分
|
||||
@Schema(description = "模板实例主键", example = "10196")
|
||||
@ExcelProperty("模板实例主键")
|
||||
private Long instanceId;
|
||||
|
||||
// 合同动态表单
|
||||
private List<TemplateInstanceDataSaveReqVO> dynamicsFields;
|
||||
|
||||
// 价款结算条款
|
||||
private List<ContractFormulaSaveReqVO> formulas;
|
||||
}
|
||||
@@ -38,7 +38,4 @@ public class ContractViewDetailRespVO {
|
||||
|
||||
// 交货计划
|
||||
private List<ContractViewPlanRespVO> plans;
|
||||
|
||||
// 价款结算条款
|
||||
private List<ContractViewFormulaRespVO> formulas;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import java.util.List;
|
||||
@Schema(description = "管理后台 - 价款结算条款 Response VO")
|
||||
@Data
|
||||
public class ContractViewFormulaRespVO {
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28539")
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "22933")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "合同明细主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "8181")
|
||||
private Long contractDetailId;
|
||||
@Schema(description = "合同主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "9162")
|
||||
private Long contractId;
|
||||
|
||||
@Schema(description = "公式类型;单价/总价/水扣款/加工费", example = "UNIT_PRICE")
|
||||
@Schema(description = "公式类型;单价/总价/水扣款/加工费", example = "1")
|
||||
private String formulaType;
|
||||
|
||||
@Schema(description = "公式")
|
||||
@@ -23,7 +23,7 @@ public class ContractViewFormulaRespVO {
|
||||
@Schema(description = "编码公式")
|
||||
private String numberFormula;
|
||||
|
||||
@Schema(description = "物料名称", example = "物料名称")
|
||||
@Schema(description = "物料名称", example = "赵六")
|
||||
private String materialName;
|
||||
|
||||
@Schema(description = "物料编码")
|
||||
@@ -38,9 +38,12 @@ public class ContractViewFormulaRespVO {
|
||||
@Schema(description = "金属元素缩写")
|
||||
private String elementAbbreviation;
|
||||
|
||||
@Schema(description = "金属元素名称", example = "金属元素名称")
|
||||
@Schema(description = "金属元素名称", example = "赵六")
|
||||
private String elementName;
|
||||
|
||||
@Schema(description = "结算类型,多条使用逗号分隔(字典:PRCH_STLM_TP)", example = "1")
|
||||
private String settlementType;
|
||||
|
||||
// 基础系数配置
|
||||
private List<ContractViewCoefficientRespVO> coefficients;
|
||||
// 品位等级价配置
|
||||
|
||||
@@ -16,11 +16,11 @@ import java.util.List;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ContractViewRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2090")
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2476")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板实例主键", example = "10196")
|
||||
@Schema(description = "模板实例主键", example = "5352")
|
||||
@ExcelProperty("模板实例主键")
|
||||
private Long instanceId;
|
||||
|
||||
@@ -28,11 +28,11 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("系统合同编号;自动生成,校验唯一")
|
||||
private String systemContractNumber;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
@Schema(description = "状态", example = "2")
|
||||
@ExcelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "合同名称;与ERP(HTMC)对应,校验唯一", example = "芋艿")
|
||||
@Schema(description = "合同名称;与ERP(HTMC)对应,校验唯一", example = "李四")
|
||||
@ExcelProperty("合同名称;与ERP(HTMC)对应,校验唯一")
|
||||
private String contractName;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("收支性质;与ERP(SZXZ)对应")
|
||||
private String direction;
|
||||
|
||||
@Schema(description = "合同类型", example = "1")
|
||||
@Schema(description = "合同类型", example = "2")
|
||||
@ExcelProperty("合同类型")
|
||||
private String contractType;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("甲方公司编号;如果是采购合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是销售合同,手动选择,且与ERP(WLDWBH)对应。")
|
||||
private String purchaseCompanyNumber;
|
||||
|
||||
@Schema(description = "甲方公司名称", example = "王五")
|
||||
@Schema(description = "甲方公司名称", example = "芋艿")
|
||||
@ExcelProperty("甲方公司名称")
|
||||
private String purchaseCompanyName;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("乙方公司编号;如果是销售合同,查询组织机构自动带出,且与ERP(HTQDZTBH)对应,如果是采购合同,手动选择,且与ERP(WLDWBH)对应。")
|
||||
private String salesCompanyNumber;
|
||||
|
||||
@Schema(description = "乙方公司名称", example = "王五")
|
||||
@Schema(description = "乙方公司名称", example = "赵六")
|
||||
@ExcelProperty("乙方公司名称")
|
||||
private String salesCompanyName;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("质保金金额;与ERP(BZJJE)对应")
|
||||
private BigDecimal qualityAmount;
|
||||
|
||||
@Schema(description = "补充协议类型;变更协议/增加条款", example = "1")
|
||||
@Schema(description = "补充协议类型;变更协议/增加条款", example = "2")
|
||||
@ExcelProperty("补充协议类型;变更协议/增加条款")
|
||||
private String replenishAgreementType;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("施工类型编号;与ERP(HTLXBH)对应,拓展信息")
|
||||
private String constructionTypeNumber;
|
||||
|
||||
@Schema(description = "施工类型名称;与ERP(HTLXMC)对应,拓展信息", example = "张三")
|
||||
@Schema(description = "施工类型名称;与ERP(HTLXMC)对应,拓展信息", example = "李四")
|
||||
@ExcelProperty("施工类型名称;与ERP(HTLXMC)对应,拓展信息")
|
||||
private String constructionTypeName;
|
||||
|
||||
@@ -216,6 +216,82 @@ public class ContractViewRespVO {
|
||||
@ExcelProperty("步骤")
|
||||
private Integer step;
|
||||
|
||||
@Schema(description = "ERP请求状态", example = "1")
|
||||
@ExcelProperty("ERP请求状态")
|
||||
private String erpStatus;
|
||||
|
||||
@Schema(description = "ERP请求失败原因")
|
||||
@ExcelProperty("ERP请求失败原因")
|
||||
private String cause;
|
||||
|
||||
@Schema(description = "流程实例编号", example = "27511")
|
||||
@ExcelProperty("流程实例编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "审批意见")
|
||||
@ExcelProperty("审批意见")
|
||||
private String reviewOpinion;
|
||||
|
||||
@Schema(description = "任务节点主键", example = "26040")
|
||||
@ExcelProperty("任务节点主键")
|
||||
private String taskNodeId;
|
||||
|
||||
@Schema(description = "模板附件对象存储")
|
||||
@ExcelProperty("模板附件对象存储")
|
||||
private String fileObject;
|
||||
|
||||
@Schema(description = "其它附件对象存储")
|
||||
@ExcelProperty("其它附件对象存储")
|
||||
private String fileObjectOther;
|
||||
|
||||
@Schema(description = "交货地点")
|
||||
@ExcelProperty("交货地点")
|
||||
private String deliveryAddress;
|
||||
|
||||
@Schema(description = "交货方式(字典:FRCST_ASN)")
|
||||
@ExcelProperty("交货方式(字典:FRCST_ASN)")
|
||||
private String deliveryWay;
|
||||
|
||||
@Schema(description = "甲方联系人")
|
||||
@ExcelProperty("甲方联系人")
|
||||
private String purchaseHuman;
|
||||
|
||||
@Schema(description = "甲方电话")
|
||||
@ExcelProperty("甲方电话")
|
||||
private String purchaseTel;
|
||||
|
||||
@Schema(description = "甲方邮箱")
|
||||
@ExcelProperty("甲方邮箱")
|
||||
private String purchaseEmail;
|
||||
|
||||
@Schema(description = "甲方传真")
|
||||
@ExcelProperty("甲方传真")
|
||||
private String purchaseFax;
|
||||
|
||||
@Schema(description = "甲方联系地址")
|
||||
@ExcelProperty("甲方联系地址")
|
||||
private String purchaseContactAddress;
|
||||
|
||||
@Schema(description = "乙方联系人")
|
||||
@ExcelProperty("乙方联系人")
|
||||
private String salesHuman;
|
||||
|
||||
@Schema(description = "乙方电话")
|
||||
@ExcelProperty("乙方电话")
|
||||
private String salesTel;
|
||||
|
||||
@Schema(description = "乙方邮箱")
|
||||
@ExcelProperty("乙方邮箱")
|
||||
private String salesEmail;
|
||||
|
||||
@Schema(description = "乙方传真")
|
||||
@ExcelProperty("乙方传真")
|
||||
private String salesFax;
|
||||
|
||||
@Schema(description = "乙方联系地址")
|
||||
@ExcelProperty("乙方联系地址")
|
||||
private String salesContactAddress;
|
||||
|
||||
// 物料信息
|
||||
private List<ContractViewDetailRespVO> detail;
|
||||
|
||||
@@ -224,4 +300,7 @@ public class ContractViewRespVO {
|
||||
|
||||
// 合同动态条款
|
||||
private List<TemplateInstanceItemRespVO> dynamicsItems;
|
||||
|
||||
// 价款结算条款
|
||||
private List<ContractViewFormulaRespVO> formulas;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public class ContractFormulaDO extends BusinessBaseDO {
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 合同明细主键
|
||||
* 合同主键
|
||||
*/
|
||||
@TableField("CTRT_DTL_ID")
|
||||
private Long contractDetailId;
|
||||
@TableField("CTRT_ID")
|
||||
private Long contractId;
|
||||
/**
|
||||
* 公式类型;单价/总价/水扣款/加工费
|
||||
*/
|
||||
|
||||
@@ -304,4 +304,64 @@ public class ContractMainDO extends BusinessBaseDO {
|
||||
*/
|
||||
@TableField("FILE_OBJ_OTH")
|
||||
private String fileObjectOther;
|
||||
/**
|
||||
* 交货地点
|
||||
*/
|
||||
@TableField("DLVY_ADR")
|
||||
private String deliveryAddress;
|
||||
/**
|
||||
* 交货方式(字典:FRCST_ASN)
|
||||
*/
|
||||
@TableField("DLVY_WY")
|
||||
private String deliveryWay;
|
||||
/**
|
||||
* 甲方联系人
|
||||
*/
|
||||
@TableField("PRCH_HMN")
|
||||
private String purchaseHuman;
|
||||
/**
|
||||
* 甲方电话
|
||||
*/
|
||||
@TableField("PRCH_TEL")
|
||||
private String purchaseTel;
|
||||
/**
|
||||
* 甲方邮箱
|
||||
*/
|
||||
@TableField("PRCH_EM")
|
||||
private String purchaseEmail;
|
||||
/**
|
||||
* 甲方传真
|
||||
*/
|
||||
@TableField("PRCH_FAX")
|
||||
private String purchaseFax;
|
||||
/**
|
||||
* 甲方联系地址
|
||||
*/
|
||||
@TableField("PRCH_CTCT_ADR")
|
||||
private String purchaseContactAddress;
|
||||
/**
|
||||
* 乙方联系人
|
||||
*/
|
||||
@TableField("SALE_HMN")
|
||||
private String salesHuman;
|
||||
/**
|
||||
* 乙方电话
|
||||
*/
|
||||
@TableField("SALE_TEL")
|
||||
private String salesTel;
|
||||
/**
|
||||
* 乙方邮箱
|
||||
*/
|
||||
@TableField("SALE_EM")
|
||||
private String salesEmail;
|
||||
/**
|
||||
* 乙方传真
|
||||
*/
|
||||
@TableField("SALE_FAX")
|
||||
private String salesFax;
|
||||
/**
|
||||
* 乙方联系地址
|
||||
*/
|
||||
@TableField("SALE_CTCT_ADR")
|
||||
private String salesContactAddress;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public interface ContractMainMapper extends BaseMapperX<ContractMainDO> {
|
||||
.betweenIfPresent(ContractMainDO::getSignDate, reqVO.getSignDate())
|
||||
.likeIfPresent(ContractMainDO::getPurchaseCompanyName, reqVO.getPurchaseCompanyName())
|
||||
.eqIfPresent(ContractMainDO::getBasicAmount, reqVO.getBasicAmount())
|
||||
.eqIfPresent(ContractMainDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(ContractMainDO::getCreateTime));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zt.plat.module.contractorder.service.contract;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractApprovalReqVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractPageReqVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractSaveReqVO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.ContractViewRespVO;
|
||||
@@ -53,4 +54,6 @@ public interface ContractService {
|
||||
* @return 审批结果
|
||||
*/
|
||||
String submitApproval(Long id);
|
||||
|
||||
String approval(@Valid ContractApprovalReqVO reqVO);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
// 合同状态保存为草稿
|
||||
contractMainDO.setStatus(ContractStatusEnum.DRAFT.getCode());
|
||||
// 生成系统合同编号
|
||||
contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getContractType()));
|
||||
contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getCategory()));
|
||||
|
||||
// 保存合同主信息
|
||||
contractMainMapper.insert(contractMainDO);
|
||||
@@ -142,74 +142,74 @@ public class ContractServiceImpl implements ContractService {
|
||||
contractPlanMapper.insert(planDO);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 价款结算条款
|
||||
if (detail.getFormulas() != null && !detail.getFormulas().isEmpty()) {
|
||||
detail.getFormulas().forEach(formula -> {
|
||||
// 价款结算条款DO
|
||||
ContractFormulaDO formulaDO = BeanUtils.toBean(formula, ContractFormulaDO.class);
|
||||
// 合同明细主键
|
||||
formulaDO.setContractDetailId(detailDOId);
|
||||
// 保存价款结算条款
|
||||
contractFormulaMapper.insert(formulaDO);
|
||||
// 价款结算条款
|
||||
if (reqVO.getFormulas() != null && !reqVO.getFormulas().isEmpty()) {
|
||||
reqVO.getFormulas().forEach(formula -> {
|
||||
// 价款结算条款DO
|
||||
ContractFormulaDO formulaDO = BeanUtils.toBean(formula, ContractFormulaDO.class);
|
||||
// 合同主键
|
||||
formulaDO.setContractId(contractId);
|
||||
// 保存价款结算条款
|
||||
contractFormulaMapper.insert(formulaDO);
|
||||
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
// 基础系数配置
|
||||
if (formula.getCoefficients() != null && !formula.getCoefficients().isEmpty()) {
|
||||
formula.getCoefficients().forEach(coefficient -> {
|
||||
// 基础系数配置DO
|
||||
ContractCoefficientDO coefficientDO = BeanUtils.toBean(coefficient, ContractCoefficientDO.class);
|
||||
// 条款主键
|
||||
coefficientDO.setFormulaId(formulaDOId);
|
||||
// 保存基础系数配置
|
||||
contractCoefficientMapper.insert(coefficientDO);
|
||||
});
|
||||
}
|
||||
// 品位等级价配置
|
||||
if (formula.getGrades() != null && !formula.getGrades().isEmpty()) {
|
||||
formula.getGrades().forEach(grade -> {
|
||||
// 品位等级价配置DO
|
||||
ContractGradeDO gradeDO = BeanUtils.toBean(grade, ContractGradeDO.class);
|
||||
// 条款主键
|
||||
gradeDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractGradeMapper.insert(gradeDO);
|
||||
});
|
||||
}
|
||||
// 调整价配置
|
||||
if (formula.getDeducts() != null && !formula.getDeducts().isEmpty()) {
|
||||
formula.getDeducts().forEach(deduct -> {
|
||||
// 调整价配置DO
|
||||
ContractDeductDO deductDO = BeanUtils.toBean(deduct, ContractDeductDO.class);
|
||||
// 条款主键
|
||||
deductDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractDeductMapper.insert(deductDO);
|
||||
});
|
||||
}
|
||||
// 市场价配置
|
||||
if (formula.getPrices()!= null && !formula.getPrices().isEmpty()) {
|
||||
formula.getPrices().forEach(price -> {
|
||||
// 市场价配置DO
|
||||
ContractPriceDO priceDO = BeanUtils.toBean(price, ContractPriceDO.class);
|
||||
// 条款主键
|
||||
priceDO.setFormulaId(formulaDOId);
|
||||
// 保存市场价配置
|
||||
contractPriceMapper.insert(priceDO);
|
||||
});
|
||||
}
|
||||
// 品位不计价配置
|
||||
if (formula.getNots() != null && !formula.getNots().isEmpty()) {
|
||||
formula.getNots().forEach(not -> {
|
||||
// 品位不计价配置DO
|
||||
ContractNotDO notDO = BeanUtils.toBean(not, ContractNotDO.class);
|
||||
// 条款主键
|
||||
notDO.setFormulaId(formulaDOId);
|
||||
// 保存品位不计价配置
|
||||
contractNotMapper.insert(notDO);
|
||||
});
|
||||
}
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
// 基础系数配置
|
||||
if (formula.getCoefficients() != null && !formula.getCoefficients().isEmpty()) {
|
||||
formula.getCoefficients().forEach(coefficient -> {
|
||||
// 基础系数配置DO
|
||||
ContractCoefficientDO coefficientDO = BeanUtils.toBean(coefficient, ContractCoefficientDO.class);
|
||||
// 条款主键
|
||||
coefficientDO.setFormulaId(formulaDOId);
|
||||
// 保存基础系数配置
|
||||
contractCoefficientMapper.insert(coefficientDO);
|
||||
});
|
||||
}
|
||||
// 品位等级价配置
|
||||
if (formula.getGrades() != null && !formula.getGrades().isEmpty()) {
|
||||
formula.getGrades().forEach(grade -> {
|
||||
// 品位等级价配置DO
|
||||
ContractGradeDO gradeDO = BeanUtils.toBean(grade, ContractGradeDO.class);
|
||||
// 条款主键
|
||||
gradeDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractGradeMapper.insert(gradeDO);
|
||||
});
|
||||
}
|
||||
// 调整价配置
|
||||
if (formula.getDeducts() != null && !formula.getDeducts().isEmpty()) {
|
||||
formula.getDeducts().forEach(deduct -> {
|
||||
// 调整价配置DO
|
||||
ContractDeductDO deductDO = BeanUtils.toBean(deduct, ContractDeductDO.class);
|
||||
// 条款主键
|
||||
deductDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractDeductMapper.insert(deductDO);
|
||||
});
|
||||
}
|
||||
// 市场价配置
|
||||
if (formula.getPrices()!= null && !formula.getPrices().isEmpty()) {
|
||||
formula.getPrices().forEach(price -> {
|
||||
// 市场价配置DO
|
||||
ContractPriceDO priceDO = BeanUtils.toBean(price, ContractPriceDO.class);
|
||||
// 条款主键
|
||||
priceDO.setFormulaId(formulaDOId);
|
||||
// 保存市场价配置
|
||||
contractPriceMapper.insert(priceDO);
|
||||
});
|
||||
}
|
||||
// 品位不计价配置
|
||||
if (formula.getNots() != null && !formula.getNots().isEmpty()) {
|
||||
formula.getNots().forEach(not -> {
|
||||
// 品位不计价配置DO
|
||||
ContractNotDO notDO = BeanUtils.toBean(not, ContractNotDO.class);
|
||||
// 条款主键
|
||||
notDO.setFormulaId(formulaDOId);
|
||||
// 保存品位不计价配置
|
||||
contractNotMapper.insert(notDO);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -259,46 +259,46 @@ public class ContractServiceImpl implements ContractService {
|
||||
if (planDOS != null && !planDOS.isEmpty()) {
|
||||
detail.setPlans(BeanUtils.toBean(planDOS, ContractViewPlanRespVO.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询并设置价款结算条款
|
||||
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_DTL_ID, detail.getId());
|
||||
if (formulaDOS != null && !formulaDOS.isEmpty()) {
|
||||
detail.setFormulas(BeanUtils.toBean(formulaDOS, ContractViewFormulaRespVO.class));
|
||||
// 查询并设置价款结算条款
|
||||
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, contractMainDO.getId());
|
||||
if (formulaDOS != null && !formulaDOS.isEmpty()) {
|
||||
respVO.setFormulas(BeanUtils.toBean(formulaDOS, ContractViewFormulaRespVO.class));
|
||||
|
||||
detail.getFormulas().forEach(formula -> {
|
||||
respVO.getFormulas().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, ContractViewCoefficientRespVO.class));
|
||||
}
|
||||
// 查询并设置品位等级价配置
|
||||
List<ContractGradeDO> gradeDOS = contractGradeMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formula.getId());
|
||||
if (gradeDOS != null && !gradeDOS.isEmpty()) {
|
||||
formula.setGrades(BeanUtils.toBean(gradeDOS, ContractViewGradeRespVO.class));
|
||||
}
|
||||
// 查询并设置调整价配置
|
||||
List<ContractDeductDO> deductDOS = contractDeductMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formula.getId());
|
||||
if (deductDOS != null && !deductDOS.isEmpty()) {
|
||||
formula.setDeducts(BeanUtils.toBean(deductDOS, ContractViewDeductRespVO.class));
|
||||
}
|
||||
// 查询并设置市场价配置
|
||||
List<ContractPriceDO> priceDOS = contractPriceMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formula.getId());
|
||||
if (priceDOS != null && !priceDOS.isEmpty()) {
|
||||
formula.setPrices(BeanUtils.toBean(priceDOS, ContractViewPriceRespVO.class));
|
||||
}
|
||||
// 查询并设置品位不计价配置
|
||||
List<ContractNotDO> notDOS = contractNotMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_NT_FMU_ID, formula.getId());
|
||||
if (notDOS != null && !notDOS.isEmpty()) {
|
||||
formula.setNots(BeanUtils.toBean(notDOS, ContractViewNotRespVO.class));
|
||||
}
|
||||
});
|
||||
// 查询并设置基础系数配置
|
||||
List<ContractCoefficientDO> coefficientDOS = contractCoefficientMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_COEF_FMU_ID, formula.getId());
|
||||
if (coefficientDOS != null && !coefficientDOS.isEmpty()) {
|
||||
formula.setCoefficients(BeanUtils.toBean(coefficientDOS, ContractViewCoefficientRespVO.class));
|
||||
}
|
||||
// 查询并设置品位等级价配置
|
||||
List<ContractGradeDO> gradeDOS = contractGradeMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formula.getId());
|
||||
if (gradeDOS != null && !gradeDOS.isEmpty()) {
|
||||
formula.setGrades(BeanUtils.toBean(gradeDOS, ContractViewGradeRespVO.class));
|
||||
}
|
||||
// 查询并设置调整价配置
|
||||
List<ContractDeductDO> deductDOS = contractDeductMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formula.getId());
|
||||
if (deductDOS != null && !deductDOS.isEmpty()) {
|
||||
formula.setDeducts(BeanUtils.toBean(deductDOS, ContractViewDeductRespVO.class));
|
||||
}
|
||||
// 查询并设置市场价配置
|
||||
List<ContractPriceDO> priceDOS = contractPriceMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formula.getId());
|
||||
if (priceDOS != null && !priceDOS.isEmpty()) {
|
||||
formula.setPrices(BeanUtils.toBean(priceDOS, ContractViewPriceRespVO.class));
|
||||
}
|
||||
// 查询并设置品位不计价配置
|
||||
List<ContractNotDO> notDOS = contractNotMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_NT_FMU_ID, formula.getId());
|
||||
if (notDOS != null && !notDOS.isEmpty()) {
|
||||
formula.setNots(BeanUtils.toBean(notDOS, ContractViewNotRespVO.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -378,37 +378,37 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
// 删除交货计划
|
||||
contractPlanMapper.delete(TableFieldConstants.BSE_CTRT_PLN_CTRT_DTL_ID, detailDOId.toString());
|
||||
|
||||
// 查询价款结算条款
|
||||
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_DTL_ID, detailDOId.toString());
|
||||
if (formulaDOS != null && !formulaDOS.isEmpty()) {
|
||||
formulaDOS.forEach(formulaDO -> {
|
||||
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
|
||||
// 删除基础系数配置
|
||||
contractCoefficientMapper.delete(TableFieldConstants.BSE_CTRT_COEF_FMU_ID, formulaDOId.toString());
|
||||
// 删除品位等级价配置
|
||||
contractGradeMapper.delete(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formulaDOId.toString());
|
||||
// 删除调整价配置
|
||||
contractDeductMapper.delete(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formulaDOId.toString());
|
||||
// 删除市场价配置
|
||||
contractPriceMapper.delete(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formulaDOId.toString());
|
||||
// 删除品位不计价配置
|
||||
contractNotMapper.delete(TableFieldConstants.BSE_CTRT_NT_FMU_ID, formulaDOId.toString());
|
||||
});
|
||||
}
|
||||
|
||||
// 删除价款结算条款
|
||||
contractFormulaMapper.delete(TableFieldConstants.BSE_CTRT_FMU_CTRT_DTL_ID, detailDOId.toString());
|
||||
});
|
||||
|
||||
// 删除合同明细
|
||||
contractDetailMapper.delete(TableFieldConstants.BSE_CTRT_DTL_CTRT_MAIN_ID, id.toString());
|
||||
}
|
||||
|
||||
// 查询价款结算条款
|
||||
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, id);
|
||||
if (formulaDOS != null && !formulaDOS.isEmpty()) {
|
||||
formulaDOS.forEach(formulaDO -> {
|
||||
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
|
||||
// 删除基础系数配置
|
||||
contractCoefficientMapper.delete(TableFieldConstants.BSE_CTRT_COEF_FMU_ID, formulaDOId.toString());
|
||||
// 删除品位等级价配置
|
||||
contractGradeMapper.delete(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formulaDOId.toString());
|
||||
// 删除调整价配置
|
||||
contractDeductMapper.delete(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formulaDOId.toString());
|
||||
// 删除市场价配置
|
||||
contractPriceMapper.delete(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formulaDOId.toString());
|
||||
// 删除品位不计价配置
|
||||
contractNotMapper.delete(TableFieldConstants.BSE_CTRT_NT_FMU_ID, formulaDOId.toString());
|
||||
});
|
||||
|
||||
// 删除价款结算条款
|
||||
contractFormulaMapper.delete(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, id.toString());
|
||||
}
|
||||
|
||||
// 重新插入关联信息
|
||||
if (reqVO.getDetail() != null && !reqVO.getDetail().isEmpty()) {
|
||||
reqVO.getDetail().forEach(detail -> {
|
||||
@@ -432,74 +432,74 @@ public class ContractServiceImpl implements ContractService {
|
||||
contractPlanMapper.insert(planDO);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 价款结算条款
|
||||
if (detail.getFormulas() != null && !detail.getFormulas().isEmpty()) {
|
||||
detail.getFormulas().forEach(formula -> {
|
||||
// 价款结算条款DO
|
||||
ContractFormulaDO formulaDO = BeanUtils.toBean(formula, ContractFormulaDO.class);
|
||||
// 合同明细主键
|
||||
formulaDO.setContractDetailId(detailDOId);
|
||||
// 保存价款结算条款
|
||||
contractFormulaMapper.insert(formulaDO);
|
||||
// 价款结算条款
|
||||
if (reqVO.getFormulas() != null && !reqVO.getFormulas().isEmpty()) {
|
||||
reqVO.getFormulas().forEach(formula -> {
|
||||
// 价款结算条款DO
|
||||
ContractFormulaDO formulaDO = BeanUtils.toBean(formula, ContractFormulaDO.class);
|
||||
// 合同主键
|
||||
formulaDO.setContractId(id);
|
||||
// 保存价款结算条款
|
||||
contractFormulaMapper.insert(formulaDO);
|
||||
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
// 基础系数配置
|
||||
if (formula.getCoefficients() != null && !formula.getCoefficients().isEmpty()) {
|
||||
formula.getCoefficients().forEach(coefficient -> {
|
||||
// 基础系数配置DO
|
||||
ContractCoefficientDO coefficientDO = BeanUtils.toBean(coefficient, ContractCoefficientDO.class);
|
||||
// 条款主键
|
||||
coefficientDO.setFormulaId(formulaDOId);
|
||||
// 保存基础系数配置
|
||||
contractCoefficientMapper.insert(coefficientDO);
|
||||
});
|
||||
}
|
||||
// 品位等级价配置
|
||||
if (formula.getGrades() != null && !formula.getGrades().isEmpty()) {
|
||||
formula.getGrades().forEach(grade -> {
|
||||
// 品位等级价配置DO
|
||||
ContractGradeDO gradeDO = BeanUtils.toBean(grade, ContractGradeDO.class);
|
||||
// 条款主键
|
||||
gradeDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractGradeMapper.insert(gradeDO);
|
||||
});
|
||||
}
|
||||
// 调整价配置
|
||||
if (formula.getDeducts() != null && !formula.getDeducts().isEmpty()) {
|
||||
formula.getDeducts().forEach(deduct -> {
|
||||
// 调整价配置DO
|
||||
ContractDeductDO deductDO = BeanUtils.toBean(deduct, ContractDeductDO.class);
|
||||
// 条款主键
|
||||
deductDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractDeductMapper.insert(deductDO);
|
||||
});
|
||||
}
|
||||
// 市场价配置
|
||||
if (formula.getPrices()!= null && !formula.getPrices().isEmpty()) {
|
||||
formula.getPrices().forEach(price -> {
|
||||
// 市场价配置DO
|
||||
ContractPriceDO priceDO = BeanUtils.toBean(price, ContractPriceDO.class);
|
||||
// 条款主键
|
||||
priceDO.setFormulaId(formulaDOId);
|
||||
// 保存市场价配置
|
||||
contractPriceMapper.insert(priceDO);
|
||||
});
|
||||
}
|
||||
// 品位不计价配置
|
||||
if (formula.getNots() != null && !formula.getNots().isEmpty()) {
|
||||
formula.getNots().forEach(not -> {
|
||||
// 品位不计价配置DO
|
||||
ContractNotDO notDO = BeanUtils.toBean(not, ContractNotDO.class);
|
||||
// 条款主键
|
||||
notDO.setFormulaId(formulaDOId);
|
||||
// 保存品位不计价配置
|
||||
contractNotMapper.insert(notDO);
|
||||
});
|
||||
}
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
// 基础系数配置
|
||||
if (formula.getCoefficients() != null && !formula.getCoefficients().isEmpty()) {
|
||||
formula.getCoefficients().forEach(coefficient -> {
|
||||
// 基础系数配置DO
|
||||
ContractCoefficientDO coefficientDO = BeanUtils.toBean(coefficient, ContractCoefficientDO.class);
|
||||
// 条款主键
|
||||
coefficientDO.setFormulaId(formulaDOId);
|
||||
// 保存基础系数配置
|
||||
contractCoefficientMapper.insert(coefficientDO);
|
||||
});
|
||||
}
|
||||
// 品位等级价配置
|
||||
if (formula.getGrades() != null && !formula.getGrades().isEmpty()) {
|
||||
formula.getGrades().forEach(grade -> {
|
||||
// 品位等级价配置DO
|
||||
ContractGradeDO gradeDO = BeanUtils.toBean(grade, ContractGradeDO.class);
|
||||
// 条款主键
|
||||
gradeDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractGradeMapper.insert(gradeDO);
|
||||
});
|
||||
}
|
||||
// 调整价配置
|
||||
if (formula.getDeducts() != null && !formula.getDeducts().isEmpty()) {
|
||||
formula.getDeducts().forEach(deduct -> {
|
||||
// 调整价配置DO
|
||||
ContractDeductDO deductDO = BeanUtils.toBean(deduct, ContractDeductDO.class);
|
||||
// 条款主键
|
||||
deductDO.setFormulaId(formulaDOId);
|
||||
// 保存品位等级价配置
|
||||
contractDeductMapper.insert(deductDO);
|
||||
});
|
||||
}
|
||||
// 市场价配置
|
||||
if (formula.getPrices()!= null && !formula.getPrices().isEmpty()) {
|
||||
formula.getPrices().forEach(price -> {
|
||||
// 市场价配置DO
|
||||
ContractPriceDO priceDO = BeanUtils.toBean(price, ContractPriceDO.class);
|
||||
// 条款主键
|
||||
priceDO.setFormulaId(formulaDOId);
|
||||
// 保存市场价配置
|
||||
contractPriceMapper.insert(priceDO);
|
||||
});
|
||||
}
|
||||
// 品位不计价配置
|
||||
if (formula.getNots() != null && !formula.getNots().isEmpty()) {
|
||||
formula.getNots().forEach(not -> {
|
||||
// 品位不计价配置DO
|
||||
ContractNotDO notDO = BeanUtils.toBean(not, ContractNotDO.class);
|
||||
// 条款主键
|
||||
notDO.setFormulaId(formulaDOId);
|
||||
// 保存品位不计价配置
|
||||
contractNotMapper.insert(notDO);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -543,34 +543,91 @@ public class ContractServiceImpl implements ContractService {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同内容校验 TODO
|
||||
// 合同状态校验
|
||||
if (ContractStatusEnum.UNDER_REVIEW.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.TERMINATED.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.ARCHIVED.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.DELETED.getCode().equals(contractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL,
|
||||
ContractStatusEnum.valueOf(contractMainDO.getStatus()).getLabel());
|
||||
}
|
||||
|
||||
// 合同内容校验
|
||||
verifyContract(get(id));
|
||||
|
||||
// 查询用户
|
||||
// 查询登陆用户
|
||||
AdminUserRespDTO adminUserRespDTO = adminUserApi
|
||||
.getUser(SecurityFrameworkUtils.getLoginUserId()).getData();
|
||||
|
||||
// 先创建流程,后更新状态
|
||||
BpmProcessInstanceCreateReqDTO pidto = new BpmProcessInstanceCreateReqDTO();
|
||||
pidto.setProcessDefinitionKey(ProcessConstants.CONTRACT_APPROVAL_PROCESS);
|
||||
pidto.setBusinessKey(String.valueOf(id));
|
||||
String data = bpmProcessInstanceApi.createProcessInstance(adminUserRespDTO.getId(), pidto).getData();
|
||||
if (StringUtils.isNotBlank(data)) {
|
||||
// 获取流程当前审批的任务节点
|
||||
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(data).getData();
|
||||
contractMainDO.setProcessInstanceId(data);
|
||||
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
BpmTaskRespDTO undoTask = taskList.get(taskList.size() - 1);
|
||||
contractMainDO.setTaskNodeId(undoTask.getId());
|
||||
if (StringUtils.isNotBlank(contractMainDO.getProcessInstanceId())) {
|
||||
|
||||
// TODO:驳回状态重新提交审批处理
|
||||
// 进入审批流程的合同,查询当前审批的任务节点
|
||||
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(contractMainDO.getProcessInstanceId()).getData();
|
||||
} else {
|
||||
|
||||
// 未进入审批流程的合同,创建审批流程
|
||||
BpmProcessInstanceCreateReqDTO pidto = new BpmProcessInstanceCreateReqDTO();
|
||||
pidto.setProcessDefinitionKey(ProcessConstants.CONTRACT_APPROVAL_PROCESS);
|
||||
pidto.setBusinessKey(String.valueOf(id));
|
||||
String data = bpmProcessInstanceApi.createProcessInstance(adminUserRespDTO.getId(), pidto).getData();
|
||||
if (StringUtils.isNotBlank(data)) {
|
||||
|
||||
// 获取流程当前审批的任务节点,更新合同审批状态
|
||||
List<BpmTaskRespDTO> taskList = bpmTaskApi.getTaskListByProcessInstanceId(data).getData();
|
||||
contractMainDO.setProcessInstanceId(data);
|
||||
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
BpmTaskRespDTO undoTask = taskList.get(taskList.size() - 1);
|
||||
contractMainDO.setTaskNodeId(undoTask.getId());
|
||||
}
|
||||
contractMainDO.setStatus(ContractStatusEnum.UNDER_REVIEW.getCode());
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
return "提交审批成功";
|
||||
}
|
||||
contractMainDO.setStatus(ContractStatusEnum.UNDER_REVIEW.getCode());
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
return "提交审批成功";
|
||||
}
|
||||
|
||||
return "提交审批失败";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String approval(ContractApprovalReqVO reqVO) {
|
||||
|
||||
// 合同主键ID
|
||||
Long id = reqVO.getId();
|
||||
|
||||
// 判断主键
|
||||
if (ObjectUtils.isEmpty(id)) {
|
||||
throw exception(CONTRACT_ID_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (ContractStatusEnum.DRAFT.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.IN_PROGRESS.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.REJECTED.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.TERMINATED.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.ARCHIVED.getCode().equals(contractMainDO.getStatus())
|
||||
|| ContractStatusEnum.DELETED.getCode().equals(contractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_APPROVAL,
|
||||
ContractStatusEnum.valueOf(contractMainDO.getStatus()).getLabel());
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验合同内容
|
||||
*
|
||||
* @param contract 合同数据
|
||||
*/
|
||||
private void verifyContract(ContractViewRespVO contract) {
|
||||
|
||||
/* 合同基本信息 */
|
||||
@@ -623,15 +680,15 @@ public class ContractServiceImpl implements ContractService {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_DRCT_LABEL);
|
||||
}
|
||||
// 签署日期不能为空
|
||||
if (contract.getSignDate() != null) {
|
||||
if (contract.getSignDate() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_SGN_DT_LABEL);
|
||||
}
|
||||
// 开始日期不能为空
|
||||
if (contract.getStartDate() != null) {
|
||||
if (contract.getStartDate() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_STRT_DT_LABEL);
|
||||
}
|
||||
// 结束日期不能为空
|
||||
if (contract.getEndDate() != null) {
|
||||
if (contract.getEndDate() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_END_DT_LABEL);
|
||||
}
|
||||
// 签署地不能为空
|
||||
@@ -645,11 +702,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_CUR_LABEL);
|
||||
}
|
||||
// 本币金额不能为空
|
||||
if (contract.getBasicAmount() != null) {
|
||||
if (contract.getBasicAmount() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_BSC_AMT_LABEL);
|
||||
}
|
||||
// 原币金额不能为空
|
||||
if (contract.getCooAmount() != null) {
|
||||
if (contract.getCooAmount() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_COO_AMT_LABEL);
|
||||
}
|
||||
// 是否有履约保证金不能为空
|
||||
@@ -659,11 +716,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
// 是否有履约保证金为是的情况
|
||||
if (ErpCtrtYesNoEnum.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);
|
||||
}
|
||||
// 本币履约保证金不能为空
|
||||
if (contract.getBasicAmountDeposit() != null) {
|
||||
if (contract.getBasicAmountDeposit() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_BSC_AMT_DPST_LABEL);
|
||||
}
|
||||
}
|
||||
@@ -674,11 +731,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
// 是否有预付款为是的情况
|
||||
if (ErpCtrtYesNoEnum.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);
|
||||
}
|
||||
// 预付款金额不能为空
|
||||
if (contract.getPrepaymentAmount() != null) {
|
||||
if (contract.getPrepaymentAmount() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_PPYM_AMT_LABEL);
|
||||
}
|
||||
}
|
||||
@@ -689,11 +746,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
// 是否有质保金为是的情况
|
||||
if (ErpCtrtYesNoEnum.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);
|
||||
}
|
||||
// 质保金金额不能为空
|
||||
if (contract.getQualityAmount() != null) {
|
||||
if (contract.getQualityAmount() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_MAIN_QLT_AMT_LABEL);
|
||||
}
|
||||
}
|
||||
@@ -703,9 +760,22 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
/* 物料信息 */
|
||||
// 物料名称不能为空
|
||||
// 数量不能为空
|
||||
// 计量单位不能为空
|
||||
if (contract.getDetail() != null && !contract.getDetail().isEmpty()) {
|
||||
contract.getDetail().forEach(detail -> {
|
||||
// 物料名称不能为空
|
||||
if (StringUtils.isBlank(detail.getMaterialName())) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_DTL_MTRL_NAME_LABEL);
|
||||
}
|
||||
// 数量不能为空
|
||||
if (detail.getQuantity() == null) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_DTL_QTY_LABEL);
|
||||
}
|
||||
// 计量单位不能为空
|
||||
if (StringUtils.isBlank(detail.getUnit())) {
|
||||
throw exception(CONTRACT_DATA_NOT_EXISTS, TableFieldConstants.BSE_CTRT_DTL_UNT_LABEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 扩展信息 */
|
||||
// 是否框架合同不能为空
|
||||
@@ -741,11 +811,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
* 单据名称(拼音)-类型-公司编码-年月日-六位编号
|
||||
* 如请款单: QKD-ZGQK-3000-20250915-00001
|
||||
*
|
||||
* @param contractType 合同类型
|
||||
* @param category 合同类别
|
||||
*
|
||||
* @return 系统合同编号
|
||||
*/
|
||||
private String generateSystemContractNumber(String contractType) {
|
||||
private String generateSystemContractNumber(String category) {
|
||||
|
||||
// 单据名称(拼音)
|
||||
String documentName = "XTHT";
|
||||
@@ -755,7 +825,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
String yearMounth8Bit = LocalDate.now()
|
||||
.format(DateTimeFormatter.ofPattern(DateConstants.DATE_FORMAT_YEAR_MONTH_DAY_8_BIT));
|
||||
// 查询最大编号
|
||||
String numPrefix = documentName+"-"+contractType+"-"+companyId+"-"+yearMounth8Bit;
|
||||
String numPrefix = documentName+"-"+category+"-"+companyId+"-"+yearMounth8Bit;
|
||||
QueryWrapper<ContractMainDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("SYS_CTRT_NUM", numPrefix);
|
||||
queryWrapper.orderByDesc("SYS_CTRT_NUM");
|
||||
|
||||
@@ -6,21 +6,43 @@ import com.zt.plat.framework.common.exception.ErrorCode;
|
||||
public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 示例模块 1-001-000-000 ==========
|
||||
ErrorCode ERP_NOT_EXISTS = new ErrorCode(1_000_000_001, "获取ERP数据为空");
|
||||
ErrorCode ERP_NOT_JSON_EXISTS = new ErrorCode(1_000_000_002, "ERP接口响应无法解析为JSON");
|
||||
ErrorCode ERP_ERROR_EXISTS = new ErrorCode(1_000_000_003, "调用ERP RFC接口失败");
|
||||
|
||||
ErrorCode ERP_CUSTOMER_NOT_EXISTS = new ErrorCode(1_001_000_001, "ERP客商主数据不存在");
|
||||
ErrorCode ERP_MATERIAL_NOT_EXISTS = new ErrorCode(1_001_000_002, "ERP物料数据不存在");
|
||||
ErrorCode ERP_COMPANY_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_BOM_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_BOM_DETAIL_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_PROCESS_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_PROCESS_DETAIL_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_FACTORY_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_COSTCENTER_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_PRODUCTIVE_VERSION_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_PURCHASE_ORGANIZATION_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_INTERNAL_ORDER_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_SALES_ORGANIZATION_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_WAREHOUSE_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_ASSET_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_CONTRACT_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
ErrorCode ERP_PRODUCTIVE_ORDER_NOT_EXISTS = new ErrorCode(1_001_000_003, "ERP物料数据不存在");
|
||||
|
||||
ErrorCode ERP_MATERIAL_NOT_EXISTS = new ErrorCode(1_002_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_BOM_NOT_EXISTS = new ErrorCode(1_004_000_001, "ERPBOM数据不存在");
|
||||
|
||||
ErrorCode ERP_BOM_DETAIL_NOT_EXISTS = new ErrorCode(1_005_000_001, "ERPBOM明细数据不存在");
|
||||
|
||||
ErrorCode ERP_PROCESS_NOT_EXISTS = new ErrorCode(1_006_000_001, "ERP工艺路线数据不存在");
|
||||
|
||||
ErrorCode ERP_PROCESS_DETAIL_NOT_EXISTS = new ErrorCode(1_007_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_COSTCENTER_NOT_EXISTS = new ErrorCode(1_009_000_001, "ERP成本中心数据不存在");
|
||||
|
||||
ErrorCode ERP_PRODUCTIVE_VERSION_NOT_EXISTS = new ErrorCode(1_010_000_001, "ERP生产版本数据不存在");
|
||||
|
||||
ErrorCode ERP_PURCHASE_ORGANIZATION_NOT_EXISTS = new ErrorCode(1_011_000_001, "ERP采购组织数据不存在");
|
||||
|
||||
ErrorCode ERP_INTERNAL_ORDER_NOT_EXISTS = new ErrorCode(1_012_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_ASSET_NOT_EXISTS = new ErrorCode(1_015_000_001, "ERP资产卡片数据不存在");
|
||||
|
||||
ErrorCode ERP_CONTRACT_NOT_EXISTS = new ErrorCode(1_016_000_001, "ERP合同数据不存在");
|
||||
|
||||
ErrorCode ERP_PRODUCTIVE_ORDER_NOT_EXISTS = new ErrorCode(1_017_000_001, "ERP生产订单数据不存在");
|
||||
}
|
||||
@@ -4,12 +4,15 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.erp.api.dto.ErpBillMainSaveReqDTO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBillMainSaveReqVO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpBillMainService;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class ErpBillMainApiImpl implements ErpBillMainApi{
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.zt.plat.module.erp.api;
|
||||
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
package com.zt.plat.module.erp.common.conf;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@Configuration
|
||||
public class ErpConfig {
|
||||
|
||||
@Value("${erp.address}")
|
||||
private String erpAddress;
|
||||
|
||||
@Value("${erp.sapsys}")
|
||||
private String sapsys;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 调用ERP接口获取erp数据
|
||||
*/
|
||||
public JSONArray fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
||||
try {
|
||||
// 构建完整URL
|
||||
String url = "http://" + erpAddress + "/api/rfc/get";
|
||||
// 构建请求参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("sapsys", sapsys);
|
||||
requestBody.put("funcnr", funcnr); // 获取枚举值
|
||||
if (req != null) {
|
||||
requestBody.put("req", req);
|
||||
}
|
||||
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 创建HTTP请求实体
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||
|
||||
// 发送POST请求
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
|
||||
// 解析响应结果
|
||||
String responseBody = response.getBody();
|
||||
if (responseBody.isEmpty()) {
|
||||
log.warn("无所选条件的查询数据" + req);
|
||||
}
|
||||
|
||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||
if (jsonResponse == null) {
|
||||
log.warn("ERP接口响应无法解析为JSON");
|
||||
}
|
||||
|
||||
// 正确获取E_DATA数组
|
||||
JSONObject dataObject = jsonResponse.getJSONObject("data");
|
||||
if (dataObject != null && "S".equals(dataObject.getString("E_FLAG"))) {
|
||||
return dataObject.getJSONArray("E_DATA");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// GET请求处理
|
||||
// public HashMap<String, String> getResult(SAPInterfaceResult result) {
|
||||
// HashMap<String, String> resMap = new HashMap<>();
|
||||
// String E_RSLT = null;
|
||||
// JSONObject jsonObject = result.getData();
|
||||
// //判断 result里的succeed是否为true
|
||||
// boolean succeed = result.isSucceed();
|
||||
// if (succeed && "S".equals(jsonObject.getString("E_FLAG"))) {
|
||||
// JSONObject data = result.getData();
|
||||
// String flag = "S";
|
||||
// String E_RESP = data.getString("E_DATA");
|
||||
//
|
||||
// String E_MSG = result.getMsg();
|
||||
//// log.info("请求SAP成功 E_RESP:{}", E_RESP);
|
||||
//// log.info("请求SAP成功 E_MSG:{}", E_MSG);
|
||||
// resMap.put("E_RESP", E_RESP);
|
||||
// resMap.put("resStr", E_MSG);
|
||||
// resMap.put("flag", flag);
|
||||
// return resMap;
|
||||
// } else {
|
||||
// String E_MSG = result.getMsg();
|
||||
// String flag = "E";
|
||||
// resMap.put("resStr", E_MSG);
|
||||
// resMap.put("flag", flag);
|
||||
//// log.info("请求SAP失败 E_MSG:{}", E_MSG);
|
||||
// return resMap;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 调用ERP接口更新erp数据
|
||||
*/
|
||||
public HashMap<String, String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
|
||||
try {
|
||||
// 构建完整URL
|
||||
String url = "http://" + erpAddress + "/api/rfc/post";
|
||||
// 构建请求参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("uuid", UUID.randomUUID().toString());
|
||||
requestBody.put("sapsys", sapsys);
|
||||
requestBody.put("srcsys", "DSC");
|
||||
requestBody.put("funcnr", reqDTO.getFuncnr());
|
||||
requestBody.put("bskey", reqDTO.getBskey());
|
||||
requestBody.put("usrid", reqDTO.getUsrid());
|
||||
requestBody.put("usrnm", reqDTO.getUsrnm());
|
||||
if (reqDTO.getSign() != null) {
|
||||
requestBody.put("sign", reqDTO.getSign());
|
||||
}
|
||||
if (reqDTO.getReq() != null) {
|
||||
requestBody.put("req", reqDTO.getReq());
|
||||
}
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 创建HTTP请求实体
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||
|
||||
// 发送POST请求
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
|
||||
// 解析响应结果
|
||||
String responseBody = response.getBody();
|
||||
if (responseBody.isEmpty()) {
|
||||
throw new RuntimeException("ERP接口返回结果为空");
|
||||
}
|
||||
|
||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||
if (jsonResponse == null) {
|
||||
throw new RuntimeException("ERP接口响应无法解析为JSON");
|
||||
}
|
||||
return postResult(jsonResponse);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("调用ERP RFC接口失败: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
// POST请求处理
|
||||
public HashMap<String, String> postResult(JSONObject result) {
|
||||
HashMap<String, String> resMap = new HashMap<>();
|
||||
|
||||
boolean succeed = result.getBoolean("succeed");
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
if (data == null) {
|
||||
throw new RuntimeException("SAP接口返回值为空," + result.getString("msg"));
|
||||
} else if (succeed && "S".equals(data.getString("E_FLAG"))) {
|
||||
String flag = "S";
|
||||
String E_RESP = data.getString("E_RESP");
|
||||
String E_MSG = data.getString("ET_MSG");
|
||||
resMap.put("E_RESP", E_RESP);
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
return resMap;
|
||||
} else if (!succeed && "E".equals(data.getString("E_FLAG"))) {
|
||||
String flag = "E";
|
||||
String E_MSG = data.getString("ET_MSG");
|
||||
if (StrUtil.isBlank(E_MSG)) {
|
||||
E_MSG = result.getString("msg");
|
||||
}
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
return resMap;
|
||||
} else {
|
||||
throw new RuntimeException("SAP接口异常," + result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//list
|
||||
public Map<String, List<String>> numbers(JSONArray dataArray, String key, String dataKey) {
|
||||
// 使用 Redis 获取缓存数据
|
||||
Map<String, List<String>> numbers = new HashMap<>();
|
||||
List<String> cachedNumbers = (List<String>) redisTemplate.opsForValue().get(key);
|
||||
if (cachedNumbers == null) {
|
||||
cachedNumbers = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 提取有效的 BUKRS 编号
|
||||
List<String> existingNumbers;
|
||||
if (dataArray != null) {
|
||||
// 将dataKey按"-"分割成多个部分
|
||||
String[] keyParts = dataKey.split("-");
|
||||
existingNumbers = dataArray.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(dataJson -> {
|
||||
JSONObject jsonObject = (JSONObject) dataJson;
|
||||
// 根据每个部分逐级获取值并拼接
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String part : keyParts) {
|
||||
String value = jsonObject.getString(part);
|
||||
if (value != null) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append("-");
|
||||
}
|
||||
sb.append(value.trim());
|
||||
} else {
|
||||
// 如果某一部分为空,则整个值视为无效
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
})
|
||||
.filter(Objects::nonNull) // 过滤掉无效值
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
existingNumbers = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 找出共同存在的编号
|
||||
Set<String> cachedNumberSet = new HashSet<>(cachedNumbers != null ? cachedNumbers : new ArrayList<>());
|
||||
List<String> commonNumbers = existingNumbers.stream()
|
||||
.filter(cachedNumberSet::contains)
|
||||
.collect(Collectors.toList());
|
||||
numbers.put("com", commonNumbers);
|
||||
|
||||
//找出需要删除的字段。只有erp查询全部的接口能用到
|
||||
List<String> deleteNumbers = cachedNumberSet.stream()
|
||||
.filter(num -> !existingNumbers.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
numbers.put("delete", deleteNumbers);
|
||||
|
||||
// 找出需要新增的编号
|
||||
List<String> newNumbers = existingNumbers.stream()
|
||||
.filter(num -> !cachedNumberSet.contains(num))
|
||||
.toList();
|
||||
|
||||
// 合并所有编号
|
||||
List<String> allNumbers = new ArrayList<>(cachedNumbers);
|
||||
allNumbers.addAll(newNumbers);
|
||||
numbers.put("all", allNumbers);
|
||||
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public void updateRedisCache(String key, List<String> allnumbers) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
redisTemplate.opsForValue().set(key, allnumbers);
|
||||
}
|
||||
|
||||
public List<String> getRedisCache(String key) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
return (List<String>) redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
//map
|
||||
public Map<String, Long> getRedisCacheMap(String key) {
|
||||
// 使用 Redis 获取缓存数据
|
||||
Map<String, Long> result = (Map<String, Long>) redisTemplate.opsForHash().entries(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addRedisCacheMap(String key, Map<String, Long> allnumbers) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
redisTemplate.opsForHash().putAll(key, allnumbers);
|
||||
}
|
||||
|
||||
public void deleteRedisCacheMap(String key, List<String> deleteNumbers) {
|
||||
if (deleteNumbers == null || deleteNumbers.isEmpty()) {
|
||||
log.debug("No items to delete from Redis hash: {}", key);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Object[] keysToDelete = deleteNumbers.toArray(new String[0]);
|
||||
Long deletedCount = redisTemplate.opsForHash().delete(key, keysToDelete);
|
||||
log.debug("Deleted" + deletedCount + "items from Redis hash:" + key);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to delete items from Redis hash:" + key, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.zt.plat.module.erp.common.conf;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
|
||||
/**
|
||||
* @author wuxz
|
||||
* @create 2022-06-07 20:54
|
||||
*/
|
||||
@Primary
|
||||
@Configuration
|
||||
public class MyRedisConfig {
|
||||
@Bean(value = "MyRedisTemplate")
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
// 通过 Jackson 组件进行序列化
|
||||
RedisSerializer<Object> serializer = redisSerializer();
|
||||
|
||||
// key 和 value
|
||||
// 一般来说, redis-key采用字符串序列化;
|
||||
// redis-value采用json序列化, json的体积小,可读性高,不需要实现serializer接口。
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(serializer);
|
||||
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(serializer);
|
||||
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public RedisSerializer<Object> redisSerializer() {
|
||||
//创建JSON序列化器
|
||||
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// objectMapper.enableDefaultTyping()被弃用
|
||||
objectMapper.activateDefaultTyping(
|
||||
LaissezFaireSubTypeValidator.instance,
|
||||
ObjectMapper.DefaultTyping.NON_FINAL,
|
||||
JsonTypeInfo.As.WRAPPER_ARRAY);
|
||||
serializer.setObjectMapper(objectMapper);
|
||||
return serializer;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.zt.plat.module.erp.common.task;
|
||||
|
||||
import com.zt.plat.module.erp.service.erp.ErpCompanyService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @ClassName energyTask
|
||||
* @Description TODO
|
||||
* @Author chen
|
||||
* @Date 2023/9/25
|
||||
**/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class statisticstask {
|
||||
|
||||
@Resource
|
||||
private ErpCompanyService erpCompanyService;
|
||||
|
||||
//能源定时每日获取成本配置机台水电数据
|
||||
@Scheduled(cron = "0 0 12 * * ?")
|
||||
@Transactional
|
||||
public void erpCompany(){
|
||||
erpCompanyService.callErpRfcInterface();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.zt.plat.module.erp.common.enums;
|
||||
package com.zt.plat.module.erp.enums;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpAssetPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpAssetRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpAssetSaveReqVO;
|
||||
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_ASSET_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_COMPANY_REDIS_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -42,6 +44,8 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
@Resource
|
||||
private ErpAssetMapper erpAssetMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,33 +114,30 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.资产卡片;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
// List<Map<String, String>> datumList = new ArrayList<>();
|
||||
// Map<String, String> datumEntry = new HashMap<>();
|
||||
// datumEntry.put("sign", "I");
|
||||
// datumEntry.put("option", "EQ");
|
||||
// datumEntry.put("low", LocalDate.now().toString());
|
||||
// datumList.add(datumEntry);
|
||||
// req.put(funcnrEnum.getDatekey(), datumList);
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(companyKey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray==null) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_ASSET_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -155,7 +156,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnrEnum) {
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpAssetDO> toUpdate = new ArrayList<>();
|
||||
List<ErpAssetDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -222,7 +223,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getCompanyNumber() + "-" + asset.getMainAssetNumber(), ErpAssetDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpAssetMapper.updateBatch(result.toUpdate);
|
||||
@@ -231,7 +232,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
// 使用流式处理和批处理优化删除逻辑
|
||||
List<Long> idsToDelete = new ArrayList<>(result.deleteNumbers.values());
|
||||
erpAssetMapper.deleteByIds(idsToDelete);
|
||||
erpConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ public class ErpAssetServiceImpl implements ErpAssetService {
|
||||
String mapKey = asset.getCompanyNumber() + "-" + asset.getMainAssetNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ErpBillMainServiceImpl implements ErpBillMainService {
|
||||
// 抽取重复代码:提交 ERP 并记录日志
|
||||
private String submitToErp(ErpSubmitReqDTO reqDTO) {
|
||||
HashMap<String, String> response = erpExternalApi.submitDataToErp(reqDTO);
|
||||
return response.get("data");
|
||||
return response.get("resStr");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -4,8 +4,9 @@ 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.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomDetailPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomDetailRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomDetailSaveReqVO;
|
||||
@@ -36,6 +37,8 @@ public class ErpBomDetailServiceImpl implements ErpBomDetailService {
|
||||
@Resource
|
||||
private ErpBomDetailMapper erpBomDetailMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -107,14 +110,14 @@ public class ErpBomDetailServiceImpl implements ErpBomDetailService {
|
||||
}
|
||||
|
||||
private ProcessingResult processData(List<ErpBomDetailDO> updateReqVOS, String key) {
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
List<ErpBomDetailDO> toUpdate = new ArrayList<>();
|
||||
List<ErpBomDetailDO> toInsert = new ArrayList<>();
|
||||
|
||||
List<String> dataArrayNumbers = new ArrayList<>();
|
||||
Map<String, Long> existingNumbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> existingNumbers = myRedisConfig.getRedisCacheMap(key);
|
||||
for (ErpBomDetailDO updateReqVO : updateReqVOS) {
|
||||
String mapKey = updateReqVO.getBomId() + "-" + updateReqVO.getErpBomId();
|
||||
if (existingNumbers.containsKey(mapKey)) {
|
||||
@@ -150,7 +153,7 @@ public class ErpBomDetailServiceImpl implements ErpBomDetailService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getBomId() + "-" + asset.getErpBomId(), ErpBomDetailDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpBomDetailMapper.updateBatch(result.toUpdate);
|
||||
@@ -161,7 +164,7 @@ public class ErpBomDetailServiceImpl implements ErpBomDetailService {
|
||||
if (!idsToDelete.isEmpty()) {
|
||||
erpBomDetailMapper.deleteByIds(idsToDelete);
|
||||
}
|
||||
erpConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +189,6 @@ public class ErpBomDetailServiceImpl implements ErpBomDetailService {
|
||||
String mapKey = asset.getBomId() + "-" + asset.getErpBomId();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,9 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.api.ErpExternalApi;
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpBomSaveReqVO;
|
||||
@@ -28,7 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_BOM_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,9 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
@Resource
|
||||
private ErpBomMapper erpBomMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -117,25 +121,29 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.BOM清单;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_BOM_NOT_EXISTS);
|
||||
throw exception(ERP_FACTORY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_BOM_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -154,7 +162,7 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnrEnum) {
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpBomDO> toUpdate = new ArrayList<>();
|
||||
|
||||
List<ErpBomDetailDO> erpBomDetailDOList = new ArrayList<>();
|
||||
@@ -231,11 +239,11 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
|
||||
// 更新Redis缓存
|
||||
if (!result.addnumbers.isEmpty()) {
|
||||
erpConfig.addRedisCacheMap(result.key, result.addnumbers);
|
||||
myRedisConfig.addRedisCacheMap(result.key, result.addnumbers);
|
||||
}
|
||||
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +274,7 @@ public class ErpBomServiceImpl implements ErpBomService {
|
||||
String mapKey = bom.getFactoryNumber() + "-" + bom.getUpMaterial() + "-" + bom.getUseItem();
|
||||
existingNumbers.put(mapKey, bom.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCompanyPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCompanyRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCompanySaveReqVO;
|
||||
@@ -20,11 +21,13 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_BOM_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_COMPANY_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@@ -40,6 +43,8 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
@Resource
|
||||
private ErpCompanyMapper erpCompanyMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -109,13 +114,14 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
return;
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_COMPANY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
@@ -135,7 +141,7 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpCompanyDO> toUpdate = new ArrayList<>();
|
||||
List<ErpCompanyDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -187,7 +193,7 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCompanyDO::getNumber, ErpCompanyDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCompanyMapper.updateBatch(result.toUpdate);
|
||||
@@ -195,7 +201,7 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpCompanyMapper.delete(new LambdaQueryWrapperX<ErpCompanyDO>().in(ErpCompanyDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +227,7 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
Map<String, Long> existingNumbers = erpCompanyMapper.selectList(new LambdaQueryWrapperX<ErpCompanyDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpCompanyDO::getNumber, ErpCompanyDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
|
||||
@@ -19,10 +20,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_COMPANY_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_CONTRACT_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@@ -38,6 +41,8 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
@Resource
|
||||
private ErpContractMapper erpContractMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -106,9 +111,10 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
OftenEnum.FuncnrEnum funcnrEnum =OftenEnum.FuncnrEnum.合同信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
return;
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, null);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
@@ -128,7 +134,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String,List<String>> numbers = erpConfig.numbers(dataArray, key,funcnr.getDatakey());
|
||||
Map<String,List<String>> numbers = myRedisConfig.numbers(dataArray, key,funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
List<ErpContractDO> toUpdate = new ArrayList<>();
|
||||
@@ -168,7 +174,7 @@ public class ErpContractServiceImpl implements ErpContractService {
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpContractMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
erpConfig.updateRedisCache(result.key,result.allnumbers);
|
||||
myRedisConfig.updateRedisCache(result.key,result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCostcenterPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCostcenterRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCostcenterSaveReqVO;
|
||||
@@ -27,6 +28,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_CONTRACT_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_COSTCENTER_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@@ -42,6 +44,8 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
@Resource
|
||||
private ErpCostcenterMapper erpCostcenterMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -111,13 +115,13 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnr;
|
||||
if (erpConfig.getRedisCacheMap( key).isEmpty()){
|
||||
if (myRedisConfig.getRedisCacheMap( key).isEmpty()){
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String commanyKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(commanyKey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(commanyKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
}
|
||||
@@ -125,12 +129,16 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_COSTCENTER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
@@ -149,7 +157,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpCostcenterDO> toUpdate = new ArrayList<>();
|
||||
List<ErpCostcenterDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -208,7 +216,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCostcenterDO::getNumber, ErpCostcenterDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCostcenterMapper.updateBatch(result.toUpdate);
|
||||
@@ -216,7 +224,7 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpCostcenterMapper.delete(new LambdaQueryWrapperX<ErpCostcenterDO>().in(ErpCostcenterDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key,result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key,result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +248,6 @@ public class ErpCostcenterServiceImpl implements ErpCostcenterService {
|
||||
Map<String, Long> existingNumbers = erpCostcenterMapper.selectList(new LambdaQueryWrapperX<ErpCostcenterDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpCostcenterDO::getNumber, ErpCostcenterDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerSaveReqVO;
|
||||
@@ -41,10 +42,12 @@ import static dm.jdbc.util.DriverUtil.log;
|
||||
public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
private MyRedisConfig myRedisConfig;
|
||||
|
||||
@Resource
|
||||
private ErpCustomerMapper erpCustomerMapper;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@Override
|
||||
public ErpCustomerRespVO createErpCustomer(ErpCustomerSaveReqVO createReqVO) {
|
||||
@@ -112,7 +115,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 构建req参数
|
||||
@@ -130,12 +133,16 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
|
||||
req.put("mode", type.modetype);
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get(funcnrEnum.getDatakey());
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -154,7 +161,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnrEnum) {
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
|
||||
List<ErpCustomerDO> toUpdate = new ArrayList<>();
|
||||
List<ErpCustomerDO> toInsert = new ArrayList<>();
|
||||
@@ -211,7 +218,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCustomerMapper.updateBatch(result.toUpdate);
|
||||
@@ -237,6 +244,6 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
Map<String, Long> existingNumbers = erpCustomerMapper.selectList(new LambdaQueryWrapperX<ErpCustomerDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpFactoryPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpFactoryRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpFactorySaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_FACTORY_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
@Resource
|
||||
private ErpFactoryMapper erpFactoryMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -109,21 +112,22 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companykey = "erp" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(companykey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companykey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw new RuntimeException("ERP公司代码缓存数据丢失,请重新同步公司代码");
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
for (String companyNumber : redisCache.keySet()) {
|
||||
req.put("BUKRS", companyNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,9 +138,11 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
item.put("BUKRS", companyNumber);
|
||||
}
|
||||
}
|
||||
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
@@ -155,7 +161,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpFactoryDO> toUpdate = new ArrayList<>();
|
||||
List<ErpFactoryDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -207,7 +213,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpFactoryDO::getNumber, ErpFactoryDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpFactoryMapper.updateBatch(result.toUpdate);
|
||||
@@ -215,7 +221,7 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpFactoryMapper.delete(new LambdaQueryWrapperX<ErpFactoryDO>().in(ErpFactoryDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +246,6 @@ public class ErpFactoryServiceImpl implements ErpFactoryService {
|
||||
Map<String, Long> existingNumbers = erpFactoryMapper.selectList(new LambdaQueryWrapperX<ErpFactoryDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpFactoryDO::getNumber, ErpFactoryDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpInternalOrderPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpInternalOrderRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpInternalOrderSaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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 dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
@Resource
|
||||
private ErpInternalOrderMapper erpInternalOrderMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,27 +113,31 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String companyCode = "erpMap" + OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(companyCode);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(companyCode);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (CollUtil.isEmpty(dataArrayALL)) {
|
||||
throw exception(ERP_INTERNAL_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -149,7 +156,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpInternalOrderDO> toUpdate = new ArrayList<>();
|
||||
List<ErpInternalOrderDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -203,7 +210,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpInternalOrderDO::getNumber, ErpInternalOrderDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpInternalOrderMapper.updateBatch(result.toUpdate);
|
||||
@@ -211,7 +218,7 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpInternalOrderMapper.delete(new LambdaQueryWrapperX<ErpInternalOrderDO>().in(ErpInternalOrderDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +243,6 @@ public class ErpInternalOrderServiceImpl implements ErpInternalOrderService {
|
||||
Map<String, Long> existingNumbers = erpInternalOrderMapper.selectList(new LambdaQueryWrapperX<ErpInternalOrderDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpInternalOrderDO::getNumber, ErpInternalOrderDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpMaterialSaveReqVO;
|
||||
@@ -28,6 +29,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.ERP_MATERIAL_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@@ -43,6 +45,8 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
@Resource
|
||||
private ErpMaterialMapper erpMaterialMapper;
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@Override
|
||||
@@ -111,7 +115,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erp" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCache(key)==null) {
|
||||
if (myRedisConfig.getRedisCache(key)==null) {
|
||||
initialize(key);
|
||||
}
|
||||
|
||||
@@ -127,9 +131,10 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
return;
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (CollUtil.isEmpty(dataArray)) {
|
||||
throw exception(ERP_MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
@@ -149,7 +154,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String,List<String>> numbers = erpConfig.numbers(dataArray, key,funcnr.getDatakey());
|
||||
Map<String,List<String>> numbers = myRedisConfig.numbers(dataArray, key,funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
List<ErpMaterialDO> toUpdate = new ArrayList<>();
|
||||
@@ -200,7 +205,7 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpMaterialMapper.updateBatchByNumber(result.toUpdate);
|
||||
}
|
||||
erpConfig.updateRedisCache(result.key,result.allnumbers);
|
||||
myRedisConfig.updateRedisCache(result.key,result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,6 +230,6 @@ public class ErpMaterialServiceImpl implements ErpMaterialService {
|
||||
.stream()
|
||||
.map(ErpMaterialDO::getDownCenterNumber)
|
||||
.collect(Collectors.toList());
|
||||
erpConfig.updateRedisCache(key, existingNumbers);
|
||||
myRedisConfig.updateRedisCache(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ 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.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessDetailPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessDetailRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessDetailSaveReqVO;
|
||||
@@ -37,7 +37,7 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
private ErpProcessDetailMapper erpProcessDetailMapper;
|
||||
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
private MyRedisConfig myRedisConfig;
|
||||
|
||||
@Override
|
||||
public ErpProcessDetailRespVO createErpProcessDetail(ErpProcessDetailSaveReqVO createReqVO) {
|
||||
@@ -106,16 +106,19 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
}
|
||||
|
||||
private ProcessingResult processData(List<ErpProcessDetailDO> updateReqVOS, String key) {
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
List<ErpProcessDetailDO> toUpdate = new ArrayList<>();
|
||||
List<ErpProcessDetailDO> toInsert = new ArrayList<>();
|
||||
|
||||
List<String> dataArrayNumbers = new ArrayList<>();
|
||||
Map<String, Long> existingNumbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> existingNumbers = myRedisConfig.getRedisCacheMap(key);
|
||||
for (ErpProcessDetailDO updateReqVO : updateReqVOS) {
|
||||
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber()+"-"+updateReqVO.getProcessingName();
|
||||
if (updateReqVO.getProcessingName() == null|| updateReqVO.getProcessingName().isEmpty()){
|
||||
continue;
|
||||
}
|
||||
String mapKey = updateReqVO.getProcessId() + "-" + updateReqVO.getProcessingNumber();
|
||||
if (existingNumbers.containsKey(mapKey)) {
|
||||
updateReqVO.setId(existingNumbers.get(mapKey));
|
||||
}
|
||||
@@ -146,11 +149,11 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
new LambdaQueryWrapperX<ErpProcessDetailDO>()
|
||||
.in(ErpProcessDetailDO::getProcessId, result.toInsert.stream().map(ErpProcessDetailDO::getProcessId).distinct().collect(Collectors.toList()))
|
||||
.in(ErpProcessDetailDO::getProcessingNumber, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingNumber).distinct().collect(Collectors.toList()))
|
||||
.in(ErpProcessDetailDO::getProcessingName, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingName).distinct().collect(Collectors.toList()))
|
||||
// .in(ErpProcessDetailDO::getProcessingName, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingName).distinct().collect(Collectors.toList()))
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getProcessId() + "-" + asset.getProcessingNumber()+"-"+asset.getProcessingName(), ErpProcessDetailDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
.collect(Collectors.toMap(asset -> asset.getProcessId() + "-" + asset.getProcessingNumber(), ErpProcessDetailDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpProcessDetailMapper.updateBatch(result.toUpdate);
|
||||
@@ -161,7 +164,7 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
if (!idsToDelete.isEmpty()) {
|
||||
erpProcessDetailMapper.deleteByIds(idsToDelete);
|
||||
}
|
||||
erpConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,9 +186,9 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
||||
List<ErpProcessDetailDO> assets = erpProcessDetailMapper.selectList(new LambdaQueryWrapperX<ErpProcessDetailDO>());
|
||||
Map<String, Long> existingNumbers = new HashMap<>();
|
||||
for (ErpProcessDetailDO asset : assets) {
|
||||
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber()+"-"+asset.getProcessingName();
|
||||
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProcessSaveReqVO;
|
||||
@@ -26,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_FACTORY_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_PROCESS_NOT_EXISTS;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@@ -41,6 +43,9 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
@Resource
|
||||
private ErpProcessMapper erpProcessMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -113,26 +118,30 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.工艺路线;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
String key = "erpMap" + funcnr;
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
throw exception(ERP_PROCESS_NOT_EXISTS);
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String factoryNumber : redisCache.keySet()) {
|
||||
req.put("WERKS", factoryNumber);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PROCESS_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -151,7 +160,7 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnrEnum) {
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpProcessDO> toUpdate = new ArrayList<>();
|
||||
|
||||
List<ErpProcessDetailDO> erpProcessDetailDOList = new ArrayList<>();
|
||||
@@ -175,6 +184,7 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
dataArrayNumbers.add(number);
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
} else {
|
||||
// 新增
|
||||
@@ -229,11 +239,11 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
|
||||
// 更新Redis缓存
|
||||
if (!result.addnumbers.isEmpty()) {
|
||||
erpConfig.addRedisCacheMap(result.key, result.addnumbers);
|
||||
myRedisConfig.addRedisCacheMap(result.key, result.addnumbers);
|
||||
}
|
||||
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,6 +274,6 @@ public class ErpProcessServiceImpl implements ErpProcessService {
|
||||
String mapKey = bom.getFactoryNumber() + "-" + bom.getMaterialNumber() + "-" + bom.getBlineGroup();
|
||||
existingNumbers.put(mapKey, bom.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveOrderPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveOrderRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveOrderSaveReqVO;
|
||||
@@ -27,7 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_PRODUCTIVE_ORDER_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,8 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
|
||||
@Override
|
||||
public ErpProductiveOrderRespVO createErpProductiveOrder(ErpProductiveOrderSaveReqVO createReqVO) {
|
||||
@@ -116,7 +119,8 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
}
|
||||
|
||||
// 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
// 返回空结果而不是抛出异常
|
||||
return new PageResult<>(new ArrayList<>(), 0L);
|
||||
@@ -193,20 +197,24 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
List<String> redisCache = erpConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PRODUCTIVE_ORDER_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -225,7 +233,7 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String, List<String>> numbers = erpConfig.numbers(dataArray, key, funcnr.getDatakey());
|
||||
Map<String, List<String>> numbers = myRedisConfig.numbers(dataArray, key, funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
List<ErpProductiveOrderDO> toUpdate = new ArrayList<>();
|
||||
@@ -265,7 +273,7 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpProductiveOrderMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
erpConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionSaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_PRODUCTIVE_VERSION_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
@Resource
|
||||
private ErpProductiveVersionMapper erpProductiveVersionMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,27 +113,31 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PRODUCTIVE_VERSION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
@@ -149,7 +156,7 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpProductiveVersionDO> toUpdate = new ArrayList<>();
|
||||
List<ErpProductiveVersionDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -204,7 +211,7 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getMaterialNumber()+ "-" + asset.getProductiveVersionNumber(), ErpProductiveVersionDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpProductiveVersionMapper.updateBatch(result.toUpdate);
|
||||
@@ -213,7 +220,7 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
// 使用流式处理和批处理优化删除逻辑
|
||||
List<Long> idsToDelete = new ArrayList<>(result.deleteNumbers.values());
|
||||
erpProductiveVersionMapper.deleteByIds(idsToDelete);
|
||||
erpConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,6 +248,6 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
||||
String mapKey = asset.getFactoryNumber() + "-" + asset.getMaterialNumber() + "-" + asset.getProductiveVersionNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpPurchaseOrganizationPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpPurchaseOrganizationRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpPurchaseOrganizationSaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_PURCHASE_ORGANIZATION_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
@Resource
|
||||
private ErpPurchaseOrganizationMapper erpPurchaseOrganizationMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,7 +113,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
@@ -118,15 +121,16 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
// String factKey ="erpMap"+ OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -139,6 +143,9 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_PURCHASE_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
@@ -157,7 +164,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpPurchaseOrganizationDO> toUpdate = new ArrayList<>();
|
||||
List<ErpPurchaseOrganizationDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -209,7 +216,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpPurchaseOrganizationDO::getNumber, ErpPurchaseOrganizationDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpPurchaseOrganizationMapper.updateBatch(result.toUpdate);
|
||||
@@ -217,7 +224,7 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
if (!result.deleteNumbers.isEmpty()){
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpPurchaseOrganizationMapper.delete(new LambdaQueryWrapperX<ErpPurchaseOrganizationDO>().in(ErpPurchaseOrganizationDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +249,6 @@ public class ErpPurchaseOrganizationServiceImpl implements ErpPurchaseOrganizati
|
||||
Map<String, Long> existingNumbers = erpPurchaseOrganizationMapper.selectList(new LambdaQueryWrapperX<ErpPurchaseOrganizationDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpPurchaseOrganizationDO::getNumber, ErpPurchaseOrganizationDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpSalesOrganizationPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpSalesOrganizationRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpSalesOrganizationSaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_SALES_ORGANIZATION_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
@Resource
|
||||
private ErpSalesOrganizationMapper erpSalesOrganizationMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,22 +113,23 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey ="erpMap"+ OftenEnum.FuncnrEnum.公司代码.getFuncnr();
|
||||
Map<String,Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String,Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_COMPANY_REDIS_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("BUKRS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -138,6 +142,9 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_SALES_ORGANIZATION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL,funcnrEnum);
|
||||
@@ -156,7 +163,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpSalesOrganizationDO> toUpdate = new ArrayList<>();
|
||||
List<ErpSalesOrganizationDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -207,7 +214,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpSalesOrganizationDO::getNumber, ErpSalesOrganizationDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpSalesOrganizationMapper.updateBatch(result.toUpdate);
|
||||
@@ -215,7 +222,7 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpSalesOrganizationMapper.delete(new LambdaQueryWrapperX<ErpSalesOrganizationDO>().in(ErpSalesOrganizationDO::getNumber, result.deleteNumbers));
|
||||
erpConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +247,6 @@ public class ErpSalesOrganizationServiceImpl implements ErpSalesOrganizationServ
|
||||
Map<String, Long> existingNumbers = erpSalesOrganizationMapper.selectList(new LambdaQueryWrapperX<ErpSalesOrganizationDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpSalesOrganizationDO::getNumber, ErpSalesOrganizationDO::getId));
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.common.conf.ErpConfig;
|
||||
import com.zt.plat.module.erp.common.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpWarehousePageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpWarehouseRespVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpWarehouseSaveReqVO;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.ERP_WAREHOUSE_NOT_EXISTS;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
@Resource
|
||||
private ErpWarehouseMapper erpWarehouseMapper;
|
||||
|
||||
@Resource
|
||||
private MyRedisConfig myRedisConfig;
|
||||
@Resource
|
||||
private ErpConfig erpConfig;
|
||||
|
||||
@@ -110,22 +113,23 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (erpConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
String factKey = "erpMap" + OftenEnum.FuncnrEnum.工厂信息.getFuncnr();
|
||||
Map<String, Long> redisCache = erpConfig.getRedisCacheMap(factKey);
|
||||
Map<String, Long> redisCache = myRedisConfig.getRedisCacheMap(factKey);
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
return;
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache.keySet()) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
JSONArray dataArray = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -136,9 +140,11 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
item.put("WERKS", number);
|
||||
}
|
||||
}
|
||||
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()){
|
||||
throw exception(ERP_WAREHOUSE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 处理公司数据,区分新增和更新
|
||||
ProcessingResult result = processData(dataArrayALL, funcnrEnum);
|
||||
@@ -157,7 +163,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = erpConfig.getRedisCacheMap(key);
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpWarehouseDO> toUpdate = new ArrayList<>();
|
||||
List<ErpWarehouseDO> toInsert = new ArrayList<>();
|
||||
|
||||
@@ -207,7 +213,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(asset -> asset.getFactoryNumber() + "-" + asset.getNumber(), ErpWarehouseDO::getId));
|
||||
erpConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
myRedisConfig.addRedisCacheMap(result.key,numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpWarehouseMapper.updateBatch(result.toUpdate);
|
||||
@@ -216,7 +222,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
// 使用流式处理和批处理优化删除逻辑
|
||||
List<Long> idsToDelete = new ArrayList<>(result.deleteNumbers.values());
|
||||
erpWarehouseMapper.deleteByIds(idsToDelete);
|
||||
erpConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, new ArrayList<>(result.deleteNumbers.keySet()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,6 +250,6 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
String mapKey = asset.getFactoryNumber() + "-" + asset.getNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
erpConfig.addRedisCacheMap(key, existingNumbers);
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.zt.plat.module.erp.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
@Configuration
|
||||
public class ErpConfig {
|
||||
|
||||
@Value("${erp.address}")
|
||||
private String erpAddress;
|
||||
|
||||
@Value("${erp.sapsys}")
|
||||
private String sapsys;
|
||||
|
||||
/**
|
||||
* 调用ERP接口获取erp数据
|
||||
*/
|
||||
public HashMap<String, Object> fetchDataFromERP(String funcnr, Map<String, Object> req) {
|
||||
try {
|
||||
// 构建完整URL
|
||||
String url = "http://" + erpAddress + "/api/rfc/get";
|
||||
// 构建请求参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("sapsys", sapsys);
|
||||
requestBody.put("funcnr", funcnr); // 获取枚举值
|
||||
if (req != null) {
|
||||
requestBody.put("req", req);
|
||||
}
|
||||
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 创建HTTP请求实体
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||
|
||||
// 发送POST请求
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
|
||||
// 解析响应结果
|
||||
String responseBody = response.getBody();
|
||||
if (responseBody.isEmpty()) {
|
||||
throw exception(ERP_NOT_EXISTS);
|
||||
}
|
||||
|
||||
HashMap<String, Object> resMap = new HashMap<>();
|
||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||
if (jsonResponse == null) {
|
||||
throw exception(ERP_NOT_JSON_EXISTS);
|
||||
}
|
||||
// 正确获取E_DATA数组
|
||||
JSONObject dataObject = jsonResponse.getJSONObject("data");
|
||||
//判断 result里的succeed是否为true
|
||||
boolean succeed = jsonResponse.getBoolean("succeed");
|
||||
if (succeed && "S".equals(dataObject.getString("E_FLAG"))) {
|
||||
String flag = "S";
|
||||
JSONArray E_RESP = dataObject.getJSONArray("E_DATA");
|
||||
String E_MSG = dataObject.getString("E_MSG");
|
||||
resMap.put("E_RESP", E_RESP);
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
return resMap;
|
||||
} else {
|
||||
String E_MSG = dataObject.getString("E_MSG");
|
||||
String flag = "E";
|
||||
resMap.put("E_RESP", null);
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
return resMap;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw exception(ERP_ERROR_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用ERP接口更新erp数据
|
||||
*/
|
||||
public HashMap<String, String> pushDataToErp(ErpSubmitReqDTO reqDTO) {
|
||||
try {
|
||||
// 构建完整URL
|
||||
String url = "http://" + erpAddress + "/api/rfc/post";
|
||||
// 构建请求参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("uuid", UUID.randomUUID().toString());
|
||||
requestBody.put("sapsys", sapsys);
|
||||
requestBody.put("srcsys", "DSC");
|
||||
requestBody.put("funcnr", reqDTO.getFuncnr());
|
||||
requestBody.put("bskey", reqDTO.getBskey());
|
||||
requestBody.put("usrid", reqDTO.getUsrid());
|
||||
requestBody.put("usrnm", reqDTO.getUsrnm());
|
||||
if (reqDTO.getSign() != null) {
|
||||
requestBody.put("sign", reqDTO.getSign());
|
||||
}
|
||||
if (reqDTO.getReq() != null) {
|
||||
requestBody.put("req", reqDTO.getReq());
|
||||
}
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 创建HTTP请求实体
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestBody.toJSONString(), headers);
|
||||
|
||||
// 发送POST请求
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> response = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
|
||||
// 解析响应结果
|
||||
String responseBody = response.getBody();
|
||||
if (responseBody.isEmpty()) {
|
||||
throw exception(ERP_NOT_EXISTS);
|
||||
}
|
||||
|
||||
JSONObject jsonResponse = JSON.parseObject(responseBody);
|
||||
if (jsonResponse == null) {
|
||||
throw exception(ERP_NOT_JSON_EXISTS);
|
||||
}
|
||||
|
||||
HashMap<String, String> resMap = new HashMap<>();
|
||||
boolean succeed = jsonResponse.getBoolean("succeed");
|
||||
JSONObject data = jsonResponse.getJSONObject("data");
|
||||
if (data == null) {
|
||||
log.error("SAP接口返回值为空," + jsonResponse.getString("msg"));
|
||||
throw exception(ERP_NOT_EXISTS);
|
||||
} else if (succeed && "S".equals(data.getString("E_FLAG"))) {
|
||||
String flag = "S";
|
||||
String E_RESP = data.getString("E_RESP");
|
||||
String E_MSG = data.getString("ET_MSG");
|
||||
resMap.put("E_RESP", E_RESP);
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
} else if (!succeed && "E".equals(data.getString("E_FLAG"))) {
|
||||
String flag = "E";
|
||||
String E_MSG = data.getString("ET_MSG");
|
||||
if (StrUtil.isBlank(E_MSG)) {
|
||||
E_MSG = jsonResponse.getString("msg");
|
||||
}
|
||||
resMap.put("resStr", E_MSG);
|
||||
resMap.put("flag", flag);
|
||||
}
|
||||
return resMap;
|
||||
} catch (Exception e) {
|
||||
log.error("调用ERP RFC接口失败: {}", e);
|
||||
throw exception(ERP_ERROR_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.zt.plat.module.erp.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dm.jdbc.util.DriverUtil.log;
|
||||
|
||||
|
||||
/**
|
||||
* @author wuxz
|
||||
* @create 2022-06-07 20:54
|
||||
*/
|
||||
@Primary
|
||||
@Configuration
|
||||
public class MyRedisConfig {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Bean(value = "MyRedisTemplate")
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
// 通过 Jackson 组件进行序列化
|
||||
RedisSerializer<Object> serializer = redisSerializer();
|
||||
|
||||
// key 和 value
|
||||
// 一般来说, redis-key采用字符串序列化;
|
||||
// redis-value采用json序列化, json的体积小,可读性高,不需要实现serializer接口。
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(serializer);
|
||||
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(serializer);
|
||||
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public RedisSerializer<Object> redisSerializer() {
|
||||
//创建JSON序列化器
|
||||
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// objectMapper.enableDefaultTyping()被弃用
|
||||
objectMapper.activateDefaultTyping(
|
||||
LaissezFaireSubTypeValidator.instance,
|
||||
ObjectMapper.DefaultTyping.NON_FINAL,
|
||||
JsonTypeInfo.As.WRAPPER_ARRAY);
|
||||
serializer.setObjectMapper(objectMapper);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//list
|
||||
public Map<String, List<String>> numbers(JSONArray dataArray, String key, String dataKey) {
|
||||
// 使用 Redis 获取缓存数据
|
||||
Map<String, List<String>> numbers = new HashMap<>();
|
||||
List<String> cachedNumbers = (List<String>) redisTemplate.opsForValue().get(key);
|
||||
if (cachedNumbers == null) {
|
||||
cachedNumbers = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 提取有效的 BUKRS 编号
|
||||
List<String> existingNumbers;
|
||||
if (dataArray != null) {
|
||||
// 将dataKey按"-"分割成多个部分
|
||||
String[] keyParts = dataKey.split("-");
|
||||
existingNumbers = dataArray.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(dataJson -> {
|
||||
JSONObject jsonObject = (JSONObject) dataJson;
|
||||
// 根据每个部分逐级获取值并拼接
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String part : keyParts) {
|
||||
String value = jsonObject.getString(part);
|
||||
if (value != null) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append("-");
|
||||
}
|
||||
sb.append(value.trim());
|
||||
} else {
|
||||
// 如果某一部分为空,则整个值视为无效
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
})
|
||||
.filter(Objects::nonNull) // 过滤掉无效值
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
existingNumbers = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 找出共同存在的编号
|
||||
Set<String> cachedNumberSet = new HashSet<>(cachedNumbers != null ? cachedNumbers : new ArrayList<>());
|
||||
List<String> commonNumbers = existingNumbers.stream()
|
||||
.filter(cachedNumberSet::contains)
|
||||
.collect(Collectors.toList());
|
||||
numbers.put("com", commonNumbers);
|
||||
|
||||
//找出需要删除的字段。只有erp查询全部的接口能用到
|
||||
List<String> deleteNumbers = cachedNumberSet.stream()
|
||||
.filter(num -> !existingNumbers.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
numbers.put("delete", deleteNumbers);
|
||||
|
||||
// 找出需要新增的编号
|
||||
List<String> newNumbers = existingNumbers.stream()
|
||||
.filter(num -> !cachedNumberSet.contains(num))
|
||||
.toList();
|
||||
|
||||
// 合并所有编号
|
||||
List<String> allNumbers = new ArrayList<>(cachedNumbers);
|
||||
allNumbers.addAll(newNumbers);
|
||||
numbers.put("all", allNumbers);
|
||||
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public void updateRedisCache(String key, List<String> allnumbers) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
redisTemplate.opsForValue().set(key, allnumbers);
|
||||
}
|
||||
|
||||
public List<String> getRedisCache(String key) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
return (List<String>) redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
//map
|
||||
public Map<String, Long> getRedisCacheMap(String key) {
|
||||
// 使用 Redis 获取缓存数据
|
||||
Map<String, Long> result = (Map<String, Long>) redisTemplate.opsForHash().entries(key);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addRedisCacheMap(String key, Map<String, Long> allnumbers) {
|
||||
// 使用 Redis 更新缓存数据
|
||||
redisTemplate.opsForHash().putAll(key, allnumbers);
|
||||
}
|
||||
|
||||
public void deleteRedisCacheMap(String key, List<String> deleteNumbers) {
|
||||
if (deleteNumbers == null || deleteNumbers.isEmpty()) {
|
||||
log.debug("No items to delete from Redis hash: {}", key);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Object[] keysToDelete = deleteNumbers.toArray(new String[0]);
|
||||
Long deletedCount = redisTemplate.opsForHash().delete(key, keysToDelete);
|
||||
log.debug("Deleted" + deletedCount + "items from Redis hash:" + key);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to delete items from Redis hash:" + key, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user